PCIe Protocol Validation¶
Protocol validation ensures that PCIe devices correctly implement the Transaction Layer, Data Link Layer, and Physical Layer protocols. This page covers the key aspects of validating PCIe protocol compliance.
PCIe Protocol Layers¶
graph TB
subgraph "Transaction Layer"
TLP[Transaction Layer Packets]
FC[Flow Control]
ORD[Ordering Rules]
end
subgraph "Data Link Layer"
DLLP[Data Link Layer Packets]
ACK[ACK/NAK Protocol]
LCRC[LCRC Generation]
end
subgraph "Physical Layer"
PHY[Encoding/Framing]
LTSSM[Link Training]
EQ[Equalization]
end
TLP --> DLLP
DLLP --> PHY
Transaction Layer Packets (TLPs)¶
TLP Types¶
| Type | Description | Direction |
|---|---|---|
| Memory Read (MRd) | Read from memory | Requester → Completer |
| Memory Write (MWr) | Write to memory | Requester → Completer |
| Completion (Cpl) | Response to read | Completer → Requester |
| Config Read/Write | Configuration access | Root → Device |
| I/O Read/Write | Legacy I/O access | Any |
| Message (Msg) | Sideband messaging | Any |
TLP Structure¶
┌─────────────────────────────────────────────────────────┐
│ TLP Header (3-4 DW) │
├───────────┬───────────┬───────────┬─────────────────────┤
│ Fmt/Type │ TC/Attr │ Length │ Requester ID/Tag │
├───────────┴───────────┴───────────┴─────────────────────┤
│ Address │
├─────────────────────────────────────────────────────────┤
│ Data Payload (0-1024 DW) │
├─────────────────────────────────────────────────────────┤
│ ECRC (Optional) │
└─────────────────────────────────────────────────────────┘
TLP Header Fields¶
| Field | Description |
|---|---|
| Fmt | Format (¾ DW header, with/without data) |
| Type | Transaction type |
| TC | Traffic Class (0-7) |
| TD | TLP Digest (ECRC present) |
| EP | Error Poisoned |
| Attr | Attributes (ordering, snoop) |
| Length | Payload length in DW |
| Requester ID | BDF of requester |
| Tag | Transaction identifier |
| Address | Target address (32 or 64 bit) |
Data Link Layer Packets (DLLPs)¶
DLLP Types¶
| Type | Code | Description |
|---|---|---|
| Ack | 00h | Acknowledge TLP received |
| Nak | 10h | Request TLP retransmission |
| InitFC1 | 40h | Flow Control Init |
| InitFC2 | 50h | Flow Control Init |
| UpdateFC | 60h | Flow Control Update |
| PM_Enter_L1 | 20h | Power management |
| PM_Enter_L23 | 21h | Power management |
| Vendor | 30h | Vendor specific |
DLLP Structure¶
┌────────────────────────────────────────┐
│ DLLP Type (8 bits) │
├────────────────────────────────────────┤
│ DLLP-specific Fields (24 bits) │
├────────────────────────────────────────┤
│ CRC (16 bits) │
└────────────────────────────────────────┘
Flow Control¶
Credit Types¶
| Credit Type | Abbreviation | Description |
|---|---|---|
| Posted Header | PH | Posted TLP headers |
| Posted Data | PD | Posted TLP data |
| Non-Posted Header | NPH | Non-posted TLP headers |
| Non-Posted Data | NPD | Non-posted TLP data |
| Completion Header | CplH | Completion headers |
| Completion Data | CplD | Completion data |
Flow Control Mechanism¶
sequenceDiagram
participant TX as Transmitter
participant RX as Receiver
Note over TX,RX: Initialization
RX->>TX: InitFC1 (Initial Credits)
RX->>TX: InitFC2 (Initial Credits)
TX->>RX: InitFC1 (Initial Credits)
TX->>RX: InitFC2 (Initial Credits)
Note over TX,RX: Normal Operation
TX->>RX: TLP (consumes credits)
TX->>RX: TLP (consumes credits)
RX->>TX: UpdateFC (returns credits)
Credit Rules¶
- TX must have credits before sending
- 1 header credit per TLP
- 1 data credit per 4 DW (16 bytes)
- Infinite credits = no flow control (value 0)
ACK/NAK Protocol¶
Sequence Numbers¶
- Each TLP assigned 12-bit sequence number
- Wraps at 4095
- Receiver tracks expected sequence
ACK/NAK Rules¶
| Scenario | Action |
|---|---|
| TLP received correctly | Send ACK |
| LCRC error | Send NAK |
| Sequence error | Send NAK |
| ACK timeout | Retransmit |
| NAK received | Retransmit |
Replay Buffer¶
TX maintains replay buffer:
├── TLP 100 (unacknowledged)
├── TLP 101 (unacknowledged)
├── TLP 102 (unacknowledged)
└── TLP 103 (just sent)
On NAK(101): Retransmit 101, 102, 103
On ACK(102): Remove 100, 101, 102 from buffer
Protocol Validation Tests¶
Transaction Layer Tests¶
| Test Category | Test Cases |
|---|---|
| TLP Format | Header format, length encoding |
| Addressing | 32-bit, 64-bit addressing |
| Completions | Status codes, byte count |
| Ordering | Producer-consumer, relaxed ordering |
| Timeout | Completion timeout handling |
Data Link Layer Tests¶
| Test Category | Test Cases |
|---|---|
| Flow Control | Credit initialization, updates |
| ACK/NAK | Sequence tracking, retransmit |
| LCRC | CRC generation, error detection |
| Replay | Buffer management, replay |
Error Handling Tests¶
| Error Type | Expected Behavior |
|---|---|
| ECRC error | Advisory or Fatal |
| LCRC error | NAK and retransmit |
| Malformed TLP | Uncorrectable error |
| Completion Timeout | Device-specific |
| Unexpected Completion | Advisory error |
| Poisoned TLP | Data corruption flag |
Protocol Analyzer Usage¶
Capture Setup¶
- Physical Connection
- Interposer between host and device
-
Probe point at connector
-
Trigger Configuration
- TLP type triggers
- Error condition triggers
-
Sequence number triggers
-
Filter Settings
- TLP type filtering
- Direction filtering
- Address range filtering
Analysis Techniques¶
Timeline View:
Time Direction Type Details
0.0 μs TX→RX MRd Addr=0x1000, Len=64B
0.2 μs RX→TX Ack Seq=100
0.5 μs RX→TX CplD Cpl for Tag=5, 64B
0.7 μs TX→RX Ack Seq=200
1.0 μs TX→RX MWr Addr=0x2000, 128B
Protocol Statistics: - TLP counts by type - Error counts - Retry counts - Latency measurements
Common Protocol Issues¶
Issue: Completion Timeout¶
Symptoms: Device stops responding
Possible Causes: - Completion not generated - Completion mis-routed - Flow control stall
Debug Steps: 1. Verify request TLP sent correctly 2. Check completer received request 3. Check completion generated 4. Trace completion routing
Issue: Flow Control Stall¶
Symptoms: No TLPs sent despite pending transactions
Possible Causes: - Credits exhausted - UpdateFC not sent - Credit counting bug
Debug Steps: 1. Monitor credit counts 2. Check for UpdateFC DLLPs 3. Verify credit initialization
Issue: Replay Storm¶
Symptoms: High retry rate, low throughput
Possible Causes: - Signal integrity issues - LCRC errors - NAK handling bugs
Debug Steps: 1. Monitor NAK rate 2. Check LCRC error counts 3. Analyze signal quality
Validation Checklist¶
Transaction Layer¶
- All TLP types formatted correctly
- Address translation works
- Completion status codes correct
- Ordering rules followed
- Timeout handling works
Data Link Layer¶
- Flow control initializes
- Credits tracked correctly
- ACK/NAK works correctly
- Replay buffer functions
- LCRC generated/checked
Error Handling¶
- ECRC errors detected
- LCRC errors trigger NAK
- Malformed TLPs reported
- Completion timeout works
- AER registers updated
Related Topics¶
- LTSSM - Physical layer state machine
- Enumeration - Configuration transactions
- High-Speed Validation - Electrical testing
References¶
- PCI Express Base Specification
- PCIe Protocol Analyzer User Guides
- PCI-SIG Compliance Program