From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by dpdk.org (Postfix) with ESMTP id 777CA2C8 for ; Tue, 27 Jun 2017 15:58:59 +0200 (CEST) Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 27 Jun 2017 06:58:58 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.39,399,1493708400"; d="scan'208";a="101925865" Received: from bricha3-mobl3.ger.corp.intel.com ([10.237.221.28]) by orsmga004.jf.intel.com with SMTP; 27 Jun 2017 06:58:56 -0700 Received: by (sSMTP sendmail emulation); Tue, 27 Jun 2017 14:58:55 +0100 Date: Tue, 27 Jun 2017 14:58:55 +0100 From: Bruce Richardson To: Gaetan Rivet Cc: dev@dpdk.org, Jan Blunck Message-ID: <20170627135855.GI104744@bricha3-MOBL3.ger.corp.intel.com> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Organization: Intel Research and =?iso-8859-1?Q?De=ACvel?= =?iso-8859-1?Q?opment?= Ireland Ltd. User-Agent: Mutt/1.8.1 (2017-04-11) Subject: Re: [dpdk-dev] [PATCH v5 12/12] eal: make virtual driver probe and remove take rte_vdev_device 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 13:59:00 -0000 On Mon, Jun 26, 2017 at 02:22:10AM +0200, Gaetan Rivet wrote: > From: Jan Blunck > > This is a preparation to embed the generic rte_device into the rte_eth_dev > also for virtual devices. > > Signed-off-by: Jan Blunck > Signed-off-by: Gaetan Rivet > --- > lib/librte_eal/common/eal_common_dev.c | 93 ++++++++++++++++++++++++++-------- > 1 file changed, 71 insertions(+), 22 deletions(-) > > diff --git a/lib/librte_eal/common/eal_common_dev.c b/lib/librte_eal/common/eal_common_dev.c > index a400ddd..d83ae41 100644 > --- a/lib/librte_eal/common/eal_common_dev.c > +++ b/lib/librte_eal/common/eal_common_dev.c > @@ -37,6 +37,7 @@ > #include > #include > > +#include > #include > #include > #include > @@ -45,50 +46,98 @@ > > #include "eal_private.h" > > +static int cmp_detached_dev_name(const struct rte_device *dev, > + const void *_name) > +{ > + const char *name = _name; > + > + /* skip attached devices */ > + if (dev->driver) > + return 0; > + Does returning 0 from this function not mean that all already-attached devices with match? Is that really what we want, as it doesn't seem to match the logic in the function below. Please explain if I'm wrong here. > + return strcmp(dev->name, name); > +} > + > int rte_eal_dev_attach(const char *name, const char *devargs) > { > - struct rte_pci_addr addr; > + struct rte_device *dev; > + int ret; > > if (name == NULL || devargs == NULL) { > RTE_LOG(ERR, EAL, "Invalid device or arguments provided\n"); > return -EINVAL; > } > > - if (eal_parse_pci_DomBDF(name, &addr) == 0) { > - if (rte_pci_probe_one(&addr) < 0) > - goto err; > + dev = rte_bus_find_device(cmp_detached_dev_name, name, NULL); > + if (dev) { > + struct rte_bus *bus; > + > + bus = rte_bus_find_by_device(dev); > + if (!bus) { > + RTE_LOG(ERR, EAL, "Cannot find bus for device (%s)\n", > + name); > + return -EINVAL; > + } > > - } else { > - if (rte_vdev_init(name, devargs)) > - goto err; > + if (!bus->plug) { > + RTE_LOG(ERR, EAL, "Bus function not supported\n"); > + return -ENOTSUP; > + } > + > + ret = (bus->plug(dev->devargs) == NULL); > + goto out; > } > > - return 0; > + /* > + * If we haven't found a bus device the user meant to "hotplug" a > + * virtual device instead. > + */ > + ret = rte_vdev_init(name, devargs); > +out: > + if (ret) > + RTE_LOG(ERR, EAL, "Driver cannot attach the device (%s)\n", > + name); > + return ret; > +} > + Regards, /Bruce