console: rearrange lines at "stats --ps"
authorYaroslav Brustinov <[email protected]>
Tue, 25 Oct 2016 14:46:47 +0000 (16:46 +0200)
committerYaroslav Brustinov <[email protected]>
Fri, 28 Oct 2016 12:38:35 +0000 (14:38 +0200)
in case of start traffic with link down, return error with link state

Signed-off-by: Yaroslav Brustinov <[email protected]>
scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_client.py
scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_port.py
scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_stats.py
src/stateless/cp/trex_stateless_port.cpp

index a2821cc..80a4c4d 100755 (executable)
@@ -2050,6 +2050,11 @@ class STLClient(object):
         validate_type('total', total, bool)
         validate_type('core_mask', core_mask, (int, list))
 
+        # verify link status
+        ports_link_down = [port_id for port_id in ports if self.ports[port_id].attr.get('link',{}).get('up') == False]
+        if not force and ports_link_down:
+            raise STLError("Port(s) %s - link DOWN - check the connection or specify 'force'" % ports_link_down)
+
         #########################
         # decode core mask argument
         decoded_mask = self.__decode_core_mask(ports, core_mask)
index d0f34f4..1ce2197 100644 (file)
@@ -719,8 +719,8 @@ class Port(object):
                 "--": "",
                 "---": "",
                 "link speed": "{speed} Gb/s".format(speed=info['speed']),
-                "status": info['status'],
-                "link": info['link'],
+                "port status": info['status'],
+                "link status": info['link'],
                 "promiscuous" : info['prom'],
                 "flow ctrl" : info['fc'],
                 }
index fd4ad95..915eabb 100644 (file)
@@ -342,7 +342,7 @@ class CTRexInfoGenerator(object):
 
     def _generate_latency_stats(self):
         lat_stats = self._latency_stats_ref
-        latency_window_size = 10
+        latency_window_size = 14
 
         # for TUI - maximum 5 
         pg_ids = list(filter(is_intable, lat_stats.latest_stats.keys()))[:5]
@@ -456,7 +456,7 @@ class CTRexInfoGenerator(object):
             stats_table.set_cols_width([10, 3, 6] + [3] * (show_len - 1))
             stats_table.set_cols_dtype(['t'] * (show_len + 2))
 
-            for i in range(min(14, len(cpu_stats))):
+            for i in range(min(18, len(cpu_stats))):
                 history = cpu_stats[i]["history"]
                 ports = cpu_stats[i]["ports"]
                 avg = int(round(sum(history[:avg_len]) / avg_len))
@@ -666,9 +666,9 @@ class CTRexInfoGenerator(object):
         return_stats_data = {}
         per_field_status = OrderedDict([("driver", []),
                                         ("description", []),
+                                        ("link status", []),
                                         ("link speed", []),
-                                        ("link", []),
-                                        ("status", []),
+                                        ("port status", []),
                                         ("promiscuous", []),
                                         ("flow ctrl", []),
                                         ("--", []),
index 1a92b30..53a225f 100644 (file)
@@ -252,14 +252,14 @@ TrexStatelessPort::start_traffic(const TrexPortMultiplier &mul, double duration,
     /* on start - we can only provide absolute values */
     assert(mul.m_op == TrexPortMultiplier::OP_ABS);
 
+    /* check link state */
+    if ( !platform_api->getPortAttrObj()->is_link_up(m_port_id) && !force ) {
+        throw TrexException("Link state is DOWN.");
+    }
+
     /* caclulate the effective factor for DP */
     double factor = calculate_effective_factor(mul, force);
 
-    /* zero factor */
-    if (factor == 0) {
-        throw TrexException("Zero multiplier, nothing to send.");
-    }
-
     StreamsFeeder feeder(this);
 
     /* compiler it */
@@ -690,6 +690,20 @@ TrexStatelessPort::calculate_effective_factor(const TrexPortMultiplier &mul, boo
         throw TrexException(ss.str());
     }
 
+    /* L1 BW must be positive */
+    if (expected_l1_rate <= 0){
+        stringstream ss;
+        ss << "Effective bandwidth must be positive, got: " << expected_l1_rate;
+        throw TrexException(ss.str());
+    }
+
+    /* factor must be positive */
+    if (factor <= 0) {
+        stringstream ss;
+        ss << "Factor must be positive, got: " << factor;
+        throw TrexException(ss.str());
+    }
+
     return factor;
 }