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 C495241D8D for ; Mon, 27 Feb 2023 08:11:56 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id BE7B740A84; Mon, 27 Feb 2023 08:11:56 +0100 (CET) Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2052.outbound.protection.outlook.com [40.107.237.52]) by mails.dpdk.org (Postfix) with ESMTP id 4FA7E40A7D for ; Mon, 27 Feb 2023 08:11:55 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=SDPwe0tVrp469JPyp+Ji9DiW9nHL9dEcHjqN5Up8+/NlsaMgjBAHTKDpXmrwyFaHOz61OhTIv84lmqA0UjUsTgJC0NuXBe1c7zYQUPlrWdvufO4Mvd4eEMMKRT/TjTMutWsGoAnxdhw6C5qle7m1fv4HeCWwxNCBUZMw4hxMeDZZUhsF1e4sCBA2UnWsnuGuGkjBIqeOySR61hXiSV+/Xen/zPLpdTDgUiH+0r6gi7egiWu5YMJKmI0MK7ei0Xax/eTEo9qfocUHOEAixvLLuQ19n3dgyYA/ZeN5/cdbdet1S2pKhuqnfdpRpDIcQp+OQJYoRSF4ZqlRMXrUyq0h9g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=FE9+L7+s00PtCTBVOoNthyYyZFaOcTYRtn3qTdObBjI=; b=QgQ4UHZHrjez2GEailYt1drvnE3olPp9RtcM/AFLpgK8caHq+90pcEQS7V6NAKTnsbj8s3hYJ53sC9LoemX39gXuK+LydWRQQJOvVUr7aFbJMCGiCZMQzzA/4YPQT8YqtIDKjcIXsApDCkDiFd6Oo/fGTYqhD7C5bKttQ57qXOT+R3h4sFcdLOKQMfB0xJfwR1n2uwJlr6GJkqmuZ+wz3PoilsWDBP4V4aYtijoBm+4zvN7hmyWe6cuFw3U5BwBSSxCmAy6RRv85PzY64D8t1I0kW2zgLHJ5iyTQ2UKJwqDAFsFublgR7FrLPojpEzmw711D/Vkf1XsI3afwZNA7aQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) smtp.rcpttodomain=huawei.com smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=FE9+L7+s00PtCTBVOoNthyYyZFaOcTYRtn3qTdObBjI=; b=PAjusmHNDqtLIjxctbiL6Tx6fZbX6Q78cRQCoWqKfWY116IjEEjb4siSxmdvMumV45UzHPeiluGYe4FubNtkrTKGdOtmAeAXtH5DvNTYltdJ+7h3z4c8AP6GQaSLi4MMaOqZz3MkioxmXOf+Zz8W9NQ36BiQz+cxP3jpEdGR0QJZXWiRYXXv6c/XewrycK86yr66GkRO5AI+1/H9lBYhAF6CGDvYmuYJ8XLIjj6knu1mf3ykMFkBTUab+YaLgGK3vhAkv9Md+6ms8SUUGlltQMv6s4XYDsqP3CNnI0lBPAfvqsteHDu95KNbeUKctwOXe6huygnbR8KtfMqhdDiuDg== Received: from DM6PR06CA0020.namprd06.prod.outlook.com (2603:10b6:5:120::33) by DS0PR12MB7631.namprd12.prod.outlook.com (2603:10b6:8:11e::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6134.29; Mon, 27 Feb 2023 07:11:53 +0000 Received: from DM6NAM11FT027.eop-nam11.prod.protection.outlook.com (2603:10b6:5:120:cafe::87) by DM6PR06CA0020.outlook.office365.com (2603:10b6:5:120::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6134.29 via Frontend Transport; Mon, 27 Feb 2023 07:11:53 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.161) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.161 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.161; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.161) by DM6NAM11FT027.mail.protection.outlook.com (10.13.172.205) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6156.16 via Frontend Transport; Mon, 27 Feb 2023 07:11:53 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.36; Sun, 26 Feb 2023 23:11:43 -0800 Received: from nvidia.com (10.126.230.37) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.37; Sun, 26 Feb 2023 23:11:41 -0800 From: Xueming Li To: Huisong Li CC: Dongdong Liu , dpdk stable Subject: patch 'net/hns3: fix RSS key size compatibility' has been queued to stable release 22.11.2 Date: Mon, 27 Feb 2023 15:00:07 +0800 Message-ID: <20230227070107.15664-99-xuemingl@nvidia.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230227070107.15664-1-xuemingl@nvidia.com> References: <20230227062349.13764-1-xuemingl@nvidia.com> <20230227070107.15664-1-xuemingl@nvidia.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [10.126.230.37] X-ClientProxiedBy: rnnvmail202.nvidia.com (10.129.68.7) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6NAM11FT027:EE_|DS0PR12MB7631:EE_ X-MS-Office365-Filtering-Correlation-Id: db0a2179-3e17-43dc-c528-08db1891e777 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: YVHuOM9biE+Wov61wVm81fsRgjLl1YLBKoNA8JFMarycRsTYpC3MUncArbxf3afRDAM/OKGCIC0ag5wQd1mlfCBOY74sYfnZ4V2Q+2QO3paVMkocrfjIRl4FVWFONiRcrVBptWwAJpPIYjRL+1cpzrUU3qzsaD1CSvM+juh3kuXo6IiMWzaeXWrj0Cvl1132O7YwZ6xl1t54/oaNaBG0OzZL53bQkgBITXrsFmo9DSNcOHkH/hrUfF/AYugEb2qrEubLHqQvfzBPH2F+THJmEQo9PoJ3PqrehJ0JAbDLc+SeghIpp52vKAGRQsH3Glsby6VWKnBn0IZf0dzco5fgdy8Hg0weYVZ8n1mN+xDiB0AsiJUS7ggepJhrdgTo+Uy6svMNli0pc2LW00ELxEcpjybx9ocb+R2xRQgxPhTXw/B5An3ac8kED2z0KTUuxtNih5DIAkPKhZq/BW8VvgwQ1hv+9i0rSk9VaRXhLsks9LvHeYV+fzc95LWRzRNcPihMQSnN2Vz0yOUA3Q8nSu1wJClsxgGnnh3bc42abuZBxv4YZqCxgYJoIeXO/+LwxnHYKlV/9PXAXsqggqvQsZhgzmlrZ7Id/vU4p5D6lP+/8hDu7CK7cfo9QkYwfq2ZgYdA0sQ/6eoPLb6rZoJxvOZUVwqR+oa+MnNBuY4kerW2C30SW+KyFP2oAwCxkpbpzE2G2LP+34DUj2EXQrzjEd52QWtWs5d492AnbTZT2hGjOZg6IYKJq3uE7C50sNiKx5ETEEueL0PC2Kv/UJGCiYZUfbWFzKmeRY+NO6mlGdb7y4Bi3wzQKRbmENrO6zkBGJhS X-Forefront-Antispam-Report: CIP:216.228.117.161; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc6edge2.nvidia.com; CAT:NONE; SFS:(13230025)(4636009)(136003)(376002)(396003)(39860400002)(346002)(451199018)(36840700001)(46966006)(40470700004)(40460700003)(16526019)(6286002)(186003)(7636003)(82740400003)(83380400001)(356005)(8936002)(6916009)(4326008)(70586007)(70206006)(41300700001)(2906002)(36860700001)(5660300002)(8676002)(34020700004)(7696005)(55016003)(40480700001)(47076005)(478600001)(1076003)(426003)(26005)(6666004)(336012)(53546011)(966005)(2616005)(316002)(36756003)(82310400005)(86362001)(54906003); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Feb 2023 07:11:53.4361 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: db0a2179-3e17-43dc-c528-08db1891e777 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.117.161]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: DM6NAM11FT027.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR12MB7631 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 22.11.2 Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet. It will be pushed if I get no objections before 03/01/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://git.dpdk.org/dpdk-stable/log/?h=22.11-staging This queued commit can be viewed at: https://git.dpdk.org/dpdk-stable/commit/?h=22.11-staging&id=9126ed75beaa67eff3fb74cc1f920de488710d6c Thanks. Xueming Li --- >From 9126ed75beaa67eff3fb74cc1f920de488710d6c 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 Cc: Xueming Li [ 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_common.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_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) }; 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; @@ -896,6 +896,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 95609f8483..a18ec7650d 100644 --- a/drivers/net/hns3/hns3_flow.c +++ b/drivers/net/hns3/hns3_flow.c @@ -1406,10 +1406,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"); 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) return 0; } -static void -hns3_adjust_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) @@ -1485,9 +1475,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_adjust_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); @@ -1495,7 +1492,8 @@ hns3_hw_rss_hash_set(struct hns3_hw *hw, struct rte_flow_action_rss *rss_config) return ret; ret = hns3_rss_set_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 3db7bf0445..d6e0754273 100644 --- a/drivers/net/hns3/hns3_rss.c +++ b/drivers/net/hns3/hns3_rss.c @@ -316,7 +316,7 @@ hns3_rss_set_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_rss_set_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); @@ -754,8 +754,8 @@ hns3_rss_set_default_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++) @@ -788,9 +788,8 @@ hns3_config_rss(struct hns3_adapter *hns) break; } - /* Configure RSS hash algorithm and hash key */ - ret = hns3_rss_set_algo_key(hw, hw->rss_info.hash_algo, hash_key, - HNS3_RSS_KEY_SIZE); + ret = hns3_rss_set_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 b7f62ca1ee..d6f81996f4 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 @@ -41,7 +42,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.25.1 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2023-02-27 14:08:44.097650000 +0800 +++ 0100-net-hns3-fix-RSS-key-size-compatibility.patch 2023-02-27 14:08:40.839237000 +0800 @@ -1 +1 @@ -From 5172f9c464aa315a9d45b9177af71b4f99d55cdb Mon Sep 17 00:00:00 2001 +From 9126ed75beaa67eff3fb74cc1f920de488710d6c Mon Sep 17 00:00:00 2001 @@ -4,0 +5,3 @@ +Cc: Xueming Li + +[ upstream commit 5172f9c464aa315a9d45b9177af71b4f99d55cdb ] @@ -11 +13,0 @@ -Cc: stable@dpdk.org @@ -53 +55 @@ -index ac094c839f..de38a42048 100644 +index 95609f8483..a18ec7650d 100644