1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2020 Inspur Corporation
5 #ifndef _GRO_VXLAN_UDP4_H_
6 #define _GRO_VXLAN_UDP4_H_
10 #define GRO_VXLAN_UDP4_TBL_MAX_ITEM_NUM (1024UL * 1024UL)
12 /* Header fields representing a VxLAN flow */
13 struct vxlan_udp4_flow_key {
14 struct udp4_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;
23 /* Note: It is unnecessary to save outer_src_port here because it can
24 * be different for VxLAN UDP fragments from the same flow.
26 uint16_t outer_dst_port;
29 struct gro_vxlan_udp4_flow {
30 struct vxlan_udp4_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_udp4_item {
39 struct gro_udp4_item inner_item;
40 /* Note: VXLAN UDP/IPv4 GRO needn't check outer_ip_id because
41 * the difference between outer_ip_ids of two received packets
42 * isn't always +/-1 in case of OVS DPDK. So no outer_ip_id
43 * and outer_is_atomic fields here.
48 * VxLAN (with an outer IPv4 header and an inner UDP/IPv4 packet)
49 * reassembly table structure
51 struct gro_vxlan_udp4_tbl {
53 struct gro_vxlan_udp4_item *items;
55 struct gro_vxlan_udp4_flow *flows;
56 /* current item number */
58 /* current flow number */
60 /* the maximum item number */
61 uint32_t max_item_num;
62 /* the maximum flow number */
63 uint32_t max_flow_num;
67 * This function creates a VxLAN reassembly table for VxLAN packets
68 * which have an outer IPv4 header and an inner UDP/IPv4 packet.
71 * Socket index for allocating the table
73 * The maximum number of flows in the table
74 * @param max_item_per_flow
75 * The maximum number of packets per flow
78 * - Return the table pointer on success.
79 * - Return NULL on failure.
81 void *gro_vxlan_udp4_tbl_create(uint16_t socket_id,
82 uint16_t max_flow_num,
83 uint16_t max_item_per_flow);
86 * This function destroys a VxLAN reassembly table.
89 * Pointer pointing to the VxLAN reassembly table
91 void gro_vxlan_udp4_tbl_destroy(void *tbl);
94 * This function merges a VxLAN packet which has an outer IPv4 header and
95 * an inner UDP/IPv4 packet. It does not process the packet which does not
98 * This function does not check if the packet has correct checksums and
99 * does not re-calculate checksums for the merged packet. It returns the
100 * packet if there is no available space in the table.
103 * Packet to reassemble
105 * Pointer pointing to the VxLAN reassembly table
107 * The time when the packet is inserted into the table
110 * - Return a positive value if the packet is merged.
111 * - Return zero if the packet isn't merged but stored in the table.
112 * - Return a negative value for invalid parameters or no available
113 * space in the table.
115 int32_t gro_vxlan_udp4_reassemble(struct rte_mbuf *pkt,
116 struct gro_vxlan_udp4_tbl *tbl,
117 uint64_t start_time);
120 * This function flushes timeout packets in the VxLAN reassembly table,
121 * and without updating checksums.
124 * Pointer pointing to a VxLAN GRO table
125 * @param flush_timestamp
126 * This function flushes packets which are inserted into the table
127 * before or at the flush_timestamp.
129 * Pointer array used to keep flushed packets
131 * The element number in 'out'. It also determines the maximum number of
132 * packets that can be flushed finally.
135 * The number of flushed packets
137 uint16_t gro_vxlan_udp4_tbl_timeout_flush(struct gro_vxlan_udp4_tbl *tbl,
138 uint64_t flush_timestamp,
139 struct rte_mbuf **out,
143 * This function returns the number of the packets in a VxLAN
147 * Pointer pointing to the VxLAN reassembly table
150 * The number of packets in the table
152 uint32_t gro_vxlan_udp4_tbl_pkt_count(void *tbl);