Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added XDP tx recipe #384

Merged
merged 3 commits into from
Nov 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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

17 changes: 17 additions & 0 deletions lnst/Recipes/ENRT/XDPTxRecipe.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
from lnst.Common.Parameters import ConstParam
from lnst.Recipes.ENRT.ConfigMixins.MultiDevInterruptHWConfigMixin import (
MultiDevInterruptHWConfigMixin,
)
from lnst.Recipes.ENRT.SimpleNetworkRecipe import SimpleNetworkRecipe
from lnst.Recipes.ENRT.MeasurementGenerators.XDPFlowMeasurementGenerator import (
XDPFlowMeasurementGenerator,
)


class XDPTxRecipe(
XDPFlowMeasurementGenerator, MultiDevInterruptHWConfigMixin, SimpleNetworkRecipe
):
xdp_command = ConstParam(value="tx")
# NOTE: Receiver's IRQs needs to be pinned to single CPU (due to test stability)
# Generator needs to reach line rate, therefore its' IRQ CPUs should not be limited.
# Simply use `multi_dev_interrupt_config` with single host.
1 change: 1 addition & 0 deletions lnst/Recipes/ENRT/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@
from lnst.Recipes.ENRT.DellLACPRecipe import DellLACPRecipe
from lnst.Recipes.ENRT.SoftwareRDMARecipe import SoftwareRDMARecipe
from lnst.Recipes.ENRT.XDPDropRecipe import XDPDropRecipe
from lnst.Recipes.ENRT.XDPTxRecipe import XDPTxRecipe
from lnst.Recipes.ENRT.CTInsertionRateNftablesRecipe import CTInsertionRateNftablesRecipe
from .CTFulltableInsertionRateRecipe import CTFulltableInsertionRateRecipe
from lnst.Recipes.ENRT.BaseEnrtRecipe import BaseEnrtRecipe
Expand Down
20 changes: 13 additions & 7 deletions lnst/Tests/XDPBench.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def parse_output(self) -> list[dict]:
return results

def _parse_line(self, line: str) -> tuple:
match = re.search(r"Summary\s+([\d,]+)\srx/s\s+([\d,]+)\serr/s?", line)
match = re.search(r"Summary\s+([\d,]+)\srx/s\s+([\d,]+)\serr(,drop)?/s?", line)

if not match: # skip summary line at the end + corrupted lines
raise ValueError("Invalid line format")
Expand All @@ -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")
enhaut marked this conversation as resolved.
Show resolved Hide resolved
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
Loading