Search code examples
linux-kernelpcipci-e

where function number is embedded for PCIE device


I have couple of doubts regarding PCIe device configuration, Generally a PCIe device is uniquely identify with BDF (BUS DEVICE FUNCTION), As per my understanding BUS number and DEVICE number is assigned during PCIe enumeration and Root Complex does this assignement but for the FUNCTION number, where is this information is coming, looking PCIe configuration space, none of register hold the FUNCTION number information?

Also, when I run lspci on my machine I get this output:

   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

I was expecting, Device number to be in specific order like, 00:00.0 and then 00:01:0, 00,02:0, 00:03:0 and so on... but what I see is 00:00.0, 00:02:0 and 00:14.0, why?


Solution

  • The function number isn't configurable; it is part of the internal implementation of the device. Since you have to use the function number as part of the address to read the configuration space of the function, there would be no point in providing a way to read the function number from the configuration space.

    The device numbers of devices on bus 0 are predefined by the implementation of the chipset (or the uncore in modern SoCs). Specific numbers have been selected for specific devices. For example, on Intel systems, an integrated graphics device is always 0:2.0 and 0:1a.0 is a USB controller. They have never been consecutive.