eal/linux: fix irq handling with igb_uio
[dpdk.git] / lib / librte_eal / linuxapp / eal / eal_interrupts.c
index 66deda2..3a84b3c 100644 (file)
@@ -361,7 +361,7 @@ vfio_disable_msix(struct rte_intr_handle *intr_handle) {
 #endif
 
 static int
-uio_intr_disable(struct rte_intr_handle *intr_handle)
+uio_intx_intr_disable(struct rte_intr_handle *intr_handle)
 {
        unsigned char command_high;
 
@@ -385,7 +385,7 @@ uio_intr_disable(struct rte_intr_handle *intr_handle)
 }
 
 static int
-uio_intr_enable(struct rte_intr_handle *intr_handle)
+uio_intx_intr_enable(struct rte_intr_handle *intr_handle)
 {
        unsigned char command_high;
 
@@ -408,6 +408,34 @@ uio_intr_enable(struct rte_intr_handle *intr_handle)
        return 0;
 }
 
+static int
+uio_intr_disable(struct rte_intr_handle *intr_handle)
+{
+       const int value = 0;
+
+       if (write(intr_handle->fd, &value, sizeof(value)) < 0) {
+               RTE_LOG(ERR, EAL,
+                       "Error disabling interrupts for fd %d (%s)\n",
+                       intr_handle->fd, strerror(errno));
+               return -1;
+       }
+       return 0;
+}
+
+static int
+uio_intr_enable(struct rte_intr_handle *intr_handle)
+{
+       const int value = 1;
+
+       if (write(intr_handle->fd, &value, sizeof(value)) < 0) {
+               RTE_LOG(ERR, EAL,
+                       "Error enabling interrupts for fd %d (%s)\n",
+                       intr_handle->fd, strerror(errno));
+               return -1;
+       }
+       return 0;
+}
+
 int
 rte_intr_callback_register(struct rte_intr_handle *intr_handle,
                        rte_intr_callback_fn cb, void *cb_arg)
@@ -556,6 +584,10 @@ rte_intr_enable(struct rte_intr_handle *intr_handle)
                if (uio_intr_enable(intr_handle))
                        return -1;
                break;
+       case RTE_INTR_HANDLE_UIO_INTX:
+               if (uio_intx_intr_enable(intr_handle))
+                       return -1;
+               break;
        /* not used at this moment */
        case RTE_INTR_HANDLE_ALARM:
                return -1;
@@ -596,6 +628,10 @@ rte_intr_disable(struct rte_intr_handle *intr_handle)
                if (uio_intr_disable(intr_handle))
                        return -1;
                break;
+       case RTE_INTR_HANDLE_UIO_INTX:
+               if (uio_intx_intr_disable(intr_handle))
+                       return -1;
+               break;
        /* not used at this moment */
        case RTE_INTR_HANDLE_ALARM:
                return -1;