From: David Marchand <david.marchand@redhat.com>
To: dev@dpdk.org
Cc: Ferruh Yigit <ferruh.yigit@intel.com>,
Anatoly Burakov <anatoly.burakov@intel.com>,
Dmitry Kozlyuk <dmitry.kozliuk@gmail.com>,
Narcisa Ana Maria Vasile <navasile@linux.microsoft.com>,
Dmitry Malloy <dmitrym@microsoft.com>,
Pallavi Kadam <pallavi.kadam@intel.com>
Subject: [dpdk-dev] [PATCH v2 4/6] mem: drop mapping API workaround
Date: Mon, 14 Sep 2020 10:23:48 +0200 [thread overview]
Message-ID: <20200914082350.13279-5-david.marchand@redhat.com> (raw)
In-Reply-To: <20200914082350.13279-1-david.marchand@redhat.com>
Now that the pci_map_resource API is private to the PCI bus, we can drop
the compatibility workaround we had implemented in 20.08.
Signed-off-by: David Marchand <david.marchand@redhat.com>
---
drivers/bus/pci/bsd/pci.c | 2 +-
drivers/bus/pci/linux/pci_uio.c | 2 +-
drivers/bus/pci/linux/pci_vfio.c | 4 ++--
drivers/bus/pci/pci_common.c | 1 -
drivers/bus/pci/pci_common_uio.c | 2 +-
drivers/bus/pci/private.h | 2 +-
lib/librte_eal/include/rte_eal_paging.h | 10 ----------
lib/librte_eal/windows/include/rte_os.h | 6 ------
8 files changed, 6 insertions(+), 23 deletions(-)
diff --git a/drivers/bus/pci/bsd/pci.c b/drivers/bus/pci/bsd/pci.c
index a07fc241fe..2ed8261349 100644
--- a/drivers/bus/pci/bsd/pci.c
+++ b/drivers/bus/pci/bsd/pci.c
@@ -192,7 +192,7 @@ pci_uio_map_resource_by_index(struct rte_pci_device *dev, int res_idx,
mapaddr = pci_map_resource(NULL, fd, (off_t)offset,
(size_t)dev->mem_resource[res_idx].len, 0);
close(fd);
- if (mapaddr == MAP_FAILED)
+ if (mapaddr == NULL)
goto error;
maps[map_idx].phaddr = dev->mem_resource[res_idx].phys_addr;
diff --git a/drivers/bus/pci/linux/pci_uio.c b/drivers/bus/pci/linux/pci_uio.c
index 9ab20a0b25..f3305a2f28 100644
--- a/drivers/bus/pci/linux/pci_uio.c
+++ b/drivers/bus/pci/linux/pci_uio.c
@@ -346,7 +346,7 @@ pci_uio_map_resource_by_index(struct rte_pci_device *dev, int res_idx,
mapaddr = pci_map_resource(pci_map_addr, fd, 0,
(size_t)dev->mem_resource[res_idx].len, 0);
close(fd);
- if (mapaddr == MAP_FAILED)
+ if (mapaddr == NULL)
goto error;
pci_map_addr = RTE_PTR_ADD(mapaddr,
diff --git a/drivers/bus/pci/linux/pci_vfio.c b/drivers/bus/pci/linux/pci_vfio.c
index c15ed3bade..34b5da80df 100644
--- a/drivers/bus/pci/linux/pci_vfio.c
+++ b/drivers/bus/pci/linux/pci_vfio.c
@@ -565,7 +565,7 @@ pci_vfio_mmap_bar(int vfio_dev_fd, struct mapped_pci_resource *vfio_res,
}
/* if there's a second part, try to map it */
- if (map_addr != MAP_FAILED
+ if (map_addr != NULL
&& memreg[1].offset && memreg[1].size) {
void *second_addr = RTE_PTR_ADD(bar_addr,
(uintptr_t)(memreg[1].offset -
@@ -577,7 +577,7 @@ pci_vfio_mmap_bar(int vfio_dev_fd, struct mapped_pci_resource *vfio_res,
RTE_MAP_FORCE_ADDRESS);
}
- if (map_addr == NULL || map_addr == MAP_FAILED) {
+ if (map_addr == NULL) {
munmap(bar_addr, bar->size);
bar_addr = MAP_FAILED;
RTE_LOG(ERR, EAL, "Failed to map pci BAR%d\n",
diff --git a/drivers/bus/pci/pci_common.c b/drivers/bus/pci/pci_common.c
index 3a2ae07958..62d45041bb 100644
--- a/drivers/bus/pci/pci_common.c
+++ b/drivers/bus/pci/pci_common.c
@@ -97,7 +97,6 @@ pci_map_resource(void *requested_addr, int fd, off_t offset, size_t size,
__func__, fd, requested_addr, size,
(unsigned long long)offset,
rte_strerror(rte_errno), mapaddr);
- mapaddr = MAP_FAILED; /* API uses mmap error code */
} else
RTE_LOG(DEBUG, EAL, " PCI memory mapped at %p\n", mapaddr);
diff --git a/drivers/bus/pci/pci_common_uio.c b/drivers/bus/pci/pci_common_uio.c
index f4dca9da91..793dfd0a7c 100644
--- a/drivers/bus/pci/pci_common_uio.c
+++ b/drivers/bus/pci/pci_common_uio.c
@@ -58,7 +58,7 @@ pci_uio_map_secondary(struct rte_pci_device *dev)
"Cannot mmap device resource file %s to address: %p\n",
uio_res->maps[i].path,
uio_res->maps[i].addr);
- if (mapaddr != MAP_FAILED) {
+ if (mapaddr != NULL) {
/* unmap addrs correctly mapped */
for (j = 0; j < i; j++)
pci_unmap_resource(
diff --git a/drivers/bus/pci/private.h b/drivers/bus/pci/private.h
index 9617268024..530123767b 100644
--- a/drivers/bus/pci/private.h
+++ b/drivers/bus/pci/private.h
@@ -132,7 +132,7 @@ TAILQ_HEAD(mapped_pci_res_list, mapped_pci_resource);
* The additional rte_mem_map() flags for the mapping range.
* @return
* - On success, the function returns a pointer to the mapped area.
- * - On error, MAP_FAILED is returned.
+ * - On error, NULL is returned.
*/
void *pci_map_resource(void *requested_addr, int fd, off_t offset,
size_t size, int additional_flags);
diff --git a/lib/librte_eal/include/rte_eal_paging.h b/lib/librte_eal/include/rte_eal_paging.h
index 429f896c8c..ed98e70e9e 100644
--- a/lib/librte_eal/include/rte_eal_paging.h
+++ b/lib/librte_eal/include/rte_eal_paging.h
@@ -3,9 +3,6 @@
*/
#include <stdint.h>
-#ifndef RTE_EXEC_ENV_WINDOWS
-#include <sys/mman.h>
-#endif
#include <rte_compat.h>
@@ -25,7 +22,6 @@ enum rte_mem_prot {
/** Additional flags for memory mapping. */
enum rte_map_flags {
-#ifdef RTE_EXEC_ENV_WINDOWS
/** Changes to the mapped memory are visible to other processes. */
RTE_MAP_SHARED = 1 << 0,
/** Mapping is not backed by a regular file. */
@@ -39,12 +35,6 @@ enum rte_map_flags {
* it is not required to do so, thus mapping with this flag may fail.
*/
RTE_MAP_FORCE_ADDRESS = 1 << 3
-#else /* map mmap flags because they are exposed in pci_map_resource() API */
- RTE_MAP_SHARED = MAP_SHARED,
- RTE_MAP_ANONYMOUS = MAP_ANONYMOUS,
- RTE_MAP_PRIVATE = MAP_PRIVATE,
- RTE_MAP_FORCE_ADDRESS = MAP_FIXED,
-#endif
};
/**
diff --git a/lib/librte_eal/windows/include/rte_os.h b/lib/librte_eal/windows/include/rte_os.h
index 2881bf2224..569ed92d51 100644
--- a/lib/librte_eal/windows/include/rte_os.h
+++ b/lib/librte_eal/windows/include/rte_os.h
@@ -25,12 +25,6 @@ extern "C" {
#define PATH_MAX _MAX_PATH
#endif
-/* sys/mman.h
- * The syscall mmap does not exist on Windows,
- * but this error code is used in a badly defined DPDK API for PCI mapping.
- */
-#define MAP_FAILED ((void *) -1)
-
#define sleep(x) Sleep(1000 * (x))
#define strerror_r(a, b, c) strerror_s(b, c, a)
--
2.23.0
next prev parent reply other threads:[~2020-09-14 8:24 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-09-14 8:17 [dpdk-dev] [PATCH 0/5] 20.11 announced cleanups David Marchand
2020-09-14 8:17 ` [dpdk-dev] [PATCH 1/5] bus/pci: switch to private kernel driver enum David Marchand
2020-09-14 8:17 ` [dpdk-dev] [PATCH 2/5] pci: move resource mapping to the PCI bus David Marchand
2020-09-14 8:17 ` [dpdk-dev] [PATCH 3/5] mem: drop mapping API workaround David Marchand
2020-09-14 8:17 ` [dpdk-dev] [PATCH 4/5] eal: hide internal device event structure David Marchand
2020-09-14 8:17 ` [dpdk-dev] [PATCH 5/5] bus/pci: remove duplicate declaration David Marchand
2020-09-14 8:23 ` [dpdk-dev] [PATCH v2 0/6] 20.11 announced cleanups David Marchand
2020-09-14 8:23 ` [dpdk-dev] [PATCH v2 1/6] ethdev: remove unused kernel driver field David Marchand
2020-09-14 10:14 ` Andrew Rybchenko
2020-09-14 8:23 ` [dpdk-dev] [PATCH v2 2/6] bus/pci: switch to private kernel driver enum David Marchand
2020-09-14 10:19 ` Andrew Rybchenko
2020-09-14 8:23 ` [dpdk-dev] [PATCH v2 3/6] pci: move resource mapping to the PCI bus David Marchand
2020-09-14 10:22 ` Andrew Rybchenko
2020-09-14 8:23 ` David Marchand [this message]
2020-09-14 10:22 ` [dpdk-dev] [PATCH v2 4/6] mem: drop mapping API workaround Andrew Rybchenko
2020-09-14 8:23 ` [dpdk-dev] [PATCH v2 5/6] eal: hide internal device event structure David Marchand
2020-09-18 14:56 ` Kinsella, Ray
2020-09-14 8:23 ` [dpdk-dev] [PATCH v2 6/6] bus/pci: remove duplicate declaration David Marchand
2020-09-14 10:24 ` Andrew Rybchenko
2020-09-17 11:28 ` [dpdk-dev] [PATCH v3 0/6] 20.11 announced cleanups David Marchand
2020-09-17 11:28 ` [dpdk-dev] [PATCH v3 1/6] ethdev: remove unused kernel driver field David Marchand
2020-09-17 11:28 ` [dpdk-dev] [PATCH v3 2/6] bus/pci: switch to private kernel driver enum David Marchand
2020-09-17 11:28 ` [dpdk-dev] [PATCH v3 3/6] pci: move resource mapping to the PCI bus David Marchand
2020-09-18 13:43 ` Kinsella, Ray
2020-09-17 11:28 ` [dpdk-dev] [PATCH v3 4/6] mem: drop mapping API workaround David Marchand
2020-09-17 11:28 ` [dpdk-dev] [PATCH v3 5/6] eal: hide internal device event structure David Marchand
2020-09-18 3:40 ` Guo, Jia
2020-09-18 13:36 ` Kinsella, Ray
2020-09-17 11:28 ` [dpdk-dev] [PATCH v3 6/6] bus/pci: remove duplicate declaration David Marchand
2020-09-21 9:05 ` [dpdk-dev] [PATCH v3 0/6] 20.11 announced cleanups David Marchand
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200914082350.13279-5-david.marchand@redhat.com \
--to=david.marchand@redhat.com \
--cc=anatoly.burakov@intel.com \
--cc=dev@dpdk.org \
--cc=dmitry.kozliuk@gmail.com \
--cc=dmitrym@microsoft.com \
--cc=ferruh.yigit@intel.com \
--cc=navasile@linux.microsoft.com \
--cc=pallavi.kadam@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).