From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id ADC11A04FF for ; Thu, 5 May 2022 14:28:21 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 4E32542820; Thu, 5 May 2022 14:28:19 +0200 (CEST) Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by mails.dpdk.org (Postfix) with ESMTP id 41BC442830; Thu, 5 May 2022 14:28:17 +0200 (CEST) Received: from kwepemi500012.china.huawei.com (unknown [172.30.72.53]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4KvCXj5VzbzHnVD; Thu, 5 May 2022 20:23:33 +0800 (CST) Received: from localhost.localdomain (10.69.192.56) by kwepemi500012.china.huawei.com (7.221.188.12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Thu, 5 May 2022 20:28:14 +0800 From: "Min Hu (Connor)" To: CC: Huisong Li , , Min Hu , Yisen Zhuang , Lijun Ou , Ferruh Yigit , Chunsong Feng , Hao Chen Subject: [PATCH v2 6/7] net/hns3: fix undo rollback when update RSS hash Date: Thu, 5 May 2022 20:27:06 +0800 Message-ID: <20220505122707.61182-7-humin29@huawei.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20220505122707.61182-1-humin29@huawei.com> References: <20220406092240.52900-1-humin29@huawei.com> <20220505122707.61182-1-humin29@huawei.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [10.69.192.56] X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) To kwepemi500012.china.huawei.com (7.221.188.12) X-CFilter-Loop: Reflected X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org From: Huisong Li The RSS tuple isn't restored when RSS key length is invalid or setting algo key failed. This patch fixes it. Fixes: c37ca66f2b27 ("net/hns3: support RSS") Cc: stable@dpdk.org Signed-off-by: Huisong Li Signed-off-by: Min Hu (Connor) --- drivers/net/hns3/hns3_rss.c | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/drivers/net/hns3/hns3_rss.c b/drivers/net/hns3/hns3_rss.c index 1c703952b9..4b2c24ace4 100644 --- a/drivers/net/hns3/hns3_rss.c +++ b/drivers/net/hns3/hns3_rss.c @@ -376,9 +376,9 @@ int hns3_dev_rss_hash_update(struct rte_eth_dev *dev, struct rte_eth_rss_conf *rss_conf) { - struct hns3_adapter *hns = dev->data->dev_private; - struct hns3_hw *hw = &hns->hw; + struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private); struct hns3_rss_tuple_cfg *tuple = &hw->rss_info.rss_tuple_sets; + uint64_t rss_hf_bk = hw->rss_info.conf.types; uint8_t key_len = rss_conf->rss_key_len; uint64_t rss_hf = rss_conf->rss_hf; uint8_t *key = rss_conf->rss_key; @@ -387,27 +387,29 @@ hns3_dev_rss_hash_update(struct rte_eth_dev *dev, if (hw->rss_dis_flag) return -EINVAL; + if (key && key_len != HNS3_RSS_KEY_SIZE) { + hns3_err(hw, "the hash key len(%u) is invalid, must be %u", + key_len, HNS3_RSS_KEY_SIZE); + return -EINVAL; + } + rte_spinlock_lock(&hw->lock); ret = hns3_set_rss_tuple_by_rss_hf(hw, tuple, rss_hf); if (ret) - goto conf_err; + goto set_tuple_fail; if (key) { - if (key_len != HNS3_RSS_KEY_SIZE) { - hns3_err(hw, "The hash key len(%u) is invalid", - key_len); - ret = -EINVAL; - goto conf_err; - } ret = hns3_rss_set_algo_key(hw, key); if (ret) - goto conf_err; + goto set_algo_key_fail; } rte_spinlock_unlock(&hw->lock); return 0; -conf_err: +set_algo_key_fail: + (void)hns3_set_rss_tuple_by_rss_hf(hw, tuple, rss_hf_bk); +set_tuple_fail: rte_spinlock_unlock(&hw->lock); return ret; } -- 2.33.0