From mboxrd@z Thu Jan 1 00:00:00 1970 From: =?iso-8859-1?Q?Ga=EBtan?= Rivet Subject: Re: [PATCH v3 01/10] bus: add bus iterator to find a particular bus Date: Sun, 11 Jun 2017 21:59:48 +0200 Message-ID: <20170611195947.GP29091@bidouze.vm.6wind.com> References: <64ba7d394994bf8f1b6e82d16f59da02ae1ad312.1496876710.git.gaetan.rivet@6wind.com> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Cc: dev To: Jan Blunck Return-path: Received: from mail-wr0-f177.google.com (mail-wr0-f177.google.com [209.85.128.177]) by dpdk.org (Postfix) with ESMTP id 56574101B for ; Sun, 11 Jun 2017 21:59:57 +0200 (CEST) Received: by mail-wr0-f177.google.com with SMTP id v104so76544771wrb.0 for ; Sun, 11 Jun 2017 12:59:57 -0700 (PDT) Content-Disposition: inline In-Reply-To: List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" On Sat, Jun 10, 2017 at 10:58:47AM +0200, Jan Blunck wrote: > On Thu, Jun 8, 2017 at 1:53 AM, Gaetan Rivet wrote: > > From: Jan Blunck > > > > Signed-off-by: Jan Blunck > > Signed-off-by: Gaetan Rivet > > --- > > 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