Hard Processor System Technical Reference Manual: Agilex™ 5 SoCs

ID 814346
Date 11/27/2024
Public
Document Table of Contents

5.1.6.5.1. Description of the TSO Feature

You can enable the TSO feature by selecting the enable TCP segmentation offloading for TCP/IP packets option and programming the TSE bit of the corresponding DMA_CH(#i)_Tx_Control register. To enable segmentation for a packet, the application must set the TSE bit of TDES3 of the first normal descriptor.

The application must program the length of the TCP packet payload in TDES3[17:0] and the length of TCP header in TDES3[22:19]. The maximum length of TCP packet payload that can be segmented is 256 KB. The header of the packet, including the Ethernet header, L3 header and L4 header must be provided in buffer 1 of the first normal descriptor of the TSO packet. Only buffer 1 of the first normal descriptor of a packet enabled for TSO is taken as the buffer containing the header. The TCP payload can begin from buffer 2 of the first normal descriptor and continue to buffer 1 and buffer 2 of the second normal descriptor and subsequent descriptors. The maximum header length supported for TSO feature is 1023 bytes.

The TCP payload may span across multiple buffers and multiple descriptors. The size of buffers containing the TCP payload must add up to be equal to the TCP payload length provided in TDES3[17:0] of the first normal descriptor.

The MAC always calculates and appends the CRC. The MAC also inserts padding (if required) for all packets segmented by the DMA. If the TSE bit of TDES3 is enabled, the CRC PAD control (CPC) field of TDES3 is reserved. To determine the size of a TCP packet after segmentation, the DMA uses the maximum segment size (MSS) provided by the application through the context descriptor. The DMA segments only those packets which have payload size greater than MSS. For packets whose TCP payload length is less than or equal to the MSS value, the EMAC recalculates the IP header checksum and TCP checksum when the TSE bit in the descriptor and the TSE bit in the DMA_CH(#i)_Tx_Control register are set.

The application must provide the MSS by either programming the MSS value in the DMA_CH(#i)_Control register or by providing a context descriptor. The DMA uses the last programmed value of MSS or the last MSS value provided through context (whichever is provided later).

The header length plus the MSS size (which is equal to the size of each TCP segment) must not exceed 16383 bytes, otherwise, the MAC transmitter truncates the packet after 16383 bytes causing a CRC error. The header length plus MSS size plus programmed PBL value in DMA_CH(#i)_Tx_Control register must be lesser than the TX queue size programmed in TQS field of MTL_TxQ(#i)_Operation_mode register. The MSS with header size must be equal to half the programmed TX queue size. The value programmed in the MSS field must be more than the configured data width in bytes. It is recommended to use a MSS value of 64 bytes or more.

The DMA also supports segmentation of VLAN tagged TCP/IP frames, so if the TCP packet has a VLAN tag, the same tag is used for all the segments irrespective of the VLAN tag type provided (C-VLAN or S-VLAN). The VLAN tag insert/replace control bits are used for all segments.

The application must not set the TSE bit in TDES3 for a TCP/IP packet with two tags. The DMA behavior in this scenario is unpredictable. If the TSE bit is set in TDES3 for the packet and TCP header length provided is less than 5 (meaning an invalid TCP header because it is less than 20 bytes), the DMA does not perform segmentation. Instead, the DMA transmits the entire packet as a single packet. In this scenario, the CRC pad control bits are forced by DMA to 2'b00 (MAC does CRC and padding), and checksum insertion control bits are forced to 2'b11 (hardware does the checksum calculation for both header and payload).