# HG changeset patch # User Yu Zhao # Date 1237353055 14400 # Node ID 582ec8e86ffff64834e8c77ef6790774352ddc7a # Parent 577169901110eb89ff36f1460e152a5c96297bde 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. diff -r 577169901110 -r 582ec8e86fff drivers/xen/core/pci.c --- a/drivers/xen/core/pci.c Tue Mar 17 02:23:02 2009 -0400 +++ b/drivers/xen/core/pci.c Wed Mar 18 01:10:55 2009 -0400 @@ -6,6 +6,7 @@ #include #include #include +#include "../../pci/pci.h" static int (*pci_bus_probe)(struct device *dev); static int (*pci_bus_remove)(struct device *dev); @@ -15,8 +16,16 @@ int r; struct pci_dev *pci_dev = to_pci_dev(dev); struct physdev_manage_pci manage_pci; + + memset(&manage_pci, 0, sizeof(manage_pci)); manage_pci.bus = pci_dev->bus->number; manage_pci.devfn = pci_dev->devfn; + if (pci_dev->is_virtfn) { + manage_pci.is_virtfn = 1; + manage_pci.physfn.bus = pci_dev->physfn->bus->number; + manage_pci.physfn.devfn = pci_dev->physfn->devfn; + } else if (pci_ari_enabled(pci_dev->bus) && PCI_SLOT(pci_dev->devfn)) + manage_pci.is_extfn = 1; r = HYPERVISOR_physdev_op(PHYSDEVOP_manage_pci_add, &manage_pci); if (r && r != -ENOSYS) diff -r 577169901110 -r 582ec8e86fff include/xen/interface/physdev.h --- a/include/xen/interface/physdev.h Tue Mar 17 02:23:02 2009 -0400 +++ b/include/xen/interface/physdev.h Wed Mar 18 01:10:55 2009 -0400 @@ -178,6 +178,12 @@ /* IN */ uint8_t bus; uint8_t devfn; + unsigned is_extfn:1; + unsigned is_virtfn:1; + struct { + uint8_t bus; + uint8_t devfn; + } physfn; }; typedef struct physdev_manage_pci physdev_manage_pci_t;