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) 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 20 static inline int __init pci_xen_initial_domain(void) 21 { 22 return -1; 23 } 24 #endif 25 #ifdef CONFIG_XEN_DOM0 26 int xen_find_device_domain_owner(struct pci_dev *dev); 27 int xen_register_device_domain_owner(struct pci_dev *dev, uint16_t domain); 28 int xen_unregister_device_domain_owner(struct pci_dev *dev); 29 #else 30 static inline int xen_find_device_domain_owner(struct pci_dev *dev) 31 { 32 return -1; 33 } 34 static inline int xen_register_device_domain_owner(struct pci_dev *dev, 35 uint16_t domain) 36 { 37 return -1; 38 } 39 static inline int xen_unregister_device_domain_owner(struct pci_dev *dev) 40 { 41 return -1; 42 } 43 #endif 44 45 #if defined(CONFIG_PCI_MSI) 46 #if defined(CONFIG_PCI_XEN) 47 /* The drivers/pci/xen-pcifront.c sets this structure to 48 * its own functions. 49 */ 50 struct xen_pci_frontend_ops { 51 int (*enable_msi)(struct pci_dev *dev, int vectors[]); 52 void (*disable_msi)(struct pci_dev *dev); 53 int (*enable_msix)(struct pci_dev *dev, int vectors[], int nvec); 54 void (*disable_msix)(struct pci_dev *dev); 55 }; 56 57 extern struct xen_pci_frontend_ops *xen_pci_frontend; 58 59 static inline int xen_pci_frontend_enable_msi(struct pci_dev *dev, 60 int vectors[]) 61 { 62 if (xen_pci_frontend && xen_pci_frontend->enable_msi) 63 return xen_pci_frontend->enable_msi(dev, vectors); 64 return -ENOSYS; 65 } 66 static inline void xen_pci_frontend_disable_msi(struct pci_dev *dev) 67 { 68 if (xen_pci_frontend && xen_pci_frontend->disable_msi) 69 xen_pci_frontend->disable_msi(dev); 70 } 71 static inline int xen_pci_frontend_enable_msix(struct pci_dev *dev, 72 int vectors[], int nvec) 73 { 74 if (xen_pci_frontend && xen_pci_frontend->enable_msix) 75 return xen_pci_frontend->enable_msix(dev, vectors, nvec); 76 return -ENOSYS; 77 } 78 static inline void xen_pci_frontend_disable_msix(struct pci_dev *dev) 79 { 80 if (xen_pci_frontend && xen_pci_frontend->disable_msix) 81 xen_pci_frontend->disable_msix(dev); 82 } 83 #endif /* CONFIG_PCI_XEN */ 84 #endif /* CONFIG_PCI_MSI */ 85 86 #endif /* _ASM_X86_XEN_PCI_H */ 87