req->rss_set_bitmap = rte_cpu_to_le_16(HNS3_RSS_SET_BITMAP_MSK);
for (j = 0; j < HNS3_RSS_CFG_TBL_SIZE; j++) {
num = i * HNS3_RSS_CFG_TBL_SIZE + j;
- req->rss_result[j] = indir[num] % hw->alloc_rss_size;
+ req->rss_result[j] = indir[num];
}
ret = hns3_cmd_send(hw, &desc, 1);
if (ret) {
req->ipv6_fragment_en |= HNS3_IP_OTHER_BIT_MASK;
break;
default:
- /* Other unsupported flow types won't change tuples */
+ /*
+ * rss_hf doesn't include unsupported flow types
+ * because the API framework has checked it, and
+ * this branch will never go unless rss_hf is zero.
+ */
break;
}
}
struct hns3_hw *hw = &hns->hw;
struct hns3_rss_tuple_cfg *tuple = &hw->rss_info.rss_tuple_sets;
struct hns3_rss_conf *rss_cfg = &hw->rss_info;
- uint8_t algo = rss_cfg->conf.func;
uint8_t key_len = rss_conf->rss_key_len;
+ uint8_t algo;
uint64_t rss_hf = rss_conf->rss_hf;
uint8_t *key = rss_conf->rss_key;
int ret;
+ if (hw->rss_dis_flag)
+ return -EINVAL;
+
rte_spinlock_lock(&hw->lock);
ret = hns3_set_rss_tuple_by_rss_hf(hw, tuple, rss_hf);
if (ret)
ret = -EINVAL;
goto conf_err;
}
+ algo = rss_cfg->conf.func == RTE_ETH_HASH_FUNCTION_SIMPLE_XOR ?
+ HNS3_RSS_HASH_ALGO_SIMPLE : HNS3_RSS_HASH_ALGO_TOEPLITZ;
ret = hns3_set_rss_algo_key(hw, algo, key);
if (ret)
goto conf_err;
rss_conf->rss_hf = rss_cfg->conf.types;
/* Get the RSS Key required by the user */
- if (rss_conf->rss_key)
+ if (rss_conf->rss_key && rss_conf->rss_key_len >= HNS3_RSS_KEY_SIZE) {
memcpy(rss_conf->rss_key, rss_cfg->key, HNS3_RSS_KEY_SIZE);
+ rss_conf->rss_key_len = HNS3_RSS_KEY_SIZE;
+ }
rte_spinlock_unlock(&hw->lock);
return 0;
shift = i % RTE_RETA_GROUP_SIZE;
if (reta_conf[idx].mask & (1ULL << shift))
reta_conf[idx].reta[shift] =
- rss_cfg->rss_indirection_tbl[i] % hw->alloc_rss_size;
+ rss_cfg->rss_indirection_tbl[i];
}
rte_spinlock_unlock(&hw->lock);
return 0;
int i;
/* Default hash algorithm */
- rss_cfg->conf.func = RTE_ETH_HASH_FUNCTION_SIMPLE_XOR;
+ rss_cfg->conf.func = RTE_ETH_HASH_FUNCTION_TOEPLITZ;
+
+ /* Default RSS key */
memcpy(rss_cfg->key, hns3_hash_key, HNS3_RSS_KEY_SIZE);
/* Initialize RSS indirection table */
enum rte_eth_rx_mq_mode mq_mode = hw->data->dev_conf.rxmode.mq_mode;
- /* When there is no open RSS, redirect the packet queue 0 */
- if (((uint32_t)mq_mode & ETH_MQ_RX_RSS_FLAG) == 0) {
+ /* When RSS is off, redirect the packet queue 0 */
+ if (((uint32_t)mq_mode & ETH_MQ_RX_RSS_FLAG) == 0)
hns3_rss_uninit(hns);
- return 0;
- }
/* Configure RSS hash algorithm and hash key offset */
ret = hns3_set_rss_algo_key(hw, hash_algo, hash_key);
if (ret)
return ret;
- ret = hns3_set_rss_indir_table(hw, rss_cfg->rss_indirection_tbl,
- HNS3_RSS_IND_TBL_SIZE);
- if (ret)
- goto rss_tuple_uninit;
+ /*
+ * When RSS is off, it doesn't need to configure rss redirection table
+ * to hardware.
+ */
+ if (((uint32_t)mq_mode & ETH_MQ_RX_RSS_FLAG)) {
+ ret = hns3_set_rss_indir_table(hw, rss_cfg->rss_indirection_tbl,
+ HNS3_RSS_IND_TBL_SIZE);
+ if (ret)
+ goto rss_tuple_uninit;
+ }
ret = hns3_set_rss_tc_mode(hw);
if (ret)
return ret;
rss_indir_table_uninit:
- ret1 = hns3_rss_reset_indir_table(hw);
- if (ret1 != 0)
- return ret;
+ if (((uint32_t)mq_mode & ETH_MQ_RX_RSS_FLAG)) {
+ ret1 = hns3_rss_reset_indir_table(hw);
+ if (ret1 != 0)
+ return ret;
+ }
rss_tuple_uninit:
hns3_rss_tuple_uninit(hw);