On Thu, Sep 19, 2019 at 09:08:11PM +0800, Jason Wang wrote:
On 2019/9/18 äå10:32, Michael S. Tsirkin wrote:I see. Thanks! IIUC, you mean we can provide a very tiny
Ok, if we go this way, it could be as simple as provide some callback toIt does seem a bit more modular, but it's certainly not a big deal.Yes, but any benefit from doing this?So I have some questions:One benefit is that we can avoid doing vhost ioctls on
1) Compared to method 2, what's the advantage of creating a new vhost char
device? I guess it's for keep the API compatibility?
VFIO device fd.
vhost, then vhost can just forward the ioctl through parent_ops.
Just to clarify, a new type of mdev driver but provides dummyOk.2) For method 2, is there any easy way for user/admin to distinguish e.gI think device-api could be a choice.
ordinary vfio-mdev for vhost from ordinary vfio-mdev?
I saw you introduceThe ops matching helper is just to check whether a given
ops matching helper but it's not friendly to management.
vfio-device is based on a mdev device.
3) A drawback of 1) and 2) is that it must follow vfio_device_ops thatAs the above draft shows, this requires introducing a new
assumes the parameter comes from userspace, it prevents support kernel
virtio drivers.
4) So comes the idea of method 3, since it register a new vhost-mdev driver,
we can use device specific ops instead of VFIO ones, then we can have a
common API between vDPA parent and vhost-mdev/virtio-mdev drivers.
VFIO device driver. I think Alex's opinion matters here.
vfio_device_ops for VFIO to make container DMA ioctl work.
VFIO device driver in drivers/vhost/mdev.c, e.g.:
static int vfio_vhost_mdev_open(void *device_data)
{
if (!try_module_get(THIS_MODULE))
return -ENODEV;
return 0;
}
static void vfio_vhost_mdev_release(void *device_data)
{
module_put(THIS_MODULE);
}
static const struct vfio_device_ops vfio_vhost_mdev_dev_ops = {
.name = "vfio-vhost-mdev",
.open = vfio_vhost_mdev_open,
.release = vfio_vhost_mdev_release,
};
static int vhost_mdev_probe(struct device *dev)
{
struct mdev_device *mdev = to_mdev_device(dev);
... Check the mdev device_id proposed in ...
... https://lkml.org/lkml/2019/9/12/151 ...
return vfio_add_group_dev(dev, &vfio_vhost_mdev_dev_ops, mdev);
}
static void vhost_mdev_remove(struct device *dev)
{
vfio_del_group_dev(dev);
}
static struct mdev_driver vhost_mdev_driver = {
.name = "vhost_mdev",
.probe = vhost_mdev_probe,
.remove = vhost_mdev_remove,
};
So we can bind above mdev driver to the virtio-mdev compatible
mdev devices when we want to use vhost-mdev.
After binding above driver to the mdev device, we can setup IOMMU
via VFIO and get VFIO device fd of this mdev device, and pass it
to vhost fd (/dev/vhost-mdev) with a SET_BACKEND ioctl.
Thanks,
Tiwei
Thanks
Yes, it is.
Thanks