mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-04 16:23:55 -06:00
pcie_sriov: Allow user to create SR-IOV device
A user can create a SR-IOV device by specifying the PF with the sriov-pf property of the VFs. The VFs must be added before the PF. A user-creatable VF must have PCIDeviceClass::sriov_vf_user_creatable set. Such a VF cannot refer to the PF because it is created before the PF. A PF that user-creatable VFs can be attached calls pcie_sriov_pf_init_from_user_created_vfs() during realization and pcie_sriov_pf_exit() when exiting. Signed-off-by: Akihiko Odaki <akihiko.odaki@daynix.com> Message-Id: <20240715-sriov-v5-5-3f5539093ffc@daynix.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
This commit is contained in:
parent
47cc753e50
commit
122173a583
4 changed files with 293 additions and 83 deletions
|
@ -18,6 +18,7 @@
|
|||
typedef struct PCIESriovPF {
|
||||
uint8_t vf_bar_type[PCI_NUM_REGIONS]; /* Store type for each VF bar */
|
||||
PCIDevice **vf; /* Pointer to an array of num_vfs VF devices */
|
||||
bool vf_user_created; /* If VFs are created by user */
|
||||
} PCIESriovPF;
|
||||
|
||||
typedef struct PCIESriovVF {
|
||||
|
@ -40,6 +41,23 @@ void pcie_sriov_pf_init_vf_bar(PCIDevice *dev, int region_num,
|
|||
void pcie_sriov_vf_register_bar(PCIDevice *dev, int region_num,
|
||||
MemoryRegion *memory);
|
||||
|
||||
/**
|
||||
* pcie_sriov_pf_init_from_user_created_vfs() - Initialize PF with user-created
|
||||
* VFs.
|
||||
* @dev: A PCIe device being realized.
|
||||
* @offset: The offset of the SR-IOV capability.
|
||||
* @errp: pointer to Error*, to store an error if it happens.
|
||||
*
|
||||
* Return: The size of added capability. 0 if the user did not create VFs.
|
||||
* -1 if failed.
|
||||
*/
|
||||
int16_t pcie_sriov_pf_init_from_user_created_vfs(PCIDevice *dev,
|
||||
uint16_t offset,
|
||||
Error **errp);
|
||||
|
||||
bool pcie_sriov_register_device(PCIDevice *dev, Error **errp);
|
||||
void pcie_sriov_unregister_device(PCIDevice *dev);
|
||||
|
||||
/*
|
||||
* Default (minimal) page size support values
|
||||
* as required by the SR/IOV standard:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue