DPDK patches and discussions
 help / color / mirror / Atom feed
From: David Marchand <david.marchand@redhat.com>
To: Thomas Monjalon <thomas@monjalon.net>
Cc: dev <dev@dpdk.org>,
	Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>,
	 Ferruh Yigit <ferruh.yigit@xilinx.com>,
	Xiaoyun Li <xiaoyun.li@intel.com>,
	 Aman Singh <aman.deep.singh@intel.com>,
	Yuying Zhang <yuying.zhang@intel.com>,
	 Bruce Richardson <bruce.richardson@intel.com>,
	spiked@nvidia.com
Subject: Re: [PATCH 2/6] app/testpmd: register driver specific commands
Date: Tue, 24 May 2022 19:44:51 +0200
Message-ID: <CAJFAV8w4CUzUMBvvVbCv-Kg4XA8PvACdqbfta6zdwVt2uzCMUA@mail.gmail.com> (raw)
In-Reply-To: <2203012.AOvM4ru3NT@thomas>

On Tue, May 24, 2022 at 7:21 PM Thomas Monjalon <thomas@monjalon.net> wrote:
>
> 23/05/2022 09:10, David Marchand:
> > Introduce a testpmd API so that drivers can register specific commands.
> >
> > A driver can list some files to compile with testpmd, by setting them
> > in the testpmd_sources (driver local) meson variable.
> > drivers/meson.build then takes care of appending this to a global meson
> > variable, and adding the driver to testpmd dependency.
> >
> > Note: testpmd.h is fixed to that it is self sufficient when being
> > included.
> >
> > Signed-off-by: David Marchand <david.marchand@redhat.com>
> > ---
> [...]
> > +     main_ctx = NULL;
> > +     for (i = 0; builtin_ctx[i] != NULL; i++) {
> > +             ctx = realloc(main_ctx, (count + i + 1) * sizeof(*ctx));
> > +             if (ctx == NULL)
> > +                     goto err;
> > +             main_ctx = ctx;
> > +             main_ctx[count + i] = builtin_ctx[i];
> > +     }
> > +     count += i;
> > +
> > +     TAILQ_FOREACH(c, &commands_head, next) {
> > +             for (i = 0; c->commands[i].ctx != NULL; i++) {
> > +                     ctx = realloc(main_ctx, (count + i + 1) * sizeof(*ctx));
> > +                     if (ctx == NULL)
> > +                             goto err;
> > +                     main_ctx = ctx;
> > +                     main_ctx[count + i] = c->commands[i].ctx;
> > +             }
> > +             count += i;
> > +     }
> > +
> > +     /* cmdline expects a NULL terminated array */
> > +     ctx = realloc(main_ctx, (count + 1) * sizeof(*ctx));
> > +     if (ctx == NULL)
> > +             goto err;
> > +     main_ctx = ctx;
> > +     main_ctx[count] = NULL;
> > +     count += 1;
>
> As Ferruh already said, there's a lot of realloc here.

Yes, it will be fixed in next revision.


>
> [...]
> > +# Driver specific sources include some testpmd headers.
>
> Suggested reword:
>         Driver-specific commands are located in driver directories.

At the moment, it's only about testpmd commands.
Maybe in the future we can have other specific code in those driver sources.
That's why I preferred a generic term.


>
> > +includes = include_directories('.')
> > +sources += testpmd_drivers_sources
> > +deps += testpmd_drivers_deps
>
> [...]
> > --- a/app/test-pmd/testpmd.h
> > +++ b/app/test-pmd/testpmd.h
> > +/* For registering testpmd commands. */
> > +struct testpmd_commands {
> > +     TAILQ_ENTRY(testpmd_commands) next;
> > +     struct {
> > +             cmdline_parse_inst_t *ctx;
> > +             const char *help;
> > +     } commands[];
> > +};
> > +
> > +extern void testpmd_add_commands(struct testpmd_commands *c);
>
> Why extern?

It can probably be removed.


>
> > +#define TESTPMD_ADD_DRIVER_COMMANDS(c) \
>
> Why not TESTPMD_ADD_COMMANDS?

I forgot to align both the function and macro.
Please note though that for now, the registered commands through this
API get displayed in the "Driver specific" usage section.
So maybe the API should state it is about driver specific commands.

WDYT?


>
> > +RTE_INIT(__##c) \
> > +{ \
> > +     testpmd_add_commands(&c); \
> > +}
> [...]
> > --- a/drivers/meson.build
> > +++ b/drivers/meson.build
> > +        if testpmd_sources.length() != 0
> > +            testpmd_drivers_sources += testpmd_sources
> > +            testpmd_drivers_deps += dependency_name
> > +        endif
>
> Are you sure the check is required?
> What happens if adding an empty string?

We don't want to push a driver dependency to testpmd if there is nothing to add.


>
> [...]
> > --- a/meson.build
> > +++ b/meson.build
> > @@ -42,6 +42,8 @@ dpdk_drivers = []
> >  dpdk_extra_ldflags = []
> >  dpdk_libs_disabled = []
> >  dpdk_drvs_disabled = []
> > +testpmd_drivers_sources = []
> > +testpmd_drivers_deps = []
>
> It's polluting a bit the global meson namespace for testpmd
> but I think it's worth, I like the idea.
>
> I hope we can merge the infrastucture patches soon.
> We can postpone a bit the move of existing drivers
> because some are not so obvious.
> At least we should make it mandatory now for all new driver-specific commands.

I'm okay with the approach.
I'll prepare a new revision with only the API part, then and respin
the drivers updates later.


-- 
David Marchand


  reply	other threads:[~2022-05-24 17:45 UTC|newest]

Thread overview: 63+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-13  7:57 [RFC PATCH 0/4] Split driver specific commands out of testpmd David Marchand
2022-05-13  7:57 ` [RFC PATCH 1/4] app/testpmd: register driver specific commands David Marchand
2022-05-13 10:30   ` David Marchand
2022-05-13  7:57 ` [RFC PATCH 2/4] net/bonding: move testpmd commands David Marchand
2022-05-13 10:09   ` Min Hu (Connor)
2022-05-18 17:24     ` David Marchand
2022-05-18 23:25       ` Konstantin Ananyev
2022-05-19  7:40         ` David Marchand
2022-05-19 11:26           ` Thomas Monjalon
2022-05-20  6:59             ` Andrew Rybchenko
2022-05-24  9:40               ` Konstantin Ananyev
2022-05-24 10:15                 ` Thomas Monjalon
2022-05-24 22:41                   ` Konstantin Ananyev
2022-05-13  7:57 ` [RFC PATCH 3/4] net/i40e: " David Marchand
2022-05-13  7:57 ` [RFC PATCH 4/4] net/ixgbe: " David Marchand
2022-05-18 19:46 ` [RFC PATCH v2 0/5] Split driver specific commands out of testpmd David Marchand
2022-05-18 19:46   ` [RFC PATCH v2 1/5] app/testpmd: mark cmdline symbols as static David Marchand
2022-05-20  6:28     ` Andrew Rybchenko
2022-05-18 19:46   ` [RFC PATCH v2 2/5] app/testpmd: register driver specific commands David Marchand
2022-05-20  6:55     ` Andrew Rybchenko
2022-05-18 19:46   ` [RFC PATCH v2 3/5] net/bonding: move testpmd commands David Marchand
2022-05-20  6:55     ` Andrew Rybchenko
2022-05-18 19:46   ` [RFC PATCH v2 4/5] net/i40e: " David Marchand
2022-05-18 19:46   ` [RFC PATCH v2 5/5] net/ixgbe: " David Marchand
2022-05-20  7:04   ` [RFC PATCH v2 0/5] Split driver specific commands out of testpmd Andrew Rybchenko
2022-05-23  7:10 ` [PATCH 0/6] " David Marchand
2022-05-23  7:10   ` [PATCH 1/6] app/testpmd: mark most cmdline symbols as static David Marchand
2022-05-23 10:19     ` Dumitrescu, Cristian
2022-05-23 18:09       ` Ferruh Yigit
2022-05-23  7:10   ` [PATCH 2/6] app/testpmd: register driver specific commands David Marchand
2022-05-23 18:10     ` Ferruh Yigit
2022-05-24 10:53       ` David Marchand
2022-05-24 11:43         ` Ferruh Yigit
2022-05-24 17:21     ` Thomas Monjalon
2022-05-24 17:44       ` David Marchand [this message]
2022-05-24 17:51         ` Thomas Monjalon
2022-05-23  7:10   ` [PATCH 3/6] net/bonding: move testpmd commands David Marchand
2022-05-23 18:10     ` Ferruh Yigit
2022-06-17  5:06     ` [PATCH v2] " David Marchand
2022-06-20 17:53       ` Ferruh Yigit
2022-05-23  7:10   ` [PATCH 4/6] net/i40e: " David Marchand
2022-06-17  5:07     ` [PATCH v2] " David Marchand
2022-06-20 17:53       ` Ferruh Yigit
2022-05-23  7:10   ` [PATCH 5/6] app/testpmd: drop ixgbe bypass commands David Marchand
2022-05-23 18:10     ` Ferruh Yigit
2022-06-17  5:07     ` [PATCH v2 1/3] app/testpmd: restore " David Marchand
2022-06-17  5:07       ` [PATCH v2 2/3] net/ixgbe: move testpmd commands David Marchand
2022-06-17  5:07       ` [PATCH v2 3/3] net/ixgbe: move bypass init in a testpmd command David Marchand
2022-06-20 19:04         ` Ferruh Yigit
2022-06-23 12:35           ` Zhang, Qi Z
2022-07-21  8:05     ` [PATCH v3 1/3] app/testpmd: restore ixgbe bypass commands David Marchand
2022-07-21  8:05       ` [PATCH v3 2/3] net/ixgbe: move testpmd commands David Marchand
2022-07-21  8:05       ` [PATCH v3 3/3] net/ixgbe: move bypass init in a testpmd command David Marchand
2022-05-23  7:10   ` [PATCH 6/6] net/ixgbe: move testpmd commands David Marchand
2022-05-23 18:09   ` [PATCH 0/6] Split driver specific commands out of testpmd Ferruh Yigit
2022-05-24 20:06 ` [PATCH v2 0/2] " David Marchand
2022-05-24 20:06   ` [PATCH v2 1/2] app/testpmd: mark most cmdline symbols as static David Marchand
2022-05-31 15:15     ` Andrew Rybchenko
2022-05-24 20:06   ` [PATCH v2 2/2] app/testpmd: register driver specific commands David Marchand
2022-05-24 20:28     ` Thomas Monjalon
2022-05-31 15:14       ` Andrew Rybchenko
2022-05-31 15:18         ` David Marchand
2022-05-31 15:18   ` [PATCH v2 0/2] Split driver specific commands out of testpmd Andrew Rybchenko

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=CAJFAV8w4CUzUMBvvVbCv-Kg4XA8PvACdqbfta6zdwVt2uzCMUA@mail.gmail.com \
    --to=david.marchand@redhat.com \
    --cc=aman.deep.singh@intel.com \
    --cc=andrew.rybchenko@oktetlabs.ru \
    --cc=bruce.richardson@intel.com \
    --cc=dev@dpdk.org \
    --cc=ferruh.yigit@xilinx.com \
    --cc=spiked@nvidia.com \
    --cc=thomas@monjalon.net \
    --cc=xiaoyun.li@intel.com \
    --cc=yuying.zhang@intel.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

DPDK patches and discussions

This inbox may be cloned and mirrored by anyone:

	git clone --mirror http://inbox.dpdk.org/dev/0 dev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 dev dev/ http://inbox.dpdk.org/dev \
		dev@dpdk.org
	public-inbox-index dev

Example config snippet for mirrors.
Newsgroup available over NNTP:
	nntp://inbox.dpdk.org/inbox.dpdk.dev


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git