[dpdk-dev] [PATCH v3 01/10] bus: add bus iterator to find a particular bus

Gaëtan Rivet gaetan.rivet at 6wind.com
Sun Jun 11 21:59:48 CEST 2017


On Sat, Jun 10, 2017 at 10:58:47AM +0200, Jan Blunck wrote:
> On Thu, Jun 8, 2017 at 1:53 AM, Gaetan Rivet <gaetan.rivet at 6wind.com> wrote:
> > From: Jan Blunck <jblunck at infradead.org>
> >
> > Signed-off-by: Jan Blunck <jblunck at infradead.org>
> > Signed-off-by: Gaetan Rivet <gaetan.rivet at 6wind.com>
> > ---
> >  lib/librte_eal/bsdapp/eal/rte_eal_version.map   |  1 +
> >  lib/librte_eal/common/eal_common_bus.c          | 11 ++++++++
> >  lib/librte_eal/common/include/rte_bus.h         | 34 +++++++++++++++++++++++++
> >  lib/librte_eal/linuxapp/eal/rte_eal_version.map |  1 +
> >  4 files changed, 47 insertions(+)
> >
> > diff --git a/lib/librte_eal/bsdapp/eal/rte_eal_version.map b/lib/librte_eal/bsdapp/eal/rte_eal_version.map
> > index 2e48a73..ed09ab2 100644
> > --- a/lib/librte_eal/bsdapp/eal/rte_eal_version.map
> > +++ b/lib/librte_eal/bsdapp/eal/rte_eal_version.map
> > @@ -162,6 +162,7 @@ DPDK_17.02 {
> >  DPDK_17.05 {
> >         global:
> >
> > +       rte_bus_find;
> >         rte_cpu_is_supported;
> >         rte_log_dump;
> >         rte_log_register;
> > diff --git a/lib/librte_eal/common/eal_common_bus.c b/lib/librte_eal/common/eal_common_bus.c
> > index 8f9baf8..a54aeb4 100644
> > --- a/lib/librte_eal/common/eal_common_bus.c
> > +++ b/lib/librte_eal/common/eal_common_bus.c
> > @@ -145,3 +145,14 @@ rte_bus_dump(FILE *f)
> >                 }
> >         }
> >  }
> > +
> > +struct rte_bus *
> > +rte_bus_find(rte_bus_cmp_t cmp, const void *data)
> > +{
> > +       struct rte_bus *bus = NULL;
> > +
> > +       TAILQ_FOREACH(bus, &rte_bus_list, next)
> > +               if (cmp(bus, data) == 0)
> > +                       break;
> > +       return bus;
> > +}
> > diff --git a/lib/librte_eal/common/include/rte_bus.h b/lib/librte_eal/common/include/rte_bus.h
> > index 7c36969..16bcfd9 100644
> > --- a/lib/librte_eal/common/include/rte_bus.h
> > +++ b/lib/librte_eal/common/include/rte_bus.h
> > @@ -141,6 +141,40 @@ int rte_bus_probe(void);
> >  void rte_bus_dump(FILE *f);
> >
> >  /**
> > + * Bus comparison function.
> > + *
> > + * @param bus
> > + *     Bus under test.
> > + *
> > + * @param data
> > + *     Data to compare against.
> > + *
> > + * @return
> > + *     0 if the bus matches the data.
> > + *     !0 if the bus does not match.
> > + *     <0 if ordering is possible and the bus is lower than the data.
> > + *     >0 if ordering is possible and the bus is greater than the data.
> > + */
> > +typedef int (*rte_bus_cmp_t)(const struct rte_bus *bus, const void *data);
> 
> Gaetan,
> 
> Thanks for doing the adjustments. I believe we should also pass the
> starting pointer down to the bus implementation to enable continuation
> of a search after the given starting pointer. Does this make sense?
> 

Hi Jan,

Yes it makes sense, I see no reason to restrict the API, it will probably
be useful and is a pretty common functionality for iterators.

It seems I missed fixing the description to rte_bus_find anyway, I will
rework this part.

> > +
> > +/**
> > + * Bus iterator to find a particular bus.
> > + *
> > + * If the callback returns non-zero this function will stop iterating over
> > + * any more buses.

--> returns zero this function will stop **

> > + *
> > + * @param cmp
> > + *     Comparison function.
> > + *
> > + * @param data
> > + *      Data to pass to cmp callback
> > + *
> > + * @return
> > + *      A pointer to a rte_bus structure or NULL in case no bus matches
> > + */
> > +struct rte_bus *rte_bus_find(rte_bus_cmp_t cmp, const void *data);
> > +
> > +/**
> >   * Helper for Bus registration.
> >   * The constructor has higher priority than PMD constructors.
> >   */
> > diff --git a/lib/librte_eal/linuxapp/eal/rte_eal_version.map b/lib/librte_eal/linuxapp/eal/rte_eal_version.map
> > index 670bab3..6efa517 100644
> > --- a/lib/librte_eal/linuxapp/eal/rte_eal_version.map
> > +++ b/lib/librte_eal/linuxapp/eal/rte_eal_version.map
> > @@ -166,6 +166,7 @@ DPDK_17.02 {
> >  DPDK_17.05 {
> >         global:
> >
> > +       rte_bus_find;
> >         rte_cpu_is_supported;
> >         rte_intr_free_epoll_fd;
> >         rte_log_dump;
> > --
> > 2.1.4
> >

-- 
Gaëtan Rivet
6WIND


More information about the dev mailing list