From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from na01-by2-obe.outbound.protection.outlook.com (mail-by2on0095.outbound.protection.outlook.com [207.46.100.95]) by dpdk.org (Postfix) with ESMTP id 41E6ECB8C for ; Thu, 16 Jun 2016 16:07:13 +0200 (CEST) Received: from BY2PR03CA048.namprd03.prod.outlook.com (10.141.249.21) by CY1PR0301MB1626.namprd03.prod.outlook.com (10.162.166.28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.517.8; Thu, 16 Jun 2016 14:07:11 +0000 Received: from BL2FFO11FD048.protection.gbl (2a01:111:f400:7c09::116) by BY2PR03CA048.outlook.office365.com (2a01:111:e400:2c5d::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.517.8 via Frontend Transport; Thu, 16 Jun 2016 14:07:11 +0000 Authentication-Results: spf=fail (sender IP is 192.88.158.2) smtp.mailfrom=nxp.com; 6wind.com; dkim=none (message not signed) header.d=none;6wind.com; dmarc=none action=none header.from=nxp.com; Received-SPF: Fail (protection.outlook.com: domain of nxp.com does not designate 192.88.158.2 as permitted sender) receiver=protection.outlook.com; client-ip=192.88.158.2; helo=az84smr01.freescale.net; Received: from az84smr01.freescale.net (192.88.158.2) by BL2FFO11FD048.mail.protection.outlook.com (10.173.161.210) with Microsoft SMTP Server (TLS) id 15.1.511.7 via Frontend Transport; Thu, 16 Jun 2016 14:07:11 +0000 Received: from Tophie.ap.freescale.net (Tophie.ap.freescale.net [10.232.14.199]) by az84smr01.freescale.net (8.14.3/8.14.0) with ESMTP id u5GE6XoG026530; Thu, 16 Jun 2016 07:07:08 -0700 From: Shreyansh Jain To: CC: , , David Marchand Date: Thu, 16 Jun 2016 19:36:49 +0530 Message-ID: <1466086011-11920-16-git-send-email-shreyansh.jain@nxp.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1466086011-11920-1-git-send-email-shreyansh.jain@nxp.com> References: <1454076516-21591-1-git-send-email-david.marchand@6wind.com> <1466086011-11920-1-git-send-email-shreyansh.jain@nxp.com> X-EOPAttributedMessage: 0 X-Matching-Connectors: 131105596316470252; (91ab9b29-cfa4-454e-5278-08d120cd25b8); () X-Forefront-Antispam-Report: CIP:192.88.158.2; IPV:NLI; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10009020)(6009001)(7916002)(2980300002)(1110001)(1109001)(339900001)(199003)(189002)(229853001)(2950100001)(5003940100001)(77096005)(8936002)(92566002)(19580405001)(87936001)(68736007)(85426001)(69596002)(48376002)(19580395003)(50466002)(33646002)(50226002)(106466001)(86362001)(105606002)(575784001)(36756003)(586003)(97736004)(81156014)(81166006)(2906002)(11100500001)(110136002)(8676002)(189998001)(47776003)(6806005)(5890100001)(104016004)(5008740100001)(356003)(50986999)(76176999)(4326007)(2351001); DIR:OUT; SFP:1101; SCL:1; SRVR:CY1PR0301MB1626; H:az84smr01.freescale.net; FPR:; SPF:Fail; PTR:InfoDomainNonexistent; A:1; MX:1; CAT:NONE; LANG:en; CAT:NONE; X-Microsoft-Exchange-Diagnostics: 1; BL2FFO11FD048; 1:raNDylbdLnczYZhk8SGoDGqVwFpb6MU53fGrI4xFJh4AzDdiAZpc5nHHSi9rr2a+mj3SVkZzn+mj/YT5Gd64pS+AtZ1ZBVaID7Q5fdNiJkanZPP5oTXjETk3oWsHJ9+jov4h/fHd5YjOqNpUgm/ZDWoofoa3h/o4UNDh3JMEXRydwJSOfDLMpbiJZvJBaQ7uc1TmvvlZ9w9MwtK/3ANtDAVG+faXlvS1Ewvya2IDfG1sJUrLBq+hMj3mkvrUNcv4QpCxD7lgUdc3b9tQ7pwg0/chZtN4ytTkBRv0VyELxwi46Bv7DOTHXVep5mjuJIMyJq2utNbRQbkp2sAIUoxSBx/wfrx+kBVpY4lrihXwDiZ8TQTI8wUfcBs/g6MzphZrj7LYyX09voAD7aDGBV9Wv2iNqujlsAL0b4s3aclkSgL3nkl0LQH5N1yklLKc5zDxP0xoIekBvxNwOoypt1iy2QJzpxXEcUZggSquaXj/yfw4yCPtwzU80bADnA4CXXhiWjepPzruHLzJ5D0+ZKVdQqDE0ekfLtWkVwrjrw1mBlR7mj16tzjRb4lHtRSFnALqCBq2/zT4DN2/EKh4cu6UVQ== MIME-Version: 1.0 Content-Type: text/plain X-MS-Office365-Filtering-Correlation-Id: 940653b3-5d96-403e-4bec-08d395ef82f9 X-Microsoft-Exchange-Diagnostics: 1; CY1PR0301MB1626; 2:AE1IxjxVEPMKvmDck1SGxwMWL4MDLwA+3sG/pv/nbL2tXbeyO4sy37yo6CIwbMCYxe9Ga4VdBSFxjvR3dQxC5HlTNgdbie0XMwHoFSZ0l7YsMSb1lTT0eYTb2iOlE9dQxlo/RCP3ZgTk4JLiolKXEu4FE29dEdoxLQyqyyAl1GVvIxJGgIfBwQVjquqHDBEk; 3:Nqbb3nbvib92qAA4ympSDnelA5mzUuHc6ibXPsX4j15pGInr1QCIuAlKdmptD8f7EqBVjalT/5JEWyntDiXKx4vpC3Fyxw6WmB2lBeik9zXNcvn/VeRdRRSSnTiLa0HabEl9I4A5DlX1rP217noI3r15ROiRPyO0rxryV0N0iV0X9sG1d6oEqmUF17JpAH8fqDlwNSlCDXC6bTQLoaOodDpejczfG1PSuSFLnNqonac=; 25:m9wbEnrhOi6scwQHoK5GI6tHplO+KZpexmxwIBpFvAIssq0UaZuMUYEQc1P8Bk5ClAy9jzuVM9fLch+/+vaJ2ldSXKzSW5RAu4uGjr6jlBg4RvfRbapCi6SiEGtFlVXHqN9eAtcdyKk+iW9yYkI1TjmX+VM6xZEeUmd2uecHvyGuOKlqO0AZjai9sTg/Xh97L6pROxuD9g7MxMS3yPRLC41jriCAEdm68yxUkFeQLPYXkDpiFlraRZbKqVrcpdeDj61zsFftr5ylDbHL2RFryKZ7V6ze+eQtH7OG4KwxP7rXPI22bjUmVDZMeyPGRA9QvpO0pFvxGYdA5ctvbn5u6RF03DVbwam+tFP5hEppS2pZyA+hffmN5uCL/NJUEv/wEFJwSNBbt0lcX4+AYr29EDSVYsDXWvC6oozhUHVdSkw= X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:CY1PR0301MB1626; X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(13018025)(13023025)(13017025)(13024025)(13015025)(8121501046)(5005006)(3002001)(10201501046)(6055026); SRVR:CY1PR0301MB1626; BCL:0; PCL:0; RULEID:(400006); SRVR:CY1PR0301MB1626; X-Microsoft-Exchange-Diagnostics: 1; CY1PR0301MB1626; 4:V95OtrYk+HuiMbyB1EJONa2TPY0WAuX+wIEQj5YEBQzJ0R5MzR8grNCDVMYe8Yx2DzCXNUzZVnaJTN8uBzilsQn0MKs61Lmx8wL0SS4c4tVZzWFdE4OXKLOh4/ZNrjulFofK8PCrYkSnRiK2bnRXJsQUTUyaAnG7W31BKheNBNcgAwsCtyusC2nAXy0Ko4T5RTDfCB/byEzYGG/y2ygwX2il7wLkMxyTZqAvbOrfHoozOgiaHHuNrTUCe2X/MM8Od3foCXIn0QMM5d0ScI6W+VQMMkK0zphiML0Hpf7osLp1LvKrNyX4zjnL0zMqkAAzEEtXhevxIsbRl0RgQ0gI/H5Z0UXmdNvXHLCva/jEuHEcBhta/zGOco+xEbfjMmnuDZQc5vT7+UQ4D5W/ITSqzCDIAbm994UKxC1GEgjhx9XhlbxEJXMiaVBbGvQjff/rKvW8gvrW0Vp0CMjy3ofw9mSrSQ/23KuM9ItMWItPVwM= X-Forefront-PRVS: 09752BC779 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; CY1PR0301MB1626; 23:cj9hyjeaiqIyrW8rXfPqVwas7xSHynZbiif4sLN?= =?us-ascii?Q?2Yjeqyf5o1UU9PYuexeU4mYH23qo2+DCZJAok40IbkGWS8PL9qrGIoh2WUX7?= =?us-ascii?Q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hKscbQNJ5lZPHWKxQcuyrYpyBXPpIkCjx4Sma84KyigrKcpdxlPyX00g8A1PHhBYMS1oDZc0tayI4Wl5Q== SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Jun 2016 14:07:11.4286 (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.158.2]; Helo=[az84smr01.freescale.net] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY1PR0301MB1626 Subject: [dpdk-dev] [PATCH v3 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: Thu, 16 Jun 2016 14:07:14 -0000 From: David Marchand 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 | 2 ++ 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 | 2 ++ 4 files changed, 68 insertions(+) diff --git a/lib/librte_eal/bsdapp/eal/rte_eal_version.map b/lib/librte_eal/bsdapp/eal/rte_eal_version.map index f8c3dea..e776768 100644 --- a/lib/librte_eal/bsdapp/eal/rte_eal_version.map +++ b/lib/librte_eal/bsdapp/eal/rte_eal_version.map @@ -156,5 +156,7 @@ DPDK_16.07 { global: pci_get_sysfs_path; + 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 3d0ff93..50b774b 100644 --- a/lib/librte_eal/linuxapp/eal/rte_eal_version.map +++ b/lib/librte_eal/linuxapp/eal/rte_eal_version.map @@ -159,5 +159,7 @@ DPDK_16.07 { global: pci_get_sysfs_path; + rte_eal_dev_attach; + rte_eal_dev_detach; } DPDK_16.04; -- 2.7.4