[RFC 6/8] vfio: stop including Linux kernel header in public and driver API

Xu, Rosen rosen.xu at altera.com
Wed Sep 3 11:38:25 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>; Dengdui Huang
> <huangdengdui at huawei.com>; Xu, Rosen <rosen.xu at altera.com>;
> Chaoyong He <chaoyong.he at corigine.com>; Vijay Kumar Srivastava
> <vsrivast at xilinx.com>; Tyler Retzlaff <roretzla at linux.microsoft.com>;
> Harman Kalra <hkalra at marvell.com>
> Subject: [RFC 6/8] vfio: stop including Linux kernel header in public and driver
> API
> 
> [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.]
> 
> The DPDK API is not dependent on the VFIO API itself.
> Remove inclusion in rte_vfio.h (and bus_fslmc_driver.h) and add explicit
> inclusion where needed.
> 
> Signed-off-by: David Marchand <david.marchand at redhat.com>
> ---
>  drivers/bus/cdx/cdx_vfio.c                 | 3 +++
>  drivers/bus/fslmc/bus_fslmc_driver.h       | 3 ++-
>  drivers/bus/fslmc/fslmc_bus.c              | 1 +
>  drivers/bus/fslmc/fslmc_vfio.c             | 2 ++
>  drivers/bus/fslmc/fslmc_vfio.h             | 1 -
>  drivers/bus/fslmc/portal/dpaa2_hw_dpio.c   | 1 +
>  drivers/bus/pci/linux/pci_vfio.c           | 2 ++
>  drivers/bus/platform/platform.c            | 2 ++
>  drivers/common/qat/dev/qat_dev_gen_lce.c   | 3 ++-
>  drivers/crypto/bcmfs/bcmfs_vfio.c          | 2 ++
>  drivers/net/hns3/hns3_ethdev_vf.c          | 1 -
>  drivers/raw/ifpga/afu_pmd_he_hssi.c        | 1 -
>  drivers/raw/ifpga/afu_pmd_he_lpbk.c        | 1 -
>  drivers/raw/ifpga/afu_pmd_he_mem.c         | 1 -
>  drivers/raw/ifpga/afu_pmd_n3000.c          | 3 ++-
>  drivers/raw/ifpga/base/ifpga_feature_dev.c | 2 +-
>  drivers/vdpa/ifc/ifcvf_vdpa.c              | 2 ++
>  drivers/vdpa/nfp/nfp_vdpa.c                | 2 ++
>  drivers/vdpa/sfc/sfc_vdpa_ops.c            | 3 ++-
>  lib/eal/include/rte_vfio.h                 | 8 --------
>  lib/eal/linux/eal_interrupts.c             | 3 ++-
>  lib/eal/linux/eal_vfio.c                   | 1 +
>  22 files changed, 29 insertions(+), 19 deletions(-)
> 
> diff --git a/drivers/bus/cdx/cdx_vfio.c b/drivers/bus/cdx/cdx_vfio.c index
> 03d156388e..576718a659 100644
> --- a/drivers/bus/cdx/cdx_vfio.c
> +++ b/drivers/bus/cdx/cdx_vfio.c
> @@ -17,6 +17,9 @@
>  #include <sys/socket.h>
>  #include <sys/ioctl.h>
>  #include <sys/mman.h>
> +
> +#include <linux/vfio.h>
> +
>  #include <eal_export.h>
>  #include <rte_eal_paging.h>
>  #include <rte_malloc.h>
> diff --git a/drivers/bus/fslmc/bus_fslmc_driver.h
> b/drivers/bus/fslmc/bus_fslmc_driver.h
> index 442de1a3fb..74ce7381d7 100644
> --- a/drivers/bus/fslmc/bus_fslmc_driver.h
> +++ b/drivers/bus/fslmc/bus_fslmc_driver.h
> @@ -20,7 +20,6 @@
>  #include <sys/queue.h>
>  #include <stdint.h>
>  #include <inttypes.h>
> -#include <linux/vfio.h>
> 
>  #include <rte_compat.h>
>  #include <rte_debug.h>
> @@ -37,6 +36,8 @@
>  extern "C" {
>  #endif
> 
> +struct vfio_device_info;
> +
>  #define FSLMC_OBJECT_MAX_LEN 32   /**< Length of each device on bus */
> 
>  #define DPAA2_INVALID_MBUF_SEQN        0
> diff --git a/drivers/bus/fslmc/fslmc_bus.c b/drivers/bus/fslmc/fslmc_bus.c
> index 20458d5030..49c61c9d2d 100644
> --- a/drivers/bus/fslmc/fslmc_bus.c
> +++ b/drivers/bus/fslmc/fslmc_bus.c
> @@ -17,6 +17,7 @@
>  #include <rte_memcpy.h>
>  #include <ethdev_driver.h>
>  #include <rte_mbuf_dyn.h>
> +#include <rte_vfio.h>
> 
>  #include "private.h"
>  #include <fslmc_vfio.h>
> diff --git a/drivers/bus/fslmc/fslmc_vfio.c b/drivers/bus/fslmc/fslmc_vfio.c
> index c08c316c94..3f041f447c 100644
> --- a/drivers/bus/fslmc/fslmc_vfio.c
> +++ b/drivers/bus/fslmc/fslmc_vfio.c
> @@ -20,6 +20,7 @@
>  #include <dirent.h>
>  #include <sys/eventfd.h>
>  #include <ctype.h>
> +#include <linux/vfio.h>
> 
>  #include <eal_export.h>
>  #include <eal_filesystem.h>
> @@ -32,6 +33,7 @@
>  #include <rte_kvargs.h>
>  #include <dev_driver.h>
>  #include <rte_eal_memconfig.h>
> +#include <rte_vfio.h>
>  #include <eal_vfio.h>
> 
>  #include "private.h"
> diff --git a/drivers/bus/fslmc/fslmc_vfio.h b/drivers/bus/fslmc/fslmc_vfio.h
> index 815970ec38..c995fd67b8 100644
> --- a/drivers/bus/fslmc/fslmc_vfio.h
> +++ b/drivers/bus/fslmc/fslmc_vfio.h
> @@ -9,7 +9,6 @@
>  #define _FSLMC_VFIO_H_
> 
>  #include <rte_compat.h>
> -#include <rte_vfio.h>
> 
>  /* Pathname of FSL-MC devices directory. */
>  #define SYSFS_FSL_MC_DEVICES   "/sys/bus/fsl-mc/devices"
> diff --git a/drivers/bus/fslmc/portal/dpaa2_hw_dpio.c
> b/drivers/bus/fslmc/portal/dpaa2_hw_dpio.c
> index e32471d8b5..cffbf3c28a 100644
> --- a/drivers/bus/fslmc/portal/dpaa2_hw_dpio.c
> +++ b/drivers/bus/fslmc/portal/dpaa2_hw_dpio.c
> @@ -22,6 +22,7 @@
>  #include <sys/epoll.h>
>  #include <sys/eventfd.h>
>  #include <sys/syscall.h>
> +#include <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 9e5776ce3c..46b87c7c38 100644
> --- a/drivers/bus/pci/linux/pci_vfio.c
> +++ b/drivers/bus/pci/linux/pci_vfio.c
> @@ -11,6 +11,8 @@
>  #include <sys/mman.h>
>  #include <stdbool.h>
> 
> +#include <linux/vfio.h>
> +
>  #include <rte_log.h>
>  #include <rte_pci.h>
>  #include <rte_bus_pci.h>
> diff --git a/drivers/bus/platform/platform.c
> b/drivers/bus/platform/platform.c index 90524fd961..149cba81a7 100644
> --- a/drivers/bus/platform/platform.c
> +++ b/drivers/bus/platform/platform.c
> @@ -11,6 +11,8 @@
>  #include <sys/queue.h>
>  #include <unistd.h>
> 
> +#include <linux/vfio.h>
> +
>  #include <bus_driver.h>
>  #include <bus_platform_driver.h>
>  #include <eal_export.h>
> diff --git a/drivers/common/qat/dev/qat_dev_gen_lce.c
> b/drivers/common/qat/dev/qat_dev_gen_lce.c
> index 6514321c32..466878bf76 100644
> --- a/drivers/common/qat/dev/qat_dev_gen_lce.c
> +++ b/drivers/common/qat/dev/qat_dev_gen_lce.c
> @@ -3,7 +3,8 @@
>   */
> 
>  #include <rte_pci.h>
> -#include <rte_vfio.h>
> +
> +#include <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 9138f96eb0..e747bef924 100644
> --- a/drivers/crypto/bcmfs/bcmfs_vfio.c
> +++ b/drivers/crypto/bcmfs/bcmfs_vfio.c
> @@ -7,6 +7,8 @@
>  #include <sys/mman.h>
>  #include <sys/ioctl.h>
> 
> +#include <linux/vfio.h>
> +
>  #include <rte_vfio.h>
> 
>  #include "bcmfs_device.h"
> diff --git a/drivers/net/hns3/hns3_ethdev_vf.c
> b/drivers/net/hns3/hns3_ethdev_vf.c
> index f9ef3dbb06..59fb790240 100644
> --- a/drivers/net/hns3/hns3_ethdev_vf.c
> +++ b/drivers/net/hns3/hns3_ethdev_vf.c
> @@ -5,7 +5,6 @@
>  #include <rte_alarm.h>
>  #include <ethdev_pci.h>
>  #include <rte_io.h>
> -#include <rte_vfio.h>
> 
>  #include "hns3_ethdev.h"
>  #include "hns3_common.h"
> diff --git a/drivers/raw/ifpga/afu_pmd_he_hssi.c
> b/drivers/raw/ifpga/afu_pmd_he_hssi.c
> index 859f28dcc1..bcb952935a 100644
> --- a/drivers/raw/ifpga/afu_pmd_he_hssi.c
> +++ b/drivers/raw/ifpga/afu_pmd_he_hssi.c
> @@ -17,7 +17,6 @@
>  #include <rte_malloc.h>
>  #include <rte_memcpy.h>
>  #include <rte_io.h>
> -#include <rte_vfio.h>
>  #include <bus_pci_driver.h>
>  #include <bus_ifpga_driver.h>
>  #include <rte_rawdev.h>
> diff --git a/drivers/raw/ifpga/afu_pmd_he_lpbk.c
> b/drivers/raw/ifpga/afu_pmd_he_lpbk.c
> index c7c5cda48c..df3b093157 100644
> --- a/drivers/raw/ifpga/afu_pmd_he_lpbk.c
> +++ b/drivers/raw/ifpga/afu_pmd_he_lpbk.c
> @@ -17,7 +17,6 @@
>  #include <rte_malloc.h>
>  #include <rte_memcpy.h>
>  #include <rte_io.h>
> -#include <rte_vfio.h>
>  #include <bus_pci_driver.h>
>  #include <bus_ifpga_driver.h>
>  #include <rte_rawdev.h>
> diff --git a/drivers/raw/ifpga/afu_pmd_he_mem.c
> b/drivers/raw/ifpga/afu_pmd_he_mem.c
> index a1db533eeb..b595cd729c 100644
> --- a/drivers/raw/ifpga/afu_pmd_he_mem.c
> +++ b/drivers/raw/ifpga/afu_pmd_he_mem.c
> @@ -16,7 +16,6 @@
>  #include <rte_malloc.h>
>  #include <rte_memcpy.h>
>  #include <rte_io.h>
> -#include <rte_vfio.h>
>  #include <bus_pci_driver.h>
>  #include <bus_ifpga_driver.h>
>  #include <rte_rawdev.h>
> diff --git a/drivers/raw/ifpga/afu_pmd_n3000.c
> b/drivers/raw/ifpga/afu_pmd_n3000.c
> index 0882a27701..ec2fdd46df 100644
> --- a/drivers/raw/ifpga/afu_pmd_n3000.c
> +++ b/drivers/raw/ifpga/afu_pmd_n3000.c
> @@ -13,11 +13,12 @@
>  #include <sys/eventfd.h>
>  #include <sys/ioctl.h>
> 
> +#include <linux/vfio.h>
> +
>  #include <rte_eal.h>
>  #include <rte_malloc.h>
>  #include <rte_memcpy.h>
>  #include <rte_io.h>
> -#include <rte_vfio.h>
>  #include <bus_pci_driver.h>
>  #include <bus_ifpga_driver.h>
>  #include <rte_rawdev.h>
> diff --git a/drivers/raw/ifpga/base/ifpga_feature_dev.c
> b/drivers/raw/ifpga/base/ifpga_feature_dev.c
> index 0a00af1b6b..3402ad97e4 100644
> --- a/drivers/raw/ifpga/base/ifpga_feature_dev.c
> +++ b/drivers/raw/ifpga/base/ifpga_feature_dev.c
> @@ -3,7 +3,7 @@
>   */
> 
>  #include <sys/ioctl.h>
> -#include <rte_vfio.h>
> +#include <linux/vfio.h>
> 
>  #include "ifpga_feature_dev.h"
> 
> diff --git a/drivers/vdpa/ifc/ifcvf_vdpa.c b/drivers/vdpa/ifc/ifcvf_vdpa.c
> index 65de383b95..c8e47e41c1 100644
> --- a/drivers/vdpa/ifc/ifcvf_vdpa.c
> +++ b/drivers/vdpa/ifc/ifcvf_vdpa.c
> @@ -11,6 +11,8 @@
>  #include <linux/virtio_net.h>
>  #include <stdbool.h>
> 
> +#include <linux/vfio.h>
> +
>  #include <rte_eal_paging.h>
>  #include <rte_malloc.h>
>  #include <rte_memory.h>
> diff --git a/drivers/vdpa/nfp/nfp_vdpa.c b/drivers/vdpa/nfp/nfp_vdpa.c
> index 7f2f21ec6c..c1ffbd1f91 100644
> --- a/drivers/vdpa/nfp/nfp_vdpa.c
> +++ b/drivers/vdpa/nfp/nfp_vdpa.c
> @@ -8,6 +8,8 @@
>  #include <sys/ioctl.h>
>  #include <unistd.h>
> 
> +#include <linux/vfio.h>
> +
>  #include <nfp_common_pci.h>
>  #include <nfp_dev.h>
>  #include <rte_vfio.h>
> diff --git a/drivers/vdpa/sfc/sfc_vdpa_ops.c
> b/drivers/vdpa/sfc/sfc_vdpa_ops.c index 00f9a4b04c..1ece47d373 100644
> --- a/drivers/vdpa/sfc/sfc_vdpa_ops.c
> +++ b/drivers/vdpa/sfc/sfc_vdpa_ops.c
> @@ -6,10 +6,11 @@
>  #include <unistd.h>
>  #include <sys/ioctl.h>
> 
> +#include <linux/vfio.h>
> +
>  #include <rte_errno.h>
>  #include <rte_malloc.h>
>  #include <rte_vdpa.h>
> -#include <rte_vfio.h>
>  #include <rte_vhost.h>
> 
>  #include <vdpa_driver.h>
> diff --git a/lib/eal/include/rte_vfio.h b/lib/eal/include/rte_vfio.h index
> 509ffec80c..683affa933 100644
> --- a/lib/eal/include/rte_vfio.h
> +++ b/lib/eal/include/rte_vfio.h
> @@ -19,17 +19,9 @@
>  extern "C" {
>  #endif
> 
> -#ifdef RTE_EXEC_ENV_LINUX
> -
> -#include <linux/vfio.h>
> -
> -#else /* ! RTE_EXEC_ENV_LINUX */
> -
>  /* we don't need an actual definition, only pointer is used */  struct
> vfio_device_info;
> 
> -#endif /* RTE_EXEC_ENV_LINUX */
> -
>  #define RTE_VFIO_DEFAULT_CONTAINER_FD (-1)
> 
>  /**
> diff --git a/lib/eal/linux/eal_interrupts.c b/lib/eal/linux/eal_interrupts.c
> index 43e05c86a2..d1789cbda2 100644
> --- a/lib/eal/linux/eal_interrupts.c
> +++ b/lib/eal/linux/eal_interrupts.c
> @@ -15,6 +15,8 @@
>  #include <assert.h>
>  #include <stdbool.h>
> 
> +#include <linux/vfio.h>
> +
>  #include <eal_export.h>
>  #include <eal_trace_internal.h>
>  #include <rte_common.h>
> @@ -28,7 +30,6 @@
>  #include <rte_errno.h>
>  #include <rte_spinlock.h>
>  #include <rte_pause.h>
> -#include <rte_vfio.h>
> 
>  #include "eal_private.h"
> 
> diff --git a/lib/eal/linux/eal_vfio.c b/lib/eal/linux/eal_vfio.c index
> c6aed44946..62f9d05e63 100644
> --- a/lib/eal/linux/eal_vfio.c
> +++ b/lib/eal/linux/eal_vfio.c
> @@ -8,6 +8,7 @@
>  #include <unistd.h>
>  #include <sys/ioctl.h>
>  #include <dirent.h>
> +#include <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