DPDK  18.02.0
rte_vfio.h
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2017 6WIND S.A.
3  */
4 
5 #ifndef _RTE_VFIO_H_
6 #define _RTE_VFIO_H_
7 
8 /*
9  * determine if VFIO is present on the system
10  */
11 #if !defined(VFIO_PRESENT) && defined(RTE_EAL_VFIO)
12 #include <linux/version.h>
13 #if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 6, 0)
14 #define VFIO_PRESENT
15 #endif /* kernel version >= 3.6.0 */
16 #endif /* RTE_EAL_VFIO */
17 
18 #ifdef VFIO_PRESENT
19 
20 #include <linux/vfio.h>
21 
22 #define VFIO_DIR "/dev/vfio"
23 #define VFIO_CONTAINER_PATH "/dev/vfio/vfio"
24 #define VFIO_GROUP_FMT "/dev/vfio/%u"
25 #define VFIO_NOIOMMU_GROUP_FMT "/dev/vfio/noiommu-%u"
26 #define VFIO_GET_REGION_ADDR(x) ((uint64_t) x << 40ULL)
27 #define VFIO_GET_REGION_IDX(x) (x >> 40)
28 #define VFIO_NOIOMMU_MODE \
29  "/sys/module/vfio/parameters/enable_unsafe_noiommu_mode"
30 
56 int rte_vfio_setup_device(const char *sysfs_base, const char *dev_addr,
57  int *vfio_dev_fd, struct vfio_device_info *device_info);
58 
78 int rte_vfio_release_device(const char *sysfs_base, const char *dev_addr, int fd);
79 
93 int rte_vfio_enable(const char *modname);
94 
108 int rte_vfio_is_enabled(const char *modname);
109 
120 int rte_vfio_noiommu_is_enabled(void);
121 
122 /* remove group fd from internal VFIO group fd array */
123 int
124 rte_vfio_clear_group(int vfio_group_fd);
125 
126 #endif /* VFIO_PRESENT */
127 
128 #endif /* _RTE_VFIO_H_ */