[dpdk-dev] [PATCH v4 01/10] devargs: introduce iterator
Gaëtan Rivet
gaetan.rivet at 6wind.com
Tue Apr 24 12:22:08 CEST 2018
On Mon, Apr 23, 2018 at 04:54:17PM -0700, Stephen Hemminger wrote:
> On Tue, 24 Apr 2018 00:41:01 +0200
> Gaetan Rivet <gaetan.rivet at 6wind.com> wrote:
>
> > In preparation to making devargs_list private.
> >
> > Bus drivers generally need to access rte_devargs pertaining to their
> > operations. This match is a common operation for bus drivers.
> >
> > Add a new accessor for the rte_devargs list.
> >
> > Signed-off-by: Gaetan Rivet <gaetan.rivet at 6wind.com>
> > ---
> > lib/librte_eal/common/eal_common_devargs.c | 20 ++++++++++++++++++++
> > lib/librte_eal/common/include/rte_devargs.h | 20 ++++++++++++++++++++
> > lib/librte_eal/rte_eal_version.map | 1 +
> > 3 files changed, 41 insertions(+)
> >
> > diff --git a/lib/librte_eal/common/eal_common_devargs.c b/lib/librte_eal/common/eal_common_devargs.c
> > index 810b3e18f..c6c5eabcf 100644
> > --- a/lib/librte_eal/common/eal_common_devargs.c
> > +++ b/lib/librte_eal/common/eal_common_devargs.c
> > @@ -207,3 +207,23 @@ rte_eal_devargs_dump(FILE *f)
> > devargs->name, devargs->args);
> > }
> > }
> > +
> > +/* bus-aware rte_devargs iterator. */
> > +__rte_experimental
> > +struct rte_devargs *
> > +rte_eal_devargs_next(const char *busname, const struct rte_devargs *start)
> > +{
> > + struct rte_devargs *da;
> > +
> > + if (start != NULL)
> > + da = TAILQ_NEXT(start, next);
> > + else
> > + da = TAILQ_FIRST(&devargs_list);
> > + while (da != NULL) {
> > + if (busname == NULL ||
> > + (strcmp(busname, da->bus->name) == 0))
> > + return da;
> > + da = TAILQ_NEXT(da, next);
> > + }
> > + return NULL;
> > +}
>
> Can this be made to return a const pointer? It seems unsymmetrical to
> get the next value as a non-const pointer when passed a const based on last value.
>
I would like to, but this iterator is used in buses to match devargs and
assign it to an rte_devive. The devargs field there is not const.
We don't have a deprecation notice running on this. This might be worth
it, though, but I think this could come after integrating this series.
--
Gaëtan Rivet
6WIND
More information about the dev
mailing list