From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jan Blunck Subject: [PATCH v8 14/14] dev: use new hotplug API in attach Date: Fri, 30 Jun 2017 20:19:43 +0200 Message-ID: <20170630181943.23929-15-jblunck@infradead.org> References: <20170629182206.1072-1-jblunck@infradead.org> <20170630181943.23929-1-jblunck@infradead.org> Cc: gaetan.rivet@6wind.com, shreyansh.jain@nxp.com To: dev@dpdk.org Return-path: Received: from mail-wm0-f68.google.com (mail-wm0-f68.google.com [74.125.82.68]) by dpdk.org (Postfix) with ESMTP id D275F7CB9 for ; Fri, 30 Jun 2017 20:20:17 +0200 (CEST) Received: by mail-wm0-f68.google.com with SMTP id p204so9336768wmg.1 for ; Fri, 30 Jun 2017 11:20:17 -0700 (PDT) In-Reply-To: <20170630181943.23929-1-jblunck@infradead.org> List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Using the new hotplug API allows attach to be backwards compatible while decoupling it from the concrete bus implementations. Signed-off-by: Jan Blunck --- lib/librte_eal/common/eal_common_dev.c | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/lib/librte_eal/common/eal_common_dev.c b/lib/librte_eal/common/eal_common_dev.c index ede68e4..4ee52fd 100644 --- a/lib/librte_eal/common/eal_common_dev.c +++ b/lib/librte_eal/common/eal_common_dev.c @@ -67,27 +67,26 @@ static int cmp_dev_name(const struct rte_device *dev, const void *_name) int rte_eal_dev_attach(const char *name, const char *devargs) { - struct rte_pci_addr addr; + 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; - - } else { - if (rte_vdev_init(name, devargs)) - goto err; - } - - return 0; + ret = rte_eal_hotplug_add("PCI", name, devargs); + if (ret && ret != -EINVAL) + return ret; -err: - RTE_LOG(ERR, EAL, "Driver cannot attach the device (%s)\n", name); - return -EINVAL; + /* + * If we haven't found a bus device the user meant to "hotplug" a + * virtual device instead. + */ + ret = rte_vdev_init(name, devargs); + if (ret) + RTE_LOG(ERR, EAL, "Driver cannot attach the device (%s)\n", + name); + return ret; } int rte_eal_dev_detach(struct rte_device *dev) -- 2.9.4