From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id DCD3C458AF; Sat, 31 Aug 2024 02:04:30 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 3195242FCF; Sat, 31 Aug 2024 02:04:10 +0200 (CEST) Received: from mail-io1-f97.google.com (mail-io1-f97.google.com [209.85.166.97]) by mails.dpdk.org (Postfix) with ESMTP id 3C35C42F8B for ; Sat, 31 Aug 2024 02:04:06 +0200 (CEST) Received: by mail-io1-f97.google.com with SMTP id ca18e2360f4ac-82a20593ec1so81211439f.2 for ; Fri, 30 Aug 2024 17:04:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=iol.unh.edu; s=unh-iol; t=1725062645; x=1725667445; darn=dpdk.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=I+h2VGreoznhsIFi6E8FEd2Fi+aGDws+10Ql6agnT3c=; b=JlfRtiCNXs2QwBT2LDZM71A+pdTJ3ewOu0Sh0BYXXBEOrqh9CVpQSv/fUelISDL2+P INHbaEDkhGoHRs9NiTjCvBvrBWh2fVr5Bwb6hC/i2AYRfA/jhvvjNpXqdUTeO7SaPF3I wj6vqwVOcPYDMk5N1wCk28LW79JKafguCt0KI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725062645; x=1725667445; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=I+h2VGreoznhsIFi6E8FEd2Fi+aGDws+10Ql6agnT3c=; b=hTxRZTfkyVERP5R/S2GIa5chDY6oWviXvUYrsHw4SjrEV8bh7Nsy4XtjkyDvsT0S/C u9p53rQzmI6PF08p53WEaLBCHbOUUpKxqp76NoPRK17THj+/iADlMChXaRw00w8EvteL ifGL5V5TSImIQ/oDQQjb16ZdF7CwG0NSH7KlzPamzCvYXjBp/tIEpLzJa4WUrEXK4kjg Ka5zO+jvgZnvartKGkXmWR8RatHsjqtFytT3qexDs0oSGPEG1im1AmfyLNrZVLR9Edlw oaCQuBhBMiMESlOlM8nXEugU+jaq/e3PDHg2TFxAe/oDwN/4JkVIqVL8CY3zADJRYcMZ y92w== X-Gm-Message-State: AOJu0YwGuHfxa4QQL8wbRBpHx7/E0RlfpiopjYTK6g60QsSNytUk4tD2 QKcpO3WeDXVg0tyU6lcRsNODHXkiZ9c+gE1gWcuQiYpAHNYl8oTIRE83fNOdhz5F6fz9/4d7WmT Fnn40eTEuY7U55UWDvMhDa8VgJHRZv6xeuUIZhMUyy2QDhXDm X-Google-Smtp-Source: AGHT+IEixDKX1yNJKkLb6QYkMMUTcB8igCvepSqUog5l4D5VzfDr0r9xNvrGY9CH+55gVeqKbcu9dTb/kdYL X-Received: by 2002:a05:6602:490:b0:825:3a02:f935 with SMTP id ca18e2360f4ac-82a110713bbmr939715439f.11.1725062645539; Fri, 30 Aug 2024 17:04:05 -0700 (PDT) Received: from postal.iol.unh.edu (postal.iol.unh.edu. [2606:4100:3880:1234::84]) by smtp-relay.gmail.com with ESMTPS id 8926c6da1cb9f-4ced2e9ce3bsm171785173.53.2024.08.30.17.04.05 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 30 Aug 2024 17:04:05 -0700 (PDT) X-Relaying-Domain: iol.unh.edu Received: from iol.unh.edu (unknown [IPv6:2606:4100:3880:1257::1083]) by postal.iol.unh.edu (Postfix) with ESMTP id 62D07605C381; Fri, 30 Aug 2024 20:04:04 -0400 (EDT) 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 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 Message-ID: <20240831000058.23009-5-jspewock@iol.unh.edu> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240831000058.23009-1-jspewock@iol.unh.edu> References: <20240831000058.23009-1-jspewock@iol.unh.edu> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org From: Jeremy Spewock 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 --- 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 rxq ..." + command.insert(2, f"{port_type}q {queue_id}") + else: + # If modifying a port the command is "port config ..." + 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