@@ -133,6 +133,12 @@ struct vfio_device_ops {
#if IS_ENABLED(CONFIG_IOMMUFD)
struct iommufd_ctx *vfio_iommufd_device_ictx(struct vfio_device *vdev);
+int vfio_iommufd_device_set_num_msi_iovas(struct vfio_device *vdev,
+ unsigned int num);
+int vfio_iommufd_device_set_msi_iova(struct vfio_device *vdev,
+ unsigned int index, dma_addr_t iova);
+void vfio_iommufd_device_unset_msi_iova(struct vfio_device *vdev,
+ unsigned int index);
int vfio_iommufd_get_dev_id(struct vfio_device *vdev, struct iommufd_ctx *ictx);
int vfio_iommufd_physical_bind(struct vfio_device *vdev,
struct iommufd_ctx *ictx, u32 *out_device_id);
@@ -151,6 +157,25 @@ vfio_iommufd_device_ictx(struct vfio_device *vdev)
return NULL;
}
+static inline int
+vfio_iommufd_device_set_num_msi_iovas(struct vfio_device *vdev,
+ unsigned int num)
+{
+ return -EOPNOTSUPP;
+}
+
+static inline int vfio_iommufd_device_set_msi_iova(struct vfio_device *vdev,
+ unsigned int index,
+ dma_addr_t iova)
+{
+ return -EOPNOTSUPP;
+}
+
+static inline void vfio_iommufd_device_unset_msi_iova(struct vfio_device *vdev,
+ unsigned int index)
+{
+}
+
static inline int
vfio_iommufd_get_dev_id(struct vfio_device *vdev, struct iommufd_ctx *ictx)
{
@@ -69,6 +69,33 @@ struct iommufd_ctx *vfio_iommufd_device_ictx(struct vfio_device *vdev)
}
EXPORT_SYMBOL_GPL(vfio_iommufd_device_ictx);
+int vfio_iommufd_device_set_num_msi_iovas(struct vfio_device *vdev,
+ unsigned int num)
+{
+ if (!vdev->iommufd_device)
+ return -ENODEV;
+ return iommufd_device_set_num_msi_iovas(vdev->iommufd_device, num);
+}
+EXPORT_SYMBOL_GPL(vfio_iommufd_device_set_num_msi_iovas);
+
+int vfio_iommufd_device_set_msi_iova(struct vfio_device *vdev,
+ unsigned int index, dma_addr_t iova)
+{
+ if (!vdev->iommufd_device)
+ return -ENODEV;
+ return iommufd_device_set_msi_iova(vdev->iommufd_device, index, iova);
+}
+EXPORT_SYMBOL_GPL(vfio_iommufd_device_set_msi_iova);
+
+void vfio_iommufd_device_unset_msi_iova(struct vfio_device *vdev,
+ unsigned int index)
+{
+ if (!vdev->iommufd_device)
+ return;
+ iommufd_device_unset_msi_iova(vdev->iommufd_device, index);
+}
+EXPORT_SYMBOL_GPL(vfio_iommufd_device_unset_msi_iova);
+
static int vfio_iommufd_device_id(struct vfio_device *vdev)
{
if (vdev->iommufd_device)
As the bridge between iommufd core and vfio core, add a set of msi_iova helpers to call the new msi_iova helpers from the iommufd_device level. The next patch will use this bridging helpers in vfio-pci code. Signed-off-by: Nicolin Chen <nicolinc@nvidia.com> --- include/linux/vfio.h | 25 +++++++++++++++++++++++++ drivers/vfio/iommufd.c | 27 +++++++++++++++++++++++++++ 2 files changed, 52 insertions(+)