From mboxrd@z Thu Jan 1 00:00:00 1970 From: Stephen Hemminger Subject: Re: [PATCH v4 01/10] devargs: introduce iterator Date: Mon, 23 Apr 2018 16:54:17 -0700 Message-ID: <20180423165417.554d0ee0@xeon-e3> References: <4ae5a6e418b19a458aefee0621af9cc7baf76aab.1524522515.git.gaetan.rivet@6wind.com> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Cc: dev@dpdk.org To: Gaetan Rivet Return-path: Received: from mail-pf0-f193.google.com (mail-pf0-f193.google.com [209.85.192.193]) by dpdk.org (Postfix) with ESMTP id 03865187 for ; Tue, 24 Apr 2018 01:54:20 +0200 (CEST) Received: by mail-pf0-f193.google.com with SMTP id f189so1533243pfa.7 for ; Mon, 23 Apr 2018 16:54:20 -0700 (PDT) In-Reply-To: <4ae5a6e418b19a458aefee0621af9cc7baf76aab.1524522515.git.gaetan.rivet@6wind.com> 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 Tue, 24 Apr 2018 00:41:01 +0200 Gaetan Rivet 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 > --- > 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.