How to check PCIe version and speed in Linux

How to check PCIe version and speed in Linux

PCIE has four different specifications. Let’s take a look at two of them in the figure below.

Check the PCI slots on the motherboard

# dmidecode | grep --color "PCI"

The transmission rates corresponding to different PCIe versions are as follows:

The transfer rate is in GT/s rather than Gbps because the transfer rate includes overhead bits that do not provide additional throughput.
For example, PCIe 1.x and PCIe 2.x use the 8b/10b encoding scheme, resulting in 20% (= 2/10) of the original channel bandwidth being occupied.

GT/s ——Giga transfer per second, which is the number of transmissions per second. The focus is on describing the rate attributes of the physical layer communication protocol, which may not be associated with link width, etc.

Gbps ——Giga Bits Per Second. There is no proportional conversion relationship between GT/s and Gbps.

PCIe throughput (available bandwidth) calculation method:

Throughput = Transmission rate * Coding scheme

For example, the PCI-e2.0 protocol supports 5.0 GT/s, which means that each Lane supports the transmission of 5G bits per second. However, this does not mean that each Lane of the PCIe 2.0 protocol supports a rate of 5Gbps.

Why do I say so? Because the PCIe 2.0 physical layer protocol uses the 8b/10b encoding scheme. That is, for every 8 bits transmitted, 10 bits need to be sent; the extra 2 bits are not meaningful information to the upper layer.

Then, each Lane of the PCIe 2.0 protocol supports a rate of 5 * 8 / 10 = 4 Gbps = 500 MB/s.

Taking a PCIe 2.0 x8 channel as an example, the available bandwidth of x8 is 4 * 8 = 32 Gbps = 4 GB/s.

The PCI-e3.0 protocol supports 8.0 GT/s, which means that each lane supports 8G bits of transmission per second.

The PCIe 3.0 physical layer protocol uses the 128b/130b encoding scheme. That is, for every 128 bits transmitted, 130 bits need to be sent.

Then, each Lane of the PCIe 3.0 protocol supports a rate of 8 * 128 / 130 = 7.877 Gbps = 984.6 MB/s.

For a PCIe 3.0 x16 channel, the available bandwidth of x16 is 7.877 * 16 = 126.031 Gbps = 15.754 GB/s.

How to know whether the PCI-E Bus is using Gen(Generation) 1, Gen2 or the newer Gen3 in Linux?
#lspci can show all the devices in the current system. But it seems that it cannot see which generation of PCI-E Bus is used.

root@XXX# lspci 
00:00.0 Host bridge: Intel Corporation Haswell DRAM Controller (rev 06)
00:01.0 PCI bridge: Intel Corporation Haswell PCI Express x16 Controller (rev 06)
00:01.1 PCI bridge: Intel Corporation Haswell PCI Express x8 Controller (rev 06)
00:02.0 VGA compatible controller: Intel Corporation Haswell Integrated Graphics Controller (rev 06)
00:03.0 Audio device: Intel Corporation Haswell HD Audio Controller (rev 06)
00:14.0 USB controller: Intel Corporation Lynx Point USB xHCI Host Controller (rev 05)
00:16.0 Communication controller: Intel Corporation Lynx Point MEI Controller #1 (rev 04)
00:1a.0 USB controller: Intel Corporation Lynx Point USB Enhanced Host Controller #2 (rev 05)
00:1c.0 PCI bridge: Intel Corporation Lynx Point PCI Express Root Port #1 (rev d5)
00:1c.4 PCI bridge: Intel Corporation Lynx Point PCI Express Root Port #5 (rev d5)
00:1c.5 PCI bridge: Intel Corporation Lynx Point PCI Express Root Port #6 (rev d5)
00:1d.0 USB controller: Intel Corporation Lynx Point USB Enhanced Host Controller #1 (rev 05)
00:1f.0 ISA bridge: Intel Corporation Lynx Point LPC Controller (rev 05)
00:1f.2 IDE interface: Intel Corporation Lynx Point 4-port SATA Controller 1 [IDE mode] (rev 05)
00:1f.3 SMBus: Intel Corporation Lynx Point SMBus Controller (rev 05)
00:1f.6 Signal processing controller: Intel Corporation Lynx Point Thermal Management Controller (rev 05)
01:00.0 PCI bridge: PLX Technology, Inc. Unknown device 8724 (rev ca)
02:01.0 PCI bridge: PLX Technology, Inc. Unknown device 8724 (rev ca)
02:02.0 PCI bridge: PLX Technology, Inc. Unknown device 8724 (rev ca)
02:08.0 PCI bridge: PLX Technology, Inc. Unknown device 8724 (rev ca)
02:09.0 PCI bridge: PLX Technology, Inc. Unknown device 8724 (rev ca)
03:00.0 Ethernet controller: Intel Corporation I350 Gigabit Network Connection (rev 01)
03:00.1 Ethernet controller: Intel Corporation I350 Gigabit Network Connection (rev 01)
03:00.2 Ethernet controller: Intel Corporation I350 Gigabit Network Connection (rev 01)
03:00.3 Ethernet controller: Intel Corporation I350 Gigabit Network Connection (rev 01)
04:00.0 Ethernet controller: Intel Corporation I350 Gigabit Network Connection (rev 01)
04:00.1 Ethernet controller: Intel Corporation I350 Gigabit Network Connection (rev 01)
04:00.2 Ethernet controller: Intel Corporation I350 Gigabit Network Connection (rev 01)
04:00.3 Ethernet controller: Intel Corporation I350 Gigabit Network Connection (rev 01)
06:00.0 Ethernet controller: Intel Corporation 82599EB 10-Gigabit SFI/SFP+ Network Connection (rev 01)
06:00.1 Ethernet controller: Intel Corporation 82599EB 10-Gigabit SFI/SFP+ Network Connection (rev 01)
07:00.0 PCI bridge: PLX Technology, Inc. PEX 8732 32-lane, 8-Port PCI Express Gen 3 (8.0 GT/s) Switch (rev ca)
08:01.0 PCI bridge: PLX Technology, Inc. PEX 8732 32-lane, 8-Port PCI Express Gen 3 (8.0 GT/s) Switch (rev ca)
08:08.0 PCI bridge: PLX Technology, Inc. PEX 8732 32-lane, 8-Port PCI Express Gen 3 (8.0 GT/s) Switch (rev ca)
08:09.0 PCI bridge: PLX Technology, Inc. PEX 8732 32-lane, 8-Port PCI Express Gen 3 (8.0 GT/s) Switch (rev ca)
08:0a.0 PCI bridge: PLX Technology, Inc. PEX 8732 32-lane, 8-Port PCI Express Gen 3 (8.0 GT/s) Switch (rev ca)
09:00.0 Ethernet controller: Intel Corporation 82599EB 10-Gigabit SFI/SFP+ Network Connection (rev 01)
09:00.1 Ethernet controller: Intel Corporation 82599EB 10-Gigabit SFI/SFP+ Network Connection (rev 01)
0e:00.0 Ethernet controller: Intel Corporation I210 Gigabit Network Connection (rev 03)
0f:00.0 Ethernet controller: Intel Corporation I210 Gigabit Network Connection (rev 03)
root@XXX#
root@XXX# lspci -tv
-[0000:00]-+-00.0 Intel Corporation Haswell DRAM Controller
   +-01.0-[0000:01-06]----00.0-[0000:02-06]--+-01.0-[0000:03]--+-00.0 Intel Corporation I350 Gigabit Network Connection
   | | +-00.1 Intel Corporation I350 Gigabit Network Connection
   | | +-00.2 Intel Corporation I350 Gigabit Network Connection
   | | \-00.3 Intel Corporation I350 Gigabit Network Connection
   | +-02.0-[0000:04]--+-00.0 Intel Corporation I350 Gigabit Network Connection
   | | +-00.1 Intel Corporation I350 Gigabit Network Connection
   | | +-00.2 Intel Corporation I350 Gigabit Network Connection
   | | \-00.3 Intel Corporation I350 Gigabit Network Connection
   | +-08.0-[0000:05]--
   | \-09.0-[0000:06]--+-00.0 Intel Corporation 82599EB 10-Gigabit SFI/SFP+ Network Connection
   | \-00.1 Intel Corporation 82599EB 10-Gigabit SFI/SFP+ Network Connection
   +-01.1-[0000:07-0c]----00.0-[0000:08-0c]--+-01.0-[0000:09]--+-00.0 Intel Corporation 82599EB 10-Gigabit SFI/SFP+ Network Connection
   | | \-00.1 Intel Corporation 82599EB 10-Gigabit SFI/SFP+ Network Connection
   | +-08.0-[0000:0a]--
   | +-09.0-[0000:0b]--
   | \-0a.0-[0000:0c]--
   +-02.0 Intel Corporation Haswell Integrated Graphics Controller
   +-03.0 Intel Corporation Haswell HD Audio Controller
   +-14.0 Intel Corporation Lynx Point USB xHCI Host Controller
   +-16.0 Intel Corporation Lynx Point MEI Controller #1
   +-1a.0 Intel Corporation Lynx Point USB Enhanced Host Controller #2
   +-1c.0-[0000:0d]--
   +-1c.4-[0000:0e]----00.0 Intel Corporation I210 Gigabit Network Connection
   +-1c.5-[0000:0f]----00.0 Intel Corporation I210 Gigabit Network Connection
   +-1d.0 Intel Corporation Lynx Point USB Enhanced Host Controller #1
   +-1f.0 Intel Corporation Lynx Point LPC Controller
   +-1f.2 Intel Corporation Lynx Point 4-port SATA Controller 1 [IDE mode]
   +-1f.3 Intel Corporation Lynx Point SMBus Controller
   \-1f.6 Intel Corporation Lynx Point Thermal Management Controller
root@XXX#

If there are unknown devices, you need to update /usr/local/share/pci.ids.gz. Please refer to the update method http://benjr.tw/node/88

First query the identification number of the Inetl 82599EB network card (bus:device.function)

root@XXX# lspci | grep --color 82599 
06:00.0 Ethernet controller: Intel Corporation 82599EB 10-Gigabit SFI/SFP+ Network Connection (rev 01)
06:00.1 Ethernet controller: Intel Corporation 82599EB 10-Gigabit SFI/SFP+ Network Connection (rev 01)
09:00.0 Ethernet controller: Intel Corporation 82599EB 10-Gigabit SFI/SFP+ Network Connection (rev 01)
09:00.1 Ethernet controller: Intel Corporation 82599EB 10-Gigabit SFI/SFP+ Network Connection (rev 01)
root@XXX#

In PCI, devices use three numbers as identification values, namely 1. "bus number", 2. "device number" and 3. "function number".

So the time 06:00.0 just now means bus number = 06 , device number = 00 function = 0 .

These three numbers will be combined into a 16-bit identification code.

Bus number 8 bits 2^8 Up to 256 buses can be connected (0 to ff),

Device number 5 bits 2^5 Up to 32 devices (0 to 1f) can be connected and

Function (function number) 3bits 2^3 Each device can have up to 8 functions (0 to 7).

For more information about #lspci, please visit http://benjr.tw/node/543

Then check the vendor id and device id

root@XXX# lspci -n | grep -i 06:00.0
06:00.0 0200: 8086:10fb (rev 01)
root@XXX#

Linux uses Class ID + Vendor ID + Device ID to represent devices. For example, the device name represented by 0200: 8086:10fb is (Class ID = 0200, Vendor ID = 8086, Device ID = 10fb)

Finally check the bandwidth of the specified PCI device

root@XXX# lspci -n -d 8086:10fb -vvv | grep --color Width
  LnkCap: Port #9, Speed ​​5GT/s, Width x8, ASPM L0s, Latency L0 <1us, L1 <8us
  LnkSta: Speed ​​5GT/s, Width x8, TrErr- Train- SlotClk+ DLActive- BWMgmt- ABWMgmt-
  LnkCap: Port #9, Speed ​​5GT/s, Width x8, ASPM L0s, Latency L0 <1us, L1 <8us
  LnkSta: Speed ​​5GT/s, Width x8, TrErr- Train- SlotClk+ DLActive- BWMgmt- ABWMgmt-
  LnkCap: Port #1, Speed ​​5GT/s, Width x8, ASPM L0s, Latency L0 <1us, L1 <8us
  LnkSta: Speed ​​5GT/s, Width x8, TrErr- Train- SlotClk+ DLActive- BWMgmt- ABWMgmt-
  LnkCap: Port #1, Speed ​​5GT/s, Width x8, ASPM L0s, Latency L0 <1us, L1 <8us
  LnkSta: Speed ​​5GT/s, Width x8, TrErr- Train- SlotClk+ DLActive- BWMgmt- ABWMgmt-
root@XXX# 

LnkSta: The current speed provided by the system is PCI-Express 2.0 (5GT/s)

LnkCap : The speed currently used by the device.

The speeds of LnkSta and LnkCap may be different, typically the system provides PCI Express 3.0 but the device uses 2.0.

The above are the relevant knowledge points introduced this time. Thank you for your learning and support for 123WORDPRESS.COM.

<<:  Several ways to update batches in MySQL

>>:  Explanation of using if judgment conditions in sum and count functions when using SQL statements to collect data

Recommend

In-depth understanding of the seven communication methods of Vue components

Table of contents 1. props/$emit Introduction Cod...

HTML structured implementation method

DIV+css structure Are you learning CSS layout? Sti...

4 Scanning Tools for the Linux Desktop

While the paperless world has not yet emerged, mo...

4 functions implemented by the transform attribute in CSS3

In CSS3, the transform function can be used to im...

Limiting the number of short-term accesses to a certain IP based on Nginx

How to set a limit on the number of visits to a c...

MySQL inspection script (must read)

As shown below: #!/usr/bin/env python3.5 import p...

Screen command and usage in Linux

Screen Introduction Screen is a free software dev...

How to implement data persistence using the vuex third-party package

Purpose: Allow the state data managed in vuex to ...

Getting Started with Mysql--sql execution process

Table of contents 1. Process 2. Core Architecture...

JavaScript canvas Tetris game

Tetris is a very classic little game, and I also ...

How to use JS code compiler Monaco

Preface My needs are syntax highlighting, functio...

N ways to align the last row of lists in CSS flex layout to the left (summary)

I would like to quote an article by Zhang Xinxu a...