xref: /linux/tools/testing/selftests/vfio/lib/include/libvfio/iova_allocator.h (revision 349bd28a86f2bc33b8c61f6cc7886f45d5c7cda7)
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 #ifndef SELFTESTS_VFIO_LIB_INCLUDE_LIBVFIO_IOVA_ALLOCATOR_H
3 #define SELFTESTS_VFIO_LIB_INCLUDE_LIBVFIO_IOVA_ALLOCATOR_H
4 
5 #include <linux/list.h>
6 #include <linux/types.h>
7 #include <linux/iommufd.h>
8 
9 #include <libvfio/iommu.h>
10 
11 struct iova_allocator {
12 	struct iommu_iova_range *ranges;
13 	u32 nranges;
14 	u32 range_idx;
15 	u64 range_offset;
16 };
17 
18 struct iova_allocator *iova_allocator_init(struct iommu *iommu);
19 void iova_allocator_cleanup(struct iova_allocator *allocator);
20 iova_t iova_allocator_alloc(struct iova_allocator *allocator, size_t size);
21 
22 #endif /* SELFTESTS_VFIO_LIB_INCLUDE_LIBVFIO_IOVA_ALLOCATOR_H */
23