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 3CE7041D4F for ; Thu, 23 Feb 2023 10:39:31 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 32AC643158; Thu, 23 Feb 2023 10:39:31 +0100 (CET) Received: from mail-wm1-f48.google.com (mail-wm1-f48.google.com [209.85.128.48]) by mails.dpdk.org (Postfix) with ESMTP id 47A0943164 for ; Thu, 23 Feb 2023 10:39:29 +0100 (CET) Received: by mail-wm1-f48.google.com with SMTP id m14-20020a7bce0e000000b003e00c739ce4so7611795wmc.5 for ; Thu, 23 Feb 2023 01:39:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=2aRszjEmwpfbco24/cca8zb1TTWp4RPTPZEt/35zTro=; b=DhHRTOP8ElumI/4GOKanTDIfAcjT3luVc8eEN9FMmHzpQwozNExDc8ucXSyDKW8l15 R5Yk/Yk28OFznikGGeGv8ugYHSE/lsHDexBkcNzSCIz61U7gYLI1uBXQlWymi1TUAfDH mnTp6T6Wte/bvPPZHVOLHsByCfDs2pzcHa1qLN4nOjjJHKlRkcHUHMScgSoJ/b1Iy1lS WJkLDBQINUrhvf5VqfwU1//m7RPTiw8i9v8/AyNkp1G0hg60Xqyow6iTHN34UREEBV2e uOEF2GmTKyyJF8NNU/26lQPWyKj4L0bop9+t3fGr84TfCbWSiss++UF3H0/uo0oKrkmv WCOg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=2aRszjEmwpfbco24/cca8zb1TTWp4RPTPZEt/35zTro=; b=20aXIxdzfqzKF2QLssEXVN98974X1ci8P+hGJMb6+y8Vg1SZXql2fxffr4uyt28QoI E3amKzOY31xeh7ziF0oOa5Kr1VkohPFW4Jtq6KZ1DU7ZM+rtwIdtJmAstypcWYVAq0Wx 8Xdz6vZWB/IKlqUxOH1UHmbMiDvSivFyT98Y+dP0us1wO7U4508n8gsgcie50Z3kmOqY EnkVPb4FtnfeVsHzsobx7OBe3i6MOQa/ssvVdbkUJMQgXRcHpWXkSacc088vrXFK5xr8 VLQgua/twBH4H2tzDDxcbdjxtDwQvuzsY6ge5ZXiLH6gOIpWFuUZb7af5QoJs49xAOdT wXAQ== X-Gm-Message-State: AO0yUKVOUlt2Z/Oa4qI0hKK8vCIYWTO1jSL7OcfC8pyUeS8P0SqdCdNf NQoBY93cD47TL+0RGJ3W9le2cH+lFOpxEw== X-Google-Smtp-Source: AK7set97c7Ei4aNl/UiXW2NAk/8HKdyAOaDzyKAvN8BheWdMEexjV0E2yA1o16TJ38MjBcTZesZwAA== X-Received: by 2002:a05:600c:80f:b0:3df:e46f:c226 with SMTP id k15-20020a05600c080f00b003dfe46fc226mr7947396wmp.16.1677145168992; Thu, 23 Feb 2023 01:39:28 -0800 (PST) Received: from localhost ([137.220.119.58]) by smtp.gmail.com with ESMTPSA id l8-20020a05600c1d0800b003e6dcd562a6sm10925177wms.28.2023.02.23.01.39.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Feb 2023 01:39:28 -0800 (PST) From: luca.boccassi@gmail.com To: Huisong Li Cc: Dongdong Liu , dpdk stable Subject: patch 'net/hns3: fix RSS key size compatibility' has been queued to stable release 20.11.8 Date: Thu, 23 Feb 2023 09:36:45 +0000 Message-Id: <20230223093715.3926893-41-luca.boccassi@gmail.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230223093715.3926893-1-luca.boccassi@gmail.com> References: <20230223093715.3926893-1-luca.boccassi@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 Hi, FYI, your patch has been queued to stable release 20.11.8 Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet. It will be pushed if I get no objections before 02/25/23. So please shout if anyone has objections. Also note that after the patch there's a diff of the upstream commit vs the patch applied to the branch. This will indicate if there was any rebasing needed to apply to the stable branch. If there were code changes for rebasing (ie: not only metadata diffs), please double check that the rebase was correctly done. Queued patches are on a temporary branch at: https://github.com/bluca/dpdk-stable This queued commit can be viewed at: https://github.com/bluca/dpdk-stable/commit/b7baddb50f519a8e24252ca27630df10c1297897 Thanks. Luca Boccassi --- >From b7baddb50f519a8e24252ca27630df10c1297897 Mon Sep 17 00:00:00 2001 From: Huisong Li Date: Tue, 31 Jan 2023 21:02:54 +0800 Subject: [PATCH] net/hns3: fix RSS key size compatibility [ upstream commit 5172f9c464aa315a9d45b9177af71b4f99d55cdb ] For better compatibility, the RSS key size of PF and VF are obtained from firmware. However, the outdated HNS3_RSS_KEY_SIZE macro is still utilized in many locations as the key size. Fixes: 9c740336f024 ("net/hns3: get device specifications from firmware") Signed-off-by: Huisong Li Signed-off-by: Dongdong Liu --- drivers/net/hns3/hns3_ethdev.c | 12 +++++++++++- drivers/net/hns3/hns3_flow.c | 26 ++++++++++++-------------- drivers/net/hns3/hns3_rss.c | 23 +++++++++++------------ drivers/net/hns3/hns3_rss.h | 3 ++- 4 files changed, 36 insertions(+), 28 deletions(-) diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c index 4956290488..4c650e9a72 100644 --- a/drivers/net/hns3/hns3_ethdev.c +++ b/drivers/net/hns3/hns3_ethdev.c @@ -2606,7 +2606,7 @@ hns3_dev_infos_get(struct rte_eth_dev *eth_dev, struct rte_eth_dev_info *info) }; info->reta_size = hw->rss_ind_tbl_size; - info->hash_key_size = HNS3_RSS_KEY_SIZE; + info->hash_key_size = hw->rss_key_size; info->flow_type_rss_offloads = HNS3_ETH_RSS_SUPPORT; info->default_rxportconf.burst_size = HNS3_DEFAULT_PORT_CONF_BURST_SIZE; @@ -3045,6 +3045,16 @@ hns3_check_dev_specifications(struct hns3_hw *hw) return -EINVAL; } + if (hw->rss_key_size == 0 || hw->rss_key_size > HNS3_RSS_KEY_SIZE_MAX) { + hns3_err(hw, "the RSS key size obtained (%u) is invalid, and should not be zero or exceed the maximum(%u)", + hw->rss_key_size, HNS3_RSS_KEY_SIZE_MAX); + return -EINVAL; + } + + if (hw->rss_key_size > HNS3_RSS_KEY_SIZE) + hns3_warn(hw, "the RSS key size obtained (%u) is greater than the default key size (%u)", + hw->rss_key_size, HNS3_RSS_KEY_SIZE); + return 0; } diff --git a/drivers/net/hns3/hns3_flow.c b/drivers/net/hns3/hns3_flow.c index fedc3ee664..0ce4cd1e2a 100644 --- a/drivers/net/hns3/hns3_flow.c +++ b/drivers/net/hns3/hns3_flow.c @@ -1363,10 +1363,10 @@ hns3_parse_rss_filter(struct rte_eth_dev *dev, return rte_flow_error_set(error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ACTION_CONF, act, "a nonzero RSS encapsulation level is not supported"); - if (rss->key_len && rss->key_len != RTE_DIM(rss_conf->key)) + if (rss->key_len && rss->key_len != hw->rss_key_size) return rte_flow_error_set(error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ACTION_CONF, act, - "RSS hash key must be exactly 40 bytes"); + "invalid RSS key length"); /* * For Kunpeng920 and Kunpeng930 NIC hardware, it is not supported to @@ -1411,16 +1411,6 @@ hns3_disable_rss(struct hns3_hw *hw) return 0; } -static void -hns3_parse_rss_key(struct hns3_hw *hw, struct rte_flow_action_rss *rss_conf) -{ - if (rss_conf->key == NULL || rss_conf->key_len < HNS3_RSS_KEY_SIZE) { - hns3_warn(hw, "Default RSS hash key to be set"); - rss_conf->key = hns3_hash_key; - rss_conf->key_len = HNS3_RSS_KEY_SIZE; - } -} - static int hns3_parse_rss_algorithm(struct hns3_hw *hw, enum rte_eth_hash_function *func, uint8_t *hash_algo) @@ -1453,9 +1443,16 @@ hns3_parse_rss_algorithm(struct hns3_hw *hw, enum rte_eth_hash_function *func, static int hns3_hw_rss_hash_set(struct hns3_hw *hw, struct rte_flow_action_rss *rss_config) { + uint8_t rss_key[HNS3_RSS_KEY_SIZE_MAX] = {0}; + bool use_default_key = false; int ret; - hns3_parse_rss_key(hw, rss_config); + if (rss_config->key == NULL || rss_config->key_len != hw->rss_key_size) { + hns3_warn(hw, "Default RSS hash key to be set"); + memcpy(rss_key, hns3_hash_key, + RTE_MIN(sizeof(hns3_hash_key), hw->rss_key_size)); + use_default_key = true; + } ret = hns3_parse_rss_algorithm(hw, &rss_config->func, &hw->rss_info.hash_algo); @@ -1463,7 +1460,8 @@ hns3_hw_rss_hash_set(struct hns3_hw *hw, struct rte_flow_action_rss *rss_config) return ret; ret = hns3_set_rss_algo_key(hw, hw->rss_info.hash_algo, - rss_config->key, HNS3_RSS_KEY_SIZE); + use_default_key ? rss_key : rss_config->key, + hw->rss_key_size); if (ret) return ret; diff --git a/drivers/net/hns3/hns3_rss.c b/drivers/net/hns3/hns3_rss.c index e1bf8f36f1..c38e12f79d 100644 --- a/drivers/net/hns3/hns3_rss.c +++ b/drivers/net/hns3/hns3_rss.c @@ -316,7 +316,7 @@ hns3_set_rss_algo_key(struct hns3_hw *hw, uint8_t hash_algo, } } /* Update the shadow RSS key with user specified */ - memcpy(hw->rss_info.key, key, HNS3_RSS_KEY_SIZE); + memcpy(hw->rss_info.key, key, hw->rss_key_size); return 0; } @@ -498,9 +498,9 @@ hns3_dev_rss_hash_update(struct rte_eth_dev *dev, uint8_t *key = rss_conf->rss_key; int ret; - if (key && key_len != HNS3_RSS_KEY_SIZE) { + if (key && key_len != hw->rss_key_size) { hns3_err(hw, "the hash key len(%u) is invalid, must be %u", - key_len, HNS3_RSS_KEY_SIZE); + key_len, hw->rss_key_size); return -EINVAL; } @@ -511,7 +511,7 @@ hns3_dev_rss_hash_update(struct rte_eth_dev *dev, if (key) { ret = hns3_set_rss_algo_key(hw, hw->rss_info.hash_algo, - key, HNS3_RSS_KEY_SIZE); + key, hw->rss_key_size); if (ret) goto set_algo_key_fail; } @@ -547,9 +547,9 @@ 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 && 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; + if (rss_conf->rss_key && rss_conf->rss_key_len >= hw->rss_key_size) { + memcpy(rss_conf->rss_key, rss_cfg->key, hw->rss_key_size); + rss_conf->rss_key_len = hw->rss_key_size; } rte_spinlock_unlock(&hw->lock); @@ -759,8 +759,8 @@ hns3_set_default_rss_args(struct hns3_hw *hw) /* Default hash algorithm */ rss_cfg->conf.func = RTE_ETH_HASH_FUNCTION_TOEPLITZ; - /* Default RSS key */ - memcpy(rss_cfg->key, hns3_hash_key, HNS3_RSS_KEY_SIZE); + memcpy(rss_cfg->key, hns3_hash_key, + RTE_MIN(sizeof(hns3_hash_key), hw->rss_key_size)); /* Initialize RSS indirection table */ for (i = 0; i < hw->rss_ind_tbl_size; i++) @@ -793,9 +793,8 @@ hns3_config_rss(struct hns3_adapter *hns) break; } - /* Configure RSS hash algorithm and hash key */ - ret = hns3_set_rss_algo_key(hw, hw->rss_info.hash_algo, hash_key, - HNS3_RSS_KEY_SIZE); + ret = hns3_set_rss_algo_key(hw, rss_cfg->hash_algo, + hash_key, hw->rss_key_size); if (ret) return ret; diff --git a/drivers/net/hns3/hns3_rss.h b/drivers/net/hns3/hns3_rss.h index 630229796c..636b6fdf3a 100644 --- a/drivers/net/hns3/hns3_rss.h +++ b/drivers/net/hns3/hns3_rss.h @@ -29,6 +29,7 @@ #define HNS3_RSS_IND_TBL_SIZE 512 /* The size of hash lookup table */ #define HNS3_RSS_IND_TBL_SIZE_MAX 2048 #define HNS3_RSS_KEY_SIZE 40 +#define HNS3_RSS_KEY_SIZE_MAX 128 #define HNS3_RSS_SET_BITMAP_MSK 0xffff #define HNS3_RSS_HASH_ALGO_TOEPLITZ 0 @@ -45,7 +46,7 @@ struct hns3_rss_conf { /* RSS parameters :algorithm, flow_types, key, queue */ struct rte_flow_action_rss conf; uint8_t hash_algo; /* hash function type defined by hardware */ - uint8_t key[HNS3_RSS_KEY_SIZE]; /* Hash key */ + uint8_t key[HNS3_RSS_KEY_SIZE_MAX]; /* Hash key */ uint16_t rss_indirection_tbl[HNS3_RSS_IND_TBL_SIZE_MAX]; uint16_t queue[HNS3_RSS_QUEUES_BUFFER_NUM]; /* Queues indices to use */ bool valid; /* check if RSS rule is valid */ -- 2.39.1 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2023-02-23 09:36:29.880234847 +0000 +++ 0041-net-hns3-fix-RSS-key-size-compatibility.patch 2023-02-23 09:36:28.270170750 +0000 @@ -1 +1 @@ -From 5172f9c464aa315a9d45b9177af71b4f99d55cdb Mon Sep 17 00:00:00 2001 +From b7baddb50f519a8e24252ca27630df10c1297897 Mon Sep 17 00:00:00 2001 @@ -5,0 +6,2 @@ +[ upstream commit 5172f9c464aa315a9d45b9177af71b4f99d55cdb ] + @@ -11 +12,0 @@ -Cc: stable@dpdk.org @@ -16 +17 @@ - drivers/net/hns3/hns3_common.c | 12 +++++++++++- + drivers/net/hns3/hns3_ethdev.c | 12 +++++++++++- @@ -22,5 +23,5 @@ -diff --git a/drivers/net/hns3/hns3_common.c b/drivers/net/hns3/hns3_common.c -index 74d537d8d0..a0c9e66c2c 100644 ---- a/drivers/net/hns3/hns3_common.c -+++ b/drivers/net/hns3/hns3_common.c -@@ -130,7 +130,7 @@ hns3_dev_infos_get(struct rte_eth_dev *eth_dev, struct rte_eth_dev_info *info) +diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c +index 4956290488..4c650e9a72 100644 +--- a/drivers/net/hns3/hns3_ethdev.c ++++ b/drivers/net/hns3/hns3_ethdev.c +@@ -2606,7 +2606,7 @@ hns3_dev_infos_get(struct rte_eth_dev *eth_dev, struct rte_eth_dev_info *info) @@ -35 +36 @@ -@@ -896,6 +896,16 @@ hns3_check_dev_specifications(struct hns3_hw *hw) +@@ -3045,6 +3045,16 @@ hns3_check_dev_specifications(struct hns3_hw *hw) @@ -40,3 +41,3 @@ -+ hns3_err(hw, "the RSS key size obtained (%u) is invalid, and should not be zero or exceed the maximum(%u)", -+ hw->rss_key_size, HNS3_RSS_KEY_SIZE_MAX); -+ return -EINVAL; ++ hns3_err(hw, "the RSS key size obtained (%u) is invalid, and should not be zero or exceed the maximum(%u)", ++ hw->rss_key_size, HNS3_RSS_KEY_SIZE_MAX); ++ return -EINVAL; @@ -46,2 +47,2 @@ -+ hns3_warn(hw, "the RSS key size obtained (%u) is greater than the default key size (%u)", -+ hw->rss_key_size, HNS3_RSS_KEY_SIZE); ++ hns3_warn(hw, "the RSS key size obtained (%u) is greater than the default key size (%u)", ++ hw->rss_key_size, HNS3_RSS_KEY_SIZE); @@ -53 +54 @@ -index ac094c839f..de38a42048 100644 +index fedc3ee664..0ce4cd1e2a 100644 @@ -56 +57 @@ -@@ -1406,10 +1406,10 @@ hns3_parse_rss_filter(struct rte_eth_dev *dev, +@@ -1363,10 +1363,10 @@ hns3_parse_rss_filter(struct rte_eth_dev *dev, @@ -67,3 +68,3 @@ - if (!hns3_rss_input_tuple_supported(hw, rss)) - return rte_flow_error_set(error, EINVAL, -@@ -1443,16 +1443,6 @@ hns3_disable_rss(struct hns3_hw *hw) + /* + * For Kunpeng920 and Kunpeng930 NIC hardware, it is not supported to +@@ -1411,16 +1411,6 @@ hns3_disable_rss(struct hns3_hw *hw) @@ -74 +75 @@ --hns3_adjust_rss_key(struct hns3_hw *hw, struct rte_flow_action_rss *rss_conf) +-hns3_parse_rss_key(struct hns3_hw *hw, struct rte_flow_action_rss *rss_conf) @@ -86 +87 @@ -@@ -1485,9 +1475,16 @@ hns3_parse_rss_algorithm(struct hns3_hw *hw, enum rte_eth_hash_function *func, +@@ -1453,9 +1443,16 @@ hns3_parse_rss_algorithm(struct hns3_hw *hw, enum rte_eth_hash_function *func, @@ -94 +95 @@ -- hns3_adjust_rss_key(hw, rss_config); +- hns3_parse_rss_key(hw, rss_config); @@ -104 +105 @@ -@@ -1495,7 +1492,8 @@ hns3_hw_rss_hash_set(struct hns3_hw *hw, struct rte_flow_action_rss *rss_config) +@@ -1463,7 +1460,8 @@ hns3_hw_rss_hash_set(struct hns3_hw *hw, struct rte_flow_action_rss *rss_config) @@ -107 +108 @@ - ret = hns3_rss_set_algo_key(hw, hw->rss_info.hash_algo, + ret = hns3_set_rss_algo_key(hw, hw->rss_info.hash_algo, @@ -115 +116 @@ -index 3db7bf0445..d6e0754273 100644 +index e1bf8f36f1..c38e12f79d 100644 @@ -118 +119 @@ -@@ -316,7 +316,7 @@ hns3_rss_set_algo_key(struct hns3_hw *hw, uint8_t hash_algo, +@@ -316,7 +316,7 @@ hns3_set_rss_algo_key(struct hns3_hw *hw, uint8_t hash_algo, @@ -142 +143 @@ - ret = hns3_rss_set_algo_key(hw, hw->rss_info.hash_algo, + ret = hns3_set_rss_algo_key(hw, hw->rss_info.hash_algo, @@ -161 +162 @@ -@@ -754,8 +754,8 @@ hns3_rss_set_default_args(struct hns3_hw *hw) +@@ -759,8 +759,8 @@ hns3_set_default_rss_args(struct hns3_hw *hw) @@ -172 +173 @@ -@@ -788,9 +788,8 @@ hns3_config_rss(struct hns3_adapter *hns) +@@ -793,9 +793,8 @@ hns3_config_rss(struct hns3_adapter *hns) @@ -177 +178 @@ -- ret = hns3_rss_set_algo_key(hw, hw->rss_info.hash_algo, hash_key, +- ret = hns3_set_rss_algo_key(hw, hw->rss_info.hash_algo, hash_key, @@ -179 +180 @@ -+ ret = hns3_rss_set_algo_key(hw, rss_cfg->hash_algo, ++ ret = hns3_set_rss_algo_key(hw, rss_cfg->hash_algo, @@ -185 +186 @@ -index b7f62ca1ee..d6f81996f4 100644 +index 630229796c..636b6fdf3a 100644 @@ -196 +197 @@ -@@ -41,7 +42,7 @@ struct hns3_rss_conf { +@@ -45,7 +46,7 @@ struct hns3_rss_conf {