WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

Re: [Xen-devel] [PATCH]: xl: pci multi-function passthrough v2

To: Xen Devel <xen-devel@xxxxxxxxxxxxxxxxxxx>
Subject: Re: [Xen-devel] [PATCH]: xl: pci multi-function passthrough v2
From: Gianni Tedesco <gianni.tedesco@xxxxxxxxxx>
Date: Mon, 9 Aug 2010 13:47:37 +0100
Cc: Ian Jackson <Ian.Jackson@xxxxxxxxxxxxx>, Stefano Stabellini <Stefano.Stabellini@xxxxxxxxxxxxx>
Delivery-date: Mon, 09 Aug 2010 06:01:06 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
In-reply-to: <1281355239.18490.259.camel@xxxxxxxxxxxxxxxxxxxxxx>
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
References: <1281355239.18490.259.camel@xxxxxxxxxxxxxxxxxxxxxx>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
On Mon, 2010-08-09 at 13:00 +0100, Gianni Tedesco wrote:
> @@ -652,8 +705,9 @@ out:
> 
>  int libxl_device_pci_add(libxl_ctx *ctx, uint32_t domid, libxl_device_pci 
> *pcidev)
>  {
> +    unsigned int orig_vdev, pfunc_mask;
>      libxl_device_pci *assigned;
> -    int num_assigned, rc;
> +    int num_assigned, rc, i;
>      int stubdomid = 0;
> 
>      rc = get_all_assigned_devices(ctx, &assigned, &num_assigned);
> @@ -679,10 +733,43 @@ int libxl_device_pci_add(libxl_ctx *ctx,
>              return rc;
>      }
> 
> -    return do_pci_add(ctx, domid, pcidev);
> +    orig_vdev = pcidev->vdevfn & ~7U;
> +
> +    if ( pcidev->vfunc_mask == LIBXL_PCI_FUNC_ALL ) {
> +        if ( !(pcidev->vdevfn >> 3) ) {
> +            XL_LOG(ctx, XL_LOG_ERROR, "Must specify a v-slot for 
> multi-function devices");
> +            return ERROR_INVAL;
> +        }
> +        if ( pci_multifunction_check(ctx, pcidev, &pfunc_mask) ) {
> +            return ERROR_FAIL;
> +        }
> +        pcidev->vfunc_mask &= pfunc_mask;
> +        /* so now vfunc_mask == pfunc_mask */
> +    }else{
> +        pfunc_mask = (1 << pcidev->func);
> +    }
> +
> +    for(i = 7; i >= 0; --i) {
> +        if ( (1 << i) & pfunc_mask ) {
> +            if ( pcidev->vfunc_mask == pfunc_mask ) {
> +                pcidev->func = i;
> +                pcidev->vdevfn = orig_vdev | i;
> +            }else{
> +                /* if not passing through multiple devices in a block make
> +                 * sure that virtual function number 0 is always used 
> otherwise
> +                 * guest won't see the device
> +                 */
> +                pcidev->vdevfn = orig_vdev;
> +            }
> +            if ( do_pci_add(ctx, domid, pcidev) )
> +                rc = ERROR_FAIL;
> +        }
> +    }
> +
> +    return rc;
>  }

Not sure that this bit is right for stubdoms, I haven't tested...


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel