From 0e8c9ae666d61897cb405c469a71be09d54a649b Mon Sep 17 00:00:00 2001 From: Hanoh Haim Date: Wed, 18 Nov 2015 16:23:55 +0200 Subject: add support for a program of streams. refactor the dp code --- src/stateless/dp/trex_stateless_dp_core.h | 92 ++++++++++++++++++++++++++++--- 1 file changed, 84 insertions(+), 8 deletions(-) (limited to 'src/stateless/dp/trex_stateless_dp_core.h') diff --git a/src/stateless/dp/trex_stateless_dp_core.h b/src/stateless/dp/trex_stateless_dp_core.h index aaa6eed3..28fff2fb 100644 --- a/src/stateless/dp/trex_stateless_dp_core.h +++ b/src/stateless/dp/trex_stateless_dp_core.h @@ -1,5 +1,6 @@ /* Itay Marom + Hanoch Haim Cisco Systems, Inc. */ @@ -33,6 +34,52 @@ class CGenNodeStateless; class TrexStreamsCompiledObj; class TrexStream; + +class CDpOneStream { +public: + void Create(){ + } + + void Delete(CFlowGenListPerThread * core); + void DeleteOnlyStream(); + + CGenNodeStateless * m_node; // schedule node + TrexStream * m_dp_stream; // stream info +}; + +class TrexStatelessDpPerPort { + +public: + /* states */ + enum state_e { + ppSTATE_IDLE, + ppSTATE_TRANSMITTING + }; + +public: + TrexStatelessDpPerPort(){ + } + + void create(CFlowGenListPerThread * core); + + void stop_traffic(uint8_t port_id); + + bool update_number_of_active_streams(uint32_t d); + +public: + + state_e m_state; + uint8_t m_port_id; + + uint32_t m_active_streams; /* how many active streams on this port */ + + std::vector m_active_nodes; /* holds the current active nodes */ + CFlowGenListPerThread * m_core ; +}; + +/* for now */ +#define NUM_PORTS_PER_CORE 2 + class TrexStatelessDpCore { public: @@ -40,7 +87,9 @@ public: /* states */ enum state_e { STATE_IDLE, - STATE_TRANSMITTING + STATE_TRANSMITTING, + STATE_TERMINATE, + }; TrexStatelessDpCore() { @@ -83,6 +132,11 @@ public: */ void stop_traffic(uint8_t port_id); + + /* return if all ports are idel */ + bool are_all_ports_idle(); + + /** * check for and handle messages from CP * @@ -112,7 +166,23 @@ public: /* quit the main loop, work in both stateless in stateful, don't free memory trigger from master */ void quit_main_loop(); + bool set_stateless_next_node(CGenNodeStateless * cur_node, + CGenNodeStateless * next_node); + private: + + + TrexStatelessDpPerPort * get_port_db(uint8_t port_id){ + assert((m_local_port_offset==port_id) ||(m_local_port_offset+1==port_id)); + uint8_t local_port_id = port_id -m_local_port_offset; + assert(local_port_id m_active_nodes; + TrexStatelessDpPerPort m_ports[NUM_PORTS_PER_CORE]; /* pointer to the main object */ - CFlowGenListPerThread *m_core; + CFlowGenListPerThread * m_core; double m_duration; }; -- cgit 1.2.3-korg From 91a4e6cc117076d3f5d34437581f7ffe91e6892b Mon Sep 17 00:00:00 2001 From: Hanoh Haim Date: Thu, 19 Nov 2015 10:44:39 +0200 Subject: another stream program tests --- .gitignore | 1 + scripts/exp/stl_simple_prog3-0-ex.erf | Bin 0 -> 4312 bytes src/gtest/trex_stateless_gtest.cpp | 69 ++++++++++++++++++++++++++++++ src/stateless/dp/trex_stateless_dp_core.h | 2 +- 4 files changed, 71 insertions(+), 1 deletion(-) create mode 100644 scripts/exp/stl_simple_prog3-0-ex.erf (limited to 'src/stateless/dp/trex_stateless_dp_core.h') diff --git a/.gitignore b/.gitignore index 34c7060d..183484fb 100644 --- a/.gitignore +++ b/.gitignore @@ -23,6 +23,7 @@ scripts/exp/stl_single_sctp_pkt-0.erf scripts/exp/stl_single_stream-0.erf scripts/exp/stl_simple_prog1-0.erf scripts/exp/stl_simple_prog2-0.erf +scripts/exp/stl_simple_prog3-0.erf diff --git a/scripts/exp/stl_simple_prog3-0-ex.erf b/scripts/exp/stl_simple_prog3-0-ex.erf new file mode 100644 index 00000000..4da3438c Binary files /dev/null and b/scripts/exp/stl_simple_prog3-0-ex.erf differ diff --git a/src/gtest/trex_stateless_gtest.cpp b/src/gtest/trex_stateless_gtest.cpp index 2e720255..93e8387f 100644 --- a/src/gtest/trex_stateless_gtest.cpp +++ b/src/gtest/trex_stateless_gtest.cpp @@ -224,6 +224,75 @@ TEST_F(basic_stl, load_pcap_file) { } + +TEST_F(basic_stl, simple_prog3) { + + CBasicStl t1; + CParserOption * po =&CGlobalInfo::m_options; + po->preview.setVMode(7); + po->preview.setFileWrite(true); + po->out_file ="exp/stl_simple_prog3"; + + TrexStreamsCompiler compile; + + + std::vector streams; + + /* stream1 */ + TrexStream * stream1 = new TrexStream(TrexStream::stSINGLE_BURST, 0,100); + stream1->set_pps(1.0); + stream1->set_single_burst(5); + stream1->m_enabled = true; + stream1->m_self_start = true; + stream1->m_next_stream_id=200; + + 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); + + + /* stream1 */ + + TrexStream * stream2 = new TrexStream(TrexStream::stMULTI_BURST, 0,200); + stream2->set_pps(1.0); + stream2->m_isg_usec = 1000000; /*time betwean stream 1 to stream 2 */ + stream2->m_enabled = true; + stream2->m_self_start = false; + stream2->set_multi_burst(5, + 3, + 2000000.0); + + // next stream is 100 - loop + stream2->m_next_stream_id=100; + + + pcap.load_pcap_file("cap2/udp_64B.pcap",0); + pcap.update_ip_src(0x10000002); + pcap.clone_packet_into_stream(stream2); + streams.push_back(stream2); + + + TrexStreamsCompiledObj comp_obj(0,1.0); + + EXPECT_TRUE(compile.compile(streams, comp_obj) ); + + TrexStatelessDpStart * lpstart = new TrexStatelessDpStart( comp_obj.clone(), 50.0 ); + + + t1.m_msg = lpstart; + + bool res=t1.init(); + + delete stream1 ; + delete stream2 ; + + EXPECT_EQ_UINT32(1, res?1:0)<< "pass"; +} + + TEST_F(basic_stl, simple_prog2) { CBasicStl t1; diff --git a/src/stateless/dp/trex_stateless_dp_core.h b/src/stateless/dp/trex_stateless_dp_core.h index 28fff2fb..85afcf8f 100644 --- a/src/stateless/dp/trex_stateless_dp_core.h +++ b/src/stateless/dp/trex_stateless_dp_core.h @@ -88,7 +88,7 @@ public: enum state_e { STATE_IDLE, STATE_TRANSMITTING, - STATE_TERMINATE, + STATE_TERMINATE }; -- cgit 1.2.3-korg