DPDK patches and discussions
 help / color / mirror / Atom feed
* [PATCH] dts: add RSS functions to testpmd
@ 2024-08-29 12:50 Alex Chapman
  2024-09-06 14:29 ` Juraj Linkeš
  0 siblings, 1 reply; 3+ messages in thread
From: Alex Chapman @ 2024-08-29 12:50 UTC (permalink / raw)
  To: dev
  Cc: Alex Chapman, Honnappa Nagarahalli, Paul Szczepanek,
	Luca Vizzarro, Juraj Linkeš

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 <alex.chapman@arm.com>
Reviewed-by: Luca Vizzarro <luca.vizzarro@arm.com>
---
 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 43e9f56517..7b66901f6e 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."""
@@ -723,6 +729,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


^ permalink raw reply	[flat|nested] 3+ messages in thread
* [PATCH] dts: add RSS functions to testpmd
@ 2024-08-21 16:09 Alex Chapman
  0 siblings, 0 replies; 3+ messages in thread
From: Alex Chapman @ 2024-08-21 16:09 UTC (permalink / raw)
  To: dev
  Cc: Alex Chapman, Honnappa Nagarahalli, Paul Szczepanek,
	Luca Vizzarro, Juraj Linkeš

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 <alex.chapman@arm.com>
Reviewed-by: Luca Vizzarro <luca.vizzarro@arm.com>
---
 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


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-09-06 14:29 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-08-29 12:50 [PATCH] dts: add RSS functions to testpmd Alex Chapman
2024-09-06 14:29 ` Juraj Linkeš
  -- strict thread matches above, loose matches on Subject: below --
2024-08-21 16:09 Alex Chapman

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).