From mboxrd@z Thu Jan 1 00:00:00 1970 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) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=6wind-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:content-transfer-encoding:in-reply-to :user-agent; bh=nFfUWb+wh23V2Lo39gQJSUv1lFnPewi65Yyeuhi/s6s=; b=EyaJfo2ch9+DUFDEaMwaEkfjW1A4yiaCWjKzYWcl/cEjxLm1zd1sModPG2aoDK0fsm ZRcLXhgkefNhASZ90ynxq6gPduNI98RdBf/2A2By9so4Mxutx2nTuk68LRt0sK6aruDl PUsVtRihc/t2Y9xQns+zCNrMqnhi1i5F7K6MiXv++JGKPYHmQ6n7Wu3qzwTB7xd4Awya kEqJRu4B1PQstJiVjQbO0ZBzRuBjEce4+vq/Wy/ptesiHnERRsbfAnmGSIRrJwp0Fkpw 245od9TMsiXHR0Q7xhaTAybPp5DivmuR9xnCY4h/V/PU4ZVDbQ201IC4+yMNG4YVhlbm twCQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to:user-agent; bh=nFfUWb+wh23V2Lo39gQJSUv1lFnPewi65Yyeuhi/s6s=; b=n3jlQu7AUJxjSMvDf69PNYIWep+ZsTbteyWm38Pcp2PtoFiNs2lyL5WEaaA60Xqp0o N/M2HhsyEoJFU4M5spf7/XeRHDPKqMihEXlYeDHiYOdpbMNvQeh/79g5aj7f0/JgC1Xl GdpztcaSHROFPNiY4U08+V80DkzblS5eR/kT5R0XT6VzuY3CbqHXsCOgNekUYLlg/Ep8 GOkk5XJE+ArVKfT60KvPJFrIrlFE1DFr88zHopZZ0I4eD3e0SnPVKxiCKIOFTEp3TAV2 UMWP9/MA/JU1eagkkv/0r9L/9NWNvyP4qgEGyjlUut8QXdXg94pGxXhVtlw2f5sJJkSF 8F6Q== X-Gm-Message-State: AKS2vOzK8i5WSZEPQ60FkUwyVImcgVVW3VB4n1VxqLkinxba7qXAEtTf DXurFAnJPIlyMaGZ X-Received: by 10.28.109.210 with SMTP id b79mr5545900wmi.55.1497211196778; Sun, 11 Jun 2017 12:59:56 -0700 (PDT) Received: from bidouze.vm.6wind.com ([62.23.145.78]) by smtp.gmail.com with ESMTPSA id h12sm6477341wrc.43.2017.06.11.12.59.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 11 Jun 2017 12:59:55 -0700 (PDT) Date: Sun, 11 Jun 2017 21:59:48 +0200 From: =?iso-8859-1?Q?Ga=EBtan?= Rivet To: Jan Blunck Cc: dev 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-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.5.23 (2014-03-12) Subject: Re: [dpdk-dev] [PATCH v3 01/10] bus: add bus iterator to find a particular bus X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 11 Jun 2017 19:59:57 -0000 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