add VFIO IOMMUFD/CDEV support
cover add VFIO IOMMUFD/CDEV support
From: Beilei Xing <[email protected]>
This is a draft implementation to support IOMMUFD[1] user interface and VFIO CDEV user interface[2].
Problem statement:
Linux now includes multiple device-passthrough frameworks (e.g. VFIO and vDPA) and those frameworks implement their own logic for managing I/O page tables, which is hard to scale to support modern IOMMU features like PASID, I/O page fault, IOMMU dirty page tracking, etc.
In order to fix the issue, a new standalone IOMMU subsystem called IOMMUFD is introduced in Linux Kernel since v6.2. The goal is to make Linux subsystems like VFIO and vDPA to consume a unified IOMMU framework. Along with this new IOMMUFD framework, new device-centric VFIO uAPI called VFIO CDEV is also introduced since Linux Kernel v6.6. vDPA support for IOMMUFD in Linux Kernel is still work in progress[3].
Since all new IOMMU features provided by different vendors will only be supported in the new framework instead of legacy one, it's important for DPDK to support this new IOMMUFD framework to use latest IOMMU features.
For VFIO subsystem, mainline Linux supports both of VFIO Container/GROUP interface and VFIO IOMMUFD/CDEV interface. IOMMUFD has no impact on the existing VFIO Container/Group interface, while latest IOMMU feature(e.g. PASID/SSID) may be only available through VFIO IOMMUFD/CDEV interface. Comparing with VFIO Container and VFIO IOMMUFD, vfio device uAPI does not change while I/O page tables management is moved from VFIO Container into IOMMUFD interface.
Design:
For DPDK implementation, since VFIO Container/GROUP & VFIO IOMMUFD/CDEV may co-exist now, a new VFIO IOMMUFD file/interface will be added in EAL. Since IOMMUFD is a unified framework which can be consumed by VFIO, vDPA, etc, iommufd will be added as a standalone file/interface in EAL. Hence, DPDK bus driver (e.g. PCI) has 2 option to probe vfio device.
The diagram below shows relationship between VFIO Container/GROUP, IOMMUFD, VFIO CDEV and bus driver (e.g. PCI) in DPDK with some comments below.
_____________________
| [4] |
| |
| |
|PCI BUS |
|_____________________|
| |
| |
________________v___ ___v______________ ________________________
| [1] | | [2] | | |
|vfio container | | | | |
|vfio group | |vfio cdev | | Other Consumer |
| | | | | (vDPA IOMMUFD, |
|VFIO | |VFIO IOMMUFD(new) | | common memory) |
|____________________| |__________________| |________________________|
| |
| |
___v______________v___
| [3] |
| i/o page table mgmt |
| |
| |
|IOMMUFD(new) |
|______________________|
1. VFIO component is the existed and mature framework for device passthrough. No function changes here.
2. VFIO IOMMUFD is a new component added to co-work with IOMMUFD. It exposes function for PCI BUS to probe PCI device through VFIO CDEV interface.
3. IOMMUFD is a new component added. It exposes unified interface for VFIO IOMMUFD and other consumer to manage I/O page table.
4. PCI BUS is the existed component. Since now Linux has both of VFIO Container/GROUP & VFIO IOMMUFD/CDEV support, PCI BUS needs to determine the interface to probe the PCI device depending on user configuration.
TBD:
Multi-process will be supported in future.
[1] https://lwn.net/Articles/912515/
[2] https://patchwork.kernel.org/project/kvm/cover/[email protected]/
[3] https://lore.kernel.org/lkml/[email protected]/
Beilei Xing (3):
vfio: add VFIO IOMMUFD support
bus/pci: add VFIO CDEV support
eal: add new args to choose VFIO mode
Yahui Cao (1):
iommufd: add IOMMUFD support
config/meson.build | 3 + config/rte_config.h | 1 + drivers/bus/pci/bus_pci_driver.h | 1 + drivers/bus/pci/linux/pci.c | 21 +- drivers/bus/pci/linux/pci_init.h | 4 + drivers/bus/pci/linux/pci_vfio.c | 52 +++- lib/eal/common/eal_common_config.c | 6 + lib/eal/common/eal_common_options.c | 48 +++- lib/eal/common/eal_internal_cfg.h | 1 + lib/eal/common/eal_options.h | 2 + lib/eal/include/rte_eal.h | 18 ++ lib/eal/include/rte_iommufd.h | 73 ++++++ lib/eal/include/rte_vfio.h | 55 ++++ lib/eal/linux/eal.c | 22 ++ lib/eal/linux/eal_iommufd.c | 183 +++++++++++++ lib/eal/linux/eal_iommufd.h | 43 ++++ lib/eal/linux/eal_vfio.h | 3 + lib/eal/linux/eal_vfio_iommufd.c | 385 ++++++++++++++++++++++++++++ lib/eal/linux/meson.build | 2 + lib/eal/version.map | 6 + 20 files changed, 918 insertions(+), 11 deletions(-) create mode 100644 lib/eal/include/rte_iommufd.h create mode 100644 lib/eal/linux/eal_iommufd.c create mode 100644 lib/eal/linux/eal_iommufd.h create mode 100644 lib/eal/linux/eal_vfio_iommufd.c
Signature · 1 line
2.34.1
PATCH 1/4 iommufd: add IOMMUFD support
From: Yahui Cao <[email protected]>
IOMMUFD is a new standalone IOMMU subsystem introduced in Linux.
Linux now includes multiple device-passthrough frameworks (e.g. VFIO and vDPA) and those frameworks implements their own logic for managing I/O page tables, which is hard to scale to support modern IOMMU features like PASID, I/O page fault, IOMMU dirty page tracking. The goal of IOMMUFD is to make Linux subsystems like VFIO and vDPA to consume a unified IOMMU framework.
This patch exports basic enable function, default isolation domain and per-IOMMUFD dma mapping function. The IOMMUFD consumer should use the default isolation domain and dma mapping function when user-initiated DMA is required.
--- config/meson.build | 3 + config/rte_config.h | 1 + lib/eal/include/rte_iommufd.h | 73 ++++++++++++++ lib/eal/linux/eal.c | 22 ++++ lib/eal/linux/eal_iommufd.c | 183 ++++++++++++++++++++++++++++++++++ lib/eal/linux/eal_iommufd.h | 43 ++++++++ lib/eal/linux/meson.build | 1 + lib/eal/version.map | 3 + 8 files changed, 329 insertions(+) create mode 100644 lib/eal/include/rte_iommufd.h create mode 100644 lib/eal/linux/eal_iommufd.c create mode 100644 lib/eal/linux/eal_iommufd.h
config/meson.build +3 -0
@@ -442,6 +442,9 @@ install_headers(['rte_config.h'], # enable VFIO only if it is linux OS dpdk_conf.set('RTE_EAL_VFIO', is_linux) +# enable IOMMUFD only if it is linux OS +dpdk_conf.set('RTE_EAL_IOMMUFD', is_linux) + # specify -D_GNU_SOURCE unconditionally add_project_arguments('-D_GNU_SOURCE', language: 'c')
config/rte_config.h +1 -0
@@ -38,6 +38,7 @@#define RTE_MAX_TAILQ 32#define RTE_LOG_DP_LEVEL RTE_LOG_INFO#define RTE_MAX_VFIO_CONTAINERS 64 +#define RTE_MAX_IOMMUFD_FD 1/* bsd module defines */ #define RTE_CONTIGMEM_MAX_NUM_BUFS 64
lib/eal/include/rte_iommufd.h new file +73 -0
73 lines not on this page · raw message
lib/eal/linux/eal.c +22 -0
@@ -41,6 +41,7 @@#include <rte_version.h> #include <malloc_heap.h> #include <rte_vfio.h> +#include <rte_iommufd.h> #include <telemetry_internal.h> #include "eal_private.h"
@@ -52,6 +53,7 @@#include "eal_trace.h" #include "eal_options.h" #include "eal_vfio.h" +#include "eal_iommufd.h" #include "hotplug_mp.h" #include "log_internal.h"
@@ -877,6 +879,16 @@ static int rte_eal_vfio_setup(void) }#endif +#ifdef IOMMUFD_PRESENT +static int rte_eal_iommufd_setup (void ) +{ +if (rte_iommufd_enable ("iommufd" )) +return -1 ; + +return 0 ; +} +#endif +static void rte_eal_init_alert (const char *msg) {fprintf (stderr,"EAL: FATAL: %s\n" , msg);
@@ -1162,6 +1174,16 @@ rte_eal_init(int argc, char **argv) return -1; }#endif + +#ifdef IOMMUFD_PRESENT +if (rte_eal_iommufd_setup () <0 ) { +rte_eal_init_alert ("Cannot init IOMMUFD" ); + rte_errno =EAGAIN ; +rte_atomic_store_explicit (&run_once,0 , rte_memory_order_relaxed); +return -1 ; + } +#endif +/* in secondary processes, memory init may allocate additional fbarrays * not present in primary processes, so to avoid any potential issues, * initialize memzones first.
lib/eal/linux/eal_iommufd.c new file +183 -0
183 lines not on this page · raw message
lib/eal/linux/eal_iommufd.h new file +43 -0
43 lines not on this page · raw message
lib/eal/linux/meson.build +1 -0
@@ -16,6 +16,7 @@ sources += files( 'eal_thread.c', 'eal_timer.c', 'eal_vfio.c', + 'eal_iommufd.c', 'eal_vfio_mp_sync.c', )
lib/eal/version.map +3 -0
@@ -393,6 +393,9 @@ EXPERIMENTAL { # added in 23.07 rte_memzone_max_get; rte_memzone_max_set; + + rte_iommufd_enable; # WINDOWS_NO_EXPORT + rte_iommufd_is_enabled; # WINDOWS_NO_EXPORT }; INTERNAL {
Signature · 1 line
2.34.1
PATCH 2/4 vfio: add VFIO IOMMUFD support
In reply to [email protected]From: Beilei Xing <[email protected]>
VFIO IOMMUFD is a new component added to co-work with IOMMUFD. IOMMUFD has no impact on the existing VFIO Container/Group interface, while the latest IOMMU feature(e.g. PASID/SSID) may be only available through VFIO IOMMUFD/CDEV interface.
This path exposes setup/release vfio device functions with VFIO IOMMUFD/CDEV interface.
--- lib/eal/include/rte_vfio.h | 55 +++++ lib/eal/linux/eal_vfio.h | 3 + lib/eal/linux/eal_vfio_iommufd.c | 385 +++++++++++++++++++++++++++++++ lib/eal/linux/meson.build | 1 + lib/eal/version.map | 2 + 5 files changed, 446 insertions(+) create mode 100644 lib/eal/linux/eal_vfio_iommufd.c
lib/eal/include/rte_vfio.h +55 -0
@@ -17,6 +17,8 @@ extern "C" {#include <stdbool.h> #include <stdint.h> +#include <rte_compat.h> +/* * determine if VFIO is present on the system */
@@ -28,6 +30,9 @@ extern "C" {#if LINUX_VERSION_CODE >=KERNEL_VERSION (4 ,0 ,0 )#define HAVE_VFIO_DEV_REQ_INTERFACE #endif /* kernel version >= 4.0.0 */ +#if LINUX_VERSION_CODE >=KERNEL_VERSION (6 ,6 ,0 ) +#define VFIO_IOMMUFD_PRESENT +#endif /* kernel version >= 6.6.0 */ #endif /* RTE_EAL_VFIO */ #ifdef VFIO_PRESENT
@@ -42,6 +47,10 @@ extern "C" {#define VFIO_NOIOMMU_MODE \ "/sys/module/vfio/parameters/enable_unsafe_noiommu_mode" +#ifdef VFIO_IOMMUFD_PRESENT +#define VFIO_CDEV_CLASS_DIR "/sys/class/vfio-dev" +#endif +/* NOIOMMU is defined from kernel version 4.5 onwards */ #ifdef VFIO_NOIOMMU_IOMMU #define RTE_VFIO_NOIOMMU VFIO_NOIOMMU_IOMMU
@@ -137,6 +146,33 @@ struct vfio_device_info;int rte_vfio_setup_device (const char *sysfs_base,const char *dev_addr,int *vfio_dev_fd,struct vfio_device_info *device_info); +/** +* Setup iommufd_cfg for the device identified by its address. +* +* This function is only relevant to linux and will return +* an error on BSD. +* +* @param sysfs_base +* sysfs path prefix. +* +* @param dev_addr +* device location. +* +* @param vfio_dev_fd +* VFIO fd. +* +* @param device_info +* Device information. +* +* @return +* 0 on success. +* <0 on failure. +* >1 if the device cannot be managed this way. +*/ +__rte_experimental +int rte_vfio_iommufd_setup_device(const char *sysfs_base, const char *dev_addr, +int *vfio_dev_fd,struct vfio_device_info *device_info); +/** * Release a device mapped to a VFIO-managed I/O MMU group. *
@@ -158,6 +194,25 @@ int rte_vfio_setup_device(const char *sysfs_base, const char *dev_addr,*/ int rte_vfio_release_device (const char *sysfs_base,const char *dev_addr,int fd); +/** +* Release a device mapped to a VFIO-iommufd-managed I/O MMU group. +* +* This function is only relevant to linux and will return +* an error on BSD. +* +* @param dev_addr +* device location. +* +* @param fd +* VFIO fd. +* +* @return +* 0 on success. +* <0 on failure. +*/ +__rte_experimental +int rte_vfio_iommufd_release_device(const char *dev_addr, int fd); +/** * Enable a VFIO-related kmod. *
lib/eal/linux/eal_vfio.h +3 -0
@@ -17,6 +17,9 @@#else #pragma message("VFIO configured but not supported by this kernel, disabling.")#endif /* kernel version >= 3.6.0 */ +#if LINUX_VERSION_CODE >=KERNEL_VERSION (6 ,6 ,0 ) +#define VFIO_IOMMUFD_PRESENT +#endif /* kernel version >= 6.6.0 */ #endif /* RTE_EAL_VFIO */ #ifdef VFIO_PRESENT
lib/eal/linux/eal_vfio_iommufd.c new file +385 -0
385 lines not on this page · raw message
lib/eal/linux/meson.build +1 -0
@@ -16,6 +16,7 @@ sources += files( 'eal_thread.c', 'eal_timer.c', 'eal_vfio.c', + 'eal_vfio_iommufd.c', 'eal_iommufd.c', 'eal_vfio_mp_sync.c', )
lib/eal/version.map +2 -0
@@ -396,6 +396,8 @@ EXPERIMENTAL { rte_iommufd_enable; # WINDOWS_NO_EXPORT rte_iommufd_is_enabled; # WINDOWS_NO_EXPORT + rte_vfio_iommufd_release_device; # WINDOWS_NO_EXPORT + rte_vfio_iommufd_setup_device; # WINDOWS_NO_EXPORT }; INTERNAL {
Signature · 1 line
2.34.1
Re: [PATCH 2/4] vfio: add VFIO IOMMUFD support
Quoted 14 lines · On Fri, 22 Dec 2023 19:44:51 +0000 [email protected] wrote:
lib/eal/include/rte_vfio.h +2
-0@@ -17,6 +17,8 @@ extern "C" {#include <stdbool.h> #include <stdint.h> +#include <rte_compat.h> +/* * determine if VFIO is present on the system */
lib/eal/include/rte_vfio.h extern "C" { · line 36
Quoted 7 lines
lib/eal/include/rte_vfio.h +3
-0@@ -28,6 +30,9 @@ extern "C" {#if LINUX_VERSION_CODE >=KERNEL_VERSION (4 ,0 ,0 )#define HAVE_VFIO_DEV_REQ_INTERFACE #endif /* kernel version >= 4.0.0 */ +#if LINUX_VERSION_CODE >=KERNEL_VERSION (6 ,6 ,0 ) +#define VFIO_IOMMUFD_PRESENT +#endif /* kernel version >= 6.6.0 */ #endif /* RTE_EAL_VFIO */
Depending on kernel version macro is a mistake because many enterprise distro's backport features and do not change kernel version. Also, it means the build and target machine have to be same kernel version.
RE: [PATCH 2/4] vfio: add VFIO IOMMUFD support
Quoted 23 lines
-----Original Message-----
From: Stephen Hemminger <[email protected]>
Sent: Saturday, December 23, 2023 1:17 AM
To: Xing, Beilei <[email protected]>
Cc: Burakov, Anatoly <[email protected]>; [email protected]; [email protected]; [email protected]; Richardson, Bruce <[email protected]>; [email protected]; Cao, Yahui <[email protected]>
Subject: Re: [PATCH 2/4] vfio: add VFIO IOMMUFD supportQuoted 8 lines · On Fri, 22 Dec 2023 19:44:51 +0000 [email protected] wrote:
lib/eal/include/rte_vfio.h +0
-0@@ -17,6 +17,8 @@ extern "C" {#include <stdbool.h> #include <stdint.h>
Quoted 14 lines
lib/eal/include/rte_vfio.h
Quoted 11 lines
lib/eal/include/rte_vfio.h +2
-0+#include <rte_compat.h> +/* * determine if VFIO is present on the system */ @@ -28,6 +30,9 @@ extern "C" { #if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 0, 0) #define
HAVE_VFIO_DEV_REQ_INTERFACE#endif /* kernel version >= 4.0.0 */lib/eal/include/rte_vfio.h +2
-0+#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 6, 0) #define +VFIO_IOMMUFD_PRESENT #endif/* kernel version >= 6.6.0 */ #endif /* RTE_EAL_VFIO */ Depending on kernel version macro is a mistake because many enterprise distro's backport features and do not change kernel version.
Make sense. We defined VFIO_IOMMUFD_PRESENT with reference to VFIO_PRESENT. Do you have suggestion for this point? Thanks a lot.
Quoted 1 line
Also, it means the build and target machine have to be same kernel version.
PATCH 3/4 bus/pci: add VFIO CDEV support
In reply to [email protected]From: Beilei Xing <[email protected]>
This patch adds VFIO CDEV support to probe PCI devices.
For VFIO subsystem, mainline Linux supports both of VFIO Container/GROUP interface and VFIO IOMMUFD/CDEV interface. Comparing with VFIO Container and VFIO IOMMUFD, vfio device uAPI does not change while I/O page tables management is moved from VFIO Container into IOMMUFD interface.
--- drivers/bus/pci/bus_pci_driver.h | 1 + drivers/bus/pci/linux/pci.c | 14 +++++++++ drivers/bus/pci/linux/pci_init.h | 4 +++ drivers/bus/pci/linux/pci_vfio.c | 52 ++++++++++++++++++++++++++------ 4 files changed, 62 insertions(+), 9 deletions(-)
drivers/bus/pci/bus_pci_driver.h +1 -0
@@ -26,6 +26,7 @@ enum rte_pci_kernel_driver {RTE_PCI_KDRV_NIC_UIO ,/* nic_uio for FreeBSD */ RTE_PCI_KDRV_NONE ,/* no attached driver */ RTE_PCI_KDRV_NET_UIO ,/* NetUIO for Windows */ + RTE_PCI_KDRV_VFIO_IOMMUFD, /* VFIO IOMMUFD for Linux */ };/**
drivers/bus/pci/linux/pci.c +14 -0
@@ -65,6 +65,12 @@ rte_pci_map_device(struct rte_pci_device *dev)#ifdef VFIO_PRESENT if (pci_vfio_is_enabled ()) ret =pci_vfio_map_resource (dev); +#endif +break ; +case RTE_PCI_KDRV_VFIO_IOMMUFD : +#ifdef VFIO_IOMMUFD_PRESENT +if (pci_iommufd_is_enabled ()) + ret =pci_vfio_map_resource (dev);#endif break ;case RTE_PCI_KDRV_IGB_UIO :
@@ -94,6 +100,12 @@ rte_pci_unmap_device(struct rte_pci_device *dev)#ifdef VFIO_PRESENT if (pci_vfio_is_enabled ())pci_vfio_unmap_resource (dev); +#endif +break ; +case RTE_PCI_KDRV_VFIO_IOMMUFD : +#ifdef VFIO_IOMMUFD_PRESENT +if (pci_iommufd_is_enabled ()) +pci_vfio_unmap_resource (dev);#endif break ;case RTE_PCI_KDRV_IGB_UIO :
@@ -645,6 +657,7 @@ int rte_pci_read_config(const struct rte_pci_device *device,return pci_uio_read_config (intr_handle, buf, len, offset);#ifdef VFIO_PRESENT case RTE_PCI_KDRV_VFIO : +case RTE_PCI_KDRV_VFIO_IOMMUFD :return pci_vfio_read_config (device, buf, len, offset);#endif default :
@@ -669,6 +682,7 @@ int rte_pci_write_config(const struct rte_pci_device *device,return pci_uio_write_config (intr_handle, buf, len, offset);#ifdef VFIO_PRESENT case RTE_PCI_KDRV_VFIO : +case RTE_PCI_KDRV_VFIO_IOMMUFD :return pci_vfio_write_config (device, buf, len, offset);#endif default :
drivers/bus/pci/linux/pci_init.h +4 -0
@@ -79,4 +79,8 @@ int pci_vfio_is_enabled(void);#endif +#ifdef VFIO_IOMMUFD_PRESENT +int pci_iommufd_is_enabled (void ); +#endif +#endif /* EAL_PCI_INIT_H_ */
drivers/bus/pci/linux/pci_vfio.c +43 -9
74 lines not on this page · raw message
Signature · 1 line
2.34.1
PATCH 4/4 eal: add new args to choose VFIO mode
In reply to [email protected]From: Beilei Xing <[email protected]>
Since now Linux has both of VFIO Container/GROUP & VFIO IOMMUFD/CDEV support, user can determine how to probe the PCI device by the new args "--vfio-mode".
Use "--vfio-mode=container" to choose VFIO Container/GROUP, and use "--vfio-mode=iommufd" to choose VFIO IOMMUFD/CDEV.
--- drivers/bus/pci/linux/pci.c | 7 ++++- lib/eal/common/eal_common_config.c | 6 ++++ lib/eal/common/eal_common_options.c | 48 ++++++++++++++++++++++++++++- lib/eal/common/eal_internal_cfg.h | 1 + lib/eal/common/eal_options.h | 2 ++ lib/eal/include/rte_eal.h | 18 +++++++++++ lib/eal/version.map | 1 + 7 files changed, 81 insertions(+), 2 deletions(-)
drivers/bus/pci/linux/pci.c +6 -1
@@ -226,6 +226,7 @@ pci_scan_one(const char *dirname, const struct rte_pci_addr *addr)struct rte_pci_device_internal *pdev;struct rte_pci_device *dev;char driver[PATH_MAX ]; +enum rte_vfio_mode vfio_mode;int ret; pdev =malloc (sizeof (*pdev));
@@ -317,6 +318,8 @@ pci_scan_one(const char *dirname, const struct rte_pci_addr *addr)return -1 ; } + vfio_mode =rte_eal_vfio_mode (); +/* parse driver */ snprintf (filename,sizeof (filename),"%s/driver" , dirname); ret =pci_get_kernel_driver_by_path (filename, driver,sizeof (driver));
@@ -327,8 +330,10 @@ pci_scan_one(const char *dirname, const struct rte_pci_addr *addr) }if (!ret) { -if (!strcmp (driver,"vfio-pci" )) +if (!strcmp (driver,"vfio-pci" ) && vfio_mode ==RTE_VFIO_CONTAINER ) dev->kdrv =RTE_PCI_KDRV_VFIO ; +else if (!strcmp (driver,"vfio-pci" ) && vfio_mode ==RTE_VFIO_IOMMUFD ) + dev->kdrv =RTE_PCI_KDRV_VFIO_IOMMUFD ;else if (!strcmp (driver,"igb_uio" )) dev->kdrv =RTE_PCI_KDRV_IGB_UIO ;else if (!strcmp (driver,"uio_pci_generic" ))
lib/eal/common/eal_common_config.c +6 -0
@@ -58,6 +58,12 @@ rte_eal_iova_mode(void)return rte_eal_get_configuration ()->iova_mode; } +enum rte_vfio_mode +rte_eal_vfio_mode (void ) +{ +return internal_config.vfio_mode; +} +/* Get the EAL base address */ uint64_t rte_eal_get_baseaddr (void )
lib/eal/common/eal_common_options.c +47 -1
78 lines not on this page · raw message
lib/eal/common/eal_internal_cfg.h +1 -0
@@ -103,6 +103,7 @@ struct internal_config {struct simd_bitwidth max_simd_bitwidth;/**< max simd bitwidth path to use */ size_t huge_worker_stack_size;/**< worker thread stack size */ +enum rte_vfio_mode vfio_mode;/**< Set VFIO mode */ };void eal_reset_internal_config (struct internal_config *internal_cfg);
lib/eal/common/eal_options.h +2 -0
@@ -89,6 +89,8 @@ enum {OPT_FORCE_MAX_SIMD_BITWIDTH_NUM , #define OPT_HUGE_WORKER_STACK "huge-worker-stack"OPT_HUGE_WORKER_STACK_NUM , +#define OPT_VFIO_MODE "vfio-mode" +OPT_VFIO_MODE_NUM , OPT_LONG_MAX_NUM };
lib/eal/include/rte_eal.h +18 -0
@@ -472,6 +472,24 @@ enum rte_iova_mode {*/ enum rte_iova_mode rte_eal_iova_mode (void ); +/** +* VFIO mode. +*/ +enum rte_vfio_mode { +RTE_VFIO_CONTAINER =0 ,/* vfio container mode */ +RTE_VFIO_IOMMUFD =1 /* vfio iommufd mode */ +}; + +/** +* Get the vfio mode +* +* @return +* enum rte_vfio_mode value. +*/ + +__rte_experimental +enum rte_vfio_mode rte_eal_vfio_mode(void); +/** * Get user provided pool ops name for mbuf *
lib/eal/version.map +1 -0
@@ -394,6 +394,7 @@ EXPERIMENTAL { rte_memzone_max_get; rte_memzone_max_set; + rte_eal_vfio_mode; # WINDOWS_NO_EXPORT rte_iommufd_enable; # WINDOWS_NO_EXPORT rte_iommufd_is_enabled; # WINDOWS_NO_EXPORT rte_vfio_iommufd_release_device; # WINDOWS_NO_EXPORT
Signature · 1 line
2.34.1
Re: [PATCH 4/4] eal: add new args to choose VFIO mode
Quoted 11 lines · On Fri, 22 Dec 2023 19:44:53 +0000 [email protected] wrote:
From: Beilei Xing <[email protected]>
Since now Linux has both of VFIO Container/GROUP & VFIO IOMMUFD/CDEV support, user can determine how to probe the PCI device by the new args "--vfio-mode".
Use "--vfio-mode=container" to choose VFIO Container/GROUP, and use "--vfio-mode=iommufd" to choose VFIO IOMMUFD/CDEV.
Signed-off-by Beilei Xing <[email protected]>Signed-off-by Yahui Cao <[email protected]>
Can't this be automatic, users don't need more EAL options.
RE: [PATCH 4/4] eal: add new args to choose VFIO mode
Quoted 21 lines
-----Original Message-----
From: Stephen Hemminger <[email protected]>
Sent: Saturday, December 23, 2023 1:18 AM
To: Xing, Beilei <[email protected]>
Cc: Burakov, Anatoly <[email protected]>; [email protected]; [email protected]; [email protected]; Richardson, Bruce <[email protected]>; [email protected]; Cao, Yahui <[email protected]>
Subject: Re: [PATCH 4/4] eal: add new args to choose VFIO modeQuoted 6 lines · On Fri, 22 Dec 2023 19:44:53 +0000 [email protected] wrote:
From: Beilei Xing <[email protected]>
Since now Linux has both of VFIO Container/GROUP & VFIO IOMMUFD/CDEV support, user can determine how to probe the PCI device by the new args "--vfio-mode".
Quoted 7 lines
Quoted 5 lines
Use "--vfio-mode=container" to choose VFIO Container/GROUP, and use "--vfio-mode=iommufd" to choose VFIO IOMMUFD/CDEV.
Signed-off-by Beilei Xing <[email protected]>Signed-off-by Yahui Cao <[email protected]>Can't this be automatic, users don't need more EAL options.
Thanks for your review. Since Linux supports both VFIO Container/GROUP and VFIO OMMUFD/CDEV currently, I think user can choose which mode they want. The new IOMMU features (e.g. PASID/SSID) may be only available through VFIO IOMMUFD/CDEV interface, VFIO Container/GROUP may be deprecated in future, and then DPDK will use iommufd mode automatically.
.