[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [RFC PATCH V2 04/10] Qemu/VFIO: Add vfio_find_free_cfg_reg(
From: |
Lan Tianyu |
Subject: |
[Qemu-devel] [RFC PATCH V2 04/10] Qemu/VFIO: Add vfio_find_free_cfg_reg() to find free PCI config space regs |
Date: |
Tue, 24 Nov 2015 21:35:21 +0800 |
This patch is to add ioctl wrap to find free PCI config sapce regs.
Signed-off-by: Lan Tianyu <address@hidden>
---
hw/vfio/pci.c | 19 +++++++++++++++++++
hw/vfio/pci.h | 2 ++
2 files changed, 21 insertions(+)
diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c
index 29845e3..d0354a0 100644
--- a/hw/vfio/pci.c
+++ b/hw/vfio/pci.c
@@ -2508,6 +2508,25 @@ static void vfio_check_af_flr(VFIOPCIDevice *vdev,
uint8_t pos)
}
}
+uint8_t vfio_find_free_cfg_reg(VFIOPCIDevice *vdev, int pos, uint8_t size)
+{
+ struct vfio_pci_cap_info reg_info = {
+ .argsz = sizeof(reg_info),
+ .offset = pos,
+ .index = VFIO_PCI_CAP_GET_FREE_REGION,
+ .size = size,
+ };
+ int ret;
+
+ ret = ioctl(vdev->vbasedev.fd, VFIO_GET_PCI_CAP_INFO, ®_info);
+ if (ret || reg_info.offset == 0) {
+ error_report("vfio: Failed to find free PCI config reg: %m\n");
+ return -EFAULT;
+ }
+
+ return reg_info.offset;
+}
+
static int vfio_add_std_cap(VFIOPCIDevice *vdev, uint8_t pos)
{
PCIDevice *pdev = &vdev->pdev;
diff --git a/hw/vfio/pci.h b/hw/vfio/pci.h
index 9f360bf..6083300 100644
--- a/hw/vfio/pci.h
+++ b/hw/vfio/pci.h
@@ -156,3 +156,5 @@ typedef struct VFIORomBlacklistEntry {
} VFIORomBlacklistEntry;
#define MSIX_CAP_LENGTH 12
+
+uint8_t vfio_find_free_cfg_reg(VFIOPCIDevice *vdev, int pos, uint8_t size);
--
1.9.3
- [Qemu-devel] [RFC PATCH V2 00/10] Qemu: Add live migration support for SRIOV NIC, Lan Tianyu, 2015/11/24
- [Qemu-devel] [RFC PATCH V2 01/10] Qemu/VFIO: Create head file pci.h to share data struct., Lan Tianyu, 2015/11/24
- [Qemu-devel] [RFC PATCH V2 02/10] Qemu/VFIO: Add new VFIO_GET_PCI_CAP_INFO ioctl cmd definition, Lan Tianyu, 2015/11/24
- [Qemu-devel] [RFC PATCH V2 03/10] Qemu/VFIO: Rework vfio_std_cap_max_size() function, Lan Tianyu, 2015/11/24
- [Qemu-devel] [RFC PATCH V2 04/10] Qemu/VFIO: Add vfio_find_free_cfg_reg() to find free PCI config space regs,
Lan Tianyu <=
- [Qemu-devel] [RFC PATCH V2 05/10] Qemu/VFIO: Expose PCI config space read/write and msix functions, Lan Tianyu, 2015/11/24
- [Qemu-devel] [RFC PATCH V2 07/10] Qemu: Add post_load_state() to run after restoring CPU state, Lan Tianyu, 2015/11/24
- [Qemu-devel] [RFC PATCH V2 06/10] Qemu/PCI: Add macros for faked PCI migration capability, Lan Tianyu, 2015/11/24
- [Qemu-devel] [RFC PATCH V2 08/10] Qemu: Add save_before_stop callback to run just before stopping VCPU during migration, Lan Tianyu, 2015/11/24
- [Qemu-devel] [RFC PATCH V2 09/10] Qemu/VFIO: Add SRIOV VF migration support, Lan Tianyu, 2015/11/24
- [Qemu-devel] [RFC PATCH V2 10/10] Qemu/VFIO: Misc change for enable migration with VFIO, Lan Tianyu, 2015/11/24
- Re: [Qemu-devel] [RFC PATCH V2 00/10] Qemu: Add live migration support for SRIOV NIC, Michael S. Tsirkin, 2015/11/30