summaryrefslogtreecommitdiffstats
path: root/src/stateless/cp
diff options
context:
space:
mode:
authorimarom <imarom@cisco.com>2015-12-23 03:46:58 -0500
committerimarom <imarom@cisco.com>2015-12-23 09:59:41 -0500
commit0bde21ac82ff025939f73bbd1e4783345917e49a (patch)
tree0679f97a0c5949f2282c428d0b63368784ab48fe /src/stateless/cp
parent61685c0768c0786859da8f6e7737cc909bd5ab26 (diff)
support for client var split
Diffstat (limited to 'src/stateless/cp')
-rw-r--r--src/stateless/cp/trex_stream.h7
-rw-r--r--src/stateless/cp/trex_stream_vm.h8
-rw-r--r--src/stateless/cp/trex_streams_compiler.cpp1
-rw-r--r--src/stateless/cp/trex_vm_splitter.cpp50
-rw-r--r--src/stateless/cp/trex_vm_splitter.h8
5 files changed, 70 insertions, 4 deletions
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 <trex_vm_splitter.h>
#include <trex_stateless.h>
+/**
+ * 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<TrexStream *> 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_stream.h>
-
+/**
+ * TRex VM splitter is used to split
+ * VM instructions around cores
+ *
+ *
+ * @author imarom (23-Dec-15)
+ */
class TrexVmSplitter {
public: