diff options
-rw-r--r-- | scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_streams.py | 34 | ||||
-rw-r--r-- | src/stateless/cp/trex_stream.h | 3 | ||||
-rw-r--r-- | src/stateless/cp/trex_stream_vm.cpp | 8 | ||||
-rw-r--r-- | src/stateless/cp/trex_stream_vm.h | 2 | ||||
-rw-r--r-- | src/stateless/cp/trex_vm_splitter.cpp | 2 |
5 files changed, 33 insertions, 16 deletions
diff --git a/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_streams.py b/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_streams.py index adbb88a6..127d1669 100644 --- a/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_streams.py +++ b/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_streams.py @@ -125,11 +125,13 @@ STLStreamDstMAC_ARP =2 class STLRxStats(object): def __init__ (self, user_id): self.fields = {} - self.fields['stream_id'] = user_id - self.fields['enabled'] = True - self.fields['seq_enabled'] = False + + self.fields['enabled'] = True + self.fields['stream_id'] = user_id + self.fields['seq_enabled'] = False self.fields['latency_enabled'] = False + def to_json (self): return dict(self.fields) @@ -356,6 +358,8 @@ class YAMLLoader(object): def __parse_mode (self, mode_obj): + if not mode_obj: + return None rate_parser = set(mode_obj).intersection(['pps', 'bps_L1', 'bps_L2', 'percentage']) if len(rate_parser) != 1: @@ -389,6 +393,18 @@ class YAMLLoader(object): + def __parse_rx_stats (self, rx_stats_obj): + + # no such object + if not rx_stats_obj or rx_stats_obj.get('enabled') == False: + return None + + user_id = rx_stats_obj.get('stream_id') + if user_id == None: + raise STLError("enabled RX stats section must contain 'stream_id' field") + + return STLRxStats(user_id = user_id) + def __parse_stream (self, yaml_object): s_obj = yaml_object['stream'] @@ -402,23 +418,21 @@ class YAMLLoader(object): # mode - mode_obj = s_obj.get('mode') - if not mode_obj: - raise STLError("YAML file must contain 'mode' field") - - mode = self.__parse_mode(mode_obj) + mode = self.__parse_mode(s_obj.get('mode')) + # rx stats + rx_stats = self.__parse_rx_stats(s_obj.get('rx_stats')) - defaults = STLStream() + defaults = STLStream() # create the stream stream = STLStream(name = yaml_object.get('name'), packet = builder, mode = mode, + rx_stats = rx_stats, enabled = s_obj.get('enabled', defaults.fields['enabled']), self_start = s_obj.get('self_start', defaults.fields['self_start']), isg = s_obj.get('isg', defaults.fields['isg']), - rx_stats = s_obj.get('rx_stats', defaults.fields['rx_stats']), next = yaml_object.get('next'), action_count = s_obj.get('action_count', defaults.fields['action_count']), mac_src_override_by_pkt = s_obj.get('mac_src_override_by_pkt', 0), diff --git a/src/stateless/cp/trex_stream.h b/src/stateless/cp/trex_stream.h index af4d4a73..36f9d407 100644 --- a/src/stateless/cp/trex_stream.h +++ b/src/stateless/cp/trex_stream.h @@ -402,7 +402,8 @@ public: /* on full clone we copy also VM */ if (full) { - m_vm.copy_instructions(dp->m_vm); + m_vm.clone(dp->m_vm); + } /* copy VM DP product */ diff --git a/src/stateless/cp/trex_stream_vm.cpp b/src/stateless/cp/trex_stream_vm.cpp index b0cadfb6..59efd6fc 100644 --- a/src/stateless/cp/trex_stream_vm.cpp +++ b/src/stateless/cp/trex_stream_vm.cpp @@ -886,14 +886,14 @@ StreamVm::set_split_instruction(StreamVmInstructionVar *instr) { } /** - * copy instructions from this VM to 'other' + * clone VM from this VM to 'other' * * @author imarom (22-Dec-15) * * @param other */ void -StreamVm::copy_instructions(StreamVm &other) const { +StreamVm::clone(StreamVm &other) const { /* clear previous if any exists */ for (auto instr : other.m_inst_list) { delete instr; @@ -903,6 +903,7 @@ StreamVm::copy_instructions(StreamVm &other) const { for (auto instr : m_inst_list) { StreamVmInstruction *new_instr = instr->clone(); + other.m_inst_list.push_back(new_instr); /* for the split instruction - find the right one */ @@ -913,6 +914,7 @@ StreamVm::copy_instructions(StreamVm &other) const { } } + other.m_is_random_var = m_is_random_var; } /** @@ -973,7 +975,7 @@ StreamVm::calc_expected_pkt_size(uint16_t regular_pkt_size) const { StreamVm dummy; - this->copy_instructions(dummy); + this->clone(dummy); dummy.compile(regular_pkt_size); assert(dummy.m_expected_pkt_size != 0); diff --git a/src/stateless/cp/trex_stream_vm.h b/src/stateless/cp/trex_stream_vm.h index 0bd00711..d43d7d4b 100644 --- a/src/stateless/cp/trex_stream_vm.h +++ b/src/stateless/cp/trex_stream_vm.h @@ -1451,7 +1451,7 @@ public: * clone VM instructions * */ - void copy_instructions(StreamVm &other) const; + void clone(StreamVm &other) const; bool is_vm_empty() const { diff --git a/src/stateless/cp/trex_vm_splitter.cpp b/src/stateless/cp/trex_vm_splitter.cpp index 5e6d4fbd..963b4525 100644 --- a/src/stateless/cp/trex_vm_splitter.cpp +++ b/src/stateless/cp/trex_vm_splitter.cpp @@ -190,7 +190,7 @@ void TrexVmSplitter::duplicate_vm() { /* for each core - duplicate the instructions */ for (TrexStream *core_stream : *m_core_streams) { - m_stream->m_vm.copy_instructions(core_stream->m_vm); + m_stream->m_vm.clone(core_stream->m_vm); } } |