net/mlx5: fix meter policy flow match item
[dpdk.git] / drivers / bus / pci / pci_common_uio.c
index dd84ec8..318f9a1 100644 (file)
@@ -51,14 +51,15 @@ pci_uio_map_secondary(struct rte_pci_device *dev)
                        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);
-                       /* fd is not needed in slave process, close it */
+
+                       /* fd is not needed in secondary process, close it */
                        close(fd);
                        if (mapaddr != uio_res->maps[i].addr) {
                                RTE_LOG(ERR, EAL,
                                        "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(
@@ -70,6 +71,7 @@ pci_uio_map_secondary(struct rte_pci_device *dev)
                                }
                                return -1;
                        }
+                       dev->mem_resource[i].addr = mapaddr;
                }
                return 0;
        }
@@ -90,7 +92,6 @@ pci_uio_map_resource(struct rte_pci_device *dev)
 
        dev->intr_handle.fd = -1;
        dev->intr_handle.uio_cfg_fd = -1;
-       dev->intr_handle.type = RTE_INTR_HANDLE_UNKNOWN;
 
        /* secondary processes - use already recorded details */
        if (rte_eal_process_type() != RTE_PROC_PRIMARY)
@@ -147,6 +148,39 @@ pci_uio_unmap(struct mapped_pci_resource *uio_res)
        }
 }
 
+/* remap the PCI resource of a PCI device in anonymous virtual memory */
+int
+pci_uio_remap_resource(struct rte_pci_device *dev)
+{
+       int i;
+       void *map_address;
+
+       if (dev == NULL)
+               return -1;
+
+       /* Remap all BARs */
+       for (i = 0; i != PCI_MAX_RESOURCE; i++) {
+               /* skip empty BAR */
+               if (dev->mem_resource[i].phys_addr == 0)
+                       continue;
+               map_address = mmap(dev->mem_resource[i].addr,
+                               (size_t)dev->mem_resource[i].len,
+                               PROT_READ | PROT_WRITE,
+                               MAP_PRIVATE | MAP_ANONYMOUS | MAP_FIXED, -1, 0);
+               if (map_address == MAP_FAILED) {
+                       RTE_LOG(ERR, EAL,
+                               "Cannot remap resource for device %s\n",
+                               dev->name);
+                       return -1;
+               }
+               RTE_LOG(INFO, EAL,
+                       "Successful remap resource for device %s\n",
+                       dev->name);
+       }
+
+       return 0;
+}
+
 static struct mapped_pci_resource *
 pci_uio_find_resource(struct rte_pci_device *dev)
 {