From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id A199043F7C; Thu, 9 May 2024 13:21:33 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 5F8364068E; Thu, 9 May 2024 13:21:16 +0200 (CEST) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mails.dpdk.org (Postfix) with ESMTP id 9E74C402EE for ; Thu, 9 May 2024 13:21:12 +0200 (CEST) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 9E88212FC; Thu, 9 May 2024 04:21:37 -0700 (PDT) Received: from localhost.localdomain (unknown [10.1.194.74]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 780823F6A8; Thu, 9 May 2024 04:21:11 -0700 (PDT) From: Luca Vizzarro To: dev@dpdk.org Cc: =?UTF-8?q?Juraj=20Linke=C5=A1?= , Jeremy Spewock , Luca Vizzarro , Paul Szczepanek Subject: [PATCH v2 3/8] dts: refactor EalParams Date: Thu, 9 May 2024 12:20:52 +0100 Message-Id: <20240509112057.1167947-4-luca.vizzarro@arm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240509112057.1167947-1-luca.vizzarro@arm.com> References: <20240326190422.577028-1-luca.vizzarro@arm.com> <20240509112057.1167947-1-luca.vizzarro@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Move EalParams to its own module to avoid circular dependencies. Signed-off-by: Luca Vizzarro Reviewed-by: Paul Szczepanek --- 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 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 7eced27096..841d456a2f 100644 --- a/dts/framework/remote_session/testpmd_shell.py +++ b/dts/framework/remote_session/testpmd_shell.py @@ -21,8 +21,8 @@ from typing import Callable, ClassVar from framework.exception import InteractiveCommandExecutionError +from framework.params.eal import EalParams 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. -- 2.34.1