mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-06 17:23:56 -06:00
vfio: Move vfio_get_info_dma_avail() into helpers.c
vfio_get_info_dma_avail() is a low level routine similar to the other routines extracting capabilities from 'struct vfio_iommu_type1_info'. It belongs to file "helpers.c". Reviewed-by: John Levon <john.levon@nutanix.com> Link: https://lore.kernel.org/qemu-devel/20250318095415.670319-17-clg@redhat.com Reviewed-by: Zhenzhong Duan <zhenzhong.duan@intel.com> Link: https://lore.kernel.org/qemu-devel/20250326075122.1299361-18-clg@redhat.com Signed-off-by: Cédric Le Goater <clg@redhat.com>
This commit is contained in:
parent
ac28680d5e
commit
f6d7f5d02b
4 changed files with 35 additions and 34 deletions
|
@ -278,37 +278,6 @@ static int vfio_legacy_query_dirty_bitmap(const VFIOContainerBase *bcontainer,
|
|||
return ret;
|
||||
}
|
||||
|
||||
static struct vfio_info_cap_header *
|
||||
vfio_get_iommu_type1_info_cap(struct vfio_iommu_type1_info *info, uint16_t id)
|
||||
{
|
||||
if (!(info->flags & VFIO_IOMMU_INFO_CAPS)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return vfio_get_cap((void *)info, info->cap_offset, id);
|
||||
}
|
||||
|
||||
bool vfio_get_info_dma_avail(struct vfio_iommu_type1_info *info,
|
||||
unsigned int *avail)
|
||||
{
|
||||
struct vfio_info_cap_header *hdr;
|
||||
struct vfio_iommu_type1_info_dma_avail *cap;
|
||||
|
||||
/* If the capability cannot be found, assume no DMA limiting */
|
||||
hdr = vfio_get_iommu_type1_info_cap(info,
|
||||
VFIO_IOMMU_TYPE1_INFO_DMA_AVAIL);
|
||||
if (!hdr) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (avail != NULL) {
|
||||
cap = (void *) hdr;
|
||||
*avail = cap->avail;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool vfio_get_info_iova_range(struct vfio_iommu_type1_info *info,
|
||||
VFIOContainerBase *bcontainer)
|
||||
{
|
||||
|
|
|
@ -222,6 +222,37 @@ retry:
|
|||
return 0;
|
||||
}
|
||||
|
||||
struct vfio_info_cap_header *
|
||||
vfio_get_iommu_type1_info_cap(struct vfio_iommu_type1_info *info, uint16_t id)
|
||||
{
|
||||
if (!(info->flags & VFIO_IOMMU_INFO_CAPS)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return vfio_get_cap((void *)info, info->cap_offset, id);
|
||||
}
|
||||
|
||||
bool vfio_get_info_dma_avail(struct vfio_iommu_type1_info *info,
|
||||
unsigned int *avail)
|
||||
{
|
||||
struct vfio_info_cap_header *hdr;
|
||||
struct vfio_iommu_type1_info_dma_avail *cap;
|
||||
|
||||
/* If the capability cannot be found, assume no DMA limiting */
|
||||
hdr = vfio_get_iommu_type1_info_cap(info,
|
||||
VFIO_IOMMU_TYPE1_INFO_DMA_AVAIL);
|
||||
if (!hdr) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (avail != NULL) {
|
||||
cap = (void *) hdr;
|
||||
*avail = cap->avail;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
int vfio_get_dev_region_info(VFIODevice *vbasedev, uint32_t type,
|
||||
uint32_t subtype, struct vfio_region_info **info)
|
||||
{
|
||||
|
|
|
@ -18,7 +18,10 @@ struct vfio_info_cap_header *
|
|||
vfio_get_device_info_cap(struct vfio_device_info *info, uint16_t id);
|
||||
struct vfio_info_cap_header *
|
||||
vfio_get_region_info_cap(struct vfio_region_info *info, uint16_t id);
|
||||
|
||||
struct vfio_info_cap_header *
|
||||
vfio_get_iommu_type1_info_cap(struct vfio_iommu_type1_info *info, uint16_t id);
|
||||
bool vfio_get_info_dma_avail(struct vfio_iommu_type1_info *info,
|
||||
unsigned int *avail);
|
||||
#endif
|
||||
|
||||
int vfio_bitmap_alloc(VFIOBitmap *vbmap, hwaddr size);
|
||||
|
|
|
@ -147,8 +147,6 @@ int vfio_get_region_info(VFIODevice *vbasedev, int index,
|
|||
int vfio_get_dev_region_info(VFIODevice *vbasedev, uint32_t type,
|
||||
uint32_t subtype, struct vfio_region_info **info);
|
||||
bool vfio_has_region_cap(VFIODevice *vbasedev, int region, uint16_t cap_type);
|
||||
bool vfio_get_info_dma_avail(struct vfio_iommu_type1_info *info,
|
||||
unsigned int *avail);
|
||||
#endif
|
||||
|
||||
bool vfio_devices_all_dirty_tracking_started(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue