eal/linux: fix irq handling with igb_uio
[dpdk.git] / lib / librte_eal / linuxapp / eal / eal_pci_uio.c
index 35d31c5..b5116a7 100644 (file)
@@ -32,6 +32,7 @@
  */
 
 #include <string.h>
+#include <unistd.h>
 #include <fcntl.h>
 #include <dirent.h>
 #include <sys/stat.h>
@@ -40,9 +41,9 @@
 
 #include <rte_log.h>
 #include <rte_pci.h>
+#include <rte_eal_memconfig.h>
 #include <rte_common.h>
 #include <rte_malloc.h>
-#include <rte_tailq.h>
 
 #include "rte_pci_dev_ids.h"
 #include "eal_filesystem.h"
 
 void *pci_map_addr = NULL;
 
+static struct rte_tailq_elem rte_uio_tailq = {
+       .name = "UIO_RESOURCE_LIST",
+};
+EAL_REGISTER_TAILQ(rte_uio_tailq)
 
 #define OFF_MAX              ((uint64_t)(off_t)-1)
 
@@ -87,8 +92,9 @@ pci_uio_map_secondary(struct rte_pci_device *dev)
 {
        int fd, i;
        struct mapped_pci_resource *uio_res;
+       struct mapped_pci_res_list *uio_res_list = RTE_TAILQ_CAST(rte_uio_tailq.head, mapped_pci_res_list);
 
-       TAILQ_FOREACH(uio_res, pci_res_list, next) {
+       TAILQ_FOREACH(uio_res, uio_res_list, next) {
 
                /* skip this element if it doesn't match our PCI address */
                if (rte_eal_compare_pci_addr(&uio_res->pci_addr, &dev->addr))
@@ -266,6 +272,7 @@ pci_uio_map_resource(struct rte_pci_device *dev)
        uint64_t phaddr;
        struct rte_pci_addr *loc = &dev->addr;
        struct mapped_pci_resource *uio_res;
+       struct mapped_pci_res_list *uio_res_list = RTE_TAILQ_CAST(rte_uio_tailq.head, mapped_pci_res_list);
        struct pci_map *maps;
 
        dev->intr_handle.fd = -1;
@@ -292,7 +299,6 @@ pci_uio_map_resource(struct rte_pci_device *dev)
                        devname, strerror(errno));
                return -1;
        }
-       dev->intr_handle.type = RTE_INTR_HANDLE_UIO;
 
        snprintf(cfgname, sizeof(cfgname),
                        "/sys/class/uio/uio%u/device/config", uio_num);
@@ -303,10 +309,16 @@ pci_uio_map_resource(struct rte_pci_device *dev)
                return -1;
        }
 
-       /* set bus master that is not done by uio_pci_generic */
-       if (pci_uio_set_bus_master(dev->intr_handle.uio_cfg_fd)) {
-               RTE_LOG(ERR, EAL, "Cannot set up bus mastering!\n");
-               return -1;
+       if (dev->kdrv == RTE_KDRV_IGB_UIO)
+               dev->intr_handle.type = RTE_INTR_HANDLE_UIO;
+       else {
+               dev->intr_handle.type = RTE_INTR_HANDLE_UIO_INTX;
+
+               /* set bus master that is not done by uio_pci_generic */
+               if (pci_uio_set_bus_master(dev->intr_handle.uio_cfg_fd)) {
+                       RTE_LOG(ERR, EAL, "Cannot set up bus mastering!\n");
+                       return -1;
+               }
        }
 
        /* allocate the mapping details for secondary processes*/
@@ -382,7 +394,7 @@ pci_uio_map_resource(struct rte_pci_device *dev)
 
        uio_res->nb_maps = map_idx;
 
-       TAILQ_INSERT_TAIL(pci_res_list, uio_res, next);
+       TAILQ_INSERT_TAIL(uio_res_list, uio_res, next);
 
        return 0;
 }
@@ -405,11 +417,12 @@ static struct mapped_pci_resource *
 pci_uio_find_resource(struct rte_pci_device *dev)
 {
        struct mapped_pci_resource *uio_res;
+       struct mapped_pci_res_list *uio_res_list = RTE_TAILQ_CAST(rte_uio_tailq.head, mapped_pci_res_list);
 
        if (dev == NULL)
                return NULL;
 
-       TAILQ_FOREACH(uio_res, pci_res_list, next) {
+       TAILQ_FOREACH(uio_res, uio_res_list, next) {
 
                /* skip this element if it doesn't match our PCI address */
                if (!rte_eal_compare_pci_addr(&uio_res->pci_addr, &dev->addr))
@@ -423,6 +436,7 @@ void
 pci_uio_unmap_resource(struct rte_pci_device *dev)
 {
        struct mapped_pci_resource *uio_res;
+       struct mapped_pci_res_list *uio_res_list = RTE_TAILQ_CAST(rte_uio_tailq.head, mapped_pci_res_list);
 
        if (dev == NULL)
                return;
@@ -436,7 +450,7 @@ pci_uio_unmap_resource(struct rte_pci_device *dev)
        if (rte_eal_process_type() != RTE_PROC_PRIMARY)
                return pci_uio_unmap(uio_res);
 
-       TAILQ_REMOVE(pci_res_list, uio_res, next);
+       TAILQ_REMOVE(uio_res_list, uio_res, next);
 
        /* unmap all resources */
        pci_uio_unmap(uio_res);