From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mellanox.co.il (mail-il-dmz.mellanox.com [193.47.165.129]) by dpdk.org (Postfix) with ESMTP id 2B07E7CCA for ; Wed, 13 Feb 2019 10:11:20 +0100 (CET) Received: from Internal Mail-Server by MTLPINE1 (envelope-from shahafs@mellanox.com) with ESMTPS (AES256-SHA encrypted); 13 Feb 2019 11:11:18 +0200 Received: from unicorn01.mtl.labs.mlnx. (unicorn01.mtl.labs.mlnx [10.7.12.62]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id x1D9BIOk031440; Wed, 13 Feb 2019 11:11:18 +0200 From: Shahaf Shuler To: anatoly.burakov@intel.com, yskoh@mellanox.com, thomas@monjalon.net, ferruh.yigit@intel.com, nhorman@tuxdriver.com, gaetan.rivet@6wind.com Cc: dev@dpdk.org Date: Wed, 13 Feb 2019 11:10:21 +0200 Message-Id: <0f98e0a06c535d58ac8d2c39645b07eb966ec5ec.1550048187.git.shahafs@mellanox.com> X-Mailer: git-send-email 2.12.0 In-Reply-To: References: In-Reply-To: References: Subject: [dpdk-dev] [PATCH 1/6] vfio: allow DMA map of memory for the default vfio fd X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 13 Feb 2019 09:11:20 -0000 Enable users the option to call rte_vfio_dma_map with request to map to the default vfio fd. Signed-off-by: Shahaf Shuler --- lib/librte_eal/common/include/rte_vfio.h | 6 ++++-- lib/librte_eal/linuxapp/eal/eal_vfio.c | 14 ++++++++++++-- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/lib/librte_eal/common/include/rte_vfio.h b/lib/librte_eal/common/include/rte_vfio.h index cae96fab90..2a6827012f 100644 --- a/lib/librte_eal/common/include/rte_vfio.h +++ b/lib/librte_eal/common/include/rte_vfio.h @@ -347,7 +347,8 @@ rte_vfio_container_group_unbind(int container_fd, int iommu_group_num); * Perform DMA mapping for devices in a container. * * @param container_fd - * the specified container fd + * the specified container fd. In case of -1 the default container + * fd will be used. * * @param vaddr * Starting virtual address of memory to be mapped. @@ -370,7 +371,8 @@ rte_vfio_container_dma_map(int container_fd, uint64_t vaddr, * Perform DMA unmapping for devices in a container. * * @param container_fd - * the specified container fd + * the specified container fd. In case of -1 the default container + * fd will be used. * * @param vaddr * Starting virtual address of memory to be unmapped. diff --git a/lib/librte_eal/linuxapp/eal/eal_vfio.c b/lib/librte_eal/linuxapp/eal/eal_vfio.c index c821e83826..48ca9465d4 100644 --- a/lib/librte_eal/linuxapp/eal/eal_vfio.c +++ b/lib/librte_eal/linuxapp/eal/eal_vfio.c @@ -1897,7 +1897,12 @@ rte_vfio_container_dma_map(int container_fd, uint64_t vaddr, uint64_t iova, return -1; } - vfio_cfg = get_vfio_cfg_by_container_fd(container_fd); + if (container_fd > 0) { + vfio_cfg = get_vfio_cfg_by_container_fd(container_fd); + } else { + /* when no fd provided use the default. */ + vfio_cfg = &vfio_cfgs[0]; + } if (vfio_cfg == NULL) { RTE_LOG(ERR, EAL, "Invalid container fd\n"); return -1; @@ -1917,7 +1922,12 @@ rte_vfio_container_dma_unmap(int container_fd, uint64_t vaddr, uint64_t iova, return -1; } - vfio_cfg = get_vfio_cfg_by_container_fd(container_fd); + if (container_fd > 0) { + vfio_cfg = get_vfio_cfg_by_container_fd(container_fd); + } else { + /* when no fd provided use the default. */ + vfio_cfg = &vfio_cfgs[0]; + } if (vfio_cfg == NULL) { RTE_LOG(ERR, EAL, "Invalid container fd\n"); return -1; -- 2.12.0