vfio: move the vfio_iommu_driver_ops interface out of <linux/vfio.h>
authorChristoph Hellwig <hch@lst.de>
Fri, 24 Sep 2021 15:56:59 +0000 (17:56 +0200)
committerAlex Williamson <alex.williamson@redhat.com>
Thu, 30 Sep 2021 18:46:44 +0000 (12:46 -0600)
Create a new private drivers/vfio/vfio.h header for the interface between
the VFIO core and the iommu drivers.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Jason Gunthorpe <jgg@nvidia.com>
Reviewed-by: Kevin Tian <kevin.tian@intel.com>
Link: https://lore.kernel.org/r/20210924155705.4258-10-hch@lst.de
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
drivers/vfio/vfio.c
drivers/vfio/vfio.h [new file with mode: 0644]
drivers/vfio/vfio_iommu_spapr_tce.c
drivers/vfio/vfio_iommu_type1.c
include/linux/vfio.h

index 2c1c731..6589e29 100644 (file)
@@ -32,6 +32,7 @@
 #include <linux/vfio.h>
 #include <linux/wait.h>
 #include <linux/sched/signal.h>
+#include "vfio.h"
 
 #define DRIVER_VERSION "0.3"
 #define DRIVER_AUTHOR  "Alex Williamson <alex.williamson@redhat.com>"
diff --git a/drivers/vfio/vfio.h b/drivers/vfio/vfio.h
new file mode 100644 (file)
index 0000000..a78de64
--- /dev/null
@@ -0,0 +1,47 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+/*
+ * Copyright (C) 2012 Red Hat, Inc.  All rights reserved.
+ *     Author: Alex Williamson <alex.williamson@redhat.com>
+ */
+
+/* events for the backend driver notify callback */
+enum vfio_iommu_notify_type {
+       VFIO_IOMMU_CONTAINER_CLOSE = 0,
+};
+
+/**
+ * struct vfio_iommu_driver_ops - VFIO IOMMU driver callbacks
+ */
+struct vfio_iommu_driver_ops {
+       char            *name;
+       struct module   *owner;
+       void            *(*open)(unsigned long arg);
+       void            (*release)(void *iommu_data);
+       long            (*ioctl)(void *iommu_data, unsigned int cmd,
+                                unsigned long arg);
+       int             (*attach_group)(void *iommu_data,
+                                       struct iommu_group *group);
+       void            (*detach_group)(void *iommu_data,
+                                       struct iommu_group *group);
+       int             (*pin_pages)(void *iommu_data,
+                                    struct iommu_group *group,
+                                    unsigned long *user_pfn,
+                                    int npage, int prot,
+                                    unsigned long *phys_pfn);
+       int             (*unpin_pages)(void *iommu_data,
+                                      unsigned long *user_pfn, int npage);
+       int             (*register_notifier)(void *iommu_data,
+                                            unsigned long *events,
+                                            struct notifier_block *nb);
+       int             (*unregister_notifier)(void *iommu_data,
+                                              struct notifier_block *nb);
+       int             (*dma_rw)(void *iommu_data, dma_addr_t user_iova,
+                                 void *data, size_t count, bool write);
+       struct iommu_domain *(*group_iommu_domain)(void *iommu_data,
+                                                  struct iommu_group *group);
+       void            (*notify)(void *iommu_data,
+                                 enum vfio_iommu_notify_type event);
+};
+
+int vfio_register_iommu_driver(const struct vfio_iommu_driver_ops *ops);
+void vfio_unregister_iommu_driver(const struct vfio_iommu_driver_ops *ops);
index fe888b5..3efd09f 100644 (file)
@@ -20,6 +20,7 @@
 #include <linux/sched/mm.h>
 #include <linux/sched/signal.h>
 #include <linux/mm.h>
+#include "vfio.h"
 
 #include <asm/iommu.h>
 #include <asm/tce.h>
index 0e92176..2e51e43 100644 (file)
@@ -40,6 +40,7 @@
 #include <linux/notifier.h>
 #include <linux/dma-iommu.h>
 #include <linux/irqdomain.h>
+#include "vfio.h"
 
 #define DRIVER_VERSION  "0.2"
 #define DRIVER_AUTHOR   "Alex Williamson <alex.williamson@redhat.com>"
index 7a57a00..76191d7 100644 (file)
@@ -82,50 +82,6 @@ extern void vfio_device_put(struct vfio_device *device);
 
 int vfio_assign_device_set(struct vfio_device *device, void *set_id);
 
-/* events for the backend driver notify callback */
-enum vfio_iommu_notify_type {
-       VFIO_IOMMU_CONTAINER_CLOSE = 0,
-};
-
-/**
- * struct vfio_iommu_driver_ops - VFIO IOMMU driver callbacks
- */
-struct vfio_iommu_driver_ops {
-       char            *name;
-       struct module   *owner;
-       void            *(*open)(unsigned long arg);
-       void            (*release)(void *iommu_data);
-       long            (*ioctl)(void *iommu_data, unsigned int cmd,
-                                unsigned long arg);
-       int             (*attach_group)(void *iommu_data,
-                                       struct iommu_group *group);
-       void            (*detach_group)(void *iommu_data,
-                                       struct iommu_group *group);
-       int             (*pin_pages)(void *iommu_data,
-                                    struct iommu_group *group,
-                                    unsigned long *user_pfn,
-                                    int npage, int prot,
-                                    unsigned long *phys_pfn);
-       int             (*unpin_pages)(void *iommu_data,
-                                      unsigned long *user_pfn, int npage);
-       int             (*register_notifier)(void *iommu_data,
-                                            unsigned long *events,
-                                            struct notifier_block *nb);
-       int             (*unregister_notifier)(void *iommu_data,
-                                              struct notifier_block *nb);
-       int             (*dma_rw)(void *iommu_data, dma_addr_t user_iova,
-                                 void *data, size_t count, bool write);
-       struct iommu_domain *(*group_iommu_domain)(void *iommu_data,
-                                                  struct iommu_group *group);
-       void            (*notify)(void *iommu_data,
-                                 enum vfio_iommu_notify_type event);
-};
-
-extern int vfio_register_iommu_driver(const struct vfio_iommu_driver_ops *ops);
-
-extern void vfio_unregister_iommu_driver(
-                               const struct vfio_iommu_driver_ops *ops);
-
 /*
  * External user API
  */