<div class="__aliyun_email_body_block"><div  style="font-family: Tahoma, Arial, STHeitiSC-Light, SimSun"><div  style="clear: both; font-family: Tahoma, Arial, STHeitiSC-Light, SimSun;"><span  style="font-family: Tahoma, Arial, STHeitiSC-Light, SimSun;">Hello <span  style="color: rgb(0, 0, 0); font-family: Tahoma, Arial, STHeiti, SimSun; font-size: 14px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; word-spacing: 0px; white-space: normal; background-color: rgb(255, 255, 255); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial; float: none; display: inline !important;">Anatoly,</span></span></div><div  style="clear: both; font-family: Tahoma, Arial, STHeitiSC-Light, SimSun;"><span  style="font-family: Tahoma, Arial, STHeiti, SimSun; color: rgb(0, 0, 0); font-size: 14px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; word-spacing: 0px; white-space: normal; background-color: rgb(255, 255, 255); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial; float: none; display: inline !important;"><br ></span></div><div  style="clear: both; font-family: Tahoma, Arial, STHeitiSC-Light, SimSun;"><span  style="font-family: Tahoma, Arial, STHeiti, SimSun; color: rgb(0, 0, 0); font-size: 14px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; word-spacing: 0px; white-space: normal; background-color: rgb(255, 255, 255); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial; float: none; display: inline !important;">I tested this patch series and encountered the same error on both Intel E810 and Nebulamatrix NICs, as follows:</span></div><div  style="clear: both; font-family: Tahoma, Arial, STHeitiSC-Light, SimSun;"><img  height="357" src="cid:__aliyun176173140123278911" width="1376" style="vertical-align: bottom;"></div><div  style="clear: both; font-family: Tahoma, Arial, STHeitiSC-Light, SimSun;"><span  style="font-family: Tahoma, Arial, STHeitiSC-Light, SimSun;"><br ></span></div><div  style="clear: both; font-family: Tahoma, Arial, STHeitiSC-Light, SimSun;"><div  class="ds-markdown" style="color: var(--dsw-alias-label-primary); letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; background-color: rgb(255, 255, 255); text-decoration-style: initial; text-decoration-color: initial; --panel-width: 0px; --ds-md-zoom: 1.143; font: var(--dsw-font-markdown-base);"><p  class="ds-markdown-paragraph" style="margin-right: 0px; margin-left: 0px; margin-top: 0px !important; margin-bottom: 0px !important;"><span >I used GDB for tracing and debugging, and found that there might be a slight issue with the code of </span><span  style="color: var(--dsw-alias-label-primary);">vfio_group_assign_device function? </span><span  style="color: var(--dsw-alias-label-primary);">I won't insist.</span></p><p  class="ds-markdown-paragraph" style="margin-right: 0px; margin-left: 0px; margin-top: 0px !important; margin-bottom: 0px !important;"><span  style="color: var(--dsw-alias-label-primary);">(1) vfio_device_create will alloc a vfio_device dev</span></p><p  class="ds-markdown-paragraph" style="margin-right: 0px; margin-left: 0px; margin-top: 0px !important; margin-bottom: 0px !important;"><span  style="color: var(--dsw-alias-label-primary);">(2) vfio_group_setup_device_fd will set dev->fd</span></p><p  class="ds-markdown-paragraph" style="margin-right: 0px; margin-left: 0px; margin-top: 0px !important; margin-bottom: 0px !important;"><span  style="color: var(--dsw-alias-label-primary);"><span ></span></span></p><div  class="ds-markdown" style="--panel-width: 0px; --ds-md-zoom: 1.143; font: var(--dsw-font-markdown-base); color: var(--dsw-alias-label-primary);"><p  class="ds-markdown-paragraph" style="margin-right: 0px; margin-left: 0px; margin-top: 0px !important; margin-bottom: 0px !important;"><span >(3) DEVICE_FOREACH_ACTIVE(cfg, idev) iterates through each idev->fd in cfg to check if it is the same as dev->fd, but at this point idev is actually dev.</span></p><p  class="ds-markdown-paragraph" style="margin-right: 0px; margin-left: 0px; margin-top: 0px !important; margin-bottom: 0px !important;"><span  style="color: var(--dsw-alias-label-primary);">     So it will report the error "Device 0000:08:00.0 already assigned to this container".</span></p><p  class="ds-markdown-paragraph" style="margin-right: 0px; margin-left: 0px; margin-top: 0px !important; margin-bottom: 0px !important;"><span  style="color: var(--dsw-alias-label-primary);"><br ></span></p></div><div ></div><p  class="ds-markdown-paragraph" style="margin-right: 0px; margin-left: 0px; margin-top: 0px !important; margin-bottom: 0px !important;"><img  src="cid:__aliyun176173140123278912" style="vertical-align: bottom"><br ></p><p  class="ds-markdown-paragraph" style="margin-right: 0px; margin-left: 0px; margin-top: 0px !important; margin-bottom: 0px !important;"><br ></p><p  class="ds-markdown-paragraph" style="margin-right: 0px; margin-left: 0px; margin-top: 0px !important; margin-bottom: 0px !important;"><img  src="cid:__aliyun176173140123278913" style="vertical-align: bottom"></p><p  class="ds-markdown-paragraph" style="margin-right: 0px; margin-left: 0px; margin-top: 0px !important; margin-bottom: 0px !important;"><br ></p><p  class="ds-markdown-paragraph" style="margin-right: 0px; margin-left: 0px; margin-top: 0px !important; margin-bottom: 0px !important;"><img  src="cid:__aliyun176173140123278914" style="vertical-align: bottom"></p><p  class="ds-markdown-paragraph" style="margin-right: 0px; margin-left: 0px; margin-top: 0px !important; margin-bottom: 0px !important;"><br ></p><p  class="ds-markdown-paragraph" style="margin-right: 0px; margin-left: 0px; margin-top: 0px !important; margin-bottom: 0px !important;"><img  height="248" src="cid:__aliyun176173140123278915" width="1376" style="vertical-align: bottom"></p></div><div  class="ds-flex _0a3d93b" style="display: flex; flex-wrap: wrap; align-items: center; width: calc(100% + 6px); margin-top: 12px; margin-bottom: 10px; position: relative; left: -6px; color: rgb(128, 0, 128); font-family: quote-cjk-patch, Inter, system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif; font-size: 14px; font-style: normal; font-variant-ligatures: no-contextual; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; background-color: rgb(255, 255, 255); text-decoration-style: initial; text-decoration-color: initial; gap: 10px;"><div  class="ds-flex _965abe9 _54866f7" style="display: flex; opacity: 1; transition: opacity var(--ds-transition-duration)var(--ds-ease-in-out); will-change: opacity; align-items: center; gap: 10px;"><div  aria-disabled="false" class="ds-icon-button db183363" role="button" tabindex="-1" style="--hover-size: 28px; border-radius: 50%; outline: none; justify-content: center; align-items: center; display: inline-flex; position: relative; overflow: visible; color: var(--dsw-alias-label-tertiary); width: 28px;"><br  class="Apple-interchange-newline"></div></div></div><span  style="font-family: Tahoma, Arial, STHeitiSC-Light, SimSun;"><br ></span></div><div  style="clear: both; font-family: Tahoma, Arial, STHeitiSC-Light, SimSun;"><span  style="font-family: Tahoma, Arial, STHeitiSC-Light, SimSun;"><br ></span></div><div  style="clear: both; font-family: Tahoma, Arial, STHeitiSC-Light, SimSun;"><span  style="font-family: Tahoma, Arial, STHeitiSC-Light, SimSun;"><br ></span></div><blockquote  _quote="1" style="margin-right: 0px; margin-top: 0px; margin-bottom: 0px; font-family: Tahoma, Arial, STHeiti, SimSun; font-size: 14px; color: rgb(0, 0, 0);"><div  class="alimail-quote"><div  style="clear: both;">------------------------------------------------------------------</div><div  style="clear: both;">发件人:Anatoly Burakov <anatoly.burakov@intel.com></div><div  style="clear: both;">发送时间:2025年10月29日(周三) 00:43</div><div  style="clear: both;">收件人:dev<dev@dpdk.org></div><div  style="clear: both;">主 题:[PATCH v1 0/8] Support VFIO cdev API in DPDK</div><div  style="clear: both;"><br ></div>This patchset introduces a major refactor of the VFIO subsystem in DPDK to<br >support character device (cdev) interface introduced in Linux kernel, as well as<br >make the API more streamlined and useful. The goal is to simplify device<br >management, improve compatibility, and clarify API responsibilities.<br ><br >The following sections outline the key issues addressed by this patchset and the<br >corresponding changes introduced.<br ><br >1. Only group mode is supported<br >===============================<br ><br >Since kernel version 4.14.327 (LTS), VFIO supports the new character device<br >(cdev)-based way of working with VFIO devices (otherwise known as IOMMUFD). This<br >is a device-centric mode and does away with all the complexity regarding groups<br >and IOMMU types, delegating it all to the kernel, and exposes a much simpler<br >interface to userspace.<br ><br >The old group interface is still around, and will need to be kept in DPDK both<br >for compatibility reasons, as well as supporting special cases (FSLMC bus, NBL<br >driver, etc.).<br ><br >To enable this, VFIO is heavily refactored, so that the code can support both<br >modes while relying on (mostly) common infrastructure.<br ><br >Note that the existing `rte_vfio_device_setup/release` model is fundamentally<br >incompatible with cdev mode, because for custom container cases, the expected<br >flow is that the user binds the IOMMU group (and thus, implicitly, the device<br >itself) to a specific container using `rte_vfio_container_group_bind`, whereas<br >this step is not needed for cdev as the device fd is assigned to the container<br >straight away.<br ><br >Therefore, what we do instead is introduce a new API for container device<br >assignment which, semantically, will assign a device to specified container, so<br >that when it is mapped using `rte_pci_map_device`, the appropriate container is<br >selected. Under the hood though, we essentially transition to getting device fd<br >straight away at assign stage, so that by the time the PCI bus attempts to map<br >the device, it is already mapped and we just return an fd.<br ><br >Additionally, a new `rte_vfio_get_mode` API is added for those cases that need<br >some introspection into VFIO's internals, with three new modes: group<br >(old-style), no-iommu (old-style but without IOMMU), and cdev (the new mode).<br >Although no-IOMMU is technically a variant of group mode, the distinction is<br >largely irrelevant to the user, as all usages of noiommu checks in our codebase<br >are for deciding whether to use IOVA or PA, not anything to do with managing<br >groups. The current plan for kernel community is to *not* introduce no-IOMMU<br >cdev implementation, which is why this will be kept for compatibility for these<br >use cases.<br ><br >As for special cases that rely on group mode, the old group-based API calls are<br >kept, but will be marked as deprecated, and will only work in group/noiommu<br >mode. This has little practical consequences, as even users such as NBL or FSLMC<br >bus do not actually use any of VFIO functionality, they just create a container<br >and proceed to do their own thing.<br ><br >2. There is duplication among API's<br >===================================<br ><br >Over time, several VFIO API's have been added that perform overlapping<br >functions:<br ><br >* `rte_vfio_get_group_fd` does the same thing as `rte_vfio_container_group_bind`<br >* `rte_vfio_clear_group` does the same thing as rte_vfio_container_group_unbind`<br ><br >The only difference between them is that for the former API's, the container<br >selection is implicit (create in default if doesn't exist, delete from any<br >container). It really only makes sense to keep container versions around, but<br >because we don't really need any of them any more, all of them will be<br >deprecated.<br ><br >3. The API responsibilities aren't clear and bleed into each other<br >==================================================================<br ><br >Some API's do multiple things at once. In particular:<br ><br >* `rte_vfio_get_group_fd` opens a new group if it doesn't exist<br >* `rte_vfio_container_group_bind/unbind` return group fd<br >* `rte_vfio_get_device_info` will setup the device<br ><br >These API's have been adjusted as follows:<br ><br >* `rte_vfio_get_group_fd` will *not* open any fd's, it will *only* return those<br >  previously bound to a container by `rte_vfio_container_group_bind`<br >* `rte_vfio_container_group_bind` will *not* return any fd's (users should call<br >  `rte_vfio_get_group_fd` to get it)<br >* `rte_vfio_get_device_info` will *not* set up the device (users should call<br >  `rte_vfio_container_device_setup` prior to calling this API)<br ><br >All current users of these API's were adjusted, and grou-related API's were<br >marked as deprecated.<br ><br >Feedback and suggestions are welcome, especially from maintainers of drivers<br >that depend on VFIO infrastructure.<br ><br >Anatoly Burakov (8):<br >  uapi: update to v6.17 and add iommufd.h<br >  vfio: add container device assignment API<br >  vhost: remove group-related API from drivers<br >  vfio: do not setup the device on get device info<br >  vfio: cleanup and refactor<br >  vfio: introduce cdev mode<br >  doc: deprecate VFIO group-based APIs<br >  vfio: deprecate group-based API<br ><br > config/arm/meson.build                    |    1 +<br > config/meson.build                        |    1 +<br > doc/guides/rel_notes/deprecation.rst      |   26 +<br > drivers/bus/cdx/cdx_vfio.c                |   13 +-<br > drivers/bus/fslmc/fslmc_bus.c             |   10 +-<br > drivers/bus/fslmc/fslmc_vfio.c            |    2 +-<br > drivers/bus/pci/linux/pci.c               |    2 +-<br > drivers/bus/pci/linux/pci_vfio.c          |   17 +-<br > drivers/crypto/bcmfs/bcmfs_vfio.c         |    6 +-<br > drivers/net/hinic3/base/hinic3_hwdev.c    |    2 +-<br > drivers/net/nbl/nbl_common/nbl_userdev.c  |   18 +-<br > drivers/net/nbl/nbl_include/nbl_include.h |    1 +<br > drivers/net/ntnic/ntnic_ethdev.c          |    2 +-<br > drivers/net/ntnic/ntnic_vfio.c            |   30 +-<br > drivers/vdpa/ifc/ifcvf_vdpa.c             |   34 +-<br > drivers/vdpa/mlx5/mlx5_vdpa.c             |    1 -<br > drivers/vdpa/nfp/nfp_vdpa.c               |   37 +-<br > drivers/vdpa/sfc/sfc_vdpa.c               |   39 +-<br > drivers/vdpa/sfc/sfc_vdpa.h               |    2 -<br > kernel/linux/uapi/linux/iommufd.h         | 1292 ++++++++++<br > kernel/linux/uapi/linux/vduse.h           |    2 +-<br > kernel/linux/uapi/linux/vfio.h            |   12 +-<br > kernel/linux/uapi/version                 |    2 +-<br > lib/eal/freebsd/eal.c                     |   36 +<br > lib/eal/include/rte_vfio.h                |  414 +++-<br > lib/eal/linux/eal_vfio.c                  | 2640 +++++++++------------<br > lib/eal/linux/eal_vfio.h                  |  170 +-<br > lib/eal/linux/eal_vfio_cdev.c             |  387 +++<br > lib/eal/linux/eal_vfio_group.c            |  981 ++++++++<br > lib/eal/linux/eal_vfio_mp_sync.c          |   91 +-<br > lib/eal/linux/meson.build                 |    2 +<br > lib/vhost/vdpa_driver.h                   |    3 -<br > 32 files changed, 4484 insertions(+), 1792 deletions(-)<br > create mode 100644 kernel/linux/uapi/linux/iommufd.h<br > create mode 100644 lib/eal/linux/eal_vfio_cdev.c<br > create mode 100644 lib/eal/linux/eal_vfio_group.c<br ><br >-- <br >2.47.3</div></blockquote><div  style="line-height: 20px; clear: both;"><br ></div></div></div>
<div style="clear: both;"><span style="font-size: 10px; color: rgb(216, 216, 216);">本邮件所含信息及其任何附件为保密信息且可能属于专有信息。任何非指定接收人均无权访问本邮件。如果您不是该邮件的指定接收人,那么任何对本邮件内容进行披露,复制或使用的行为均是禁止的。如果您不是该邮件的指定接收人,请您立即通过邮件通知 compliance@nebula-matrix.com并立即删除您错误接受的邮件。</span></div><div style="clear: both;"><span style="font-size: 10px; color: rgb(216, 216, 216);">The information in this message and any attachments is confidential and may be privileged.  Access to this email by anyone other than the intended recipient is not authorized.  If you are not the intended recipient, disclosure, copying or use of the contents of this email is prohibited.  If you are not the intended recipient, please notify  compliance@nebula-matrix.com immediately by email, and please destroy the email you received in error.</span></div>