From: Patrick Robb <probb@iol.unh.edu>
To: Dean Marx <dmarx@iol.unh.edu>
Cc: npratte@iol.unh.edu, jspewock@iol.unh.edu, luca.vizzarro@arm.com,
yoan.picchi@foss.arm.com, Honnappa.Nagarahalli@arm.com,
paul.szczepanek@arm.com, juraj.linkes@pantheon.tech,
dev@dpdk.org
Subject: Re: [PATCH v1] dts: add VLAN methods to testpmd shell
Date: Wed, 11 Sep 2024 22:17:03 -0400 [thread overview]
Message-ID: <CAJvnSUAtKVYeaDCu6fdNASg7O0GoMfK4DPqkkJMMyk4eOZnsGA@mail.gmail.com> (raw)
In-Reply-To: <20240911173801.16538-1-dmarx@iol.unh.edu>
A new version should be submitted which will apply onto next-dts.
Mostly looks good barring 1 or 2 nits and some overlap with Luca's
pktgen/testpmd series which was merged to next-dts the other day.
On Wed, Sep 11, 2024 at 1:37 PM Dean Marx <dmarx@iol.unh.edu> wrote:
>
> added the following methods to testpmd shell class:
> vlan set filter on/off, rx vlan add/rm,
> vlan set strip on/off, port stop/start all/port,
> tx vlan set/reset, set promisc/verbose
>
> fixed bug in vlan_offload for
> show port info, removed $ at end of regex
I think to align with the submission guidelines, commit body should include:
Fixes: 61d5bc9bf974 ("dts: add port info command to testpmd shell")
> + def vlan_filter_set(self, port: int, on: bool, verify: bool = True) -> None:
> + """Set vlan filter on.
> +
> + Args:
> + port: The port number to enable VLAN filter on, should be within 0-32.
> + on: Sets filter on if :data:`True`, otherwise turns off.
> + verify: If :data:`True`, the output of the command and show port info
> + is scanned to verify that vlan filtering was enabled successfully.
> + If not, it is considered an error.
> +
> + Raises:
> + InteractiveCommandExecutionError: If `verify` is :data:`True` and the filter
> + fails to update.
> + """
> + filter_cmd_output = self.send_command(f"vlan set filter {'on' if on else 'off'} {port}")
> + if verify:
> + vlan_settings = self.show_port_info(port_id=port).vlan_offload
> + if on ^ (vlan_settings is not None and VLANOffloadFlag.FILTER in vlan_settings):
Thank you for teaching me this syntax for python xor :)
> + self._logger.debug(f"Failed to set filter on port {port}: \n{filter_cmd_output}")
> + raise InteractiveCommandExecutionError(
> + f"Testpmd failed to set VLAN filter on port {port}."
> + )
> +
> + def rx_vlan(self, vlan: int, port: int, add: bool, verify: bool = True) -> None:
> + """Add specified vlan tag to the filter list on a port.
> +
> + Args:
> + vlan: The vlan tag to add, should be within 1-1005, 1-4094 extended.
> + port: The port number to add the tag on, should be within 0-32.
> + add: Adds the tag if :data:`True`, otherwise removes tag.
> + verify: If :data:`True`, the output of the command is scanned to verify that
> + the vlan tag was added to the filter list on the specified port. If not, it is
> + considered an error.
> +
> + Raises:
> + InteractiveCommandExecutionError: If `verify` is :data:`True` and the tag
> + is not added.
> + """
> + rx_output = self.send_command(f"rx_vlan {'add' if add else 'rm'} {vlan} {port}")
I guess this variable should be named rx_cmd_output, or
rx_vlan_cmd_output to remain consistent with the preceding method, but
not a huge deal.
> + if verify:
> + if (
> + "VLAN-filtering disabled" in rx_output
> + or "Invalid vlan_id" in rx_output
> + or "Bad arguments" in rx_output
> + ):
> + self._logger.debug(
> + f"Failed to {'add' if add else 'remove'} tag {vlan} port {port}: \n{rx_output}"
> + )
> + raise InteractiveCommandExecutionError(
> + f"Testpmd failed to {'add' if add else 'remove'} tag {vlan} on port {port}."
> + )
> +
> + def vlan_strip_set(self, port: int, on: bool, verify: bool = True) -> None:
> + """Enable vlan stripping on the specified port.
> +
> + Args:
> + port: The port number to use, should be within 0-32.
> + on: If :data:`True`, will turn strip on, otherwise will turn off.
> + 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.
> + """
> + strip_output = self.send_command(f"vlan set strip {'on' if on else 'off'} {port}")
> + if verify:
> + vlan_settings = self.show_port_info(port_id=port).vlan_offload
> + if on ^ (vlan_settings is not None and VLANOffloadFlag.STRIP in vlan_settings):
> + self._logger.debug(
> + f"Failed to set strip {'on' if on else 'off'} port {port}: \n{strip_output}"
> + )
> + raise InteractiveCommandExecutionError(
> + f"Testpmd failed to set strip {'on' if on else 'off'} port {port}."
> + )
> +
> + def port_stop_all(self, verify: bool = True) -> None:
> + """Stop all ports.
Luca's pktgen and testpmd change series included an equivalent method
for stopping all ports, so this can be removed.
> +
> + Args:
> + verify: If :data:`True`, the output of the command is scanned
> + to ensure all ports are stopped. If not, it is considered an error.
> +
> + Raises:
> + InteractiveCommandExecutionError: If `verify` is :data:`True` and all ports
> + fail to stop.
> + """
> + port_output = self.send_command("port stop all")
> + if verify:
> + if "Done" not in port_output:
> + self._logger.debug(f"Failed to stop all ports: \n{port_output}")
> + raise InteractiveCommandExecutionError("Testpmd failed to stop all ports.")
> +
> + def port_stop(self, port: int, verify: bool = True) -> None:
> + """Stop specified port.
There is a new TestPmdShell attribute, ports_started, which may need
to be updated when this is run. You may have to iterate through
self._ports and scan testpmd for port info or check otherwise and
modify ports_started depending on the result.
> +
> + Args:
> + port: Specifies the port number to use, must be between 0-32.
> + verify: If :data:`True`, the output of the command is scanned
> + to ensure specified port is stopped. If not, it is considered an error.
> +
> + Raises:
> + InteractiveCommandExecutionError: If `verify` is :data:`True` and the port
> + is not stopped.
> + """
> + port_output = self.send_command(f"port stop {port}")
> + if verify:
> + if "Done" not in port_output:
> + self._logger.debug(f"Failed to stop port {port}: \n{port_output}")
> + raise InteractiveCommandExecutionError(f"Testpmd failed to stop port {port}.")
> +
> + def port_start_all(self, verify: bool = True) -> None:
> + """Start all ports.
> +
> + Args:
> + verify: If :data:`True`, the output of the command is scanned
> + to ensure all ports are started. If not, it is considered an error.
> +
> + Raises:
> + InteractiveCommandExecutionError: If `verify` is :data:`True` and all ports
> + fail to start.
> + """
> + port_output = self.send_command("port start all")
> + if verify:
> + if "Done" not in port_output:
> + self._logger.debug(f"Failed to start all ports: \n{port_output}")
> + raise InteractiveCommandExecutionError("Testpmd failed to start all ports.")
> +
> + def port_start(self, port: int, verify: bool = True) -> None:
> + """Start specified port.
Same possible concern as described for port_start()
next prev parent reply other threads:[~2024-09-12 2:17 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-09-11 17:38 Dean Marx
2024-09-12 2:17 ` Patrick Robb [this message]
2024-09-18 19:41 ` [PATCH v2] " Dean Marx
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=CAJvnSUAtKVYeaDCu6fdNASg7O0GoMfK4DPqkkJMMyk4eOZnsGA@mail.gmail.com \
--to=probb@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=npratte@iol.unh.edu \
--cc=paul.szczepanek@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).