1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2019 Intel Corporation
13 #include <rte_debug.h>
14 #include <rte_ether.h>
15 #include <rte_ethdev_driver.h>
17 #include <rte_malloc.h>
18 #include <rte_eth_ctrl.h>
19 #include <rte_tailq.h>
20 #include <rte_flow_driver.h>
23 #include "base/ice_type.h"
24 #include "base/ice_flow.h"
25 #include "ice_ethdev.h"
26 #include "ice_generic_flow.h"
28 #define ICE_GTPU_EH_DWNLINK 0
29 #define ICE_GTPU_EH_UPLINK 1
31 struct rss_type_match_hdr {
33 uint64_t eth_rss_hint;
36 struct ice_hash_match_type {
44 uint8_t hash_function;
47 struct ice_hash_flow_cfg {
49 struct ice_rss_cfg rss_cfg;
53 ice_hash_init(struct ice_adapter *ad);
56 ice_hash_create(struct ice_adapter *ad,
57 struct rte_flow *flow,
59 struct rte_flow_error *error);
62 ice_hash_destroy(struct ice_adapter *ad,
63 struct rte_flow *flow,
64 struct rte_flow_error *error);
67 ice_hash_uninit(struct ice_adapter *ad);
70 ice_hash_free(struct rte_flow *flow);
73 ice_hash_parse_pattern_action(struct ice_adapter *ad,
74 struct ice_pattern_match_item *array,
76 const struct rte_flow_item pattern[],
77 const struct rte_flow_action actions[],
79 struct rte_flow_error *error);
81 /* The first member is protocol header, the second member is ETH_RSS_*. */
82 struct rss_type_match_hdr hint_empty = {
83 ICE_FLOW_SEG_HDR_NONE, 0};
84 struct rss_type_match_hdr hint_eth_ipv4 = {
85 ICE_FLOW_SEG_HDR_IPV4 | ICE_FLOW_SEG_HDR_IPV_OTHER,
86 ETH_RSS_ETH | ETH_RSS_IPV4};
87 struct rss_type_match_hdr hint_eth_ipv4_udp = {
88 ICE_FLOW_SEG_HDR_IPV4 | ICE_FLOW_SEG_HDR_IPV_OTHER |
90 ETH_RSS_ETH | ETH_RSS_NONFRAG_IPV4_UDP};
91 struct rss_type_match_hdr hint_eth_ipv4_tcp = {
92 ICE_FLOW_SEG_HDR_IPV4 | ICE_FLOW_SEG_HDR_IPV_OTHER |
94 ETH_RSS_ETH | ETH_RSS_NONFRAG_IPV4_TCP};
95 struct rss_type_match_hdr hint_eth_ipv4_sctp = {
96 ICE_FLOW_SEG_HDR_IPV4 | ICE_FLOW_SEG_HDR_IPV_OTHER |
97 ICE_FLOW_SEG_HDR_SCTP,
98 ETH_RSS_ETH | ETH_RSS_NONFRAG_IPV4_SCTP};
99 struct rss_type_match_hdr hint_eth_ipv4_gtpu_ipv4 = {
100 ICE_FLOW_SEG_HDR_GTPU_IP | ICE_FLOW_SEG_HDR_IPV4 |
101 ICE_FLOW_SEG_HDR_IPV_OTHER,
102 ETH_RSS_GTPU | ETH_RSS_IPV4};
103 struct rss_type_match_hdr hint_eth_ipv4_gtpu_eh_ipv4 = {
104 ICE_FLOW_SEG_HDR_GTPU_EH | ICE_FLOW_SEG_HDR_IPV4 |
105 ICE_FLOW_SEG_HDR_IPV_OTHER,
106 ETH_RSS_GTPU | ETH_RSS_IPV4};
107 struct rss_type_match_hdr hint_eth_ipv4_gtpu_eh_ipv4_udp = {
108 ICE_FLOW_SEG_HDR_GTPU_EH | ICE_FLOW_SEG_HDR_IPV4 |
109 ICE_FLOW_SEG_HDR_IPV_OTHER | ICE_FLOW_SEG_HDR_UDP,
110 ETH_RSS_GTPU | ETH_RSS_NONFRAG_IPV4_UDP};
111 struct rss_type_match_hdr hint_eth_ipv4_gtpu_eh_ipv4_tcp = {
112 ICE_FLOW_SEG_HDR_GTPU_EH | ICE_FLOW_SEG_HDR_IPV4 |
113 ICE_FLOW_SEG_HDR_IPV_OTHER | ICE_FLOW_SEG_HDR_TCP,
114 ETH_RSS_GTPU | ETH_RSS_NONFRAG_IPV4_TCP};
115 struct rss_type_match_hdr hint_eth_pppoes_ipv4 = {
116 ICE_FLOW_SEG_HDR_PPPOE,
117 ETH_RSS_ETH | ETH_RSS_PPPOE | ETH_RSS_IPV4};
118 struct rss_type_match_hdr hint_eth_pppoes_ipv4_udp = {
119 ICE_FLOW_SEG_HDR_PPPOE,
120 ETH_RSS_ETH | ETH_RSS_PPPOE | ETH_RSS_NONFRAG_IPV4_UDP};
121 struct rss_type_match_hdr hint_eth_pppoes_ipv4_tcp = {
122 ICE_FLOW_SEG_HDR_PPPOE,
123 ETH_RSS_ETH | ETH_RSS_PPPOE | ETH_RSS_NONFRAG_IPV4_TCP};
124 struct rss_type_match_hdr hint_eth_pppoes_ipv4_sctp = {
125 ICE_FLOW_SEG_HDR_PPPOE,
126 ETH_RSS_ETH | ETH_RSS_PPPOE | ETH_RSS_NONFRAG_IPV4_SCTP};
127 struct rss_type_match_hdr hint_eth_ipv6 = {
128 ICE_FLOW_SEG_HDR_IPV6 | ICE_FLOW_SEG_HDR_IPV_OTHER,
129 ETH_RSS_ETH | ETH_RSS_IPV6};
130 struct rss_type_match_hdr hint_eth_ipv6_udp = {
131 ICE_FLOW_SEG_HDR_IPV6 | ICE_FLOW_SEG_HDR_IPV_OTHER |
132 ICE_FLOW_SEG_HDR_UDP,
133 ETH_RSS_ETH | ETH_RSS_NONFRAG_IPV6_UDP};
134 struct rss_type_match_hdr hint_eth_ipv6_tcp = {
135 ICE_FLOW_SEG_HDR_IPV6 | ICE_FLOW_SEG_HDR_IPV_OTHER |
136 ICE_FLOW_SEG_HDR_TCP,
137 ETH_RSS_ETH | ETH_RSS_NONFRAG_IPV6_TCP};
138 struct rss_type_match_hdr hint_eth_ipv6_sctp = {
139 ICE_FLOW_SEG_HDR_IPV6 | ICE_FLOW_SEG_HDR_IPV_OTHER |
140 ICE_FLOW_SEG_HDR_SCTP,
141 ETH_RSS_ETH | ETH_RSS_NONFRAG_IPV6_SCTP};
142 struct rss_type_match_hdr hint_eth_pppoes_ipv6 = {
143 ICE_FLOW_SEG_HDR_PPPOE,
144 ETH_RSS_ETH | ETH_RSS_PPPOE | ETH_RSS_IPV6};
145 struct rss_type_match_hdr hint_eth_pppoes_ipv6_udp = {
146 ICE_FLOW_SEG_HDR_PPPOE,
147 ETH_RSS_ETH | ETH_RSS_PPPOE | ETH_RSS_NONFRAG_IPV6_UDP};
148 struct rss_type_match_hdr hint_eth_pppoes_ipv6_tcp = {
149 ICE_FLOW_SEG_HDR_PPPOE,
150 ETH_RSS_ETH | ETH_RSS_PPPOE | ETH_RSS_NONFRAG_IPV6_TCP};
151 struct rss_type_match_hdr hint_eth_pppoes_ipv6_sctp = {
152 ICE_FLOW_SEG_HDR_PPPOE,
153 ETH_RSS_ETH | ETH_RSS_PPPOE | ETH_RSS_NONFRAG_IPV6_SCTP};
154 struct rss_type_match_hdr hint_eth_pppoes = {
155 ICE_FLOW_SEG_HDR_PPPOE,
156 ETH_RSS_ETH | ETH_RSS_PPPOE};
158 /* Supported pattern for os default package. */
159 static struct ice_pattern_match_item ice_hash_pattern_list_os[] = {
160 {pattern_eth_ipv4, ICE_INSET_NONE, &hint_eth_ipv4},
161 {pattern_eth_ipv4_udp, ICE_INSET_NONE, &hint_eth_ipv4_udp},
162 {pattern_eth_ipv4_tcp, ICE_INSET_NONE, &hint_eth_ipv4_tcp},
163 {pattern_eth_ipv4_sctp, ICE_INSET_NONE, &hint_eth_ipv4_sctp},
164 {pattern_eth_ipv6, ICE_INSET_NONE, &hint_eth_ipv6},
165 {pattern_eth_ipv6_udp, ICE_INSET_NONE, &hint_eth_ipv6_udp},
166 {pattern_eth_ipv6_tcp, ICE_INSET_NONE, &hint_eth_ipv6_tcp},
167 {pattern_eth_ipv6_sctp, ICE_INSET_NONE, &hint_eth_ipv6_sctp},
168 {pattern_empty, ICE_INSET_NONE, &hint_empty},
171 /* Supported pattern for comms package. */
172 static struct ice_pattern_match_item ice_hash_pattern_list_comms[] = {
173 {pattern_empty, ICE_INSET_NONE,
175 {pattern_eth_ipv4, ICE_INSET_NONE,
177 {pattern_eth_ipv4_udp, ICE_INSET_NONE,
179 {pattern_eth_ipv4_tcp, ICE_INSET_NONE,
181 {pattern_eth_ipv4_sctp, ICE_INSET_NONE,
182 &hint_eth_ipv4_sctp},
183 {pattern_eth_ipv4_gtpu_ipv4, ICE_INSET_NONE,
184 &hint_eth_ipv4_gtpu_ipv4},
185 {pattern_eth_ipv4_gtpu_eh_ipv4, ICE_INSET_NONE,
186 &hint_eth_ipv4_gtpu_eh_ipv4},
187 {pattern_eth_ipv4_gtpu_eh_ipv4_udp, ICE_INSET_NONE,
188 &hint_eth_ipv4_gtpu_eh_ipv4_udp},
189 {pattern_eth_ipv4_gtpu_eh_ipv4_tcp, ICE_INSET_NONE,
190 &hint_eth_ipv4_gtpu_eh_ipv4_tcp},
191 {pattern_eth_pppoes_ipv4, ICE_INSET_NONE,
192 &hint_eth_pppoes_ipv4},
193 {pattern_eth_pppoes_ipv4_udp, ICE_INSET_NONE,
194 &hint_eth_pppoes_ipv4_udp},
195 {pattern_eth_pppoes_ipv4_tcp, ICE_INSET_NONE,
196 &hint_eth_pppoes_ipv4_tcp},
197 {pattern_eth_pppoes_ipv4_sctp, ICE_INSET_NONE,
198 &hint_eth_pppoes_ipv4_sctp},
199 {pattern_eth_ipv6, ICE_INSET_NONE,
201 {pattern_eth_ipv6_udp, ICE_INSET_NONE,
203 {pattern_eth_ipv6_tcp, ICE_INSET_NONE,
205 {pattern_eth_ipv6_sctp, ICE_INSET_NONE,
206 &hint_eth_ipv6_sctp},
207 {pattern_eth_pppoes_ipv6, ICE_INSET_NONE,
208 &hint_eth_pppoes_ipv6},
209 {pattern_eth_pppoes_ipv6_udp, ICE_INSET_NONE,
210 &hint_eth_pppoes_ipv6_udp},
211 {pattern_eth_pppoes_ipv6_tcp, ICE_INSET_NONE,
212 &hint_eth_pppoes_ipv6_tcp},
213 {pattern_eth_pppoes_ipv6_sctp, ICE_INSET_NONE,
214 &hint_eth_pppoes_ipv6_sctp},
215 {pattern_eth_pppoes, ICE_INSET_NONE,
220 * The first member is input set combination,
221 * the second member is hash fields.
223 struct ice_hash_match_type ice_hash_type_list[] = {
225 ICE_FLOW_HASH_PPPOE_SESS_ID},
226 {ETH_RSS_ETH | ETH_RSS_PPPOE | ETH_RSS_L2_SRC_ONLY,
227 ICE_FLOW_HASH_PPPOE_SESS_ID |
228 BIT_ULL(ICE_FLOW_FIELD_IDX_ETH_SA)},
230 {ETH_RSS_IPV4 | ETH_RSS_L3_SRC_ONLY,
231 BIT_ULL(ICE_FLOW_FIELD_IDX_IPV4_SA)},
232 {ETH_RSS_IPV4 | ETH_RSS_L3_DST_ONLY,
233 BIT_ULL(ICE_FLOW_FIELD_IDX_IPV4_DA)},
234 {ETH_RSS_IPV4, ICE_FLOW_HASH_IPV4},
235 {ETH_RSS_NONFRAG_IPV4_UDP | ETH_RSS_L3_SRC_ONLY | ETH_RSS_L4_SRC_ONLY,
236 BIT_ULL(ICE_FLOW_FIELD_IDX_IPV4_SA) |
237 BIT_ULL(ICE_FLOW_FIELD_IDX_IPV4_PROT) |
238 BIT_ULL(ICE_FLOW_FIELD_IDX_UDP_SRC_PORT)},
239 {ETH_RSS_NONFRAG_IPV4_UDP | ETH_RSS_L3_SRC_ONLY | ETH_RSS_L4_DST_ONLY,
240 BIT_ULL(ICE_FLOW_FIELD_IDX_IPV4_SA) |
241 BIT_ULL(ICE_FLOW_FIELD_IDX_IPV4_PROT) |
242 BIT_ULL(ICE_FLOW_FIELD_IDX_UDP_DST_PORT)},
243 {ETH_RSS_NONFRAG_IPV4_UDP | ETH_RSS_L3_SRC_ONLY,
244 BIT_ULL(ICE_FLOW_FIELD_IDX_IPV4_SA)},
245 {ETH_RSS_NONFRAG_IPV4_UDP | ETH_RSS_L3_DST_ONLY | ETH_RSS_L4_SRC_ONLY,
246 BIT_ULL(ICE_FLOW_FIELD_IDX_IPV4_DA) |
247 BIT_ULL(ICE_FLOW_FIELD_IDX_IPV4_PROT) |
248 BIT_ULL(ICE_FLOW_FIELD_IDX_UDP_SRC_PORT)},
249 {ETH_RSS_NONFRAG_IPV4_UDP | ETH_RSS_L3_DST_ONLY | ETH_RSS_L4_DST_ONLY,
250 BIT_ULL(ICE_FLOW_FIELD_IDX_IPV4_DA) |
251 BIT_ULL(ICE_FLOW_FIELD_IDX_IPV4_PROT) |
252 BIT_ULL(ICE_FLOW_FIELD_IDX_UDP_DST_PORT)},
253 {ETH_RSS_NONFRAG_IPV4_UDP | ETH_RSS_L3_DST_ONLY,
254 BIT_ULL(ICE_FLOW_FIELD_IDX_IPV4_DA)},
255 {ETH_RSS_NONFRAG_IPV4_UDP | ETH_RSS_L4_SRC_ONLY,
256 BIT_ULL(ICE_FLOW_FIELD_IDX_UDP_SRC_PORT) |
257 BIT_ULL(ICE_FLOW_FIELD_IDX_IPV4_PROT)},
258 {ETH_RSS_NONFRAG_IPV4_UDP | ETH_RSS_L4_DST_ONLY,
259 BIT_ULL(ICE_FLOW_FIELD_IDX_UDP_DST_PORT) |
260 BIT_ULL(ICE_FLOW_FIELD_IDX_IPV4_PROT)},
261 {ETH_RSS_NONFRAG_IPV4_UDP,
263 BIT_ULL(ICE_FLOW_FIELD_IDX_IPV4_PROT)},
264 {ETH_RSS_NONFRAG_IPV4_TCP | ETH_RSS_L3_SRC_ONLY | ETH_RSS_L4_SRC_ONLY,
265 BIT_ULL(ICE_FLOW_FIELD_IDX_IPV4_SA) |
266 BIT_ULL(ICE_FLOW_FIELD_IDX_IPV4_PROT) |
267 BIT_ULL(ICE_FLOW_FIELD_IDX_TCP_SRC_PORT)},
268 {ETH_RSS_NONFRAG_IPV4_TCP | ETH_RSS_L3_SRC_ONLY | ETH_RSS_L4_DST_ONLY,
269 BIT_ULL(ICE_FLOW_FIELD_IDX_IPV4_SA) |
270 BIT_ULL(ICE_FLOW_FIELD_IDX_IPV4_PROT) |
271 BIT_ULL(ICE_FLOW_FIELD_IDX_TCP_DST_PORT)},
272 {ETH_RSS_NONFRAG_IPV4_TCP | ETH_RSS_L3_SRC_ONLY,
273 BIT_ULL(ICE_FLOW_FIELD_IDX_IPV4_SA)},
274 {ETH_RSS_NONFRAG_IPV4_TCP | ETH_RSS_L3_DST_ONLY | ETH_RSS_L4_SRC_ONLY,
275 BIT_ULL(ICE_FLOW_FIELD_IDX_IPV4_DA) |
276 BIT_ULL(ICE_FLOW_FIELD_IDX_IPV4_PROT) |
277 BIT_ULL(ICE_FLOW_FIELD_IDX_TCP_SRC_PORT)},
278 {ETH_RSS_NONFRAG_IPV4_TCP | ETH_RSS_L3_DST_ONLY | ETH_RSS_L4_DST_ONLY,
279 BIT_ULL(ICE_FLOW_FIELD_IDX_IPV4_DA) |
280 BIT_ULL(ICE_FLOW_FIELD_IDX_IPV4_PROT) |
281 BIT_ULL(ICE_FLOW_FIELD_IDX_TCP_DST_PORT)},
282 {ETH_RSS_NONFRAG_IPV4_TCP | ETH_RSS_L3_DST_ONLY,
283 BIT_ULL(ICE_FLOW_FIELD_IDX_IPV4_DA)},
284 {ETH_RSS_NONFRAG_IPV4_TCP | ETH_RSS_L4_SRC_ONLY,
285 BIT_ULL(ICE_FLOW_FIELD_IDX_TCP_SRC_PORT) |
286 BIT_ULL(ICE_FLOW_FIELD_IDX_IPV4_PROT)},
287 {ETH_RSS_NONFRAG_IPV4_TCP | ETH_RSS_L4_DST_ONLY,
288 BIT_ULL(ICE_FLOW_FIELD_IDX_TCP_DST_PORT) |
289 BIT_ULL(ICE_FLOW_FIELD_IDX_IPV4_PROT)},
290 {ETH_RSS_NONFRAG_IPV4_TCP,
292 BIT_ULL(ICE_FLOW_FIELD_IDX_IPV4_PROT)},
293 {ETH_RSS_NONFRAG_IPV4_SCTP | ETH_RSS_L3_SRC_ONLY | ETH_RSS_L4_SRC_ONLY,
294 BIT_ULL(ICE_FLOW_FIELD_IDX_IPV4_SA) |
295 BIT_ULL(ICE_FLOW_FIELD_IDX_IPV4_PROT) |
296 BIT_ULL(ICE_FLOW_FIELD_IDX_SCTP_SRC_PORT)},
297 {ETH_RSS_NONFRAG_IPV4_SCTP | ETH_RSS_L3_SRC_ONLY | ETH_RSS_L4_DST_ONLY,
298 BIT_ULL(ICE_FLOW_FIELD_IDX_IPV4_SA) |
299 BIT_ULL(ICE_FLOW_FIELD_IDX_IPV4_PROT) |
300 BIT_ULL(ICE_FLOW_FIELD_IDX_SCTP_DST_PORT)},
301 {ETH_RSS_NONFRAG_IPV4_SCTP | ETH_RSS_L3_SRC_ONLY,
302 BIT_ULL(ICE_FLOW_FIELD_IDX_IPV4_SA)},
303 {ETH_RSS_NONFRAG_IPV4_SCTP | ETH_RSS_L3_DST_ONLY | ETH_RSS_L4_SRC_ONLY,
304 BIT_ULL(ICE_FLOW_FIELD_IDX_IPV4_DA) |
305 BIT_ULL(ICE_FLOW_FIELD_IDX_IPV4_PROT) |
306 BIT_ULL(ICE_FLOW_FIELD_IDX_SCTP_SRC_PORT)},
307 {ETH_RSS_NONFRAG_IPV4_SCTP | ETH_RSS_L3_DST_ONLY | ETH_RSS_L4_DST_ONLY,
308 BIT_ULL(ICE_FLOW_FIELD_IDX_IPV4_DA) |
309 BIT_ULL(ICE_FLOW_FIELD_IDX_IPV4_PROT) |
310 BIT_ULL(ICE_FLOW_FIELD_IDX_SCTP_DST_PORT)},
311 {ETH_RSS_NONFRAG_IPV4_SCTP | ETH_RSS_L3_DST_ONLY,
312 BIT_ULL(ICE_FLOW_FIELD_IDX_IPV4_DA)},
313 {ETH_RSS_NONFRAG_IPV4_SCTP | ETH_RSS_L4_SRC_ONLY,
314 BIT_ULL(ICE_FLOW_FIELD_IDX_SCTP_SRC_PORT) |
315 BIT_ULL(ICE_FLOW_FIELD_IDX_IPV4_PROT)},
316 {ETH_RSS_NONFRAG_IPV4_SCTP | ETH_RSS_L4_DST_ONLY,
317 BIT_ULL(ICE_FLOW_FIELD_IDX_SCTP_DST_PORT) |
318 BIT_ULL(ICE_FLOW_FIELD_IDX_IPV4_PROT)},
319 {ETH_RSS_NONFRAG_IPV4_SCTP,
321 BIT_ULL(ICE_FLOW_FIELD_IDX_IPV4_PROT)},
323 {ETH_RSS_IPV6 | ETH_RSS_L3_SRC_ONLY,
324 BIT_ULL(ICE_FLOW_FIELD_IDX_IPV6_SA)},
325 {ETH_RSS_IPV6 | ETH_RSS_L3_DST_ONLY,
326 BIT_ULL(ICE_FLOW_FIELD_IDX_IPV6_DA)},
327 {ETH_RSS_IPV6, ICE_FLOW_HASH_IPV6},
328 {ETH_RSS_NONFRAG_IPV6_UDP | ETH_RSS_L3_SRC_ONLY | ETH_RSS_L4_SRC_ONLY,
329 BIT_ULL(ICE_FLOW_FIELD_IDX_IPV6_SA) |
330 BIT_ULL(ICE_FLOW_FIELD_IDX_IPV6_PROT) |
331 BIT_ULL(ICE_FLOW_FIELD_IDX_UDP_SRC_PORT)},
332 {ETH_RSS_NONFRAG_IPV6_UDP | ETH_RSS_L3_SRC_ONLY | ETH_RSS_L4_DST_ONLY,
333 BIT_ULL(ICE_FLOW_FIELD_IDX_IPV6_SA) |
334 BIT_ULL(ICE_FLOW_FIELD_IDX_IPV6_PROT) |
335 BIT_ULL(ICE_FLOW_FIELD_IDX_UDP_DST_PORT)},
336 {ETH_RSS_NONFRAG_IPV6_UDP | ETH_RSS_L3_SRC_ONLY,
337 BIT_ULL(ICE_FLOW_FIELD_IDX_IPV6_SA)},
338 {ETH_RSS_NONFRAG_IPV6_UDP | ETH_RSS_L3_DST_ONLY | ETH_RSS_L4_SRC_ONLY,
339 BIT_ULL(ICE_FLOW_FIELD_IDX_IPV6_DA) |
340 BIT_ULL(ICE_FLOW_FIELD_IDX_IPV6_PROT) |
341 BIT_ULL(ICE_FLOW_FIELD_IDX_UDP_SRC_PORT)},
342 {ETH_RSS_NONFRAG_IPV6_UDP | ETH_RSS_L3_DST_ONLY | ETH_RSS_L4_DST_ONLY,
343 BIT_ULL(ICE_FLOW_FIELD_IDX_IPV6_DA) |
344 BIT_ULL(ICE_FLOW_FIELD_IDX_IPV6_PROT) |
345 BIT_ULL(ICE_FLOW_FIELD_IDX_UDP_DST_PORT)},
346 {ETH_RSS_NONFRAG_IPV6_UDP | ETH_RSS_L3_DST_ONLY,
347 BIT_ULL(ICE_FLOW_FIELD_IDX_IPV6_DA)},
348 {ETH_RSS_NONFRAG_IPV6_UDP | ETH_RSS_L4_SRC_ONLY,
349 BIT_ULL(ICE_FLOW_FIELD_IDX_UDP_SRC_PORT) |
350 BIT_ULL(ICE_FLOW_FIELD_IDX_IPV6_PROT)},
351 {ETH_RSS_NONFRAG_IPV6_UDP | ETH_RSS_L4_DST_ONLY,
352 BIT_ULL(ICE_FLOW_FIELD_IDX_UDP_DST_PORT) |
353 BIT_ULL(ICE_FLOW_FIELD_IDX_IPV6_PROT)},
354 {ETH_RSS_NONFRAG_IPV6_UDP | ETH_RSS_PFCP,
355 BIT_ULL(ICE_FLOW_FIELD_IDX_PFCP_SEID)},
356 {ETH_RSS_NONFRAG_IPV6_UDP,
358 BIT_ULL(ICE_FLOW_FIELD_IDX_IPV6_PROT)},
359 {ETH_RSS_NONFRAG_IPV6_TCP | ETH_RSS_L3_SRC_ONLY | ETH_RSS_L4_SRC_ONLY,
360 BIT_ULL(ICE_FLOW_FIELD_IDX_IPV6_SA) |
361 BIT_ULL(ICE_FLOW_FIELD_IDX_IPV6_PROT) |
362 BIT_ULL(ICE_FLOW_FIELD_IDX_TCP_SRC_PORT)},
363 {ETH_RSS_NONFRAG_IPV6_TCP | ETH_RSS_L3_SRC_ONLY | ETH_RSS_L4_DST_ONLY,
364 BIT_ULL(ICE_FLOW_FIELD_IDX_IPV6_SA) |
365 BIT_ULL(ICE_FLOW_FIELD_IDX_IPV6_PROT) |
366 BIT_ULL(ICE_FLOW_FIELD_IDX_TCP_DST_PORT)},
367 {ETH_RSS_NONFRAG_IPV6_TCP | ETH_RSS_L3_SRC_ONLY,
368 BIT_ULL(ICE_FLOW_FIELD_IDX_IPV6_SA)},
369 {ETH_RSS_NONFRAG_IPV6_TCP | ETH_RSS_L3_DST_ONLY | ETH_RSS_L4_SRC_ONLY,
370 BIT_ULL(ICE_FLOW_FIELD_IDX_IPV6_DA) |
371 BIT_ULL(ICE_FLOW_FIELD_IDX_IPV6_PROT) |
372 BIT_ULL(ICE_FLOW_FIELD_IDX_TCP_SRC_PORT)},
373 {ETH_RSS_NONFRAG_IPV6_TCP | ETH_RSS_L3_DST_ONLY | ETH_RSS_L4_DST_ONLY,
374 BIT_ULL(ICE_FLOW_FIELD_IDX_IPV6_DA) |
375 BIT_ULL(ICE_FLOW_FIELD_IDX_IPV6_PROT) |
376 BIT_ULL(ICE_FLOW_FIELD_IDX_TCP_DST_PORT)},
377 {ETH_RSS_NONFRAG_IPV6_TCP | ETH_RSS_L3_DST_ONLY,
378 BIT_ULL(ICE_FLOW_FIELD_IDX_IPV6_DA)},
379 {ETH_RSS_NONFRAG_IPV6_TCP | ETH_RSS_L4_SRC_ONLY,
380 BIT_ULL(ICE_FLOW_FIELD_IDX_TCP_SRC_PORT) |
381 BIT_ULL(ICE_FLOW_FIELD_IDX_IPV6_PROT)},
382 {ETH_RSS_NONFRAG_IPV6_TCP | ETH_RSS_L4_DST_ONLY,
383 BIT_ULL(ICE_FLOW_FIELD_IDX_TCP_DST_PORT) |
384 BIT_ULL(ICE_FLOW_FIELD_IDX_IPV6_PROT)},
385 {ETH_RSS_NONFRAG_IPV6_TCP,
387 BIT_ULL(ICE_FLOW_FIELD_IDX_IPV6_PROT)},
388 {ETH_RSS_NONFRAG_IPV6_SCTP | ETH_RSS_L3_SRC_ONLY | ETH_RSS_L4_SRC_ONLY,
389 BIT_ULL(ICE_FLOW_FIELD_IDX_IPV6_SA) |
390 BIT_ULL(ICE_FLOW_FIELD_IDX_IPV6_PROT) |
391 BIT_ULL(ICE_FLOW_FIELD_IDX_SCTP_SRC_PORT)},
392 {ETH_RSS_NONFRAG_IPV6_SCTP | ETH_RSS_L3_SRC_ONLY | ETH_RSS_L4_DST_ONLY,
393 BIT_ULL(ICE_FLOW_FIELD_IDX_IPV6_SA) |
394 BIT_ULL(ICE_FLOW_FIELD_IDX_IPV6_PROT) |
395 BIT_ULL(ICE_FLOW_FIELD_IDX_SCTP_DST_PORT)},
396 {ETH_RSS_NONFRAG_IPV6_SCTP | ETH_RSS_L3_SRC_ONLY,
397 BIT_ULL(ICE_FLOW_FIELD_IDX_IPV6_SA)},
398 {ETH_RSS_NONFRAG_IPV6_SCTP | ETH_RSS_L3_DST_ONLY | ETH_RSS_L4_SRC_ONLY,
399 BIT_ULL(ICE_FLOW_FIELD_IDX_IPV6_DA) |
400 BIT_ULL(ICE_FLOW_FIELD_IDX_IPV6_PROT) |
401 BIT_ULL(ICE_FLOW_FIELD_IDX_SCTP_SRC_PORT)},
402 {ETH_RSS_NONFRAG_IPV6_SCTP | ETH_RSS_L3_DST_ONLY | ETH_RSS_L4_DST_ONLY,
403 BIT_ULL(ICE_FLOW_FIELD_IDX_IPV6_DA) |
404 BIT_ULL(ICE_FLOW_FIELD_IDX_IPV6_PROT) |
405 BIT_ULL(ICE_FLOW_FIELD_IDX_SCTP_DST_PORT)},
406 {ETH_RSS_NONFRAG_IPV6_SCTP | ETH_RSS_L3_DST_ONLY,
407 BIT_ULL(ICE_FLOW_FIELD_IDX_IPV6_DA)},
408 {ETH_RSS_NONFRAG_IPV6_SCTP | ETH_RSS_L4_SRC_ONLY,
409 BIT_ULL(ICE_FLOW_FIELD_IDX_SCTP_SRC_PORT) |
410 BIT_ULL(ICE_FLOW_FIELD_IDX_IPV6_PROT)},
411 {ETH_RSS_NONFRAG_IPV6_SCTP | ETH_RSS_L4_DST_ONLY,
412 BIT_ULL(ICE_FLOW_FIELD_IDX_SCTP_DST_PORT) |
413 BIT_ULL(ICE_FLOW_FIELD_IDX_IPV6_PROT)},
414 {ETH_RSS_NONFRAG_IPV6_SCTP,
416 BIT_ULL(ICE_FLOW_FIELD_IDX_IPV6_PROT)},
419 static struct ice_flow_engine ice_hash_engine = {
420 .init = ice_hash_init,
421 .create = ice_hash_create,
422 .destroy = ice_hash_destroy,
423 .uninit = ice_hash_uninit,
424 .free = ice_hash_free,
425 .type = ICE_FLOW_ENGINE_HASH,
428 /* Register parser for os package. */
429 static struct ice_flow_parser ice_hash_parser_os = {
430 .engine = &ice_hash_engine,
431 .array = ice_hash_pattern_list_os,
432 .array_len = RTE_DIM(ice_hash_pattern_list_os),
433 .parse_pattern_action = ice_hash_parse_pattern_action,
434 .stage = ICE_FLOW_STAGE_RSS,
437 /* Register parser for comms package. */
438 static struct ice_flow_parser ice_hash_parser_comms = {
439 .engine = &ice_hash_engine,
440 .array = ice_hash_pattern_list_comms,
441 .array_len = RTE_DIM(ice_hash_pattern_list_comms),
442 .parse_pattern_action = ice_hash_parse_pattern_action,
443 .stage = ICE_FLOW_STAGE_RSS,
446 RTE_INIT(ice_hash_engine_init)
448 struct ice_flow_engine *engine = &ice_hash_engine;
449 ice_register_flow_engine(engine);
453 ice_hash_init(struct ice_adapter *ad)
455 struct ice_flow_parser *parser = NULL;
457 if (ad->hw.dcf_enabled)
460 if (ad->active_pkg_type == ICE_PKG_TYPE_OS_DEFAULT)
461 parser = &ice_hash_parser_os;
462 else if (ad->active_pkg_type == ICE_PKG_TYPE_COMMS)
463 parser = &ice_hash_parser_comms;
467 return ice_register_parser(parser, ad);
471 ice_hash_parse_pattern(struct ice_pattern_match_item *pattern_match_item,
472 const struct rte_flow_item pattern[], void **meta,
473 struct rte_flow_error *error)
475 uint32_t hdr_mask = ((struct rss_type_match_hdr *)
476 (pattern_match_item->meta))->hdr_mask;
477 const struct rte_flow_item *item = pattern;
478 const struct rte_flow_item_gtp_psc *psc;
481 for (item = pattern; item->type != RTE_FLOW_ITEM_TYPE_END; item++) {
483 rte_flow_error_set(error, EINVAL,
484 RTE_FLOW_ERROR_TYPE_ITEM, item,
485 "Not support range");
489 switch (item->type) {
490 case RTE_FLOW_ITEM_TYPE_GTPU:
491 hdrs |= ICE_FLOW_SEG_HDR_GTPU_IP;
493 case RTE_FLOW_ITEM_TYPE_GTP_PSC:
495 hdr_mask &= ~ICE_FLOW_SEG_HDR_GTPU_EH;
496 hdrs &= ~ICE_FLOW_SEG_HDR_GTPU_IP;
498 hdrs |= ICE_FLOW_SEG_HDR_GTPU_EH;
499 else if (psc->pdu_type == ICE_GTPU_EH_UPLINK)
500 hdrs |= ICE_FLOW_SEG_HDR_GTPU_UP;
501 else if (psc->pdu_type == ICE_GTPU_EH_DWNLINK)
502 hdrs |= ICE_FLOW_SEG_HDR_GTPU_DWN;
509 /* Save protocol header to rss_meta. */
510 ((struct rss_meta *)*meta)->pkt_hdr |= hdr_mask | hdrs;
516 ice_hash_parse_action(struct ice_pattern_match_item *pattern_match_item,
517 const struct rte_flow_action actions[],
519 struct rte_flow_error *error)
521 struct rss_type_match_hdr *m = (struct rss_type_match_hdr *)
522 (pattern_match_item->meta);
523 struct rss_meta *hash_meta = (struct rss_meta *)*meta;
524 uint32_t type_list_len = RTE_DIM(ice_hash_type_list);
525 enum rte_flow_action_type action_type;
526 const struct rte_flow_action_rss *rss;
527 const struct rte_flow_action *action;
528 uint64_t combine_type;
532 /* Supported action is RSS. */
533 for (action = actions; action->type !=
534 RTE_FLOW_ACTION_TYPE_END; action++) {
535 action_type = action->type;
536 switch (action_type) {
537 case RTE_FLOW_ACTION_TYPE_RSS:
539 rss_type = rss->types;
541 /* Check hash function and save it to rss_meta. */
542 if (pattern_match_item->pattern_list !=
543 pattern_empty && rss->func ==
544 RTE_ETH_HASH_FUNCTION_SIMPLE_XOR) {
545 return rte_flow_error_set(error, ENOTSUP,
546 RTE_FLOW_ERROR_TYPE_ACTION, action,
547 "Not supported flow");
548 } else if (rss->func ==
549 RTE_ETH_HASH_FUNCTION_SIMPLE_XOR){
550 ((struct rss_meta *)*meta)->hash_function =
551 RTE_ETH_HASH_FUNCTION_SIMPLE_XOR;
553 } else if (rss->func ==
554 RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ) {
555 ((struct rss_meta *)*meta)->hash_function =
556 RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ;
560 return rte_flow_error_set(error, ENOTSUP,
561 RTE_FLOW_ERROR_TYPE_ACTION, action,
562 "a nonzero RSS encapsulation level is not supported");
565 return rte_flow_error_set(error, ENOTSUP,
566 RTE_FLOW_ERROR_TYPE_ACTION, action,
567 "a nonzero RSS key_len is not supported");
570 return rte_flow_error_set(error, ENOTSUP,
571 RTE_FLOW_ERROR_TYPE_ACTION, action,
572 "a non-NULL RSS queue is not supported");
575 * Check simultaneous use of SRC_ONLY and DST_ONLY
578 rss_type = rte_eth_rss_hf_refine(rss_type);
580 combine_type = ETH_RSS_L2_SRC_ONLY |
581 ETH_RSS_L2_DST_ONLY |
582 ETH_RSS_L3_SRC_ONLY |
583 ETH_RSS_L3_DST_ONLY |
584 ETH_RSS_L4_SRC_ONLY |
587 /* Check if rss types match pattern. */
588 if (rss_type & ~combine_type & ~m->eth_rss_hint) {
589 return rte_flow_error_set(error,
590 ENOTSUP, RTE_FLOW_ERROR_TYPE_ACTION,
591 action, "Not supported RSS types");
594 /* Find matched hash fields according to hash type. */
595 for (i = 0; i < type_list_len; i++) {
596 struct ice_hash_match_type *ht_map =
597 &ice_hash_type_list[i];
599 if (rss_type == ht_map->hash_type) {
600 hash_meta->hash_flds =
606 /* update hash field for gtpu-ip and gtpu-eh. */
607 if (rss_type != ETH_RSS_GTPU)
609 else if (hash_meta->pkt_hdr & ICE_FLOW_SEG_HDR_GTPU_IP)
610 hash_meta->hash_flds |=
611 BIT_ULL(ICE_FLOW_FIELD_IDX_GTPU_IP_TEID);
612 else if (hash_meta->pkt_hdr & ICE_FLOW_SEG_HDR_GTPU_EH)
613 hash_meta->hash_flds |=
614 BIT_ULL(ICE_FLOW_FIELD_IDX_GTPU_EH_TEID);
615 else if (hash_meta->pkt_hdr & ICE_FLOW_SEG_HDR_GTPU_DWN)
616 hash_meta->hash_flds |=
617 BIT_ULL(ICE_FLOW_FIELD_IDX_GTPU_DWN_TEID);
618 else if (hash_meta->pkt_hdr & ICE_FLOW_SEG_HDR_GTPU_UP)
619 hash_meta->hash_flds |=
620 BIT_ULL(ICE_FLOW_FIELD_IDX_GTPU_UP_TEID);
624 case RTE_FLOW_ACTION_TYPE_END:
628 rte_flow_error_set(error, EINVAL,
629 RTE_FLOW_ERROR_TYPE_ACTION, action,
639 ice_hash_parse_pattern_action(__rte_unused struct ice_adapter *ad,
640 struct ice_pattern_match_item *array,
642 const struct rte_flow_item pattern[],
643 const struct rte_flow_action actions[],
645 struct rte_flow_error *error)
648 struct ice_pattern_match_item *pattern_match_item;
649 struct rss_meta *rss_meta_ptr;
651 rss_meta_ptr = rte_zmalloc(NULL, sizeof(*rss_meta_ptr), 0);
653 rte_flow_error_set(error, EINVAL,
654 RTE_FLOW_ERROR_TYPE_HANDLE, NULL,
655 "No memory for rss_meta_ptr");
659 /* Check rss supported pattern and find matched pattern. */
660 pattern_match_item = ice_search_pattern_match_item(pattern,
661 array, array_len, error);
662 if (!pattern_match_item) {
667 ret = ice_hash_parse_pattern(pattern_match_item, pattern,
668 (void **)&rss_meta_ptr, error);
672 /* Check rss action. */
673 ret = ice_hash_parse_action(pattern_match_item, actions,
674 (void **)&rss_meta_ptr, error);
678 *meta = rss_meta_ptr;
680 rte_free(rss_meta_ptr);
681 rte_free(pattern_match_item);
687 ice_hash_create(struct ice_adapter *ad,
688 struct rte_flow *flow,
690 struct rte_flow_error *error)
692 struct ice_pf *pf = &ad->pf;
693 struct ice_hw *hw = ICE_PF_TO_HW(pf);
694 struct ice_vsi *vsi = pf->main_vsi;
697 struct ice_hash_flow_cfg *filter_ptr;
699 uint32_t headermask = ((struct rss_meta *)meta)->pkt_hdr;
700 uint64_t hash_field = ((struct rss_meta *)meta)->hash_flds;
701 uint8_t hash_function = ((struct rss_meta *)meta)->hash_function;
703 filter_ptr = rte_zmalloc("ice_rss_filter",
704 sizeof(struct ice_hash_flow_cfg), 0);
706 rte_flow_error_set(error, EINVAL,
707 RTE_FLOW_ERROR_TYPE_HANDLE, NULL,
708 "No memory for filter_ptr");
712 if (hash_function == RTE_ETH_HASH_FUNCTION_SIMPLE_XOR) {
713 /* Enable registers for simple_xor hash function. */
714 reg = ICE_READ_REG(hw, VSIQF_HASH_CTL(vsi->vsi_id));
715 reg = (reg & (~VSIQF_HASH_CTL_HASH_SCHEME_M)) |
716 (2 << VSIQF_HASH_CTL_HASH_SCHEME_S);
717 ICE_WRITE_REG(hw, VSIQF_HASH_CTL(vsi->vsi_id), reg);
719 filter_ptr->simple_xor = 1;
723 filter_ptr->rss_cfg.packet_hdr = headermask;
724 filter_ptr->rss_cfg.hashed_flds = hash_field;
725 filter_ptr->rss_cfg.symm =
727 RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ);
729 ret = ice_add_rss_cfg(hw, vsi->idx,
730 filter_ptr->rss_cfg.hashed_flds,
731 filter_ptr->rss_cfg.packet_hdr,
732 filter_ptr->rss_cfg.symm);
734 rte_flow_error_set(error, EINVAL,
735 RTE_FLOW_ERROR_TYPE_HANDLE, NULL,
736 "rss flow create fail");
742 flow->rule = filter_ptr;
747 rte_free(filter_ptr);
753 ice_hash_destroy(struct ice_adapter *ad,
754 struct rte_flow *flow,
755 struct rte_flow_error *error)
757 struct ice_pf *pf = ICE_DEV_PRIVATE_TO_PF(ad);
758 struct ice_hw *hw = ICE_PF_TO_HW(pf);
759 struct ice_vsi *vsi = pf->main_vsi;
762 struct ice_hash_flow_cfg *filter_ptr;
764 filter_ptr = (struct ice_hash_flow_cfg *)flow->rule;
766 if (filter_ptr->simple_xor == 1) {
767 /* Return to symmetric_toeplitz state. */
768 reg = ICE_READ_REG(hw, VSIQF_HASH_CTL(vsi->vsi_id));
769 reg = (reg & (~VSIQF_HASH_CTL_HASH_SCHEME_M)) |
770 (1 << VSIQF_HASH_CTL_HASH_SCHEME_S);
771 ICE_WRITE_REG(hw, VSIQF_HASH_CTL(vsi->vsi_id), reg);
773 ret = ice_rem_rss_cfg(hw, vsi->idx,
774 filter_ptr->rss_cfg.hashed_flds,
775 filter_ptr->rss_cfg.packet_hdr);
776 /* Fixme: Ignore the error if a rule does not exist.
777 * Currently a rule for inputset change or symm turn on/off
778 * will overwrite an exist rule, while application still
779 * have 2 rte_flow handles.
781 if (ret && ret != ICE_ERR_DOES_NOT_EXIST) {
782 rte_flow_error_set(error, EINVAL,
783 RTE_FLOW_ERROR_TYPE_HANDLE, NULL,
784 "rss flow destroy fail");
789 rte_free(filter_ptr);
793 rte_free(filter_ptr);
798 ice_hash_uninit(struct ice_adapter *ad)
800 if (ad->hw.dcf_enabled)
803 if (ad->active_pkg_type == ICE_PKG_TYPE_OS_DEFAULT)
804 ice_unregister_parser(&ice_hash_parser_os, ad);
805 else if (ad->active_pkg_type == ICE_PKG_TYPE_COMMS)
806 ice_unregister_parser(&ice_hash_parser_comms, ad);
810 ice_hash_free(struct rte_flow *flow)
812 rte_free(flow->rule);