summaryrefslogtreecommitdiffstats
path: root/src/stateless
diff options
context:
space:
mode:
Diffstat (limited to 'src/stateless')
-rw-r--r--src/stateless/cp/trex_stream_vm.cpp10
-rw-r--r--src/stateless/cp/trex_stream_vm.h25
-rw-r--r--src/stateless/cp/trex_vm_splitter.cpp7
3 files changed, 32 insertions, 10 deletions
diff --git a/src/stateless/cp/trex_stream_vm.cpp b/src/stateless/cp/trex_stream_vm.cpp
index b086e21b..cbd2ce7c 100644
--- a/src/stateless/cp/trex_stream_vm.cpp
+++ b/src/stateless/cp/trex_stream_vm.cpp
@@ -426,7 +426,7 @@ void StreamVm::build_program(){
op = StreamDPVmInstructions::ditRANDOM64 ;
}
- StreamDPOpFlowVar32 fv64;
+ StreamDPOpFlowVar64 fv64;
fv64.m_op = op;
fv64.m_flow_offset = get_var_offset(lpMan->m_var_name);
fv64.m_min_val = (uint64_t)lpMan->m_min_value;
@@ -549,19 +549,19 @@ void StreamVm::build_bss() {
switch (ins_man->m_size_bytes) {
case 1:
- *p=(uint8_t)ins_man->m_init_value;
+ *p=(uint8_t)ins_man->get_bss_init_value();
p+=1;
break;
case 2:
- *((uint16_t*)p)=(uint16_t)ins_man->m_init_value;
+ *((uint16_t*)p)=(uint16_t)ins_man->get_bss_init_value();
p+=2;
break;
case 4:
- *((uint32_t*)p)=(uint32_t)ins_man->m_init_value;
+ *((uint32_t*)p)=(uint32_t)ins_man->get_bss_init_value();
p+=4;
break;
case 8:
- *((uint64_t*)p)=(uint64_t)ins_man->m_init_value;
+ *((uint64_t*)p)=(uint64_t)ins_man->get_bss_init_value();
p+=8;
break;
default:
diff --git a/src/stateless/cp/trex_stream_vm.h b/src/stateless/cp/trex_stream_vm.h
index cd78dbd1..a0e8b6b5 100644
--- a/src/stateless/cp/trex_stream_vm.h
+++ b/src/stateless/cp/trex_stream_vm.h
@@ -352,7 +352,7 @@ public:
class StreamDPVmInstructions {
public:
enum INS_TYPE {
- ditINC8 ,
+ ditINC8 =7 ,
ditINC16 ,
ditINC32 ,
ditINC64 ,
@@ -636,6 +636,29 @@ public:
FLOW_VAR_OP_RANDOM
};
+
+ /**
+ * for BSS we take one previous value
+ * because the VM will be executed before writing to pkt
+ * so the init value is one step's advanced
+ *
+ */
+ uint64_t get_bss_init_value() const {
+ uint64_t init = m_init_value;
+
+ switch (m_op) {
+ case FLOW_VAR_OP_INC:
+ return (init == m_min_value ? m_max_value : (init - 1));
+
+ case FLOW_VAR_OP_DEC:
+ return (init == m_max_value ? m_min_value : (init + 1));
+
+ default:
+ return init;
+ }
+
+ }
+
StreamVmInstructionFlowMan(const std::string &var_name,
uint8_t size,
flow_var_op_e op,
diff --git a/src/stateless/cp/trex_vm_splitter.cpp b/src/stateless/cp/trex_vm_splitter.cpp
index 489e3b75..8aae8c76 100644
--- a/src/stateless/cp/trex_vm_splitter.cpp
+++ b/src/stateless/cp/trex_vm_splitter.cpp
@@ -89,9 +89,8 @@ TrexVmSplitter::split_by_flow_var(const StreamVmInstructionFlowMan *instr) {
return false;
}
- /* if the range is too small - multiply */
+ /* if the range is too small - it is unsplitable */
if (instr->get_range() < m_dp_core_count) {
- // FIXME
return false;
}
@@ -118,8 +117,8 @@ TrexVmSplitter::split_by_flow_var(const StreamVmInstructionFlowMan *instr) {
per_core_instr->m_min_value = start;
per_core_instr->m_max_value = end;
- /* init value is the max value because the VM program's first iteration */
- per_core_instr->m_init_value = end;
+ /* after split this has no meaning - choose it as we see fit */
+ per_core_instr->m_init_value = (per_core_instr->m_op == StreamVmInstructionFlowMan::FLOW_VAR_OP_DEC ? end : start);
core_stream->vm_compile();