[13/15] net/virtio: add vDPA ops to get VFIO FDs
diff mbox series

Message ID 20190829080000.20806-14-maxime.coquelin@redhat.com
State Deferred
Delegated to: Maxime Coquelin
Headers show
Series
  • Introduce Virtio vDPA driver
Related show

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation fail Compilation issues

Commit Message

Maxime Coquelin Aug. 29, 2019, 7:59 a.m. UTC
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

Tiwei Bie Sept. 3, 2019, 4:47 a.m. UTC | #1
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>

Patch
diff mbox series

diff --git a/drivers/net/virtio/virtio_vdpa.c b/drivers/net/virtio/virtio_vdpa.c
index 9b61688a1..e0b2f99ba 100644
--- a/drivers/net/virtio/virtio_vdpa.c
+++ b/drivers/net/virtio/virtio_vdpa.c
@@ -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