bus/pci: fix namespace of sysfs path function
[dpdk.git] / drivers / bus / pci / linux / pci_vfio.c
index 1a3c308..1f93fa4 100644 (file)
@@ -62,7 +62,7 @@
  * This file is only compiled if CONFIG_RTE_EAL_VFIO is set to "y".
  */
 
-#ifdef RTE_EAL_VFIO
+#ifdef VFIO_PRESENT
 
 #define PAGE_SIZE   (sysconf(_SC_PAGESIZE))
 #define PAGE_MASK   (~(PAGE_SIZE - 1))
@@ -325,7 +325,7 @@ pci_vfio_is_ioport_bar(int vfio_dev_fd, int bar_index)
 }
 
 static int
-pci_vfio_setup_device(struct rte_pci_device *dev, int vfio_dev_fd)
+pci_rte_vfio_setup_device(struct rte_pci_device *dev, int vfio_dev_fd)
 {
        if (pci_vfio_setup_interrupts(dev, vfio_dev_fd) != 0) {
                RTE_LOG(ERR, EAL, "Error setting up interrupts!\n");
@@ -338,8 +338,15 @@ pci_vfio_setup_device(struct rte_pci_device *dev, int vfio_dev_fd)
                return -1;
        }
 
-       /* Reset the device */
-       ioctl(vfio_dev_fd, VFIO_DEVICE_RESET);
+       /*
+        * Reset the device. If the device is not capable of resetting,
+        * then it updates errno as EINVAL.
+        */
+       if (ioctl(vfio_dev_fd, VFIO_DEVICE_RESET) && errno != EINVAL) {
+               RTE_LOG(ERR, EAL, "Unable to reset device! Error: %d (%s)\n",
+                               errno, strerror(errno));
+               return -1;
+       }
 
        return 0;
 }
@@ -458,7 +465,7 @@ pci_vfio_map_resource_primary(struct rte_pci_device *dev)
        snprintf(pci_addr, sizeof(pci_addr), PCI_PRI_FMT,
                        loc->domain, loc->bus, loc->devid, loc->function);
 
-       ret = vfio_setup_device(pci_get_sysfs_path(), pci_addr,
+       ret = rte_vfio_setup_device(rte_pci_get_sysfs_path(), pci_addr,
                                        &vfio_dev_fd, &device_info);
        if (ret)
                return ret;
@@ -539,7 +546,7 @@ pci_vfio_map_resource_primary(struct rte_pci_device *dev)
                dev->mem_resource[i].addr = maps[i].addr;
        }
 
-       if (pci_vfio_setup_device(dev, vfio_dev_fd) < 0) {
+       if (pci_rte_vfio_setup_device(dev, vfio_dev_fd) < 0) {
                RTE_LOG(ERR, EAL, "  %s setup device failed\n", pci_addr);
                goto err_vfio_res;
        }
@@ -575,14 +582,14 @@ pci_vfio_map_resource_secondary(struct rte_pci_device *dev)
        snprintf(pci_addr, sizeof(pci_addr), PCI_PRI_FMT,
                        loc->domain, loc->bus, loc->devid, loc->function);
 
-       ret = vfio_setup_device(pci_get_sysfs_path(), pci_addr,
+       ret = rte_vfio_setup_device(rte_pci_get_sysfs_path(), pci_addr,
                                        &vfio_dev_fd, &device_info);
        if (ret)
                return ret;
 
        /* if we're in a secondary process, just find our tailq entry */
        TAILQ_FOREACH(vfio_res, vfio_res_list, next) {
-               if (pci_addr_cmp(&vfio_res->pci_addr,
+               if (rte_pci_addr_cmp(&vfio_res->pci_addr,
                                                 &dev->addr))
                        continue;
                break;
@@ -655,7 +662,7 @@ pci_vfio_unmap_resource(struct rte_pci_device *dev)
                return -1;
        }
 
-       ret = vfio_release_device(pci_get_sysfs_path(), pci_addr,
+       ret = rte_vfio_release_device(rte_pci_get_sysfs_path(), pci_addr,
                                  dev->intr_handle.vfio_dev_fd);
        if (ret < 0) {
                RTE_LOG(ERR, EAL,
@@ -751,6 +758,6 @@ pci_vfio_ioport_unmap(struct rte_pci_ioport *p)
 int
 pci_vfio_is_enabled(void)
 {
-       return vfio_is_enabled("vfio_pci");
+       return rte_vfio_is_enabled("vfio_pci");
 }
 #endif