qemu-devel
[Top][All Lists]
Advanced

[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, &reg_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




reply via email to

[Prev in Thread] Current Thread [Next in Thread]