WFU

[ 精選文章 ]

自行車 入門 Escape 3 , Snap 21 , Revel

最近周末想運動 , 平日想通勤 , 想買台自行車 , 把自己找的資料跟大家分享 , 如果你是玩家級的 就不用看了 這是給跟我一樣的新新新手 參考的 騎車半年後的補充: 如果你有把握你是真的有時間有興趣會一直騎,建議還是存點錢買好一點的彎把公路車, 或是可以考慮買2手的自...

2021年1月22日 星期五

PCIE LINK SPEED Check

PCIE LINK SPEED in PCIE Configuration space

 img_5698740ef1890

OffsetDescription
0x06BIT4=1  Support Capability
0x34Point to Capability Struct
More detail: 

1.12 PCI Code and ID Assignment Specification Revision 1.12
Capability Struct
OffsetDescription
0x00CapabilityID
0x01 = PCI_CAP_ID_PMI 
0x02 = PCI_CAP_ID_AGP
0x03 = PCI_CAP_ID_VPD
0x04 = PCI_CAP_ID_SLOTID 
0x05 = PCI_CAP_ID_MSI
0x06 = PCI_CAP_ID_HOTSWAP 
0x07 = PCI_CAP_ID_PCIX
0x10 = PCI_CAP_ID_PCIEXP
0x0C = PCI_CAP_ID_HOTPLUG
0x01NextCapabilityStruct 
Check PCIe SPEC for more infomation



7.5.3 PCI Express Capability Structure
OffsetWidthDescription
0x0216bitPCIE Capability
[3:0] Capability Version
    1 –  Capability Version 1 Support
    2 –  Capability Version 2 Support
[7:4] Device/Port Type
For Type 00h PCI Configuration Space header are:
    0000b PCI Express Endpoint
    0001b Legacy PCI Express Endpoint
    1001b RCiEP
    1010b Root Complex Event Collector

For Type 01h PCI Configuration Space header are:
    0100b Root Port of PCI Express Root Complex
    0101b Upstream Port of PCI Express Switch
    0110b Downstream Port of PCI Express Switch
    0111b PCI Express to PCI/PCI-X Bridge
    1000b PCI/PCI-X to PCI Express Bridge
0x0432bitDevice Capability
[2:0] Max_Payload_Size SupportedDefined encodings are:
    000b 128 bytes max payload size
    001b 256 bytes max payload size
    010b 512 bytes max payload size
    011b 1024 bytes max payload size
    100b 2048 bytes max payload size
    101b 4096 bytes max payload size
0x0C32bitLink Capability
[3:0] Max Link Speed (RO)
    0001b Supported Link Speeds Vector field bit 0
    0010b Supported Link Speeds Vector field bit 1
    0011b Supported Link Speeds Vector field bit 2
    0100b Supported Link Speeds Vector field bit 3
    0101b Supported Link Speeds Vector field bit 4
    0110b Supported Link Speeds Vector field bit 5
    0111b Supported Link Speeds Vector field bit 6
[9:4] Maximum Link Width (RO)
    000000b Reserved
    000001b x1
    000010b x2
    000100b x4
    001000b x8
    001100b x12
    010000b x16
    100000b x32
[11:10] Active State Power Management (ASPM) Support
    00b:No ASPM Support
    01b:L0s Supported
    10b:Supported
    11b:L0s and L1 Supported
0x1016bitLink Control
[1:0] ASPM
    00                Disabled
    01                L0s Entry Enabled
    10                L1 Entry Enabled
    01                L0s Entry Enabled
    11                L0s and L1 Entry Enabled
[4] Link Disabled
[5] Retrain Link
0x12 16bit Link Status Register
[3:0] Current Link Speed
    0001b Supported Link Speeds Vector field bit 0
    0010b Supported Link Speeds Vector field bit 1
    0011b Supported Link Speeds Vector field bit 2
    0100b Supported Link Speeds Vector field bit 3
    0101b Supported Link Speeds Vector field bit 4
    0110b Supported Link Speeds Vector field bit 5
    0111b Supported Link Speeds Vector field bit 6
[9:4] Negotiated Link Width
    00 0001b x1
    00 0010b x2
    00 0100b x4
    00 1000b x8
    00 1100b x12
    01 0000b x16
    10 0000b x32
0x14 32bitSlot Capabilities Register


0x1A 16bit
Slot Status Register
0x24 32bitDevice Capability 2
0x2816bitDevice Control 2
0x2C32bitLink Capability 2
[7:1] Supportd Link Speeds Vector
         Bit definitions within this field are:
         Bit 0 2.5 GT/s
         Bit 1 5.0 GT/s
         Bit 2 8.0 GT/s
         Bits 6:3 RsvdP
0x3032bitLink Control 2
[3:0] Target Link Speed
Defined encodings are:
         0001b Supported Link Speeds Vector field bit 0
         0010b Supported Link Speeds Vector field bit 1
         0011b Supported Link Speeds Vector field bit 2
         0100b Supported Link Speeds Vector field bit 3
         0101b Supported Link Speeds Vector field bit 4
         0110b Supported Link Speeds Vector field bit 5
         0111b Supported Link Speeds Vector field bit 6

Offset 0x0C : 0x43 Max supported setting => Gen3 by 4
    Maximum Link Width = 0x4, Max Link Speed = 0x3

Offset 0x12 :  0x43 Currently : Gen3 by 4
    Negotiated Link Width = 0x4, Current Link Speed = 0x3

Offset 0x1A Bit6 Present Status

Offset 0x30 :  0x03 Target Link Speed

To re-train the device speed
1. Set offset 0x30 "Target Link speed" to the target speed value 
2. Set offset 0x10 => its <value | 0x10> (e.g. 0x40=> 0x50) to disable the link
3. Set offset 0x10 => its <value | 0x20> (e.g. 0x40=> 0x60) to retrain
if it failed to adjust the Gen speed @ the device try to modify it @ its root port.

About Offset 0x10 : [5] Retrain Link

Avoiding Race Conditions When Using the Retrain Link Bit

When software changes Link control parameters and writes a 1b to the Retrain Link bit in order to initiate Link training using the new parameter settings, special care is required in order to avoid certain race conditions. At any instant the LTSSM may transition to the Recovery or Configuration state due to normal Link activity, without software awareness. If the LTSSM is already in Recovery or Configuration when software writes updated parameters to the Link Control register, as well as a 1b, to the Retrain Link bit, the LTSSM might not use the updated parameter settings with the current Link training, and the current Link training might not achieve the results that software intended.

To avoid this potential race condition, it is highly recommended that software use the following algorithm or something similar:

1. Software sets the relevant Link control parameters to the desired settings without writing a 1b to the Retrain Link bit.
2. Software polls the Link Training bit in the Link Status register until the value returned is 0b. 
3. Software writes a 1b to the Retrain Link bit without changing any other fields in the Link Control register.

The above algorithm guarantees that Link training will be based on the Link control parameter settings that software intends.

沒有留言:

張貼留言