aboutsummaryrefslogtreecommitdiffstats
path: root/GPL/tools
diff options
context:
space:
mode:
authorpmikus <peter.mikus@protonmail.ch>2023-10-13 12:34:04 +0000
committerPeter Mikus <peter.mikus@protonmail.ch>2023-10-25 14:30:07 +0000
commit039a8a325bc24cd8d7c5770d88a20ce517197fe9 (patch)
treeac3a958d9493e89781ee61266b3d3e7de41e0c5f /GPL/tools
parent8993ddb4f38f2754ae3af1c61e69a2e747f32a67 (diff)
feat(core): Multilink TRex Sync mode II
Signed-off-by: Peter Mikus <peter.mikus@protonmail.ch> Change-Id: Idf4df372520d4a72c0738a89290d16710485f140
Diffstat (limited to 'GPL/tools')
-rw-r--r--GPL/tools/trex/trex_stl_profile.py55
1 files changed, 28 insertions, 27 deletions
diff --git a/GPL/tools/trex/trex_stl_profile.py b/GPL/tools/trex/trex_stl_profile.py
index c318674899..ac53e90571 100644
--- a/GPL/tools/trex/trex_stl_profile.py
+++ b/GPL/tools/trex/trex_stl_profile.py
@@ -74,8 +74,7 @@ def simple_burst(
duration,
framesize,
rate,
- port_0,
- port_1,
+ ports,
latency,
async_start=False,
traffic_directions=2,
@@ -103,8 +102,7 @@ def simple_burst(
:param framesize: Frame size.
:param duration: Duration of traffic run in seconds (-1=infinite).
:param rate: Traffic rate [percentage, pps, bps].
- :param port_0: Port 0 on the traffic generator.
- :param port_1: Port 1 on the traffic generator.
+ :param ports: Port list on the traffic generator.
:param latency: With latency stats.
:param async_start: Start the traffic and exit.
:param traffic_directions: Bidirectional (2) or unidirectional (1) traffic.
@@ -114,8 +112,7 @@ def simple_burst(
:type framesize: int or str
:type duration: float
:type rate: str
- :type port_0: int
- :type port_1: int
+ :type ports: list
:type latency: bool
:type async_start: bool
:type traffic_directions: int
@@ -153,38 +150,47 @@ def simple_burst(
if "macsrc" in profile_file:
client.set_port_attr(promiscuous=True)
if isinstance(framesize, int):
- last_stream_a = int((len(streams) - 2) / 2)
- last_stream_b = (last_stream_a * 2)
- client.add_streams(streams[0:last_stream_a], ports=[port_0])
+ mark_a = len(streams) // 4
+ mark_b = len(streams) // 2
+ for i,j in zip(streams[:mark_a], ports[::2]):
+ client.add_streams(streams=[i], ports=[j])
if traffic_directions > 1:
- client.add_streams(
- streams[last_stream_a:last_stream_b], ports=[port_1])
+ for i,j in zip(streams[mark_a:mark_b], ports[1::2]):
+ print(i, j)
+ client.add_streams(streams=[i], ports=[j])
elif isinstance(framesize, str):
- client.add_streams(streams[0:3], ports=[port_0])
+ mark = 0
+ for i in ports[::2]:
+ client.add_streams(streams=streams[mark:mark+3], ports=[i])
+ mark = mark + 3
if traffic_directions > 1:
- client.add_streams(streams[3:6], ports=[port_1])
+ mark = len(streams) // 2
+ for i in ports[1::2]:
+ client.add_streams(streams=streams[mark:mark+3], ports=[i])
+ mark = mark + 3
if latency:
try:
if isinstance(framesize, int):
- client.add_streams(streams[last_stream_b], ports=[port_0])
+ mark_c = len(streams) // 2
+ mark_d = len(streams) // 2 + len(streams) // 4
+ for i,j in zip(streams[mark_c:mark_d], ports[::2]):
+ client.add_streams(streams=[i], ports=[j])
if traffic_directions > 1:
- client.add_streams(
- streams[last_stream_b + 1], ports=[port_1])
+ for i,j in zip(streams[mark_d:], ports[1::2]):
+ client.add_streams(streams=[i], ports=[j])
elif isinstance(framesize, str):
latency = False
except STLError:
# Disable latency if NIC does not support requested stream type
print("##### FAILED to add latency streams #####")
latency = False
- # Even for unidir, both ports are needed to see both rx and tx.
- ports = [port_0, port_1]
# Clear the stats before injecting:
client.clear_stats()
# Choose rate and start traffic:
client.start(
- ports=ports[:traffic_directions],
+ ports=ports[::] if traffic_directions == 2 else ports[::2],
mult=rate,
duration=duration,
force=force,
@@ -286,12 +292,8 @@ def main():
help="Traffic rate with included units (pps)."
)
parser.add_argument(
- "--port_0", required=True, type=int,
- help="Port 0 on the traffic generator."
- )
- parser.add_argument(
- "--port_1", required=True, type=int,
- help="Port 1 on the traffic generator."
+ "--ports", required=True, type=int, nargs="+",
+ help="Port list on the traffic generator."
)
parser.add_argument(
"--async_start", action="store_true", default=False,
@@ -326,8 +328,7 @@ def main():
duration=args.duration,
framesize=framesize,
rate=args.rate,
- port_0=args.port_0,
- port_1=args.port_1,
+ ports=args.ports,
latency=args.latency,
async_start=args.async_start,
traffic_directions=args.traffic_directions,