xref: /qemu/hw/vfio/vfio-helpers.h (revision 005b8d10450d2d41e9c1bcf8da4085f23cb85b76)
1 /*
2  * VFIO helpers
3  *
4  * Copyright Red Hat, Inc. 2025
5  *
6  * SPDX-License-Identifier: GPL-2.0-or-later
7  */
8 
9 #ifndef HW_VFIO_VFIO_HELPERS_H
10 #define HW_VFIO_VFIO_HELPERS_H
11 
12 #ifdef CONFIG_LINUX
13 #include <linux/vfio.h>
14 
15 struct vfio_info_cap_header *
16 vfio_get_cap(void *ptr, uint32_t cap_offset, uint16_t id);
17 struct vfio_info_cap_header *
18 vfio_get_device_info_cap(struct vfio_device_info *info, uint16_t id);
19 struct vfio_info_cap_header *
20 vfio_get_region_info_cap(struct vfio_region_info *info, uint16_t id);
21 struct vfio_info_cap_header *
22 vfio_get_iommu_type1_info_cap(struct vfio_iommu_type1_info *info, uint16_t id);
23 bool vfio_get_info_dma_avail(struct vfio_iommu_type1_info *info,
24                              unsigned int *avail);
25 #endif
26 
27 int vfio_bitmap_alloc(VFIOBitmap *vbmap, hwaddr size);
28 struct vfio_device_info *vfio_get_device_info(int fd);
29 
30 int vfio_kvm_device_add_fd(int fd, Error **errp);
31 int vfio_kvm_device_del_fd(int fd, Error **errp);
32 
33 #endif /* HW_VFIO_VFIO_HELPERS_H */
34