blob: 4fbda9a3f33905342a08c7819f247056228e1b9f [file] [log] [blame]
Alex Nixonb5401a92010-03-18 16:31:34 -04001#ifndef _ASM_X86_XEN_PCI_H
2#define _ASM_X86_XEN_PCI_H
3
4#if defined(CONFIG_PCI_XEN)
5extern int __init pci_xen_init(void);
Stefano Stabellini3942b742010-06-24 17:50:18 +01006extern int __init pci_xen_hvm_init(void);
Alex Nixonb5401a92010-03-18 16:31:34 -04007#define pci_xen 1
8#else
9#define pci_xen 0
10#define pci_xen_init (0)
Stefano Stabellini3942b742010-06-24 17:50:18 +010011static inline int pci_xen_hvm_init(void)
12{
13 return -1;
14}
Alex Nixonb5401a92010-03-18 16:31:34 -040015#endif
Jeremy Fitzhardinge38aa66f2010-09-02 14:51:39 +010016#if defined(CONFIG_XEN_DOM0)
17void __init xen_setup_pirqs(void);
Konrad Rzeszutek Wilkc55fa782010-11-08 14:13:35 -050018int xen_find_device_domain_owner(struct pci_dev *dev);
19int xen_register_device_domain_owner(struct pci_dev *dev, uint16_t domain);
20int xen_unregister_device_domain_owner(struct pci_dev *dev);
Jeremy Fitzhardinge38aa66f2010-09-02 14:51:39 +010021#else
22static inline void __init xen_setup_pirqs(void)
23{
24}
Konrad Rzeszutek Wilkc55fa782010-11-08 14:13:35 -050025static inline int xen_find_device_domain_owner(struct pci_dev *dev)
26{
27 return -1;
28}
29static inline int xen_register_device_domain_owner(struct pci_dev *dev,
30 uint16_t domain)
31{
32 return -1;
33}
34static inline int xen_unregister_device_domain_owner(struct pci_dev *dev)
35{
36 return -1;
37}
Jeremy Fitzhardinge38aa66f2010-09-02 14:51:39 +010038#endif
Alex Nixonb5401a92010-03-18 16:31:34 -040039
40#if defined(CONFIG_PCI_MSI)
41#if defined(CONFIG_PCI_XEN)
42/* The drivers/pci/xen-pcifront.c sets this structure to
43 * its own functions.
44 */
45struct xen_pci_frontend_ops {
Konrad Rzeszutek Wilkcc0f89c2011-02-17 12:02:23 -050046 int (*enable_msi)(struct pci_dev *dev, int vectors[]);
Alex Nixonb5401a92010-03-18 16:31:34 -040047 void (*disable_msi)(struct pci_dev *dev);
Konrad Rzeszutek Wilkcc0f89c2011-02-17 12:02:23 -050048 int (*enable_msix)(struct pci_dev *dev, int vectors[], int nvec);
Alex Nixonb5401a92010-03-18 16:31:34 -040049 void (*disable_msix)(struct pci_dev *dev);
50};
51
52extern struct xen_pci_frontend_ops *xen_pci_frontend;
53
54static inline int xen_pci_frontend_enable_msi(struct pci_dev *dev,
Konrad Rzeszutek Wilkcc0f89c2011-02-17 12:02:23 -050055 int vectors[])
Alex Nixonb5401a92010-03-18 16:31:34 -040056{
57 if (xen_pci_frontend && xen_pci_frontend->enable_msi)
58 return xen_pci_frontend->enable_msi(dev, vectors);
59 return -ENODEV;
60}
61static inline void xen_pci_frontend_disable_msi(struct pci_dev *dev)
62{
63 if (xen_pci_frontend && xen_pci_frontend->disable_msi)
64 xen_pci_frontend->disable_msi(dev);
65}
66static inline int xen_pci_frontend_enable_msix(struct pci_dev *dev,
Konrad Rzeszutek Wilkcc0f89c2011-02-17 12:02:23 -050067 int vectors[], int nvec)
Alex Nixonb5401a92010-03-18 16:31:34 -040068{
69 if (xen_pci_frontend && xen_pci_frontend->enable_msix)
70 return xen_pci_frontend->enable_msix(dev, vectors, nvec);
71 return -ENODEV;
72}
73static inline void xen_pci_frontend_disable_msix(struct pci_dev *dev)
74{
75 if (xen_pci_frontend && xen_pci_frontend->disable_msix)
76 xen_pci_frontend->disable_msix(dev);
77}
78#endif /* CONFIG_PCI_XEN */
79#endif /* CONFIG_PCI_MSI */
80
81#endif /* _ASM_X86_XEN_PCI_H */