[v4,3/8] dts: refactor EalParams

Message ID 20240617144257.61831-4-luca.vizzarro@arm.com (mailing list archive)
State Superseded
Delegated to: Thomas Monjalon
Headers
Series dts: add testpmd params and statefulness |

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Luca Vizzarro June 17, 2024, 2:42 p.m. UTC
  Move EalParams to its own module to avoid circular dependencies.
Also the majority of the attributes are now optional.

Signed-off-by: Luca Vizzarro <luca.vizzarro@arm.com>
Reviewed-by: Paul Szczepanek <paul.szczepanek@arm.com>
Reviewed-by: Juraj Linkeš <juraj.linkes@pantheon.tech>
Reviewed-by: Jeremy Spewock <jspewock@iol.unh.edu>
Reviewed-by: Nicholas Pratte <npratte@iol.unh.edu>
Tested-by: Nicholas Pratte <npratte@iol.unh.edu>
---
 dts/framework/params/eal.py                   | 50 +++++++++++++++++++
 dts/framework/remote_session/testpmd_shell.py |  2 +-
 dts/framework/testbed_model/sut_node.py       | 42 +---------------
 3 files changed, 53 insertions(+), 41 deletions(-)
 create mode 100644 dts/framework/params/eal.py
  

Patch

diff --git a/dts/framework/params/eal.py b/dts/framework/params/eal.py
new file mode 100644
index 0000000000..bbdbc8f334
--- /dev/null
+++ b/dts/framework/params/eal.py
@@ -0,0 +1,50 @@ 
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright(c) 2024 Arm Limited
+
+"""Module representing the DPDK EAL-related parameters."""
+
+from dataclasses import dataclass, field
+from typing import Literal
+
+from framework.params import Params, Switch
+from framework.testbed_model.cpu import LogicalCoreList
+from framework.testbed_model.port import Port
+from framework.testbed_model.virtual_device import VirtualDevice
+
+
+def _port_to_pci(port: Port) -> str:
+    return port.pci
+
+
+@dataclass(kw_only=True)
+class EalParams(Params):
+    """The environment abstraction layer parameters.
+
+    Attributes:
+        lcore_list: The list of logical cores to use.
+        memory_channels: The number of memory channels to use.
+        prefix: Set the file prefix string with which to start DPDK, e.g.: ``prefix="vf"``.
+        no_pci: Switch to disable PCI bus, e.g.: ``no_pci=True``.
+        vdevs: Virtual devices, e.g.::
+            vdevs=[
+                VirtualDevice('net_ring0'),
+                VirtualDevice('net_ring1')
+            ]
+        ports: The list of ports to allow.
+        other_eal_param: user defined DPDK EAL parameters, e.g.:
+                ``other_eal_param='--single-file-segments'``
+    """
+
+    lcore_list: LogicalCoreList = field(metadata=Params.short("l"))
+    memory_channels: int = field(metadata=Params.short("n"))
+    prefix: str = field(metadata=Params.long("file-prefix"))
+    no_pci: Switch = None
+    vdevs: list[VirtualDevice] | None = field(
+        default=None, metadata=Params.multiple() | Params.long("vdev")
+    )
+    ports: list[Port] | None = field(
+        default=None,
+        metadata=Params.convert_value(_port_to_pci) | Params.multiple() | Params.short("a"),
+    )
+    other_eal_param: Params | None = None
+    _separator: Literal[True] = field(default=True, init=False, metadata=Params.short("-"))
diff --git a/dts/framework/remote_session/testpmd_shell.py b/dts/framework/remote_session/testpmd_shell.py
index 2836ed5c48..2b9ef9418d 100644
--- a/dts/framework/remote_session/testpmd_shell.py
+++ b/dts/framework/remote_session/testpmd_shell.py
@@ -26,9 +26,9 @@ 
 from typing_extensions import Self
 
 from framework.exception import InteractiveCommandExecutionError
+from framework.params.eal import EalParams
 from framework.parser import ParserFn, TextParser
 from framework.settings import SETTINGS
-from framework.testbed_model.sut_node import EalParams
 from framework.utils import StrEnum
 
 from .interactive_shell import InteractiveShell
diff --git a/dts/framework/testbed_model/sut_node.py b/dts/framework/testbed_model/sut_node.py
index c886590979..e1163106a3 100644
--- a/dts/framework/testbed_model/sut_node.py
+++ b/dts/framework/testbed_model/sut_node.py
@@ -15,9 +15,8 @@ 
 import os
 import tarfile
 import time
-from dataclasses import dataclass, field
 from pathlib import PurePath
-from typing import Literal, Type
+from typing import Type
 
 from framework.config import (
     BuildTargetConfiguration,
@@ -26,6 +25,7 @@ 
     SutNodeConfiguration,
 )
 from framework.params import Params, Switch
+from framework.params.eal import EalParams
 from framework.remote_session import CommandResult
 from framework.settings import SETTINGS
 from framework.utils import MesonArgs
@@ -37,44 +37,6 @@ 
 from .virtual_device import VirtualDevice
 
 
-def _port_to_pci(port: Port) -> str:
-    return port.pci
-
-
-@dataclass(kw_only=True)
-class EalParams(Params):
-    """The environment abstraction layer parameters.
-
-    Attributes:
-        lcore_list: The list of logical cores to use.
-        memory_channels: The number of memory channels to use.
-        prefix: Set the file prefix string with which to start DPDK, e.g.: ``prefix="vf"``.
-        no_pci: Switch to disable PCI bus, e.g.: ``no_pci=True``.
-        vdevs: Virtual devices, e.g.::
-            vdevs=[
-                VirtualDevice('net_ring0'),
-                VirtualDevice('net_ring1')
-            ]
-        ports: The list of ports to allow.
-        other_eal_param: user defined DPDK EAL parameters, e.g.:
-                ``other_eal_param='--single-file-segments'``
-    """
-
-    lcore_list: LogicalCoreList = field(metadata=Params.short("l"))
-    memory_channels: int = field(metadata=Params.short("n"))
-    prefix: str = field(metadata=Params.long("file-prefix"))
-    no_pci: Switch
-    vdevs: list[VirtualDevice] | None = field(
-        default=None, metadata=Params.multiple() | Params.long("vdev")
-    )
-    ports: list[Port] | None = field(
-        default=None,
-        metadata=Params.convert_value(_port_to_pci) | Params.multiple() | Params.short("a"),
-    )
-    other_eal_param: Params | None = None
-    _separator: Literal[True] = field(default=True, init=False, metadata=Params.short("-"))
-
-
 class SutNode(Node):
     """The system under test node.