summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.gitignore4
-rw-r--r--scripts/exp/stl_bb_start_stop-0-ex.erf0
-rw-r--r--scripts/exp/stl_bb_start_stop2-0-ex.erfbin0 -> 968 bytes
-rw-r--r--scripts/exp/stl_bb_start_stop3-0-ex.erf0
-rw-r--r--src/gtest/trex_stateless_gtest.cpp231
-rw-r--r--src/stateless/dp/trex_stateless_dp_core.cpp11
-rw-r--r--src/stateless/dp/trex_stateless_dp_core.h2
-rw-r--r--src/stateless/messaging/trex_stateless_messaging.cpp3
8 files changed, 242 insertions, 9 deletions
diff --git a/.gitignore b/.gitignore
index fcc5135f..39bea09a 100644
--- a/.gitignore
+++ b/.gitignore
@@ -25,6 +25,10 @@ scripts/exp/stl_simple_prog1-0.erf
scripts/exp/stl_simple_prog2-0.erf
scripts/exp/stl_simple_prog3-0.erf
scripts/exp/stl_simple_prog4-0.erf
+scripts/exp/stl_bb_start_stop-0.erf
+scripts/exp/stl_bb_start_stop2-0.erf
+scripts/exp/stl_bb_start_stop3-0.erf
+
diff --git a/scripts/exp/stl_bb_start_stop-0-ex.erf b/scripts/exp/stl_bb_start_stop-0-ex.erf
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/scripts/exp/stl_bb_start_stop-0-ex.erf
diff --git a/scripts/exp/stl_bb_start_stop2-0-ex.erf b/scripts/exp/stl_bb_start_stop2-0-ex.erf
new file mode 100644
index 00000000..0eff9601
--- /dev/null
+++ b/scripts/exp/stl_bb_start_stop2-0-ex.erf
Binary files differ
diff --git a/scripts/exp/stl_bb_start_stop3-0-ex.erf b/scripts/exp/stl_bb_start_stop3-0-ex.erf
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/scripts/exp/stl_bb_start_stop3-0-ex.erf
diff --git a/src/gtest/trex_stateless_gtest.cpp b/src/gtest/trex_stateless_gtest.cpp
index bdaebcea..83721f0d 100644
--- a/src/gtest/trex_stateless_gtest.cpp
+++ b/src/gtest/trex_stateless_gtest.cpp
@@ -47,6 +47,54 @@ public:
/**
+ * Queue of RPC msgs for test
+ *
+ * @author hhaim
+ */
+
+class CBasicStl;
+
+
+struct CBasicStlDelayCommand {
+
+ CBasicStlDelayCommand(){
+ m_node=NULL;
+ }
+ CGenNodeCommand * m_node;
+};
+
+
+
+class CBasicStlMsgQueue {
+
+friend CBasicStl;
+
+public:
+ CBasicStlMsgQueue(){
+ }
+
+ /* user will allocate the message, no need to free it by this module */
+ void add_msg(TrexStatelessCpToDpMsgBase * msg){
+ m_msgs.push_back(msg);
+ }
+ void add_command(CBasicStlDelayCommand & command){
+ m_commands.push_back(command);
+ }
+
+ void clear(){
+ m_msgs.clear();
+ m_commands.clear();
+ }
+
+
+protected:
+ std::vector<TrexStatelessCpToDpMsgBase *> m_msgs;
+
+ std::vector<CBasicStlDelayCommand> m_commands;
+};
+
+
+/**
* handler for DP to CP messages
*
* @author imarom (19-Nov-15)
@@ -66,6 +114,7 @@ public:
m_threads=1;
m_dump_json=false;
m_dp_to_cp_handler = NULL;
+ m_msg = NULL;
}
@@ -120,9 +169,22 @@ public:
lpt->start_stateless_simulation_file(buf,CGlobalInfo::m_options.preview);
/* add stream to the queue */
- assert(m_msg);
+ if ( m_msg ) {
+ assert(m_ring_from_cp->Enqueue((CGenNode *)m_msg)==0);
+ }
+ if (m_msg_queue.m_msgs.size()>0) {
+ for (auto msg : m_msg_queue.m_msgs) {
+ assert(m_ring_from_cp->Enqueue((CGenNode *)msg)==0);
+ }
+ }
- assert(m_ring_from_cp->Enqueue((CGenNode *)m_msg)==0);
+ /* add the commands */
+ if (m_msg_queue.m_commands.size()>0) {
+ for (auto cmd : m_msg_queue.m_commands) {
+ /* add commands nodes */
+ lpt->m_node_gen.add_node((CGenNode *)cmd.m_node);
+ }
+ }
lpt->start_stateless_daemon_simulation();
@@ -142,6 +204,8 @@ public:
}
flush_dp_to_cp_messages();
+ m_msg_queue.clear();
+
fl.Delete();
return (res);
@@ -155,6 +219,7 @@ public:
TrexStatelessCpToDpMsgBase * m_msg;
CNodeRing *m_ring_from_cp;
+ CBasicStlMsgQueue m_msg_queue;
CFlowGenList fl;
};
@@ -264,6 +329,168 @@ TEST_F(basic_stl, load_pcap_file) {
+/* start/stop/stop back to back */
+TEST_F(basic_stl, single_pkt_bb_start_stop3) {
+
+ CBasicStl t1;
+ CParserOption * po =&CGlobalInfo::m_options;
+ po->preview.setVMode(7);
+ po->preview.setFileWrite(true);
+ po->out_file ="exp/stl_bb_start_stop3";
+
+ TrexStreamsCompiler compile;
+
+ uint8_t port_id=0;
+
+ std::vector<TrexStream *> streams;
+
+ TrexStream * stream1 = new TrexStream(TrexStream::stCONTINUOUS,0,0);
+ stream1->set_pps(1.0);
+
+
+ stream1->m_enabled = true;
+ stream1->m_self_start = true;
+ stream1->m_port_id= port_id;
+
+
+ CPcapLoader pcap;
+ pcap.load_pcap_file("cap2/udp_64B.pcap",0);
+ pcap.update_ip_src(0x10000001);
+ pcap.clone_packet_into_stream(stream1);
+
+ streams.push_back(stream1);
+
+ // stream - clean
+
+ TrexStreamsCompiledObj comp_obj(port_id, 1.0 /*mul*/);
+
+ assert(compile.compile(streams, comp_obj) );
+
+ TrexStatelessDpStart * lpStartCmd = new TrexStatelessDpStart(port_id, 0, comp_obj.clone(), 10.0 /*sec */ );
+ TrexStatelessDpStop * lpStopCmd = new TrexStatelessDpStop(port_id);
+ TrexStatelessDpStop * lpStopCmd1 = new TrexStatelessDpStop(port_id);
+
+
+ t1.m_msg_queue.add_msg(lpStartCmd);
+ t1.m_msg_queue.add_msg(lpStopCmd);
+ t1.m_msg_queue.add_msg(lpStopCmd1);
+
+ bool res=t1.init();
+
+ delete stream1 ;
+
+ EXPECT_EQ_UINT32(1, res?1:0)<< "pass";
+}
+
+
+TEST_F(basic_stl, single_pkt_bb_start_stop2) {
+
+ CBasicStl t1;
+ CParserOption * po =&CGlobalInfo::m_options;
+ po->preview.setVMode(7);
+ po->preview.setFileWrite(true);
+ po->out_file ="exp/stl_bb_start_stop2";
+
+ TrexStreamsCompiler compile;
+
+ uint8_t port_id=0;
+
+ std::vector<TrexStream *> streams;
+
+ TrexStream * stream1 = new TrexStream(TrexStream::stCONTINUOUS,0,0);
+ stream1->set_pps(1.0);
+
+
+ stream1->m_enabled = true;
+ stream1->m_self_start = true;
+ stream1->m_port_id= port_id;
+
+
+ CPcapLoader pcap;
+ pcap.load_pcap_file("cap2/udp_64B.pcap",0);
+ pcap.update_ip_src(0x10000001);
+ pcap.clone_packet_into_stream(stream1);
+
+ streams.push_back(stream1);
+
+ // stream - clean
+
+ TrexStreamsCompiledObj comp_obj(port_id, 1.0 /*mul*/);
+
+ assert(compile.compile(streams, comp_obj) );
+
+ TrexStatelessDpStart * lpStartCmd = new TrexStatelessDpStart(port_id, 0, comp_obj.clone(), 10.0 /*sec */ );
+ TrexStatelessDpStop * lpStopCmd = new TrexStatelessDpStop(port_id);
+ TrexStatelessDpStart * lpStartCmd1 = new TrexStatelessDpStart(port_id, 0, comp_obj.clone(), 10.0 /*sec */ );
+
+
+ t1.m_msg_queue.add_msg(lpStartCmd);
+ t1.m_msg_queue.add_msg(lpStopCmd);
+ t1.m_msg_queue.add_msg(lpStartCmd1);
+
+ bool res=t1.init();
+
+ delete stream1 ;
+
+ EXPECT_EQ_UINT32(1, res?1:0)<< "pass";
+}
+
+
+
+/* back to back send start/stop */
+TEST_F(basic_stl, single_pkt_bb_start_stop) {
+
+ CBasicStl t1;
+ CParserOption * po =&CGlobalInfo::m_options;
+ po->preview.setVMode(7);
+ po->preview.setFileWrite(true);
+ po->out_file ="exp/stl_bb_start_stop";
+
+ TrexStreamsCompiler compile;
+
+ uint8_t port_id=0;
+
+ std::vector<TrexStream *> streams;
+
+ TrexStream * stream1 = new TrexStream(TrexStream::stCONTINUOUS,0,0);
+ stream1->set_pps(1.0);
+
+
+ stream1->m_enabled = true;
+ stream1->m_self_start = true;
+ stream1->m_port_id= port_id;
+
+
+ CPcapLoader pcap;
+ pcap.load_pcap_file("cap2/udp_64B.pcap",0);
+ pcap.update_ip_src(0x10000001);
+ pcap.clone_packet_into_stream(stream1);
+
+ streams.push_back(stream1);
+
+ // stream - clean
+
+ TrexStreamsCompiledObj comp_obj(port_id, 1.0 /*mul*/);
+
+ assert(compile.compile(streams, comp_obj) );
+
+ TrexStatelessDpStart * lpStartCmd = new TrexStatelessDpStart(port_id, 0, comp_obj.clone(), 10.0 /*sec */ );
+ TrexStatelessDpStop * lpStopCmd = new TrexStatelessDpStop(port_id);
+
+
+ t1.m_msg_queue.add_msg(lpStartCmd);
+ t1.m_msg_queue.add_msg(lpStopCmd);
+
+ bool res=t1.init();
+
+ delete stream1 ;
+
+ EXPECT_EQ_UINT32(1, res?1:0)<< "pass";
+}
+
+
+
+
TEST_F(basic_stl, simple_prog4) {
CBasicStl t1;
diff --git a/src/stateless/dp/trex_stateless_dp_core.cpp b/src/stateless/dp/trex_stateless_dp_core.cpp
index e17c9075..6430e520 100644
--- a/src/stateless/dp/trex_stateless_dp_core.cpp
+++ b/src/stateless/dp/trex_stateless_dp_core.cpp
@@ -124,12 +124,12 @@ bool TrexStatelessDpPerPort::update_number_of_active_streams(uint32_t d){
}
-void TrexStatelessDpPerPort::stop_traffic(uint8_t port_id){
+bool TrexStatelessDpPerPort::stop_traffic(uint8_t port_id){
/* there could be race of stop after stop */
if (m_state == TrexStatelessDpPerPort::ppSTATE_IDLE) {
assert(m_active_streams==0);
- return;
+ return false;
}
for (auto dp_stream : m_active_nodes) {
@@ -149,6 +149,7 @@ void TrexStatelessDpPerPort::stop_traffic(uint8_t port_id){
assert(m_active_streams==0);
m_active_nodes.clear();
m_state=TrexStatelessDpPerPort::ppSTATE_IDLE;
+ return (true);
}
@@ -517,7 +518,11 @@ TrexStatelessDpCore::stop_traffic(uint8_t port_id) {
TrexStatelessDpPerPort * lp_port = get_port_db(port_id);
- lp_port->stop_traffic(port_id);
+ if ( lp_port->stop_traffic(port_id) == false){
+ /* nothing to do ! already stopped */
+ return;
+ }
+
if ( are_all_ports_idle() ) {
diff --git a/src/stateless/dp/trex_stateless_dp_core.h b/src/stateless/dp/trex_stateless_dp_core.h
index c0bbe702..326bbe30 100644
--- a/src/stateless/dp/trex_stateless_dp_core.h
+++ b/src/stateless/dp/trex_stateless_dp_core.h
@@ -62,7 +62,7 @@ public:
void create(CFlowGenListPerThread * core);
- void stop_traffic(uint8_t port_id);
+ bool stop_traffic(uint8_t port_id);
bool update_number_of_active_streams(uint32_t d);
diff --git a/src/stateless/messaging/trex_stateless_messaging.cpp b/src/stateless/messaging/trex_stateless_messaging.cpp
index 629fe24c..c861d0fa 100644
--- a/src/stateless/messaging/trex_stateless_messaging.cpp
+++ b/src/stateless/messaging/trex_stateless_messaging.cpp
@@ -74,9 +74,6 @@ TrexStatelessDpStart::handle(TrexStatelessDpCore *dp_core) {
************************/
bool
TrexStatelessDpStop::handle(TrexStatelessDpCore *dp_core) {
- if (dp_core->get_port_db(m_port_id)->get_state() == TrexStatelessDpPerPort::ppSTATE_IDLE) {
- return true;
- }
dp_core->stop_traffic(m_port_id);
return true;