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 <sshukla at mvista.com>
---
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

Reply via email to