* [PATCH v1 0/3] dts: add tx_offload support in dts @ 2025-09-02 14:27 Andrew Bailey 2025-09-02 14:27 ` [PATCH v1 1/3] dts: allow mbuf_fast_free to be set with testpmd shell Andrew Bailey ` (4 more replies) 0 siblings, 5 replies; 21+ messages in thread From: Andrew Bailey @ 2025-09-02 14:27 UTC (permalink / raw) To: luca.vizzarro; +Cc: abailey, dev, dmarx, probb This patchset introduces the support for TX offload configuration through DTS, allowing test cases to be written utilizing TX offload capabilities. Along with configuring these capabilities, they are also added to the NIC capabilities class, in which they can be required by test suites. Finally, a test suite was created using the aforementioned changes to update the RX TX offload test suite in legacy DTS. Andrew Bailey (3): dts: allow mbuf_fast_free to be set with testpmd shell dts: add TX offload capabilities to NIC capabilities dts: update tx_offload test from old dts dts/framework/remote_session/testpmd_shell.py | 340 +++++++++++++++++- dts/tests/TestSuite_rxtx_offload.py | 153 ++++++++ 2 files changed, 492 insertions(+), 1 deletion(-) create mode 100644 dts/tests/TestSuite_rxtx_offload.py -- 2.50.1 ^ permalink raw reply [flat|nested] 21+ messages in thread
* [PATCH v1 1/3] dts: allow mbuf_fast_free to be set with testpmd shell 2025-09-02 14:27 [PATCH v1 0/3] dts: add tx_offload support in dts Andrew Bailey @ 2025-09-02 14:27 ` Andrew Bailey 2025-09-02 19:37 ` Ivan Malov 2025-09-02 14:27 ` [PATCH v1 2/3] dts: add TX offload capabilities to NIC capabilities Andrew Bailey ` (3 subsequent siblings) 4 siblings, 1 reply; 21+ messages in thread From: Andrew Bailey @ 2025-09-02 14:27 UTC (permalink / raw) To: luca.vizzarro; +Cc: abailey, dev, dmarx, probb Currently, there is no way in the testpmd shell class to set the mbuf fast free offload configuration for RX or TX ports. This prohibits any test suites to be written utilizing this offload configuration. Additionally, the NIC capabilities for the TX offload are not gathered. This prevents future test suites from being skipped if they do not support a TX offload capability. Introduce methods that support calls to testpmd in order to allow the configuration of mbuf fast free and to gather TX offload capabilities. Signed-off-by: Andrew Bailey <abailey@iol.unh.edu> --- dts/framework/remote_session/testpmd_shell.py | 137 +++++++++++++++++- 1 file changed, 136 insertions(+), 1 deletion(-) diff --git a/dts/framework/remote_session/testpmd_shell.py b/dts/framework/remote_session/testpmd_shell.py index 786714d1c5..91642efec5 100644 --- a/dts/framework/remote_session/testpmd_shell.py +++ b/dts/framework/remote_session/testpmd_shell.py @@ -19,7 +19,7 @@ import time from collections.abc import Callable, MutableSet from dataclasses import dataclass, field -from enum import Flag, auto +from enum import Enum, Flag, auto from os import environ from pathlib import PurePath from typing import TYPE_CHECKING, Any, ClassVar, Concatenate, Literal, ParamSpec, Tuple, TypeAlias @@ -344,6 +344,13 @@ def make_parser(cls) -> ParserFn: ) +class RxTxArgFlag(Enum): + """Enum representing receiving or transmitting ports.""" + + TX = "tx" + RX = "rx" + + class DeviceCapabilitiesFlag(Flag): """Flag representing the device capabilities.""" @@ -2787,6 +2794,134 @@ def get_capabilities_physical_function( else: unsupported_capabilities.add(NicCapability.PHYSICAL_FUNCTION) + @requires_started_ports + def get_rxtx_offload_config( + self, + rxtx: RxTxArgFlag, + verify: bool, + port_id: int = 0, + num_queues: int = 0, + ) -> dict[int | str, str]: + """Get the RX or TX offload configuration of the queues from the given port. + + Args: + rxtx: Whether to get the RX or TX configuration of the given queues. + verify: If :data:'True' the output of the command will be scanned in an attempt to + verify that the offload configuration was retrieved successfully on all queues. + num_queues: The number of queues to get the offload configuration for. + port_id: The port ID that contains the desired queues. + + Returns: + A dict containing port info at key 'port' and queue info keyed by the appropriate queue + id. + + Raises: + InteractiveCommandExecutionError: If all queue offload configurations could not be + retrieved. + + """ + returnDict: dict[int | str, str] = {} + + config_output = self.send_command(f"show port {port_id} {rxtx.value}_offload configuration") + if verify: + if ( + f"Rx Offloading Configuration of port {port_id}" not in config_output + and f"Tx Offloading Configuration of port {port_id}" not in config_output + ): + self._logger.debug(f"Get port offload config error\n{config_output}") + raise InteractiveCommandExecutionError( + f"""Failed to get offload config on port {port_id}:\n{config_output}""" + ) + # Actual output data starts on the thrid line + tempList: list[str] = config_output.splitlines()[3::] + returnDict["port"] = tempList[0] + for i in range(0, num_queues): + returnDict[i] = tempList[i + 1] + return returnDict + + @requires_stopped_ports + def set_port_rxtx_mbuf_fast_free( + self, rxtx: RxTxArgFlag, on: bool, verify: bool, port_id: int = 0 + ) -> None: + """Sets the mbuf_fast_free configuration for the RX or TX offload for a given port. + + Args: + rxtx: Whether to set the mbuf_fast_free on the RX or TX port. + on: If :data:'True' mbuf_fast_free will be enabled, disable it otherwise. + verify: If :data:'True' the output of the command will be scanned in an attempt to + verify that the mbuf_fast_free was set successfully. + port_id: The port number to enable or disable mbuf_fast_free on. + + Raises: + InteractiveCommandExecutionError: If mbuf_fast_free could not be set successfully + """ + mbuf_output = self.send_command( + f"port config {port_id} {rxtx.value}_offload mbuf_fast_free {"on" if on else "off"}" + ) + + if "error" in mbuf_output and verify: + raise InteractiveCommandExecutionError( + f"""Unable to set mbuf_fast_free config on port {port_id}:\n{mbuf_output}""" + ) + + @requires_stopped_ports + def set_queue_rxtx_mbuf_fast_free( + self, + rxtx: RxTxArgFlag, + on: bool, + verify: bool, + port_id: int = 0, + queue_id: int = 0, + ) -> None: + """Sets RX or TX mbuf_fast_free configuration of the specified queue on a given port. + + Args: + rxtx: Whether to set mbuf_fast_free for the RX or TX offload configuration on the + given queues. + on: If :data:'True' the mbuf_fast_free configuration will be enabled, otherwise + disabled. + verify: If :data:'True' the output of the command will be scanned in an attempt to + verify that mbuf_fast_free was set successfully on all ports. + queue_id: The queue to disable mbuf_fast_free on. + port_id: The ID of the port containing the queues. + + Raises: + InteractiveCommandExecutionError: If all queues could not be set successfully. + """ + toggle = "on" if on else "off" + output = self.send_command( + f"port {port_id} {rxtx.value}q {queue_id} {rxtx.value}_offload mbuf_fast_free {toggle}" + ) + if verify: + if "Error" in output: + self._logger.debug(f"Set queue offload config error\n{output}") + raise InteractiveCommandExecutionError( + f"Failed to get offload config on port {port_id}, queue {queue_id}:\n{output}" + ) + + def set_all_queues_rxtx_mbuf_fast_free( + self, + rxtx: RxTxArgFlag, + on: bool, + verify: bool, + port_id=0, + num_queues: int = 0, + ) -> None: + """Sets mbuf_fast_free configuration for the RX or TX offload of all queues on a given port. + + Args: + rxtx: Whether to set mbuf_fast_free for the RX or TX offload configuration on the + given queues. + on: If :data:'True' the mbuf fast_free_configuration will be enabled, otherwise + disabled. + verify: If :data:'True' the output of the command will be scanned in an attempt to + verify that mbuf_fast_free was set successfully on all ports. + port_id: The ID of the port containing the queues. + num_queues: The queue to disable mbuf_fast_free on. + """ + for i in range(0, num_queues): + self.set_queue_rxtx_mbuf_fast_free(rxtx, on, verify, port_id=port_id, queue_id=i) + class NicCapability(NoAliasEnum): """A mapping between capability names and the associated :class:`TestPmdShell` methods. -- 2.50.1 ^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH v1 1/3] dts: allow mbuf_fast_free to be set with testpmd shell 2025-09-02 14:27 ` [PATCH v1 1/3] dts: allow mbuf_fast_free to be set with testpmd shell Andrew Bailey @ 2025-09-02 19:37 ` Ivan Malov 2025-09-02 19:48 ` Ivan Malov 0 siblings, 1 reply; 21+ messages in thread From: Ivan Malov @ 2025-09-02 19:37 UTC (permalink / raw) To: Andrew Bailey; +Cc: luca.vizzarro, dev, dmarx, probb Hi Andrew, On Tue, 2 Sep 2025, Andrew Bailey wrote: > Currently, there is no way in the testpmd shell class to set the mbuf > fast free offload configuration for RX or TX ports. This prohibits any To me, this reads like some ports can be Rx-only while others can be Tx-only, which is a little bit confusing. Also, let's double check that it makes to talk about the 'mbuf fast free offload' in the context of an Rx queue; -- it was my impression that this offload is only applicable to Tx queues, as they are meant to 'reap' mbufs associated with 'done' Tx descriptors. Am I missing something? > test suites to be written utilizing this offload configuration. Additionally, > the NIC capabilities for the TX offload are not gathered. This prevents future > test suites from being skipped if they do not support a TX offload capability. > Introduce methods that support calls to testpmd in order to allow the > configuration of mbuf fast free and to gather TX offload capabilities. This added ability to collect Tx offload capability info is good. One more point to consider: this handles 'mbuf_fast_free' on per-queue level, but if it is valid on port-global level, too, may be one can also cover that. > > Signed-off-by: Andrew Bailey <abailey@iol.unh.edu> > --- > dts/framework/remote_session/testpmd_shell.py | 137 +++++++++++++++++- > 1 file changed, 136 insertions(+), 1 deletion(-) > > diff --git a/dts/framework/remote_session/testpmd_shell.py b/dts/framework/remote_session/testpmd_shell.py > index 786714d1c5..91642efec5 100644 > --- a/dts/framework/remote_session/testpmd_shell.py > +++ b/dts/framework/remote_session/testpmd_shell.py > @@ -19,7 +19,7 @@ > import time > from collections.abc import Callable, MutableSet > from dataclasses import dataclass, field > -from enum import Flag, auto > +from enum import Enum, Flag, auto > from os import environ > from pathlib import PurePath > from typing import TYPE_CHECKING, Any, ClassVar, Concatenate, Literal, ParamSpec, Tuple, TypeAlias > @@ -344,6 +344,13 @@ def make_parser(cls) -> ParserFn: > ) > > > +class RxTxArgFlag(Enum): > + """Enum representing receiving or transmitting ports.""" > + > + TX = "tx" > + RX = "rx" > + > + > class DeviceCapabilitiesFlag(Flag): > """Flag representing the device capabilities.""" > > @@ -2787,6 +2794,134 @@ def get_capabilities_physical_function( > else: > unsupported_capabilities.add(NicCapability.PHYSICAL_FUNCTION) > > + @requires_started_ports > + def get_rxtx_offload_config( > + self, > + rxtx: RxTxArgFlag, > + verify: bool, > + port_id: int = 0, > + num_queues: int = 0, > + ) -> dict[int | str, str]: > + """Get the RX or TX offload configuration of the queues from the given port. > + > + Args: > + rxtx: Whether to get the RX or TX configuration of the given queues. > + verify: If :data:'True' the output of the command will be scanned in an attempt to > + verify that the offload configuration was retrieved successfully on all queues. > + num_queues: The number of queues to get the offload configuration for. > + port_id: The port ID that contains the desired queues. > + > + Returns: > + A dict containing port info at key 'port' and queue info keyed by the appropriate queue > + id. > + > + Raises: > + InteractiveCommandExecutionError: If all queue offload configurations could not be > + retrieved. > + > + """ > + returnDict: dict[int | str, str] = {} > + > + config_output = self.send_command(f"show port {port_id} {rxtx.value}_offload configuration") > + if verify: > + if ( > + f"Rx Offloading Configuration of port {port_id}" not in config_output > + and f"Tx Offloading Configuration of port {port_id}" not in config_output > + ): > + self._logger.debug(f"Get port offload config error\n{config_output}") > + raise InteractiveCommandExecutionError( > + f"""Failed to get offload config on port {port_id}:\n{config_output}""" > + ) > + # Actual output data starts on the thrid line > + tempList: list[str] = config_output.splitlines()[3::] > + returnDict["port"] = tempList[0] > + for i in range(0, num_queues): > + returnDict[i] = tempList[i + 1] > + return returnDict > + > + @requires_stopped_ports > + def set_port_rxtx_mbuf_fast_free( > + self, rxtx: RxTxArgFlag, on: bool, verify: bool, port_id: int = 0 > + ) -> None: > + """Sets the mbuf_fast_free configuration for the RX or TX offload for a given port. > + > + Args: > + rxtx: Whether to set the mbuf_fast_free on the RX or TX port. > + on: If :data:'True' mbuf_fast_free will be enabled, disable it otherwise. > + verify: If :data:'True' the output of the command will be scanned in an attempt to > + verify that the mbuf_fast_free was set successfully. > + port_id: The port number to enable or disable mbuf_fast_free on. > + > + Raises: > + InteractiveCommandExecutionError: If mbuf_fast_free could not be set successfully > + """ > + mbuf_output = self.send_command( > + f"port config {port_id} {rxtx.value}_offload mbuf_fast_free {"on" if on else "off"}" > + ) > + > + if "error" in mbuf_output and verify: > + raise InteractiveCommandExecutionError( > + f"""Unable to set mbuf_fast_free config on port {port_id}:\n{mbuf_output}""" > + ) > + > + @requires_stopped_ports > + def set_queue_rxtx_mbuf_fast_free( > + self, > + rxtx: RxTxArgFlag, So this is questionable. Please see below. > + on: bool, > + verify: bool, > + port_id: int = 0, > + queue_id: int = 0, > + ) -> None: > + """Sets RX or TX mbuf_fast_free configuration of the specified queue on a given port. > + > + Args: > + rxtx: Whether to set mbuf_fast_free for the RX or TX offload configuration on the > + given queues. > + on: If :data:'True' the mbuf_fast_free configuration will be enabled, otherwise > + disabled. > + verify: If :data:'True' the output of the command will be scanned in an attempt to > + verify that mbuf_fast_free was set successfully on all ports. > + queue_id: The queue to disable mbuf_fast_free on. > + port_id: The ID of the port containing the queues. > + > + Raises: > + InteractiveCommandExecutionError: If all queues could not be set successfully. > + """ > + toggle = "on" if on else "off" > + output = self.send_command( > + f"port {port_id} {rxtx.value}q {queue_id} {rxtx.value}_offload mbuf_fast_free {toggle}" For me, on a slightly dated DPDK build, setting this on an Rx queue fails: testpmd> port 0 rxq 0 rx_offload mbuf_fast_free off Bad arguments An equivalent Tx command works, albeit unsupported in my specific circumstances. testpmd> port 0 txq 0 tx_offload mbuf_fast_free off Error: port 0 doesn't support per queue offload: mbuf_fast_free. > + ) > + if verify: > + if "Error" in output: > + self._logger.debug(f"Set queue offload config error\n{output}") > + raise InteractiveCommandExecutionError( > + f"Failed to get offload config on port {port_id}, queue {queue_id}:\n{output}" > + ) > + > + def set_all_queues_rxtx_mbuf_fast_free( > + self, > + rxtx: RxTxArgFlag, > + on: bool, > + verify: bool, > + port_id=0, > + num_queues: int = 0, > + ) -> None: > + """Sets mbuf_fast_free configuration for the RX or TX offload of all queues on a given port. > + > + Args: > + rxtx: Whether to set mbuf_fast_free for the RX or TX offload configuration on the > + given queues. > + on: If :data:'True' the mbuf fast_free_configuration will be enabled, otherwise > + disabled. > + verify: If :data:'True' the output of the command will be scanned in an attempt to > + verify that mbuf_fast_free was set successfully on all ports. > + port_id: The ID of the port containing the queues. > + num_queues: The queue to disable mbuf_fast_free on. While I'm not well-versed in DTS style in general and cannot push to choose some specific naming, I'd say, to me, 'queue_ids' would read less ambiguous. Thank you. > + """ > + for i in range(0, num_queues): > + self.set_queue_rxtx_mbuf_fast_free(rxtx, on, verify, port_id=port_id, queue_id=i) > + > > class NicCapability(NoAliasEnum): > """A mapping between capability names and the associated :class:`TestPmdShell` methods. > -- > 2.50.1 > > ^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH v1 1/3] dts: allow mbuf_fast_free to be set with testpmd shell 2025-09-02 19:37 ` Ivan Malov @ 2025-09-02 19:48 ` Ivan Malov 0 siblings, 0 replies; 21+ messages in thread From: Ivan Malov @ 2025-09-02 19:48 UTC (permalink / raw) To: Andrew Bailey; +Cc: luca.vizzarro, dev, dmarx, probb On Tue, 2 Sep 2025, Ivan Malov wrote: <snip> >> + port_id: The ID of the port containing the queues. >> + num_queues: The queue to disable mbuf_fast_free on. > > While I'm not well-versed in DTS style in general and cannot push to choose > some specific naming, I'd say, to me, 'queue_ids' would read less ambiguous. > Sorry, I now see this is not a queue ID array but the total number of queues. If so, the description should be corrected to say so. Right now it reads like this is a specific queue index. Thank you. ^ permalink raw reply [flat|nested] 21+ messages in thread
* [PATCH v1 2/3] dts: add TX offload capabilities to NIC capabilities 2025-09-02 14:27 [PATCH v1 0/3] dts: add tx_offload support in dts Andrew Bailey 2025-09-02 14:27 ` [PATCH v1 1/3] dts: allow mbuf_fast_free to be set with testpmd shell Andrew Bailey @ 2025-09-02 14:27 ` Andrew Bailey 2025-09-04 14:43 ` Luca Vizzarro 2025-09-02 14:27 ` [PATCH v1 3/3] dts: update tx_offload test from old dts Andrew Bailey ` (2 subsequent siblings) 4 siblings, 1 reply; 21+ messages in thread From: Andrew Bailey @ 2025-09-02 14:27 UTC (permalink / raw) To: luca.vizzarro; +Cc: abailey, dev, dmarx, probb Currently, there is support for tracking the RX offload capabilities of a NIC, but not for TX offload capabilities. This is an issue if a test suite is written requiring one of these capabilities, since there is no way currently to verify that the NIC in use meets the requirements. Add TX capabilities to the NIC capabiltiies at beginning of dts so requirements can be verified. Signed-off-by: Andrew Bailey <abailey@iol.unh.edu> --- dts/framework/remote_session/testpmd_shell.py | 203 ++++++++++++++++++ 1 file changed, 203 insertions(+) diff --git a/dts/framework/remote_session/testpmd_shell.py b/dts/framework/remote_session/testpmd_shell.py index ad8cb273dc..786714d1c5 100644 --- a/dts/framework/remote_session/testpmd_shell.py +++ b/dts/framework/remote_session/testpmd_shell.py @@ -1278,6 +1278,99 @@ class TestPmdVerbosePacket(TextParser): ) +class TxOffloadCapability(Flag): + """TX offload capabilities of a device. + + The flags are taken from ``lib/ethdev/rte_ethdev.h``. + They're prefixed with ``RTE_ETH_TX_OFFLOAD`` in ``lib/ethdev/rte_ethdev.h`` + instead of ``TX_OFFLOAD``, which is what testpmd changes the prefix to. + The values are not contiguous, so the correspondence is preserved + by specifying concrete values interspersed between auto() values. + + The ``TX_OFFLOAD`` prefix has been preserved so that the same flag names can be used + in :class:`NicCapability`. The prefix is needed in :class:`NicCapability` since there's + no other qualifier which would sufficiently distinguish it from other capabilities. + + References: + DPDK lib: ``lib/ethdev/rte_ethdev.h`` + testpmd display function: ``app/test-pmd/cmdline.c:print_rx_offloads()`` + """ + + TX_OFFLOAD_VLAN_INSERT = auto() + TX_OFFLOAD_IPV4_CKSUM = auto() + TX_OFFLOAD_UDP_CKSUM = auto() + TX_OFFLOAD_TCP_CKSUM = auto() + TX_OFFLOAD_SCTP_CKSUM = auto() + TX_OFFLOAD_TCP_TSO = auto() + TX_OFFLOAD_UDP_TSO = auto() + TX_OFFLOAD_OUTER_IPV4_CKSUM = auto() + TX_OFFLOAD_QINQ_INSERT = auto() + TX_OFFLOAD_VXLAN_TNL_TSO = auto() + TX_OFFLOAD_GRE_TNL_TSO = auto() + TX_OFFLOAD_IPIP_TNL_TSO = auto() + TX_OFFLOAD_GENEVE_TNL_TSO = auto() + TX_OFFLOAD_MACSEC_INSERT = auto() + TX_OFFLOAD_MT_LOCKFREE = auto() + TX_OFFLOAD_MULTI_SEGS = auto() + TX_OFFLOAD_MBUF_FAST_FREE = auto() + TX_OFFLOAD_SECURITY = auto() + TX_OFFLOAD_UDP_TNL_TSO = auto() + TX_OFFLOAD_IP_TNL_TSO = auto() + TX_OFFLOAD_OUTER_UDP_CKSUM = auto() + TX_OFFLOAD_SEND_ON_TIMESTAMP = auto() + + @classmethod + def from_string(cls, line: str) -> Self: + """Make an instance from a string containing the flag names separated with a space. + + Args: + line: The line to parse. + + Returns: + A new instance containing all found flags. + """ + flag = cls(0) + for flag_name in line.split(): + flag |= cls[f"TX_OFFLOAD_{flag_name}"] + return flag + + @classmethod + def make_parser(cls, per_port: bool) -> ParserFn: + """Make a parser function. + + Args: + per_port: If :data:`True`, will return capabilities per port. If :data:`False`, + will return capabilities per queue. + + Returns: + ParserFn: A dictionary for the `dataclasses.field` metadata argument containing a + parser function that makes an instance of this flag from text. + """ + granularity = "Port" if per_port else "Queue" + return TextParser.wrap( + TextParser.find(rf"Per {granularity}\s+:(.*)$", re.MULTILINE), + cls.from_string, + ) + + +@dataclass +class TxOffloadCapabilities(TextParser): + """The result of testpmd's ``show port <port_id> tx_offload capabilities`` command. + + References: + testpmd command function: ``app/test-pmd/cmdline.c:cmd_tx_offload_get_capa()`` + testpmd display function: ``app/test-pmd/cmdline.c:cmd_tx_offload_get_capa_parsed()`` + """ + + port_id: int = field( + metadata=TextParser.find_int(r"Tx Offloading Capabilities of port (\d+) :") + ) + #: Per-queue Tx offload capabilities. + per_queue: TxOffloadCapability = field(metadata=TxOffloadCapability.make_parser(False)) + #: Capabilities other than per-queue Tx offload capabilities. + per_port: TxOffloadCapability = field(metadata=TxOffloadCapability.make_parser(True)) + + class RxOffloadCapability(Flag): """Rx offload capabilities of a device. @@ -2390,6 +2483,28 @@ def close(self) -> None: ====== Capability retrieval methods ====== """ + def get_capabilities_tx_offload( + self, + supported_capabilities: MutableSet["NicCapability"], + unsupported_capabilities: MutableSet["NicCapability"], + ) -> None: + """Get all TX offload capabilities and divide them into supported and unsupported. + + Args: + supported_capabilities: Supported capabilities will be added to this set. + unsupported_capabilities: Unsupported capabilities will be added to this set. + """ + self._logger.debug("Getting TX offload capabilities.") + command = f"show port {self.ports[0].id} tx_offload capabilities" + tx_offload_capabilities_out = self.send_command(command) + tx_offload_capabilities = TxOffloadCapabilities.parse(tx_offload_capabilities_out) + self._update_capabilities_from_flag( + supported_capabilities, + unsupported_capabilities, + TxOffloadCapability, + tx_offload_capabilities.per_port | tx_offload_capabilities.per_queue, + ) + def get_capabilities_rx_offload( self, supported_capabilities: MutableSet["NicCapability"], @@ -2698,6 +2813,94 @@ class NicCapability(NoAliasEnum): we don't go looking for it again if a different test case also needs it. """ + TX_OFFLOAD_VLAN_INSERT: TestPmdShellNicCapability = ( + TestPmdShell.get_capabilities_tx_offload, + None, + ) + TX_OFFLOAD_IPV4_CKSUM: TestPmdShellNicCapability = ( + TestPmdShell.get_capabilities_tx_offload, + None, + ) + TX_OFFLOAD_UDP_CKSUM: TestPmdShellNicCapability = ( + TestPmdShell.get_capabilities_tx_offload, + None, + ) + TX_OFFLOAD_TCP_CKSUM: TestPmdShellNicCapability = ( + TestPmdShell.get_capabilities_tx_offload, + None, + ) + TX_OFFLOAD_SCTP_CKSUM: TestPmdShellNicCapability = ( + TestPmdShell.get_capabilities_tx_offload, + None, + ) + TX_OFFLOAD_TCP_TSO: TestPmdShellNicCapability = ( + TestPmdShell.get_capabilities_tx_offload, + None, + ) + TX_OFFLOAD_UDP_TSO: TestPmdShellNicCapability = ( + TestPmdShell.get_capabilities_tx_offload, + None, + ) + TX_OFFLOAD_OUTER_IPV4_CKSUM: TestPmdShellNicCapability = ( + TestPmdShell.get_capabilities_tx_offload, + None, + ) + TX_OFFLOAD_QINQ_INSERT: TestPmdShellNicCapability = ( + TestPmdShell.get_capabilities_tx_offload, + None, + ) + TX_OFFLOAD_VXLAN_TNL_TSO: TestPmdShellNicCapability = ( + TestPmdShell.get_capabilities_tx_offload, + None, + ) + TX_OFFLOAD_GRE_TNL_TSO: TestPmdShellNicCapability = ( + TestPmdShell.get_capabilities_tx_offload, + None, + ) + TX_OFFLOAD_IPIP_TNL_TSO: TestPmdShellNicCapability = ( + TestPmdShell.get_capabilities_tx_offload, + None, + ) + TX_OFFLOAD_GENEVE_TNL_TSO: TestPmdShellNicCapability = ( + TestPmdShell.get_capabilities_tx_offload, + None, + ) + TX_OFFLOAD_MACSEC_INSERT: TestPmdShellNicCapability = ( + TestPmdShell.get_capabilities_tx_offload, + None, + ) + TX_OFFLOAD_MT_LOCKFREE: TestPmdShellNicCapability = ( + TestPmdShell.get_capabilities_tx_offload, + None, + ) + TX_OFFLOAD_MULTI_SEGS: TestPmdShellNicCapability = ( + TestPmdShell.get_capabilities_tx_offload, + None, + ) + TX_OFFLOAD_MBUF_FAST_FREE: TestPmdShellNicCapability = ( + TestPmdShell.get_capabilities_tx_offload, + None, + ) + TX_OFFLOAD_SECURITY: TestPmdShellNicCapability = ( + TestPmdShell.get_capabilities_tx_offload, + None, + ) + TX_OFFLOAD_UDP_TNL_TSO: TestPmdShellNicCapability = ( + TestPmdShell.get_capabilities_tx_offload, + None, + ) + TX_OFFLOAD_IP_TNL_TSO: TestPmdShellNicCapability = ( + TestPmdShell.get_capabilities_tx_offload, + None, + ) + TX_OFFLOAD_OUTER_UDP_CKSUM: TestPmdShellNicCapability = ( + TestPmdShell.get_capabilities_tx_offload, + None, + ) + TX_OFFLOAD_SEND_ON_TIMESTAMP: TestPmdShellNicCapability = ( + TestPmdShell.get_capabilities_tx_offload, + None, + ) #: Scattered packets Rx enabled SCATTERED_RX_ENABLED: TestPmdShellNicCapability = ( TestPmdShell.get_capabilities_rxq_info, -- 2.50.1 ^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH v1 2/3] dts: add TX offload capabilities to NIC capabilities 2025-09-02 14:27 ` [PATCH v1 2/3] dts: add TX offload capabilities to NIC capabilities Andrew Bailey @ 2025-09-04 14:43 ` Luca Vizzarro 2025-09-04 14:45 ` Luca Vizzarro 0 siblings, 1 reply; 21+ messages in thread From: Luca Vizzarro @ 2025-09-04 14:43 UTC (permalink / raw) To: Andrew Bailey; +Cc: dev, dmarx, probb Hi Andrew, thank you for your patches! On Tue, Sep 02, 2025 at 10:27:24AM +0000, Andrew Bailey wrote: > diff --git a/dts/framework/remote_session/testpmd_shell.py b/dts/framework/remote_session/testpmd_shell.py > index ad8cb273dc..786714d1c5 100644 > --- a/dts/framework/remote_session/testpmd_shell.py > +++ b/dts/framework/remote_session/testpmd_shell.py > @@ -1278,6 +1278,99 @@ class TestPmdVerbosePacket(TextParser): > ) > > > +class TxOffloadCapability(Flag): > + """TX offload capabilities of a device. > + > + The flags are taken from ``lib/ethdev/rte_ethdev.h``. > + They're prefixed with ``RTE_ETH_TX_OFFLOAD`` in ``lib/ethdev/rte_ethdev.h`` > + instead of ``TX_OFFLOAD``, which is what testpmd changes the prefix to. > + The values are not contiguous, so the correspondence is preserved > + by specifying concrete values interspersed between auto() values. > + > + The ``TX_OFFLOAD`` prefix has been preserved so that the same flag names can be used > + in :class:`NicCapability`. The prefix is needed in :class:`NicCapability` since there's > + no other qualifier which would sufficiently distinguish it from other capabilities. > + > + References: > + DPDK lib: ``lib/ethdev/rte_ethdev.h`` > + testpmd display function: ``app/test-pmd/cmdline.c:print_rx_offloads()`` > + """ > + > + TX_OFFLOAD_VLAN_INSERT = auto() > + TX_OFFLOAD_IPV4_CKSUM = auto() > + TX_OFFLOAD_UDP_CKSUM = auto() > + TX_OFFLOAD_TCP_CKSUM = auto() > + TX_OFFLOAD_SCTP_CKSUM = auto() > + TX_OFFLOAD_TCP_TSO = auto() > + TX_OFFLOAD_UDP_TSO = auto() > + TX_OFFLOAD_OUTER_IPV4_CKSUM = auto() > + TX_OFFLOAD_QINQ_INSERT = auto() > + TX_OFFLOAD_VXLAN_TNL_TSO = auto() > + TX_OFFLOAD_GRE_TNL_TSO = auto() > + TX_OFFLOAD_IPIP_TNL_TSO = auto() > + TX_OFFLOAD_GENEVE_TNL_TSO = auto() > + TX_OFFLOAD_MACSEC_INSERT = auto() > + TX_OFFLOAD_MT_LOCKFREE = auto() > + TX_OFFLOAD_MULTI_SEGS = auto() > + TX_OFFLOAD_MBUF_FAST_FREE = auto() > + TX_OFFLOAD_SECURITY = auto() > + TX_OFFLOAD_UDP_TNL_TSO = auto() > + TX_OFFLOAD_IP_TNL_TSO = auto() > + TX_OFFLOAD_OUTER_UDP_CKSUM = auto() > + TX_OFFLOAD_SEND_ON_TIMESTAMP = auto() > + > + @classmethod > + def from_string(cls, line: str) -> Self: > + """Make an instance from a string containing the flag names separated with a space. > + > + Args: > + line: The line to parse. > + > + Returns: > + A new instance containing all found flags. > + """ > + flag = cls(0) > + for flag_name in line.split(): > + flag |= cls[f"TX_OFFLOAD_{flag_name}"] > + return flag > + > + @classmethod > + def make_parser(cls, per_port: bool) -> ParserFn: > + """Make a parser function. > + > + Args: > + per_port: If :data:`True`, will return capabilities per port. If :data:`False`, > + will return capabilities per queue. > + > + Returns: > + ParserFn: A dictionary for the `dataclasses.field` metadata argument containing a > + parser function that makes an instance of this flag from text. > + """ > + granularity = "Port" if per_port else "Queue" > + return TextParser.wrap( > + TextParser.find(rf"Per {granularity}\s+:(.*)$", re.MULTILINE), > + cls.from_string, > + ) The above is creating a lot of duplication. I'd personally implement the functions in a class that the flags RxOffload and TxOffload can inherit from. You can deal with `cls[f"TX_OFFLOAD_{flag_name}"]` by introducing a "PREFIX" ClassVar for all the classes where you can specify it: PREFIX: ClassVar[str] = "TX_OFFLOAD_" ... cls[f"{cls.PREFIX}{flag_name}"] ^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH v1 2/3] dts: add TX offload capabilities to NIC capabilities 2025-09-04 14:43 ` Luca Vizzarro @ 2025-09-04 14:45 ` Luca Vizzarro 0 siblings, 0 replies; 21+ messages in thread From: Luca Vizzarro @ 2025-09-04 14:45 UTC (permalink / raw) To: Andrew Bailey; +Cc: dev, dmarx, probb whoops! I was meant to reply to the v2 patch. The same applies though. ^ permalink raw reply [flat|nested] 21+ messages in thread
* [PATCH v1 3/3] dts: update tx_offload test from old dts 2025-09-02 14:27 [PATCH v1 0/3] dts: add tx_offload support in dts Andrew Bailey 2025-09-02 14:27 ` [PATCH v1 1/3] dts: allow mbuf_fast_free to be set with testpmd shell Andrew Bailey 2025-09-02 14:27 ` [PATCH v1 2/3] dts: add TX offload capabilities to NIC capabilities Andrew Bailey @ 2025-09-02 14:27 ` Andrew Bailey 2025-09-03 18:04 ` [PATCH v2 0/3] dts: add tx_offlaod support in dts Andrew Bailey 2025-09-17 12:42 ` [PATCH v3 0/3] dts: add tx_offload support in dts Andrew Bailey 4 siblings, 0 replies; 21+ messages in thread From: Andrew Bailey @ 2025-09-02 14:27 UTC (permalink / raw) To: luca.vizzarro; +Cc: abailey, dev, dmarx, probb Currently, the RX/TX offload test in old DTS expects the TX ports to be initially configured to use mbuf fast free. This is no longer the case and must be updated to assume mbuf fast free is not initially utilized by capable NICs. Add updated test suite to test mbuf fast free configuration. Signed-off-by: Andrew Bailey <abailey@iol.unh.edu> --- dts/tests/TestSuite_rxtx_offload.py | 153 ++++++++++++++++++++++++++++ 1 file changed, 153 insertions(+) create mode 100644 dts/tests/TestSuite_rxtx_offload.py diff --git a/dts/tests/TestSuite_rxtx_offload.py b/dts/tests/TestSuite_rxtx_offload.py new file mode 100644 index 0000000000..f4a51a5eed --- /dev/null +++ b/dts/tests/TestSuite_rxtx_offload.py @@ -0,0 +1,153 @@ +# Copyright(c) 2025 University of New Hampshire + +"""RX TX offload test suite. + +Test the testpmd feature of configuring RX and TX offloads +""" + +from framework.remote_session.testpmd_shell import ( + NicCapability, + RxTxArgFlag, + TestPmdShell, +) +from framework.test_suite import TestSuite, func_test +from framework.testbed_model.capability import requires + + +@requires(NicCapability.TX_OFFLOAD_MBUF_FAST_FREE) +class TestRxTxOffload(TestSuite): + """RX/TX offload test suite.""" + + def check_port_config( + self, + testpmd: TestPmdShell, + offload: str, + rxtx: RxTxArgFlag, + verify: bool, + port_id: int = 0, + ) -> bool: + """Checks that the current port configuration matches the given offload. + + Args: + testpmd: The currrent testpmd shell session to send commands to. + offload: The expected configuration of the given port. + rxtx: Whether to check the RX or TX configuration of the given port. + verify: Whether to verify the result of call to testpmd. + port_id: Id of the port to check. + + Returns: + Whether current configuration matches given offload. + """ + output = testpmd.get_rxtx_offload_config(rxtx, verify, port_id, 0) + return offload in output["port"] or ( + offload == "NULL" and "MBUF_FAST_FREE" not in output["port"] + ) + + def check_queue_config( + self, + testpmd: TestPmdShell, + offload: list[str], + rxtx: RxTxArgFlag, + verify: bool, + port_id: int = 0, + num_queues: int = 0, + ) -> bool: + """Checks that the queue configuration matches the given offload. + + Args: + testpmd: The currrent testpmd shell session to send commands to. + offload: The expected configuration of the queues, each index corresponds + to the queue id. + rxtx: Whether to check the RX or TX configuration of the given queues. + verify: Whether to verify commands sent to testpmd. + port_id: The port of which the queues reside. + num_queues: The number of queues to check. + + Returns: + Whether current configuration matches given offload + """ + output = testpmd.get_rxtx_offload_config(rxtx, verify, port_id, num_queues) + for i in range(0, num_queues): + if not ( + offload[i] in output[i] + or (offload[i] == "NULL" and "MBUF_FAST_FREE" not in output[i]) + ): + return False + return True + + @func_test + def test_mbuf_fast_free_configurations(self) -> None: + """Ensure mbuf_fast_free can be configured with testpmd. + + Steps: + Start up testpmd shell. + Toggle mbuf_fast_free on. + Toggle mbuf_fast_free off. + + Verify: + Mbuf_fast_free starts disabled. + Mbuf_fast_free can be configured on. + Mbuf_fast_free can be configured off. + """ + with TestPmdShell() as testpmd: + verify: bool = True + port_id: int = 0 + num_queues: int = 4 + queue_off: list[str] = [] + queue_on: list[str] = [] + mbuf_on = "MBUF_FAST_FREE" + mbuf_off = "NULL" + tx = RxTxArgFlag.TX + + for _ in range(0, num_queues): + queue_off.append(mbuf_off) + queue_on.append(mbuf_on) + + testpmd.set_ports_queues(num_queues) + testpmd.start_all_ports() + + # Ensure mbuf_fast_free is disabled by default on port and queues + self.verify( + self.check_port_config(testpmd, mbuf_off, tx, verify, port_id), + "Mbuf_fast_free enabled on port start", + ) + self.verify( + self.check_queue_config(testpmd, queue_off, tx, verify, port_id, num_queues), + "Mbuf_fast_free enabled on queue start", + ) + + # Enable mbuf_fast_free per queue and verify + testpmd.set_all_queues_rxtx_mbuf_fast_free(tx, True, verify, port_id, num_queues) + self.verify( + self.check_port_config(testpmd, mbuf_off, tx, verify, port_id), + "Port configuration changed without call", + ) + self.verify( + self.check_queue_config(testpmd, queue_on, tx, verify, port_id, num_queues), + "Queues failed to enable mbuf_fast_free", + ) + + # Enable mbuf_fast_free per port and verify + testpmd.set_port_rxtx_mbuf_fast_free(tx, True, verify, port_id) + self.verify( + self.check_port_config(testpmd, mbuf_on, tx, verify, port_id), + "Port failed to enable mbuf_fast_free", + ) + + # Disable mbuf_fast_free per queue and verify + testpmd.set_all_queues_rxtx_mbuf_fast_free(tx, False, verify, port_id, num_queues) + self.verify( + self.check_port_config(testpmd, mbuf_on, tx, verify, port_id), + "Port configuration changed without call", + ) + self.verify( + self.check_queue_config(testpmd, queue_off, tx, verify, port_id, num_queues), + "Queues failed to disable mbuf_fast_free", + ) + + # Disable mbuf_fast_free per port and verify + testpmd.set_port_rxtx_mbuf_fast_free(tx, False, verify, port_id) + self.verify( + self.check_port_config(testpmd, mbuf_off, tx, verify, port_id), + "Port failed to disable mbuf_fast_free", + ) -- 2.50.1 ^ permalink raw reply [flat|nested] 21+ messages in thread
* [PATCH v2 0/3] dts: add tx_offlaod support in dts 2025-09-02 14:27 [PATCH v1 0/3] dts: add tx_offload support in dts Andrew Bailey ` (2 preceding siblings ...) 2025-09-02 14:27 ` [PATCH v1 3/3] dts: update tx_offload test from old dts Andrew Bailey @ 2025-09-03 18:04 ` Andrew Bailey 2025-09-03 18:04 ` [PATCH v2 1/3] dts: allow mbuf_fast_free to be set with testpmd shell Andrew Bailey ` (2 more replies) 2025-09-17 12:42 ` [PATCH v3 0/3] dts: add tx_offload support in dts Andrew Bailey 4 siblings, 3 replies; 21+ messages in thread From: Andrew Bailey @ 2025-09-03 18:04 UTC (permalink / raw) To: luca.vizzarro; +Cc: abailey, dev, dmarx, ivan.malov, probb This patchset introduces the support for Tx offload configuration through DTS, allowing test cases to be written utilizing Tx offload capabilities. Along with configuring these capabilities, they are also added to the NIC capabilities class, in which they can be required by test suites. Finally, a test suite was created using the aforementioned changes to update the Rx\Tx offload test suite in legacy DTS. --- v2: * Removed mentions of mbuf_fast_free being configured for Rx queues/ports as this is not accurate behaviour. * Clarify argument descriptions in docstrings. Signed-off-by: Andrew Bailey <abailey@iol.unh.edu> Andrew Bailey (3): dts: allow mbuf_fast_free to be set with testpmd shell dts: add TX offload capabilities to NIC capabilities dts: update tx_offload test from old dts dts/framework/remote_session/testpmd_shell.py | 333 +++++++++++++++++- dts/tests/TestSuite_rxtx_offload.py | 150 ++++++++ 2 files changed, 482 insertions(+), 1 deletion(-) create mode 100644 dts/tests/TestSuite_rxtx_offload.py -- 2.50.1 ^ permalink raw reply [flat|nested] 21+ messages in thread
* [PATCH v2 1/3] dts: allow mbuf_fast_free to be set with testpmd shell 2025-09-03 18:04 ` [PATCH v2 0/3] dts: add tx_offlaod support in dts Andrew Bailey @ 2025-09-03 18:04 ` Andrew Bailey 2025-09-04 15:15 ` Luca Vizzarro 2025-09-03 18:04 ` [PATCH v2 2/3] dts: add TX offload capabilities to NIC capabilities Andrew Bailey 2025-09-03 18:04 ` [PATCH v2 3/3] dts: update tx_offload test from old dts Andrew Bailey 2 siblings, 1 reply; 21+ messages in thread From: Andrew Bailey @ 2025-09-03 18:04 UTC (permalink / raw) To: luca.vizzarro; +Cc: abailey, dev, dmarx, ivan.malov, probb Currently, there is no way in the testpmd shell class to set the mbuf fast free offload configuration for queues or ports. This prohibits any test suites to be written utilizing this offload configuration. Additionally, the NIC capabilities for the Tx offload are not gathered. This prevents future test suites from being skipped if they do not support a Tx offload capability. Introduce methods that support calls to testpmd in order to allow the configuration of mbuf fast free and to gather Tx offload capabilities. Signed-off-by: Andrew Bailey <abailey@iol.unh.edu> --- dts/framework/remote_session/testpmd_shell.py | 128 +++++++++++++++++- 1 file changed, 127 insertions(+), 1 deletion(-) diff --git a/dts/framework/remote_session/testpmd_shell.py b/dts/framework/remote_session/testpmd_shell.py index ad8cb273dc..4d9caceb37 100644 --- a/dts/framework/remote_session/testpmd_shell.py +++ b/dts/framework/remote_session/testpmd_shell.py @@ -19,7 +19,7 @@ import time from collections.abc import Callable, MutableSet from dataclasses import dataclass, field -from enum import Flag, auto +from enum import Enum, Flag, auto from os import environ from pathlib import PurePath from typing import TYPE_CHECKING, Any, ClassVar, Concatenate, Literal, ParamSpec, Tuple, TypeAlias @@ -344,6 +344,13 @@ def make_parser(cls) -> ParserFn: ) +class RxTxArgFlag(Enum): + """Enum representing receiving or transmitting ports.""" + + TX = "tx" + RX = "rx" + + class DeviceCapabilitiesFlag(Flag): """Flag representing the device capabilities.""" @@ -2672,6 +2679,125 @@ def get_capabilities_physical_function( else: unsupported_capabilities.add(NicCapability.PHYSICAL_FUNCTION) + @requires_started_ports + def get_rxtx_offload_config( + self, + rxtx: RxTxArgFlag, + verify: bool, + port_id: int = 0, + num_queues: int = 0, + ) -> dict[int | str, str]: + """Get the Rx or Tx offload configuration of the queues from the given port. + + Args: + rxtx: Whether to get the Rx or Tx configuration of the given queues. + verify: If :data:'True' the output of the command will be scanned in an attempt to + verify that the offload configuration was retrieved successfully on all queues. + port_id: The port ID that contains the desired queues. + num_queues: The number of queues to get the offload configuration for. + + Returns: + A dict containing port info at key 'port' and queue info keyed by the appropriate queue + id. + + Raises: + InteractiveCommandExecutionError: If all queue offload configurations could not be + retrieved. + + """ + returnDict: dict[int | str, str] = {} + + config_output = self.send_command(f"show port {port_id} {rxtx.value}_offload configuration") + if verify: + if ( + f"Rx Offloading Configuration of port {port_id}" not in config_output + and f"Tx Offloading Configuration of port {port_id}" not in config_output + ): + self._logger.debug(f"Get port offload config error\n{config_output}") + raise InteractiveCommandExecutionError( + f"""Failed to get offload config on port {port_id}:\n{config_output}""" + ) + # Actual output data starts on the third line + tempList: list[str] = config_output.splitlines()[3::] + returnDict["port"] = tempList[0] + for i in range(0, num_queues): + returnDict[i] = tempList[i + 1] + return returnDict + + @requires_stopped_ports + def set_port_mbuf_fast_free(self, on: bool, verify: bool, port_id: int = 0) -> None: + """Sets the mbuf_fast_free configuration for the Tx offload for a given port. + + Args: + on: If :data:'True' mbuf_fast_free will be enabled, disable it otherwise. + verify: If :data:'True' the output of the command will be scanned in an attempt to + verify that the mbuf_fast_free was set successfully. + port_id: The port number to enable or disable mbuf_fast_free on. + + Raises: + InteractiveCommandExecutionError: If mbuf_fast_free could not be set successfully + """ + mbuf_output = self.send_command( + f"port config {port_id} tx_offload mbuf_fast_free {"on" if on else "off"}" + ) + + if "error" in mbuf_output and verify: + raise InteractiveCommandExecutionError( + f"""Unable to set mbuf_fast_free config on port {port_id}:\n{mbuf_output}""" + ) + + @requires_stopped_ports + def set_queue_mbuf_fast_free( + self, + on: bool, + verify: bool, + port_id: int = 0, + queue_id: int = 0, + ) -> None: + """Sets the Tx mbuf_fast_free configuration of the specified queue on a given port. + + Args: + on: If :data:'True' the mbuf_fast_free configuration will be enabled, otherwise + disabled. + verify: If :data:'True' the output of the command will be scanned in an attempt to + verify that mbuf_fast_free was set successfully on all ports. + port_id: The ID of the port containing the queues. + queue_id: The queue to disable mbuf_fast_free on. + + Raises: + InteractiveCommandExecutionError: If all queues could not be set successfully. + """ + toggle = "on" if on else "off" + output = self.send_command( + f"port {port_id} txq {queue_id} tx_offload mbuf_fast_free {toggle}" + ) + if verify: + if "Error" in output: + self._logger.debug(f"Set queue offload config error\n{output}") + raise InteractiveCommandExecutionError( + f"Failed to get offload config on port {port_id}, queue {queue_id}:\n{output}" + ) + + def set_all_queues_mbuf_fast_free( + self, + on: bool, + verify: bool, + port_id=0, + num_queues: int = 0, + ) -> None: + """Sets mbuf_fast_free configuration for the Tx offload of all queues on a given port. + + Args: + on: If :data:'True' the mbuf_fast_free configuration will be enabled, otherwise + disabled. + verify: If :data:'True' the output of the command will be scanned in an attempt to + verify that mbuf_fast_free was set successfully on all ports. + port_id: The ID of the port containing the queues. + num_queues: The amount of queues to disable mbuf_fast_free on. + """ + for i in range(0, num_queues): + self.set_queue_mbuf_fast_free(on, verify, port_id=port_id, queue_id=i) + class NicCapability(NoAliasEnum): """A mapping between capability names and the associated :class:`TestPmdShell` methods. -- 2.50.1 ^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH v2 1/3] dts: allow mbuf_fast_free to be set with testpmd shell 2025-09-03 18:04 ` [PATCH v2 1/3] dts: allow mbuf_fast_free to be set with testpmd shell Andrew Bailey @ 2025-09-04 15:15 ` Luca Vizzarro 2025-09-04 21:18 ` Patrick Robb 0 siblings, 1 reply; 21+ messages in thread From: Luca Vizzarro @ 2025-09-04 15:15 UTC (permalink / raw) To: Andrew Bailey; +Cc: dev, dmarx, ivan.malov, probb On Wed, Sep 03, 2025 at 02:04:12PM +0000, Andrew Bailey wrote: > diff --git a/dts/framework/remote_session/testpmd_shell.py b/dts/framework/remote_session/testpmd_shell.py > index ad8cb273dc..4d9caceb37 100644 > --- a/dts/framework/remote_session/testpmd_shell.py > +++ b/dts/framework/remote_session/testpmd_shell.py > @@ -19,7 +19,7 @@ > import time > from collections.abc import Callable, MutableSet > from dataclasses import dataclass, field > -from enum import Flag, auto > +from enum import Enum, Flag, auto > from os import environ > from pathlib import PurePath > from typing import TYPE_CHECKING, Any, ClassVar, Concatenate, Literal, ParamSpec, Tuple, TypeAlias > @@ -344,6 +344,13 @@ def make_parser(cls) -> ParserFn: > ) > > > +class RxTxArgFlag(Enum): this could be StrEnum given the values used. Moreover, is it a flag? Looks like a regular enum to me. > + """Enum representing receiving or transmitting ports.""" > + > + TX = "tx" > + RX = "rx" > + > + > class DeviceCapabilitiesFlag(Flag): > """Flag representing the device capabilities.""" > > @@ -2672,6 +2679,125 @@ def get_capabilities_physical_function( > else: > unsupported_capabilities.add(NicCapability.PHYSICAL_FUNCTION) > > + @requires_started_ports > + def get_rxtx_offload_config( if we are considering rxtx as two words, they should be split by _ > + self, > + rxtx: RxTxArgFlag, as above. If the whole purpose of the Enum is just a switch for the argument, you can consider using a Literal instead, it'll be easier to write from a user perspective as well: RxTxLiteralSwitch = Literal["rx", "tx"] ... get_rx_tx_offload_config("rx") This also makes me question whether we need rx_tx at all in the name of the method. > + verify: bool, We've made verify an optional argument across the board, should be the same here. > + port_id: int = 0, I would also *not* make port_id optional. For the sake of readability when using, you can split rx_tx from port_id using a /. This will determine the end of positional arguments, therefore making anything after mandatory keyword arguments. > + num_queues: int = 0, > + ) -> dict[int | str, str]: This return type looks like it needs a dedicated data structure. > + """Get the Rx or Tx offload configuration of the queues from the given port. > + > + Args: > + rxtx: Whether to get the Rx or Tx configuration of the given queues. > + verify: If :data:'True' the output of the command will be scanned in an attempt to Any RST directives need backticks: :data:`True` > + verify that the offload configuration was retrieved successfully on all queues. > + port_id: The port ID that contains the desired queues. > + num_queues: The number of queues to get the offload configuration for. > + > + Returns: > + A dict containing port info at key 'port' and queue info keyed by the appropriate queue > + id. Keys cannot be enforced by mypy with a generic dict. Consider using a NamedDict or a dataclass appropriately. > + > + Raises: > + InteractiveCommandExecutionError: If all queue offload configurations could not be > + retrieved. > + extra empty line shouldn't be here. > + """ > + returnDict: dict[int | str, str] = {} snake_case notation is used for variables. > + > + config_output = self.send_command(f"show port {port_id} {rxtx.value}_offload configuration") > + if verify: > + if ( > + f"Rx Offloading Configuration of port {port_id}" not in config_output > + and f"Tx Offloading Configuration of port {port_id}" not in config_output > + ): > + self._logger.debug(f"Get port offload config error\n{config_output}") > + raise InteractiveCommandExecutionError( > + f"""Failed to get offload config on port {port_id}:\n{config_output}""" No need to use multi-line quotes for a single line. > + ) > + # Actual output data starts on the third line > + tempList: list[str] = config_output.splitlines()[3::] > + returnDict["port"] = tempList[0] > + for i in range(0, num_queues): > + returnDict[i] = tempList[i + 1] Looks like an occasion to use a TextParser for the return data structure. > + return returnDict > + > + @requires_stopped_ports > + def set_port_mbuf_fast_free(self, on: bool, verify: bool, port_id: int = 0) -> None: Similar situation for port_id and verify as above. > + """Sets the mbuf_fast_free configuration for the Tx offload for a given port. > + > + Args: > + on: If :data:'True' mbuf_fast_free will be enabled, disable it otherwise. backticks instead of single quotes > + verify: If :data:'True' the output of the command will be scanned in an attempt to backticks instead of single quotes > + verify that the mbuf_fast_free was set successfully. > + port_id: The port number to enable or disable mbuf_fast_free on. > + > + Raises: > + InteractiveCommandExecutionError: If mbuf_fast_free could not be set successfully missed full stop at the end. > + """ > + mbuf_output = self.send_command( > + f"port config {port_id} tx_offload mbuf_fast_free {"on" if on else "off"}" > + ) > + > + if "error" in mbuf_output and verify: This is not really that important but you may always want to check for the boolean first as that will spare doing a text search if set to False. Writing it like this is generally better: if verify and "error" in mbuf_output: > + raise InteractiveCommandExecutionError( > + f"""Unable to set mbuf_fast_free config on port {port_id}:\n{mbuf_output}""" multi-line quotes in single line string. > + ) > + > + @requires_stopped_ports > + def set_queue_mbuf_fast_free( > + self, > + on: bool, > + verify: bool, > + port_id: int = 0, > + queue_id: int = 0, > + ) -> None: same discussion for verify, port_id and queue_id. > + """Sets the Tx mbuf_fast_free configuration of the specified queue on a given port. > + > + Args: > + on: If :data:'True' the mbuf_fast_free configuration will be enabled, otherwise backticks instead of single quotes > + disabled. > + verify: If :data:'True' the output of the command will be scanned in an attempt to backticks instead of single quotes > + verify that mbuf_fast_free was set successfully on all ports. > + port_id: The ID of the port containing the queues. > + queue_id: The queue to disable mbuf_fast_free on. > + > + Raises: > + InteractiveCommandExecutionError: If all queues could not be set successfully. > + """ > + toggle = "on" if on else "off" > + output = self.send_command( > + f"port {port_id} txq {queue_id} tx_offload mbuf_fast_free {toggle}" > + ) > + if verify: > + if "Error" in output: the two conditions could be merged together, and it will read easier requiring one level less of indentation. > + self._logger.debug(f"Set queue offload config error\n{output}") > + raise InteractiveCommandExecutionError( > + f"Failed to get offload config on port {port_id}, queue {queue_id}:\n{output}" > + ) > + > + def set_all_queues_mbuf_fast_free( > + self, > + on: bool, > + verify: bool, > + port_id=0, > + num_queues: int = 0, > + ) -> None: same discussion for the args. > + """Sets mbuf_fast_free configuration for the Tx offload of all queues on a given port. > + > + Args: > + on: If :data:'True' the mbuf_fast_free configuration will be enabled, otherwise backticks instead of single quotes > + disabled. > + verify: If :data:'True' the output of the command will be scanned in an attempt to backticks instead of single quotes > + verify that mbuf_fast_free was set successfully on all ports. > + port_id: The ID of the port containing the queues. > + num_queues: The amount of queues to disable mbuf_fast_free on. > + """ > + for i in range(0, num_queues): > + self.set_queue_mbuf_fast_free(on, verify, port_id=port_id, queue_id=i) So far we have been mostly replicating the testpmd functionality. I am wondering if this is actually needed to be implemented on the TestPmdShell side. > + > > class NicCapability(NoAliasEnum): > """A mapping between capability names and the associated :class:`TestPmdShell` methods. > -- > 2.50.1 > ^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH v2 1/3] dts: allow mbuf_fast_free to be set with testpmd shell 2025-09-04 15:15 ` Luca Vizzarro @ 2025-09-04 21:18 ` Patrick Robb 0 siblings, 0 replies; 21+ messages in thread From: Patrick Robb @ 2025-09-04 21:18 UTC (permalink / raw) To: Luca Vizzarro; +Cc: Andrew Bailey, dev, dmarx, ivan.malov [-- Attachment #1: Type: text/plain, Size: 1219 bytes --] On Thu, Sep 4, 2025 at 11:16 AM Luca Vizzarro <luca.vizzarro@arm.com> wrote: > On Wed, Sep 03, 2025 at 02:04:12PM +0000, Andrew Bailey wrote: > > diff --git a/dts/framework/remote_session/testpmd_shell.py > b/dts/framework/remote_session/testpmd_shell.py > > index ad8cb273dc..4d9caceb37 100644 > > --- a/dts/framework/remote_session/testpmd_shell.py > > +++ b/dts/framework/remote_session/testpmd_shell.py > > @@ -19,7 +19,7 @@ > > import time > > from collections.abc import Callable, MutableSet > > from dataclasses import dataclass, field > > -from enum import Flag, auto > > +from enum import Enum, Flag, auto > > from os import environ > > from pathlib import PurePath > > from typing import TYPE_CHECKING, Any, ClassVar, Concatenate, Literal, > ParamSpec, Tuple, TypeAlias > > @@ -344,6 +344,13 @@ def make_parser(cls) -> ParserFn: > > ) > > > > > > +class RxTxArgFlag(Enum): > > this could be StrEnum given the values used. Moreover, is it a > flag? Looks like a regular enum to me. > I was wondering the same but no, by my understanding it's currently an enum or StrEnum and I can't see us adding additional attributes in the future so that won't be changing. [-- Attachment #2: Type: text/html, Size: 1701 bytes --] ^ permalink raw reply [flat|nested] 21+ messages in thread
* [PATCH v2 2/3] dts: add TX offload capabilities to NIC capabilities 2025-09-03 18:04 ` [PATCH v2 0/3] dts: add tx_offlaod support in dts Andrew Bailey 2025-09-03 18:04 ` [PATCH v2 1/3] dts: allow mbuf_fast_free to be set with testpmd shell Andrew Bailey @ 2025-09-03 18:04 ` Andrew Bailey 2025-09-03 18:36 ` Patrick Robb 2025-09-04 14:47 ` Luca Vizzarro 2025-09-03 18:04 ` [PATCH v2 3/3] dts: update tx_offload test from old dts Andrew Bailey 2 siblings, 2 replies; 21+ messages in thread From: Andrew Bailey @ 2025-09-03 18:04 UTC (permalink / raw) To: luca.vizzarro; +Cc: abailey, dev, dmarx, ivan.malov, probb Currently, there is support for tracking the Rx offload capabilities of a NIC, but not for Tx offload capabilities. This is an issue if a test suite is written requiring one of these capabilities, since there is no way currently to verify that the NIC in use meets the requirements. Add Tx capabilities to the NIC capabilities at beginning of dts so requirements can be verified. Signed-off-by: Andrew Bailey <abailey@iol.unh.edu> --- dts/framework/remote_session/testpmd_shell.py | 203 ++++++++++++++++++ 1 file changed, 203 insertions(+) diff --git a/dts/framework/remote_session/testpmd_shell.py b/dts/framework/remote_session/testpmd_shell.py index 4d9caceb37..dfd83ebdb3 100644 --- a/dts/framework/remote_session/testpmd_shell.py +++ b/dts/framework/remote_session/testpmd_shell.py @@ -1285,6 +1285,99 @@ class TestPmdVerbosePacket(TextParser): ) +class TxOffloadCapability(Flag): + """TX offload capabilities of a device. + + The flags are taken from ``lib/ethdev/rte_ethdev.h``. + They're prefixed with ``RTE_ETH_TX_OFFLOAD`` in ``lib/ethdev/rte_ethdev.h`` + instead of ``TX_OFFLOAD``, which is what testpmd changes the prefix to. + The values are not contiguous, so the correspondence is preserved + by specifying concrete values interspersed between auto() values. + + The ``TX_OFFLOAD`` prefix has been preserved so that the same flag names can be used + in :class:`NicCapability`. The prefix is needed in :class:`NicCapability` since there's + no other qualifier which would sufficiently distinguish it from other capabilities. + + References: + DPDK lib: ``lib/ethdev/rte_ethdev.h`` + testpmd display function: ``app/test-pmd/cmdline.c:print_rx_offloads()`` + """ + + TX_OFFLOAD_VLAN_INSERT = auto() + TX_OFFLOAD_IPV4_CKSUM = auto() + TX_OFFLOAD_UDP_CKSUM = auto() + TX_OFFLOAD_TCP_CKSUM = auto() + TX_OFFLOAD_SCTP_CKSUM = auto() + TX_OFFLOAD_TCP_TSO = auto() + TX_OFFLOAD_UDP_TSO = auto() + TX_OFFLOAD_OUTER_IPV4_CKSUM = auto() + TX_OFFLOAD_QINQ_INSERT = auto() + TX_OFFLOAD_VXLAN_TNL_TSO = auto() + TX_OFFLOAD_GRE_TNL_TSO = auto() + TX_OFFLOAD_IPIP_TNL_TSO = auto() + TX_OFFLOAD_GENEVE_TNL_TSO = auto() + TX_OFFLOAD_MACSEC_INSERT = auto() + TX_OFFLOAD_MT_LOCKFREE = auto() + TX_OFFLOAD_MULTI_SEGS = auto() + TX_OFFLOAD_MBUF_FAST_FREE = auto() + TX_OFFLOAD_SECURITY = auto() + TX_OFFLOAD_UDP_TNL_TSO = auto() + TX_OFFLOAD_IP_TNL_TSO = auto() + TX_OFFLOAD_OUTER_UDP_CKSUM = auto() + TX_OFFLOAD_SEND_ON_TIMESTAMP = auto() + + @classmethod + def from_string(cls, line: str) -> Self: + """Make an instance from a string containing the flag names separated with a space. + + Args: + line: The line to parse. + + Returns: + A new instance containing all found flags. + """ + flag = cls(0) + for flag_name in line.split(): + flag |= cls[f"TX_OFFLOAD_{flag_name}"] + return flag + + @classmethod + def make_parser(cls, per_port: bool) -> ParserFn: + """Make a parser function. + + Args: + per_port: If :data:`True`, will return capabilities per port. If :data:`False`, + will return capabilities per queue. + + Returns: + ParserFn: A dictionary for the `dataclasses.field` metadata argument containing a + parser function that makes an instance of this flag from text. + """ + granularity = "Port" if per_port else "Queue" + return TextParser.wrap( + TextParser.find(rf"Per {granularity}\s+:(.*)$", re.MULTILINE), + cls.from_string, + ) + + +@dataclass +class TxOffloadCapabilities(TextParser): + """The result of testpmd's ``show port <port_id> tx_offload capabilities`` command. + + References: + testpmd command function: ``app/test-pmd/cmdline.c:cmd_tx_offload_get_capa()`` + testpmd display function: ``app/test-pmd/cmdline.c:cmd_tx_offload_get_capa_parsed()`` + """ + + port_id: int = field( + metadata=TextParser.find_int(r"Tx Offloading Capabilities of port (\d+) :") + ) + #: Per-queue Tx offload capabilities. + per_queue: TxOffloadCapability = field(metadata=TxOffloadCapability.make_parser(False)) + #: Capabilities other than per-queue Tx offload capabilities. + per_port: TxOffloadCapability = field(metadata=TxOffloadCapability.make_parser(True)) + + class RxOffloadCapability(Flag): """Rx offload capabilities of a device. @@ -2397,6 +2490,28 @@ def close(self) -> None: ====== Capability retrieval methods ====== """ + def get_capabilities_tx_offload( + self, + supported_capabilities: MutableSet["NicCapability"], + unsupported_capabilities: MutableSet["NicCapability"], + ) -> None: + """Get all TX offload capabilities and divide them into supported and unsupported. + + Args: + supported_capabilities: Supported capabilities will be added to this set. + unsupported_capabilities: Unsupported capabilities will be added to this set. + """ + self._logger.debug("Getting TX offload capabilities.") + command = f"show port {self.ports[0].id} tx_offload capabilities" + tx_offload_capabilities_out = self.send_command(command) + tx_offload_capabilities = TxOffloadCapabilities.parse(tx_offload_capabilities_out) + self._update_capabilities_from_flag( + supported_capabilities, + unsupported_capabilities, + TxOffloadCapability, + tx_offload_capabilities.per_port | tx_offload_capabilities.per_queue, + ) + def get_capabilities_rx_offload( self, supported_capabilities: MutableSet["NicCapability"], @@ -2824,6 +2939,94 @@ class NicCapability(NoAliasEnum): we don't go looking for it again if a different test case also needs it. """ + TX_OFFLOAD_VLAN_INSERT: TestPmdShellNicCapability = ( + TestPmdShell.get_capabilities_tx_offload, + None, + ) + TX_OFFLOAD_IPV4_CKSUM: TestPmdShellNicCapability = ( + TestPmdShell.get_capabilities_tx_offload, + None, + ) + TX_OFFLOAD_UDP_CKSUM: TestPmdShellNicCapability = ( + TestPmdShell.get_capabilities_tx_offload, + None, + ) + TX_OFFLOAD_TCP_CKSUM: TestPmdShellNicCapability = ( + TestPmdShell.get_capabilities_tx_offload, + None, + ) + TX_OFFLOAD_SCTP_CKSUM: TestPmdShellNicCapability = ( + TestPmdShell.get_capabilities_tx_offload, + None, + ) + TX_OFFLOAD_TCP_TSO: TestPmdShellNicCapability = ( + TestPmdShell.get_capabilities_tx_offload, + None, + ) + TX_OFFLOAD_UDP_TSO: TestPmdShellNicCapability = ( + TestPmdShell.get_capabilities_tx_offload, + None, + ) + TX_OFFLOAD_OUTER_IPV4_CKSUM: TestPmdShellNicCapability = ( + TestPmdShell.get_capabilities_tx_offload, + None, + ) + TX_OFFLOAD_QINQ_INSERT: TestPmdShellNicCapability = ( + TestPmdShell.get_capabilities_tx_offload, + None, + ) + TX_OFFLOAD_VXLAN_TNL_TSO: TestPmdShellNicCapability = ( + TestPmdShell.get_capabilities_tx_offload, + None, + ) + TX_OFFLOAD_GRE_TNL_TSO: TestPmdShellNicCapability = ( + TestPmdShell.get_capabilities_tx_offload, + None, + ) + TX_OFFLOAD_IPIP_TNL_TSO: TestPmdShellNicCapability = ( + TestPmdShell.get_capabilities_tx_offload, + None, + ) + TX_OFFLOAD_GENEVE_TNL_TSO: TestPmdShellNicCapability = ( + TestPmdShell.get_capabilities_tx_offload, + None, + ) + TX_OFFLOAD_MACSEC_INSERT: TestPmdShellNicCapability = ( + TestPmdShell.get_capabilities_tx_offload, + None, + ) + TX_OFFLOAD_MT_LOCKFREE: TestPmdShellNicCapability = ( + TestPmdShell.get_capabilities_tx_offload, + None, + ) + TX_OFFLOAD_MULTI_SEGS: TestPmdShellNicCapability = ( + TestPmdShell.get_capabilities_tx_offload, + None, + ) + TX_OFFLOAD_MBUF_FAST_FREE: TestPmdShellNicCapability = ( + TestPmdShell.get_capabilities_tx_offload, + None, + ) + TX_OFFLOAD_SECURITY: TestPmdShellNicCapability = ( + TestPmdShell.get_capabilities_tx_offload, + None, + ) + TX_OFFLOAD_UDP_TNL_TSO: TestPmdShellNicCapability = ( + TestPmdShell.get_capabilities_tx_offload, + None, + ) + TX_OFFLOAD_IP_TNL_TSO: TestPmdShellNicCapability = ( + TestPmdShell.get_capabilities_tx_offload, + None, + ) + TX_OFFLOAD_OUTER_UDP_CKSUM: TestPmdShellNicCapability = ( + TestPmdShell.get_capabilities_tx_offload, + None, + ) + TX_OFFLOAD_SEND_ON_TIMESTAMP: TestPmdShellNicCapability = ( + TestPmdShell.get_capabilities_tx_offload, + None, + ) #: Scattered packets Rx enabled SCATTERED_RX_ENABLED: TestPmdShellNicCapability = ( TestPmdShell.get_capabilities_rxq_info, -- 2.50.1 ^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH v2 2/3] dts: add TX offload capabilities to NIC capabilities 2025-09-03 18:04 ` [PATCH v2 2/3] dts: add TX offload capabilities to NIC capabilities Andrew Bailey @ 2025-09-03 18:36 ` Patrick Robb 2025-09-04 14:47 ` Luca Vizzarro 1 sibling, 0 replies; 21+ messages in thread From: Patrick Robb @ 2025-09-03 18:36 UTC (permalink / raw) To: Andrew Bailey; +Cc: luca.vizzarro, dev, dmarx, ivan.malov [-- Attachment #1: Type: text/plain, Size: 10187 bytes --] On Wed, Sep 3, 2025 at 2:04 PM Andrew Bailey <abailey@iol.unh.edu> wrote: > Currently, there is support for tracking the Rx offload capabilities of > a NIC, but not for Tx offload capabilities. This is an issue if a test > suite is written requiring one of these capabilities, since there is no > way currently to verify that the NIC in use meets the requirements. Add > Tx capabilities to the NIC capabilities at beginning of dts so > requirements can be verified. > > Signed-off-by: Andrew Bailey <abailey@iol.unh.edu> > --- > dts/framework/remote_session/testpmd_shell.py | 203 ++++++++++++++++++ > 1 file changed, 203 insertions(+) > > diff --git a/dts/framework/remote_session/testpmd_shell.py > b/dts/framework/remote_session/testpmd_shell.py > index 4d9caceb37..dfd83ebdb3 100644 > --- a/dts/framework/remote_session/testpmd_shell.py > +++ b/dts/framework/remote_session/testpmd_shell.py > @@ -1285,6 +1285,99 @@ class TestPmdVerbosePacket(TextParser): > ) > > > +class TxOffloadCapability(Flag): > + """TX offload capabilities of a device. > + > + The flags are taken from ``lib/ethdev/rte_ethdev.h``. > + They're prefixed with ``RTE_ETH_TX_OFFLOAD`` in > ``lib/ethdev/rte_ethdev.h`` > + instead of ``TX_OFFLOAD``, which is what testpmd changes the prefix > to. > + The values are not contiguous, so the correspondence is preserved > + by specifying concrete values interspersed between auto() values. > afaik only rx_offloads specify concrete values. It looks like these flags are all auto(). > + > + The ``TX_OFFLOAD`` prefix has been preserved so that the same flag > names can be used > + in :class:`NicCapability`. The prefix is needed in > :class:`NicCapability` since there's > + no other qualifier which would sufficiently distinguish it from other > capabilities. > + > + References: > + DPDK lib: ``lib/ethdev/rte_ethdev.h`` > + testpmd display function: > ``app/test-pmd/cmdline.c:print_rx_offloads()`` > + """ > + > + TX_OFFLOAD_VLAN_INSERT = auto() > + TX_OFFLOAD_IPV4_CKSUM = auto() > + TX_OFFLOAD_UDP_CKSUM = auto() > + TX_OFFLOAD_TCP_CKSUM = auto() > + TX_OFFLOAD_SCTP_CKSUM = auto() > + TX_OFFLOAD_TCP_TSO = auto() > + TX_OFFLOAD_UDP_TSO = auto() > + TX_OFFLOAD_OUTER_IPV4_CKSUM = auto() > + TX_OFFLOAD_QINQ_INSERT = auto() > + TX_OFFLOAD_VXLAN_TNL_TSO = auto() > + TX_OFFLOAD_GRE_TNL_TSO = auto() > + TX_OFFLOAD_IPIP_TNL_TSO = auto() > + TX_OFFLOAD_GENEVE_TNL_TSO = auto() > + TX_OFFLOAD_MACSEC_INSERT = auto() > + TX_OFFLOAD_MT_LOCKFREE = auto() > + TX_OFFLOAD_MULTI_SEGS = auto() > + TX_OFFLOAD_MBUF_FAST_FREE = auto() > + TX_OFFLOAD_SECURITY = auto() > + TX_OFFLOAD_UDP_TNL_TSO = auto() > + TX_OFFLOAD_IP_TNL_TSO = auto() > + TX_OFFLOAD_OUTER_UDP_CKSUM = auto() > + TX_OFFLOAD_SEND_ON_TIMESTAMP = auto() > + > + @classmethod > + def from_string(cls, line: str) -> Self: > + """Make an instance from a string containing the flag names > separated with a space. > + > + Args: > + line: The line to parse. > + > + Returns: > + A new instance containing all found flags. > + """ > + flag = cls(0) > + for flag_name in line.split(): > + flag |= cls[f"TX_OFFLOAD_{flag_name}"] > + return flag > + > + @classmethod > + def make_parser(cls, per_port: bool) -> ParserFn: > + """Make a parser function. > + > + Args: > + per_port: If :data:`True`, will return capabilities per port. > If :data:`False`, > + will return capabilities per queue. > + > + Returns: > + ParserFn: A dictionary for the `dataclasses.field` metadata > argument containing a > + parser function that makes an instance of this flag from > text. > + """ > + granularity = "Port" if per_port else "Queue" > + return TextParser.wrap( > + TextParser.find(rf"Per {granularity}\s+:(.*)$", re.MULTILINE), > + cls.from_string, > + ) > + > + > +@dataclass > +class TxOffloadCapabilities(TextParser): > + """The result of testpmd's ``show port <port_id> tx_offload > capabilities`` command. > + > + References: > + testpmd command function: > ``app/test-pmd/cmdline.c:cmd_tx_offload_get_capa()`` > + testpmd display function: > ``app/test-pmd/cmdline.c:cmd_tx_offload_get_capa_parsed()`` > + """ > + > + port_id: int = field( > + metadata=TextParser.find_int(r"Tx Offloading Capabilities of port > (\d+) :") > + ) > + #: Per-queue Tx offload capabilities. > + per_queue: TxOffloadCapability = > field(metadata=TxOffloadCapability.make_parser(False)) > + #: Capabilities other than per-queue Tx offload capabilities. > + per_port: TxOffloadCapability = > field(metadata=TxOffloadCapability.make_parser(True)) > + > + > class RxOffloadCapability(Flag): > """Rx offload capabilities of a device. > > @@ -2397,6 +2490,28 @@ def close(self) -> None: > ====== Capability retrieval methods ====== > """ > > + def get_capabilities_tx_offload( > + self, > + supported_capabilities: MutableSet["NicCapability"], > + unsupported_capabilities: MutableSet["NicCapability"], > + ) -> None: > + """Get all TX offload capabilities and divide them into supported > and unsupported. > + > + Args: > + supported_capabilities: Supported capabilities will be added > to this set. > + unsupported_capabilities: Unsupported capabilities will be > added to this set. > + """ > + self._logger.debug("Getting TX offload capabilities.") > + command = f"show port {self.ports[0].id} tx_offload capabilities" > + tx_offload_capabilities_out = self.send_command(command) > + tx_offload_capabilities = > TxOffloadCapabilities.parse(tx_offload_capabilities_out) > + self._update_capabilities_from_flag( > + supported_capabilities, > + unsupported_capabilities, > + TxOffloadCapability, > + tx_offload_capabilities.per_port | > tx_offload_capabilities.per_queue, > + ) > + > def get_capabilities_rx_offload( > self, > supported_capabilities: MutableSet["NicCapability"], > @@ -2824,6 +2939,94 @@ class NicCapability(NoAliasEnum): > we don't go looking for it again if a different test case also needs > it. > """ > > + TX_OFFLOAD_VLAN_INSERT: TestPmdShellNicCapability = ( > + TestPmdShell.get_capabilities_tx_offload, > + None, > + ) > + TX_OFFLOAD_IPV4_CKSUM: TestPmdShellNicCapability = ( > + TestPmdShell.get_capabilities_tx_offload, > + None, > + ) > + TX_OFFLOAD_UDP_CKSUM: TestPmdShellNicCapability = ( > + TestPmdShell.get_capabilities_tx_offload, > + None, > + ) > + TX_OFFLOAD_TCP_CKSUM: TestPmdShellNicCapability = ( > + TestPmdShell.get_capabilities_tx_offload, > + None, > + ) > + TX_OFFLOAD_SCTP_CKSUM: TestPmdShellNicCapability = ( > + TestPmdShell.get_capabilities_tx_offload, > + None, > + ) > + TX_OFFLOAD_TCP_TSO: TestPmdShellNicCapability = ( > + TestPmdShell.get_capabilities_tx_offload, > + None, > + ) > + TX_OFFLOAD_UDP_TSO: TestPmdShellNicCapability = ( > + TestPmdShell.get_capabilities_tx_offload, > + None, > + ) > + TX_OFFLOAD_OUTER_IPV4_CKSUM: TestPmdShellNicCapability = ( > + TestPmdShell.get_capabilities_tx_offload, > + None, > + ) > + TX_OFFLOAD_QINQ_INSERT: TestPmdShellNicCapability = ( > + TestPmdShell.get_capabilities_tx_offload, > + None, > + ) > + TX_OFFLOAD_VXLAN_TNL_TSO: TestPmdShellNicCapability = ( > + TestPmdShell.get_capabilities_tx_offload, > + None, > + ) > + TX_OFFLOAD_GRE_TNL_TSO: TestPmdShellNicCapability = ( > + TestPmdShell.get_capabilities_tx_offload, > + None, > + ) > + TX_OFFLOAD_IPIP_TNL_TSO: TestPmdShellNicCapability = ( > + TestPmdShell.get_capabilities_tx_offload, > + None, > + ) > + TX_OFFLOAD_GENEVE_TNL_TSO: TestPmdShellNicCapability = ( > + TestPmdShell.get_capabilities_tx_offload, > + None, > + ) > + TX_OFFLOAD_MACSEC_INSERT: TestPmdShellNicCapability = ( > + TestPmdShell.get_capabilities_tx_offload, > + None, > + ) > + TX_OFFLOAD_MT_LOCKFREE: TestPmdShellNicCapability = ( > + TestPmdShell.get_capabilities_tx_offload, > + None, > + ) > + TX_OFFLOAD_MULTI_SEGS: TestPmdShellNicCapability = ( > + TestPmdShell.get_capabilities_tx_offload, > + None, > + ) > + TX_OFFLOAD_MBUF_FAST_FREE: TestPmdShellNicCapability = ( > + TestPmdShell.get_capabilities_tx_offload, > + None, > + ) > + TX_OFFLOAD_SECURITY: TestPmdShellNicCapability = ( > + TestPmdShell.get_capabilities_tx_offload, > + None, > + ) > + TX_OFFLOAD_UDP_TNL_TSO: TestPmdShellNicCapability = ( > + TestPmdShell.get_capabilities_tx_offload, > + None, > + ) > + TX_OFFLOAD_IP_TNL_TSO: TestPmdShellNicCapability = ( > + TestPmdShell.get_capabilities_tx_offload, > + None, > + ) > + TX_OFFLOAD_OUTER_UDP_CKSUM: TestPmdShellNicCapability = ( > + TestPmdShell.get_capabilities_tx_offload, > + None, > + ) > + TX_OFFLOAD_SEND_ON_TIMESTAMP: TestPmdShellNicCapability = ( > + TestPmdShell.get_capabilities_tx_offload, > + None, > + ) > #: Scattered packets Rx enabled > SCATTERED_RX_ENABLED: TestPmdShellNicCapability = ( > TestPmdShell.get_capabilities_rxq_info, > -- > 2.50.1 > > Looks good. Have you verified the docs will build from this patch? If you haven't done this yet it's meson setup my_build ninja -C my_build doc Reviewed-by: Patrick Robb <probb@iol.unh.edu> [-- Attachment #2: Type: text/html, Size: 12276 bytes --] ^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH v2 2/3] dts: add TX offload capabilities to NIC capabilities 2025-09-03 18:04 ` [PATCH v2 2/3] dts: add TX offload capabilities to NIC capabilities Andrew Bailey 2025-09-03 18:36 ` Patrick Robb @ 2025-09-04 14:47 ` Luca Vizzarro 1 sibling, 0 replies; 21+ messages in thread From: Luca Vizzarro @ 2025-09-04 14:47 UTC (permalink / raw) To: Andrew Bailey; +Cc: dev, dmarx, ivan.malov, probb Copying reply from v1. On Wed, Sep 03, 2025 at 02:04:13PM +0000, Andrew Bailey wrote: > diff --git a/dts/framework/remote_session/testpmd_shell.py b/dts/framework/remote_session/testpmd_shell.py > index 4d9caceb37..dfd83ebdb3 100644 > --- a/dts/framework/remote_session/testpmd_shell.py > +++ b/dts/framework/remote_session/testpmd_shell.py > @@ -1285,6 +1285,99 @@ class TestPmdVerbosePacket(TextParser): > ) > > > +class TxOffloadCapability(Flag): > + """TX offload capabilities of a device. > + > + The flags are taken from ``lib/ethdev/rte_ethdev.h``. > + They're prefixed with ``RTE_ETH_TX_OFFLOAD`` in ``lib/ethdev/rte_ethdev.h`` > + instead of ``TX_OFFLOAD``, which is what testpmd changes the prefix to. > + The values are not contiguous, so the correspondence is preserved > + by specifying concrete values interspersed between auto() values. > + > + The ``TX_OFFLOAD`` prefix has been preserved so that the same flag names can be used > + in :class:`NicCapability`. The prefix is needed in :class:`NicCapability` since there's > + no other qualifier which would sufficiently distinguish it from other capabilities. > + > + References: > + DPDK lib: ``lib/ethdev/rte_ethdev.h`` > + testpmd display function: ``app/test-pmd/cmdline.c:print_rx_offloads()`` > + """ > + > + TX_OFFLOAD_VLAN_INSERT = auto() > + TX_OFFLOAD_IPV4_CKSUM = auto() > + TX_OFFLOAD_UDP_CKSUM = auto() > + TX_OFFLOAD_TCP_CKSUM = auto() > + TX_OFFLOAD_SCTP_CKSUM = auto() > + TX_OFFLOAD_TCP_TSO = auto() > + TX_OFFLOAD_UDP_TSO = auto() > + TX_OFFLOAD_OUTER_IPV4_CKSUM = auto() > + TX_OFFLOAD_QINQ_INSERT = auto() > + TX_OFFLOAD_VXLAN_TNL_TSO = auto() > + TX_OFFLOAD_GRE_TNL_TSO = auto() > + TX_OFFLOAD_IPIP_TNL_TSO = auto() > + TX_OFFLOAD_GENEVE_TNL_TSO = auto() > + TX_OFFLOAD_MACSEC_INSERT = auto() > + TX_OFFLOAD_MT_LOCKFREE = auto() > + TX_OFFLOAD_MULTI_SEGS = auto() > + TX_OFFLOAD_MBUF_FAST_FREE = auto() > + TX_OFFLOAD_SECURITY = auto() > + TX_OFFLOAD_UDP_TNL_TSO = auto() > + TX_OFFLOAD_IP_TNL_TSO = auto() > + TX_OFFLOAD_OUTER_UDP_CKSUM = auto() > + TX_OFFLOAD_SEND_ON_TIMESTAMP = auto() > + > + @classmethod > + def from_string(cls, line: str) -> Self: > + """Make an instance from a string containing the flag names separated with a space. > + > + Args: > + line: The line to parse. > + > + Returns: > + A new instance containing all found flags. > + """ > + flag = cls(0) > + for flag_name in line.split(): > + flag |= cls[f"TX_OFFLOAD_{flag_name}"] > + return flag > + > + @classmethod > + def make_parser(cls, per_port: bool) -> ParserFn: > + """Make a parser function. > + > + Args: > + per_port: If :data:`True`, will return capabilities per port. If :data:`False`, > + will return capabilities per queue. > + > + Returns: > + ParserFn: A dictionary for the `dataclasses.field` metadata argument containing a > + parser function that makes an instance of this flag from text. > + """ > + granularity = "Port" if per_port else "Queue" > + return TextParser.wrap( > + TextParser.find(rf"Per {granularity}\s+:(.*)$", re.MULTILINE), > + cls.from_string, > + ) The above is creating a lot of duplication. I'd personally implement the functions in a class that the flags RxOffload and TxOffload can inherit from. You can deal with `cls[f"TX_OFFLOAD_{flag_name}"]` by introducing a "PREFIX" ClassVar for all the classes where you can specify it: PREFIX: ClassVar[str] = "TX_OFFLOAD_" ... cls[f"{cls.PREFIX}{flag_name}"] ^ permalink raw reply [flat|nested] 21+ messages in thread
* [PATCH v2 3/3] dts: update tx_offload test from old dts 2025-09-03 18:04 ` [PATCH v2 0/3] dts: add tx_offlaod support in dts Andrew Bailey 2025-09-03 18:04 ` [PATCH v2 1/3] dts: allow mbuf_fast_free to be set with testpmd shell Andrew Bailey 2025-09-03 18:04 ` [PATCH v2 2/3] dts: add TX offload capabilities to NIC capabilities Andrew Bailey @ 2025-09-03 18:04 ` Andrew Bailey 2025-09-04 15:25 ` Luca Vizzarro 2 siblings, 1 reply; 21+ messages in thread From: Andrew Bailey @ 2025-09-03 18:04 UTC (permalink / raw) To: luca.vizzarro; +Cc: abailey, dev, dmarx, ivan.malov, probb Currently, the Rx/Tx offload test in old DTS expects the Tx ports to be initially configured to use mbuf fast free. This is no longer the case and must be updated to assume mbuf fast free is not initially utilized by capable NICs. Add updated test suite to test mbuf fast free configuration. Signed-off-by: Andrew Bailey <abailey@iol.unh.edu> --- dts/tests/TestSuite_rxtx_offload.py | 148 ++++++++++++++++++++++++++++ 1 file changed, 148 insertions(+) create mode 100644 dts/tests/TestSuite_rxtx_offload.py diff --git a/dts/tests/TestSuite_rxtx_offload.py b/dts/tests/TestSuite_rxtx_offload.py new file mode 100644 index 0000000000..133994d795 --- /dev/null +++ b/dts/tests/TestSuite_rxtx_offload.py @@ -0,0 +1,148 @@ +# Copyright(c) 2025 University of New Hampshire + +"""Rx Tx offload test suite. + +Test the testpmd feature of configuring Rx and Tx offloads +""" + +from framework.remote_session.testpmd_shell import ( + NicCapability, + RxTxArgFlag, + TestPmdShell, +) +from framework.test_suite import TestSuite, func_test +from framework.testbed_model.capability import requires + + +@requires(NicCapability.TX_OFFLOAD_MBUF_FAST_FREE) +class TestRxTxOffload(TestSuite): + """RX/TX offload test suite.""" + + def check_port_config( + self, + testpmd: TestPmdShell, + offload: str, + verify: bool, + port_id: int = 0, + ) -> bool: + """Checks that the current port configuration matches the given offload. + + Args: + testpmd: The current testpmd shell session to send commands to. + offload: The expected configuration of the given port. + verify: Whether to verify the result of call to testpmd. + port_id: Id of the port to check. + + Returns: + Whether current configuration matches given offload. + """ + output = testpmd.get_rxtx_offload_config(RxTxArgFlag.TX, verify, port_id, 0) + return offload in output["port"] or ( + offload == "NULL" and "MBUF_FAST_FREE" not in output["port"] + ) + + def check_queue_config( + self, + testpmd: TestPmdShell, + offload: list[str], + verify: bool, + port_id: int = 0, + num_queues: int = 0, + ) -> bool: + """Checks that the queue configuration matches the given offload. + + Args: + testpmd: The current testpmd shell session to send commands to. + offload: The expected configuration of the queues, each index corresponds + to the queue id. + verify: Whether to verify commands sent to testpmd. + port_id: The port of which the queues reside. + num_queues: The number of queues to check. + + Returns: + Whether current configuration matches given offload + """ + output = testpmd.get_rxtx_offload_config(RxTxArgFlag.TX, verify, port_id, num_queues) + for i in range(0, num_queues): + if not ( + offload[i] in output[i] + or (offload[i] == "NULL" and "MBUF_FAST_FREE" not in output[i]) + ): + return False + return True + + @func_test + def test_mbuf_fast_free_configurations(self) -> None: + """Ensure mbuf_fast_free can be configured with testpmd. + + Steps: + Start up testpmd shell. + Toggle mbuf_fast_free on. + Toggle mbuf_fast_free off. + + Verify: + Mbuf_fast_free starts disabled. + Mbuf_fast_free can be configured on. + Mbuf_fast_free can be configured off. + """ + with TestPmdShell() as testpmd: + verify: bool = True + port_id: int = 0 + num_queues: int = 4 + queue_off: list[str] = [] + queue_on: list[str] = [] + mbuf_on = "MBUF_FAST_FREE" + mbuf_off = "NULL" + + for _ in range(0, num_queues): + queue_off.append(mbuf_off) + queue_on.append(mbuf_on) + + testpmd.set_ports_queues(num_queues) + testpmd.start_all_ports() + + # Ensure mbuf_fast_free is disabled by default on port and queues + self.verify( + self.check_port_config(testpmd, mbuf_off, verify, port_id), + "Mbuf_fast_free enabled on port start", + ) + self.verify( + self.check_queue_config(testpmd, queue_off, verify, port_id, num_queues), + "Mbuf_fast_free enabled on queue start", + ) + + # Enable mbuf_fast_free per queue and verify + testpmd.set_all_queues_mbuf_fast_free(True, verify, port_id, num_queues) + self.verify( + self.check_port_config(testpmd, mbuf_off, verify, port_id), + "Port configuration changed without call", + ) + self.verify( + self.check_queue_config(testpmd, queue_on, verify, port_id, num_queues), + "Queues failed to enable mbuf_fast_free", + ) + + # Enable mbuf_fast_free per port and verify + testpmd.set_port_mbuf_fast_free(True, verify, port_id) + self.verify( + self.check_port_config(testpmd, mbuf_on, verify, port_id), + "Port failed to enable mbuf_fast_free", + ) + + # Disable mbuf_fast_free per queue and verify + testpmd.set_all_queues_mbuf_fast_free(False, verify, port_id, num_queues) + self.verify( + self.check_port_config(testpmd, mbuf_on, verify, port_id), + "Port configuration changed without call", + ) + self.verify( + self.check_queue_config(testpmd, queue_off, verify, port_id, num_queues), + "Queues failed to disable mbuf_fast_free", + ) + + # Disable mbuf_fast_free per port and verify + testpmd.set_port_mbuf_fast_free(False, verify, port_id) + self.verify( + self.check_port_config(testpmd, mbuf_off, verify, port_id), + "Port failed to disable mbuf_fast_free", + ) -- 2.50.1 ^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH v2 3/3] dts: update tx_offload test from old dts 2025-09-03 18:04 ` [PATCH v2 3/3] dts: update tx_offload test from old dts Andrew Bailey @ 2025-09-04 15:25 ` Luca Vizzarro 0 siblings, 0 replies; 21+ messages in thread From: Luca Vizzarro @ 2025-09-04 15:25 UTC (permalink / raw) To: Andrew Bailey; +Cc: dev, dmarx, ivan.malov, probb On Wed, Sep 03, 2025 at 02:04:14PM +0000, Andrew Bailey wrote: > Currently, the Rx/Tx offload test in old DTS expects the Tx ports to be > initially configured to use mbuf fast free. This is no longer the case > and must be updated to assume mbuf fast free is not initially utilized > by capable NICs. Add updated test suite to test mbuf fast free > configuration. > > Signed-off-by: Andrew Bailey <abailey@iol.unh.edu> > --- > dts/tests/TestSuite_rxtx_offload.py | 148 ++++++++++++++++++++++++++++ > 1 file changed, 148 insertions(+) > create mode 100644 dts/tests/TestSuite_rxtx_offload.py > > diff --git a/dts/tests/TestSuite_rxtx_offload.py b/dts/tests/TestSuite_rxtx_offload.py > new file mode 100644 > index 0000000000..133994d795 > --- /dev/null > +++ b/dts/tests/TestSuite_rxtx_offload.py > @@ -0,0 +1,148 @@ Missing SPDX License identifier > +# Copyright(c) 2025 University of New Hampshire > + > +"""Rx Tx offload test suite. > + > +Test the testpmd feature of configuring Rx and Tx offloads missed full stop at the end. > +""" > + > +from framework.remote_session.testpmd_shell import ( > + NicCapability, > + RxTxArgFlag, > + TestPmdShell, > +) > +from framework.test_suite import TestSuite, func_test > +from framework.testbed_model.capability import requires > + > + > +@requires(NicCapability.TX_OFFLOAD_MBUF_FAST_FREE) > +class TestRxTxOffload(TestSuite): Have you tested this test suite? From the looks of it, it doesn't seem it was ever tested. The current test suite discovery logic matches the file name to the class name, and they are currently mismatching. TestSuite_rxtx_offload -> TestRxtxOffload TestRxTxOffload -> TestSuite_rx_tx_offload > + """RX/TX offload test suite.""" > + > + def check_port_config( Any method that is not a test case should be made private. > + self, > + testpmd: TestPmdShell, > + offload: str, > + verify: bool, > + port_id: int = 0, > + ) -> bool: > + """Checks that the current port configuration matches the given offload. > + > + Args: > + testpmd: The current testpmd shell session to send commands to. > + offload: The expected configuration of the given port. > + verify: Whether to verify the result of call to testpmd. > + port_id: Id of the port to check. > + > + Returns: > + Whether current configuration matches given offload. > + """ And docstrings shoud be reserved for test suite module and test case methods only. This docstring won't be rendered as a private method. > + output = testpmd.get_rxtx_offload_config(RxTxArgFlag.TX, verify, port_id, 0) > + return offload in output["port"] or ( > + offload == "NULL" and "MBUF_FAST_FREE" not in output["port"] > + ) > + > + def check_queue_config( > + self, > + testpmd: TestPmdShell, > + offload: list[str], > + verify: bool, > + port_id: int = 0, > + num_queues: int = 0, > + ) -> bool: > + """Checks that the queue configuration matches the given offload. > + > + Args: > + testpmd: The current testpmd shell session to send commands to. > + offload: The expected configuration of the queues, each index corresponds > + to the queue id. > + verify: Whether to verify commands sent to testpmd. > + port_id: The port of which the queues reside. > + num_queues: The number of queues to check. > + > + Returns: > + Whether current configuration matches given offload > + """ as above. > + output = testpmd.get_rxtx_offload_config(RxTxArgFlag.TX, verify, port_id, num_queues) > + for i in range(0, num_queues): > + if not ( > + offload[i] in output[i] > + or (offload[i] == "NULL" and "MBUF_FAST_FREE" not in output[i]) > + ): > + return False > + return True > + > + @func_test > + def test_mbuf_fast_free_configurations(self) -> None: > + """Ensure mbuf_fast_free can be configured with testpmd. > + > + Steps: > + Start up testpmd shell. > + Toggle mbuf_fast_free on. > + Toggle mbuf_fast_free off. > + > + Verify: > + Mbuf_fast_free starts disabled. > + Mbuf_fast_free can be configured on. > + Mbuf_fast_free can be configured off. Improperly formatted unordered lists. Should prefix the lines with * > + """ > + with TestPmdShell() as testpmd: > + verify: bool = True > + port_id: int = 0 > + num_queues: int = 4 The types are inferred from the assigned value, there is no need to specify it explicitly. > + queue_off: list[str] = [] > + queue_on: list[str] = [] > + mbuf_on = "MBUF_FAST_FREE" > + mbuf_off = "NULL" > + > + for _ in range(0, num_queues): > + queue_off.append(mbuf_off) > + queue_on.append(mbuf_on) This should be rather written as a list comprehension. > + > + testpmd.set_ports_queues(num_queues) > + testpmd.start_all_ports() > + > + # Ensure mbuf_fast_free is disabled by default on port and queues > + self.verify( > + self.check_port_config(testpmd, mbuf_off, verify, port_id), > + "Mbuf_fast_free enabled on port start", Full stop at the end of the sentence. > + ) > + self.verify( > + self.check_queue_config(testpmd, queue_off, verify, port_id, num_queues), > + "Mbuf_fast_free enabled on queue start", Full stop at the end of the sentence. > + ) > + > + # Enable mbuf_fast_free per queue and verify > + testpmd.set_all_queues_mbuf_fast_free(True, verify, port_id, num_queues) > + self.verify( > + self.check_port_config(testpmd, mbuf_off, verify, port_id), > + "Port configuration changed without call", Full stop at the end of the sentence. > + ) > + self.verify( > + self.check_queue_config(testpmd, queue_on, verify, port_id, num_queues), > + "Queues failed to enable mbuf_fast_free", Full stop at the end of the sentence. > + ) > + > + # Enable mbuf_fast_free per port and verify > + testpmd.set_port_mbuf_fast_free(True, verify, port_id) > + self.verify( > + self.check_port_config(testpmd, mbuf_on, verify, port_id), > + "Port failed to enable mbuf_fast_free", Full stop at the end of the sentence. > + ) > + > + # Disable mbuf_fast_free per queue and verify > + testpmd.set_all_queues_mbuf_fast_free(False, verify, port_id, num_queues) > + self.verify( > + self.check_port_config(testpmd, mbuf_on, verify, port_id), > + "Port configuration changed without call", Full stop at the end of the sentence. > + ) > + self.verify( > + self.check_queue_config(testpmd, queue_off, verify, port_id, num_queues), > + "Queues failed to disable mbuf_fast_free", Full stop at the end of the sentence. > + ) > + > + # Disable mbuf_fast_free per port and verify > + testpmd.set_port_mbuf_fast_free(False, verify, port_id) > + self.verify( > + self.check_port_config(testpmd, mbuf_off, verify, port_id), > + "Port failed to disable mbuf_fast_free", Full stop at the end of the sentence. > + ) > -- > 2.50.1 > It looks like mbuf_off and mbuf_on are the same throughout, is there a need to make these a variable and pass it along the methods? ^ permalink raw reply [flat|nested] 21+ messages in thread
* [PATCH v3 0/3] dts: add tx_offload support in dts 2025-09-02 14:27 [PATCH v1 0/3] dts: add tx_offload support in dts Andrew Bailey ` (3 preceding siblings ...) 2025-09-03 18:04 ` [PATCH v2 0/3] dts: add tx_offlaod support in dts Andrew Bailey @ 2025-09-17 12:42 ` Andrew Bailey 2025-09-17 12:42 ` [PATCH v3 1/3] dts: allow mbuf_fast_free to be set with testpmd shell Andrew Bailey ` (2 more replies) 4 siblings, 3 replies; 21+ messages in thread From: Andrew Bailey @ 2025-09-17 12:42 UTC (permalink / raw) To: luca.vizzarro; +Cc: abailey, dev, dmarx, probb, ivan.malov This patchset introduces the support for Tx offload configuration through DTS, allowing test cases to be written utilizing Tx offload capabilities. Along with configuring these capabilities, they are also added to the NIC capabilities class, in which they can be required by test suites. Finally, a test suite was created using the aforementioned changes to update the Rx\Tx offload test suite in legacy DTS. --- v2: * Removed mentions of mbuf_fast_free being configured for Rx queues/ports as this is not accurate behaviour. * Clarify argument descriptions in docstrings. v3: * Added seperation between port and queue capabilites as it is relevant to the added test case that queues support mbuf fast free configuration. * Homogenized methods for getting Rx and Tx offload capabilities and configurations * Moved to use the text parser to gather the configuration, rather than returning the raw string output. * Updated test suites to use the new ports/queues offload flags in the requires decorator * Updated mbuf fast free test suite to test ports and queues individually. Along with updating the way it confirms the configuration to be consistent with the new process of getting the configuration. * Moved the get configuration method to the get nic capability patch as it is more relevant to that patches context. Andrew Bailey (3): dts: allow mbuf_fast_free to be set with testpmd shell dts: add TX offload capabilities to NIC capabilities dts: update tx_offload test from old dts dts/framework/parser.py | 30 + dts/framework/remote_session/testpmd_shell.py | 720 +++++++++++++++--- dts/tests/TestSuite_checksum_offload.py | 10 +- dts/tests/TestSuite_pmd_buffer_scatter.py | 4 +- dts/tests/TestSuite_rx_tx_offload.py | 130 ++++ dts/tests/TestSuite_vlan.py | 4 +- 6 files changed, 789 insertions(+), 109 deletions(-) create mode 100644 dts/tests/TestSuite_rx_tx_offload.py -- 2.50.1 ^ permalink raw reply [flat|nested] 21+ messages in thread
* [PATCH v3 1/3] dts: allow mbuf_fast_free to be set with testpmd shell 2025-09-17 12:42 ` [PATCH v3 0/3] dts: add tx_offload support in dts Andrew Bailey @ 2025-09-17 12:42 ` Andrew Bailey 2025-09-17 12:42 ` [PATCH v3 2/3] dts: add TX offload capabilities to NIC capabilities Andrew Bailey 2025-09-17 12:42 ` [PATCH v3 3/3] dts: update tx_offload test from old dts Andrew Bailey 2 siblings, 0 replies; 21+ messages in thread From: Andrew Bailey @ 2025-09-17 12:42 UTC (permalink / raw) To: luca.vizzarro; +Cc: abailey, dev, dmarx, probb, ivan.malov Currently, there is no way in the testpmd shell class to set the mbuf fast free offload configuration for queues or ports. This prohibits any test suites to be written utilizing this offload configuration. Introduce methods that support calls to testpmd in order to allow the configuration of mbuf fast free. Signed-off-by: Andrew Bailey <abailey@iol.unh.edu> --- dts/framework/remote_session/testpmd_shell.py | 60 +++++++++++++++++++ 1 file changed, 60 insertions(+) diff --git a/dts/framework/remote_session/testpmd_shell.py b/dts/framework/remote_session/testpmd_shell.py index 1df3d5f792..ecbdd66edd 100644 --- a/dts/framework/remote_session/testpmd_shell.py +++ b/dts/framework/remote_session/testpmd_shell.py @@ -2672,6 +2672,66 @@ def get_capabilities_physical_function( else: unsupported_capabilities.add(NicCapability.PHYSICAL_FUNCTION) + @requires_stopped_ports + def set_port_mbuf_fast_free( + self, + on: bool, + port_id: int, + /, + verify: bool = True, + ) -> None: + """Sets the mbuf_fast_free configuration for the Tx offload of a given port. + + Args: + on: If :data:`True` mbuf_fast_free will be enabled, disable it otherwise. + port_id: The ID of the port to configure mbuf_fast_free on. + verify: If :data:`True` the output of the command will be scanned in an attempt to + verify that the mbuf_fast_free was set successfully. + + Raises: + InteractiveCommandExecutionError: If mbuf_fast_free could not be set successfully. + """ + mbuf_output = self.send_command( + f"port config {port_id} tx_offload mbuf_fast_free {"on" if on else "off"}" + ) + + if verify and "Error" in mbuf_output: + raise InteractiveCommandExecutionError( + f"Unable to set mbuf_fast_free config on port {port_id}:\n{mbuf_output}" + ) + + @requires_stopped_ports + def set_queue_mbuf_fast_free( + self, + on: bool, + port_id: int, + /, + queue_id: int = 0, + verify: bool = True, + ) -> None: + """Sets the Tx mbuf_fast_free configuration of the specified queue on a given port. + + Args: + on: If :data:`True` the mbuf_fast_free configuration will be enabled, otherwise + disabled. + port_id: The ID of the port containing the queues. + queue_id: The ID of the queue to configure mbuf_fast_free on. + verify: If :data:`True` the output of the command will be scanned in an attempt to + verify that mbuf_fast_free was set successfully on all ports. + + Raises: + InteractiveCommandExecutionError: If all queues could not be set successfully. + """ + toggle = "on" if on else "off" + output = self.send_command( + f"port {port_id} txq {queue_id} tx_offload mbuf_fast_free {toggle}" + ) + if verify and "Error" in output: + self._logger.debug(f"Set queue offload config error\n{output}") + raise InteractiveCommandExecutionError( + f"Failed to get offload config on port {port_id}, queue {queue_id}:\n{output}" + ) + class NicCapability(NoAliasEnum): """A mapping between capability names and the associated :class:`TestPmdShell` methods. -- 2.50.1 ^ permalink raw reply [flat|nested] 21+ messages in thread
* [PATCH v3 2/3] dts: add TX offload capabilities to NIC capabilities 2025-09-17 12:42 ` [PATCH v3 0/3] dts: add tx_offload support in dts Andrew Bailey 2025-09-17 12:42 ` [PATCH v3 1/3] dts: allow mbuf_fast_free to be set with testpmd shell Andrew Bailey @ 2025-09-17 12:42 ` Andrew Bailey 2025-09-17 12:42 ` [PATCH v3 3/3] dts: update tx_offload test from old dts Andrew Bailey 2 siblings, 0 replies; 21+ messages in thread From: Andrew Bailey @ 2025-09-17 12:42 UTC (permalink / raw) To: luca.vizzarro; +Cc: abailey, dev, dmarx, probb, ivan.malov, Jeremy Spewock Currently, there is no support for tracking tx_offload capabilities and there is no separation between port capabilities and queue capabilities. This is an issue if a test case requires a tx_offload capability or if a test case requires that a card supports a capability on a queue. This causes test cases with said requirements to not be skipped when appropriate. Add tx_offload capabilities and distinguish capabilities between ports and queues. Signed-off-by: Andrew Bailey <abailey@iol.unh.edu> Signed-off-by: Jeremy Spewock <jspewock@iol.unh.edu> --- dts/framework/parser.py | 30 + dts/framework/remote_session/testpmd_shell.py | 660 +++++++++++++++--- dts/tests/TestSuite_checksum_offload.py | 10 +- dts/tests/TestSuite_pmd_buffer_scatter.py | 4 +- dts/tests/TestSuite_vlan.py | 4 +- 5 files changed, 599 insertions(+), 109 deletions(-) diff --git a/dts/framework/parser.py b/dts/framework/parser.py index 7254c75b71..4170cdb1dd 100644 --- a/dts/framework/parser.py +++ b/dts/framework/parser.py @@ -116,6 +116,36 @@ def _composite_parser_fn(text: str) -> Any: return ParserFn(TextParser_fn=_composite_parser_fn) + @staticmethod + def find_all( + pattern: str | re.Pattern[str], + flags: re.RegexFlag = re.RegexFlag(0), + ) -> ParserFn: + """Makes a parser function that finds all of the regular expression matches in the text. + + If there are no matches found in the text than None will be returned, otherwise a list + containing all matches will be returned. Patterns that contain multiple groups will pack + the matches for each group into a tuple. + + Args: + pattern: The regular expression pattern. + flags: The regular expression flags. Ignored if the given pattern is already compiled. + + Returns: + A :class:`ParserFn` that can be used as metadata for a dataclass field. + """ + if isinstance(pattern, str): + pattern = re.compile(pattern, flags) + + def _find_all(text: str) -> list[str] | None: + m = pattern.findall(text) + if len(m) == 0: + return None + + return m + + return ParserFn(TextParser_fn=_find_all) + @staticmethod def find( pattern: str | re.Pattern[str], diff --git a/dts/framework/remote_session/testpmd_shell.py b/dts/framework/remote_session/testpmd_shell.py index ecbdd66edd..f2a7307e44 100644 --- a/dts/framework/remote_session/testpmd_shell.py +++ b/dts/framework/remote_session/testpmd_shell.py @@ -22,7 +22,17 @@ from enum import Flag, auto from os import environ from pathlib import PurePath -from typing import TYPE_CHECKING, Any, ClassVar, Concatenate, Literal, ParamSpec, Tuple, TypeAlias +from typing import ( + TYPE_CHECKING, + Any, + ClassVar, + Concatenate, + Literal, + ParamSpec, + Tuple, + TypeAlias, + cast, +) from framework.context import get_ctx from framework.remote_session.interactive_shell import only_active @@ -43,6 +53,7 @@ from framework.settings import SETTINGS from framework.utils import REGEX_FOR_MAC_ADDRESS, StrEnum +RxTxLiteralSwitch = Literal["rx", "tx"] P = ParamSpec("P") TestPmdShellMethod = Callable[Concatenate["TestPmdShell", P], Any] @@ -1278,7 +1289,110 @@ class TestPmdVerbosePacket(TextParser): ) -class RxOffloadCapability(Flag): +class OffloadCapability(Flag): + """Flags generated from RxOffloadCapabilites and TxOffloadCapabilities classes.""" + + @classmethod + def from_string(cls, line: str) -> Self: + """Make an instance from a string containing the flag names separated with a space. + + Args: + line: The line to parse. + + Returns: + A new instance containing all found flags. + """ + flag = cls(0) + for flag_name in line.split(): + flag |= cls[ + f"{getattr( + cls, f"_{cls.__name__}__PREFIX", 'PREFIX_NOT_FOUND_' + ) + }{flag_name}" + ] + return flag + + @classmethod + def from_list(cls, lines: list[str]) -> list[Self]: + """Gather capabilities from a list of strings. + + Args: + lines: The list of capabilities to make flags from. + """ + return [cls.from_string(line) for line in lines] + + @classmethod + def make_parser(cls, per_port: bool, /, find_multiple: bool = False) -> ParserFn: + """Make a parser function. + + Args: + per_port: If :data:`True`, will return capabilities per port. If :data:`False`, + will return capabilities per queue. + find_multiple: If :data:`True`, will use :func:`TextParser.find_all` to find all + matches for the regex query and return a list of instances based on those matches. + If :data:`False`, will return a single instance of the flag based off a single + match. + + Returns: + ParserFn: A dictionary for the `dataclasses.field` metadata argument containing a + parser function that makes an instance of this flag from text. + """ + granularity = "Port" if per_port else "Queue" + parser_func: Callable[..., ParserFn] = ( + TextParser.find_all if find_multiple else TextParser.find + ) + instance_func: Callable[..., list[OffloadCapability]] | Callable[..., OffloadCapability] = ( + cls.from_list if find_multiple else cls.from_string + ) + return TextParser.wrap( + parser_func(rf"{granularity}[\s\[\]\d]+:(.*)$", re.MULTILINE), + instance_func, + ) + + +class TxOffloadCapability(OffloadCapability): + """TX offload capabilities of a device. + + The flags are taken from ``lib/ethdev/rte_ethdev.h``. + They're prefixed with ``RTE_ETH_TX_OFFLOAD`` in ``lib/ethdev/rte_ethdev.h`` + instead of ``TX_OFFLOAD``, which is what testpmd changes the prefix to. + + The ``TX_OFFLOAD`` prefix has been preserved so that the same flag names can be used + in :class:`NicCapability`. The prefix is needed in :class:`NicCapability` since there's + no other qualifier which would sufficiently distinguish it from other capabilities. + + References: + DPDK lib: ``lib/ethdev/rte_ethdev.h`` + testpmd display function: ``app/test-pmd/cmdline.c:print_rx_offloads()`` + """ + + __PREFIX: ClassVar[str] = "TX_OFFLOAD_" + + TX_OFFLOAD_VLAN_INSERT = auto() + TX_OFFLOAD_IPV4_CKSUM = auto() + TX_OFFLOAD_UDP_CKSUM = auto() + TX_OFFLOAD_TCP_CKSUM = auto() + TX_OFFLOAD_SCTP_CKSUM = auto() + TX_OFFLOAD_TCP_TSO = auto() + TX_OFFLOAD_UDP_TSO = auto() + TX_OFFLOAD_OUTER_IPV4_CKSUM = auto() + TX_OFFLOAD_QINQ_INSERT = auto() + TX_OFFLOAD_VXLAN_TNL_TSO = auto() + TX_OFFLOAD_GRE_TNL_TSO = auto() + TX_OFFLOAD_IPIP_TNL_TSO = auto() + TX_OFFLOAD_GENEVE_TNL_TSO = auto() + TX_OFFLOAD_MACSEC_INSERT = auto() + TX_OFFLOAD_MT_LOCKFREE = auto() + TX_OFFLOAD_MULTI_SEGS = auto() + TX_OFFLOAD_MBUF_FAST_FREE = auto() + TX_OFFLOAD_SECURITY = auto() + TX_OFFLOAD_UDP_TNL_TSO = auto() + TX_OFFLOAD_IP_TNL_TSO = auto() + TX_OFFLOAD_OUTER_UDP_CKSUM = auto() + TX_OFFLOAD_SEND_ON_TIMESTAMP = auto() + + +class RxOffloadCapability(OffloadCapability): """Rx offload capabilities of a device. The flags are taken from ``lib/ethdev/rte_ethdev.h``. @@ -1296,6 +1410,8 @@ class RxOffloadCapability(Flag): testpmd display function: ``app/test-pmd/cmdline.c:print_rx_offloads()`` """ + __PREFIX: ClassVar[str] = "RX_OFFLOAD_" + #: RX_OFFLOAD_VLAN_STRIP = auto() #: Device supports L3 checksum offload. @@ -1342,57 +1458,68 @@ class RxOffloadCapability(Flag): | RX_OFFLOAD_QINQ_STRIP ) - @classmethod - def from_string(cls, line: str) -> Self: - """Make an instance from a string containing the flag names separated with a space. - Args: - line: The line to parse. +@dataclass +class OffloadCapabilities(TextParser): + """The result of testpmd's ``show port <port_id> tx_offload capabilities`` command. - Returns: - A new instance containing all found flags. - """ - flag = cls(0) - for flag_name in line.split(): - flag |= cls[f"RX_OFFLOAD_{flag_name}"] - return flag + References: + testpmd command function: ``app/test-pmd/cmdline.c:cmd_tx_offload_get_capa()`` + testpmd display function: ``app/test-pmd/cmdline.c:cmd_tx_offload_get_capa_parsed()`` + """ - @classmethod - def make_parser(cls, per_port: bool) -> ParserFn: - """Make a parser function. + port_id: int = field(metadata=TextParser.find_int(r"Offloading Capabilities of port (\d+) :")) + #: Per-queue Rx offload capabilities. + per_queue: RxOffloadCapability | TxOffloadCapability + #: Capabilities other than per-queue Rx offload capabilities. + per_port: RxOffloadCapability | TxOffloadCapability - Args: - per_port: If :data:`True`, will return capabilities per port. If :data:`False`, - will return capabilities per queue. - Returns: - ParserFn: A dictionary for the `dataclasses.field` metadata argument containing a - parser function that makes an instance of this flag from text. - """ - granularity = "Port" if per_port else "Queue" - return TextParser.wrap( - TextParser.find(rf"Per {granularity}\s+:(.*)$", re.MULTILINE), - cls.from_string, - ) +@dataclass +class RxOffloadCapabilities(OffloadCapabilities): + """Extends :class:`OffloadCapabilities` with Rx specific functionality.""" + + per_queue: RxOffloadCapability = field(metadata=RxOffloadCapability.make_parser(False)) + per_port: RxOffloadCapability = field(metadata=RxOffloadCapability.make_parser(True)) @dataclass -class RxOffloadCapabilities(TextParser): - """The result of testpmd's ``show port <port_id> rx_offload capabilities`` command. +class TxOffloadCapabilities(OffloadCapabilities): + """Extends :class:`OffloadCapabilities` with Tx specific functionality.""" - References: - testpmd command function: ``app/test-pmd/cmdline.c:cmd_rx_offload_get_capa()`` - testpmd display function: ``app/test-pmd/cmdline.c:cmd_rx_offload_get_capa_parsed()`` - """ + per_queue: TxOffloadCapability = field(metadata=TxOffloadCapability.make_parser(False)) + per_port: TxOffloadCapability = field(metadata=TxOffloadCapability.make_parser(True)) - #: - port_id: int = field( - metadata=TextParser.find_int(r"Rx Offloading Capabilities of port (\d+) :") + +@dataclass +class OffloadConfiguration(TextParser): + """The result of testpmd's ``show port <port_id> rx/tx_offload configuration`` command.""" + + port_id: int = field(metadata=TextParser.find_int(r"Offloading Configuration of port (\d+) :")) + #: Queue offload configurations. + queues: list[RxOffloadCapability] | list[TxOffloadCapability] + #: Port offload configuration. + port: RxOffloadCapability | TxOffloadCapability + + +@dataclass +class RxOffloadConfiguration(OffloadConfiguration): + """Extends :class:`OffloadingConfiguration` with Rx specific functionality.""" + + queues: list[RxOffloadCapability] = field( + metadata=RxOffloadCapability.make_parser(False, find_multiple=True) ) - #: Per-queue Rx offload capabilities. - per_queue: RxOffloadCapability = field(metadata=RxOffloadCapability.make_parser(False)) - #: Capabilities other than per-queue Rx offload capabilities. - per_port: RxOffloadCapability = field(metadata=RxOffloadCapability.make_parser(True)) + port: RxOffloadCapability = field(metadata=RxOffloadCapability.make_parser(True)) + + +@dataclass +class TxOffloadConfiguration(OffloadConfiguration): + """Extends :class:`OffloadingConfiguration` with Tx specific functionality.""" + + queues: list[TxOffloadCapability] = field( + metadata=TxOffloadCapability.make_parser(False, find_multiple=True) + ) + port: TxOffloadCapability = field(metadata=TxOffloadCapability.make_parser(True)) @dataclass @@ -2390,27 +2517,56 @@ def close(self) -> None: ====== Capability retrieval methods ====== """ - def get_capabilities_rx_offload( - self, - supported_capabilities: MutableSet["NicCapability"], - unsupported_capabilities: MutableSet["NicCapability"], - ) -> None: - """Get all rx offload capabilities and divide them into supported and unsupported. + @staticmethod + def get_offload_capabilities_func( + rxtx: RxTxLiteralSwitch, + ) -> Callable[["TestPmdShell", MutableSet["NicCapability"], MutableSet["NicCapability"]], None]: + """High-order function that returns a method for gathering Rx/Tx offload capabilities. Args: - supported_capabilities: Supported capabilities will be added to this set. - unsupported_capabilities: Unsupported capabilities will be added to this set. - """ - self._logger.debug("Getting rx offload capabilities.") - command = f"show port {self.ports[0].id} rx_offload capabilities" - rx_offload_capabilities_out = self.send_command(command) - rx_offload_capabilities = RxOffloadCapabilities.parse(rx_offload_capabilities_out) - self._update_capabilities_from_flag( - supported_capabilities, - unsupported_capabilities, - RxOffloadCapability, - rx_offload_capabilities.per_port | rx_offload_capabilities.per_queue, - ) + rxtx: whether to gather the rx or tx capabilities in the returned method. + + Returns: + A method for gathering Rx/Tx offload capabilities that meets the required structure. + """ + + def get_capabilities( + self: "TestPmdShell", + supported_capabilities: MutableSet["NicCapability"], + unsupported_capabilities: MutableSet["NicCapability"], + ) -> None: + """Get all rx/tx offload capabilities and divide them into supported and unsupported. + + Args: + self: The shell instance to get the capabilities from. + supported_capabilities: Supported capabilities will be added to this set. + unsupported_capabilities: Unsupported capabilities will be added to this set. + """ + self._logger.debug(f"Getting {rxtx} offload capabilities.") + command = f"show port {self.ports[0].id} {rxtx}_offload capabilities" + offload_capabilities_out = self.send_command(command) + + capabilities = TxOffloadCapabilities if rxtx == "tx" else RxOffloadCapabilities + offload_capabilities = capabilities.parse(offload_capabilities_out) + per_port = cast(OffloadCapability, offload_capabilities.per_port) + per_queue = cast(OffloadCapability, offload_capabilities.per_queue) + + self._update_capabilities_from_flag( + supported_capabilities, + unsupported_capabilities, + TxOffloadCapability if rxtx == "tx" else RxOffloadCapability, + per_port | per_queue, + prefix="PORT_", + ) + self._update_capabilities_from_flag( + supported_capabilities, + unsupported_capabilities, + TxOffloadCapability if rxtx == "tx" else RxOffloadCapability, + per_queue, + prefix="QUEUE_", + ) + + return get_capabilities def get_port_queue_info( self, port_id: int, queue_id: int, is_rx_queue: bool @@ -2569,13 +2725,52 @@ def _update_capabilities_from_flag( unsupported_capabilities: MutableSet["NicCapability"], flag_class: type[Flag], supported_flags: Flag, + prefix: str = "", ) -> None: """Divide all flags from `flag_class` into supported and unsupported.""" for flag in flag_class: if flag in supported_flags: - supported_capabilities.add(NicCapability[str(flag.name)]) + supported_capabilities.add(NicCapability[f"{prefix}{flag.name}"]) else: - unsupported_capabilities.add(NicCapability[str(flag.name)]) + unsupported_capabilities.add(NicCapability[f"{prefix}{flag.name}"]) + + @requires_started_ports + def get_offload_config( + self, + rxtx: RxTxLiteralSwitch, + port_id: int, + /, + verify: bool = True, + ) -> RxOffloadConfiguration | TxOffloadConfiguration: + """Get the Rx or Tx offload configuration of the queues from the given port. + + Args: + rxtx: Whether to get the Rx or Tx configuration of the given queues. + port_id: The port ID that contains the desired queues. + verify: If :data:`True` the output of the command will be scanned in an attempt to + verify that the offload configuration was retrieved successfully on all queues. + + Returns: + An offload configuration containing the capabilities of the port and queues. + + Raises: + InteractiveCommandExecutionError: If all queue offload configurations could not be + retrieved. + """ + config_output = self.send_command(f"show port {port_id} {rxtx}_offload configuration") + if verify: + if ( + f"Rx Offloading Configuration of port {port_id}" not in config_output + and f"Tx Offloading Configuration of port {port_id}" not in config_output + ): + self._logger.debug(f"Get port offload config error\n{config_output}") + raise InteractiveCommandExecutionError( + f"Failed to get offload config on port {port_id}:\n{config_output}" + ) + if rxtx == "rx": + return RxOffloadConfiguration.parse(config_output) + else: + return TxOffloadConfiguration.parse(config_output) @requires_started_ports def get_capabilities_rxq_info( @@ -2758,102 +2953,367 @@ class NicCapability(NoAliasEnum): we don't go looking for it again if a different test case also needs it. """ + PORT_TX_OFFLOAD_VLAN_INSERT: TestPmdShellNicCapability = ( + TestPmdShell.get_offload_capabilities_func("tx"), + None, + ) + QUEUE_TX_OFFLOAD_VLAN_INSERT: TestPmdShellNicCapability = ( + TestPmdShell.get_offload_capabilities_func("tx"), + None, + ) + PORT_TX_OFFLOAD_IPV4_CKSUM: TestPmdShellNicCapability = ( + TestPmdShell.get_offload_capabilities_func("tx"), + None, + ) + QUEUE_TX_OFFLOAD_IPV4_CKSUM: TestPmdShellNicCapability = ( + TestPmdShell.get_offload_capabilities_func("tx"), + None, + ) + PORT_TX_OFFLOAD_UDP_CKSUM: TestPmdShellNicCapability = ( + TestPmdShell.get_offload_capabilities_func("tx"), + None, + ) + QUEUE_TX_OFFLOAD_UDP_CKSUM: TestPmdShellNicCapability = ( + TestPmdShell.get_offload_capabilities_func("tx"), + None, + ) + PORT_TX_OFFLOAD_TCP_CKSUM: TestPmdShellNicCapability = ( + TestPmdShell.get_offload_capabilities_func("tx"), + None, + ) + QUEUE_TX_OFFLOAD_TCP_CKSUM: TestPmdShellNicCapability = ( + TestPmdShell.get_offload_capabilities_func("tx"), + None, + ) + PORT_TX_OFFLOAD_SCTP_CKSUM: TestPmdShellNicCapability = ( + TestPmdShell.get_offload_capabilities_func("tx"), + None, + ) + QUEUE_TX_OFFLOAD_SCTP_CKSUM: TestPmdShellNicCapability = ( + TestPmdShell.get_offload_capabilities_func("tx"), + None, + ) + PORT_TX_OFFLOAD_TCP_TSO: TestPmdShellNicCapability = ( + TestPmdShell.get_offload_capabilities_func("tx"), + None, + ) + QUEUE_TX_OFFLOAD_TCP_TSO: TestPmdShellNicCapability = ( + TestPmdShell.get_offload_capabilities_func("tx"), + None, + ) + PORT_TX_OFFLOAD_UDP_TSO: TestPmdShellNicCapability = ( + TestPmdShell.get_offload_capabilities_func("tx"), + None, + ) + QUEUE_TX_OFFLOAD_UDP_TSO: TestPmdShellNicCapability = ( + TestPmdShell.get_offload_capabilities_func("tx"), + None, + ) + PORT_TX_OFFLOAD_OUTER_IPV4_CKSUM: TestPmdShellNicCapability = ( + TestPmdShell.get_offload_capabilities_func("tx"), + None, + ) + QUEUE_TX_OFFLOAD_OUTER_IPV4_CKSUM: TestPmdShellNicCapability = ( + TestPmdShell.get_offload_capabilities_func("tx"), + None, + ) + PORT_TX_OFFLOAD_QINQ_INSERT: TestPmdShellNicCapability = ( + TestPmdShell.get_offload_capabilities_func("tx"), + None, + ) + QUEUE_TX_OFFLOAD_QINQ_INSERT: TestPmdShellNicCapability = ( + TestPmdShell.get_offload_capabilities_func("tx"), + None, + ) + PORT_TX_OFFLOAD_VXLAN_TNL_TSO: TestPmdShellNicCapability = ( + TestPmdShell.get_offload_capabilities_func("tx"), + None, + ) + QUEUE_TX_OFFLOAD_VXLAN_TNL_TSO: TestPmdShellNicCapability = ( + TestPmdShell.get_offload_capabilities_func("tx"), + None, + ) + PORT_TX_OFFLOAD_GRE_TNL_TSO: TestPmdShellNicCapability = ( + TestPmdShell.get_offload_capabilities_func("tx"), + None, + ) + QUEUE_TX_OFFLOAD_GRE_TNL_TSO: TestPmdShellNicCapability = ( + TestPmdShell.get_offload_capabilities_func("tx"), + None, + ) + PORT_TX_OFFLOAD_IPIP_TNL_TSO: TestPmdShellNicCapability = ( + TestPmdShell.get_offload_capabilities_func("tx"), + None, + ) + QUEUE_TX_OFFLOAD_IPIP_TNL_TSO: TestPmdShellNicCapability = ( + TestPmdShell.get_offload_capabilities_func("tx"), + None, + ) + PORT_TX_OFFLOAD_GENEVE_TNL_TSO: TestPmdShellNicCapability = ( + TestPmdShell.get_offload_capabilities_func("tx"), + None, + ) + QUEUE_TX_OFFLOAD_GENEVE_TNL_TSO: TestPmdShellNicCapability = ( + TestPmdShell.get_offload_capabilities_func("tx"), + None, + ) + PORT_TX_OFFLOAD_MACSEC_INSERT: TestPmdShellNicCapability = ( + TestPmdShell.get_offload_capabilities_func("tx"), + None, + ) + QUEUE_TX_OFFLOAD_MACSEC_INSERT: TestPmdShellNicCapability = ( + TestPmdShell.get_offload_capabilities_func("tx"), + None, + ) + PORT_TX_OFFLOAD_MT_LOCKFREE: TestPmdShellNicCapability = ( + TestPmdShell.get_offload_capabilities_func("tx"), + None, + ) + QUEUE_TX_OFFLOAD_MT_LOCKFREE: TestPmdShellNicCapability = ( + TestPmdShell.get_offload_capabilities_func("tx"), + None, + ) + PORT_TX_OFFLOAD_MULTI_SEGS: TestPmdShellNicCapability = ( + TestPmdShell.get_offload_capabilities_func("tx"), + None, + ) + QUEUE_TX_OFFLOAD_MULTI_SEGS: TestPmdShellNicCapability = ( + TestPmdShell.get_offload_capabilities_func("tx"), + None, + ) + PORT_TX_OFFLOAD_MBUF_FAST_FREE: TestPmdShellNicCapability = ( + TestPmdShell.get_offload_capabilities_func("tx"), + None, + ) + QUEUE_TX_OFFLOAD_MBUF_FAST_FREE: TestPmdShellNicCapability = ( + TestPmdShell.get_offload_capabilities_func("tx"), + None, + ) + PORT_TX_OFFLOAD_SECURITY: TestPmdShellNicCapability = ( + TestPmdShell.get_offload_capabilities_func("tx"), + None, + ) + QUEUE_TX_OFFLOAD_SECURITY: TestPmdShellNicCapability = ( + TestPmdShell.get_offload_capabilities_func("tx"), + None, + ) + PORT_TX_OFFLOAD_UDP_TNL_TSO: TestPmdShellNicCapability = ( + TestPmdShell.get_offload_capabilities_func("tx"), + None, + ) + QUEUE_TX_OFFLOAD_UDP_TNL_TSO: TestPmdShellNicCapability = ( + TestPmdShell.get_offload_capabilities_func("tx"), + None, + ) + PORT_TX_OFFLOAD_IP_TNL_TSO: TestPmdShellNicCapability = ( + TestPmdShell.get_offload_capabilities_func("tx"), + None, + ) + QUEUE_TX_OFFLOAD_IP_TNL_TSO: TestPmdShellNicCapability = ( + TestPmdShell.get_offload_capabilities_func("tx"), + None, + ) + PORT_TX_OFFLOAD_OUTER_UDP_CKSUM: TestPmdShellNicCapability = ( + TestPmdShell.get_offload_capabilities_func("tx"), + None, + ) + QUEUE_TX_OFFLOAD_OUTER_UDP_CKSUM: TestPmdShellNicCapability = ( + TestPmdShell.get_offload_capabilities_func("tx"), + None, + ) + PORT_TX_OFFLOAD_SEND_ON_TIMESTAMP: TestPmdShellNicCapability = ( + TestPmdShell.get_offload_capabilities_func("tx"), + None, + ) + QUEUE_TX_OFFLOAD_SEND_ON_TIMESTAMP: TestPmdShellNicCapability = ( + TestPmdShell.get_offload_capabilities_func("tx"), + None, + ) #: Scattered packets Rx enabled SCATTERED_RX_ENABLED: TestPmdShellNicCapability = ( TestPmdShell.get_capabilities_rxq_info, add_remove_mtu(9000), ) #: - RX_OFFLOAD_VLAN_STRIP: TestPmdShellNicCapability = ( - TestPmdShell.get_capabilities_rx_offload, + PORT_RX_OFFLOAD_VLAN_STRIP: TestPmdShellNicCapability = ( + TestPmdShell.get_offload_capabilities_func("rx"), + None, + ) + QUEUE_RX_OFFLOAD_VLAN_STRIP: TestPmdShellNicCapability = ( + TestPmdShell.get_offload_capabilities_func("rx"), None, ) #: Device supports L3 checksum offload. - RX_OFFLOAD_IPV4_CKSUM: TestPmdShellNicCapability = ( - TestPmdShell.get_capabilities_rx_offload, + PORT_RX_OFFLOAD_IPV4_CKSUM: TestPmdShellNicCapability = ( + TestPmdShell.get_offload_capabilities_func("rx"), + None, + ) + QUEUE_RX_OFFLOAD_IPV4_CKSUM: TestPmdShellNicCapability = ( + TestPmdShell.get_offload_capabilities_func("rx"), None, ) #: Device supports L4 checksum offload. - RX_OFFLOAD_UDP_CKSUM: TestPmdShellNicCapability = ( - TestPmdShell.get_capabilities_rx_offload, + PORT_RX_OFFLOAD_UDP_CKSUM: TestPmdShellNicCapability = ( + TestPmdShell.get_offload_capabilities_func("rx"), + None, + ) + QUEUE_RX_OFFLOAD_UDP_CKSUM: TestPmdShellNicCapability = ( + TestPmdShell.get_offload_capabilities_func("rx"), None, ) #: Device supports L4 checksum offload. - RX_OFFLOAD_TCP_CKSUM: TestPmdShellNicCapability = ( - TestPmdShell.get_capabilities_rx_offload, + PORT_RX_OFFLOAD_TCP_CKSUM: TestPmdShellNicCapability = ( + TestPmdShell.get_offload_capabilities_func("rx"), + None, + ) + QUEUE_RX_OFFLOAD_TCP_CKSUM: TestPmdShellNicCapability = ( + TestPmdShell.get_offload_capabilities_func("rx"), None, ) #: Device supports Large Receive Offload. - RX_OFFLOAD_TCP_LRO: TestPmdShellNicCapability = (TestPmdShell.get_capabilities_rx_offload, None) + PORT_RX_OFFLOAD_TCP_LRO: TestPmdShellNicCapability = ( + TestPmdShell.get_offload_capabilities_func("rx"), + None, + ) + QUEUE_RX_OFFLOAD_TCP_LRO: TestPmdShellNicCapability = ( + TestPmdShell.get_offload_capabilities_func("rx"), + None, + ) #: Device supports QinQ (queue in queue) offload. - RX_OFFLOAD_QINQ_STRIP: TestPmdShellNicCapability = ( - TestPmdShell.get_capabilities_rx_offload, + PORT_RX_OFFLOAD_QINQ_STRIP: TestPmdShellNicCapability = ( + TestPmdShell.get_offload_capabilities_func("rx"), + None, + ) + QUEUE_RX_OFFLOAD_QINQ_STRIP: TestPmdShellNicCapability = ( + TestPmdShell.get_offload_capabilities_func("rx"), None, ) #: Device supports inner packet L3 checksum. - RX_OFFLOAD_OUTER_IPV4_CKSUM: TestPmdShellNicCapability = ( - TestPmdShell.get_capabilities_rx_offload, + PORT_RX_OFFLOAD_OUTER_IPV4_CKSUM: TestPmdShellNicCapability = ( + TestPmdShell.get_offload_capabilities_func("rx"), + None, + ) + QUEUE_RX_OFFLOAD_OUTER_IPV4_CKSUM: TestPmdShellNicCapability = ( + TestPmdShell.get_offload_capabilities_func("rx"), None, ) #: Device supports MACsec. - RX_OFFLOAD_MACSEC_STRIP: TestPmdShellNicCapability = ( - TestPmdShell.get_capabilities_rx_offload, + PORT_RX_OFFLOAD_MACSEC_STRIP: TestPmdShellNicCapability = ( + TestPmdShell.get_offload_capabilities_func("rx"), + None, + ) + QUEUE_RX_OFFLOAD_MACSEC_STRIP: TestPmdShellNicCapability = ( + TestPmdShell.get_offload_capabilities_func("rx"), None, ) #: Device supports filtering of a VLAN Tag identifier. - RX_OFFLOAD_VLAN_FILTER: TestPmdShellNicCapability = ( - TestPmdShell.get_capabilities_rx_offload, + PORT_RX_OFFLOAD_VLAN_FILTER: TestPmdShellNicCapability = ( + TestPmdShell.get_offload_capabilities_func("rx"), + None, + ) + QUEUE_RX_OFFLOAD_VLAN_FILTER: TestPmdShellNicCapability = ( + TestPmdShell.get_offload_capabilities_func("rx"), None, ) #: Device supports VLAN offload. - RX_OFFLOAD_VLAN_EXTEND: TestPmdShellNicCapability = ( - TestPmdShell.get_capabilities_rx_offload, + PORT_RX_OFFLOAD_VLAN_EXTEND: TestPmdShellNicCapability = ( + TestPmdShell.get_offload_capabilities_func("rx"), + None, + ) + QUEUE_RX_OFFLOAD_VLAN_EXTEND: TestPmdShellNicCapability = ( + TestPmdShell.get_offload_capabilities_func("rx"), None, ) #: Device supports receiving segmented mbufs. - RX_OFFLOAD_SCATTER: TestPmdShellNicCapability = (TestPmdShell.get_capabilities_rx_offload, None) + PORT_RX_OFFLOAD_SCATTER: TestPmdShellNicCapability = ( + TestPmdShell.get_offload_capabilities_func("rx"), + None, + ) + QUEUE_RX_OFFLOAD_SCATTER: TestPmdShellNicCapability = ( + TestPmdShell.get_offload_capabilities_func("rx"), + None, + ) #: Device supports Timestamp. - RX_OFFLOAD_TIMESTAMP: TestPmdShellNicCapability = ( - TestPmdShell.get_capabilities_rx_offload, + PORT_RX_OFFLOAD_TIMESTAMP: TestPmdShellNicCapability = ( + TestPmdShell.get_offload_capabilities_func("rx"), + None, + ) + QUEUE_RX_OFFLOAD_TIMESTAMP: TestPmdShellNicCapability = ( + TestPmdShell.get_offload_capabilities_func("rx"), None, ) #: Device supports crypto processing while packet is received in NIC. - RX_OFFLOAD_SECURITY: TestPmdShellNicCapability = ( - TestPmdShell.get_capabilities_rx_offload, + PORT_RX_OFFLOAD_SECURITY: TestPmdShellNicCapability = ( + TestPmdShell.get_offload_capabilities_func("rx"), + None, + ) + QUEUE_RX_OFFLOAD_SECURITY: TestPmdShellNicCapability = ( + TestPmdShell.get_offload_capabilities_func("rx"), None, ) #: Device supports CRC stripping. - RX_OFFLOAD_KEEP_CRC: TestPmdShellNicCapability = ( - TestPmdShell.get_capabilities_rx_offload, + PORT_RX_OFFLOAD_KEEP_CRC: TestPmdShellNicCapability = ( + TestPmdShell.get_offload_capabilities_func("rx"), + None, + ) + QUEUE_RX_OFFLOAD_KEEP_CRC: TestPmdShellNicCapability = ( + TestPmdShell.get_offload_capabilities_func("rx"), None, ) #: Device supports L4 checksum offload. - RX_OFFLOAD_SCTP_CKSUM: TestPmdShellNicCapability = ( - TestPmdShell.get_capabilities_rx_offload, + PORT_RX_OFFLOAD_SCTP_CKSUM: TestPmdShellNicCapability = ( + TestPmdShell.get_offload_capabilities_func("rx"), + None, + ) + QUEUE_RX_OFFLOAD_SCTP_CKSUM: TestPmdShellNicCapability = ( + TestPmdShell.get_offload_capabilities_func("rx"), None, ) #: Device supports inner packet L4 checksum. - RX_OFFLOAD_OUTER_UDP_CKSUM: TestPmdShellNicCapability = ( - TestPmdShell.get_capabilities_rx_offload, + PORT_RX_OFFLOAD_OUTER_UDP_CKSUM: TestPmdShellNicCapability = ( + TestPmdShell.get_offload_capabilities_func("rx"), + None, + ) + QUEUE_RX_OFFLOAD_OUTER_UDP_CKSUM: TestPmdShellNicCapability = ( + TestPmdShell.get_offload_capabilities_func("rx"), None, ) #: Device supports RSS hashing. - RX_OFFLOAD_RSS_HASH: TestPmdShellNicCapability = ( - TestPmdShell.get_capabilities_rx_offload, + PORT_RX_OFFLOAD_RSS_HASH: TestPmdShellNicCapability = ( + TestPmdShell.get_offload_capabilities_func("rx"), + None, + ) + QUEUE_RX_OFFLOAD_RSS_HASH: TestPmdShellNicCapability = ( + TestPmdShell.get_offload_capabilities_func("rx"), None, ) #: Device supports scatter Rx packets to segmented mbufs. - RX_OFFLOAD_BUFFER_SPLIT: TestPmdShellNicCapability = ( - TestPmdShell.get_capabilities_rx_offload, + PORT_RX_OFFLOAD_BUFFER_SPLIT: TestPmdShellNicCapability = ( + TestPmdShell.get_offload_capabilities_func("rx"), + None, + ) + QUEUE_RX_OFFLOAD_BUFFER_SPLIT: TestPmdShellNicCapability = ( + TestPmdShell.get_offload_capabilities_func("rx"), None, ) #: Device supports all checksum capabilities. - RX_OFFLOAD_CHECKSUM: TestPmdShellNicCapability = ( - TestPmdShell.get_capabilities_rx_offload, + PORT_RX_OFFLOAD_CHECKSUM: TestPmdShellNicCapability = ( + TestPmdShell.get_offload_capabilities_func("rx"), + None, + ) + QUEUE_RX_OFFLOAD_CHECKSUM: TestPmdShellNicCapability = ( + TestPmdShell.get_offload_capabilities_func("rx"), None, ) #: Device supports all VLAN capabilities. - RX_OFFLOAD_VLAN: TestPmdShellNicCapability = (TestPmdShell.get_capabilities_rx_offload, None) + PORT_RX_OFFLOAD_VLAN: TestPmdShellNicCapability = ( + TestPmdShell.get_offload_capabilities_func("rx"), + None, + ) + QUEUE_RX_OFFLOAD_VLAN: TestPmdShellNicCapability = ( + TestPmdShell.get_offload_capabilities_func("rx"), + None, + ) #: Device supports Rx queue setup after device started. RUNTIME_RX_QUEUE_SETUP: TestPmdShellNicCapability = ( TestPmdShell.get_capabilities_show_port_info, diff --git a/dts/tests/TestSuite_checksum_offload.py b/dts/tests/TestSuite_checksum_offload.py index ff916a4bb7..8e06c6b65f 100644 --- a/dts/tests/TestSuite_checksum_offload.py +++ b/dts/tests/TestSuite_checksum_offload.py @@ -30,9 +30,9 @@ @requires(topology_type=TopologyType.two_links) -@requires(NicCapability.RX_OFFLOAD_IPV4_CKSUM) -@requires(NicCapability.RX_OFFLOAD_UDP_CKSUM) -@requires(NicCapability.RX_OFFLOAD_TCP_CKSUM) +@requires(NicCapability.PORT_RX_OFFLOAD_IPV4_CKSUM) +@requires(NicCapability.PORT_RX_OFFLOAD_UDP_CKSUM) +@requires(NicCapability.PORT_RX_OFFLOAD_TCP_CKSUM) class TestChecksumOffload(TestSuite): """Checksum offload test suite. @@ -285,7 +285,7 @@ def validate_rx_checksum(self) -> None: packet=packet_list[i], good_L4=False, good_IP=True, testpmd=testpmd, id=dport_id ) - @requires(NicCapability.RX_OFFLOAD_VLAN) + @requires(NicCapability.PORT_RX_OFFLOAD_VLAN) @func_test def vlan_checksum(self) -> None: """Test VLAN Rx checksum hardware offload and verify packet reception. @@ -342,7 +342,7 @@ def vlan_checksum(self) -> None: packet=packet_list[i], good_L4=False, good_IP=True, testpmd=testpmd, id=dport_id ) - @requires(NicCapability.RX_OFFLOAD_SCTP_CKSUM) + @requires(NicCapability.PORT_RX_OFFLOAD_SCTP_CKSUM) @func_test def validate_sctp_checksum(self) -> None: """Test SCTP Rx checksum hardware offload and verify packet reception. diff --git a/dts/tests/TestSuite_pmd_buffer_scatter.py b/dts/tests/TestSuite_pmd_buffer_scatter.py index 802777a697..54627157b5 100644 --- a/dts/tests/TestSuite_pmd_buffer_scatter.py +++ b/dts/tests/TestSuite_pmd_buffer_scatter.py @@ -29,7 +29,7 @@ @requires(NicCapability.PHYSICAL_FUNCTION) -@requires(NicCapability.RX_OFFLOAD_SCATTER) +@requires(NicCapability.PORT_RX_OFFLOAD_SCATTER) class TestPmdBufferScatter(TestSuite): """DPDK PMD packet scattering test suite. @@ -135,7 +135,7 @@ def scatter_mbuf_2048(self) -> None: """Run the :meth:`pmd_scatter` test with `mb_size` set to 2048.""" self.pmd_scatter(mb_size=2048) - @requires(NicCapability.RX_OFFLOAD_SCATTER) + @requires(NicCapability.PORT_RX_OFFLOAD_SCATTER) @func_test def scatter_mbuf_2048_with_offload(self) -> None: """Run the :meth:`pmd_scatter` test with `mb_size` set to 2048 and rx_scatter offload.""" diff --git a/dts/tests/TestSuite_vlan.py b/dts/tests/TestSuite_vlan.py index ed36a2950d..906ceb0072 100644 --- a/dts/tests/TestSuite_vlan.py +++ b/dts/tests/TestSuite_vlan.py @@ -20,7 +20,7 @@ from framework.testbed_model.capability import NicCapability, TopologyType, requires -@requires(NicCapability.RX_OFFLOAD_VLAN_FILTER) +@requires(NicCapability.PORT_RX_OFFLOAD_VLAN_FILTER) @requires(topology_type=TopologyType.two_links) class TestVlan(TestSuite): """DPDK VLAN test suite. @@ -129,7 +129,7 @@ def vlan_receipt_no_stripping(self) -> None: testpmd.start() self.send_vlan_packet_and_verify(True, strip=False, vlan_id=1) - @requires(NicCapability.RX_OFFLOAD_VLAN_STRIP) + @requires(NicCapability.PORT_RX_OFFLOAD_VLAN_STRIP) @func_test def vlan_receipt_stripping(self) -> None: """Ensure VLAN packet received with no tag when receipts and header stripping are enabled. -- 2.50.1 ^ permalink raw reply [flat|nested] 21+ messages in thread
* [PATCH v3 3/3] dts: update tx_offload test from old dts 2025-09-17 12:42 ` [PATCH v3 0/3] dts: add tx_offload support in dts Andrew Bailey 2025-09-17 12:42 ` [PATCH v3 1/3] dts: allow mbuf_fast_free to be set with testpmd shell Andrew Bailey 2025-09-17 12:42 ` [PATCH v3 2/3] dts: add TX offload capabilities to NIC capabilities Andrew Bailey @ 2025-09-17 12:42 ` Andrew Bailey 2 siblings, 0 replies; 21+ messages in thread From: Andrew Bailey @ 2025-09-17 12:42 UTC (permalink / raw) To: luca.vizzarro; +Cc: abailey, dev, dmarx, probb, ivan.malov Currently, the RX/TX offload test in old DTS expects the TX ports to be initially configured to use mbuf fast free. This is no longer the case and must be updated to assume mbuf fast free is not initially utilized by capable NICs. Add updated test suite to test mbuf fast free configuration. Signed-off-by: Andrew Bailey <abailey@iol.unh.edu> --- dts/tests/TestSuite_rx_tx_offload.py | 130 +++++++++++++++++++++++++++ 1 file changed, 130 insertions(+) create mode 100644 dts/tests/TestSuite_rx_tx_offload.py diff --git a/dts/tests/TestSuite_rx_tx_offload.py b/dts/tests/TestSuite_rx_tx_offload.py new file mode 100644 index 0000000000..f97bb4978a --- /dev/null +++ b/dts/tests/TestSuite_rx_tx_offload.py @@ -0,0 +1,130 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright(c) 2025 University of New Hampshire + +"""RX TX offload test suite. + +Test the testpmd feature of configuring RX and TX offloads. +""" + +from typing import Optional + +from framework.remote_session.testpmd_shell import ( + OffloadConfiguration, + RxTxLiteralSwitch, + TestPmdShell, +) +from framework.test_suite import TestSuite, func_test +from framework.testbed_model.capability import NicCapability, requires + + +class TestRxTxOffload(TestSuite): + """RX/TX offload test suite.""" + + def _check_config( + self, + testpmd: TestPmdShell, + port_offload: str | None, + rxtx: RxTxLiteralSwitch, + port_id: int, + /, + queue_offload: Optional[list[str | None]] = None, + verify: bool = True, + ) -> bool: + config: OffloadConfiguration = testpmd.get_offload_config(rxtx, port_id, verify) + if config.port.name != port_offload: + return False + + if queue_offload: + for i, q in enumerate(config.queues): + if q.name != queue_offload[i]: + return False + return True + + def _set_all_queues_mbuf_fast_free( + self, testpmd: TestPmdShell, on: bool, port_id: int, num_queues: int, /, verify: bool = True + ) -> None: + for i in range(num_queues): + testpmd.set_queue_mbuf_fast_free(on, port_id, i, verify) + + @requires(NicCapability.PORT_TX_OFFLOAD_MBUF_FAST_FREE) + @func_test + def test_mbuf_fast_free_configuration_per_port(self) -> None: + """Ensure mbuf_fast_free can be configured with testpmd per port. + + Steps: + * Start up testpmd shell. + * Toggle mbuf_fast_free on per port. + * Toggle mbuf_fast_free off per port. + + Verify: + * Mbuf_fast_free starts disabled. + * Mbuf_fast_free can be configured on per port. + * Mbuf_fast_free can be configured off per port. + """ + with TestPmdShell() as testpmd: + verify = True + port_id = 0 + testpmd.start_all_ports() + + # Ensure MBUF_FAST_FREE is disabled by default and verify + self.verify( + self._check_config(testpmd, None, "tx", port_id, verify=verify), + "MBUF_FAST_FREE enabled on port start.", + ) + # Enable MBUF_FAST_FREE per port and verify + testpmd.set_port_mbuf_fast_free(True, port_id, verify) + self.verify( + self._check_config( + testpmd, "TX_OFFLOAD_MBUF_FAST_FREE", "tx", port_id, verify=verify + ), + "Failed to enable MBUF_FAST_FREE on port.", + ) + # Disable MBUF_FAST_FREE per port and verify + testpmd.set_port_mbuf_fast_free(False, port_id, verify) + self.verify( + self._check_config(testpmd, None, "tx", port_id, verify=verify), + "Failed to disable MBUF_FAST_FREE on port.", + ) + + @requires(NicCapability.QUEUE_TX_OFFLOAD_MBUF_FAST_FREE) + @func_test + def test_mbuf_fast_free_configuration_per_queue(self) -> None: + """Ensure mbuf_fast_free can be configured with testpmd. + + Steps: + * Start up testpmd shell. + * Toggle mbuf_fast_free on per queue. + * Toggle mbuf_fast_free off per queue. + + Verify: + * Mbuf_fast_free starts disabled. + * Mbuf_fast_free can be configured on per queue. + * Mbuf_fast_free can be configured off per queue. + """ + with TestPmdShell() as testpmd: + verify = True + port_id = 0 + num_queues = 4 + queue_off: Optional[list[str | None]] = [None] * num_queues + queue_on: Optional[list[str | None]] = ["TX_OFFLOAD_MBUF_FAST_FREE"] * num_queues + + testpmd.set_ports_queues(num_queues) + testpmd.start_all_ports() + + # Ensure mbuf_fast_free is disabled by default on port and queues + self.verify( + self._check_config(testpmd, None, "tx", port_id, queue_off, verify=verify), + "MBUF_FAST_FREE enabled on queue start.", + ) + # Enable mbuf_fast_free per queue and verify + self._set_all_queues_mbuf_fast_free(testpmd, True, port_id, num_queues, verify) + self.verify( + self._check_config(testpmd, None, "tx", port_id, queue_on, verify), + "Failed to enable MBUF_FAST_FREE on all queues.", + ) + # Disable mbuf_fast_free per queue and verify + self._set_all_queues_mbuf_fast_free(testpmd, False, port_id, num_queues, verify) + self.verify( + self._check_config(testpmd, None, "tx", port_id, queue_off, verify), + "Failed to disable MBUF_FAST_FREE on all queues.", + ) -- 2.50.1 ^ permalink raw reply [flat|nested] 21+ messages in thread
end of thread, other threads:[~2025-09-17 12:43 UTC | newest] Thread overview: 21+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2025-09-02 14:27 [PATCH v1 0/3] dts: add tx_offload support in dts Andrew Bailey 2025-09-02 14:27 ` [PATCH v1 1/3] dts: allow mbuf_fast_free to be set with testpmd shell Andrew Bailey 2025-09-02 19:37 ` Ivan Malov 2025-09-02 19:48 ` Ivan Malov 2025-09-02 14:27 ` [PATCH v1 2/3] dts: add TX offload capabilities to NIC capabilities Andrew Bailey 2025-09-04 14:43 ` Luca Vizzarro 2025-09-04 14:45 ` Luca Vizzarro 2025-09-02 14:27 ` [PATCH v1 3/3] dts: update tx_offload test from old dts Andrew Bailey 2025-09-03 18:04 ` [PATCH v2 0/3] dts: add tx_offlaod support in dts Andrew Bailey 2025-09-03 18:04 ` [PATCH v2 1/3] dts: allow mbuf_fast_free to be set with testpmd shell Andrew Bailey 2025-09-04 15:15 ` Luca Vizzarro 2025-09-04 21:18 ` Patrick Robb 2025-09-03 18:04 ` [PATCH v2 2/3] dts: add TX offload capabilities to NIC capabilities Andrew Bailey 2025-09-03 18:36 ` Patrick Robb 2025-09-04 14:47 ` Luca Vizzarro 2025-09-03 18:04 ` [PATCH v2 3/3] dts: update tx_offload test from old dts Andrew Bailey 2025-09-04 15:25 ` Luca Vizzarro 2025-09-17 12:42 ` [PATCH v3 0/3] dts: add tx_offload support in dts Andrew Bailey 2025-09-17 12:42 ` [PATCH v3 1/3] dts: allow mbuf_fast_free to be set with testpmd shell Andrew Bailey 2025-09-17 12:42 ` [PATCH v3 2/3] dts: add TX offload capabilities to NIC capabilities Andrew Bailey 2025-09-17 12:42 ` [PATCH v3 3/3] dts: update tx_offload test from old dts Andrew Bailey
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).