| 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 | extern int vfio_kvm_device_fd; |
| 16 | |
| 17 | struct vfio_info_cap_header * |
| 18 | vfio_get_cap(void *ptr, uint32_t cap_offset, uint16_t id); |
| 19 | struct vfio_info_cap_header * |
| 20 | vfio_get_device_info_cap(struct vfio_device_info *info, uint16_t id); |
| 21 | struct vfio_info_cap_header * |
| 22 | vfio_get_region_info_cap(struct vfio_region_info *info, uint16_t id); |
| 23 | struct vfio_info_cap_header * |
| 24 | vfio_get_iommu_type1_info_cap(struct vfio_iommu_type1_info *info, uint16_t id); |
| 25 | bool vfio_get_info_dma_avail(struct vfio_iommu_type1_info *info, |
| 26 | unsigned int *avail); |
| 27 | #endif |
| 28 | |
| 29 | int vfio_bitmap_alloc(VFIOBitmap *vbmap, hwaddr size); |
| 30 | struct vfio_device_info *vfio_get_device_info(int fd); |
| 31 | |
| 32 | int vfio_kvm_device_add_fd(int fd, Error **errp); |
| 33 | int vfio_kvm_device_del_fd(int fd, Error **errp); |
| 34 | |
| 35 | #endif /* HW_VFIO_VFIO_HELPERS_H */ |