From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM02-CY1-obe.outbound.protection.outlook.com (mail-cys01nam02on0062.outbound.protection.outlook.com [104.47.37.62]) by dpdk.org (Postfix) with ESMTP id A70455A50 for ; Fri, 26 Aug 2016 15:57:59 +0200 (CEST) Received: from BN6PR03CA0042.namprd03.prod.outlook.com (10.175.124.28) by DM2PR0301MB0718.namprd03.prod.outlook.com (10.160.97.139) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA_P384) id 15.1.557.21; Fri, 26 Aug 2016 13:57:57 +0000 Received: from BY2FFO11OLC013.protection.gbl (2a01:111:f400:7c0c::158) by BN6PR03CA0042.outlook.office365.com (2603:10b6:404:10c::28) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA_P384) id 15.1.557.21 via Frontend Transport; Fri, 26 Aug 2016 13:57:56 +0000 Authentication-Results: spf=fail (sender IP is 192.88.168.50) smtp.mailfrom=nxp.com; nxp.com; dkim=none (message not signed) header.d=none;nxp.com; dmarc=fail action=none header.from=nxp.com;nxp.com; dkim=none (message not signed) header.d=none; Received-SPF: Fail (protection.outlook.com: domain of nxp.com does not designate 192.88.168.50 as permitted sender) receiver=protection.outlook.com; client-ip=192.88.168.50; helo=tx30smr01.am.freescale.net; Received: from tx30smr01.am.freescale.net (192.88.168.50) by BY2FFO11OLC013.mail.protection.outlook.com (10.1.15.25) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.587.6 via Frontend Transport; Fri, 26 Aug 2016 13:57:57 +0000 Received: from Tophie.ap.freescale.net ([10.232.14.87]) by tx30smr01.am.freescale.net (8.14.3/8.14.0) with ESMTP id u7QDvHpn023630; Fri, 26 Aug 2016 06:57:54 -0700 From: Shreyansh Jain To: CC: , , , , Shreyansh Jain Date: Fri, 26 Aug 2016 19:26:50 +0530 Message-ID: <1472219823-29486-13-git-send-email-shreyansh.jain@nxp.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1472219823-29486-1-git-send-email-shreyansh.jain@nxp.com> References: <1466510566-9240-1-git-send-email-shreyansh.jain@nxp.com> <1472219823-29486-1-git-send-email-shreyansh.jain@nxp.com> X-EOPAttributedMessage: 0 X-Matching-Connectors: 131166934780801944; (91ab9b29-cfa4-454e-5278-08d120cd25b8); () X-Forefront-Antispam-Report: CIP:192.88.168.50; IPV:NLI; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10009020)(6009001)(7916002)(2980300002)(1110001)(1109001)(339900001)(199003)(189002)(5003940100001)(8676002)(85426001)(92566002)(36756003)(77096005)(5660300001)(8936002)(2950100001)(19580395003)(356003)(8666005)(305945005)(19580405001)(50226002)(81166006)(106466001)(7846002)(586003)(68736007)(50986999)(575784001)(86362001)(33646002)(87936001)(2351001)(76176999)(626004)(110136002)(229853001)(189998001)(104016004)(2906002)(81156014)(47776003)(50466002)(5890100001)(48376002)(4326007)(97736004)(105606002)(7059030); DIR:OUT; SFP:1101; SCL:1; SRVR:DM2PR0301MB0718; H:tx30smr01.am.freescale.net; FPR:; SPF:Fail; PTR:InfoDomainNonexistent; A:1; MX:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BY2FFO11OLC013; 1:PwYWTro6MhiC/IcgqrY9hHZbV+OACr3932yaJMAH4Ox3GDwr+guq6dyYiePvQV5DCYo0kvZ4oGO4yXhCPAGvOIwD42H6uziAu9/LmL5sj2nBttPAzURoeOC0nuDth1WRqgWlaSzdaBpD99Onm/KkPOJXCqftm9dKtyCiT/0g4RfRhlhYkLA7ibzDadoV1pv2Ah2Yfq9oyXtCoTc8VAD9+DtFAozCdBPIG4kL/v5MabqOohrWuSyH7lrFfm7wR9rTTAKQTHIp6Q8JOqILAXEFs7pcyC/jAjIhoFQh06vqiy1rn5Olq3FaevXnFeceSwpQpBAO23R3tr9NGwFTYutMJ+LALN5+exyBfIMuM3WyV977Ir3NR+gva49nHcN1OtHAu1ayjR8QMRH5G+sp7OyBKCf4NkLgJkoEaQckSFX2FyIUU2+aemVXwxYreZKxKRjineZXnXlBuRGYaa/x85HJsSjV9XPg9K+G+KlmnonU2FeZdE9IPSxv6gMKMSpfAqKlU7/HG5GvIIh/YaI7odbUEe4j8SoWMZuhZqwMOIxtZOFMmSiVG+Tql5tAd59Bzf3h0fRJHaDsOzCPjmTpWIQgzULXJYSVAKrV1cJAnUyzZiBWX9acpv5BcSC2Uwqe9/Ix8sl51n3jwT15SVOAYm9SBXPtiZFbGuI7bgDrh5DTyUvLuG3NfG15lKAEmGZu0HKbYeNsHXWa/vgGw31SJNiyoyBOYWEUXTrPYHLEtTx1Mnk= MIME-Version: 1.0 Content-Type: text/plain X-MS-Office365-Filtering-Correlation-Id: 0a640542-3b90-4674-f398-08d3cdb8fc59 X-Microsoft-Exchange-Diagnostics: 1; DM2PR0301MB0718; 2:JmpTrQ6t+OJJEQ21CYnT3ZwswTpVYhwXZ3W8eQHvocUgD5yHvaXejWwg9U0kEiA4iuuUxS6xWUeu47n6x/APr0TRtGd6B5TtPi89c2B3lO4huHvThuzTFe3toypNiLTNtCCCiIbLNnFxmlQwiaMUOAQ9FkhsoeREclNFfbwJCD1uZHEMuEBNwkcfC4HqbWM2; 3:6QEuujsTx2DfZOuZM26X4VqXv/KLp/wv7YVkki6AVwAUs05xgP5Pb+e0xDR2HzmIAoCJbs9et5T2SfIuesBWvVPWEXFgrhRsXa3CxzbcdR/lttiVA4UhC8w/Q3V5RbP1YusvgF4YuEqe+mtEIWy9tQWwgY7LLpbXijFh+3MuhaV/TqkiUGOwEjGpPPnUxrQWqlRm0ZUziD9s8/yXWGeX3aIOq2arNU54+YkfsNEE840= X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:DM2PR0301MB0718; X-Microsoft-Exchange-Diagnostics: 1; DM2PR0301MB0718; 25:5I4rvET9f+rGS2wwwA2C0pZxh1G22rl2ABJxvUJcgH3vLtX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2Dlb/6Ab1Bdtv30J9DVzovMfONH9dIdWOHbVC76pDhhC0HSKCgpr9+dBMjskkIj8B//QbzyeHex8XiHe8RYoy1JdnrJlS5xI4Q0ISXUGi2DHuF0ubNuiLqEp0OD2qbr138EXq+3zwMmbmwA6Nh9CWSl7rjEhs7CEiye2jZ17fPQmk753CTyRGhuX2U16lt5kMLXnDd9SauU7bYdWTdaMFjx90qiUlq/Xyi04p4/VES+QEi0kGGNw+fkyy997lL1xyiJRql1nboUOOo6t/PFrKu+Dei9/mOW85IiRowHIPXeO3qJxgjgL3uNYEUF3n+g+peKYgcTESuCWjolJJp+jHB7F1EZK1DPdv1N4xG7m2M0tUI0brTugbI5YkTyXjs+dMyMs6R5piOuOCGcjx9gYCtVK/3D5TBlFgcUeK6I3LL/Thrvoy54Ul8sYQzQQlK3R5SnjtcjOzoDzX2Owu6c33yCcFHH+1TH4UtmIBr+PBnoAwJj/U= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(185117386973197); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040176)(601004)(2401047)(13015025)(13023025)(13024025)(13018025)(13017025)(8121501046)(5005006)(10201501046)(3002001)(6055026); SRVR:DM2PR0301MB0718; BCL:0; PCL:0; RULEID:(400006); SRVR:DM2PR0301MB0718; X-Forefront-PRVS: 00462943DE X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; DM2PR0301MB0718; 23:4sxg2n1wN65F3UXNBqsKfTL/rjO/gzh9ktmpOA/?= =?us-ascii?Q?0TwxGV9GCjjcQ/bQ7ZiGK1qBfAO5JC+dH4CLgeGq2gFmzBiD7P6nGmIEwo3v?= =?us-ascii?Q?hjUCDU5WL7accBQ/wobhqYqDF7Y9MtZQ5KTAA0oLDcADVy0i86+eYC5bFKgk?= =?us-ascii?Q?DYiJ7tXYzpbaixlZXKyOrB4sPtNCn5C8tTSyq0lokOiGpuoDAI/uj/nBmW7a?= =?us-ascii?Q?2zEegaL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riginalArrivalTime: 26 Aug 2016 13:57:57.8773 (UTC) X-MS-Exchange-CrossTenant-Id: 5afe0b00-7697-4969-b663-5eab37d5f47e X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=5afe0b00-7697-4969-b663-5eab37d5f47e; Ip=[192.88.168.50]; Helo=[tx30smr01.am.freescale.net] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM2PR0301MB0718 Subject: [dpdk-dev] [PATCH v8 12/25] 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: Fri, 26 Aug 2016 13:58:00 -0000 Hotplug invocations, which deals with devices, 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 Signed-off-by: Shreyansh Jain --- lib/librte_eal/bsdapp/eal/rte_eal_version.map | 7 ++++ lib/librte_eal/common/eal_common_dev.c | 48 +++++++++++++++++++++++++ lib/librte_eal/common/include/rte_dev.h | 26 ++++++++++++++ lib/librte_eal/linuxapp/eal/rte_eal_version.map | 7 ++++ 4 files changed, 88 insertions(+) diff --git a/lib/librte_eal/bsdapp/eal/rte_eal_version.map b/lib/librte_eal/bsdapp/eal/rte_eal_version.map index a335e04..7b3d409 100644 --- a/lib/librte_eal/bsdapp/eal/rte_eal_version.map +++ b/lib/librte_eal/bsdapp/eal/rte_eal_version.map @@ -162,3 +162,10 @@ DPDK_16.07 { rte_thread_setname; } DPDK_16.04; + +DPDK_16.11 { + global: + + rte_eal_dev_attach; + rte_eal_dev_detach; +} DPDK_16.07; diff --git a/lib/librte_eal/common/eal_common_dev.c b/lib/librte_eal/common/eal_common_dev.c index a8a4146..88f9d3f 100644 --- a/lib/librte_eal/common/eal_common_dev.c +++ b/lib/librte_eal/common/eal_common_dev.c @@ -150,3 +150,51 @@ 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; + + 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_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 (%s)\n", name); + return -EINVAL; +} + +int rte_eal_dev_detach(const char *name) +{ + struct rte_pci_addr addr; + + if (name == NULL) { + RTE_LOG(ERR, EAL, "Invalid device provided.\n"); + return -EINVAL; + } + + 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 (%s)\n", name); + return -EINVAL; +} diff --git a/lib/librte_eal/common/include/rte_dev.h b/lib/librte_eal/common/include/rte_dev.h index 994650b..a4f08b5 100644 --- a/lib/librte_eal/common/include/rte_dev.h +++ b/lib/librte_eal/common/include/rte_dev.h @@ -178,6 +178,32 @@ int rte_eal_vdev_init(const char *name, const char *args); */ int rte_eal_vdev_uninit(const char *name); +/** + * Attach a device to a registered driver. + * + * @param name + * The device name, that refers to a pci device (or some private + * way of designating a vdev device). Based on this device name, eal + * will identify a driver capable of handling it and pass it 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 device from its driver. + * + * @param name + * Same description as for rte_eal_dev_attach(). + * Here, eal will call the driver detaching function. + * @return + * 0 on success, negative on error. + */ +int rte_eal_dev_detach(const char *name); + #define DRIVER_EXPORT_NAME_ARRAY(n, idx) n##idx[] #define DRIVER_EXPORT_NAME(name, idx) \ diff --git a/lib/librte_eal/linuxapp/eal/rte_eal_version.map b/lib/librte_eal/linuxapp/eal/rte_eal_version.map index db8c984..c0bd391 100644 --- a/lib/librte_eal/linuxapp/eal/rte_eal_version.map +++ b/lib/librte_eal/linuxapp/eal/rte_eal_version.map @@ -166,3 +166,10 @@ DPDK_16.07 { rte_thread_setname; } DPDK_16.04; + +DPDK_16.11 { + global: + + rte_eal_dev_attach; + rte_eal_dev_detach; +} DPDK_16.07; -- 2.7.4