Thread (36 messages) flat view 36 messages, 4 authors, 2016-01-29
STALE3874d

[PATCH v4 13/14] virtio: enable vfio in pmd driver

From: Santosh Shukla <hidden>
Date: 2016-01-14 13:29:27
Subsystem: networking drivers, the rest · Maintainers: Andrew Lunn, "David S. Miller", Eric Dumazet, Jakub Kicinski, Paolo Abeni, Linus Torvalds

Using mapping api i.e. rte_eal_pci_map_device() to create vfio container, group
id and get the vfio-dev-fd for virtio-net-pci interface. Later vfio_dev_fd used
for virtio device rd/wr operation.

Signed-off-by: Santosh Shukla <redacted>
---
v3->v4:
- Per stephens comment, removed static driver flag RTE_PCI_XXX_XX_NEED_MAPPING ,
  now vfio virtio pmd driver intialized vifio interface at runtime.

drivers/net/virtio/virtio_ethdev.c |   12 ++++++++++++
 1 file changed, 12 insertions(+)
diff --git a/drivers/net/virtio/virtio_ethdev.c b/drivers/net/virtio/virtio_ethdev.c
index 8f2260f..ce03a24 100644
--- a/drivers/net/virtio/virtio_ethdev.c
+++ b/drivers/net/virtio/virtio_ethdev.c
@@ -497,6 +497,8 @@ virtio_dev_close(struct rte_eth_dev *dev)
 	hw->started = 0;
 	virtio_dev_free_mbufs(dev);
 	virtio_free_queues(dev);
+
+	/* For vfio case : hotunplug/unmap not supported (todo) */
 }
 
 static void
@@ -1286,6 +1288,16 @@ static int virtio_hw_init_by_vfio(struct virtio_hw *hw,
 		return -1;
 	}
 
+	/*
+	 * pci_map_device used not to actually map ioport region but
+	 * create vfio container/group and vfio-dev-fd for _this_
+	 * virtio interface.
+	 */
+	if (rte_eal_pci_map_device(pci_dev) != 0) {
+		PMD_INIT_LOG(ERR, "vfio pci mapping failed for ioport bar\n");
+		return -1;
+	}
+
 	/* .. So attached interface is vfio */
 	vdev->is_vfio = true;
 	vdev->pci_dev = pci_dev;
-- 
1.7.9.5
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help