From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm0-f50.google.com (mail-wm0-f50.google.com [74.125.82.50]) by dpdk.org (Postfix) with ESMTP id 6CB24569A for ; Wed, 20 Apr 2016 13:44:38 +0200 (CEST) Received: by mail-wm0-f50.google.com with SMTP id e201so47238214wme.0 for ; Wed, 20 Apr 2016 04:44:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=6wind-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=ImrtE2HGQUC0jNVJ/oUfVgHaCP5Hg+PNrd3HzTUhSHg=; b=DOk1wzJn3PNEsMkZaE6nbNCerpFMKam3RUfClpA+0Mwr0SCFjwqVYsRomskVTjcwRJ m2jaOrPTdLWnrNHsDYprk6XX8fcMP9x+c4n6hn5TWeaiiU9kq99L3B9MzDVwY4Pq+ux8 Mxj8wx9AjQ4wFrgdb/pw9IPM26aaEGfS2SPIXmtRrTC71qpj6My4Qht/8B00ar5uADLu u8pC4l/stMxRAQwZg1OXk7hvcH4SU9YcQxObJWQ7wGSxhO8FG405tYP8Vtu2cNWY9ydh M+IN1WdK+F0XbIHAHf5J4DuWqqPzcsB4DGOzuht6DnkyTnRXD+gBghDv7rzZzR7mVh2x GbIg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=ImrtE2HGQUC0jNVJ/oUfVgHaCP5Hg+PNrd3HzTUhSHg=; b=d69vd63VPMPv7upsFT2yI0/103dawq3IgeYqjOSEtjkmvCCOW7yOHiuMLdMv8v+Ozk 81CSn7rNtGwthPX6BrrBeO7dj/lq1t3R+gTotet77/vyEGGyoxWQ6qm9y1c4GHXzHvPq Z6E8WJgSbfyRPjcE48HYfSC7kjA64rVMoSA1bllbyX+8SsnSScdZ6Y+KXA5dvL8rATzF BpUqglGmmU2+vFXOfNCPmnT6p7eJspG77yNJglxw5yeGwPK+Oh4GD4HAzOYQzLZrpbgO WSkuNMB5AHWe17iVe3rjXbAYdoYhLPDw9L40hNfH1x+alfv/m7eW+04gBbebi1T24PCB Hu+w== X-Gm-Message-State: AOPr4FU0uF1+2xJ9YUfw6+iBwFjfQY+ijAg42NDH8cNCtoEEAtbJbA/FHrkN9QSoeXnFH+yU X-Received: by 10.28.141.18 with SMTP id p18mr8586971wmd.57.1461152678296; Wed, 20 Apr 2016 04:44:38 -0700 (PDT) Received: from gloops.dev.6wind.com (144.77.126.78.rev.sfr.net. [78.126.77.144]) by smtp.gmail.com with ESMTPSA id m6sm5195708wje.21.2016.04.20.04.44.37 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 20 Apr 2016 04:44:37 -0700 (PDT) From: David Marchand To: dev@dpdk.org Cc: thomas.monjalon@6wind.com, viktorin@rehivetech.com Date: Wed, 20 Apr 2016 13:44:15 +0200 Message-Id: <1461152657-19969-16-git-send-email-david.marchand@6wind.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1461152657-19969-1-git-send-email-david.marchand@6wind.com> References: <1454076516-21591-1-git-send-email-david.marchand@6wind.com> <1461152657-19969-1-git-send-email-david.marchand@6wind.com> Subject: [dpdk-dev] [PATCH v2 15/17] eal: add hotplug operations for pci and vdev X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 20 Apr 2016 11:44:38 -0000 hotplug which deals with resources should come from the layer that already handles them, i.e. eal. For both attach and detach operations, 'name' is used to select the bus that will handle the request. Signed-off-by: David Marchand --- lib/librte_eal/bsdapp/eal/rte_eal_version.map | 8 +++++ lib/librte_eal/common/eal_common_dev.c | 39 +++++++++++++++++++++++++ lib/librte_eal/common/include/rte_dev.h | 25 ++++++++++++++++ lib/librte_eal/linuxapp/eal/rte_eal_version.map | 8 +++++ 4 files changed, 80 insertions(+) diff --git a/lib/librte_eal/bsdapp/eal/rte_eal_version.map b/lib/librte_eal/bsdapp/eal/rte_eal_version.map index 58c2951..4d075df 100644 --- a/lib/librte_eal/bsdapp/eal/rte_eal_version.map +++ b/lib/librte_eal/bsdapp/eal/rte_eal_version.map @@ -151,3 +151,11 @@ DPDK_16.04 { rte_eal_primary_proc_alive; } DPDK_2.2; + +DPDK_16.07 { + global: + + rte_eal_dev_attach; + rte_eal_dev_detach; + +} DPDK_16.04; diff --git a/lib/librte_eal/common/eal_common_dev.c b/lib/librte_eal/common/eal_common_dev.c index a8a4146..59ed3a0 100644 --- a/lib/librte_eal/common/eal_common_dev.c +++ b/lib/librte_eal/common/eal_common_dev.c @@ -150,3 +150,42 @@ rte_eal_vdev_uninit(const char *name) RTE_LOG(ERR, EAL, "no driver found for %s\n", name); return -EINVAL; } + +int rte_eal_dev_attach(const char *name, const char *devargs) +{ + struct rte_pci_addr addr; + int ret = -1; + + if (eal_parse_pci_DomBDF(name, &addr) == 0) { + if (rte_eal_pci_probe_one(&addr) < 0) + goto err; + + } else { + if (rte_eal_vdev_init(name, devargs)) + goto err; + } + + return 0; + +err: + RTE_LOG(ERR, EAL, "Driver, cannot attach the device\n"); + return ret; +} + +int rte_eal_dev_detach(const char *name) +{ + struct rte_pci_addr addr; + + if (eal_parse_pci_DomBDF(name, &addr) == 0) { + if (rte_eal_pci_detach(&addr) < 0) + goto err; + } else { + if (rte_eal_vdev_uninit(name)) + goto err; + } + return 0; + +err: + RTE_LOG(ERR, EAL, "Driver, cannot detach the device\n"); + return -1; +} diff --git a/lib/librte_eal/common/include/rte_dev.h b/lib/librte_eal/common/include/rte_dev.h index 85e48f2..b1c0520 100644 --- a/lib/librte_eal/common/include/rte_dev.h +++ b/lib/librte_eal/common/include/rte_dev.h @@ -178,6 +178,31 @@ int rte_eal_vdev_init(const char *name, const char *args); */ int rte_eal_vdev_uninit(const char *name); +/** + * Attach a resource to a registered driver. + * + * @param name + * The resource name, that refers to a pci resource or some private + * way of designating a resource for vdev drivers. Based on this + * resource name, eal will identify a driver capable of handling + * this resource and pass this resource to the driver probing + * function. + * @param devargs + * Device arguments to be passed to the driver. + * @return + * 0 on success, negative on error. + */ +int rte_eal_dev_attach(const char *name, const char *devargs); + +/** + * Detach a resource from its driver. + * + * @param name + * Same description as for rte_eal_dev_attach(). + * Here, eal will call the driver detaching function. + */ +int rte_eal_dev_detach(const char *name); + #define PMD_REGISTER_DRIVER(d)\ RTE_INIT(devinitfn_ ##d);\ static void devinitfn_ ##d(void)\ diff --git a/lib/librte_eal/linuxapp/eal/rte_eal_version.map b/lib/librte_eal/linuxapp/eal/rte_eal_version.map index 12503ef..0404a52 100644 --- a/lib/librte_eal/linuxapp/eal/rte_eal_version.map +++ b/lib/librte_eal/linuxapp/eal/rte_eal_version.map @@ -154,3 +154,11 @@ DPDK_16.04 { rte_eal_primary_proc_alive; } DPDK_2.2; + +DPDK_16.07 { + global: + + rte_eal_dev_attach; + rte_eal_dev_detach; + +} DPDK_16.04; -- 1.9.1