From: jspewock@iol.unh.edu
To: Honnappa.Nagarahalli@arm.com, probb@iol.unh.edu,
paul.szczepanek@arm.com, juraj.linkes@pantheon.tech,
yoan.picchi@foss.arm.com, npratte@iol.unh.edu,
wathsala.vithanage@arm.com, Luca.Vizzarro@arm.com,
alex.chapman@arm.com, thomas@monjalon.net
Cc: dev@dpdk.org, Jeremy Spewock <jspewock@iol.unh.edu>
Subject: [RFC PATCH v1 3/5] dts: add offload configuration querying to testpmd
Date: Fri, 30 Aug 2024 20:00:11 -0400 [thread overview]
Message-ID: <20240831000058.23009-4-jspewock@iol.unh.edu> (raw)
In-Reply-To: <20240831000058.23009-1-jspewock@iol.unh.edu>
From: Jeremy Spewock <jspewock@iol.unh.edu>
Testpmd offers methods for querying the runtime configuration of
offloads on a device that are useful for verification, but bindings to
reach these methods do not exist in the Testpmd API offered in the
framework. This patch creates methods that can query this configuration
and also generalizes the OffloadCapability class to allow it to account
for parsing the configuration output as well since the flag values will
be the same.
Signed-off-by: Jeremy Spewock <jspewock@iol.unh.edu>
---
dts/framework/remote_session/testpmd_shell.py | 84 ++++++++++++++++++-
1 file changed, 81 insertions(+), 3 deletions(-)
diff --git a/dts/framework/remote_session/testpmd_shell.py b/dts/framework/remote_session/testpmd_shell.py
index cfb51e3acb..58b8995d21 100644
--- a/dts/framework/remote_session/testpmd_shell.py
+++ b/dts/framework/remote_session/testpmd_shell.py
@@ -680,21 +680,41 @@ def from_string(cls, line: str) -> Self:
return flag
@classmethod
- def make_parser(cls, per_port: bool) -> ParserFn:
+ def from_list(cls, lines: list[str]) -> list[Self]:
+ """Make a list of instances from a list of strings that contain flag names.
+
+ The strings are expected to separate the flag names by whitespace.
+
+ Args:
+ lines: The list of strings to parse.
+
+ Returns:
+ A list of instances parsed from each string in `lines`.
+ """
+ return [cls.from_string(line) for line in lines]
+
+ @classmethod
+ def make_parser(cls, per_port: bool, find_multiple: bool = False) -> ParserFn:
"""Make a parser function.
Args:
per_port: If :data:`True`, will return capabilities per port. If :data:`False`,
will return capabilities per queue.
+ find_multiple: If :data:`True`, will use :func:`TextParser.find_all` to find all
+ matches for the regex query and return a list of instances based on those matches.
+ If :data:`False`, will return a single instance of the flag based off a single
+ match.
Returns:
ParserFn: A dictionary for the `dataclasses.field` metadata argument containing a
parser function that makes an instance of this flag from text.
"""
granularity = "Port" if per_port else "Queue"
+ parser_func = TextParser.find_all if find_multiple else TextParser.find
+ instance_func = cls.from_list if find_multiple else cls.from_string
return TextParser.wrap(
- TextParser.find(rf"Per {granularity}\s+:(.*)$", re.MULTILINE),
- cls.from_string,
+ parser_func(rf"{granularity}[\s\[\]\d]+:(.*)$", re.MULTILINE),
+ instance_func,
)
@@ -824,6 +844,38 @@ class TxOffloadCapabilities(OffloadCapabilities):
per_port: TxOffloadCapability = field(metadata=TxOffloadCapability.make_parser(True))
+@dataclass
+class OffloadConfiguration(TextParser):
+ """The result of testpmd's ``show port <port_id> rx/tx_offload configuration`` command."""
+
+ #:
+ port_id: int = field(
+ metadata=TextParser.find_int(r"Offloading Configuration of port (\d+) :")
+ )
+ #: Queue offload configurations.
+ queues: list[RxOffloadCapability] | list[TxOffloadCapability]
+ #: Port offload configuration.
+ port: RxOffloadCapability | TxOffloadCapability
+
+
+@dataclass
+class RxOffloadConfiguration(OffloadConfiguration):
+ """Extends :class:`OffloadingConfiguration` with Rx specific functionality."""
+ #:
+ queues: list[RxOffloadCapability] = field(metadata=RxOffloadCapability.make_parser(False, find_multiple=True))
+ #:
+ port: RxOffloadCapability = field(metadata=RxOffloadCapability.make_parser(True))
+
+
+@dataclass
+class TxOffloadConfiguration(OffloadConfiguration):
+ """Extends :class:`OffloadingConfiguration` with Tx specific functionality."""
+ #:
+ queues: list[TxOffloadCapability] = field(metadata=TxOffloadCapability.make_parser(False, find_multiple=True))
+ #:
+ port: TxOffloadCapability = field(metadata=TxOffloadCapability.make_parser(True))
+
+
T = TypeVarTuple("T") # type: ignore[misc]
@@ -1592,6 +1644,32 @@ def show_port_tx_offload_capabilities(self, port_id: int) -> TxOffloadCapabiliti
offload_capabilities_out = self.send_command(command)
return TxOffloadCapabilities.parse(offload_capabilities_out)
+ def show_port_rx_offload_configuration(self, port_id: int) -> RxOffloadConfiguration:
+ """Get the Rx offload configuration on a given port.
+
+ Args:
+ port_id: The ID of the port to query the configuration of.
+
+ Returns:
+ An instance of :class:`RxOffloadConfiguration` containing the offload configuration of
+ the port.
+ """
+ output = self.send_command(f"show port {port_id} rx_offload configuration")
+ return RxOffloadConfiguration.parse(output)
+
+ def show_port_tx_offload_configuration(self, port_id: int) -> TxOffloadConfiguration:
+ """Get the Tx offload configuration on a given port.
+
+ Args:
+ port_id: The ID of the port to query the configuration of.
+
+ Returns:
+ An instance of :class:`TxOffloadConfiguration` containing the offload configuration of
+ the port.
+ """
+ output = self.send_command(f"show port {port_id} tx_offload configuration")
+ return TxOffloadConfiguration.parse(output)
+
def _stop_port(self, port_id: int, verify: bool = True) -> None:
"""Stop port with `port_id` in testpmd.
--
2.46.0
next prev parent reply other threads:[~2024-08-31 0:04 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-31 0:00 [RFC PATCH v1 0/5] dts: port over Rx/Tx offload suite jspewock
2024-08-31 0:00 ` [RFC PATCH v1 1/5] dts: add TX offload capabilities jspewock
2024-08-31 0:00 ` [RFC PATCH v1 2/5] dts: add a distinction between port and queue " jspewock
2024-08-31 0:00 ` jspewock [this message]
2024-08-31 0:00 ` [RFC PATCH v1 4/5] dts: add methods for configuring offloads on a device in testpmd jspewock
2024-08-31 0:00 ` [RFC PATCH v1 5/5] dts: add test suite for RX and TX offloads jspewock
2024-09-03 19:46 ` [PATCH v2 0/5] dts: port over Rx/Tx offload suite jspewock
2024-09-03 19:46 ` [PATCH v2 1/5] dts: add TX offload capabilities jspewock
2024-09-03 19:46 ` [PATCH v2 2/5] dts: add a distinction between port and queue " jspewock
2024-09-03 19:46 ` [PATCH v2 3/5] dts: add offload configuration querying to testpmd jspewock
2024-09-03 19:46 ` [PATCH v2 4/5] dts: add methods for configuring offloads on a device in testpmd jspewock
2024-09-03 19:46 ` [PATCH v2 5/5] dts: add test suite for RX and TX offloads jspewock
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=20240831000058.23009-4-jspewock@iol.unh.edu \
--to=jspewock@iol.unh.edu \
--cc=Honnappa.Nagarahalli@arm.com \
--cc=Luca.Vizzarro@arm.com \
--cc=alex.chapman@arm.com \
--cc=dev@dpdk.org \
--cc=juraj.linkes@pantheon.tech \
--cc=npratte@iol.unh.edu \
--cc=paul.szczepanek@arm.com \
--cc=probb@iol.unh.edu \
--cc=thomas@monjalon.net \
--cc=wathsala.vithanage@arm.com \
--cc=yoan.picchi@foss.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).