VM bug youtrack: trex-187
authorimarom <[email protected]>
Wed, 24 Feb 2016 12:13:52 +0000 (07:13 -0500)
committerIdo Barnea <[email protected]>
Wed, 24 Feb 2016 12:21:29 +0000 (14:21 +0200)
and rx stats

scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_streams.py
src/stateless/cp/trex_stream.h
src/stateless/cp/trex_stream_vm.cpp
src/stateless/cp/trex_stream_vm.h
src/stateless/cp/trex_vm_splitter.cpp

index adbb88a..127d166 100644 (file)
@@ -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),
index af4d4a7..36f9d40 100644 (file)
@@ -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 */
index b0cadfb..59efd6f 100644 (file)
@@ -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);
index 0bd0071..d43d7d4 100644 (file)
@@ -1451,7 +1451,7 @@ public:
      * clone VM instructions
      * 
      */
-    void copy_instructions(StreamVm &other) const;
+    void clone(StreamVm &other) const;
 
     
     bool is_vm_empty() const {
index 5e6d4fb..963b452 100644 (file)
@@ -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);
     }
 }