This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
Home Products Support Community News


[Xen-devel] [PATCH 4/8] [xen/pci] Provide a registration mechanism for t

This registration mechanism allows us to "hook-up" the PCI frontend
enable/disable MSI/MSI-X calls when the module (or if it is compiled in)
is loaded. If it is not loaded, the caller (next patch) will just
call an empty stub.

Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@xxxxxxxxxx>
 arch/x86/include/asm/xen/pci.h |   45 ++++++++++++++++++++++++++++-----------
 1 files changed, 32 insertions(+), 13 deletions(-)

diff --git a/arch/x86/include/asm/xen/pci.h b/arch/x86/include/asm/xen/pci.h
index 6c022c8..9f0a14b 100644
--- a/arch/x86/include/asm/xen/pci.h
+++ b/arch/x86/include/asm/xen/pci.h
@@ -35,24 +35,43 @@ static inline int xen_setup_msi_irqs(struct pci_dev *dev, 
int nvec, int type)
        return -1;
-/* Defined in drivers/pci/xen-pcifront.c */
-int pci_frontend_enable_msi(struct pci_dev *dev, int **vectors);
-void pci_frontend_disable_msi(struct pci_dev *dev);
-int pci_frontend_enable_msix(struct pci_dev *dev,
-                            int **vectors, int nvec);
-void pci_frontend_disable_msix(struct pci_dev *dev);
-static inline int pci_frontend_enable_msi(struct pci_dev *dev, int **vectors)
+#if defined(CONFIG_PCI_MSI)
+/* The drivers/pci/xen-pcifront.c sets this structure to
+ * its own functions.
+ */
+struct xen_pci_frontend_ops {
+       int (*enable_msi)(struct pci_dev *dev, int **vectors);
+       void (*disable_msi)(struct pci_dev *dev);
+       int (*enable_msix)(struct pci_dev *dev, int **vectors, int nvec);
+       void (*disable_msix)(struct pci_dev *dev);
+extern struct xen_pci_frontend_ops *xen_pci_frontend;
+static inline int xen_pci_frontend_enable_msi(struct pci_dev *dev,
+                                             int **vectors)
+       if (xen_pci_frontend && xen_pci_frontend->enable_msi)
+               return xen_pci_frontend->enable_msi(dev, vectors);
        return -1;
-static inline void pci_frontend_disable_msi(struct pci_dev *dev) { }
-static inline int pci_frontend_enable_msix(struct pci_dev *dev,
-                                          int **vectors, int nvec)
+static inline void xen_pci_frontend_disable_msi(struct pci_dev *dev)
+       if (xen_pci_frontend && xen_pci_frontend->disable_msi)
+                       xen_pci_frontend->disable_msi(dev);
+static inline int xen_pci_frontend_enable_msix(struct pci_dev *dev,
+                                              int **vectors, int nvec)
+       if (xen_pci_frontend && xen_pci_frontend->enable_msix)
+               return xen_pci_frontend->enable_msix(dev, vectors, nvec);
        return -1;
-static inline void pci_frontend_disable_msix(struct pci_dev *dev) { }
+static inline void xen_pci_frontend_disable_msix(struct pci_dev *dev)
+       if (xen_pci_frontend && xen_pci_frontend->disable_msix)
+                       xen_pci_frontend->disable_msix(dev);
 #endif /* _ASM_X86_XEN_PCI_H */

Xen-devel mailing list