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 9ABA02BB8 for ; Wed, 7 Jun 2017 15:27:49 +0200 (CEST) Received: by mail-wr0-f177.google.com with SMTP id v104so6200646wrb.0 for ; Wed, 07 Jun 2017 06:27:49 -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=wWDUtOLlheLq4CrqosLVS5HPYIKk1uCtWsKHdMQWyBE=; b=UQAMaiv61tXz6p4p0DSEoam+tXHTdjf7S+ndaKivNsOTOjgzhYhPbOzqxb6Zn17Sr9 k/PaSm8GBkYyb5YSXWABIC/vgB8GXYBQ1+1TzpAOCk94OcOSN42uSldNjC8ZR37uoFkS HEEmo7MNGpQPqOMQsW3vjFlEaBxr2nqUJn/0XmUbCGFmQAoflFo1SKc5MDvYFfL2M1KO h85+xfSXbGwCs+rc2ZlKRVLo/KPETVoU4Sl66XeWx0bna0w2SH617ypTuodkI61sQQYm Srei/Xy5bJi7feoC0Ktq+AALoEDa3VkGubX0G1gemq6zNEKDwWPL2JCbH1Bxsjmy1KUq Tn6w== 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=wWDUtOLlheLq4CrqosLVS5HPYIKk1uCtWsKHdMQWyBE=; b=JxWuSf9vN0/mya3PLqOlObYfTOZWJtIcKL9VlG0MazCW6zhzlP5+96ml1050LJkI7w uda10SYedcCkNgjI+6VKKQBIiXdkQkCqOKNXhmVxuAta3t6CcvK6BwfEk0DgSto0kZKO fEZEVtmtFe2Bi9iOxQBLXvhPBw17FYEdBjip7PZAJqee4Pq8s0VPIeCJ/DSKbkU/OFaE fzqAK3UKBluMsSdrMGEBXmHSsY8oUIen6i0ky593FVzCWVsGLwvWcsz1qtJC5MpfLxqB kT/XFwHjp9hC3kmfbRamGw1E6ee85C+4Cv7Lqn8kkP7b/5N6WOD1dATDmNyKjNCO4Zj6 3w4Q== X-Gm-Message-State: AODbwcBnf/qEeBvjWPJ4Ts+PY1UjAO3Bsfu9i5ZPP0urt9AfJSQPuncV 1yV/waFXt+aK11Oc X-Received: by 10.223.134.113 with SMTP id 46mr10075699wrw.62.1496842069230; Wed, 07 Jun 2017 06:27:49 -0700 (PDT) Received: from bidouze.vm.6wind.com (host.78.145.23.62.rev.coltfrance.com. [62.23.145.78]) by smtp.gmail.com with ESMTPSA id 69sm12631930wml.0.2017.06.07.06.27.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 07 Jun 2017 06:27:48 -0700 (PDT) Date: Wed, 7 Jun 2017 15:27:42 +0200 From: =?iso-8859-1?Q?Ga=EBtan?= Rivet To: Shreyansh Jain Cc: dev@dpdk.org, Jan Blunck Message-ID: <20170607132742.GP18840@bidouze.vm.6wind.com> References: <33c95f6a-82b4-6557-7011-f210f34cbc88@nxp.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <33c95f6a-82b4-6557-7011-f210f34cbc88@nxp.com> User-Agent: Mutt/1.5.23 (2014-03-12) Subject: Re: [dpdk-dev] [PATCH v2 01/11] 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: Wed, 07 Jun 2017 13:27:49 -0000 On Wed, Jun 07, 2017 at 12:36:53PM +0530, Shreyansh Jain wrote: > Hello Gaetan, > > On Wednesday 31 May 2017 06:47 PM, 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 | 13 ++++++++++ > > lib/librte_eal/common/include/rte_bus.h | 32 +++++++++++++++++++++++++ > > 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..68f70d0 100644 > >--- a/lib/librte_eal/common/eal_common_bus.c > >+++ b/lib/librte_eal/common/eal_common_bus.c > >@@ -145,3 +145,16 @@ rte_bus_dump(FILE *f) > > } > > } > > } > >+ > >+struct rte_bus * > >+rte_bus_find(rte_bus_match_t match, const void *data) > >+{ > >+ struct rte_bus *bus = NULL; > >+ > >+ TAILQ_FOREACH(bus, &rte_bus_list, next) { > >+ if (match(bus, data)) > >+ 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..006feca 100644 > >--- a/lib/librte_eal/common/include/rte_bus.h > >+++ b/lib/librte_eal/common/include/rte_bus.h > >@@ -141,6 +141,38 @@ int rte_bus_probe(void); > > void rte_bus_dump(FILE *f); > > /** > >+ * Bus match function. > >+ * > >+ * @param bus > >+ * bus under test. > >+ * > >+ * @param data > >+ * data matched > >+ * > >+ * @return > >+ * 0 if the bus does not match. > >+ * !0 if the bus matches. > > One of the common match function implementation could be simply to match > a string. strcmp itself returns '0' for a successful match. > On the same lines, should this function return value be reversed? > - > 0 if match > !0 if not a match > - > That way, people would not have to change either the way strcmp works, > for example, or the way various APIs expect '0' as success. > > same for rte_device_match_t as well. (in next patch) > It was actually a point I hesitated a little before submitting this version. The logic behind strcmp is that you can express three states: greater than, equal, lower than, thus having total order within the string set. Here, buses are not ordered (logically). Having a bus lower or greater than some arbitrary data does not mean much. Anyway, this was my reasoning for following Jan's proposal on this, but I'm not against changing this API. Maybe having to possibility to express total order could be useful eventually. I don't have a strong opinion on this so unless someone shouts about it, I will follow your remark. > >+ */ > >+typedef int (*rte_bus_match_t)(const struct rte_bus *bus, const void *data); > >+ > >+/** > >+ * Bus iterator to find a particular bus. > >+ * > >+ * If the callback returns non-zero this function will stop iterating over > >+ * any more buses. > >+ * > >+ * @param match > >+ * Callback function to check bus > >+ * > >+ * @param data > >+ * Data to pass to match callback > >+ * > >+ * @return > >+ * A pointer to a rte_bus structure or NULL in case no bus matches > >+ */ > >+struct rte_bus *rte_bus_find(rte_bus_match_t match, 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; > > -- Gaëtan Rivet 6WIND