dts: add RSS functions to testpmd
PATCH 1/1 dts: add RSS functions to testpmd
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.
--- dts/framework/remote_session/testpmd_shell.py | 84 ++++++++++++++++++- 1 file changed, 83 insertions(+), 1 deletion(-)
dts/framework/remote_session/testpmd_shell.py +83 -1
@@ -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.
Signature · 1 line
2.34.1
Two notes on sending patches. The patch is missing a version. I believe this is version 2?
Second, looks like you didn't send this as a reply to the first version of the patch. The message-id to use can be found in the patchwork patch page.
Quoted 34 lines · Alex Chapman
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 <[email protected]>Reviewed-by Luca Vizzarro <[email protected]>--- dts/framework/remote_session/testpmd_shell.py | 84 ++++++++++++++++++- 1 file changed, 83 insertions(+), 1 deletion(-)dts/framework/remote_session/testpmd_shell.py +1
-1@@ -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
dts/framework/remote_session/testpmd_shell.py def make_parser(cls) -> ParserFn: · line 309
Quoted 5 lines
dts/framework/remote_session/testpmd_shell.py +2
-0@@ -305,6 +305,12 @@ def make_parser(cls) -> ParserFn: RSSOffloadTypesFlag.from_list_string, ) + def __str__(self): + """Stringifies the flag name."""
Since the stringifying is basically a given, I'd put something else here, such as "Replace undercores with hyphens to produce valid testpmd value." or something similar.
Quoted 8 lines
dts/framework/remote_session/testpmd_shell.py +4
-0+ if self.name is None: + return "" + return self.name.replace("_", "-") + class DeviceCapabilitiesFlag(Flag): """Flag representing the device capabilities."""
dts/framework/remote_session/testpmd_shell.py def set_forward_mode(self, mode: SimpleForwardingModes, verify: bool = True): · line 735
Quoted 7 lines
dts/framework/remote_session/testpmd_shell.py +4
-0@@ -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.
Just a note here: I like to use imperative (configure), but we don't really enforce this in the framework (we have both imperative and third person).
dts/framework/remote_session/testpmd_shell.py def set_forward_mode(self, mode: SimpleForwardingModes, verify: bool = True): · line 738
Quoted 3 lines
dts/framework/remote_session/testpmd_shell.py +3
-0+ + Args: + port_id: Port where redirection table will be configured.
This is missing definite articles (which are present everywhere else):
port where redirection table -> the port where the redirection table
dts/framework/remote_session/testpmd_shell.py def set_forward_mode(self, mode: SimpleForwardingModes, verify: bool = True): · line 741
Quoted 3 lines
dts/framework/remote_session/testpmd_shell.py +3
-0+ 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
the "it" is redundant
Quoted 9 lines
dts/framework/remote_session/testpmd_shell.py +9
-0+ 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:
dts/framework/remote_session/testpmd_shell.py def set_forward_mode(self, mode: SimpleForwardingModes, verify: bool = True): · line 760
Quoted 10 lines
dts/framework/remote_session/testpmd_shell.py +10
-0+ 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.
This doesn't match the arg name, we should probably rename flag to rss_offload_type.
Also, RSSOffloadTypesFlag says:
Flag representing the RSS offload flow types supported by the NIC port.
I don't know what iptype is, we could just replace iptype with "offload flow type".
dts/framework/remote_session/testpmd_shell.py def set_forward_mode(self, mode: SimpleForwardingModes, verify: bool = True): · line 770
Quoted 10 lines
dts/framework/remote_session/testpmd_shell.py +10
-0+ 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 of curiosity, when can this happen?
Also, two more points:
1. Please end sentences with a dot. Check the whole patch.
2. I really don't like messages constructed like this as it doesn't help that much when debugging. Let's add more info, like what the contradiction is.
dts/framework/remote_session/testpmd_shell.py def set_forward_mode(self, mode: SimpleForwardingModes, verify: bool = True): · line 779
Quoted 9 lines
dts/framework/remote_session/testpmd_shell.py +9
-0+ + 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" + )
Here we could also add what mode we were configuring.
dts/framework/remote_session/testpmd_shell.py def set_forward_mode(self, mode: SimpleForwardingModes, verify: bool = True): · line 784
Quoted 5 lines
dts/framework/remote_session/testpmd_shell.py +5
-0+ + 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.
Now this is in imperative instead of third person. Let's pick one for the entire patch.
dts/framework/remote_session/testpmd_shell.py def set_forward_mode(self, mode: SimpleForwardingModes, verify: bool = True): · line 787
Quoted 3 lines
dts/framework/remote_session/testpmd_shell.py +3
-0+ + Args: + port_id: Port the hash key will be set.
This looks like an unfinished sentence, should it be set for (as in the docsting's first line)?
dts/framework/remote_session/testpmd_shell.py def set_forward_mode(self, mode: SimpleForwardingModes, verify: bool = True): · line 790
Quoted 3 lines
dts/framework/remote_session/testpmd_shell.py +3
-0+ 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.
verify that RSS has key
dts/framework/remote_session/testpmd_shell.py def set_forward_mode(self, mode: SimpleForwardingModes, verify: bool = True): · line 803
Quoted 13 lines
dts/framework/remote_session/testpmd_shell.py +13
-0+ + 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 + ):
Would it make sense to check for one positive instead of multiple negatives? Or is it not that simple?
dts/framework/remote_session/testpmd_shell.py def set_forward_mode(self, mode: SimpleForwardingModes, verify: bool = True): · line 805
Quoted 2 lines
dts/framework/remote_session/testpmd_shell.py +2
-0+ self._logger.debug(f"Failed to set rss hash key: \n{output}") + raise InteractiveCommandExecutionError("Testpmd failed to set the RSS hash key.")
We can also add extra info here: port, offload_type and the hex str.
Quoted 5 lines
dts/framework/remote_session/testpmd_shell.py +2
-0+ return output + def show_port_info_all(self) -> list[TestPmdPort]: """Returns the information of all the ports.
v2 cover Added RSS functions and tests.
In reply to Alex Chapmanv2:
- Added RSS capabilities check.
- Added testsuite that tests RSS hashes.
- Added testsuite that tests updating the RSS hash key.
- Added testsuite that verifies the RETA size.
Alex Chapman (5):
dts: add RSS functions to testpmd
dts: add utils for PMD RSS testsuites
dts: add PMD RSS hash testsuite
dts: add PMD RSS RETA testsuite
dts: add PMD RSS key update testsuite
Thomas Wilks (1):
dts: add NIC capabilities for hash algorithms
dts/framework/remote_session/testpmd_shell.py | 283 +++++++++++++++++- dts/tests/TestSuite_pmd_rss_hash.py | 121 ++++++++ dts/tests/TestSuite_pmd_rss_key_update.py | 168 +++++++++++ dts/tests/TestSuite_pmd_rss_reta.py | 101 +++++++ dts/tests/pmd_rss_utils.py | 195 ++++++++++++ 5 files changed, 854 insertions(+), 14 deletions(-) create mode 100644 dts/tests/TestSuite_pmd_rss_hash.py create mode 100644 dts/tests/TestSuite_pmd_rss_key_update.py create mode 100644 dts/tests/TestSuite_pmd_rss_reta.py create mode 100644 dts/tests/pmd_rss_utils.py
Signature · 1 line
2.43.0
PATCH v2 1/6 dts: add RSS functions to testpmd
From: Alex Chapman <[email protected]>
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.
--- dts/framework/remote_session/testpmd_shell.py | 137 ++++++++++++++++-- 1 file changed, 123 insertions(+), 14 deletions(-)
dts/framework/remote_session/testpmd_shell.py +123 -14
@@ -350,6 +350,12 @@ def make_parser(cls) -> ParserFn: RSSOffloadTypesFlag.from_list_string, ) + def __str__(self): + """Replaces underscores with hyphens to produce valid testpmd value.""" + if self.name is None: + return "" + return self.name.replace("_", "-") + class DeviceCapabilitiesFlag(Flag): """Flag representing the device capabilities."""
@@ -655,7 +661,8 @@ class TestPmdPort(TextParser): ) #: Maximum number of VMDq pools max_vmdq_pools_num: int | None = field( - default=None, metadata=TextParser.find_int(r"Maximum number of VMDq pools: (\d+)") + default=None, + metadata=TextParser.find_int(r"Maximum number of VMDq pools: (\d+)"), ) #:
@@ -1482,7 +1489,9 @@ def _wrapper(self: "TestPmdShell", *args: P.args, **kwargs: P.kwargs): return _wrapper -def add_remove_mtu(mtu: int = 1500) -> Callable[[TestPmdShellMethod], TestPmdShellMethod]: +def add_remove_mtu( + mtu: int = 1500, +) -> Callable[[TestPmdShellMethod], TestPmdShellMethod]: """Configure MTU to `mtu` on all ports, run the decorated function, then revert. Args:
@@ -1723,6 +1732,82 @@ def set_ports_queues(self, number_of: int) -> None: self.send_command(f"port config all rxq {number_of}") self.send_command(f"port config all txq {number_of}") + def port_config_rss_reta( + self, port_id: int, hash_index: int, queue_id: int, verify: bool = True + ) -> None: + """Configure a port's RSS redirection table. + + Args: + port_id: The port where the 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`, 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: + flag: 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: + InteractiveCommandExecutionError: If `verify` is :data:`True` + Testpmd failed to config the RSS mode on all ports. + """ + 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( + f"Testpmd failed to change RSS mode to {flag.name}" + ) + + def port_config_rss_hash_key( + self, + port_id: int, + offload_type: RSSOffloadTypesFlag, + hex_str: str, + verify: bool = True, + ) -> str: + """Sets the RSS hash key for the specified port. + + Args: + port_id: The port that will have the hash key applied to. + offload_type: The offload type the hash key will be applied to. + hex_str: The hash key to set. + verify: If :data:`True`, verify that RSS has the key. + + 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}", + skip_first_line=True, + ) + + if verify: + if output.strip(): + self._logger.debug(f"Failed to set rss hash key: \n{output}") + raise InteractiveCommandExecutionError( + f"Testpmd failed to set {hex_str} on {port_id} with a flag of {offload_type}." + ) + return output + def show_port_info_all(self) -> list[TestPmdPort]: """Returns the information of all the ports.
@@ -1939,22 +2024,28 @@ def csum_set_hw( {port_id}:\n{csum_output}""" ) - def flow_create(self, flow_rule: FlowRule, port_id: int) -> int: + def flow_create(self, flow_rule: FlowRule, port_id: int, verify: bool = True) -> int: """Creates a flow rule in the testpmd session. - This command is implicitly verified as needed to return the created flow rule id. - Args: flow_rule: :class:`FlowRule` object used for creating testpmd flow rule. port_id: Integer representing the port to use. + verify: If :data:`True`, the output of the command is scanned + to ensure the flow rule was created successfully. Raises: InteractiveCommandExecutionError: If flow rule is invalid. Returns: - Id of created flow rule. + Id of created flow rule as an integer. """ flow_output = self.send_command(f"flow create {port_id} {flow_rule}") + if verify: + if "created" not in flow_output: + self._logger.debug(f"Failed to create flow rule:\n{flow_output}") + raise InteractiveCommandExecutionError( + f"Failed to create flow rule:\n{flow_output}" + ) match = re.search(r"#(\d+)", flow_output) if match is not None: match_str = match.group(1)
@@ -1968,10 +2059,10 @@ def flow_delete(self, flow_id: int, port_id: int, verify: bool = True) -> None: """Deletes the specified flow rule from the testpmd session. Args: - flow_id: ID of the flow to remove. + flow_id: :class:`FlowRule` id used for deleting testpmd flow rule. port_id: Integer representing the port to use. verify: If :data:`True`, the output of the command is scanned - to ensure the flow rule was deleted successfully. + to ensure the flow rule was deleted successfully. Raises: InteractiveCommandExecutionError: If flow rule is invalid.
@@ -2639,7 +2730,10 @@ class NicCapability(NoAliasEnum): None, ) #: Device supports Large Receive Offload. - RX_OFFLOAD_TCP_LRO: TestPmdShellNicCapability = (TestPmdShell.get_capabilities_rx_offload, None) + RX_OFFLOAD_TCP_LRO: TestPmdShellNicCapability = ( + TestPmdShell.get_capabilities_rx_offload, + None, + ) #: Device supports QinQ (queue in queue) offload. RX_OFFLOAD_QINQ_STRIP: TestPmdShellNicCapability = ( TestPmdShell.get_capabilities_rx_offload,
@@ -2666,7 +2760,10 @@ class NicCapability(NoAliasEnum): None, ) #: Device supports receiving segmented mbufs. - RX_OFFLOAD_SCATTER: TestPmdShellNicCapability = (TestPmdShell.get_capabilities_rx_offload, None) + RX_OFFLOAD_SCATTER: TestPmdShellNicCapability = ( + TestPmdShell.get_capabilities_rx_offload, + None, + ) #: Device supports Timestamp. RX_OFFLOAD_TIMESTAMP: TestPmdShellNicCapability = ( TestPmdShell.get_capabilities_rx_offload,
@@ -2708,7 +2805,10 @@ class NicCapability(NoAliasEnum): None, ) #: Device supports all VLAN capabilities. - RX_OFFLOAD_VLAN: TestPmdShellNicCapability = (TestPmdShell.get_capabilities_rx_offload, None) + RX_OFFLOAD_VLAN: TestPmdShellNicCapability = ( + TestPmdShell.get_capabilities_rx_offload, + None, + ) #: Device supports Rx queue setup after device started. RUNTIME_RX_QUEUE_SETUP: TestPmdShellNicCapability = ( TestPmdShell.get_capabilities_show_port_info,
@@ -2720,9 +2820,15 @@ class NicCapability(NoAliasEnum): None, ) #: Device supports shared Rx queue among ports within Rx domain and switch domain. - RXQ_SHARE: TestPmdShellNicCapability = (TestPmdShell.get_capabilities_show_port_info, None) + RXQ_SHARE: TestPmdShellNicCapability = ( + TestPmdShell.get_capabilities_show_port_info, + None, + ) #: Device supports keeping flow rules across restart. - FLOW_RULE_KEEP: TestPmdShellNicCapability = (TestPmdShell.get_capabilities_show_port_info, None) + FLOW_RULE_KEEP: TestPmdShellNicCapability = ( + TestPmdShell.get_capabilities_show_port_info, + None, + ) #: Device supports keeping shared flow objects across restart. FLOW_SHARED_OBJECT_KEEP: TestPmdShellNicCapability = ( TestPmdShell.get_capabilities_show_port_info,
@@ -2734,7 +2840,10 @@ class NicCapability(NoAliasEnum): None, ) #: Device supports flow ctrl. - FLOW_CTRL: TestPmdShellNicCapability = (TestPmdShell.get_capabilities_flow_ctrl, None) + FLOW_CTRL: TestPmdShellNicCapability = ( + TestPmdShell.get_capabilities_flow_ctrl, + None, + ) def __call__( self,
Signature · 1 line
2.43.0
Quoted 16 lines · Thomas Wilks
From: Alex Chapman <[email protected]>
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.
Quoted 7 lines
Signed-off-by Alex Chapman <[email protected]>Signed-off-by Thomas Wilks <[email protected]>Reviewed-by Paul Szczepanek <[email protected]>---
PATCH v2 2/6 dts: add utils for PMD RSS testsuites
In reply to Thomas WilksFrom: Alex Chapman <[email protected]>
To reduce the amount of maintenance and code duplication, common functionality between the rss_key_update, pmd_rss_reta and pmd_rss_hash test suites has been collated into a single file called rss_utils.
It contains 3 main functions:
1. verify that a packets RSS hash correctly associates with the packets RSS queue.
2. Send test packets specific to RSS, such as symmetric packets that have the L4 port src and dst swapped.
3. The setting up of the RSS environment which is common between all 3 tets suites.
--- dts/tests/pmd_rss_utils.py | 195 +++++++++++++++++++++++++++++++++++++ 1 file changed, 195 insertions(+) create mode 100644 dts/tests/pmd_rss_utils.py
dts/tests/pmd_rss_utils.py new file +195 -0
@@ -0,0 +1,195 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright(c) 2025 Arm Limited + +"""PMD RSS Test Suite Utils. + +Utility functions for the pmd_rss_... test suite series +""" + +import random + +from scapy.layers.inet import IP, UDP +from scapy.layers.l2 import Ether + +from framework.exception import InteractiveCommandExecutionError +from framework.params.testpmd import SimpleForwardingModes +from framework.remote_session.testpmd_shell import ( + FlowRule, + RSSOffloadTypesFlag, + TestPmdShell, + TestPmdVerbosePacket, +) +from framework.test_suite import TestSuite + + +def VerifyHashQueue( + test_suite: TestSuite, + reta: list[int], + received_packets: list[TestPmdVerbosePacket], + verify_packet_pairs: bool, +) -> None: + """Verifies the packet hash corresponds to the packet queue. + + Given the received packets in the verbose output, iterate through each packet. + Lookup the packet hash in the RETA and get its intended queue. + Verify the intended queue is the same as the actual queue the packet was received in. + If the hash algorithm is symmetric, verify that pairs of packets have the same hash, + as the pairs of packets sent have "mirrored" L4 ports. + e.g. received_packets[0, 1, 2, 3, ...] hash(0) = hash(1), hash(2) = hash(3), ... + + Args: + test_suite: The reference to the currently running test suite. + reta: Used to get predicted queue based on hash. + received_packets: Packets received in the verbose output of testpmd. + verify_packet_pairs: Verify pairs of packets have the same hash. + + Raises: + InteractiveCommandExecutionError: If packet_hash is None. + """ + # List of packet hashes, used for symmetric algorithms + hash_list = [] + for packet in received_packets: + if packet.port_id != 0 or packet.src_mac != "02:00:00:00:00:00": + continue + + # Get packet hash + packet_hash = packet.rss_hash + if packet_hash is None: + raise InteractiveCommandExecutionError( + "Packet sent by the Traffic Generator has no RSS hash attribute." + ) + + packet_queue = packet.rss_queue + + # Calculate the predicted packet queue + predicted_reta_index = packet_hash % len(reta) + predicted_queue = reta[predicted_reta_index] + + # Verify packets are in the correct queue + test_suite.verify( + predicted_queue == packet_queue, + "Packet sent by the Traffic Generator has no RSS queue attribute.", + ) + + if verify_packet_pairs: + hash_list.append(packet_hash) + + if verify_packet_pairs: + # Go through pairs of hashes in list and verify they are the same + for odd_hash, even_hash in zip(hash_list[0::2], hash_list[1::2]): + test_suite.verify( + odd_hash == even_hash, + "Packet pair do not have same hash. Hash algorithm is not symmetric.", + ) + + +def SendTestPackets( + TestSuite: TestSuite, + testpmd: TestPmdShell, + send_additional_mirrored_packet: bool, +) -> list[TestPmdVerbosePacket]: + """Sends test packets. + + Send 10 packets from the TG to SUT, parsing the verbose output and returning it. + If the algorithm chosen is symmetric, send an additional packet for each initial + packet sent, which has the L4 src and dst swapped. + + Args: + TestSuite: The reference to the currently running test suite. + testpmd: Used to send packets and send commands to testpmd. + send_additional_mirrored_packet: Send an additional mirrored packet for each packet sent. + + Returns: + TestPmdVerbosePacket: List of packets. + """ + # Create test packets + packets = [] + for i in range(10): + packets.append( + Ether(src="02:00:00:00:00:00", dst="11:00:00:00:00:00") + / IP() + / UDP(sport=i, dport=i + 1), + ) + if send_additional_mirrored_packet: # If symmetric, send the inverse packets + packets.append( + Ether(src="02:00:00:00:00:00", dst="11:00:00:00:00:00") + / IP() + / UDP(sport=i + 1, dport=i), + ) + + # Set verbose packet information and start packet capture + testpmd.set_verbose(3) + testpmd.start() + testpmd.start_all_ports() + TestSuite.send_packets_and_capture(packets) + + # Stop packet capture and revert verbose packet information + testpmd_shell_out = testpmd.stop() + testpmd.set_verbose(0) + # Parse the packets and return them + return testpmd.extract_verbose_output(testpmd_shell_out) + + +def SetupRssEnvironment( + TestSuite: TestSuite, + testpmd: TestPmdShell, + num_queues: int, + flow_rule: FlowRule | None, +) -> tuple[list[int], int]: + """Sets up the testpmd environment for RSS test suites. + + This involves: + 1. Setting the testpmd forward mode to rx_only. + 2. Setting RSS on the NIC to UDP. + 3. Creating a flow if provided. + 4. Configuring RETA. + + The reta and key_size of the NIC are then returned + + Args: + TestSuite: TestSuite environment. + testpmd: Where the environment will be set. + num_queues: Number of queues in the RETA table. + flow_rule: The flow rule for altering packet fate. + + Raises: + InteractiveCommandExecutionError: If size of hash key for driver is None. + InteractiveCommandExecutionError: If size of RETA table for driver is None. + + Returns: + reta: Configured Redirection Table. + key_size: key size supported by NIC. + """ + ports = [] + for port_id, _ in enumerate(TestSuite.topology.sut_ports): + ports.append(port_id) + + port_info = testpmd.show_port_info(ports[0]) + + # Get hash key size + key_size = port_info.hash_key_size + if key_size is None: + raise InteractiveCommandExecutionError("Size of hash key for driver is None.") + + # Get RETA table size + reta_size = port_info.redirection_table_size + if reta_size is None: + raise InteractiveCommandExecutionError("Size of RETA table for driver is None.") + + # Set forward mode to receive only, to remove forwarded packets from verbose output + testpmd.set_forward_mode(SimpleForwardingModes.rxonly) + + # Reset RSS settings and only RSS udp packets + testpmd.port_config_all_rss_offload_type(RSSOffloadTypesFlag.udp) + + # Create flow rule + if flow_rule is not None: + testpmd.flow_create(flow_rule, ports[0]) + + # Configure the RETA with random queues + reta: list[int] = [] + for i in range(reta_size): + reta.insert(i, random.randint(0, num_queues - 1)) + testpmd.port_config_rss_reta(ports[0], i, reta[i]) + + return reta, key_size
Signature · 1 line
2.43.0
Re: [PATCH v2 2/6] dts: add utils for PMD RSS testsuites
Thanks Thomas and Alex.
Quoted 7 lines · Thomas Wilks
From: Alex Chapman <[email protected]>
To reduce the amount of maintenance and code duplication, common functionality between the
rss_key_update,pmd_rss_retaandpmd_rss_hashtest suites has been collated into a single file calledrss_utils.
Quoted 8 lines
It contains 3 main functions:
1. verify that a packets RSS hash correctly associates with the packets RSS queue.
2. Send test packets specific to RSS, such as symmetric packets that have the L4 port src and dst swapped.
3. The setting up of the RSS environment which is common between all 3 tets suites.
tets -> test.
Quoted 31 lines
Signed-off-by Alex Chapman <[email protected]>Signed-off-by Thomas Wilks <[email protected]>Reviewed-by Paul Szczepanek <[email protected]>--- dts/tests/pmd_rss_utils.py | 195 +++++++++++++++++++++++++++++++++++++ 1 file changed, 195 insertions(+) create mode 100644 dts/tests/pmd_rss_utils.pydts/tests/pmd_rss_utils.py new file +15
-0@@ -0,0 +1,195 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright(c) 2025 Arm Limited + +"""PMD RSS Test Suite Utils. + +Utility functions for the pmd_rss_... test suite series +""" + +import random + +from scapy.layers.inet import IP, UDP +from scapy.layers.l2 import Ether + +from framework.exception import InteractiveCommandExecutionError +from framework.params.testpmd import SimpleForwardingModes
dts/tests/pmd_rss_utils.py line 25
Quoted 10 lines
dts/tests/pmd_rss_utils.py new file +10
-0+from framework.remote_session.testpmd_shell import ( + FlowRule, + RSSOffloadTypesFlag, + TestPmdShell, + TestPmdVerbosePacket, +) +from framework.test_suite import TestSuite + + +def VerifyHashQueue(
Should be snake case - VerifyHashQueue -> verify_hash_queue.
And that applies to the later functions in this patch also.
Quoted 66 lines
dts/tests/pmd_rss_utils.py new file +8
-0+ test_suite: TestSuite, + reta: list[int], + received_packets: list[TestPmdVerbosePacket], + verify_packet_pairs: bool, +) -> None: + """Verifies the packet hash corresponds to the packet queue. + + Given the received packets in the verbose output, iterate througheach packet.
dts/tests/pmd_rss_utils.py new file +2
-0+ Lookup the packet hash in the RETA and get its intended queue. + Verify the intended queue is the same as the actual queue the packetwas received in.
+ If the hash algorithm is symmetric, verify that pairs of packets have
the same hash,dts/tests/pmd_rss_utils.py new file +2
-0+ as the pairs of packets sent have "mirrored" L4 ports. + e.g. received_packets[0, 1, 2, 3, ...] hash(0) = hash(1), hash(2) =hash(3), ...
dts/tests/pmd_rss_utils.py new file +5
-0+ + Args: + test_suite: The reference to the currently running test suite. + reta: Used to get predicted queue based on hash. + received_packets: Packets received in the verbose output oftestpmd.
dts/tests/pmd_rss_utils.py new file +16
-0+ verify_packet_pairs: Verify pairs of packets have the same hash. + + Raises: + InteractiveCommandExecutionError: If packet_hash is None. + """ + # List of packet hashes, used for symmetric algorithms + hash_list = [] + for packet in received_packets: + if packet.port_id != 0 or packet.src_mac != "02:00:00:00:00:00": + continue + + # Get packet hash + packet_hash = packet.rss_hash + if packet_hash is None: + raise InteractiveCommandExecutionError( + "Packet sent by the Traffic Generator has no RSS hashattribute."
dts/tests/pmd_rss_utils.py new file +12
-0+ ) + + packet_queue = packet.rss_queue + + # Calculate the predicted packet queue + predicted_reta_index = packet_hash % len(reta) + predicted_queue = reta[predicted_reta_index] + + # Verify packets are in the correct queue + test_suite.verify( + predicted_queue == packet_queue, + "Packet sent by the Traffic Generator has no RSS queueattribute.",
dts/tests/pmd_rss_utils.py new file +11
-0+ ) + + if verify_packet_pairs: + hash_list.append(packet_hash) + + if verify_packet_pairs: + # Go through pairs of hashes in list and verify they are the same + for odd_hash, even_hash in zip(hash_list[0::2], hash_list[1::2]): + test_suite.verify( + odd_hash == even_hash, + "Packet pair do not have same hash. Hash algorithm is notsymmetric.",
dts/tests/pmd_rss_utils.py line 86
Quoted 4 lines
dts/tests/pmd_rss_utils.py new file +4
-0+ ) + + +def SendTestPackets(
Aside from the snake case, I think this function name could more clearly indicate its purpose as it relates to RSS functions.
Quoted 119 lines
dts/tests/pmd_rss_utils.py new file +7
-0+ TestSuite: TestSuite, + testpmd: TestPmdShell, + send_additional_mirrored_packet: bool, +) -> list[TestPmdVerbosePacket]: + """Sends test packets. + + Send 10 packets from the TG to SUT, parsing the verbose output andreturning it.
+ If the algorithm chosen is symmetric, send an additional packet for
each initialdts/tests/pmd_rss_utils.py new file +6
-0+ packet sent, which has the L4 src and dst swapped. + + Args: + TestSuite: The reference to the currently running test suite. + testpmd: Used to send packets and send commands to testpmd. + send_additional_mirrored_packet: Send an additional mirroredpacket for each packet sent.
dts/tests/pmd_rss_utils.py new file +13
-0+ + Returns: + TestPmdVerbosePacket: List of packets. + """ + # Create test packets + packets = [] + for i in range(10): + packets.append( + Ether(src="02:00:00:00:00:00", dst="11:00:00:00:00:00") + / IP() + / UDP(sport=i, dport=i + 1), + ) + if send_additional_mirrored_packet: # If symmetric, send theinverse packets
dts/tests/pmd_rss_utils.py new file +43
-0+ packets.append( + Ether(src="02:00:00:00:00:00", dst="11:00:00:00:00:00") + / IP() + / UDP(sport=i + 1, dport=i), + ) + + # Set verbose packet information and start packet capture + testpmd.set_verbose(3) + testpmd.start() + testpmd.start_all_ports() + TestSuite.send_packets_and_capture(packets) + + # Stop packet capture and revert verbose packet information + testpmd_shell_out = testpmd.stop() + testpmd.set_verbose(0) + # Parse the packets and return them + return testpmd.extract_verbose_output(testpmd_shell_out) + + +def SetupRssEnvironment( + TestSuite: TestSuite, + testpmd: TestPmdShell, + num_queues: int, + flow_rule: FlowRule | None, +) -> tuple[list[int], int]: + """Sets up the testpmd environment for RSS test suites. + + This involves: + 1. Setting the testpmd forward mode to rx_only. + 2. Setting RSS on the NIC to UDP. + 3. Creating a flow if provided. + 4. Configuring RETA. + + The reta and key_size of the NIC are then returned + + Args: + TestSuite: TestSuite environment. + testpmd: Where the environment will be set. + num_queues: Number of queues in the RETA table. + flow_rule: The flow rule for altering packet fate. + + Raises: + InteractiveCommandExecutionError: If size of hash key for driveris None.
+ InteractiveCommandExecutionError: If size of RETA table for
driver is None.dts/tests/pmd_rss_utils.py new file +15
-0+ + Returns: + reta: Configured Redirection Table. + key_size: key size supported by NIC. + """ + ports = [] + for port_id, _ in enumerate(TestSuite.topology.sut_ports): + ports.append(port_id) + + port_info = testpmd.show_port_info(ports[0]) + + # Get hash key size + key_size = port_info.hash_key_size + if key_size is None: + raise InteractiveCommandExecutionError("Size of hash key fordriver is None.")
dts/tests/pmd_rss_utils.py new file +5
-0+ + # Get RETA table size + reta_size = port_info.redirection_table_size + if reta_size is None: + raise InteractiveCommandExecutionError("Size of RETA table fordriver is None.")
dts/tests/pmd_rss_utils.py new file +2
-0+ + # Set forward mode to receive only, to remove forwarded packets fromverbose output
dts/tests/pmd_rss_utils.py new file +16
-1+ testpmd.set_forward_mode(SimpleForwardingModes.rxonly) + + # Reset RSS settings and only RSS udp packets + testpmd.port_config_all_rss_offload_type(RSSOffloadTypesFlag.udp) + + # Create flow rule + if flow_rule is not None: + testpmd.flow_create(flow_rule, ports[0]) + + # Configure the RETA with random queues + reta: list[int] = [] + for i in range(reta_size): + reta.insert(i, random.randint(0, num_queues - 1)) + testpmd.port_config_rss_reta(ports[0], i, reta[i]) + + return reta, key_size --
Quoted 3 lines
2.43.0
Thanks, the function logic seems good.
I do want to reduce code duplication where possible, so having these functions makes sense in principle. But, we have tried to maintain such functions as a part of the testsuite class. So, I think that it would be fine to move these functions to the testsuite class - but let me know what you think.
Happy to discuss on Thursday at the DPDK CI meeting.
PATCH v2 3/6 dts: add PMD RSS hash testsuite
In reply to Thomas WilksFrom: Alex Chapman <[email protected]>
Port over the pmd_rss_hash test suite from old DTS. This suite verifies that the 4 supported types of hashing algorithm used in Receive Side Scaling (RSS) function correctly. Them being DEFAULT, TOEPLITZ SYMMETRIC_TOEPLITZ and SIMPLE_XOR. This test suite also verifies the supported hashing algorithms reported by the NIC are correct.
--- dts/tests/TestSuite_pmd_rss_hash.py | 118 ++++++++++++++++++++++++++++ 1 file changed, 118 insertions(+) create mode 100644 dts/tests/TestSuite_pmd_rss_hash.py
dts/tests/TestSuite_pmd_rss_hash.py new file +118 -0
@@ -0,0 +1,118 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright(c) 2025 Arm Limited + +"""RSS Hash testing suite. + +Hashing algorithms are used in conjunction with a RSS hash keys to hash packets. +This test suite verifies that updating the Hashing algorithms will +continue to correctly hash packets. + +Symmetric_toeplitz_sort hasn't been included due to it not being supported by +the rss func actions in the flow rule. +""" + +from framework.remote_session.testpmd_shell import FlowRule, TestPmdShell +from framework.test_suite import TestSuite, func_test +from framework.testbed_model.capability import NicCapability, requires +from framework.testbed_model.topology import TopologyType +from framework.utils import StrEnum + +from .pmd_rss_utils import ( # type: ignore[import-untyped] + SendTestPackets, + SetupRssEnvironment, + VerifyHashQueue, +) + +NUM_QUEUES = 16 + + +class HashAlgorithm(StrEnum): + """Enum of hashing algorithms.""" + + DEFAULT = "default" + SIMPLE_XOR = "simple_xor" + TOEPLITZ = "toeplitz" + SYMMETRIC_TOEPLITZ = "symmetric_toeplitz" + + +@requires(topology_type=TopologyType.one_link) +class TestPmdRssHash(TestSuite): + """PMD RSS Hash test suite. + + Verifies the redirection table when updating the size. + The suite contains four tests, one for each hash algorithms. + """ + + def VerifyHashFunction(self, hash_algorithm: HashAlgorithm) -> None: + """Verifies the hash function is supported by the NIC. + + Args: + hash_algorithm: The hash algorithm to be tested. + """ + is_symmetric = hash_algorithm == HashAlgorithm.SYMMETRIC_TOEPLITZ + # Build flow rule + flow_rule = FlowRule( + group_id=0, + direction="ingress", + pattern=["eth / ipv4 / udp"], + actions=[f"rss types ipv4-udp end queues end func {str(hash_algorithm).lower()}"], + ) + + # Run the key update test suite with an asymmetric hash algorithm + with TestPmdShell( + rx_queues=NUM_QUEUES, + tx_queues=NUM_QUEUES, + ) as testpmd: + # Setup testpmd environment for RSS, create RETA table, return RETA table and key_size + reta, _ = SetupRssEnvironment(self, testpmd, NUM_QUEUES, flow_rule) + # Send udp packets and ensure hash corresponds with queue + parsed_output = SendTestPackets(self, testpmd, is_symmetric) + VerifyHashQueue(self, reta, parsed_output, is_symmetric) + + @func_test + def TestDefaultHashAlgorithm(self) -> None: + """Default hashing algorithm test. + + Steps: + Setup RSS environment using the default RSS hashing algorithm + and send test packets. + Verify: + Packet hash corresponds to the packet queue. + """ + self.VerifyHashFunction(HashAlgorithm.DEFAULT) + + @func_test + def TestToeplitzHashAlgorithm(self) -> None: + """Toeplitz hashing algorithm test. + + Steps: + Setup RSS environment using the toeplitz RSS hashing algorithm and send test packets. + Verify: + Packet hash corresponds to the packet queue. + """ + self.VerifyHashFunction(HashAlgorithm.TOEPLITZ) + + @func_test + def TestSymmetricToeplitzHashAlgorithm(self) -> None: + """Symmetric toeplitz hashing algorithm test. + + Steps: + Setup RSS environment using the symmetric_toeplitz RSS hashing algorithm + and send test packets. + Verify: + Packet hash corresponds to the packet queue. + """ + self.VerifyHashFunction(HashAlgorithm.SYMMETRIC_TOEPLITZ) + + @requires(NicCapability.XOR_SUPPORT) + @func_test + def TestSimpleXorHashAlgorithm(self) -> None: + """Simple xor hashing algorithm test. + + Steps: + Setup RSS environment using the simple xor RSS hashing algorithm + and send test packets. + Verify: + Packet hash corresponds to the packet queue. + """ + self.VerifyHashFunction(HashAlgorithm.SIMPLE_XOR)
Signature · 1 line
2.43.0
Re: [PATCH v2 3/6] dts: add PMD RSS hash testsuite
Quoted 153 lines · Thomas Wilks
From: Alex Chapman <[email protected]>
Port over the
pmd_rss_hashtest suite from old DTS. This suite verifies that the 4 supported types of hashing algorithm used in Receive Side Scaling (RSS) function correctly. Them being DEFAULT, TOEPLITZSYMMETRIC_TOEPLITZandSIMPLE_XOR. This test suite also verifies the supported hashing algorithms reported by the NIC are correct.Signed-off-by Alex Chapman <[email protected]>Signed-off-by Thomas Wilks <[email protected]>Reviewed-by Paul Szczepanek <[email protected]>--- dts/tests/TestSuite_pmd_rss_hash.py | 118 ++++++++++++++++++++++++++++ 1 file changed, 118 insertions(+) create mode 100644 dts/tests/TestSuite_pmd_rss_hash.pydts/tests/TestSuite_pmd_rss_hash.py new file +6
-0@@ -0,0 +1,118 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright(c) 2025 Arm Limited + +"""RSS Hash testing suite. + +Hashing algorithms are used in conjunction with a RSS hash keys to hashpackets.
dts/tests/TestSuite_pmd_rss_hash.py new file +4
-0+This test suite verifies that updating the Hashing algorithms will +continue to correctly hash packets. + +Symmetric_toeplitz_sort hasn't been included due to it not beingsupported by
dts/tests/TestSuite_pmd_rss_hash.py new file +48
-0+the rss func actions in the flow rule. +""" + +from framework.remote_session.testpmd_shell import FlowRule, TestPmdShell +from framework.test_suite import TestSuite, func_test +from framework.testbed_model.capability import NicCapability, requires +from framework.testbed_model.topology import TopologyType +from framework.utils import StrEnum + +from .pmd_rss_utils import ( # type: ignore[import-untyped] + SendTestPackets, + SetupRssEnvironment, + VerifyHashQueue, +) + +NUM_QUEUES = 16 + + +class HashAlgorithm(StrEnum): + """Enum of hashing algorithms.""" + + DEFAULT = "default" + SIMPLE_XOR = "simple_xor" + TOEPLITZ = "toeplitz" + SYMMETRIC_TOEPLITZ = "symmetric_toeplitz" + + +@requires(topology_type=TopologyType.one_link) +class TestPmdRssHash(TestSuite): + """PMD RSS Hash test suite. + + Verifies the redirection table when updating the size. + The suite contains four tests, one for each hash algorithms. + """ + + def VerifyHashFunction(self, hash_algorithm: HashAlgorithm) -> None: + """Verifies the hash function is supported by the NIC. + + Args: + hash_algorithm: The hash algorithm to be tested. + """ + is_symmetric = hash_algorithm == HashAlgorithm.SYMMETRIC_TOEPLITZ + # Build flow rule + flow_rule = FlowRule( + group_id=0, + direction="ingress", + pattern=["eth / ipv4 / udp"], + actions=[f"rss types ipv4-udp end queues end func{str(hash_algorithm).lower()}"],
dts/tests/TestSuite_pmd_rss_hash.py new file +8
-0+ ) + + # Run the key update test suite with an asymmetric hash algorithm + with TestPmdShell( + rx_queues=NUM_QUEUES, + tx_queues=NUM_QUEUES, + ) as testpmd: + # Setup testpmd environment for RSS, create RETA table,return RETA table and
key_size
+ reta, _ = SetupRssEnvironment(self, testpmd,NUM_QUEUES,flow_rule)dts/tests/TestSuite_pmd_rss_hash.py new file +22
-0+ # Send udp packets and ensure hash corresponds with queue + parsed_output = SendTestPackets(self, testpmd, is_symmetric) + VerifyHashQueue(self, reta, parsed_output, is_symmetric) + + @func_test + def TestDefaultHashAlgorithm(self) -> None: + """Default hashing algorithm test. + + Steps: + Setup RSS environment using the default RSS hashing algorithm + and send test packets. + Verify: + Packet hash corresponds to the packet queue. + """ + self.VerifyHashFunction(HashAlgorithm.DEFAULT) + + @func_test + def TestToeplitzHashAlgorithm(self) -> None: + """Toeplitz hashing algorithm test. + + Steps: + Setup RSS environment using the toeplitz RSS hashingalgorithm and send test packets.
dts/tests/TestSuite_pmd_rss_hash.py new file +11
-0+ Verify: + Packet hash corresponds to the packet queue. + """ + self.VerifyHashFunction(HashAlgorithm.TOEPLITZ) + + @func_test + def TestSymmetricToeplitzHashAlgorithm(self) -> None: + """Symmetric toeplitz hashing algorithm test. + + Steps: + Setup RSS environment using the symmetric_toeplitz RSShashing algorithm
dts/tests/TestSuite_pmd_rss_hash.py new file +13
-0+ and send test packets. + Verify: + Packet hash corresponds to the packet queue. + """ + self.VerifyHashFunction(HashAlgorithm.SYMMETRIC_TOEPLITZ) + + @requires(NicCapability.XOR_SUPPORT) + @func_test + def TestSimpleXorHashAlgorithm(self) -> None: + """Simple xor hashing algorithm test. + + Steps: + Setup RSS environment using the simple xor RSS hashingalgorithm
dts/tests/TestSuite_pmd_rss_hash.py new file +5
-1+ and send test packets. + Verify: + Packet hash corresponds to the packet queue. + """ + self.VerifyHashFunction(HashAlgorithm.SIMPLE_XOR) --
Quoted 3 lines
2.43.0
The testsuite looks good although the functions need to move to snake style naming convention.
Tested on an Intel XL710, which skipped all but the default hash algorithm (passing).
PATCH v2 4/6 dts: add PMD RSS RETA testsuite
In reply to Thomas WilksFrom: Alex Chapman <[email protected]>
Port over the pmd_rss_reta test suite from old DTS. This suite verifies that Redirection Tables (RETAs) of different sizes function correctly in Receive Side Scaling (RSS). This test suite also verifies that the reported reta size of the NIC is correct.
--- dts/tests/TestSuite_pmd_rss_reta.py | 101 ++++++++++++++++++++++++++++ 1 file changed, 101 insertions(+) create mode 100644 dts/tests/TestSuite_pmd_rss_reta.py
dts/tests/TestSuite_pmd_rss_reta.py new file +101 -0
@@ -0,0 +1,101 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright(c) 2025 Arm Limited + +"""RSS RETA (redirection table) Test Suite. + +The RETA is used in RSS to redirect packets to different queues based on the +least significant bits of the packets hash. +This suite tests updating the size of the RETA and verifying the reported RETA size. +""" + +from framework.remote_session.testpmd_shell import TestPmdShell +from framework.test_suite import TestSuite, func_test +from framework.testbed_model.capability import requires +from framework.testbed_model.topology import TopologyType + +from .pmd_rss_utils import ( # type: ignore[import-untyped] + SendTestPackets, + SetupRssEnvironment, + VerifyHashQueue, +) + +ACTUAL_RETA_SIZE = 512 + + +@requires(topology_type=TopologyType.one_link) +class TestPmdRssReta(TestSuite): + """PMD RSS Reta test suite. + + Verifies the redirection table when updating the size. + The suite contains four tests, three for different RETA sizes + and one for verifying the reported RETA size. + """ + + def CheckRetaNQueues(self, num_queues: int) -> None: + """Create RETA of size n, send packets, verify packets end up in correct queue. + + Args: + num_queues: Number of rx/tx queues. + """ + with TestPmdShell( + rx_queues=num_queues, + tx_queues=num_queues, + ) as testpmd: + # Setup testpmd for RSS, create RETA table, return RETA table and key_size + reta, _ = SetupRssEnvironment(self, testpmd, num_queues, None) + + # Send UDP packets and ensure hash corresponds with queue + parsed_output = SendTestPackets(self, testpmd, False) + VerifyHashQueue(self, reta, parsed_output, False) + + @func_test + def TestReta2Queues(self) -> None: + """RETA rx/tx queues 2 test. + + Steps: + Setup RSS environment and send Test packets. + Verify: + Packet hash corresponds to hash queue. + """ + self.CheckRetaNQueues(2) + + @func_test + def TestReta9Queues(self) -> None: + """RETA rx/tx queues 9 test. + + Steps: + Setup RSS environment and send Test packets. + Verify: + Packet hash corresponds to hash queue. + """ + self.CheckRetaNQueues(9) + + @func_test + def TestReta16Queues(self) -> None: + """RETA rx/tx queues 16 test. + + Steps: + Setup RSS environment and send Test packets. + Verify: + Packet hash corresponds to hash queue. + """ + self.CheckRetaNQueues(16) + + @func_test + def TestReportedRetaSize(self) -> None: + """Reported RETA size test. + + Steps: + Fetch reported reta size. + Verify: + Reported RETA size is equal to the actual RETA size. + """ + with TestPmdShell() as testpmd: + self.topology.sut_port_egress.config + # Get RETA table size + port_info = testpmd.show_port_info(0) + reported_reta_size = port_info.redirection_table_size + self.verify( + reported_reta_size == ACTUAL_RETA_SIZE, + "Reported RETA size is not the same as the config file.", + )
Signature · 1 line
2.43.0
PATCH v2 5/6 dts: add PMD RSS key update testsuite
In reply to Thomas WilksFrom: Alex Chapman <[email protected]>
Port over the rss_key_update test suite from old DTS. This suite verifies that setting a new hash key when Receive Side Scaling (RSS) will result in a change in the packets destination queue. This test suite also verifies that the reported key size of the NIC is correct.
--- dts/tests/TestSuite_pmd_rss_key_update.py | 168 ++++++++++++++++++++++ 1 file changed, 168 insertions(+) create mode 100644 dts/tests/TestSuite_pmd_rss_key_update.py
dts/tests/TestSuite_pmd_rss_key_update.py new file +168 -0
@@ -0,0 +1,168 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright(c) 2025 Arm Limited + +"""RSS Key Update testing suite. + +RSS hash keys are used in conjunction with a hashing algorithm to hash packets. +This test suite verifies that updating the RSS hash key will change the hash +generated if the hashing algorithm stays the same. +""" + +import random + +from framework.exception import InteractiveCommandExecutionError +from framework.remote_session.testpmd_shell import ( + FlowRule, + RSSOffloadTypesFlag, + TestPmdShell, +) +from framework.test_suite import TestSuite, func_test +from framework.testbed_model.capability import requires +from framework.testbed_model.topology import TopologyType + +from .pmd_rss_utils import ( # type: ignore[import-untyped] + SendTestPackets, + SetupRssEnvironment, + VerifyHashQueue, +) + +NUM_QUEUES = 16 + +ACTUAL_KEY_SIZE = 52 + + +@requires(topology_type=TopologyType.one_link) +class TestPmdRssKeyUpdate(TestSuite): + """The DPDK RSS key update test suite. + + Configure the redirection table to have random entries. + Create a flow rule so ipv4-udp packets utalise the desired RSS hash algorithm. + Send packets, and verify they are in the desired queue based on the redirection table. + Update the RSS hash key. + Send packets, and verify they are in the desired queue based on the redirection table. + Verify the packet hashes before and after the key update are different. + """ + + @func_test + def TestKeyUpdate( + self, + ) -> None: + """Update RSS hash key test. + + Steps: + Setup the RSS environment, send test packet verify the hash queue based on the + RETA table, Reset the flow rules and update the hash key. + Create the flow and send/verify the hash/queue of the packets again. + + Verify: + Verify the packet hashes before and after the hash key was updated are not the same. + to show the key update was successful. + """ + # Create flow rule + flow_rule = FlowRule( + group_id=0, + direction="ingress", + pattern=["eth / ipv4 / udp"], + actions=["rss types ipv4-udp end queues end func default"], + ) + + with TestPmdShell( + memory_channels=4, + rx_queues=NUM_QUEUES, + tx_queues=NUM_QUEUES, + ) as testpmd: + # Setup testpmd environment for RSS, create RETA table, return RETA table and key_size + reta, key_size = SetupRssEnvironment(self, testpmd, NUM_QUEUES, flow_rule) + + # Send UDP packets and ensure hash corresponds with queue + pre_update_output = SendTestPackets(self, testpmd, False) + + VerifyHashQueue(self, reta, pre_update_output, False) + + # Reset RSS settings and only RSS UDP packets + testpmd.port_config_all_rss_offload_type(RSSOffloadTypesFlag.udp) + + # Create new hash key and update it + new_hash_key = "".join([random.choice("0123456789ABCDEF") for n in range(key_size * 2)]) + testpmd.port_config_rss_hash_key(0, RSSOffloadTypesFlag.ipv4_udp, new_hash_key) + + # Create flow rule + + for port_id, _ in enumerate(self.topology.sut_ports): + testpmd.flow_create(flow_rule, port_id) + + # Send UDP packets and ensure hash corresponds with queue + post_update_output = SendTestPackets(self, testpmd, False) + VerifyHashQueue(self, reta, pre_update_output, False) + + self.verify( + pre_update_output != post_update_output, + "The hash key had no effect on the packets hash.", + ) + + @func_test + def TestSetHashKeyShortLong(self) -> None: + """Set hash key short long test. + + Steps: + Fetch the hash key size, create two random hash keys one key that is too short and one + that is too long. + + Verify: + Verify that it is not possible to set the shorter key. + Verify that it is not possible to set the longer key. + + Raises: + InteractiveCommandExecutionError: If port info dose not contain hash key size. + """ + with TestPmdShell( + memory_channels=4, + rx_queues=NUM_QUEUES, + tx_queues=NUM_QUEUES, + ) as testpmd: + # Get RETA and key size + port_info = testpmd.show_port_info(0) + + # Get hash key size + key_size = port_info.hash_key_size + if key_size is None: + raise InteractiveCommandExecutionError("Port info does not contain hash key size.") + + # Create 2 hash keys based on the NIC capabilities + short_key = "".join( + [random.choice("0123456789ABCDEF") for n in range(key_size * 2 - 2)] + ) + long_key = "".join([random.choice("0123456789ABCDEF") for n in range(key_size * 2 + 2)]) + + # Verify a short key cannot be set + short_key_out = testpmd.port_config_rss_hash_key( + 0, RSSOffloadTypesFlag.ipv4_udp, short_key, False + ) + self.verify( + "invalid" in short_key_out, + "Able to set hash key shorter than specified.", + ) + + # Verify a long key cannot be set + long_key_out = testpmd.port_config_rss_hash_key( + 0, RSSOffloadTypesFlag.ipv4_udp, long_key, False + ) + self.verify("invalid" in long_key_out, "Able to set hash key longer than specified.") + + @func_test + def TestReportedKeySize(self) -> None: + """Verify reported hash key size is the same as the NIC capabilities. + + Steps: + Fetch the hash key size and compare to the actual key size. + Verify: + Reported key size is the same as the actual key size. + """ + with TestPmdShell() as testpmd: + port_info = testpmd.show_port_info(0) + reported_key_size = port_info.hash_key_size + + self.verify( + reported_key_size == ACTUAL_KEY_SIZE, + "Reported key size is not the same as the config file.", + )
Signature · 1 line
2.43.0
PATCH v2 6/6 dts: add NIC capabilities for hash algorithms
In reply to Thomas WilksAdded checks for if a nic supports the simple_xor, symmetric_toeplitz, symmetric_toeplitz_sort, toeplitz, and default hashing algorithms.
--- dts/framework/remote_session/testpmd_shell.py | 146 ++++++++++++++++++ dts/tests/TestSuite_pmd_rss_hash.py | 5 +- 2 files changed, 150 insertions(+), 1 deletion(-)
dts/framework/remote_session/testpmd_shell.py +146 -0
@@ -2678,6 +2678,127 @@ def get_capabilities_flow_ctrl( else: unsupported_capabilities.add(NicCapability.FLOW_CTRL) + def get_capabilities_xor_rss_hash_algorithms( + self, + supported_capabilities: MutableSet["NicCapability"], + unsupported_capabilities: MutableSet["NicCapability"], + ) -> None: + """Get simple_xor rss hash algorithm capability and check for testpmd failure. + + Args: + supported_capabilities: Supported capabilities will be added to this set. + unsupported_capabilities: Unsupported capabilities will be added to this set. + """ + self.get_capabilities_rss_hash_algorithms( + "simple_xor", + NicCapability.RSS_HASH_XOR, + supported_capabilities, + unsupported_capabilities, + ) + + def get_capabilities_symmetric_toeplitz_rss_hash_algorithms( + self, + supported_capabilities: MutableSet["NicCapability"], + unsupported_capabilities: MutableSet["NicCapability"], + ) -> None: + """Get symmetric_toeplitz rss hash algorithm capability and check for testpmd failure. + + Args: + supported_capabilities: Supported capabilities will be added to this set. + unsupported_capabilities: Unsupported capabilities will be added to this set. + """ + self.get_capabilities_rss_hash_algorithms( + "symmetric Toeplitz", + NicCapability.RSS_HASH_SYMMETRIC_TOEPLITZ, + supported_capabilities, + unsupported_capabilities, + ) + + def get_capabilities_toeplitz_rss_hash_algorithms( + self, + supported_capabilities: MutableSet["NicCapability"], + unsupported_capabilities: MutableSet["NicCapability"], + ) -> None: + """Get toeplitz rss hash algorithm capability and check for testpmd failure. + + Args: + supported_capabilities: Supported capabilities will be added to this set. + unsupported_capabilities: Unsupported capabilities will be added to this set. + """ + self.get_capabilities_rss_hash_algorithms( + "toeplitz", + NicCapability.RSS_HASH_TOEPLITZ, + supported_capabilities, + unsupported_capabilities, + ) + + def get_capabilities_default_rss_hash_algorithms( + self, + supported_capabilities: MutableSet["NicCapability"], + unsupported_capabilities: MutableSet["NicCapability"], + ) -> None: + """Get default rss hash algorithm capability and check for testpmd failure. + + Args: + supported_capabilities: Supported capabilities will be added to this set. + unsupported_capabilities: Unsupported capabilities will be added to this set. + """ + self.get_capabilities_rss_hash_algorithms( + "default", + NicCapability.RSS_HASH_DEFAULT, + supported_capabilities, + unsupported_capabilities, + ) + + def get_capabilities_symmetric_toeplitz_sort_rss_hash_algorithms( + self, + supported_capabilities: MutableSet["NicCapability"], + unsupported_capabilities: MutableSet["NicCapability"], + ) -> None: + """Get symmetric_toeplitz_sort rss hash algorithm capability and check for testpmd failure. + + Args: + supported_capabilities: Supported capabilities will be added to this set. + unsupported_capabilities: Unsupported capabilities will be added to this set. + """ + self.get_capabilities_rss_hash_algorithms( + "symmetric_toeplitz_sort", + NicCapability.RSS_HASH_SYMMETRIC_TOEPLITZ_SORT, + supported_capabilities, + unsupported_capabilities, + ) + + def get_capabilities_rss_hash_algorithms( + self, + algorithm: str, + NicCapability, + supported_capabilities: MutableSet["NicCapability"], + unsupported_capabilities: MutableSet["NicCapability"], + ): + """Get algorithm and check for capability. + + Args: + algorithm: The rss algorithm that is being tested. + NicCapability: The nic capability constant to be added to one of the MutableSets. + 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 hash capabilities for {algorithm} algorithm.") + self.send_command("port stop all") + self.send_command("port config all rxq 16") + self.send_command("port config all txq 16") + self.send_command("port start all") + command = f"show port {self.ports[0].id} rss-hash algorithm" + output = self.send_command(command) + if algorithm in output: + supported_capabilities.add(NicCapability) + else: + unsupported_capabilities.add(NicCapability) + self.send_command("port stop all") + self.send_command("port config all rxq 0") + self.send_command("port config all txq 0") + class NicCapability(NoAliasEnum): """A mapping between capability names and the associated :class:`TestPmdShell` methods.
@@ -2844,6 +2965,31 @@ class NicCapability(NoAliasEnum): TestPmdShell.get_capabilities_flow_ctrl, None, ) + #: Device supports simple_xor algorithm. + RSS_HASH_XOR: TestPmdShellNicCapability = ( + TestPmdShell.get_capabilities_xor_rss_hash_algorithms, + None, + ) + #: Device supports symmetric_toeplitz algorithm. + RSS_HASH_SYMMETRIC_TOEPLITZ: TestPmdShellNicCapability = ( + TestPmdShell.get_capabilities_symmetric_toeplitz_rss_hash_algorithms, + None, + ) + #: Device supports toeplitz algorithm. + RSS_HASH_TOEPLITZ: TestPmdShellNicCapability = ( + TestPmdShell.get_capabilities_toeplitz_rss_hash_algorithms, + None, + ) + #: Device supports default algorithm. + RSS_HASH_DEFAULT: TestPmdShellNicCapability = ( + TestPmdShell.get_capabilities_default_rss_hash_algorithms, + None, + ) + #: Device supports symmetric_toeplitz_sort algorithm. + RSS_HASH_SYMMETRIC_TOEPLITZ_SORT: TestPmdShellNicCapability = ( + TestPmdShell.get_capabilities_symmetric_toeplitz_sort_rss_hash_algorithms, + None, + ) def __call__( self,
dts/tests/TestSuite_pmd_rss_hash.py +4 -1
@@ -69,6 +69,7 @@ def VerifyHashFunction(self, hash_algorithm: HashAlgorithm) -> None: parsed_output = SendTestPackets(self, testpmd, is_symmetric) VerifyHashQueue(self, reta, parsed_output, is_symmetric) + @requires(NicCapability.RSS_HASH_DEFAULT) @func_test def TestDefaultHashAlgorithm(self) -> None: """Default hashing algorithm test.
@@ -81,6 +82,7 @@ def TestDefaultHashAlgorithm(self) -> None: """ self.VerifyHashFunction(HashAlgorithm.DEFAULT) + @requires(NicCapability.RSS_HASH_TOEPLITZ) @func_test def TestToeplitzHashAlgorithm(self) -> None: """Toeplitz hashing algorithm test.
@@ -92,6 +94,7 @@ def TestToeplitzHashAlgorithm(self) -> None: """ self.VerifyHashFunction(HashAlgorithm.TOEPLITZ) + @requires(NicCapability.RSS_HASH_SYMMETRIC_TOEPLITZ) @func_test def TestSymmetricToeplitzHashAlgorithm(self) -> None: """Symmetric toeplitz hashing algorithm test.
@@ -104,7 +107,7 @@ def TestSymmetricToeplitzHashAlgorithm(self) -> None: """ self.VerifyHashFunction(HashAlgorithm.SYMMETRIC_TOEPLITZ) - @requires(NicCapability.XOR_SUPPORT) + @requires(NicCapability.RSS_HASH_XOR) @func_test def TestSimpleXorHashAlgorithm(self) -> None: """Simple xor hashing algorithm test.
Signature · 1 line
2.43.0
v3 cover dts: add RSS functions and test suite
In reply to Thomas WilksHi all,
This is v3 of the RSS test suites which has been rebased onto the latest patches.
I’m also requesting comments and some help with an issue where the packet RSS queue and
the predicted RSS queue differ when running on ConnectX-6 NICs while being the same on E810-C NICs. I’m currently in the process of refactoring the test suites and addressing
the review comments from v2. Below is a summary of the changes made so far that are included in this version:
Changes in v3:
- Merged the RSS test suites into a single file for better maintainability.
- Moved the supporting functions into the same test suite file and removed the previous separate function file.
- Combined the reta_key_reta_queues test cases into a single test case.
- Added new test cases to support flow rule creation on ConnectX-6 NICs.
- Removed requirements for specific hashing algorithms which has been replaced the flow_validate function.
Regards,
Thomas Wilks
Alex Chapman (1):
dts: add RSS functions to testpmd
Thomas Wilks (1):
dts: add PMD RSS testsuite
dts/framework/remote_session/testpmd_shell.py | 132 +++- dts/tests/TestSuite_pmd_rss.py | 610 ++++++++++++++++++ 2 files changed, 729 insertions(+), 13 deletions(-) create mode 100644 dts/tests/TestSuite_pmd_rss.py
Signature · 1 line
2.43.0
RFC PATCH v3 1/2 dts: add RSS functions to testpmd
From: Alex Chapman <[email protected]>
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.
--- dts/framework/remote_session/testpmd_shell.py | 132 ++++++++++++++++-- 1 file changed, 119 insertions(+), 13 deletions(-)
dts/framework/remote_session/testpmd_shell.py +119 -13
@@ -343,6 +343,12 @@ def make_parser(cls) -> ParserFn: RSSOffloadTypesFlag.from_list_string, ) + def __str__(self): + """Replaces underscores with hyphens to produce valid testpmd value.""" + if self.name is None: + return "" + return self.name.replace("_", "-") + class DeviceCapabilitiesFlag(Flag): """Flag representing the device capabilities."""
@@ -648,7 +654,8 @@ class TestPmdPort(TextParser): ) #: Maximum number of VMDq pools max_vmdq_pools_num: int | None = field( - default=None, metadata=TextParser.find_int(r"Maximum number of VMDq pools: (\d+)") + default=None, + metadata=TextParser.find_int(r"Maximum number of VMDq pools: (\d+)"), ) #:
@@ -1480,7 +1487,9 @@ def _wrapper(self: "TestPmdShell", *args: P.args, **kwargs: P.kwargs): return _wrapper -def add_remove_mtu(mtu: int = 1500) -> Callable[[TestPmdShellMethod], TestPmdShellMethod]: +def add_remove_mtu( + mtu: int = 1500, +) -> Callable[[TestPmdShellMethod], TestPmdShellMethod]: """Configure MTU to `mtu` on all ports, run the decorated function, then revert. Args:
@@ -1734,6 +1743,82 @@ def close_all_ports(self, verify: bool = True) -> None: if not all(f"Port {p_id} is closed" in port_close_output for p_id in range(num_ports)): raise InteractiveCommandExecutionError("Ports were not closed successfully.") + def port_config_rss_reta( + self, port_id: int, hash_index: int, queue_id: int, verify: bool = True + ) -> None: + """Configure a port's RSS redirection table. + + Args: + port_id: The port where the 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`, 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: + flag: 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: + InteractiveCommandExecutionError: If `verify` is :data:`True` + Testpmd failed to config the RSS mode on all ports. + """ + 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( + f"Testpmd failed to change RSS mode to {flag.name}" + ) + + def port_config_rss_hash_key( + self, + port_id: int, + offload_type: RSSOffloadTypesFlag, + hex_str: str, + verify: bool = True, + ) -> str: + """Sets the RSS hash key for the specified port. + + Args: + port_id: The port that will have the hash key applied to. + offload_type: The offload type the hash key will be applied to. + hex_str: The hash key to set. + verify: If :data:`True`, verify that RSS has the key. + + 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}", + skip_first_line=True, + ) + + if verify: + if output.strip(): + self._logger.debug(f"Failed to set rss hash key: \n{output}") + raise InteractiveCommandExecutionError( + f"Testpmd failed to set {hex_str} on {port_id} with a flag of {offload_type}." + ) + return output + def show_port_info_all(self) -> list[TestPmdPort]: """Returns the information of all the ports.
@@ -1952,22 +2037,28 @@ def csum_set_hw( {port_id}:\n{csum_output}""" ) - def flow_create(self, flow_rule: FlowRule, port_id: int) -> int: + def flow_create(self, flow_rule: FlowRule, port_id: int, verify: bool = True) -> int: """Creates a flow rule in the testpmd session. - This command is implicitly verified as needed to return the created flow rule id. - Args: flow_rule: :class:`FlowRule` object used for creating testpmd flow rule. port_id: Integer representing the port to use. + verify: If :data:`True`, the output of the command is scanned + to ensure the flow rule was created successfully. Raises: InteractiveCommandExecutionError: If flow rule is invalid. Returns: - Id of created flow rule. + Id of created flow rule as an integer. """ flow_output = self.send_command(f"flow create {port_id} {flow_rule}") + if verify: + if "created" not in flow_output: + self._logger.debug(f"Failed to create flow rule:\n{flow_output}") + raise InteractiveCommandExecutionError( + f"Failed to create flow rule:\n{flow_output}" + ) match = re.search(r"#(\d+)", flow_output) if match is not None: match_str = match.group(1)
@@ -1996,10 +2087,10 @@ def flow_delete(self, flow_id: int, port_id: int, verify: bool = True) -> None: """Deletes the specified flow rule from the testpmd session. Args: - flow_id: ID of the flow to remove. + flow_id: :class:`FlowRule` id used for deleting testpmd flow rule. port_id: Integer representing the port to use. verify: If :data:`True`, the output of the command is scanned - to ensure the flow rule was deleted successfully. + to ensure the flow rule was deleted successfully. Raises: InteractiveCommandExecutionError: If flow rule is invalid.
@@ -2724,7 +2815,10 @@ class NicCapability(NoAliasEnum): None, ) #: Device supports Large Receive Offload. - RX_OFFLOAD_TCP_LRO: TestPmdShellNicCapability = (TestPmdShell.get_capabilities_rx_offload, None) + RX_OFFLOAD_TCP_LRO: TestPmdShellNicCapability = ( + TestPmdShell.get_capabilities_rx_offload, + None, + ) #: Device supports QinQ (queue in queue) offload. RX_OFFLOAD_QINQ_STRIP: TestPmdShellNicCapability = ( TestPmdShell.get_capabilities_rx_offload,
@@ -2751,7 +2845,10 @@ class NicCapability(NoAliasEnum): None, ) #: Device supports receiving segmented mbufs. - RX_OFFLOAD_SCATTER: TestPmdShellNicCapability = (TestPmdShell.get_capabilities_rx_offload, None) + RX_OFFLOAD_SCATTER: TestPmdShellNicCapability = ( + TestPmdShell.get_capabilities_rx_offload, + None, + ) #: Device supports Timestamp. RX_OFFLOAD_TIMESTAMP: TestPmdShellNicCapability = ( TestPmdShell.get_capabilities_rx_offload,
@@ -2793,7 +2890,10 @@ class NicCapability(NoAliasEnum): None, ) #: Device supports all VLAN capabilities. - RX_OFFLOAD_VLAN: TestPmdShellNicCapability = (TestPmdShell.get_capabilities_rx_offload, None) + RX_OFFLOAD_VLAN: TestPmdShellNicCapability = ( + TestPmdShell.get_capabilities_rx_offload, + None, + ) #: Device supports Rx queue setup after device started. RUNTIME_RX_QUEUE_SETUP: TestPmdShellNicCapability = ( TestPmdShell.get_capabilities_show_port_info,
@@ -2805,9 +2905,15 @@ class NicCapability(NoAliasEnum): None, ) #: Device supports shared Rx queue among ports within Rx domain and switch domain. - RXQ_SHARE: TestPmdShellNicCapability = (TestPmdShell.get_capabilities_show_port_info, None) + RXQ_SHARE: TestPmdShellNicCapability = ( + TestPmdShell.get_capabilities_show_port_info, + None, + ) #: Device supports keeping flow rules across restart. - FLOW_RULE_KEEP: TestPmdShellNicCapability = (TestPmdShell.get_capabilities_show_port_info, None) + FLOW_RULE_KEEP: TestPmdShellNicCapability = ( + TestPmdShell.get_capabilities_show_port_info, + None, + ) #: Device supports keeping shared flow objects across restart. FLOW_SHARED_OBJECT_KEEP: TestPmdShellNicCapability = ( TestPmdShell.get_capabilities_show_port_info,
Signature · 1 line
2.43.0
RFC PATCH v3 2/2 dts: add PMD RSS testsuite
In reply to Thomas WilksPort over the rss_key_update, pmd_rss_reta and pmd_rss_hash test suites from old DTS into one file including all of the helper functions that are required by all of the test suites to work.
The rss_key_update test cases verify that setting a new hash key when Receive Side Scaling (RSS) will result in a change in the packets destination queue. These test cases also verifies that the reported key size of the NIC is correct.
The pmd_rss_reta test cases verify that Redirection Tables (RETAs) of different sizes function correctly in RSS. These test cases also verify that the reported reta size of the NIC is correct.
The pmd_rss_hash test cases verify that the 4 supported types of hashing algorithm used in RSS function correctly and that the nic supports them. The four hashing algorithms being DEFAULT, TOEPLITZ, SYMMETRIC_TOEPLITZ and SIMPLE_XOR. These test cases also verify that the supported hashing algorithms reported by the NIC are correct.
--- dts/tests/TestSuite_pmd_rss.py | 610 +++++++++++++++++++++++++++++++++ 1 file changed, 610 insertions(+) create mode 100644 dts/tests/TestSuite_pmd_rss.py
dts/tests/TestSuite_pmd_rss.py new file +610 -0
@@ -0,0 +1,610 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright(c) 2025 Arm Limited + +"""RSS testing suite. + +This TestSuite tests the following. + +RSS Hash Test Cases: + Hashing algorithms are used in conjunction with a RSS hash keys to hash packets. + This test suite verifies that updating the Hashing algorithms will + continue to correctly hash packets. + + Symmetric_toeplitz_sort hasn't been included due to it not being supported by + the rss func actions in the flow rule. + +RSS Key Update Test Cases: + RSS hash keys are used in conjunction with a hashing algorithm to hash packets. + This test suite verifies that updating the RSS hash key will change the hash + generated if the hashing algorithm stays the same. + +RSS RETA (redirection table) Test Cases: + The RETA is used in RSS to redirect packets to different queues based on the + least significant bits of the packets hash. + This suite tests updating the size of the RETA and verifying the reported RETA size. +""" + +import random + +from scapy.layers.inet import IP, UDP +from scapy.layers.l2 import Ether + +from framework.exception import InteractiveCommandExecutionError +from framework.params.testpmd import SimpleForwardingModes +from framework.remote_session.testpmd_shell import ( + FlowRule, + RSSOffloadTypesFlag, + TestPmdShell, + TestPmdVerbosePacket, +) +from framework.test_suite import BaseConfig, TestSuite, func_test +from framework.testbed_model.capability import requires +from framework.testbed_model.topology import TopologyType +from framework.utils import StrEnum + + +class Config(BaseConfig): + """Default configuration for Per Test Suite config.""" + + NUM_QUEUES: int = 4 + + ACTUAL_KEY_SIZE: int = 52 + + ACTUAL_RETA_SIZE: int = 512 + + +class HashAlgorithm(StrEnum): + """Enum of hashing algorithms.""" + + DEFAULT = "default" + SIMPLE_XOR = "simple_xor" + TOEPLITZ = "toeplitz" + SYMMETRIC_TOEPLITZ = "symmetric_toeplitz" + + +@requires(topology_type=TopologyType.one_link) +class TestPmdRss(TestSuite): + """PMD RSS test suite. + + Hash: + Verifies the redirection table when updating the size. + The suite contains four tests, one for each hash algorithms. + Configure the redirection table to have random entries. + + Update: + Create a flow rule so ipv4-udp packets utilize the desired RSS hash algorithm. + Send packets, and verify they are in the desired queue based on the redirection table. + Update the RSS hash key. + Send packets, and verify they are in the desired queue based on the redirection table. + Verify the packet hashes before and after the key update are different. + + RSS: + Verifies the redirection table when updating the size. + The suite contains four tests, three for different RETA sizes + and one for verifying the reported RETA size. + """ + + config: Config + + def set_up_suite(self): + """Generates the queues for the flow rule.""" + self.queue = ( + str([x for x in range(self.config.NUM_QUEUES)]) + .replace(",", "") + .replace("[", "") + .replace("]", "") + ) + + def verify_hash_queue( + self, + reta: list[int], + received_packets: list[TestPmdVerbosePacket], + verify_packet_pairs: bool, + ) -> None: + """Verifies the packet hash corresponds to the packet queue. + + Given the received packets in the verbose output, iterate through each packet. + Lookup the packet hash in the RETA and get its intended queue. + Verify the intended queue is the same as the actual queue the packet was received in. + If the hash algorithm is symmetric, verify that pairs of packets have the same hash, + as the pairs of packets sent have "mirrored" L4 ports. + e.g. received_packets[0, 1, 2, 3, ...] hash(0) = hash(1), hash(2) = hash(3), ... + + Args: + test_suite: The reference to the currently running test suite. + reta: Used to get predicted queue based on hash. + received_packets: Packets received in the verbose output of testpmd. + verify_packet_pairs: Verify pairs of packets have the same hash. + + Raises: + InteractiveCommandExecutionError: If packet_hash is None. + """ + # List of packet hashes, used for symmetric algorithms + hash_list = [] + for packet in received_packets: + if packet.port_id != 0 or packet.src_mac != "02:00:00:00:00:00": + continue + + # Get packet hash + packet_hash = packet.rss_hash + if packet_hash is None: + raise InteractiveCommandExecutionError( + "Packet sent by the Traffic Generator has no RSS hash attribute." + ) + + packet_queue = packet.rss_queue + + # Calculate the predicted packet queue + predicted_reta_index = packet_hash % len(reta) + predicted_queue = reta[predicted_reta_index] + print( + "\nreta:\n", + len(reta), + "\npacket_hash:\n", + packet_hash, + "\npredicted queue:\n", + predicted_queue, + "\npacket queue:\n", + packet_queue, + "\n", + ) + # Verify packets are in the correct queue + self.verify( + predicted_queue == packet_queue, + "Packet sent by the Traffic Generator has no RSS queue attribute.", + ) + + if verify_packet_pairs: + hash_list.append(packet_hash) + + if verify_packet_pairs: + # Go through pairs of hashes in list and verify they are the same + for odd_hash, even_hash in zip(hash_list[0::2], hash_list[1::2]): + self.verify( + odd_hash == even_hash, + "Packet pair do not have same hash. Hash algorithm is not symmetric.", + ) + + def send_test_packets( + self, + testpmd: TestPmdShell, + send_additional_mirrored_packet: bool, + ) -> list[TestPmdVerbosePacket]: + """Sends test packets. + + Send 10 packets from the TG to SUT, parsing the verbose output and returning it. + If the algorithm chosen is symmetric, send an additional packet for each initial + packet sent, which has the L4 src and dst swapped. + + Args: + TestSuite: The reference to the currently running test suite. + testpmd: Used to send packets and send commands to testpmd. + send_additional_mirrored_packet: Send an additional mirrored packet for each packet + sent. + + Returns: + TestPmdVerbosePacket: List of packets. + """ + # Create test packets + packets = [] + for i in range(10): + packets.append( + Ether(src="02:00:00:00:00:00", dst="11:00:00:00:00:00") + / IP() + / UDP(sport=i, dport=i + 1), + ) + if send_additional_mirrored_packet: # If symmetric, send the inverse packets + packets.append( + Ether(src="02:00:00:00:00:00", dst="11:00:00:00:00:00") + / IP() + / UDP(sport=i + 1, dport=i), + ) + + # Set verbose packet information and start packet capture + testpmd.set_verbose(3) + testpmd.start() + testpmd.start_all_ports() + self.send_packets_and_capture(packets) + + # Stop packet capture and revert verbose packet information + testpmd_shell_out = testpmd.stop() + testpmd.set_verbose(0) + # Parse the packets and return them + return testpmd.extract_verbose_output(testpmd_shell_out) + + def setup_rss_environment( + self, + testpmd: TestPmdShell, + num_queues: int, + flow_rule: FlowRule | None, + ) -> tuple[list[int], int]: + """Sets up the testpmd environment for RSS test suites. + + This involves: + 1. Setting the testpmd forward mode to rx_only. + 2. Setting RSS on the NIC to UDP. + 3. Creating a flow if provided. + 4. Configuring RETA. + + The reta and key_size of the NIC are then returned + + Args: + TestSuite: TestSuite environment. + testpmd: Where the environment will be set. + num_queues: Number of queues in the RETA table. + flow_rule: The flow rule for altering packet fate. + + Raises: + InteractiveCommandExecutionError: If size of hash key for driver is None. + InteractiveCommandExecutionError: If size of RETA table for driver is None. + + Returns: + reta: Configured Redirection Table. + key_size: key size supported by NIC. + """ + port_info = testpmd.show_port_info(0) + + # Get hash key size + key_size = port_info.hash_key_size + if key_size is None: + raise InteractiveCommandExecutionError("Size of hash key for driver is None.") + + # Get RETA table size + reta_size = port_info.redirection_table_size + if reta_size is None: + raise InteractiveCommandExecutionError("Size of RETA table for driver is None.") + + # Set forward mode to receive only, to remove forwarded packets from verbose output + testpmd.set_forward_mode(SimpleForwardingModes.rxonly) + + # Reset RSS settings and only RSS udp packets + testpmd.port_config_all_rss_offload_type(RSSOffloadTypesFlag.udp) + + # Create flow rule + if flow_rule is not None: + testpmd.flow_create(flow_rule, 0) + + # Configure the RETA with random queues + reta: list[int] = [] + for i in range(reta_size): + reta.insert(i, random.randint(0, num_queues - 1)) + testpmd.port_config_rss_reta(0, i, reta[i]) + + return reta, key_size + + def verify_rss_hash_function( + self, testpmd: TestPmdShell, hash_algorithm: HashAlgorithm, flow_rule: FlowRule + ) -> None: + """Verifies the hash function is supported by the NIC. + + Args: + testpmd: The testpmd instance that will be used to set the rss environment. + hash_algorithm: The hash algorithm to be tested. + flow_rule: The flow rule that is to be validated and then created. + """ + self.verify_else_skip(testpmd.flow_validate(flow_rule, 0), "flow rule failed validation.") + is_symmetric = hash_algorithm == HashAlgorithm.SYMMETRIC_TOEPLITZ + # Run the key update test suite with an asymmetric hash algorithm + # Setup testpmd environment for RSS, create RETA table, return RETA table and key_size + reta, _ = self.setup_rss_environment(testpmd, self.config.NUM_QUEUES, flow_rule) + # Send udp packets and ensure hash corresponds with queue + parsed_output = self.send_test_packets(testpmd, is_symmetric) + self.verify_hash_queue(reta, parsed_output, is_symmetric) + + def check_reta_n_queues(self, num_queues: int) -> None: + """Create RETA of size n, send packets, verify packets end up in correct queue. + + Args: + num_queues: Number of rx/tx queues. + """ + with TestPmdShell( + rx_queues=num_queues, + tx_queues=num_queues, + ) as testpmd: + # Setup testpmd for RSS, create RETA table, return RETA table and key_size + reta, _ = self.setup_rss_environment(testpmd, num_queues, None) + + # Send UDP packets and ensure hash corresponds with queue + parsed_output = self.send_test_packets(testpmd, False) + self.verify_hash_queue(reta, parsed_output, False) + + @func_test + def test_key_hash_default_hash_algorithm(self) -> None: + """Default hashing algorithm test. + + Steps: + Setup RSS environment using the default RSS hashing algorithm + and send test packets. + Verify: + Packet hash corresponds to the packet queue. + """ + flow_rule = FlowRule( + group_id=0, + direction="ingress", + pattern=["eth / ipv4 / udp"], + actions=[f"rss types ipv4-udp end queues func {str(HashAlgorithm.DEFAULT).lower()}"], + ) + with TestPmdShell( + rx_queues=self.config.NUM_QUEUES, + tx_queues=self.config.NUM_QUEUES, + ) as testpmd: + self.verify_rss_hash_function(testpmd, HashAlgorithm.DEFAULT, flow_rule) + + # Note: Below Testcase packet RSS queue and predict RSS queue are always incorrect on ConnectX + # nics with the actual packet queue being a random queue that the packet can use that is one of + # the queues within the flow rule (self.queue). + @func_test + def test_key_hash_default_hash_algorithm_queues(self) -> None: + """Default hashing algorithm test for ConnectX nics. + + Steps: + Setup RSS environment using the default RSS hashing algorithm + and send test packets. + Verify: + Packet hash corresponds to the packet queue. + """ + flow_rule = FlowRule( + group_id=0, + direction="ingress", + pattern=["eth / ipv4 / udp"], + actions=[ + f"rss types ipv4-udp end queues {self.queue} end func " + + str(HashAlgorithm.DEFAULT).lower() + ], + ) + with TestPmdShell( + rx_queues=self.config.NUM_QUEUES, + tx_queues=self.config.NUM_QUEUES, + ) as testpmd: + self.verify_rss_hash_function(testpmd, HashAlgorithm.DEFAULT, flow_rule) + + @func_test + def test_key_hash_toeplitz_hash_algorithm(self) -> None: + """Toeplitz hashing algorithm test. + + Steps: + Setup RSS environment using the toeplitz RSS hashing algorithm and send test packets. + Verify: + Packet hash corresponds to the packet queue. + """ + flow_rule = FlowRule( + group_id=0, + direction="ingress", + pattern=["eth / ipv4 / udp"], + actions=[ + f"rss types ipv4-udp end queues end func {str(HashAlgorithm.TOEPLITZ).lower()}" + ], + ) + with TestPmdShell( + rx_queues=self.config.NUM_QUEUES, + tx_queues=self.config.NUM_QUEUES, + ) as testpmd: + self.verify_rss_hash_function(testpmd, HashAlgorithm.TOEPLITZ, flow_rule) + + # Note: Below Testcase packet RSS queue and predict RSS queue are always incorrect on ConnectX + # nics with the actual packet queue being a random queue that the packet can use that is one of + # the queues within the flow rule (self.queue). + @func_test + def test_key_hash_toeplitz_hash_algorithm_queues(self) -> None: + """Toeplitz hashing algorithm test for ConnectX nics. + + Steps: + Setup RSS environment using the toeplitz RSS hashing algorithm and send test packets. + Verify: + Packet hash corresponds to the packet queue. + """ + flow_rule = FlowRule( + group_id=0, + direction="ingress", + pattern=["eth / ipv4 / udp"], + actions=[ + f"rss types ipv4-udp end queues {self.queue} end func " + + str(HashAlgorithm.TOEPLITZ).lower() + ], + ) + with TestPmdShell( + rx_queues=self.config.NUM_QUEUES, + tx_queues=self.config.NUM_QUEUES, + ) as testpmd: + self.verify_rss_hash_function(testpmd, HashAlgorithm.TOEPLITZ, flow_rule) + + @func_test + def test_key_hash_symmetric_toeplitz_hash_algorithm(self) -> None: + """Symmetric toeplitz hashing algorithm test. + + Steps: + Setup RSS environment using the symmetric_toeplitz RSS hashing algorithm + and send test packets. + Verify: + Packet hash corresponds to the packet queue. + """ + flow_rule = FlowRule( + group_id=0, + direction="ingress", + pattern=["eth / ipv4 / udp"], + actions=[ + "rss types ipv4-udp end queues end func " + + str(HashAlgorithm.SYMMETRIC_TOEPLITZ).lower() + ], + ) + with TestPmdShell( + rx_queues=self.config.NUM_QUEUES, + tx_queues=self.config.NUM_QUEUES, + ) as testpmd: + self.verify_rss_hash_function(testpmd, HashAlgorithm.SYMMETRIC_TOEPLITZ, flow_rule) + + # Note: Below Testcase packet RSS queue and predict RSS queue are always incorrect on ConnectX + # nics with the actual packet queue being a random queue that the packet can use that is one of + # the queues within the flow rule (self.queue). + @func_test + def test_key_hash_symmetric_toeplitz_hash_algorithm_queues(self) -> None: + """Symmetric toeplitz hashing algorithm test for ConnectX nics. + + Steps: + Setup RSS environment using the symmetric_toeplitz RSS hashing algorithm + and send test packets. + Verify: + Packet hash corresponds to the packet queue. + """ + flow_rule = FlowRule( + group_id=0, + direction="ingress", + pattern=["eth / ipv4 / udp"], + actions=[ + f"rss types ipv4-udp end queues {self.queue} end func " + + str(HashAlgorithm.SYMMETRIC_TOEPLITZ).lower() + ], + ) + with TestPmdShell( + rx_queues=self.config.NUM_QUEUES, + tx_queues=self.config.NUM_QUEUES, + ) as testpmd: + self.verify_rss_hash_function(testpmd, HashAlgorithm.SYMMETRIC_TOEPLITZ, flow_rule) + + @func_test + def test_key_hash_simple_xor_hash_algorithm(self) -> None: + """Simple xor hashing algorithm test. + + Steps: + Setup RSS environment using the simple xor RSS hashing algorithm + and send test packets. + Verify: + Packet hash corresponds to the packet queue. + """ + flow_rule = FlowRule( + group_id=0, + direction="ingress", + pattern=["eth / ipv4 / udp"], + actions=[ + "rss types ipv4-udp end queues end func " + str(HashAlgorithm.SIMPLE_XOR).lower() + ], + ) + with TestPmdShell( + rx_queues=self.config.NUM_QUEUES, + tx_queues=self.config.NUM_QUEUES, + ) as testpmd: + self.verify_rss_hash_function(testpmd, HashAlgorithm.SIMPLE_XOR, flow_rule) + + # Note: Below Testcase packet RSS queue and predict RSS queue are always incorrect on ConnectX + # nics with the actual packet queue being a random queue that the packet can use that is one of + # the queues within the flow rule (self.queue). + @func_test + def test_key_hash_simple_xor_hash_algorithm_queues(self) -> None: + """Simple xor hashing algorithm test for ConnectX nics. + + Steps: + Setup RSS environment using the simple xor RSS hashing algorithm + and send test packets. + Verify: + Packet hash corresponds to the packet queue. + """ + flow_rule = FlowRule( + group_id=0, + direction="ingress", + pattern=["eth / ipv4 / udp"], + actions=[ + f"rss types ipv4-udp end queues {self.queue} end func " + + str(HashAlgorithm.SIMPLE_XOR).lower() + ], + ) + with TestPmdShell( + rx_queues=self.config.NUM_QUEUES, + tx_queues=self.config.NUM_QUEUES, + ) as testpmd: + self.verify_rss_hash_function(testpmd, HashAlgorithm.SIMPLE_XOR, flow_rule) + + @func_test + def test_update_key_set_hash_key_short_long(self) -> None: + """Set hash key short long test. + + Steps: + Fetch the hash key size, create two random hash keys one key that is too short and one + that is too long. + + Verify: + Verify that it is not possible to set the shorter hash key. + Verify that it is not possible to set the longer hash key. + + Raises: + InteractiveCommandExecutionError: If port info dose not contain hash key size. + """ + with TestPmdShell( + memory_channels=4, + rx_queues=self.config.NUM_QUEUES, + tx_queues=self.config.NUM_QUEUES, + ) as testpmd: + # Get RETA and key size + port_info = testpmd.show_port_info(0) + + # Get hash key size + key_size = port_info.hash_key_size + if key_size is None: + raise InteractiveCommandExecutionError("Port info does not contain hash key size.") + + # Create 2 hash keys based on the NIC capabilities + short_key = "".join( + [random.choice("0123456789ABCDEF") for n in range(key_size * 2 - 2)] + ) + long_key = "".join([random.choice("0123456789ABCDEF") for n in range(key_size * 2 + 2)]) + + # Verify a short key cannot be set + short_key_out = testpmd.port_config_rss_hash_key( + 0, RSSOffloadTypesFlag.ipv4_udp, short_key, False + ) + self.verify( + "invalid" in short_key_out, + "Able to set hash key shorter than specified.", + ) + + # Verify a long key cannot be set + long_key_out = testpmd.port_config_rss_hash_key( + 0, RSSOffloadTypesFlag.ipv4_udp, long_key, False + ) + self.verify("invalid" in long_key_out, "Able to set hash key longer than specified.") + + @func_test + def test_update_key_reported_key_size(self) -> None: + """Verify reported hash key size is the same as the NIC capabilities. + + Steps: + Fetch the hash key size and compare to the actual key size. + Verify: + Reported key size is the same as the actual key size. + """ + with TestPmdShell() as testpmd: + reported_key_size = testpmd.show_port_info(0).hash_key_size + self.verify( + reported_key_size == self.config.ACTUAL_KEY_SIZE, + "Reported key size is not the same as the config file.", + ) + + @func_test + def test_reta_key_reta_queues(self) -> None: + """RETA rx/tx queues test. + + Steps: + Setup RSS environment and send Test packets. + Verify: + Packet hash corresponds to hash queue. + """ + queues = [2, 9, 16] + for queue in queues: + self.check_reta_n_queues(queue) + + @func_test + def test_reta_key_reported_reta_size(self) -> None: + """Reported RETA size test. + + Steps: + Fetch reported reta size. + Verify: + Reported RETA size is equal to the actual RETA size. + """ + with TestPmdShell( + rx_queues=self.config.NUM_QUEUES, tx_queues=self.config.NUM_QUEUES + ) as testpmd: + reported_reta_size = testpmd.show_port_info(0).redirection_table_size + self.verify( + reported_reta_size == self.config.ACTUAL_RETA_SIZE, + "Reported RETA size is not the same as the config file.", + )
Signature · 1 line
2.43.0
Re: [RFC PATCH v3 2/2] dts: add PMD RSS testsuite
Quoted 15 lines · Thomas Wilks
Port over the
rss_key_update,pmd_rss_retaandpmd_rss_hashtest suites from old DTS into one file including all of the helper functions that are required by all of the test suites to work.The
rss_key_updatetest cases verify that setting a new hash key when Receive Side Scaling (RSS) will result in a change in the packets destination queue. These test cases also verifies that the reported key size of the NIC is correct.The
pmd_rss_retatest cases verify that Redirection Tables (RETAs) of different sizes function correctly in RSS. These test cases also verify that the reported reta size of the NIC is correct.
Quoted 8 lines
The
pmd_rss_hashtest cases verify that the 4 supported types of hashing algorithm used in RSS function correctly and that the nic supports them. The four hashing algorithms being DEFAULT, TOEPLITZ,SYMMETRIC_TOEPLITZandSIMPLE_XOR. These test cases also verify that the supported hashing algorithms reported by the NIC are correct.Signed-off-by Alex Chapman <[email protected]>Signed-off-by Thomas Wilks <[email protected]>
It was brought up at the DTS meeting yesterday that this suite is reliable on Intel NICs, but unreliable on Mellanox (CX6), which I can confirm after running on a CX5 and Intel XL710 and seeing the same behavior.
Re: [RFC PATCH v3 2/2] dts: add PMD RSS testsuite
Hi Dean,
Quoted 22 lines · Dean Marx
Quoted 21 lines · Thomas Wilks
Port over the
rss_key_update,pmd_rss_retaandpmd_rss_hashtest suites from old DTS into one file including all of the helper functions that are required by all of the test suites to work.The
rss_key_updatetest cases verify that setting a new hash key when Receive Side Scaling (RSS) will result in a change in the packets destination queue. These test cases also verifies that the reported key size of the NIC is correct.The
pmd_rss_retatest cases verify that Redirection Tables (RETAs) of different sizes function correctly in RSS. These test cases also verify that the reported reta size of the NIC is correct.The
pmd_rss_hashtest cases verify that the 4 supported types of hashing algorithm used in RSS function correctly and that the nic supports them. The four hashing algorithms being DEFAULT, TOEPLITZ,SYMMETRIC_TOEPLITZandSIMPLE_XOR. These test cases also verify that the supported hashing algorithms reported by the NIC are correct.
Quoted 7 lines
Quoted 2 lines
Signed-off-by Alex Chapman <[email protected]>Signed-off-by Thomas Wilks <[email protected]>It was brought up at the DTS meeting yesterday that this suite is reliable on Intel NICs, but unreliable on Mellanox (CX6), which I can confirm after running on a CX5 and Intel XL710 and seeing the same behavior.
As I tried to explain earlier, this might be due to the 'queue' array of the action 'rss' logically comprising a separate 'reta' for the packets intercepted by the flow. The test should not check such packets against the global 'reta'.
As to why the test passes for the latter NIC, please take a look at [1]. In that specific case, the code that is meant to parse the 'queue' array of action 'rss' might be called only when there are no match items in the flow pattern or when the first pattern item is VLAN. If this is indeed the case, then the use of action 'rss' overrides only the hash types for packets intercepted by the flow, but not the 'reta' to be used, so they still land the global 'reta'.
Also, in 'setup_rss_environment', it might be more robust to first configure the port's global 'reta' and then insert the flow (if any), to rule out the flow possibly overriding the global 'reta', which, in theory, shall not happen.
With this in mind, the test could possibly be reworked to act as follows:
1) set up and memorise the port's global 'reta';
2) create a flow rule (say, match UDP DST "A") with 'rss', memorise its 'reta';
4) send a packet that matches the flow (say, with UDP DST "A");
5) receive the packet and check the queue against the flow's own 'reta'; on queue mismatch, check against the global 'reta' and log the artifact;
6) send a packet that does not match the flow (say, with UDP DST "B");
7) receive the packet and check the queue against the global 'reta'.
Thank you.
Quoted 4 lines
Reviewed-by Dean Marx <[email protected]>Tested-by Dean Marx <[email protected]>
Re: [RFC PATCH v3 0/2] dts: add RSS functions and test suite
In reply to Thomas WilksHi Thomas,
Quoted 5 lines · Thomas Wilks
Hi all,
This is v3 of the RSS test suites which has been rebased onto the latest patches. I’m also requesting comments and some help with an issue where the packet RSS queue and the predicted RSS queue differ when running on ConnectX-6 NICs while being the same on E810-C NICs.
Looking at patch [2/2], 'test_key_hash_default_hash_algorithm_queues' might do the following:
1) insert a flow rule with action 'rss' and a specific/single random queue "A", which is expressed as 'rss types ipv4-udp end queues {self.queue} end';
2) set the GLOBAL rss table ('reta') for the port, with the queue indices going in some random order (say, [ACBBAAADCDAA..C], of size 512);
3) send/receive the packet;
4) based on the packet mbuf hash value, offset into the GLOBAL table ('reta') and retrieve the "expected" queue index;
5) compare the actual receive queue index with the predicted one.
Is this understanding correct?
If my understanding is correct, then I'm afraid this design might be flawed. Why does it assume the GLOBAL table effect on action 'rss" with some specific queue index listed in it? In fact, the 'queue' array of the action, at least, when non-empty, defines exact subset of queues where the packet can land, which might effectively form a distinct, per-flow 'reta'. In this case, where only one queue index "A" is specified, the effective 'reta' for this particular flow match is going to be [AAAAAAAAA..A] (say, of size 512 by default), isn't it? If so, then why does the code try to peek at the GLOBAL reta instead, when it has in fact wittingly reduced action 'rss' behaviour to such of action 'queue'?
Once again, I apologise in case I've got something wrong.
Quoted 3 lines
I’m currently in the process of refactoring the test suites and addressing
the review comments from v2. Below is a summary of the changes made so far that are included in this version:
As a separate question, doesn't one also want to verify the "expected" hash value (SW hash based on the IP/UDP 2/4-tuple) versus the "actual" value? Or is this too inconvenient to automate in testpmd environment?
Thank you.
Quoted 25 lines
Changes in v3:
- Merged the RSS test suites into a single file for better maintainability.
- Moved the supporting functions into the same test suite file and removed the previous separate function file.
- Combined thereta_key_reta_queuestest cases into a single test case.
- Added new test cases to support flow rule creation on ConnectX-6 NICs.
- Removed requirements for specific hashing algorithms which has been replaced theflow_validatefunction.Regards,
Thomas WilksAlex Chapman (1):
dts: add RSS functions to testpmdThomas Wilks (1):
dts: add PMD RSS testsuite
dts/framework/remote_session/testpmd_shell.py| 132 +++-dts/tests/TestSuite_pmd_rss.py| 610 ++++++++++++++++++2 files changed, 729 insertions(+), 13 deletions(-)create mode 100644
dts/tests/TestSuite_pmd_rss.pySignature · 1 line
2.43.0
Re: [RFC PATCH v3 0/2] dts: add RSS functions and test suite
A quick follow-up: I now see that 'self.queue' is in fact a misnomer for an array of queues and not a single queue index specification. It would be better to name it 'queues'. But the issue stands: this array differs from GLOBAL table.
As far as I can tell from reading documentation for action 'rss', it does not specifically assume a per-flow 'reta' to be derived from the queue array. If the meaning of queue indices in the action is solely to give a subset of queues where a packet can land, but not in a strict, 'reta'-like manner, then the assumption of the test that the GLOBAL 'reta' should be consulted is still odd. It in fact checks where the the packet would have landed were it not for the flow rule to intercept it. Once again, I apologise in case I've got this wrong.
Thank you.
Quoted 73 lines · Ivan Malov
Hi Thomas,
Quoted 5 lines · Thomas Wilks
Hi all,
This is v3 of the RSS test suites which has been rebased onto the latest patches. I’m also requesting comments and some help with an issue where the packet RSS queue and the predicted RSS queue differ when running on ConnectX-6 NICs while being the same on E810-C NICs.
Looking at patch [2/2], '
test_key_hash_default_hash_algorithm_queues' might do the following:1) insert a flow rule with action 'rss' and a specific/single random queue "A", which is expressed as 'rss types ipv4-udp end queues {self.queue} end';
2) set the GLOBAL rss table ('reta') for the port, with the queue indices going in some random order (say, [ACBBAAADCDAA..C], of size 512);
3) send/receive the packet;
4) based on the packet mbuf hash value, offset into the GLOBAL table ('reta') and retrieve the "expected" queue index;
5) compare the actual receive queue index with the predicted one.Is this understanding correct?
If my understanding is correct, then I'm afraid this design might be flawed. Why does it assume the GLOBAL table effect on action 'rss" with some specific queue index listed in it? In fact, the 'queue' array of the action, at least, when non-empty, defines exact subset of queues where the packet can land, which might effectively form a distinct, per-flow 'reta'. In this case, where only one queue index "A" is specified, the effective 'reta' for this particular flow match is going to be [AAAAAAAAA..A] (say, of size 512 by default), isn't it? If so, then why does the code try to peek at the GLOBAL reta instead, when it has in fact wittingly reduced action 'rss' behaviour to such of action 'queue'?
Once again, I apologise in case I've got something wrong.
Quoted 3 lines
I’m currently in the process of refactoring the test suites and addressing
the review comments from v2. Below is a summary of the changes made so far that are included in this version:As a separate question, doesn't one also want to verify the "expected" hash value (SW hash based on the IP/UDP 2/4-tuple) versus the "actual" value? Or is this too inconvenient to automate in testpmd environment?
Thank you.
Quoted 26 lines
Changes in v3:
- Merged the RSS test suites into a single file for better maintainability.
- Moved the supporting functions into the same test suite file and removed the previous separate function file.
- Combined thereta_key_reta_queuestest cases into a single test case.
- Added new test cases to support flow rule creation on ConnectX-6 NICs.
- Removed requirements for specific hashing algorithms which has been replaced theflow_validatefunction.Regards,
Thomas WilksAlex Chapman (1):
dts: add RSS functions to testpmdThomas Wilks (1):
dts: add PMD RSS testsuite
dts/framework/remote_session/testpmd_shell.py| 132 +++-dts/tests/TestSuite_pmd_rss.py| 610 ++++++++++++++++++2 files changed, 729 insertions(+), 13 deletions(-)create mode 100644
dts/tests/TestSuite_pmd_rss.pySignature · 1 line
2.43.0
v4 cover dts: add RSS functions and test suite
In reply to Thomas WilksHi all,
This is v4 of the RSS test suites which addresses the issues with running the hashing algorithm test cases on ConnectX nics. The patches have also been rebased onto the latest upstream changes.
Also thank you for your help and feedback with my previous RFC patch.
Changes in v4:
- Merged the RSS hashing algorithms tests into a single test case.
- Resolved issues with packet RSS queues when being ran on ConnectX nics.
- Updated doc strings to better reflect the test suites functionality.
- Moved RETA configuration into a dedicated function.
Regards,
Thomas Wilks
Alex Chapman (1):
dts: add RSS functions to testpmd
Thomas Wilks (1):
dts: add PMD RSS testsuite
dts/framework/remote_session/testpmd_shell.py | 104 ++++- dts/tests/TestSuite_pmd_rss.py | 383 ++++++++++++++++++ 2 files changed, 480 insertions(+), 7 deletions(-) create mode 100644 dts/tests/TestSuite_pmd_rss.py
Signature · 1 line
2.43.0
PATCH v4 1/2 dts: add RSS functions to testpmd
From: Alex Chapman <[email protected]>
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.
--- dts/framework/remote_session/testpmd_shell.py | 104 ++++++++++++++++-- 1 file changed, 97 insertions(+), 7 deletions(-)
dts/framework/remote_session/testpmd_shell.py +97 -7
@@ -343,6 +343,12 @@ def make_parser(cls) -> ParserFn: RSSOffloadTypesFlag.from_list_string, ) + def __str__(self): + """Replaces underscores with hyphens to produce valid testpmd value.""" + if self.name is None: + return "" + return self.name.replace("_", "-") + class DeviceCapabilitiesFlag(Flag): """Flag representing the device capabilities."""
@@ -644,11 +650,13 @@ class TestPmdPort(TextParser): ) #: Maximum number of VFs max_vfs_num: int | None = field( - default=None, metadata=TextParser.find_int(r"Maximum number of VFs: (\d+)") + default=None, + metadata=TextParser.find_int(r"Maximum number of VFs: (\d+)"), ) #: Maximum number of VMDq pools max_vmdq_pools_num: int | None = field( - default=None, metadata=TextParser.find_int(r"Maximum number of VMDq pools: (\d+)") + default=None, + metadata=TextParser.find_int(r"Maximum number of VMDq pools: (\d+)"), ) #:
@@ -1734,6 +1742,82 @@ def close_all_ports(self, verify: bool = True) -> None: if not all(f"Port {p_id} is closed" in port_close_output for p_id in range(num_ports)): raise InteractiveCommandExecutionError("Ports were not closed successfully.") + def port_config_rss_reta( + self, port_id: int, hash_index: int, queue_id: int, verify: bool = True + ) -> None: + """Configure a port's RSS redirection table. + + Args: + port_id: The port where the 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`, 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: + flag: 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: + InteractiveCommandExecutionError: If `verify` is :data:`True` + Testpmd failed to config the RSS mode on all ports. + """ + 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( + f"Testpmd failed to change RSS mode to {flag.name}" + ) + + def port_config_rss_hash_key( + self, + port_id: int, + offload_type: RSSOffloadTypesFlag, + hex_str: str, + verify: bool = True, + ) -> str: + """Sets the RSS hash key for the specified port. + + Args: + port_id: The port that will have the hash key applied to. + offload_type: The offload type the hash key will be applied to. + hex_str: The hash key to set. + verify: If :data:`True`, verify that RSS has the key. + + 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}", + skip_first_line=True, + ) + + if verify: + if output.strip(): + self._logger.debug(f"Failed to set rss hash key: \n{output}") + raise InteractiveCommandExecutionError( + f"Testpmd failed to set {hex_str} on {port_id} with a flag of {offload_type}." + ) + return output + def show_port_info_all(self) -> list[TestPmdPort]: """Returns the information of all the ports.
@@ -1952,22 +2036,28 @@ def csum_set_hw( {port_id}:\n{csum_output}""" ) - def flow_create(self, flow_rule: FlowRule, port_id: int) -> int: + def flow_create(self, flow_rule: FlowRule, port_id: int, verify: bool = True) -> int: """Creates a flow rule in the testpmd session. - This command is implicitly verified as needed to return the created flow rule id. - Args: flow_rule: :class:`FlowRule` object used for creating testpmd flow rule. port_id: Integer representing the port to use. + verify: If :data:`True`, the output of the command is scanned + to ensure the flow rule was created successfully. Raises: InteractiveCommandExecutionError: If flow rule is invalid. Returns: - Id of created flow rule. + Id of created flow rule as an integer. """ flow_output = self.send_command(f"flow create {port_id} {flow_rule}") + if verify: + if "created" not in flow_output: + self._logger.debug(f"Failed to create flow rule:\n{flow_output}") + raise InteractiveCommandExecutionError( + f"Failed to create flow rule:\n{flow_output}" + ) match = re.search(r"#(\d+)", flow_output) if match is not None: match_str = match.group(1)
@@ -1996,7 +2086,7 @@ def flow_delete(self, flow_id: int, port_id: int, verify: bool = True) -> None: """Deletes the specified flow rule from the testpmd session. Args: - flow_id: ID of the flow to remove. + flow_id: :class:`FlowRule` id used for deleting testpmd flow rule. port_id: Integer representing the port to use. verify: If :data:`True`, the output of the command is scanned to ensure the flow rule was deleted successfully.
Signature · 1 line
2.43.0
I think this patch looks good. Thanks Thomas and thanks Ivan for your insights.
Quoted 216 lines · Thomas Wilks
From: Alex Chapman <[email protected]>
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 <[email protected]>Signed-off-by Thomas Wilks <[email protected]>Reviewed-by Paul Szczepanek <[email protected]>Reviewed-by Patrick Robb <[email protected]>Tested-by Patrick Robb <[email protected]>--- dts/framework/remote_session/testpmd_shell.py | 104 ++++++++++++++++-- 1 file changed, 97 insertions(+), 7 deletions(-)dts/framework/remote_session/testpmd_shell.py +2
-0@@ -343,6 +343,12 @@ def make_parser(cls) -> ParserFn: RSSOffloadTypesFlag.from_list_string, ) + def __str__(self): + """Replaces underscores with hyphens to produce valid testpmdvalue."""
dts/framework/remote_session/testpmd_shell.py +8
-2+ if self.name is None: + return "" + return self.name.replace("_", "-") + class DeviceCapabilitiesFlag(Flag): """Flag representing the device capabilities."""@@ -644,11 +650,13 @@ class TestPmdPort(TextParser): ) #: Maximum number of VFs max_vfs_num: int | None = field( - default=None, metadata=TextParser.find_int(r"Maximum number of VFs: (\d+)") + default=None, + metadata=TextParser.find_int(r"Maximum number of VFs: (\d+)"), ) #: Maximum number of VMDq pools max_vmdq_pools_num: int | None = field( - default=None, metadata=TextParser.find_int(r"Maximum number of VMDq pools: (\d+)") + default=None, + metadata=TextParser.find_int(r"Maximum number of VMDq pools: (\d+)"),) #:dts/framework/remote_session/testpmd_shell.py +0
-0@@ -1734,6 +1742,82 @@ def close_all_ports(self, verify: bool = True) ->None:
if not all(f"Port {p_id} is closed" inport_close_outputforp_idinrange(num_ports)):
raise InteractiveCommandExecutionError("Ports were not
closed successfully.")dts/framework/remote_session/testpmd_shell.py +2
-0+ def port_config_rss_reta( + self, port_id: int, hash_index: int, queue_id: int, verify: bool= True
dts/framework/remote_session/testpmd_shell.py +5
-0+ ) -> None: + """Configure a port's RSS redirection table. + + Args: + port_id: The port where the redirection table will beconfigured.
+hash_index: The index into the redirection table associated
with the destination queue.dts/framework/remote_session/testpmd_shell.py +2
-0+ queue_id: The destination queue of the packet. + verify: If :data:`True`, verifies if a port's redirectiontable
dts/framework/remote_session/testpmd_shell.py +7
-0+ 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})")
dts/framework/remote_session/testpmd_shell.py +4
-0+ 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 toconfig RSS reta.")
dts/framework/remote_session/testpmd_shell.py +9
-0+ + def port_config_all_rss_offload_type( + self, flag: RSSOffloadTypesFlag, verify: bool = True + ) -> None: + """Set the RSS mode on all ports. + + Args: + flag: The RSS iptype all ports will be configured to. + verify: If :data:`True`, it verifies if all ports RSS offloadtype
dts/framework/remote_session/testpmd_shell.py +10
-0+ was correctly configured. + + Raises: + InteractiveCommandExecutionError: If `verify` is :data:`True` + Testpmd failed to config the RSS mode on all ports. + """ + 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 allports: \n{out}")
dts/framework/remote_session/testpmd_shell.py +16
-0+ raise InteractiveCommandExecutionError( + f"Testpmd failed to change RSS mode to {flag.name}" + ) + + def port_config_rss_hash_key( + self, + port_id: int, + offload_type: RSSOffloadTypesFlag, + hex_str: str, + verify: bool = True, + ) -> str: + """Sets the RSS hash key for the specified port. + + Args: + port_id: The port that will have the hash key applied to. + offload_type: The offload type the hash key will be appliedto.
dts/framework/remote_session/testpmd_shell.py +9
-0+ hex_str: The hash key to set. + verify: If :data:`True`, verify that RSS has the key. + + 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}",dts/framework/remote_session/testpmd_shell.py +6
-0+ skip_first_line=True, + ) + + if verify: + if output.strip(): + self._logger.debug(f"Failed to set rss hash key:\n{output}")
dts/framework/remote_session/testpmd_shell.py +2
-0+ raise InteractiveCommandExecutionError( + f"Testpmd failed to set {hex_str} on {port_id} with aflag of {
offload_type}."dts/framework/remote_session/testpmd_shell.py +3
-0+ ) + return output + def show_port_info_all(self) -> list[TestPmdPort]: """Returns the information of all the ports.@@ -1952,22 +2036,28 @@ def csum_set_hw({port_id}:\n{csum_output}"""
)dts/framework/remote_session/testpmd_shell.py +1
-1- def flow_create(self, flow_rule: FlowRule, port_id: int) -> int: + def flow_create(self, flow_rule: FlowRule, port_id: int, verify: bool= True) -> int:
"""Creates a flow rule in the testpmd session.- This command is implicitly verified as needed to return the
created flow rule id.
-
Args:
flow_rule: :class:FlowRuleobject used for creating testpmd
flow rule.
port_id: Integer representing the port to use.dts/framework/remote_session/testpmd_shell.py +3
-1+ verify: If :data:`True`, the output of the command is scanned + to ensure the flow rule was created successfully. Raises: InteractiveCommandExecutionError: If flow rule is invalid. Returns: - Id of created flow rule. + Id of created flow rule as an integer. """ flow_output = self.send_command(f"flow create {port_id}{
flow_rule}")dts/framework/remote_session/testpmd_shell.py +3
-0+ if verify: + if "created" not in flow_output: + self._logger.debug(f"Failed to create flowrule:\n{flow_output}")
dts/framework/remote_session/testpmd_shell.py +3
-0+ raise InteractiveCommandExecutionError( + f"Failed to create flow rule:\n{flow_output}" + ) match = re.search(r"#(\d+)", flow_output) if match is not None: match_str = match.group(1)@@ -1996,7 +2086,7 @@ def flow_delete(self, flow_id: int, port_id: int,verify: bool = True) -> None:
"""Deletes the specified flow rule from the testpmd session.Args:
dts/framework/remote_session/testpmd_shell.py +1
-1- flow_id: ID of the flow to remove. + flow_id: :class:`FlowRule` id used for deleting testpmd flowrule.
port_id: Integer representing the port to use.
verify: If :data:True, the output of the command is scanned
to ensure the flow rule was deleted successfully.
--
2.43.0
PATCH v4 2/2 dts: add PMD RSS testsuite
In reply to Thomas WilksPort over the rss_key_update, pmd_rss_reta and pmd_rss_hash test suites from old DTS into one file including all of the helper functions that are required by all of the test suites to work.
The rss_key_update test cases verify that setting a new hash key when Receive Side Scaling (RSS) will result in a change in the packets destination queue. These test cases also verifies that the reported key size of the NIC is correct.
The pmd_rss_reta test cases verify that Redirection Tables (RETAs) of different sizes function correctly in RSS. These test cases also verify that the reported reta size of the NIC is correct.
The pmd_rss_hash test case verifies that the 4 supported types of hashing algorithm used in RSS function correctly and that the nic supports them. The four hashing algorithms being DEFAULT, TOEPLITZ, SYMMETRIC_TOEPLITZ and SIMPLE_XOR. These test cases also verify that the supported hashing algorithms reported by the NIC are correct.
--- dts/tests/TestSuite_pmd_rss.py | 383 +++++++++++++++++++++++++++++++++ 1 file changed, 383 insertions(+) create mode 100644 dts/tests/TestSuite_pmd_rss.py
dts/tests/TestSuite_pmd_rss.py new file +383 -0
@@ -0,0 +1,383 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright(c) 2025 Arm Limited + +"""RSS testing suite. + +Tests different hashing algorithms by checking if packets are routed to correct queues. +Tests updating the RETA (Redirection Table) key to verify it takes effect and follows +set size constraints. +Tests RETA behavior under changing number of queues. +""" + +import random + +from scapy.layers.inet import IP, UDP +from scapy.layers.l2 import Ether + +from framework.exception import InteractiveCommandExecutionError +from framework.params.testpmd import SimpleForwardingModes +from framework.remote_session.testpmd_shell import ( + FlowRule, + RSSOffloadTypesFlag, + TestPmdShell, + TestPmdVerbosePacket, +) +from framework.test_suite import BaseConfig, TestSuite, func_test +from framework.testbed_model.capability import requires +from framework.testbed_model.topology import TopologyType +from framework.utils import StrEnum + + +class Config(BaseConfig): + """Default configuration for Per Test Suite config.""" + + NUM_QUEUES: int = 4 + + ACTUAL_KEY_SIZE: int = 52 + + ACTUAL_RETA_SIZE: int = 512 + + +class HashAlgorithm(StrEnum): + """Enum of hashing algorithms.""" + + DEFAULT = "default" + SIMPLE_XOR = "simple_xor" + TOEPLITZ = "toeplitz" + SYMMETRIC_TOEPLITZ = "symmetric_toeplitz" + + +@requires(topology_type=TopologyType.one_link) +class TestPmdRss(TestSuite): + """PMD RSS test suite.""" + + config: Config + + def verify_hash_queue( + self, + reta: list[int], + received_packets: list[TestPmdVerbosePacket], + verify_packet_pairs: bool, + ) -> None: + """Verifies the packet hash corresponds to the packet queue. + + Given the received packets in the verbose output, iterate through each packet. + Use the hash to index into RETA and get its intended queue. + Verify the intended queue is the same as the actual queue the packet was received in. + If the hash algorithm is symmetric, verify that pairs of packets have the same hash, + as the pairs of packets sent have "mirrored" L4 ports. + e.g. received_packets[0, 1, 2, 3, ...] hash(0) = hash(1), hash(2) = hash(3), ... + + Args: + reta: Used to get predicted queue based on hash. + received_packets: Packets received in the verbose output of testpmd. + verify_packet_pairs: Verify pairs of packets have the same hash. + + Raises: + InteractiveCommandExecutionError: If packet_hash is None. + """ + # List of packet hashes, used for symmetric algorithms + hash_list = [] + for packet in received_packets: + # Ignore stray packets + if packet.port_id != 0 or packet.src_mac != "02:00:00:00:00:00": + continue + # Get packet hash + packet_hash = packet.rss_hash + if packet_hash is None: + raise InteractiveCommandExecutionError( + "Packet sent by the Traffic Generator has no RSS hash attribute." + ) + + packet_queue = packet.rss_queue + + # Calculate the predicted packet queue + predicted_queue = reta[packet_hash % len(reta)] + self.verify( + predicted_queue == packet_queue, + "Packet sent by the Traffic Generator assigned to incorrect queue by the RSS.", + ) + + if verify_packet_pairs: + hash_list.append(packet_hash) + + if verify_packet_pairs: + # Go through pairs of hashes in list and verify they are the same + for odd_hash, even_hash in zip(hash_list[0::2], hash_list[1::2]): + self.verify( + odd_hash == even_hash, + "Packet pair do not have same hash. Hash algorithm is not symmetric.", + ) + + def send_test_packets( + self, + testpmd: TestPmdShell, + send_additional_mirrored_packet: bool = False, + ) -> list[TestPmdVerbosePacket]: + """Sends test packets. + + Send 10 packets from the TG to SUT, parsing the verbose output and returning it. + If the algorithm chosen is symmetric, send an additional packet for each initial + packet sent, which has the L4 src and dst swapped. + + Args: + testpmd: Used to send packets and send commands to testpmd. + send_additional_mirrored_packet: Send an additional mirrored packet for each packet + sent. + + Returns: + TestPmdVerbosePacket: List of packets. + """ + # Create test packets + packets = [] + for i in range(10): + packets.append( + Ether(src="02:00:00:00:00:00", dst="11:00:00:00:00:00") + / IP() + / UDP(sport=i, dport=i + 1), + ) + if send_additional_mirrored_packet: # If symmetric, send the inverse packets + packets.append( + Ether(src="02:00:00:00:00:00", dst="11:00:00:00:00:00") + / IP() + / UDP(sport=i + 1, dport=i), + ) + + # Set verbose packet information and start packet capture + testpmd.set_verbose(level=3) + testpmd.start() + testpmd.start_all_ports() + self.send_packets_and_capture(packets) + + # Stop packet capture and revert verbose packet information + testpmd_shell_out = testpmd.stop() + testpmd.set_verbose(level=0) + # Parse the packets and return them + return testpmd.extract_verbose_output(testpmd_shell_out) + + def setup_rss_environment( + self, + testpmd: TestPmdShell, + ) -> None: + """Sets up the testpmd environment for RSS test suites. + + Sets the testpmd forward mode to rx_only and RSS on the NIC to UDP. + + Args: + testpmd: Where the environment will be set. + """ + # Set forward mode to receive only, to remove forwarded packets from verbose output + testpmd.set_forward_mode(SimpleForwardingModes.rxonly) + + # Reset RSS settings and only RSS udp packets + testpmd.port_config_all_rss_offload_type(RSSOffloadTypesFlag.udp) + + def configure_random_reta(self, testpmd: TestPmdShell, queue_number: int) -> list[int]: + """Configure RETA to have random order of queues. + + Args: + testpmd: The testpmd instance that will be used to set the rss environment. + queue_number: Number of queues that will be randomly inserted into the RETA. + + Returns: + List of ids matching the configured RETA table + + Raises: + InteractiveCommandExecutionError: If size of RETA table for driver is None. + """ + reta_size = testpmd.show_port_info(port_id=0).redirection_table_size + if reta_size is None: + raise InteractiveCommandExecutionError("Size of RETA table for driver is None.") + reta_table: list[int] = [] + + for i in range(reta_size): + random_id = random.randint(0, queue_number - 1) + reta_table.insert(i, random_id) + testpmd.port_config_rss_reta(port_id=0, hash_index=i, queue_id=random_id) + return reta_table + + def verify_rss_hash_function( + self, + testpmd: TestPmdShell, + hash_algorithm: HashAlgorithm, + flow_rule: FlowRule, + reta: list[int], + ) -> None: + """Verifies hash function are working by sending test packets and checking the packet queue. + + Args: + testpmd: The testpmd instance that will be used to set the rss environment. + hash_algorithm: The hash algorithm to be tested. + flow_rule: The flow rule that is to be validated and then created. + reta: Will be used to calculate the predicted packet queues. + """ + is_symmetric = hash_algorithm == HashAlgorithm.SYMMETRIC_TOEPLITZ + self.setup_rss_environment(testpmd) + testpmd.flow_create(flow_rule, port_id=0) + # Send udp packets and ensure hash corresponds with queue + parsed_output = self.send_test_packets( + testpmd, send_additional_mirrored_packet=is_symmetric + ) + self.verify_hash_queue(reta, parsed_output, is_symmetric) + + @func_test + def test_key_hash_algorithm(self) -> None: + """Hashing algorithm test. + + Steps: + Setup RSS environment using the chosen algorithm. + Send test packets for each flow rule. + + Verify: + Packet hash corresponds to the packet queue. + + Raises: + InteractiveCommandExecutionError: If size of RETA table for driver is None. + InteractiveCommandExecutionError: If there are no valid flow rules that can be created. + """ + failed_attempts: int = 0 + for algorithm in HashAlgorithm: + flow_rule = FlowRule( + group_id=0, + direction="ingress", + pattern=["eth / ipv4 / udp"], + actions=[f"rss types ipv4-udp end queues end func {algorithm.name.lower()}"], + ) + with TestPmdShell( + rx_queues=self.config.NUM_QUEUES, + tx_queues=self.config.NUM_QUEUES, + ) as testpmd: + reta_table = self.configure_random_reta(testpmd, self.config.NUM_QUEUES) + + if not testpmd.flow_validate(flow_rule, port_id=0): + # Queues need to be specified in the flow rule on some NICs + queue_ids = " ".join([str(x) for x in reta_table]) + flow_rule.actions = [ + f"rss types ipv4-udp end queues {queue_ids} end func " + + algorithm.name.lower() + ] + + if not testpmd.flow_validate(flow_rule, port_id=0): + failed_attempts += 1 + if failed_attempts == len(HashAlgorithm): + raise InteractiveCommandExecutionError( + "No Valid flow rule could be created." + ) + # if neither rule format is valid then the algorithm is not supported, + # move to next one + continue + self.verify_rss_hash_function(testpmd, algorithm, flow_rule, reta_table) + + @func_test + def test_update_key_set_hash_key_short_long(self) -> None: + """Set hash key short long test. + + Steps: + Fetch the hash key size. + Create two random hash keys one key too short and one too long. + + Verify: + Verify that it is not possible to set the shorter hash key. + Verify that it is not possible to set the longer hash key. + + Raises: + InteractiveCommandExecutionError: If port info dose not contain hash key size. + """ + with TestPmdShell( + memory_channels=4, + rx_queues=self.config.NUM_QUEUES, + tx_queues=self.config.NUM_QUEUES, + ) as testpmd: + # Get RETA and key size + port_info = testpmd.show_port_info(port_id=0) + + # Get hash key size + key_size = port_info.hash_key_size + if key_size is None: + raise InteractiveCommandExecutionError("Port info does not contain hash key size.") + + # Create 2 hash keys based on the NIC capabilities + short_key = "".join( + [random.choice("0123456789ABCDEF") for n in range(key_size * 2 - 2)] + ) + long_key = "".join([random.choice("0123456789ABCDEF") for n in range(key_size * 2 + 2)]) + + # Verify a short key cannot be set + short_key_out = testpmd.port_config_rss_hash_key( + 0, RSSOffloadTypesFlag.ipv4_udp, short_key, False + ) + self.verify( + "invalid" in short_key_out, + "Able to set hash key shorter than specified.", + ) + + # Verify a long key cannot be set + long_key_out = testpmd.port_config_rss_hash_key( + 0, RSSOffloadTypesFlag.ipv4_udp, long_key, False + ) + self.verify("invalid" in long_key_out, "Able to set hash key longer than specified.") + + @func_test + def test_update_key_reported_key_size(self) -> None: + """Verify reported hash key size is the same as the NIC capabilities. + + Steps: + Fetch the hash key size and compare to the actual key size. + + Verify: + Reported key size is the same as the actual key size. + """ + with TestPmdShell() as testpmd: + reported_key_size = testpmd.show_port_info(port_id=0).hash_key_size + self.verify( + reported_key_size == self.config.ACTUAL_KEY_SIZE, + "Reported key size is not the same as the config file.", + ) + + @func_test + def test_reta_key_reta_queues(self) -> None: + """RETA rx/tx queues test. + + Steps: + For each queue size setup RSS environment and send Test packets. + + Verify: + Packet hash corresponds to hash queue. + + Raises: + InteractiveCommandExecutionError: If size of RETA table for driver is None. + """ + queues_numbers = [2, 9, 16] + for queue_number in queues_numbers: + with TestPmdShell( + rx_queues=queue_number, + tx_queues=queue_number, + ) as testpmd: + # Configure the RETA with random queues + reta = self.configure_random_reta(testpmd, queue_number) + + self.setup_rss_environment(testpmd) + + # Send UDP packets and ensure hash corresponds with queue + parsed_output = self.send_test_packets(testpmd) + self.verify_hash_queue(reta, parsed_output, False) + + @func_test + def test_reta_key_reported_reta_size(self) -> None: + """Reported RETA size test. + + Steps: + Fetch reported reta size. + + Verify: + Reported RETA size is equal to the actual RETA size. + """ + with TestPmdShell( + rx_queues=self.config.NUM_QUEUES, + tx_queues=self.config.NUM_QUEUES, + ) as testpmd: + reported_reta_size = testpmd.show_port_info(port_id=0).redirection_table_size + self.verify( + reported_reta_size == self.config.ACTUAL_RETA_SIZE, + "Reported RETA size is not the same as the config file.", + )
Signature · 1 line
2.43.0
Re: [PATCH v4 2/2] dts: add PMD RSS testsuite
Hi Thomas,
Quoted 14 lines · Thomas Wilks
Port over the
rss_key_update,pmd_rss_retaandpmd_rss_hashtest suites from old DTS into one file including all of the helper functions that are required by all of the test suites to work.The
rss_key_updatetest cases verify that setting a new hash key when Receive Side Scaling (RSS) will result in a change in the packets destination queue. These test cases also verifies that the reported key size of the NIC is correct.The
pmd_rss_retatest cases verify that Redirection Tables (RETAs) of different sizes function correctly in RSS. These test cases also verify that the reported reta size of the NIC is correct.
Quoted 5 lines
The
pmd_rss_hashtest case verifies that the 4 supported types of hashing algorithm used in RSS function correctly and that the nic supports them. The four hashing algorithms being DEFAULT, TOEPLITZ,SYMMETRIC_TOEPLITZandSIMPLE_XOR. These test cases also verify that the supported hashing algorithms reported by the NIC are correct.
This is a huge improvement, and the patch is quite neat.
Apparently, the code does not consider cases where 'l3-dst-only, 'l4-dst-only' and similar flags get requested along with 'ipv4-udp'. Is it worth considering?
Also, the test doesn't seem to validate the literal value of the 32-bit hash to make sure the predicted value matches the one in the packet's metadata. Though, I admit adding such coverage on the hoof might not be good and I don't insist.
The patch is probably good as it is.
Thank you.
Quoted 400 lines
Signed-off-by Thomas Wilks <[email protected]>---
dts/tests/TestSuite_pmd_rss.py| 383 +++++++++++++++++++++++++++++++++1 file changed, 383 insertions(+)create mode 100644
dts/tests/TestSuite_pmd_rss.pydts/tests/TestSuite_pmd_rss.py new file +383
-0@@ -0,0 +1,383 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright(c) 2025 Arm Limited + +"""RSS testing suite. + +Tests different hashing algorithms by checking if packets are routed to correct queues. +Tests updating the RETA (Redirection Table) key to verify it takes effect and follows +set size constraints. +Tests RETA behavior under changing number of queues. +""" + +import random + +from scapy.layers.inet import IP, UDP +from scapy.layers.l2 import Ether + +from framework.exception import InteractiveCommandExecutionError +from framework.params.testpmd import SimpleForwardingModes +from framework.remote_session.testpmd_shell import ( + FlowRule, + RSSOffloadTypesFlag, + TestPmdShell, + TestPmdVerbosePacket, +) +from framework.test_suite import BaseConfig, TestSuite, func_test +from framework.testbed_model.capability import requires +from framework.testbed_model.topology import TopologyType +from framework.utils import StrEnum + + +class Config(BaseConfig): + """Default configuration for Per Test Suite config.""" + + NUM_QUEUES: int = 4 + + ACTUAL_KEY_SIZE: int = 52 + + ACTUAL_RETA_SIZE: int = 512 + + +class HashAlgorithm(StrEnum): + """Enum of hashing algorithms.""" + + DEFAULT = "default" + SIMPLE_XOR = "simple_xor" + TOEPLITZ = "toeplitz" + SYMMETRIC_TOEPLITZ = "symmetric_toeplitz" + + +@requires(topology_type=TopologyType.one_link) +class TestPmdRss(TestSuite): + """PMD RSS test suite.""" + + config: Config + + def verify_hash_queue( + self, + reta: list[int], + received_packets: list[TestPmdVerbosePacket], + verify_packet_pairs: bool, + ) -> None: + """Verifies the packet hash corresponds to the packet queue. + + Given the received packets in the verbose output, iterate through each packet. + Use the hash to index into RETA and get its intended queue. + Verify the intended queue is the same as the actual queue the packet was received in. + If the hash algorithm is symmetric, verify that pairs of packets have the same hash, + as the pairs of packets sent have "mirrored" L4 ports. + e.g. received_packets[0, 1, 2, 3, ...] hash(0) = hash(1), hash(2) = hash(3), ... + + Args: + reta: Used to get predicted queue based on hash. + received_packets: Packets received in the verbose output of testpmd. + verify_packet_pairs: Verify pairs of packets have the same hash. + + Raises: + InteractiveCommandExecutionError: If packet_hash is None. + """ + # List of packet hashes, used for symmetric algorithms + hash_list = [] + for packet in received_packets: + # Ignore stray packets + if packet.port_id != 0 or packet.src_mac != "02:00:00:00:00:00": + continue + # Get packet hash + packet_hash = packet.rss_hash + if packet_hash is None: + raise InteractiveCommandExecutionError( + "Packet sent by the Traffic Generator has no RSS hash attribute." + ) + + packet_queue = packet.rss_queue + + # Calculate the predicted packet queue + predicted_queue = reta[packet_hash % len(reta)] + self.verify( + predicted_queue == packet_queue, + "Packet sent by the Traffic Generator assigned to incorrect queue by the RSS.", + ) + + if verify_packet_pairs: + hash_list.append(packet_hash) + + if verify_packet_pairs: + # Go through pairs of hashes in list and verify they are the same + for odd_hash, even_hash in zip(hash_list[0::2], hash_list[1::2]): + self.verify( + odd_hash == even_hash, + "Packet pair do not have same hash. Hash algorithm is not symmetric.", + ) + + def send_test_packets( + self, + testpmd: TestPmdShell, + send_additional_mirrored_packet: bool = False, + ) -> list[TestPmdVerbosePacket]: + """Sends test packets. + + Send 10 packets from the TG to SUT, parsing the verbose output and returning it. + If the algorithm chosen is symmetric, send an additional packet for each initial + packet sent, which has the L4 src and dst swapped. + + Args: + testpmd: Used to send packets and send commands to testpmd. + send_additional_mirrored_packet: Send an additional mirrored packet for each packet + sent. + + Returns: + TestPmdVerbosePacket: List of packets. + """ + # Create test packets + packets = [] + for i in range(10): + packets.append( + Ether(src="02:00:00:00:00:00", dst="11:00:00:00:00:00") + / IP() + / UDP(sport=i, dport=i + 1), + ) + if send_additional_mirrored_packet: # If symmetric, send the inverse packets + packets.append( + Ether(src="02:00:00:00:00:00", dst="11:00:00:00:00:00") + / IP() + / UDP(sport=i + 1, dport=i), + ) + + # Set verbose packet information and start packet capture + testpmd.set_verbose(level=3) + testpmd.start() + testpmd.start_all_ports() + self.send_packets_and_capture(packets) + + # Stop packet capture and revert verbose packet information + testpmd_shell_out = testpmd.stop() + testpmd.set_verbose(level=0) + # Parse the packets and return them + return testpmd.extract_verbose_output(testpmd_shell_out) + + def setup_rss_environment( + self, + testpmd: TestPmdShell, + ) -> None: + """Sets up the testpmd environment for RSS test suites. + + Sets the testpmd forward mode to rx_only and RSS on the NIC to UDP. + + Args: + testpmd: Where the environment will be set. + """ + # Set forward mode to receive only, to remove forwarded packets from verbose output + testpmd.set_forward_mode(SimpleForwardingModes.rxonly) + + # Reset RSS settings and only RSS udp packets + testpmd.port_config_all_rss_offload_type(RSSOffloadTypesFlag.udp) + + def configure_random_reta(self, testpmd: TestPmdShell, queue_number: int) -> list[int]: + """Configure RETA to have random order of queues. + + Args: + testpmd: The testpmd instance that will be used to set the rss environment. + queue_number: Number of queues that will be randomly inserted into the RETA. + + Returns: + List of ids matching the configured RETA table + + Raises: + InteractiveCommandExecutionError: If size of RETA table for driver is None. + """ + reta_size = testpmd.show_port_info(port_id=0).redirection_table_size + if reta_size is None: + raise InteractiveCommandExecutionError("Size of RETA table for driver is None.") + reta_table: list[int] = [] + + for i in range(reta_size): + random_id = random.randint(0, queue_number - 1) + reta_table.insert(i, random_id) + testpmd.port_config_rss_reta(port_id=0, hash_index=i, queue_id=random_id) + return reta_table + + def verify_rss_hash_function( + self, + testpmd: TestPmdShell, + hash_algorithm: HashAlgorithm, + flow_rule: FlowRule, + reta: list[int], + ) -> None: + """Verifies hash function are working by sending test packets and checking the packet queue. + + Args: + testpmd: The testpmd instance that will be used to set the rss environment. + hash_algorithm: The hash algorithm to be tested. + flow_rule: The flow rule that is to be validated and then created. + reta: Will be used to calculate the predicted packet queues. + """ + is_symmetric = hash_algorithm == HashAlgorithm.SYMMETRIC_TOEPLITZ + self.setup_rss_environment(testpmd) + testpmd.flow_create(flow_rule, port_id=0) + # Send udp packets and ensure hash corresponds with queue + parsed_output = self.send_test_packets( + testpmd, send_additional_mirrored_packet=is_symmetric + ) + self.verify_hash_queue(reta, parsed_output, is_symmetric) + + @func_test + def test_key_hash_algorithm(self) -> None: + """Hashing algorithm test. + + Steps: + Setup RSS environment using the chosen algorithm. + Send test packets for each flow rule. + + Verify: + Packet hash corresponds to the packet queue. + + Raises: + InteractiveCommandExecutionError: If size of RETA table for driver is None. + InteractiveCommandExecutionError: If there are no valid flow rules that can be created. + """ + failed_attempts: int = 0 + for algorithm in HashAlgorithm: + flow_rule = FlowRule( + group_id=0, + direction="ingress", + pattern=["eth / ipv4 / udp"], + actions=[f"rss types ipv4-udp end queues end func {algorithm.name.lower()}"], + ) + with TestPmdShell( + rx_queues=self.config.NUM_QUEUES, + tx_queues=self.config.NUM_QUEUES, + ) as testpmd: + reta_table = self.configure_random_reta(testpmd, self.config.NUM_QUEUES) + + if not testpmd.flow_validate(flow_rule, port_id=0): + # Queues need to be specified in the flow rule on some NICs + queue_ids = " ".join([str(x) for x in reta_table]) + flow_rule.actions = [ + f"rss types ipv4-udp end queues {queue_ids} end func " + + algorithm.name.lower() + ] + + if not testpmd.flow_validate(flow_rule, port_id=0): + failed_attempts += 1 + if failed_attempts == len(HashAlgorithm): + raise InteractiveCommandExecutionError( + "No Valid flow rule could be created." + ) + # if neither rule format is valid then the algorithm is not supported, + # move to next one + continue + self.verify_rss_hash_function(testpmd, algorithm, flow_rule, reta_table) + + @func_test + def test_update_key_set_hash_key_short_long(self) -> None: + """Set hash key short long test. + + Steps: + Fetch the hash key size. + Create two random hash keys one key too short and one too long. + + Verify: + Verify that it is not possible to set the shorter hash key. + Verify that it is not possible to set the longer hash key. + + Raises: + InteractiveCommandExecutionError: If port info dose not contain hash key size. + """ + with TestPmdShell( + memory_channels=4, + rx_queues=self.config.NUM_QUEUES, + tx_queues=self.config.NUM_QUEUES, + ) as testpmd: + # Get RETA and key size + port_info = testpmd.show_port_info(port_id=0) + + # Get hash key size + key_size = port_info.hash_key_size + if key_size is None: + raise InteractiveCommandExecutionError("Port info does not contain hash key size.") + + # Create 2 hash keys based on the NIC capabilities + short_key = "".join( + [random.choice("0123456789ABCDEF") for n in range(key_size * 2 - 2)] + ) + long_key = "".join([random.choice("0123456789ABCDEF") for n in range(key_size * 2 + 2)]) + + # Verify a short key cannot be set + short_key_out = testpmd.port_config_rss_hash_key( + 0, RSSOffloadTypesFlag.ipv4_udp, short_key, False + ) + self.verify( + "invalid" in short_key_out, + "Able to set hash key shorter than specified.", + ) + + # Verify a long key cannot be set + long_key_out = testpmd.port_config_rss_hash_key( + 0, RSSOffloadTypesFlag.ipv4_udp, long_key, False + ) + self.verify("invalid" in long_key_out, "Able to set hash key longer than specified.") + + @func_test + def test_update_key_reported_key_size(self) -> None: + """Verify reported hash key size is the same as the NIC capabilities. + + Steps: + Fetch the hash key size and compare to the actual key size. + + Verify: + Reported key size is the same as the actual key size. + """ + with TestPmdShell() as testpmd: + reported_key_size = testpmd.show_port_info(port_id=0).hash_key_size + self.verify( + reported_key_size == self.config.ACTUAL_KEY_SIZE, + "Reported key size is not the same as the config file.", + ) + + @func_test + def test_reta_key_reta_queues(self) -> None: + """RETA rx/tx queues test. + + Steps: + For each queue size setup RSS environment and send Test packets. + + Verify: + Packet hash corresponds to hash queue. + + Raises: + InteractiveCommandExecutionError: If size of RETA table for driver is None. + """ + queues_numbers = [2, 9, 16] + for queue_number in queues_numbers: + with TestPmdShell( + rx_queues=queue_number, + tx_queues=queue_number, + ) as testpmd: + # Configure the RETA with random queues + reta = self.configure_random_reta(testpmd, queue_number) + + self.setup_rss_environment(testpmd) + + # Send UDP packets and ensure hash corresponds with queue + parsed_output = self.send_test_packets(testpmd) + self.verify_hash_queue(reta, parsed_output, False) + + @func_test + def test_reta_key_reported_reta_size(self) -> None: + """Reported RETA size test. + + Steps: + Fetch reported reta size. + + Verify: + Reported RETA size is equal to the actual RETA size. + """ + with TestPmdShell( + rx_queues=self.config.NUM_QUEUES, + tx_queues=self.config.NUM_QUEUES, + ) as testpmd: + reported_reta_size = testpmd.show_port_info(port_id=0).redirection_table_size + self.verify( + reported_reta_size == self.config.ACTUAL_RETA_SIZE, + "Reported RETA size is not the same as the config file.", + )Signature · 1 line
2.43.0
Re: [PATCH v4 2/2] dts: add PMD RSS testsuite
In reply to Thomas WilksQuoted 29 lines · Thomas Wilks
+ def configure_random_reta(self, testpmd: TestPmdShell,
queue_number:
int) -> list[int]:dts/tests/TestSuite_pmd_rss.py new file +4
-0+ """Configure RETA to have random order of queues. + + Args: + testpmd: The testpmd instance that will be used to set therss environment.
+queue_number: Number of queues that will be randomly inserted
into the RETA.dts/tests/TestSuite_pmd_rss.py new file +6
-0+ + Returns: + List of ids matching the configured RETA table + + Raises: + InteractiveCommandExecutionError: If size of RETA table fordriver is None.
(quoted diff) +2
-0+ """ + reta_size =testpmd.show_port_info(port_id=0).redirection_table_size
(quoted diff) +2
-0+ if reta_size is None: + raise InteractiveCommandExecutionError("Size of RETA tablefor driver is None.")
dts/tests/TestSuite_pmd_rss.py new file +6
-0+ reta_table: list[int] = [] + + for i in range(reta_size): + random_id = random.randint(0, queue_number - 1) + reta_table.insert(i, random_id) + testpmd.port_config_rss_reta(port_id=0, hash_index=i,
Quoted 2 lines
queue_id=random_id)
I just did my testrun with a connectx5 NIC. It looks like it returned 4 for redirection_table_size.
2025/08/25 22:04:04 - test_case - dts.lucian-cx5-SUT.TestPmdShell - INFO -
Sending: 'port config 0 rss reta (0,2)'
2025/08/25 22:04:04 - test_case - dts.lucian-cx5-SUT.TestPmdShell - INFO -
Sending: 'port config 0 rss reta (1,1)'
2025/08/25 22:04:04 - test_case - dts.lucian-cx5-SUT.TestPmdShell - INFO -
Sending: 'port config 0 rss reta (2,0)'
2025/08/25 22:04:04 - test_case - dts.lucian-cx5-SUT.TestPmdShell - INFO -
Sending: 'port config 0 rss reta (3,2)'
So, if the default queue size is 4, and the redirection_table_size is 4 in this case, then there is a 1/(4^3), or 1/64 chance that all of the reta table entries will be directed to the same queue. Should we enforce some diversity of queues in the implementation?
I guess in principle even if all the hashes get associated with the same queue the test would still be valid (it would show that all the packets get directed to the same queue) but that seems moreso like testing an edge case (which again, is valid) rather than testing the primary use case of RSS. Another strategy might be like:
test1: enforce diversity of queue destinations for different hashes via the implementation
test2: set random queue destinations for each hash (your current strategy)
test3: set the same queue destination for all hashes
What are your thoughts on this? And let me know if I'm misunderstanding your strategy in any way.
+ return reta_table
Quoted 164 lines
dts/tests/TestSuite_pmd_rss.py new file +9
-0+ + def verify_rss_hash_function( + self, + testpmd: TestPmdShell, + hash_algorithm: HashAlgorithm, + flow_rule: FlowRule, + reta: list[int], + ) -> None: + """Verifies hash function are working by sending test packets andchecking the packet queue.
dts/tests/TestSuite_pmd_rss.py new file +3
-0+ + Args: + testpmd: The testpmd instance that will be used to set therss environment.
(quoted diff) +2
-0+ hash_algorithm: The hash algorithm to be tested. + flow_rule: The flow rule that is to be validated and thencreated.
dts/tests/TestSuite_pmd_rss.py new file +24
-0+ reta: Will be used to calculate the predicted packet queues. + """ + is_symmetric = hash_algorithm == HashAlgorithm.SYMMETRIC_TOEPLITZ + self.setup_rss_environment(testpmd) + testpmd.flow_create(flow_rule, port_id=0) + # Send udp packets and ensure hash corresponds with queue + parsed_output = self.send_test_packets( + testpmd, send_additional_mirrored_packet=is_symmetric + ) + self.verify_hash_queue(reta, parsed_output, is_symmetric) + + @func_test + def test_key_hash_algorithm(self) -> None: + """Hashing algorithm test. + + Steps: + Setup RSS environment using the chosen algorithm. + Send test packets for each flow rule. + + Verify: + Packet hash corresponds to the packet queue. + + Raises: + InteractiveCommandExecutionError: If size of RETA table fordriver is None.
+ InteractiveCommandExecutionError: If there are no valid flow
rules that can be created.dts/tests/TestSuite_pmd_rss.py new file +8
-0+ """ + failed_attempts: int = 0 + for algorithm in HashAlgorithm: + flow_rule = FlowRule( + group_id=0, + direction="ingress", + pattern=["eth / ipv4 / udp"], + actions=[f"rss types ipv4-udp end queues end func{
algorithm.name.lower()}"],dts/tests/TestSuite_pmd_rss.py new file +6
-0+ ) + with TestPmdShell( + rx_queues=self.config.NUM_QUEUES, + tx_queues=self.config.NUM_QUEUES, + ) as testpmd: + reta_table = self.configure_random_reta(testpmd,self.config.NUM_QUEUES)
dts/tests/TestSuite_pmd_rss.py new file +3
-0+ + if not testpmd.flow_validate(flow_rule, port_id=0): + # Queues need to be specified in the flow rule onsome NICs
dts/tests/TestSuite_pmd_rss.py new file +3
-0+ queue_ids = " ".join([str(x) for x in reta_table]) + flow_rule.actions = [ + f"rss types ipv4-udp end queues {queue_ids} endfunc "
dts/tests/TestSuite_pmd_rss.py new file +10
-0+ + algorithm.name.lower() + ] + + if not testpmd.flow_validate(flow_rule, port_id=0): + failed_attempts += 1 + if failed_attempts == len(HashAlgorithm): + raise InteractiveCommandExecutionError( + "No Valid flow rule could be created." + ) + # if neither rule format is valid then thealgorithm is not supported,
dts/tests/TestSuite_pmd_rss.py new file +3
-0+ # move to next one + continue + self.verify_rss_hash_function(testpmd, algorithm,
flow_rule,reta_table)dts/tests/TestSuite_pmd_rss.py new file +8
-0+ + @func_test + def test_update_key_set_hash_key_short_long(self) -> None: + """Set hash key short long test. + + Steps: + Fetch the hash key size. + Create two random hash keys one key too short and one toolong.
dts/tests/TestSuite_pmd_rss.py new file +7
-0+ + Verify: + Verify that it is not possible to set the shorter hash key. + Verify that it is not possible to set the longer hash key. + + Raises: + InteractiveCommandExecutionError: If port info dose notcontain hash key size.
dts/tests/TestSuite_pmd_rss.py new file +13
-0+ """ + with TestPmdShell( + memory_channels=4, + rx_queues=self.config.NUM_QUEUES, + tx_queues=self.config.NUM_QUEUES, + ) as testpmd: + # Get RETA and key size + port_info = testpmd.show_port_info(port_id=0) + + # Get hash key size + key_size = port_info.hash_key_size + if key_size is None: + raise InteractiveCommandExecutionError("Port info doesnot contain hash key size.")
dts/tests/TestSuite_pmd_rss.py new file +4
-0+ + # Create 2 hash keys based on the NIC capabilities + short_key = "".join( + [random.choice("0123456789ABCDEF") for n in
range(key_size * 2 - 2)](quoted diff) +2
-0+ ) + long_key = "".join([random.choice("0123456789ABCDEF") for nin
range(key_size * 2 + 2)])dts/tests/TestSuite_pmd_rss.py new file +15
-0+ + # Verify a short key cannot be set + short_key_out = testpmd.port_config_rss_hash_key( + 0, RSSOffloadTypesFlag.ipv4_udp, short_key, False + ) + self.verify( + "invalid" in short_key_out, + "Able to set hash key shorter than specified.", + ) + + # Verify a long key cannot be set + long_key_out = testpmd.port_config_rss_hash_key( + 0, RSSOffloadTypesFlag.ipv4_udp, long_key, False + ) + self.verify("invalid" in long_key_out, "Able to set hash keylonger than specified.")
dts/tests/TestSuite_pmd_rss.py new file +4
-0+ + @func_test + def test_update_key_reported_key_size(self) -> None: + """Verify reported hash key size is the same as the NICcapabilities.
dts/tests/TestSuite_pmd_rss.py new file +9
-0+ + Steps: + Fetch the hash key size and compare to the actual key size. + + Verify: + Reported key size is the same as the actual key size. + """ + with TestPmdShell() as testpmd: + reported_key_size =testpmd.show_port_info(port_id=0).hash_key_size
dts/tests/TestSuite_pmd_rss.py new file +11
-0+ self.verify( + reported_key_size == self.config.ACTUAL_KEY_SIZE, + "Reported key size is not the same as the config file.", + ) + + @func_test + def test_reta_key_reta_queues(self) -> None: + """RETA rx/tx queues test. + + Steps: + For each queue size setup RSS environment and send Test
Quoted 2 lines
packets.
Test should have lowercase t
dts/tests/TestSuite_pmd_rss.py line 351
Quoted 11 lines
dts/tests/TestSuite_pmd_rss.py new file +6
-0+ + Verify: + Packet hash corresponds to hash queue. + + Raises: + InteractiveCommandExecutionError: If size of RETA table fordriver is None.
dts/tests/TestSuite_pmd_rss.py new file +3
-0+ """ + queues_numbers = [2, 9, 16] + for queue_number in queues_numbers:
I am a little confused by how this ran - maybe you can help. :)
The first iteration through, the reta size was 2, and it used a queue size of 2.
The second iteration through, the reta size was 512, and the queue size was 9.
The third iteration through, the reta size was 16 and the queue size was 16.
Is this what you expect? I can't quite tell why the reta size was 512 in the second case. If it matters, I didn't provide any tests_config.yaml for this testsuite, so I was running from the default config.
Quoted 30 lines
dts/tests/TestSuite_pmd_rss.py new file +28
-0+ with TestPmdShell( + rx_queues=queue_number, + tx_queues=queue_number, + ) as testpmd: + # Configure the RETA with random queues + reta = self.configure_random_reta(testpmd, queue_number) + + self.setup_rss_environment(testpmd) + + # Send UDP packets and ensure hash corresponds with queue + parsed_output = self.send_test_packets(testpmd) + self.verify_hash_queue(reta, parsed_output, False) + + @func_test + def test_reta_key_reported_reta_size(self) -> None: + """Reported RETA size test. + + Steps: + Fetch reported reta size. + + Verify: + Reported RETA size is equal to the actual RETA size. + """ + with TestPmdShell( + rx_queues=self.config.NUM_QUEUES, + tx_queues=self.config.NUM_QUEUES, + ) as testpmd: + reported_reta_size =testpmd.show_port_info(port_id=0).redirection_table_size
dts/tests/TestSuite_pmd_rss.py line 382
Quoted 3 lines
dts/tests/TestSuite_pmd_rss.py new file +3
-0+ self.verify( + reported_reta_size == self.config.ACTUAL_RETA_SIZE, + "Reported RETA size is not the same as the config file.",
If we are going to have such a test I think this verify fail message should be an f string which inserts the reported reta size and the reta size from the config file. I think that's an improvement in general, and it also will help with the fact that some users may not be accustomed to usage of tests_config.yaml (yet).
At the same time, I want to thank you for making effective use of tests_config in this testsuite. :)
Quoted 5 lines
+ )
--
2.43.0
Thanks a bunch Thomas - this looks good overall. Let me know what your thoughts are on the comments and otherwise I think we are close to pushing this.
Patrick Robb
Reviewed-byRe: [PATCH v4 2/2] dts: add PMD RSS testsuite
I forgot to add my tag to the previous email.
v5 cover dts: add RSS functions and test suite
In reply to Thomas WilksThis patch series adds the required functionality for the RSS functions and test suite.
v5:
- added preset RETA configurations as per review
- rebased onto latest upstream
Alex Chapman (1):
dts: add RSS functions to testpmd
Thomas Wilks (1):
dts: add PMD RSS testsuite
dts/api/testpmd/__init__.py | 91 +++++++- dts/api/testpmd/types.py | 12 +- dts/tests/TestSuite_pmd_rss.py | 396 +++++++++++++++++++++++++++++++++ 3 files changed, 494 insertions(+), 5 deletions(-) create mode 100644 dts/tests/TestSuite_pmd_rss.py
--
2.39.5
PATCH v5 1/2 dts: add RSS functions to testpmd
From: Alex Chapman <[email protected]>
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.
Depends-on: series-36111 ("Split DTS framework and public API")
--- dts/api/testpmd/__init__.py | 91 +++++++++++++++++++++++++++++++++++-- dts/api/testpmd/types.py | 12 ++++- 2 files changed, 98 insertions(+), 5 deletions(-)
dts/api/testpmd/__init__.py +88 -3
@@ -37,6 +37,7 @@ ChecksumOffloadOptions, DeviceCapabilitiesFlag, FlowRule, + RSSOffloadTypesFlag, RxOffloadCapabilities, RxOffloadCapability, TestPmdDevice,
@@ -355,6 +356,82 @@ def close_all_ports(self, verify: bool = True) -> None: if not all(f"Port {p_id} is closed" in port_close_output for p_id in range(num_ports)): raise InteractiveCommandExecutionError("Ports were not closed successfully.") + def port_config_rss_reta( + self, port_id: int, hash_index: int, queue_id: int, verify: bool = True + ) -> None: + """Configure a port's RSS redirection table. + + Args: + port_id: The port where the 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`, 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: + flag: 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: + InteractiveCommandExecutionError: If `verify` is :data:`True` + Testpmd failed to config the RSS mode on all ports. + """ + 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( + f"Testpmd failed to change RSS mode to {flag.name}" + ) + + def port_config_rss_hash_key( + self, + port_id: int, + offload_type: RSSOffloadTypesFlag, + hex_str: str, + verify: bool = True, + ) -> str: + """Sets the RSS hash key for the specified port. + + Args: + port_id: The port that will have the hash key applied to. + offload_type: The offload type the hash key will be applied to. + hex_str: The hash key to set. + verify: If :data:`True`, verify that RSS has the key. + + 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}", + skip_first_line=True, + ) + + if verify: + if output.strip(): + self._logger.debug(f"Failed to set rss hash key: \n{output}") + raise InteractiveCommandExecutionError( + f"Testpmd failed to set {hex_str} on {port_id} with a flag of {offload_type}." + ) + return output + def show_port_info_all(self) -> list[TestPmdPort]: """Returns the information of all the ports.
@@ -573,7 +650,7 @@ def csum_set_hw( {port_id}:\n{csum_output}""" ) - def flow_create(self, flow_rule: FlowRule, port_id: int) -> int: + def flow_create(self, flow_rule: FlowRule, port_id: int, verify: bool = True) -> int: """Creates a flow rule in the testpmd session. This command is implicitly verified as needed to return the created flow rule id.
@@ -581,14 +658,22 @@ def flow_create(self, flow_rule: FlowRule, port_id: int) -> int: Args: flow_rule: :class:`FlowRule` object used for creating testpmd flow rule. port_id: Integer representing the port to use. + verify: If :data:`True`, the output of the command is scanned + to ensure the flow rule was created successfully. Raises: InteractiveCommandExecutionError: If flow rule is invalid. Returns: - Id of created flow rule. + Id of created flow rule as an integer. """ flow_output = self.send_command(f"flow create {port_id} {flow_rule}") + if verify: + if "created" not in flow_output: + self._logger.debug(f"Failed to create flow rule:\n{flow_output}") + raise InteractiveCommandExecutionError( + f"Failed to create flow rule:\n{flow_output}" + ) match = re.search(r"#(\d+)", flow_output) if match is not None: match_str = match.group(1)
@@ -617,7 +702,7 @@ def flow_delete(self, flow_id: int, port_id: int, verify: bool = True) -> None: """Deletes the specified flow rule from the testpmd session. Args: - flow_id: ID of the flow to remove. + flow_id: :class:`FlowRule` id used for deleting testpmd flow rule. port_id: Integer representing the port to use. verify: If :data:`True`, the output of the command is scanned to ensure the flow rule was deleted successfully.
dts/api/testpmd/types.py +10 -2
@@ -307,6 +307,12 @@ def make_parser(cls) -> ParserFn: RSSOffloadTypesFlag.from_list_string, ) + def __str__(self): + """Replaces underscores with hyphens to produce valid testpmd value.""" + if self.name is None: + return "" + return self.name.replace("_", "-") + class DeviceCapabilitiesFlag(Flag): """Flag representing the device capabilities."""
@@ -612,11 +618,13 @@ def _validate(info: str) -> str | None: ) #: Maximum number of VFs max_vfs_num: int | None = field( - default=None, metadata=TextParser.find_int(r"Maximum number of VFs: (\d+)") + default=None, + metadata=TextParser.find_int(r"Maximum number of VFs: (\d+)"), ) #: Maximum number of VMDq pools max_vmdq_pools_num: int | None = field( - default=None, metadata=TextParser.find_int(r"Maximum number of VMDq pools: (\d+)") + default=None, + metadata=TextParser.find_int(r"Maximum number of VMDq pools: (\d+)"), ) #:
--
2.39.5
PATCH v5 2/2 dts: add PMD RSS testsuite
In reply to Paul SzczepanekFrom: Thomas Wilks <[email protected]>
Port over the rss_key_update, pmd_rss_reta and pmd_rss_hash test suites from old DTS into one file including all of the helper functions that are required by all of the test suites to work.
The rss_key_update test cases verify that setting a new hash key when Receive Side Scaling (RSS) will result in a change in the packets destination queue. These test cases also verifies that the reported key size of the NIC is correct.
The pmd_rss_reta test cases verify that Redirection Tables (RETAs) of different sizes function correctly in RSS. These test cases also verify that the reported reta size of the NIC is correct.
The pmd_rss_hash test case verifies that the 4 supported types of hashing algorithm used in RSS function correctly and that the nic supports them. The four hashing algorithms being DEFAULT, TOEPLITZ, SYMMETRIC_TOEPLITZ and SIMPLE_XOR. These test cases also verify that the supported hashing algorithms reported by the NIC are correct.
Depends-on: series-36111 ("Split DTS framework and public API")
--- dts/tests/TestSuite_pmd_rss.py | 396 +++++++++++++++++++++++++++++++++ 1 file changed, 396 insertions(+) create mode 100644 dts/tests/TestSuite_pmd_rss.py
dts/tests/TestSuite_pmd_rss.py new file +396 -0
@@ -0,0 +1,396 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright(c) 2025 Arm Limited + +"""RSS testing suite. + +Tests different hashing algorithms by checking if packets are routed to correct queues. +Tests updating the RETA (Redirection Table) key to verify it takes effect and follows +set size constraints. +Tests RETA behavior under changing number of queues. +""" + +import random + +from scapy.layers.inet import IP, UDP +from scapy.layers.l2 import Ether + +from api.capabilities import ( + LinkTopology, + NicCapability, + requires_link_topology, + requires_nic_capability, +) +from api.testpmd import TestPmd +from api.testpmd.config import SimpleForwardingModes +from api.testpmd.types import ( + FlowRule, + RSSOffloadTypesFlag, + TestPmdVerbosePacket, +) +from framework.exception import InteractiveCommandExecutionError +from framework.test_suite import BaseConfig, TestSuite, func_test +from framework.utils import StrEnum + + +class Config(BaseConfig): + """Default configuration for Per Test Suite config.""" + + NUM_QUEUES: int = 4 + + ACTUAL_KEY_SIZE: int = 52 + + ACTUAL_RETA_SIZE: int = 512 + + +class HashAlgorithm(StrEnum): + """Enum of hashing algorithms.""" + + DEFAULT = "default" + SIMPLE_XOR = "simple_xor" + TOEPLITZ = "toeplitz" + SYMMETRIC_TOEPLITZ = "symmetric_toeplitz" + + +@requires_link_topology(LinkTopology.ONE_LINK) +@requires_nic_capability(NicCapability.RX_OFFLOAD_RSS_HASH) +class TestPmdRss(TestSuite): + """PMD RSS test suite.""" + + config: Config + + def _verify_hash_queue( + self, + reta: list[int], + received_packets: list[TestPmdVerbosePacket], + verify_packet_pairs: bool, + ) -> None: + """Verifies the packet hash corresponds to the packet queue. + + Given the received packets in the verbose output, iterate through each packet. + Use the hash to index into RETA and get its intended queue. + Verify the intended queue is the same as the actual queue the packet was received in. + If the hash algorithm is symmetric, verify that pairs of packets have the same hash, + as the pairs of packets sent have "mirrored" L4 ports. + e.g. received_packets[0, 1, 2, 3, ...] hash(0) = hash(1), hash(2) = hash(3), ... + + Args: + reta: Used to get predicted queue based on hash. + received_packets: Packets received in the verbose output of testpmd. + verify_packet_pairs: Verify pairs of packets have the same hash. + + Raises: + InteractiveCommandExecutionError: If packet_hash is None. + """ + # List of packet hashes, used for symmetric algorithms + hash_list = [] + for packet in received_packets: + # Ignore stray packets + if packet.port_id != 0 or packet.src_mac != "02:00:00:00:00:00": + continue + # Get packet hash + packet_hash = packet.rss_hash + if packet_hash is None: + raise InteractiveCommandExecutionError( + "Packet sent by the Traffic Generator has no RSS hash attribute." + ) + + packet_queue = packet.rss_queue + + # Calculate the predicted packet queue + predicted_queue = reta[packet_hash % len(reta)] + self.verify( + predicted_queue == packet_queue, + "Packet sent by the Traffic Generator assigned to incorrect queue by the RSS.", + ) + + if verify_packet_pairs: + hash_list.append(packet_hash) + + if verify_packet_pairs: + # Go through pairs of hashes in list and verify they are the same + for odd_hash, even_hash in zip(hash_list[0::2], hash_list[1::2]): + self.verify( + odd_hash == even_hash, + "Packet pair do not have same hash. Hash algorithm is not symmetric.", + ) + + def _send_test_packets( + self, + testpmd: TestPmd, + send_additional_mirrored_packet: bool = False, + ) -> list[TestPmdVerbosePacket]: + """Sends test packets. + + Send 10 packets from the TG to SUT, parsing the verbose output and returning it. + If the algorithm chosen is symmetric, send an additional packet for each initial + packet sent, which has the L4 src and dst swapped. + + Args: + testpmd: Used to send packets and send commands to testpmd. + send_additional_mirrored_packet: Send an additional mirrored packet for each packet + sent. + + Returns: + TestPmdVerbosePacket: List of packets. + """ + # Create test packets + packets = [] + for i in range(10): + packets.append( + Ether(src="02:00:00:00:00:00", dst="11:00:00:00:00:00") + / IP() + / UDP(sport=i, dport=i + 1), + ) + if send_additional_mirrored_packet: # If symmetric, send the inverse packets + packets.append( + Ether(src="02:00:00:00:00:00", dst="11:00:00:00:00:00") + / IP() + / UDP(sport=i + 1, dport=i), + ) + + # Set verbose packet information and start packet capture + testpmd.set_verbose(level=3) + testpmd.start() + testpmd.start_all_ports() + self.send_packets_and_capture(packets) + + # Stop packet capture and revert verbose packet information + testpmd_shell_out = testpmd.stop() + testpmd.set_verbose(level=0) + # Parse the packets and return them + return testpmd.extract_verbose_output(testpmd_shell_out) + + def _setup_rss_environment( + self, + testpmd: TestPmd, + ) -> None: + """Sets up the testpmd environment for RSS test suites. + + Sets the testpmd forward mode to rx_only and RSS on the NIC to UDP. + + Args: + testpmd: Where the environment will be set. + """ + # Set forward mode to receive only, to remove forwarded packets from verbose output + testpmd.set_forward_mode(SimpleForwardingModes.rxonly) + + # Reset RSS settings and only RSS udp packets + testpmd.port_config_all_rss_offload_type(RSSOffloadTypesFlag.udp) + + def _configure_reta_presets(self, testpmd: TestPmd, queue_number: int) -> list[list[int]]: + """Build deterministic RETA presets. + + Sequential pattern [0,1,2,...] repeated to RETA size, + reversed pattern [...,2,1,0] repeated to RETA size, + and constant pattern of queue 0. + + Args: + testpmd: The testpmd instance that will be used to set the RSS environment. + queue_number: Number of queues available. + + Returns: + List of RETA tables. + + Raises: + InteractiveCommandExecutionError: If size of RETA table for driver is None. + """ + reta_size = testpmd.show_port_info(port_id=0).redirection_table_size + if reta_size is None: + raise InteractiveCommandExecutionError("Size of RETA table for driver is None.") + + seq = [(i % queue_number) for i in range(reta_size)] + rev = [queue_number - 1 - (i % queue_number) for i in range(reta_size)] + const0 = [0 for _ in range(reta_size)] + return [seq, rev, const0] + + def _apply_reta(self, testpmd: TestPmd, reta: list[int]) -> None: + """Program a RETA into testpmd.""" + for i, q in enumerate(reta): + testpmd.port_config_rss_reta(port_id=0, hash_index=i, queue_id=q) + + def _verify_rss_hash_function( + self, + testpmd: TestPmd, + hash_algorithm: HashAlgorithm, + flow_rule: FlowRule, + reta: list[int], + ) -> None: + """Verifies hash function are working by sending test packets and checking the packet queue. + + Args: + testpmd: The testpmd instance that will be used to set the rss environment. + hash_algorithm: The hash algorithm to be tested. + flow_rule: The flow rule that is to be validated and then created. + reta: Will be used to calculate the predicted packet queues. + """ + is_symmetric = hash_algorithm == HashAlgorithm.SYMMETRIC_TOEPLITZ + self._setup_rss_environment(testpmd) + testpmd.flow_create(flow_rule, port_id=0) + # Send udp packets and ensure hash corresponds with queue + parsed_output = self._send_test_packets( + testpmd, send_additional_mirrored_packet=is_symmetric + ) + self._verify_hash_queue(reta, parsed_output, is_symmetric) + + @func_test + def key_hash_algorithm(self) -> None: + """Hashing algorithm test. + + Steps: + Setup RSS environment using the chosen algorithm. + Send test packets for each flow rule. + + Verify: + Packet hash corresponds to the packet queue. + + Raises: + InteractiveCommandExecutionError: If size of RETA table for driver is None. + InteractiveCommandExecutionError: If there are no valid flow rules that can be created. + """ + failed_attempts: int = 0 + for algorithm in HashAlgorithm: + flow_rule = FlowRule( + group_id=0, + direction="ingress", + pattern=["eth / ipv4 / udp"], + actions=[f"rss types ipv4-udp end queues end func {algorithm.name.lower()}"], + ) + with TestPmd( + rx_queues=self.config.NUM_QUEUES, + tx_queues=self.config.NUM_QUEUES, + ) as testpmd: + reta_tables = self._configure_reta_presets(testpmd, self.config.NUM_QUEUES) + for reta in reta_tables: + self._apply_reta(testpmd, reta) + if not testpmd.flow_validate(flow_rule, port_id=0): + # Queues need to be specified in the flow rule on some NICs + queue_ids = " ".join([str(x) for x in reta]) + flow_rule.actions = [ + f"rss types ipv4-udp end queues {queue_ids} end func " + + algorithm.name.lower() + ] + + if not testpmd.flow_validate(flow_rule, port_id=0): + failed_attempts += 1 + if failed_attempts == len(HashAlgorithm): + raise InteractiveCommandExecutionError( + "No Valid flow rule could be created." + ) + # if neither rule format is valid then the algorithm is not supported, + # move to next one + continue + self._verify_rss_hash_function(testpmd, algorithm, flow_rule, reta) + + @func_test + def update_key_set_hash_key_short_long(self) -> None: + """Set hash key short long test. + + Steps: + Fetch the hash key size. + Create two random hash keys one key too short and one too long. + + Verify: + Verify that it is not possible to set the shorter hash key. + Verify that it is not possible to set the longer hash key. + + Raises: + InteractiveCommandExecutionError: If port info dose not contain hash key size. + """ + with TestPmd( + memory_channels=4, + rx_queues=self.config.NUM_QUEUES, + tx_queues=self.config.NUM_QUEUES, + ) as testpmd: + # Get RETA and key size + port_info = testpmd.show_port_info(port_id=0) + + # Get hash key size + key_size = port_info.hash_key_size + if key_size is None: + raise InteractiveCommandExecutionError("Port info does not contain hash key size.") + + # Create 2 hash keys based on the NIC capabilities + short_key = "".join( + [random.choice("0123456789ABCDEF") for n in range(key_size * 2 - 2)] + ) + long_key = "".join([random.choice("0123456789ABCDEF") for n in range(key_size * 2 + 2)]) + + # Verify a short key cannot be set + short_key_out = testpmd.port_config_rss_hash_key( + 0, RSSOffloadTypesFlag.ipv4_udp, short_key, False + ) + self.verify( + "invalid" in short_key_out, + "Able to set hash key shorter than specified.", + ) + + # Verify a long key cannot be set + long_key_out = testpmd.port_config_rss_hash_key( + 0, RSSOffloadTypesFlag.ipv4_udp, long_key, False + ) + self.verify("invalid" in long_key_out, "Able to set hash key longer than specified.") + + @func_test + def update_key_reported_key_size(self) -> None: + """Verify reported hash key size is the same as the NIC capabilities. + + Steps: + Fetch the hash key size and compare to the actual key size. + + Verify: + Reported key size is the same as the actual key size. + """ + with TestPmd() as testpmd: + reported_key_size = testpmd.show_port_info(port_id=0).hash_key_size + self.verify( + reported_key_size == self.config.ACTUAL_KEY_SIZE, + "Reported key size is not the same as the config file.", + ) + + @func_test + def reta_key_reta_queues(self) -> None: + """RETA rx/tx queues test. + + Steps: + For each queue size setup RSS environment and send Test packets. + + Verify: + Packet hash corresponds to hash queue. + + Raises: + InteractiveCommandExecutionError: If size of RETA table for driver is None. + """ + queues_numbers = [2, 9, 16] + for queue_number in queues_numbers: + with TestPmd( + rx_queues=queue_number, + tx_queues=queue_number, + ) as testpmd: + reta_tables = self._configure_reta_presets(testpmd, queue_number) + for reta in reta_tables: + self._apply_reta(testpmd, reta) + self._setup_rss_environment(testpmd) + + # Send UDP packets and ensure hash corresponds with queue + parsed_output = self._send_test_packets(testpmd) + self._verify_hash_queue(reta, parsed_output, False) + + @func_test + def reta_key_reported_reta_size(self) -> None: + """Reported RETA size test. + + Steps: + Fetch reported reta size. + + Verify: + Reported RETA size is equal to the actual RETA size. + """ + with TestPmd( + rx_queues=self.config.NUM_QUEUES, + tx_queues=self.config.NUM_QUEUES, + ) as testpmd: + reported_reta_size = testpmd.show_port_info(port_id=0).redirection_table_size + self.verify( + reported_reta_size == self.config.ACTUAL_RETA_SIZE, + "Reported RETA size is not the same as the config file.", + )
--
2.39.5
Re: [PATCH v5 2/2] dts: add PMD RSS testsuite
Applied with a rebase on for-main with these fixes:
-imports now coming from api instead of framework -RX_OFFLOAD_RSS_HASH renamed to PORT_RX_OFFLOAD_RSS_HASH