Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 27 Dec 2010 08:58:43 -0500
From:      John Baldwin <jhb@FreeBSD.org>
To:        Jeff Roberson <jeff@FreeBSD.org>
Cc:        svn-src-projects@freebsd.org, src-committers@freebsd.org
Subject:   Re: svn commit: r216729 - in projects/ofed/head/sys/ofed: drivers/infiniband/hw/mthca drivers/net/mlx4 include/linux
Message-ID:  <4D189B93.3020204@FreeBSD.org>
In-Reply-To: <201012270547.oBR5lOhJ012472@svn.freebsd.org>
References:  <201012270547.oBR5lOhJ012472@svn.freebsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help
Jeff Roberson wrote:
> Author: jeff
> Date: Mon Dec 27 05:47:24 2010
> New Revision: 216729
> URL: http://svn.freebsd.org/changeset/base/216729
> 
> Log:
>    - Implement Linux compatible support for msix, removing some diffs against
>      driver sources.
>    - Add plubming to find the device based on the irq to eliminate another
>      linux incompatibility in request_irq().
>    - Implement free_irq() which was previously empty.
>   
>   Sponsored by:	Isilon Systems, iX Systems, and Panasas.
> 
> Modified:
>   projects/ofed/head/sys/ofed/drivers/infiniband/hw/mthca/mthca_eq.c
>   projects/ofed/head/sys/ofed/drivers/infiniband/hw/mthca/mthca_main.c
>   projects/ofed/head/sys/ofed/drivers/net/mlx4/eq.c
>   projects/ofed/head/sys/ofed/drivers/net/mlx4/main.c
>   projects/ofed/head/sys/ofed/include/linux/device.h
>   projects/ofed/head/sys/ofed/include/linux/interrupt.h
>   projects/ofed/head/sys/ofed/include/linux/linux_compat.c
>   projects/ofed/head/sys/ofed/include/linux/pci.h
> 
> @@ -444,6 +486,40 @@ pci_unregister_driver(struct pci_driver 
>  	devclass_delete_driver(bus, &pdrv->driver);
>  }
>  
> +struct msix_entry {
> +	int entry;
> +	int vector;
> +};
> +
> +/*
> + * Enable msix, positive errors indicate actual number of available
> + * vectors.  Negative errors are failures.
> + */
> +static inline int
> +pci_enable_msix(struct pci_dev *pdev, struct msix_entry *entries, int nreq)
> +{
> +	struct resource_list_entry *rle;
> +	int error;
> +	int avail;
> +	int i;
> +
> +	avail = pci_msix_count(pdev->dev.bsddev);
> +	if (avail < nreq) {
> +		if (avail == 0)
> +			return -EINVAL;
> +		return avail;
> +	}
> +	avail = nreq;
> +	if ((error = -pci_alloc_msix(pdev->dev.bsddev, &avail)) != 0)
> +		return error;
> +	rle = _pci_get_rle(pdev, SYS_RES_IRQ, 1);
> +	pdev->dev.msix = rle->start;
> +	pdev->dev.msix_max = rle->start + avail;

MSI-X and MSI IRQs are not guaranteed to be a contiguous range.  Only 
the RIDs are guaranteed to be 1...N.  They usually are contiguous on x86 
because there is not a lot of turnover in MSI IRQs, but this is not 
guaranteed.

-- 
John Baldwin



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?4D189B93.3020204>