tools/testing/selftests/vfio/lib/include/libvfio/iommu.h
Source file repositories/reference/linux-study-clean/tools/testing/selftests/vfio/lib/include/libvfio/iommu.h
File Facts
- System
- Linux kernel
- Corpus path
tools/testing/selftests/vfio/lib/include/libvfio/iommu.h- Extension
.h- Size
- 2417 bytes
- Lines
- 83
- Domain
- Support Tooling And Documentation
- Bucket
- tools
- Inferred role
- Support Tooling And Documentation: implementation source
- Status
- source implementation candidate
Why This File Exists
Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/list.hlinux/types.hlibvfio/assert.h
Detected Declarations
struct iommu_modestruct dma_regionstruct iommufunction iommu_mapfunction iommu_unmapfunction iommu_unmap_all
Annotated Snippet
struct iommu_mode {
const char *name;
const char *container_path;
unsigned long iommu_type;
};
extern const char *default_iommu_mode;
struct dma_region {
struct list_head link;
void *vaddr;
iova_t iova;
u64 size;
};
struct iommu {
const struct iommu_mode *mode;
int container_fd;
int iommufd;
u32 ioas_id;
struct list_head dma_regions;
};
struct iommu *iommu_init(const char *iommu_mode);
void iommu_cleanup(struct iommu *iommu);
int __iommu_map(struct iommu *iommu, struct dma_region *region);
static inline void iommu_map(struct iommu *iommu, struct dma_region *region)
{
VFIO_ASSERT_EQ(__iommu_map(iommu, region), 0);
}
int __iommu_unmap(struct iommu *iommu, struct dma_region *region, u64 *unmapped);
static inline void iommu_unmap(struct iommu *iommu, struct dma_region *region)
{
VFIO_ASSERT_EQ(__iommu_unmap(iommu, region, NULL), 0);
}
int __iommu_unmap_all(struct iommu *iommu, u64 *unmapped);
static inline void iommu_unmap_all(struct iommu *iommu)
{
VFIO_ASSERT_EQ(__iommu_unmap_all(iommu, NULL), 0);
}
int __iommu_hva2iova(struct iommu *iommu, void *vaddr, iova_t *iova);
iova_t iommu_hva2iova(struct iommu *iommu, void *vaddr);
struct iommu_iova_range *iommu_iova_ranges(struct iommu *iommu, u32 *nranges);
#define MODE_VFIO_TYPE1_IOMMU "vfio_type1_iommu"
#define MODE_VFIO_TYPE1V2_IOMMU "vfio_type1v2_iommu"
#define MODE_IOMMUFD_COMPAT_TYPE1 "iommufd_compat_type1"
#define MODE_IOMMUFD_COMPAT_TYPE1V2 "iommufd_compat_type1v2"
#define MODE_IOMMUFD "iommufd"
/*
* Generator for VFIO selftests fixture variants that replicate across all
* possible IOMMU modes. Tests must define FIXTURE_VARIANT_ADD_IOMMU_MODE()
* which should then use FIXTURE_VARIANT_ADD() to create the variant.
*/
#define FIXTURE_VARIANT_ADD_ALL_IOMMU_MODES(...) \
FIXTURE_VARIANT_ADD_IOMMU_MODE(vfio_type1_iommu, ##__VA_ARGS__); \
FIXTURE_VARIANT_ADD_IOMMU_MODE(vfio_type1v2_iommu, ##__VA_ARGS__); \
FIXTURE_VARIANT_ADD_IOMMU_MODE(iommufd_compat_type1, ##__VA_ARGS__); \
FIXTURE_VARIANT_ADD_IOMMU_MODE(iommufd_compat_type1v2, ##__VA_ARGS__); \
FIXTURE_VARIANT_ADD_IOMMU_MODE(iommufd, ##__VA_ARGS__)
#endif /* SELFTESTS_VFIO_LIB_INCLUDE_LIBVFIO_IOMMU_H */
Annotation
- Immediate include surface: `linux/list.h`, `linux/types.h`, `libvfio/assert.h`.
- Detected declarations: `struct iommu_mode`, `struct dma_region`, `struct iommu`, `function iommu_map`, `function iommu_unmap`, `function iommu_unmap_all`.
- Atlas domain: Support Tooling And Documentation / tools.
- Implementation status: source implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.