summaryrefslogtreecommitdiffstats
path: root/scripts/automation/trex_control_plane/stl/trex_stl_lib
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/automation/trex_control_plane/stl/trex_stl_lib')
-rwxr-xr-xscripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_client.py53
-rw-r--r--scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_port.py33
-rwxr-xr-xscripts/automation/trex_control_plane/stl/trex_stl_lib/utils/parsing_opts.py4
3 files changed, 60 insertions, 30 deletions
diff --git a/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_client.py b/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_client.py
index 8429bb86..cc20e088 100755
--- a/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_client.py
+++ b/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_client.py
@@ -869,6 +869,15 @@ class STLClient(object):
return rc
+ def __get_rx_queue_pkts (self, port_id_list):
+ port_id_list = self.__ports(port_id_list)
+ rc = RC()
+
+ for port_id in port_id_list:
+ rc.add(self.ports[port_id].get_rx_queue_pkts())
+
+ return rc
+
# connect to server
def __connect(self):
@@ -1833,8 +1842,21 @@ class STLClient(object):
+ :exc:`STLError`
"""
- self._validate_port_list(src_port)
+ # validate src port
+ validate_type('src_port', src_port, int)
+ if src_port not in self.get_all_ports():
+ raise STLError("src port is not a valid port id")
+ if not is_valid_ipv4(dst_ipv4):
+ raise STLError("dst_ipv4 is not a valid IPv4 address: '{0}'".format(dst_ipv4))
+
+ if (pkt_size < 64) or (pkt_size > 9216):
+ raise STLError("pkt_size should be a value between 64 and 9216: '{0}'".format(pkt_size))
+
+ validate_type('count', count, int)
+
+
+
self.logger.pre_cmd("Pinging {0} from port {1} with {2} bytes of data:".format(dst_ipv4,
src_port,
pkt_size))
@@ -2873,11 +2895,7 @@ class STLClient(object):
"""
# by default - resolve all the ports that are configured with IPv4 dest
- if ports is None:
- ports = self.get_resolvable_ports()
- if not ports:
- raise STLError('No ports configured with destination as IPv4')
-
+ ports = ports if ports is not None else self.get_resolvable_ports()
ports = self._validate_port_list(ports)
active_ports = list_intersect(ports, self.get_active_ports())
@@ -3019,9 +3037,14 @@ class STLClient(object):
ports = ports if ports is not None else self.get_acquired_ports()
ports = self._validate_port_list(ports)
+ rc = self.__get_rx_queue_pkts(ports)
+ if not rc:
+ raise STLError(rc)
+
+ # decode the data back to the user
result = {}
- for port in ports:
- result[port] = self.ports[port].get_rx_queue_pkts()
+ for port, r in zip(ports, rc.data()):
+ result[port] = r
return result
@@ -3688,6 +3711,8 @@ class STLClient(object):
self.set_rx_sniffer(opts.ports, opts.output_filename, opts.limit)
+ return RC_OK()
+
@__console
def resolve_line (self, line):
@@ -3703,9 +3728,19 @@ class STLClient(object):
if not opts:
return opts
+ ports = list_intersect(opts.ports, self.get_resolvable_ports())
+ if not ports:
+ if not opts.ports:
+ msg = 'resolve - no ports with IPv4 destination'
+ else:
+ msg = 'pause - none of ports {0} are configured with IPv4 destination'.format(opts.ports)
+
+ self.logger.log(msg)
+ return RC_ERR(msg)
- self.resolve(ports = opts.ports, retries = opts.retries)
+ self.resolve(ports = ports, retries = opts.retries)
+ return RC_OK()
@__console
diff --git a/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_port.py b/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_port.py
index 42b7b89b..9b955465 100644
--- a/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_port.py
+++ b/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_port.py
@@ -825,37 +825,32 @@ class Port(object):
else:
info['is_virtual'] = 'N/A'
- if 'speed' in attr:
- info['speed'] = self.get_formatted_speed()
- else:
- info['speed'] = 'N/A'
-
+ # speed
+ info['speed'] = self.get_formatted_speed()
- if 'rx_filter_mode' in attr:
- info['rx_filter_mode'] = 'hardware match' if attr['rx_filter_mode'] == 'hw' else 'fetch all'
- else:
- info['rx_filter_mode'] = 'N/A'
+ # RX filter mode
+ info['rx_filter_mode'] = 'hardware match' if attr['rx_filter_mode'] == 'hw' else 'fetch all'
# src MAC and IPv4
- info['src_mac'] = attr.get('src_mac', 'N/A')
-
- info['src_ipv4'] = attr.get('src_ipv4', 'N/A')
+ info['src_mac'] = attr['src_mac']
+ info['src_ipv4'] = attr['src_ipv4']
+
if info['src_ipv4'] is None:
info['src_ipv4'] = 'Not Configured'
# dest
dest = attr['dest']
if dest['type'] == 'mac':
- info['dest'] = dest['mac']
- info['arp'] = '-'
+ info['dest'] = dest['mac']
+ info['arp'] = '-'
elif dest['type'] == 'ipv4':
- info['dest'] = dest['ipv4']
- info['arp'] = dest['arp']
+ info['dest'] = dest['ipv4']
+ info['arp'] = dest['arp']
elif dest['type'] == 'ipv4_u':
- info['dest'] = dest['ipv4']
- info['arp'] = 'unresolved'
+ info['dest'] = dest['ipv4']
+ info['arp'] = 'unresolved'
# RX info
@@ -900,7 +895,7 @@ class Port(object):
assert(0)
- # return True if the port is resolved
+ # port is considered resolved if it's dest is either MAC or resolved IPv4
def is_resolved (self):
return (self.get_dst_addr()['mac'] is not None)
diff --git a/scripts/automation/trex_control_plane/stl/trex_stl_lib/utils/parsing_opts.py b/scripts/automation/trex_control_plane/stl/trex_stl_lib/utils/parsing_opts.py
index 8a667dc0..7ae22e89 100755
--- a/scripts/automation/trex_control_plane/stl/trex_stl_lib/utils/parsing_opts.py
+++ b/scripts/automation/trex_control_plane/stl/trex_stl_lib/utils/parsing_opts.py
@@ -245,8 +245,8 @@ def check_pkt_size (pkt_size):
except ValueError:
raise argparse.ArgumentTypeError("invalid packet size type: '{0}'".format(pkt_size))
- if (pkt_size < 64) or (pkt_size > 9000):
- raise argparse.ArgumentTypeError("invalid packet size: '{0}' - valid range is 64 to 9000".format(pkt_size))
+ if (pkt_size < 64) or (pkt_size > 9216):
+ raise argparse.ArgumentTypeError("invalid packet size: '{0}' - valid range is 64 to 9216".format(pkt_size))
return pkt_size