From: Nicholas Pratte <npratte@iol.unh.edu>
To: Honnappa.Nagarahalli@arm.com, yoan.picchi@foss.arm.com,
paul.szczepanek@arm.com, juraj.linkes@pantheon.tech,
luca.vizzarro@arm.com, probb@iol.unh.edu, dmarx@iol.unh.edu,
jspewock@iol.unh.edu
Cc: dev@dpdk.org, Nicholas Pratte <npratte@iol.unh.edu>
Subject: [RFC v1 1/2] dts: add additional vlan configuration to testpmd shell class
Date: Mon, 5 Aug 2024 13:12:45 -0400 [thread overview]
Message-ID: <20240805171246.18580-2-npratte@iol.unh.edu> (raw)
In-Reply-To: <20240805171246.18580-1-npratte@iol.unh.edu>
The ethertype test suite requires many different internal runtime
vlan offload options to test ethertype configuration. The following patch
adds a new RxVlanOffloadOptions class that contains all the different
vlan configuration options available within testpmd. Additionally, an
extra method has beena added to adjust both the inner and outer tpids of
ingressing and egressing packets.
Bugzilla ID: 1505
Signed-off-by: Nicholas Pratte <npratte@iol.unh.edu>
---
dts/framework/remote_session/testpmd_shell.py | 55 +++++++++++++++++++
1 file changed, 55 insertions(+)
diff --git a/dts/framework/remote_session/testpmd_shell.py b/dts/framework/remote_session/testpmd_shell.py
index 288be9a085..268e34f0eb 100644
--- a/dts/framework/remote_session/testpmd_shell.py
+++ b/dts/framework/remote_session/testpmd_shell.py
@@ -70,6 +70,10 @@ class VLANOffloadFlag(Flag):
#:
QINQ_STRIP = auto()
+ def __str__(self):
+ """Return flag name when cast to a string."""
+ return self.name
+
@classmethod
def from_str_dict(cls, d):
"""Makes an instance from a dict containing the flag member names with an "on" value.
@@ -915,6 +919,26 @@ def show_port_stats_all(self) -> list[TestPmdPortStats]:
iter = re.finditer(r"(^ #*.+#*$[^#]+)^ #*\r$", output, re.MULTILINE)
return [TestPmdPortStats.parse(block.group(1)) for block in iter]
+ def set_vlan_tpid(self, port_id: int, tpid: int, inner_id: bool) -> None:
+ """Set ethertype tpid values using the ethdev api.
+
+ Args:
+ port_id: the ID of the port the tpid is being changed on.
+ tpid: The tpid value being changed on the port.
+ inner_id: If :data:`True`, set the inner tpid to the specified value. If
+ :data:`False`, change the outer tpid to the specified value.
+
+ Raises:
+ InteractiveCommandExecutionError: If either `port_id` or `tpid` value is invalid.
+ """
+ if tpid < 0 or tpid > 65535:
+ raise InteractiveCommandExecutionError("Invalid TPID value given.")
+ output = self.send_command(
+ f'vlan set {"inner" if inner_id else "outer"} tpid {tpid} {port_id}'
+ )
+ if output.startswith("Invalid port"):
+ raise InteractiveCommandExecutionError(f"Invalid port ID {port_id} given.")
+
def show_port_stats(self, port_id: int) -> TestPmdPortStats:
"""Returns the given port statistics.
@@ -978,6 +1002,37 @@ def rx_vlan(self, vlan: int, port: int, add: bool, verify: bool = True) -> None:
f"Testpmd failed to {'add' if add else 'remove'} tag {vlan} on port {port}."
)
+ def set_vlan_offload_option(
+ self, port: int, offload_option: VLANOffloadFlag, on: bool, verify: bool = True
+ ) -> None:
+ """Enable extended vlans on the specified port.
+
+ Args:
+ port: The port number to use, should be within 0-32.
+ on: If :data:`True`, extended vlan turn on, otherwise it turns off.
+ offload_options: The rx vlan offload option to be set.
+ verify: If :data:`True`, the output of the command and show port info
+ is scanned to verify that vlan stripping was enabled on the specified port.
+ If not, it is considered an error.
+
+ Raises:
+ InteractiveCommandExecutionError: If `verify` is :data:`True` and stripping
+ fails to update.
+ """
+ offload_output = self.send_command(
+ f"vlan set {str(offload_option).lower()} {'on' if on else 'off'} {port}"
+ )
+ if verify:
+ if on ^ (str(offload_option) in str(self.show_port_info(port_id=port).vlan_offload)):
+ self._logger.debug(
+ f"""Failed to set {offload_option} {'on' if on else 'off'} port {port}:
+ \n{offload_output}
+ """
+ )
+ raise InteractiveCommandExecutionError(
+ f"Testpmd failed to set {offload_option} {'on' if on else 'off'} port {port}."
+ )
+
def port_stop_all(self, verify: bool = True) -> None:
"""Stop all ports.
--
2.44.0
next prev parent reply other threads:[~2024-08-05 17:13 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-05 17:12 [RFC v1 0/2] dts: Ethertype ethdev api test suite Nicholas Pratte
2024-08-05 17:12 ` Nicholas Pratte [this message]
2024-08-08 21:40 ` [RFC v1 1/2] dts: add additional vlan configuration to testpmd shell class Jeremy Spewock
2024-08-05 17:12 ` [RFC v1 2/2] dts: port ethertype ethdev api test suite to new dts framework Nicholas Pratte
2024-08-08 21:40 ` Jeremy Spewock
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=20240805171246.18580-2-npratte@iol.unh.edu \
--to=npratte@iol.unh.edu \
--cc=Honnappa.Nagarahalli@arm.com \
--cc=dev@dpdk.org \
--cc=dmarx@iol.unh.edu \
--cc=jspewock@iol.unh.edu \
--cc=juraj.linkes@pantheon.tech \
--cc=luca.vizzarro@arm.com \
--cc=paul.szczepanek@arm.com \
--cc=probb@iol.unh.edu \
--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).