From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM03-BY2-obe.outbound.protection.outlook.com (mail-by2nam03on0061.outbound.protection.outlook.com [104.47.42.61]) by dpdk.org (Postfix) with ESMTP id 23FEA5A43 for ; Mon, 1 Aug 2016 12:45:28 +0200 (CEST) Received: from BY2PR03CA061.namprd03.prod.outlook.com (10.141.249.34) by SN1PR0301MB2062.namprd03.prod.outlook.com (10.163.227.149) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.549.15; Mon, 1 Aug 2016 10:45:25 +0000 Received: from BN1BFFO11FD015.protection.gbl (2a01:111:f400:7c10::1:185) by BY2PR03CA061.outlook.office365.com (2a01:111:e400:2c5d::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.549.15 via Frontend Transport; Mon, 1 Aug 2016 10:45:25 +0000 Authentication-Results: spf=fail (sender IP is 192.88.168.50) smtp.mailfrom=nxp.com; 6wind.com; dkim=none (message not signed) header.d=none;6wind.com; dmarc=fail action=none header.from=nxp.com; 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 BN1BFFO11FD015.mail.protection.outlook.com (10.58.144.78) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.549.5 via Frontend Transport; Mon, 1 Aug 2016 10:45:25 +0000 Received: from Tophie.ap.freescale.net (Tophie.ap.freescale.net [10.232.14.199]) by tx30smr01.am.freescale.net (8.14.3/8.14.0) with ESMTP id u71Aibjv018422; Mon, 1 Aug 2016 03:45:23 -0700 From: Shreyansh Jain To: CC: , , David Marchand Date: Mon, 1 Aug 2016 16:15:30 +0530 Message-ID: <1470048332-27318-16-git-send-email-shreyansh.jain@nxp.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1470048332-27318-1-git-send-email-shreyansh.jain@nxp.com> References: <1466510566-9240-1-git-send-email-shreyansh.jain@nxp.com> <1470048332-27318-1-git-send-email-shreyansh.jain@nxp.com> X-EOPAttributedMessage: 0 X-Matching-Connectors: 131145219262099351; (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)(199003)(189002)(8676002)(81166006)(8936002)(50466002)(81156014)(48376002)(50226002)(229853001)(50986999)(76176999)(7846002)(305945005)(106466001)(47776003)(2351001)(575784001)(86362001)(356003)(87936001)(5003940100001)(11100500001)(36756003)(104016004)(92566002)(19580405001)(19580395003)(2950100001)(110136002)(33646002)(97736004)(77096005)(105606002)(586003)(68736007)(5890100001)(85426001)(2906002)(189998001)(4326007); DIR:OUT; SFP:1101; SCL:1; SRVR:SN1PR0301MB2062; H:tx30smr01.am.freescale.net; FPR:; SPF:Fail; PTR:InfoDomainNonexistent; A:1; MX:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BN1BFFO11FD015; 1:DGHazDtHKSffAjcdO3GFUjwDgTwOD4cX8zw4usZYIyTyC+1f5F687xjiswiis156uD3g83uTnqp4UHadIWir+8R0EwuBDOa8CS3JvaIuFj7y6dielSLYozVT6BQFEtMIXqXFUbHSKnTyE+AzL3VIbiXnZ5uvI/OSs8ycL1XecVTu6bFN6lh4A1TyxrzygCvI6pqPQvjPAUtXkN/TCEjU6ubiAPz0XyX551s/c+3TukGfRvkowP5Oyfc89W4SVBM6Z5ydwQdQBbrW6gr+Zcp2ZNl7YU7iaL12oy5rsxwDx+Oe6eCSJsWB2dNCKi17jmAWbKd0VFnXABQj9zRfj5POrDQn2uFwZPRp7VEHGVy0nCz2fkRodcVgKXHNZyBeXUR/PoIcYWODza3EvdRhsMV7pL78MmWecFC5oPBZxTlIBpdSedW64MeQoFZno9t2QElrNFc9gNG8w3kvd7OhvTAzbeocs2AyV5QF9wyGXzoL5JCUw3Zfxe4i+AYb6Y463hXBuAOyI7MUx9mrEiUqCRKnIg54bZa8YumFCJIGj2NRBcKrD6VAE944ApHyJBAnKJS0YNBfNG/tapSecIM1603ExzwI7HgWOhfnQQmYY8i2kDZbMqlmndGrn5FPCyZ0vK+z MIME-Version: 1.0 Content-Type: text/plain X-MS-Office365-Filtering-Correlation-Id: 6099223a-e8dd-4e67-a497-08d3b9f8f27f X-Microsoft-Exchange-Diagnostics: 1; SN1PR0301MB2062; 2:oOz8/rKYHfroQ2f0Cru9HIMgeDEu1ZRin5P+IoMagYoVyat1IXdfkbBHKWpOrtIv+q4cl40esQQxgWMNLzW13WL5XWMAR0JMjW6XSXG+MSFmbSlyEg0i4XP5J2s375oh7VtSpxx10zgRrtFfGj17x0OjEjOaIM/8WeyxN3kCL8yQGoHyQLKDb6uwShQH4/It; 3:ozZRCnDaWMF4wKsMxLtG7BewTfw8bZ3jAUNIZO3BGRRtNF0qCUzdNokgP9JpB5vGmPLmH+QHJO441VFIwnMVR7iOcsWmNdrrEVhFz38QVBhDGoZtOpYIZhiqHdTJcHNNcF2bYWKKGba3L3ZHnAWzH8+ipjpdf8XrQKUNLVPlNSIC3QinaiiMA6bn2F67nOg2j81h2eTeVm1UxAr45NU1UJ3WoKZ7Qul/wMrvKgOnTlU= X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:SN1PR0301MB2062; X-Microsoft-Exchange-Diagnostics: 1; SN1PR0301MB2062; 25:jHC5Q2T1fEF423H31v6/Nc2baNHBDLh6zU7JB8oUTq+ArcHFem9hATqc3wzsT1FaWBUVidcjTkj67UNazC3M+ubRW/my2EtlOPD8T5dksJ3jfyOzkwl3pe8EXYaDJ7T1Kxii1Z6eDQd2jZfOYfBvIBcwo1laejBc3I0eeIsEXRnMAcSGc5qyUAoMcAvh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zaG/op690sunY2GdzUy9gnfc1SEjADlpR3nuiIbraxbi/bvM6jDEB/xNBD5mwrh5fi2rH0jTMbxOJuLQ8yZuaFKlXvjikf5jAEUTNv9Us2EgmZDQuAZ4Tf8bSlnd4GGri4bZsttomGgHeU4fmvqvTZwIjKZ7R0Hhjppfx4T+vWetsaWrD4usODrFsmFljfw9WOzQ5lpDUgtsmTkHp7W6AASAvgGvE0dxvYr+H8yT9rYtKD+3gdAzeo7G9nv3mvFSdX9gwNwj72m7x2BwMkqfKtGzukddwXyjKzQ3PzNCctiONa8zaIHJYfAf1MP/j3Ow== X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(185117386973197); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(13023025)(13024025)(13015025)(13018025)(13017025)(8121501046)(5005006)(10201501046)(3002001)(6055026); SRVR:SN1PR0301MB2062; BCL:0; PCL:0; RULEID:(400006); SRVR:SN1PR0301MB2062; X-Forefront-PRVS: 0021920B5A X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; SN1PR0301MB2062; 23:4s003/1tGP4OWmmwLV3TCb+OG5TRVP3v/C6Nkkr?= =?us-ascii?Q?vjaNO1kuUio7AYOPp1iaJ5M2CZH+hYUXvCFf0zEwem9YDUt27G93HIoWUlef?= =?us-ascii?Q?pn24uODzo/8niFUmKOA7uTjSmkZ6KxfdvenxfUQ1Yk/FCfZYYvDSdBmo69YW?= =?us-ascii?Q?FvGK7U/uaqK1dLmClNcOARX30MkR6dD4QwoaQzlkHmwqNc7QZMLuTbSmYbio?= =?us-ascii?Q?3ZHI33y+zBiTXKQW7rlYUTvzCzIWSDxOG3F2Ahu/0r43LLbKKj2J8o0f8Chd?= =?us-ascii?Q?0J7WIEEXOr6T8igAziovzGact1eKlJgHuPWPCyg+NJFcr1Y5Mtxc3vqlOSIm?= =?us-ascii?Q?AOTb/4junpHcaOecs96GbQl8iz6a5uu0NsghM3EgbbASI95aaw6HBxrv5d09?= =?us-ascii?Q?Zem2r5KJMxOGA5JiSTcfPUv4oQ223Y3WA7rNSMDczv7W31p27yd5DnxF2SEm?= =?us-ascii?Q?LVr+VoIUc+FiLlBCfcCz/tBI7qSOWIZ+vp35Itjc4wm2knKfgcTmTf6Ufl0Q?= =?us-ascii?Q?UwJi7EN9B071Vlh5/n4cbk3cAmMpSDmY1mw3mj3lGG+++6ZSbRguAdpGROuu?= =?us-ascii?Q?1brHVgLIqd8/QudbMlPRmleKtANsdkLWwBYFMBIy5hqN26OjU8ZKbBSb/1mD?= =?us-ascii?Q?QNsdl9oN/tyIfDsP/AUmXdxwN4WCRamoH5krepLuIPYBSUqLDIEuesvunYfK?= =?us-ascii?Q?gEPjR+bSIYRBBRofo5Np/jYXae8maear+qMoJdszeR3X0u0wGSH+6F2T+uha?= =?us-ascii?Q?dINoameAMfkbT9YOnqnZXHADMPPrK1zk29+obUhsIG5VekWo0X+MTaH9O9BO?= =?us-ascii?Q?jZu6lRNNub9Xw8SYh0crKo3P1tEAEUp+wF8kiFA17Ef99paDNbqarO9X+RQp?= =?us-ascii?Q?Nw32lOZ2Ahl4ywrZV+SBSluOl504cKMWLrWrV8jfCjNFVv1y9QUseCdBMjM9?= =?us-ascii?Q?QClZNIITAlOC+jTAGDAvLQIuORK5tfT4PKXwaWVyg+0h0P/MDFz+v4YtONeK?= =?us-ascii?Q?3E7Qcoofr7wJh1BC4zv5rqkTcqZ2egJeHSv9RXl1/FLvt3ZOESHtdFdRr2o2?= =?us-ascii?Q?zBpD4U7xDgu3mi2LLYQ9eZv8pzIwL1isD1NFW8o1SOPX7mq0zDqApBfZLyOi?= =?us-ascii?Q?CH4UAdEfBBPJVSXORA/8s6+13LcvJfxGo?= X-Microsoft-Exchange-Diagnostics: 1; SN1PR0301MB2062; 6:2tlrtobr+5YonvEvyk4UOWThtALfVO3QigEc4pOeBmPYb3UZBrETSh0VlAHiYj8ZXnX+rzpzk46sc/DYguqUdrHLYIIB3U0Wda19edTQpiaNgeupyww4xZ8HzmF+Lu6YOftaNqT/hN6YrrCtA5WiTIjliBZ+OkAhvE2GDam2/OhRN+fF8m1V5OmPI/RF1gojqrmjIvRyZDxOsXIKofsuahjY3iT090P0ABfhC5vG4d7fdYG9SwLxzvp3VyuBEboSe77WdXXW1S2zE/NYqi97EaACi2zeaYbd0Z7RQHhhHZE=; 5:pjqmym9Bmk1INKp3jk9qA27HdqFkw8UhMazHLX15+6bMrJGJ1i5xJRGS4n6xw8HrfzsY+bw5QXLrLbNQRIj5zcpDMldVlAtsnI7/sRsizmskq2lSybprRMSB3r5BZIo/URHTjTTZkghUFyTqU/ug7cE8F1vhOmcjS58x3rogUI0=; 24:ZyAozzpDArA4GW2firtbOpJs2JJAiZPW/pVSMumobCJ7jHMfrqNKkcElpyyPm7JYKOSxd84Esov3VsxxygRfb7Zv6f3hwkgDv+clktKjMFM=; 7:YSRFHWXk06lxbWoWh5oCrFFQ45fBCcCxbGEoXEsRaF1U6Au1w0F2bix7erL7Za9Z5lsGD+lqm62BpLkt7WgN6YU0MYTr+3Vck276zNWPwwSlJpmTJAJRdPQ4UV03Tv4vhRlaAfPqRyZTMNu+fFn3HJ2W4E6LkRQmlIy/a+QIyTfLB4QJirgq4JWRzLyQWh3LWGqcZYl1qBIboJZqIos5H5Kmwq6se6w/v2sNUx1TaBM7LrKfIce0LZg0AChJ0BsR SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Aug 2016 10:45:25.3675 (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: SN1PR0301MB2062 Subject: [dpdk-dev] [PATCH v7 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: Mon, 01 Aug 2016 10:45:29 -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