This patch adds the ability to specify build arguments when building DPDK through DTS. Doing so allows users to build DPDK with the desired build arguments, which allows for a more configurable DTS run.
Signed-off-by: Koushik Bhargav Nimoji <[email protected]> --- dts/configurations/test_run.example.yaml | 13 +++++++++++++ dts/framework/config/test_run.py | 2 ++ dts/framework/remote_session/dpdk.py | 12 ++++++++---- dts/framework/utils.py | 21 ++++++++++++++++++++- 4 files changed, 43 insertions(+), 5 deletions(-) diff --git a/dts/configurations/test_run.example.yaml b/dts/configurations/test_run.example.yaml index ee641f5dce..0bd5151801 100644 --- a/dts/configurations/test_run.example.yaml +++ b/dts/configurations/test_run.example.yaml @@ -16,6 +16,8 @@ # `precompiled_build_dir` or `build_options` can be defined, but not both. # `compiler_wrapper`: # Optional, adds a compiler wrapper if present. +# `build_args`: +# The additional build arguments to be used when building DPDK. # `func_traffic_generator` & `perf_traffic_generator`: # Define `func_traffic_generator` when `func` set to true. # Define `perf_traffic_generator` when `perf` set to true. @@ -40,6 +42,17 @@ dpdk: # the combination of the following two makes CC="ccache gcc" compiler: gcc compiler_wrapper: ccache # see `Optional Fields` + # arguments to be used when building DPDK + # build_args: + # c_args: + # - O3 + # - g + # b_coverage: + # - "true" + # buildtype: + # - release + # flags: + # - strip func_traffic_generator: type: SCAPY # perf_traffic_generator: diff --git a/dts/framework/config/test_run.py b/dts/framework/config/test_run.py index 76e24d1785..eab12041fc 100644 --- a/dts/framework/config/test_run.py +++ b/dts/framework/config/test_run.py @@ -191,6 +191,8 @@ class DPDKBuildOptionsConfiguration(FrozenModel): #: This string will be put in front of the compiler when executing the build. Useful for adding #: wrapper commands, such as ``ccache``. compiler_wrapper: str = "" + #: The build arguments to build dpdk with + build_args: dict[str, list[str]] = {} class DPDKUncompiledBuildConfiguration(BaseDPDKBuildConfiguration): diff --git a/dts/framework/remote_session/dpdk.py b/dts/framework/remote_session/dpdk.py index 865f97f6ca..4dc0ceeaaf 100644 --- a/dts/framework/remote_session/dpdk.py +++ b/dts/framework/remote_session/dpdk.py @@ -100,8 +100,8 @@ def setup(self) -> None: match self.config: case DPDKPrecompiledBuildConfiguration(precompiled_build_dir=build_dir): self._set_remote_dpdk_build_dir(build_dir) - case DPDKUncompiledBuildConfiguration(build_options=build_options): - self._configure_dpdk_build(build_options) + case DPDKUncompiledBuildConfiguration(): + self._configure_dpdk_build(self.config.build_options) self._build_dpdk() def teardown(self) -> None: @@ -277,16 +277,20 @@ def _build_dpdk(self) -> None: `remote_dpdk_tree_path` has already been set on the SUT node. """ ctx = get_ctx() + build_options = getattr(self.config, "build_options") # If the SUT is an ice driver device, make sure to build with 16B descriptors. if ( ctx.topology.sut_port_ingress and ctx.topology.sut_port_ingress.config.os_driver == "ice" ): meson_args = MesonArgs( - default_library="static", libdir="lib", c_args="-DRTE_NET_INTEL_USE_16BYTE_DESC" + build_options.build_args, + default_library="static", + libdir="lib", + c_args="-DRTE_NET_INTEL_USE_16BYTE_DESC", ) else: - meson_args = MesonArgs(default_library="static", libdir="lib") + meson_args = MesonArgs(build_options.build_args, default_library="static", libdir="lib") if SETTINGS.code_coverage: meson_args._add_arg("-Db_coverage=true") diff --git a/dts/framework/utils.py b/dts/framework/utils.py index 38da88cd9c..e0ed35066c 100644 --- a/dts/framework/utils.py +++ b/dts/framework/utils.py @@ -99,10 +99,16 @@ class MesonArgs: _default_library: str - def __init__(self, default_library: str | None = None, **dpdk_args: str | bool): + def __init__( + self, + dpdk_build_args: dict[str, list[str]], + default_library: str | None = None, + **dpdk_args: str | bool, + ): """Initialize the meson arguments. Args: + dpdk_build_args: The DPDK build arguments specified in the test run configuration file. default_library: The default library type, Meson supports ``shared``, ``static`` and ``both``. Defaults to :data:`None`, in which case the argument won't be used. dpdk_args: The arguments found in ``meson_options.txt`` in root DPDK directory. @@ -121,6 +127,19 @@ def __init__(self, default_library: str | None = None, **dpdk_args: str | bool): ) ) + arguments = [] + for option, value in dpdk_build_args.items(): + if option == "c_args": + values = " ".join(f"-{val}" for val in value) + arguments.append(f'-D{option}="{values}"') + elif option == "flags": + values = " ".join(f"--{val}" for val in value) + arguments.append(values) + else: + arguments.append(f" -D{option}={value[0]}") + + self._dpdk_args = " ".join(arguments) + def __str__(self) -> str: """The actual args.""" return " ".join(f"{self._default_library} {self._dpdk_args}".split()) -- 2.54.0

