1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2020 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>
24 #include "iavf_generic_flow.h"
26 enum iavf_pattern_hint_type {
27 IAVF_PATTERN_HINT_NONE,
28 IAVF_PATTERN_HINT_IPV4,
29 IAVF_PATTERN_HINT_IPV4_UDP,
30 IAVF_PATTERN_HINT_IPV4_TCP,
31 IAVF_PATTERN_HINT_IPV4_SCTP,
32 IAVF_PATTERN_HINT_IPV6,
33 IAVF_PATTERN_HINT_IPV6_UDP,
34 IAVF_PATTERN_HINT_IPV6_TCP,
35 IAVF_PATTERN_HINT_IPV6_SCTP,
38 struct iavf_pattern_match_type {
39 enum iavf_pattern_hint_type phint_type;
42 struct iavf_hash_match_type {
43 enum iavf_pattern_hint_type phint_type;
45 struct virtchnl_proto_hdrs *proto_hdrs;
48 struct iavf_rss_meta {
49 struct virtchnl_proto_hdrs *proto_hdrs;
50 uint32_t hash_function;
53 struct iavf_hash_flow_cfg {
54 struct virtchnl_rss_cfg *rss_cfg;
59 iavf_hash_init(struct iavf_adapter *ad);
61 iavf_hash_create(struct iavf_adapter *ad, struct rte_flow *flow, void *meta,
62 struct rte_flow_error *error);
64 iavf_hash_destroy(struct iavf_adapter *ad, struct rte_flow *flow,
65 struct rte_flow_error *error);
67 iavf_hash_uninit(struct iavf_adapter *ad);
69 iavf_hash_free(struct rte_flow *flow);
71 iavf_hash_parse_pattern_action(struct iavf_adapter *ad,
72 struct iavf_pattern_match_item *array,
74 const struct rte_flow_item pattern[],
75 const struct rte_flow_action actions[],
77 struct rte_flow_error *error);
79 struct iavf_pattern_match_type phint_empty = {
80 IAVF_PATTERN_HINT_NONE};
81 struct iavf_pattern_match_type phint_eth_ipv4 = {
82 IAVF_PATTERN_HINT_IPV4};
83 struct iavf_pattern_match_type phint_eth_ipv4_udp = {
84 IAVF_PATTERN_HINT_IPV4_UDP};
85 struct iavf_pattern_match_type phint_eth_ipv4_tcp = {
86 IAVF_PATTERN_HINT_IPV4_TCP};
87 struct iavf_pattern_match_type phint_eth_ipv4_sctp = {
88 IAVF_PATTERN_HINT_IPV4_SCTP};
89 struct iavf_pattern_match_type phint_eth_ipv4_gtpu_eh = {
90 IAVF_PATTERN_HINT_IPV4_UDP};
91 struct iavf_pattern_match_type phint_eth_ipv4_esp = {
92 IAVF_PATTERN_HINT_IPV4};
93 struct iavf_pattern_match_type phint_eth_ipv4_ah = {
94 IAVF_PATTERN_HINT_IPV4};
95 struct iavf_pattern_match_type phint_eth_ipv4_l2tpv3 = {
96 IAVF_PATTERN_HINT_IPV4};
97 struct iavf_pattern_match_type phint_eth_ipv4_pfcp = {
98 IAVF_PATTERN_HINT_IPV4_UDP};
99 struct iavf_pattern_match_type phint_eth_ipv6 = {
100 IAVF_PATTERN_HINT_IPV6};
101 struct iavf_pattern_match_type phint_eth_ipv6_udp = {
102 IAVF_PATTERN_HINT_IPV6_UDP};
103 struct iavf_pattern_match_type phint_eth_ipv6_tcp = {
104 IAVF_PATTERN_HINT_IPV6_TCP};
105 struct iavf_pattern_match_type phint_eth_ipv6_sctp = {
106 IAVF_PATTERN_HINT_IPV6_SCTP};
107 struct iavf_pattern_match_type phint_eth_ipv6_esp = {
108 IAVF_PATTERN_HINT_IPV6};
109 struct iavf_pattern_match_type phint_eth_ipv6_ah = {
110 IAVF_PATTERN_HINT_IPV6};
111 struct iavf_pattern_match_type phint_eth_ipv6_l2tpv3 = {
112 IAVF_PATTERN_HINT_IPV6};
113 struct iavf_pattern_match_type phint_eth_ipv6_pfcp = {
114 IAVF_PATTERN_HINT_IPV6_UDP};
117 * Supported pattern for hash.
118 * The first member is pattern item type,
119 * the second member is input set mask,
120 * the third member is pattern hint for hash.
122 static struct iavf_pattern_match_item iavf_hash_pattern_list[] = {
123 {iavf_pattern_eth_ipv4, IAVF_INSET_NONE, &phint_eth_ipv4},
124 {iavf_pattern_eth_ipv4_udp, IAVF_INSET_NONE, &phint_eth_ipv4_udp},
125 {iavf_pattern_eth_ipv4_tcp, IAVF_INSET_NONE, &phint_eth_ipv4_tcp},
126 {iavf_pattern_eth_ipv4_sctp, IAVF_INSET_NONE, &phint_eth_ipv4_sctp},
127 {iavf_pattern_eth_ipv6, IAVF_INSET_NONE, &phint_eth_ipv6},
128 {iavf_pattern_eth_ipv4_gtpu_eh_ipv4, IAVF_INSET_NONE,
129 &phint_eth_ipv4_gtpu_eh},
130 {iavf_pattern_eth_ipv4_gtpu_eh_ipv4_udp, IAVF_INSET_NONE,
131 &phint_eth_ipv4_gtpu_eh},
132 {iavf_pattern_eth_ipv4_gtpu_eh_ipv4_tcp, IAVF_INSET_NONE,
133 &phint_eth_ipv4_gtpu_eh},
134 {iavf_pattern_eth_ipv4_esp, IAVF_INSET_NONE, &phint_eth_ipv4_esp},
135 {iavf_pattern_eth_ipv4_ah, IAVF_INSET_NONE, &phint_eth_ipv4_ah},
136 {iavf_pattern_eth_ipv4_l2tpv3, IAVF_INSET_NONE,
137 &phint_eth_ipv4_l2tpv3},
138 {iavf_pattern_eth_ipv4_pfcp, IAVF_INSET_NONE, &phint_eth_ipv4_pfcp},
139 {iavf_pattern_eth_ipv6_udp, IAVF_INSET_NONE, &phint_eth_ipv6_udp},
140 {iavf_pattern_eth_ipv6_tcp, IAVF_INSET_NONE, &phint_eth_ipv6_tcp},
141 {iavf_pattern_eth_ipv6_sctp, IAVF_INSET_NONE, &phint_eth_ipv6_sctp},
142 {iavf_pattern_eth_ipv6_esp, IAVF_INSET_NONE, &phint_eth_ipv6_esp},
143 {iavf_pattern_eth_ipv6_ah, IAVF_INSET_NONE, &phint_eth_ipv6_ah},
144 {iavf_pattern_eth_ipv6_l2tpv3, IAVF_INSET_NONE,
145 &phint_eth_ipv6_l2tpv3},
146 {iavf_pattern_eth_ipv6_pfcp, IAVF_INSET_NONE, &phint_eth_ipv6_pfcp},
147 {iavf_pattern_empty, IAVF_INSET_NONE, &phint_empty},
150 #define GTP_EH_PDU_LINK_UP 1
151 #define GTP_EH_PDU_LINK_DWN 0
153 #define TUNNEL_LEVEL_OUTER 0
154 #define TUNNEL_LEVEL_FIRST_INNER 1
156 #define PROTO_COUNT_ONE 1
157 #define PROTO_COUNT_TWO 2
158 #define PROTO_COUNT_THREE 3
160 #define BUFF_NOUSED 0
161 #define FIELD_FOR_PROTO_ONLY 0
163 #define proto_hint_eth_src { \
164 VIRTCHNL_PROTO_HDR_ETH, VIRTCHNL_PROTO_HDR_ETH_SRC, {BUFF_NOUSED } }
166 #define proto_hint_eth_dst { \
167 VIRTCHNL_PROTO_HDR_ETH, VIRTCHNL_PROTO_HDR_ETH_DST, {BUFF_NOUSED } }
169 #define proto_hint_eth_only { \
170 VIRTCHNL_PROTO_HDR_ETH, FIELD_FOR_PROTO_ONLY, {BUFF_NOUSED } }
172 #define proto_hint_eth { \
173 VIRTCHNL_PROTO_HDR_ETH, \
174 VIRTCHNL_PROTO_HDR_ETH_SRC | VIRTCHNL_PROTO_HDR_ETH_DST, \
177 #define proto_hint_svlan { \
178 VIRTCHNL_PROTO_HDR_S_VLAN, VIRTCHNL_PROTO_HDR_S_VLAN_ID, \
181 #define proto_hint_cvlan { \
182 VIRTCHNL_PROTO_HDR_C_VLAN, VIRTCHNL_PROTO_HDR_C_VLAN_ID, \
185 #define proto_hint_ipv4_src { \
186 VIRTCHNL_PROTO_HDR_IPV4, VIRTCHNL_PROTO_HDR_IPV4_SRC, {BUFF_NOUSED } }
188 #define proto_hint_ipv4_dst { \
189 VIRTCHNL_PROTO_HDR_IPV4, VIRTCHNL_PROTO_HDR_IPV4_DST, {BUFF_NOUSED } }
191 #define proto_hint_ipv4_only { \
192 VIRTCHNL_PROTO_HDR_IPV4, FIELD_FOR_PROTO_ONLY, {BUFF_NOUSED } }
194 #define proto_hint_ipv4 { \
195 VIRTCHNL_PROTO_HDR_IPV4, \
196 VIRTCHNL_PROTO_HDR_IPV4_SRC | VIRTCHNL_PROTO_HDR_IPV4_DST, \
199 #define proto_hint_udp_src_port { \
200 VIRTCHNL_PROTO_HDR_UDP, VIRTCHNL_PROTO_HDR_UDP_SRC_PORT, \
203 #define proto_hint_udp_dst_port { \
204 VIRTCHNL_PROTO_HDR_UDP, VIRTCHNL_PROTO_HDR_UDP_DST_PORT, \
207 #define proto_hint_udp_only { \
208 VIRTCHNL_PROTO_HDR_UDP, FIELD_FOR_PROTO_ONLY, {BUFF_NOUSED } }
210 #define proto_hint_udp { \
211 VIRTCHNL_PROTO_HDR_UDP, \
212 VIRTCHNL_PROTO_HDR_UDP_SRC_PORT | VIRTCHNL_PROTO_HDR_UDP_DST_PORT, \
215 #define proto_hint_tcp_src_port { \
216 VIRTCHNL_PROTO_HDR_TCP, VIRTCHNL_PROTO_HDR_TCP_SRC_PORT, \
219 #define proto_hint_tcp_dst_port { \
220 VIRTCHNL_PROTO_HDR_TCP, VIRTCHNL_PROTO_HDR_TCP_DST_PORT, \
223 #define proto_hint_tcp_only { \
224 VIRTCHNL_PROTO_HDR_TCP, FIELD_FOR_PROTO_ONLY, {BUFF_NOUSED } }
226 #define proto_hint_tcp { \
227 VIRTCHNL_PROTO_HDR_TCP, \
228 VIRTCHNL_PROTO_HDR_TCP_SRC_PORT | VIRTCHNL_PROTO_HDR_TCP_DST_PORT, \
231 #define proto_hint_sctp_src_port { \
232 VIRTCHNL_PROTO_HDR_SCTP, VIRTCHNL_PROTO_HDR_SCTP_SRC_PORT, \
235 #define proto_hint_sctp_dst_port { \
236 VIRTCHNL_PROTO_HDR_SCTP, VIRTCHNL_PROTO_HDR_SCTP_DST_PORT, \
239 #define proto_hint_sctp_only { \
240 VIRTCHNL_PROTO_HDR_SCTP, FIELD_FOR_PROTO_ONLY, {BUFF_NOUSED } }
242 #define proto_hint_sctp { \
243 VIRTCHNL_PROTO_HDR_SCTP, \
244 VIRTCHNL_PROTO_HDR_SCTP_SRC_PORT | VIRTCHNL_PROTO_HDR_SCTP_DST_PORT, \
247 #define proto_hint_ipv6_src { \
248 VIRTCHNL_PROTO_HDR_IPV6, VIRTCHNL_PROTO_HDR_IPV6_SRC, {BUFF_NOUSED } }
250 #define proto_hint_ipv6_dst { \
251 VIRTCHNL_PROTO_HDR_IPV6, VIRTCHNL_PROTO_HDR_IPV6_DST, {BUFF_NOUSED } }
253 #define proto_hint_ipv6_only { \
254 VIRTCHNL_PROTO_HDR_IPV6, FIELD_FOR_PROTO_ONLY, {BUFF_NOUSED } }
256 #define proto_hint_ipv6 { \
257 VIRTCHNL_PROTO_HDR_IPV6, \
258 VIRTCHNL_PROTO_HDR_IPV6_SRC | VIRTCHNL_PROTO_HDR_IPV6_DST, \
261 #define proto_hint_gtpu_up_only { \
262 VIRTCHNL_PROTO_HDR_GTPU_EH_PDU_UP, \
263 FIELD_FOR_PROTO_ONLY, {BUFF_NOUSED } }
265 #define proto_hint_gtpu_dwn_only { \
266 VIRTCHNL_PROTO_HDR_GTPU_EH_PDU_DWN, \
267 FIELD_FOR_PROTO_ONLY, {BUFF_NOUSED } }
269 #define proto_hint_esp { \
270 VIRTCHNL_PROTO_HDR_ESP, \
271 VIRTCHNL_PROTO_HDR_ESP_SPI, {BUFF_NOUSED } }
273 #define proto_hint_ah { \
274 VIRTCHNL_PROTO_HDR_AH, \
275 VIRTCHNL_PROTO_HDR_AH_SPI, {BUFF_NOUSED } }
277 #define proto_hint_l2tpv3 { \
278 VIRTCHNL_PROTO_HDR_L2TPV3, \
279 VIRTCHNL_PROTO_HDR_L2TPV3_SESS_ID, {BUFF_NOUSED } }
281 #define proto_hint_pfcp { \
282 VIRTCHNL_PROTO_HDR_PFCP, VIRTCHNL_PROTO_HDR_PFCP_SEID, {BUFF_NOUSED } }
284 struct virtchnl_proto_hdrs hdrs_hint_eth_src = {
285 TUNNEL_LEVEL_OUTER, PROTO_COUNT_ONE, {proto_hint_eth_src }
288 struct virtchnl_proto_hdrs hdrs_hint_eth_dst = {
289 TUNNEL_LEVEL_OUTER, PROTO_COUNT_ONE, {proto_hint_eth_dst }
292 struct virtchnl_proto_hdrs hdrs_hint_eth = {
293 TUNNEL_LEVEL_OUTER, PROTO_COUNT_ONE, {proto_hint_eth }
296 struct virtchnl_proto_hdrs hdrs_hint_svlan = {
297 TUNNEL_LEVEL_OUTER, PROTO_COUNT_ONE, {proto_hint_svlan }
300 struct virtchnl_proto_hdrs hdrs_hint_cvlan = {
301 TUNNEL_LEVEL_OUTER, PROTO_COUNT_ONE, {proto_hint_cvlan }
304 struct virtchnl_proto_hdrs hdrs_hint_ipv4_src = {
305 TUNNEL_LEVEL_OUTER, PROTO_COUNT_ONE, {proto_hint_ipv4_src }
308 struct virtchnl_proto_hdrs hdrs_hint_ipv4_dst = {
309 TUNNEL_LEVEL_OUTER, PROTO_COUNT_ONE, {proto_hint_ipv4_dst }
312 struct virtchnl_proto_hdrs hdrs_hint_ipv4_src_gtpu_up = {
313 TUNNEL_LEVEL_FIRST_INNER, PROTO_COUNT_TWO, {proto_hint_gtpu_up_only,
314 proto_hint_ipv4_src }
317 struct virtchnl_proto_hdrs hdrs_hint_ipv4_dst_gtpu_dwn = {
318 TUNNEL_LEVEL_FIRST_INNER, PROTO_COUNT_TWO, {proto_hint_gtpu_dwn_only,
319 proto_hint_ipv4_dst }
322 struct virtchnl_proto_hdrs hdrs_hint_ipv4_esp = {
323 TUNNEL_LEVEL_OUTER, PROTO_COUNT_TWO, {proto_hint_ipv4_only,
327 struct virtchnl_proto_hdrs hdrs_hint_ipv4_ah = {
328 TUNNEL_LEVEL_OUTER, PROTO_COUNT_TWO, {proto_hint_ipv4_only,
332 struct virtchnl_proto_hdrs hdrs_hint_ipv4_l2tpv3 = {
333 TUNNEL_LEVEL_OUTER, PROTO_COUNT_TWO, {proto_hint_ipv4_only,
337 struct virtchnl_proto_hdrs hdrs_hint_ipv4_pfcp = {
338 TUNNEL_LEVEL_OUTER, PROTO_COUNT_TWO, {proto_hint_ipv4_only,
342 struct virtchnl_proto_hdrs hdrs_hint_ipv4 = {
343 TUNNEL_LEVEL_OUTER, PROTO_COUNT_ONE, {proto_hint_ipv4 }
346 struct virtchnl_proto_hdrs hdrs_hint_ipv4_src_udp_src_port = {
347 TUNNEL_LEVEL_OUTER, PROTO_COUNT_TWO, {proto_hint_ipv4_src,
348 proto_hint_udp_src_port }
351 struct virtchnl_proto_hdrs hdrs_hint_ipv4_src_udp_dst_port = {
352 TUNNEL_LEVEL_OUTER, PROTO_COUNT_TWO, {proto_hint_ipv4_src,
353 proto_hint_udp_dst_port }
356 struct virtchnl_proto_hdrs hdrs_hint_ipv4_dst_udp_src_port = {
357 TUNNEL_LEVEL_OUTER, PROTO_COUNT_TWO, {proto_hint_ipv4_dst,
358 proto_hint_udp_src_port }
361 struct virtchnl_proto_hdrs hdrs_hint_ipv4_dst_udp_dst_port = {
362 TUNNEL_LEVEL_OUTER, PROTO_COUNT_TWO, {proto_hint_ipv4_dst,
363 proto_hint_udp_dst_port }
366 struct virtchnl_proto_hdrs hdrs_hint_ipv4_udp_src_port = {
367 TUNNEL_LEVEL_OUTER, PROTO_COUNT_TWO, {proto_hint_ipv4_only,
368 proto_hint_udp_src_port }
371 struct virtchnl_proto_hdrs hdrs_hint_ipv4_udp_dst_port = {
372 TUNNEL_LEVEL_OUTER, PROTO_COUNT_TWO, {proto_hint_ipv4_only,
373 proto_hint_udp_dst_port }
376 struct virtchnl_proto_hdrs hdrs_hint_ipv4_udp = {
377 TUNNEL_LEVEL_OUTER, PROTO_COUNT_TWO, {proto_hint_ipv4,
381 struct virtchnl_proto_hdrs hdrs_hint_ipv4_src_tcp_src_port = {
382 TUNNEL_LEVEL_OUTER, PROTO_COUNT_TWO, {proto_hint_ipv4_src,
383 proto_hint_tcp_src_port }
386 struct virtchnl_proto_hdrs hdrs_hint_ipv4_src_tcp_dst_port = {
387 TUNNEL_LEVEL_OUTER, PROTO_COUNT_TWO, {proto_hint_ipv4_src,
388 proto_hint_tcp_dst_port }
391 struct virtchnl_proto_hdrs hdrs_hint_ipv4_dst_tcp_src_port = {
392 TUNNEL_LEVEL_OUTER, PROTO_COUNT_TWO, {proto_hint_ipv4_dst,
393 proto_hint_tcp_src_port }
396 struct virtchnl_proto_hdrs hdrs_hint_ipv4_dst_tcp_dst_port = {
397 TUNNEL_LEVEL_OUTER, PROTO_COUNT_TWO, {proto_hint_ipv4_dst,
398 proto_hint_tcp_dst_port }
401 struct virtchnl_proto_hdrs hdrs_hint_ipv4_tcp_src_port = {
402 TUNNEL_LEVEL_OUTER, PROTO_COUNT_TWO, {proto_hint_ipv4_only,
403 proto_hint_tcp_src_port }
406 struct virtchnl_proto_hdrs hdrs_hint_ipv4_tcp_dst_port = {
407 TUNNEL_LEVEL_OUTER, PROTO_COUNT_TWO, {proto_hint_ipv4_only,
408 proto_hint_tcp_dst_port }
411 struct virtchnl_proto_hdrs hdrs_hint_ipv4_tcp = {
412 TUNNEL_LEVEL_OUTER, PROTO_COUNT_TWO, {proto_hint_ipv4,
416 struct virtchnl_proto_hdrs hdrs_hint_ipv4_src_sctp_src_port = {
417 TUNNEL_LEVEL_OUTER, PROTO_COUNT_TWO, {proto_hint_ipv4_src,
418 proto_hint_sctp_src_port }
421 struct virtchnl_proto_hdrs hdrs_hint_ipv4_src_sctp_dst_port = {
422 TUNNEL_LEVEL_OUTER, PROTO_COUNT_TWO, {proto_hint_ipv4_src,
423 proto_hint_sctp_dst_port }
426 struct virtchnl_proto_hdrs hdrs_hint_ipv4_dst_sctp_src_port = {
427 TUNNEL_LEVEL_OUTER, PROTO_COUNT_TWO, {proto_hint_ipv4_dst,
428 proto_hint_sctp_src_port }
431 struct virtchnl_proto_hdrs hdrs_hint_ipv4_dst_sctp_dst_port = {
432 TUNNEL_LEVEL_OUTER, PROTO_COUNT_TWO, {proto_hint_ipv4_dst,
433 proto_hint_sctp_dst_port }
436 struct virtchnl_proto_hdrs hdrs_hint_ipv4_sctp_src_port = {
437 TUNNEL_LEVEL_OUTER, PROTO_COUNT_TWO, {proto_hint_ipv4_only,
438 proto_hint_sctp_src_port }
441 struct virtchnl_proto_hdrs hdrs_hint_ipv4_sctp_dst_port = {
442 TUNNEL_LEVEL_OUTER, PROTO_COUNT_TWO, {proto_hint_ipv4_only,
443 proto_hint_sctp_dst_port }
446 struct virtchnl_proto_hdrs hdrs_hint_ipv4_sctp = {
447 TUNNEL_LEVEL_OUTER, PROTO_COUNT_TWO, {proto_hint_ipv4,
451 struct virtchnl_proto_hdrs hdrs_hint_ipv6_src = {
452 TUNNEL_LEVEL_OUTER, PROTO_COUNT_ONE, {proto_hint_ipv6_src }
455 struct virtchnl_proto_hdrs hdrs_hint_ipv6_dst = {
456 TUNNEL_LEVEL_OUTER, PROTO_COUNT_ONE, {proto_hint_ipv6_dst }
459 struct virtchnl_proto_hdrs hdrs_hint_ipv6_esp = {
460 TUNNEL_LEVEL_OUTER, PROTO_COUNT_TWO, {proto_hint_ipv6_only,
464 struct virtchnl_proto_hdrs hdrs_hint_ipv6_ah = {
465 TUNNEL_LEVEL_OUTER, PROTO_COUNT_TWO, {proto_hint_ipv6_only,
469 struct virtchnl_proto_hdrs hdrs_hint_ipv6_l2tpv3 = {
470 TUNNEL_LEVEL_OUTER, PROTO_COUNT_TWO, {proto_hint_ipv6_only,
474 struct virtchnl_proto_hdrs hdrs_hint_ipv6_pfcp = {
475 TUNNEL_LEVEL_OUTER, PROTO_COUNT_TWO, {proto_hint_ipv6_only,
479 struct virtchnl_proto_hdrs hdrs_hint_ipv6 = {
480 TUNNEL_LEVEL_OUTER, PROTO_COUNT_ONE, {proto_hint_ipv6 }
483 struct virtchnl_proto_hdrs hdrs_hint_ipv6_src_udp_src_port = {
484 TUNNEL_LEVEL_OUTER, PROTO_COUNT_TWO, {proto_hint_ipv6_src,
485 proto_hint_udp_src_port }
488 struct virtchnl_proto_hdrs hdrs_hint_ipv6_src_udp_dst_port = {
489 TUNNEL_LEVEL_OUTER, PROTO_COUNT_TWO, {proto_hint_ipv6_src,
490 proto_hint_udp_dst_port }
493 struct virtchnl_proto_hdrs hdrs_hint_ipv6_dst_udp_src_port = {
494 TUNNEL_LEVEL_OUTER, PROTO_COUNT_TWO, {proto_hint_ipv6_dst,
495 proto_hint_udp_src_port }
498 struct virtchnl_proto_hdrs hdrs_hint_ipv6_dst_udp_dst_port = {
499 TUNNEL_LEVEL_OUTER, PROTO_COUNT_TWO, {proto_hint_ipv6_dst,
500 proto_hint_udp_dst_port }
503 struct virtchnl_proto_hdrs hdrs_hint_ipv6_udp_src_port = {
504 TUNNEL_LEVEL_OUTER, PROTO_COUNT_TWO, {proto_hint_udp_only,
505 proto_hint_udp_src_port }
508 struct virtchnl_proto_hdrs hdrs_hint_ipv6_udp_dst_port = {
509 TUNNEL_LEVEL_OUTER, PROTO_COUNT_TWO, {proto_hint_udp_only,
510 proto_hint_udp_dst_port }
513 struct virtchnl_proto_hdrs hdrs_hint_ipv6_udp = {
514 TUNNEL_LEVEL_OUTER, PROTO_COUNT_TWO, {proto_hint_ipv6,
518 struct virtchnl_proto_hdrs hdrs_hint_ipv6_src_tcp_src_port = {
519 TUNNEL_LEVEL_OUTER, PROTO_COUNT_TWO, {proto_hint_ipv6_src,
520 proto_hint_tcp_src_port }
523 struct virtchnl_proto_hdrs hdrs_hint_ipv6_src_tcp_dst_port = {
524 TUNNEL_LEVEL_OUTER, PROTO_COUNT_TWO, {proto_hint_ipv6_src,
525 proto_hint_tcp_dst_port }
528 struct virtchnl_proto_hdrs hdrs_hint_ipv6_dst_tcp_src_port = {
529 TUNNEL_LEVEL_OUTER, PROTO_COUNT_TWO, {proto_hint_ipv6_dst,
530 proto_hint_tcp_src_port }
533 struct virtchnl_proto_hdrs hdrs_hint_ipv6_dst_tcp_dst_port = {
534 TUNNEL_LEVEL_OUTER, PROTO_COUNT_TWO, {proto_hint_ipv6_dst,
535 proto_hint_tcp_dst_port }
538 struct virtchnl_proto_hdrs hdrs_hint_ipv6_tcp_src_port = {
539 TUNNEL_LEVEL_OUTER, PROTO_COUNT_TWO, {proto_hint_udp_only,
540 proto_hint_tcp_src_port }
543 struct virtchnl_proto_hdrs hdrs_hint_ipv6_tcp_dst_port = {
544 TUNNEL_LEVEL_OUTER, PROTO_COUNT_TWO, {proto_hint_udp_only,
545 proto_hint_tcp_dst_port }
548 struct virtchnl_proto_hdrs hdrs_hint_ipv6_tcp = {
549 TUNNEL_LEVEL_OUTER, PROTO_COUNT_TWO, {proto_hint_ipv6,
553 struct virtchnl_proto_hdrs hdrs_hint_ipv6_src_sctp_src_port = {
554 TUNNEL_LEVEL_OUTER, PROTO_COUNT_TWO, {proto_hint_ipv6_src,
555 proto_hint_sctp_src_port }
558 struct virtchnl_proto_hdrs hdrs_hint_ipv6_src_sctp_dst_port = {
559 TUNNEL_LEVEL_OUTER, PROTO_COUNT_TWO, {proto_hint_ipv6_src,
560 proto_hint_sctp_dst_port }
563 struct virtchnl_proto_hdrs hdrs_hint_ipv6_dst_sctp_src_port = {
564 TUNNEL_LEVEL_OUTER, PROTO_COUNT_TWO, {proto_hint_ipv6_dst,
565 proto_hint_sctp_src_port }
568 struct virtchnl_proto_hdrs hdrs_hint_ipv6_dst_sctp_dst_port = {
569 TUNNEL_LEVEL_OUTER, PROTO_COUNT_TWO, {proto_hint_ipv6_dst,
570 proto_hint_sctp_dst_port }
573 struct virtchnl_proto_hdrs hdrs_hint_ipv6_sctp_src_port = {
574 TUNNEL_LEVEL_OUTER, PROTO_COUNT_TWO, {proto_hint_udp_only,
575 proto_hint_sctp_src_port }
578 struct virtchnl_proto_hdrs hdrs_hint_ipv6_sctp_dst_port = {
579 TUNNEL_LEVEL_OUTER, PROTO_COUNT_TWO, {proto_hint_udp_only,
580 proto_hint_sctp_dst_port }
583 struct virtchnl_proto_hdrs hdrs_hint_ipv6_sctp = {
584 TUNNEL_LEVEL_OUTER, PROTO_COUNT_TWO, {proto_hint_ipv6,
589 * The first member is pattern hint type,
590 * the second member is hash type,
591 * the third member is virtchnl protocol hdrs.
593 struct iavf_hash_match_type iavf_hash_type_list[] = {
595 {IAVF_PATTERN_HINT_IPV4, ETH_RSS_L2_SRC_ONLY, &hdrs_hint_eth_src},
596 {IAVF_PATTERN_HINT_IPV4, ETH_RSS_L2_DST_ONLY, &hdrs_hint_eth_dst},
597 {IAVF_PATTERN_HINT_IPV4, ETH_RSS_ETH, &hdrs_hint_eth},
598 {IAVF_PATTERN_HINT_IPV4, ETH_RSS_S_VLAN, &hdrs_hint_svlan},
599 {IAVF_PATTERN_HINT_IPV4, ETH_RSS_C_VLAN, &hdrs_hint_cvlan},
600 {IAVF_PATTERN_HINT_IPV4, ETH_RSS_L3_SRC_ONLY, &hdrs_hint_ipv4_src},
601 {IAVF_PATTERN_HINT_IPV4, ETH_RSS_L3_DST_ONLY, &hdrs_hint_ipv4_dst},
602 {IAVF_PATTERN_HINT_IPV4, ETH_RSS_ESP, &hdrs_hint_ipv4_esp},
603 {IAVF_PATTERN_HINT_IPV4, ETH_RSS_AH, &hdrs_hint_ipv4_ah},
604 {IAVF_PATTERN_HINT_IPV4, ETH_RSS_L2TPV3, &hdrs_hint_ipv4_l2tpv3},
605 {IAVF_PATTERN_HINT_IPV4, ETH_RSS_IPV4, &hdrs_hint_ipv4},
607 {IAVF_PATTERN_HINT_IPV4_UDP, ETH_RSS_L3_SRC_ONLY | ETH_RSS_L4_SRC_ONLY,
608 &hdrs_hint_ipv4_src_udp_src_port},
609 {IAVF_PATTERN_HINT_IPV4_UDP, ETH_RSS_L3_SRC_ONLY | ETH_RSS_L4_DST_ONLY,
610 &hdrs_hint_ipv4_src_udp_dst_port},
611 {IAVF_PATTERN_HINT_IPV4_UDP, ETH_RSS_L3_SRC_ONLY | ETH_RSS_GTPU,
612 &hdrs_hint_ipv4_src_gtpu_up},
613 {IAVF_PATTERN_HINT_IPV4_UDP, ETH_RSS_L3_SRC_ONLY,
614 &hdrs_hint_ipv4_src},
615 {IAVF_PATTERN_HINT_IPV4_UDP, ETH_RSS_L3_DST_ONLY | ETH_RSS_L4_SRC_ONLY,
616 &hdrs_hint_ipv4_dst_udp_src_port},
617 {IAVF_PATTERN_HINT_IPV4_UDP, ETH_RSS_L3_DST_ONLY | ETH_RSS_L4_DST_ONLY,
618 &hdrs_hint_ipv4_dst_udp_dst_port},
619 {IAVF_PATTERN_HINT_IPV4_UDP, ETH_RSS_L3_DST_ONLY | ETH_RSS_GTPU,
620 &hdrs_hint_ipv4_dst_gtpu_dwn},
621 {IAVF_PATTERN_HINT_IPV4_UDP, ETH_RSS_L3_DST_ONLY,
622 &hdrs_hint_ipv4_dst},
623 {IAVF_PATTERN_HINT_IPV4_UDP, ETH_RSS_L4_SRC_ONLY,
624 &hdrs_hint_ipv4_udp_src_port},
625 {IAVF_PATTERN_HINT_IPV4_UDP, ETH_RSS_L4_DST_ONLY,
626 &hdrs_hint_ipv4_udp_dst_port},
627 {IAVF_PATTERN_HINT_IPV4_UDP, ETH_RSS_PFCP,
628 &hdrs_hint_ipv4_pfcp},
629 {IAVF_PATTERN_HINT_IPV4_UDP, ETH_RSS_NONFRAG_IPV4_UDP,
630 &hdrs_hint_ipv4_udp},
632 {IAVF_PATTERN_HINT_IPV4_TCP, ETH_RSS_L3_SRC_ONLY | ETH_RSS_L4_SRC_ONLY,
633 &hdrs_hint_ipv4_src_tcp_src_port},
634 {IAVF_PATTERN_HINT_IPV4_TCP, ETH_RSS_L3_SRC_ONLY | ETH_RSS_L4_DST_ONLY,
635 &hdrs_hint_ipv4_src_tcp_dst_port},
636 {IAVF_PATTERN_HINT_IPV4_TCP, ETH_RSS_L3_SRC_ONLY,
637 &hdrs_hint_ipv4_src},
638 {IAVF_PATTERN_HINT_IPV4_TCP, ETH_RSS_L3_DST_ONLY | ETH_RSS_L4_SRC_ONLY,
639 &hdrs_hint_ipv4_dst_tcp_src_port},
640 {IAVF_PATTERN_HINT_IPV4_TCP, ETH_RSS_L3_DST_ONLY | ETH_RSS_L4_DST_ONLY,
641 &hdrs_hint_ipv4_dst_tcp_dst_port},
642 {IAVF_PATTERN_HINT_IPV4_TCP, ETH_RSS_L3_DST_ONLY,
643 &hdrs_hint_ipv4_dst},
644 {IAVF_PATTERN_HINT_IPV4_TCP, ETH_RSS_L4_SRC_ONLY,
645 &hdrs_hint_ipv4_tcp_src_port},
646 {IAVF_PATTERN_HINT_IPV4_TCP, ETH_RSS_L4_DST_ONLY,
647 &hdrs_hint_ipv4_tcp_dst_port},
648 {IAVF_PATTERN_HINT_IPV4_TCP, ETH_RSS_NONFRAG_IPV4_TCP,
649 &hdrs_hint_ipv4_tcp},
651 {IAVF_PATTERN_HINT_IPV4_SCTP, ETH_RSS_L3_SRC_ONLY | ETH_RSS_L4_SRC_ONLY,
652 &hdrs_hint_ipv4_src_sctp_src_port},
653 {IAVF_PATTERN_HINT_IPV4_SCTP, ETH_RSS_L3_SRC_ONLY | ETH_RSS_L4_DST_ONLY,
654 &hdrs_hint_ipv4_src_sctp_dst_port},
655 {IAVF_PATTERN_HINT_IPV4_SCTP, ETH_RSS_L3_SRC_ONLY,
656 &hdrs_hint_ipv4_src},
657 {IAVF_PATTERN_HINT_IPV4_SCTP, ETH_RSS_L3_DST_ONLY | ETH_RSS_L4_SRC_ONLY,
658 &hdrs_hint_ipv4_dst_sctp_src_port},
659 {IAVF_PATTERN_HINT_IPV4_SCTP, ETH_RSS_L3_DST_ONLY | ETH_RSS_L4_DST_ONLY,
660 &hdrs_hint_ipv4_dst_sctp_dst_port},
661 {IAVF_PATTERN_HINT_IPV4_SCTP, ETH_RSS_L3_DST_ONLY,
662 &hdrs_hint_ipv4_dst},
663 {IAVF_PATTERN_HINT_IPV4_SCTP, ETH_RSS_L4_SRC_ONLY,
664 &hdrs_hint_ipv4_sctp_src_port},
665 {IAVF_PATTERN_HINT_IPV4_SCTP, ETH_RSS_L4_DST_ONLY,
666 &hdrs_hint_ipv4_sctp_dst_port},
667 {IAVF_PATTERN_HINT_IPV4_SCTP, ETH_RSS_NONFRAG_IPV4_SCTP,
668 &hdrs_hint_ipv4_sctp},
670 {IAVF_PATTERN_HINT_IPV6, ETH_RSS_L2_SRC_ONLY, &hdrs_hint_eth_src},
671 {IAVF_PATTERN_HINT_IPV6, ETH_RSS_L2_DST_ONLY, &hdrs_hint_eth_dst},
672 {IAVF_PATTERN_HINT_IPV6, ETH_RSS_ETH, &hdrs_hint_eth},
673 {IAVF_PATTERN_HINT_IPV6, ETH_RSS_S_VLAN, &hdrs_hint_svlan},
674 {IAVF_PATTERN_HINT_IPV4, ETH_RSS_C_VLAN, &hdrs_hint_cvlan},
675 {IAVF_PATTERN_HINT_IPV6, ETH_RSS_L3_SRC_ONLY, &hdrs_hint_ipv6_src},
676 {IAVF_PATTERN_HINT_IPV6, ETH_RSS_L3_DST_ONLY, &hdrs_hint_ipv6_dst},
677 {IAVF_PATTERN_HINT_IPV6, ETH_RSS_ESP, &hdrs_hint_ipv6_esp},
678 {IAVF_PATTERN_HINT_IPV6, ETH_RSS_AH, &hdrs_hint_ipv6_ah},
679 {IAVF_PATTERN_HINT_IPV6, ETH_RSS_L2TPV3, &hdrs_hint_ipv6_l2tpv3},
680 {IAVF_PATTERN_HINT_IPV6, ETH_RSS_IPV6, &hdrs_hint_ipv6},
682 {IAVF_PATTERN_HINT_IPV6_UDP, ETH_RSS_L3_SRC_ONLY | ETH_RSS_L4_SRC_ONLY,
683 &hdrs_hint_ipv6_src_udp_src_port},
684 {IAVF_PATTERN_HINT_IPV6_UDP, ETH_RSS_L3_SRC_ONLY | ETH_RSS_L4_DST_ONLY,
685 &hdrs_hint_ipv6_src_udp_dst_port},
686 {IAVF_PATTERN_HINT_IPV6_UDP, ETH_RSS_L3_SRC_ONLY,
687 &hdrs_hint_ipv6_src},
688 {IAVF_PATTERN_HINT_IPV6_UDP, ETH_RSS_L3_DST_ONLY | ETH_RSS_L4_SRC_ONLY,
689 &hdrs_hint_ipv6_dst_udp_src_port},
690 {IAVF_PATTERN_HINT_IPV6_UDP, ETH_RSS_L3_DST_ONLY | ETH_RSS_L4_DST_ONLY,
691 &hdrs_hint_ipv6_dst_udp_dst_port},
692 {IAVF_PATTERN_HINT_IPV6_UDP, ETH_RSS_L3_DST_ONLY,
693 &hdrs_hint_ipv6_dst},
694 {IAVF_PATTERN_HINT_IPV6_UDP, ETH_RSS_L4_SRC_ONLY,
695 &hdrs_hint_ipv6_udp_src_port},
696 {IAVF_PATTERN_HINT_IPV6_UDP, ETH_RSS_L4_DST_ONLY,
697 &hdrs_hint_ipv6_udp_dst_port},
698 {IAVF_PATTERN_HINT_IPV6_UDP, ETH_RSS_PFCP,
699 &hdrs_hint_ipv6_pfcp},
700 {IAVF_PATTERN_HINT_IPV6_UDP, ETH_RSS_NONFRAG_IPV6_UDP,
701 &hdrs_hint_ipv6_udp},
703 {IAVF_PATTERN_HINT_IPV6_TCP, ETH_RSS_L3_SRC_ONLY | ETH_RSS_L4_SRC_ONLY,
704 &hdrs_hint_ipv6_src_tcp_src_port},
705 {IAVF_PATTERN_HINT_IPV6_TCP, ETH_RSS_L3_SRC_ONLY | ETH_RSS_L4_DST_ONLY,
706 &hdrs_hint_ipv6_src_tcp_dst_port},
707 {IAVF_PATTERN_HINT_IPV6_TCP, ETH_RSS_L3_SRC_ONLY,
708 &hdrs_hint_ipv6_src},
709 {IAVF_PATTERN_HINT_IPV6_TCP, ETH_RSS_L3_DST_ONLY | ETH_RSS_L4_SRC_ONLY,
710 &hdrs_hint_ipv6_dst_tcp_src_port},
711 {IAVF_PATTERN_HINT_IPV6_TCP, ETH_RSS_L3_DST_ONLY | ETH_RSS_L4_DST_ONLY,
712 &hdrs_hint_ipv6_dst_tcp_dst_port},
713 {IAVF_PATTERN_HINT_IPV6_TCP, ETH_RSS_L3_DST_ONLY,
714 &hdrs_hint_ipv6_dst},
715 {IAVF_PATTERN_HINT_IPV6_TCP, ETH_RSS_L4_SRC_ONLY,
716 &hdrs_hint_ipv6_tcp_src_port},
717 {IAVF_PATTERN_HINT_IPV6_TCP, ETH_RSS_L4_DST_ONLY,
718 &hdrs_hint_ipv6_tcp_dst_port},
719 {IAVF_PATTERN_HINT_IPV6_TCP, ETH_RSS_NONFRAG_IPV6_TCP,
720 &hdrs_hint_ipv6_tcp},
722 {IAVF_PATTERN_HINT_IPV6_SCTP, ETH_RSS_L3_SRC_ONLY | ETH_RSS_L4_SRC_ONLY,
723 &hdrs_hint_ipv6_src_sctp_src_port},
724 {IAVF_PATTERN_HINT_IPV6_SCTP, ETH_RSS_L3_SRC_ONLY | ETH_RSS_L4_DST_ONLY,
725 &hdrs_hint_ipv6_src_sctp_dst_port},
726 {IAVF_PATTERN_HINT_IPV6_SCTP, ETH_RSS_L3_SRC_ONLY,
727 &hdrs_hint_ipv6_src},
728 {IAVF_PATTERN_HINT_IPV6_SCTP, ETH_RSS_L3_DST_ONLY | ETH_RSS_L4_SRC_ONLY,
729 &hdrs_hint_ipv6_dst_sctp_src_port},
730 {IAVF_PATTERN_HINT_IPV6_SCTP, ETH_RSS_L3_DST_ONLY | ETH_RSS_L4_DST_ONLY,
731 &hdrs_hint_ipv6_dst_sctp_dst_port},
732 {IAVF_PATTERN_HINT_IPV6_SCTP, ETH_RSS_L3_DST_ONLY,
733 &hdrs_hint_ipv6_dst},
734 {IAVF_PATTERN_HINT_IPV6_SCTP, ETH_RSS_L4_SRC_ONLY,
735 &hdrs_hint_ipv6_sctp_src_port},
736 {IAVF_PATTERN_HINT_IPV6_SCTP, ETH_RSS_L4_DST_ONLY,
737 &hdrs_hint_ipv6_sctp_dst_port},
738 {IAVF_PATTERN_HINT_IPV6_SCTP, ETH_RSS_NONFRAG_IPV6_SCTP,
739 &hdrs_hint_ipv6_sctp},
742 static struct iavf_flow_engine iavf_hash_engine = {
743 .init = iavf_hash_init,
744 .create = iavf_hash_create,
745 .destroy = iavf_hash_destroy,
746 .uninit = iavf_hash_uninit,
747 .free = iavf_hash_free,
748 .type = IAVF_FLOW_ENGINE_HASH,
751 /* Register parser for comms package. */
752 static struct iavf_flow_parser iavf_hash_parser = {
753 .engine = &iavf_hash_engine,
754 .array = iavf_hash_pattern_list,
755 .array_len = RTE_DIM(iavf_hash_pattern_list),
756 .parse_pattern_action = iavf_hash_parse_pattern_action,
757 .stage = IAVF_FLOW_STAGE_RSS,
760 RTE_INIT(iavf_hash_engine_init)
762 struct iavf_flow_engine *engine = &iavf_hash_engine;
764 iavf_register_flow_engine(engine);
768 iavf_hash_init(struct iavf_adapter *ad)
770 struct iavf_info *vf = IAVF_DEV_PRIVATE_TO_VF(ad);
771 struct iavf_flow_parser *parser;
776 if (!(vf->vf_res->vf_cap_flags & VIRTCHNL_VF_OFFLOAD_ADV_RSS_PF))
779 parser = &iavf_hash_parser;
781 return iavf_register_parser(parser, ad);
785 iavf_hash_check_inset(const struct rte_flow_item pattern[],
786 struct rte_flow_error *error)
788 const struct rte_flow_item *item = pattern;
790 for (item = pattern; item->type != RTE_FLOW_ITEM_TYPE_END; item++) {
792 rte_flow_error_set(error, EINVAL,
793 RTE_FLOW_ERROR_TYPE_ITEM, item,
794 "Not support range");
803 iavf_hash_refine_type(uint64_t rss_type, const struct rte_flow_item pattern[])
805 const struct rte_flow_item *item;
807 for (item = pattern; item->type != RTE_FLOW_ITEM_TYPE_END; item++) {
808 if (item->type == RTE_FLOW_ITEM_TYPE_GTP_PSC) {
809 const struct rte_flow_item_gtp_psc *psc = item->spec;
811 if (psc && (psc->pdu_type == GTP_EH_PDU_LINK_UP ||
812 psc->pdu_type == GTP_EH_PDU_LINK_DWN)) {
813 rss_type |= ETH_RSS_GTPU;
822 iavf_hash_parse_action(struct iavf_pattern_match_item *pattern_match_item,
823 const struct rte_flow_item pattern[],
824 const struct rte_flow_action actions[],
825 void **meta, struct rte_flow_error *error)
827 struct iavf_rss_meta *rss_meta = (struct iavf_rss_meta *)*meta;
828 uint32_t type_list_len = RTE_DIM(iavf_hash_type_list);
829 struct iavf_hash_match_type *type_match_item;
830 enum rte_flow_action_type action_type;
831 const struct rte_flow_action_rss *rss;
832 const struct rte_flow_action *action;
833 bool item_found = false;
837 struct iavf_pattern_match_type *tt = (struct iavf_pattern_match_type *)
838 (pattern_match_item->meta);
840 /* Supported action is RSS. */
841 for (action = actions; action->type !=
842 RTE_FLOW_ACTION_TYPE_END; action++) {
843 action_type = action->type;
844 switch (action_type) {
845 case RTE_FLOW_ACTION_TYPE_RSS:
847 rss_type = rss->types;
850 * Check simultaneous use of SRC_ONLY and DST_ONLY
853 rss_type = rte_eth_rss_hf_refine(rss_type);
856 * Refine the hash type base on some specific item of
857 * the pattern, such as identify the gtpu hash.
859 rss_type = iavf_hash_refine_type(rss_type, pattern);
861 /* Check if pattern is empty. */
862 if (pattern_match_item->pattern_list !=
863 iavf_pattern_empty && rss->func ==
864 RTE_ETH_HASH_FUNCTION_SIMPLE_XOR)
865 return rte_flow_error_set(error, ENOTSUP,
866 RTE_FLOW_ERROR_TYPE_ACTION, action,
867 "Not supported flow");
870 return rte_flow_error_set(error, ENOTSUP,
871 RTE_FLOW_ERROR_TYPE_ACTION, action,
872 "a nonzero RSS encapsulation level is not supported");
875 return rte_flow_error_set(error, ENOTSUP,
876 RTE_FLOW_ERROR_TYPE_ACTION, action,
877 "a nonzero RSS key_len is not supported");
880 return rte_flow_error_set(error, ENOTSUP,
881 RTE_FLOW_ERROR_TYPE_ACTION, action,
882 "a non-NULL RSS queue is not supported");
884 /* Check hash function and save it to rss_meta. */
885 if (rss->func == RTE_ETH_HASH_FUNCTION_SIMPLE_XOR)
886 rss_meta->hash_function =
887 RTE_ETH_HASH_FUNCTION_SIMPLE_XOR;
890 RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ)
891 rss_meta->hash_function =
892 RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ;
895 rte_zmalloc("iavf_type_match_item",
896 sizeof(struct iavf_hash_match_type), 0);
897 if (!type_match_item) {
898 rte_flow_error_set(error, EINVAL,
899 RTE_FLOW_ERROR_TYPE_HANDLE,
901 "No memory for type_match_item");
905 /* Find matched proto hdrs according to hash type. */
906 for (i = 0; i < type_list_len; i++) {
907 struct iavf_hash_match_type *ht_map =
908 &iavf_hash_type_list[i];
909 if (rss_type == ht_map->hash_type &&
910 tt->phint_type == ht_map->phint_type) {
911 type_match_item->hash_type =
913 type_match_item->proto_hdrs =
915 rss_meta->proto_hdrs =
916 type_match_item->proto_hdrs;
921 rte_free(type_match_item);
924 return rte_flow_error_set(error, ENOTSUP,
925 RTE_FLOW_ERROR_TYPE_ACTION, action,
926 "Not supported flow");
929 case RTE_FLOW_ACTION_TYPE_END:
933 rte_flow_error_set(error, EINVAL,
934 RTE_FLOW_ERROR_TYPE_ACTION, action,
944 iavf_hash_parse_pattern_action(__rte_unused struct iavf_adapter *ad,
945 struct iavf_pattern_match_item *array,
947 const struct rte_flow_item pattern[],
948 const struct rte_flow_action actions[],
950 struct rte_flow_error *error)
952 struct iavf_pattern_match_item *pattern_match_item;
953 struct iavf_rss_meta *rss_meta_ptr;
956 rss_meta_ptr = rte_zmalloc(NULL, sizeof(*rss_meta_ptr), 0);
958 rte_flow_error_set(error, EINVAL,
959 RTE_FLOW_ERROR_TYPE_HANDLE, NULL,
960 "No memory for rss_meta_ptr");
964 /* Check rss supported pattern and find matched pattern. */
966 iavf_search_pattern_match_item(pattern, array, array_len,
968 if (!pattern_match_item) {
973 ret = iavf_hash_check_inset(pattern, error);
977 /* Check rss action. */
978 ret = iavf_hash_parse_action(pattern_match_item, pattern, actions,
979 (void **)&rss_meta_ptr, error);
983 *meta = rss_meta_ptr;
985 rte_free(rss_meta_ptr);
987 rte_free(pattern_match_item);
993 iavf_hash_create(__rte_unused struct iavf_adapter *ad,
994 __rte_unused struct rte_flow *flow, void *meta,
995 __rte_unused struct rte_flow_error *error)
997 struct iavf_rss_meta *rss_meta = (struct iavf_rss_meta *)meta;
998 struct virtchnl_rss_cfg *rss_cfg;
1001 rss_cfg = rte_zmalloc("iavf rss rule",
1002 sizeof(struct virtchnl_rss_cfg), 0);
1004 rte_flow_error_set(error, EINVAL,
1005 RTE_FLOW_ERROR_TYPE_HANDLE, NULL,
1006 "No memory for rss rule");
1010 rss_cfg->proto_hdrs = *rss_meta->proto_hdrs;
1011 rss_cfg->rss_algorithm = rss_meta->hash_function;
1013 ret = iavf_add_del_rss_cfg(ad, rss_cfg, true);
1015 flow->rule = rss_cfg;
1017 PMD_DRV_LOG(ERR, "fail to add RSS configure");
1027 iavf_hash_destroy(__rte_unused struct iavf_adapter *ad,
1028 struct rte_flow *flow,
1029 __rte_unused struct rte_flow_error *error)
1031 struct virtchnl_rss_cfg *rss_cfg;
1034 rss_cfg = (struct virtchnl_rss_cfg *)flow->rule;
1036 ret = iavf_add_del_rss_cfg(ad, rss_cfg, false);
1038 PMD_DRV_LOG(ERR, "fail to del RSS configure");
1044 iavf_hash_uninit(struct iavf_adapter *ad)
1046 iavf_unregister_parser(&iavf_hash_parser, ad);
1050 iavf_hash_free(struct rte_flow *flow)
1052 rte_free(flow->rule);