Chapter 6.2 – Credit-Based Flow Control Concept in PCI Express

Understanding credit tokens, lifecycle, and synchronization across the link


1 . Recap: Why PCIe Needs Credit-Based Control

In PCI Express, multiple TLPs can be in-flight simultaneously across a high-speed serial link.
To prevent the transmitter from overwhelming the receiver’s buffers, PCIe uses a credit-based system — a sort of “permission token” model.

Rather than handshaking on every packet, PCIe uses credit accounting to manage how many TLPs can be transmitted.


2 . What is a Credit?

A credit represents one unit of buffer capacity at the receiver’s Transaction Layer.
When the receiver advertises a certain number of credits, it’s essentially saying:

“You can send me this many TLPs (or this much data) before I run out of space.”

Each credit corresponds to:

  • One TLP header (for Header Credits)
  • One Doubleword (DW = 4 bytes) of payload (for Data Credits)

💡 Credits are abstract — they don’t represent bytes directly but capacity units negotiated at link training.


3 . Credit Types and Granularity

Each Virtual Channel (VC) in PCIe maintains six types of credits, representing different TLP classes and packet components.

Credit TypeMeaningApplies To
PHPosted HeaderMemory Writes, Messages
PDPosted DataMemory Writes, Messages
NPHNon-Posted HeaderMemory Read / I/O / Config Reads
NPDNon-Posted DataMemory Write (with response expected)
CPLHCompletion HeaderCompletion / Completion with Data
CPLDCompletion DataCompletion with Data

Thus, for each VC, you have 6 independent counters tracking buffer space.


4 . Lifecycle of a Credit

Here’s the credit lifecycle across the PCIe link:

[1] Receiver advertises credits

       ↓

[2] Transmitter stores credits in counters

       ↓

[3] Transmitter sends TLP (consumes credits)

       ↓

[4] Receiver stores packet in buffer (credit used)

       ↓

[5] Receiver processes packet and frees buffer

       ↓

[6] Receiver sends Flow Control Update DLLP

       ↓

[7] Transmitter increments credit counter

This ongoing cycle ensures both sides stay synchronized.


5 . Flow Control at Link Initialization

During link training (transition to L0 state):

  1. The receiver sends its initial credit capacity to the transmitter via Initialization Flow Control DLLPs.
  2. The transmitter stores those values as its starting counters.
  3. Transmission begins — each outgoing TLP decrements counters.
  4. The receiver issues periodic Flow Control Update DLLPs to restore credits.

⚙️ If credits = 0 for a specific TLP type, the transmitter must pause sending that type until credits are replenished.


6 . How Credits Are Counted

Header Credits (H)
→ Count one per TLP header transmitted.
Data Credits (D)
→ Count per data segment, measured in doublewords (4 bytes each).

Example:
A Memory Write TLP with 16 bytes of payload consumes:

  • 1 PH credit (for the header)
  • 4 PD credits (16 bytes ÷ 4 = 4 DWs)

7 . Credit Accounting Example

Let’s say:

  • Receiver advertises PH = 10, PD = 40
  • Transmitter has PH = 6, PD = 20 remaining

Now a Memory Write TLP (with 4 DW data) is to be sent:

  • Needs 1 PH + 4 PD credits
  • After sending → PH = 5, PD = 16

When receiver processes that packet and issues a Flow Control Update:

  • PH and PD counters increase back toward their original values.

8 . Separate Credit Pools per TLP Type

Each TLP category (Posted, Non-Posted, Completion) uses a dedicated pool of credits because:

  • They have different latency and buffering requirements.
  • Posted packets (like Memory Writes) never expect responses.
  • Non-Posted packets (like Reads) require Completion responses.
  • Completions must always have priority since they fulfill pending requests.

This segregation ensures no packet type starves another and guarantees forward progress.


9 . Link Synchronization via DLLPs

Synchronization between the two link partners occurs through:

  • Initialization Flow Control DLLPs: Sent once during link bring-up.
  • Flow Control Update DLLPs: Sent dynamically whenever buffers are freed.

DLLPs (Data Link Layer Packets) are lightweight control packets used solely for link management (not visible to the Transaction Layer).


10 . Design Insight

In a PCIe controller design:

  • Each credit type is tracked in a register counter.
  • Tx Scheduler checks counters before choosing a packet to send.
  • Credit Arbiter ensures that only TLPs with available credits are allowed.
  • If no credits → packet waits in Transaction Queue.

In testbenches:

assert(credits_available(type)) else $fatal(“TLP sent without credit!”);

Such assertions are essential for verifying link compliance.


11 . Key Advantages of Credit-Based System

FeatureBenefit
Predictable BandwidthFlow depends on known buffer limits, not random backpressure.
Low LatencyNo round-trip wait for “ready” signals.
ScalableWorks over multiple hops (switches and bridges).
Lossless OperationNo overflow — link partners always in sync.
Full DuplexEach direction has independent credit management.

NOTES

  • Credits = permission to send packets.
  • Each VC maintains six counters for different TLP classes.
  • Credits are consumed when packets are sent and replenished by Flow Control Update DLLPs.
  • Flow control guarantees no buffer overflow, even at multi-gigabit speeds.
  • This system is the backbone of PCIe’s deterministic, pipelined performance.

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top