| 1 | .. SPDX-License-Identifier: GPL-2.0-or-later |
| 2 | |
| 3 | Composable SR-IOV device |
| 4 | ======================== |
| 5 | |
| 6 | SR-IOV (Single Root I/O Virtualization) is an optional extended capability of a |
| 7 | PCI Express device. It allows a single physical function (PF) to appear as |
| 8 | multiple virtual functions (VFs) for the main purpose of eliminating software |
| 9 | overhead in I/O from virtual machines. |
| 10 | |
| 11 | There are devices with predefined SR-IOV configurations, but it is also possible |
| 12 | to compose an SR-IOV device yourself. Composing an SR-IOV device is currently |
| 13 | only supported by virtio-net-pci. |
| 14 | |
| 15 | Users can configure an SR-IOV-capable virtio-net device by adding |
| 16 | virtio-net-pci functions to a bus. Below is a command line example: |
| 17 | |
| 18 | .. code-block:: shell |
| 19 | |
| 20 | -netdev user,id=n -netdev user,id=o |
| 21 | -netdev user,id=p -netdev user,id=q |
| 22 | -device pcie-root-port,id=b |
| 23 | -device virtio-net-pci,bus=b,addr=0x0.0x3,netdev=q,sriov-pf=f |
| 24 | -device virtio-net-pci,bus=b,addr=0x0.0x2,netdev=p,sriov-pf=f |
| 25 | -device virtio-net-pci,bus=b,addr=0x0.0x1,netdev=o,sriov-pf=f |
| 26 | -device virtio-net-pci,bus=b,addr=0x0.0x0,netdev=n,id=f |
| 27 | |
| 28 | The VFs specify the paired PF with ``sriov-pf`` property. The PF must be |
| 29 | added after all VFs. It is the user's responsibility to ensure that VFs have |
| 30 | function numbers larger than one of the PF, and that the function numbers |
| 31 | have a consistent stride. Both the PF and VFs are ARI-capable so you can have |
| 32 | 255 VFs at maximum. |
| 33 | |
| 34 | You may also need to perform additional steps to activate the SR-IOV feature on |
| 35 | your guest. For Linux, refer to [1]_. |
| 36 | |
| 37 | .. [1] https://docs.kernel.org/PCI/pci-iov-howto.html |