bus/pci: enhance driver pointer documentation
[dpdk.git] / drivers / bus / pci / pci_common.c
index 79a6fcf..37ab879 100644 (file)
@@ -207,11 +207,6 @@ rte_pci_probe_one_driver(struct rte_pci_driver *dr,
        RTE_LOG(DEBUG, EAL, "  probe driver: %x:%x %s\n", dev->id.vendor_id,
                dev->id.device_id, dr->driver.name);
 
-       /*
-        * reference driver structure
-        * This needs to be before rte_pci_map_device(), as it enables to use
-        * driver flags for adjusting configuration.
-        */
        if (!already_probed) {
                enum rte_iova_mode dev_iova_mode;
                enum rte_iova_mode iova_mode;
@@ -226,15 +221,43 @@ rte_pci_probe_one_driver(struct rte_pci_driver *dr,
                        return -EINVAL;
                }
 
-               dev->driver = dr;
-       }
+               /* Allocate interrupt instance for pci device */
+               dev->intr_handle =
+                       rte_intr_instance_alloc(RTE_INTR_INSTANCE_F_PRIVATE);
+               if (dev->intr_handle == NULL) {
+                       RTE_LOG(ERR, EAL,
+                               "Failed to create interrupt instance for %s\n",
+                               dev->device.name);
+                       return -ENOMEM;
+               }
 
-       if (!already_probed && (dr->drv_flags & RTE_PCI_DRV_NEED_MAPPING)) {
-               /* map resources for devices that use igb_uio */
-               ret = rte_pci_map_device(dev);
-               if (ret != 0) {
-                       dev->driver = NULL;
-                       return ret;
+               dev->vfio_req_intr_handle =
+                       rte_intr_instance_alloc(RTE_INTR_INSTANCE_F_PRIVATE);
+               if (dev->vfio_req_intr_handle == NULL) {
+                       rte_intr_instance_free(dev->intr_handle);
+                       dev->intr_handle = NULL;
+                       RTE_LOG(ERR, EAL,
+                               "Failed to create vfio req interrupt instance for %s\n",
+                               dev->device.name);
+                       return -ENOMEM;
+               }
+
+               /*
+                * Reference driver structure.
+                * This needs to be before rte_pci_map_device(), as it enables
+                * to use driver flags for adjusting configuration.
+                */
+               dev->driver = dr;
+               if (dev->driver->drv_flags & RTE_PCI_DRV_NEED_MAPPING) {
+                       ret = rte_pci_map_device(dev);
+                       if (ret != 0) {
+                               dev->driver = NULL;
+                               rte_intr_instance_free(dev->vfio_req_intr_handle);
+                               dev->vfio_req_intr_handle = NULL;
+                               rte_intr_instance_free(dev->intr_handle);
+                               dev->intr_handle = NULL;
+                               return ret;
+                       }
                }
        }
 
@@ -255,6 +278,10 @@ rte_pci_probe_one_driver(struct rte_pci_driver *dr,
                        !(ret > 0 &&
                                (dr->drv_flags & RTE_PCI_DRV_KEEP_MAPPED_RES)))
                        rte_pci_unmap_device(dev);
+               rte_intr_instance_free(dev->vfio_req_intr_handle);
+               dev->vfio_req_intr_handle = NULL;
+               rte_intr_instance_free(dev->intr_handle);
+               dev->intr_handle = NULL;
        } else {
                dev->device.driver = &dr->driver;
        }
@@ -300,6 +327,11 @@ rte_pci_detach_dev(struct rte_pci_device *dev)
                /* unmap resources for devices that use igb_uio */
                rte_pci_unmap_device(dev);
 
+       rte_intr_instance_free(dev->intr_handle);
+       dev->intr_handle = NULL;
+       rte_intr_instance_free(dev->vfio_req_intr_handle);
+       dev->vfio_req_intr_handle = NULL;
+
        return 0;
 }
 
@@ -785,6 +817,7 @@ struct rte_pci_bus rte_pci_bus = {
                .plug = pci_plug,
                .unplug = pci_unplug,
                .parse = pci_parse,
+               .devargs_parse = rte_pci_devargs_parse,
                .dma_map = pci_dma_map,
                .dma_unmap = pci_dma_unmap,
                .get_iommu_class = rte_pci_get_iommu_class,