virtio-net: add support for SR-IOV emulation
Get series with b4
b4 am [email protected] change-id 20231202-sriov-9402fb262be8Versions newest first
- v9 Latest9 patches 4 repliesIn review
- v89 patches 1 replySuperseded
- v79 patches 2 repliesSuperseded
Earlier versions · 6
| Version | Posted | Patches | Replies | Status |
|---|---|---|---|---|
| v6 | 9 patches | 0 replies | Superseded | |
| v5 | 8 patches | 6 replies | Superseded | |
| v4 RFC | 7 patches | 5 replies | Superseded | |
| v3 RFC | 6 patches | 1 reply | Superseded | |
| v2 RFC | 12 patches | 10 replies | Superseded | |
| v1 | 14 patches | 2 replies | Superseded |
Changes in v9 from the cover letter
- Rebased.
- Link to v8: https://lore.kernel.org/r/[email protected]
Patches in v9 No applies recorded yet
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/9 | hw/pci: Do not add ROM BAR for SR-IOV VFhw/ | +8 | 0 replies | |
| 2/9 | hw/pci: Fix SR-IOV VF number calculationhw/ | +5 | 0 replies | |
| 3/9 | pcie_sriov: Ensure PF and VF are mutually exclusivehw/ | +5 | 0 replies | |
| 4/9 | pcie_sriov: Check PCI Express for SR-IOV PFhw/ | +5 | 0 replies | |
| 5/9 | pcie_sriov: Allow user to create SR-IOV devicehw/ hw/ include/ +1 more | +286 | 0 replies | |
| 6/9 | virtio-pci: Implement SR-IOV PFhw/ include/ | +16 | 0 replies | |
| 7/9 | virtio-net: Implement SR-IOV VFhw/ | +1 | 0 replies | |
| 8/9 | docs: Document composable SR-IOV deviceMAINTAINERS docs/ docs/ | +38 | 0 replies | |
| 9/9 | pcie_sriov: Make a PCI device with user-created VF ARI-capabledocs/ hw/ hw/ +1 more | +24 | 0 replies |
Reviews trailers per patch
None of the 9 patches has a Reviewed-by or Acked-by.
| Patch | Your Name | Yui Washizu | Pasha Tatashin |
|---|---|---|---|
| Series | T-b | T-b | T-b |
| 1/9 | |||
| 2/9 | |||
| 3/9 | |||
| 4/9 | |||
| 5/9 | |||
| 6/9 | |||
| 7/9 | |||
| 8/9 | |||
| 9/9 |
Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes. Scroll the table sideways for all 3 reviewers.
Cover letter [PATCH for-10.1 v9 0/9] virtio-net: add support for SR-IOV emulation
Based-on: <[email protected]> ("[PATCH v18 00/14] hw/pci: SR-IOV related fixes and improvements")
Introduction
------------
This series is based on the RFC series submitted by Yui Washizu[1]. See also [2] for the context.
This series enables SR-IOV emulation for virtio-net. It is useful to test SR-IOV support on the guest, or to expose several vDPA devices in a VM. vDPA devices can also provide L2 switching feature for offloading though it is out of scope to allow the guest to configure such a feature.
The PF side code resides in virtio-pci. The VF side code resides in the PCI common infrastructure, but it is restricted to work only for virtio-net-pci because of lack of validation.
User Interface
--------------
A user can configure a SR-IOV capable virtio-net device by adding virtio-net-pci functions to a bus. Below is a command line example:
-netdev user,id=n -netdev user,id=o
-netdev user,id=p -netdev user,id=q
-device pcie-root-port,id=b
-device virtio-net-pci,bus=b,addr=0x0.0x3,netdev=q,sriov-pf=f -device virtio-net-pci,bus=b,addr=0x0.0x2,netdev=p,sriov-pf=f -device virtio-net-pci,bus=b,addr=0x0.0x1,netdev=o,sriov-pf=f -device virtio-net-pci,bus=b,addr=0x0.0x0,netdev=n,id=f
The VFs specify the paired PF with "sriov-pf" property. The PF must be added after all VFs. It is user's responsibility to ensure that VFs have function numbers larger than one of the PF, and the function numbers have a consistent stride.
Keeping VF instances
--------------------
A problem with SR-IOV emulation is that it needs to hotplug the VFs as the guest requests. Previously, this behavior was implemented by realizing and unrealizing VFs at runtime. However, this strategy does not work well for the proposed virtio-net emulation; in this proposal, device options passed in the command line must be maintained as VFs are hotplugged, but they are consumed when the machine starts and not available after that, which makes realizing VFs at runtime impossible.
As an strategy alternative to runtime realization/unrealization, this series proposes to reuse the code to power down PCI Express devices. When a PCI Express device is powered down, it will be hidden from the guest but will be kept realized. This effectively implements the behavior we need for the SR-IOV emulation.
Summary
-------
Patch 1 disables ROM BAR, which virtio-net-pci enables by default, for VFs.
Patch 2 makes zero stride valid for 1 VF configuration. Patch 3 and 4 adds validations.
Patch 5 adds user-created SR-IOV VF infrastructure.
Patch 6 makes virtio-pci work as SR-IOV PF for user-created VFs. Patch 7 allows user to create SR-IOV VFs with virtio-net-pci.
[1] https://patchew.org/QEMU/[email protected]/
[2] https://lore.kernel.org/all/[email protected]/
---
Changes in v9:
- Rebased.
- Link to v8: https://lore.kernel.org/r/[email protected]
Changes in v8:
- Rebased.
- Link to v7: https://lore.kernel.org/r/[email protected]
Changes in v7:
- Removed #include <error-report.h>, which is no longer needed.
- Rebased.
- Link to v6: https://lore.kernel.org/r/[email protected]
Changes in v6:
- Added ARI extended capability.
- Rebased.
- Link to v5: https://lore.kernel.org/r/[email protected]
Changes in v5:
- Dropped the RFC tag.
- Fixed device unrealization.
- Rebased.
- Link to v4: https://lore.kernel.org/r/[email protected]
Changes in v4:
- Added patch "hw/pci: Fix SR-IOV VF number calculation" to fix division by zero reported by Yui Washizu.
- Rebased.
- Link to v3: https://lore.kernel.org/r/[email protected]
Changes in v3:
- Rebased.
- Link to v2: https://lore.kernel.org/r/[email protected]
Changes in v2:
- Changed to keep VF instances.
- Link to v1: https://lore.kernel.org/r/[email protected]
---
Akihiko Odaki (9):
hw/pci: Do not add ROM BAR for SR-IOV VF
hw/pci: Fix SR-IOV VF number calculation
pcie_sriov: Ensure PF and VF are mutually exclusive
pcie_sriov: Check PCI Express for SR-IOV PF
pcie_sriov: Allow user to create SR-IOV device
virtio-pci: Implement SR-IOV PF
virtio-net: Implement SR-IOV VF
docs: Document composable SR-IOV device
pcie_sriov: Make a PCI device with user-created VF ARI-capable
MAINTAINERS | 1 + docs/system/index.rst | 1 + docs/system/sriov.rst | 37 ++++++ include/hw/pci/pci_device.h | 6 +- include/hw/pci/pcie_sriov.h | 21 +++ include/hw/virtio/virtio-pci.h | 1 + hw/pci/pci.c | 76 +++++++---- hw/pci/pcie_sriov.c | 294 +++++++++++++++++++++++++++++++++-------- hw/virtio/virtio-net-pci.c | 1 + hw/virtio/virtio-pci.c | 24 +++- 10 files changed, 378 insertions(+), 84 deletions(-)
---
base-commit: 825b96dbcee23d134b691fc75618b59c5f53da32
change-id: 20231202-sriov-9402fb262be8
Best regards,
Signature · 1 line
Akihiko Odaki <[email protected]>