eal: reserve VFIO vector zero for misc interrupt
authorCunming Liang <cunming.liang@intel.com>
Wed, 4 Nov 2015 08:45:28 +0000 (16:45 +0800)
committerThomas Monjalon <thomas.monjalon@6wind.com>
Wed, 4 Nov 2015 13:20:36 +0000 (14:20 +0100)
During VFIO_DEVICE_SET_IRQS, the previous order is
{Q0_fd, ... Qn_fd, misc_fd}.
The vector number of misc is indeterminable which is
ugly to some NIC (e.g. i40e, fm10k).
The patch adjusts the order in {misc_fd, Q0_fd, ... Qn_fd},
always reserve the first vector to misc interrupt.

Signed-off-by: Cunming Liang <cunming.liang@intel.com>
Acked-by: David Marchand <david.marchand@6wind.com>
lib/librte_eal/bsdapp/eal/include/exec-env/rte_interrupts.h
lib/librte_eal/linuxapp/eal/eal_interrupts.c
lib/librte_eal/linuxapp/eal/include/exec-env/rte_interrupts.h

index 88d4ae1..05bb484 100644 (file)
@@ -38,6 +38,9 @@
 #ifndef _RTE_BSDAPP_INTERRUPTS_H_
 #define _RTE_BSDAPP_INTERRUPTS_H_
 
+#define RTE_INTR_VEC_ZERO_OFFSET      0
+#define RTE_INTR_VEC_RXTX_OFFSET      1
+
 enum rte_intr_handle_type {
        RTE_INTR_HANDLE_UNKNOWN = 0,
        RTE_INTR_HANDLE_UIO,      /**< uio device handle */
index a4b9506..8758239 100644 (file)
@@ -301,8 +301,10 @@ vfio_enable_msix(struct rte_intr_handle *intr_handle) {
        irq_set->index = VFIO_PCI_MSIX_IRQ_INDEX;
        irq_set->start = 0;
        fd_ptr = (int *) &irq_set->data;
-       memcpy(fd_ptr, intr_handle->efds, sizeof(intr_handle->efds));
-       fd_ptr[intr_handle->max_intr - 1] = intr_handle->fd;
+       /* INTR vector offset 0 reserve for non-efds mapping */
+       fd_ptr[RTE_INTR_VEC_ZERO_OFFSET] = intr_handle->fd;
+       memcpy(&fd_ptr[RTE_INTR_VEC_RXTX_OFFSET], intr_handle->efds,
+               sizeof(*intr_handle->efds) * intr_handle->nb_efd);
 
        ret = ioctl(intr_handle->vfio_dev_fd, VFIO_DEVICE_SET_IRQS, irq_set);
 
@@ -1083,10 +1085,14 @@ rte_intr_rx_ctl(struct rte_intr_handle *intr_handle, int epfd,
        struct rte_epoll_event *rev;
        struct rte_epoll_data *epdata;
        int epfd_op;
+       unsigned int efd_idx;
        int rc = 0;
 
+       efd_idx = (vec >= RTE_INTR_VEC_RXTX_OFFSET) ?
+               (vec - RTE_INTR_VEC_RXTX_OFFSET) : vec;
+
        if (!intr_handle || intr_handle->nb_efd == 0 ||
-           vec >= intr_handle->nb_efd) {
+           efd_idx >= intr_handle->nb_efd) {
                RTE_LOG(ERR, EAL, "Wrong intr vector number.\n");
                return -EPERM;
        }
@@ -1094,7 +1100,7 @@ rte_intr_rx_ctl(struct rte_intr_handle *intr_handle, int epfd,
        switch (op) {
        case RTE_INTR_EVENT_ADD:
                epfd_op = EPOLL_CTL_ADD;
-               rev = &intr_handle->elist[vec];
+               rev = &intr_handle->elist[efd_idx];
                if (rev->status != RTE_EPOLL_INVALID) {
                        RTE_LOG(INFO, EAL, "Event already been added.\n");
                        return -EEXIST;
@@ -1106,7 +1112,8 @@ rte_intr_rx_ctl(struct rte_intr_handle *intr_handle, int epfd,
                epdata->data   = data;
                epdata->cb_fun = (rte_intr_event_cb_t)eal_intr_proc_rxtx_intr;
                epdata->cb_arg = (void *)intr_handle;
-               rc = rte_epoll_ctl(epfd, epfd_op, intr_handle->efds[vec], rev);
+               rc = rte_epoll_ctl(epfd, epfd_op,
+                                  intr_handle->efds[efd_idx], rev);
                if (!rc)
                        RTE_LOG(DEBUG, EAL,
                                "efd %d associated with vec %d added on epfd %d"
@@ -1116,7 +1123,7 @@ rte_intr_rx_ctl(struct rte_intr_handle *intr_handle, int epfd,
                break;
        case RTE_INTR_EVENT_DEL:
                epfd_op = EPOLL_CTL_DEL;
-               rev = &intr_handle->elist[vec];
+               rev = &intr_handle->elist[efd_idx];
                if (rev->status == RTE_EPOLL_INVALID) {
                        RTE_LOG(INFO, EAL, "Event does not exist.\n");
                        return -EPERM;
index b095b86..8da81e7 100644 (file)
@@ -39,6 +39,8 @@
 #define _RTE_LINUXAPP_INTERRUPTS_H_
 
 #define RTE_MAX_RXTX_INTR_VEC_ID     32
+#define RTE_INTR_VEC_ZERO_OFFSET      0
+#define RTE_INTR_VEC_RXTX_OFFSET      1
 
 enum rte_intr_handle_type {
        RTE_INTR_HANDLE_UNKNOWN = 0,