From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM02-CY1-obe.outbound.protection.outlook.com (mail-cys01nam02on0069.outbound.protection.outlook.com [104.47.37.69]) by dpdk.org (Postfix) with ESMTP id CC1276CD0 for ; Fri, 14 Oct 2016 12:54:22 +0200 (CEST) Received: from BN3PR0301CA0040.namprd03.prod.outlook.com (10.160.180.178) by BY2PR03MB331.namprd03.prod.outlook.com (10.141.139.20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.587.9; Fri, 14 Oct 2016 10:54:20 +0000 Received: from BY2FFO11OLC006.protection.gbl (2a01:111:f400:7c0c::119) by BN3PR0301CA0040.outlook.office365.com (2a01:111:e400:4000::50) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.669.12 via Frontend Transport; Fri, 14 Oct 2016 10:54:20 +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 BY2FFO11OLC006.mail.protection.outlook.com (10.1.14.199) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.629.5 via Frontend Transport; Fri, 14 Oct 2016 10:54:19 +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 u9EAs937011436; Fri, 14 Oct 2016 03:54:17 -0700 From: Shreyansh Jain To: CC: , , , Shreyansh Jain Date: Fri, 14 Oct 2016 16:25:26 +0530 Message-ID: <1476442527-30726-4-git-send-email-shreyansh.jain@nxp.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1476442527-30726-1-git-send-email-shreyansh.jain@nxp.com> References: <1474985551-14219-1-git-send-email-shreyansh.jain@nxp.com> <1476442527-30726-1-git-send-email-shreyansh.jain@nxp.com> X-EOPAttributedMessage: 0 X-Matching-Connectors: 131209160599349818; (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)(81156014)(2906002)(92566002)(6916009)(2950100002)(356003)(86362001)(575784001)(8666005)(36756003)(7846002)(586003)(11100500001)(4326007)(2351001)(189998001)(105606002)(106466001)(305945005)(33646002)(47776003)(50466002)(19580405001)(97736004)(48376002)(8676002)(6666003)(81166006)(229853001)(104016004)(19580395003)(68736007)(50986999)(87936001)(85426001)(110136003)(50226002)(77096005)(626004)(5003940100001)(76176999)(5660300001)(8936002)(7059030); DIR:OUT; SFP:1101; SCL:1; SRVR:BY2PR03MB331; H:tx30smr01.am.freescale.net; FPR:; SPF:Fail; PTR:InfoDomainNonexistent; MX:1; A:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BY2FFO11OLC006; 1:uAawqsdFib1LTNSvYXi8H8nF2XJFArNrIvKV7rRfHIFGMRkz0tp4DeV/+YTynif+ews77NV9mmd59K+Bj/2B986sYWhgcT568o80m+IbVMA1NYzdo30S77KtuEBT8R3xqiNZ5PjZ0LBSJxypqwKJ/o2QxLBvQG55Pn5jitS+G+vG6XLbWh71v8C05JRtNROd5l9SzY6aOor9KLxOu/LFXHyEVwjNisg9iYPoV/VHN37MpivhQnG6MtxyhE0s+911Fhe/Cki/LNzuS8Ivc8O3+QsE5+v9f6++ld/UzOtqjVnho3tGqIoyoCOuZRlkuQekv1L+PYT1y5k3iVIHF6hdezDOHGEq61/kE2GfbqkEGhgIn+OBLSnPXxCoMY2mSJdSrUMiTb+K/J5OneHOYpdueGmRtdbW6thvXXzfQlDUZ/U29ZoRyU6JXwTbrpi5xsAHLJ9rEwwVzM1iEIVsq17uV9LEeeinG1Euvm+HOQx9TzpTYswEyIKarG2yvjBu31yeWwKe2Zqz9DryiLIJlNRkK8vBqVoep1Cvkh3Bvh3VqTkyOogNsH5XnWtlacfW+CrZ0PTVYKFJueu2P/7GFhq20lihHCQa17OWO9TsTU9yKjvpHniWPgH+zBA9kkHBcwtlBKvH3BQjGYwiGi8EmTbycbZ+DZd+LTnoNiSvCdKficO4h2PBieZT3H1oX9PBUcYUzroCWZ3dXqhmmpKUelpsevEVZaD0j5XTQVPbB2b30ro= MIME-Version: 1.0 Content-Type: text/plain X-MS-Office365-Filtering-Correlation-Id: c7978c4c-362a-484e-c8dd-08d3f4207341 X-Microsoft-Exchange-Diagnostics: 1; BY2PR03MB331; 2:H32Rv7SfQnX09B2xWmINj2sNvWulUf+zKqg/dWeMZhNkqI/7/14lz/iJBXPX8spBRpKsxmoL/4qTuC73lkAdtPpGocnbt+PpWeN05pEdmtV3RyQ91/X8ZiV2vjSuU4NUv+dMy21SeB2u4sOh1WbgNGYRPcR6sji5rYVKOD/jhAmIAuMGYegTrjsQN1/mTro1; 3:CibQf7ra0DpPevZm8wpIqSefisXzpXH3ZQvuXR5YLdY3UNJZrZFhhcII9hXl0Ica7BLeLqHyCRNBn6rR2Mcgsxw+mAkczD2prK0wqWLSXo6zVL+p73FOR7bF1BVcK4HOSuTACzp+sySFuoGt3FMBMWwMynQE/9Ci7oqaTQhJLfOL5nm/skTdsKYyojNAL1ZXqY5Cw97CjmFq7mxmo82Hg05ot9tKKgg6jAbwdXuSFvU= X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BY2PR03MB331; X-Microsoft-Exchange-Diagnostics: 1; BY2PR03MB331; 25:+sf2R9/dayzP3yhvrfdWc6wUZvXua+OeZFN5Q390Jx4OZzdLXhAmzXa46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mj9yv1DN865sp7ox7bER1Gc1g6/A6YaQXcGHi/IIx4O4Ra90idaKmWGb8jz3BWE/h6HCzY7dbWdNb9J1/d0sbW/swklPzoC7y42Hqf8UTP2VCHgLS1QAZLbxPlyv03xiPUBe/wqJEH8CljwFm707SwdyEc1Vd6eEm/UJT9KBiAF0vtWVvFetKhWRRnbgZIxWFfgWC8211sa55yXEfjWNf4ODlMtc2NUFQvkO/t+7qNmRZk8Q7CwA859YzZ9Bil+K78+GADAHLKXvegQQV9YszGdJBOOgO4sYIXVlbNFEZcAUjJNiwVPlY3ndVmMWA1Xwmhy23tQeCP44zIpeLLgeliqixjzxGZGzIl4vVyLq/x0IYyCOcWW+O0O7Ia6cewIUhFDY1BSwZz40YIrna5xIaSfJm0nGWolA5k/bZ2/KF7ocRkOv3oaUrYx/rtIDFMLQnTmW2i0UhtlWAUT4AP/55Vpmsgru/hcyvULXsNkLHx65CEO8C0KxyySoWYdSeIKmrXJx0BxEhLl+VA= 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)(5005006)(8121501046)(13023025)(13017025)(13015025)(13018025)(13024025)(3002001)(10201501046)(6055026); SRVR:BY2PR03MB331; BCL:0; PCL:0; RULEID:(400006); SRVR:BY2PR03MB331; X-Forefront-PRVS: 0095BCF226 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; BY2PR03MB331; 23:2msx7bFaCrpV6rCBuLS/k6P/yDKl8DXWxIQlVl5g2j?= =?us-ascii?Q?yb5Zo9Hl93kNSQtzFaRRMGgm8XlH1COQ2EG4XSuKsPbydjDXcgriUQpAsALW?= =?us-ascii?Q?7Rqt5FUMZ8GdOxeUmSgd9iHv8I5yb08oMl00oeWflz+3TRg5RFIiehF3RqE7?= =?us-ascii?Q?D8JcOCeZkmANOdPvAtCvuv6LSNHP2UlU7W35LU0WPXXQt+X/WQA6y5NDCb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W+DKp4im/C7XGA5mhJB74te1f8uPTLaa6MjuEAPPKn8e7/Pp+M/YdunSQo4mmlN8SNNLTIrqGYGegRN9a26UrdP9yqd9eA== SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Oct 2016 10:54:19.7321 (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: BY2PR03MB331 Subject: [dpdk-dev] [PATCH v2 3/4] eal/linux: generalize PCI kernel unbinding driver to EAL 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, 14 Oct 2016 10:54:23 -0000 From: Jan Viktorin Generalize the PCI-specific pci_unbind_kernel_driver. It is now divided into two parts. First, determination of the path and string identification of the device to be unbound. Second, the actual unbind operation which is generic. BSD implementation updated as ENOTSUP Signed-off-by: Jan Viktorin Signed-off-by: Shreyansh Jain -- Changes since v1: - update BSD support for unbind kernel driver --- lib/librte_eal/bsdapp/eal/eal.c | 7 +++++++ lib/librte_eal/bsdapp/eal/eal_pci.c | 4 ++-- lib/librte_eal/common/eal_private.h | 13 +++++++++++++ lib/librte_eal/linuxapp/eal/eal.c | 26 ++++++++++++++++++++++++++ lib/librte_eal/linuxapp/eal/eal_pci.c | 33 +++++++++------------------------ 5 files changed, 57 insertions(+), 26 deletions(-) diff --git a/lib/librte_eal/bsdapp/eal/eal.c b/lib/librte_eal/bsdapp/eal/eal.c index 35e3117..5271fc2 100644 --- a/lib/librte_eal/bsdapp/eal/eal.c +++ b/lib/librte_eal/bsdapp/eal/eal.c @@ -633,3 +633,10 @@ rte_eal_process_type(void) { return rte_config.process_type; } + +int +rte_eal_unbind_kernel_driver(const char *devpath __rte_unused, + const char *devid __rte_unused) +{ + return -ENOTSUP; +} diff --git a/lib/librte_eal/bsdapp/eal/eal_pci.c b/lib/librte_eal/bsdapp/eal/eal_pci.c index 7ed0115..703f034 100644 --- a/lib/librte_eal/bsdapp/eal/eal_pci.c +++ b/lib/librte_eal/bsdapp/eal/eal_pci.c @@ -89,11 +89,11 @@ /* unbind kernel driver for this device */ int -pci_unbind_kernel_driver(struct rte_pci_device *dev __rte_unused) +pci_unbind_kernel_driver(struct rte_pci_device *dev) { RTE_LOG(ERR, EAL, "RTE_PCI_DRV_FORCE_UNBIND flag is not implemented " "for BSD\n"); - return -ENOTSUP; + return rte_eal_unbind_kernel_driver(dev); } /* Map pci device */ diff --git a/lib/librte_eal/common/eal_private.h b/lib/librte_eal/common/eal_private.h index 9e7d8f6..b0c208a 100644 --- a/lib/librte_eal/common/eal_private.h +++ b/lib/librte_eal/common/eal_private.h @@ -256,6 +256,19 @@ int rte_eal_alarm_init(void); int rte_eal_check_module(const char *module_name); /** + * Unbind kernel driver bound to the device specified by the given devpath, + * and its string identification. + * + * @param devpath path to the device directory ("/sys/.../devices/") + * @param devid identification of the device () + * + * @return + * -1 unbind has failed + * 0 module has been unbound + */ +int rte_eal_unbind_kernel_driver(const char *devpath, const char *devid); + +/** * Get cpu core_id. * * This function is private to the EAL. diff --git a/lib/librte_eal/linuxapp/eal/eal.c b/lib/librte_eal/linuxapp/eal/eal.c index 2075282..5f6676d 100644 --- a/lib/librte_eal/linuxapp/eal/eal.c +++ b/lib/librte_eal/linuxapp/eal/eal.c @@ -943,3 +943,29 @@ rte_eal_check_module(const char *module_name) /* Module has been found */ return 1; } + +int +rte_eal_unbind_kernel_driver(const char *devpath, const char *devid) +{ + char filename[PATH_MAX]; + FILE *f; + + snprintf(filename, sizeof(filename), + "%s/driver/unbind", devpath); + + f = fopen(filename, "w"); + if (f == NULL) /* device was not bound */ + return 0; + + if (fwrite(devid, strlen(devid), 1, f) == 0) { + RTE_LOG(ERR, EAL, "%s(): could not write to %s\n", __func__, + filename); + goto error; + } + + fclose(f); + return 0; +error: + fclose(f); + return -1; +} diff --git a/lib/librte_eal/linuxapp/eal/eal_pci.c b/lib/librte_eal/linuxapp/eal/eal_pci.c index 876ba38..a03553f 100644 --- a/lib/librte_eal/linuxapp/eal/eal_pci.c +++ b/lib/librte_eal/linuxapp/eal/eal_pci.c @@ -59,38 +59,23 @@ int pci_unbind_kernel_driver(struct rte_pci_device *dev) { int n; - FILE *f; - char filename[PATH_MAX]; - char buf[BUFSIZ]; + char devpath[PATH_MAX]; + char devid[BUFSIZ]; struct rte_pci_addr *loc = &dev->addr; - /* open /sys/bus/pci/devices/AAAA:BB:CC.D/driver */ - snprintf(filename, sizeof(filename), - "%s/" PCI_PRI_FMT "/driver/unbind", pci_get_sysfs_path(), + /* devpath /sys/bus/pci/devices/AAAA:BB:CC.D */ + snprintf(devpath, sizeof(devpath), + "%s/" PCI_PRI_FMT, pci_get_sysfs_path(), loc->domain, loc->bus, loc->devid, loc->function); - f = fopen(filename, "w"); - if (f == NULL) /* device was not bound */ - return 0; - - n = snprintf(buf, sizeof(buf), PCI_PRI_FMT "\n", + n = snprintf(devid, sizeof(devid), PCI_PRI_FMT "\n", loc->domain, loc->bus, loc->devid, loc->function); - if ((n < 0) || (n >= (int)sizeof(buf))) { + if ((n < 0) || (n >= (int)sizeof(devid))) { RTE_LOG(ERR, EAL, "%s(): snprintf failed\n", __func__); - goto error; - } - if (fwrite(buf, n, 1, f) == 0) { - RTE_LOG(ERR, EAL, "%s(): could not write to %s\n", __func__, - filename); - goto error; + return -1; } - fclose(f); - return 0; - -error: - fclose(f); - return -1; + return rte_eal_unbind_kernel_driver(devpath, devid); } static int -- 2.7.4