diff options
author | 2016-02-01 08:59:38 -0500 | |
---|---|---|
committer | 2016-02-01 09:03:03 -0500 | |
commit | 11bcf4ca8fed5259e321c535bf90d0442e9b9746 (patch) | |
tree | d0c632c77fdb15773b7151c394224d6e7253c743 /src/stateless | |
parent | bdc690e8229808974a8f899e145931c06db6e082 (diff) |
fix for http://trex-tgn.cisco.com/youtrack/issue/trex-174
Diffstat (limited to 'src/stateless')
-rw-r--r-- | src/stateless/cp/trex_stateless_port.cpp | 11 | ||||
-rw-r--r-- | src/stateless/cp/trex_stream.h | 13 | ||||
-rw-r--r-- | src/stateless/cp/trex_stream_vm.h | 2 | ||||
-rw-r--r-- | src/stateless/cp/trex_streams_compiler.cpp | 71 | ||||
-rw-r--r-- | src/stateless/cp/trex_streams_compiler.h | 17 | ||||
-rw-r--r-- | src/stateless/dp/trex_stateless_dp_core.h | 9 |
6 files changed, 116 insertions, 7 deletions
diff --git a/src/stateless/cp/trex_stateless_port.cpp b/src/stateless/cp/trex_stateless_port.cpp index 2286ef76..a281e428 100644 --- a/src/stateless/cp/trex_stateless_port.cpp +++ b/src/stateless/cp/trex_stateless_port.cpp @@ -184,8 +184,15 @@ TrexStatelessPort::start_traffic(const TrexPortMultiplier &mul, double duration, int index = 0; for (auto core_id : m_cores_id_list) { - TrexStatelessCpToDpMsgBase *start_msg = new TrexStatelessDpStart(m_port_id, event_id, compiled_objs[index], duration); - send_message_to_dp(core_id, start_msg); + /* was the core assigned a compiled object ? */ + if (compiled_objs[index]) { + TrexStatelessCpToDpMsgBase *start_msg = new TrexStatelessDpStart(m_port_id, event_id, compiled_objs[index], duration); + send_message_to_dp(core_id, start_msg); + } else { + + /* mimic an end event */ + m_dp_events.handle_event(TrexDpPortEvent::EVENT_STOP, core_id, event_id); + } index++; } diff --git a/src/stateless/cp/trex_stream.h b/src/stateless/cp/trex_stream.h index e854cdf7..525bf594 100644 --- a/src/stateless/cp/trex_stream.h +++ b/src/stateless/cp/trex_stream.h @@ -165,6 +165,19 @@ public: } + /* can this stream be split ? */ + bool is_splitable(uint8_t dp_core_count) const { + + /* cont stream is always splitable */ + if (m_type == stCONTINUOUS) { + return true; + } + + int per_core_burst_total_pkts = (m_burst_total_pkts / dp_core_count); + + return (per_core_burst_total_pkts > 0); + + } void set_multi_burst(uint32_t burst_total_pkts, uint32_t num_bursts, diff --git a/src/stateless/cp/trex_stream_vm.h b/src/stateless/cp/trex_stream_vm.h index ca7f71c1..dabc502c 100644 --- a/src/stateless/cp/trex_stream_vm.h +++ b/src/stateless/cp/trex_stream_vm.h @@ -1196,7 +1196,7 @@ public: void copy_instructions(StreamVm &other) const; - bool is_vm_empty() { + bool is_vm_empty() const { return (m_inst_list.size() == 0); } diff --git a/src/stateless/cp/trex_streams_compiler.cpp b/src/stateless/cp/trex_streams_compiler.cpp index d9f979e8..9d048dbd 100644 --- a/src/stateless/cp/trex_streams_compiler.cpp +++ b/src/stateless/cp/trex_streams_compiler.cpp @@ -391,6 +391,7 @@ TrexStreamsCompiler::compile(uint8_t port_id, } } + bool TrexStreamsCompiler::compile_internal(uint8_t port_id, const std::vector<TrexStream *> &streams, @@ -440,6 +441,14 @@ TrexStreamsCompiler::compile_internal(uint8_t por compile_stream(stream, factor, dp_core_count, objs, nodes); } + /* some objects might be empty - no streams were assigned */ + for (uint8_t i = 0; i < dp_core_count; i++) { + if (objs[i]->is_empty()) { + delete objs[i]; + objs[i] = NULL; + } + } + return true; } @@ -466,13 +475,43 @@ TrexStreamsCompiler::compile_stream(const TrexStream *stream, new_next_id = nodes.get(stream->m_next_stream_id)->m_compressed_stream_id; } + + /* can this stream be split to many cores ? */ + if (!stream->is_splitable(dp_core_count)) { + compile_stream_on_single_core(stream, + factor, + objs[0], + new_id, + new_next_id); + } else { + compile_stream_on_all_cores(stream, + factor, + dp_core_count, + objs, + new_id, + new_next_id); + } + + +} + +/** + * compile the stream on all the cores available + * + */ +void +TrexStreamsCompiler::compile_stream_on_all_cores(const TrexStream *stream, + double factor, + uint8_t dp_core_count, + std::vector<TrexStreamsCompiledObj *> &objs, + int new_id, + int new_next_id) { + std::vector<TrexStream *> core_streams(dp_core_count); - /* calculate rate */ double per_core_rate = (stream->m_pps * (factor / dp_core_count)); int per_core_burst_total_pkts = (stream->m_burst_total_pkts / dp_core_count); - /* for each core - creates its own version of the stream */ for (uint8_t i = 0; i < dp_core_count; i++) { TrexStream *dp_stream = stream->clone(); @@ -488,7 +527,7 @@ TrexStreamsCompiler::compile_stream(const TrexStream *stream, core_streams[i] = dp_stream; } - /* take care of remainder from a burst */ + /* take care of remainder from a burst on core 0 */ int burst_remainder = stream->m_burst_total_pkts - (per_core_burst_total_pkts * dp_core_count); core_streams[0]->m_burst_total_pkts += burst_remainder; @@ -501,9 +540,33 @@ TrexStreamsCompiler::compile_stream(const TrexStream *stream, objs[i]->add_compiled_stream(core_streams[i]); } - } +/** + * compile the stream on core 0 + * + */ +void +TrexStreamsCompiler::compile_stream_on_single_core(const TrexStream *stream, + double factor, + TrexStreamsCompiledObj *obj, + int new_id, + int new_next_id) { + + TrexStream *dp_stream = stream->clone(); + + /* fix stream ID */ + dp_stream->fix_dp_stream_id(new_id, new_next_id); + + /* compile the VM if exists */ + if (!stream->m_vm.is_vm_empty()) { + ((TrexStream *)stream)->vm_compile(); + dp_stream->m_vm_dp = stream->m_vm_dp->clone(); + } + + /* update the core */ + obj->add_compiled_stream(dp_stream); +} /************************************** * streams graph diff --git a/src/stateless/cp/trex_streams_compiler.h b/src/stateless/cp/trex_streams_compiler.h index aaef78be..a3a1f8f7 100644 --- a/src/stateless/cp/trex_streams_compiler.h +++ b/src/stateless/cp/trex_streams_compiler.h @@ -65,6 +65,10 @@ public: TrexStreamsCompiledObj* clone(); + bool is_empty() { + return (m_objs.size() == 0); + } + private: void add_compiled_stream(TrexStream *stream); @@ -125,6 +129,19 @@ private: std::vector<TrexStreamsCompiledObj *> &objs, GraphNodeMap &nodes); + void compile_stream_on_single_core(const TrexStream *stream, + double factor, + TrexStreamsCompiledObj *obj, + int new_id, + int new_next_id); + + void compile_stream_on_all_cores(const TrexStream *stream, + double factor, + uint8_t dp_core_count, + std::vector<TrexStreamsCompiledObj *> &objs, + int new_id, + int new_next_id); + std::vector<std::string> m_warnings; }; diff --git a/src/stateless/dp/trex_stateless_dp_core.h b/src/stateless/dp/trex_stateless_dp_core.h index efdb364c..c8a5eff5 100644 --- a/src/stateless/dp/trex_stateless_dp_core.h +++ b/src/stateless/dp/trex_stateless_dp_core.h @@ -181,6 +181,15 @@ public: /** + * return true if core has any pending messages from CP + * + */ + bool are_any_pending_cp_messages() { + return (!m_ring_from_cp->isEmpty()); + } + + + /** * check for and handle messages from CP * * @author imarom (27-Oct-15) |