Hard Processor System Technical Reference Manual: Agilex™ 5 SoCs

ID 814346
Date 4/01/2024
Public

A newer version of this document is available. Customers should click here to go to the newest version.

Document Table of Contents

5.1.6.2.3. Buffer Size Calculations

The DMA does not provide buffer size in the RX descriptors. The DMA updates only the status fields (RDES) of the descriptors. The driver has to perform the size calculations.

The TX DMA transfers the exact number of bytes (indicated by buffer size field of TDES2) towards the MAC. If a descriptor is marked as first (FD bit of TDES3 is 1), the DMA marks the first transfer from the buffer as SOP. If a descriptor is marked as last (LD bit of TDES3), the DMA marks the last transfer from that data buffer as EOP to the MTL.

The RX DMA transfers data to a buffer until the buffer is full or the end of packet is received from the MTL. When the FD bit of a descriptor is set, the amount of valid data in a buffer is accurately indicated by its buffer size field minus the data buffer pointer offset. The offset is zero when the data buffer pointer is aligned to the data bus width. If a descriptor is marked as last, the buffer may not be full (as indicated by the buffer size in bits [14:1] of Receive Control Register). To compute the amount of valid data in this final buffer, the driver must read the packet length (PL bits of RDES3[13:0]) and subtract the sum of the buffer sizes of the preceding buffers in this packet. The RX DMA always transfers the start of next packet with a new descriptor.
Note: Even when the start address of a RX buffer is not aligned to the data width of system bus, the system must allocate a RX buffer of a size aligned to the system bus width. For example, if the system allocates a RX buffer of 1,024 bytes (1 KB) starting from address 0x1000, the software can program the buffer start address in the RX descriptor to have a 0x1002 offset. The RX DMA writes the packet to this buffer with dummy data in the first two locations (0x1000 and 0x1001). The actual packet is written from location 0x1002. Therefore, the actual useful space in this buffer is 1,022 bytes, even though the buffer size is programmed as 1,024 bytes, because of the start address offset.