From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM03-CO1-obe.outbound.protection.outlook.com (mail-co1nam03on0040.outbound.protection.outlook.com [104.47.40.40]) by dpdk.org (Postfix) with ESMTP id 2C2DF2B8C for ; Tue, 27 Sep 2016 16:12:31 +0200 (CEST) Received: from DM2PR03CA0053.namprd03.prod.outlook.com (10.141.96.52) by CO2PR03MB2231.namprd03.prod.outlook.com (10.166.92.136) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.639.5; Tue, 27 Sep 2016 14:12:30 +0000 Received: from BN1BFFO11FD044.protection.gbl (2a01:111:f400:7c10::1:188) 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.639.5 via Frontend Transport; Tue, 27 Sep 2016 14:12:29 +0000 Authentication-Results: spf=fail (sender IP is 192.88.158.2) 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.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 BN1BFFO11FD044.mail.protection.outlook.com (10.58.144.107) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.629.5 via Frontend Transport; Tue, 27 Sep 2016 14:12:28 +0000 Received: from Tophie.ap.freescale.net ([10.232.14.87]) by az84smr01.freescale.net (8.14.3/8.14.0) with ESMTP id u8REBqcf027766; Tue, 27 Sep 2016 07:12:26 -0700 From: Shreyansh Jain To: CC: , , , Shreyansh Jain Date: Tue, 27 Sep 2016 19:42:29 +0530 Message-ID: <1474985551-14219-3-git-send-email-shreyansh.jain@nxp.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1474985551-14219-1-git-send-email-shreyansh.jain@nxp.com> References: <1472704915-13112-1-git-send-email-shreyansh.jain@nxp.com> <1474985551-14219-1-git-send-email-shreyansh.jain@nxp.com> X-EOPAttributedMessage: 0 X-Matching-Connectors: 131194591488014988; (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)(189002)(199003)(87936001)(85426001)(8676002)(2906002)(626004)(5660300001)(4326007)(50466002)(8936002)(6916009)(305945005)(105606002)(81166006)(69596002)(2950100002)(7846002)(8666005)(110136003)(77096005)(104016004)(356003)(36756003)(48376002)(81156014)(68736007)(86362001)(189998001)(47776003)(586003)(50226002)(76176999)(50986999)(97736004)(33646002)(229853001)(5003940100001)(2351001)(19580395003)(92566002)(106466001)(19580405001)(7059030); DIR:OUT; SFP:1101; SCL:1; SRVR:CO2PR03MB2231; H:az84smr01.freescale.net; FPR:; SPF:Fail; PTR:InfoDomainNonexistent; MX:1; A:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BN1BFFO11FD044; 1:LDO+kUfO3nT1uSqr4qLeGyOmLOa04lznmdf+/7ze3qTVLQ7SPCJKTYsE9o2m34yd3vgafoUQvgPLuvgKFObsVG9cIoopbQJgHZsiMZ2ueWYeKigNKBEwiqj90/qg2xnlKXU9moRTdMFoxA5NNkALuNvaiVpDj+0J8VxbhroiuGY7MeDGmRekXY/D8wMskWOhVGNsyXvHXg2izLBDTLkseI0w55Ltsbb+c8dmXe0CvIrfqn6OggfRSanFAL/bPHPoc6C8fxGCFsijg7hYp/Ey+tPTUzfl/iMwjS0nj3cjDj4ayxyegOsRFaE6qg+pcXiA67JWMpK8hhnlADJA6BcpBIsE8uS+RaecUx4MuWZqBiv2Zp1eetePwSOGW5ytkjcGZh+qGs9bk2sPoVBiAW3m260zH/pOfyLCapSNHv7ctf6k0qqxkKpqvCunyB7r/eNBohHOsO2GY80VWVYhVEklbeZsZ7SLigYU/YPU+yWunu3Ozg4WZ+dLYO9gssiE/bMuv75YZ+6V/0M3GZWalWAbULrVCMAAU0MR2mAbHA2lkHTqHeOSQuaXuVSLFezDSC/y4EBIzTjfvXhBnGGPpvmTiFQ0K927nzZbfAknfS4galrpDpjtrAY7Dv2jWOUF0lT/q7eBpW14mpdmjT6rsZLznaIXNtW3qot+3tAP5HpISfBBKkG3RHoHx5ylam8gjzTAA8LHjSK/SBUeOVcfcdJKNKB80iCg+fKggWcNUEgjRW8= MIME-Version: 1.0 Content-Type: text/plain X-MS-Office365-Filtering-Correlation-Id: 9030ded6-e939-4ad4-192b-08d3e6e0508d X-Microsoft-Exchange-Diagnostics: 1; CO2PR03MB2231; 2:nSuW+31uJY8YOkYgqlpW30Ow8qzcwWl7abgtS43adHJThasdG/qTaHOFpA9ozU+ZeAtraA9LIbUiOiGEB66W+tALz3FNiuywpW4APBm6SnJrbUv9qJ31aR4iWT+9BQzMwU7ccKba+phhj6jajTPAiqZTLmq7+vdlZnIJIVdDT3BbEyTWxTBDAEaDRGg3ksMY; 3:JukxfYUR+w8Gvw0c4ZNhjtfiD4Y8TWGkHQ2HZlXOzhjmOy4+kxHCmCIAHL+KJOFcJE/l58mLGfYsT04+WwLxwX/1eEG3ySQ9SgJ/JRL2PCp2XQweA1SX/Kkb1TFu8cw1Tl0bKWO7zqR9jbTx5RKi9CyIyWqf2YPAI4PmI/OEFT1uDbOrQtM/vXTwE5B4bGdfFZoM8l7RAkT16v7W7MxJ/Kb/PAHmekWIQPlwnstjBNk= X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:CO2PR03MB2231; X-Microsoft-Exchange-Diagnostics: 1; CO2PR03MB2231; 25:AUjLmA1ZcaaAL+yfFsH0xBpauM7WsG/9hbtsZkuVrOgJiYoW+v6gXkVnX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2nCkUHLavgq469/GdKcvN13jWMjYWkaW3spWQ9af0rBmw+h9gq1IRBAKKEq8Vxb7K9F3FHLjM4HBS8ZfK7ktxKzdq6MLvbMCwVUjU4FZ+7vFItA5Y3vL4RyTL7N5/QrilxPCMm+V6TRUF2ugyy9fq6hKWkCQFSGSrcrH+RsSM/2bK/wVz37nGoQikyeT+WkEosAfkaVkKVq+WNLZaAFV9k74SqB1VrGBKIypegFm6drClZdCuKb50kgtOluGYy2eW4bI1C2FqIZ6pRwXCgBh+pxN51UywHbjmspZxiU/axvPznyzGycarSd3Wm80dZHeGtzmwUOhXKyoBCllqJNjg8wK4HY6Sf2oN7x9SxsF/hFPZEbHbzS7UFv5lJYfTqj0JhCTj5ezKl4u+d/ir83aCc1iRPnHBvasqDGwxkhHVx/g0= 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)(13023025)(13015025)(13017025)(13018025)(13024025)(5005006)(8121501046)(3002001)(10201501046)(6055026); SRVR:CO2PR03MB2231; BCL:0; PCL:0; RULEID:(400006); SRVR:CO2PR03MB2231; X-Forefront-PRVS: 007814487B X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; CO2PR03MB2231; 23:SGOzE47G2QYuHV4srrPBnRwBn4ounuWMeNkJKxROK?= =?us-ascii?Q?Ms+IpxBpmzrSEwP9XhMaJdDPCSQut6BiNVWBkhY44ayZqvSVacmxzhSTnfZv?= =?us-ascii?Q?NFe1myiw6WCzswOdTwbWJAkexDCfk6uu0HGyT0ClZQ6T4uq7fpZ+i0a7nyLl?= =?us-ascii?Q?t+EQUDG1rI6qa9ZLwTz/7WMcXG1hVpjH7ihepnmqFB1yHMqEZQ9imZD8Hrc5?= =?us-ascii?Q?DXLky+t3NXNQuYSVjjo1J213MxPamvOReicnJJIw+bdV/HuUw1JorViBc+nO?= =?us-ascii?Q?XJFFZ4TixzF+/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ascii?Q?bH0Zhy15HxwSL0=3D?= X-Microsoft-Exchange-Diagnostics: 1; CO2PR03MB2231; 6:/jr265X3uYvgdbf2dEp34bsVV7z60oA1DQqB1d4xGY8lAWfaMGGW1LS023b09Cqi4jUtJ3w1v5jRA2jV4KBPj8VpVWcF3tXEKouKYLgH23Cu/9Jb9epbaEXYyYSbWsLF2by1NpzbRdF1mH+IdcVla/RC8ZOb8Nygwa7u93Rof3Agbdp5fI/yCFfXwxNtaTHieDHoOU3xNcY5EHRV/fScydNoI+Zm7P+nlutXCzKn2oarjHEV5t2lxddHvOJU7uldQ6hfkNP9gAdvPefhcU64iZ/v1n6SShyg/kEkooyzGi8=; 5:JI9O86r3htD1WuKA3Lavw9hJVWZfPtx20Y8VELUI45YK/Ozzh6/Vl9EJ/06kcS4eCdj8TpeVehsMeIL3wzCI+lJkBJGNytSw7HsLGpFpjU0KWXu6WJa1qNc8+5aYYONMjeJza5/qS164gs9qk+iiZ5JQunqK4OxWN7Ok7fxPkTY=; 24:BVj7gPcqkJ1kotZXVnzgNZfbC5gKITWm6mhrh50VAlvG7YghyfUVqVYAxRAyhSImaRxYA3FU3I8dCRcd3BxIp2cK3C8Yd4DncoP7GBwJggg=; 7:ct5QTzN3RKfsbIGaQNFVcZy2TyEL3P8gQ9uLBgId4C73CsZ9GyQFlR/1oHcRmSFjOCC1ZMXGrs4NXa2ca2dJrK1FzyXhuq68M3XvhsemEEcXR4PFaC7bqbVCzwekaVIMV9E+dZw2EUHekJX2E6s6OJecTzAIu3B6rUFdL+NUDvAycx6JTQQ1+qqddGbmej6v3sPG9Emt2auMlW4E+b7fbSX7nz6rXmpAKtQQv5d5yqOxukqYFSIZEN1LpBTuu4s5wGOjjufav6w8lFSWCsWI2o7HvAtmfUecbcJz7aX6esVrKJP1QGmHcs40syJnd42P SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Sep 2016 14:12:28.5518 (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: CO2PR03MB2231 Subject: [dpdk-dev] [PATCH v1 2/4] eal: generalize PCI map/unmap resource 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: Tue, 27 Sep 2016 14:12:32 -0000 From: Jan Viktorin The functions pci_map_resource, pci_unmap_resource are generic so the pci_* prefix can be omitted. The functions are moved to the eal_common_dev.c so they can be reused by other infrastructure. Signed-off-by: Jan Viktorin Signed-off-by: Shreyansh Jain --- lib/librte_eal/bsdapp/eal/eal_pci.c | 2 +- lib/librte_eal/bsdapp/eal/rte_eal_version.map | 8 +++++ lib/librte_eal/common/eal_common_dev.c | 39 +++++++++++++++++++++++++ lib/librte_eal/common/eal_common_pci.c | 39 ------------------------- lib/librte_eal/common/eal_common_pci_uio.c | 16 +++++----- lib/librte_eal/common/include/rte_dev.h | 32 ++++++++++++++++++++ lib/librte_eal/common/include/rte_pci.h | 32 -------------------- lib/librte_eal/linuxapp/eal/eal_pci_uio.c | 2 +- lib/librte_eal/linuxapp/eal/eal_pci_vfio.c | 5 ++-- lib/librte_eal/linuxapp/eal/rte_eal_version.map | 8 +++++ 10 files changed, 101 insertions(+), 82 deletions(-) diff --git a/lib/librte_eal/bsdapp/eal/eal_pci.c b/lib/librte_eal/bsdapp/eal/eal_pci.c index 374b68f..c021969 100644 --- a/lib/librte_eal/bsdapp/eal/eal_pci.c +++ b/lib/librte_eal/bsdapp/eal/eal_pci.c @@ -228,7 +228,7 @@ pci_uio_map_resource_by_index(struct rte_pci_device *dev, int res_idx, /* if matching map is found, then use it */ offset = res_idx * pagesz; - mapaddr = pci_map_resource(NULL, fd, (off_t)offset, + mapaddr = rte_eal_map_resource(NULL, fd, (off_t)offset, (size_t)dev->mem_resource[res_idx].len, 0); close(fd); if (mapaddr == MAP_FAILED) diff --git a/lib/librte_eal/bsdapp/eal/rte_eal_version.map b/lib/librte_eal/bsdapp/eal/rte_eal_version.map index a335e04..6dd4186 100644 --- a/lib/librte_eal/bsdapp/eal/rte_eal_version.map +++ b/lib/librte_eal/bsdapp/eal/rte_eal_version.map @@ -162,3 +162,11 @@ DPDK_16.07 { rte_thread_setname; } DPDK_16.04; + +DPDK_16.11 { + global: + + rte_eal_map_resource; + rte_eal_unmap_resource; + +} 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..83aa1ca 100644 --- a/lib/librte_eal/common/eal_common_dev.c +++ b/lib/librte_eal/common/eal_common_dev.c @@ -36,6 +36,7 @@ #include #include #include +#include #include #include @@ -150,3 +151,41 @@ rte_eal_vdev_uninit(const char *name) RTE_LOG(ERR, EAL, "no driver found for %s\n", name); return -EINVAL; } + +/* map a particular resource from a file */ +void * +rte_eal_map_resource(void *requested_addr, int fd, off_t offset, size_t size, + int additional_flags) +{ + void *mapaddr; + + /* Map the Memory resource of device */ + mapaddr = mmap(requested_addr, size, PROT_READ | PROT_WRITE, + MAP_SHARED | additional_flags, fd, offset); + if (mapaddr == MAP_FAILED) { + RTE_LOG(ERR, EAL, "%s(): cannot mmap(%d, %p, 0x%lx, 0x%lx): %s" + " (%p)\n", __func__, fd, requested_addr, + (unsigned long)size, (unsigned long)offset, + strerror(errno), mapaddr); + } else + RTE_LOG(DEBUG, EAL, " Device memory mapped at %p\n", mapaddr); + + return mapaddr; +} + +/* unmap a particular resource */ +void +rte_eal_unmap_resource(void *requested_addr, size_t size) +{ + if (requested_addr == NULL) + return; + + /* Unmap the Memory resource of device */ + if (munmap(requested_addr, size)) { + RTE_LOG(ERR, EAL, "%s(): cannot munmap(%p, 0x%lx): %s\n", + __func__, requested_addr, (unsigned long)size, + strerror(errno)); + } else + RTE_LOG(DEBUG, EAL, " Device memory unmapped at %p\n", + requested_addr); +} diff --git a/lib/librte_eal/common/eal_common_pci.c b/lib/librte_eal/common/eal_common_pci.c index 7248c38..0818b63 100644 --- a/lib/librte_eal/common/eal_common_pci.c +++ b/lib/librte_eal/common/eal_common_pci.c @@ -67,7 +67,6 @@ #include #include #include -#include #include #include @@ -112,44 +111,6 @@ static struct rte_devargs *pci_devargs_lookup(struct rte_pci_device *dev) return NULL; } -/* map a particular resource from a file */ -void * -pci_map_resource(void *requested_addr, int fd, off_t offset, size_t size, - int additional_flags) -{ - void *mapaddr; - - /* Map the PCI memory resource of device */ - mapaddr = mmap(requested_addr, size, PROT_READ | PROT_WRITE, - MAP_SHARED | additional_flags, fd, offset); - if (mapaddr == MAP_FAILED) { - RTE_LOG(ERR, EAL, "%s(): cannot mmap(%d, %p, 0x%lx, 0x%lx): %s (%p)\n", - __func__, fd, requested_addr, - (unsigned long)size, (unsigned long)offset, - strerror(errno), mapaddr); - } else - RTE_LOG(DEBUG, EAL, " PCI memory mapped at %p\n", mapaddr); - - return mapaddr; -} - -/* unmap a particular resource */ -void -pci_unmap_resource(void *requested_addr, size_t size) -{ - if (requested_addr == NULL) - return; - - /* Unmap the PCI memory resource of device */ - if (munmap(requested_addr, size)) { - RTE_LOG(ERR, EAL, "%s(): cannot munmap(%p, 0x%lx): %s\n", - __func__, requested_addr, (unsigned long)size, - strerror(errno)); - } else - RTE_LOG(DEBUG, EAL, " PCI memory unmapped at %p\n", - requested_addr); -} - /* * If vendor/device ID match, call the devinit() function of the * driver. diff --git a/lib/librte_eal/common/eal_common_pci_uio.c b/lib/librte_eal/common/eal_common_pci_uio.c index 367a681..3402518 100644 --- a/lib/librte_eal/common/eal_common_pci_uio.c +++ b/lib/librte_eal/common/eal_common_pci_uio.c @@ -75,9 +75,11 @@ pci_uio_map_secondary(struct rte_pci_device *dev) return -1; } - void *mapaddr = pci_map_resource(uio_res->maps[i].addr, - fd, (off_t)uio_res->maps[i].offset, - (size_t)uio_res->maps[i].size, 0); + void *mapaddr = rte_eal_map_resource( + uio_res->maps[i].addr, fd, + (off_t)uio_res->maps[i].offset, + (size_t)uio_res->maps[i].size, + 0); /* fd is not needed in slave process, close it */ close(fd); if (mapaddr != uio_res->maps[i].addr) { @@ -88,11 +90,11 @@ pci_uio_map_secondary(struct rte_pci_device *dev) if (mapaddr != MAP_FAILED) { /* unmap addrs correctly mapped */ for (j = 0; j < i; j++) - pci_unmap_resource( + rte_eal_unmap_resource( uio_res->maps[j].addr, (size_t)uio_res->maps[j].size); /* unmap addr wrongly mapped */ - pci_unmap_resource(mapaddr, + rte_eal_unmap_resource(mapaddr, (size_t)uio_res->maps[i].size); } return -1; @@ -150,7 +152,7 @@ pci_uio_map_resource(struct rte_pci_device *dev) return 0; error: for (i = 0; i < map_idx; i++) { - pci_unmap_resource(uio_res->maps[i].addr, + rte_eal_unmap_resource(uio_res->maps[i].addr, (size_t)uio_res->maps[i].size); rte_free(uio_res->maps[i].path); } @@ -167,7 +169,7 @@ pci_uio_unmap(struct mapped_pci_resource *uio_res) return; for (i = 0; i != uio_res->nb_maps; i++) { - pci_unmap_resource(uio_res->maps[i].addr, + rte_eal_unmap_resource(uio_res->maps[i].addr, (size_t)uio_res->maps[i].size); if (rte_eal_process_type() == RTE_PROC_PRIMARY) rte_free(uio_res->maps[i].path); diff --git a/lib/librte_eal/common/include/rte_dev.h b/lib/librte_eal/common/include/rte_dev.h index 60bc91d..938f8c8 100644 --- a/lib/librte_eal/common/include/rte_dev.h +++ b/lib/librte_eal/common/include/rte_dev.h @@ -190,6 +190,38 @@ int rte_eal_vdev_init(const char *name, const char *args); */ int rte_eal_vdev_uninit(const char *name); +/** + * @internal + * Map a particular resource from a file. + * + * @param requested_addr + * The starting address for the new mapping range. + * @param fd + * The file descriptor. + * @param offset + * The offset for the mapping range. + * @param size + * The size for the mapping range. + * @param additional_flags + * The additional flags for the mapping range. + * @return + * - On success, the function returns a pointer to the mapped area. + * - On error, the value MAP_FAILED is returned. + */ +void *rte_eal_map_resource(void *requested_addr, int fd, off_t offset, + size_t size, int additional_flags); + +/** + * @internal + * Unmap a particular resource. + * + * @param requested_addr + * The address for the unmapping range. + * @param size + * The size for the unmapping range. + */ +void rte_eal_unmap_resource(void *requested_addr, size_t size); + #define DRIVER_EXPORT_NAME_ARRAY(n, idx) n##idx[] #define DRIVER_EXPORT_NAME(name, idx) \ diff --git a/lib/librte_eal/common/include/rte_pci.h b/lib/librte_eal/common/include/rte_pci.h index 108000a..418fd6b 100644 --- a/lib/librte_eal/common/include/rte_pci.h +++ b/lib/librte_eal/common/include/rte_pci.h @@ -384,38 +384,6 @@ int rte_eal_pci_map_device(struct rte_pci_device *dev); void rte_eal_pci_unmap_device(struct rte_pci_device *dev); /** - * @internal - * Map a particular resource from a file. - * - * @param requested_addr - * The starting address for the new mapping range. - * @param fd - * The file descriptor. - * @param offset - * The offset for the mapping range. - * @param size - * The size for the mapping range. - * @param additional_flags - * The additional flags for the mapping range. - * @return - * - On success, the function returns a pointer to the mapped area. - * - On error, the value MAP_FAILED is returned. - */ -void *pci_map_resource(void *requested_addr, int fd, off_t offset, - size_t size, int additional_flags); - -/** - * @internal - * Unmap a particular resource. - * - * @param requested_addr - * The address for the unmapping range. - * @param size - * The size for the unmapping range. - */ -void pci_unmap_resource(void *requested_addr, size_t size); - -/** * Probe the single PCI device. * * Scan the content of the PCI bus, and find the pci device specified by pci diff --git a/lib/librte_eal/linuxapp/eal/eal_pci_uio.c b/lib/librte_eal/linuxapp/eal/eal_pci_uio.c index 1786b75..5c34421 100644 --- a/lib/librte_eal/linuxapp/eal/eal_pci_uio.c +++ b/lib/librte_eal/linuxapp/eal/eal_pci_uio.c @@ -347,7 +347,7 @@ pci_uio_map_resource_by_index(struct rte_pci_device *dev, int res_idx, if (pci_map_addr == NULL) pci_map_addr = pci_find_max_end_va(); - mapaddr = pci_map_resource(pci_map_addr, fd, 0, + mapaddr = rte_eal_map_resource(pci_map_addr, fd, 0, (size_t)dev->mem_resource[res_idx].len, 0); close(fd); if (mapaddr == MAP_FAILED) diff --git a/lib/librte_eal/linuxapp/eal/eal_pci_vfio.c b/lib/librte_eal/linuxapp/eal/eal_pci_vfio.c index 5f478c5..5ad8cbe 100644 --- a/lib/librte_eal/linuxapp/eal/eal_pci_vfio.c +++ b/lib/librte_eal/linuxapp/eal/eal_pci_vfio.c @@ -465,7 +465,8 @@ pci_vfio_map_resource(struct rte_pci_device *dev) void *map_addr = NULL; if (memreg[0].size) { /* actual map of first part */ - map_addr = pci_map_resource(bar_addr, vfio_dev_fd, + map_addr = rte_eal_map_resource(bar_addr, + vfio_dev_fd, memreg[0].offset, memreg[0].size, MAP_FIXED); @@ -477,7 +478,7 @@ pci_vfio_map_resource(struct rte_pci_device *dev) void *second_addr = RTE_PTR_ADD(bar_addr, memreg[1].offset - (uintptr_t)reg.offset); - map_addr = pci_map_resource(second_addr, + map_addr = rte_eal_map_resource(second_addr, vfio_dev_fd, memreg[1].offset, memreg[1].size, MAP_FIXED); diff --git a/lib/librte_eal/linuxapp/eal/rte_eal_version.map b/lib/librte_eal/linuxapp/eal/rte_eal_version.map index db8c984..15e8332 100644 --- a/lib/librte_eal/linuxapp/eal/rte_eal_version.map +++ b/lib/librte_eal/linuxapp/eal/rte_eal_version.map @@ -166,3 +166,11 @@ DPDK_16.07 { rte_thread_setname; } DPDK_16.04; + +DPDK_16.11 { + global: + + rte_eal_map_resource; + rte_eal_unmap_resource; + +} DPDK_16.07; -- 2.7.4