Debug PCIe Issues using lspci and setpci

Các lệnh lspci và setpci có sẵn trong các bản phân phối Linux. Lệnh này có nhiều mức đầu ra khác nhau và cung cấp một cái nhìn theo thời gian rất hữu ích về khả năng và trạng thái của các thành phần khác nhau được đào tạo trên bus PCI. 

Hầu hết các khả năng này là phản ánh của các thanh ghi Không gian cấu hình theo yêu cầu của Đặc điểm kỹ thuật cơ sở PCI-Express. Như với hầu hết các lệnh, có thể tìm thấy hướng dẫn sử dụng bằng cách chạy “lspci –help” hoặc “man lspci”, trong Linux.  

lspci

Mặc định sẽ hiển thị toàn bộ thông tin

[root@sv1 ~]# lspci
00:00.0 Host bridge: Intel Corporation Xeon E5/Core i7 DMI2 (rev 06)
00:01.0 PCI bridge: Intel Corporation Xeon E5/Core i7 IIO PCI Express Root Port 1a (rev 06)
00:01.1 PCI bridge: Intel Corporation Xeon E5/Core i7 IIO PCI Express Root Port 1b (rev 06)
00:02.0 PCI bridge: Intel Corporation Xeon E5/Core i7 IIO PCI Express Root Port 2a (rev 06)
00:02.1 PCI bridge: Intel Corporation Xeon E5/Core i7 IIO PCI Express Root Port 2b (rev 06)
00:02.2 PCI bridge: Intel Corporation Xeon E5/Core i7 IIO PCI Express Root Port 2c (rev 06)
00:02.3 PCI bridge: Intel Corporation Xeon E5/Core i7 IIO PCI Express Root Port 2d (rev 06)
00:03.0 PCI bridge: Intel Corporation Xeon E5/Core i7 IIO PCI Express Root Port 3a in PCI Express Mode (rev 06)
00:03.1 PCI bridge: Intel Corporation Xeon E5/Core i7 IIO PCI Express Root Port 3b (rev 06)
00:03.2 PCI bridge: Intel Corporation Xeon E5/Core i7 IIO PCI Express Root Port 3c (rev 06)
00:03.3 PCI bridge: Intel Corporation Xeon E5/Core i7 IIO PCI Express Root Port 3d (rev 06)
00:04.0 System peripheral: Intel Corporation Xeon E5/Core i7 DMA Channel 0 (rev 06)
00:04.1 System peripheral: Intel Corporation Xeon E5/Core i7 DMA Channel 1 (rev 06)
00:04.2 System peripheral: Intel Corporation Xeon E5/Core i7 DMA Channel 2 (rev 06)
00:04.3 System peripheral: Intel Corporation Xeon E5/Core i7 DMA Channel 3 (rev 06)
00:04.4 System peripheral: Intel Corporation Xeon E5/Core i7 DMA Channel 4 (rev 06)
00:04.5 System peripheral: Intel Corporation Xeon E5/Core i7 DMA Channel 5 (rev 06)
00:04.6 System peripheral: Intel Corporation Xeon E5/Core i7 DMA Channel 6 (rev 06)
00:04.7 System peripheral: Intel Corporation Xeon E5/Core i7 DMA Channel 7 (rev 06)
00:05.0 System peripheral: Intel Corporation Xeon E5/Core i7 Address Map, VTd_Misc, System Management (rev 06)
00:05.2 System peripheral: Intel Corporation Xeon E5/Core i7 Control Status and Global Errors (rev 06)

lspci -tv

Lệnh này hiển thị các thiết bị PCI ở định dạng cây và cung cấp số hiệu BDF (Bus, Device, Function) của cổng gốc.

Trong kết quả card 10 Gb được kết nối tới bus 00 , device number 01 và Function number 0

lspci -vvv

Lệnh này hiển thị thông tin chi tiết

lspci -vvvs <BDF>

Lệnh này hiển thị thông tin tương tự

Kiểm tra độ rộng liên kết PCIe

Kiểm tra tốc độ PCIe

Checking PCIe Max Payload Size (MPS)

Checking PCIe Max Read Request Size

Listing all PCIe Devices

setpci

Lệnh setpci có thể được sử dụng để đọc và ghi vào các thanh ghi cấu hình. Xem “setpci –help” để biết thông tin chi tiết về các tính năng của setpci.

Ví dụ:

Kiểm tra thông báo lỗi và tìm thiết bị lỗi,

khi kiểm tra log có thông báo sau

[root@server ~]# hplog -v

0163 Critical 18:01 11/18/2021 18:01 11/18/2021 0001
LOG: Uncorrectable PCI Express Error (Slot 2, Bus 0, Device 1, Function 0, Error status 0x00000020)

Thiết bị slot 2,

sử dụng lệnh

lspci -vvv

để tìm thiết bị ở slot 2 và có thông số trùng