diff mbox series

[1/5] pcie: add helper function to get number of VFs

Message ID 20221222114120.8790-2-sriram.yagnaraman@est.tech (mailing list archive)
State New, archived
Headers show
Series hw/net/igb: emulated network device with SR-IOV | expand

Commit Message

Sriram Yagnaraman Dec. 22, 2022, 11:41 a.m. UTC
Signed-off-by: Sriram Yagnaraman <sriram.yagnaraman@est.tech>
---
 hw/pci/pcie_sriov.c         | 6 ++++++
 include/hw/pci/pcie_sriov.h | 5 +++++
 2 files changed, 11 insertions(+)
diff mbox series

Patch

diff --git a/hw/pci/pcie_sriov.c b/hw/pci/pcie_sriov.c
index 8e3faf1f59..88ba642a20 100644
--- a/hw/pci/pcie_sriov.c
+++ b/hw/pci/pcie_sriov.c
@@ -300,3 +300,9 @@  PCIDevice *pcie_sriov_get_vf_at_index(PCIDevice *dev, int n)
     }
     return NULL;
 }
+
+int pcie_sriov_get_num_vfs(PCIDevice *dev)
+{
+    assert(!pci_is_vf(dev));
+    return dev->exp.sriov_pf.num_vfs;
+}
diff --git a/include/hw/pci/pcie_sriov.h b/include/hw/pci/pcie_sriov.h
index 80f5c84e75..8e9367a03a 100644
--- a/include/hw/pci/pcie_sriov.h
+++ b/include/hw/pci/pcie_sriov.h
@@ -74,4 +74,9 @@  PCIDevice *pcie_sriov_get_pf(PCIDevice *dev);
  */
 PCIDevice *pcie_sriov_get_vf_at_index(PCIDevice *dev, int n);
 
+/*
+ * Get the number of VFs created for this physical function.
+ */
+int pcie_sriov_get_num_vfs(PCIDevice *dev);
+
 #endif /* QEMU_PCIE_SRIOV_H */