R 4.1: Generating Sequence Numbers: Inside the NEXT_TRANSMIT_SEQ Counter

In the PCIe Data Link Layer, the Ack/Nak protocol serves as the ultimate safeguard for ensuring the reliable, in-order delivery of Transaction Layer Packets (TLPs). To track every packet perfectly, the transmitter must assign a unique, sequential identifier to every outbound TLP before it is sent across the wire.

This critical numbering process is handled by a dedicated hardware component known as the NEXT_TRANSMIT_SEQ counter. Here is a closer look at how this counter operates, how it numbers packets, and how it handles maximum limits.

The 12-Bit Counter (0 to 4095)

The NEXT_TRANSMIT_SEQ is a 12-bit counter inside the transmitter that initializes to 0 upon a system reset or whenever the Link Layer is inactive.

As TLPs arrive from the Transaction Layer to be sent across the link, the counter assigns the current sequence number to the packet and then increments by one. This assigned sequence number acts as a permanent tracking tag; when the receiver eventually sends an Ack or Nak message back, it will use this specific number to tell the transmitter exactly which packet to purge from or replay from its Replay Buffer.

The Rollover Effect

Because it is a 12-bit counter, it has a finite range: it continuously counts forward until it reaches a maximum value of 4095.

Once the counter maxes out at 4095, it simply “rolls over” and continues counting from 0 again. This creates a continuous, rolling window of numbers. Because of this rollover behavior, the system’s logic is designed to understand that a sequence number of 0 can actually be a “later” (more recently sent) packet than a packet carrying the sequence number 4095.

Safeguarding the Pipeline: The 2048 Limit

You might wonder: If the counter rolls over, what happens if the transmitter sends 4,096 unacknowledged packets and the sequence numbers overlap?

In normal operation, this is incredibly unlikely because the receiver is strictly required to send Ack messages within a very short timeframe. However, to prevent any possibility of a catastrophic overlap, the PCIe specification enforces a strict safeguard: The number of unacknowledged packets in flight can never exceed half the maximum counter value, which is 2048.

The transmitter tracks its furthest progress using an ACKD_SEQ register, which logs the sequence number of the most recent Ack or Nak. The hardware constantly checks the difference between the NEXT_TRANSMIT_SEQ count and the ACKD_SEQ count. If the distance between these two ever reaches 2048, the transmitter will automatically block any new TLPs from the Transaction Layer until the receiver catches up and acknowledges some of the pending packets.

Summary By utilizing the 12-bit NEXT_TRANSMIT_SEQ counter, the Data Link Layer effortlessly numbers up to 4,096 packets in a rolling, continuous loop. Coupled with strict limits on how many unacknowledged packets can be in flight at once, this counter ensures that every TLP has a perfectly unique, trackable identifier, forming the foundation of PCIe’s reliable transport mechanism.

Leave a Comment

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

Scroll to Top