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.
40 /**< the max packets number that rte_gro_reassemble_burst()
41 * can process in each invocation.
43 #define RTE_GRO_MAX_BURST_ITEM_NUM 128U
45 /**< max number of supported GRO types */
46 #define RTE_GRO_TYPE_MAX_NUM 64
47 /**< current supported GRO num */
48 #define RTE_GRO_TYPE_SUPPORT_NUM 1
50 /**< TCP/IPv4 GRO flag */
51 #define RTE_GRO_TCP_IPV4_INDEX 0
52 #define RTE_GRO_TCP_IPV4 (1ULL << RTE_GRO_TCP_IPV4_INDEX)
54 struct rte_gro_param {
55 /**< desired GRO types */
57 /**< max flow number */
58 uint16_t max_flow_num;
59 /**< max packet number per flow */
60 uint16_t max_item_per_flow;
61 /**< socket index for allocating GRO related data structures,
62 * like reassembly tables. When use rte_gro_reassemble_burst(),
63 * applications don't need to set this value.
70 * @b EXPERIMENTAL: this API may change without prior notice
72 * This function create a GRO context object, which is used to merge
73 * packets in rte_gro_reassemble().
76 * applications use it to pass needed parameters to create a GRO
80 * if create successfully, return a pointer which points to the GRO
81 * context object. Otherwise, return NULL.
83 void *rte_gro_ctx_create(const struct rte_gro_param *param);
87 * @b EXPERIMENTAL: this API may change without prior notice
89 * This function destroys a GRO context object.
92 * pointer points to a GRO context object.
94 void rte_gro_ctx_destroy(void *ctx);
97 * This is one of the main reassembly APIs, which merges numbers of
98 * packets at a time. It assumes that all inputted packets are with
99 * correct checksums. That is, applications should guarantee all
100 * inputted packets are correct. Besides, it doesn't re-calculate
101 * checksums for merged packets. If inputted packets are IP fragmented,
102 * this function assumes them are complete (i.e. with L4 header). After
103 * finishing processing, it returns all GROed packets to applications
107 * a pointer array which points to the packets to reassemble. Besides,
108 * it keeps packet addresses for GROed packets.
110 * the number of packets to reassemble.
112 * applications use it to tell rte_gro_reassemble_burst() what rules
116 * the number of packets after been GROed. If no packets are merged,
117 * the returned value is nb_pkts.
119 uint16_t rte_gro_reassemble_burst(struct rte_mbuf **pkts,
121 const struct rte_gro_param *param);
125 * @b EXPERIMENTAL: this API may change without prior notice
127 * Reassembly function, which tries to merge inputted packets with
128 * the packets in the reassembly tables of a given GRO context. This
129 * function assumes all inputted packets are with correct checksums.
130 * And it won't update checksums if two packets are merged. Besides,
131 * if inputted packets are IP fragmented, this function assumes they
132 * are complete packets (i.e. with L4 header).
134 * If the inputted packets don't have data or are with unsupported GRO
135 * types etc., they won't be processed and are returned to applications.
136 * Otherwise, the inputted packets are either merged or inserted into
137 * the table. If applications want get packets in the table, they need
141 * packet to reassemble. Besides, after this function finishes, it
142 * keeps the unprocessed packets (e.g. without data or unsupported
145 * the number of packets to reassemble.
147 * a pointer points to a GRO context object.
150 * return the number of unprocessed packets (e.g. without data or
151 * unsupported GRO types). If all packets are processed (merged or
152 * inserted into the table), return 0.
154 uint16_t rte_gro_reassemble(struct rte_mbuf **pkts,
160 * @b EXPERIMENTAL: this API may change without prior notice
162 * This function flushes the timeout packets from reassembly tables of
163 * desired GRO types. The max number of flushed timeout packets is the
164 * element number of the array which is used to keep the flushed packets.
166 * Besides, this function won't re-calculate checksums for merged
167 * packets in the tables. That is, the returned packets may be with
171 * a pointer points to a GRO context object.
172 * @param timeout_cycles
173 * max TTL for packets in reassembly tables, measured in nanosecond.
175 * this function only flushes packets which belong to the GRO types
176 * specified by gro_types.
178 * a pointer array that is used to keep flushed timeout packets.
180 * the element number of out. It's also the max number of timeout
181 * packets that can be flushed finally.
184 * the number of flushed packets. If no packets are flushed, return 0.
186 uint16_t rte_gro_timeout_flush(void *ctx,
187 uint64_t timeout_cycles,
189 struct rte_mbuf **out,
190 uint16_t max_nb_out);
194 * @b EXPERIMENTAL: this API may change without prior notice
196 * This function returns the number of packets in all reassembly tables
197 * of a given GRO context.
200 * pointer points to a GRO context object.
203 * the number of packets in all reassembly tables.
205 uint64_t rte_gro_get_pkt_count(void *ctx);
211 #endif /* _RTE_GRO_H_ */