DPDK patches and discussions
 help / color / mirror / Atom feed
From: jspewock@iol.unh.edu
To: Honnappa.Nagarahalli@arm.com, probb@iol.unh.edu,
	paul.szczepanek@arm.com, juraj.linkes@pantheon.tech,
	yoan.picchi@foss.arm.com, npratte@iol.unh.edu,
	wathsala.vithanage@arm.com, Luca.Vizzarro@arm.com,
	alex.chapman@arm.com, thomas@monjalon.net
Cc: dev@dpdk.org, Jeremy Spewock <jspewock@iol.unh.edu>
Subject: [RFC PATCH v1 4/5] dts: add methods for configuring offloads on a device in testpmd
Date: Fri, 30 Aug 2024 20:00:12 -0400	[thread overview]
Message-ID: <20240831000058.23009-5-jspewock@iol.unh.edu> (raw)
In-Reply-To: <20240831000058.23009-1-jspewock@iol.unh.edu>

From: Jeremy Spewock <jspewock@iol.unh.edu>

Testpmd offers methods to add and remove offloads from both ports and
queues on ports, but there are not yet method bindings in the Testpmd
API that the framework provides to reach them. This patch adds these
bindings for future test cases/suites that require certain
functionalities to be offloaded on the device.

Signed-off-by: Jeremy Spewock <jspewock@iol.unh.edu>
---
 dts/framework/remote_session/testpmd_shell.py | 229 +++++++++++++++++-
 1 file changed, 228 insertions(+), 1 deletion(-)

diff --git a/dts/framework/remote_session/testpmd_shell.py b/dts/framework/remote_session/testpmd_shell.py
index 58b8995d21..383a3c48b8 100644
--- a/dts/framework/remote_session/testpmd_shell.py
+++ b/dts/framework/remote_session/testpmd_shell.py
@@ -32,7 +32,7 @@
 
 from typing_extensions import TypeVarTuple
 
-from framework.exception import InteractiveCommandExecutionError
+from framework.exception import InteractiveCommandExecutionError, InternalError
 from framework.params.testpmd import SimpleForwardingModes, TestPmdParams
 from framework.params.types import TestPmdParamsDict
 from framework.parser import ParserFn, TextParser
@@ -1314,6 +1314,54 @@ class TestPmdVerbosePacket(TextParser):
     l4_len: int | None = field(default=None, metadata=TextParser.find_int(r"l4_len=(\d+)"))
 
 
+class TestPmdOffloadCapabilities(StrEnum):
+    """Base class for offload capabilities of ports/queues in testpmd.
+
+    This base class is primarily used to give the Rx and Tx variants a common parent type.
+    """
+
+    pass
+
+
+class TestPmdRxOffloadCapabilities(TestPmdOffloadCapabilities):
+    """Rx offload capabilities of ports/queues in testpmd."""
+
+    # *** Common attributes *** #
+    #:
+    all = auto()
+    #:
+    ipv4_cksum = auto()
+    #:
+    udp_cksum = auto()
+    #:
+    tcp_cksum = auto()
+    #:
+    outer_ipv4_cksum = auto()
+    #:
+    security = auto()
+    # *** End ***#
+    #:
+    vlan_strip = auto()
+    #:
+    tcp_lro = auto()
+    #:
+    qinq_strip = auto()
+    #:
+    macsec_strip = auto()
+    #:
+    vlan_filter = auto()
+    #:
+    vlan_extend = auto()
+    #:
+    scatter = auto()
+    #:
+    timestamp = auto()
+    #:
+    keep_crc = auto()
+    #:
+    rss_hash = auto()
+
+
 @dataclass
 class FlowRule:
     """Dataclass for setting flow rule parameters."""
@@ -1352,6 +1400,51 @@ def __str__(self) -> str:
         return ret
 
 
+class TestPmdTxOffloadCapabilities(TestPmdOffloadCapabilities):
+    """Tx offload capabilities of ports/queues in testpmd."""
+
+    # *** Common attributes *** #
+    #:
+    all = auto()
+    #:
+    ipv4_cksum = auto()
+    #:
+    udp_cksum = auto()
+    #:
+    tcp_cksum = auto()
+    #:
+    outer_ipv4_cksum = auto()
+    #:
+    security = auto()
+    # *** End *** #
+    #:
+    vlan_insert = auto()
+    #:
+    sctp_cksum = auto()
+    #:
+    tcp_tso = auto()
+    #:
+    udp_tso = auto()
+    #:
+    qinq_insert = auto()
+    #:
+    vxlan_tnl_tso = auto()
+    #:
+    gre_tnl_tso = auto()
+    #:
+    ipip_tnl_tso = auto()
+    #:
+    geneve_tnl_tso = auto()
+    #:
+    macsec_insert = auto()
+    #:
+    mt_lockfree = auto()
+    #:
+    multi_segs = auto()
+    #:
+    mbuf_fast_free = auto()
+
+
 class TestPmdShell(DPDKShell):
     """Testpmd interactive shell.
 
@@ -1995,6 +2088,140 @@ def set_verbose(self, level: int, verify: bool = True) -> None:
                     f"Testpmd failed to set verbose level to {level}."
                 )
 
+    @stop_then_start_port()
+    def _set_offload(
+        self,
+        port_id: int,
+        is_rx: bool,
+        offloads: OffloadCapability,
+        on: bool,
+        queue_id: int | None = None,
+        verify: bool = True,
+    ) -> None:
+        """Base method for configuring offloads on ports and queues.
+
+        If `queue_id` is not specified then it is assumed that you want to set the offloads on the
+        port rather than a queue.
+        """
+        for offload in type(offloads):
+            if offload not in offloads:
+                continue
+            port_type = "rx" if is_rx else "tx"
+            command = [
+                "port",
+                f"{port_id}",
+                f"{port_type}_offload",
+                f"{offload.name}",
+                f"{'on' if on else 'off'}",
+            ]
+            if queue_id is not None:
+                # If modifying queues the command is "port <id> rxq <q_id> ..."
+                command.insert(2, f"{port_type}q {queue_id}")
+            else:
+                # If modifying a port the command is "port config <id> ..."
+                command.insert(1, "config")
+
+            self.send_command(" ".join(command))
+            if verify:
+                # verification of ports has to be done based on if it was applied to all queues or
+                # not because the "Per Port" line doesn't get modified until the port is started.
+                current_offload_conf: OffloadConfiguration = (
+                    self.show_port_rx_offload_configuration(port_id) if is_rx else
+                    self.show_port_tx_offload_configuration(port_id)
+                )
+                if queue_id is not None and len(current_offload_conf.queues) < queue_id + 1:
+                    raise InternalError(f"Queue {queue_id} does not exist in testpmd")
+                capability_is_set = (
+                    len(current_offload_conf.queues) > 0 and
+                    (queue_id is not None and offload in current_offload_conf.queues[queue_id]) or
+                    all(offload in conf for conf in current_offload_conf.queues)
+                )
+                if capability_is_set != on:
+                    self._logger.debug(
+                        f"Test pmd failed to modify capabilities on port {port_id}:\n"
+                        f"{current_offload_conf.queues}"
+                    )
+                    raise InteractiveCommandExecutionError(
+                        f"Test pmd failed to {'add' if on else 'remove'} capability {offload.name} "
+                        f"{'to' if on else 'from'} port {port_id}."
+                    )
+
+    def set_port_offload(
+        self,
+        port_id: int,
+        is_rx: bool,
+        offload: OffloadCapability,
+        on: bool,
+        verify: bool = True,
+    ) -> None:
+        """Configure Rx/Tx offload on a port.
+
+        Args:
+            port_id: The ID of the port to set configure the offload on.
+            is_rx: A flag that signifies which type of offload to set. If :data:`True` an Rx
+                offload will be set, otherwise a Tx offload will be set.
+            offload: The offload to set on the port.
+            on: If :data:`True` the specified offload will be set turned on, otherwise the offload
+                will be turned off.
+            verify: If :data:`True` an additional command will be sent to check the configuration
+                of offloads on the port to verify `offload` was set properly. Defaults to
+                :data:`True`.
+
+        Raises:
+            InteractiveCommandExecutionError: If `verify` is :data:`True` and testpmd failed to
+                set the offload on the port.
+        """
+        self._set_offload(port_id, is_rx, offload, on, None, verify)
+
+    def set_queue_offload(
+        self,
+        port_id: int,
+        queue_id: int,
+        is_rx: bool,
+        offload: OffloadCapability,
+        on: bool,
+        verify: bool = True,
+    ) -> None:
+        """Configure Rx/Tx offload on a queue that resides on a specified port.
+
+        Args:
+            port_id: The ID of the port where the queue resides.
+            queue_id: The ID of the queue on the port.
+            is_rx: A flag that signifies which type of offload to set. If :data:`True` an Rx
+                offload will be set, otherwise a Tx offload will be set.
+            offload: The offload to set on a port.
+            on: If :data:`True` the offload will be turned on, otherwise the offload will be turned
+                off.
+            verify: If :data:`True` an additional command will be sent to check the configuration
+                of the queue to validate that the offload was configured properly. Defaults to
+                :data:`True`.
+
+        Raises:
+            InteractiveCommandExecutionError: If `verify` is :data:`True` and testpmd failed to
+                set the offload on the queue.
+        """
+        self._set_offload(port_id, is_rx, offload, on, queue_id, verify)
+
+    def is_port_offload_configured(
+        self, port_id: int, is_rx: bool, offload: OffloadCapability
+    ) -> bool:
+        """Verify whether or not an Rx/Tx offload is currently configured on a port.
+
+        Args:
+            port_id: The ID of the port to check the configuration of.
+            is_rx: If :data:`True` the Rx offloads of the port will be checked, otherwise the Tx
+                offloads will be checked.
+            offload: The offload to search for on the port.
+
+        Returns:
+            :data:`True` if the offload is configured on the port, :data:`False` otherwise.
+        """
+        offload_config: OffloadConfiguration = (
+            self.show_port_rx_offload_configuration(port_id) if is_rx else
+            self.show_port_tx_offload_configuration(port_id)
+        )
+        return offload in offload_config.port
+
     def flow_create(self, cmd: FlowRule, verify: bool = True) -> None:
         """Creates a flow rule in the testpmd session.
 
-- 
2.46.0


  parent reply	other threads:[~2024-08-31  0:04 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-31  0:00 [RFC PATCH v1 0/5] dts: port over Rx/Tx offload suite jspewock
2024-08-31  0:00 ` [RFC PATCH v1 1/5] dts: add TX offload capabilities jspewock
2024-08-31  0:00 ` [RFC PATCH v1 2/5] dts: add a distinction between port and queue " jspewock
2024-08-31  0:00 ` [RFC PATCH v1 3/5] dts: add offload configuration querying to testpmd jspewock
2024-08-31  0:00 ` jspewock [this message]
2024-08-31  0:00 ` [RFC PATCH v1 5/5] dts: add test suite for RX and TX offloads jspewock
2024-09-03 19:46 ` [PATCH v2 0/5] dts: port over Rx/Tx offload suite jspewock
2024-09-03 19:46   ` [PATCH v2 1/5] dts: add TX offload capabilities jspewock
2024-09-03 19:46   ` [PATCH v2 2/5] dts: add a distinction between port and queue " jspewock
2024-09-03 19:46   ` [PATCH v2 3/5] dts: add offload configuration querying to testpmd jspewock
2024-09-03 19:46   ` [PATCH v2 4/5] dts: add methods for configuring offloads on a device in testpmd jspewock
2024-09-03 19:46   ` [PATCH v2 5/5] dts: add test suite for RX and TX offloads jspewock

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240831000058.23009-5-jspewock@iol.unh.edu \
    --to=jspewock@iol.unh.edu \
    --cc=Honnappa.Nagarahalli@arm.com \
    --cc=Luca.Vizzarro@arm.com \
    --cc=alex.chapman@arm.com \
    --cc=dev@dpdk.org \
    --cc=juraj.linkes@pantheon.tech \
    --cc=npratte@iol.unh.edu \
    --cc=paul.szczepanek@arm.com \
    --cc=probb@iol.unh.edu \
    --cc=thomas@monjalon.net \
    --cc=wathsala.vithanage@arm.com \
    --cc=yoan.picchi@foss.arm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).