From: Alex Chapman <alex.chapman@arm.com>
To: dev@dpdk.org
Cc: "Alex Chapman" <alex.chapman@arm.com>,
"Honnappa Nagarahalli" <honnappa.nagarahalli@arm.com>,
"Paul Szczepanek" <paul.szczepanek@arm.com>,
"Luca Vizzarro" <luca.vizzarro@arm.com>,
"Juraj Linkeš" <juraj.linkes@pantheon.tech>
Subject: [PATCH] dts: add RSS functions to testpmd
Date: Thu, 29 Aug 2024 13:50:20 +0100 [thread overview]
Message-ID: <20240829125020.34341-1-alex.chapman@arm.com> (raw)
This patch adds the required functionality for the RSS key_update,
RETA, and hash test suites. This includes:
The setting of custom RETA values for routing packets to specific
queues.
The setting of the RSS mode on all ports, to specify how to hash
the packets.
The updating of the RSS hash key used during the hashing process.
Alongside this, there is the addition of a __str__ method to the
RSSOffloadTypesFlags class, so that when flag names are cast to
a string they will use '-' as separators, instead of '_'.
This allows them to be directly used within testpmd RSS commands
without any further changes.
Signed-off-by: Alex Chapman <alex.chapman@arm.com>
Reviewed-by: Luca Vizzarro <luca.vizzarro@arm.com>
---
dts/framework/remote_session/testpmd_shell.py | 84 ++++++++++++++++++-
1 file changed, 83 insertions(+), 1 deletion(-)
diff --git a/dts/framework/remote_session/testpmd_shell.py b/dts/framework/remote_session/testpmd_shell.py
index 43e9f56517..7b66901f6e 100644
--- a/dts/framework/remote_session/testpmd_shell.py
+++ b/dts/framework/remote_session/testpmd_shell.py
@@ -23,7 +23,7 @@
from typing_extensions import Self, Unpack
-from framework.exception import InteractiveCommandExecutionError
+from framework.exception import InteractiveCommandExecutionError, InternalError
from framework.params.testpmd import SimpleForwardingModes, TestPmdParams
from framework.params.types import TestPmdParamsDict
from framework.parser import ParserFn, TextParser
@@ -305,6 +305,12 @@ def make_parser(cls) -> ParserFn:
RSSOffloadTypesFlag.from_list_string,
)
+ def __str__(self):
+ """Stringifies the flag name."""
+ if self.name is None:
+ return ""
+ return self.name.replace("_", "-")
+
class DeviceCapabilitiesFlag(Flag):
"""Flag representing the device capabilities."""
@@ -723,6 +729,82 @@ def set_forward_mode(self, mode: SimpleForwardingModes, verify: bool = True):
f"Test pmd failed to set fwd mode to {mode.value}"
)
+ def port_config_rss_reta(
+ self, port_id: int, hash_index: int, queue_id: int, verify: bool = True
+ ) -> None:
+ """Configures a port's RSS redirection table.
+
+ Args:
+ port_id: Port where redirection table will be configured.
+ hash_index: The index into the redirection table associated with the destination queue.
+ queue_id: The destination queue of the packet.
+ verify: If :data:`True`, it verifies if a port's redirection table
+ was correctly configured.
+
+ Raises:
+ InteractiveCommandExecutionError: If `verify` is :data:`True`
+ Testpmd failed to config RSS reta.
+ """
+ out = self.send_command(f"port config {port_id} rss reta ({hash_index},{queue_id})")
+ if verify:
+ if f"The reta size of port {port_id} is" not in out:
+ self._logger.debug(f"Failed to config RSS reta: \n{out}")
+ raise InteractiveCommandExecutionError("Testpmd failed to config RSS reta.")
+
+ def port_config_all_rss_offload_type(
+ self, flag: RSSOffloadTypesFlag, verify: bool = True
+ ) -> None:
+ """Set the RSS mode on all ports.
+
+ Args:
+ rss_offload_type: The RSS iptype all ports will be configured to.
+ verify: If :data:`True`, it verifies if all ports RSS offload type
+ was correctly configured.
+
+ Raises:
+ InternalError: Offload Flag has contradictory values set.
+ InteractiveCommandExecutionError: If `verify` is :data:`True`
+ Testpmd failed to config the RSS mode on all ports.
+ """
+ if not flag.name:
+ raise InternalError("Offload Flag has contradictory values set")
+
+ out = self.send_command(f"port config all rss {flag.name}")
+
+ if verify:
+ if "error" in out:
+ self._logger.debug(f"Failed to config the RSS mode on all ports: \n{out}")
+ raise InteractiveCommandExecutionError(
+ "Testpmd failed to config the RSS mode on all ports"
+ )
+
+ def port_config_rss_hash_key(
+ self, port_id: int, offload_type: RSSOffloadTypesFlag, hex_str: str, verify: bool = True
+ ) -> str:
+ """Set the RSS hash key for the specified port.
+
+ Args:
+ port_id: Port the hash key will be set.
+ offload_type: The offload type the hash key will be applied to.
+ hex_str: The new hash key.
+ verify: If :data:`True`, RSS hash key has been correctly set.
+
+ Raises:
+ InteractiveCommandExecutionError: If `verify` is :data:`True`
+ Testpmd failed to set the RSS hash key.
+ """
+ output = self.send_command(f"port config {port_id} rss-hash-key {offload_type} {hex_str}")
+
+ if verify:
+ if (
+ "invalid - key must be a string of" in output
+ or "Bad arguments" in output
+ or "Error during getting device" in output
+ ):
+ self._logger.debug(f"Failed to set rss hash key: \n{output}")
+ raise InteractiveCommandExecutionError("Testpmd failed to set the RSS hash key.")
+ return output
+
def show_port_info_all(self) -> list[TestPmdPort]:
"""Returns the information of all the ports.
--
2.34.1
next reply other threads:[~2024-08-29 12:50 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-29 12:50 Alex Chapman [this message]
2024-09-06 14:29 ` Juraj Linkeš
-- strict thread matches above, loose matches on Subject: below --
2024-08-21 16:09 Alex Chapman
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240829125020.34341-1-alex.chapman@arm.com \
--to=alex.chapman@arm.com \
--cc=dev@dpdk.org \
--cc=honnappa.nagarahalli@arm.com \
--cc=juraj.linkes@pantheon.tech \
--cc=luca.vizzarro@arm.com \
--cc=paul.szczepanek@arm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).