From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM02-SN1-obe.outbound.protection.outlook.com (mail-sn1nam02on0048.outbound.protection.outlook.com [104.47.36.48]) by dpdk.org (Postfix) with ESMTP id 5F3026CB8 for ; Fri, 16 Sep 2016 06:32:43 +0200 (CEST) Received: from BN3PR0301CA0022.namprd03.prod.outlook.com (10.160.180.160) by BY2PR0301MB2005.namprd03.prod.outlook.com (10.163.196.27) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA_P384) id 15.1.619.10; Fri, 16 Sep 2016 04:32:42 +0000 Received: from BL2FFO11FD041.protection.gbl (2a01:111:f400:7c09::102) by BN3PR0301CA0022.outlook.office365.com (2a01:111:e400:4000::32) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA_P384) id 15.1.619.10 via Frontend Transport; Fri, 16 Sep 2016 04:32:42 +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 BL2FFO11FD041.mail.protection.outlook.com (10.173.161.137) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.619.6 via Frontend Transport; Fri, 16 Sep 2016 04:32:41 +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 u8G4Trft029256; Thu, 15 Sep 2016 21:32:38 -0700 From: Shreyansh Jain To: CC: , David Marchand , , Thomas Monjalon , Shreyansh Jain Date: Fri, 16 Sep 2016 09:59:48 +0530 Message-ID: <1474000200-16705-14-git-send-email-shreyansh.jain@nxp.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1474000200-16705-1-git-send-email-shreyansh.jain@nxp.com> References: <1466510566-9240-1-git-send-email-shreyansh.jain@nxp.com> <1474000200-16705-1-git-send-email-shreyansh.jain@nxp.com> X-EOPAttributedMessage: 0 X-Matching-Connectors: 131184739618658904; (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)(1109001)(1110001)(339900001)(189002)(199003)(189998001)(2351001)(104016004)(11100500001)(586003)(81156014)(19580395003)(87936001)(5003940100001)(50466002)(50226002)(5660300001)(86362001)(92566002)(85426001)(19580405001)(110136003)(575784001)(48376002)(8676002)(8936002)(81166006)(77096005)(2950100001)(626004)(229853001)(97736004)(8666005)(106466001)(36756003)(50986999)(76176999)(33646002)(105606002)(7846002)(5890100001)(305945005)(2906002)(4326007)(47776003)(356003)(68736007)(7059030); DIR:OUT; SFP:1101; SCL:1; SRVR:BY2PR0301MB2005; H:tx30smr01.am.freescale.net; FPR:; SPF:Fail; PTR:InfoDomainNonexistent; MX:1; A:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BL2FFO11FD041; 1:0Hz8iRySeGEs6vKFZxj6Zrvlso8MeSONQpt/TuIl14ydd9iRiCvKx82q18aDu5e04J6kmotq1w4IZ1ZmXbiKVquHaW1dPCZ52pj2EzlefZ/Nt3/VhON4H8GGxBIERIiD+4VOT3XYpRLOaKC5zWCRxYm/9q0l5S9PLP5WEQDipje2Jkn7WF2oCU0oejdRlotg9MaSvWrar+rGiyCxyIa5zjwBUu/dycmjrwqwBZg1qaK2bSI+EFax2Gxc9JyZj4QYhHhO8U88wCUtni8AhCoB0JNN2qXuhWLVj3btwYDcJoflipY9LjltHpVh7/d8Y2dSejkUS16pzxbAkM4Oak/jENfhgkISXh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bQwKc4S1h5Yv1bpwhMD8SnDztKqfCbxK8g7DcuBxeOmJ+9jhcWW6kTmM+o1TVXZybEoPeKs6Ps8aDct7IE95WlxUBV+THJHgDi8o97lMQpoKjR557uL4qgPpGUVv6lLuLYDl8iVP1vvzUE= 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)(13017025)(5005006)(8121501046)(13015025)(13024025)(13023025)(13018025)(10201501046)(3002001)(6055026); SRVR:BY2PR0301MB2005; BCL:0; PCL:0; RULEID:(400006); SRVR:BY2PR0301MB2005; X-Forefront-PRVS: 0067A8BA2A X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; BY2PR0301MB2005; 23:QzhzHcogb5+GLAQ+wE/cXo2mxp2GJyppyb+rKmU?= =?us-ascii?Q?fJOUwBVIw69e5rt1yrw3PYpXPi7WD2GGjp7mI+Bkz1O5aPRg0BGhFxh0dQMH?= =?us-ascii?Q?1g1ZVogOKT+whsjugNY7CjTcZrXuw+zHlpIazztpOYKuf3Rn/IVqvzodXFWL?= =?us-ascii?Q?plMAb6VhArW7O93r3a/gn1nYoUNKIvnqVDYQG3aGkHHuFNdrv35P0XVXR8v6?= =?us-ascii?Q?f0YCIKMe+GIAeQqZQth9SxYdCO9IXdM9w5AXd4glf9hZRX3V1owcLImJJncA?= =?us-ascii?Q?K86zj5CVeDPBPad3/pqJm4VCT1pXO7lLBUKtEkjCK+tPqXF4bvMqglNA9rAN?= =?us-ascii?Q?FB7xehV3YjLGf5vLTAOWhLDsHpOrbpbJ4CSC9+M4jZkAG18NbFx3KYX4FIF2?= =?us-ascii?Q?4CxmlDvsc/fpR+ODTk6Lk/Al72Oct+ipup+gT01jIgNJwwpNnOS/26TYd3F4?= =?us-ascii?Q?e/Vp9FtoKDqGwm73x9QoLLQdbMICgbRkBokyU0oSaeZEpL+gdVWyt0yYEDzc?= =?us-ascii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I9vmk73AMA3W4wQuTN0pSBLSmLcOhpKnvOHGQumDegEBGOhcIF5gahkynilv8ANo+aXxXRb4qCIqRpfTQx3iIsB0Z3bR0kWWh1PCmtAqiIA99UtMrkhnziLHEVEseB7cucJx38IrZBFQ2U3eN+y5IcY+Xtdkr/g8ggOLllf9b/vWo=; 5:RAJN2/Wa15QbZjKjxlWa+ozGWYuVCPh4666LRJ0SMqdIsKdPtzgANUE3Cp3S8K/uH2eOroNC8FapW6MKa/8LyNJyIm8I16o9k9et3ShAw0TK3Jb/nruRxZa3xNaz4XAtlUZ/zHMnA5/SwSmTDHg2VrkSGT9amOFuzX4Q5VpoHSI=; 24:rKbP+EN13DSrBJNOmo6BT02FlqG8cWgR/IEzQtMnGb+3BRUbLiJOOfzTvWmW49zTmxOFYztdrFYeJlOoci0NXVP9RXl6wM+3rkz2LwDsSTY=; 7:H3ouIDgngutxj5tPNG2xbGMaqJc11AXkiNKRrqa8lAyvNpCTkipXjuwdU32/eog77aO1vAJ/gHczw5fbOOnxl1KUxewB3Ia80BFAdwMf+0pTkTz2lj2PP8yx4G8pnXO4sp7I1SLwxZyeLPV8SafMcx3zlvMXWLdHn0Jn3ZzyHgMfrTKOx0LNPMbvEYxqKWMmmkP+SJQGZp6sMWDN4oVYbxKnRPT+3cpPauwJEyyKEp1Wt/3k/JkV+eIjOqzzi9+w SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Sep 2016 04:32:41.6942 (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: BY2PR0301MB2005 Subject: [dpdk-dev] [PATCH v10 13/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, 16 Sep 2016 04:32:43 -0000 From: David Marchand 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 94ae14e..6cc9b01 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