From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM01-BY2-obe.outbound.protection.outlook.com (mail-by2nam01on0059.outbound.protection.outlook.com [104.47.34.59]) by dpdk.org (Postfix) with ESMTP id BC71C5921 for ; Mon, 1 Aug 2016 12:45:22 +0200 (CEST) Received: from BY2PR03CA065.namprd03.prod.outlook.com (10.141.249.38) by SN1PR0301MB2061.namprd03.prod.outlook.com (10.163.226.158) 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:20 +0000 Received: from BY2FFO11FD038.protection.gbl (2a01:111:f400:7c0c::148) by BY2PR03CA065.outlook.office365.com (2a01:111:e400:2c5d::38) 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:20 +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 BY2FFO11FD038.mail.protection.outlook.com (10.1.14.223) 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:21 +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 u71Aibjt018422; Mon, 1 Aug 2016 03:45:18 -0700 From: Shreyansh Jain To: CC: , , David Marchand Date: Mon, 1 Aug 2016 16:15:28 +0530 Message-ID: <1470048332-27318-14-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: 131145219212104570; (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)(7846002)(97736004)(76176999)(11100500001)(68736007)(50986999)(2950100001)(4326007)(2906002)(305945005)(110136002)(86362001)(92566002)(85426001)(15650500001)(356003)(47776003)(77096005)(48376002)(104016004)(105606002)(229853001)(19580405001)(19580395003)(33646002)(8936002)(2351001)(81156014)(106466001)(81166006)(5003940100001)(8676002)(189998001)(36756003)(50226002)(50466002)(586003)(87936001); DIR:OUT; SFP:1101; SCL:1; SRVR:SN1PR0301MB2061; H:tx30smr01.am.freescale.net; FPR:; SPF:Fail; PTR:InfoDomainNonexistent; A:1; MX:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BY2FFO11FD038; 1:JhOmAFevElFsRipoyLwymaSLUiYZ6/zx3WHBi7iIoufCEFez8eYS7AZyhRRt1z5gUCRGg0naPbJ6XtIkDNUuSSaPZG+Q5eI10JL0/ffRQXT1L1cdzo9Ng+ZDpdnCdfRB9vW7tYdKiRDZ3o8k3b8PAa3jd+FOWccil7Os+3LZVx9HiDYz+i8xm7O+dSkl7WiNPUscIIew55PAj4HaIuxSL4A64LFHwNasv0QOXX3SdsYWWizpkQtQfRIWPsKNBlQn25afR5nYthpZX7Tr3Kgk0aiNPNEPv6+kENlKjW+Pb3V79GoZBeTHZTWcAodWM+GfcDcrd5IKs5IULjxZ9Es8X5gTbbKf6qknXG3oMDkIrMGTdWdLl/3laDNrwpSaA6xVj1ISvadGxLIrZrIeiN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qdHjrVLUnkK2wkePbmtpxil0wbM0tgoR4akre1Rb+BsGqmqnh0QuwSQC8CBZLwkTcaqoK947Tn0ZWbNPlVse5kuQkMZ9orm3/UxP/0afoU/yo5fVsUR8NnnmSLZRKiAclXyN/LhiwCIJ36M7ghBqdMOGXNRo6qs= X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:SN1PR0301MB2061; X-Microsoft-Exchange-Diagnostics: 1; SN1PR0301MB2061; 31:e6yLP7uRLyHA+UOu2AfSUBI7S4ifVJRmVg7HbkNbQ+M8x4k+lqm0BUNJSOXJsqnTRh1JSPRGm3PH+pRf34edtHWIlCq40JM35WZzxCtGQvevPudpwf3b7tjGHVcq2Mp1N9wxc8CKn/dFA5ofIDLBJcrjwCyL7v5yUN64YcKae/IYqZeYVM8dqwZZow28imuUfEArt5HZr6JaxHa/BC0RAw==; 4:dVUfGfpgWyqlnlPsxgyG61rvlEpEAx3rLTs5MLi+J6KYhsmJjl3aq/UhnQU4wY0f8D2z7xiAYc4XcH4sWbmZEDp4WIm6z6TlTLeibZEmoMaX/JfSb9frL1DxwTt9OIbBK2vSzjiNN75e57nJeigC1fw/iBMT5fHTRGLTuyit9F/tVYPylHekzTKD/ZKt8kXtCMMVFOpUVsrDE50rGxnKYzMqoWGrNe5548NH3QOm/jZk4ECVx7XZ9gkhtYeeVI7z1Efjry7Jt+OaRwERnuWONFy69mB1Ul/VpkM13JHagDq8NdrExSsWLx6irfZy9opRrGi343vhLEf9i6DCFMfHrcQF5EFvx/Uywfs4WmzydxvDXGmQyTOitR2fyhBnzPoEAPOoEEyn6zdtxdTRkgkWd72L+RGlCtAaFeBFvcUD4suNYFvbGkooX4REsLwpVPRIzQwUWEgQHfzkVT6/F9CeNbXXTg5vhIaIYo42EI/ymbhYr0Yq7hH3a2TTup3iijL/JWM14GLmmYONL57VGASJWg== 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)(8121501046)(13024025)(13023025)(13015025)(13017025)(5005006)(10201501046)(3002001)(6055026); SRVR:SN1PR0301MB2061; BCL:0; PCL:0; RULEID:(400006); SRVR:SN1PR0301MB2061; X-Forefront-PRVS: 0021920B5A X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; SN1PR0301MB2061; 23:Rwakr6VONb53qeDQZo0v9feMR2lp2OSLC7jJ0ZI?= =?us-ascii?Q?VQplKXfAWWb/nNTQT/EV4yuqkeQrs/CCzBq/tu1cUdWhSkwyhuwqq4T2RiET?= =?us-ascii?Q?5Q84yz7qprDiOXOV+JP/zZ+xs8benVNgrQEZn4qJqOlxjwqPoJDeB5i8105O?= =?us-ascii?Q?cki3U/B5h7UE/pUxE552ysiOWnDlVdtKtNWgzQcU+L/SBN/01yLWssDQT0D7?= =?us-ascii?Q?vbRMGUpaGRdcCryjy+AaF2RvYSoOTfRlSDNp06nElbfjaTqJqNLisXKxD0Se?= =?us-ascii?Q?O4n86ifRiCwphg4R+dIqgGZi7yA34EUi6MJgayAQN07Xx9u2TwnCZj7o4JYF?= =?us-ascii?Q?0ekQb86AwieKxbxRiLDxbOKrVbmFWHwbrn3eRYoQO0sw7/9IoOYDF5OJITgs?= =?us-ascii?Q?GFysutJDBPdpXAjwaMsbNtmGl4DHxCaFCkS1TTgrvvQGSbKXfq/fvqyNG2Ab?= =?us-ascii?Q?ZeGiDFxfeE9E9p9f4uv2VhA1sGlXX+X02l2VhZV3GCex2svQ/bdiqDO2ueQq?= =?us-ascii?Q?xL7CJMm/hjfPzy6Yvi8caMsyT+UTJ9ezo0p5vkeYqEMxgxfwKT1Nyd4yODY6?= =?us-ascii?Q?1t7f+wVIQG8kbesDLUb5DA7Sxr432PtMqLpEH0h0ovGIfJMcCtv2kunrK2Rk?= =?us-ascii?Q?HUZMMJzvu6fiirgrVCpnMXwg4wSIcTKn4ziMdhBEE9lmq2p79bPJMqctWc+4?= =?us-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eFFeyxPCm3bSV5GNl2AdK60PsjlpFgYNhrweBO7uGA6W9ZaeudaDRA54txMx9Ka4ADv2Vkqh/Drg1qQJCsGc2C8CHGtE8=; 7:Ng4en6mFNO7NHGc93YiqUCZpUO/pQxEfI09/t8GEEPKLXR5vS3vBOEM/1/+OfksuVTcrDf1SjaxdAo0KbKDT+9KGm2AM6D90YRQkBZVKphbyoKqZjySHAunBQyiujUm05HEconNP09Q8qPK/hD2aXhpMcR7n4OsU8pu74bVwdVINzZ5Ny/dIyHqMgFB7rik9kupgWH6FPJSKfptujTfaB8OyhuMPsPnJUDPPe+mK755FluRgdl5giF+vwrzw30Bc SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Aug 2016 10:45:21.0076 (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: SN1PR0301MB2061 Subject: [dpdk-dev] [PATCH v7 13/17] pci: add a helper to update a device 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:23 -0000 This helper updates a pci device object with latest information it can find. It will be used mainly for hotplug code. Signed-off-by: David Marchand Signed-off-by: Shreyansh Jain --- lib/librte_eal/bsdapp/eal/eal_pci.c | 49 +++++++++++++++++++++++++++++++++++ lib/librte_eal/common/eal_private.h | 13 ++++++++++ lib/librte_eal/linuxapp/eal/eal_pci.c | 13 ++++++++++ 3 files changed, 75 insertions(+) diff --git a/lib/librte_eal/bsdapp/eal/eal_pci.c b/lib/librte_eal/bsdapp/eal/eal_pci.c index a73cbb0..1d91c78 100644 --- a/lib/librte_eal/bsdapp/eal/eal_pci.c +++ b/lib/librte_eal/bsdapp/eal/eal_pci.c @@ -406,6 +406,55 @@ error: return -1; } +int +pci_update_device(const struct rte_pci_addr *addr) +{ + int fd; + struct pci_conf matches[2]; + struct pci_match_conf match = { + .pc_sel = { + .pc_domain = addr->domain, + .pc_bus = addr->bus, + .pc_dev = addr->devid, + .pc_func = addr->function, + }, + }; + struct pci_conf_io conf_io = { + .pat_buf_len = 0, + .num_patterns = 1, + .patterns = &match, + .match_buf_len = sizeof(matches), + .matches = &matches[0], + }; + + fd = open("/dev/pci", O_RDONLY); + if (fd < 0) { + RTE_LOG(ERR, EAL, "%s(): error opening /dev/pci\n", __func__); + goto error; + } + + if (ioctl(fd, PCIOCGETCONF, &conf_io) < 0) { + RTE_LOG(ERR, EAL, "%s(): error with ioctl on /dev/pci: %s\n", + __func__, strerror(errno)); + goto error; + } + + if (conf_io.num_matches != 1) + goto error; + + if (pci_scan_one(fd, &matches[0]) < 0) + goto error; + + close(fd); + + return 0; + +error: + if (fd >= 0) + close(fd); + return -1; +} + /* Read PCI config space. */ int rte_eal_pci_read_config(const struct rte_pci_device *dev, void *buf, size_t len, off_t offset) diff --git a/lib/librte_eal/common/eal_private.h b/lib/librte_eal/common/eal_private.h index 06a68f6..b8ff9c5 100644 --- a/lib/librte_eal/common/eal_private.h +++ b/lib/librte_eal/common/eal_private.h @@ -152,6 +152,19 @@ struct rte_pci_driver; struct rte_pci_device; /** + * Update a pci device object by asking the kernel for the latest information. + * + * This function is private to EAL. + * + * @param addr + * The PCI Bus-Device-Function address to look for + * @return + * - 0 on success. + * - negative on error. + */ +int pci_update_device(const struct rte_pci_addr *addr); + +/** * Unbind kernel driver for this device * * This function is private to EAL. diff --git a/lib/librte_eal/linuxapp/eal/eal_pci.c b/lib/librte_eal/linuxapp/eal/eal_pci.c index f0215ee..62da4d4 100644 --- a/lib/librte_eal/linuxapp/eal/eal_pci.c +++ b/lib/librte_eal/linuxapp/eal/eal_pci.c @@ -417,6 +417,19 @@ pci_scan_one(const char *dirname, uint16_t domain, uint8_t bus, return 0; } +int +pci_update_device(const struct rte_pci_addr *addr) +{ + char filename[PATH_MAX]; + + snprintf(filename, sizeof(filename), "%s/" PCI_PRI_FMT, + pci_get_sysfs_path(), addr->domain, addr->bus, addr->devid, + addr->function); + + return pci_scan_one(filename, addr->domain, addr->bus, addr->devid, + addr->function); +} + /* * split up a pci address into its constituent parts. */ -- 2.7.4