From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm0-f67.google.com (mail-wm0-f67.google.com [74.125.82.67]) by dpdk.org (Postfix) with ESMTP id 8063F2C02 for ; Thu, 8 Jun 2017 12:45:18 +0200 (CEST) Received: by mail-wm0-f67.google.com with SMTP id g15so6647524wmc.2 for ; Thu, 08 Jun 2017 03:45:18 -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:content-transfer-encoding; bh=ycm3guVx4UQZJsqbquFmDwYPYUSYEyHitAov0auVPcs=; b=JSrYaFda8dQ8MT5CW9E2lJUt0mV4QWuOjzbOsa4dd838JrpBgrmhjNS3sDFC1elV6w yWtXwrXgfoABFnRBcwVXk0AAlV5mE40cON4yGFg6kFY7MTPukxLDY2KkMUW9bO+lHRXB 9/JzM2vfK6vhg+cmLoZIMK3qATaySB2q7uMVHs9jbk9eKfS9ZcIdgVoowRQC2TPTQUv8 YmlQruZFXcPZjBVmA6qR623Dms3d+JEqjO2O+iIMwaFlPqnL7vVTMgy7O1SJ+O6jyVVw 70/uMGFZo7SAyIcMoMW4SnjQqcVvGC8MZWCz33QfOzjX4f19zHVXX3tDiKKPWpy56Fne JdqA== 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:content-transfer-encoding; bh=ycm3guVx4UQZJsqbquFmDwYPYUSYEyHitAov0auVPcs=; b=dqVP72rUxh2z+KzYHdhtvU69Sqo71GNagHkKAJfejn7MSF+kJYun0qvjYBaRCt62bW R+dm2+rep9lV9rxRVx6ZNHmYZ/LfD4/LnHSG9HzPIuNX6QcJBr8RExc7sgCl8anE6sQq JkyJ5lMZBwb4l379+0Xuba6ZYZfsvdRKbXLHX//MNyQ3+hjrLrCgh9IENIIr2Fc7QXyD NMfreUf/SBJtoc8uPDBOb/EMI630SxoLQ4ZgnfdsNvpRkrQcZgOWeHyg++bHAG3RXHHi oUAaxJA2Zu1f2vp31rBF4U+wCFnnLscCiC6oEsufLbW3j+u01WOFw5BI6Okhjxgw+Z3g Gvmw== X-Gm-Message-State: AODbwcCFqQ88pzcEBGI0iHOc22+RXTRntGFriJXvQhmTh+GPNWL31dyi GERpWYnsx2Qpub/Dq+zA4j2sp7WpRcLAINo= X-Received: by 10.28.109.210 with SMTP id b79mr2847839wmi.55.1496918718004; Thu, 08 Jun 2017 03:45:18 -0700 (PDT) MIME-Version: 1.0 Sender: jblunck@gmail.com Received: by 10.28.25.65 with HTTP; Thu, 8 Jun 2017 03:45:17 -0700 (PDT) In-Reply-To: <20170607200331.GU18840@bidouze.vm.6wind.com> References: <1a54f0dd79200960921ca495aa7381817a599bc0.1495629122.git.gaetan.rivet@6wind.com> <20170607200331.GU18840@bidouze.vm.6wind.com> From: Jan Blunck Date: Thu, 8 Jun 2017 12:45:17 +0200 X-Google-Sender-Auth: zyR3JkTHIIy1-WQFBm4jysVtY9Y Message-ID: To: =?UTF-8?Q?Ga=C3=ABtan_Rivet?= Cc: dev , Stephen Hemminger , Maxime Coquelin , Jerin Jacob , David Marchand Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable 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 10:45:18 -0000 On Wed, Jun 7, 2017 at 10:03 PM, Ga=C3=ABtan 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 w= rote: >> > Find which bus should be able to parse this device name into an intern= al >> > 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. > 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/librt= e_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/c= ommon/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 =3D _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 stru= ct 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/lib= rte_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=C4=97tan Rivet > 6WIND