3,197 瀏覽數

Linux – lspci

在 Linux 使用 lspci 只要可以看到目前系統所有的裝置.

[root@benjr ~]# lspci
00:00.0 Host bridge: Intel Corporation 3200/3210 Chipset DRAM Controller (rev 01)
00:01.0 PCI bridge: Intel Corporation 3200/3210 Chipset Host-Primary PCI Express Bridge (rev 01)
00:1a.0 USB Controller: Intel Corporation 82801I (ICH9 Family) USB UHCI Controller #4 (rev 02)
00:1a.1 USB Controller: Intel Corporation 82801I (ICH9 Family) USB UHCI Controller #5 (rev 02)
00:1a.2 USB Controller: Intel Corporation 82801I (ICH9 Family) USB UHCI Controller #6 (rev 02)
00:1a.7 USB Controller: Intel Corporation 82801I (ICH9 Family) USB2 EHCI Controller #2 (rev 02)
00:1c.0 PCI bridge: Intel Corporation 82801I (ICH9 Family) PCI Express Port 5 (rev 02)
00:1c.1 PCI bridge: Intel Corporation 82801I (ICH9 Family) PCI Express Port 6 (rev 02)
00:1c.2 PCI bridge: Intel Corporation 82801I (ICH9 Family) PCI Express Port 1 (rev 02)
00:1d.0 USB Controller: Intel Corporation 82801I (ICH9 Family) USB UHCI Controller #1 (rev 02)
00:1d.1 USB Controller: Intel Corporation 82801I (ICH9 Family) USB UHCI Controller #2 (rev 02)
00:1d.2 USB Controller: Intel Corporation 82801I (ICH9 Family) USB UHCI Controller #3 (rev 02)
00:1d.7 USB Controller: Intel Corporation 82801I (ICH9 Family) USB2 EHCI Controller #1 (rev 02)
00:1e.0 PCI bridge: Intel Corporation 82801 PCI Bridge (rev 92)
00:1f.0 ISA bridge: Intel Corporation 82801IR (ICH9R) LPC Interface Controller (rev 02)
00:1f.2 IDE interface: Intel Corporation 82801IR/IO/IH (ICH9R/DO/DH) 4 port SATA IDE Controller (rev 02)
00:1f.3 SMBus: Intel Corporation 82801I (ICH9 Family) SMBus Controller (rev 02)
00:1f.5 IDE interface: Intel Corporation 82801I (ICH9 Family) 2 port SATA IDE Controller (rev 02)
03:00.0 Ethernet controller: Broadcom Corporation NetXtreme BCM5722 Gigabit Ethernet PCI Express
04:03.0 VGA compatible controller: ATI Technologies Inc ES1000 (rev 02)
0c:00.0 SCSI storage controller: LSI Logic / Symbios Logic SAS1064ET PCI-Express Fusion-MPT SAS (rev 02)

後面可以很清楚知道是裝置名稱,如果有裝置是 unknown 的,需要更新 /usr/share/hwdata/pci.ids 請參考更新方式 http://benjr.tw/265
不過這一次我要說明的是前面的 3 個數字是各代表什麼意思.如我系統上的 Network 裝置 03:00.0 Ethernet controller: Broadcom Corporation NetXtreme BCM5722 Gigabit Ethernet PCI Express
在 PCI 的裝置使用三個編號用來當作識別值,個別為 1. "匯流排(bus number)", 2. "裝置(device number) 以及 3. "功能(function number)".

所以剛剛的 03:00.0 就是 bus number = 03 ,device number = 00 function = 0 .

這3個編號會組合成一個 16-bits 的識別碼,

  1. 匯流排(bus number) 8bits 2^8 至多可連接 256 個匯流排(0 to ff),  
  2. 裝置(device number) 5bits 2^5 至多可接 32 種裝置(0 to 1f) 以及  
  3. 功能(function number) 3bits 2^3 至多每種裝置可有 8 項功能(0 to 7).

使用 lspci -vt 則可以看到這些 PCI 裝置的樹狀圖以及所使用的資源

[root@benjr ~]# lspci -vt
-[0000:00]-+-00.0  Intel Corporation 3200/3210 Chipset DRAM Controller
           +-01.0-[0000:06]–
           +-1a.0  Intel Corporation 82801I (ICH9 Family) USB UHCI Controller #4
           +-1a.1  Intel Corporation 82801I (ICH9 Family) USB UHCI Controller #5
           +-1a.2  Intel Corporation 82801I (ICH9 Family) USB UHCI Controller #6
           +-1a.7  Intel Corporation 82801I (ICH9 Family) USB2 EHCI Controller #2
           +-1c.0-[0000:09]–
           +-1c.1-[0000:03]—-00.0  Broadcom Corporation NetXtreme BCM5722 Gigabit Ethernet PCI Express
           +-1c.2-[0000:0c]—-00.0  LSI Logic / Symbios Logic SAS1064ET PCI-Express Fusion-MPT SAS
           +-1d.0  Intel Corporation 82801I (ICH9 Family) USB UHCI Controller #1
           +-1d.1  Intel Corporation 82801I (ICH9 Family) USB UHCI Controller #2
           +-1d.2  Intel Corporation 82801I (ICH9 Family) USB UHCI Controller #3
           +-1d.7  Intel Corporation 82801I (ICH9 Family) USB2 EHCI Controller #1
           +-1e.0-[0000:04]—-03.0  ATI Technologies Inc ES1000
           +-1f.0  Intel Corporation 82801IR (ICH9R) LPC Interface Controller
           +-1f.2  Intel Corporation 82801IR/IO/IH (ICH9R/DO/DH) 4 port SATA IDE Controller
           +-1f.3  Intel Corporation 82801I (ICH9 Family) SMBus Controller
           \-1f.5  Intel Corporation 82801I (ICH9 Family) 2 port SATA IDE Controller

不過在 Linux 使用 Class ID + Vendor ID + Device ID  來代表裝置,如剛剛的 03:00.0 Ethernet controller: Broadcom Corporation NetXtreme BCM5722 Gigabit Ethernet PCI Express 所代表裝置名稱為 (Class ID = 0200 ,Vendor ID = 14e4 ,Device ID =165a) .後面我們會透過 #lspci -n 就可以看到這三個名稱

  • 0200 : class 0200 表示是 "Network controller"
  • 14e4 : vendor ID 14e4 製造廠商 "Broadcom Corporation"
  • 165a : device ID 1659 產品名稱 "NetXtreme BCM5721 Gigabit Ethernet PCI Express"

透過 lspci 可以查到 PCI 的裝置識別值,1. "匯流排(bus number)", 2. "裝置(device number) 以及 3. "功能(function number)". 之後,我們可以透過 lspci -n 不同的參數來查到 Linux 所使用 Class ID + Vendor ID + Device ID   的裝置值.

[root@benjr ~]# lspci -n
00:00.0 0600: 8086:29f0 (rev 01)
00:01.0 0604: 8086:29f1 (rev 01)
00:1a.0 0c03: 8086:2937 (rev 02)
00:1a.1 0c03: 8086:2938 (rev 02)
00:1a.2 0c03: 8086:2939 (rev 02)
00:1a.7 0c03: 8086:293c (rev 02)
00:1c.0 0604: 8086:2948 (rev 02)
00:1c.1 0604: 8086:294a (rev 02)
00:1c.2 0604: 8086:2940 (rev 02)
00:1d.0 0c03: 8086:2934 (rev 02)
00:1d.1 0c03: 8086:2935 (rev 02)
00:1d.2 0c03: 8086:2936 (rev 02)
00:1d.7 0c03: 8086:293a (rev 02)
00:1e.0 0604: 8086:244e (rev 92)
00:1f.0 0601: 8086:2916 (rev 02)
00:1f.2 0106: 8086:2922 (rev 02)
00:1f.3 0c05: 8086:2930 (rev 02)
03:00.0 0200: 14e4:165a

04:03.0 0300: 1002:515e (rev 02)
09:00.0 0c04: 1077:2432 (rev 03)
09:00.1 0c04: 1077:2432 (rev 03)
0c:00.0 0100: 1000:0056 (rev 02)

參考文件 http://www.oreilly.com.tw/product_linux.php?id=a049_sample

5 個網友的想法 “Linux – lspci

  1. 自動參照通知: Linux – udev 網絡介面卡的順序 | Benjr.tw

  2. 自動參照通知: Hardware detection 檢視硬體資源 | Benjr.tw

  3. 自動參照通知: 硬體裝置 | Benjr.tw

  4. 看 Graphic card 的版本.

    [root@benjr ~]# lspci |grep –i VGA
    00:05.0 VGA compatible controller: ATI Technologies Inc ES1000 (rev 02)
    

    看 PCI-E/ PCI 的 bus 速度

    [root@benjr ~]# lspci –vv |grep –i Freq
    Freq=133MHz
    

    關於 PCI-E 的細項,請參考
    http://benjr.tw/10842

  5. 自動參照通知: Linux – lspci (PCI Express Gen 1 , 2 , 3) | Benjr.tw

發表迴響