PCIe enumeration for SR-IOV PCIe device
2017-01-04 22:44
281 查看
PCIe enumeration for SR-IOV PCIe device
-v0.1 2017.1.3 Sherlock init-v0.2 2017.1.4 Sherlock add part II
There are a lot things should be done in software to support PCIe SR-IOV.
Using qemu(for example) to use a VF, at least, we should:
host PCI subsystem finds VF and allocate resources for VF.
vfio driver exports VF’s configure space, MEM/IO range to user space.
vfio driver allocate DMA for VF by IOMMU.
vfio driver builds the interrupt flow for VF.
qemu vfio driver simulates PCIe device for guest kernel.
This document just tries to share an outline about point 1.
I. Parse VF/PF BARs
/* In PCI enumeration, once we find SR-IOV capability, sriov_init will be called */ pci_device_add --> pci_init_capabilities --> pci_iov_init /* parse sr-iov capability in pf, get bar sizef of vf */ --> sriov_init(struct pci_dev *dev, int pos) ... /* get bar_i size of vf */ --> __pci_read_base(dev, pci_bar_unknown, res, pos + PCI_SRIOV_BAR + i * 4); ... /* get bar_i size for all vf */ --> res->end = res->start + resource_size(res) * total - 1;
so at this step, we will see BAR0~BAR5, ROM_BAR, VF_BAR0~VF_BAR5…, the sizes
of them will be known. VF_BAR0 includes BAR0 in VF1,2,…. the resouces assignment
below will allocate resources for VF BARs ahead. Here all BAR0 in VF1,2… has
been seen as one block. you can see pci_enable_sriov below will directly assign
related BAR of certain VF to related pci_dev, as we already caculate and allocate
the resouces here.
/* * so if we get the size of bar of vf here, assignment will happen in standard * assignment in PCI subsystem. */ ...
/* * this function will be called in specific PCIe device driver. e.g. * drivers/net/ethernet/intel/ixgbe/ixgbe_sriov.c, when user in userspace triggers * vf by sysfs or loads modules with vf parameters. */ pci_enable_sriov --> sriov_enable(dev, nr_virtfn) --> pci_iov_add_virtfn ... /* * As we already got all VFs' BARs been assigned above, so here * just fill the BAR resource to each VF's pci_dev. */ --> virtfn->resource[i].start = res->start + size * id
II. Note:
1) BARs in PF/VF+--------------+ +-------->+----------+ | PF CFG | | | VF1 BAR0 | +--------------+ | | VF2 BAR0 | | PCI cfg head:| | | ... | | ... | | | VF5 BAR0 | | BAR0 ~ BAR5 | | +----------+ | ... | | +----->+----------+ +--------------+ | | | VF1 BAR1 | | SR-IOV cap: | | | | VF2 BAR1 | | ... | | | | ... | | VF BAR0 +----+ | | VF5 BAR1 | | VF BAR1 +-------+ +----------+ | ... | ... | VF BAR5 +------------->+----------+ +--------------+ | VF1 BAR5 | | VF2 BAR5 | | ... | | VF5 BAR5 | +----------+
相关文章推荐
- KVM 介绍(4):I/O 设备直接分配和 SR-IOV [KVM PCI/PCIe Pass-Through SR-IOV]
- KVM 介绍(4):I/O 设备直接分配和 SR-IOV [KVM PCI/PCIe Pass-Through SR-IOV]
- Setting up Red Hat 5.4 Xen for SR-IOV using the Intel 82576 GbE
- adb shell 无法启动 (insufficient permissions for device)
- 'default' is not a best match for any device/locale combination.
- SR-IOV Windows Server 2012 R2
- no device found for connection ‘ System eth0′
- Device Checks for ASM Fails with PRVF-5150: Path ORCL: is not a valid path(1210863.1)
- Error:No suitable device found: no device found for connection "System eth0"
- Error: No suitable device found: no device found for connection 'System eth0' 分类: Linux 2015-03-18 21:24 63人阅读 评论(0) 收藏
- 服务器上基于SR-IOV的IO虚拟化技术解读
- android源码编译出现No private recovery resources for TARGET_DEVICE解决方法
- adb shell 无法启动 (insufficient permissions for device)
- ubuntu android 设备识别 Setting up a Device for Development
- adb shell 无法启动 (insufficient permissions for device)
- Ubuntu下adb 显示insufficient permissions for device,或Eclipse中DDMS设备显示?????
- How to set up ADB for remote machine development and local device deployment
- 探讨I/O虚拟化技术:SR-IOV、MR-IOV、网卡等
- Problem:Ubuntu Give up waiting for root device
- 解决:no device found for connection ‘ System eth0′问题