From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm0-f66.google.com (mail-wm0-f66.google.com [74.125.82.66]) by dpdk.org (Postfix) with ESMTP id 1A4A3374 for ; Tue, 27 Jun 2017 20:55:50 +0200 (CEST) Received: by mail-wm0-f66.google.com with SMTP id 131so7444172wmq.2 for ; Tue, 27 Jun 2017 11:55:50 -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=7tsd4j2RPFRAmSwPzgIrVVzCYLprDiJu9t58zFpj9GQ=; b=uY2XVBRkHC/a7DuYnFc748h83XbDMIkREPh7W1fgp4dwUdBO2tpR0C0ggecaGzq5vM DmCKFM3bfrMLIGNTkdWuFnbInHv3Z1qIgoJb7TxRn4bYQILJmFkWRpVEJwKirzgaPtmo l556E0bN08sL3zUM3DUZVgHATUAXT19qv7cLwWC9wWDQ1Mss4S5UEMioMzgk6NxT4l4Q 8gyUYX60891w2YTuXj6Yz071ChxiEvZ6OpLiDMJDNrOLkwj+UG7jn/G96mg1t0V1WU1h aB8MvbbVuShNOjg+AbX7gSbQA1Yt3EqI/4tfi6W+kTP/LiBH8wdulzekpVeqEC9Nc3JC E3vw== 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=7tsd4j2RPFRAmSwPzgIrVVzCYLprDiJu9t58zFpj9GQ=; b=Q7QPnHbi88tqDV4X8DNHY6TkrPjxb7XzCJ5XWlFDVLDw9OuF2O+KWM8/y73VZn4Y+V UqmyQNi18yudKt/zepPgi6ktB4doEOGNQNQQbSXY6PASSGqqr9heHgLmkV9KKo/mI1xV g/PxptpebN+scctlx/jsktYIWghoaEQ8nLsSyi1Z527VZwUmoQX/2Z6nOdJlfXXFXQoX ZnQPfew4Jea1TihP9sO7AWTeXwObSEtJKaqoX2Sux6Sj2fTnxMtuiAkrDrlkix3FWYam ZdW9pBlqY5EmRsTTTtGMvJKT8paSNxH6EGUyL5g/j4KEwXvAHrNlyMzYWjglkA8qtLbL lWPQ== X-Gm-Message-State: AKS2vOxY8htZUPClQuF9WQVNbcQlsg3SPJYBOcYvEDK5DoRXu9Y++MvH n9poZGMBnwn0h9CziYpLlVIY6+gp1g== X-Received: by 10.28.167.207 with SMTP id q198mr4670845wme.36.1498589749687; Tue, 27 Jun 2017 11:55:49 -0700 (PDT) MIME-Version: 1.0 Sender: jblunck@gmail.com Received: by 10.28.158.200 with HTTP; Tue, 27 Jun 2017 11:55:47 -0700 (PDT) In-Reply-To: References: From: Jan Blunck Date: Tue, 27 Jun 2017 20:55:47 +0200 X-Google-Sender-Auth: 8qxKqde-UFwzc8Khbcp6pmO16_U Message-ID: To: Gaetan Rivet Cc: dev Content-Type: text/plain; charset="UTF-8" Subject: Re: [dpdk-dev] [PATCH v5 5/7] bus: add helper to find a bus from a device name 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: Tue, 27 Jun 2017 18:55:50 -0000 On Wed, Jun 21, 2017 at 1:30 AM, Gaetan Rivet wrote: > Find which bus should be able to parse this device name into an internal > device representation. > > Signed-off-by: Gaetan Rivet > --- > lib/librte_eal/bsdapp/eal/rte_eal_version.map | 1 + > lib/librte_eal/common/eal_common_bus.c | 15 +++++++++++++++ > lib/librte_eal/common/include/rte_bus.h | 12 ++++++++++++ > lib/librte_eal/linuxapp/eal/rte_eal_version.map | 1 + > 4 files changed, 29 insertions(+) > > diff --git a/lib/librte_eal/bsdapp/eal/rte_eal_version.map b/lib/librte_eal/bsdapp/eal/rte_eal_version.map > index 3517d74..04fa882 100644 > --- a/lib/librte_eal/bsdapp/eal/rte_eal_version.map > +++ b/lib/librte_eal/bsdapp/eal/rte_eal_version.map > @@ -202,5 +202,6 @@ DPDK_17.08 { > global: > > rte_bus_from_name; > + rte_bus_from_dev; > > } DPDK_17.05; > diff --git a/lib/librte_eal/common/eal_common_bus.c b/lib/librte_eal/common/eal_common_bus.c > index e69ce38..e9fbc03 100644 > --- a/lib/librte_eal/common/eal_common_bus.c > +++ b/lib/librte_eal/common/eal_common_bus.c > @@ -231,3 +231,18 @@ rte_bus_from_name(const char *str) > { > return rte_bus_find(bus_cmp_name, str, NULL); > } > + > +static int > +bus_can_parse(const struct rte_bus *bus, const void *_name) > +{ > + const char *name = _name; > + > + return !(bus->parse && bus->parse(name, NULL) == 0); > +} > + > +/* find a bus capable of parsing a device description */ > +struct rte_bus * > +rte_bus_from_dev(const char *str) > +{ > + return rte_bus_find(bus_can_parse, str, NULL); > +} > diff --git a/lib/librte_eal/common/include/rte_bus.h b/lib/librte_eal/common/include/rte_bus.h > index da8b8a1..61d9e6e 100644 > --- a/lib/librte_eal/common/include/rte_bus.h > +++ b/lib/librte_eal/common/include/rte_bus.h > @@ -283,6 +283,18 @@ struct rte_bus *rte_bus_find_by_device(const struct rte_device *dev); > struct rte_bus *rte_bus_from_name(const char *str); > > /** > + * Find a bus capable of identifying a device. > + * > + * @param str > + * A device identifier (PCI address, virtual PMD name, ...). > + * > + * @return > + * A valid bus handle if found. > + * NULL if no bus is able to parse this device. > + */ > +struct rte_bus *rte_bus_from_dev(const char *str); I still don't agree with this. The bus name should be passed explicitly by the user of the API. NAK. > + > +/** > * 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 6607acc..a5127d6 100644 > --- a/lib/librte_eal/linuxapp/eal/rte_eal_version.map > +++ b/lib/librte_eal/linuxapp/eal/rte_eal_version.map > @@ -206,5 +206,6 @@ DPDK_17.08 { > global: > > rte_bus_from_name; > + rte_bus_from_dev; > > } DPDK_17.05; > -- > 2.1.4 >