From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM02-CY1-obe.outbound.protection.outlook.com (mail-cys01nam02on0058.outbound.protection.outlook.com [104.47.37.58]) by dpdk.org (Postfix) with ESMTP id 1EE90532C for ; Thu, 1 Sep 2016 06:42:25 +0200 (CEST) Received: from BN3PR0301CA0033.namprd03.prod.outlook.com (10.160.180.171) by SN1PR0301MB2016.namprd03.prod.outlook.com (10.163.226.26) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA_P384) id 15.1.587.13; Thu, 1 Sep 2016 04:42:23 +0000 Received: from BL2FFO11FD028.protection.gbl (2a01:111:f400:7c09::119) by BN3PR0301CA0033.outlook.office365.com (2a01:111:e400:4000::43) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA_P384) id 15.1.599.9 via Frontend Transport; Thu, 1 Sep 2016 04:42:22 +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 BL2FFO11FD028.mail.protection.outlook.com (10.173.161.107) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.587.6 via Frontend Transport; Thu, 1 Sep 2016 04:42:22 +0000 Received: from Tophie.ap.freescale.net ([10.232.14.87]) by az84smr01.freescale.net (8.14.3/8.14.0) with ESMTP id u814g8R1029498; Wed, 31 Aug 2016 21:42:19 -0700 From: Shreyansh Jain To: , CC: , Shreyansh Jain Date: Thu, 1 Sep 2016 10:11:53 +0530 Message-ID: <1472704915-13112-4-git-send-email-shreyansh.jain@nxp.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1472704915-13112-1-git-send-email-shreyansh.jain@nxp.com> References: <1472704915-13112-1-git-send-email-shreyansh.jain@nxp.com> X-EOPAttributedMessage: 0 X-Matching-Connectors: 131171785426352647; (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)(199003)(189002)(92566002)(626004)(8666005)(356003)(305945005)(7846002)(76176999)(11100500001)(50986999)(8676002)(8936002)(50226002)(81156014)(81166006)(2906002)(4326007)(68736007)(5660300001)(189998001)(586003)(47776003)(69596002)(5001770100001)(229853001)(97736004)(33646002)(36756003)(104016004)(5003940100001)(19580405001)(19580395003)(48376002)(86362001)(77096005)(105606002)(87936001)(2950100001)(85426001)(106466001)(50466002)(7059030); DIR:OUT; SFP:1101; SCL:1; SRVR:SN1PR0301MB2016; H:az84smr01.freescale.net; FPR:; SPF:Fail; PTR:InfoDomainNonexistent; A:1; MX:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BL2FFO11FD028; 1:ZskR6gSNNexuLGU7XdwXEClHuSkdoZ0KJ+Roc9QoT0dhd3neYfVK7OZf31Pl/krGvBZJWE4NJQIb0n3ks0Ymyuy00OGP57abBfVqxouOo9VJ1ZvhoDGV2FBBHsmO40WaLRKxwklDJ2gUk3ZcdM7l9+Jo0+p8qp8d6n2SSoE3y24r+fzVRttP3jr634fUzUq3+TOxlpEqM2Y/z+urOSZD/Eytai9V74AvxBxIXSvMVtv1NzpKsUKbVlM+fL2psyPtvb/jjPZXwhMNs7PmUwdQOOkVjItO0pKHHXf+/aIM+UBM/gV4ZSXdZQ5LRp+OK4A3wEcxihChtK2gKrtuUYDoduQcUZTmdbtM84evBuT2ZW8HojeZtPmpe8ZWGV+CXp97KSuAF5ChIoZ+y90ET6Cz9Me4mkFJZHJaJIvtRoxr/x0cTH3NZWWcXn+TsU4ortHTkA5Wd3nkPgWIwsaX3zGRDF/MOsOMUeSfRXpM5tJGOz49/8tuAeFzGqO3UWqRGg3SHuwsoRZjDSNF6hglfpqwOGCnd0Qg6BeshkXbD7SgOuuQoOpM7hX92b01dkh3uDerHS5I3XXDircpJ5TIh6mzhGQApNySZ09Oh6UWDrWcnJk7aPB94xhv3+36YO0sWYX6a+7aaFm2NEW1JJm/TtFzbUdAquk+i7jVACBO6dF67cCYKELO4kElCn/7pYCn3Cbxz96S7nG6FYPs9aA3oo5Qp6We+ygPAM6jqOemmi+4QDo= MIME-Version: 1.0 Content-Type: text/plain X-MS-Office365-Filtering-Correlation-Id: 0cc44b88-770c-4960-d8a6-08d3d2225d58 X-Microsoft-Exchange-Diagnostics: 1; SN1PR0301MB2016; 2:7MgjVJQmRtFDI/DCY2irApo4u51Nlyah6JNilMoQVLvUByQEvy9ddPg+C9aPxfwpii43ZrCCvGnpzF3pdD8hiKyQ3foi5iR7YzIjhjDNwxWG3mwLsYggpPOAFqSiUDIaFwwhtcNjIP/tdSpVWHBbzyTtuemRc5Uqu8KfGkDNam/cGqMJ6dbupC5A4xBXU2EV; 3:aQQtgvB3wrk32h5toGVtUx2EpMdDZsPi85ZOfCwXV8pr5PwVl6T3Th23PDH8yAyNcR50UeZsPvA7T/nd8pw7+tWk3SXAWvI291bAR3Qp6/qfxO6DEUnPEqsM6QFY84Zo/xHRFPyaakcabDWBAFa6En1Wo32s3NSb+ad4H5oDar/sXVY/0yuImPZjVNE5qI2SKSf4dOtH1Oo0jGAXrc2Nb0bVm+jEnfump6vaR5TDofM=; 25:QLa4RSLvrsLTxNJCgvQ5+eJxAOnwC2+0ll+37tTwI0i+4OtYBQ1etb6XY4+96FnSBt6OCeYYBZaKDa0Y0fxRCHfjxR6LurWPtvyMBRa+hxJTfHphPaIbOO5qJy3osR6iShPGQjhmCqBToM13rGtRRbBIoXo5D+GxTmvmqL4b9OOgC/p/R8l8iPtnH97hY9jfGt5F7yhK4lxJ1XodLJY+YKz+9eUgWxcTsT677wsUoDS1wQq0EVbv/HFv2DVmFXZQJGyMuvQIO5S8h/cSvmfkFI2pPpdLADsG4EloU74PChk7AzOAckus053CnkvkYnRKdySkX93NUxkDTDoW5WebEDXlaGIxApVjqfeJhTaeusKty4JWaLzgyIjux7i/0Qm/Sr4IswX1sEh/1bKXkik2Wr9Gj8NZZTqFh/fZacPLSzs= X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:SN1PR0301MB2016; X-Microsoft-Exchange-Diagnostics: 1; SN1PR0301MB2016; 31:IcpB9FYtb9HG/hBhxTBePXZSFL5k2HwAHFtrCPlMZuPsqInrHjtq07Z2Gqzq0JUNx26p8wIqhFLo4ieBdN1zBYr2TB9ytnitdJWGIAA5nsWviQNNnaZ3Aozv2bE65eVaaSx7V2oji6KQFQzegeekpvU0bPSct8V0v31E5L8RWluxFrmz0LtC/7IY5kw4jFAFF1Rm73v5vuMfArTtXn8PJR+x/VqGP5j7ZGsLMTaBKIU=; 4:RiwjkxBcgCGvuFFzuV9LqfEbHwr5sdiYmcWnVGBaiCENCpVVPMrnRgFFsq7qFbS8f4yOTkkK2UDZXmGwFIVKJlVgyKpyTe+CmebbG6pEE7VDou5XXhoXrudDVEbf0vh1BVpO96y1W/VcJG8Hen+4hspQohLvnto1ew+Qu5m8ZqVbael8Fzw0YFjZ5lEwKWtNmcIamvzIbb6Q0W+jZlB2njVaShFQFhOfnoiDxcx1iiOdONNBey1zI/Q6KxkYt23TZ9WEVjM+tJ45HeXwZbYtKhtO5JNtK1bpFpu/NYav04KDq3eq9e3Yo1G/04BIhyYCg8wrwSpohRGsipoLUBdgulzCGmFFB5oFfRjRSJuu6ZB3kAkTwX3CyyizwGK7RIsJUOk9h9dfkgeenpK/vO1dY/tzNQeSD/x0HM78jiK6UE2xcYMKPoHD1QeuksMexgN0aHUplHdWKs3+qu+77xhqneIAj4fbDHiTPp/nIvxe1DP4OONfM48g4BW884fSB5Wal5W9HXMp22GqmesJFaZAheezusytPZVLQ9xJbREo86M= 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)(8121501046)(5005006)(13015025)(13017025)(13024025)(13023025)(13018025)(10201501046)(3002001)(6055026); SRVR:SN1PR0301MB2016; BCL:0; PCL:0; RULEID:(400006); SRVR:SN1PR0301MB2016; X-Forefront-PRVS: 0052308DC6 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; SN1PR0301MB2016; 23:t9dU9IBcz5tgoJUltv0HM5Bj3metE67Z+PH4PKm?= =?us-ascii?Q?dIhzAqXYTbfdvp7tULxCGpDDVgSy4wjDm2/eMDRMpLpltzn7BrSJ4enUtzqx?= =?us-ascii?Q?ZIMQTkO8MrHM3rkvXbYY+MN6y+3wt8lTZCnroi4n/Woi+q+HNDZgYxv8BvRY?= =?us-ascii?Q?W6OwXSAVg+gk5L7hzFfg2/u5SP7B8NjN/WhG/HkDRsYPrA7l+oHx9QC/N/Ad?= =?us-ascii?Q?GyPE0wVXb10BeA0eHEvTUApxSURZolnhuzOEbmclOPwJ4AIN13JKJxD3L163?= =?us-ascii?Q?IjiUW3wOh524re0jQEzqX6Qhvy36WRw6QZQfNQqkFdcEeSRDLvv6ZCFpkKC2?= =?us-ascii?Q?ssJaT6uJLDe0dEis87TWk+302miljgQWIpsesVOMAuGOk1c5qR2O1+uUDFoN?= =?us-ascii?Q?Fz0Gi3gW0rlbjRiL1LdIoQAFGxfm2ZD/k1pTLTpXNMn9ugy35dMGxc+SjEJd?= =?us-ascii?Q?W4mhLP+bNzB0iA+IcbhShkXeXQV6BhQs5WQwYPSyoIzmB5JzRgtH1fSDZy5E?= =?us-ascii?Q?aKy48svvCnuzDtKwu/L+FF2rxz1QLpz3cW7yvjksj9rzg+bJSMmZU0Fw6Odf?= =?us-ascii?Q?yt5n59kZLKSVsmGGcwyaWH25M+KZTLhrr9XiKbwdZ4GpcaPTEvtzsVTjzzlW?= =?us-ascii?Q?ak4AcXTKWDC0UqoympSL2odOPuqaweb+aWr2xzDOe6paJ9Kih1jGeprFpUgV?= =?us-ascii?Q?sUnZ5kCRJoqcQdYJdqWb2utyoOExFFdZX3xGSoe60hnCGNs4lliRxxCCjilo?= =?us-ascii?Q?roz0eSNUWfAEVRIL0/FhwT13bxaarE43snAUCFLv3zRr5a/eON60WbkQp/PM?= =?us-ascii?Q?iDOSTCIZdPP+oOejFDOX9E/Je5obu+mJulGsxNxgScy8lWzXtq3NvZvKGbWj?= =?us-ascii?Q?YmBCbce4s9UxBeWEmCOakxgTAfcUK5zWLf1fWfgo8EulHnrD1A7upQT7N5PK?= =?us-ascii?Q?zUziT1vt3d2+RQ8opsg4HvUrfwPVf85quSkwELIBYkEjNHw8wKc2QDRuJ5lP?= =?us-ascii?Q?anKoMHOXrXZCJGezwEl+MNypebFUM5J9NPuK5r+tipcW4MA0I04iYOuOAhnf?= =?us-ascii?Q?DL11e8Rf9wFaDc72vDHyifn7uxHgF35uLCu9Fyg5QX56XMLOFjlvS7v2Vqeh?= =?us-ascii?Q?8wPUqan4DYNaF/t21UuWZU2/7kY5LzyqtmCumLc7YLryozUbKTJheCRuwOle?= =?us-ascii?Q?EciBSYvRmiwxxJDk=3D?= X-Microsoft-Exchange-Diagnostics: 1; SN1PR0301MB2016; 6:XRbR61AXMHGt7PvUOirIXI8O/ElaAAyQn32dhiDjDOrNwBv2hxFNygK445T/Pb+KB3Eb2ap8suISstriQGIbTKxmiM6WM8geqGJoDm09PUmZbEguLgRsvrbcvHODADaYfTRduGV1SI+cdCuWWo/psD6ElqNY7WRIY94nz+26jgJZ2yCTkOkfqqv0Oeu+2b7Zb+BV/TcwEK2A76G82CEDvVt141smRzV87Rh9dJmYe4Cf2IMBEkKB0LmWX0gpbCyS9JtKyqrqlB1oKcQNr/UJjO2q/T/470KmBoilSkE5wng=; 5:2AXbUWLju3doFtBT4bP5m+VPSKPw9h7FJvwBqpaPmCqqKmn2Ev7MqQhgr9gV1htsdbpDPiG6ieU+iWnEMJWpvylCA/UC6larcWos1ujM58p5qJ57PxcXLYAtrRUkrhmjOl8v8ZVlmsE7otkLsZ1TFwWRyHUz1ZFXmozU2c0pYIU=; 24:d6mcRKed5veuINQYOM9IOW6CTRX0V5+aCB/sK73W3r8Ahmbt9PzNDX7QAi17/xrRca9bJChN8TaS6CR+EUut3NaAINb34Lr3E+2JVuDGZWM=; 7:xuuiq0rrlCkiQhZbyqD2IyohBqdCKZy+O9WktsE0YJ8JLXlYl//9k2id/Nk1KleLravfBtFT1FHadSQMx9U4xJxvbRtAuG8nwKYdUvzCbwCSlyWgRrC9Wmdusj55VtCtm+adyxMpAYlQu5D9vJCU1pDzLDou8T0Btb0WxWqS+vq9unKKlFe6dPzS7B4SoBCrZ5+kUKDA1UuXtYpSTuLdq4Z+rkZsztM/t9l3le1azQIrVl69EXHtiMcSYFcwYIeZ SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Sep 2016 04:42:22.4012 (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: SN1PR0301MB2016 Subject: [dpdk-dev] [PATCH 3/5] eal: Convert pci_(un)map_resource to rte_eal_(un)map_resource 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: Thu, 01 Sep 2016 04:42:25 -0000 From: Jan Viktorin 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 a4c8156..78e0245 100644 --- a/lib/librte_eal/common/include/rte_pci.h +++ b/lib/librte_eal/common/include/rte_pci.h @@ -383,38 +383,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