[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 21/32] vfio: Create shared routine for scanning info capabilities
From: |
Alex Williamson |
Subject: |
[PULL 21/32] vfio: Create shared routine for scanning info capabilities |
Date: |
Mon, 26 Oct 2020 13:35:30 -0600 |
User-agent: |
StGit/0.21-dirty |
From: Matthew Rosato <mjrosato@linux.ibm.com>
Rather than duplicating the same loop in multiple locations,
create a static function to do the work.
Signed-off-by: Matthew Rosato <mjrosato@linux.ibm.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Reviewed-by: Cornelia Huck <cohuck@redhat.com>
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
---
hw/vfio/common.c | 21 +++++++++++++--------
1 file changed, 13 insertions(+), 8 deletions(-)
diff --git a/hw/vfio/common.c b/hw/vfio/common.c
index 56f6fee66a55..3714f8bcb84e 100644
--- a/hw/vfio/common.c
+++ b/hw/vfio/common.c
@@ -1124,17 +1124,12 @@ static void vfio_listener_release(VFIOContainer
*container)
}
}
-struct vfio_info_cap_header *
-vfio_get_region_info_cap(struct vfio_region_info *info, uint16_t id)
+static struct vfio_info_cap_header *
+vfio_get_cap(void *ptr, uint32_t cap_offset, uint16_t id)
{
struct vfio_info_cap_header *hdr;
- void *ptr = info;
- if (!(info->flags & VFIO_REGION_INFO_FLAG_CAPS)) {
- return NULL;
- }
-
- for (hdr = ptr + info->cap_offset; hdr != ptr; hdr = ptr + hdr->next) {
+ for (hdr = ptr + cap_offset; hdr != ptr; hdr = ptr + hdr->next) {
if (hdr->id == id) {
return hdr;
}
@@ -1143,6 +1138,16 @@ vfio_get_region_info_cap(struct vfio_region_info *info,
uint16_t id)
return NULL;
}
+struct vfio_info_cap_header *
+vfio_get_region_info_cap(struct vfio_region_info *info, uint16_t id)
+{
+ if (!(info->flags & VFIO_REGION_INFO_FLAG_CAPS)) {
+ return NULL;
+ }
+
+ return vfio_get_cap((void *)info, info->cap_offset, id);
+}
+
static int vfio_setup_region_sparse_mmaps(VFIORegion *region,
struct vfio_region_info *info)
{
- [PULL 11/32] vfio: Get migration capability flags for container, (continued)
- [PULL 11/32] vfio: Get migration capability flags for container, Alex Williamson, 2020/10/26
- [PULL 12/32] vfio: Add function to start and stop dirty pages tracking, Alex Williamson, 2020/10/26
- [PULL 13/32] vfio: Add vfio_listener_log_sync to mark dirty pages, Alex Williamson, 2020/10/26
- [PULL 14/32] vfio: Dirty page tracking when vIOMMU is enabled, Alex Williamson, 2020/10/26
- [PULL 15/32] vfio: Add ioctl to get dirty pages bitmap during dma unmap, Alex Williamson, 2020/10/26
- [PULL 16/32] vfio: Make vfio-pci device migration capable, Alex Williamson, 2020/10/26
- [PULL 17/32] qapi: Add VFIO devices migration stats in Migration stats, Alex Williamson, 2020/10/26
- [PULL 19/32] linux-headers: update against 5.10-rc1, Alex Williamson, 2020/10/26
- [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 <=
- [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, 2020/10/26
- [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