From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr0-f176.google.com (mail-wr0-f176.google.com [209.85.128.176]) by dpdk.org (Postfix) with ESMTP id 6F0BD2BA1 for ; Thu, 8 Jun 2017 13:36:37 +0200 (CEST) Received: by mail-wr0-f176.google.com with SMTP id g76so17280405wrd.1 for ; Thu, 08 Jun 2017 04:36:37 -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=Ze2Rfl3afuwEq3J6KajtdeHYo24lE2FHW+tPZe0I5GA=; b=SBPaZoPyJmuSRCLhRktvdKbgpB1qbWBWfWpeDeMQnM7tz7lUq2+ixxfoRaXt/tQaUT jqHuo0ySwI44y2QqPoh5DBKcqfq5TenYs0FJH79eyOg8A23kbLWVtTiEk+q5ZK3YpOzj 9XAjLTwzBR/wJZa3WikRnwfvXSnF3DhGNPaCE6CouQYVbvONlJHactvjGQNllcKFPwqu ab7j+Ccd3tNdWfiBCM306U/zRJMEXf7YqAkagZgehCQh2qLfGA3muPmUZHepRTWIyuEh ZZtxIUW+IUjoVal3tq6sJCPeCdNnZm8sraSbm1O4f6+FcFspwoLs6JHkl9O9CAckbDT5 QF5Q== 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=Ze2Rfl3afuwEq3J6KajtdeHYo24lE2FHW+tPZe0I5GA=; b=EBtePM5SkCKazeHHKnV6ukokur0wl/Usy2HsPWhkVXJnmT6oKU9QjKlC4d6WbHAb3e xADEWNBYBj+EhNKho4IBIOFD1/m44R8/EYQQ3cIFLCfSsQwsl3Qls62INW4lgGyv4eXY cbWKXfOrweug9wlEBm5SAp8R0jSf0pKwFOgeZSTxc5Hm0l7J881lOy3JAmAGcgq88m+c K1VU9Cj4fiKH0W2I3FIMdEgLKrIIslbnOfMBLDB9lv6MD+QBMsSiiHh8X5FUVocC3vDI CEE1+Gc3YlnQMWynoeEYI7BEEhvKnVcNfivFxw6zoAK7Rs9PCrllzRGs0+/hmF8ZDQNy UphQ== X-Gm-Message-State: AODbwcDfO17Ibwfc4sHjaoTpKB0xhgM0becK8FjLMOPgAZu2AxVte0nZ +2fe0HP+2Y8wyEc3 X-Received: by 10.223.142.150 with SMTP id q22mr24691103wrb.180.1496921796952; Thu, 08 Jun 2017 04:36:36 -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 y17sm5816221wrb.39.2017.06.08.04.36.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 08 Jun 2017 04:36:36 -0700 (PDT) Date: Thu, 8 Jun 2017 13:36:30 +0200 From: =?iso-8859-1?Q?Ga=EBtan?= Rivet To: Jan Blunck Cc: dev , Stephen Hemminger , Maxime Coquelin , Jerin Jacob , David Marchand Message-ID: <20170608113630.GB18840@bidouze.vm.6wind.com> References: <1a54f0dd79200960921ca495aa7381817a599bc0.1495629122.git.gaetan.rivet@6wind.com> <20170607200331.GU18840@bidouze.vm.6wind.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.5.23 (2014-03-12) 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: Thu, 08 Jun 2017 11:36:37 -0000 On Thu, Jun 08, 2017 at 12:45:17PM +0200, Jan Blunck wrote: > On Wed, Jun 7, 2017 at 10:03 PM, Gaëtan Rivet wrote: > > On Wed, Jun 07, 2017 at 07:28:07PM +0200, Jan Blunck wrote: > >> 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. > >> > > > > When plugging a device the users know about: > - bus name > - device name > > Its not the case that the users invent the device names out of thin > air. The EAL shouldn't codify what the users of the EAL already know > about. > > Yes, but in that case the user is forced to explicitly name the bus used for a device. I think it might be sufficient to have this as a private function to the EAL, as it is currently only used within the rte_devargs parsing. Applications could use this helper to recognize a bus from a device name, but this is contrived. > > The EAL has no way to know this currently. As you noted, it has to know > > onto which bus a device belongs before plugging it. > > > >> > 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 > >> > > > > > -- > > Gaėtan Rivet > > 6WIND -- Gaëtan Rivet 6WIND