From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM02-SN1-obe.outbound.protection.outlook.com (mail-sn1nam02on0070.outbound.protection.outlook.com [104.47.36.70]) by dpdk.org (Postfix) with ESMTP id 8C3328E9D for ; Wed, 7 Sep 2016 16:10:04 +0200 (CEST) Received: from BN3PR0301CA0013.namprd03.prod.outlook.com (10.160.180.151) by MWHPR03MB2447.namprd03.prod.outlook.com (10.169.200.141) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA_P384) id 15.1.609.9; Wed, 7 Sep 2016 14:10:03 +0000 Received: from BN1AFFO11FD043.protection.gbl (2a01:111:f400:7c10::184) by BN3PR0301CA0013.outlook.office365.com (2a01:111:e400:4000::23) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA_P384) id 15.1.609.9 via Frontend Transport; Wed, 7 Sep 2016 14:10:03 +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 BN1AFFO11FD043.mail.protection.outlook.com (10.58.52.190) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.587.6 via Frontend Transport; Wed, 7 Sep 2016 14:10:02 +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 u87E8BCv013556; Wed, 7 Sep 2016 07:10:00 -0700 From: Shreyansh Jain To: CC: , Shreyansh Jain , "David Marchand" Date: Wed, 7 Sep 2016 19:38:04 +0530 Message-ID: <1473257297-7221-13-git-send-email-shreyansh.jain@nxp.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1473257297-7221-1-git-send-email-shreyansh.jain@nxp.com> References: <1466510566-9240-1-git-send-email-shreyansh.jain@nxp.com> <1473257297-7221-1-git-send-email-shreyansh.jain@nxp.com> X-EOPAttributedMessage: 0 X-Matching-Connectors: 131177310027577139; (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)(77096005)(86362001)(575784001)(2950100001)(92566002)(5003940100001)(81156014)(626004)(85426001)(5660300001)(104016004)(19580395003)(50466002)(8676002)(19580405001)(8666005)(81166006)(7846002)(356003)(87936001)(586003)(106466001)(50986999)(76176999)(68736007)(2906002)(50226002)(8936002)(11100500001)(105606002)(48376002)(305945005)(4326007)(47776003)(189998001)(5890100001)(97736004)(2351001)(33646002)(229853001)(36756003)(110136002)(7059030); DIR:OUT; SFP:1101; SCL:1; SRVR:MWHPR03MB2447; H:tx30smr01.am.freescale.net; FPR:; SPF:Fail; PTR:InfoDomainNonexistent; A:1; MX:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BN1AFFO11FD043; 1:9bEf+fUITyHrK7mktmj+vD7XkVkoB+MLjbiIFWAS3qG9Qn1kroG8M2JShnTGFNFhm55a5+xtcJ6aXCCGgajvjuIlqvVfrVOaFoj7lY5TQbr2W1rmRCQGMgLj6num2hWNUdscapb57Qfqm6xSwivJW3GHW7UjhOSzHrUDBkNEs811aVxcDRCcyOr190pIphqVfRPTK3kNWT/9VPkO2aQW8CWg8B+2KwRUTCUB1klbjFZvKMSP1N+M43a2CqV6CFZz8Au5Av/QszQgrrUB3APrfD8iAhGWkcP1dVVDKrVIGj7mWypo6uuG+HQSptNrXCcLIykueOPlB1vK/BtYFfD4Wru/77aGHTuWNJ++DQg3gVEqwress6xI/1vRvqDYuz0zEYxoBK25nuwi5dVZ9XkhMzmXAgIQLgXh9QXgGGhLhGW68dre5EebUpatnL94IQiizsgbBY8CRvIBRCFOATKzBvmwsHd2UaGbRRfghLA3Ag8u8O5sVgikZlDls4Qwo80gFvqQJN3FoL+MGY3Yt/u6lLQ4vlmOFDWkpXRbolSBHoMgk+HqohJea8BH25HcZCL2XroPKFTBZfzfHRLE4CLYAg9nXR/HyjOKPkDwVzmlPms0b+BvNMZAxf/oPWGl6tue MIME-Version: 1.0 Content-Type: text/plain X-MS-Office365-Filtering-Correlation-Id: 4606fd6f-5dc2-4541-95d2-08d3d728a93d X-Microsoft-Exchange-Diagnostics: 1; MWHPR03MB2447; 2:muCyI0MyCj4d4vjPXctyaYlk6HGIsa3VaPH1bzouhDeQZCQqNaHxD52Y9QVEKS6A9xXzGt0y4HIdMUHEy1/c2yOqZxGjnsSDBqJeo6WK5wzjvXE1vp0Dii55ZI/0s4FUoeR/+TWFMhRG7XgVELP/x+hr+dh0S/vQYx6D5eO2ilcjZ3hq4kL6P2Q6bvR60yom; 3:ke1MKtPAAuZWOd/FViE2/Ri+FbC5cFTJK3Bs5WvWqCJoJTFKo6DBid7kMDuYy89V5o5wwswGN8WtTf4vHbtP13IkbKAqXSnzCq1HInj/fX5uVEYfvv2dewbOAvHDCm/7nk5L4Yy/JzNpOkZwmNNLcC0gAEz2q+DsbkVBk0YtDi8nVN0Bgt15w7/DBmDNMsQT05vOhd1b6OG6uVYSS303iS5035D9WqrpJbbKpBrMdgY= X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:MWHPR03MB2447; X-Microsoft-Exchange-Diagnostics: 1; MWHPR03MB2447; 25:dewgimyxq9wwT/pOflENBbZ8QUYho6JRNDW4KqT+S7tbw0u7aKZTMu7uS4Agrc7MGPRIze614mN/8dQHqfINUut3TNS8BR/ohKSkNvgaZSPfEilKm88gHKXAcwlqbqKbgd1VphnoUn3+gQlYlyGxlxlMbwCbvew2xXJ19vgalUimnUYPrirU6aK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RapwXHaxbEav6MRFSZEAN4VYkh/roZnpJF6LKDssjiU7JvTlse45/jx53LFxpoBXUv78LxL5QWTRBRcLQMhT9CGi1RvsdI/4/Pqi1ErrFA3wo3BxQHtvIcSHB/0sLZuthoPMNSjj4SRhEb7IWQgo/kPk71lOMV2ErlRAcHNOlVIoc8RefehXaaEpZ+akm6HVS1qu1qVGklEuhxodyQqovUQYK7ZySvBrT0US6Iz+ERbh5qX0fde+WdE0yHJkzxSFyEL+at+uPM0z9qhTEjxXnGqOw2cTUOs011UgLvIdEGINlZDHFIY6povgETyzYskBRqyZDigJOs= 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)(13015025)(13023025)(13024025)(13018025)(8121501046)(5005006)(10201501046)(3002001)(6055026); SRVR:MWHPR03MB2447; BCL:0; PCL:0; RULEID:(400006); SRVR:MWHPR03MB2447; X-Forefront-PRVS: 0058ABBBC7 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; MWHPR03MB2447; 23:0/a3NZ2xFeNhY+F2bD4BAzH7oJBpKdirM0CnwE764?= =?us-ascii?Q?1h/DClVXXAiZkGqtE8WE8kPL9E7kncTCUdgX3PT8hOAWijJjuHnPv4jdrN5U?= =?us-ascii?Q?CMhcs7i2h1K/IW/VuhKcNbnoyH0EF5swDpHi/02JmU/33zHhur3ZqRblb7aA?= =?us-ascii?Q?QURrIoYjb70ZxTzWGSxlVVhaP1WO8peWYBmvgIEgKqDxTVdJt2QgQgeBnFyC?= =?us-ascii?Q?biaHTKpcPjG4gl/UAKljw9KZFYXibfBSxkYcPn1afXFIOl7gQDNxJfYntpuM?= =?us-ascii?Q?luIoqpu9NS5xUM+2ch9s3L0OnnPHaxLjXPjJqHNoXT7AVIE034A1F0XY10mU?= =?us-ascii?Q?Qiql38Mlf0RG2LHPKBT/RUGJAlEusFmOQh0qP/MUiV2833Za1vYQnumRkEgp?= =?us-ascii?Q?bHSIly7hFcWAZFF2taph6Cu/mDyUWZpe8lvsop3LE+Zc+e/88+EzGXzEGqwC?= =?us-ascii?Q?PyMFoB4SdxNP0wnjr43S+qdOqoNnSG5lNkyJpSeY8wzlasQ1hF7vu42wIdB3?= =?us-ascii?Q?92ac3h4O+f4Qjq+W8vt1sgrYIzF/TGPgZ++Qxq7aGvnvoX5Gcye1HQB6FovA?= =?us-ascii?Q?lOo0k81moTazv4g/mKTPvnCeJeMt0dUoEob6h+atxW0hoKjdAVy8d39iN4E4?= =?us-ascii?Q?kd/LsBoF7/zryy57XEouhwjONCEMuGx4LuWRP7EdA41RwDV92cvsN0kvW5cp?= =?us-ascii?Q?Xs14isEIUvU6ldOgnSK7CpiN/6eS6PiHzCL2Fvf8l4stEUL+vgcqAk5cAwSs?= =?us-ascii?Q?eMtumfkBZMOTd3iX2xEwG1xTs0SL5KLndedLLNec4Aik48n8KuvZdkun5wWD?= =?us-ascii?Q?f66gN94Eb8+xPmG14dsyhft8lcE6SUw8h38kSuEz75cm6pR/j20U5Dd4d0EW?= =?us-ascii?Q?27xzmTAjH0HNje/47q+eJI/mA9Y6aFxefxwwm5coimeDUxvSsc9f8s6FRbwM?= =?us-ascii?Q?cV29SdttxMq9IjRTIjD3fgRu48ymtsrIdx00y+ts8gPIFQnK+fUU/oYmyN6v?= =?us-ascii?Q?wCJImeYoGb0LqQ7t9nPyzVGr296SadEs0yqXA0h+1eh9HJ8awTWJj5WI3YjW?= =?us-ascii?Q?yoXY2Ed6xME5lt8E9qTd6rqqAoL240lt+fg0skBPQLJFcF4MmBRluJ/ivafy?= =?us-ascii?Q?vMlbGTg8VsASU60i+a/GTVbr1oryzLC05P7IdmBasNGuGg3t0lWJgmEy1STa?= =?us-ascii?Q?9b9WJF3oaknow1x/MM9P0oXwfU+CnkPLuDSRs3VJ3cbZJQChRO8uS3Pfg=3D?= =?us-ascii?Q?=3D?= X-Microsoft-Exchange-Diagnostics: 1; MWHPR03MB2447; 6:OGm/cugnTQ5fWXpUrvtVS48xRwE1gkvNQ0bN18/NgXzXwgDtc81+05RoAJccqdOEkxXDyAMsJtGyvoPCH/JjjU7a7NKGqyNSeCBi2aSZQ1NHR7mJLNM1b9aOl2oSho8wdvU2O8YqhN9FaK+Dr8DSo6VJ3eia/I2wJyKFXUi3XQbEjZ7NhxHqXz88neARusCYWFjTpCICb6b7B3+t1izhjsojamH3KCNGliPRthc3cwDLDQ8Pu1NSi+OfoEyen/Hd2z74+XLrOWXzzmjeYJ/iCbyOi3FNxgqecTYmPq2iPmo=; 5:RiQk4hlf4rMv4D2it/w1ChN/9mTt5ij5i5tPMp/Lxg4683cVoNriwlZd/E280QipFFLw1LgVlhbsLUV0lkdcf5YIynNBik2WIMoZrxIlRwJOZsAEjmPO8RFIbXA4/6wpMdQbVYRMt2hYrEqw7o9wBjFVLB1kQcA66bicHlHYbKU=; 24:TCi2yLQ5ZY6i1RmNX13q/bNN3svyLhbv4nUed4KkHXAmS9tuYaD7jItmGj/1vTv0ATcsZybVe3rntrJLipqPY8uDnx9XRpZC+5WZtQ3JWpg=; 7:7lJpPb2BU7Jrh2tYiWtLQ87kpsT0UkkEi7QSkifSPtRWwG0FndXdOYU5hqDohCulGY19UqSf2Un2zU3VmIPfwZW4Jb8v9LZzPBoy+P+QetMF16iW2S/92dE0bCcu2rnImrVimJgajmfjOaYHPywZQr6TahQf6x1LAaDLgV9QlwZKQK7Rm0hblq/QmaiLHzHc2Jja/Qa8A5WjGzkO0LeifDDQPPtpuiMh9iFIAuSRK8p97qCa8rH8wjdF798CdgNg SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Sep 2016 14:10:02.5705 (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: MWHPR03MB2447 Subject: [dpdk-dev] [PATCH v9 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: Wed, 07 Sep 2016 14:10:05 -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