This patch introduces a new method in the vdpa_config_ops to support processing the raw vhost memory mapping message in the vDPA device driver. Signed-off-by: Xie Yongji <xieyongji@xxxxxxxxxxxxx> --- drivers/vhost/vdpa.c | 5 ++++- include/linux/vdpa.h | 7 +++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/drivers/vhost/vdpa.c b/drivers/vhost/vdpa.c index 448be7875b6d..ccbb391e38be 100644 --- a/drivers/vhost/vdpa.c +++ b/drivers/vhost/vdpa.c @@ -728,6 +728,9 @@ static int vhost_vdpa_process_iotlb_msg(struct vhost_dev *dev, if (r) return r; + if (ops->process_iotlb_msg) + return ops->process_iotlb_msg(vdpa, msg); + switch (msg->type) { case VHOST_IOTLB_UPDATE: r = vhost_vdpa_process_iotlb_update(v, msg); @@ -770,7 +773,7 @@ static int vhost_vdpa_alloc_domain(struct vhost_vdpa *v) int ret; /* Device want to do DMA by itself */ - if (ops->set_map || ops->dma_map) + if (ops->set_map || ops->dma_map || ops->process_iotlb_msg) return 0; bus = dma_dev->bus; diff --git a/include/linux/vdpa.h b/include/linux/vdpa.h index 656fe264234e..7bccedf22f4b 100644 --- a/include/linux/vdpa.h +++ b/include/linux/vdpa.h @@ -5,6 +5,7 @@ #include <linux/kernel.h> #include <linux/device.h> #include <linux/interrupt.h> +#include <linux/vhost_types.h> #include <linux/vhost_iotlb.h> #include <net/genetlink.h> @@ -172,6 +173,10 @@ struct vdpa_iova_range { * @vdev: vdpa device * Returns the iova range supported by * the device. + * @process_iotlb_msg: Process vhost memory mapping message (optional) + * Only used for VDUSE device now + * @vdev: vdpa device + * @msg: vhost memory mapping message * @set_map: Set device memory mapping (optional) * Needed for device that using device * specific DMA translation (on-chip IOMMU) @@ -240,6 +245,8 @@ struct vdpa_config_ops { struct vdpa_iova_range (*get_iova_range)(struct vdpa_device *vdev); /* DMA ops */ + int (*process_iotlb_msg)(struct vdpa_device *vdev, + struct vhost_iotlb_msg *msg); int (*set_map)(struct vdpa_device *vdev, struct vhost_iotlb *iotlb); int (*dma_map)(struct vdpa_device *vdev, u64 iova, u64 size, u64 pa, u32 perm); -- 2.11.0