Skip to content

Commit

Permalink
XDPBench: exported xdp-bench tool arguments
Browse files Browse the repository at this point in the history
All the params that are passed to `xdp-bench` tool needs to be
able to use them within LNST.
`XDPBench._prepare_arguments` ignores empty parameters set to
empty string. Thats because not all of the params are applicable
to all XDP bench modes but we still need a way of providing them
to XDPBench so these are passed to XDPBench but set to empty str.

More elegant way would be splitting `XDPBench` into multiple
test modules based on mode it runs...
  • Loading branch information
enhaut authored and olichtne committed Nov 12, 2024
1 parent 55b6900 commit f4e828e
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 9 deletions.
19 changes: 18 additions & 1 deletion lnst/RecipeCommon/Perf/Measurements/XDPBenchMeasurement.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,26 @@


class XDPBenchMeasurement(BaseFlowMeasurement):
def __init__(self, flows: list[Flow], xdp_command: str, recipe_conf=None):
def __init__(
self,
flows: list[Flow],
xdp_command: str,
xdp_mode: str,
xdp_load_mode: str = None,
xdp_packet_operation: str = None,
xdp_remote_action: str = None,
recipe_conf=None,
):
super().__init__(recipe_conf)
self._flows = flows
self._running_measurements = []
self._finished_measurements = []

self.command = xdp_command
self.mode = xdp_mode
self.load_mode = xdp_load_mode
self.packet_operation = xdp_packet_operation
self.remote_action = xdp_remote_action

def version(self):
return 1.0
Expand Down Expand Up @@ -65,6 +78,10 @@ def simulate_start(self):
def _prepare_server(self, flow: Flow):
params = {
"command": self.command,
"xdp_mode": self.mode,
"load_mode": self.load_mode,
"packet_operation": self.packet_operation,
"remote_action": self.remote_action,
"interface": flow.receiver_nic,
"duration": flow.duration + flow.warmup_duration * 2,
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,25 @@
BaseFlowMeasurementGenerator,
)

from lnst.Tests.XDPBench import XDP_BENCH_COMMANDS
from lnst.Tests.XDPBench import (
XDP_BENCH_COMMANDS,
XDP_MODES,
XDP_LOAD_MODES,
XDP_PACKET_OPERATIONS,
XDP_REMOTE_ACTIONS,
)


class XDPFlowMeasurementGenerator(BaseFlowMeasurementGenerator):
xdp_command = ChoiceParam(type=StrParam, choices=XDP_BENCH_COMMANDS)
xdp_mode = ChoiceParam(type=StrParam, choices=XDP_MODES, default="native")
xdp_load_mode = ChoiceParam(type=StrParam, choices=XDP_LOAD_MODES, default="")
xdp_packet_operation = ChoiceParam(
type=StrParam, choices=XDP_PACKET_OPERATIONS, default=""
)
xdp_remote_action = ChoiceParam(
type=StrParam, choices=XDP_REMOTE_ACTIONS, default=""
)

@property
def net_perf_tool_class(self):
Expand All @@ -25,7 +39,15 @@ def net_perf_tool_class(self):
[1] https://github.com/LNST-project/lnst/pull/310#discussion_r1305763175
"""
def XDPBenchMeasurement_partial(*args, **kwargs):
return XDPBenchMeasurement(*args, self.params.xdp_command, **kwargs)
return XDPBenchMeasurement(
*args,
self.params.xdp_command,
self.params.xdp_mode,
self.params.xdp_load_mode,
self.params.xdp_packet_operation,
self.params.xdp_remote_action,
**kwargs
)

return XDPBenchMeasurement_partial

18 changes: 12 additions & 6 deletions lnst/Tests/XDPBench.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,11 @@ def _parse_line(self, line: str) -> tuple:
"redirect-multi",
)

XDP_MODES = ("native", "skb")
XDP_LOAD_MODES = ("dpa", "load-bytes", "")
XDP_PACKET_OPERATIONS = ("no-touch", "read-data", "parse-ip", "swap-macs", "")
XDP_REMOTE_ACTIONS = ("disabled", "drop", "pass", "redirect", "")


class XDPBench(BaseTestModule):
"""
Expand All @@ -108,15 +113,13 @@ class XDPBench(BaseTestModule):
interval = IntParam(default=1)

redirect_device = DeviceParam()
xdp_mode = ChoiceParam(type=StrParam, choices=("native", "skb"), default="native")
load_mode = ChoiceParam(type=StrParam, choices=("dpa", "load-bytes"))
xdp_mode = ChoiceParam(type=StrParam, choices=XDP_MODES, default="native")
load_mode = ChoiceParam(type=StrParam, choices=XDP_LOAD_MODES)
packet_operation = ChoiceParam(
type=StrParam, choices=("no-touch", "read-data", "parse-ip", "swap-macs")
)
type=StrParam, choices=XDP_PACKET_OPERATIONS)
qsize = IntParam()
remote_action = ChoiceParam(
type=StrParam, choices=("disabled", "drop", "pass", "redirect")
)
type=StrParam, choices=XDP_REMOTE_ACTIONS)

# NOTE: order and names of params above matters. xdp-bench accepts params in that way
duration = IntParam(default=60, mandatory=True)
Expand Down Expand Up @@ -146,6 +149,9 @@ def _prepare_command(self):
def _prepare_arguments(self):
args = []
for param, value in self.params:
if value == "":
continue # skip empty (default) values

if param == "duration":
continue # not a xdp-bench argument

Expand Down

0 comments on commit f4e828e

Please sign in to comment.