From: Lijun Ou Date: Tue, 22 Sep 2020 12:03:25 +0000 (+0800) Subject: net/hns3: fix config when creating RSS rule after flush X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=eb158fc756a5c0c91ed05a676b2085927d76aa63;p=dpdk.git net/hns3: fix config when creating RSS rule after flush Currnetly, when user create a flow RSS rule and then flush the rule, driver will set 0 for the internal structure of hw->rss_info maintained in driver. And then user create a flow RSS rule without specified RSS hash key, driver configure a validate RSS hash key into hardware network engine and will cause an RSS error. The related steps when using testpmd as follows: flow 0 action rss xx end / end flow flush 0 flow 0 action rss queues 0 1 end / end To slove the preceding problem, the flow flush processing is modified. it don't clear all RSS configurations for hw->rss_info. Actually the RSS key information in the hardware is not cleared, therefore, the hw->rss_info.key is kept consistent with the value in the hardware. In addition, because reset the redirection table, we need to set queues NULL and queue_num for zero that indicate the corresponding parameters in the hardware is unavailable. Also we set hw->rss_info.func to RTE_ETH_HASH_FUNCTION_MAX that indicate it is invalid. Fixes: c37ca66f2b27 ("net/hns3: support RSS") Cc: stable@dpdk.org Signed-off-by: Lijun Ou Signed-off-by: Wei Hu (Xavier) --- diff --git a/drivers/net/hns3/hns3_flow.c b/drivers/net/hns3/hns3_flow.c index f4ea47aff4..6f2ff87496 100644 --- a/drivers/net/hns3/hns3_flow.c +++ b/drivers/net/hns3/hns3_flow.c @@ -1293,10 +1293,24 @@ static bool hns3_action_rss_same(const struct rte_flow_action_rss *comp, const struct rte_flow_action_rss *with) { - return (comp->func == with->func && - comp->level == with->level && - comp->types == with->types && - comp->key_len == with->key_len && + bool func_is_same; + + /* + * When user flush all RSS rule, RSS func is set invalid with + * RTE_ETH_HASH_FUNCTION_MAX. Then the user create a flow after + * flushed, any validate RSS func is different with it before + * flushed. Others, when user create an action RSS with RSS func + * specified RTE_ETH_HASH_FUNCTION_DEFAULT, the func is the same + * between continuous RSS flow. + */ + if (comp->func == RTE_ETH_HASH_FUNCTION_MAX) + func_is_same = false; + else + func_is_same = (with->func ? (comp->func == with->func) : true); + + return (func_is_same && + comp->types == (with->types & HNS3_ETH_RSS_SUPPORT) && + comp->level == with->level && comp->key_len == with->key_len && comp->queue_num == with->queue_num && !memcmp(comp->key, with->key, with->key_len) && !memcmp(comp->queue, with->queue, @@ -1589,7 +1603,19 @@ hns3_config_rss_filter(struct rte_eth_dev *dev, hns3_err(hw, "RSS disable failed(%d)", ret); return ret; } - memset(rss_info, 0, sizeof(struct hns3_rss_conf)); + + if (rss_flow_conf.queue_num) { + /* + * Due the content of queue pointer have been + * reset to 0, the rss_info->conf.queue should + * be set NULL. + */ + rss_info->conf.queue = NULL; + rss_info->conf.queue_num = 0; + } + + /* set RSS func invalid after flushed */ + rss_info->conf.func = RTE_ETH_HASH_FUNCTION_MAX; return 0; } return -EINVAL; @@ -1651,6 +1677,10 @@ hns3_restore_rss_filter(struct rte_eth_dev *dev) if (hw->rss_info.conf.queue_num == 0) return 0; + /* When user flush all rules, it doesn't need to restore RSS rule */ + if (hw->rss_info.conf.func == RTE_ETH_HASH_FUNCTION_MAX) + return 0; + return hns3_config_rss_filter(dev, &hw->rss_info, true); }