On Tue, Apr 28, 2015 at 09:36:38AM -0700, Stephen Hemminger wrote:
> The introduction of uio_pci_generic broke interrupt handling with
> igb_uio. The igb_uio device uses the kernel read/write method to
> enable disable IRQ's; the uio_pci_generic has to use PCI intx
> config read/write to enable disable interrupts.
> 
> Since igb_uio uses MSI-X the PCI intx config read/write won't
> work.
> 
> Signed-off-by: Stephen Hemminger <stephen at networkplumber.org>

Acked-by: Bruce Richardson <bruce.richardson at intel.com>

> ---
>  lib/librte_eal/linuxapp/eal/eal_interrupts.c       | 40 
> ++++++++++++++++++++--
>  lib/librte_eal/linuxapp/eal/eal_pci_uio.c          | 15 +++++---
>  .../linuxapp/eal/include/exec-env/rte_interrupts.h |  3 +-
>  3 files changed, 50 insertions(+), 8 deletions(-)
> 
> diff --git a/lib/librte_eal/linuxapp/eal/eal_interrupts.c 
> b/lib/librte_eal/linuxapp/eal/eal_interrupts.c
> index 66deda2..3a84b3c 100644
> --- a/lib/librte_eal/linuxapp/eal/eal_interrupts.c
> +++ b/lib/librte_eal/linuxapp/eal/eal_interrupts.c
> @@ -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;
> diff --git a/lib/librte_eal/linuxapp/eal/eal_pci_uio.c 
> b/lib/librte_eal/linuxapp/eal/eal_pci_uio.c
> index 2d1c69b..b5116a7 100644
> --- a/lib/librte_eal/linuxapp/eal/eal_pci_uio.c
> +++ b/lib/librte_eal/linuxapp/eal/eal_pci_uio.c
> @@ -299,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);
> @@ -310,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*/
> diff --git a/lib/librte_eal/linuxapp/eal/include/exec-env/rte_interrupts.h 
> b/lib/librte_eal/linuxapp/eal/include/exec-env/rte_interrupts.h
> index 6a159c7..bdeb3fc 100644
> --- a/lib/librte_eal/linuxapp/eal/include/exec-env/rte_interrupts.h
> +++ b/lib/librte_eal/linuxapp/eal/include/exec-env/rte_interrupts.h
> @@ -40,7 +40,8 @@
>  
>  enum rte_intr_handle_type {
>       RTE_INTR_HANDLE_UNKNOWN = 0,
> -     RTE_INTR_HANDLE_UIO,      /**< uio device handle */
> +     RTE_INTR_HANDLE_UIO,          /**< uio device handle */
> +     RTE_INTR_HANDLE_UIO_INTX,     /**< uio generic handle */
>       RTE_INTR_HANDLE_VFIO_LEGACY,  /**< vfio device handle (legacy) */
>       RTE_INTR_HANDLE_VFIO_MSI,     /**< vfio device handle (MSI) */
>       RTE_INTR_HANDLE_VFIO_MSIX,    /**< vfio device handle (MSIX) */
> -- 
> 2.1.4
> 

Reply via email to