R 5.3: Handling the Unexpected: Duplicate vs. Out-of-Sequence TLPs in PCIe

In the PCI Express (PCIe) Data Link Layer, the receiver acts as a strict gatekeeper, evaluating every incoming Transaction Layer Packet (TLP) against an internal NEXT_RCV_SEQ (NRS) counter. Under perfect conditions, the sequence number stamped on the incoming packet perfectly matches the NRS count, and the data flows smoothly.

However, in the real world of high-speed transit, packets can be delayed or destroyed. When an incoming sequence number does not match the expected count, the receiver must immediately determine if the packet is a harmless duplicate or an out-of-sequence error indicating lost data.

Here is exactly how the Data Link Layer handles both of these scenarios.

The Harmless Duplicate (Earlier Sequence Number)

Because the 12-bit sequence counters eventually roll over, the receiver evaluates numbers logically. If the sequence number of the incoming packet is logically smaller (earlier) than the expected NRS count, the receiver knows the transmitter decided to re-send a packet it has already processed.

Why would this happen? Typically, this occurs if the transmitter’s internal REPLAY_TIMER expires because an Ack was lost or delayed in transit, forcing the transmitter to unnecessarily replay its entire buffer.

When the receiver encounters this duplicate TLP, it handles it gracefully:

  • No Error Reported: As long as the expected sequence number and the received sequence number have not separated by more than half the maximum count value (2048), this is not considered an error.
  • Silently Discarded: Because the receiver has already successfully processed this data, the duplicate packet is silently dropped.
  • Send an Ack: To update the transmitter on its actual progress, the receiver schedules an Ack DLLP containing the sequence number of the last good TLP it successfully received (which is the NRS count minus 1).

The Lost Packet (Later Sequence Number)

A much more serious situation occurs if the incoming sequence number is logically larger (later) than the expected value. For example, if the receiver’s NRS counter is expecting packet 30, but packet 31 arrives instead, the receiver instantly knows that packet 30 was lost or corrupted somewhere along the physical wire.

Because the strict golden rule of PCIe architecture is that all TLPs must be accepted in their exact sequential order, the receiver takes aggressive action to halt the pipeline:

  • Discard the Packet: The receiver immediately discards the out-of-sequence packet, regardless of whether it passed its LCRC check perfectly. Good data cannot be forwarded to the Transaction Layer if the packet before it is missing.
  • Schedule a Nak: The receiver flags a correctable error and schedules a Negative Acknowledge (Nak) DLLP. Like the Ack, this Nak uses the sequence number of the last good TLP received (NRS minus 1) to tell the transmitter exactly where the successful transport stopped.
  • Wait for the Missing Data: After scheduling the Nak, the receiver sets a NAK_SCHEDULED flag. While this flag is set, the receiver will stubbornly drop all newly arriving TLPs and will not send any additional Acks or Naks. It will wait in this state until the transmitter successfully replays the missing packet that perfectly matches the expected NRS count.

Summary By comparing incoming sequence numbers against the NEXT_RCV_SEQ counter, the Data Link Layer effortlessly sorts out the chaotic flow of traffic. It safely ignores redundant duplicate packets to save processing overhead, and it strictly enforces sequential ordering by immediately halting the pipeline the moment a lost packet is detected.

Leave a Comment

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

Scroll to Top