[v2,1/6] vfio: allow DMA map of memory for the default vfio fd
Checks
Commit Message
Enable users the option to call rte_vfio_dma_map with request to map
to the default vfio fd.
Signed-off-by: Shahaf Shuler <shahafs@mellanox.com>
---
doc/guides/rel_notes/release_19_05.rst | 3 +++
lib/librte_eal/common/include/rte_vfio.h | 8 ++++++--
lib/librte_eal/linuxapp/eal/eal_vfio.c | 10 ++++++++--
3 files changed, 17 insertions(+), 4 deletions(-)
Comments
On 21-Feb-19 2:50 PM, Shahaf Shuler wrote:
> Enable users the option to call rte_vfio_dma_map with request to map
> to the default vfio fd.
>
> Signed-off-by: Shahaf Shuler <shahafs@mellanox.com>
> ---
LGTM
Acked-by: Anatoly Burakov <anatoly.burakov@intel.com>
@@ -110,6 +110,9 @@ ABI Changes
Also, make sure to start the actual text at the margin.
=========================================================
+* vfio: Functions ``rte_vfio_container_dma_map`` and
+ ``rte_vfio_container_dma_unmap`` have been extended with an option to
+ request mapping or un-mapping to the default vfio container fd.
Shared Library Versions
-----------------------
@@ -73,6 +73,8 @@ struct vfio_info_cap_header {
#define RTE_VFIO_CAP_MSIX_MAPPABLE 3
#endif
+#define RTE_VFIO_DEFAULT_CONTAINER_FD (-1)
+
#else /* not VFIO_PRESENT */
/* we don't need an actual definition, only pointer is used */
@@ -347,7 +349,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. Use RTE_VFIO_DEFAULT_CONTAINER_FD to
+ * use the default container.
*
* @param vaddr
* Starting virtual address of memory to be mapped.
@@ -370,7 +373,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. Use RTE_VFIO_DEFAULT_CONTAINER_FD to
+ * use the default container.
*
* @param vaddr
* Starting virtual address of memory to be unmapped.
@@ -1897,7 +1897,10 @@ 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 == RTE_VFIO_DEFAULT_CONTAINER_FD)
+ vfio_cfg = default_vfio_cfg;
+ else
+ vfio_cfg = get_vfio_cfg_by_container_fd(container_fd);
if (vfio_cfg == NULL) {
RTE_LOG(ERR, EAL, "Invalid container fd\n");
return -1;
@@ -1917,7 +1920,10 @@ 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 == RTE_VFIO_DEFAULT_CONTAINER_FD)
+ vfio_cfg = default_vfio_cfg;
+ else
+ vfio_cfg = get_vfio_cfg_by_container_fd(container_fd);
if (vfio_cfg == NULL) {
RTE_LOG(ERR, EAL, "Invalid container fd\n");
return -1;