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 55A0445834; Wed, 21 Aug 2024 18:09:28 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 1BA09402E8; Wed, 21 Aug 2024 18:09:28 +0200 (CEST) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mails.dpdk.org (Postfix) with ESMTP id AF66A402B5 for ; Wed, 21 Aug 2024 18:09:26 +0200 (CEST) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 17CCFDA7; Wed, 21 Aug 2024 09:09:52 -0700 (PDT) Received: from e132423.cambridge.arm.com (e132423.arm.com [10.1.25.36]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 02E723F66E; Wed, 21 Aug 2024 09:09:24 -0700 (PDT) From: Alex Chapman To: dev@dpdk.org Cc: Alex Chapman , Honnappa Nagarahalli , Paul Szczepanek , Luca Vizzarro , =?UTF-8?q?Juraj=20Linke=C5=A1?= Subject: [PATCH] dts: add RSS functions to testpmd Date: Wed, 21 Aug 2024 17:09:05 +0100 Message-Id: <20240821160905.225594-1-alex.chapman@arm.com> X-Mailer: git-send-email 2.34.1 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 This patch adds the required functionality for the RSS key_update, RETA, and hash test suites. This includes: The setting of custom RETA values for routing packets to specific queues. The setting of the RSS mode on all ports, to specify how to hash the packets. The updating of the RSS hash key used during the hashing process. Alongside this, there is the addition of a __str__ method to the RSSOffloadTypesFlags class, so that when flag names are cast to a string they will use '-' as separators, instead of '_'. This allows them to be directly used within testpmd RSS commands without any further changes. Signed-off-by: Alex Chapman Reviewed-by: Luca Vizzarro --- dts/framework/remote_session/testpmd_shell.py | 84 ++++++++++++++++++- 1 file changed, 83 insertions(+), 1 deletion(-) diff --git a/dts/framework/remote_session/testpmd_shell.py b/dts/framework/remote_session/testpmd_shell.py index 18b0533658..6a2d8be6fa 100644 --- a/dts/framework/remote_session/testpmd_shell.py +++ b/dts/framework/remote_session/testpmd_shell.py @@ -23,7 +23,7 @@ from typing_extensions import Self, Unpack -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 @@ -305,6 +305,12 @@ def make_parser(cls) -> ParserFn: RSSOffloadTypesFlag.from_list_string, ) + def __str__(self): + """Stringifies the flag name.""" + if self.name is None: + return "" + return self.name.replace("_", "-") + class DeviceCapabilitiesFlag(Flag): """Flag representing the device capabilities.""" @@ -1178,6 +1184,82 @@ def set_forward_mode(self, mode: SimpleForwardingModes, verify: bool = True): f"Test pmd failed to set fwd mode to {mode.value}" ) + def port_config_rss_reta( + self, port_id: int, hash_index: int, queue_id: int, verify: bool = True + ) -> None: + """Configures a port's RSS redirection table. + + Args: + port_id: Port where redirection table will be configured. + hash_index: The index into the redirection table associated with the destination queue. + queue_id: The destination queue of the packet. + verify: If :data:`True`, it verifies if a port's redirection table + was correctly configured. + + Raises: + InteractiveCommandExecutionError: If `verify` is :data:`True` + Testpmd failed to config RSS reta. + """ + out = self.send_command(f"port config {port_id} rss reta ({hash_index},{queue_id})") + if verify: + if f"The reta size of port {port_id} is" not in out: + self._logger.debug(f"Failed to config RSS reta: \n{out}") + raise InteractiveCommandExecutionError("Testpmd failed to config RSS reta.") + + def port_config_all_rss_offload_type( + self, flag: RSSOffloadTypesFlag, verify: bool = True + ) -> None: + """Set the RSS mode on all ports. + + Args: + rss_offload_type: The RSS iptype all ports will be configured to. + verify: If :data:`True`, it verifies if all ports RSS offload type + was correctly configured. + + Raises: + InternalError: Offload Flag has contradictory values set. + InteractiveCommandExecutionError: If `verify` is :data:`True` + Testpmd failed to config the RSS mode on all ports. + """ + if not flag.name: + raise InternalError("Offload Flag has contradictory values set") + + out = self.send_command(f"port config all rss {flag.name}") + + if verify: + if "error" in out: + self._logger.debug(f"Failed to config the RSS mode on all ports: \n{out}") + raise InteractiveCommandExecutionError( + "Testpmd failed to config the RSS mode on all ports" + ) + + def port_config_rss_hash_key( + self, port_id: int, offload_type: RSSOffloadTypesFlag, hex_str: str, verify: bool = True + ) -> str: + """Set the RSS hash key for the specified port. + + Args: + port_id: Port the hash key will be set. + offload_type: The offload type the hash key will be applied to. + hex_str: The new hash key. + verify: If :data:`True`, RSS hash key has been correctly set. + + Raises: + InteractiveCommandExecutionError: If `verify` is :data:`True` + Testpmd failed to set the RSS hash key. + """ + output = self.send_command(f"port config {port_id} rss-hash-key {offload_type} {hex_str}") + + if verify: + if ( + "invalid - key must be a string of" in output + or "Bad arguments" in output + or "Error during getting device" in output + ): + self._logger.debug(f"Failed to set rss hash key: \n{output}") + raise InteractiveCommandExecutionError("Testpmd failed to set the RSS hash key.") + return output + def show_port_info_all(self) -> list[TestPmdPort]: """Returns the information of all the ports. -- 2.34.1