1 /*
2 * This program is free software; you can redistribute it and/or modify it
3 * under the terms and conditions of the GNU General Public License,
4 * version 2, as published by the Free Software Foundation.
5 *
6 * This program is distributed in the hope it will be useful, but WITHOUT
7 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
8 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
9 * more details.
10 *
11 * You should have received a copy of the GNU General Public License along with
12 * this program; If not, see <http://www.gnu.org/licenses/>.
13 */
14
15 #ifndef _ATS_H_
16 #define _ATS_H_
17
18 #include <xen/pci_regs.h>
19
20 #define ATS_REG_CAP 4
21 #define ATS_REG_CTL 6
22 #define ATS_QUEUE_DEPTH_MASK 0x1f
23 #define ATS_ENABLE (1<<15)
24
25 extern bool_t ats_enabled;
26
27 int enable_ats_device(struct pci_dev *pdev, struct list_head *ats_list);
28 void disable_ats_device(struct pci_dev *pdev);
29
pci_ats_enabled(int seg,int bus,int devfn)30 static inline int pci_ats_enabled(int seg, int bus, int devfn)
31 {
32 u32 value;
33 int pos;
34
35 pos = pci_find_ext_capability(seg, bus, devfn, PCI_EXT_CAP_ID_ATS);
36 BUG_ON(!pos);
37
38 value = pci_conf_read16(seg, bus, PCI_SLOT(devfn), PCI_FUNC(devfn),
39 pos + ATS_REG_CTL);
40 return value & ATS_ENABLE;
41 }
42
pci_ats_device(int seg,int bus,int devfn)43 static inline int pci_ats_device(int seg, int bus, int devfn)
44 {
45 if ( !ats_enabled )
46 return 0;
47
48 return pci_find_ext_capability(seg, bus, devfn, PCI_EXT_CAP_ID_ATS);
49 }
50
51 #endif /* _ATS_H_ */
52
53