doc: support IPsec Multi-buffer lib v0.54
[dpdk.git] / drivers / net / hns3 / hns3_rss.c
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2018-2019 Hisilicon Limited.
3  */
4
5 #include <stdbool.h>
6 #include <rte_ethdev.h>
7 #include <rte_io.h>
8 #include <rte_malloc.h>
9 #include <rte_memcpy.h>
10 #include <rte_spinlock.h>
11
12 #include "hns3_ethdev.h"
13 #include "hns3_logs.h"
14
15 /*
16  * The hash key used for rss initialization.
17  */
18 static const uint8_t hns3_hash_key[] = {
19         0x6D, 0x5A, 0x56, 0xDA, 0x25, 0x5B, 0x0E, 0xC2,
20         0x41, 0x67, 0x25, 0x3D, 0x43, 0xA3, 0x8F, 0xB0,
21         0xD0, 0xCA, 0x2B, 0xCB, 0xAE, 0x7B, 0x30, 0xB4,
22         0x77, 0xCB, 0x2D, 0xA3, 0x80, 0x30, 0xF2, 0x0C,
23         0x6A, 0x42, 0xB7, 0x3B, 0xBE, 0xAC, 0x01, 0xFA
24 };
25
26 /*
27  * rss_generic_config command function, opcode:0x0D01.
28  * Used to set algorithm, key_offset and hash key of rss.
29  */
30 int
31 hns3_set_rss_algo_key(struct hns3_hw *hw, uint8_t hash_algo, const uint8_t *key)
32 {
33 #define HNS3_KEY_OFFSET_MAX     3
34 #define HNS3_SET_HASH_KEY_BYTE_FOUR     2
35
36         struct hns3_rss_generic_config_cmd *req;
37         struct hns3_cmd_desc desc;
38         uint32_t key_offset, key_size;
39         const uint8_t *key_cur;
40         uint8_t cur_offset;
41         int ret;
42
43         req = (struct hns3_rss_generic_config_cmd *)desc.data;
44
45         /*
46          * key_offset=0, hash key byte0~15 is set to hardware.
47          * key_offset=1, hash key byte16~31 is set to hardware.
48          * key_offset=2, hash key byte32~39 is set to hardware.
49          */
50         for (key_offset = 0; key_offset < HNS3_KEY_OFFSET_MAX; key_offset++) {
51                 hns3_cmd_setup_basic_desc(&desc, HNS3_OPC_RSS_GENERIC_CONFIG,
52                                           false);
53
54                 req->hash_config |= (hash_algo & HNS3_RSS_HASH_ALGO_MASK);
55                 req->hash_config |= (key_offset << HNS3_RSS_HASH_KEY_OFFSET_B);
56
57                 if (key_offset == HNS3_SET_HASH_KEY_BYTE_FOUR)
58                         key_size = HNS3_RSS_KEY_SIZE - HNS3_RSS_HASH_KEY_NUM *
59                         HNS3_SET_HASH_KEY_BYTE_FOUR;
60                 else
61                         key_size = HNS3_RSS_HASH_KEY_NUM;
62
63                 cur_offset = key_offset * HNS3_RSS_HASH_KEY_NUM;
64                 key_cur = key + cur_offset;
65                 memcpy(req->hash_key, key_cur, key_size);
66
67                 ret = hns3_cmd_send(hw, &desc, 1);
68                 if (ret) {
69                         hns3_err(hw, "Configure RSS algo key failed %d", ret);
70                         return ret;
71                 }
72         }
73         /* Update the shadow RSS key with user specified */
74         memcpy(hw->rss_info.key, key, HNS3_RSS_KEY_SIZE);
75         return 0;
76 }
77
78 /*
79  * Used to configure the tuple selection for RSS hash input.
80  */
81 static int
82 hns3_set_rss_input_tuple(struct hns3_hw *hw)
83 {
84         struct hns3_rss_conf *rss_config = &hw->rss_info;
85         struct hns3_rss_input_tuple_cmd *req;
86         struct hns3_cmd_desc desc_tuple;
87         int ret;
88
89         hns3_cmd_setup_basic_desc(&desc_tuple, HNS3_OPC_RSS_INPUT_TUPLE, false);
90
91         req = (struct hns3_rss_input_tuple_cmd *)desc_tuple.data;
92
93         req->ipv4_tcp_en = rss_config->rss_tuple_sets.ipv4_tcp_en;
94         req->ipv4_udp_en = rss_config->rss_tuple_sets.ipv4_udp_en;
95         req->ipv4_sctp_en = rss_config->rss_tuple_sets.ipv4_sctp_en;
96         req->ipv4_fragment_en = rss_config->rss_tuple_sets.ipv4_fragment_en;
97         req->ipv6_tcp_en = rss_config->rss_tuple_sets.ipv6_tcp_en;
98         req->ipv6_udp_en = rss_config->rss_tuple_sets.ipv6_udp_en;
99         req->ipv6_sctp_en = rss_config->rss_tuple_sets.ipv6_sctp_en;
100         req->ipv6_fragment_en = rss_config->rss_tuple_sets.ipv6_fragment_en;
101
102         ret = hns3_cmd_send(hw, &desc_tuple, 1);
103         if (ret)
104                 hns3_err(hw, "Configure RSS input tuple mode failed %d", ret);
105
106         return ret;
107 }
108
109 /*
110  * rss_indirection_table command function, opcode:0x0D07.
111  * Used to configure the indirection table of rss.
112  */
113 int
114 hns3_set_rss_indir_table(struct hns3_hw *hw, uint8_t *indir, uint16_t size)
115 {
116         struct hns3_rss_indirection_table_cmd *req;
117         struct hns3_cmd_desc desc;
118         int ret, i, j, num;
119
120         req = (struct hns3_rss_indirection_table_cmd *)desc.data;
121
122         for (i = 0; i < size / HNS3_RSS_CFG_TBL_SIZE; i++) {
123                 hns3_cmd_setup_basic_desc(&desc, HNS3_OPC_RSS_INDIR_TABLE,
124                                           false);
125                 req->start_table_index =
126                                 rte_cpu_to_le_16(i * HNS3_RSS_CFG_TBL_SIZE);
127                 req->rss_set_bitmap = rte_cpu_to_le_16(HNS3_RSS_SET_BITMAP_MSK);
128                 for (j = 0; j < HNS3_RSS_CFG_TBL_SIZE; j++) {
129                         num = i * HNS3_RSS_CFG_TBL_SIZE + j;
130                         req->rss_result[j] = indir[num];
131                 }
132                 ret = hns3_cmd_send(hw, &desc, 1);
133                 if (ret) {
134                         hns3_err(hw,
135                                  "Sets RSS indirection table failed %d size %u",
136                                  ret, size);
137                         return ret;
138                 }
139         }
140
141         /* Update redirection table of hw */
142         memcpy(hw->rss_info.rss_indirection_tbl, indir, HNS3_RSS_IND_TBL_SIZE);
143
144         return 0;
145 }
146
147 int
148 hns3_rss_reset_indir_table(struct hns3_hw *hw)
149 {
150         uint8_t *lut;
151         int ret;
152
153         lut = rte_zmalloc("hns3_rss_lut", HNS3_RSS_IND_TBL_SIZE, 0);
154         if (lut == NULL) {
155                 hns3_err(hw, "No hns3_rss_lut memory can be allocated");
156                 return -ENOMEM;
157         }
158
159         ret = hns3_set_rss_indir_table(hw, lut, HNS3_RSS_IND_TBL_SIZE);
160         if (ret)
161                 hns3_err(hw, "RSS uninit indir table failed: %d", ret);
162         rte_free(lut);
163
164         return ret;
165 }
166
167 int
168 hns3_set_rss_tuple_by_rss_hf(struct hns3_hw *hw,
169                              struct hns3_rss_tuple_cfg *tuple, uint64_t rss_hf)
170 {
171         struct hns3_rss_input_tuple_cmd *req;
172         struct hns3_cmd_desc desc;
173         uint32_t i;
174         int ret;
175
176         hns3_cmd_setup_basic_desc(&desc, HNS3_OPC_RSS_INPUT_TUPLE, false);
177
178         req = (struct hns3_rss_input_tuple_cmd *)desc.data;
179
180         /* Enable ipv4 or ipv6 tuple by flow type */
181         for (i = 0; i < RTE_ETH_FLOW_MAX; i++) {
182                 switch (rss_hf & (1ULL << i)) {
183                 case ETH_RSS_NONFRAG_IPV4_TCP:
184                         req->ipv4_tcp_en = HNS3_RSS_INPUT_TUPLE_OTHER;
185                         break;
186                 case ETH_RSS_NONFRAG_IPV4_UDP:
187                         req->ipv4_udp_en = HNS3_RSS_INPUT_TUPLE_OTHER;
188                         break;
189                 case ETH_RSS_NONFRAG_IPV4_SCTP:
190                         req->ipv4_sctp_en = HNS3_RSS_INPUT_TUPLE_SCTP;
191                         break;
192                 case ETH_RSS_FRAG_IPV4:
193                         req->ipv4_fragment_en |= HNS3_IP_FRAG_BIT_MASK;
194                         break;
195                 case ETH_RSS_NONFRAG_IPV4_OTHER:
196                         req->ipv4_fragment_en |= HNS3_IP_OTHER_BIT_MASK;
197                         break;
198                 case ETH_RSS_NONFRAG_IPV6_TCP:
199                         req->ipv6_tcp_en = HNS3_RSS_INPUT_TUPLE_OTHER;
200                         break;
201                 case ETH_RSS_NONFRAG_IPV6_UDP:
202                         req->ipv6_udp_en = HNS3_RSS_INPUT_TUPLE_OTHER;
203                         break;
204                 case ETH_RSS_NONFRAG_IPV6_SCTP:
205                         req->ipv6_sctp_en = HNS3_RSS_INPUT_TUPLE_SCTP;
206                         break;
207                 case ETH_RSS_FRAG_IPV6:
208                         req->ipv6_fragment_en |= HNS3_IP_FRAG_BIT_MASK;
209                         break;
210                 case ETH_RSS_NONFRAG_IPV6_OTHER:
211                         req->ipv6_fragment_en |= HNS3_IP_OTHER_BIT_MASK;
212                         break;
213                 default:
214                         /*
215                          * rss_hf doesn't include unsupported flow types
216                          * because the API framework has checked it, and
217                          * this branch will never go unless rss_hf is zero.
218                          */
219                         break;
220                 }
221         }
222
223         ret = hns3_cmd_send(hw, &desc, 1);
224         if (ret) {
225                 hns3_err(hw, "Update RSS flow types tuples failed %d", ret);
226                 return ret;
227         }
228
229         tuple->ipv4_tcp_en = req->ipv4_tcp_en;
230         tuple->ipv4_udp_en = req->ipv4_udp_en;
231         tuple->ipv4_sctp_en = req->ipv4_sctp_en;
232         tuple->ipv4_fragment_en = req->ipv4_fragment_en;
233         tuple->ipv6_tcp_en = req->ipv6_tcp_en;
234         tuple->ipv6_udp_en = req->ipv6_udp_en;
235         tuple->ipv6_sctp_en = req->ipv6_sctp_en;
236         tuple->ipv6_fragment_en = req->ipv6_fragment_en;
237
238         return 0;
239 }
240
241 /*
242  * Configure RSS hash protocols and hash key.
243  * @param dev
244  *   Pointer to Ethernet device.
245  * @praram rss_conf
246  *   The configuration select of  rss key size and tuple flow_types.
247  * @return
248  *   0 on success, a negative errno value otherwise is set.
249  */
250 int
251 hns3_dev_rss_hash_update(struct rte_eth_dev *dev,
252                          struct rte_eth_rss_conf *rss_conf)
253 {
254         struct hns3_adapter *hns = dev->data->dev_private;
255         struct hns3_hw *hw = &hns->hw;
256         struct hns3_rss_tuple_cfg *tuple = &hw->rss_info.rss_tuple_sets;
257         struct hns3_rss_conf *rss_cfg = &hw->rss_info;
258         uint8_t key_len = rss_conf->rss_key_len;
259         uint8_t algo;
260         uint64_t rss_hf = rss_conf->rss_hf;
261         uint8_t *key = rss_conf->rss_key;
262         int ret;
263
264         if (hw->rss_dis_flag)
265                 return -EINVAL;
266
267         rte_spinlock_lock(&hw->lock);
268         ret = hns3_set_rss_tuple_by_rss_hf(hw, tuple, rss_hf);
269         if (ret)
270                 goto conf_err;
271
272         if (rss_cfg->conf.types && rss_hf == 0) {
273                 /* Disable RSS, reset indirection table by local variable */
274                 ret = hns3_rss_reset_indir_table(hw);
275                 if (ret)
276                         goto conf_err;
277         } else if (rss_hf && rss_cfg->conf.types == 0) {
278                 /* Enable RSS, restore indirection table by hw's config */
279                 ret = hns3_set_rss_indir_table(hw, rss_cfg->rss_indirection_tbl,
280                                                HNS3_RSS_IND_TBL_SIZE);
281                 if (ret)
282                         goto conf_err;
283         }
284
285         /* Update supported flow types when set tuple success */
286         rss_cfg->conf.types = rss_hf;
287
288         if (key) {
289                 if (key_len != HNS3_RSS_KEY_SIZE) {
290                         hns3_err(hw, "The hash key len(%u) is invalid",
291                                  key_len);
292                         ret = -EINVAL;
293                         goto conf_err;
294                 }
295                 algo = rss_cfg->conf.func == RTE_ETH_HASH_FUNCTION_SIMPLE_XOR ?
296                         HNS3_RSS_HASH_ALGO_SIMPLE : HNS3_RSS_HASH_ALGO_TOEPLITZ;
297                 ret = hns3_set_rss_algo_key(hw, algo, key);
298                 if (ret)
299                         goto conf_err;
300         }
301         rte_spinlock_unlock(&hw->lock);
302
303         return 0;
304
305 conf_err:
306         rte_spinlock_unlock(&hw->lock);
307         return ret;
308 }
309
310 /*
311  * Get rss key and rss_hf types set of RSS hash configuration.
312  * @param dev
313  *   Pointer to Ethernet device.
314  * @praram rss_conf
315  *   The buffer to get rss key size and tuple types.
316  * @return
317  *   0 on success.
318  */
319 int
320 hns3_dev_rss_hash_conf_get(struct rte_eth_dev *dev,
321                            struct rte_eth_rss_conf *rss_conf)
322 {
323         struct hns3_adapter *hns = dev->data->dev_private;
324         struct hns3_hw *hw = &hns->hw;
325         struct hns3_rss_conf *rss_cfg = &hw->rss_info;
326
327         rte_spinlock_lock(&hw->lock);
328         rss_conf->rss_hf = rss_cfg->conf.types;
329
330         /* Get the RSS Key required by the user */
331         if (rss_conf->rss_key && rss_conf->rss_key_len >= HNS3_RSS_KEY_SIZE) {
332                 memcpy(rss_conf->rss_key, rss_cfg->key, HNS3_RSS_KEY_SIZE);
333                 rss_conf->rss_key_len = HNS3_RSS_KEY_SIZE;
334         }
335         rte_spinlock_unlock(&hw->lock);
336
337         return 0;
338 }
339
340 /*
341  * Update rss redirection table of RSS.
342  * @param dev
343  *   Pointer to Ethernet device.
344  * @praram reta_conf
345  *   Pointer to the configuration select of mask and redirection tables.
346  * @param reta_size
347  *   Redirection table size.
348  * @return
349  *   0 on success, a negative errno value otherwise is set.
350  */
351 int
352 hns3_dev_rss_reta_update(struct rte_eth_dev *dev,
353                          struct rte_eth_rss_reta_entry64 *reta_conf,
354                          uint16_t reta_size)
355 {
356         struct hns3_adapter *hns = dev->data->dev_private;
357         struct hns3_hw *hw = &hns->hw;
358         struct hns3_rss_conf *rss_cfg = &hw->rss_info;
359         uint16_t i, indir_size = HNS3_RSS_IND_TBL_SIZE; /* Table size is 512 */
360         uint8_t indirection_tbl[HNS3_RSS_IND_TBL_SIZE];
361         uint16_t idx, shift, allow_rss_queues;
362         int ret;
363
364         if (reta_size != indir_size || reta_size > ETH_RSS_RETA_SIZE_512) {
365                 hns3_err(hw, "The size of hash lookup table configured (%u)"
366                          "doesn't match the number hardware can supported"
367                          "(%u)", reta_size, indir_size);
368                 return -EINVAL;
369         }
370         rte_spinlock_lock(&hw->lock);
371         memcpy(indirection_tbl, rss_cfg->rss_indirection_tbl,
372                 HNS3_RSS_IND_TBL_SIZE);
373         allow_rss_queues = RTE_MIN(dev->data->nb_rx_queues, hw->rss_size_max);
374         for (i = 0; i < reta_size; i++) {
375                 idx = i / RTE_RETA_GROUP_SIZE;
376                 shift = i % RTE_RETA_GROUP_SIZE;
377                 if (reta_conf[idx].reta[shift] >= allow_rss_queues) {
378                         rte_spinlock_unlock(&hw->lock);
379                         hns3_err(hw, "Invalid queue id(%u) to be set in "
380                                  "redirection table, max number of rss "
381                                  "queues: %u", reta_conf[idx].reta[shift],
382                                  allow_rss_queues);
383                         return -EINVAL;
384                 }
385
386                 if (reta_conf[idx].mask & (1ULL << shift))
387                         indirection_tbl[i] = reta_conf[idx].reta[shift];
388         }
389
390         ret = hns3_set_rss_indir_table(hw, indirection_tbl,
391                                        HNS3_RSS_IND_TBL_SIZE);
392
393         rte_spinlock_unlock(&hw->lock);
394         return ret;
395 }
396
397 /*
398  * Get rss redirection table of RSS hash configuration.
399  * @param dev
400  *   Pointer to Ethernet device.
401  * @praram reta_conf
402  *   Pointer to the configuration select of mask and redirection tables.
403  * @param reta_size
404  *   Redirection table size.
405  * @return
406  *   0 on success, a negative errno value otherwise is set.
407  */
408 int
409 hns3_dev_rss_reta_query(struct rte_eth_dev *dev,
410                         struct rte_eth_rss_reta_entry64 *reta_conf,
411                         uint16_t reta_size)
412 {
413         struct hns3_adapter *hns = dev->data->dev_private;
414         struct hns3_hw *hw = &hns->hw;
415         struct hns3_rss_conf *rss_cfg = &hw->rss_info;
416         uint16_t i, indir_size = HNS3_RSS_IND_TBL_SIZE; /* Table size is 512 */
417         uint16_t idx, shift;
418
419         if (reta_size != indir_size || reta_size > ETH_RSS_RETA_SIZE_512) {
420                 hns3_err(hw, "The size of hash lookup table configured (%u)"
421                          " doesn't match the number hardware can supported"
422                          "(%u)", reta_size, indir_size);
423                 return -EINVAL;
424         }
425         rte_spinlock_lock(&hw->lock);
426         for (i = 0; i < reta_size; i++) {
427                 idx = i / RTE_RETA_GROUP_SIZE;
428                 shift = i % RTE_RETA_GROUP_SIZE;
429                 if (reta_conf[idx].mask & (1ULL << shift))
430                         reta_conf[idx].reta[shift] =
431                                                 rss_cfg->rss_indirection_tbl[i];
432         }
433         rte_spinlock_unlock(&hw->lock);
434         return 0;
435 }
436
437 /*
438  * Used to configure the tc_size and tc_offset.
439  */
440 static int
441 hns3_set_rss_tc_mode(struct hns3_hw *hw)
442 {
443         uint16_t rss_size = hw->alloc_rss_size;
444         struct hns3_rss_tc_mode_cmd *req;
445         uint16_t tc_offset[HNS3_MAX_TC_NUM];
446         uint8_t tc_valid[HNS3_MAX_TC_NUM];
447         uint16_t tc_size[HNS3_MAX_TC_NUM];
448         struct hns3_cmd_desc desc;
449         uint16_t roundup_size;
450         uint16_t i;
451         int ret;
452
453         req = (struct hns3_rss_tc_mode_cmd *)desc.data;
454
455         roundup_size = roundup_pow_of_two(rss_size);
456         roundup_size = ilog2(roundup_size);
457
458         for (i = 0; i < HNS3_MAX_TC_NUM; i++) {
459                 tc_valid[i] = !!(hw->hw_tc_map & BIT(i));
460                 tc_size[i] = roundup_size;
461                 tc_offset[i] = rss_size * i;
462         }
463
464         hns3_cmd_setup_basic_desc(&desc, HNS3_OPC_RSS_TC_MODE, false);
465         for (i = 0; i < HNS3_MAX_TC_NUM; i++) {
466                 uint16_t mode = 0;
467
468                 hns3_set_bit(mode, HNS3_RSS_TC_VALID_B, (tc_valid[i] & 0x1));
469                 hns3_set_field(mode, HNS3_RSS_TC_SIZE_M, HNS3_RSS_TC_SIZE_S,
470                                tc_size[i]);
471                 hns3_set_field(mode, HNS3_RSS_TC_OFFSET_M, HNS3_RSS_TC_OFFSET_S,
472                                tc_offset[i]);
473
474                 req->rss_tc_mode[i] = rte_cpu_to_le_16(mode);
475         }
476         ret = hns3_cmd_send(hw, &desc, 1);
477         if (ret)
478                 hns3_err(hw, "Sets rss tc mode failed %d", ret);
479
480         return ret;
481 }
482
483 static void
484 hns3_rss_tuple_uninit(struct hns3_hw *hw)
485 {
486         struct hns3_rss_input_tuple_cmd *req;
487         struct hns3_cmd_desc desc;
488         int ret;
489
490         hns3_cmd_setup_basic_desc(&desc, HNS3_OPC_RSS_INPUT_TUPLE, false);
491
492         req = (struct hns3_rss_input_tuple_cmd *)desc.data;
493
494         memset(req, 0, sizeof(struct hns3_rss_tuple_cfg));
495
496         ret = hns3_cmd_send(hw, &desc, 1);
497         if (ret) {
498                 hns3_err(hw, "RSS uninit tuple failed %d", ret);
499                 return;
500         }
501 }
502
503 /*
504  * Set the default rss configuration in the init of driver.
505  */
506 void
507 hns3_set_default_rss_args(struct hns3_hw *hw)
508 {
509         struct hns3_rss_conf *rss_cfg = &hw->rss_info;
510         uint16_t queue_num = hw->alloc_rss_size;
511         int i;
512
513         /* Default hash algorithm */
514         rss_cfg->conf.func = RTE_ETH_HASH_FUNCTION_TOEPLITZ;
515
516         /* Default RSS key */
517         memcpy(rss_cfg->key, hns3_hash_key, HNS3_RSS_KEY_SIZE);
518
519         /* Initialize RSS indirection table */
520         for (i = 0; i < HNS3_RSS_IND_TBL_SIZE; i++)
521                 rss_cfg->rss_indirection_tbl[i] = i % queue_num;
522 }
523
524 /*
525  * RSS initialization for hns3 pmd driver.
526  */
527 int
528 hns3_config_rss(struct hns3_adapter *hns)
529 {
530         struct hns3_hw *hw = &hns->hw;
531         struct hns3_rss_conf *rss_cfg = &hw->rss_info;
532         uint8_t hash_algo =
533                 (hw->rss_info.conf.func == RTE_ETH_HASH_FUNCTION_TOEPLITZ ?
534                  HNS3_RSS_HASH_ALGO_TOEPLITZ : HNS3_RSS_HASH_ALGO_SIMPLE);
535         uint8_t *hash_key = rss_cfg->key;
536         int ret, ret1;
537
538         enum rte_eth_rx_mq_mode mq_mode = hw->data->dev_conf.rxmode.mq_mode;
539
540         /* When RSS is off, redirect the packet queue 0 */
541         if (((uint32_t)mq_mode & ETH_MQ_RX_RSS_FLAG) == 0)
542                 hns3_rss_uninit(hns);
543
544         /* Configure RSS hash algorithm and hash key offset */
545         ret = hns3_set_rss_algo_key(hw, hash_algo, hash_key);
546         if (ret)
547                 return ret;
548
549         /* Configure the tuple selection for RSS hash input */
550         ret = hns3_set_rss_input_tuple(hw);
551         if (ret)
552                 return ret;
553
554         /*
555          * When RSS is off, it doesn't need to configure rss redirection table
556          * to hardware.
557          */
558         if (((uint32_t)mq_mode & ETH_MQ_RX_RSS_FLAG)) {
559                 ret = hns3_set_rss_indir_table(hw, rss_cfg->rss_indirection_tbl,
560                                                HNS3_RSS_IND_TBL_SIZE);
561                 if (ret)
562                         goto rss_tuple_uninit;
563         }
564
565         ret = hns3_set_rss_tc_mode(hw);
566         if (ret)
567                 goto rss_indir_table_uninit;
568
569         return ret;
570
571 rss_indir_table_uninit:
572         if (((uint32_t)mq_mode & ETH_MQ_RX_RSS_FLAG)) {
573                 ret1 = hns3_rss_reset_indir_table(hw);
574                 if (ret1 != 0)
575                         return ret;
576         }
577
578 rss_tuple_uninit:
579         hns3_rss_tuple_uninit(hw);
580
581         /* Disable RSS */
582         hw->rss_info.conf.types = 0;
583
584         return ret;
585 }
586
587 /*
588  * RSS uninitialization for hns3 pmd driver.
589  */
590 void
591 hns3_rss_uninit(struct hns3_adapter *hns)
592 {
593         struct hns3_hw *hw = &hns->hw;
594         int ret;
595
596         hns3_rss_tuple_uninit(hw);
597         ret = hns3_rss_reset_indir_table(hw);
598         if (ret != 0)
599                 return;
600
601         /* Disable RSS */
602         hw->rss_info.conf.types = 0;
603 }