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 E4D7A45484; Mon, 17 Jun 2024 16:54:38 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 2E86A40A77; Mon, 17 Jun 2024 16:54:21 +0200 (CEST) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mails.dpdk.org (Postfix) with ESMTP id 27AA04028A for ; Mon, 17 Jun 2024 16:54:19 +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 2C566FEC; Mon, 17 Jun 2024 07:54:43 -0700 (PDT) Received: from localhost.localdomain (unknown [10.57.73.90]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 832543F6A8; Mon, 17 Jun 2024 07:54:17 -0700 (PDT) From: Luca Vizzarro To: dev@dpdk.org Cc: Jeremy Spewock , =?UTF-8?q?Juraj=20Linke=C5=A1?= , Luca Vizzarro , Paul Szczepanek , Nicholas Pratte Subject: [PATCH v5 3/8] dts: refactor EalParams Date: Mon, 17 Jun 2024 15:54:04 +0100 Message-Id: <20240617145409.67407-4-luca.vizzarro@arm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240617145409.67407-1-luca.vizzarro@arm.com> References: <20240326190422.577028-1-luca.vizzarro@arm.com> <20240617145409.67407-1-luca.vizzarro@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 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. Also the majority of the attributes are now optional. Signed-off-by: Luca Vizzarro Reviewed-by: Paul Szczepanek Reviewed-by: Juraj Linkeš Reviewed-by: Jeremy Spewock Reviewed-by: Nicholas Pratte --- 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 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. -- 2.34.1