[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v3 09/10] vfio: Add routine for finding VFIO_DEVICE_GET_INFO capa
From: |
Matthew Rosato |
Subject: |
[PATCH v3 09/10] vfio: Add routine for finding VFIO_DEVICE_GET_INFO capabilities |
Date: |
Wed, 7 Oct 2020 15:04:14 -0400 |
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>
---
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 e47a4d7..7cda9d2 100644
--- a/hw/vfio/common.c
+++ b/hw/vfio/common.c
@@ -849,6 +849,16 @@ vfio_get_region_info_cap(struct vfio_region_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);
+}
+
static int vfio_setup_region_sparse_mmaps(VFIORegion *region,
struct vfio_region_info *info)
{
diff --git a/include/hw/vfio/vfio-common.h b/include/hw/vfio/vfio-common.h
index c78f3ff..3c236ed 100644
--- a/include/hw/vfio/vfio-common.h
+++ b/include/hw/vfio/vfio-common.h
@@ -191,6 +191,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;
--
1.8.3.1
- [PATCH v3 02/10] vfio: Create shared routine for scanning info capabilities, (continued)
- [PATCH v3 02/10] vfio: Create shared routine for scanning info capabilities, Matthew Rosato, 2020/10/07
- [PATCH v3 03/10] update-linux-headers: Add vfio_zdev.h, Matthew Rosato, 2020/10/07
- [PATCH v3 04/10] linux-headers: update against 5.9-rc8, Matthew Rosato, 2020/10/07
- [PATCH v3 06/10] s390x/pci: use a PCI Group structure, Matthew Rosato, 2020/10/07
- [PATCH v3 05/10] s390x/pci: create a header dedicated to PCI CLP, Matthew Rosato, 2020/10/07
- [PATCH v3 07/10] s390x/pci: clean up s390 PCI groups, Matthew Rosato, 2020/10/07
- [PATCH v3 08/10] s390x/pci: use a PCI Function structure, Matthew Rosato, 2020/10/07
- [PATCH v3 09/10] vfio: Add routine for finding VFIO_DEVICE_GET_INFO capabilities,
Matthew Rosato <=
- [PATCH v3 10/10] s390x/pci: get zPCI function info from host, Matthew Rosato, 2020/10/07