xref: /linux/arch/x86/include/asm/xen/pci.h (revision 03ab8e6297acd1bc0eedaa050e2a1635c576fd11)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _ASM_X86_XEN_PCI_H
3 #define _ASM_X86_XEN_PCI_H
4 
5 #if defined(CONFIG_PCI_XEN)
6 extern int __init pci_xen_init(void);
7 extern int __init pci_xen_hvm_init(void);
8 #define pci_xen 1
9 #else
10 #define pci_xen 0
11 #define pci_xen_init (0)
pci_xen_hvm_init(void)12 static inline int pci_xen_hvm_init(void)
13 {
14 	return -1;
15 }
16 #endif
17 #ifdef CONFIG_XEN_PV_DOM0
18 int __init pci_xen_initial_domain(void);
19 #else
pci_xen_initial_domain(void)20 static inline int __init pci_xen_initial_domain(void)
21 {
22 	return -1;
23 }
24 #endif
25 
26 #if defined(CONFIG_PCI_MSI)
27 #if defined(CONFIG_PCI_XEN)
28 /* The drivers/pci/xen-pcifront.c sets this structure to
29  * its own functions.
30  */
31 struct xen_pci_frontend_ops {
32 	int (*enable_msi)(struct pci_dev *dev, int vectors[]);
33 	void (*disable_msi)(struct pci_dev *dev);
34 	int (*enable_msix)(struct pci_dev *dev, int vectors[], int nvec);
35 	void (*disable_msix)(struct pci_dev *dev);
36 };
37 
38 extern struct xen_pci_frontend_ops *xen_pci_frontend;
39 
xen_pci_frontend_enable_msi(struct pci_dev * dev,int vectors[])40 static inline int xen_pci_frontend_enable_msi(struct pci_dev *dev,
41 					      int vectors[])
42 {
43 	if (xen_pci_frontend && xen_pci_frontend->enable_msi)
44 		return xen_pci_frontend->enable_msi(dev, vectors);
45 	return -ENOSYS;
46 }
xen_pci_frontend_disable_msi(struct pci_dev * dev)47 static inline void xen_pci_frontend_disable_msi(struct pci_dev *dev)
48 {
49 	if (xen_pci_frontend && xen_pci_frontend->disable_msi)
50 			xen_pci_frontend->disable_msi(dev);
51 }
xen_pci_frontend_enable_msix(struct pci_dev * dev,int vectors[],int nvec)52 static inline int xen_pci_frontend_enable_msix(struct pci_dev *dev,
53 					       int vectors[], int nvec)
54 {
55 	if (xen_pci_frontend && xen_pci_frontend->enable_msix)
56 		return xen_pci_frontend->enable_msix(dev, vectors, nvec);
57 	return -ENOSYS;
58 }
xen_pci_frontend_disable_msix(struct pci_dev * dev)59 static inline void xen_pci_frontend_disable_msix(struct pci_dev *dev)
60 {
61 	if (xen_pci_frontend && xen_pci_frontend->disable_msix)
62 			xen_pci_frontend->disable_msix(dev);
63 }
64 #endif /* CONFIG_PCI_XEN */
65 #endif /* CONFIG_PCI_MSI */
66 
67 #endif	/* _ASM_X86_XEN_PCI_H */
68