mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-21 17:11:57 -06:00
vfio: Introduce a new header file for helper services
Gather all helper routine declarations into "vfio-helpers.h" to reduce exposure of VFIO internals in "hw/vfio/vfio-common.h". Reviewed-by: John Levon <john.levon@nutanix.com> Link: https://lore.kernel.org/qemu-devel/20250318095415.670319-16-clg@redhat.com Reviewed-by: Zhenzhong Duan <zhenzhong.duan@intel.com> Link: https://lore.kernel.org/qemu-devel/20250326075122.1299361-17-clg@redhat.com Signed-off-by: Cédric Le Goater <clg@redhat.com>
This commit is contained in:
parent
5cf52416e4
commit
ac28680d5e
8 changed files with 32 additions and 7 deletions
|
@ -21,6 +21,7 @@
|
||||||
#include "hw/s390x/s390-pci-vfio.h"
|
#include "hw/s390x/s390-pci-vfio.h"
|
||||||
#include "hw/vfio/pci.h"
|
#include "hw/vfio/pci.h"
|
||||||
#include "hw/vfio/vfio-container.h"
|
#include "hw/vfio/vfio-container.h"
|
||||||
|
#include "hw/vfio/vfio-helpers.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Get the current DMA available count from vfio. Returns true if vfio is
|
* Get the current DMA available count from vfio. Returns true if vfio is
|
||||||
|
|
|
@ -44,6 +44,7 @@
|
||||||
#include "system/tcg.h"
|
#include "system/tcg.h"
|
||||||
#include "system/tpm.h"
|
#include "system/tpm.h"
|
||||||
#include "vfio-migration-internal.h"
|
#include "vfio-migration-internal.h"
|
||||||
|
#include "vfio-helpers.h"
|
||||||
|
|
||||||
VFIODeviceList vfio_device_list =
|
VFIODeviceList vfio_device_list =
|
||||||
QLIST_HEAD_INITIALIZER(vfio_device_list);
|
QLIST_HEAD_INITIALIZER(vfio_device_list);
|
||||||
|
|
|
@ -33,6 +33,7 @@
|
||||||
#include "qapi/error.h"
|
#include "qapi/error.h"
|
||||||
#include "pci.h"
|
#include "pci.h"
|
||||||
#include "hw/vfio/vfio-container.h"
|
#include "hw/vfio/vfio-container.h"
|
||||||
|
#include "vfio-helpers.h"
|
||||||
|
|
||||||
#define TYPE_HOST_IOMMU_DEVICE_LEGACY_VFIO TYPE_HOST_IOMMU_DEVICE "-legacy-vfio"
|
#define TYPE_HOST_IOMMU_DEVICE_LEGACY_VFIO TYPE_HOST_IOMMU_DEVICE "-legacy-vfio"
|
||||||
|
|
||||||
|
|
|
@ -30,6 +30,7 @@
|
||||||
#include "qemu/error-report.h"
|
#include "qemu/error-report.h"
|
||||||
#include "qemu/units.h"
|
#include "qemu/units.h"
|
||||||
#include "monitor/monitor.h"
|
#include "monitor/monitor.h"
|
||||||
|
#include "vfio-helpers.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Common VFIO interrupt disable
|
* Common VFIO interrupt disable
|
||||||
|
|
|
@ -45,6 +45,7 @@
|
||||||
#include "migration/qemu-file.h"
|
#include "migration/qemu-file.h"
|
||||||
#include "system/iommufd.h"
|
#include "system/iommufd.h"
|
||||||
#include "vfio-migration-internal.h"
|
#include "vfio-migration-internal.h"
|
||||||
|
#include "vfio-helpers.h"
|
||||||
|
|
||||||
#define TYPE_VFIO_PCI_NOHOTPLUG "vfio-pci-nohotplug"
|
#define TYPE_VFIO_PCI_NOHOTPLUG "vfio-pci-nohotplug"
|
||||||
|
|
||||||
|
|
|
@ -29,6 +29,7 @@
|
||||||
#include "qemu/error-report.h"
|
#include "qemu/error-report.h"
|
||||||
#include "qemu/units.h"
|
#include "qemu/units.h"
|
||||||
#include "monitor/monitor.h"
|
#include "monitor/monitor.h"
|
||||||
|
#include "vfio-helpers.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* IO Port/MMIO - Beware of the endians, VFIO is always little endian
|
* IO Port/MMIO - Beware of the endians, VFIO is always little endian
|
||||||
|
|
26
hw/vfio/vfio-helpers.h
Normal file
26
hw/vfio/vfio-helpers.h
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
/*
|
||||||
|
* VFIO helpers
|
||||||
|
*
|
||||||
|
* Copyright Red Hat, Inc. 2025
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef HW_VFIO_VFIO_HELPERS_H
|
||||||
|
#define HW_VFIO_VFIO_HELPERS_H
|
||||||
|
|
||||||
|
#ifdef CONFIG_LINUX
|
||||||
|
#include <linux/vfio.h>
|
||||||
|
|
||||||
|
struct vfio_info_cap_header *
|
||||||
|
vfio_get_cap(void *ptr, uint32_t cap_offset, uint16_t id);
|
||||||
|
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);
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
int vfio_bitmap_alloc(VFIOBitmap *vbmap, hwaddr size);
|
||||||
|
|
||||||
|
#endif /* HW_VFIO_VFIO_HELPERS_H */
|
|
@ -147,17 +147,10 @@ int vfio_get_region_info(VFIODevice *vbasedev, int index,
|
||||||
int vfio_get_dev_region_info(VFIODevice *vbasedev, uint32_t type,
|
int vfio_get_dev_region_info(VFIODevice *vbasedev, uint32_t type,
|
||||||
uint32_t subtype, struct vfio_region_info **info);
|
uint32_t subtype, struct vfio_region_info **info);
|
||||||
bool vfio_has_region_cap(VFIODevice *vbasedev, int region, uint16_t cap_type);
|
bool vfio_has_region_cap(VFIODevice *vbasedev, int region, uint16_t cap_type);
|
||||||
struct vfio_info_cap_header *
|
|
||||||
vfio_get_region_info_cap(struct vfio_region_info *info, uint16_t id);
|
|
||||||
bool vfio_get_info_dma_avail(struct vfio_iommu_type1_info *info,
|
bool vfio_get_info_dma_avail(struct vfio_iommu_type1_info *info,
|
||||||
unsigned int *avail);
|
unsigned int *avail);
|
||||||
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_cap(void *ptr, uint32_t cap_offset, uint16_t id);
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int vfio_bitmap_alloc(VFIOBitmap *vbmap, hwaddr size);
|
|
||||||
bool vfio_devices_all_dirty_tracking_started(
|
bool vfio_devices_all_dirty_tracking_started(
|
||||||
const VFIOContainerBase *bcontainer);
|
const VFIOContainerBase *bcontainer);
|
||||||
bool
|
bool
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue