我对PCIe设备配置有几个疑问,通常PCIe设备是用BDF(总线设备功能(唯一标识的,根据我的理解,总线编号和设备编号是在PCIe枚举期间分配的,Root Complex会进行此分配,但对于FUNCTION编号,此信息来自哪里,查看PCIe配置空间,寄存器中没有一个保存FUNCTION编号信息?
此外,当我在机器上运行lspci时,我会得到以下输出:
00:00.0 Host bridge: Intel Corporation 3rd Gen Core processor DRAM Controller (rev 09)
Subsystem: Lenovo 3rd Gen Core processor DRAM Controller
Control: I/O- Mem+ BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR- FastB2B- DisINTx-
Status: Cap+ 66MHz- UDF- FastB2B+ ParErr- DEVSEL=fast >TAbort- <TAbort- <MAbort+ >SERR- <PERR- INTx-
Latency: 0
Capabilities: <access denied>
Kernel driver in use: ivb_uncore
00:02.0 VGA compatible controller: Intel Corporation 3rd Gen Core processor Graphics Controller (rev 09) (prog-if 00 [VGA controller])
Subsystem: Lenovo 3rd Gen Core processor Graphics Controller
Control: I/O+ Mem+ BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR- FastB2B- DisINTx+
Status: Cap+ 66MHz- UDF- FastB2B+ ParErr- DEVSEL=fast >TAbort- <TAbort- <MAbort- >SERR- <PERR- INTx-
Latency: 0
Interrupt: pin A routed to IRQ 29
Region 0: Memory at f0000000 (64-bit, non-prefetchable) [size=4M]
Region 2: Memory at e0000000 (64-bit, prefetchable) [size=256M]
Region 4: I/O ports at 6000 [size=64]
[virtual] Expansion ROM at 000c0000 [disabled] [size=128K]
Capabilities: <access denied>
Kernel driver in use: i915
Kernel modules: i915
00:14.0 USB controller: Intel Corporation 7 Series/C210 Series Chipset Family USB xHCI Host Controller (rev 04) (prog-if 30 [XHCI])
Subsystem: Lenovo 7 Series/C210 Series Chipset Family USB xHCI Host Controller
Control: I/O- Mem+ BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR- FastB2B- DisINTx+
Status: Cap+ 66MHz- UDF- FastB2B+ ParErr- DEVSEL=medium >TAbort- <TAbort- <MAbort- >SERR- <PERR- INTx-
Latency: 0
Interrupt: pin A routed to IRQ 26
Region 0: Memory at f2520000 (64-bit, non-prefetchable) [size=64K]
Capabilities: <access denied>
Kernel driver in use: xhci_hcd
我原以为,设备编号会按照特定的顺序排列,比如00:00.0,然后是00:01:0、00,02:0、00:03:0等等……但我看到的是00:00.0、00:02:0和00:14.0,为什么?
函数编号不可配置;它是设备内部实现的一部分。由于必须使用函数号作为地址的一部分来读取函数的配置空间,因此提供从配置空间读取函数号的方法毫无意义。
总线0上的设备的设备编号是通过芯片组(或现代SoC中的uncore(的实现来预定义的。已为特定设备选择了特定编号。例如,在英特尔系统上,集成图形设备始终为0:2.0,0:1a。0是USB控制器。它们从来都不是连续的。