DPDK patches and discussions
 help / color / mirror / Atom feed
From: Jeremy Spewock <jspewock@iol.unh.edu>
To: Dean Marx <dmarx@iol.unh.edu>
Cc: Honnappa.Nagarahalli@arm.com, juraj.linkes@pantheon.tech,
	 probb@iol.unh.edu, paul.szczepanek@arm.com,
	yoan.picchi@foss.arm.com,  bruce.richardson@intel.com,
	luca.vizzarro@arm.com, dev@dpdk.org
Subject: Re: [PATCH v2 1/4] dts: add multicast set function to shell
Date: Wed, 10 Jul 2024 12:44:23 -0400	[thread overview]
Message-ID: <CAAA20UQgrMC79J49unvwy8iGUM+UQpuSdd0m36rrUen-tDju9g@mail.gmail.com> (raw)
In-Reply-To: <20240708191938.32132-2-dmarx@iol.unh.edu>

On Mon, Jul 8, 2024 at 3:19 PM Dean Marx <dmarx@iol.unh.edu> wrote:
>
> added set multicast function for changing allmulticast mode within testpmd.
>
> Signed-off-by: Dean Marx <dmarx@iol.unh.edu>
> ---
>  dts/framework/remote_session/testpmd_shell.py | 46 +++++++++++++++++++
>  1 file changed, 46 insertions(+)
>
> diff --git a/dts/framework/remote_session/testpmd_shell.py b/dts/framework/remote_session/testpmd_shell.py
> index ec22f72221..a0be0bd09d 100644
> --- a/dts/framework/remote_session/testpmd_shell.py
> +++ b/dts/framework/remote_session/testpmd_shell.py
> @@ -806,6 +806,52 @@ def show_port_stats(self, port_id: int) -> TestPmdPortStats:
>
>          return TestPmdPortStats.parse(output)
>
> +    def set_promisc(self, port: int, on: bool, verify: bool = True):

This public method seems to be missing the return type, it should
probably specify that it doesn't return anything with a None-type.

> +        """Turns promiscuous mode on/off for the specified port.
> +
> +        Args:
> +            port: Port number to use, should be within 0-32.
> +            on: If :data:`True`, turn promisc mode on, otherwise turn off.
> +            verify: If :data:`True` an additional command will be sent to verify that promisc mode
> +                is properly set. Defaults to :data:`True`.
> +
> +        Raises:
> +            InteractiveCommandExecutionError: If `verify` is :data:`True` and promisc mode
> +                is not correctly set.
> +        """
> +        promisc_output = self.send_command(f"set promisc {port} {'on' if on else 'off'}")
> +        if verify:
> +            stats = self.show_port_info(port_id=port)
> +            if on ^ stats.is_promiscuous_mode_enabled:
> +                self._logger.debug(f"Failed to set promisc mode on port {port}: \n{promisc_output}")
> +                raise InteractiveCommandExecutionError(
> +                    f"Testpmd failed to set promisc mode on port {port}."
> +                )
> +
> +    def set_multicast_all(self, on: bool, verify: bool = True):

This method also should probably have a typehint for the return type.

> +        """Turns multicast mode on/off for the specified port.
> +
> +        Args:
> +            on: If :data:`True`, turns multicast mode on, otherwise turns off.
> +            verify: If :data:`True` an additional command will be sent to verify
> +            that multicast mode is properly set. Defaults to :data:`True`.

I'm surprised the formatting script doesn't complain about a
mismatched indent here, I thought it normally did for doc-strings. The
second line of this verify argument should probably be indented just
to better show that it is a continuation of the previous line.

> +
> +        Raises:
> +            InteractiveCommandExecutionError: If `verify` is :data:`True` and multicast
> +                mode is not properly set.
> +        """
> +        multicast_output = self.send_command(f"set allmulti all {'on' if on else 'off'}")
> +        if verify:
> +            stats0 = self.show_port_info(port_id=0)
> +            stats1 = self.show_port_info(port_id=1)

Getting the stats for port 0 and port 1 limit this method to only
working when there are exactly 2 ports. Right now in DTS this is a
restriction, but we should be able to make this robust enough to work
with any number of ports using self.show_port_info_all().

> +            if on ^ (stats0.is_allmulticast_mode_enabled and stats1.is_allmulticast_mode_enabled):

If you used the show port info all command, you could then just
replace this `and` statement with something like this:

all(info.is_allmulticast_mode_enabled for info in all_stats)

if `all_stats` was the name of the list you stored the port stats in.


> +                self._logger.debug(
> +                    f"Failed to set multicast mode on all ports.: \n{multicast_output}"
> +                )
> +                raise InteractiveCommandExecutionError(
> +                    "Testpmd failed to set multicast mode on all ports."
> +                )
> +
>      def close(self) -> None:
>          """Overrides :meth:`~.interactive_shell.close`."""
>          self.send_command("quit", "")
> --
> 2.44.0
>

  reply	other threads:[~2024-07-10 16:44 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-08 19:19 [PATCH v2 0/4] dts: initial dynamic config suite Dean Marx
2024-07-08 19:19 ` [PATCH v2 1/4] dts: add multicast set function to shell Dean Marx
2024-07-10 16:44   ` Jeremy Spewock [this message]
2024-07-08 19:19 ` [PATCH v2 2/4] dts: add toggle option to send and capture Dean Marx
2024-07-08 19:19 ` [PATCH v2 3/4] dts: dynamic config conf schema Dean Marx
2024-07-08 19:19 ` [PATCH v2 4/4] dts: dynamic config test suite Dean Marx
2024-07-08 19:30 ` [PATCH v3 1/4] dts: add multicast set function to shell Dean Marx
2024-07-08 19:30   ` [PATCH v3 2/4] dts: add toggle option to send and capture Dean Marx
2024-07-10 16:13     ` Jeremy Spewock
2024-07-08 19:30   ` [PATCH v3 3/4] dts: dynamic config conf schema Dean Marx
2024-07-10 16:45     ` Jeremy Spewock
2024-07-08 19:30   ` [PATCH v3 4/4] dts: dynamic config test suite Dean Marx
2024-07-10 16:45     ` Jeremy Spewock
2024-07-15 16:00 ` [PATCH v4 1/3] dts: add multicast set function to shell Dean Marx
2024-07-15 16:00   ` [PATCH v4 2/3] dts: dynamic config conf schema Dean Marx
2024-07-15 20:22     ` Jeremy Spewock
2024-07-15 16:00   ` [PATCH v4 3/3] dts: dynamic config test suite Dean Marx
2024-07-15 20:22     ` Jeremy Spewock
2024-07-15 20:22   ` [PATCH v4 1/3] dts: add multicast set function to shell Jeremy Spewock
2024-07-24 19:21 ` [PATCH v5 0/3] dts: refactored dynamic config test suite Dean Marx
2024-07-24 19:21   ` [PATCH v5 1/3] dts: add multicast set function to shell Dean Marx
2024-08-07 15:50     ` Luca Vizzarro
2024-07-24 19:21   ` [PATCH v5 2/3] dts: dynamic config conf schema Dean Marx
2024-07-26 19:35     ` Jeremy Spewock
2024-08-07 15:56     ` Luca Vizzarro
2024-07-24 19:21   ` [PATCH v5 3/3] dts: dynamic config test suite Dean Marx
2024-07-26 19:35     ` Jeremy Spewock
2024-08-07 19:18   ` [PATCH v6 0/2] dts: refactored " Dean Marx
2024-08-07 19:18     ` [PATCH v6 1/2] dts: add multicast set function to shell Dean Marx
2024-08-07 19:18     ` [PATCH v6 2/2] dts: dynamic config test suite 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=CAAA20UQgrMC79J49unvwy8iGUM+UQpuSdd0m36rrUen-tDju9g@mail.gmail.com \
    --to=jspewock@iol.unh.edu \
    --cc=Honnappa.Nagarahalli@arm.com \
    --cc=bruce.richardson@intel.com \
    --cc=dev@dpdk.org \
    --cc=dmarx@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).