]> git.proxmox.com Git - ceph.git/blame - ceph/src/spdk/dpdk/drivers/net/iavf/iavf_hash.c
update source to Ceph Pacific 16.2.2
[ceph.git] / ceph / src / spdk / dpdk / drivers / net / iavf / iavf_hash.c
CommitLineData
f67539c2
TL
1/* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2020 Intel Corporation
3 */
4
5#include <sys/queue.h>
6#include <stdio.h>
7#include <errno.h>
8#include <stdint.h>
9#include <string.h>
10#include <unistd.h>
11#include <stdarg.h>
12
13#include <rte_debug.h>
14#include <rte_ether.h>
15#include <rte_ethdev_driver.h>
16#include <rte_log.h>
17#include <rte_malloc.h>
18#include <rte_eth_ctrl.h>
19#include <rte_tailq.h>
20#include <rte_flow_driver.h>
21
22#include "iavf_log.h"
23#include "iavf.h"
24#include "iavf_generic_flow.h"
25
26enum 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,
36};
37
38struct iavf_pattern_match_type {
39 enum iavf_pattern_hint_type phint_type;
40};
41
42struct iavf_hash_match_type {
43 enum iavf_pattern_hint_type phint_type;
44 uint64_t hash_type;
45 struct virtchnl_proto_hdrs *proto_hdrs;
46};
47
48struct iavf_rss_meta {
49 struct virtchnl_proto_hdrs *proto_hdrs;
50 enum virtchnl_rss_algorithm rss_algorithm;
51};
52
53struct iavf_hash_flow_cfg {
54 struct virtchnl_rss_cfg *rss_cfg;
55 bool simple_xor;
56};
57
58static int
59iavf_hash_init(struct iavf_adapter *ad);
60static int
61iavf_hash_create(struct iavf_adapter *ad, struct rte_flow *flow, void *meta,
62 struct rte_flow_error *error);
63static int
64iavf_hash_destroy(struct iavf_adapter *ad, struct rte_flow *flow,
65 struct rte_flow_error *error);
66static void
67iavf_hash_uninit(struct iavf_adapter *ad);
68static void
69iavf_hash_free(struct rte_flow *flow);
70static int
71iavf_hash_parse_pattern_action(struct iavf_adapter *ad,
72 struct iavf_pattern_match_item *array,
73 uint32_t array_len,
74 const struct rte_flow_item pattern[],
75 const struct rte_flow_action actions[],
76 void **meta,
77 struct rte_flow_error *error);
78
79struct iavf_pattern_match_type phint_empty = {
80 IAVF_PATTERN_HINT_NONE};
81struct iavf_pattern_match_type phint_eth_ipv4 = {
82 IAVF_PATTERN_HINT_IPV4};
83struct iavf_pattern_match_type phint_eth_ipv4_udp = {
84 IAVF_PATTERN_HINT_IPV4_UDP};
85struct iavf_pattern_match_type phint_eth_ipv4_tcp = {
86 IAVF_PATTERN_HINT_IPV4_TCP};
87struct iavf_pattern_match_type phint_eth_ipv4_sctp = {
88 IAVF_PATTERN_HINT_IPV4_SCTP};
89struct iavf_pattern_match_type phint_eth_ipv4_gtpu_eh = {
90 IAVF_PATTERN_HINT_IPV4_UDP};
91struct iavf_pattern_match_type phint_eth_ipv4_esp = {
92 IAVF_PATTERN_HINT_IPV4};
93struct iavf_pattern_match_type phint_eth_ipv4_ah = {
94 IAVF_PATTERN_HINT_IPV4};
95struct iavf_pattern_match_type phint_eth_ipv4_l2tpv3 = {
96 IAVF_PATTERN_HINT_IPV4};
97struct iavf_pattern_match_type phint_eth_ipv4_pfcp = {
98 IAVF_PATTERN_HINT_IPV4_UDP};
99struct iavf_pattern_match_type phint_eth_ipv6 = {
100 IAVF_PATTERN_HINT_IPV6};
101struct iavf_pattern_match_type phint_eth_ipv6_udp = {
102 IAVF_PATTERN_HINT_IPV6_UDP};
103struct iavf_pattern_match_type phint_eth_ipv6_tcp = {
104 IAVF_PATTERN_HINT_IPV6_TCP};
105struct iavf_pattern_match_type phint_eth_ipv6_sctp = {
106 IAVF_PATTERN_HINT_IPV6_SCTP};
107struct iavf_pattern_match_type phint_eth_ipv6_esp = {
108 IAVF_PATTERN_HINT_IPV6};
109struct iavf_pattern_match_type phint_eth_ipv6_ah = {
110 IAVF_PATTERN_HINT_IPV6};
111struct iavf_pattern_match_type phint_eth_ipv6_l2tpv3 = {
112 IAVF_PATTERN_HINT_IPV6};
113struct iavf_pattern_match_type phint_eth_ipv6_pfcp = {
114 IAVF_PATTERN_HINT_IPV6_UDP};
115
116/**
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.
121 */
122static 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},
148};
149
150#define GTP_EH_PDU_LINK_UP 1
151#define GTP_EH_PDU_LINK_DWN 0
152
153#define TUNNEL_LEVEL_OUTER 0
154#define TUNNEL_LEVEL_FIRST_INNER 1
155
156#define PROTO_COUNT_ONE 1
157#define PROTO_COUNT_TWO 2
158#define PROTO_COUNT_THREE 3
159
160#define BUFF_NOUSED 0
161#define FIELD_FOR_PROTO_ONLY 0
162
163#define proto_hint_eth_src { \
164 VIRTCHNL_PROTO_HDR_ETH, VIRTCHNL_PROTO_HDR_ETH_SRC, {BUFF_NOUSED } }
165
166#define proto_hint_eth_dst { \
167 VIRTCHNL_PROTO_HDR_ETH, VIRTCHNL_PROTO_HDR_ETH_DST, {BUFF_NOUSED } }
168
169#define proto_hint_eth_only { \
170 VIRTCHNL_PROTO_HDR_ETH, FIELD_FOR_PROTO_ONLY, {BUFF_NOUSED } }
171
172#define proto_hint_eth { \
173 VIRTCHNL_PROTO_HDR_ETH, \
174 VIRTCHNL_PROTO_HDR_ETH_SRC | VIRTCHNL_PROTO_HDR_ETH_DST, \
175 {BUFF_NOUSED } }
176
177#define proto_hint_svlan { \
178 VIRTCHNL_PROTO_HDR_S_VLAN, VIRTCHNL_PROTO_HDR_S_VLAN_ID, \
179 {BUFF_NOUSED } }
180
181#define proto_hint_cvlan { \
182 VIRTCHNL_PROTO_HDR_C_VLAN, VIRTCHNL_PROTO_HDR_C_VLAN_ID, \
183 {BUFF_NOUSED } }
184
185#define proto_hint_ipv4_src { \
186 VIRTCHNL_PROTO_HDR_IPV4, VIRTCHNL_PROTO_HDR_IPV4_SRC, {BUFF_NOUSED } }
187
188#define proto_hint_ipv4_dst { \
189 VIRTCHNL_PROTO_HDR_IPV4, VIRTCHNL_PROTO_HDR_IPV4_DST, {BUFF_NOUSED } }
190
191#define proto_hint_ipv4_only { \
192 VIRTCHNL_PROTO_HDR_IPV4, FIELD_FOR_PROTO_ONLY, {BUFF_NOUSED } }
193
194#define proto_hint_ipv4 { \
195 VIRTCHNL_PROTO_HDR_IPV4, \
196 VIRTCHNL_PROTO_HDR_IPV4_SRC | VIRTCHNL_PROTO_HDR_IPV4_DST, \
197 {BUFF_NOUSED } }
198
199#define proto_hint_udp_src_port { \
200 VIRTCHNL_PROTO_HDR_UDP, VIRTCHNL_PROTO_HDR_UDP_SRC_PORT, \
201 {BUFF_NOUSED } }
202
203#define proto_hint_udp_dst_port { \
204 VIRTCHNL_PROTO_HDR_UDP, VIRTCHNL_PROTO_HDR_UDP_DST_PORT, \
205 {BUFF_NOUSED } }
206
207#define proto_hint_udp_only { \
208 VIRTCHNL_PROTO_HDR_UDP, FIELD_FOR_PROTO_ONLY, {BUFF_NOUSED } }
209
210#define proto_hint_udp { \
211 VIRTCHNL_PROTO_HDR_UDP, \
212 VIRTCHNL_PROTO_HDR_UDP_SRC_PORT | VIRTCHNL_PROTO_HDR_UDP_DST_PORT, \
213 {BUFF_NOUSED } }
214
215#define proto_hint_tcp_src_port { \
216 VIRTCHNL_PROTO_HDR_TCP, VIRTCHNL_PROTO_HDR_TCP_SRC_PORT, \
217 {BUFF_NOUSED } }
218
219#define proto_hint_tcp_dst_port { \
220 VIRTCHNL_PROTO_HDR_TCP, VIRTCHNL_PROTO_HDR_TCP_DST_PORT, \
221 {BUFF_NOUSED } }
222
223#define proto_hint_tcp_only { \
224 VIRTCHNL_PROTO_HDR_TCP, FIELD_FOR_PROTO_ONLY, {BUFF_NOUSED } }
225
226#define proto_hint_tcp { \
227 VIRTCHNL_PROTO_HDR_TCP, \
228 VIRTCHNL_PROTO_HDR_TCP_SRC_PORT | VIRTCHNL_PROTO_HDR_TCP_DST_PORT, \
229 {BUFF_NOUSED } }
230
231#define proto_hint_sctp_src_port { \
232 VIRTCHNL_PROTO_HDR_SCTP, VIRTCHNL_PROTO_HDR_SCTP_SRC_PORT, \
233 {BUFF_NOUSED } }
234
235#define proto_hint_sctp_dst_port { \
236 VIRTCHNL_PROTO_HDR_SCTP, VIRTCHNL_PROTO_HDR_SCTP_DST_PORT, \
237 {BUFF_NOUSED } }
238
239#define proto_hint_sctp_only { \
240 VIRTCHNL_PROTO_HDR_SCTP, FIELD_FOR_PROTO_ONLY, {BUFF_NOUSED } }
241
242#define proto_hint_sctp { \
243 VIRTCHNL_PROTO_HDR_SCTP, \
244 VIRTCHNL_PROTO_HDR_SCTP_SRC_PORT | VIRTCHNL_PROTO_HDR_SCTP_DST_PORT, \
245 {BUFF_NOUSED } }
246
247#define proto_hint_ipv6_src { \
248 VIRTCHNL_PROTO_HDR_IPV6, VIRTCHNL_PROTO_HDR_IPV6_SRC, {BUFF_NOUSED } }
249
250#define proto_hint_ipv6_dst { \
251 VIRTCHNL_PROTO_HDR_IPV6, VIRTCHNL_PROTO_HDR_IPV6_DST, {BUFF_NOUSED } }
252
253#define proto_hint_ipv6_only { \
254 VIRTCHNL_PROTO_HDR_IPV6, FIELD_FOR_PROTO_ONLY, {BUFF_NOUSED } }
255
256#define proto_hint_ipv6 { \
257 VIRTCHNL_PROTO_HDR_IPV6, \
258 VIRTCHNL_PROTO_HDR_IPV6_SRC | VIRTCHNL_PROTO_HDR_IPV6_DST, \
259 {BUFF_NOUSED } }
260
261#define proto_hint_gtpu_up_only { \
262 VIRTCHNL_PROTO_HDR_GTPU_EH_PDU_UP, \
263 FIELD_FOR_PROTO_ONLY, {BUFF_NOUSED } }
264
265#define proto_hint_gtpu_dwn_only { \
266 VIRTCHNL_PROTO_HDR_GTPU_EH_PDU_DWN, \
267 FIELD_FOR_PROTO_ONLY, {BUFF_NOUSED } }
268
269#define proto_hint_esp { \
270 VIRTCHNL_PROTO_HDR_ESP, \
271 VIRTCHNL_PROTO_HDR_ESP_SPI, {BUFF_NOUSED } }
272
273#define proto_hint_ah { \
274 VIRTCHNL_PROTO_HDR_AH, \
275 VIRTCHNL_PROTO_HDR_AH_SPI, {BUFF_NOUSED } }
276
277#define proto_hint_l2tpv3 { \
278 VIRTCHNL_PROTO_HDR_L2TPV3, \
279 VIRTCHNL_PROTO_HDR_L2TPV3_SESS_ID, {BUFF_NOUSED } }
280
281#define proto_hint_pfcp { \
282 VIRTCHNL_PROTO_HDR_PFCP, VIRTCHNL_PROTO_HDR_PFCP_SEID, {BUFF_NOUSED } }
283
284struct virtchnl_proto_hdrs hdrs_hint_eth_src = {
285 TUNNEL_LEVEL_OUTER, PROTO_COUNT_ONE, {proto_hint_eth_src }
286};
287
288struct virtchnl_proto_hdrs hdrs_hint_eth_dst = {
289 TUNNEL_LEVEL_OUTER, PROTO_COUNT_ONE, {proto_hint_eth_dst }
290};
291
292struct virtchnl_proto_hdrs hdrs_hint_eth = {
293 TUNNEL_LEVEL_OUTER, PROTO_COUNT_ONE, {proto_hint_eth }
294};
295
296struct virtchnl_proto_hdrs hdrs_hint_svlan = {
297 TUNNEL_LEVEL_OUTER, PROTO_COUNT_ONE, {proto_hint_svlan }
298};
299
300struct virtchnl_proto_hdrs hdrs_hint_cvlan = {
301 TUNNEL_LEVEL_OUTER, PROTO_COUNT_ONE, {proto_hint_cvlan }
302};
303
304struct virtchnl_proto_hdrs hdrs_hint_ipv4_src = {
305 TUNNEL_LEVEL_OUTER, PROTO_COUNT_ONE, {proto_hint_ipv4_src }
306};
307
308struct virtchnl_proto_hdrs hdrs_hint_ipv4_dst = {
309 TUNNEL_LEVEL_OUTER, PROTO_COUNT_ONE, {proto_hint_ipv4_dst }
310};
311
312struct 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 }
315};
316
317struct 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 }
320};
321
322struct virtchnl_proto_hdrs hdrs_hint_ipv4_esp = {
323 TUNNEL_LEVEL_OUTER, PROTO_COUNT_TWO, {proto_hint_ipv4_only,
324 proto_hint_esp }
325};
326
327struct virtchnl_proto_hdrs hdrs_hint_ipv4_ah = {
328 TUNNEL_LEVEL_OUTER, PROTO_COUNT_TWO, {proto_hint_ipv4_only,
329 proto_hint_ah }
330};
331
332struct virtchnl_proto_hdrs hdrs_hint_ipv4_l2tpv3 = {
333 TUNNEL_LEVEL_OUTER, PROTO_COUNT_TWO, {proto_hint_ipv4_only,
334 proto_hint_l2tpv3 }
335};
336
337struct virtchnl_proto_hdrs hdrs_hint_ipv4_pfcp = {
338 TUNNEL_LEVEL_OUTER, PROTO_COUNT_TWO, {proto_hint_ipv4_only,
339 proto_hint_pfcp }
340};
341
342struct virtchnl_proto_hdrs hdrs_hint_ipv4 = {
343 TUNNEL_LEVEL_OUTER, PROTO_COUNT_ONE, {proto_hint_ipv4 }
344};
345
346struct 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 }
349};
350
351struct 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 }
354};
355
356struct 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 }
359};
360
361struct 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 }
364};
365
366struct 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 }
369};
370
371struct 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 }
374};
375
376struct virtchnl_proto_hdrs hdrs_hint_ipv4_udp = {
377 TUNNEL_LEVEL_OUTER, PROTO_COUNT_TWO, {proto_hint_ipv4,
378 proto_hint_udp }
379};
380
381struct 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 }
384};
385
386struct 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 }
389};
390
391struct 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 }
394};
395
396struct 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 }
399};
400
401struct 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 }
404};
405
406struct 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 }
409};
410
411struct virtchnl_proto_hdrs hdrs_hint_ipv4_tcp = {
412 TUNNEL_LEVEL_OUTER, PROTO_COUNT_TWO, {proto_hint_ipv4,
413 proto_hint_tcp }
414};
415
416struct 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 }
419};
420
421struct 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 }
424};
425
426struct 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 }
429};
430
431struct 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 }
434};
435
436struct 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 }
439};
440
441struct 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 }
444};
445
446struct virtchnl_proto_hdrs hdrs_hint_ipv4_sctp = {
447 TUNNEL_LEVEL_OUTER, PROTO_COUNT_TWO, {proto_hint_ipv4,
448 proto_hint_sctp }
449};
450
451struct virtchnl_proto_hdrs hdrs_hint_ipv6_src = {
452 TUNNEL_LEVEL_OUTER, PROTO_COUNT_ONE, {proto_hint_ipv6_src }
453};
454
455struct virtchnl_proto_hdrs hdrs_hint_ipv6_dst = {
456 TUNNEL_LEVEL_OUTER, PROTO_COUNT_ONE, {proto_hint_ipv6_dst }
457};
458
459struct virtchnl_proto_hdrs hdrs_hint_ipv6_esp = {
460 TUNNEL_LEVEL_OUTER, PROTO_COUNT_TWO, {proto_hint_ipv6_only,
461 proto_hint_esp }
462};
463
464struct virtchnl_proto_hdrs hdrs_hint_ipv6_ah = {
465 TUNNEL_LEVEL_OUTER, PROTO_COUNT_TWO, {proto_hint_ipv6_only,
466 proto_hint_ah }
467};
468
469struct virtchnl_proto_hdrs hdrs_hint_ipv6_l2tpv3 = {
470 TUNNEL_LEVEL_OUTER, PROTO_COUNT_TWO, {proto_hint_ipv6_only,
471 proto_hint_l2tpv3 }
472};
473
474struct virtchnl_proto_hdrs hdrs_hint_ipv6_pfcp = {
475 TUNNEL_LEVEL_OUTER, PROTO_COUNT_TWO, {proto_hint_ipv6_only,
476 proto_hint_pfcp }
477};
478
479struct virtchnl_proto_hdrs hdrs_hint_ipv6 = {
480 TUNNEL_LEVEL_OUTER, PROTO_COUNT_ONE, {proto_hint_ipv6 }
481};
482
483struct 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 }
486};
487
488struct 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 }
491};
492
493struct 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 }
496};
497
498struct 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 }
501};
502
503struct 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 }
506};
507
508struct 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 }
511};
512
513struct virtchnl_proto_hdrs hdrs_hint_ipv6_udp = {
514 TUNNEL_LEVEL_OUTER, PROTO_COUNT_TWO, {proto_hint_ipv6,
515 proto_hint_udp }
516};
517
518struct 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 }
521};
522
523struct 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 }
526};
527
528struct 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 }
531};
532
533struct 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 }
536};
537
538struct 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 }
541};
542
543struct 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 }
546};
547
548struct virtchnl_proto_hdrs hdrs_hint_ipv6_tcp = {
549 TUNNEL_LEVEL_OUTER, PROTO_COUNT_TWO, {proto_hint_ipv6,
550 proto_hint_tcp }
551};
552
553struct 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 }
556};
557
558struct 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 }
561};
562
563struct 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 }
566};
567
568struct 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 }
571};
572
573struct 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 }
576};
577
578struct 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 }
581};
582
583struct virtchnl_proto_hdrs hdrs_hint_ipv6_sctp = {
584 TUNNEL_LEVEL_OUTER, PROTO_COUNT_TWO, {proto_hint_ipv6,
585 proto_hint_sctp }
586};
587
588/**
589 * The first member is pattern hint type,
590 * the second member is hash type,
591 * the third member is virtchnl protocol hdrs.
592 */
593struct iavf_hash_match_type iavf_hash_type_list[] = {
594 /* IPV4 */
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 | ETH_RSS_L2_SRC_ONLY,
598 &hdrs_hint_eth_src},
599 {IAVF_PATTERN_HINT_IPV4, ETH_RSS_ETH | ETH_RSS_L2_DST_ONLY,
600 &hdrs_hint_eth_dst},
601 {IAVF_PATTERN_HINT_IPV4, ETH_RSS_ETH, &hdrs_hint_eth},
602 {IAVF_PATTERN_HINT_IPV4, ETH_RSS_S_VLAN, &hdrs_hint_svlan},
603 {IAVF_PATTERN_HINT_IPV4, ETH_RSS_C_VLAN, &hdrs_hint_cvlan},
604 {IAVF_PATTERN_HINT_IPV4, ETH_RSS_L3_SRC_ONLY, &hdrs_hint_ipv4_src},
605 {IAVF_PATTERN_HINT_IPV4, ETH_RSS_L3_DST_ONLY, &hdrs_hint_ipv4_dst},
606 {IAVF_PATTERN_HINT_IPV4, ETH_RSS_IPV4 | ETH_RSS_L3_SRC_ONLY,
607 &hdrs_hint_ipv4_src},
608 {IAVF_PATTERN_HINT_IPV4, ETH_RSS_IPV4 | ETH_RSS_L3_DST_ONLY,
609 &hdrs_hint_ipv4_dst},
610 {IAVF_PATTERN_HINT_IPV4, ETH_RSS_ESP, &hdrs_hint_ipv4_esp},
611 {IAVF_PATTERN_HINT_IPV4, ETH_RSS_AH, &hdrs_hint_ipv4_ah},
612 {IAVF_PATTERN_HINT_IPV4, ETH_RSS_L2TPV3, &hdrs_hint_ipv4_l2tpv3},
613 {IAVF_PATTERN_HINT_IPV4, ETH_RSS_IPV4, &hdrs_hint_ipv4},
614 /* IPV4 UDP */
615 {IAVF_PATTERN_HINT_IPV4_UDP, ETH_RSS_L3_SRC_ONLY | ETH_RSS_L4_SRC_ONLY,
616 &hdrs_hint_ipv4_src_udp_src_port},
617 {IAVF_PATTERN_HINT_IPV4_UDP, ETH_RSS_L3_SRC_ONLY | ETH_RSS_L4_DST_ONLY,
618 &hdrs_hint_ipv4_src_udp_dst_port},
619 {IAVF_PATTERN_HINT_IPV4_UDP, ETH_RSS_L3_SRC_ONLY | ETH_RSS_GTPU,
620 &hdrs_hint_ipv4_src_gtpu_up},
621 {IAVF_PATTERN_HINT_IPV4_UDP, ETH_RSS_L3_SRC_ONLY,
622 &hdrs_hint_ipv4_src},
623 {IAVF_PATTERN_HINT_IPV4_UDP, ETH_RSS_L3_DST_ONLY | ETH_RSS_L4_SRC_ONLY,
624 &hdrs_hint_ipv4_dst_udp_src_port},
625 {IAVF_PATTERN_HINT_IPV4_UDP, ETH_RSS_L3_DST_ONLY | ETH_RSS_L4_DST_ONLY,
626 &hdrs_hint_ipv4_dst_udp_dst_port},
627 {IAVF_PATTERN_HINT_IPV4_UDP, ETH_RSS_L3_DST_ONLY | ETH_RSS_GTPU,
628 &hdrs_hint_ipv4_dst_gtpu_dwn},
629 {IAVF_PATTERN_HINT_IPV4_UDP, ETH_RSS_L3_DST_ONLY,
630 &hdrs_hint_ipv4_dst},
631 {IAVF_PATTERN_HINT_IPV4_UDP, ETH_RSS_NONFRAG_IPV4_UDP |
632 ETH_RSS_L3_SRC_ONLY | ETH_RSS_L4_SRC_ONLY,
633 &hdrs_hint_ipv4_src_udp_src_port},
634 {IAVF_PATTERN_HINT_IPV4_UDP, ETH_RSS_NONFRAG_IPV4_UDP |
635 ETH_RSS_L3_SRC_ONLY | ETH_RSS_L4_DST_ONLY,
636 &hdrs_hint_ipv4_src_udp_dst_port},
637 {IAVF_PATTERN_HINT_IPV4_UDP, ETH_RSS_NONFRAG_IPV4_UDP |
638 ETH_RSS_L3_SRC_ONLY | ETH_RSS_GTPU,
639 &hdrs_hint_ipv4_src_gtpu_up},
640 {IAVF_PATTERN_HINT_IPV4_UDP, ETH_RSS_NONFRAG_IPV4_UDP |
641 ETH_RSS_L3_SRC_ONLY, &hdrs_hint_ipv4_src},
642 {IAVF_PATTERN_HINT_IPV4_UDP, ETH_RSS_NONFRAG_IPV4_UDP |
643 ETH_RSS_L3_DST_ONLY | ETH_RSS_L4_SRC_ONLY,
644 &hdrs_hint_ipv4_dst_udp_src_port},
645 {IAVF_PATTERN_HINT_IPV4_UDP, ETH_RSS_NONFRAG_IPV4_UDP |
646 ETH_RSS_L3_DST_ONLY | ETH_RSS_L4_DST_ONLY,
647 &hdrs_hint_ipv4_dst_udp_dst_port},
648 {IAVF_PATTERN_HINT_IPV4_UDP, ETH_RSS_NONFRAG_IPV4_UDP |
649 ETH_RSS_L3_DST_ONLY | ETH_RSS_GTPU,
650 &hdrs_hint_ipv4_dst_gtpu_dwn},
651 {IAVF_PATTERN_HINT_IPV4_UDP, ETH_RSS_NONFRAG_IPV4_UDP |
652 ETH_RSS_L3_DST_ONLY, &hdrs_hint_ipv4_dst},
653 {IAVF_PATTERN_HINT_IPV4_UDP, ETH_RSS_L4_SRC_ONLY,
654 &hdrs_hint_ipv4_udp_src_port},
655 {IAVF_PATTERN_HINT_IPV4_UDP, ETH_RSS_L4_DST_ONLY,
656 &hdrs_hint_ipv4_udp_dst_port},
657 {IAVF_PATTERN_HINT_IPV4_UDP, ETH_RSS_PFCP,
658 &hdrs_hint_ipv4_pfcp},
659 {IAVF_PATTERN_HINT_IPV4_UDP, ETH_RSS_NONFRAG_IPV4_UDP,
660 &hdrs_hint_ipv4_udp},
661 /* IPV4 TCP */
662 {IAVF_PATTERN_HINT_IPV4_TCP, ETH_RSS_L3_SRC_ONLY | ETH_RSS_L4_SRC_ONLY,
663 &hdrs_hint_ipv4_src_tcp_src_port},
664 {IAVF_PATTERN_HINT_IPV4_TCP, ETH_RSS_L3_SRC_ONLY | ETH_RSS_L4_DST_ONLY,
665 &hdrs_hint_ipv4_src_tcp_dst_port},
666 {IAVF_PATTERN_HINT_IPV4_TCP, ETH_RSS_L3_SRC_ONLY,
667 &hdrs_hint_ipv4_src},
668 {IAVF_PATTERN_HINT_IPV4_TCP, ETH_RSS_L3_DST_ONLY | ETH_RSS_L4_SRC_ONLY,
669 &hdrs_hint_ipv4_dst_tcp_src_port},
670 {IAVF_PATTERN_HINT_IPV4_TCP, ETH_RSS_L3_DST_ONLY | ETH_RSS_L4_DST_ONLY,
671 &hdrs_hint_ipv4_dst_tcp_dst_port},
672 {IAVF_PATTERN_HINT_IPV4_TCP, ETH_RSS_L3_DST_ONLY,
673 &hdrs_hint_ipv4_dst},
674 {IAVF_PATTERN_HINT_IPV4_TCP, ETH_RSS_NONFRAG_IPV4_TCP |
675 ETH_RSS_L3_SRC_ONLY | ETH_RSS_L4_SRC_ONLY,
676 &hdrs_hint_ipv4_src_tcp_src_port},
677 {IAVF_PATTERN_HINT_IPV4_TCP, ETH_RSS_NONFRAG_IPV4_TCP |
678 ETH_RSS_L3_SRC_ONLY | ETH_RSS_L4_DST_ONLY,
679 &hdrs_hint_ipv4_src_tcp_dst_port},
680 {IAVF_PATTERN_HINT_IPV4_TCP, ETH_RSS_NONFRAG_IPV4_TCP |
681 ETH_RSS_L3_SRC_ONLY, &hdrs_hint_ipv4_src},
682 {IAVF_PATTERN_HINT_IPV4_TCP, ETH_RSS_NONFRAG_IPV4_TCP |
683 ETH_RSS_L3_DST_ONLY | ETH_RSS_L4_SRC_ONLY,
684 &hdrs_hint_ipv4_dst_tcp_src_port},
685 {IAVF_PATTERN_HINT_IPV4_TCP, ETH_RSS_NONFRAG_IPV4_TCP |
686 ETH_RSS_L3_DST_ONLY | ETH_RSS_L4_DST_ONLY,
687 &hdrs_hint_ipv4_dst_tcp_dst_port},
688 {IAVF_PATTERN_HINT_IPV4_TCP, ETH_RSS_NONFRAG_IPV4_TCP |
689 ETH_RSS_L3_DST_ONLY, &hdrs_hint_ipv4_dst},
690 {IAVF_PATTERN_HINT_IPV4_TCP, ETH_RSS_L4_SRC_ONLY,
691 &hdrs_hint_ipv4_tcp_src_port},
692 {IAVF_PATTERN_HINT_IPV4_TCP, ETH_RSS_L4_DST_ONLY,
693 &hdrs_hint_ipv4_tcp_dst_port},
694 {IAVF_PATTERN_HINT_IPV4_TCP, ETH_RSS_NONFRAG_IPV4_TCP,
695 &hdrs_hint_ipv4_tcp},
696 /* IPV4 SCTP */
697 {IAVF_PATTERN_HINT_IPV4_SCTP, ETH_RSS_L3_SRC_ONLY | ETH_RSS_L4_SRC_ONLY,
698 &hdrs_hint_ipv4_src_sctp_src_port},
699 {IAVF_PATTERN_HINT_IPV4_SCTP, ETH_RSS_L3_SRC_ONLY | ETH_RSS_L4_DST_ONLY,
700 &hdrs_hint_ipv4_src_sctp_dst_port},
701 {IAVF_PATTERN_HINT_IPV4_SCTP, ETH_RSS_L3_SRC_ONLY,
702 &hdrs_hint_ipv4_src},
703 {IAVF_PATTERN_HINT_IPV4_SCTP, ETH_RSS_L3_DST_ONLY | ETH_RSS_L4_SRC_ONLY,
704 &hdrs_hint_ipv4_dst_sctp_src_port},
705 {IAVF_PATTERN_HINT_IPV4_SCTP, ETH_RSS_L3_DST_ONLY | ETH_RSS_L4_DST_ONLY,
706 &hdrs_hint_ipv4_dst_sctp_dst_port},
707 {IAVF_PATTERN_HINT_IPV4_SCTP, ETH_RSS_L3_DST_ONLY,
708 &hdrs_hint_ipv4_dst},
709 {IAVF_PATTERN_HINT_IPV4_SCTP, ETH_RSS_NONFRAG_IPV4_SCTP |
710 ETH_RSS_L3_SRC_ONLY | ETH_RSS_L4_SRC_ONLY,
711 &hdrs_hint_ipv4_src_sctp_src_port},
712 {IAVF_PATTERN_HINT_IPV4_SCTP, ETH_RSS_NONFRAG_IPV4_SCTP |
713 ETH_RSS_L3_SRC_ONLY | ETH_RSS_L4_DST_ONLY,
714 &hdrs_hint_ipv4_src_sctp_dst_port},
715 {IAVF_PATTERN_HINT_IPV4_SCTP, ETH_RSS_NONFRAG_IPV4_SCTP |
716 ETH_RSS_L3_SRC_ONLY, &hdrs_hint_ipv4_src},
717 {IAVF_PATTERN_HINT_IPV4_SCTP, ETH_RSS_NONFRAG_IPV4_SCTP |
718 ETH_RSS_L3_DST_ONLY | ETH_RSS_L4_SRC_ONLY,
719 &hdrs_hint_ipv4_dst_sctp_src_port},
720 {IAVF_PATTERN_HINT_IPV4_SCTP, ETH_RSS_NONFRAG_IPV4_SCTP |
721 ETH_RSS_L3_DST_ONLY | ETH_RSS_L4_DST_ONLY,
722 &hdrs_hint_ipv4_dst_sctp_dst_port},
723 {IAVF_PATTERN_HINT_IPV4_SCTP, ETH_RSS_NONFRAG_IPV4_SCTP |
724 ETH_RSS_L3_DST_ONLY, &hdrs_hint_ipv4_dst},
725 {IAVF_PATTERN_HINT_IPV4_SCTP, ETH_RSS_L4_SRC_ONLY,
726 &hdrs_hint_ipv4_sctp_src_port},
727 {IAVF_PATTERN_HINT_IPV4_SCTP, ETH_RSS_L4_DST_ONLY,
728 &hdrs_hint_ipv4_sctp_dst_port},
729 {IAVF_PATTERN_HINT_IPV4_SCTP, ETH_RSS_NONFRAG_IPV4_SCTP,
730 &hdrs_hint_ipv4_sctp},
731 /* IPV6 */
732 {IAVF_PATTERN_HINT_IPV6, ETH_RSS_L2_SRC_ONLY, &hdrs_hint_eth_src},
733 {IAVF_PATTERN_HINT_IPV6, ETH_RSS_L2_DST_ONLY, &hdrs_hint_eth_dst},
734 {IAVF_PATTERN_HINT_IPV6, ETH_RSS_IPV6 | ETH_RSS_L2_SRC_ONLY,
735 &hdrs_hint_eth_src},
736 {IAVF_PATTERN_HINT_IPV6, ETH_RSS_IPV6 | ETH_RSS_L2_DST_ONLY,
737 &hdrs_hint_eth_dst},
738 {IAVF_PATTERN_HINT_IPV6, ETH_RSS_ETH, &hdrs_hint_eth},
739 {IAVF_PATTERN_HINT_IPV6, ETH_RSS_S_VLAN, &hdrs_hint_svlan},
740 {IAVF_PATTERN_HINT_IPV4, ETH_RSS_C_VLAN, &hdrs_hint_cvlan},
741 {IAVF_PATTERN_HINT_IPV6, ETH_RSS_L3_SRC_ONLY, &hdrs_hint_ipv6_src},
742 {IAVF_PATTERN_HINT_IPV6, ETH_RSS_L3_DST_ONLY, &hdrs_hint_ipv6_dst},
743 {IAVF_PATTERN_HINT_IPV6, ETH_RSS_IPV6 | ETH_RSS_L3_SRC_ONLY,
744 &hdrs_hint_ipv6_src},
745 {IAVF_PATTERN_HINT_IPV6, ETH_RSS_IPV6 | ETH_RSS_L3_DST_ONLY,
746 &hdrs_hint_ipv6_dst},
747 {IAVF_PATTERN_HINT_IPV6, ETH_RSS_ESP, &hdrs_hint_ipv6_esp},
748 {IAVF_PATTERN_HINT_IPV6, ETH_RSS_AH, &hdrs_hint_ipv6_ah},
749 {IAVF_PATTERN_HINT_IPV6, ETH_RSS_L2TPV3, &hdrs_hint_ipv6_l2tpv3},
750 {IAVF_PATTERN_HINT_IPV6, ETH_RSS_IPV6, &hdrs_hint_ipv6},
751 /* IPV6 UDP */
752 {IAVF_PATTERN_HINT_IPV6_UDP, ETH_RSS_L3_SRC_ONLY | ETH_RSS_L4_SRC_ONLY,
753 &hdrs_hint_ipv6_src_udp_src_port},
754 {IAVF_PATTERN_HINT_IPV6_UDP, ETH_RSS_L3_SRC_ONLY | ETH_RSS_L4_DST_ONLY,
755 &hdrs_hint_ipv6_src_udp_dst_port},
756 {IAVF_PATTERN_HINT_IPV6_UDP, ETH_RSS_L3_SRC_ONLY,
757 &hdrs_hint_ipv6_src},
758 {IAVF_PATTERN_HINT_IPV6_UDP, ETH_RSS_L3_DST_ONLY | ETH_RSS_L4_SRC_ONLY,
759 &hdrs_hint_ipv6_dst_udp_src_port},
760 {IAVF_PATTERN_HINT_IPV6_UDP, ETH_RSS_L3_DST_ONLY | ETH_RSS_L4_DST_ONLY,
761 &hdrs_hint_ipv6_dst_udp_dst_port},
762 {IAVF_PATTERN_HINT_IPV6_UDP, ETH_RSS_L3_DST_ONLY,
763 &hdrs_hint_ipv6_dst},
764 {IAVF_PATTERN_HINT_IPV6_UDP, ETH_RSS_NONFRAG_IPV6_UDP |
765 ETH_RSS_L3_SRC_ONLY | ETH_RSS_L4_SRC_ONLY,
766 &hdrs_hint_ipv6_src_udp_src_port},
767 {IAVF_PATTERN_HINT_IPV6_UDP, ETH_RSS_NONFRAG_IPV6_UDP |
768 ETH_RSS_L3_SRC_ONLY | ETH_RSS_L4_DST_ONLY,
769 &hdrs_hint_ipv6_src_udp_dst_port},
770 {IAVF_PATTERN_HINT_IPV6_UDP, ETH_RSS_NONFRAG_IPV6_UDP |
771 ETH_RSS_L3_SRC_ONLY, &hdrs_hint_ipv6_src},
772 {IAVF_PATTERN_HINT_IPV6_UDP, ETH_RSS_NONFRAG_IPV6_UDP |
773 ETH_RSS_L3_DST_ONLY | ETH_RSS_L4_SRC_ONLY,
774 &hdrs_hint_ipv6_dst_udp_src_port},
775 {IAVF_PATTERN_HINT_IPV6_UDP, ETH_RSS_NONFRAG_IPV6_UDP |
776 ETH_RSS_L3_DST_ONLY | ETH_RSS_L4_DST_ONLY,
777 &hdrs_hint_ipv6_dst_udp_dst_port},
778 {IAVF_PATTERN_HINT_IPV6_UDP, ETH_RSS_NONFRAG_IPV6_UDP |
779 ETH_RSS_L3_DST_ONLY, &hdrs_hint_ipv6_dst},
780 {IAVF_PATTERN_HINT_IPV6_UDP, ETH_RSS_L4_SRC_ONLY,
781 &hdrs_hint_ipv6_udp_src_port},
782 {IAVF_PATTERN_HINT_IPV6_UDP, ETH_RSS_L4_DST_ONLY,
783 &hdrs_hint_ipv6_udp_dst_port},
784 {IAVF_PATTERN_HINT_IPV6_UDP, ETH_RSS_PFCP,
785 &hdrs_hint_ipv6_pfcp},
786 {IAVF_PATTERN_HINT_IPV6_UDP, ETH_RSS_NONFRAG_IPV6_UDP,
787 &hdrs_hint_ipv6_udp},
788 /* IPV6 TCP */
789 {IAVF_PATTERN_HINT_IPV6_TCP, ETH_RSS_L3_SRC_ONLY | ETH_RSS_L4_SRC_ONLY,
790 &hdrs_hint_ipv6_src_tcp_src_port},
791 {IAVF_PATTERN_HINT_IPV6_TCP, ETH_RSS_L3_SRC_ONLY | ETH_RSS_L4_DST_ONLY,
792 &hdrs_hint_ipv6_src_tcp_dst_port},
793 {IAVF_PATTERN_HINT_IPV6_TCP, ETH_RSS_L3_SRC_ONLY,
794 &hdrs_hint_ipv6_src},
795 {IAVF_PATTERN_HINT_IPV6_TCP, ETH_RSS_L3_DST_ONLY | ETH_RSS_L4_SRC_ONLY,
796 &hdrs_hint_ipv6_dst_tcp_src_port},
797 {IAVF_PATTERN_HINT_IPV6_TCP, ETH_RSS_L3_DST_ONLY | ETH_RSS_L4_DST_ONLY,
798 &hdrs_hint_ipv6_dst_tcp_dst_port},
799 {IAVF_PATTERN_HINT_IPV6_TCP, ETH_RSS_L3_DST_ONLY,
800 &hdrs_hint_ipv6_dst},
801 {IAVF_PATTERN_HINT_IPV6_TCP, ETH_RSS_NONFRAG_IPV6_TCP |
802 ETH_RSS_L3_SRC_ONLY | ETH_RSS_L4_SRC_ONLY,
803 &hdrs_hint_ipv6_src_tcp_src_port},
804 {IAVF_PATTERN_HINT_IPV6_TCP, ETH_RSS_NONFRAG_IPV6_TCP |
805 ETH_RSS_L3_SRC_ONLY | ETH_RSS_L4_DST_ONLY,
806 &hdrs_hint_ipv6_src_tcp_dst_port},
807 {IAVF_PATTERN_HINT_IPV6_TCP, ETH_RSS_NONFRAG_IPV6_TCP |
808 ETH_RSS_L3_SRC_ONLY, &hdrs_hint_ipv6_src},
809 {IAVF_PATTERN_HINT_IPV6_TCP, ETH_RSS_NONFRAG_IPV6_TCP |
810 ETH_RSS_L3_DST_ONLY | ETH_RSS_L4_SRC_ONLY,
811 &hdrs_hint_ipv6_dst_tcp_src_port},
812 {IAVF_PATTERN_HINT_IPV6_TCP, ETH_RSS_NONFRAG_IPV6_TCP |
813 ETH_RSS_L3_DST_ONLY | ETH_RSS_L4_DST_ONLY,
814 &hdrs_hint_ipv6_dst_tcp_dst_port},
815 {IAVF_PATTERN_HINT_IPV6_TCP, ETH_RSS_NONFRAG_IPV6_TCP |
816 ETH_RSS_L3_DST_ONLY, &hdrs_hint_ipv6_dst},
817 {IAVF_PATTERN_HINT_IPV6_TCP, ETH_RSS_L4_SRC_ONLY,
818 &hdrs_hint_ipv6_tcp_src_port},
819 {IAVF_PATTERN_HINT_IPV6_TCP, ETH_RSS_L4_DST_ONLY,
820 &hdrs_hint_ipv6_tcp_dst_port},
821 {IAVF_PATTERN_HINT_IPV6_TCP, ETH_RSS_NONFRAG_IPV6_TCP,
822 &hdrs_hint_ipv6_tcp},
823 /* IPV6 SCTP */
824 {IAVF_PATTERN_HINT_IPV6_SCTP, ETH_RSS_L3_SRC_ONLY | ETH_RSS_L4_SRC_ONLY,
825 &hdrs_hint_ipv6_src_sctp_src_port},
826 {IAVF_PATTERN_HINT_IPV6_SCTP, ETH_RSS_L3_SRC_ONLY | ETH_RSS_L4_DST_ONLY,
827 &hdrs_hint_ipv6_src_sctp_dst_port},
828 {IAVF_PATTERN_HINT_IPV6_SCTP, ETH_RSS_L3_SRC_ONLY,
829 &hdrs_hint_ipv6_src},
830 {IAVF_PATTERN_HINT_IPV6_SCTP, ETH_RSS_L3_DST_ONLY | ETH_RSS_L4_SRC_ONLY,
831 &hdrs_hint_ipv6_dst_sctp_src_port},
832 {IAVF_PATTERN_HINT_IPV6_SCTP, ETH_RSS_L3_DST_ONLY | ETH_RSS_L4_DST_ONLY,
833 &hdrs_hint_ipv6_dst_sctp_dst_port},
834 {IAVF_PATTERN_HINT_IPV6_SCTP, ETH_RSS_L3_DST_ONLY,
835 &hdrs_hint_ipv6_dst},
836 {IAVF_PATTERN_HINT_IPV6_SCTP, ETH_RSS_NONFRAG_IPV6_SCTP |
837 ETH_RSS_L3_SRC_ONLY | ETH_RSS_L4_SRC_ONLY,
838 &hdrs_hint_ipv6_src_sctp_src_port},
839 {IAVF_PATTERN_HINT_IPV6_SCTP, ETH_RSS_NONFRAG_IPV6_SCTP |
840 ETH_RSS_L3_SRC_ONLY | ETH_RSS_L4_DST_ONLY,
841 &hdrs_hint_ipv6_src_sctp_dst_port},
842 {IAVF_PATTERN_HINT_IPV6_SCTP, ETH_RSS_NONFRAG_IPV6_SCTP |
843 ETH_RSS_L3_SRC_ONLY, &hdrs_hint_ipv6_src},
844 {IAVF_PATTERN_HINT_IPV6_SCTP, ETH_RSS_NONFRAG_IPV6_SCTP |
845 ETH_RSS_L3_DST_ONLY | ETH_RSS_L4_SRC_ONLY,
846 &hdrs_hint_ipv6_dst_sctp_src_port},
847 {IAVF_PATTERN_HINT_IPV6_SCTP, ETH_RSS_NONFRAG_IPV6_SCTP |
848 ETH_RSS_L3_DST_ONLY | ETH_RSS_L4_DST_ONLY,
849 &hdrs_hint_ipv6_dst_sctp_dst_port},
850 {IAVF_PATTERN_HINT_IPV6_SCTP, ETH_RSS_NONFRAG_IPV6_SCTP |
851 ETH_RSS_L3_DST_ONLY, &hdrs_hint_ipv6_dst},
852 {IAVF_PATTERN_HINT_IPV6_SCTP, ETH_RSS_L4_SRC_ONLY,
853 &hdrs_hint_ipv6_sctp_src_port},
854 {IAVF_PATTERN_HINT_IPV6_SCTP, ETH_RSS_L4_DST_ONLY,
855 &hdrs_hint_ipv6_sctp_dst_port},
856 {IAVF_PATTERN_HINT_IPV6_SCTP, ETH_RSS_NONFRAG_IPV6_SCTP,
857 &hdrs_hint_ipv6_sctp},
858};
859
860struct virtchnl_proto_hdrs *iavf_hash_default_hdrs[] = {
861 &hdrs_hint_ipv4,
862 &hdrs_hint_ipv4_udp,
863 &hdrs_hint_ipv4_tcp,
864 &hdrs_hint_ipv4_sctp,
865 &hdrs_hint_ipv6,
866 &hdrs_hint_ipv6_udp,
867 &hdrs_hint_ipv6_tcp,
868 &hdrs_hint_ipv6_sctp,
869};
870
871static struct iavf_flow_engine iavf_hash_engine = {
872 .init = iavf_hash_init,
873 .create = iavf_hash_create,
874 .destroy = iavf_hash_destroy,
875 .uninit = iavf_hash_uninit,
876 .free = iavf_hash_free,
877 .type = IAVF_FLOW_ENGINE_HASH,
878};
879
880/* Register parser for comms package. */
881static struct iavf_flow_parser iavf_hash_parser = {
882 .engine = &iavf_hash_engine,
883 .array = iavf_hash_pattern_list,
884 .array_len = RTE_DIM(iavf_hash_pattern_list),
885 .parse_pattern_action = iavf_hash_parse_pattern_action,
886 .stage = IAVF_FLOW_STAGE_RSS,
887};
888
889static int
890iavf_hash_default_set(struct iavf_adapter *ad, bool add)
891{
892 struct virtchnl_rss_cfg *rss_cfg;
893 uint16_t i;
894 int ret;
895
896 rss_cfg = rte_zmalloc("iavf rss rule",
897 sizeof(struct virtchnl_rss_cfg), 0);
898 if (!rss_cfg)
899 return -ENOMEM;
900
901 for (i = 0; i < RTE_DIM(iavf_hash_default_hdrs); i++) {
902 rss_cfg->proto_hdrs = *iavf_hash_default_hdrs[i];
903 rss_cfg->rss_algorithm = VIRTCHNL_RSS_ALG_TOEPLITZ_ASYMMETRIC;
904
905 ret = iavf_add_del_rss_cfg(ad, rss_cfg, add);
906 if (ret) {
907 PMD_DRV_LOG(ERR, "fail to %s RSS configure",
908 add ? "add" : "delete");
909 rte_free(rss_cfg);
910 return ret;
911 }
912 }
913
914 return ret;
915}
916
917RTE_INIT(iavf_hash_engine_init)
918{
919 struct iavf_flow_engine *engine = &iavf_hash_engine;
920
921 iavf_register_flow_engine(engine);
922}
923
924static int
925iavf_hash_init(struct iavf_adapter *ad)
926{
927 struct iavf_info *vf = IAVF_DEV_PRIVATE_TO_VF(ad);
928 struct iavf_flow_parser *parser;
929 int ret;
930
931 if (!vf->vf_res)
932 return -EINVAL;
933
934 if (!(vf->vf_res->vf_cap_flags & VIRTCHNL_VF_OFFLOAD_ADV_RSS_PF))
935 return -ENOTSUP;
936
937 parser = &iavf_hash_parser;
938
939 ret = iavf_register_parser(parser, ad);
940 if (ret) {
941 PMD_DRV_LOG(ERR, "fail to register hash parser");
942 return ret;
943 }
944
945 ret = iavf_hash_default_set(ad, true);
946 if (ret) {
947 PMD_DRV_LOG(ERR, "fail to set default RSS");
948 iavf_unregister_parser(parser, ad);
949 }
950
951 return ret;
952}
953
954static int
955iavf_hash_check_inset(const struct rte_flow_item pattern[],
956 struct rte_flow_error *error)
957{
958 const struct rte_flow_item *item = pattern;
959
960 for (item = pattern; item->type != RTE_FLOW_ITEM_TYPE_END; item++) {
961 if (item->last) {
962 rte_flow_error_set(error, EINVAL,
963 RTE_FLOW_ERROR_TYPE_ITEM, item,
964 "Not support range");
965 return -rte_errno;
966 }
967 }
968
969 return 0;
970}
971
972static uint64_t
973iavf_hash_refine_type(uint64_t rss_type, const struct rte_flow_item pattern[])
974{
975 const struct rte_flow_item *item;
976
977 for (item = pattern; item->type != RTE_FLOW_ITEM_TYPE_END; item++) {
978 if (item->type == RTE_FLOW_ITEM_TYPE_GTP_PSC) {
979 const struct rte_flow_item_gtp_psc *psc = item->spec;
980
981 if (psc && (psc->pdu_type == GTP_EH_PDU_LINK_UP ||
982 psc->pdu_type == GTP_EH_PDU_LINK_DWN)) {
983 rss_type |= ETH_RSS_GTPU;
984 }
985 }
986 }
987
988 return rss_type;
989}
990
991static int
992iavf_hash_parse_action(struct iavf_pattern_match_item *pattern_match_item,
993 const struct rte_flow_item pattern[],
994 const struct rte_flow_action actions[],
995 void **meta, struct rte_flow_error *error)
996{
997 struct iavf_rss_meta *rss_meta = (struct iavf_rss_meta *)*meta;
998 uint32_t type_list_len = RTE_DIM(iavf_hash_type_list);
999 struct iavf_hash_match_type *type_match_item;
1000 enum rte_flow_action_type action_type;
1001 const struct rte_flow_action_rss *rss;
1002 const struct rte_flow_action *action;
1003 bool item_found = false;
1004 uint64_t rss_type;
1005 uint16_t i;
1006
1007 struct iavf_pattern_match_type *tt = (struct iavf_pattern_match_type *)
1008 (pattern_match_item->meta);
1009
1010 /* Supported action is RSS. */
1011 for (action = actions; action->type !=
1012 RTE_FLOW_ACTION_TYPE_END; action++) {
1013 action_type = action->type;
1014 switch (action_type) {
1015 case RTE_FLOW_ACTION_TYPE_RSS:
1016 rss = action->conf;
1017 rss_type = rss->types;
1018
1019 /**
1020 * Check simultaneous use of SRC_ONLY and DST_ONLY
1021 * of the same level.
1022 */
1023 rss_type = rte_eth_rss_hf_refine(rss_type);
1024
1025 /**
1026 * Refine the hash type base on some specific item of
1027 * the pattern, such as identify the gtpu hash.
1028 */
1029 rss_type = iavf_hash_refine_type(rss_type, pattern);
1030
1031 /* Check if pattern is empty. */
1032 if (pattern_match_item->pattern_list !=
1033 iavf_pattern_empty && rss->func ==
1034 RTE_ETH_HASH_FUNCTION_SIMPLE_XOR)
1035 return rte_flow_error_set(error, ENOTSUP,
1036 RTE_FLOW_ERROR_TYPE_ACTION, action,
1037 "Not supported flow");
1038
1039 if (rss->level)
1040 return rte_flow_error_set(error, ENOTSUP,
1041 RTE_FLOW_ERROR_TYPE_ACTION, action,
1042 "a nonzero RSS encapsulation level is not supported");
1043
1044 if (rss->key_len)
1045 return rte_flow_error_set(error, ENOTSUP,
1046 RTE_FLOW_ERROR_TYPE_ACTION, action,
1047 "a nonzero RSS key_len is not supported");
1048
1049 if (rss->queue_num)
1050 return rte_flow_error_set(error, ENOTSUP,
1051 RTE_FLOW_ERROR_TYPE_ACTION, action,
1052 "a non-NULL RSS queue is not supported");
1053
1054 /* Check hash function and save it to rss_meta. */
1055 if (rss->func == RTE_ETH_HASH_FUNCTION_SIMPLE_XOR)
1056 rss_meta->rss_algorithm =
1057 VIRTCHNL_RSS_ALG_XOR_ASYMMETRIC;
1058 else if (rss->func ==
1059 RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ)
1060 rss_meta->rss_algorithm =
1061 VIRTCHNL_RSS_ALG_TOEPLITZ_SYMMETRIC;
1062 else
1063 rss_meta->rss_algorithm =
1064 VIRTCHNL_RSS_ALG_TOEPLITZ_ASYMMETRIC;
1065
1066 type_match_item =
1067 rte_zmalloc("iavf_type_match_item",
1068 sizeof(struct iavf_hash_match_type), 0);
1069 if (!type_match_item) {
1070 rte_flow_error_set(error, EINVAL,
1071 RTE_FLOW_ERROR_TYPE_HANDLE,
1072 NULL,
1073 "No memory for type_match_item");
1074 return -ENOMEM;
1075 }
1076
1077 /* Find matched proto hdrs according to hash type. */
1078 for (i = 0; i < type_list_len; i++) {
1079 struct iavf_hash_match_type *ht_map =
1080 &iavf_hash_type_list[i];
1081 if (rss_type == ht_map->hash_type &&
1082 tt->phint_type == ht_map->phint_type) {
1083 type_match_item->hash_type =
1084 ht_map->hash_type;
1085 type_match_item->proto_hdrs =
1086 ht_map->proto_hdrs;
1087 rss_meta->proto_hdrs =
1088 type_match_item->proto_hdrs;
1089 item_found = true;
1090 }
1091 }
1092
1093 rte_free(type_match_item);
1094
1095 if (!item_found)
1096 return rte_flow_error_set(error, ENOTSUP,
1097 RTE_FLOW_ERROR_TYPE_ACTION, action,
1098 "Not supported flow");
1099 break;
1100
1101 case RTE_FLOW_ACTION_TYPE_END:
1102 break;
1103
1104 default:
1105 rte_flow_error_set(error, EINVAL,
1106 RTE_FLOW_ERROR_TYPE_ACTION, action,
1107 "Invalid action.");
1108 return -rte_errno;
1109 }
1110 }
1111
1112 return 0;
1113}
1114
1115static int
1116iavf_hash_parse_pattern_action(__rte_unused struct iavf_adapter *ad,
1117 struct iavf_pattern_match_item *array,
1118 uint32_t array_len,
1119 const struct rte_flow_item pattern[],
1120 const struct rte_flow_action actions[],
1121 void **meta,
1122 struct rte_flow_error *error)
1123{
1124 struct iavf_pattern_match_item *pattern_match_item;
1125 struct iavf_rss_meta *rss_meta_ptr;
1126 int ret = 0;
1127
1128 rss_meta_ptr = rte_zmalloc(NULL, sizeof(*rss_meta_ptr), 0);
1129 if (!rss_meta_ptr) {
1130 rte_flow_error_set(error, EINVAL,
1131 RTE_FLOW_ERROR_TYPE_HANDLE, NULL,
1132 "No memory for rss_meta_ptr");
1133 return -ENOMEM;
1134 }
1135
1136 /* Check rss supported pattern and find matched pattern. */
1137 pattern_match_item =
1138 iavf_search_pattern_match_item(pattern, array, array_len,
1139 error);
1140 if (!pattern_match_item) {
1141 ret = -rte_errno;
1142 goto error;
1143 }
1144
1145 ret = iavf_hash_check_inset(pattern, error);
1146 if (ret)
1147 goto error;
1148
1149 /* Check rss action. */
1150 ret = iavf_hash_parse_action(pattern_match_item, pattern, actions,
1151 (void **)&rss_meta_ptr, error);
1152
1153error:
1154 if (!ret && meta)
1155 *meta = rss_meta_ptr;
1156 else
1157 rte_free(rss_meta_ptr);
1158
1159 rte_free(pattern_match_item);
1160
1161 return ret;
1162}
1163
1164static int
1165iavf_hash_create(__rte_unused struct iavf_adapter *ad,
1166 __rte_unused struct rte_flow *flow, void *meta,
1167 __rte_unused struct rte_flow_error *error)
1168{
1169 struct iavf_rss_meta *rss_meta = (struct iavf_rss_meta *)meta;
1170 struct virtchnl_rss_cfg *rss_cfg;
1171 int ret = 0;
1172
1173 rss_cfg = rte_zmalloc("iavf rss rule",
1174 sizeof(struct virtchnl_rss_cfg), 0);
1175 if (!rss_cfg) {
1176 rte_flow_error_set(error, EINVAL,
1177 RTE_FLOW_ERROR_TYPE_HANDLE, NULL,
1178 "No memory for rss rule");
1179 return -ENOMEM;
1180 }
1181
1182 rss_cfg->proto_hdrs = *rss_meta->proto_hdrs;
1183 rss_cfg->rss_algorithm = rss_meta->rss_algorithm;
1184
1185 ret = iavf_add_del_rss_cfg(ad, rss_cfg, true);
1186 if (!ret) {
1187 flow->rule = rss_cfg;
1188 } else {
1189 PMD_DRV_LOG(ERR, "fail to add RSS configure");
1190 rte_flow_error_set(error, -ret,
1191 RTE_FLOW_ERROR_TYPE_HANDLE, NULL,
1192 "Failed to add rss rule.");
1193 rte_free(rss_cfg);
1194 return -rte_errno;
1195 }
1196
1197 rte_free(meta);
1198
1199 return ret;
1200}
1201
1202static int
1203iavf_hash_destroy(__rte_unused struct iavf_adapter *ad,
1204 struct rte_flow *flow,
1205 __rte_unused struct rte_flow_error *error)
1206{
1207 struct virtchnl_rss_cfg *rss_cfg;
1208 int ret = 0;
1209
1210 rss_cfg = (struct virtchnl_rss_cfg *)flow->rule;
1211
1212 ret = iavf_add_del_rss_cfg(ad, rss_cfg, false);
1213 if (ret) {
1214 PMD_DRV_LOG(ERR, "fail to del RSS configure");
1215 rte_flow_error_set(error, -ret,
1216 RTE_FLOW_ERROR_TYPE_HANDLE, NULL,
1217 "Failed to delete rss rule.");
1218 return -rte_errno;
1219 }
1220 return ret;
1221}
1222
1223static void
1224iavf_hash_uninit(struct iavf_adapter *ad)
1225{
1226 if (iavf_hash_default_set(ad, false))
1227 PMD_DRV_LOG(ERR, "fail to delete default RSS");
1228
1229 iavf_unregister_parser(&iavf_hash_parser, ad);
1230}
1231
1232static void
1233iavf_hash_free(struct rte_flow *flow)
1234{
1235 rte_free(flow->rule);
1236}