R 5.2: Tracking Expected Packets: Inside the PCIe Receiver’s NEXT_RCV_SEQ Counter

In the PCI Express (PCIe) Data Link Layer, preventing data corruption is only part of the reliability equation. The receiver must also guarantee that no packets are lost in transit and that every packet is processed in the exact order it was transmitted. To manage this strict sequential ordering, the receiver utilizes a dedicated hardware tracker known as the NEXT_RCV_SEQ (Next Receive Sequence) counter, often abbreviated as the NRS.

Here is an inside look at how the NRS counter keeps a watchful eye on incoming traffic to ensure flawless, in-order packet delivery.

What is the NEXT_RCV_SEQ Counter?

The NEXT_RCV_SEQ is a 12-bit counter located inside the receiver’s Data Link Layer. Its primary responsibility is to keep track of the exact Sequence Number the receiver expects to see in the very next incoming Transaction Layer Packet (TLP).

When the system is reset, or whenever the Data Link Layer becomes inactive, this counter is automatically initialized to 0. As long as traffic is flowing perfectly, the counter increments by one for every good TLP that is successfully accepted and forwarded up to the Transaction Layer. However, the counter is strictly withheld from incrementing if a TLP arrives with an LCRC error, is nullified, or fails its sequence number check.

The Sequence Number Check: Three Possible Outcomes

When a TLP arrives at the receiver, it first undergoes a strict 32-bit LCRC check to ensure there are no corrupted bits. If the packet passes that mathematical test, the receiver’s next step is to compare the Sequence Number embedded inside the incoming TLP against its internal expected NEXT_RCV_SEQ count.

This comparison will result in one of three possible scenarios:

1. The Perfect Match (In-Sequence) If the incoming TLP’s Sequence Number perfectly equals the NRS count, the packet has arrived exactly when expected. In this ideal scenario, the receiver knows everything is functioning properly:

  • The TLP is accepted and forwarded to the Transaction Layer.
  • The NEXT_RCV_SEQ counter is incremented by one to prepare for the next packet.
  • The receiver schedules an Ack to notify the transmitter of the success (though it may wait for a timer to expire before actually sending it, allowing it to coalesce multiple Acks into one).

2. An Earlier Number (The Duplicate TLP) Because sequence counters roll over, the receiver evaluates numbers logically. If the incoming Sequence Number is logically smaller (earlier) than the expected NRS count, the receiver knows the transmitter decided to re-send a packet that the receiver has actually already processed.

  • This is not considered an error; it simply means the transmitter likely experienced a timeout and replayed its buffer.
  • Because the receiver doesn’t need the packet again, the duplicate TLP is silently dropped.
  • To remind the transmitter of its actual progress, the receiver sends an Ack containing the sequence number of the last good TLP it received (NEXT_RCV_SEQ count – 1).

3. A Later Number (The Lost TLP) If the incoming Sequence Number is logically larger (later) than the expected NRS count (for example, the receiver expects TLP 30, but TLP 31 arrives), the receiver instantly knows that a packet was lost or dropped earlier in transit.

  • Because PCIe architecture enforces a strict rule that all TLPs must be accepted in order, the receiver immediately discards this out-of-sequence packet, regardless of whether its LCRC was perfect.
  • The receiver sets a flag to schedule a “Nak” (Negative Acknowledge) DLLP.
  • The receiver will then stubbornly drop all subsequent incoming TLPs and wait until the missing packet is finally replayed and arrives with the exact sequence number matching the NRS count.

Summary The NEXT_RCV_SEQ counter acts as the ultimate gatekeeper for your system’s data pipeline. By maintaining a strict, uncompromising count of the expected sequence number and cross-referencing it against every single incoming packet, the receiver guarantees that missing TLPs are instantly detected and that data is never processed out of order.

Leave a Comment

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

Scroll to Top