diff options
author | 2016-02-24 16:08:33 +0200 | |
---|---|---|
committer | 2016-02-24 16:08:33 +0200 | |
commit | 4ae35508f6b448162aa4707264895b4dc42dd0de (patch) | |
tree | 671c99ed4607e5e23954239d52f6fbd289e94266 /src | |
parent | 5a844c9d72411435842e5a0674c6fdc04e5d4e84 (diff) |
add seed per stream
Diffstat (limited to 'src')
-rw-r--r-- | src/gtest/trex_stateless_gtest.cpp | 12 | ||||
-rw-r--r-- | src/rpc-server/commands/trex_rpc_cmd_stream.cpp | 2 | ||||
-rw-r--r-- | src/stateless/cp/trex_stream.h | 2 | ||||
-rw-r--r-- | src/stateless/cp/trex_stream_vm.h | 14 | ||||
-rw-r--r-- | src/stateless/dp/trex_stateless_dp_core.cpp | 15 | ||||
-rw-r--r-- | src/stateless/dp/trex_stream_node.h | 9 |
6 files changed, 44 insertions, 10 deletions
diff --git a/src/gtest/trex_stateless_gtest.cpp b/src/gtest/trex_stateless_gtest.cpp index e946f5d5..4cc40cdb 100644 --- a/src/gtest/trex_stateless_gtest.cpp +++ b/src/gtest/trex_stateless_gtest.cpp @@ -757,7 +757,7 @@ TEST_F(basic_vm, vm_mask1) { StreamVmInstructionFlowMan::FLOW_VAR_OP_INC,0x10000007,0x10000007,0x100000fe) ); - vm.add_instruction( new StreamVmInstructionWriteMaskToPkt("var1", 36,2,0x00ff,0,1) ); + vm.add_instruction( new StreamVmInstructionWriteMaskToPkt("var1", 36,2,0x00ff,0,0,1) ); vm.compile(128); @@ -811,7 +811,7 @@ TEST_F(basic_vm, vm_mask2) { StreamVmInstructionFlowMan::FLOW_VAR_OP_INC,0x10000007,0x10000007,0x100000fe) ); - vm.add_instruction( new StreamVmInstructionWriteMaskToPkt("var1", 36,2,0xff00,8,1) ); + vm.add_instruction( new StreamVmInstructionWriteMaskToPkt("var1", 36,2,0xff00,8,0,1) ); vm.compile(128); @@ -864,7 +864,7 @@ TEST_F(basic_vm, vm_mask3) { StreamVmInstructionFlowMan::FLOW_VAR_OP_INC,0x10000007,0x10000007,0x100000fe) ); - vm.add_instruction( new StreamVmInstructionWriteMaskToPkt("var1", 36,1,0x2,1,1) ); + vm.add_instruction( new StreamVmInstructionWriteMaskToPkt("var1", 36,1,0x2,1,0,1) ); vm.compile(128); @@ -917,7 +917,7 @@ TEST_F(basic_vm, vm_mask4) { StreamVmInstructionFlowMan::FLOW_VAR_OP_INC,1,1,10) ); - vm.add_instruction( new StreamVmInstructionWriteMaskToPkt("var1", 36,2,0xFF00,8,1) ); + vm.add_instruction( new StreamVmInstructionWriteMaskToPkt("var1", 36,2,0xFF00,8,0,1) ); vm.compile(128); @@ -970,7 +970,7 @@ TEST_F(basic_vm, vm_mask5) { StreamVmInstructionFlowMan::FLOW_VAR_OP_INC,1,1,10) ); - vm.add_instruction( new StreamVmInstructionWriteMaskToPkt("var1", 36,4,0x00FF0000,16,1) ); + vm.add_instruction( new StreamVmInstructionWriteMaskToPkt("var1", 36,4,0x00FF0000,16,0,1) ); vm.compile(128); @@ -1024,7 +1024,7 @@ TEST_F(basic_vm, vm_mask6) { StreamVmInstructionFlowMan::FLOW_VAR_OP_INC,1,1,20) ); - vm.add_instruction( new StreamVmInstructionWriteMaskToPkt("var1", 36,2,0x00FF,-1,1) ); + vm.add_instruction( new StreamVmInstructionWriteMaskToPkt("var1", 36,2,0x00FF,-1,0,1) ); vm.compile(128); diff --git a/src/rpc-server/commands/trex_rpc_cmd_stream.cpp b/src/rpc-server/commands/trex_rpc_cmd_stream.cpp index d2cb4ce6..5e23b813 100644 --- a/src/rpc-server/commands/trex_rpc_cmd_stream.cpp +++ b/src/rpc-server/commands/trex_rpc_cmd_stream.cpp @@ -59,7 +59,7 @@ TrexRpcCmdAddStream::_run(const Json::Value ¶ms, Json::Value &result) { stream->m_self_start = parse_bool(section, "self_start", result); stream->m_flags = parse_int(section, "flags", result); stream->m_action_count = parse_uint16(section, "action_count", result); - + stream->m_random_seed = parse_uint32(section, "random_seed", result,0); /* default is zero */ /* inter stream gap */ stream->m_isg_usec = parse_double(section, "isg", result); diff --git a/src/stateless/cp/trex_stream.h b/src/stateless/cp/trex_stream.h index 36f9d407..161e9592 100644 --- a/src/stateless/cp/trex_stream.h +++ b/src/stateless/cp/trex_stream.h @@ -429,6 +429,7 @@ public: dp->m_ibg_usec = m_ibg_usec; dp->m_flags = m_flags; dp->m_action_count = m_action_count; + dp->m_random_seed = m_random_seed; dp->m_rate = m_rate; @@ -485,6 +486,7 @@ public: uint16_t m_flags; uint32_t m_stream_id; /* id from RPC can be anything */ uint16_t m_action_count; + uint32_t m_random_seed; /* config fields */ diff --git a/src/stateless/cp/trex_stream_vm.h b/src/stateless/cp/trex_stream_vm.h index c1db090d..4a0b1d59 100644 --- a/src/stateless/cp/trex_stream_vm.h +++ b/src/stateless/cp/trex_stream_vm.h @@ -1276,7 +1276,8 @@ public: uint16_t prog_size, uint16_t max_pkt_offset, uint16_t prefix_size, - bool a_is_pkt_size_var + bool a_is_pkt_size_var, + bool a_is_random_seed ){ if (bss) { @@ -1303,6 +1304,7 @@ public: m_max_pkt_offset_change = max_pkt_offset; m_prefix_size = prefix_size; m_is_pkt_size_var=a_is_pkt_size_var; + m_is_random_seed=a_is_random_seed; } ~StreamVmDp(){ @@ -1325,7 +1327,8 @@ public: m_program_size, m_max_pkt_offset_change, m_prefix_size, - m_is_pkt_size_var + m_is_pkt_size_var, + m_is_random_seed ); assert(lp); return (lp); @@ -1373,6 +1376,9 @@ public: bool is_pkt_size_var(){ return (m_is_pkt_size_var); } + bool is_random_seed(){ + return (m_is_random_seed); + } private: @@ -1383,6 +1389,7 @@ private: uint16_t m_max_pkt_offset_change; uint16_t m_prefix_size; bool m_is_pkt_size_var; + bool m_is_random_seed; }; @@ -1445,7 +1452,8 @@ public: get_dp_instruction_buffer()->get_program_size(), get_max_packet_update_offset(), get_prefix_size(), - is_var_pkt_size() + is_var_pkt_size(), + m_is_random_var ); assert(lp); return (lp); diff --git a/src/stateless/dp/trex_stateless_dp_core.cpp b/src/stateless/dp/trex_stateless_dp_core.cpp index 39080453..549f923f 100644 --- a/src/stateless/dp/trex_stateless_dp_core.cpp +++ b/src/stateless/dp/trex_stateless_dp_core.cpp @@ -75,6 +75,13 @@ void CGenNodeStateless::refresh_vm_bss(){ StreamVmDp * vm_s=m_ref_stream_info->m_vm_dp; assert(vm_s); memcpy(m_vm_flow_var,vm_s->get_bss(),vm_s->get_bss_size()); + + if ( vm_s->is_random_seed() ){ + /* if we have random seed for this program */ + if (m_ref_stream_info->m_random_seed) { + set_random_seed(m_ref_stream_info->m_random_seed); + } + } } } @@ -670,6 +677,14 @@ TrexStatelessDpCore::add_stream(TrexStatelessDpPerPort * lp_port, node->m_vm_program_size = lpDpVm->get_program_size(); + /* set the random seed if was set */ + if ( lpDpVm->is_random_seed() ){ + /* if we have random seed for this program */ + if (stream->m_random_seed) { + node->set_random_seed(stream->m_random_seed); + } + } + /* we need to copy the object */ if ( pkt_size > lpDpVm->get_prefix_size() ) { /* we need const packet */ diff --git a/src/stateless/dp/trex_stream_node.h b/src/stateless/dp/trex_stream_node.h index ab43defe..b366a770 100644 --- a/src/stateless/dp/trex_stream_node.h +++ b/src/stateless/dp/trex_stream_node.h @@ -116,6 +116,15 @@ private: public: + void set_random_seed(uint32_t seed){ + uint32_t *p=get_random_bss_seed_memory(); + *p=seed; + } + + uint32_t* get_random_bss_seed_memory(){ + return (uint32_t*)m_vm_flow_var;/* always the first 4 bytes */ + } + uint8_t get_port_id(){ return (m_port_id); } |