net/mlx5: Support encap id when setting new steering entry
[sfrench/cifs-2.6.git] / drivers / net / ethernet / mellanox / mlx5 / core / en_fs_ethtool.c
1 /*
2  * Copyright (c) 2016, Mellanox Technologies. All rights reserved.
3  *
4  * This software is available to you under a choice of one of two
5  * licenses.  You may choose to be licensed under the terms of the GNU
6  * General Public License (GPL) Version 2, available from the file
7  * COPYING in the main directory of this source tree, or the
8  * OpenIB.org BSD license below:
9  *
10  *     Redistribution and use in source and binary forms, with or
11  *     without modification, are permitted provided that the following
12  *     conditions are met:
13  *
14  *      - Redistributions of source code must retain the above
15  *        copyright notice, this list of conditions and the following
16  *        disclaimer.
17  *
18  *      - Redistributions in binary form must reproduce the above
19  *        copyright notice, this list of conditions and the following
20  *        disclaimer in the documentation and/or other materials
21  *        provided with the distribution.
22  *
23  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
24  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
25  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
26  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
27  * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
28  * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
29  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
30  * SOFTWARE.
31  */
32
33 #include <linux/mlx5/fs.h>
34 #include "en.h"
35
36 struct mlx5e_ethtool_rule {
37         struct list_head             list;
38         struct ethtool_rx_flow_spec  flow_spec;
39         struct mlx5_flow_handle      *rule;
40         struct mlx5e_ethtool_table   *eth_ft;
41 };
42
43 static void put_flow_table(struct mlx5e_ethtool_table *eth_ft)
44 {
45         if (!--eth_ft->num_rules) {
46                 mlx5_destroy_flow_table(eth_ft->ft);
47                 eth_ft->ft = NULL;
48         }
49 }
50
51 #define MLX5E_ETHTOOL_L3_L4_PRIO 0
52 #define MLX5E_ETHTOOL_L2_PRIO (MLX5E_ETHTOOL_L3_L4_PRIO + ETHTOOL_NUM_L3_L4_FTS)
53 #define MLX5E_ETHTOOL_NUM_ENTRIES 64000
54 #define MLX5E_ETHTOOL_NUM_GROUPS  10
55 static struct mlx5e_ethtool_table *get_flow_table(struct mlx5e_priv *priv,
56                                                   struct ethtool_rx_flow_spec *fs,
57                                                   int num_tuples)
58 {
59         struct mlx5e_ethtool_table *eth_ft;
60         struct mlx5_flow_namespace *ns;
61         struct mlx5_flow_table *ft;
62         int max_tuples;
63         int table_size;
64         int prio;
65
66         switch (fs->flow_type & ~(FLOW_EXT | FLOW_MAC_EXT)) {
67         case TCP_V4_FLOW:
68         case UDP_V4_FLOW:
69                 max_tuples = ETHTOOL_NUM_L3_L4_FTS;
70                 prio = MLX5E_ETHTOOL_L3_L4_PRIO + (max_tuples - num_tuples);
71                 eth_ft = &priv->fs.ethtool.l3_l4_ft[prio];
72                 break;
73         case IP_USER_FLOW:
74                 max_tuples = ETHTOOL_NUM_L3_L4_FTS;
75                 prio = MLX5E_ETHTOOL_L3_L4_PRIO + (max_tuples - num_tuples);
76                 eth_ft = &priv->fs.ethtool.l3_l4_ft[prio];
77                 break;
78         case ETHER_FLOW:
79                 max_tuples = ETHTOOL_NUM_L2_FTS;
80                 prio = max_tuples - num_tuples;
81                 eth_ft = &priv->fs.ethtool.l2_ft[prio];
82                 prio += MLX5E_ETHTOOL_L2_PRIO;
83                 break;
84         default:
85                 return ERR_PTR(-EINVAL);
86         }
87
88         eth_ft->num_rules++;
89         if (eth_ft->ft)
90                 return eth_ft;
91
92         ns = mlx5_get_flow_namespace(priv->mdev,
93                                      MLX5_FLOW_NAMESPACE_ETHTOOL);
94         if (!ns)
95                 return ERR_PTR(-ENOTSUPP);
96
97         table_size = min_t(u32, BIT(MLX5_CAP_FLOWTABLE(priv->mdev,
98                                                        flow_table_properties_nic_receive.log_max_ft_size)),
99                            MLX5E_ETHTOOL_NUM_ENTRIES);
100         ft = mlx5_create_auto_grouped_flow_table(ns, prio,
101                                                  table_size,
102                                                  MLX5E_ETHTOOL_NUM_GROUPS, 0, 0);
103         if (IS_ERR(ft))
104                 return (void *)ft;
105
106         eth_ft->ft = ft;
107         return eth_ft;
108 }
109
110 static void mask_spec(u8 *mask, u8 *val, size_t size)
111 {
112         unsigned int i;
113
114         for (i = 0; i < size; i++, mask++, val++)
115                 *((u8 *)val) = *((u8 *)mask) & *((u8 *)val);
116 }
117
118 static void set_ips(void *outer_headers_v, void *outer_headers_c, __be32 ip4src_m,
119                     __be32 ip4src_v, __be32 ip4dst_m, __be32 ip4dst_v)
120 {
121         if (ip4src_m) {
122                 memcpy(MLX5_ADDR_OF(fte_match_set_lyr_2_4, outer_headers_v,
123                                     src_ipv4_src_ipv6.ipv4_layout.ipv4),
124                        &ip4src_v, sizeof(ip4src_v));
125                 memset(MLX5_ADDR_OF(fte_match_set_lyr_2_4, outer_headers_c,
126                                     src_ipv4_src_ipv6.ipv4_layout.ipv4),
127                        0xff, sizeof(ip4src_m));
128         }
129         if (ip4dst_m) {
130                 memcpy(MLX5_ADDR_OF(fte_match_set_lyr_2_4, outer_headers_v,
131                                     dst_ipv4_dst_ipv6.ipv4_layout.ipv4),
132                        &ip4dst_v, sizeof(ip4dst_v));
133                 memset(MLX5_ADDR_OF(fte_match_set_lyr_2_4, outer_headers_c,
134                                     dst_ipv4_dst_ipv6.ipv4_layout.ipv4),
135                        0xff, sizeof(ip4dst_m));
136         }
137         MLX5_SET(fte_match_set_lyr_2_4, outer_headers_v,
138                  ethertype, ETH_P_IP);
139         MLX5_SET(fte_match_set_lyr_2_4, outer_headers_c,
140                  ethertype, 0xffff);
141 }
142
143 static int set_flow_attrs(u32 *match_c, u32 *match_v,
144                           struct ethtool_rx_flow_spec *fs)
145 {
146         void *outer_headers_c = MLX5_ADDR_OF(fte_match_param, match_c,
147                                              outer_headers);
148         void *outer_headers_v = MLX5_ADDR_OF(fte_match_param, match_v,
149                                              outer_headers);
150         u32 flow_type = fs->flow_type & ~(FLOW_EXT | FLOW_MAC_EXT);
151         struct ethtool_tcpip4_spec *l4_mask;
152         struct ethtool_tcpip4_spec *l4_val;
153         struct ethtool_usrip4_spec *l3_mask;
154         struct ethtool_usrip4_spec *l3_val;
155         struct ethhdr *eth_val;
156         struct ethhdr *eth_mask;
157
158         switch (flow_type) {
159         case TCP_V4_FLOW:
160                 l4_mask = &fs->m_u.tcp_ip4_spec;
161                 l4_val = &fs->h_u.tcp_ip4_spec;
162                 set_ips(outer_headers_v, outer_headers_c, l4_mask->ip4src,
163                         l4_val->ip4src, l4_mask->ip4dst, l4_val->ip4dst);
164
165                 if (l4_mask->psrc) {
166                         MLX5_SET(fte_match_set_lyr_2_4, outer_headers_c, tcp_sport,
167                                  0xffff);
168                         MLX5_SET(fte_match_set_lyr_2_4, outer_headers_v, tcp_sport,
169                                  ntohs(l4_val->psrc));
170                 }
171                 if (l4_mask->pdst) {
172                         MLX5_SET(fte_match_set_lyr_2_4, outer_headers_c, tcp_dport,
173                                  0xffff);
174                         MLX5_SET(fte_match_set_lyr_2_4, outer_headers_v, tcp_dport,
175                                  ntohs(l4_val->pdst));
176                 }
177                 MLX5_SET(fte_match_set_lyr_2_4, outer_headers_c, ip_protocol,
178                          0xffff);
179                 MLX5_SET(fte_match_set_lyr_2_4, outer_headers_v, ip_protocol,
180                          IPPROTO_TCP);
181                 break;
182         case UDP_V4_FLOW:
183                 l4_mask = &fs->m_u.tcp_ip4_spec;
184                 l4_val = &fs->h_u.tcp_ip4_spec;
185                 set_ips(outer_headers_v, outer_headers_c, l4_mask->ip4src,
186                         l4_val->ip4src, l4_mask->ip4dst, l4_val->ip4dst);
187
188                 if (l4_mask->psrc) {
189                         MLX5_SET(fte_match_set_lyr_2_4, outer_headers_c, udp_sport,
190                                  0xffff);
191                         MLX5_SET(fte_match_set_lyr_2_4, outer_headers_v, udp_sport,
192                                  ntohs(l4_val->psrc));
193                 }
194                 if (l4_mask->pdst) {
195                         MLX5_SET(fte_match_set_lyr_2_4, outer_headers_c, udp_dport,
196                                  0xffff);
197                         MLX5_SET(fte_match_set_lyr_2_4, outer_headers_v, udp_dport,
198                                  ntohs(l4_val->pdst));
199                 }
200                 MLX5_SET(fte_match_set_lyr_2_4, outer_headers_c, ip_protocol,
201                          0xffff);
202                 MLX5_SET(fte_match_set_lyr_2_4, outer_headers_v, ip_protocol,
203                          IPPROTO_UDP);
204                 break;
205         case IP_USER_FLOW:
206                 l3_mask = &fs->m_u.usr_ip4_spec;
207                 l3_val = &fs->h_u.usr_ip4_spec;
208                 set_ips(outer_headers_v, outer_headers_c, l3_mask->ip4src,
209                         l3_val->ip4src, l3_mask->ip4dst, l3_val->ip4dst);
210                 break;
211         case ETHER_FLOW:
212                 eth_mask = &fs->m_u.ether_spec;
213                 eth_val = &fs->h_u.ether_spec;
214
215                 mask_spec((u8 *)eth_mask, (u8 *)eth_val, sizeof(*eth_mask));
216                 ether_addr_copy(MLX5_ADDR_OF(fte_match_set_lyr_2_4,
217                                              outer_headers_c, smac_47_16),
218                                 eth_mask->h_source);
219                 ether_addr_copy(MLX5_ADDR_OF(fte_match_set_lyr_2_4,
220                                              outer_headers_v, smac_47_16),
221                                 eth_val->h_source);
222                 ether_addr_copy(MLX5_ADDR_OF(fte_match_set_lyr_2_4,
223                                              outer_headers_c, dmac_47_16),
224                                 eth_mask->h_dest);
225                 ether_addr_copy(MLX5_ADDR_OF(fte_match_set_lyr_2_4,
226                                              outer_headers_v, dmac_47_16),
227                                 eth_val->h_dest);
228                 MLX5_SET(fte_match_set_lyr_2_4, outer_headers_c, ethertype,
229                          ntohs(eth_mask->h_proto));
230                 MLX5_SET(fte_match_set_lyr_2_4, outer_headers_v, ethertype,
231                          ntohs(eth_val->h_proto));
232                 break;
233         default:
234                 return -EINVAL;
235         }
236
237         if ((fs->flow_type & FLOW_EXT) &&
238             (fs->m_ext.vlan_tci & cpu_to_be16(VLAN_VID_MASK))) {
239                 MLX5_SET(fte_match_set_lyr_2_4, outer_headers_c,
240                          vlan_tag, 1);
241                 MLX5_SET(fte_match_set_lyr_2_4, outer_headers_v,
242                          vlan_tag, 1);
243                 MLX5_SET(fte_match_set_lyr_2_4, outer_headers_c,
244                          first_vid, 0xfff);
245                 MLX5_SET(fte_match_set_lyr_2_4, outer_headers_v,
246                          first_vid, ntohs(fs->h_ext.vlan_tci));
247         }
248         if (fs->flow_type & FLOW_MAC_EXT &&
249             !is_zero_ether_addr(fs->m_ext.h_dest)) {
250                 ether_addr_copy(MLX5_ADDR_OF(fte_match_set_lyr_2_4,
251                                              outer_headers_c, dmac_47_16),
252                                 fs->m_ext.h_dest);
253                 ether_addr_copy(MLX5_ADDR_OF(fte_match_set_lyr_2_4,
254                                              outer_headers_v, dmac_47_16),
255                                 fs->h_ext.h_dest);
256         }
257
258         return 0;
259 }
260
261 static void add_rule_to_list(struct mlx5e_priv *priv,
262                              struct mlx5e_ethtool_rule *rule)
263 {
264         struct mlx5e_ethtool_rule *iter;
265         struct list_head *head = &priv->fs.ethtool.rules;
266
267         list_for_each_entry(iter, &priv->fs.ethtool.rules, list) {
268                 if (iter->flow_spec.location > rule->flow_spec.location)
269                         break;
270                 head = &iter->list;
271         }
272         priv->fs.ethtool.tot_num_rules++;
273         list_add(&rule->list, head);
274 }
275
276 static bool outer_header_zero(u32 *match_criteria)
277 {
278         int size = MLX5_ST_SZ_BYTES(fte_match_param);
279         char *outer_headers_c = MLX5_ADDR_OF(fte_match_param, match_criteria,
280                                              outer_headers);
281
282         return outer_headers_c[0] == 0 && !memcmp(outer_headers_c,
283                                                   outer_headers_c + 1,
284                                                   size - 1);
285 }
286
287 static struct mlx5_flow_handle *
288 add_ethtool_flow_rule(struct mlx5e_priv *priv,
289                       struct mlx5_flow_table *ft,
290                       struct ethtool_rx_flow_spec *fs)
291 {
292         struct mlx5_flow_destination *dst = NULL;
293         struct mlx5_flow_act flow_act = {0};
294         struct mlx5_flow_spec *spec;
295         struct mlx5_flow_handle *rule;
296         int err = 0;
297
298         spec = mlx5_vzalloc(sizeof(*spec));
299         if (!spec)
300                 return ERR_PTR(-ENOMEM);
301         err = set_flow_attrs(spec->match_criteria, spec->match_value,
302                              fs);
303         if (err)
304                 goto free;
305
306         if (fs->ring_cookie == RX_CLS_FLOW_DISC) {
307                 flow_act.action = MLX5_FLOW_CONTEXT_ACTION_DROP;
308         } else {
309                 dst = kzalloc(sizeof(*dst), GFP_KERNEL);
310                 if (!dst) {
311                         err = -ENOMEM;
312                         goto free;
313                 }
314
315                 dst->type = MLX5_FLOW_DESTINATION_TYPE_TIR;
316                 dst->tir_num = priv->direct_tir[fs->ring_cookie].tirn;
317                 flow_act.action = MLX5_FLOW_CONTEXT_ACTION_FWD_DEST;
318         }
319
320         spec->match_criteria_enable = (!outer_header_zero(spec->match_criteria));
321         flow_act.flow_tag = MLX5_FS_DEFAULT_FLOW_TAG;
322         rule = mlx5_add_flow_rules(ft, spec, &flow_act, dst, 1);
323         if (IS_ERR(rule)) {
324                 err = PTR_ERR(rule);
325                 netdev_err(priv->netdev, "%s: failed to add ethtool steering rule: %d\n",
326                            __func__, err);
327                 goto free;
328         }
329 free:
330         kvfree(spec);
331         kfree(dst);
332         return err ? ERR_PTR(err) : rule;
333 }
334
335 static void del_ethtool_rule(struct mlx5e_priv *priv,
336                              struct mlx5e_ethtool_rule *eth_rule)
337 {
338         if (eth_rule->rule)
339                 mlx5_del_flow_rules(eth_rule->rule);
340         list_del(&eth_rule->list);
341         priv->fs.ethtool.tot_num_rules--;
342         put_flow_table(eth_rule->eth_ft);
343         kfree(eth_rule);
344 }
345
346 static struct mlx5e_ethtool_rule *find_ethtool_rule(struct mlx5e_priv *priv,
347                                                     int location)
348 {
349         struct mlx5e_ethtool_rule *iter;
350
351         list_for_each_entry(iter, &priv->fs.ethtool.rules, list) {
352                 if (iter->flow_spec.location == location)
353                         return iter;
354         }
355         return NULL;
356 }
357
358 static struct mlx5e_ethtool_rule *get_ethtool_rule(struct mlx5e_priv *priv,
359                                                    int location)
360 {
361         struct mlx5e_ethtool_rule *eth_rule;
362
363         eth_rule = find_ethtool_rule(priv, location);
364         if (eth_rule)
365                 del_ethtool_rule(priv, eth_rule);
366
367         eth_rule = kzalloc(sizeof(*eth_rule), GFP_KERNEL);
368         if (!eth_rule)
369                 return ERR_PTR(-ENOMEM);
370
371         add_rule_to_list(priv, eth_rule);
372         return eth_rule;
373 }
374
375 #define MAX_NUM_OF_ETHTOOL_RULES BIT(10)
376
377 #define all_ones(field) (field == (__force typeof(field))-1)
378 #define all_zeros_or_all_ones(field)            \
379         ((field) == 0 || (field) == (__force typeof(field))-1)
380
381 static int validate_flow(struct mlx5e_priv *priv,
382                          struct ethtool_rx_flow_spec *fs)
383 {
384         struct ethtool_tcpip4_spec *l4_mask;
385         struct ethtool_usrip4_spec *l3_mask;
386         struct ethhdr *eth_mask;
387         int num_tuples = 0;
388
389         if (fs->location >= MAX_NUM_OF_ETHTOOL_RULES)
390                 return -EINVAL;
391
392         if (fs->ring_cookie >= priv->params.num_channels &&
393             fs->ring_cookie != RX_CLS_FLOW_DISC)
394                 return -EINVAL;
395
396         switch (fs->flow_type & ~(FLOW_EXT | FLOW_MAC_EXT)) {
397         case ETHER_FLOW:
398                 eth_mask = &fs->m_u.ether_spec;
399                 if (!is_zero_ether_addr(eth_mask->h_dest))
400                         num_tuples++;
401                 if (!is_zero_ether_addr(eth_mask->h_source))
402                         num_tuples++;
403                 if (eth_mask->h_proto)
404                         num_tuples++;
405                 break;
406         case TCP_V4_FLOW:
407         case UDP_V4_FLOW:
408                 if (fs->m_u.tcp_ip4_spec.tos)
409                         return -EINVAL;
410                 l4_mask = &fs->m_u.tcp_ip4_spec;
411                 if (l4_mask->ip4src) {
412                         if (!all_ones(l4_mask->ip4src))
413                                 return -EINVAL;
414                         num_tuples++;
415                 }
416                 if (l4_mask->ip4dst) {
417                         if (!all_ones(l4_mask->ip4dst))
418                                 return -EINVAL;
419                         num_tuples++;
420                 }
421                 if (l4_mask->psrc) {
422                         if (!all_ones(l4_mask->psrc))
423                                 return -EINVAL;
424                         num_tuples++;
425                 }
426                 if (l4_mask->pdst) {
427                         if (!all_ones(l4_mask->pdst))
428                                 return -EINVAL;
429                         num_tuples++;
430                 }
431                 /* Flow is TCP/UDP */
432                 num_tuples++;
433                 break;
434         case IP_USER_FLOW:
435                 l3_mask = &fs->m_u.usr_ip4_spec;
436                 if (l3_mask->l4_4_bytes || l3_mask->tos || l3_mask->proto ||
437                     fs->h_u.usr_ip4_spec.ip_ver != ETH_RX_NFC_IP4)
438                         return -EINVAL;
439                 if (l3_mask->ip4src) {
440                         if (!all_ones(l3_mask->ip4src))
441                                 return -EINVAL;
442                         num_tuples++;
443                 }
444                 if (l3_mask->ip4dst) {
445                         if (!all_ones(l3_mask->ip4dst))
446                                 return -EINVAL;
447                         num_tuples++;
448                 }
449                 /* Flow is IPv4 */
450                 num_tuples++;
451                 break;
452         default:
453                 return -EINVAL;
454         }
455         if ((fs->flow_type & FLOW_EXT)) {
456                 if (fs->m_ext.vlan_etype ||
457                     (fs->m_ext.vlan_tci != cpu_to_be16(VLAN_VID_MASK)))
458                         return -EINVAL;
459
460                 if (fs->m_ext.vlan_tci) {
461                         if (be16_to_cpu(fs->h_ext.vlan_tci) >= VLAN_N_VID)
462                                 return -EINVAL;
463                 }
464                 num_tuples++;
465         }
466
467         if (fs->flow_type & FLOW_MAC_EXT &&
468             !is_zero_ether_addr(fs->m_ext.h_dest))
469                 num_tuples++;
470
471         return num_tuples;
472 }
473
474 int mlx5e_ethtool_flow_replace(struct mlx5e_priv *priv,
475                                struct ethtool_rx_flow_spec *fs)
476 {
477         struct mlx5e_ethtool_table *eth_ft;
478         struct mlx5e_ethtool_rule *eth_rule;
479         struct mlx5_flow_handle *rule;
480         int num_tuples;
481         int err;
482
483         num_tuples = validate_flow(priv, fs);
484         if (num_tuples <= 0) {
485                 netdev_warn(priv->netdev, "%s: flow is not valid\n",  __func__);
486                 return -EINVAL;
487         }
488
489         eth_ft = get_flow_table(priv, fs, num_tuples);
490         if (IS_ERR(eth_ft))
491                 return PTR_ERR(eth_ft);
492
493         eth_rule = get_ethtool_rule(priv, fs->location);
494         if (IS_ERR(eth_rule)) {
495                 put_flow_table(eth_ft);
496                 return PTR_ERR(eth_rule);
497         }
498
499         eth_rule->flow_spec = *fs;
500         eth_rule->eth_ft = eth_ft;
501         if (!eth_ft->ft) {
502                 err = -EINVAL;
503                 goto del_ethtool_rule;
504         }
505         rule = add_ethtool_flow_rule(priv, eth_ft->ft, fs);
506         if (IS_ERR(rule)) {
507                 err = PTR_ERR(rule);
508                 goto del_ethtool_rule;
509         }
510
511         eth_rule->rule = rule;
512
513         return 0;
514
515 del_ethtool_rule:
516         del_ethtool_rule(priv, eth_rule);
517
518         return err;
519 }
520
521 int mlx5e_ethtool_flow_remove(struct mlx5e_priv *priv,
522                               int location)
523 {
524         struct mlx5e_ethtool_rule *eth_rule;
525         int err = 0;
526
527         if (location >= MAX_NUM_OF_ETHTOOL_RULES)
528                 return -ENOSPC;
529
530         eth_rule = find_ethtool_rule(priv, location);
531         if (!eth_rule) {
532                 err =  -ENOENT;
533                 goto out;
534         }
535
536         del_ethtool_rule(priv, eth_rule);
537 out:
538         return err;
539 }
540
541 int mlx5e_ethtool_get_flow(struct mlx5e_priv *priv, struct ethtool_rxnfc *info,
542                            int location)
543 {
544         struct mlx5e_ethtool_rule *eth_rule;
545
546         if (location < 0 || location >= MAX_NUM_OF_ETHTOOL_RULES)
547                 return -EINVAL;
548
549         list_for_each_entry(eth_rule, &priv->fs.ethtool.rules, list) {
550                 if (eth_rule->flow_spec.location == location) {
551                         info->fs = eth_rule->flow_spec;
552                         return 0;
553                 }
554         }
555
556         return -ENOENT;
557 }
558
559 int mlx5e_ethtool_get_all_flows(struct mlx5e_priv *priv, struct ethtool_rxnfc *info,
560                                 u32 *rule_locs)
561 {
562         int location = 0;
563         int idx = 0;
564         int err = 0;
565
566         while ((!err || err == -ENOENT) && idx < info->rule_cnt) {
567                 err = mlx5e_ethtool_get_flow(priv, info, location);
568                 if (!err)
569                         rule_locs[idx++] = location;
570                 location++;
571         }
572         return err;
573 }
574
575 void mlx5e_ethtool_cleanup_steering(struct mlx5e_priv *priv)
576 {
577         struct mlx5e_ethtool_rule *iter;
578         struct mlx5e_ethtool_rule *temp;
579
580         list_for_each_entry_safe(iter, temp, &priv->fs.ethtool.rules, list)
581                 del_ethtool_rule(priv, iter);
582 }
583
584 void mlx5e_ethtool_init_steering(struct mlx5e_priv *priv)
585 {
586         INIT_LIST_HEAD(&priv->fs.ethtool.rules);
587 }