[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH 3 of 5] ats: Add new ATS helper functions
# HG changeset patch # User Wei Wang <wei.wang2@xxxxxxx> # Date 1320314663 -3600 # Node ID c839972486f86a0833595bebae0baa0cd2c0d15e # Parent d0c38cb215cd96e01de27eadf5ec0a5e711de448 ats: Add new ATS helper functions Signed-off-by Wei Wang <wei.wang2@xxxxxxx> diff -r d0c38cb215cd -r c839972486f8 xen/drivers/passthrough/ats.h --- a/xen/drivers/passthrough/ats.h Thu Nov 03 11:03:37 2011 +0100 +++ b/xen/drivers/passthrough/ats.h Thu Nov 03 11:04:23 2011 +0100 @@ -21,6 +21,8 @@ #define ATS_QUEUE_DEPTH_MASK 0xF #define ATS_ENABLE (1<<15) +#include <xen/pci_regs.h> + struct pci_ats_dev { struct list_head list; u16 seg; @@ -34,6 +36,27 @@ extern bool_t ats_enabled; int enable_ats_device(int seg, int bus, int devfn); void disable_ats_device(int seg, int bus, int devfn); +struct pci_ats_dev *get_ats_device(int seg, int bus, int devfn); +static inline int pci_ats_enabled(int seg, int bus, int devfn) +{ + u32 value; + int pos; + + pos = pci_find_ext_capability(seg, bus, devfn, PCI_EXT_CAP_ID_ATS); + BUG_ON(!pos); + + value = pci_conf_read16(seg, bus, PCI_SLOT(devfn), + PCI_FUNC(devfn), pos + ATS_REG_CTL); + return value & ATS_ENABLE; +} + +static inline int pci_ats_device(int seg, int bus, int devfn) +{ + if ( !ats_enabled ) + return 0; + + return pci_find_ext_capability(seg, bus, devfn, PCI_EXT_CAP_ID_ATS); +} #endif /* _ATS_H_ */ diff -r d0c38cb215cd -r c839972486f8 xen/drivers/passthrough/x86/ats.c --- a/xen/drivers/passthrough/x86/ats.c Thu Nov 03 11:03:37 2011 +0100 +++ b/xen/drivers/passthrough/x86/ats.c Thu Nov 03 11:04:23 2011 +0100 @@ -137,3 +137,19 @@ void disable_ats_device(int seg, int bus "%04x:%02x:%02x.%u: ATS is disabled\n", seg, bus, PCI_SLOT(devfn), PCI_FUNC(devfn)); } + +struct pci_ats_dev *get_ats_device(int seg, int bus, int devfn) +{ + struct pci_ats_dev *pdev; + + if ( !pci_ats_device(seg, bus, devfn) ) + return NULL; + + list_for_each_entry ( pdev, &ats_devices, list ) + { + if ( pdev->seg == seg && pdev->bus == bus && pdev->devfn == devfn ) + return pdev; + } + + return NULL; +} _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxxxxxxxx http://lists.xensource.com/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |