[13/15] net/virtio: add vDPA ops to get VFIO FDs
Checks
Commit Message
This patch implements the vDPA .get_vfio_group_fd() and
.get_vfio_device_fd() callbacks.
Signed-off-by: Maxime Coquelin <maxime.coquelin@redhat.com>
---
drivers/net/virtio/virtio_vdpa.c | 34 ++++++++++++++++++++++++++++++++
1 file changed, 34 insertions(+)
Comments
On Thu, Aug 29, 2019 at 09:59:58AM +0200, Maxime Coquelin wrote:
> This patch implements the vDPA .get_vfio_group_fd() and
> .get_vfio_device_fd() callbacks.
>
> Signed-off-by: Maxime Coquelin <maxime.coquelin@redhat.com>
> ---
> drivers/net/virtio/virtio_vdpa.c | 34 ++++++++++++++++++++++++++++++++
> 1 file changed, 34 insertions(+)
Reviewed-by: Tiwei Bie <tiwei.bie@intel.com>
@@ -675,6 +675,38 @@ virtio_vdpa_set_features(int vid)
return 0;
}
+static int
+virtio_vdpa_get_vfio_group_fd(int vid)
+{
+ int did;
+ struct internal_list *list;
+
+ did = rte_vhost_get_vdpa_device_id(vid);
+ list = find_internal_resource_by_did(did);
+ if (list == NULL) {
+ DRV_LOG(ERR, "Invalid device id: %d", did);
+ return -1;
+ }
+
+ return list->dev->vfio_group_fd;
+}
+
+static int
+virtio_vdpa_get_vfio_device_fd(int vid)
+{
+ int did;
+ struct internal_list *list;
+
+ did = rte_vhost_get_vdpa_device_id(vid);
+ list = find_internal_resource_by_did(did);
+ if (list == NULL) {
+ DRV_LOG(ERR, "Invalid device id: %d", did);
+ return -1;
+ }
+
+ return list->dev->vfio_dev_fd;
+}
+
static struct rte_vdpa_dev_ops virtio_vdpa_ops = {
.get_queue_num = virtio_vdpa_get_queue_num,
.get_features = virtio_vdpa_get_features,
@@ -682,6 +714,8 @@ static struct rte_vdpa_dev_ops virtio_vdpa_ops = {
.dev_conf = virtio_vdpa_dev_config,
.dev_close = virtio_vdpa_dev_close,
.set_features = virtio_vdpa_set_features,
+ .get_vfio_group_fd = virtio_vdpa_get_vfio_group_fd,
+ .get_vfio_device_fd = virtio_vdpa_get_vfio_device_fd,
};
static inline int