From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from na01-bn1-obe.outbound.protection.outlook.com (mail-bn1on0053.outbound.protection.outlook.com [157.56.110.53]) by dpdk.org (Postfix) with ESMTP id 1654CC342 for ; Tue, 21 Jun 2016 14:03:17 +0200 (CEST) Received: from DM2PR03CA0053.namprd03.prod.outlook.com (10.141.96.52) by CY1PR0301MB1627.namprd03.prod.outlook.com (10.162.166.29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.523.12; Tue, 21 Jun 2016 12:03:15 +0000 Received: from BN1AFFO11FD017.protection.gbl (2a01:111:f400:7c10::107) by DM2PR03CA0053.outlook.office365.com (2a01:111:e400:2428::52) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.523.12 via Frontend Transport; Tue, 21 Jun 2016 12:03:16 +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 BN1AFFO11FD017.mail.protection.outlook.com (10.58.52.77) with Microsoft SMTP Server (TLS) id 15.1.517.7 via Frontend Transport; Tue, 21 Jun 2016 12:03:15 +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 u5LC2TDW004076; Tue, 21 Jun 2016 05:03:12 -0700 From: Shreyansh Jain To: CC: , Date: Tue, 21 Jun 2016 17:32:44 +0530 Message-ID: <1466510566-9240-16-git-send-email-shreyansh.jain@nxp.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1466510566-9240-1-git-send-email-shreyansh.jain@nxp.com> References: <1454076516-21591-1-git-send-email-david.marchand@6wind.com> <1466510566-9240-1-git-send-email-shreyansh.jain@nxp.com> X-EOPAttributedMessage: 0 X-Matching-Connectors: 131109841952856330; (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)(1109001)(1110001)(339900001)(199003)(189002)(2906002)(33646002)(77096005)(50466002)(4326007)(105606002)(48376002)(87936001)(5003940100001)(68736007)(47776003)(86362001)(69596002)(50226002)(189998001)(19580405001)(19580395003)(50986999)(92566002)(76176999)(2351001)(229853001)(7846002)(104016004)(97736004)(2950100001)(6806005)(110136002)(8936002)(586003)(81156014)(81166006)(36756003)(85426001)(5890100001)(356003)(8676002)(106466001); DIR:OUT; SFP:1101; SCL:1; SRVR:CY1PR0301MB1627; H:az84smr01.freescale.net; FPR:; SPF:Fail; PTR:InfoDomainNonexistent; A:1; MX:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BN1AFFO11FD017; 1:i1o8RYNgXc2cM98+kWE8OVGT3Q/7BEZqa0L7RZBiO3Jfx+JTv6oLMZGvB41xT2ZNwga73Eb0oFg+Q94P4gWUM0LxCkQE0XtDxPC+VH+FNr/JLFc4bSm6sZCYl8vYwTGf3WuGgsEQ8mUj+H4SKfGkSZVFofV/YvMGSqpyL89Gt0WNFumfndPD/34fC/AFYT9edTU63Zb3pmULuGLTRNuCbMC5zQl/kZgCPIMaYsOgRtfaD7xm+AN3tAvxKZXkhdPcvxP9byw0p7gzHBxlNzmhKSEySyC6JM47mrElBZqYk+Qd3cOlQi5lnYq952edRhw1IjPArl/fLQbOaugibxTv/IO4RqNGW1c62mmsDlvQpgrBYODKEp8U4YsBF5s5Ng7GTAKcgbKW8TP1lXxYinGMlQLeL39BtaHeMexc0wN+EUzExk9BsiXYovJWCZ8/ARM8Cb0HGGdICMZN55JeFWgWIVWUrYPwtF5mCSooXhXWjcpOC2cdi5X5n5yy7S5CePtf43wsprrsLmP98ySt666SjQHsp7+K9b+3UjCHwCi2Zn4BCAQk18rO55uMlmP2bAQ6thql+wOHFsqRKu5qLLNcFQ== MIME-Version: 1.0 Content-Type: text/plain X-MS-Office365-Filtering-Correlation-Id: ad781e77-ddd0-4573-590a-08d399cc069f X-Microsoft-Exchange-Diagnostics: 1; CY1PR0301MB1627; 2:Kl5Rq/i1aDCZVkn4YO6XEHqDjuLLt+wQ1gbqBVQvx/8jrp6gXOlzkRwCtL04FMRne9uulvgTs2M5jd+KlIq47lHQzHhbHG1zzsQBPbUqi/dKPVxLhq8/oq4A8vcK2CjvjMbqoZ3vnYlH6qemTt2H2wXPTscZ/JUDFgP+KYu+KGeH8lmbmYmMcXTBTgZxtPoG; 3:ZGHxMY8rOdzJGAw1y15evyDKouwyxxzO4qMrYzmUJWcaIXDOCprhSgjSQ0dzjPj2JiL2QEcx+NT1A2c5reroisndZ/JJXXxrImMYyYw4f7mgokwYBzSC3sNkcbKYqs9Ne9Ml3V658N2YWZZ6QrJZ1cmxp4XeQqP235eWYzGF5fqzxQn7o6P6+PObvzvg18UQTjNNrQw3klqC2SgsIw5U3GdS6Te0eVLLfxk/vCbG+R0=; 25:c5dk/6uU5Y5a8uODGAZaNqtbk0k+89KgoM1gu+sgv/oterY62FQXrcYcMNT8wovR2rOLsbo5C1gncwsMPua6W+gjU1jqMSO/hqioP0yYjyCq+Z+1qrfKqKhYbExuJ+p1PBL8gLqd6hRse6j8pe6bnlyjjsCs1DbhelTMQbyhSFzKGJJg9j24fzHX7lWYxAUHpxW0+EMT0wXYWL5vsVqtSp/XR9QkSf4wJb/IvyUMmMDh9iGkQSFctMvGsfKtIsTfgj61Kl1BYALUihRYARQQatRR6BqC++Q7UjO7rxT9kv235Ph3HRqE3WLcoSHgfySzoT0lZaIvvTBhA4/5Z+g4hzxlXAw7WJ4WqDjD1FOy0fGQfHOFZXISvK7zl1hpnkFASabE8NbLtQs26dhqq++onee1UZc4g+TBlkrQWxGGDqU= X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:CY1PR0301MB1627; X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(185117386973197); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(13018025)(13017025)(13024025)(13023025)(13015025)(5005006)(8121501046)(10201501046)(3002001)(6055026); SRVR:CY1PR0301MB1627; BCL:0; PCL:0; RULEID:(400006); SRVR:CY1PR0301MB1627; X-Microsoft-Exchange-Diagnostics: 1; CY1PR0301MB1627; 4:jkYWnB0P9GDiNZreLOjryeXZG7a+fcQlbZq/Xz3nU+/qSHhjVCfqFKGAJv3HW9FH3uMDuqnOc/FKqbdT5XDaBChTXcM2D8xR7VPGaM6Yi1Neb2/j8o6IqMqIagq+xKeo7fH/Hs7jff4tJkYeRqzULBQFpwokA5/kqDvC4ntyy0ZpRO200gosGupGCHgCEfwh0WFGV3AlPNR9JslNE5CNTIHjMIukqSB2lnu/PNSKGmLMCX5oPiNnfEMdjm/qILnMOtlPWZPN4eW+BmGeG+n/vMyVz7z1ANZrK6lY/c33VYjPSyPqyZ+pdVppChtE4vurhWMJ2MhUIL//X5s78vKPYCJHGyxAISlowS8sVzA0oKQFM3r0iLkPq0MDAKntxfL473ApWGjF5q0RZlEDhvsHd1vIJdqhyNjNGDoAb18UYBJifYlDeKMawEH/2IriLRPvGKRIwHFf9jFh/xQPx+dufCOB3UIU408DkdX+KaKib4/qlo7t2erAOgd+tgx70NDL20cKvbJcJ+/MPOSYcyIrCA== X-Forefront-PRVS: 098076C36C X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; CY1PR0301MB1627; 23:UWPH1vX3hrviVj8/NFfWvMTUcla2fL5Eli68QHr?= =?us-ascii?Q?80a/mQvD3iDZbv06QIpgsOrzQ1o5RJvE7IlDjuD4XaggIViSWUmiPP6VCj3q?= =?us-ascii?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9x78kA7rtCPnC4DOeU0f/1LtY+ SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Jun 2016 12:03:15.0672 (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: CY1PR0301MB1627 Subject: [dpdk-dev] [PATCH v4 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: Tue, 21 Jun 2016 12:03:17 -0000 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 Signed-off-by: Shreyansh Jain --- lib/librte_eal/bsdapp/eal/rte_eal_version.map | 2 ++ lib/librte_eal/common/eal_common_dev.c | 47 +++++++++++++++++++++++++ lib/librte_eal/common/include/rte_dev.h | 25 +++++++++++++ lib/librte_eal/linuxapp/eal/rte_eal_version.map | 2 ++ 4 files changed, 76 insertions(+) diff --git a/lib/librte_eal/bsdapp/eal/rte_eal_version.map b/lib/librte_eal/bsdapp/eal/rte_eal_version.map index 1852c4a..6f9324f 100644 --- a/lib/librte_eal/bsdapp/eal/rte_eal_version.map +++ b/lib/librte_eal/bsdapp/eal/rte_eal_version.map @@ -159,5 +159,7 @@ DPDK_16.07 { rte_keepalive_mark_sleep; rte_keepalive_register_relay_callback; rte_thread_setname; + 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..14c6cf1 100644 --- a/lib/librte_eal/common/eal_common_dev.c +++ b/lib/librte_eal/common/eal_common_dev.c @@ -150,3 +150,50 @@ 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 (name == NULL || devargs == NULL) { + RTE_LOG(ERR, EAL, "Invalid device arguments provided\n"); + return ret; + } + + 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 (name == NULL) + goto err; + + 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 0513467..6c6163e 100644 --- a/lib/librte_eal/linuxapp/eal/rte_eal_version.map +++ b/lib/librte_eal/linuxapp/eal/rte_eal_version.map @@ -162,5 +162,7 @@ DPDK_16.07 { rte_keepalive_mark_sleep; rte_keepalive_register_relay_callback; rte_thread_setname; + rte_eal_dev_attach; + rte_eal_dev_detach; } DPDK_16.04; -- 2.7.4