DPDK patches and discussions
 help / color / mirror / Atom feed
From: Bruce Richardson <bruce.richardson@intel.com>
To: Stephen Hemminger <stephen@networkplumber.org>
Cc: dev@dpdk.org
Subject: Re: [dpdk-dev] [PATCH 1/3] uio: fix irq handling with igb_uio
Date: Thu, 30 Apr 2015 17:27:04 +0100	[thread overview]
Message-ID: <20150430162703.GA5972@bricha3-MOBL3> (raw)
In-Reply-To: <1430239000-30881-2-git-send-email-stephen@networkplumber.org>

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@networkplumber.org>

Acked-by: Bruce Richardson <bruce.richardson@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	other threads:[~2015-04-30 16:27 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-28 16:36 [dpdk-dev] [PATCH 0/3] eal: uio irq fixes and enhancements Stephen Hemminger
2015-04-28 16:36 ` [dpdk-dev] [PATCH 1/3] uio: fix irq handling with igb_uio Stephen Hemminger
2015-04-30 16:27   ` Bruce Richardson [this message]
2015-05-13  9:31     ` Thomas Monjalon
2015-04-28 16:36 ` [dpdk-dev] [PATCH 2/3] pci: add ability to read/write config space Stephen Hemminger
2015-04-28 16:36 ` [dpdk-dev] [PATCH 3/3] eal: use pci_uio_read/write config to enable/disable INTX Stephen Hemminger
2015-05-12 20:02 ` [dpdk-dev] [PATCH 0/3] eal: uio irq fixes and enhancements Thomas Monjalon
2015-05-13  8:57   ` Bruce Richardson
2015-05-13  9:32     ` Thomas Monjalon

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20150430162703.GA5972@bricha3-MOBL3 \
    --to=bruce.richardson@intel.com \
    --cc=dev@dpdk.org \
    --cc=stephen@networkplumber.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).