1 /* SPDX-License-Identifier: GPL-2.0-only */
3 * Copyright (C) 2012 Red Hat, Inc. All rights reserved.
4 * Author: Alex Williamson <alex.williamson@redhat.com>
9 * Physical device with IOMMU backing.
14 * Virtual device without IOMMU backing. The VFIO core fakes up an
15 * iommu_group as the iommu_group sysfs interface is part of the
16 * userspace ABI. The user of these devices must not be able to
17 * directly trigger unmediated DMA.
22 * Physical device without IOMMU backing. The VFIO core fakes up an
23 * iommu_group as the iommu_group sysfs interface is part of the
24 * userspace ABI. Users can trigger unmediated DMA by the device,
25 * usage is highly dangerous, requires an explicit opt-in and will
31 /* events for the backend driver notify callback */
32 enum vfio_iommu_notify_type {
33 VFIO_IOMMU_CONTAINER_CLOSE = 0,
37 * struct vfio_iommu_driver_ops - VFIO IOMMU driver callbacks
39 struct vfio_iommu_driver_ops {
42 void *(*open)(unsigned long arg);
43 void (*release)(void *iommu_data);
44 long (*ioctl)(void *iommu_data, unsigned int cmd,
46 int (*attach_group)(void *iommu_data,
47 struct iommu_group *group,
48 enum vfio_group_type);
49 void (*detach_group)(void *iommu_data,
50 struct iommu_group *group);
51 int (*pin_pages)(void *iommu_data,
52 struct iommu_group *group,
56 void (*unpin_pages)(void *iommu_data,
57 dma_addr_t user_iova, int npage);
58 void (*register_device)(void *iommu_data,
59 struct vfio_device *vdev);
60 void (*unregister_device)(void *iommu_data,
61 struct vfio_device *vdev);
62 int (*dma_rw)(void *iommu_data, dma_addr_t user_iova,
63 void *data, size_t count, bool write);
64 struct iommu_domain *(*group_iommu_domain)(void *iommu_data,
65 struct iommu_group *group);
66 void (*notify)(void *iommu_data,
67 enum vfio_iommu_notify_type event);
70 int vfio_register_iommu_driver(const struct vfio_iommu_driver_ops *ops);
71 void vfio_unregister_iommu_driver(const struct vfio_iommu_driver_ops *ops);