DPDK patches and discussions
 help / color / mirror / Atom feed
From: Luca Vizzarro <Luca.Vizzarro@arm.com>
To: Jeremy Spewock <jspewock@iol.unh.edu>
Cc: dev@dpdk.org, "Juraj Linkeš" <juraj.linkes@pantheon.tech>,
	"Honnappa Nagarahalli" <honnappa.nagarahalli@arm.com>,
	"Paul Szczepanek" <paul.szczepanek@arm.com>
Subject: Re: [PATCH v2 4/5] dts: add ability to start/stop testpmd ports
Date: Fri, 6 Sep 2024 17:41:56 +0100	[thread overview]
Message-ID: <c0c99e24-f8b7-4c44-bf6d-5c17cb40e4a7@arm.com> (raw)
In-Reply-To: <CAAA20UTq-BHZOhVpqo+PqSSoQvSt0-Qn2erWnqeU7E0jSGLq4Q@mail.gmail.com>

On 09/08/2024 16:13, Jeremy Spewock wrote:
> I tried to address this very same problem in the scatter expansion
> patch series but, admittedly, I like your approach better. There is
> one thing that Juraj and I discussed on that thread however that is
> probably worth noting here regarding verification of the stopping and
> starting ports. The main idea behind that being if the user calls a
> testpmd method and specifically specifies they don't want to verify
> the outcome of that method, but then we still verify whether we
> stopped the ports or not, that could cause confusion. The compromise
> we ended up settling for was just to make a parameter to the decorator
> that allows you to statically decide which decorated methods should
> verify the ports stopping and which shouldn't. It was mainly because
> of the ability to specify "verify" as a kwarg or an arg and the types
> being messy. The discussion we had about it starts here if you were
> interested in reading it:
> http://inbox.dpdk.org/dev/dff89e16-0173-4069-878c-d1c34df1ae13@pantheon.tech/

When it comes to starting and stopping ports, we may need to ensure that 
the operations were done correctly. Surely we don't want to start 
forwarding thinking that the ports are initialised, when they could be 
not... I guess the point here is that it may be important to save the 
correct state. Not sure, I guess verify could always be added later if 
needed.

> On Tue, Aug 6, 2024 at 8:49 AM Luca Vizzarro <luca.vizzarro@arm.com> wrote:
>>
>> Add testpmd commands to start and stop all the ports, so that they can
>> be configured. Because there is a distinction of commands that require
>> the ports to be stopped and started, also add decorators for commands
>> that require a specific state, removing this logic from the test
>> writer's duty.
>>
>> Signed-off-by: Luca Vizzarro <luca.vizzarro@arm.com>
>> Reviewed-by: Paul Szczepanek <paul.szczepanek@arm.com>
>> ---
> <snip>
>> +P = ParamSpec("P")
>> +TestPmdShellMethod = Callable[Concatenate["TestPmdShell", P], Any]
> 
> Agggh, I spent so much time trying to figure out how to do exactly
> this when I was working on the scatter series but I couldn't get a
> nice typehint while specifying that I wanted a TestPmdShell first. I
> had no idea that Concatenate was a type but I will definitely keep
> that one in mind.
> 

Glad I could help! :D

>> +def requires_started_ports(func: TestPmdShellMethod) -> TestPmdShellMethod:
>> +    """Decorator for :class:`TestPmdShell` commands methods that require started ports.
>> +
>> +    If the decorated method is called while the ports are stopped, then these are started before
>> +    continuing.
>> +    """
>> +
>> +    @functools.wraps(func)
>> +    def _wrapper(self: "TestPmdShell", *args: P.args, **kwargs: P.kwargs):
>> +        if not self.ports_started:
>> +            self._logger.debug("Ports need to be started to continue")
>> +            self.start_all_ports()
>> +
>> +        return func(self, *args, **kwargs)
>> +
>> +    return _wrapper
>> +
> 
> I'm not sure how much it is necessary since it is pretty clear what
> these decorators are trying to do with the parameter, but since these
> are public methods I think not having an "Args:" section for the func
> might trip up the doc generation.

We have several methods that have one-liner docstrings... so not really 
sure. I was hoping to have the doc generation merged as testing what's 
correct and what's not is currently complicated.

>>
>> +        self.ports_started = not self._app_params.disable_device_start
>> +
> 
> It might be useful to add this attribute as a stub in the class just
> to be clear on the typing. It also helps me understand things at more
> of a glance personally.

You make a fair point here.


  reply	other threads:[~2024-09-06 16:42 UTC|newest]

Thread overview: 47+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-06 12:14 [PATCH 0/4] dts: add pktgen and testpmd changes Luca Vizzarro
2024-08-06 12:14 ` [PATCH 1/5] dts: add ability to send/receive multiple packets Luca Vizzarro
2024-08-06 12:14 ` [PATCH 2/5] dts: add random generation seed setting Luca Vizzarro
2024-08-06 12:14 ` [PATCH 3/5] dts: add random packet generator Luca Vizzarro
2024-08-06 12:14 ` [PATCH 4/5] dts: add ability to start/stop ports Luca Vizzarro
2024-08-06 12:14 ` [PATCH 4/5] dts: add ability to start/stop testpmd ports Luca Vizzarro
2024-08-06 12:14 ` [PATCH 5/5] dts: add testpmd set ports queues Luca Vizzarro
2024-08-06 12:46 ` [PATCH v2 0/5] dts: add pktgen and testpmd changes Luca Vizzarro
2024-08-06 12:46   ` [PATCH v2 1/5] dts: add ability to send/receive multiple packets Luca Vizzarro
2024-08-09 15:10     ` Jeremy Spewock
2024-09-06 16:23       ` Luca Vizzarro
2024-09-09 14:12         ` Jeremy Spewock
2024-08-23 10:17     ` Juraj Linkeš
2024-09-06 16:30       ` Luca Vizzarro
2024-08-06 12:46   ` [PATCH v2 2/5] dts: add random generation seed setting Luca Vizzarro
2024-08-09 15:10     ` Jeremy Spewock
2024-08-23 10:30     ` Juraj Linkeš
2024-08-06 12:46   ` [PATCH v2 3/5] dts: add random packet generator Luca Vizzarro
2024-08-09 15:11     ` Jeremy Spewock
2024-08-23 11:58     ` Juraj Linkeš
2024-09-06 16:31       ` Luca Vizzarro
2024-08-06 12:46   ` [PATCH v2 4/5] dts: add ability to start/stop testpmd ports Luca Vizzarro
2024-08-09 15:13     ` Jeremy Spewock
2024-09-06 16:41       ` Luca Vizzarro [this message]
2024-08-23 12:16     ` Juraj Linkeš
2024-09-06 16:46       ` Luca Vizzarro
2024-09-09  7:32         ` Juraj Linkeš
2024-09-09 14:20         ` Jeremy Spewock
2024-09-09 15:16           ` Juraj Linkeš
2024-08-06 12:46   ` [PATCH v2 5/5] dts: add testpmd set ports queues Luca Vizzarro
2024-08-09 15:14     ` Jeremy Spewock
2024-08-20 16:04       ` Jeremy Spewock
2024-09-06 16:51       ` Luca Vizzarro
2024-08-23 12:22     ` Juraj Linkeš
2024-09-06 16:53       ` Luca Vizzarro
2024-09-09 11:01 ` [PATCH v3 0/5] dts: add pktgen and testpmd changes Luca Vizzarro
2024-09-09 11:01   ` [PATCH v3 1/5] dts: add ability to send/receive multiple packets Luca Vizzarro
2024-09-09 17:12     ` Patrick Robb
2024-09-09 11:01   ` [PATCH v3 2/5] dts: add random generation seed setting Luca Vizzarro
2024-09-09 11:01   ` [PATCH v3 3/5] dts: add random packet generator Luca Vizzarro
2024-09-09 11:01   ` [PATCH v3 4/5] dts: add ability to start/stop testpmd ports Luca Vizzarro
2024-09-09 11:54     ` Juraj Linkeš
2024-09-09 14:20     ` Jeremy Spewock
2024-09-09 11:01   ` [PATCH v3 5/5] dts: add testpmd set ports queues Luca Vizzarro
2024-09-09 12:01     ` Juraj Linkeš
2024-09-09 14:20     ` Jeremy Spewock
2024-09-09 15:50 ` [PATCH 0/4] dts: add pktgen and testpmd changes Juraj Linkeš

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=c0c99e24-f8b7-4c44-bf6d-5c17cb40e4a7@arm.com \
    --to=luca.vizzarro@arm.com \
    --cc=dev@dpdk.org \
    --cc=honnappa.nagarahalli@arm.com \
    --cc=jspewock@iol.unh.edu \
    --cc=juraj.linkes@pantheon.tech \
    --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).