ia64/linux-2.6.18-xen.hg

changeset 841:558c390e3d92

PCI: pass ARI and SR-IOV device information to the hypervisor

PCIe Alternative Routing-ID Interpretation (ARI) ECN defines the Extended
Function -- a function whose function number is greater than 7 within an
ARI Device. Intel VT-d spec 1.2 section 8.3.2 specifies that the Extended
Function is under the scope of the same remapping unit as the traditional
function. The hypervisor needs to know if a function is Extended
Function so it can find proper DMAR for it.

And section 8.3.3 specifies that the SR-IOV Virtual Function is under the
scope of the same remapping unit as the Physical Function. The hypervisor
also needs to know if a function is the Virtual Function and which
Physical Function it's associated with for same reason.

Signed-off-by: Yu Zhao <yu.zhao@intel.com>
author Keir Fraser <keir.fraser@citrix.com>
date Thu Mar 19 10:21:46 2009 +0000 (2009-03-19)
parents 5ad6b350e4ab
children 9e65f17be1cd
files drivers/xen/core/pci.c include/xen/interface/physdev.h
line diff
     1.1 --- a/drivers/xen/core/pci.c	Thu Mar 19 10:21:21 2009 +0000
     1.2 +++ b/drivers/xen/core/pci.c	Thu Mar 19 10:21:46 2009 +0000
     1.3 @@ -6,6 +6,7 @@
     1.4  #include <linux/init.h>
     1.5  #include <linux/pci.h>
     1.6  #include <xen/interface/physdev.h>
     1.7 +#include "../../pci/pci.h"
     1.8  
     1.9  static int (*pci_bus_probe)(struct device *dev);
    1.10  static int (*pci_bus_remove)(struct device *dev);
    1.11 @@ -15,10 +16,30 @@ static int pci_bus_probe_wrapper(struct 
    1.12  	int r;
    1.13  	struct pci_dev *pci_dev = to_pci_dev(dev);
    1.14  	struct physdev_manage_pci manage_pci;
    1.15 -	manage_pci.bus = pci_dev->bus->number;
    1.16 -	manage_pci.devfn = pci_dev->devfn;
    1.17 +	struct physdev_manage_pci_ext manage_pci_ext;
    1.18  
    1.19 -	r = HYPERVISOR_physdev_op(PHYSDEVOP_manage_pci_add, &manage_pci);
    1.20 +	if (pci_dev->is_virtfn) {
    1.21 +		memset(&manage_pci_ext, 0, sizeof(manage_pci_ext));
    1.22 +		manage_pci_ext.bus = pci_dev->bus->number;
    1.23 +		manage_pci_ext.devfn = pci_dev->devfn;
    1.24 +		manage_pci_ext.is_virtfn = 1;
    1.25 +		manage_pci_ext.physfn.bus = pci_dev->physfn->bus->number;
    1.26 +		manage_pci_ext.physfn.devfn = pci_dev->physfn->devfn;
    1.27 +		r = HYPERVISOR_physdev_op(PHYSDEVOP_manage_pci_add_ext,
    1.28 +					  &manage_pci_ext);
    1.29 +	} else if (pci_ari_enabled(pci_dev->bus) && PCI_SLOT(pci_dev->devfn)) {
    1.30 +		memset(&manage_pci_ext, 0, sizeof(manage_pci_ext));
    1.31 +		manage_pci_ext.bus = pci_dev->bus->number;
    1.32 +		manage_pci_ext.devfn = pci_dev->devfn;
    1.33 +		manage_pci_ext.is_extfn = 1;
    1.34 +		r = HYPERVISOR_physdev_op(PHYSDEVOP_manage_pci_add_ext,
    1.35 +					  &manage_pci_ext);
    1.36 +	} else {
    1.37 +		manage_pci.bus = pci_dev->bus->number;
    1.38 +		manage_pci.devfn = pci_dev->devfn;
    1.39 +		r = HYPERVISOR_physdev_op(PHYSDEVOP_manage_pci_add,
    1.40 +					  &manage_pci);
    1.41 +	}
    1.42  	if (r && r != -ENOSYS)
    1.43  		return r;
    1.44  
     2.1 --- a/include/xen/interface/physdev.h	Thu Mar 19 10:21:21 2009 +0000
     2.2 +++ b/include/xen/interface/physdev.h	Thu Mar 19 10:21:46 2009 +0000
     2.3 @@ -192,6 +192,22 @@ struct physdev_restore_msi {
     2.4  typedef struct physdev_restore_msi physdev_restore_msi_t;
     2.5  DEFINE_XEN_GUEST_HANDLE(physdev_restore_msi_t);
     2.6  
     2.7 +#define PHYSDEVOP_manage_pci_add_ext	20
     2.8 +struct physdev_manage_pci_ext {
     2.9 +    /* IN */
    2.10 +    uint8_t bus;
    2.11 +    uint8_t devfn;
    2.12 +    unsigned is_extfn;
    2.13 +    unsigned is_virtfn;
    2.14 +    struct {
    2.15 +        uint8_t bus;
    2.16 +        uint8_t devfn;
    2.17 +    } physfn;
    2.18 +};
    2.19 +
    2.20 +typedef struct physdev_manage_pci_ext physdev_manage_pci_ext_t;
    2.21 +DEFINE_XEN_GUEST_HANDLE(physdev_manage_pci_ext_t);
    2.22 +
    2.23  /*
    2.24   * Argument to physdev_op_compat() hypercall. Superceded by new physdev_op()
    2.25   * hypercall since 0x00030202.