From: Lijun Ou Date: Fri, 10 Apr 2020 11:09:28 +0000 (+0800) Subject: net/hns3: fix RSS key length X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=708e60a4e63c872573e11befa9a073125395343d;p=dpdk.git net/hns3: fix RSS key length When upper application calls the rte_eth_dev_rss_hash_conf_get API function to get the RSS key parameters, the function should return the RSS key length supported by the device. Otherwise, an error will occur when the upper application needs to use the RSS key length supported by this specified hardware for judgment and configure the specified key into hardware. For example, in the following scenario: When users want to use their own RSS key, but the length of the key is bigger than the one of the supported by hardware. As a result, users need to get the RSS key length supported by hardware according to the above API firstly, and then compare the actual obtained RSS key length with the length of their own RSS key. If the driver does not return the actual value, error may occur when user calls the rte_eth_dev_rss_hash_update API function to configure their own key into hardware. Besides, this patch fixes the problem of stepping on memory when the RSS key array configured by users are less than the RSS key length supported by the driver at the same time. Fixes: c37ca66f2b27 ("net/hns3: support RSS") Cc: stable@dpdk.org Signed-off-by: Lijun Ou Signed-off-by: Wei Hu (Xavier) Signed-off-by: Chengwen Feng Signed-off-by: Chengchang Tang --- diff --git a/drivers/net/hns3/hns3_rss.c b/drivers/net/hns3/hns3_rss.c index 95a637ddc2..a6cab29c93 100644 --- a/drivers/net/hns3/hns3_rss.c +++ b/drivers/net/hns3/hns3_rss.c @@ -328,8 +328,10 @@ hns3_dev_rss_hash_conf_get(struct rte_eth_dev *dev, 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;