From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM03-DM3-obe.outbound.protection.outlook.com (mail-dm3nam03on0069.outbound.protection.outlook.com [104.47.41.69]) by dpdk.org (Postfix) with ESMTP id 98C38568F for ; Tue, 12 Jul 2016 08:01:38 +0200 (CEST) Received: from BN3PR0301CA0077.namprd03.prod.outlook.com (10.160.152.173) by CY1PR0301MB0780.namprd03.prod.outlook.com (10.160.160.140) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.528.16; Tue, 12 Jul 2016 06:01:37 +0000 Received: from BN1BFFO11FD032.protection.gbl (2a01:111:f400:7c10::1:101) by BN3PR0301CA0077.outlook.office365.com (2a01:111:e400:401e::45) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.528.16 via Frontend Transport; Tue, 12 Jul 2016 06:01:36 +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 BN1BFFO11FD032.mail.protection.outlook.com (10.58.144.95) with Microsoft SMTP Server (TLS) id 15.1.534.7 via Frontend Transport; Tue, 12 Jul 2016 06:01:35 +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 u6C60qWn006202; Mon, 11 Jul 2016 23:01:33 -0700 From: Shreyansh Jain To: CC: , , Date: Tue, 12 Jul 2016 11:31:20 +0530 Message-ID: <1468303282-2806-16-git-send-email-shreyansh.jain@nxp.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1468303282-2806-1-git-send-email-shreyansh.jain@nxp.com> References: <1466510566-9240-1-git-send-email-shreyansh.jain@nxp.com> <1468303282-2806-1-git-send-email-shreyansh.jain@nxp.com> X-EOPAttributedMessage: 0 X-Matching-Connectors: 131127768961323525; (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)(2950100001)(305945005)(86362001)(8676002)(77096005)(6806005)(104016004)(4326007)(76176999)(356003)(50986999)(50466002)(586003)(189998001)(47776003)(7846002)(81156014)(19580395003)(97736004)(8936002)(50226002)(36756003)(48376002)(68736007)(106466001)(5003940100001)(92566002)(105606002)(33646002)(110136002)(229853001)(2351001)(2906002)(81166006)(87936001)(85426001)(5890100001)(19580405001); DIR:OUT; SFP:1101; SCL:1; SRVR:CY1PR0301MB0780; H:tx30smr01.am.freescale.net; FPR:; SPF:Fail; PTR:InfoDomainNonexistent; MX:1; A:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BN1BFFO11FD032; 1:PedNAf+Jq+wKoykD+OK6xFJtAeGP4gf9WifyS1SnBdpuFtBSIRcQCv/3o4lfDIT6oTC9f6rh41abXbK8/viKX1SSh19561KyPvS2npZbIa2dCG7IW+DvX/azqpmDCT1GAwSQVjHnkEPzBw2iyF3VcKMNDI6SXVSnkNPRcGc3KM0+9/I71PheaEkWDigcXBo7bLdmX5965UCa59TMTjV1ynEtpDUXVbRT60j7Y6U4HFNuBSXwXY0NJmwPfFpFRgq+jiuQPRLGGZvlBkapuOU+cYfgq75AiswXuj6ah+n8CwxV637b2B8rJYpqb1mW/zaM+0iixVAa8+CdBvvyvGPWtZ/3VdzzgROo246BOzq5KIMQ4QF12i3NeLUZ2Jne2pzeCsgyKO2kFr19xyA1QA2Tyv9hhmE+980hxPDRIl7IWyW8HJNt999ZHc2u+sNseomOQvwiYHvH2YNqiX7csHof9qLy1N8DGVW5BJS2e7AdxvUrGe+i1VcC1SR0DIkfD21+fgZ5XAC3hbjVqF5I1gBxvsPhF6BXQ2yFqkLfH1eU5hi8ES/kpoCUo2saAglpVcZRbYa8rMBbF5yrDfV46mMUaXDw+xHtTbi3Y2ZSlb9VJunL11Enm6oHlfCBzMO+JQCH MIME-Version: 1.0 Content-Type: text/plain X-MS-Office365-Filtering-Correlation-Id: 0153c84d-0910-4656-06fd-08d3aa19fb85 X-Microsoft-Exchange-Diagnostics: 1; CY1PR0301MB0780; 2:7vLt8hC4NMGtVPCmdFIyF3p/GFrVKSkSbyg9xJ2qCvV5qOE+yxhd9uFMgRnT2Wq8c9EOTxoyhogoehswd0M2NjLcPh5VIAdB0lb979ayJL1NumhSiM8mX83T7W5kIRJozCDzDM03KHHR00LfF1tdkfIdVK0bo4rPwyAeG3zRy67KPykbaYQmjjxQpM4yE6b0; 3:gkWU/A2S9RPFeNpFuBgp1r8YLK8P/hUYN8RvaPkBo1Ai9UQO/rmVpj52cJoQh+iLQ1OOxZIDYN732D/QSiRN3uZX3nouHez93tYs8ZvYPkC9W2wwuS4DpHu41kGdXVSvHFd8Evi81hOTWAIcXxhwEwI6LeZqJlrDUJ+QQivIb2WGnkM478gwUgn9ekS9CZbRnn42qg9tmThSOcgOr+O3pSvF2KQzJoaidwchXRQmsNM= X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:CY1PR0301MB0780; X-Microsoft-Exchange-Diagnostics: 1; CY1PR0301MB0780; 25:Kx4ThHWmu4NnU+zN9BW681vMQ3a2zZpdrS+Eb6fYivOIK8j0yyan2V1sBwDMOjorsL1Wl7yhlt2gGN0ClRK1TBV+1JJPyT6priviZwEU8et4GPg3/MDArc65StK4+CnsWV+h/0Bl/i/gHrXxdmXiZ0W6qjaXDlHoM5sy2eF3zurjQtTBxMajaE1R10qfaJIl9hLyH+Irg3YH924Mmr5YKsyBi+RvJu56SZ93qdpDzirA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T16xsK7T6+Zi/2Gf1oTVJ5ihDNV9RnwZK0r3PHrB86z2XwmjpCBa5ZQKcHcpejmQx4ymTvmsvfOqHfocFueT6y9Inw2zp8ApEJihDmURX4ciukTffTqiHxZernIblmybudg8uI/lJsajIPMs3xqPsPSNeE711QayqfMRQZ8nzFkUvAf/tNDGv+4w+Q/95OyfCtdmjGaR3X+JAspNHwZVftv7Ykgru+DoluzpnJeoH4sVuTy5L7982pZg0PzdpXg== X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(185117386973197); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(13015025)(13018025)(13024025)(13017025)(13023025)(5005006)(8121501046)(10201501046)(3002001)(6055026); SRVR:CY1PR0301MB0780; BCL:0; PCL:0; RULEID:(400006); SRVR:CY1PR0301MB0780; X-Forefront-PRVS: 0001227049 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; CY1PR0301MB0780; 23:NV3V/E+I14GeVZHx8h6nITrcQzkr/0xxqlOrMRx?= =?us-ascii?Q?DQDqa4x8Veb3Lab8Btffy6zMqjpyL09svg0/hGIQ6uC3oCqtpIMi2amkV12r?= =?us-ascii?Q?Ry36GX3kWxmBm1A/nuoF/5GQjmubf9WEJHHqU0Sahw+tLdi5Go7CFyposJT/?= =?us-ascii?Q?ekygODV7KF7ebXklk5fazIeAxzXpdXLKO8x8NBnlL7yffd7LBV/tTThk8C39?= =?us-ascii?Q?o6fVj7lc7vzuJOuFO2u9/03N1qNRBgrZM0MdtXcHpfbL56LDIC5JtimELRwe?= =?us-ascii?Q?74TpolJQAI3ZbnLMtPsjS9kDHx7+U4ZmRsIrLnPtTRqQyni7JZhBfmMLmtmU?= =?us-ascii?Q?DhhxD8F7mPIRLdRJokbsy5mUcc2GNgp7uhkHlDuc5zWFf5yafEPbMPBcYs7K?= =?us-ascii?Q?DxFxap5Mmr4Yo3s8mvN5n0qb0HKH1N/0+LCwk9bJ96cmJ0rWx1HSVWNf+Gy/?= =?us-ascii?Q?dqM7yuKNcEJjFVwDNsVBZlFAdzoYzLwc7F1Vcg1uU2dJdegZIMP3kSQZIAEe?= =?us-ascii?Q?q5L0/zhVEWfYSqOd2sE09Y/kAu5OUMIkdTFvKto9r8/yqqpAMmL1Oepl94KV?= =?us-ascii?Q?mSYMFR0DzluE7RyR2rzLpEP/76B8+T4BwNDfEFM691pFokWldqMLkb4dA65t?= =?us-ascii?Q?qzyEDWpolM3tFC9BCKISuAqWZyGCg84WSc6C4Sg2lZH/IBeFC5zP9MUXlfNM?= =?us-ascii?Q?TeFt0/WuPZFAVLmRdLt7nL9E5NGKjZ5pPB1rUaIbsrryO73gdp6R/o4nuwa1?= =?us-ascii?Q?ClS8mEoB0V5vJb7E056t1k84a+L0vSO1990ZBJmParVNm86iDIWSSQFgNLVe?= =?us-ascii?Q?zJDpUfcAIALRbyxc451v3IRKBLn1oalsnPNIf1wEjB0psV+mphchF/QV94gV?= =?us-ascii?Q?HbMnQ7wDPK9ZgYxnSCJ6cry66Y3WLHyD4b9DEYYleC3SqiTGMVf9o3IL2VfO?= =?us-ascii?Q?QUPnJneCQ1IRPL2OlxdXGHuzvVif8FQ0cbOJGmO8W6anRK4kuECgRhR03IQw?= =?us-ascii?Q?MJzAeHetMrF1PpYRx6jeUOiLNBushkALFh09K019CzfOEiCqpSRv4e99BGcy?= =?us-ascii?Q?pg9w5L4vFohh84EF3sY2ku/IPFc0c/tAdCn+S00INYrx/swNWDI/o+ETvK4V?= =?us-ascii?Q?LFepS1B4eMo0=3D?= X-Microsoft-Exchange-Diagnostics: 1; CY1PR0301MB0780; 6:CLRl/qi0q9c/mYmiL5CgN3cZskusVoKFOCxn/qGqbuJ63pwzbrKnHu2o4K4sxXHQ+L2Mtb537XH/xe/OCMHaDJIDWrQdmBY1yxefHukzvkJD85bg7wnbe5d/8Kok+EVRbCCeCpkLMEnu5Vm+NJD6YJ8ZDtYFO99MRbV/ll93uAgrMpEB/okllrL7nZA3xzYmYUMit18xZUQ5r4B3mk3pNyWe2oi1lpcBLp23+lo79LbLa/EGOk2jDO3tPWvBCZK+rI/HyYBbUKaoNlWjdOxu6DEv1hij/BvVOUs47+H06gc=; 5:SdMBiwCjGQMkrdPQqAP/40nP51gMmZzserUCzL3Zsyjbeoti4j8qYuiUBsiQvZ1HwOSaYGKsLf/6L8OcFAZtuv4NNgLVhzYfhEu36z6HdfjyAVKMoQcREuTdAUTObiF9vIr4SqaUlpBObOidIy9wNxrlSjrO0Ng5qzkqrlYXIDg=; 24:nAFg14YXQh3UHs2DeDxYd3KSJNDbm3AlW9K1Ck60Hamb+n4kVPkV/dOGDR7Inkx6bDFcDs2i9zVhjJfkSkrKhNiLt0gQVyg/JnYt7A933RA=; 7:wFqF/ZEs2cCa+KbNIJ+wezgMbRoMy/omsgC67AEddp1GpijSyFK+CcPJQBmloS3GKe4UpjrcuEVWqZXwX+3R5WyZk3E7bGxTZ5Xl/BcIgVzcwsHiRNhi507UtDMbXQiae9meB8r1jR2OXWyyg2QeBZ+KCU18EXb8dl1bJmL758sRNKFIkYWMltTyD18l5cfAx5sFb71SwHj/FFq4Uwh11atSLvTbWm3yIOL/eqyFGvQVkf3X024FK4K+sQhpnfED SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Jul 2016 06:01:35.8203 (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: CY1PR0301MB0780 Subject: [dpdk-dev] [PATCH v6 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, 12 Jul 2016 06:01:39 -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 994650b..2f0579c 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 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 a617b9e..db866b8 100644 --- a/lib/librte_eal/linuxapp/eal/rte_eal_version.map +++ b/lib/librte_eal/linuxapp/eal/rte_eal_version.map @@ -163,5 +163,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