From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by dpdk.org (Postfix) with ESMTP id D8778CD77 for ; Thu, 30 Apr 2015 18:27:07 +0200 (CEST) Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga103.jf.intel.com with ESMTP; 30 Apr 2015 09:27:07 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.11,677,1422950400"; d="scan'208";a="487750699" Received: from unknown ([10.237.220.106]) by FMSMGA003.fm.intel.com with SMTP; 30 Apr 2015 09:27:05 -0700 Received: by (sSMTP sendmail emulation); Thu, 30 Apr 2015 17:27:04 +0025 Date: Thu, 30 Apr 2015 17:27:04 +0100 From: Bruce Richardson To: Stephen Hemminger Message-ID: <20150430162703.GA5972@bricha3-MOBL3> References: <1430239000-30881-1-git-send-email-stephen@networkplumber.org> <1430239000-30881-2-git-send-email-stephen@networkplumber.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1430239000-30881-2-git-send-email-stephen@networkplumber.org> Organization: Intel Shannon Ltd. User-Agent: Mutt/1.5.23 (2014-03-12) Cc: dev@dpdk.org Subject: Re: [dpdk-dev] [PATCH 1/3] uio: fix irq handling with igb_uio X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 30 Apr 2015 16:27:08 -0000 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 Acked-by: Bruce Richardson > --- > 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 >