From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id DC4D3A059F; Fri, 10 Apr 2020 13:11:03 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 514511D51D; Fri, 10 Apr 2020 13:10:11 +0200 (CEST) Received: from mail.chinasoftinc.com (unknown [114.113.233.8]) by dpdk.org (Postfix) with ESMTP id 07FA91D40F for ; Fri, 10 Apr 2020 13:10:07 +0200 (CEST) Received: from localhost.localdomain (114.119.4.74) by INCCAS002.ito.icss (10.168.0.60) with Microsoft SMTP Server id 14.3.487.0; Fri, 10 Apr 2020 19:09:43 +0800 From: "Wei Hu (Xavier)" To: Date: Fri, 10 Apr 2020 19:09:28 +0800 Message-ID: <20200410110930.15717-8-huwei013@chinasoftinc.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20200410110930.15717-1-huwei013@chinasoftinc.com> References: <20200410110930.15717-1-huwei013@chinasoftinc.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [114.119.4.74] Subject: [dpdk-dev] [PATCH 7/9] net/hns3: fix missing length of hash key when getting RSS X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" From: Lijun Ou 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 drvier does not return the actual value, error may coccur when user calls the rte_eth_dev_rss_hash_update API function to configure their own kye 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 --- drivers/net/hns3/hns3_rss.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/net/hns3/hns3_rss.c b/drivers/net/hns3/hns3_rss.c index 95a637ddc..a6cab29c9 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; -- 2.23.0