Branch data Line data Source code
1 : : /* SPDX-License-Identifier: BSD-3-Clause
2 : : * Copyright(c) 2017 Intel Corporation
3 : : */
4 : :
5 : : #include <eal_export.h>
6 : : #include <rte_malloc.h>
7 : : #include <rte_cycles.h>
8 : : #include <rte_ethdev.h>
9 : :
10 : : #include "rte_gro.h"
11 : : #include "gro_tcp4.h"
12 : : #include "gro_tcp6.h"
13 : : #include "gro_udp4.h"
14 : : #include "gro_vxlan_tcp4.h"
15 : : #include "gro_vxlan_udp4.h"
16 : :
17 : : typedef void *(*gro_tbl_create_fn)(uint16_t socket_id,
18 : : uint16_t max_flow_num,
19 : : uint16_t max_item_per_flow);
20 : : typedef void (*gro_tbl_destroy_fn)(void *tbl);
21 : : typedef uint32_t (*gro_tbl_pkt_count_fn)(void *tbl);
22 : :
23 : : static gro_tbl_create_fn tbl_create_fn[RTE_GRO_TYPE_MAX_NUM] = {
24 : : gro_tcp4_tbl_create, gro_vxlan_tcp4_tbl_create,
25 : : gro_udp4_tbl_create, gro_vxlan_udp4_tbl_create, gro_tcp6_tbl_create, NULL};
26 : : static gro_tbl_destroy_fn tbl_destroy_fn[RTE_GRO_TYPE_MAX_NUM] = {
27 : : gro_tcp4_tbl_destroy, gro_vxlan_tcp4_tbl_destroy,
28 : : gro_udp4_tbl_destroy, gro_vxlan_udp4_tbl_destroy,
29 : : gro_tcp6_tbl_destroy,
30 : : NULL};
31 : : static gro_tbl_pkt_count_fn tbl_pkt_count_fn[RTE_GRO_TYPE_MAX_NUM] = {
32 : : gro_tcp4_tbl_pkt_count, gro_vxlan_tcp4_tbl_pkt_count,
33 : : gro_udp4_tbl_pkt_count, gro_vxlan_udp4_tbl_pkt_count,
34 : : gro_tcp6_tbl_pkt_count,
35 : : NULL};
36 : :
37 : : #define IS_IPV4_TCP_PKT(ptype) (RTE_ETH_IS_IPV4_HDR(ptype) && \
38 : : ((ptype & RTE_PTYPE_L4_MASK) == RTE_PTYPE_L4_TCP) && \
39 : : (RTE_ETH_IS_TUNNEL_PKT(ptype) == 0))
40 : :
41 : : /* GRO with extension headers is not supported */
42 : : #define IS_IPV6_TCP_PKT(ptype) (RTE_ETH_IS_IPV6_HDR(ptype) && \
43 : : ((ptype & RTE_PTYPE_L4_MASK) == RTE_PTYPE_L4_TCP) && \
44 : : (RTE_ETH_IS_TUNNEL_PKT(ptype) == 0))
45 : :
46 : : /* GRO for UDP ingests IP fragments */
47 : : #define IS_IPV4_FRAG_PKT(ptype) (RTE_ETH_IS_IPV4_HDR(ptype) && \
48 : : ((ptype & RTE_PTYPE_L4_MASK) == RTE_PTYPE_L4_FRAG) && \
49 : : (RTE_ETH_IS_TUNNEL_PKT(ptype) == 0))
50 : :
51 : : #define IS_IPV4_VXLAN_TCP4_PKT(ptype) (RTE_ETH_IS_IPV4_HDR(ptype) && \
52 : : ((ptype & RTE_PTYPE_L4_MASK) == RTE_PTYPE_L4_UDP) && \
53 : : ((ptype & RTE_PTYPE_TUNNEL_MASK) == \
54 : : RTE_PTYPE_TUNNEL_VXLAN) && \
55 : : ((ptype & RTE_PTYPE_INNER_L4_MASK) == \
56 : : RTE_PTYPE_INNER_L4_TCP) && \
57 : : (((ptype & RTE_PTYPE_INNER_L3_MASK) == \
58 : : RTE_PTYPE_INNER_L3_IPV4) || \
59 : : ((ptype & RTE_PTYPE_INNER_L3_MASK) == \
60 : : RTE_PTYPE_INNER_L3_IPV4_EXT) || \
61 : : ((ptype & RTE_PTYPE_INNER_L3_MASK) == \
62 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN)))
63 : :
64 : : /* GRO for inner UDP of VXLAN ingests inner IP fragments */
65 : : #define IS_IPV4_VXLAN_FRAG4_PKT(ptype) (RTE_ETH_IS_IPV4_HDR(ptype) && \
66 : : ((ptype & RTE_PTYPE_L4_MASK) == RTE_PTYPE_L4_UDP) && \
67 : : ((ptype & RTE_PTYPE_TUNNEL_MASK) == \
68 : : RTE_PTYPE_TUNNEL_VXLAN) && \
69 : : ((ptype & RTE_PTYPE_INNER_L4_MASK) == \
70 : : RTE_PTYPE_INNER_L4_FRAG) && \
71 : : (((ptype & RTE_PTYPE_INNER_L3_MASK) == \
72 : : RTE_PTYPE_INNER_L3_IPV4) || \
73 : : ((ptype & RTE_PTYPE_INNER_L3_MASK) == \
74 : : RTE_PTYPE_INNER_L3_IPV4_EXT) || \
75 : : ((ptype & RTE_PTYPE_INNER_L3_MASK) == \
76 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN)))
77 : :
78 : : /*
79 : : * GRO context structure. It keeps the table structures, which are
80 : : * used to merge packets, for different GRO types. Before using
81 : : * rte_gro_reassemble(), applications need to create the GRO context
82 : : * first.
83 : : */
84 : : struct gro_ctx {
85 : : /* GRO types to perform */
86 : : uint64_t gro_types;
87 : : /* reassembly tables */
88 : : void *tbls[RTE_GRO_TYPE_MAX_NUM];
89 : : };
90 : :
91 : : RTE_EXPORT_SYMBOL(rte_gro_ctx_create)
92 : : void *
93 : 0 : rte_gro_ctx_create(const struct rte_gro_param *param)
94 : : {
95 : : struct gro_ctx *gro_ctx;
96 : : gro_tbl_create_fn create_tbl_fn;
97 : : uint64_t gro_type_flag = 0;
98 : : uint64_t gro_types = 0;
99 : : uint8_t i;
100 : :
101 : 0 : gro_ctx = rte_zmalloc_socket(__func__,
102 : : sizeof(struct gro_ctx),
103 : : RTE_CACHE_LINE_SIZE,
104 : 0 : param->socket_id);
105 [ # # ]: 0 : if (gro_ctx == NULL)
106 : : return NULL;
107 : :
108 [ # # ]: 0 : for (i = 0; i < RTE_GRO_TYPE_MAX_NUM; i++) {
109 : 0 : gro_type_flag = 1ULL << i;
110 [ # # ]: 0 : if ((param->gro_types & gro_type_flag) == 0)
111 : 0 : continue;
112 : :
113 : 0 : create_tbl_fn = tbl_create_fn[i];
114 [ # # ]: 0 : if (create_tbl_fn == NULL)
115 : 0 : continue;
116 : :
117 : 0 : gro_ctx->tbls[i] = create_tbl_fn(param->socket_id,
118 : 0 : param->max_flow_num,
119 : 0 : param->max_item_per_flow);
120 [ # # ]: 0 : if (gro_ctx->tbls[i] == NULL) {
121 : : /* destroy all created tables */
122 : 0 : gro_ctx->gro_types = gro_types;
123 : 0 : rte_gro_ctx_destroy(gro_ctx);
124 : 0 : return NULL;
125 : : }
126 : 0 : gro_types |= gro_type_flag;
127 : : }
128 : 0 : gro_ctx->gro_types = param->gro_types;
129 : :
130 : 0 : return gro_ctx;
131 : : }
132 : :
133 : : RTE_EXPORT_SYMBOL(rte_gro_ctx_destroy)
134 : : void
135 : 0 : rte_gro_ctx_destroy(void *ctx)
136 : : {
137 : : gro_tbl_destroy_fn destroy_tbl_fn;
138 : : struct gro_ctx *gro_ctx = ctx;
139 : : uint64_t gro_type_flag;
140 : : uint8_t i;
141 : :
142 [ # # ]: 0 : for (i = 0; i < RTE_GRO_TYPE_MAX_NUM; i++) {
143 : 0 : gro_type_flag = 1ULL << i;
144 [ # # ]: 0 : if ((gro_ctx->gro_types & gro_type_flag) == 0)
145 : 0 : continue;
146 : 0 : destroy_tbl_fn = tbl_destroy_fn[i];
147 [ # # ]: 0 : if (destroy_tbl_fn)
148 : 0 : destroy_tbl_fn(gro_ctx->tbls[i]);
149 : : }
150 : 0 : rte_free(gro_ctx);
151 : 0 : }
152 : :
153 : : RTE_EXPORT_SYMBOL(rte_gro_reassemble_burst)
154 : : uint16_t
155 : 0 : rte_gro_reassemble_burst(struct rte_mbuf **pkts,
156 : : uint16_t nb_pkts,
157 : : const struct rte_gro_param *param)
158 : : {
159 : : /* allocate a reassembly table for TCP/IPv4 GRO */
160 : : struct gro_tcp4_tbl tcp_tbl;
161 : : struct gro_tcp4_flow tcp_flows[RTE_GRO_MAX_BURST_ITEM_NUM];
162 : 0 : struct gro_tcp_item tcp_items[RTE_GRO_MAX_BURST_ITEM_NUM] = {{0} };
163 : :
164 : : struct gro_tcp6_tbl tcp6_tbl;
165 : : struct gro_tcp6_flow tcp6_flows[RTE_GRO_MAX_BURST_ITEM_NUM];
166 : 0 : struct gro_tcp_item tcp6_items[RTE_GRO_MAX_BURST_ITEM_NUM] = {{0} };
167 : :
168 : : /* allocate a reassembly table for UDP/IPv4 GRO */
169 : : struct gro_udp4_tbl udp_tbl;
170 : : struct gro_udp4_flow udp_flows[RTE_GRO_MAX_BURST_ITEM_NUM];
171 : 0 : struct gro_udp4_item udp_items[RTE_GRO_MAX_BURST_ITEM_NUM] = {{0} };
172 : :
173 : : /* Allocate a reassembly table for VXLAN TCP GRO */
174 : : struct gro_vxlan_tcp4_tbl vxlan_tcp_tbl;
175 : : struct gro_vxlan_tcp4_flow vxlan_tcp_flows[RTE_GRO_MAX_BURST_ITEM_NUM];
176 : 0 : struct gro_vxlan_tcp4_item vxlan_tcp_items[RTE_GRO_MAX_BURST_ITEM_NUM]
177 : : = {{{0}, 0, 0} };
178 : :
179 : : /* Allocate a reassembly table for VXLAN UDP GRO */
180 : : struct gro_vxlan_udp4_tbl vxlan_udp_tbl;
181 : : struct gro_vxlan_udp4_flow vxlan_udp_flows[RTE_GRO_MAX_BURST_ITEM_NUM];
182 : 0 : struct gro_vxlan_udp4_item vxlan_udp_items[RTE_GRO_MAX_BURST_ITEM_NUM]
183 : : = {{{0}} };
184 : :
185 : : uint32_t item_num;
186 : : int32_t ret;
187 : : uint16_t i, unprocess_num = 0, nb_after_gro = nb_pkts;
188 : : uint8_t do_tcp4_gro = 0, do_vxlan_tcp_gro = 0, do_udp4_gro = 0,
189 : : do_vxlan_udp_gro = 0, do_tcp6_gro = 0;
190 : :
191 [ # # ]: 0 : if (unlikely((param->gro_types & (RTE_GRO_IPV4_VXLAN_TCP_IPV4 |
192 : : RTE_GRO_TCP_IPV4 | RTE_GRO_TCP_IPV6 |
193 : : RTE_GRO_IPV4_VXLAN_UDP_IPV4 |
194 : : RTE_GRO_UDP_IPV4)) == 0))
195 : : return nb_pkts;
196 : :
197 : : /* Get the maximum number of packets */
198 : 0 : item_num = RTE_MIN(nb_pkts, (param->max_flow_num *
199 : : param->max_item_per_flow));
200 : 0 : item_num = RTE_MIN(item_num, RTE_GRO_MAX_BURST_ITEM_NUM);
201 : :
202 [ # # ]: 0 : if (param->gro_types & RTE_GRO_IPV4_VXLAN_TCP_IPV4) {
203 [ # # ]: 0 : for (i = 0; i < item_num; i++)
204 : 0 : vxlan_tcp_flows[i].start_index = INVALID_ARRAY_INDEX;
205 : :
206 : 0 : vxlan_tcp_tbl.flows = vxlan_tcp_flows;
207 : 0 : vxlan_tcp_tbl.items = vxlan_tcp_items;
208 : 0 : vxlan_tcp_tbl.flow_num = 0;
209 : 0 : vxlan_tcp_tbl.item_num = 0;
210 : 0 : vxlan_tcp_tbl.max_flow_num = item_num;
211 : 0 : vxlan_tcp_tbl.max_item_num = item_num;
212 : : do_vxlan_tcp_gro = 1;
213 : : }
214 : :
215 [ # # ]: 0 : if (param->gro_types & RTE_GRO_IPV4_VXLAN_UDP_IPV4) {
216 [ # # ]: 0 : for (i = 0; i < item_num; i++)
217 : 0 : vxlan_udp_flows[i].start_index = INVALID_ARRAY_INDEX;
218 : :
219 : 0 : vxlan_udp_tbl.flows = vxlan_udp_flows;
220 : 0 : vxlan_udp_tbl.items = vxlan_udp_items;
221 : 0 : vxlan_udp_tbl.flow_num = 0;
222 : 0 : vxlan_udp_tbl.item_num = 0;
223 : 0 : vxlan_udp_tbl.max_flow_num = item_num;
224 : 0 : vxlan_udp_tbl.max_item_num = item_num;
225 : : do_vxlan_udp_gro = 1;
226 : : }
227 : :
228 [ # # ]: 0 : if (param->gro_types & RTE_GRO_TCP_IPV4) {
229 [ # # ]: 0 : for (i = 0; i < item_num; i++)
230 : 0 : tcp_flows[i].start_index = INVALID_ARRAY_INDEX;
231 : :
232 : 0 : tcp_tbl.flows = tcp_flows;
233 : 0 : tcp_tbl.items = tcp_items;
234 : 0 : tcp_tbl.flow_num = 0;
235 : 0 : tcp_tbl.item_num = 0;
236 : 0 : tcp_tbl.max_flow_num = item_num;
237 : 0 : tcp_tbl.max_item_num = item_num;
238 : : do_tcp4_gro = 1;
239 : : }
240 : :
241 [ # # ]: 0 : if (param->gro_types & RTE_GRO_UDP_IPV4) {
242 [ # # ]: 0 : for (i = 0; i < item_num; i++)
243 : 0 : udp_flows[i].start_index = INVALID_ARRAY_INDEX;
244 : :
245 : 0 : udp_tbl.flows = udp_flows;
246 : 0 : udp_tbl.items = udp_items;
247 : 0 : udp_tbl.flow_num = 0;
248 : 0 : udp_tbl.item_num = 0;
249 : 0 : udp_tbl.max_flow_num = item_num;
250 : 0 : udp_tbl.max_item_num = item_num;
251 : : do_udp4_gro = 1;
252 : : }
253 : :
254 [ # # ]: 0 : if (param->gro_types & RTE_GRO_TCP_IPV6) {
255 [ # # ]: 0 : for (i = 0; i < item_num; i++)
256 : 0 : tcp6_flows[i].start_index = INVALID_ARRAY_INDEX;
257 : :
258 : 0 : tcp6_tbl.flows = tcp6_flows;
259 : 0 : tcp6_tbl.items = tcp6_items;
260 : 0 : tcp6_tbl.flow_num = 0;
261 : 0 : tcp6_tbl.item_num = 0;
262 : 0 : tcp6_tbl.max_flow_num = item_num;
263 : 0 : tcp6_tbl.max_item_num = item_num;
264 : : do_tcp6_gro = 1;
265 : : }
266 : :
267 [ # # ]: 0 : for (i = 0; i < nb_pkts; i++) {
268 : : /*
269 : : * The timestamp is ignored, since all packets
270 : : * will be flushed from the tables.
271 : : */
272 [ # # # # : 0 : if (IS_IPV4_VXLAN_TCP4_PKT(pkts[i]->packet_type) &&
# # # # ]
273 : : do_vxlan_tcp_gro) {
274 : 0 : ret = gro_vxlan_tcp4_reassemble(pkts[i],
275 : : &vxlan_tcp_tbl, 0);
276 [ # # ]: 0 : if (ret > 0)
277 : : /* Merge successfully */
278 : 0 : nb_after_gro--;
279 [ # # ]: 0 : else if (ret < 0)
280 : 0 : pkts[unprocess_num++] = pkts[i];
281 [ # # # # : 0 : } else if (IS_IPV4_VXLAN_FRAG4_PKT(pkts[i]->packet_type) &&
# # # # ]
282 : : do_vxlan_udp_gro) {
283 : 0 : ret = gro_vxlan_udp4_reassemble(pkts[i],
284 : : &vxlan_udp_tbl, 0);
285 [ # # ]: 0 : if (ret > 0)
286 : : /* Merge successfully */
287 : 0 : nb_after_gro--;
288 [ # # ]: 0 : else if (ret < 0)
289 : 0 : pkts[unprocess_num++] = pkts[i];
290 [ # # # # ]: 0 : } else if (IS_IPV4_TCP_PKT(pkts[i]->packet_type) &&
291 : : do_tcp4_gro) {
292 : 0 : ret = gro_tcp4_reassemble(pkts[i], &tcp_tbl, 0);
293 [ # # ]: 0 : if (ret > 0)
294 : : /* merge successfully */
295 : 0 : nb_after_gro--;
296 [ # # ]: 0 : else if (ret < 0)
297 : 0 : pkts[unprocess_num++] = pkts[i];
298 [ # # # # ]: 0 : } else if (IS_IPV4_FRAG_PKT(pkts[i]->packet_type) &&
299 : : do_udp4_gro) {
300 : 0 : ret = gro_udp4_reassemble(pkts[i], &udp_tbl, 0);
301 [ # # ]: 0 : if (ret > 0)
302 : : /* merge successfully */
303 : 0 : nb_after_gro--;
304 [ # # ]: 0 : else if (ret < 0)
305 : 0 : pkts[unprocess_num++] = pkts[i];
306 [ # # # # ]: 0 : } else if (IS_IPV6_TCP_PKT(pkts[i]->packet_type) &&
307 : : do_tcp6_gro) {
308 : 0 : ret = gro_tcp6_reassemble(pkts[i], &tcp6_tbl, 0);
309 [ # # ]: 0 : if (ret > 0)
310 : : /* merge successfully */
311 : 0 : nb_after_gro--;
312 [ # # ]: 0 : else if (ret < 0)
313 : 0 : pkts[unprocess_num++] = pkts[i];
314 : : } else
315 : 0 : pkts[unprocess_num++] = pkts[i];
316 : : }
317 : :
318 [ # # ]: 0 : if ((nb_after_gro < nb_pkts)
319 : : || (unprocess_num < nb_pkts)) {
320 : :
321 : : i = unprocess_num;
322 : :
323 : : /* Flush all packets from the tables */
324 [ # # ]: 0 : if (do_vxlan_tcp_gro) {
325 : 0 : i += gro_vxlan_tcp4_tbl_timeout_flush(&vxlan_tcp_tbl,
326 : 0 : 0, &pkts[i], nb_pkts - i);
327 : : }
328 : :
329 [ # # ]: 0 : if (do_vxlan_udp_gro) {
330 : 0 : i += gro_vxlan_udp4_tbl_timeout_flush(&vxlan_udp_tbl,
331 : 0 : 0, &pkts[i], nb_pkts - i);
332 : :
333 : : }
334 : :
335 [ # # ]: 0 : if (do_tcp4_gro) {
336 : 0 : i += gro_tcp4_tbl_timeout_flush(&tcp_tbl, 0,
337 : 0 : &pkts[i], nb_pkts - i);
338 : : }
339 : :
340 [ # # ]: 0 : if (do_udp4_gro) {
341 : 0 : i += gro_udp4_tbl_timeout_flush(&udp_tbl, 0,
342 : 0 : &pkts[i], nb_pkts - i);
343 : : }
344 : :
345 [ # # ]: 0 : if (do_tcp6_gro) {
346 : 0 : i += gro_tcp6_tbl_timeout_flush(&tcp6_tbl, 0,
347 : 0 : &pkts[i], nb_pkts - i);
348 : : }
349 : : }
350 : :
351 : : return i;
352 : : }
353 : :
354 : : RTE_EXPORT_SYMBOL(rte_gro_reassemble)
355 : : uint16_t
356 : 0 : rte_gro_reassemble(struct rte_mbuf **pkts,
357 : : uint16_t nb_pkts,
358 : : void *ctx)
359 : : {
360 : : struct gro_ctx *gro_ctx = ctx;
361 : : void *tcp_tbl, *udp_tbl, *vxlan_tcp_tbl, *vxlan_udp_tbl, *tcp6_tbl;
362 : : uint64_t current_time;
363 : : uint16_t i, unprocess_num = 0;
364 : : uint8_t do_tcp4_gro, do_vxlan_tcp_gro, do_udp4_gro, do_vxlan_udp_gro, do_tcp6_gro;
365 : :
366 [ # # ]: 0 : if (unlikely((gro_ctx->gro_types & (RTE_GRO_IPV4_VXLAN_TCP_IPV4 |
367 : : RTE_GRO_TCP_IPV4 | RTE_GRO_TCP_IPV6 |
368 : : RTE_GRO_IPV4_VXLAN_UDP_IPV4 |
369 : : RTE_GRO_UDP_IPV4)) == 0))
370 : : return nb_pkts;
371 : :
372 : 0 : tcp_tbl = gro_ctx->tbls[RTE_GRO_TCP_IPV4_INDEX];
373 : 0 : vxlan_tcp_tbl = gro_ctx->tbls[RTE_GRO_IPV4_VXLAN_TCP_IPV4_INDEX];
374 : 0 : udp_tbl = gro_ctx->tbls[RTE_GRO_UDP_IPV4_INDEX];
375 : 0 : vxlan_udp_tbl = gro_ctx->tbls[RTE_GRO_IPV4_VXLAN_UDP_IPV4_INDEX];
376 : 0 : tcp6_tbl = gro_ctx->tbls[RTE_GRO_TCP_IPV6_INDEX];
377 : :
378 : 0 : do_tcp4_gro = (gro_ctx->gro_types & RTE_GRO_TCP_IPV4) ==
379 : : RTE_GRO_TCP_IPV4;
380 : 0 : do_vxlan_tcp_gro = (gro_ctx->gro_types & RTE_GRO_IPV4_VXLAN_TCP_IPV4) ==
381 : : RTE_GRO_IPV4_VXLAN_TCP_IPV4;
382 : 0 : do_udp4_gro = (gro_ctx->gro_types & RTE_GRO_UDP_IPV4) ==
383 : : RTE_GRO_UDP_IPV4;
384 : 0 : do_vxlan_udp_gro = (gro_ctx->gro_types & RTE_GRO_IPV4_VXLAN_UDP_IPV4) ==
385 : : RTE_GRO_IPV4_VXLAN_UDP_IPV4;
386 : 0 : do_tcp6_gro = (gro_ctx->gro_types & RTE_GRO_TCP_IPV6) == RTE_GRO_TCP_IPV6;
387 : :
388 : : current_time = rte_rdtsc();
389 : :
390 [ # # ]: 0 : for (i = 0; i < nb_pkts; i++) {
391 [ # # # # : 0 : if (IS_IPV4_VXLAN_TCP4_PKT(pkts[i]->packet_type) &&
# # # # ]
392 : : do_vxlan_tcp_gro) {
393 [ # # ]: 0 : if (gro_vxlan_tcp4_reassemble(pkts[i], vxlan_tcp_tbl,
394 : : current_time) < 0)
395 : 0 : pkts[unprocess_num++] = pkts[i];
396 [ # # # # : 0 : } else if (IS_IPV4_VXLAN_FRAG4_PKT(pkts[i]->packet_type) &&
# # # # ]
397 : : do_vxlan_udp_gro) {
398 [ # # ]: 0 : if (gro_vxlan_udp4_reassemble(pkts[i], vxlan_udp_tbl,
399 : : current_time) < 0)
400 : 0 : pkts[unprocess_num++] = pkts[i];
401 [ # # # # ]: 0 : } else if (IS_IPV4_TCP_PKT(pkts[i]->packet_type) &&
402 : : do_tcp4_gro) {
403 [ # # ]: 0 : if (gro_tcp4_reassemble(pkts[i], tcp_tbl,
404 : : current_time) < 0)
405 : 0 : pkts[unprocess_num++] = pkts[i];
406 [ # # # # ]: 0 : } else if (IS_IPV4_FRAG_PKT(pkts[i]->packet_type) &&
407 : : do_udp4_gro) {
408 [ # # ]: 0 : if (gro_udp4_reassemble(pkts[i], udp_tbl,
409 : : current_time) < 0)
410 : 0 : pkts[unprocess_num++] = pkts[i];
411 [ # # # # ]: 0 : } else if (IS_IPV6_TCP_PKT(pkts[i]->packet_type) &&
412 : : do_tcp6_gro) {
413 [ # # ]: 0 : if (gro_tcp6_reassemble(pkts[i], tcp6_tbl,
414 : : current_time) < 0)
415 : 0 : pkts[unprocess_num++] = pkts[i];
416 : : } else
417 : 0 : pkts[unprocess_num++] = pkts[i];
418 : : }
419 : :
420 : : return unprocess_num;
421 : : }
422 : :
423 : : RTE_EXPORT_SYMBOL(rte_gro_timeout_flush)
424 : : uint16_t
425 : 0 : rte_gro_timeout_flush(void *ctx,
426 : : uint64_t timeout_cycles,
427 : : uint64_t gro_types,
428 : : struct rte_mbuf **out,
429 : : uint16_t max_nb_out)
430 : : {
431 : : struct gro_ctx *gro_ctx = ctx;
432 : : uint64_t flush_timestamp;
433 : : uint16_t num = 0;
434 : : uint16_t left_nb_out = max_nb_out;
435 : :
436 : 0 : gro_types = gro_types & gro_ctx->gro_types;
437 : 0 : flush_timestamp = rte_rdtsc() - timeout_cycles;
438 : :
439 [ # # ]: 0 : if (gro_types & RTE_GRO_IPV4_VXLAN_TCP_IPV4) {
440 : 0 : num = gro_vxlan_tcp4_tbl_timeout_flush(gro_ctx->tbls[
441 : : RTE_GRO_IPV4_VXLAN_TCP_IPV4_INDEX],
442 : : flush_timestamp, out, left_nb_out);
443 : 0 : left_nb_out = max_nb_out - num;
444 : : }
445 : :
446 [ # # # # ]: 0 : if ((gro_types & RTE_GRO_IPV4_VXLAN_UDP_IPV4) && left_nb_out > 0) {
447 : 0 : num += gro_vxlan_udp4_tbl_timeout_flush(gro_ctx->tbls[
448 : : RTE_GRO_IPV4_VXLAN_UDP_IPV4_INDEX],
449 : 0 : flush_timestamp, &out[num], left_nb_out);
450 : 0 : left_nb_out = max_nb_out - num;
451 : : }
452 : :
453 : : /* If no available space in 'out', stop flushing. */
454 [ # # # # ]: 0 : if ((gro_types & RTE_GRO_TCP_IPV4) && left_nb_out > 0) {
455 : 0 : num += gro_tcp4_tbl_timeout_flush(
456 : 0 : gro_ctx->tbls[RTE_GRO_TCP_IPV4_INDEX],
457 : : flush_timestamp,
458 : 0 : &out[num], left_nb_out);
459 : 0 : left_nb_out = max_nb_out - num;
460 : : }
461 : :
462 : : /* If no available space in 'out', stop flushing. */
463 [ # # # # ]: 0 : if ((gro_types & RTE_GRO_UDP_IPV4) && left_nb_out > 0) {
464 : 0 : num += gro_udp4_tbl_timeout_flush(
465 : 0 : gro_ctx->tbls[RTE_GRO_UDP_IPV4_INDEX],
466 : : flush_timestamp,
467 : 0 : &out[num], left_nb_out);
468 : 0 : left_nb_out = max_nb_out - num;
469 : : }
470 : :
471 [ # # # # ]: 0 : if ((gro_types & RTE_GRO_TCP_IPV6) && left_nb_out > 0) {
472 : 0 : num += gro_tcp6_tbl_timeout_flush(
473 : 0 : gro_ctx->tbls[RTE_GRO_TCP_IPV6_INDEX],
474 : : flush_timestamp,
475 : 0 : &out[num], left_nb_out);
476 : :
477 : : }
478 : :
479 : 0 : return num;
480 : : }
481 : :
482 : : RTE_EXPORT_SYMBOL(rte_gro_get_pkt_count)
483 : : uint64_t
484 : 0 : rte_gro_get_pkt_count(void *ctx)
485 : : {
486 : : struct gro_ctx *gro_ctx = ctx;
487 : : gro_tbl_pkt_count_fn pkt_count_fn;
488 : 0 : uint64_t gro_types = gro_ctx->gro_types, flag;
489 : : uint64_t item_num = 0;
490 : : uint8_t i;
491 : :
492 [ # # ]: 0 : for (i = 0; i < RTE_GRO_TYPE_MAX_NUM && gro_types; i++) {
493 : 0 : flag = 1ULL << i;
494 [ # # ]: 0 : if ((gro_types & flag) == 0)
495 : 0 : continue;
496 : :
497 : 0 : gro_types ^= flag;
498 : 0 : pkt_count_fn = tbl_pkt_count_fn[i];
499 [ # # ]: 0 : if (pkt_count_fn)
500 : 0 : item_num += pkt_count_fn(gro_ctx->tbls[i]);
501 : : }
502 : :
503 : 0 : return item_num;
504 : : }
|