net/ice: support hash for GTPU protocols
[dpdk.git] / drivers / net / ice / ice_hash.c
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2019 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 "ice_logs.h"
23 #include "base/ice_type.h"
24 #include "base/ice_flow.h"
25 #include "ice_ethdev.h"
26 #include "ice_generic_flow.h"
27
28 #define ICE_GTPU_EH_DWNLINK     0
29 #define ICE_GTPU_EH_UPLINK      1
30
31 struct rss_type_match_hdr {
32         uint32_t hdr_mask;
33         uint64_t eth_rss_hint;
34 };
35
36 struct ice_hash_match_type {
37         uint64_t hash_type;
38         uint64_t hash_flds;
39 };
40
41 struct rss_meta {
42         uint32_t pkt_hdr;
43         uint64_t hash_flds;
44         uint8_t hash_function;
45 };
46
47 struct ice_hash_flow_cfg {
48         bool simple_xor;
49         struct ice_rss_cfg rss_cfg;
50 };
51
52 static int
53 ice_hash_init(struct ice_adapter *ad);
54
55 static int
56 ice_hash_create(struct ice_adapter *ad,
57                 struct rte_flow *flow,
58                 void *meta,
59                 struct rte_flow_error *error);
60
61 static int
62 ice_hash_destroy(struct ice_adapter *ad,
63                 struct rte_flow *flow,
64                 struct rte_flow_error *error);
65
66 static void
67 ice_hash_uninit(struct ice_adapter *ad);
68
69 static void
70 ice_hash_free(struct rte_flow *flow);
71
72 static int
73 ice_hash_parse_pattern_action(struct ice_adapter *ad,
74                         struct ice_pattern_match_item *array,
75                         uint32_t array_len,
76                         const struct rte_flow_item pattern[],
77                         const struct rte_flow_action actions[],
78                         void **meta,
79                         struct rte_flow_error *error);
80
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 |
89         ICE_FLOW_SEG_HDR_UDP,
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 |
93         ICE_FLOW_SEG_HDR_TCP,
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};
157
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},
169 };
170
171 /* Supported pattern for comms package. */
172 static struct ice_pattern_match_item ice_hash_pattern_list_comms[] = {
173         {pattern_empty,                     ICE_INSET_NONE,
174                 &hint_empty},
175         {pattern_eth_ipv4,                  ICE_INSET_NONE,
176                 &hint_eth_ipv4},
177         {pattern_eth_ipv4_udp,              ICE_INSET_NONE,
178                 &hint_eth_ipv4_udp},
179         {pattern_eth_ipv4_tcp,              ICE_INSET_NONE,
180                 &hint_eth_ipv4_tcp},
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,
200                 &hint_eth_ipv6},
201         {pattern_eth_ipv6_udp,              ICE_INSET_NONE,
202                 &hint_eth_ipv6_udp},
203         {pattern_eth_ipv6_tcp,              ICE_INSET_NONE,
204                 &hint_eth_ipv6_tcp},
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,
216                 &hint_eth_pppoes},
217 };
218
219 /**
220  * The first member is input set combination,
221  * the second member is hash fields.
222  */
223 struct ice_hash_match_type ice_hash_type_list[] = {
224         {ETH_RSS_PPPOE,
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)},
229         /* IPV4 */
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,
262                 ICE_HASH_UDP_IPV4 |
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,
291                 ICE_HASH_TCP_IPV4 |
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,
320                 ICE_HASH_SCTP_IPV4 |
321                 BIT_ULL(ICE_FLOW_FIELD_IDX_IPV4_PROT)},
322         /* IPV6 */
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,
357                 ICE_HASH_UDP_IPV6 |
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,
386                 ICE_HASH_TCP_IPV6 |
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,
415                 ICE_HASH_SCTP_IPV6 |
416                 BIT_ULL(ICE_FLOW_FIELD_IDX_IPV6_PROT)},
417 };
418
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,
426 };
427
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,
435 };
436
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,
444 };
445
446 RTE_INIT(ice_hash_engine_init)
447 {
448         struct ice_flow_engine *engine = &ice_hash_engine;
449         ice_register_flow_engine(engine);
450 }
451
452 static int
453 ice_hash_init(struct ice_adapter *ad)
454 {
455         struct ice_flow_parser *parser = NULL;
456
457         if (ad->hw.dcf_enabled)
458                 return 0;
459
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;
464         else
465                 return -EINVAL;
466
467         return ice_register_parser(parser, ad);
468 }
469
470 static int
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)
474 {
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;
479         uint32_t hdrs = 0;
480
481         for (item = pattern; item->type != RTE_FLOW_ITEM_TYPE_END; item++) {
482                 if (item->last) {
483                         rte_flow_error_set(error, EINVAL,
484                                         RTE_FLOW_ERROR_TYPE_ITEM, item,
485                                         "Not support range");
486                         return -rte_errno;
487                 }
488
489                 switch (item->type) {
490                 case RTE_FLOW_ITEM_TYPE_GTPU:
491                         hdrs |= ICE_FLOW_SEG_HDR_GTPU_IP;
492                         break;
493                 case RTE_FLOW_ITEM_TYPE_GTP_PSC:
494                         psc = item->spec;
495                         hdr_mask &= ~ICE_FLOW_SEG_HDR_GTPU_EH;
496                         hdrs &= ~ICE_FLOW_SEG_HDR_GTPU_IP;
497                         if (!psc)
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;
503                         break;
504                 default:
505                         break;
506                 }
507         }
508
509         /* Save protocol header to rss_meta. */
510         ((struct rss_meta *)*meta)->pkt_hdr |= hdr_mask | hdrs;
511
512         return 0;
513 }
514
515 static int
516 ice_hash_parse_action(struct ice_pattern_match_item *pattern_match_item,
517                 const struct rte_flow_action actions[],
518                 void **meta,
519                 struct rte_flow_error *error)
520 {
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;
529         uint64_t rss_type;
530         uint16_t i;
531
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:
538                         rss = action->conf;
539                         rss_type = rss->types;
540
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;
552                                 return 0;
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;
557                         }
558
559                         if (rss->level)
560                                 return rte_flow_error_set(error, ENOTSUP,
561                                         RTE_FLOW_ERROR_TYPE_ACTION, action,
562                                         "a nonzero RSS encapsulation level is not supported");
563
564                         if (rss->key_len)
565                                 return rte_flow_error_set(error, ENOTSUP,
566                                         RTE_FLOW_ERROR_TYPE_ACTION, action,
567                                         "a nonzero RSS key_len is not supported");
568
569                         if (rss->queue)
570                                 return rte_flow_error_set(error, ENOTSUP,
571                                         RTE_FLOW_ERROR_TYPE_ACTION, action,
572                                         "a non-NULL RSS queue is not supported");
573
574                         /**
575                          * Check simultaneous use of SRC_ONLY and DST_ONLY
576                          * of the same level.
577                          */
578                         rss_type = rte_eth_rss_hf_refine(rss_type);
579
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 |
585                                         ETH_RSS_L4_DST_ONLY;
586
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");
592                         }
593
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];
598
599                                 if (rss_type == ht_map->hash_type) {
600                                         hash_meta->hash_flds =
601                                                         ht_map->hash_flds;
602                                         break;
603                                 }
604                         }
605
606                         /* update hash field for gtpu-ip and gtpu-eh. */
607                         if (rss_type != ETH_RSS_GTPU)
608                                 break;
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);
621
622                         break;
623
624                 case RTE_FLOW_ACTION_TYPE_END:
625                         break;
626
627                 default:
628                         rte_flow_error_set(error, EINVAL,
629                                         RTE_FLOW_ERROR_TYPE_ACTION, action,
630                                         "Invalid action.");
631                         return -rte_errno;
632                 }
633         }
634
635         return 0;
636 }
637
638 static int
639 ice_hash_parse_pattern_action(__rte_unused struct ice_adapter *ad,
640                         struct ice_pattern_match_item *array,
641                         uint32_t array_len,
642                         const struct rte_flow_item pattern[],
643                         const struct rte_flow_action actions[],
644                         void **meta,
645                         struct rte_flow_error *error)
646 {
647         int ret = 0;
648         struct ice_pattern_match_item *pattern_match_item;
649         struct rss_meta *rss_meta_ptr;
650
651         rss_meta_ptr = rte_zmalloc(NULL, sizeof(*rss_meta_ptr), 0);
652         if (!rss_meta_ptr) {
653                 rte_flow_error_set(error, EINVAL,
654                                 RTE_FLOW_ERROR_TYPE_HANDLE, NULL,
655                                 "No memory for rss_meta_ptr");
656                 return -ENOMEM;
657         }
658
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) {
663                 ret = -rte_errno;
664                 goto error;
665         }
666
667         ret = ice_hash_parse_pattern(pattern_match_item, pattern,
668                                      (void **)&rss_meta_ptr, error);
669         if (ret)
670                 goto error;
671
672         /* Check rss action. */
673         ret = ice_hash_parse_action(pattern_match_item, actions,
674                                     (void **)&rss_meta_ptr, error);
675
676 error:
677         if (!ret && meta)
678                 *meta = rss_meta_ptr;
679         else
680                 rte_free(rss_meta_ptr);
681         rte_free(pattern_match_item);
682
683         return ret;
684 }
685
686 static int
687 ice_hash_create(struct ice_adapter *ad,
688                 struct rte_flow *flow,
689                 void *meta,
690                 struct rte_flow_error *error)
691 {
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;
695         int ret;
696         uint32_t reg;
697         struct ice_hash_flow_cfg *filter_ptr;
698
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;
702
703         filter_ptr = rte_zmalloc("ice_rss_filter",
704                                 sizeof(struct ice_hash_flow_cfg), 0);
705         if (!filter_ptr) {
706                 rte_flow_error_set(error, EINVAL,
707                                 RTE_FLOW_ERROR_TYPE_HANDLE, NULL,
708                                 "No memory for filter_ptr");
709                 return -ENOMEM;
710         }
711
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);
718
719                 filter_ptr->simple_xor = 1;
720
721                 goto out;
722         } else {
723                 filter_ptr->rss_cfg.packet_hdr = headermask;
724                 filter_ptr->rss_cfg.hashed_flds = hash_field;
725                 filter_ptr->rss_cfg.symm =
726                         (hash_function ==
727                                 RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ);
728
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);
733                 if (ret) {
734                         rte_flow_error_set(error, EINVAL,
735                                         RTE_FLOW_ERROR_TYPE_HANDLE, NULL,
736                                         "rss flow create fail");
737                         goto error;
738                 }
739         }
740
741 out:
742         flow->rule = filter_ptr;
743         rte_free(meta);
744         return 0;
745
746 error:
747         rte_free(filter_ptr);
748         rte_free(meta);
749         return -rte_errno;
750 }
751
752 static int
753 ice_hash_destroy(struct ice_adapter *ad,
754                 struct rte_flow *flow,
755                 struct rte_flow_error *error)
756 {
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;
760         int ret;
761         uint32_t reg;
762         struct ice_hash_flow_cfg *filter_ptr;
763
764         filter_ptr = (struct ice_hash_flow_cfg *)flow->rule;
765
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);
772         } else {
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.
780                  **/
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");
785                         goto error;
786                 }
787         }
788
789         rte_free(filter_ptr);
790         return 0;
791
792 error:
793         rte_free(filter_ptr);
794         return -rte_errno;
795 }
796
797 static void
798 ice_hash_uninit(struct ice_adapter *ad)
799 {
800         if (ad->hw.dcf_enabled)
801                 return;
802
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);
807 }
808
809 static void
810 ice_hash_free(struct rte_flow *flow)
811 {
812         rte_free(flow->rule);
813 }