[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL v2 26/47] pcie: Add a helper to the SR/IOV API
From: |
Michael S. Tsirkin |
Subject: |
[PULL v2 26/47] pcie: Add a helper to the SR/IOV API |
Date: |
Mon, 7 Mar 2022 05:02:39 -0500 |
From: Łukasz Gieryk <lukasz.gieryk@linux.intel.com>
Convenience function for retrieving the PCIDevice object of the N-th VF.
Signed-off-by: Łukasz Gieryk <lukasz.gieryk@linux.intel.com>
Reviewed-by: Knut Omang <knuto@ifi.uio.no>
Message-Id: <20220217174504.1051716-4-lukasz.maniak@linux.intel.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
include/hw/pci/pcie_sriov.h | 6 ++++++
hw/pci/pcie_sriov.c | 10 +++++++++-
2 files changed, 15 insertions(+), 1 deletion(-)
diff --git a/include/hw/pci/pcie_sriov.h b/include/hw/pci/pcie_sriov.h
index 990cff0a1c..80f5c84e75 100644
--- a/include/hw/pci/pcie_sriov.h
+++ b/include/hw/pci/pcie_sriov.h
@@ -68,4 +68,10 @@ uint16_t pcie_sriov_vf_number(PCIDevice *dev);
*/
PCIDevice *pcie_sriov_get_pf(PCIDevice *dev);
+/*
+ * Get the n-th VF of this physical function - only valid for PF.
+ * Returns NULL if index is invalid
+ */
+PCIDevice *pcie_sriov_get_vf_at_index(PCIDevice *dev, int n);
+
#endif /* QEMU_PCIE_SRIOV_H */
diff --git a/hw/pci/pcie_sriov.c b/hw/pci/pcie_sriov.c
index 3f256d483f..87abad6ac8 100644
--- a/hw/pci/pcie_sriov.c
+++ b/hw/pci/pcie_sriov.c
@@ -287,8 +287,16 @@ uint16_t pcie_sriov_vf_number(PCIDevice *dev)
return dev->exp.sriov_vf.vf_number;
}
-
PCIDevice *pcie_sriov_get_pf(PCIDevice *dev)
{
return dev->exp.sriov_vf.pf;
}
+
+PCIDevice *pcie_sriov_get_vf_at_index(PCIDevice *dev, int n)
+{
+ assert(!pci_is_vf(dev));
+ if (n < dev->exp.sriov_pf.num_vfs) {
+ return dev->exp.sriov_pf.vf[n];
+ }
+ return NULL;
+}
--
MST
- [PULL v2 14/47] vhost-vdpa: make notifiers _init()/_uninit() symmetric, (continued)
- [PULL v2 14/47] vhost-vdpa: make notifiers _init()/_uninit() symmetric, Michael S. Tsirkin, 2022/03/07
- [PULL v2 17/47] hw/i386: Replace magic number with field length calculation, Michael S. Tsirkin, 2022/03/07
- [PULL v2 16/47] hw/i386: Improve bounds checking in OVMF table parsing, Michael S. Tsirkin, 2022/03/07
- [PULL v2 18/47] virtio-iommu: Default to bypass during boot, Michael S. Tsirkin, 2022/03/07
- [PULL v2 19/47] virtio-iommu: Support bypass domain, Michael S. Tsirkin, 2022/03/07
- [PULL v2 21/47] hw/i386/pc_piix: Mark the machine types from version 1.4 to 1.7 as deprecated, Michael S. Tsirkin, 2022/03/07
- [PULL v2 22/47] hw/pci-bridge/pxb: Fix missing swizzle, Michael S. Tsirkin, 2022/03/07
- [PULL v2 23/47] virtio-net: Unlimit tx queue size if peer is vdpa, Michael S. Tsirkin, 2022/03/07
- [PULL v2 24/47] pcie: Add support for Single Root I/O Virtualization (SR/IOV), Michael S. Tsirkin, 2022/03/07
- [PULL v2 25/47] pcie: Add some SR/IOV API documentation in docs/pcie_sriov.txt, Michael S. Tsirkin, 2022/03/07
- [PULL v2 26/47] pcie: Add a helper to the SR/IOV API,
Michael S. Tsirkin <=
- [PULL v2 27/47] pcie: Add 1.2 version token for the Power Management Capability, Michael S. Tsirkin, 2022/03/07
- [PULL v2 28/47] pci-bridge/xio3130_upstream: Fix error handling, Michael S. Tsirkin, 2022/03/07
- [PULL v2 30/47] headers: Add pvpanic.h, Michael S. Tsirkin, 2022/03/07
- [PULL v2 29/47] pci-bridge/xio3130_downstream: Fix error handling, Michael S. Tsirkin, 2022/03/07
- [PULL v2 31/47] hw/misc/pvpanic: Use standard headers instead, Michael S. Tsirkin, 2022/03/07
- [PULL v2 33/47] pci: expose TYPE_XIO3130_DOWNSTREAM name, Michael S. Tsirkin, 2022/03/07
- [PULL v2 34/47] acpi: pcihp: pcie: set power on cap on parent slot, Michael S. Tsirkin, 2022/03/07
- [PULL v2 37/47] x86: cleanup unused compat_apic_id_mode, Michael S. Tsirkin, 2022/03/07
- [PULL v2 20/47] tests/qtest/virtio-iommu-test: Check bypass config, Michael S. Tsirkin, 2022/03/07
- [PULL v2 36/47] vhost-vsock: detach the virqueue element in case of error, Michael S. Tsirkin, 2022/03/07