PCI (Linux)

Identity

Each device is identified by a
  • domain (0000 each domain can have 256 buses)
  • bus number (00)
  • device number (00)
  • function (0)

# update-pciids      #update pci ids

# lspci
 00:00.0 Host bridge: Intel ...

# lspci -tv
-[0000:00]-+-00.0  Intel Corporation ...
           +-01.0-[0000:01-06]----00.0  Intel Corporation 82574L Gigabit Network Connection

Address Spaces

  1. Configuration
  2. I/O
  3. Memory

SYSFS

The address spaces (config, io, memory) can be seen from the sysfs tree.

config

# lspci -s 00:1f.3 -x
00:1f.3 SMBus: Intel Corporation 6 Series/C200 Series Chipset Family SMBus Controller (rev 04)
00: 86 80 22 1c 03 00 80 02 04 00 05 0c 00 00 00 00
10: 04 60 52 c2 00 00 00 00 00 00 00 00 00 00 00 00
20: 41 40 00 00 00 00 00 00 00 00 00 00 86 80 22 1c
30: 00 00 00 00 00 00 00 00 00 00 00 00 0a 03 00 00

# od -x /sys/devices/pci0000:00/0000:00:1f.3/config
0000000 8086 1c22 0003 0280 0004 0c05 0000 0000
0000020 6004 c252 0000 0000 0000 0000 0000 0000
0000040 4041 0000 0000 0000 0000 0000 8086 1c22
0000060 0000 0000 0000 0000 0000 0000 030a 0000
0000100 0001 0000 0000 0000 0000 0000 0000 0000
0000120 0000 0000 0000 0000 0000 0000 0000 0000
0000140 0403 0004 0000 0808 0000 0000 0000 0000
0000160 0000 0000 0000 0000 0000 0000 0000 0000
0000200 0004 0000 0000 0000 0000 0000 0000 0000
0000220 0000 0000 0000 0000 0000 0000 0000 0000
*
0000360 0000 0000 0000 0000 0f87 0806 0000 0000

I/O and Memory

These can be mmap'ed

# ll /sys/devices/pci0000:00/0000:00:1f.3/resource*
-r--r--r-- 1 root root 4096 Jul  5 17:46 /sys/devices/pci0000:00/0000:00:1f.3/resource
-rw------- 1 root root  256 Jul  5 17:46 /sys/devices/pci0000:00/0000:00:1f.3/resource0
-rw------- 1 root root   32 Jul  5 17:46 /sys/devices/pci0000:00/0000:00:1f.3/resource4

# lspci -v
00:1f.3 SMBus: Intel Corporation 6 Series/C200 Series Chipset Family SMBus Controller (rev 04)
        Subsystem: Intel Corporation 6 Series/C200 Series Chipset Family SMBus Controller
        Flags: medium devsel, IRQ 201
        Memory at c2526000 (64-bit, non-prefetchable) [size=256]
        I/O ports at 4040 [size=32]

resource0 (BAR0) is the memory
resource4 (BAR4) is IO ports

Other Useful

Below is how you can find the driver used for the device

# lspci |grep Ether
00:19.0 Ethernet controller: Intel Corporation 82579LM 

# lspci -s 00:19.0 -n
00:19.0 0200: 8086:1502 (rev 04)

# grep 1502 /lib/modules/2.*/modules.pcimap
e1000e               0x00008086 0x00001502 0xffffffff 0xffffffff 0x00000000 0x00000000 0x0

No comments: