summaryrefslogtreecommitdiffstats
path: root/scripts/automation/trex_control_plane/stl/trex_stl_lib/utils
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/automation/trex_control_plane/stl/trex_stl_lib/utils')
-rwxr-xr-xscripts/automation/trex_control_plane/stl/trex_stl_lib/utils/parsing_opts.py55
-rw-r--r--scripts/automation/trex_control_plane/stl/trex_stl_lib/utils/text_tables.py9
-rw-r--r--scripts/automation/trex_control_plane/stl/trex_stl_lib/utils/zipmsg.py32
3 files changed, 86 insertions, 10 deletions
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 af7e90c1..9ed6c0f8 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
@@ -37,6 +37,8 @@ PROMISCUOUS_SWITCH = 21
TUNABLES = 22
REMOTE_FILE = 23
LOCKED = 24
+PIN_CORES = 25
+CORE_MASK = 26
GLOBAL_STATS = 50
PORT_STATS = 51
@@ -47,6 +49,8 @@ CPU_STATS = 55
MBUF_STATS = 56
STREAMS_MASK = 60
+CORE_MASK_GROUP = 61
+
# ALL_STREAMS = 61
# STREAM_LIST_WITH_ALL = 62
@@ -79,14 +83,23 @@ def match_time_unit(val):
"-d 10m : in min \n"
"-d 1h : in hours")
+
match_multiplier_help = """Multiplier should be passed in the following format:
- [number][<empty> | bps | kbps | mbps | gbps | pps | kpps | mpps | %% ].
+ [number][<empty> | bps | kbps | mbps | gbps | pps | kpps | mpps | %% ].
+
no suffix will provide an absoulute factor and percentage
will provide a percentage of the line rate. examples
- '-m 10', '-m 10kbps', '-m 10mpps', '-m 23%%'
- '-m 23%%' : is 23%% L1 bandwidth
- '-m 23mbps' : is 23mbps in L2 bandwidth (including FCS+4)
+ '-m 10',
+ '-m 10kbps',
+ '-m 10kbpsl1',
+ '-m 10mpps',
+ '-m 23%% '
+
+ '-m 23%%' : is 23%% L1 bandwidth
+ '-m 23mbps': is 23mbps in L2 bandwidth (including FCS+4)
+ '-m 23mbpsl1': is 23mbps in L1 bandwidth
+
"""
@@ -183,6 +196,14 @@ def match_multiplier_strict(val):
return val
+def hex_int (val):
+ pattern = r"0x[1-9a-fA-F][0-9a-fA-F]*"
+
+ if not re.match(pattern, val):
+ raise argparse.ArgumentTypeError("{0} is not a valid positive HEX formatted number".format(val))
+
+ return int(val, 16)
+
def is_valid_file(filename):
if not os.path.isfile(filename):
@@ -264,7 +285,7 @@ OPTIONS_DB = {MULTIPLIER: ArgumentPack(['-m', '--multiplier'],
{"nargs": '+',
'dest':'ports',
'metavar': 'PORTS',
- 'type': int,
+ 'type': int,
'help': "A list of ports on which to apply the command",
'default': []}),
@@ -314,7 +335,6 @@ OPTIONS_DB = {MULTIPLIER: ArgumentPack(['-m', '--multiplier'],
'default': False,
'help': "Dry run - no traffic will be injected"}),
-
XTERM: ArgumentPack(['-x', '--xterm'],
{'action': 'store_true',
'dest': 'xterm',
@@ -364,6 +384,21 @@ OPTIONS_DB = {MULTIPLIER: ArgumentPack(['-m', '--multiplier'],
'default': []}),
+ PIN_CORES: ArgumentPack(['--pin'],
+ {'action': 'store_true',
+ 'dest': 'pin_cores',
+ 'default': False,
+ 'help': "Pin cores to interfaces - cores will be divided between interfaces (performance boot for symetric profiles)"}),
+
+ CORE_MASK: ArgumentPack(['--core_mask'],
+ {'action': 'store',
+ 'nargs': '+',
+ 'type': hex_int,
+ 'dest': 'core_mask',
+ 'default': None,
+ 'help': "Core mask - only cores responding to the bit mask will be active"}),
+
+
# promiscuous
PROMISCUOUS_SWITCH: ArgumentGroup(MUTEX, [PROMISCUOUS,
NO_PROMISCUOUS],
@@ -383,7 +418,13 @@ OPTIONS_DB = {MULTIPLIER: ArgumentPack(['-m', '--multiplier'],
STREAMS_STATS,
CPU_STATS,
MBUF_STATS],
- {})
+ {}),
+
+
+ CORE_MASK_GROUP: ArgumentGroup(MUTEX, [PIN_CORES,
+ CORE_MASK],
+ {'required': False}),
+
}
diff --git a/scripts/automation/trex_control_plane/stl/trex_stl_lib/utils/text_tables.py b/scripts/automation/trex_control_plane/stl/trex_stl_lib/utils/text_tables.py
index 4b7e9b3e..393ba111 100644
--- a/scripts/automation/trex_control_plane/stl/trex_stl_lib/utils/text_tables.py
+++ b/scripts/automation/trex_control_plane/stl/trex_stl_lib/utils/text_tables.py
@@ -1,7 +1,10 @@
+from __future__ import print_function
+
import sys
from texttable import Texttable
from .text_opts import format_text
+
class TRexTextTable(Texttable):
def __init__(self):
@@ -21,11 +24,11 @@ class TRexTextInfo(Texttable):
def generate_trex_stats_table():
pass
-def print_table_with_header(texttable_obj, header="", untouched_header=""):
+def print_table_with_header(texttable_obj, header="", untouched_header="", buffer=sys.stdout):
header = header.replace("_", " ").title() + untouched_header
- print(format_text(header, 'cyan', 'underline') + "\n")
+ print(format_text(header, 'cyan', 'underline') + "\n", file=buffer)
- print((texttable_obj.draw() + "\n"))
+ print((texttable_obj.draw() + "\n"), file=buffer)
if __name__ == "__main__":
pass
diff --git a/scripts/automation/trex_control_plane/stl/trex_stl_lib/utils/zipmsg.py b/scripts/automation/trex_control_plane/stl/trex_stl_lib/utils/zipmsg.py
new file mode 100644
index 00000000..397ada16
--- /dev/null
+++ b/scripts/automation/trex_control_plane/stl/trex_stl_lib/utils/zipmsg.py
@@ -0,0 +1,32 @@
+import zlib
+import struct
+
+class ZippedMsg:
+
+ MSG_COMPRESS_THRESHOLD = 256
+ MSG_COMPRESS_HEADER_MAGIC = 0xABE85CEA
+
+ def check_threshold (self, msg):
+ return len(msg) >= self.MSG_COMPRESS_THRESHOLD
+
+ def compress (self, msg):
+ # compress
+ compressed = zlib.compress(msg)
+ new_msg = struct.pack(">II", self.MSG_COMPRESS_HEADER_MAGIC, len(msg)) + compressed
+ return new_msg
+
+
+ def decompress (self, msg):
+ if len(msg) < 8:
+ return None
+
+ t = struct.unpack(">II", msg[:8])
+ if (t[0] != self.MSG_COMPRESS_HEADER_MAGIC):
+ return None
+
+ x = zlib.decompress(msg[8:])
+ if len(x) != t[1]:
+ return None
+
+ return x
+