Introduction to SR-IOV
文章目录
本文只介绍SR-IOV的基本内容,并不能cover SR-IOV的全部知识点。
1. prerequisites
- 需要理解VT-d的DMA remapping,interrupt remapping ,posted interrupt
- 需要理解PCI&PCIe的config space,MSI与MSI-X.
- 需要理解ATS,ACS,ARI
- Introduction to PCIe Address Translation Services
- Introduction to PCIe Access Control Services
- PCIe Alternative Routing-ID Interpretation (ARI)
- Enable up-to 256 functions for single PCI Express component
- PCIe config space位于MMIO空间内
2. motivation
推荐论文:High Performance Network Virtualization with SRIOV
可阅读Junming’s notes。
3. details
BIOS should be able to enumerate SR-IOV capable device and allocate MMIO (Memory mapped IO) resource for VFs.
SR-IOV Extended Capability The SR-IOV Extended Capability defined here is a PCIe extended capability that must be implemented in each PF device that supports the SR-IOV feature. This capability is used to describe and control a PF’s SR-IOV capabilities.
3.1 the differences between a normal passthrough device and SR-IOV VF device
- physical device detection
The hypervisor uses Subsystem Vendor ID
to detect the SR-IOV VF physical device instead of Vendor ID
since no valid Vendor ID
exists for the SR-IOV VF physical device.
- BARs initialization
The VF BARs are initialized by its associated PF’s SR-IOV capabilities, not PCI standard BAR registers.
- MSI-X initialization
The MSI-X mapping base address is also from the PF’s SR-IOV capabilities, not PCI standard BAR registers.
3.2 VF的bdf number如何分配
Routing ID就是BDF number,即采用Bus Number、Device Number和Function Number来确定目标设备的位置的id。
SR-IOV Extended Capability中用FirstVF Offset和VF Stride来标记VF的Routing ID。VF的Routing ID是以PF的Routing ID值为参考来计算的。
FirstVF Offset:第一个VF相对PF的Routing ID的偏移量
VF Stride: 相邻VF之间的Routing ID的偏移量
PF的Routing ID在PF枚举之后就已经分配好了。PF的驱动程序通过配置SR-IOV Extended Capability,打开这个PF关联的VF之后,通过FirstVF Offset和VF Stride就能计算出VF们的Routing ID。
3.3 VF的BAR空间如何分配
VF的BAR[n]空间是通过PF的SR-IOV Capability中每个VF_BAR[n]来分配的,和VF Configuration Space的BAR无关。
3.4 ACRN Enable SR-IOV Virtualization
建议阅读ACRN Enable SR-IOV Virtualization。😊
参考资料: