[RFC 8/8] vfio: use imported uAPI header
Xu, Rosen
rosen.xu at altera.com
Wed Sep 3 11:38:38 CEST 2025
Hi,
> -----Original Message-----
> From: David Marchand <david.marchand at redhat.com>
> Sent: Wednesday, September 3, 2025 3:28 PM
> To: dev at dpdk.org
> Cc: thomas at monjalon.net; maxime.coquelin at redhat.com; Nipun Gupta
> <nipun.gupta at amd.com>; Nikhil Agarwal <nikhil.agarwal at amd.com>;
> Hemant Agrawal <hemant.agrawal at nxp.com>; Sachin Saxena
> <sachin.saxena at nxp.com>; Anatoly Burakov <anatoly.burakov at intel.com>;
> Chenbo Xia <chenbox at nvidia.com>; Tomasz Duszynski
> <tduszynski at marvell.com>; Kai Ji <kai.ji at intel.com>; Ajit Khaparde
> <ajit.khaparde at broadcom.com>; Vikas Gupta
> <vikas.gupta at broadcom.com>; Xu, Rosen <rosen.xu at altera.com>;
> Chaoyong He <chaoyong.he at corigine.com>; Vijay Kumar Srivastava
> <vsrivast at xilinx.com>; Harman Kalra <hkalra at marvell.com>
> Subject: [RFC 8/8] vfio: use imported uAPI header
>
> [CAUTION: This email is from outside your organization. Unless you trust the
> sender, do not click on links or open attachments as it may be a fraudulent
> email attempting to steal your information and/or compromise your
> computer.]
>
> Now that we have a v6.16 header in DPDK, we can remove all remaining
> wrappers around VFIO uapi.
>
> Signed-off-by: David Marchand <david.marchand at redhat.com>
> ---
> drivers/bus/cdx/cdx_vfio.c | 45 +++++-------------------
> drivers/bus/fslmc/fslmc_vfio.c | 3 +-
> drivers/bus/fslmc/portal/dpaa2_hw_dpio.c | 3 +-
> drivers/bus/pci/linux/pci_vfio.c | 2 +-
> drivers/bus/platform/platform.c | 2 +-
> drivers/common/qat/dev/qat_dev_gen_lce.c | 2 +-
> drivers/crypto/bcmfs/bcmfs_vfio.c | 2 +-
> drivers/raw/ifpga/afu_pmd_n3000.c | 2 +-
> drivers/vdpa/ifc/ifcvf_vdpa.c | 2 +-
> drivers/vdpa/nfp/nfp_vdpa.c | 2 +-
> drivers/vdpa/sfc/sfc_vdpa_ops.c | 2 +-
> lib/eal/linux/eal_interrupts.c | 2 +-
> lib/eal/linux/eal_vfio.c | 3 +-
> 13 files changed, 24 insertions(+), 48 deletions(-)
>
> diff --git a/drivers/bus/cdx/cdx_vfio.c b/drivers/bus/cdx/cdx_vfio.c index
> 576718a659..f9f19b4122 100644
> --- a/drivers/bus/cdx/cdx_vfio.c
> +++ b/drivers/bus/cdx/cdx_vfio.c
> @@ -18,7 +18,7 @@
> #include <sys/ioctl.h>
> #include <sys/mman.h>
>
> -#include <linux/vfio.h>
> +#include <uapi/linux/vfio.h>
>
> #include <eal_export.h>
> #include <rte_eal_paging.h>
> @@ -616,33 +616,6 @@ rte_cdx_vfio_intr_disable(const struct
> rte_intr_handle *intr_handle)
> return ret;
> }
>
> -/* VFIO_DEVICE_FEATURE is defined for kernel version 5.7 and newer. */ -
> #ifdef VFIO_DEVICE_FEATURE
> -#define RTE_VFIO_DEVICE_FEATURE VFIO_DEVICE_FEATURE
> -#else
> -#define RTE_VFIO_DEVICE_FEATURE _IO(VFIO_TYPE, VFIO_BASE + 17)
> -struct vfio_device_feature {
> - __u32 argsz;
> - __u32 flags;
> -#define VFIO_DEVICE_FEATURE_MASK (0xffff) /* 16-bit feature
> index */
> -#define VFIO_DEVICE_FEATURE_GET (1 << 16) /* Get feature into
> data[] */
> -#define VFIO_DEVICE_FEATURE_SET (1 << 17) /* Set feature from
> data[] */
> -#define VFIO_DEVICE_FEATURE_PROBE (1 << 18) /* Probe feature
> support */
> - __u8 data[];
> -};
> -#endif
> -
> -#ifdef VFIO_DEVICE_FEATURE_BUS_MASTER
> -#define RTE_VFIO_DEVICE_FEATURE_BUS_MASTER
> VFIO_DEVICE_FEATURE_BUS_MASTER
> -#else
> -#define RTE_VFIO_DEVICE_FEATURE_BUS_MASTER 10
> -struct vfio_device_feature_bus_master {
> - __u32 op;
> -#define VFIO_DEVICE_FEATURE_CLEAR_MASTER 0 /* Clear Bus
> Master */
> -#define VFIO_DEVICE_FEATURE_SET_MASTER 1 /* Set Bus
> Master */
> -};
> -#endif
> -
> /* Enable Bus Mastering */
> RTE_EXPORT_INTERNAL_SYMBOL(rte_cdx_vfio_bm_enable)
> int
> @@ -668,9 +641,9 @@ rte_cdx_vfio_bm_enable(struct rte_cdx_device *dev)
>
> feature->argsz = argsz;
>
> - feature->flags = RTE_VFIO_DEVICE_FEATURE_BUS_MASTER |
> VFIO_DEVICE_FEATURE_PROBE;
> + feature->flags = VFIO_DEVICE_FEATURE_BUS_MASTER |
> + VFIO_DEVICE_FEATURE_PROBE;
> feature->flags |= VFIO_DEVICE_FEATURE_SET;
> - ret = ioctl(vfio_dev_fd, RTE_VFIO_DEVICE_FEATURE, feature);
> + ret = ioctl(vfio_dev_fd, VFIO_DEVICE_FEATURE, feature);
> if (ret) {
> CDX_BUS_ERR("Bus Master configuring not supported for device: %s,
> error: %d (%s)",
> dev->name, errno, strerror(errno)); @@ -678,9 +651,9 @@
> rte_cdx_vfio_bm_enable(struct rte_cdx_device *dev)
> return ret;
> }
>
> - feature->flags = RTE_VFIO_DEVICE_FEATURE_BUS_MASTER |
> VFIO_DEVICE_FEATURE_SET;
> + feature->flags = VFIO_DEVICE_FEATURE_BUS_MASTER |
> + VFIO_DEVICE_FEATURE_SET;
> vfio_bm_feature->op = VFIO_DEVICE_FEATURE_SET_MASTER;
> - ret = ioctl(vfio_dev_fd, RTE_VFIO_DEVICE_FEATURE, feature);
> + ret = ioctl(vfio_dev_fd, VFIO_DEVICE_FEATURE, feature);
> if (ret < 0)
> CDX_BUS_ERR("BM Enable Error for device: %s, Error: %d (%s)",
> dev->name, errno, strerror(errno)); @@ -713,9 +686,9 @@
> rte_cdx_vfio_bm_disable(struct rte_cdx_device *dev)
>
> feature->argsz = argsz;
>
> - feature->flags = RTE_VFIO_DEVICE_FEATURE_BUS_MASTER |
> VFIO_DEVICE_FEATURE_PROBE;
> + feature->flags = VFIO_DEVICE_FEATURE_BUS_MASTER |
> + VFIO_DEVICE_FEATURE_PROBE;
> feature->flags |= VFIO_DEVICE_FEATURE_SET;
> - ret = ioctl(vfio_dev_fd, RTE_VFIO_DEVICE_FEATURE, feature);
> + ret = ioctl(vfio_dev_fd, VFIO_DEVICE_FEATURE, feature);
> if (ret) {
> CDX_BUS_ERR("Bus Master configuring not supported for device: %s,
> Error: %d (%s)",
> dev->name, errno, strerror(errno)); @@ -723,9 +696,9 @@
> rte_cdx_vfio_bm_disable(struct rte_cdx_device *dev)
> return ret;
> }
>
> - feature->flags = RTE_VFIO_DEVICE_FEATURE_BUS_MASTER |
> VFIO_DEVICE_FEATURE_SET;
> + feature->flags = VFIO_DEVICE_FEATURE_BUS_MASTER |
> + VFIO_DEVICE_FEATURE_SET;
> vfio_bm_feature->op = VFIO_DEVICE_FEATURE_CLEAR_MASTER;
> - ret = ioctl(vfio_dev_fd, RTE_VFIO_DEVICE_FEATURE, feature);
> + ret = ioctl(vfio_dev_fd, VFIO_DEVICE_FEATURE, feature);
> if (ret < 0)
> CDX_BUS_ERR("BM Disable Error for device: %s, Error: %d (%s)",
> dev->name, errno, strerror(errno)); diff --git
> a/drivers/bus/fslmc/fslmc_vfio.c b/drivers/bus/fslmc/fslmc_vfio.c index
> 3f041f447c..abf38a7bf6 100644
> --- a/drivers/bus/fslmc/fslmc_vfio.c
> +++ b/drivers/bus/fslmc/fslmc_vfio.c
> @@ -20,7 +20,8 @@
> #include <dirent.h>
> #include <sys/eventfd.h>
> #include <ctype.h>
> -#include <linux/vfio.h>
> +
> +#include <uapi/linux/vfio.h>
>
> #include <eal_export.h>
> #include <eal_filesystem.h>
> diff --git a/drivers/bus/fslmc/portal/dpaa2_hw_dpio.c
> b/drivers/bus/fslmc/portal/dpaa2_hw_dpio.c
> index cffbf3c28a..18909811a1 100644
> --- a/drivers/bus/fslmc/portal/dpaa2_hw_dpio.c
> +++ b/drivers/bus/fslmc/portal/dpaa2_hw_dpio.c
> @@ -22,7 +22,8 @@
> #include <sys/epoll.h>
> #include <sys/eventfd.h>
> #include <sys/syscall.h>
> -#include <linux/vfio.h>
> +
> +#include <uapi/linux/vfio.h>
>
> #include <eal_export.h>
> #include <rte_mbuf.h>
> diff --git a/drivers/bus/pci/linux/pci_vfio.c b/drivers/bus/pci/linux/pci_vfio.c
> index 46b87c7c38..ec54b7ac69 100644
> --- a/drivers/bus/pci/linux/pci_vfio.c
> +++ b/drivers/bus/pci/linux/pci_vfio.c
> @@ -11,7 +11,7 @@
> #include <sys/mman.h>
> #include <stdbool.h>
>
> -#include <linux/vfio.h>
> +#include <uapi/linux/vfio.h>
>
> #include <rte_log.h>
> #include <rte_pci.h>
> diff --git a/drivers/bus/platform/platform.c
> b/drivers/bus/platform/platform.c index 149cba81a7..905b258595 100644
> --- a/drivers/bus/platform/platform.c
> +++ b/drivers/bus/platform/platform.c
> @@ -11,7 +11,7 @@
> #include <sys/queue.h>
> #include <unistd.h>
>
> -#include <linux/vfio.h>
> +#include <uapi/linux/vfio.h>
>
> #include <bus_driver.h>
> #include <bus_platform_driver.h>
> diff --git a/drivers/common/qat/dev/qat_dev_gen_lce.c
> b/drivers/common/qat/dev/qat_dev_gen_lce.c
> index 466878bf76..8486dfa384 100644
> --- a/drivers/common/qat/dev/qat_dev_gen_lce.c
> +++ b/drivers/common/qat/dev/qat_dev_gen_lce.c
> @@ -4,7 +4,7 @@
>
> #include <rte_pci.h>
>
> -#include <linux/vfio.h>
> +#include <uapi/linux/vfio.h>
>
> #include "qat_device.h"
> #include "qat_qp.h"
> diff --git a/drivers/crypto/bcmfs/bcmfs_vfio.c
> b/drivers/crypto/bcmfs/bcmfs_vfio.c
> index e747bef924..5f309a6b34 100644
> --- a/drivers/crypto/bcmfs/bcmfs_vfio.c
> +++ b/drivers/crypto/bcmfs/bcmfs_vfio.c
> @@ -7,7 +7,7 @@
> #include <sys/mman.h>
> #include <sys/ioctl.h>
>
> -#include <linux/vfio.h>
> +#include <uapi/linux/vfio.h>
>
> #include <rte_vfio.h>
>
> diff --git a/drivers/raw/ifpga/afu_pmd_n3000.c
> b/drivers/raw/ifpga/afu_pmd_n3000.c
> index ec2fdd46df..5e792ead8c 100644
> --- a/drivers/raw/ifpga/afu_pmd_n3000.c
> +++ b/drivers/raw/ifpga/afu_pmd_n3000.c
> @@ -13,7 +13,7 @@
> #include <sys/eventfd.h>
> #include <sys/ioctl.h>
>
> -#include <linux/vfio.h>
> +#include <uapi/linux/vfio.h>
>
> #include <rte_eal.h>
> #include <rte_malloc.h>
> diff --git a/drivers/vdpa/ifc/ifcvf_vdpa.c b/drivers/vdpa/ifc/ifcvf_vdpa.c
> index c8e47e41c1..ce63abd275 100644
> --- a/drivers/vdpa/ifc/ifcvf_vdpa.c
> +++ b/drivers/vdpa/ifc/ifcvf_vdpa.c
> @@ -11,7 +11,7 @@
> #include <linux/virtio_net.h>
> #include <stdbool.h>
>
> -#include <linux/vfio.h>
> +#include <uapi/linux/vfio.h>
>
> #include <rte_eal_paging.h>
> #include <rte_malloc.h>
> diff --git a/drivers/vdpa/nfp/nfp_vdpa.c b/drivers/vdpa/nfp/nfp_vdpa.c
> index c1ffbd1f91..df31851cb6 100644
> --- a/drivers/vdpa/nfp/nfp_vdpa.c
> +++ b/drivers/vdpa/nfp/nfp_vdpa.c
> @@ -8,7 +8,7 @@
> #include <sys/ioctl.h>
> #include <unistd.h>
>
> -#include <linux/vfio.h>
> +#include <uapi/linux/vfio.h>
>
> #include <nfp_common_pci.h>
> #include <nfp_dev.h>
> diff --git a/drivers/vdpa/sfc/sfc_vdpa_ops.c
> b/drivers/vdpa/sfc/sfc_vdpa_ops.c index 1ece47d373..dc64c4d213 100644
> --- a/drivers/vdpa/sfc/sfc_vdpa_ops.c
> +++ b/drivers/vdpa/sfc/sfc_vdpa_ops.c
> @@ -6,7 +6,7 @@
> #include <unistd.h>
> #include <sys/ioctl.h>
>
> -#include <linux/vfio.h>
> +#include <uapi/linux/vfio.h>
>
> #include <rte_errno.h>
> #include <rte_malloc.h>
> diff --git a/lib/eal/linux/eal_interrupts.c b/lib/eal/linux/eal_interrupts.c
> index d1789cbda2..346a2d4c72 100644
> --- a/lib/eal/linux/eal_interrupts.c
> +++ b/lib/eal/linux/eal_interrupts.c
> @@ -15,7 +15,7 @@
> #include <assert.h>
> #include <stdbool.h>
>
> -#include <linux/vfio.h>
> +#include <uapi/linux/vfio.h>
>
> #include <eal_export.h>
> #include <eal_trace_internal.h>
> diff --git a/lib/eal/linux/eal_vfio.c b/lib/eal/linux/eal_vfio.c index
> 62f9d05e63..89a8fb0a12 100644
> --- a/lib/eal/linux/eal_vfio.c
> +++ b/lib/eal/linux/eal_vfio.c
> @@ -8,7 +8,8 @@
> #include <unistd.h>
> #include <sys/ioctl.h>
> #include <dirent.h>
> -#include <linux/vfio.h>
> +
> +#include <uapi/linux/vfio.h>
>
> #include <rte_errno.h>
> #include <rte_log.h>
> --
> 2.51.0
Reviewed-by: Rosen Xu <rosen.xu at altera.com>
More information about the dev
mailing list