From: Santosh Shukla Subject: [PATCH v4 13/14] virtio: enable vfio in pmd driver Date: Thu, 14 Jan 2016 18:58:36 +0530 Message-ID: <1452778117-30178-14-git-send-email-sshukla@mvista.com> References: <1452778117-30178-1-git-send-email-sshukla@mvista.com> To: dev@dpdk.org Return-path: Received: from mail-pf0-f181.google.com (mail-pf0-f181.google.com [209.85.192.181]) by dpdk.org (Postfix) with ESMTP id 5BE3D91E3 for ; Thu, 14 Jan 2016 14:29:27 +0100 (CET) Received: by mail-pf0-f181.google.com with SMTP id n128so99907357pfn.3 for ; Thu, 14 Jan 2016 05:29:27 -0800 (PST) In-Reply-To: <1452778117-30178-1-git-send-email-sshukla@mvista.com> List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" 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 --- 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