From 0bde21ac82ff025939f73bbd1e4783345917e49a Mon Sep 17 00:00:00 2001 From: imarom Date: Wed, 23 Dec 2015 03:46:58 -0500 Subject: support for client var split --- src/stateless/cp/trex_stream.h | 7 ++++ src/stateless/cp/trex_stream_vm.h | 8 +++++ src/stateless/cp/trex_streams_compiler.cpp | 1 - src/stateless/cp/trex_vm_splitter.cpp | 50 +++++++++++++++++++++++++++-- src/stateless/cp/trex_vm_splitter.h | 8 ++++- src/stateless/dp/trex_stateless_dp_core.cpp | 2 ++ 6 files changed, 72 insertions(+), 4 deletions(-) (limited to 'src/stateless') diff --git a/src/stateless/cp/trex_stream.h b/src/stateless/cp/trex_stream.h index 80368e4c..b4f19111 100644 --- a/src/stateless/cp/trex_stream.h +++ b/src/stateless/cp/trex_stream.h @@ -206,6 +206,13 @@ public: return(dp); } + /* release the DP object */ + void release_dp_object() { + if (m_vm_dp) { + delete m_vm_dp; + m_vm_dp = NULL; + } + } double get_burst_length_usec() const { return ( (m_burst_total_pkts / m_pps) * 1000 * 1000); diff --git a/src/stateless/cp/trex_stream_vm.h b/src/stateless/cp/trex_stream_vm.h index 136389c5..ce905655 100644 --- a/src/stateless/cp/trex_stream_vm.h +++ b/src/stateless/cp/trex_stream_vm.h @@ -766,6 +766,14 @@ public: return (4+2+4); } + uint32_t get_ip_range() const { + return (m_client_max - m_client_min + 1); + } + + uint16_t get_port_range() const { + return (m_port_max - m_port_min + 1); + } + bool is_unlimited_flows(){ return ( (m_flags & StreamVmInstructionFlowClient::CLIENT_F_UNLIMITED_FLOWS ) == StreamVmInstructionFlowClient::CLIENT_F_UNLIMITED_FLOWS ); diff --git a/src/stateless/cp/trex_streams_compiler.cpp b/src/stateless/cp/trex_streams_compiler.cpp index 24b14469..6bcddc1d 100644 --- a/src/stateless/cp/trex_streams_compiler.cpp +++ b/src/stateless/cp/trex_streams_compiler.cpp @@ -184,7 +184,6 @@ TrexStreamsCompiledObj::clone() { } return new_compiled_obj; - } void TrexStreamsCompiledObj::Dump(FILE *fd){ diff --git a/src/stateless/cp/trex_vm_splitter.cpp b/src/stateless/cp/trex_vm_splitter.cpp index 8aae8c76..56776f7e 100644 --- a/src/stateless/cp/trex_vm_splitter.cpp +++ b/src/stateless/cp/trex_vm_splitter.cpp @@ -22,6 +22,11 @@ limitations under the License. #include #include +/** + * split a specific stream's VM to multiple cores + * number of cores is implied by the size of the vector + * + */ void TrexVmSplitter::split(TrexStream *stream, std::vector core_streams) { @@ -57,6 +62,8 @@ bool TrexVmSplitter::split_internal() { const StreamVmInstruction *split_instr = m_stream->m_vm.get_split_instruction(); + + /* if no split instruction was specified - fall back*/ if (split_instr == NULL) { return false; } @@ -132,10 +139,48 @@ TrexVmSplitter::split_by_flow_var(const StreamVmInstructionFlowMan *instr) { bool TrexVmSplitter::split_by_flow_client_var(const StreamVmInstructionFlowClient *instr) { - return false; -} + /* if the range is too small - it is unsplitable */ + if (instr->get_ip_range() < m_dp_core_count) { + return false; + } + + /* we need to split - duplicate VM now */ + duplicate_vm(); + + /* calculate range splitting */ + uint64_t range = instr->get_ip_range(); + + uint64_t range_part = range / m_dp_core_count; + uint64_t leftover = range % m_dp_core_count; + + /* first core handles a bit more */ + uint64_t start = instr->m_client_min; + uint64_t end = start + range_part + leftover - 1; + + + /* do work */ + for (TrexStream *core_stream : *m_core_streams) { + + /* get the per-core instruction to split */ + StreamVmInstructionFlowClient *per_core_instr = (StreamVmInstructionFlowClient *)core_stream->m_vm.get_split_instruction(); + + per_core_instr->m_client_min = start; + per_core_instr->m_client_max = end; + core_stream->vm_compile(); + + start = end + 1; + end = start + range_part - 1; + } + + return true; +} + +/** + * duplicate the VM instructions + * to all the cores + */ void TrexVmSplitter::duplicate_vm() { /* for each core - duplicate the instructions */ @@ -143,3 +188,4 @@ TrexVmSplitter::duplicate_vm() { m_stream->m_vm.copy_instructions(core_stream->m_vm); } } + diff --git a/src/stateless/cp/trex_vm_splitter.h b/src/stateless/cp/trex_vm_splitter.h index 37c61599..dac71c21 100644 --- a/src/stateless/cp/trex_vm_splitter.h +++ b/src/stateless/cp/trex_vm_splitter.h @@ -23,7 +23,13 @@ limitations under the License. #include - +/** + * TRex VM splitter is used to split + * VM instructions around cores + * + * + * @author imarom (23-Dec-15) + */ class TrexVmSplitter { public: diff --git a/src/stateless/dp/trex_stateless_dp_core.cpp b/src/stateless/dp/trex_stateless_dp_core.cpp index e0378cfb..acbf1b88 100644 --- a/src/stateless/dp/trex_stateless_dp_core.cpp +++ b/src/stateless/dp/trex_stateless_dp_core.cpp @@ -472,6 +472,8 @@ TrexStatelessDpCore::add_stream(TrexStatelessDpPerPort * lp_port, /* clone the stream from control plane memory to DP memory */ node->m_ref_stream_info = stream->clone(); + /* no need for this memory anymore on the control plane memory */ + stream->release_dp_object(); node->m_next_stream=0; /* will be fixed later */ -- cgit 1.2.3-korg