From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr0-f194.google.com (mail-wr0-f194.google.com [209.85.128.194]) by dpdk.org (Postfix) with ESMTP id CE6E02C2A for ; Sat, 10 Jun 2017 10:58:48 +0200 (CEST) Received: by mail-wr0-f194.google.com with SMTP id u101so11235397wrc.1 for ; Sat, 10 Jun 2017 01:58:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=pz3ZgznF9A01PvunRB8WSonmeh1n/9Utqrb6hNRSQUA=; b=WaCTHdTz6LNoGTCpBO5ZOB492nG4flJoFw8RtPD4fnCyyirWX34cuir6mmYYAT8aAy 25Q3SX58EEu1XTEriYbMlnd32p6eqd/4x4Q7pKXNGvsvSPl74r894Pj90DfjJetO22uE z/69mjSVdy07CzaamaIK759oZqoVSeH+0GddAftvmPOdVRhdaaTxi6q++hSNumiAp+Dw S2s6wYRPfHvw5NTZVmNEYmOxql9tmnDZgva8gLuUeuqzuQQ4OyhDa/+4RjHzdY39nddW 2mmcbl/xLoutH86XmNix/56u1QONL8FwZWE4sWo6FZnMU+2BF5etfJF+U7uhIFlpE57+ dGvQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc; bh=pz3ZgznF9A01PvunRB8WSonmeh1n/9Utqrb6hNRSQUA=; b=ioRvzJxemm9WU3mpI6NecInCs/MpiBHoZcWNGra+bt3PcTXYoMVHm+Y5hT8ZU+yM6d 0A6QlF15XFG3H1F+j8W8g8TQUlkCf3IvMJNUbx0KOK0gn/bBSch41qXWh3fMqVw81B4T w5kq4un8YYalkZPHi/33gQ016O5IgJ8V+Yx+xAPeTcVP36rLcGU6PQnH2S8wFoLZZ0si K4v0kqzw8rQgdDj0emUxZnnuvesh+znbv2Lcn0dsg672mbLw/5mK2TBHf5C8YsPMhdUX 1/F9p7EkldS6MmI8Zi99fGqiYmnF/oF5zTUzeRJHc7QFuyBhMnnb50OEVK7/dU57Bknk EKeg== X-Gm-Message-State: AODbwcBOsn4AOMm0L83BHY2FLNM/QNyNBmiIoqbFbnpuP1YgzZ0T/hwR MBZJOld1Ai5b1Zb6jYIWOTCZcGGoVg== X-Received: by 10.223.182.152 with SMTP id j24mr1466016wre.122.1497085128376; Sat, 10 Jun 2017 01:58:48 -0700 (PDT) MIME-Version: 1.0 Sender: jblunck@gmail.com Received: by 10.28.25.65 with HTTP; Sat, 10 Jun 2017 01:58:47 -0700 (PDT) In-Reply-To: <64ba7d394994bf8f1b6e82d16f59da02ae1ad312.1496876710.git.gaetan.rivet@6wind.com> References: <64ba7d394994bf8f1b6e82d16f59da02ae1ad312.1496876710.git.gaetan.rivet@6wind.com> From: Jan Blunck Date: Sat, 10 Jun 2017 10:58:47 +0200 X-Google-Sender-Auth: YQ9YpH-xok0Y61qRYwXciZKFGXk Message-ID: To: Gaetan Rivet Cc: dev Content-Type: text/plain; charset="UTF-8" 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: Sat, 10 Jun 2017 08:58:49 -0000 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? > + > +/** > + * Bus iterator to find a particular bus. > + * > + * If the callback returns non-zero this function will stop iterating over > + * any more buses. > + * > + * @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 >