diff options
author | 2015-11-13 14:28:54 +0200 | |
---|---|---|
committer | 2015-11-13 14:28:54 +0200 | |
commit | 1f98e85aba1fb41110ea9743a69c075eeb60f476 (patch) | |
tree | e5c4216361e75df62d4790ec50776451c979b5ea /src/stateless/dp/trex_stateless_dp_core.cpp | |
parent | 57e67fd2ae248039951798978cc8c1c219c3d752 (diff) | |
parent | 45b71cff9d0465b77f82e4cd40b64a9f3183c1c7 (diff) |
Merge branch 'rpc_intg1' of csi-sceasr-b45:/auto/proj-pcube-b/apps/PL-b/tools/repo//trex-core into rpc_intg1
Diffstat (limited to 'src/stateless/dp/trex_stateless_dp_core.cpp')
-rw-r--r-- | src/stateless/dp/trex_stateless_dp_core.cpp | 98 |
1 files changed, 80 insertions, 18 deletions
diff --git a/src/stateless/dp/trex_stateless_dp_core.cpp b/src/stateless/dp/trex_stateless_dp_core.cpp index b2bd0152..96c18dbd 100644 --- a/src/stateless/dp/trex_stateless_dp_core.cpp +++ b/src/stateless/dp/trex_stateless_dp_core.cpp @@ -22,6 +22,7 @@ limitations under the License. #include <trex_stateless_messaging.h> #include <trex_streams_compiler.h> #include <trex_stream_node.h> +#include <trex_stream.h> #include <bp_sim.h> @@ -31,6 +32,18 @@ usec_to_sec(double usec) { } + +void CGenNodeStateless::free_stl_node(){ + /* if we have cache mbuf free it */ + rte_mbuf_t * m=get_cache_mbuf(); + if (m) { + rte_pktmbuf_free(m); + m_cache_mbuf=0; + } +} + + + void TrexStatelessDpCore::create(uint8_t thread_id, CFlowGenListPerThread *core) { m_thread_id = thread_id; @@ -79,44 +92,91 @@ TrexStatelessDpCore::start_scheduler() { m_core->m_node_gen.close_file(m_core); } + +void +TrexStatelessDpCore::run_once(){ + + idle_state_loop(); + start_scheduler(); +} + + void TrexStatelessDpCore::start() { while (true) { - idle_state_loop(); + run_once(); + } +} + +void +TrexStatelessDpCore::add_duration(double duration){ + if (duration > 0.0) { + CGenNode *node = m_core->create_node() ; + + node->m_type = CGenNode::EXIT_SCHED; - start_scheduler(); + /* make sure it will be scheduled after the current node */ + node->m_time = m_core->m_cur_time_sec + duration ; + + m_core->m_node_gen.add_node(node); } } + void -TrexStatelessDpCore::add_cont_stream(uint8_t port_id, - double isg_usec, - double pps, - const uint8_t *pkt, - uint16_t pkt_len) { +TrexStatelessDpCore::add_cont_stream(TrexStream * stream, + TrexStreamsCompiledObj *comp) { CGenNodeStateless *node = m_core->create_node_sl(); /* add periodic */ node->m_type = CGenNode::STATELESS_PKT; - node->m_time = m_core->m_cur_time_sec + usec_to_sec(isg_usec); + node->m_time = m_core->m_cur_time_sec + usec_to_sec(stream->m_isg_usec); - pkt_dir_t dir = m_core->m_node_gen.m_v_if->port_id_to_dir(port_id); + pkt_dir_t dir = m_core->m_node_gen.m_v_if->port_id_to_dir(stream->m_port_id); node->m_flags = 0; /* set socket id */ node->set_socket_id(m_core->m_node_gen.m_socket_id); /* build a mbuf from a packet */ - uint16_t pkt_size = pkt_len; - const uint8_t *stream_pkt = pkt; + + uint16_t pkt_size = stream->m_pkt.len; + const uint8_t *stream_pkt = stream->m_pkt.binary; + + node->m_stream_type = stream->m_type; + node->m_next_time_offset = 1.0 / (stream->get_pps() * comp->get_multiplier()) ; + /* stateless specific fields */ - node->m_next_time_offset = 1.0 / pps; + switch ( stream->m_type ) { + + case TrexStream::stCONTINUOUS : + break; + + case TrexStream::stSINGLE_BURST : + node->m_stream_type = TrexStream::stMULTI_BURST; + node->m_single_burst = stream->m_burst_total_pkts; + node->m_single_burst_refill = stream->m_burst_total_pkts; + node->m_multi_bursts = 1; /* single burst in multi burst of 1 */ + node->m_ibg_sec = 0.0; + break; + + case TrexStream::stMULTI_BURST : + node->m_single_burst = stream->m_burst_total_pkts; + node->m_single_burst_refill = stream->m_burst_total_pkts; + node->m_multi_bursts = stream->m_num_bursts; + node->m_ibg_sec = usec_to_sec( stream->m_ibg_usec ); + break; + default: + + assert(0); + }; + node->m_is_stream_active = 1; - node->m_port_id = port_id; + node->m_port_id = stream->m_port_id; /* allocate const mbuf */ rte_mbuf_t *m = CGlobalInfo::pktmbuf_alloc(node->get_socket_id(), pkt_size); @@ -149,11 +209,13 @@ TrexStatelessDpCore::add_cont_stream(uint8_t port_id, void TrexStatelessDpCore::start_traffic(TrexStreamsCompiledObj *obj) { for (auto single_stream : obj->get_objects()) { - add_cont_stream(single_stream.m_port_id, - single_stream.m_isg_usec, - single_stream.m_pps, - single_stream.m_pkt, - single_stream.m_pkt_len); + add_cont_stream(single_stream.m_stream,obj); + } + + double duration=obj->get_simulation_duration(); + + if ( duration >0.0){ + add_duration( duration ); } } |