blob: 68bcefd7fca002a89446603d4fc894e6de2b24b0 [file] [log] [blame]
Joerg Roedel5cdede22011-04-04 15:55:18 +02001#ifndef LINUX_PCI_ATS_H
2#define LINUX_PCI_ATS_H
3
Joerg Roedeldb3c33c2011-09-27 15:57:13 +02004#include <linux/pci.h>
5
Joerg Roedel5cdede22011-04-04 15:55:18 +02006/* Address Translation Service */
7struct pci_ats {
8 int pos; /* capability position */
9 int stu; /* Smallest Translation Unit */
10 int qdep; /* Invalidate Queue Depth */
11 int ref_cnt; /* Physical Function reference count */
12 unsigned int is_enabled:1; /* Enable bit is set */
13};
14
Joerg Roedel466b3dd2011-10-30 16:35:08 +010015#ifdef CONFIG_PCI_ATS
Joerg Roedel5cdede22011-04-04 15:55:18 +020016
Bjorn Helgaasf39d5b72013-04-12 12:02:59 -060017int pci_enable_ats(struct pci_dev *dev, int ps);
18void pci_disable_ats(struct pci_dev *dev);
19int pci_ats_queue_depth(struct pci_dev *dev);
Joerg Roedelc320b972011-09-27 15:57:15 +020020
Joerg Roedel5cdede22011-04-04 15:55:18 +020021/**
22 * pci_ats_enabled - query the ATS status
23 * @dev: the PCI device
24 *
25 * Returns 1 if ATS capability is enabled, or 0 if not.
26 */
27static inline int pci_ats_enabled(struct pci_dev *dev)
28{
29 return dev->ats && dev->ats->is_enabled;
30}
31
Joerg Roedel466b3dd2011-10-30 16:35:08 +010032#else /* CONFIG_PCI_ATS */
Joerg Roedel5cdede22011-04-04 15:55:18 +020033
34static inline int pci_enable_ats(struct pci_dev *dev, int ps)
35{
36 return -ENODEV;
37}
38
39static inline void pci_disable_ats(struct pci_dev *dev)
40{
41}
42
43static inline int pci_ats_queue_depth(struct pci_dev *dev)
44{
45 return -ENODEV;
46}
47
48static inline int pci_ats_enabled(struct pci_dev *dev)
49{
50 return 0;
51}
52
Joerg Roedel466b3dd2011-10-30 16:35:08 +010053#endif /* CONFIG_PCI_ATS */
Joerg Roedel5cdede22011-04-04 15:55:18 +020054
Joerg Roedelc320b972011-09-27 15:57:15 +020055#ifdef CONFIG_PCI_PRI
56
Bjorn Helgaasf39d5b72013-04-12 12:02:59 -060057int pci_enable_pri(struct pci_dev *pdev, u32 reqs);
58void pci_disable_pri(struct pci_dev *pdev);
59bool pci_pri_enabled(struct pci_dev *pdev);
60int pci_reset_pri(struct pci_dev *pdev);
61bool pci_pri_stopped(struct pci_dev *pdev);
62int pci_pri_status(struct pci_dev *pdev);
Joerg Roedelc320b972011-09-27 15:57:15 +020063
64#else /* CONFIG_PCI_PRI */
65
66static inline int pci_enable_pri(struct pci_dev *pdev, u32 reqs)
67{
68 return -ENODEV;
69}
70
71static inline void pci_disable_pri(struct pci_dev *pdev)
72{
73}
74
75static inline bool pci_pri_enabled(struct pci_dev *pdev)
76{
77 return false;
78}
79
80static inline int pci_reset_pri(struct pci_dev *pdev)
81{
82 return -ENODEV;
83}
84
85static inline bool pci_pri_stopped(struct pci_dev *pdev)
86{
87 return true;
88}
89
90static inline int pci_pri_status(struct pci_dev *pdev)
91{
92 return -ENODEV;
93}
94#endif /* CONFIG_PCI_PRI */
95
Joerg Roedel086ac112011-09-27 15:57:16 +020096#ifdef CONFIG_PCI_PASID
97
Bjorn Helgaasf39d5b72013-04-12 12:02:59 -060098int pci_enable_pasid(struct pci_dev *pdev, int features);
99void pci_disable_pasid(struct pci_dev *pdev);
100int pci_pasid_features(struct pci_dev *pdev);
101int pci_max_pasids(struct pci_dev *pdev);
Joerg Roedel086ac112011-09-27 15:57:16 +0200102
103#else /* CONFIG_PCI_PASID */
104
105static inline int pci_enable_pasid(struct pci_dev *pdev, int features)
106{
107 return -EINVAL;
108}
109
110static inline void pci_disable_pasid(struct pci_dev *pdev)
111{
112}
113
114static inline int pci_pasid_features(struct pci_dev *pdev)
115{
116 return -EINVAL;
117}
118
119static inline int pci_max_pasids(struct pci_dev *pdev)
120{
121 return -EINVAL;
122}
123
124#endif /* CONFIG_PCI_PASID */
125
126
Joerg Roedel5cdede22011-04-04 15:55:18 +0200127#endif /* LINUX_PCI_ATS_H*/