From: Anatoly Burakov <anatoly.burakov@intel.com>
To: dev@dpdk.org, Bruce Richardson <bruce.richardson@intel.com>
Subject: [PATCH v6 04/18] vfio: add container device assignment API
Date: Fri, 21 Nov 2025 10:08:49 +0000 [thread overview]
Message-ID: <2584c63cf06c805e624f151b69605aa84362eca0.1763719706.git.anatoly.burakov@intel.com> (raw)
In-Reply-To: <cover.1763719706.git.anatoly.burakov@intel.com> <cover.1763719706.git.anatoly.burakov@intel.com>
Currently, VFIO has explicit group bind API's, but the way they're used is
such that no one actually cares about VFIO groups, and the real goal of
everyone using VFIO group bind API is to bind devices to particular VFIO
container, such that when `rte_vfio_setup_device` call eventually comes,
VFIO will pick up the correct container.
To remove dependency on group API's, add a new "container assign device"
API call that will do the same thing, but will not depend on managing VFIO
group fd's.
Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
---
lib/eal/freebsd/eal.c | 10 ++++++++++
lib/eal/include/rte_vfio.h | 26 ++++++++++++++++++++++++++
lib/eal/linux/eal_vfio.c | 32 ++++++++++++++++++++++++++++++++
3 files changed, 68 insertions(+)
diff --git a/lib/eal/freebsd/eal.c b/lib/eal/freebsd/eal.c
index dea32ae428..a7360db7a7 100644
--- a/lib/eal/freebsd/eal.c
+++ b/lib/eal/freebsd/eal.c
@@ -936,3 +936,13 @@ rte_vfio_container_dma_unmap(__rte_unused int container_fd,
rte_errno = ENOTSUP;
return -1;
}
+
+RTE_EXPORT_INTERNAL_SYMBOL(rte_vfio_container_assign_device)
+int
+rte_vfio_container_assign_device(__rte_unused int vfio_container_fd,
+ __rte_unused const char *sysfs_base,
+ __rte_unused const char *dev_addr)
+{
+ rte_errno = ENOTSUP;
+ return -1;
+}
diff --git a/lib/eal/include/rte_vfio.h b/lib/eal/include/rte_vfio.h
index fb666141f6..e7e2ee950b 100644
--- a/lib/eal/include/rte_vfio.h
+++ b/lib/eal/include/rte_vfio.h
@@ -271,6 +271,32 @@ __rte_internal
int
rte_vfio_container_destroy(int container_fd);
+/**
+ * @internal
+ *
+ * Assign a device to a VFIO container.
+ *
+ * Doing so will cause `rte_vfio_setup_device()` to set up the device with the VFIO container
+ * specified in this assign operation.
+ *
+ * This function is only relevant on Linux.
+ *
+ * @param vfio_container_fd
+ * VFIO container file descriptor.
+ * @param sysfs_base
+ * Sysfs path prefix.
+ * @param dev_addr
+ * Device identifier.
+ *
+ * @return
+ * 0 on success.
+ * <0 on failure, rte_errno is set.
+ */
+__rte_internal
+int
+rte_vfio_container_assign_device(int vfio_container_fd, const char *sysfs_base,
+ const char *dev_addr);
+
/**
* @internal
* Bind a IOMMU group to a container.
diff --git a/lib/eal/linux/eal_vfio.c b/lib/eal/linux/eal_vfio.c
index 47c973e49a..02fec64658 100644
--- a/lib/eal/linux/eal_vfio.c
+++ b/lib/eal/linux/eal_vfio.c
@@ -2102,6 +2102,38 @@ rte_vfio_container_destroy(int container_fd)
return 0;
}
+RTE_EXPORT_INTERNAL_SYMBOL(rte_vfio_container_assign_device)
+int
+rte_vfio_container_assign_device(int vfio_container_fd, const char *sysfs_base,
+ const char *dev_addr)
+{
+ int iommu_group_num;
+ int ret;
+
+ ret = rte_vfio_get_group_num(sysfs_base, dev_addr, &iommu_group_num);
+ if (ret < 0) {
+ EAL_LOG(ERR, "Cannot get IOMMU group number for device %s",
+ dev_addr);
+ return -1;
+ } else if (ret == 0) {
+ EAL_LOG(ERR,
+ "Device %s is not assigned to any IOMMU group",
+ dev_addr);
+ return -1;
+ }
+
+ ret = rte_vfio_container_group_bind(vfio_container_fd,
+ iommu_group_num);
+ if (ret < 0) {
+ EAL_LOG(ERR,
+ "Cannot bind IOMMU group %d for device %s",
+ iommu_group_num, dev_addr);
+ return -1;
+ }
+
+ return 0;
+}
+
RTE_EXPORT_INTERNAL_SYMBOL(rte_vfio_container_group_bind)
int
rte_vfio_container_group_bind(int container_fd, int iommu_group_num)
--
2.47.3
next prev parent reply other threads:[~2025-11-21 10:09 UTC|newest]
Thread overview: 96+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-28 16:43 [PATCH v1 0/8] Support VFIO cdev API in DPDK Anatoly Burakov
2025-10-28 16:43 ` [PATCH v1 1/8] uapi: update to v6.17 and add iommufd.h Anatoly Burakov
2025-10-28 16:43 ` [PATCH v1 2/8] vfio: add container device assignment API Anatoly Burakov
2025-10-28 16:43 ` [PATCH v1 3/8] vhost: remove group-related API from drivers Anatoly Burakov
2025-10-28 16:43 ` [PATCH v1 4/8] vfio: do not setup the device on get device info Anatoly Burakov
2025-10-28 16:43 ` [PATCH v1 5/8] vfio: cleanup and refactor Anatoly Burakov
2025-10-28 16:43 ` [PATCH v1 6/8] vfio: introduce cdev mode Anatoly Burakov
2025-10-28 16:43 ` [PATCH v1 7/8] doc: deprecate VFIO group-based APIs Anatoly Burakov
2025-10-28 16:43 ` [PATCH v1 8/8] vfio: deprecate group-based API Anatoly Burakov
2025-10-29 9:50 ` 回复:[PATCH v1 0/8] Support VFIO cdev API in DPDK Dimon
2025-10-29 12:03 ` Burakov, Anatoly
2025-10-30 9:21 ` [PATCH " David Marchand
2025-10-30 10:11 ` Burakov, Anatoly
2025-11-14 17:40 ` [PATCH v2 00/19] " Anatoly Burakov
2025-11-14 17:40 ` [PATCH v2 01/19] doc: add deprecation notice for VFIO API Anatoly Burakov
2025-11-14 17:40 ` [PATCH v2 02/19] doc: add deprecation notice for vDPA driver API Anatoly Burakov
2025-11-14 17:40 ` [PATCH v2 03/19] uapi: update to v6.17 and add iommufd.h Anatoly Burakov
2025-11-14 17:40 ` [PATCH v2 04/19] vfio: make all functions internal Anatoly Burakov
2025-11-14 18:18 ` Stephen Hemminger
2025-11-18 10:37 ` Burakov, Anatoly
2025-11-14 17:40 ` [PATCH v2 05/19] vfio: add container device assignment API Anatoly Burakov
2025-11-14 17:40 ` [PATCH v2 06/19] vfio: split get device info from setup Anatoly Burakov
2025-11-14 17:40 ` [PATCH v2 07/19] net/nbl: do not use VFIO group bind API Anatoly Burakov
2025-11-15 8:31 ` 回复:[PATCH " Dimon
2025-11-18 10:39 ` Burakov, Anatoly
2025-11-14 17:40 ` [PATCH v2 08/19] net/ntnic: use container device assignment API Anatoly Burakov
2025-11-14 17:40 ` [PATCH v2 09/19] vdpa/ifc: " Anatoly Burakov
2025-11-14 17:40 ` [PATCH v2 10/19] vdpa/nfp: " Anatoly Burakov
2025-11-14 17:40 ` [PATCH v2 11/19] vdpa/sfc: " Anatoly Burakov
2025-11-14 17:40 ` [PATCH v2 12/19] vhost: remove group-related API from drivers Anatoly Burakov
2025-11-14 17:40 ` [PATCH v2 13/19] vfio: cleanup and refactor Anatoly Burakov
2025-11-14 17:40 ` [PATCH v2 14/19] bus/pci: use the new VFIO mode API Anatoly Burakov
2025-11-14 17:40 ` [PATCH v2 15/19] bus/fslmc: " Anatoly Burakov
2025-11-14 17:40 ` [PATCH v2 16/19] net/hinic3: " Anatoly Burakov
2025-11-14 17:40 ` [PATCH v2 17/19] net/ntnic: " Anatoly Burakov
2025-11-14 17:40 ` [PATCH v2 18/19] vfio: remove group API functions Anatoly Burakov
2025-11-14 17:40 ` [PATCH v2 19/19] vfio: introduce cdev mode Anatoly Burakov
2025-11-19 11:01 ` [PATCH v4 00/17] Support VFIO cdev API in DPDK Anatoly Burakov
2025-11-19 11:01 ` [PATCH v4 01/17] vfio: make all functions internal Anatoly Burakov
2025-11-19 11:01 ` [PATCH v4 02/17] vfio: split get device info from setup Anatoly Burakov
2025-11-19 11:01 ` [PATCH v4 03/17] vfio: add container device assignment API Anatoly Burakov
2025-11-19 11:01 ` [PATCH v4 04/17] net/nbl: do not use VFIO group bind API Anatoly Burakov
2025-11-19 11:01 ` [PATCH v4 05/17] net/ntnic: use container device assignment API Anatoly Burakov
2025-11-19 11:01 ` [PATCH v4 06/17] vdpa/ifc: " Anatoly Burakov
2025-11-19 11:01 ` [PATCH v4 07/17] vdpa/nfp: " Anatoly Burakov
2025-11-19 11:01 ` [PATCH v4 08/17] vdpa/sfc: " Anatoly Burakov
2025-11-19 11:01 ` [PATCH v4 09/17] vhost: remove group-related API from drivers Anatoly Burakov
2025-11-19 11:01 ` [PATCH v4 10/17] vfio: remove group-based API Anatoly Burakov
2025-11-19 11:01 ` [PATCH v4 11/17] vfio: cleanup and refactor Anatoly Burakov
2025-11-19 11:01 ` [PATCH v4 12/17] bus/pci: use the new VFIO mode API Anatoly Burakov
2025-11-19 11:01 ` [PATCH v4 13/17] bus/fslmc: " Anatoly Burakov
2025-11-19 11:01 ` [PATCH v4 14/17] net/hinic3: " Anatoly Burakov
2025-11-19 11:01 ` [PATCH v4 15/17] net/ntnic: " Anatoly Burakov
2025-11-19 11:01 ` [PATCH v4 16/17] vfio: remove no-IOMMU check API Anatoly Burakov
2025-11-19 11:02 ` [PATCH v4 17/17] vfio: introduce cdev mode Anatoly Burakov
2025-11-19 11:06 ` [PATCH v4 00/17] Support VFIO cdev API in DPDK Burakov, Anatoly
2025-11-19 11:07 ` [PATCH v5 00/18] " Anatoly Burakov
2025-11-19 11:07 ` [PATCH v5 01/18] uapi: update to v6.17 and add iommufd.h Anatoly Burakov
2025-11-19 11:08 ` [PATCH v5 02/18] vfio: make all functions internal Anatoly Burakov
2025-11-19 11:08 ` [PATCH v5 03/18] vfio: split get device info from setup Anatoly Burakov
2025-11-19 11:08 ` [PATCH v5 04/18] vfio: add container device assignment API Anatoly Burakov
2025-11-19 11:08 ` [PATCH v5 05/18] net/nbl: do not use VFIO group bind API Anatoly Burakov
2025-11-19 11:08 ` [PATCH v5 06/18] net/ntnic: use container device assignment API Anatoly Burakov
2025-11-19 11:08 ` [PATCH v5 07/18] vdpa/ifc: " Anatoly Burakov
2025-11-19 11:08 ` [PATCH v5 08/18] vdpa/nfp: " Anatoly Burakov
2025-11-19 11:08 ` [PATCH v5 09/18] vdpa/sfc: " Anatoly Burakov
2025-11-19 11:08 ` [PATCH v5 10/18] vhost: remove group-related API from drivers Anatoly Burakov
2025-11-19 11:08 ` [PATCH v5 11/18] vfio: remove group-based API Anatoly Burakov
2025-11-19 11:08 ` [PATCH v5 12/18] vfio: cleanup and refactor Anatoly Burakov
2025-11-20 7:04 ` Hemant Agrawal
2025-11-19 11:08 ` [PATCH v5 13/18] bus/pci: use the new VFIO mode API Anatoly Burakov
2025-11-19 11:08 ` [PATCH v5 14/18] bus/fslmc: " Anatoly Burakov
2025-11-20 7:03 ` Hemant Agrawal
2025-11-19 11:08 ` [PATCH v5 15/18] net/hinic3: " Anatoly Burakov
2025-11-19 11:08 ` [PATCH v5 16/18] net/ntnic: " Anatoly Burakov
2025-11-19 11:08 ` [PATCH v5 17/18] vfio: remove no-IOMMU check API Anatoly Burakov
2025-11-19 11:08 ` [PATCH v5 18/18] vfio: introduce cdev mode Anatoly Burakov
2025-11-21 10:08 ` [PATCH v6 00/18] Support VFIO cdev API in DPDK Anatoly Burakov
2025-11-21 10:08 ` [PATCH v6 01/18] uapi: update to v6.17 and add iommufd.h Anatoly Burakov
2025-11-21 10:08 ` [PATCH v6 02/18] vfio: make all functions internal Anatoly Burakov
2025-11-21 10:08 ` [PATCH v6 03/18] vfio: split get device info from setup Anatoly Burakov
2025-11-21 10:08 ` Anatoly Burakov [this message]
2025-11-21 10:08 ` [PATCH v6 05/18] net/nbl: do not use VFIO group bind API Anatoly Burakov
2025-11-21 10:08 ` [PATCH v6 06/18] net/ntnic: use container device assignment API Anatoly Burakov
2025-11-21 10:08 ` [PATCH v6 07/18] vdpa/ifc: " Anatoly Burakov
2025-11-21 10:08 ` [PATCH v6 08/18] vdpa/nfp: " Anatoly Burakov
2025-11-21 10:08 ` [PATCH v6 09/18] vdpa/sfc: " Anatoly Burakov
2025-11-21 10:08 ` [PATCH v6 10/18] vhost: remove group-related API from drivers Anatoly Burakov
2025-11-21 10:08 ` [PATCH v6 11/18] vfio: remove group-based API Anatoly Burakov
2025-11-21 10:08 ` [PATCH v6 12/18] vfio: cleanup and refactor Anatoly Burakov
2025-11-21 10:08 ` [PATCH v6 13/18] bus/pci: use the new VFIO mode API Anatoly Burakov
2025-11-21 10:08 ` [PATCH v6 14/18] bus/fslmc: " Anatoly Burakov
2025-11-21 10:09 ` [PATCH v6 15/18] net/hinic3: " Anatoly Burakov
2025-11-21 10:09 ` [PATCH v6 16/18] net/ntnic: " Anatoly Burakov
2025-11-21 10:09 ` [PATCH v6 17/18] vfio: remove no-IOMMU check API Anatoly Burakov
2025-11-21 10:09 ` [PATCH v6 18/18] vfio: introduce cdev mode Anatoly Burakov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=2584c63cf06c805e624f151b69605aa84362eca0.1763719706.git.anatoly.burakov@intel.com \
--to=anatoly.burakov@intel.com \
--cc=bruce.richardson@intel.com \
--cc=dev@dpdk.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).