1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2018 Intel Corporation
5 #ifndef _GRO_VXLAN_TCP4_H_
6 #define _GRO_VXLAN_TCP4_H_
10 #define GRO_VXLAN_TCP4_TBL_MAX_ITEM_NUM (1024UL * 1024UL)
12 /* Header fields representing a VxLAN flow */
13 struct vxlan_tcp4_flow_key {
14 struct tcp4_flow_key inner_key;
15 struct rte_vxlan_hdr vxlan_hdr;
17 struct rte_ether_addr outer_eth_saddr;
18 struct rte_ether_addr outer_eth_daddr;
20 uint32_t outer_ip_src_addr;
21 uint32_t outer_ip_dst_addr;
24 uint16_t outer_src_port;
25 uint16_t outer_dst_port;
29 struct gro_vxlan_tcp4_flow {
30 struct vxlan_tcp4_flow_key key;
32 * The index of the first packet in the flow. INVALID_ARRAY_INDEX
33 * indicates an empty flow.
38 struct gro_vxlan_tcp4_item {
39 struct gro_tcp4_item inner_item;
40 /* IPv4 ID in the outer IPv4 header */
42 /* Indicate if outer IPv4 ID can be ignored */
43 uint8_t outer_is_atomic;
47 * VxLAN (with an outer IPv4 header and an inner TCP/IPv4 packet)
48 * reassembly table structure
50 struct gro_vxlan_tcp4_tbl {
52 struct gro_vxlan_tcp4_item *items;
54 struct gro_vxlan_tcp4_flow *flows;
55 /* current item number */
57 /* current flow number */
59 /* the maximum item number */
60 uint32_t max_item_num;
61 /* the maximum flow number */
62 uint32_t max_flow_num;
66 * This function creates a VxLAN reassembly table for VxLAN packets
67 * which have an outer IPv4 header and an inner TCP/IPv4 packet.
70 * Socket index for allocating the table
72 * The maximum number of flows in the table
73 * @param max_item_per_flow
74 * The maximum number of packets per flow
77 * - Return the table pointer on success.
78 * - Return NULL on failure.
80 void *gro_vxlan_tcp4_tbl_create(uint16_t socket_id,
81 uint16_t max_flow_num,
82 uint16_t max_item_per_flow);
85 * This function destroys a VxLAN reassembly table.
88 * Pointer pointing to the VxLAN reassembly table
90 void gro_vxlan_tcp4_tbl_destroy(void *tbl);
93 * This function merges a VxLAN packet which has an outer IPv4 header and
94 * an inner TCP/IPv4 packet. It doesn't process the packet, whose TCP
95 * header has SYN, FIN, RST, PSH, CWR, ECE or URG bit set, or which
96 * doesn't have payload.
98 * This function doesn't check if the packet has correct checksums and
99 * doesn't re-calculate checksums for the merged packet. Additionally,
100 * it assumes the packets are complete (i.e., MF==0 && frag_off==0), when
101 * IP fragmentation is possible (i.e., DF==0). It returns the packet, if
102 * the packet has invalid parameters (e.g. SYN bit is set) or there is no
103 * available space in the table.
106 * Packet to reassemble
108 * Pointer pointing to the VxLAN reassembly table
110 * The time when the packet is inserted into the table
113 * - Return a positive value if the packet is merged.
114 * - Return zero if the packet isn't merged but stored in the table.
115 * - Return a negative value for invalid parameters or no available
116 * space in the table.
118 int32_t gro_vxlan_tcp4_reassemble(struct rte_mbuf *pkt,
119 struct gro_vxlan_tcp4_tbl *tbl,
120 uint64_t start_time);
123 * This function flushes timeout packets in the VxLAN reassembly table,
124 * and without updating checksums.
127 * Pointer pointing to a VxLAN GRO table
128 * @param flush_timestamp
129 * This function flushes packets which are inserted into the table
130 * before or at the flush_timestamp.
132 * Pointer array used to keep flushed packets
134 * The element number in 'out'. It also determines the maximum number of
135 * packets that can be flushed finally.
138 * The number of flushed packets
140 uint16_t gro_vxlan_tcp4_tbl_timeout_flush(struct gro_vxlan_tcp4_tbl *tbl,
141 uint64_t flush_timestamp,
142 struct rte_mbuf **out,
146 * This function returns the number of the packets in a VxLAN
150 * Pointer pointing to the VxLAN reassembly table
153 * The number of packets in the table
155 uint32_t gro_vxlan_tcp4_tbl_pkt_count(void *tbl);