1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2017 Intel Corporation
10 * Interface to GRO library
20 #define RTE_GRO_MAX_BURST_ITEM_NUM 128U
21 /**< the max number of packets that rte_gro_reassemble_burst()
22 * can process in each invocation.
24 #define RTE_GRO_TYPE_MAX_NUM 64
25 /**< the max number of supported GRO types */
26 #define RTE_GRO_TYPE_SUPPORT_NUM 1
27 /**< the number of currently supported GRO types */
29 #define RTE_GRO_TCP_IPV4_INDEX 0
30 #define RTE_GRO_TCP_IPV4 (1ULL << RTE_GRO_TCP_IPV4_INDEX)
31 /**< TCP/IPv4 GRO flag */
34 * A structure which is used to create GRO context objects or tell
35 * rte_gro_reassemble_burst() what reassembly rules are demanded.
37 struct rte_gro_param {
39 /**< desired GRO types */
40 uint16_t max_flow_num;
41 /**< max flow number */
42 uint16_t max_item_per_flow;
43 /**< max packet number per flow */
45 /**< socket index for allocating GRO related data structures,
46 * like reassembly tables. When use rte_gro_reassemble_burst(),
47 * applications don't need to set this value.
53 * @b EXPERIMENTAL: this API may change without prior notice
55 * This function create a GRO context object, which is used to merge
56 * packets in rte_gro_reassemble().
59 * applications use it to pass needed parameters to create a GRO
63 * if create successfully, return a pointer which points to the GRO
64 * context object. Otherwise, return NULL.
66 void *rte_gro_ctx_create(const struct rte_gro_param *param);
70 * @b EXPERIMENTAL: this API may change without prior notice
72 * This function destroys a GRO context object.
75 * pointer points to a GRO context object.
77 void rte_gro_ctx_destroy(void *ctx);
80 * This is one of the main reassembly APIs, which merges numbers of
81 * packets at a time. It assumes that all inputted packets are with
82 * correct checksums. That is, applications should guarantee all
83 * inputted packets are correct. Besides, it doesn't re-calculate
84 * checksums for merged packets. If inputted packets are IP fragmented,
85 * this function assumes them are complete (i.e. with L4 header). After
86 * finishing processing, it returns all GROed packets to applications
90 * a pointer array which points to the packets to reassemble. Besides,
91 * it keeps mbuf addresses for the GROed packets.
93 * the number of packets to reassemble.
95 * applications use it to tell rte_gro_reassemble_burst() what rules
99 * the number of packets after been GROed. If no packets are merged,
100 * the returned value is nb_pkts.
102 uint16_t rte_gro_reassemble_burst(struct rte_mbuf **pkts,
104 const struct rte_gro_param *param);
108 * @b EXPERIMENTAL: this API may change without prior notice
110 * Reassembly function, which tries to merge inputted packets with
111 * the packets in the reassembly tables of a given GRO context. This
112 * function assumes all inputted packets are with correct checksums.
113 * And it won't update checksums if two packets are merged. Besides,
114 * if inputted packets are IP fragmented, this function assumes they
115 * are complete packets (i.e. with L4 header).
117 * If the inputted packets don't have data or are with unsupported GRO
118 * types etc., they won't be processed and are returned to applications.
119 * Otherwise, the inputted packets are either merged or inserted into
120 * the table. If applications want get packets in the table, they need
124 * packet to reassemble. Besides, after this function finishes, it
125 * keeps the unprocessed packets (e.g. without data or unsupported
128 * the number of packets to reassemble.
130 * a pointer points to a GRO context object.
133 * return the number of unprocessed packets (e.g. without data or
134 * unsupported GRO types). If all packets are processed (merged or
135 * inserted into the table), return 0.
137 uint16_t rte_gro_reassemble(struct rte_mbuf **pkts,
143 * @b EXPERIMENTAL: this API may change without prior notice
145 * This function flushes the timeout packets from reassembly tables of
146 * desired GRO types. The max number of flushed timeout packets is the
147 * element number of the array which is used to keep the flushed packets.
149 * Besides, this function won't re-calculate checksums for merged
150 * packets in the tables. That is, the returned packets may be with
154 * a pointer points to a GRO context object.
155 * @param timeout_cycles
156 * max TTL for packets in reassembly tables, measured in nanosecond.
158 * this function only flushes packets which belong to the GRO types
159 * specified by gro_types.
161 * a pointer array that is used to keep flushed timeout packets.
163 * the element number of out. It's also the max number of timeout
164 * packets that can be flushed finally.
167 * the number of flushed packets. If no packets are flushed, return 0.
169 uint16_t rte_gro_timeout_flush(void *ctx,
170 uint64_t timeout_cycles,
172 struct rte_mbuf **out,
173 uint16_t max_nb_out);
177 * @b EXPERIMENTAL: this API may change without prior notice
179 * This function returns the number of packets in all reassembly tables
180 * of a given GRO context.
183 * pointer points to a GRO context object.
186 * the number of packets in all reassembly tables.
188 uint64_t rte_gro_get_pkt_count(void *ctx);
194 #endif /* _RTE_GRO_H_ */