1. Data Link Layer Overview
What is the Data Link Layer?
The Data Link Layer (DLL) provides reliable, point-to-point delivery of Transaction Layer Packets (TLPs) across a single PCIe link. It sits between the Transaction Layer and Physical Layer, adding error detection (LCRC), sequencing, and a retry mechanism to ensure TLPs are delivered correctly despite physical layer errors.
Position in Protocol Stack
Core Responsibilities
TLP Integrity
- Add LCRC (32-bit)
- Add sequence number
- Verify LCRC on receive
- Detect corruption
Reliable Delivery
- ACK/NAK protocol
- Replay buffer
- Retransmission
- Duplicate detection
Link Management
- Flow Control Init
- Power Management DLLPs
- Link state tracking
- Data Link Feature Exchange
2. Data Link Layer Architecture
Transmit Side Processing
TLP Transmission Sequence (Step-by-Step)
- Receive TLP from Transaction Layer (already includes ECRC if enabled)
- Assign Sequence Number: Use NEXT_TRANSMIT_SEQ, then increment
- Prepend Sequence Number: 2-byte header added to TLP
- Calculate LCRC: 32-bit CRC over [Seq Num + TLP]
- Append LCRC: 4-byte trailer added
- Store in Replay Buffer: Keep copy for potential retransmission
- Pass to Physical Layer: For encoding and transmission
- Start/Reset REPLAY_TIMER: Track ACK timeout
Receive Side Processing
TLP Reception Sequence (Step-by-Step)
- Receive Packet from Physical Layer
- Verify LCRC: Calculate CRC, compare with received LCRC
- If LCRC invalid → Schedule NAK, discard packet
- Extract Sequence Number: From 2-byte header
- Check Sequence Number:
- If Seq == NEXT_RCV_SEQ → Accept TLP, increment NEXT_RCV_SEQ
- If Seq < NEXT_RCV_SEQ (using modulo arithmetic) → Duplicate, discard silently
- If Seq > NEXT_RCV_SEQ → Out-of-order, schedule NAK for NEXT_RCV_SEQ
- Forward TLP to Transaction Layer (strip Seq Num and LCRC)
- Schedule ACK: Update ACK sequence number to send
3. DLCMSM (Data Link Control and Management State Machine)
The DLCMSM controls the overall operational state of the Data Link Layer. It determines when TLPs can be exchanged and manages the transition between inactive, initialization, and active states.
DL_Inactive State
DL_Inactive Conditions
- Physical Layer LTSSM is NOT in L0 state
- Link is training, in low-power state, or disabled
- No TLPs or DLLPs can be transmitted/received
- Replay buffer is cleared
- All sequence counters reset to 0
Exit Condition: Physical Layer signals LinkUp (LTSSM enters L0)
DL_Init State
DL_Init Activities
- Flow Control Initialization: Exchange InitFC1 and InitFC2 DLLPs
- Data Link Feature Exchange: Negotiate DL features (PCIe 4.0+)
- TLPs are NOT transmitted (only DLLPs)
- Both ports must complete FC initialization for all enabled VCs
Exit Condition: FC initialization complete for all Virtual Channels
DL_Active State
DL_Active - Normal Operation
- TLPs can be transmitted and received
- ACK/NAK protocol active
- Flow Control Updates (UpdateFC DLLPs) exchanged
- Replay mechanism operational
- DL_Up Status reported to Transaction Layer
Exit Conditions: Physical Layer LinkDown, REPLAY_NUM exceeds limit, errors
4. Data Link Layer Packets (DLLPs) - Complete Specification
DLLPs are packets generated and consumed entirely within the Data Link Layer. They are NOT subject to flow control and can always be transmitted when the Physical Layer is ready.
DLLP Format
Complete DLLP Type Encoding
| Type Code | DLLP Name | Category | Description |
|---|---|---|---|
0000 0000 |
Ack | ACK/NAK | Acknowledge TLPs up to sequence number |
0001 0000 |
Nak | ACK/NAK | Request retransmission from sequence number |
0010 0000 |
PM_Enter_L1 | Power Mgmt | Request ASPM L1 entry |
0010 0001 |
PM_Enter_L23 | Power Mgmt | Request L2/L3 Ready entry |
0010 0011 |
PM_Active_State_Request_L1 | Power Mgmt | ASPM L1 request (Upstream only) |
0010 0100 |
PM_Request_Ack | Power Mgmt | Acknowledge PM request |
0011 0xxx |
Vendor Specific | Vendor | Vendor-defined DLLP |
0100 0xxx |
InitFC1-P | FC Init | FC Init Phase 1 - Posted (VC in xxx) |
0101 0xxx |
InitFC1-NP | FC Init | FC Init Phase 1 - Non-Posted (VC in xxx) |
0110 0xxx |
InitFC1-Cpl | FC Init | FC Init Phase 1 - Completion (VC in xxx) |
1000 0xxx |
UpdateFC-P | FC Update | Update Posted credits |
1001 0xxx |
UpdateFC-NP | FC Update | Update Non-Posted credits |
1010 0xxx |
UpdateFC-Cpl | FC Update | Update Completion credits |
1100 0xxx |
InitFC2-P | FC Init | FC Init Phase 2 - Posted |
1101 0xxx |
InitFC2-NP | FC Init | FC Init Phase 2 - Non-Posted |
1110 0xxx |
InitFC2-Cpl | FC Init | FC Init Phase 2 - Completion |
ACK/NAK DLLP Format
| Byte 0 | Byte 1 | Byte 2 | Byte 3 | ||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Type | Rsvd | Seq[11:8] | Seq[7:0] | Reserved | |||||||||||||||||||||||||||
| 00h=Ack 10h=Nak |
0000 | 12-bit AckNak_Seq_Num | 00h | ||||||||||||||||||||||||||||
Flow Control DLLP Format
| Byte 0 | Byte 1 | Byte 2 | Byte 3 | ||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Type | VC | Rsvd | HdrFC[7:2] | HdrFC[1:0] | DataFC[11:8] | Rsvd | DataFC[7:0] | ||||||||||||||||||||||||
| FC Type | 0-7 | Header Credits (8-bit) | Data Credits (12-bit) | ||||||||||||||||||||||||||||
5. ACK/NAK Protocol - Complete Technical Specification
The ACK/NAK protocol provides reliable delivery by acknowledging successfully received TLPs and requesting retransmission of missing or corrupted TLPs.
Sequence Number Management
ACK Rules
ACK DLLP Semantics and Rules
Ack(N)means: "I have successfully received all TLPs with sequence numbers ≤ N"- ACK is cumulative - acknowledges ALL TLPs up to and including N
- Receiver MUST send ACK within ACKNOWLEDGE_LATENCY_TIMER after receiving a TLP
- ACK may acknowledge multiple TLPs at once
- Transmitter purges all TLPs with sequence ≤ N from Replay Buffer upon receiving ACK(N)
- Receiving ACK for already-ACKed sequence is silently ignored
NAK Rules
NAK DLLP Semantics and Rules
Nak(N)means: "I am missing TLP with sequence N, please retransmit from N onwards"- NAK is sent when:
- LCRC check fails on received packet
- Received sequence number > expected (gap detected)
- 8b/10b decode error (at data rates using 8b/10b)
- Only ONE NAK can be outstanding at a time (NAK_SCHEDULED flag)
- After sending NAK, receiver enters NAK_OUTSTANDING state
- Exit NAK_OUTSTANDING when expected TLP is received correctly
- Duplicate NAKs for same sequence are suppressed
6. LCRC (Link CRC) Calculation
LCRC Specification
| Polynomial: | 0x04C11DB7 (CRC-32) |
| Polynomial Expansion: | x³² + x²⁶ + x²³ + x²² + x¹⁶ + x¹² + x¹¹ + x¹⁰ + x⁸ + x⁷ + x⁵ + x⁴ + x² + x + 1 |
| Initial Value: | 0xFFFFFFFF |
| Final XOR: | 0xFFFFFFFF (invert result) |
| Input/Output: | Bit-reversed (LSB first) |
| Residue: | 0x1CDF4421 (when CRC verified over entire packet including LCRC) |
LCRC vs ECRC Comparison
| Aspect | LCRC | ECRC |
|---|---|---|
| Scope | Single link (point-to-point) | End-to-end (source to destination) |
| Regenerated? | Yes, at every switch/bridge | No, preserved through switches |
| Coverage | Seq Num + TLP + ECRC | TLP Header (some fields) + Data |
| Detects | Link transmission errors | Switch/path corruption |
| Required? | Always | Optional |
7. Retry Mechanism - Complete Technical Analysis
Replay Buffer
Replay Buffer Architecture
The transmitter maintains a Replay Buffer containing copies of all transmitted but unacknowledged TLPs. This buffer enables retransmission when NAK is received or REPLAY_TIMER expires.
- Store Operation: TLP copied to buffer before transmission
- Purge Operation: Remove TLPs with sequence ≤ ACK'd sequence
- Replay Operation: Retransmit all buffered TLPs from NAK'd sequence
Buffer Size (bytes) = Max_Payload_Size × Max_Outstanding_TLPs
Example: 512 bytes MPS × 64 outstanding = 32 KB buffer
Example: 4096 bytes MPS × 32 outstanding = 128 KB buffer
Replay Timer and Counters
Replay Protocol Rules
Normative Replay Rules
- Replay Initiation (NAK): Upon receiving Nak(N), transmitter MUST retransmit all TLPs starting from sequence N
- Replay Initiation (Timeout): Upon REPLAY_TIMER expiration, transmitter MUST retransmit from oldest unACK'd TLP
- Replay Order: Replayed TLPs MUST be retransmitted in original sequence order
- New TLPs During Replay: New TLPs may be interleaved with replayed TLPs
- Sequence Numbers: Replayed TLPs retain their original sequence numbers
- LCRC: LCRC is NOT recalculated for replay (original LCRC used)
- REPLAY_NUM Limit: After REPLAY_NUM_ROLLOVER + 1 consecutive replays without ACK advancement, initiate Recovery
8. Flow Control Initialization Protocol
Before TLPs can be exchanged, both ends of the link must complete Flow Control Initialization to advertise their buffer capacities.
FC Initialization Rules
- InitFC1 DLLPs advertise initial credit values for P, NP, and Cpl
- InitFC2 DLLPs confirm values (may be same or different from InitFC1)
- Both phases required for each enabled Virtual Channel
- Minimum VC0 always enabled; other VCs optional
- Credit values: Header (8-bit) and Data (12-bit)
- Value 0 in InitFC = infinite credits
9. Flit Mode Data Link Layer (PCIe 6.0+)
PCIe 6.0 and later operating at 64 GT/s+ use Flit Mode, which fundamentally changes Data Link Layer operation.
Non-Flit Mode (Legacy)
- Separate DLLPs for ACK/NAK
- Per-TLP LCRC (32-bit)
- 12-bit sequence numbers
- Variable packet sizes
- Replay buffer by TLP
- 8b/10b or 128b/130b encoding
Flit Mode (PCIe 6.0+)
- DLP embedded in 256-byte Flit
- FEC + CRC at Flit level
- 8-bit Flit sequence numbers
- Fixed 256-byte Flits
- Replay buffer by Flit
- 1b/1b PAM4 encoding
10. Data Link Layer Error Handling
| Error Condition | Detection | Action | Recovery |
|---|---|---|---|
| LCRC Error | CRC mismatch on receive | Discard TLP, send NAK | Transmitter replays from NAK'd seq |
| Sequence Error | Unexpected sequence number | Send NAK for expected seq | Transmitter replays missing TLPs |
| DLLP CRC Error | CRC-16 mismatch on DLLP | Discard DLLP silently | Wait for retransmission/timeout |
| REPLAY_TIMER Timeout | No ACK within timeout | Increment REPLAY_NUM, replay | Retransmit unACK'd TLPs |
| REPLAY_NUM Exceeded | Too many consecutive replays | Enter Recovery state | Link retraining via LTSSM |
| Receiver Overflow | No FC credits but TLP received | Protocol error | Link error, may require reset |
Correctable vs Uncorrectable DLL Errors
- Correctable: LCRC error, sequence error, replay timeout (recovered via retry)
- Uncorrectable: REPLAY_NUM exceeded, receiver overflow, persistent errors
DLL errors are reported via AER (Advanced Error Reporting) capability. Repeated correctable errors may indicate marginal link quality.