[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 29/32] vfio: Add routine for finding VFIO_DEVICE_GET_INFO capabili
From: |
Alex Williamson |
Subject: |
[PULL 29/32] vfio: Add routine for finding VFIO_DEVICE_GET_INFO capabilities |
Date: |
Mon, 26 Oct 2020 13:36:28 -0600 |
User-agent: |
StGit/0.21-dirty |
From: Matthew Rosato <mjrosato@linux.ibm.com>
Now that VFIO_DEVICE_GET_INFO supports capability chains, add a helper
function to find specific capabilities in the chain.
Signed-off-by: Matthew Rosato <mjrosato@linux.ibm.com>
Reviewed-by: Cornelia Huck <cohuck@redhat.com>
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
---
hw/vfio/common.c | 10 ++++++++++
include/hw/vfio/vfio-common.h | 2 ++
2 files changed, 12 insertions(+)
diff --git a/hw/vfio/common.c b/hw/vfio/common.c
index 246adcdcaefa..5b369e15b381 100644
--- a/hw/vfio/common.c
+++ b/hw/vfio/common.c
@@ -1158,6 +1158,16 @@ vfio_get_iommu_type1_info_cap(struct
vfio_iommu_type1_info *info, uint16_t id)
return vfio_get_cap((void *)info, info->cap_offset, id);
}
+struct vfio_info_cap_header *
+vfio_get_device_info_cap(struct vfio_device_info *info, uint16_t id)
+{
+ if (!(info->flags & VFIO_DEVICE_FLAGS_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)
{
diff --git a/include/hw/vfio/vfio-common.h b/include/hw/vfio/vfio-common.h
index 8336f2e7ac19..a95ed7ced5dc 100644
--- a/include/hw/vfio/vfio-common.h
+++ b/include/hw/vfio/vfio-common.h
@@ -216,6 +216,8 @@ int vfio_get_dev_region_info(VFIODevice *vbasedev, uint32_t
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);
+struct vfio_info_cap_header *
+vfio_get_device_info_cap(struct vfio_device_info *info, uint16_t id);
#endif
extern const MemoryListener vfio_prereg_listener;
- [PULL 18/32] update-linux-headers: Add vfio_zdev.h, (continued)
- [PULL 18/32] update-linux-headers: Add vfio_zdev.h, Alex Williamson, 2020/10/26
- [PULL 20/32] s390x/pci: Move header files to include/hw/s390x, Alex Williamson, 2020/10/26
- [PULL 21/32] vfio: Create shared routine for scanning info capabilities, Alex Williamson, 2020/10/26
- [PULL 22/32] vfio: Find DMA available capability, Alex Williamson, 2020/10/26
- [PULL 23/32] s390x/pci: Add routine to get the vfio dma available count, Alex Williamson, 2020/10/26
- [PULL 24/32] s390x/pci: Honor DMA limits set by vfio, Alex Williamson, 2020/10/26
- [PULL 25/32] s390x/pci: create a header dedicated to PCI CLP, Alex Williamson, 2020/10/26
- [PULL 26/32] s390x/pci: use a PCI Group structure, Alex Williamson, 2020/10/26
- [PULL 27/32] s390x/pci: clean up s390 PCI groups, Alex Williamson, 2020/10/26
- [PULL 28/32] s390x/pci: use a PCI Function structure, Alex Williamson, 2020/10/26
- [PULL 29/32] vfio: Add routine for finding VFIO_DEVICE_GET_INFO capabilities,
Alex Williamson <=
- [PULL 30/32] s390x/pci: get zPCI function info from host, Alex Williamson, 2020/10/26
- [PULL 31/32] hw/vfio: Use lock guard macros, Alex Williamson, 2020/10/26
- [PULL 32/32] vfio: fix incorrect print type, Alex Williamson, 2020/10/26
- Re: [PULL 00/32] VFIO updates 2020-10-26 (for QEMU 5.2 soft-freeze), Peter Maydell, 2020/10/27
- Re: [PULL 00/32] VFIO updates 2020-10-26 (for QEMU 5.2 soft-freeze), Cornelia Huck, 2020/10/28