]> git.droids-corp.org - dpdk.git/commitdiff
pci: move resource mapping to the PCI bus
authorDavid Marchand <david.marchand@redhat.com>
Thu, 17 Sep 2020 11:28:20 +0000 (13:28 +0200)
committerDavid Marchand <david.marchand@redhat.com>
Mon, 21 Sep 2020 08:12:10 +0000 (10:12 +0200)
As reported during 20.08 work for Windows, the pci_map_resource API was
built with the assumption that its flags would be passed to mmap().

This introduced a regression when adding the rte_mem_map API as reported
in the workaround commit 9d2b24593724 ("pci: keep API compatibility with
mmap values").

This API was only used in the PCI bus code, so move it there.

There is no code change happening during the move.
The only change is in the pci_map_resource description where the
additional flags are now documented as rte_mem_map API flags:
- *      The additional flags for the mapping range.
+ *      The additional rte_mem_map() flags for the mapping range.

Signed-off-by: David Marchand <david.marchand@redhat.com>
Acked-by: Andrew Rybchenko <arybchenko@solarflare.com>
Acked-by: Ray Kinsella <mdr@ashroe.eu>
doc/guides/rel_notes/deprecation.rst
doc/guides/rel_notes/release_20_11.rst
drivers/bus/pci/linux/pci_init.h
drivers/bus/pci/linux/pci_uio.c
drivers/bus/pci/pci_common.c
drivers/bus/pci/private.h
lib/librte_pci/rte_pci.c
lib/librte_pci/rte_pci.h
lib/librte_pci/rte_pci_version.map

index f4c38b4327f6dc6764cc7a547639526f3ef2efb3..fc07e5f285da2a12811f40231c5fbbaae642b5d8 100644 (file)
@@ -113,17 +113,6 @@ Deprecation Notices
   us extending existing enum/define.
   One solution can be using a fixed size array instead of ``.*MAX.*`` value.
 
-* pci: The PCI resources map API (``pci_map_resource`` and
-  ``pci_unmap_resource``) was not abstracting the Unix mmap flags (see the
-  workaround for Windows support implemented in the commit
-  9d2b24593724 ("pci: keep API compatibility with mmap values")).
-  This API will be removed from the public API in 20.11 and moved to the PCI
-  bus driver along with the PCI resources lists and associated structures
-  (``pci_map``, ``pci_msix_table``, ``mapped_pci_resource`` and
-  ``mapped_pci_res_list``).
-  With this removal, there won't be a need for the mentioned workaround which
-  will be reverted.
-
 * mbuf: Some fields will be converted to dynamic API in DPDK 20.11
   in order to reserve more space for the dynamic fields, as explained in
   `this presentation <https://www.youtube.com/watch?v=Ttl6MlhmzWY>`_.
index 35add85170b3e7e8e575db121e51d826ded247da..401e7295878ac3ee3cd33fe5c8f8b57533bddc49 100644 (file)
@@ -112,6 +112,12 @@ API Changes
 * pci: Removed the ``rte_kernel_driver`` enum defined in rte_dev.h and
   replaced with a private enum in the PCI subsystem.
 
+* pci: Removed the PCI resources map API from the public API
+  (``pci_map_resource`` and ``pci_unmap_resource``) and moved it to the
+  PCI bus driver along with the PCI resources lists and associated structures
+  (``pci_map``, ``pci_msix_table``, ``mapped_pci_resource`` and
+  ``mapped_pci_res_list``).
+
 * ethdev: Removed the ``kdrv`` field in the ethdev ``rte_eth_dev_data``
   structure as it gave no useful abstracted information to the applications.
 
index c2e603a3742497a09ea23c609fa439fd464a9520..dcea726186a6cced4a5405764cfc11824f2a73d0 100644 (file)
@@ -7,6 +7,8 @@
 
 #include <rte_vfio.h>
 
+#include "private.h"
+
 /** IO resource type: */
 #define IORESOURCE_IO         0x00000100
 #define IORESOURCE_MEM        0x00000200
index a354920d5f4d6151780e5442700405e1fb92be1e..9ab20a0b2514a2686898c176cd4473c7f3668385 100644 (file)
@@ -25,6 +25,7 @@
 
 #include "eal_filesystem.h"
 #include "pci_init.h"
+#include "private.h"
 
 void *pci_map_addr = NULL;
 
index dddf2b2aadb2b21baafd9c5aa900fc70e637fe81..3a2ae079584f407f3ab2f02c707b78470e4a3371 100644 (file)
@@ -19,6 +19,7 @@
 #include <rte_per_lcore.h>
 #include <rte_memory.h>
 #include <rte_eal.h>
+#include <rte_eal_paging.h>
 #include <rte_string_fns.h>
 #include <rte_common.h>
 #include <rte_devargs.h>
@@ -79,6 +80,46 @@ pci_name_set(struct rte_pci_device *dev)
                dev->device.name = dev->name;
 }
 
+/* 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 = rte_mem_map(requested_addr, size,
+               RTE_PROT_READ | RTE_PROT_WRITE,
+               RTE_MAP_SHARED | additional_flags, fd, offset);
+       if (mapaddr == NULL) {
+               RTE_LOG(ERR, EAL,
+                       "%s(): cannot map resource(%d, %p, 0x%zx, 0x%llx): %s (%p)\n",
+                       __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);
+
+       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 (rte_mem_unmap(requested_addr, size)) {
+               RTE_LOG(ERR, EAL, "%s(): cannot mem unmap(%p, %#zx): %s\n",
+                       __func__, requested_addr, size,
+                       rte_strerror(rte_errno));
+       } else
+               RTE_LOG(DEBUG, EAL, "  PCI memory unmapped at %p\n",
+                               requested_addr);
+}
 /*
  * Match the PCI Driver and Device using the ID Table
  */
index 367cdd9a65bc011c90783c8eeeb20bacec1b12e5..7c89744b6627c0f88a076105bd29a9ddd02fd0e3 100644 (file)
@@ -81,6 +81,71 @@ void rte_pci_insert_device(struct rte_pci_device *exist_pci_dev,
  */
 int pci_update_device(const struct rte_pci_addr *addr);
 
+/**
+ * A structure describing a PCI mapping.
+ */
+struct pci_map {
+       void *addr;
+       char *path;
+       uint64_t offset;
+       uint64_t size;
+       uint64_t phaddr;
+};
+
+struct pci_msix_table {
+       int bar_index;
+       uint32_t offset;
+       uint32_t size;
+};
+
+/**
+ * A structure describing a mapped PCI resource.
+ * For multi-process we need to reproduce all PCI mappings in secondary
+ * processes, so save them in a tailq.
+ */
+struct mapped_pci_resource {
+       TAILQ_ENTRY(mapped_pci_resource) next;
+
+       struct rte_pci_addr pci_addr;
+       char path[PATH_MAX];
+       int nb_maps;
+       struct pci_map maps[PCI_MAX_RESOURCE];
+       struct pci_msix_table msix_table;
+};
+
+/** mapped pci device list */
+TAILQ_HEAD(mapped_pci_res_list, mapped_pci_resource);
+
+/**
+ * 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 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.
+ */
+void *pci_map_resource(void *requested_addr, int fd, off_t offset,
+               size_t size, int additional_flags);
+
+/**
+ * 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);
+
 /**
  * Map the PCI resource of a PCI device in virtual memory
  *
index 1d1cbc75acacd047de5d76ee002549de0a5415d2..c91be8b16777afa30b1c7e6c4ce402758d5fc39f 100644 (file)
@@ -144,45 +144,3 @@ rte_pci_addr_parse(const char *str, struct rte_pci_addr *addr)
                return 0;
        return -1;
 }
-
-
-/* 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 = rte_mem_map(requested_addr, size,
-               RTE_PROT_READ | RTE_PROT_WRITE,
-               RTE_MAP_SHARED | additional_flags, fd, offset);
-       if (mapaddr == NULL) {
-               RTE_LOG(ERR, EAL,
-                       "%s(): cannot map resource(%d, %p, 0x%zx, 0x%llx): %s (%p)\n",
-                       __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);
-
-       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 (rte_mem_unmap(requested_addr, size)) {
-               RTE_LOG(ERR, EAL, "%s(): cannot mem unmap(%p, %#zx): %s\n",
-                       __func__, requested_addr, size,
-                       rte_strerror(rte_errno));
-       } else
-               RTE_LOG(DEBUG, EAL, "  PCI memory unmapped at %p\n",
-                               requested_addr);
-}
index a03235da1f2ae80e907b2a9fa278478300a94d87..567c8cd68dfedd8d65ac50a1d76e317e8e410d9a 100644 (file)
@@ -64,42 +64,6 @@ struct rte_pci_addr {
 #define PCI_ANY_ID (0xffff)
 #define RTE_CLASS_ANY_ID (0xffffff)
 
-/**
- * A structure describing a PCI mapping.
- */
-struct pci_map {
-       void *addr;
-       char *path;
-       uint64_t offset;
-       uint64_t size;
-       uint64_t phaddr;
-};
-
-struct pci_msix_table {
-       int bar_index;
-       uint32_t offset;
-       uint32_t size;
-};
-
-/**
- * A structure describing a mapped PCI resource.
- * For multi-process we need to reproduce all PCI mappings in secondary
- * processes, so save them in a tailq.
- */
-struct mapped_pci_resource {
-       TAILQ_ENTRY(mapped_pci_resource) next;
-
-       struct rte_pci_addr pci_addr;
-       char path[PATH_MAX];
-       int nb_maps;
-       struct pci_map maps[PCI_MAX_RESOURCE];
-       struct pci_msix_table msix_table;
-};
-
-
-/** mapped pci device list */
-TAILQ_HEAD(mapped_pci_res_list, mapped_pci_resource);
-
 /**
  * Utility function to write a pci device name, this device name can later be
  * used to retrieve the corresponding rte_pci_addr using eal_parse_pci_*
@@ -145,36 +109,6 @@ int rte_pci_addr_cmp(const struct rte_pci_addr *addr,
  */
 int rte_pci_addr_parse(const char *str, struct rte_pci_addr *addr);
 
-/**
- * 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, MAP_FAILED is returned.
- */
-void *pci_map_resource(void *requested_addr, int fd, off_t offset,
-               size_t size, int additional_flags);
-
-/**
- * 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);
-
 #ifdef __cplusplus
 }
 #endif
index cd77c9dc9e36a1f760b422250d863b3b5f887c1b..1db19a51224f4ec480794ac51370b1f21787a74b 100644 (file)
@@ -1,8 +1,6 @@
 DPDK_21 {
        global:
 
-       pci_map_resource;
-       pci_unmap_resource;
        rte_pci_addr_cmp;
        rte_pci_addr_parse;
        rte_pci_device_name;