From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm0-f65.google.com (mail-wm0-f65.google.com [74.125.82.65]) by dpdk.org (Postfix) with ESMTP id 97F811396 for ; Wed, 7 Jun 2017 19:28:08 +0200 (CEST) Received: by mail-wm0-f65.google.com with SMTP id x3so3583128wme.0 for ; Wed, 07 Jun 2017 10:28:08 -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=7qgCjPfI6aLOOO8zNKhDsPD9/1NQnHgI4lvg2ES6qNE=; b=IMziR0a2tJ/ECMcav+p26RarZNoPgrMNTvU/x9Lru3XiHUapsOPxWqDFAtGeYMmtF0 qOqGNypjc6EWTMvQDdsgq2mpErdGjB3fvnlCIGiAhn3/+NTYEgm68A+aA4tKZVDZ1lyh 1LBE5IDEt2vSDjr9j7CydDoGygF6qoK4R1bd3XalYHAG4tJYcz0fBmimsi3fVdOQrMSe 6/bBbFNlWb4gjHDdFGqQy/5RIzdXA8pdl2/gArQym3b5BFeT+yNLj43Kgy8ZWz7POmQG lqRi649y5E9GZ6EvXJDd7n2y7qFIEKTs/YfSNyldCOXKdu1fpbgLIU10VFqmutlx1i3O jY6g== 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=7qgCjPfI6aLOOO8zNKhDsPD9/1NQnHgI4lvg2ES6qNE=; b=byJzehzq1BOAZ4bHSRYlKkIYSVK8Ho/fKr1gCJ/gaDNEaWAtcRO4z0UV1SLZkzew1p FN8qCHKkiZUYf0DVbKbefBmC+1pUiIYMwL/JDh/2FHWRtghuQMxtQb0IfO4ctYkwZy6c 3M8LrHTv/8NLcTk4FNQWIB3I5R3Be1xwhRcWJwFHiui5hQ3rVyfT0p62UoCBRor3qJSx gGh8w/rzOgni/IbT97u1wTDL5ai731NizuMiiFfu2ToO6Q6JZiaPnZ6NbMUnkftbuC9Q Yym9hvfwJeveJIZwUjaesDl83PCBT+MteLAY02EarDXNZ7Xv7vWrAKduc0G0XAb22oJK OZKA== X-Gm-Message-State: AODbwcD1dkX0Lbtt4bLtUAJQ3ghkDyI4DTcC9zSVuqDDXK7lHsbf06uF 30cNyM5b6cTD42+4ZNmW4wHp3T25YCg+ X-Received: by 10.28.155.65 with SMTP id d62mr589293wme.78.1496856488267; Wed, 07 Jun 2017 10:28:08 -0700 (PDT) MIME-Version: 1.0 Sender: jblunck@gmail.com Received: by 10.28.25.65 with HTTP; Wed, 7 Jun 2017 10:28:07 -0700 (PDT) In-Reply-To: <1a54f0dd79200960921ca495aa7381817a599bc0.1495629122.git.gaetan.rivet@6wind.com> References: <1a54f0dd79200960921ca495aa7381817a599bc0.1495629122.git.gaetan.rivet@6wind.com> From: Jan Blunck Date: Wed, 7 Jun 2017 19:28:07 +0200 X-Google-Sender-Auth: bV2l5LYPIGWuTSc98j-8Pvc7rrs Message-ID: To: Gaetan Rivet Cc: dev , Stephen Hemminger , Maxime Coquelin , Jerin Jacob , David Marchand Content-Type: text/plain; charset="UTF-8" Subject: Re: [dpdk-dev] [PATCH 7/9] 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: Wed, 07 Jun 2017 17:28:08 -0000 On Wed, May 24, 2017 at 5:12 PM, Gaetan Rivet wrote: > Find which bus should be able to parse this device name into an internal > device representation. > No, please don't add this. One should know to what bus a device belongs to before plugging it. Artificially encoding the parent bus into the device name is not the right thing to do. Please keep those things separate. > 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 7977190..08fff60 100644 > --- a/lib/librte_eal/common/eal_common_bus.c > +++ b/lib/librte_eal/common/eal_common_bus.c > @@ -242,3 +242,18 @@ rte_bus_from_name(const char *str) > return NULL; > return rte_bus_find(bus_cmp_name, str); > } > + > +static int > +bus_can_parse(const struct rte_bus *bus, const void *_name) > +{ > + const char *name = _name; > + > + return (bus->parse && !bus->parse(name, NULL)); > +} > + > +/* 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); > +} > diff --git a/lib/librte_eal/common/include/rte_bus.h b/lib/librte_eal/common/include/rte_bus.h > index 5b87ac4..0b48e66 100644 > --- a/lib/librte_eal/common/include/rte_bus.h > +++ b/lib/librte_eal/common/include/rte_bus.h > @@ -251,6 +251,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 structure if found. > + * NULL if no bus is able to parse this device. > + */ > +struct rte_bus *rte_bus_from_dev(const char *str); > + > +/** > * 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 >