From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm0-f47.google.com (mail-wm0-f47.google.com [74.125.82.47]) by dpdk.org (Postfix) with ESMTP id 17E582A58 for ; Tue, 4 Jul 2017 14:28:43 +0200 (CEST) Received: by mail-wm0-f47.google.com with SMTP id w126so194470947wme.0 for ; Tue, 04 Jul 2017 05:28:43 -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=M7PiyZhTbFh7Rd5CmfeYOAixlN3BWQFQvrLY4jQFIIg=; b=J6UXsYtKRQZ6jTm74cP9HpR3g6jtEJLdhIjtcivH/Uzysmq03SlNS37ALaq2iVZ5bb JN9WIkiZHI1MalOKi8VlvoWeidjTwltT243BrT0UBQC7BkCanWREpklph2hpJ7ODMy2i l7Zsd9tMbiBORlFf2r3Fe02tC6fJnm1Y9Xv9lUiiDPNEHmE5hgXGNRCArkSwly0VtR/Y KeqSesqCxLE+EBUX9n+BX11d2kOYxZ8N/YzFwwQnjsT0OKlcz7MAbt81mqdru1AjBSx5 JnJrA0+WxXZt66fliYu+fCaNu4+GPyUO/9W7nLBReFmFg39TB8XFsAAb7h5YLvyd1V+I 6LnA== 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=M7PiyZhTbFh7Rd5CmfeYOAixlN3BWQFQvrLY4jQFIIg=; b=SVnCJ/w64kchaLcK2tK5RAy8heu1vocJUPEAJEzMwD7ayrPJMF2iHXNX+D2DTEZgti useEmAORfqPdjwnAE9btneVjQlRr3OWCpdcnczxweZlUUXfWh2ZJ6R9MGu70cKAAI1Cg cGAqtDz3phUiKwW+YSAiA4AdqCsylEbit42WbLa3F18uc3e2y0JPQ2utLczyR2nG0gIH GET8mg05VGj8goXNfEJyNvJuYYcIoMBJAl2r+TX7ODdB7jm1/uF6Br5X9cwaDIgIAArA XQwDp9tbBO0qpJLSG0HBVVG8fVLGFvJ5qDVwBGYyr1Yfv2fjVlYMKoCHgtQTOnXMFnl1 Id1A== X-Gm-Message-State: AKS2vOxhOD3Wzc4OGDVcQVVPAHKl/qy58r3xiIVPm3KSA357PwHayJ2k qbDc5Pahc36jfGiwKjk= X-Received: by 10.28.218.149 with SMTP id r143mr26346728wmg.74.1499171323115; Tue, 04 Jul 2017 05:28:43 -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 x5sm12442987wrd.50.2017.07.04.05.28.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 04 Jul 2017 05:28:42 -0700 (PDT) Date: Tue, 4 Jul 2017 14:28:34 +0200 From: =?iso-8859-1?Q?Ga=EBtan?= Rivet To: dev@dpdk.org Cc: Jan Blunck , Stephen Hemminger , Bruce Richardson , Gowrishankar Message-ID: <20170704122834.GC11154@bidouze.vm.6wind.com> References: <69856355c46d84d0e0d992afdd2e1dc07ee49c19.1499127915.git.gaetan.rivet@6wind.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <69856355c46d84d0e0d992afdd2e1dc07ee49c19.1499127915.git.gaetan.rivet@6wind.com> User-Agent: Mutt/1.5.23 (2014-03-12) Subject: Re: [dpdk-dev] [PATCH v6 5/6] 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, 04 Jul 2017 12:28:44 -0000 I made this API private, however we can see the bonding PMD could use this kind of facility: http://dpdk.org/ml/archives/dev/2017-July/070087.html I know the failsafe could leverage this, as well as another bus idea I threw together a few weeks ago[1]. So maybe I should make it public? This can always be fixed past-integration though, and I'd prefer being able to go forward on the PCI move. [1]: http://dpdk.org/ml/archives/dev/2017-June/067546.html On Tue, Jul 04, 2017 at 02:58:32AM +0200, 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/common/eal_common_bus.c | 15 +++++++++++++++ > lib/librte_eal/common/eal_private.h | 12 ++++++++++++ > 2 files changed, 27 insertions(+) > > diff --git a/lib/librte_eal/common/eal_common_bus.c b/lib/librte_eal/common/eal_common_bus.c > index 87b0c6e..b143f21 100644 > --- a/lib/librte_eal/common/eal_common_bus.c > +++ b/lib/librte_eal/common/eal_common_bus.c > @@ -204,3 +204,18 @@ rte_bus_find_by_name(const char *busname) > { > return rte_bus_find(NULL, cmp_bus_name, (const void *)busname); > } > + > +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_find_by_device_name(const char *str) > +{ > + return rte_bus_find(NULL, bus_can_parse, str); > +} > diff --git a/lib/librte_eal/common/eal_private.h b/lib/librte_eal/common/eal_private.h > index 6cacce0..0836339 100644 > --- a/lib/librte_eal/common/eal_private.h > +++ b/lib/librte_eal/common/eal_private.h > @@ -338,4 +338,16 @@ int rte_eal_hugepage_attach(void); > */ > bool rte_eal_using_phys_addrs(void); > > +/** > + * 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_find_by_device_name(const char *str); > + > #endif /* _EAL_PRIVATE_H_ */ > -- > 2.1.4 > -- Gaëtan Rivet 6WIND