4 * Copyright(c) 2017 Intel Corporation. All rights reserved.
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
10 * * Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * * Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in
14 * the documentation and/or other materials provided with the
16 * * Neither the name of Intel Corporation nor the names of its
17 * contributors may be used to endorse or promote products derived
18 * from this software without specific prior written permission.
20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
38 * Interface to GRO library
48 #define RTE_GRO_MAX_BURST_ITEM_NUM 128U
49 /**< the max number of packets that rte_gro_reassemble_burst()
50 * can process in each invocation.
52 #define RTE_GRO_TYPE_MAX_NUM 64
53 /**< the max number of supported GRO types */
54 #define RTE_GRO_TYPE_SUPPORT_NUM 1
55 /**< the number of currently supported GRO types */
57 #define RTE_GRO_TCP_IPV4_INDEX 0
58 #define RTE_GRO_TCP_IPV4 (1ULL << RTE_GRO_TCP_IPV4_INDEX)
59 /**< TCP/IPv4 GRO flag */
62 * A structure which is used to create GRO context objects or tell
63 * rte_gro_reassemble_burst() what reassembly rules are demanded.
65 struct rte_gro_param {
67 /**< desired GRO types */
68 uint16_t max_flow_num;
69 /**< max flow number */
70 uint16_t max_item_per_flow;
71 /**< max packet number per flow */
73 /**< socket index for allocating GRO related data structures,
74 * like reassembly tables. When use rte_gro_reassemble_burst(),
75 * applications don't need to set this value.
81 * @b EXPERIMENTAL: this API may change without prior notice
83 * This function create a GRO context object, which is used to merge
84 * packets in rte_gro_reassemble().
87 * applications use it to pass needed parameters to create a GRO
91 * if create successfully, return a pointer which points to the GRO
92 * context object. Otherwise, return NULL.
94 void *rte_gro_ctx_create(const struct rte_gro_param *param);
98 * @b EXPERIMENTAL: this API may change without prior notice
100 * This function destroys a GRO context object.
103 * pointer points to a GRO context object.
105 void rte_gro_ctx_destroy(void *ctx);
108 * This is one of the main reassembly APIs, which merges numbers of
109 * packets at a time. It assumes that all inputted packets are with
110 * correct checksums. That is, applications should guarantee all
111 * inputted packets are correct. Besides, it doesn't re-calculate
112 * checksums for merged packets. If inputted packets are IP fragmented,
113 * this function assumes them are complete (i.e. with L4 header). After
114 * finishing processing, it returns all GROed packets to applications
118 * a pointer array which points to the packets to reassemble. Besides,
119 * it keeps mbuf addresses for the GROed packets.
121 * the number of packets to reassemble.
123 * applications use it to tell rte_gro_reassemble_burst() what rules
127 * the number of packets after been GROed. If no packets are merged,
128 * the returned value is nb_pkts.
130 uint16_t rte_gro_reassemble_burst(struct rte_mbuf **pkts,
132 const struct rte_gro_param *param);
136 * @b EXPERIMENTAL: this API may change without prior notice
138 * Reassembly function, which tries to merge inputted packets with
139 * the packets in the reassembly tables of a given GRO context. This
140 * function assumes all inputted packets are with correct checksums.
141 * And it won't update checksums if two packets are merged. Besides,
142 * if inputted packets are IP fragmented, this function assumes they
143 * are complete packets (i.e. with L4 header).
145 * If the inputted packets don't have data or are with unsupported GRO
146 * types etc., they won't be processed and are returned to applications.
147 * Otherwise, the inputted packets are either merged or inserted into
148 * the table. If applications want get packets in the table, they need
152 * packet to reassemble. Besides, after this function finishes, it
153 * keeps the unprocessed packets (e.g. without data or unsupported
156 * the number of packets to reassemble.
158 * a pointer points to a GRO context object.
161 * return the number of unprocessed packets (e.g. without data or
162 * unsupported GRO types). If all packets are processed (merged or
163 * inserted into the table), return 0.
165 uint16_t rte_gro_reassemble(struct rte_mbuf **pkts,
171 * @b EXPERIMENTAL: this API may change without prior notice
173 * This function flushes the timeout packets from reassembly tables of
174 * desired GRO types. The max number of flushed timeout packets is the
175 * element number of the array which is used to keep the flushed packets.
177 * Besides, this function won't re-calculate checksums for merged
178 * packets in the tables. That is, the returned packets may be with
182 * a pointer points to a GRO context object.
183 * @param timeout_cycles
184 * max TTL for packets in reassembly tables, measured in nanosecond.
186 * this function only flushes packets which belong to the GRO types
187 * specified by gro_types.
189 * a pointer array that is used to keep flushed timeout packets.
191 * the element number of out. It's also the max number of timeout
192 * packets that can be flushed finally.
195 * the number of flushed packets. If no packets are flushed, return 0.
197 uint16_t rte_gro_timeout_flush(void *ctx,
198 uint64_t timeout_cycles,
200 struct rte_mbuf **out,
201 uint16_t max_nb_out);
205 * @b EXPERIMENTAL: this API may change without prior notice
207 * This function returns the number of packets in all reassembly tables
208 * of a given GRO context.
211 * pointer points to a GRO context object.
214 * the number of packets in all reassembly tables.
216 uint64_t rte_gro_get_pkt_count(void *ctx);
222 #endif /* _RTE_GRO_H_ */