pci: use EAL exposed configuration
[dpdk.git] / lib / librte_eal / linuxapp / eal / eal_pci_vfio.c
index 8fa101b..7006a1d 100644 (file)
@@ -48,7 +48,6 @@
 
 #include "eal_filesystem.h"
 #include "eal_pci_init.h"
-#include "eal_vfio.h"
 #include "eal_private.h"
 
 /**
@@ -61,7 +60,7 @@
  * This file is only compiled if CONFIG_RTE_EAL_VFIO is set to "y".
  */
 
-#ifdef VFIO_PRESENT
+#ifdef RTE_EAL_VFIO
 
 #define PAGE_SIZE   (sysconf(_SC_PAGESIZE))
 #define PAGE_MASK   (~(PAGE_SIZE - 1))
@@ -210,14 +209,18 @@ static int
 pci_vfio_setup_interrupts(struct rte_pci_device *dev, int vfio_dev_fd)
 {
        int i, ret, intr_idx;
+       enum rte_intr_mode intr_mode;
 
        /* default to invalid index */
        intr_idx = VFIO_PCI_NUM_IRQS;
 
+       /* Get default / configured intr_mode */
+       intr_mode = rte_eal_vfio_intr_mode();
+
        /* get interrupt type from internal config (MSI-X by default, can be
         * overridden from the command line
         */
-       switch (internal_config.vfio_intr_mode) {
+       switch (intr_mode) {
        case RTE_INTR_MODE_MSIX:
                intr_idx = VFIO_PCI_MSIX_IRQ_INDEX;
                break;
@@ -241,7 +244,7 @@ pci_vfio_setup_interrupts(struct rte_pci_device *dev, int vfio_dev_fd)
                int fd = -1;
 
                /* skip interrupt modes we don't want */
-               if (internal_config.vfio_intr_mode != RTE_INTR_MODE_NONE &&
+               if (intr_mode != RTE_INTR_MODE_NONE &&
                                i != intr_idx)
                        continue;
 
@@ -257,7 +260,7 @@ pci_vfio_setup_interrupts(struct rte_pci_device *dev, int vfio_dev_fd)
                /* if this vector cannot be used with eventfd, fail if we explicitly
                 * specified interrupt type, otherwise continue */
                if ((irq.flags & VFIO_IRQ_INFO_EVENTFD) == 0) {
-                       if (internal_config.vfio_intr_mode != RTE_INTR_MODE_NONE) {
+                       if (intr_mode != RTE_INTR_MODE_NONE) {
                                RTE_LOG(ERR, EAL,
                                                "  interrupt vector does not support eventfd!\n");
                                return -1;
@@ -278,15 +281,15 @@ pci_vfio_setup_interrupts(struct rte_pci_device *dev, int vfio_dev_fd)
 
                switch (i) {
                case VFIO_PCI_MSIX_IRQ_INDEX:
-                       internal_config.vfio_intr_mode = RTE_INTR_MODE_MSIX;
+                       intr_mode = RTE_INTR_MODE_MSIX;
                        dev->intr_handle.type = RTE_INTR_HANDLE_VFIO_MSIX;
                        break;
                case VFIO_PCI_MSI_IRQ_INDEX:
-                       internal_config.vfio_intr_mode = RTE_INTR_MODE_MSI;
+                       intr_mode = RTE_INTR_MODE_MSI;
                        dev->intr_handle.type = RTE_INTR_HANDLE_VFIO_MSI;
                        break;
                case VFIO_PCI_INTX_IRQ_INDEX:
-                       internal_config.vfio_intr_mode = RTE_INTR_MODE_LEGACY;
+                       intr_mode = RTE_INTR_MODE_LEGACY;
                        dev->intr_handle.type = RTE_INTR_HANDLE_VFIO_LEGACY;
                        break;
                default:
@@ -577,8 +580,8 @@ pci_vfio_map_resource_secondary(struct rte_pci_device *dev)
 
        /* if we're in a secondary process, just find our tailq entry */
        TAILQ_FOREACH(vfio_res, vfio_res_list, next) {
-               if (rte_eal_compare_pci_addr(&vfio_res->pci_addr,
-                                                &dev->addr))
+               if (rte_pci_addr_cmp(&vfio_res->pci_addr,
+                                    &dev->addr))
                        continue;
                break;
        }
@@ -616,7 +619,7 @@ err_vfio_dev_fd:
 int
 pci_vfio_map_resource(struct rte_pci_device *dev)
 {
-       if (internal_config.process_type == RTE_PROC_PRIMARY)
+       if (rte_eal_process_type() == RTE_PROC_PRIMARY)
                return pci_vfio_map_resource_primary(dev);
        else
                return pci_vfio_map_resource_secondary(dev);