bus/fslmc: add interrupt enabling routine
authorNipun Gupta <nipun.gupta@nxp.com>
Fri, 30 Jun 2017 08:54:32 +0000 (14:24 +0530)
committerJerin Jacob <jerin.jacob@caviumnetworks.com>
Fri, 7 Jul 2017 07:27:39 +0000 (09:27 +0200)
Signed-off-by: Nipun Gupta <nipun.gupta@nxp.com>
drivers/bus/fslmc/fslmc_vfio.c
drivers/bus/fslmc/fslmc_vfio.h

index a8002c9..c431662 100644 (file)
@@ -368,6 +368,40 @@ fslmc_bus_add_device(struct rte_dpaa2_device *dev)
        }
 }
 
+#define IRQ_SET_BUF_LEN  (sizeof(struct vfio_irq_set) + sizeof(int))
+
+int rte_dpaa2_intr_enable(struct rte_intr_handle *intr_handle,
+                         uint32_t index)
+{
+       struct vfio_irq_set *irq_set;
+       char irq_set_buf[IRQ_SET_BUF_LEN];
+       int *fd_ptr, fd, ret;
+
+       /* Prepare vfio_irq_set structure and SET the IRQ in VFIO */
+       /* Give the eventfd to VFIO */
+       fd = eventfd(0, 0);
+       irq_set = (struct vfio_irq_set *)irq_set_buf;
+       irq_set->argsz = sizeof(irq_set_buf);
+       irq_set->count = 1;
+       irq_set->flags = VFIO_IRQ_SET_DATA_EVENTFD |
+                        VFIO_IRQ_SET_ACTION_TRIGGER;
+       irq_set->index = index;
+       irq_set->start = 0;
+       fd_ptr = (int *)&irq_set->data;
+       *fd_ptr = fd;
+
+       ret = ioctl(intr_handle->vfio_dev_fd, VFIO_DEVICE_SET_IRQS, irq_set);
+       if (ret < 0) {
+               FSLMC_VFIO_LOG(ERR, "Unable to set IRQ in VFIO, ret: %d\n",
+                              ret);
+               return -1;
+       }
+
+       /* Set the FD and update the flags */
+       intr_handle->fd = fd;
+       return 0;
+}
+
 /* Following function shall fetch total available list of MC devices
  * from VFIO container & populate private list of devices and other
  * data structures
index 7c725f4..ebca2b0 100644 (file)
@@ -90,6 +90,9 @@ int vfio_dmamap_mem_region(
        uint64_t iova,
        uint64_t size);
 
+int rte_dpaa2_intr_enable(struct rte_intr_handle *intr_handle,
+                         uint32_t index);
+
 int fslmc_vfio_setup_group(void);
 int fslmc_vfio_process_group(void);
 int rte_fslmc_vfio_dmamap(void);