From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <shreyansh.jain@nxp.com>
Received: from NAM03-CO1-obe.outbound.protection.outlook.com
 (mail-co1nam03on0051.outbound.protection.outlook.com [104.47.40.51])
 by dpdk.org (Postfix) with ESMTP id AD2C168EE
 for <dev@dpdk.org>; Thu, 27 Oct 2016 17:17:34 +0200 (CEST)
Received: from DM2PR03CA0002.namprd03.prod.outlook.com (10.141.96.12) by
 CY1PR03MB2378.namprd03.prod.outlook.com (10.166.207.153) with Microsoft SMTP
 Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id
 15.1.679.12; Thu, 27 Oct 2016 15:17:27 +0000
Received: from BN1BFFO11FD041.protection.gbl (2a01:111:f400:7c10::1:169) by
 DM2PR03CA0002.outlook.office365.com (2a01:111:e400:2428::12) 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; Thu, 27 Oct 2016 15:17:26 +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
 BN1BFFO11FD041.mail.protection.outlook.com (10.58.144.104) with Microsoft
 SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id
 15.1.679.5 via Frontend Transport; Thu, 27 Oct 2016 15:17:26 +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 u9RFGIfW027183;
 Thu, 27 Oct 2016 08:17:24 -0700
From: Shreyansh Jain <shreyansh.jain@nxp.com>
To: <dev@dpdk.org>
Date: Thu, 27 Oct 2016 20:47:28 +0530
Message-ID: <1477581467-12588-3-git-send-email-shreyansh.jain@nxp.com>
X-Mailer: git-send-email 2.7.4
In-Reply-To: <1477581467-12588-1-git-send-email-shreyansh.jain@nxp.com>
References: <1477310380-17944-1-git-send-email-shreyansh.jain@nxp.com>
 <1477581467-12588-1-git-send-email-shreyansh.jain@nxp.com>
X-EOPAttributedMessage: 0
X-Matching-Connectors: 131220550468290663;
 (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)(76176999)(36756003)(2950100002)(97736004)(356003)(77096005)(50986999)(104016004)(189998001)(6916009)(92566002)(5003940100001)(7846002)(87936001)(2906002)(305945005)(47776003)(8666005)(85426001)(5890100001)(586003)(4326007)(2351001)(105606002)(106466001)(229853001)(86362001)(33646002)(8676002)(48376002)(8936002)(19580405001)(68736007)(19580395003)(50226002)(110136003)(81166006)(11100500001)(81156014)(5660300001)(50466002)(626004)(7059030);
 DIR:OUT; SFP:1101; SCL:1; SRVR:CY1PR03MB2378; H:tx30smr01.am.freescale.net;
 FPR:; SPF:Fail; PTR:InfoDomainNonexistent; A:1; MX:1; LANG:en; 
X-Microsoft-Exchange-Diagnostics: 1; BN1BFFO11FD041;
 1:MT+NDHPnogyFT+UM4OyLkM9dp8a/4p7EI+QCAIk7qxV6sTnYEzno80TT7tIn6oQdSyWd9d3f4OTdbP7rCuZyH6cjjzplOnYNH5bvVAO5H9XVf3+gy7YE2wyyaMqUUHhc+cSzgIvqj8yxBYLGveH+Z1QoqR4geHgNF0qNr6EuaqiWdOCkpcXjQgJuGU/vhYG2Vtt/e2124/VS932MIiqpdnctkkIDh4YWvJmIf1TvAt4A4aQ+doC5yBwRoqptF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2dAvxsN0CcFqAVrr4P80M3jF65zO5SbrQ7HGzo6mwtSUIBYLevJFRY17zQbcXH5JozD8vskh5anOrP5HpP2JviE5z1OW6BKIMRGvb2fQYobXyIvmAuQpt9mbe58Va5XO4bkzlbR1aiwPOEwPQAGcxNzhgeW99laZtxdkCZZ/pACzHPmvCDCuilnic1jcyC3NUl6PAKR073nryA==;
 4:4rxTnWTR7CiOs7j2W0Ijq7dS11ZGbnH16fVVkqGOBIYNab8P/77+YfIumG1BGrAcm8XQB3ypQIWYcq0xRg7SKxg+WRAVo7bUbRkTiAWTieRxuvaJ5Q0dvxlaBP9IEOu5jN9AOa3g/rUg4mjyzL9viV0RfFr+PTDoWIICOI8z0NtXPxxoqP5dXfHEsuHx71rg/k2o9e/RgsX7fXwWHfBxumy73LndvxEosGDk5alO15pJz/mPziwNY4NXFmp8XMN5ITEtCq2Ert9ATWNNxUTUUg37y4HYgRENLYUo/1aEHW/8VIwJNFxb2hbcclQYQFi17GvifwgidCs5H4x7OdW+jfptNB3srM3oxNgeiXIymlVkgItj/zPHd18/KtgMOJtr5E0sFzY4vp6p7HfyE8m/UJiyFuowm6bqP96ajaMkAw7o5iObbxMSv3S31XfUfMLNa01BtGYug8304huhHAh0mupBY3vKDPFsaFpqecHu4cPVivB0EtmIbTMqJ/GkapIwKXMCq9Sdj3EfPhOeQ9EoJDHXD3c0DuPIsMg2HgK6HrSN78jyD6bq4IN4e5aQVTmB
X-Microsoft-Antispam-PRVS: <CY1PR03MB2378B4032E8ECE935EE24EE590AA0@CY1PR03MB2378.namprd03.prod.outlook.com>
X-Exchange-Antispam-Report-Test: UriScan:(185117386973197);
X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0;
 RULEID:(6040176)(601004)(2401047)(13023025)(13024025)(5005006)(13018025)(13017025)(13015025)(8121501046)(3002001)(10201501046)(6055026);
 SRVR:CY1PR03MB2378; BCL:0; PCL:0; RULEID:(400006); SRVR:CY1PR03MB2378; 
X-Forefront-PRVS: 0108A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Tm6nyO8aJYGOUOrHO63lkjOJN70a0KGRsNi9Ztejg4h;
 24:35QeX5GkfRC/5t5nnMJjA11aRl76wbFzrmULYocXx6I3Rfks7rF33VuiPkFKRiGtkbR4jJvVRxL5aHmH0h+wY6jTQW94+3T40DEp4TXle+I=
SpamDiagnosticOutput: 1:99
SpamDiagnosticMetadata: NSPM
X-Microsoft-Exchange-Diagnostics: 1; CY1PR03MB2378;
 7:E5xaDPXQfWj8yCpKW4RRd0ZOc2qO0rxKtd+zxTmyrWLx+Ezcnp/lsntjFUMgjerNbpv66LUr5eGvBX9b7BpLMmUZQk+z/hyzcNd5vYwREVS8T+JEzeXclbRWclUTJzaXEfXUJ2my0FJ9uu2G5B0WeNBnUUqK4ktMzsCEqd0TaB2KZKGXNcHQvbbf2/oGzdBFZAhQ7n5QfOjoiZUlQZSSNoA8trI+WjICEPw9jStm+PSW+Q9+vwCI3fFo9kd27e4qRvOYI6XZKbOWYYn+kOcDlM67JiMOaIW17gn2iCEH5e0dQU/g3JSsOVKYcs8jpKABgOnMcYl1N3eOkHpC4e3wO90qFyOuPHTTw6lJrGnFAac=
X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Oct 2016 15:17:26.5014 (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: CY1PR03MB2378
Cc: Shreyansh Jain <shreyansh.jain@nxp.com>, thomas.monjalon@6wind.com,
 viktorin@rehivetech.com
Subject: [dpdk-dev] [PATCH v6 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 <dev.dpdk.org>
List-Unsubscribe: <http://dpdk.org/ml/options/dev>,
 <mailto:dev-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://dpdk.org/ml/archives/dev/>
List-Post: <mailto:dev@dpdk.org>
List-Help: <mailto:dev-request@dpdk.org?subject=help>
List-Subscribe: <http://dpdk.org/ml/listinfo/dev>,
 <mailto:dev-request@dpdk.org?subject=subscribe>
X-List-Received-Date: Thu, 27 Oct 2016 15:17:35 -0000

From: Jan Viktorin <viktorin@rehivetech.com>

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 <viktorin@rehivetech.com>
Signed-off-by: Shreyansh Jain <shreyansh.jain@nxp.com>
---
 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 <string.h>
 #include <inttypes.h>
 #include <sys/queue.h>
+#include <sys/mman.h>
 
 #include <rte_dev.h>
 #include <rte_devargs.h>
@@ -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 <stdlib.h>
 #include <stdio.h>
 #include <sys/queue.h>
-#include <sys/mman.h>
 
 #include <rte_interrupts.h>
 #include <rte_log.h>
@@ -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