Support VFIO cdev API in DPDK
Get series with b4
b4 am [email protected]Versions newest first · linked by author and title
- v18 Latest29 patches 0 repliesNew
- v1726 patches 12 repliesSuperseded
- v1626 patches 2 repliesSuperseded
Earlier versions · 15
| Version | Posted | Patches | Replies | Status |
|---|---|---|---|---|
| v15 | 25 patches | 0 replies | Superseded | |
| v14 | 25 patches | 1 reply | Superseded | |
| v13 | 24 patches | 0 replies | Superseded | |
| v12 | 20 patches | 3 replies | Superseded | |
| v11 | 20 patches | 1 reply | Superseded | |
| v10 | 20 patches | 1 reply | Superseded | |
| v9 | 19 patches | 1 reply | Superseded | |
| v8 | 18 patches | 1 reply | Superseded | |
| v7 | 18 patches | 1 reply | Superseded | |
| v6 | 18 patches | 2 replies | Superseded | |
| v5 | 18 patches | 2 replies | Superseded | |
| v4 | 17 patches | 1 reply | Superseded | |
| v3 | 20 patches | 1 reply | Superseded | |
| v2 | 19 patches | 4 replies | Superseded | |
| v1 | 8 patches | 4 replies | Superseded |
Changes in v18 from the cover letter
- Adjusted pre-refactor VFIO cleanup to not rely on per-config enabled flag
- Moved loaded module detection from EAL into VFIO
- Added API to check for specific VFIO modules being loaded
- Removed VFIO stubs from non-Linux code by removing PCI bus dependency on VFIO
- Reworked vhost DMA capability check
- Renamed "IOMMU mode" and "safe/unsafe" terminology to IOVA VA/PA
- Fixed typo in FSLMC bus IOVA mode selection
Patches in v18 No applies recorded yet
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/29 | uapi: update to v6.17 and add iommufd.hkernel/ kernel/ kernel/ +1 more | +1305 | 0 replies | |
| 2/29 | vfio: make all functions internaldoc/ doc/ doc/ +5 more | +84 | 0 replies | |
| 3/29 | bus/fslmc: decouple from EAL VFIOdrivers/ drivers/ | +31 | 0 replies | |
| 4/29 | vfio: decouple EAL from VFIO internalslib/ lib/ lib/ +2 more | +29 | 0 replies | |
| 5/29 | vhost: check DMA capability only oncelib/ lib/ lib/ | +10 | 0 replies | |
| 6/29 | vfio: do proper teardown on VFIO cleanuplib/ | +149 | 0 replies | |
| 7/29 | eal: move kernel module check function into VFIOlib/ lib/ lib/ | +39 | 0 replies | |
| 8/29 | vfio: remove modname parameter from initdrivers/ lib/ lib/ +2 more | +7 | 0 replies | |
| 9/29 | vfio: add module check APIdrivers/ lib/ lib/ +2 more | +65 | 0 replies | |
| 10/29 | bus/pci: decouple PCI bus driver from VFIOdrivers/ drivers/ drivers/ +4 more | +247 | 0 replies | |
| 11/29 | vfio: rename API to reflect internal statusdoc/ drivers/ drivers/ +21 more | +227 | 0 replies | |
| 12/29 | bus/pci: rename mismatching error labelsdrivers/ | +7 | 0 replies | |
| 13/29 | vfio: split get device info from setupdrivers/ drivers/ drivers/ +3 more | +58 | 0 replies | |
| 14/29 | vfio: add container device assignment APIlib/ lib/ | +58 | 0 replies | |
| 15/29 | net/nbl: do not use VFIO group bind APIdrivers/ drivers/ drivers/ | +50 | 0 replies | |
| 16/29 | net/ntnic: use container device assignment APIdrivers/ | +9 | 0 replies | |
| 17/29 | vdpa/ifc: use container device assignment APIdrivers/ | +3 | 0 replies | |
| 18/29 | vdpa/nfp: use container device assignment APIdrivers/ | +5 | 0 replies | |
| 19/29 | vdpa/sfc: use container device assignment APIdrivers/ drivers/ | +7 | 0 replies | |
| 20/29 | vdpa/mlx5: remove group-related APIdrivers/ | +0 | 0 replies | |
| 21/29 | vhost: remove group-related API from driverdoc/ doc/ doc/ +1 more | +3 | 0 replies | |
| 22/29 | vfio: remove group-based APIlib/ lib/ lib/ +1 more | +26 | 0 replies | |
| 23/29 | vfio: cleanup and refactorconfig/ config/ drivers/ +11 more | +2305 | 0 replies | |
| 24/29 | bus/pci: use the new VFIO IOVA mode APIdrivers/ | +1 | 0 replies | |
| 25/29 | bus/fslmc: use the new VFIO IOVA mode APIdrivers/ drivers/ | +10 | 0 replies | |
| 26/29 | net/hinic3: use the new VFIO IOVA mode APIdrivers/ | +2 | 0 replies | |
| 27/29 | net/ntnic: use the new VFIO IOVA mode APIdrivers/ | +1 | 0 replies | |
| 28/29 | vfio: remove no-IOMMU check APIlib/ lib/ | +0 | 0 replies | |
| 29/29 | vfio: introduce cdev modedoc/ doc/ lib/ +6 more | +862 | 0 replies |
Reviews trailers per patch
3 of 29 patches have a Reviewed-by or Acked-by.
| Patch | Stephen Hemminger | Hemant Agrawal |
|---|---|---|
| 1/29 | A-b | |
| 2/29 | ||
| 3/29 | ||
| 4/29 | ||
| 5/29 | ||
| 6/29 | ||
| 7/29 | ||
| 8/29 | ||
| 9/29 | ||
| 10/29 | ||
| 11/29 | ||
| 12/29 | ||
| 13/29 | ||
| 14/29 | ||
| 15/29 | ||
| 16/29 | ||
| 17/29 | ||
| 18/29 | ||
| 19/29 | ||
| 20/29 | ||
| 21/29 | ||
| 22/29 | ||
| 23/29 | A-b | |
| 24/29 | ||
| 25/29 | A-b | |
| 26/29 | ||
| 27/29 | ||
| 28/29 | ||
| 29/29 |
Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.
Cover letter [PATCH v18 00/29] Support VFIO cdev API in DPDK
This patchset introduces a major refactor of the VFIO subsystem in DPDK to support character device (cdev) interface introduced in Linux kernel, as well as make the API more streamlined and useful. The goal is to simplify device management, improve compatibility, make the code readable, and clarify API.
The following sections outline the key issues addressed by this patchset and the corresponding changes introduced.
1. Only group mode is supported
===============================
Since kernel version 4.14.327 (LTS), VFIO supports the new character device (cdev)-based way of working with VFIO devices (otherwise known as IOMMUFD). This is a device-centric mode and does away with all the complexity regarding groups and IOMMU types, delegating it all to the kernel, and exposes a much simpler interface to userspace. The old group-based implementation will still be around, and will need to be kept in DPDK for compatibility reasons.
To enable this, VFIO is heavily refactored, so that the code can support both modes while relying on (mostly) common infrastructure.
Additionally, new vfio_get_mode API is added for those cases that need some introspection into VFIO's internals, with two modes: group (old-style), and cdev (the new mode).
Historically, no-IOMMU mode was technically a variant of group mode, the distinction is largely irrelevant to the user, as all usages of noiommu checks in our codebase are for deciding whether to use IOVA or PA, not anything to do with managing groups. However, now that upcoming kernel versions will support no-IOMMU for both group, cdev compatibility, and full cdev paths, a new vfio_get_iommu_mode is also added, with two modes: safe (full IOMMU backing), and unsafe (no-IOMMU mode). The naming is chosen explicitly to emphasize that using no-IOMMU mode is not ideal.
2. Custom container assignment API does not map to cdev mode
============================================================
The existing rte_vfio_device_setup/release model is fundamentally incompatible with cdev mode, because for custom container cases, the expected flow is that the user binds the IOMMU group (and thus, implicitly, the device itself) to a specific container using rte_vfio_container_group_bind, whereas this step is not needed for cdev as the device fd is assigned to the container straight away.
Therefore, what we do instead is introduce a new API for container device assignment which, semantically, will assign a device to specified container, so that when it is mapped using rte_pci_map_device, the appropriate container is selected. Under the hood though, we essentially transition to getting device fd straight away at assign stage, so that by the time the PCI bus attempts to map the device, it is already mapped and we just return an fd. There is no "unassign" API because release_device already performs that function.
Because the API is now unified around device assignment, the old group-specific API's can be removed and, where appropriate, reimplemented using new API. There were other users of VFIO which relied on group API but only for convenience purposes; no actual VFIO functionality depended on those API's.
List of removed API's:
* rte_vfio_get_group_fd
* rte_vfio_clear_group
* rte_vfio_container_group_bind (replaced by container assign API)
* rte_vfio_container_group_unbind
* rte_vfio_noiommu_is_enabled (replaced by new mode API)
3. The API responsibilities aren't clear and bleed into each other
==================================================================
Some API's do multiple things at once. In particular:
* rte_vfio_get_device_info will setup the device
* rte_vfio_setup_device will get device info
These API's have been adjusted to do one thing only.
4. The API does not need to be public
=====================================
The initial idea for exposing VFIO API was to enable userspace applications to directly map memory for DMA, but it turns out that in practice only drivers use this API. Therefore, the entire VFIO API is made internal, driver-only, and is renamed from rte_vfio to dev_vfio.
v18:
- Adjusted pre-refactor VFIO cleanup to not rely on per-config enabled flag
- Moved loaded module detection from EAL into VFIO
- Added API to check for specific VFIO modules being loaded
- Removed VFIO stubs from non-Linux code by removing PCI bus dependency on VFIO
- Reworked vhost DMA capability check
- Renamed "IOMMU mode" and "safe/unsafe" terminology to IOVA VA/PA
- Fixed typo in FSLMC bus IOVA mode selection
v17:
- Support multiple devices per group in NBL
v16:
- Fixed an unused variable compile error due to typo
- Fixed code for patch 19 being accidentally added into patch 21
- Included the NBL fix[1] in the patchset to enable CI testing
v15:
- Fixed resource leak in group mode deduplication path
- On account of kernel 7.3 supporting no-IOMMU mode in kernel version 7.3, split the "VFIO mode" model into two distinct axis: group/cdev, and IOMMU mode
v14:
- Hardened the transitional patches against attempting to use VFIO without having done initialization
- Fixed a bunch of typos, moved a few hunks around to where they belong, and added a more release note entries
v13:
- Addressed feedback from Stephen's AI review:
- Added strdup-based deduplication for group mode to avoid leaking fd's when container assignment API is used
- Added more documentation about cdev mode to Linux GSG
- Fixed comments and log levels in a couple of places
- Renamed the API from rte_vfio_* to dev_vfio_* on account of it no longer being a publicly visible API
- Moved dev_vfio.h into driver SDK headers
- Decoupled VFIO internals from FSLMC and EAL
- Added proper teardown for VFIO subsystem on cleanup
v12:
- Addressed feedback from Stephen's AI review:
- Add release notes updates to patch 2 and 20
- Fix ENXIO typos
- Added a new init step after memory init to enable DMA mapping for cdev
v11:
- Addressed feedback from Stephen's AI review:
- Use CONTAINER_INITIALIZER for reset
- Set container fd to -1 in CONTAINER_INITIALIZER
- Fixed double close()
- Moved VFIO init to earlier in init sequence to account for bus drivers needing no-IOMMU mode status
- Fixed missing ops set for cdev mode, and missing ops reset
- Fixed fd leak on failed attach in cdev
v10:
- Added a patch that renames confusing error labels
- Fixed compiler warning about unused variable
v9:
- Moved erroneous rte_errno-related comments to later in the patchset
- Moved removal of vDPA group fd API's to their respective patches
- Fixed typo in errno comments (ENXIO vs ENOXIO)
- Fixed corruption of group config in secondary process (v8 AI review)
v8:
- Rebase
- Fixed build errors due to variable shadowing
- Removed duplicate fd check as kernel does not provide a way to distinguish between device fd's
v7:
- Rebase
- Added removal of deprecation notices
- Fixed implicit numeric comparison in patch 12
v6:
- Fixed missing header include in vfio cdev file
v5:
- Added back missing uapi patch
v4:
- Fixed issues with documenting rte_vfio_mode enum
- Separated deprecation notices into a separate patchset
v3:
- Make API removal cleaner
- Fix get_group_num usages to align with new API
- Fix issues with function exports
- Fix issues with setup_device returning old-style values in some cases
v2:
- Make the entire API internal
- More aggressive API pruning, complete removal of group API
- Fixed a bug in group mode where device could not be used
- Better documentation and deprecation notice patches
- Moved doc patches to beginning of patchset
Anatoly Burakov (29):
uapi: update to v6.17 and add iommufd.h
vfio: make all functions internal bus/fslmc: decouple from EAL VFIO
vfio: decouple EAL from VFIO internals
vhost: check DMA capability only once
vfio: do proper teardown on VFIO cleanup
eal: move kernel module check function into VFIO
vfio: remove modname parameter from init
vfio: add module check API
bus/pci: decouple PCI bus driver from VFIO
vfio: rename API to reflect internal status bus/pci: rename mismatching error labels
vfio: split get device info from setup
vfio: add container device assignment API net/nbl: do not use VFIO group bind API net/ntnic: use container device assignment API vdpa/ifc: use container device assignment API vdpa/nfp: use container device assignment API vdpa/sfc: use container device assignment API vdpa/mlx5: remove group-related API
vhost: remove group-related API from driver
vfio: remove group-based API
vfio: cleanup and refactor
bus/pci: use the new VFIO IOVA mode API bus/fslmc: use the new VFIO IOVA mode API net/hinic3: use the new VFIO IOVA mode API net/ntnic: use the new VFIO IOVA mode API
vfio: remove no-IOMMU check API
vfio: introduce cdev mode
config/arm/meson.build | 1 + config/meson.build | 1 + doc/api/doxy-api-index.md | 3 +- doc/guides/linux_gsg/linux_drivers.rst | 30 + doc/guides/prog_guide/vhost_lib.rst | 4 - doc/guides/rel_notes/deprecation.rst | 10 - doc/guides/rel_notes/release_26_11.rst | 16 + drivers/bus/cdx/cdx.c | 6 +- drivers/bus/cdx/cdx_vfio.c | 37 +- drivers/bus/fslmc/fslmc_bus.c | 12 +- drivers/bus/fslmc/fslmc_vfio.c | 66 +- drivers/bus/fslmc/meson.build | 1 - drivers/bus/pci/bsd/pci.c | 24 + drivers/bus/pci/linux/pci.c | 59 +- drivers/bus/pci/linux/pci_vfio.c | 84 +- drivers/bus/pci/pci_common.c | 64 +- drivers/bus/pci/private.h | 132 + drivers/bus/pci/windows/pci.c | 24 + drivers/bus/platform/platform.c | 17 +- drivers/crypto/bcmfs/bcmfs_vfio.c | 20 +- drivers/net/hinic3/base/hinic3_hwdev.c | 5 +- drivers/net/nbl/nbl_common/nbl_userdev.c | 73 +- drivers/net/nbl/nbl_common/nbl_userdev.h | 1 + drivers/net/nbl/nbl_include/nbl_include.h | 1 + drivers/net/ntnic/ntnic_ethdev.c | 4 +- drivers/net/ntnic/ntnic_vfio.c | 48 +- drivers/vdpa/ifc/ifcvf_vdpa.c | 54 +- drivers/vdpa/mlx5/mlx5_vdpa.c | 1 - drivers/vdpa/nfp/nfp_vdpa.c | 53 +- drivers/vdpa/sfc/sfc_vdpa.c | 47 +- drivers/vdpa/sfc/sfc_vdpa.h | 2 - drivers/vdpa/sfc/sfc_vdpa_hw.c | 12 +- kernel/linux/uapi/linux/iommufd.h | 1292 ++++++++++ kernel/linux/uapi/linux/vduse.h | 2 +- kernel/linux/uapi/linux/vfio.h | 12 +- kernel/linux/uapi/version | 2 +- lib/eal/common/eal_private.h | 14 - lib/eal/freebsd/eal.c | 128 - lib/eal/include/dev_vfio.h | 500 ++++ lib/eal/include/meson.build | 2 +- lib/eal/include/rte_vfio.h | 338 --- lib/eal/linux/eal.c | 62 +- lib/eal/linux/eal_vfio.c | 2764 +++++++++------------ lib/eal/linux/eal_vfio.h | 188 +- lib/eal/linux/eal_vfio_cdev.c | 420 ++++ lib/eal/linux/eal_vfio_group.c | 951 +++++++ lib/eal/linux/eal_vfio_mp_sync.c | 118 +- lib/eal/linux/meson.build | 2 + lib/eal/windows/eal.c | 23 - lib/vhost/socket.c | 6 +- lib/vhost/vdpa_driver.h | 3 - lib/vhost/vhost.h | 1 + lib/vhost/vhost_user.c | 16 +- 53 files changed, 5284 insertions(+), 2472 deletions(-) create mode 100644 kernel/linux/uapi/linux/iommufd.h create mode 100644 lib/eal/include/dev_vfio.h delete mode 100644 lib/eal/include/rte_vfio.h create mode 100644 lib/eal/linux/eal_vfio_cdev.c create mode 100644 lib/eal/linux/eal_vfio_group.c
Signature · 1 line
2.52.0