svn commit: r216729 - in projects/ofed/head/sys/ofed: drivers/infiniband/hw/mthca drivers/net/mlx4 include/linux

John Baldwin jhb at FreeBSD.org
Mon Dec 27 13:58:45 UTC 2010


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


More information about the svn-src-projects mailing list