From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM02-CY1-obe.outbound.protection.outlook.com (mail-cys01nam02on0060.outbound.protection.outlook.com [104.47.37.60]) by dpdk.org (Postfix) with ESMTP id 4A75656A8 for ; Fri, 28 Oct 2016 14:30:31 +0200 (CEST) Received: from BN3PR0301CA0066.namprd03.prod.outlook.com (10.160.152.162) by BN3PR03MB2370.namprd03.prod.outlook.com (10.166.74.153) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.693.12; Fri, 28 Oct 2016 12:30:30 +0000 Received: from BL2FFO11FD010.protection.gbl (2a01:111:f400:7c09::199) by BN3PR0301CA0066.outlook.office365.com (2a01:111:e400:401e::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.693.12 via Frontend Transport; Fri, 28 Oct 2016 12:30:29 +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 BL2FFO11FD010.mail.protection.outlook.com (10.173.161.16) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.679.5 via Frontend Transport; Fri, 28 Oct 2016 12:30:29 +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 u9SCPEME019399; Fri, 28 Oct 2016 05:30:27 -0700 From: Shreyansh Jain To: Date: Fri, 28 Oct 2016 17:56:19 +0530 Message-ID: <1477657598-826-3-git-send-email-shreyansh.jain@nxp.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1477657598-826-1-git-send-email-shreyansh.jain@nxp.com> References: <1477581467-12588-1-git-send-email-shreyansh.jain@nxp.com> <1477657598-826-1-git-send-email-shreyansh.jain@nxp.com> X-EOPAttributedMessage: 0 X-Matching-Connectors: 131221314299053774; (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)(189002)(199003)(87936001)(47776003)(105606002)(68736007)(8676002)(85426001)(6666003)(5660300001)(86362001)(77096005)(50226002)(2950100002)(19580395003)(6916009)(626004)(189998001)(586003)(36756003)(305945005)(5890100001)(7846002)(4326007)(2351001)(19580405001)(8666005)(8936002)(48376002)(11100500001)(97736004)(110136003)(229853001)(50986999)(356003)(106466001)(76176999)(50466002)(2906002)(92566002)(104016004)(5003940100001)(81166006)(33646002)(81156014)(7059030); DIR:OUT; SFP:1101; SCL:1; SRVR:BN3PR03MB2370; H:tx30smr01.am.freescale.net; FPR:; SPF:Fail; PTR:InfoDomainNonexistent; MX:1; A:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BL2FFO11FD010; 1:jehdT20DpgUg+KYCASymZBWD/DILF8jPy2T453LSiy3/w9Tb0lKgqMdZub/8Wz2Cg2a2oNkA5MsGQbfNaxvP+zC5i6IO/iYTLYyHn8I42CfiuWcHZdiny3EAjh4eZC4+4TlAFwc5+ichcEkdVIKls+UQ/MRHZmTy/xKN6orFnCj3+8gBWh7B2QrGqmPcimL1uhgJiZBdMdahCqtFwKqn6IpI+blXoerg7RAQ5pG1URkTKu67zV8VKCn5f8ZHxbdb1jlKM+Aq3vZweFeWuAajOAhPxOfcjWJSroUUXShjdcG7LDvcrak5CHgP0tF/XEg1O9jVamKbFKAFQ4iN/Ch76EKasnNzcpfN/XG4AgAzK/FxJ4/k9fVb67+1vb49HY87Qt0CeUw3eTrJ6uShi/RCj0mmYmfNhj/XEbZzmgUZ7z1mRM3t2IqxbJoo4Wq6eX+KoUidAsPdSrrT7KMU4saff4INDvI8tDOEg8oV7WpVqkjN/RK6vEyfGQMjALPAm9MG8DIZGSJtaPHCkDzabUsEwOOWhlO5Mocj/dMHry+08AIVRdFPy/HhEM8/75S5XW8Tk8zg5U/URaNYcdcxFAB4ww3ghJj+fuNNCQ7mf8O/2jvuukDzaaJ4aTxbBIYtilC4aaYIoxtMyD2JI8eqaChY5m1dg90oM0gyf3FJeev51ZdoO6sF5ZJRB+9+reJ9u2tJbb9aBoJggVOwQqvTIZwTmhELqJzfAFnmv0gfdhplU6k= MIME-Version: 1.0 Content-Type: text/plain X-MS-Office365-Filtering-Correlation-Id: 64d5623d-3f86-46d8-e570-08d3ff2e3435 X-Microsoft-Exchange-Diagnostics: 1; BN3PR03MB2370; 2:XNjabd2oQHIw/ALza7PSl3A/eEtnsHDhi8mTjaykoKO3kOyRDKKowuEmcDH2qO7rV4VuDONHzZ/Z/9G6UqQZGHrMvJ7JOOVTQ6tm3dpetnF92DH0AsiGuwDnCh7740ZmUOyvs5dgqp8H8+daFoGOUfRnDmDT31KJ24o8tNQzswwSV3jmaSbPIb5E9Y69kdPV5pc5VROvE14JAPs8NQr9BQ==; 3:0QeQAQ5HejMFok5sKwo7AgmbmRRsI/UQiLPd+NaX+AtJpAv4P6Da5INNF1kSkm548pt9G4BguLMvD1lhe/QgD5X5gU6vQTT07Bx2JtipbBnMWtnxbA4FAH3jp/GHVmsPv0bInvlCRJMjFAXeJtIuOhxaeUDyUu5IxFAfZttj/p8Ona/MFHe3IHI/Gxv9+ofg9TBnLOagOwaeniQ5No13/nN9vxlsm9uZDfFS/wqKnbUUmTFoh6oPvvNKEfiqStOc X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BN3PR03MB2370; X-Microsoft-Exchange-Diagnostics: 1; BN3PR03MB2370; 25:ZyeVAaDaf+Yu2CkMM+7m2eX11SZ8qPrLfjOsRDGVP/wNUx4DiAuq32QGe3Xsyi29rgRcNyWtFHEfzfqShj4o79/nEQ4B6qSBUP0wca3IOWF8ynGvIPzbofx/1K1bppp9MM+ig5YnceueURrfTnXGhsVdozNBRvIhPqEKKArOYKMezg3IMf6RhRF6s/jX1IX2xKQLP8r4tAWFByoc3GfpcGAjj3lWvlj8GGtdiZcWKKPmODJC2b2HFTE+yNQvjcczBdoA/c+2xUY+prS1FZ/XI8WV0pZEx9MKyIDjXkWZsVntf+iRKo2IYVVfZgVR6FsEI199/r2ApZi2KaZQEUn4pTazK1q99eNJCwdJ/cxnhTK7kA/ZdqFRSOBwqoq8BcaZNeJYxkzmVnd3X8CMLCa/JCH3/J3zAMuutopljiamtQQ2flWAvvuLBHHR3VPHbiz2IzVTIykhk8Gj8SE5eLAqWw==; 31:bG3mSQAHv0WYvICHRF78NYnmnFDhkMYpD6KqCv9YdrZdrveHDt5t1j/VM674sXPNKg0tNBCTY0F/NcJFafMUWDX599dT4Oc+VG2Fn0a7ZRP5bDoEkGqxAJMjQyZDN7Juci3u/+0KV+PccG6vkS3aizEiuOerG0XdPlncmvIN74J5bNIXdeIm+WevzX2U7KqxAyUxq/i6JZxoQUrPF3Rbv8pcOwkoW2FpVjdvHXTL1kdYU0S4h3kKn5m3Hig7NeT5VnOyqUu4L76KDdHhxtsHkA== 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)(13024025)(13015025)(8121501046)(13017025)(13018025)(13023025)(5005006)(3002001)(10201501046)(6055026); SRVR:BN3PR03MB2370; BCL:0; PCL:0; RULEID:(400006); SRVR:BN3PR03MB2370; X-Microsoft-Exchange-Diagnostics: 1; BN3PR03MB2370; 4:IHC60qxdJnfq3aT951fa99t4lEri+D8CzXp5d5Ym1+LSyWKL9MevsXuXVM0AoEKW0UhdqIuCnb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Q?zt0bE3ZRSLlQvEhya/bcvb/s7qJkq8FUl+Ov9lOaX7mY3bntp40lLHVIV2EA?= =?us-ascii?Q?75Y+q5foJ5kH+aTjE7XZHNH1wEe8NGyMHOK4ZMzMC3JVb3s1BTSiY/Zv4OnV?= =?us-ascii?Q?LVF53OeRjONepUhV8ey9cmNOCyZsYnzKyinE9E2bZSUAfcOQFKl+SXXBW6Y7?= =?us-ascii?Q?1SA259h74RKpZGtk9jz4YYgimPUCssN+DdUJC9o6bn7BPfiuBsDrNKHuPTn9?= =?us-ascii?Q?7FknzfJTwCSZVytbtkSL2PZbVcYDDSMbUG2PKrzGqEYTwMp4HB2ZBIfeODxr?= =?us-ascii?Q?+9eMMJIDm48dLaKgJSTX1nrlZSe361S4Z8MbCo/7uQUxULTrHleQ0TkcWFsq?= =?us-ascii?Q?xPLm2vLC6oyUbfN0D76XmzzeTD6oQeoIMxSOng7k4zOqoIWxkvqW+6M3GD4S?= =?us-ascii?Q?eZJSxqINLRMV1S3k87h4N+DQtYduQDgC33Mx8pnLYdtDKs379VZJEtUq7/JT?= =?us-ascii?Q?JJ38L6AoAJsdrX2figR10r730s414ZsnqV6+avARyy8IH/XlvZQxfza2B5Oc?= =?us-ascii?Q?MKNCJRwEP/HMnvPZHP4vmSVMsZ3pkSoDwLGkMhuBjD8tg5TC1U/iWw2b2jF5?= =?us-ascii?Q?YXuSui1Xf5+2iph7VftrfVqXeDegcKx8wCbxtvczJp1vwikrCSH9vgNecafa?= =?us-ascii?Q?t5pXhd50Bjchy8dFC+rTGE++/rGdTS+4Ocq8vzb8u1sVCM3a80ldXTjQTw42?= =?us-ascii?Q?iR5bpXMjGBVNeEReku/oo/CurwhwB0V7UD0QkPkTrQYgchZ5yQHykK104jgH?= =?us-ascii?Q?Ss04tq0n8YE/PXwilpdB4VAco1uQXGY6d2QA+QD6ai/z0t+60sJvrimkXamG?= =?us-ascii?Q?psxs+vlEMzdTTFiA0c=3D?= X-Microsoft-Exchange-Diagnostics: 1; B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SihzrjZM= X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Oct 2016 12:30:29.7181 (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: BN3PR03MB2370 Cc: Shreyansh Jain , thomas.monjalon@6wind.com, viktorin@rehivetech.com Subject: [dpdk-dev] [PATCH v7 02/21] 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: Fri, 28 Oct 2016 12:30: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 | 2 ++ 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 | 2 ++ 10 files changed, 89 insertions(+), 82 deletions(-) diff --git a/lib/librte_eal/bsdapp/eal/eal_pci.c b/lib/librte_eal/bsdapp/eal/eal_pci.c index 8b3ed88..7ed0115 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 2f81f7c..11d9f59 100644 --- a/lib/librte_eal/bsdapp/eal/rte_eal_version.map +++ b/lib/librte_eal/bsdapp/eal/rte_eal_version.map @@ -170,6 +170,8 @@ DPDK_16.11 { rte_delay_us_callback_register; rte_eal_dev_attach; rte_eal_dev_detach; + rte_eal_map_resource; + rte_eal_unmap_resource; rte_eal_vdrv_register; rte_eal_vdrv_unregister; diff --git a/lib/librte_eal/common/eal_common_dev.c b/lib/librte_eal/common/eal_common_dev.c index 4f3b493..457d227 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 @@ -151,3 +152,41 @@ err: RTE_LOG(ERR, EAL, "Driver cannot detach the device (%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 638cd86..464acc1 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 @@ -114,44 +113,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 probe() 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 6975b9f..5be6326 100644 --- a/lib/librte_eal/common/include/rte_dev.h +++ b/lib/librte_eal/common/include/rte_dev.h @@ -235,6 +235,38 @@ int rte_eal_dev_attach(const char *name, const char *devargs); */ int rte_eal_dev_detach(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 RTE_PMD_EXPORT_NAME_ARRAY(n, idx) n##idx[] #define RTE_PMD_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 2c7046f..7d6eef5 100644 --- a/lib/librte_eal/common/include/rte_pci.h +++ b/lib/librte_eal/common/include/rte_pci.h @@ -399,38 +399,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 83721ba..22b5b59 100644 --- a/lib/librte_eal/linuxapp/eal/rte_eal_version.map +++ b/lib/librte_eal/linuxapp/eal/rte_eal_version.map @@ -174,6 +174,8 @@ DPDK_16.11 { rte_delay_us_callback_register; rte_eal_dev_attach; rte_eal_dev_detach; + rte_eal_map_resource; + rte_eal_unmap_resource; rte_eal_vdrv_register; rte_eal_vdrv_unregister; -- 2.7.4