[dpdk-dev] [PATCH v12 2/3] lib/gro: add TCP/IPv4 GRO support

Tan, Jianfeng jianfeng.tan at intel.com
Sat Jul 8 18:37:46 CEST 2017



On 7/7/2017 6:39 PM, Jiayu Hu wrote:
> In this patch, we introduce five APIs to support TCP/IPv4 GRO.
> - gro_tcp4_reassemble: reassemble an inputted TCP/IPv4 packet.
> - gro_tcp4_tbl_create: create a TCP/IPv4 reassembly table, which is used
>      to merge packets.
> - gro_tcp4_tbl_destroy: free memory space of a TCP/IPv4 reassembly table.
> - gro_tcp4_tbl_pkt_count: return the number of packets in a TCP/IPv4
>      reassembly table.
> - gro_tcp4_tbl_timeout_flush: flush timeout packets from a TCP/IPv4
>      reassembly table.
>
> TCP/IPv4 GRO API assumes all inputted packets are with correct IPv4
> and TCP checksums. And TCP/IPv4 GRO API doesn't update IPv4 and TCP
> checksums for merged packets. If inputted packets are IP fragmented,
> TCP/IPv4 GRO API assumes they are complete packets (i.e. with L4
> headers).
>
> In TCP/IPv4 GRO, we use a table structure, called TCP/IPv4 reassembly
> table, to reassemble packets. A TCP/IPv4 reassembly table includes a key
> array and a item array, where the key array keeps the criteria to merge
> packets and the item array keeps packet information.
>
> One key in the key array points to an item group, which consists of
> packets which have the same criteria value. If two packets are able to
> merge, they must be in the same item group. Each key in the key array
> includes two parts:
> - criteria: the criteria of merging packets. If two packets can be
>      merged, they must have the same criteria value.
> - start_index: the index of the first incoming packet of the item group.
>
> Each element in the item array keeps the information of one packet. It
> mainly includes three parts:
> - firstseg: the address of the first segment of the packet
> - lastseg: the address of the last segment of the packet
> - next_pkt_index: the index of the next packet in the same item group.
>      All packets in the same item group are chained by next_pkt_index.
>      With next_pkt_index, we can locate all packets in the same item
>      group one by one.
>
> To process an incoming packet needs three steps:
> a. check if the packet should be processed. Packets with one of the
>      following properties won't be processed:
> 	- FIN, SYN, RST, URG, PSH, ECE or CWR bit is set;
> 	- packet payload length is 0.
> b. traverse the key array to find a key which has the same criteria
>      value with the incoming packet. If find, goto step c. Otherwise,
>      insert a new key and insert the packet into the item array.
> c. locate the first packet in the item group via the start_index in the
>      key. Then traverse all packets in the item group via next_pkt_index.
>      If find one packet which can merge with the incoming one, merge them
>      together. If can't find, insert the packet into this item group.
>
> Signed-off-by: Jiayu Hu <jiayu.hu at intel.com>

Reviewed-by: Jianfeng Tan <jianfeng.tan at intel.com>


More information about the dev mailing list