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 321BB428F8 for ; Sun, 9 Apr 2023 17:32:26 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 2B4DC410EE; Sun, 9 Apr 2023 17:32:26 +0200 (CEST) Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2074.outbound.protection.outlook.com [40.107.92.74]) by mails.dpdk.org (Postfix) with ESMTP id F169640A80 for ; Sun, 9 Apr 2023 17:32:24 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=SSQXB0QylZIcq4q5dAqB7KBWmB1M9B75DAGJaSt0Gcq9DxlrgYbYGEqJWV6kB8EoNRTYD3VhqQu6lQCDAsHXAt3vj0vwxsDM6PxexCWsL0JuL374+iuz+KGGDPhZODlCVNozLAswCB3aTm4deGpRZDyQeUlV+PyOTgPLoVFTnaKlD1mFYy4/Mnm7n/cttDsWVtvxBEZoAq/pG2+ZaSeir9pRa1v7Njcn0esi8XLN9z9Hk8NYVoHk/HbciFy1dqAWkwLj+VpG4VcTf7z9vOPW2KUYXE5GJQ/Am9IXVUtHEInK2r/r1EQbOI1c/DB9tRP58YX4nLlfIxsNOfh7Oezpdw== 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=cXsdxBgzoWUU9gBWB8gq/BOIA0dQnZG0EYpH+9l7+zw=; b=L1/xDl7y0JYlLJFHhEzH63ukIs4m2uRwTydJYjhbRHSlgS5VP5MolZfVPklAmdAKeC9xRBQ6q1CcRAUWhUAv/OVTxcWBNLftja9UY+SS0cm49p5I4HaRfQoMcclEbtt+BJyCAVDNqqUGfWXg9yyXVnbHHRIMEF3Y8k2tsibSLpLKuf38GK66FgKuoKG6ZYJVC3a5UG6oMb4FfEc3URZUjBabfF3lGjDh7Wq79q2qKF2AbqzOLM2WmMNilLvhCOqorExVw9n6NOZeNHN1I08gCuXgoe/2NNoM2f0ljJnaVnxCMOgmW1PpaIzAmxaWBE2fBsCOyrZDDgrrR3vHyMe0rA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) 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=cXsdxBgzoWUU9gBWB8gq/BOIA0dQnZG0EYpH+9l7+zw=; b=OT0Zyc3diCZ2CEhOndw1+id7nngvikIEqKghihQoKkeI82jAinnWsvKxPNCNdNPw4nxjSf5+dF7ZcgEZg9FTSUy615bWM7bBE7RiuTSEse46l4QjIca2umbg03mzGUuey4ToaT8D750Xx0py6144xu+jpFR5D5J05YOyg4KGMlKU75qWbSjo3EcwTMwhS+tgj7E08WFTsULHldmkpitOZTFLh4xkilME6glyntRpTfX4nBY9fFx6PMqw8iFzAM7ovYRIjSr2bgkFvSfwfOjVfYXlvCMF0XlYX58CA12sKMcYCZZnN0IeDuRFbRPJGN5Um5kXCN9IybbnDElmZaDzUA== Received: from MW4PR04CA0288.namprd04.prod.outlook.com (2603:10b6:303:89::23) by DM6PR12MB4563.namprd12.prod.outlook.com (2603:10b6:5:28e::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6277.38; Sun, 9 Apr 2023 15:32:23 +0000 Received: from CO1NAM11FT009.eop-nam11.prod.protection.outlook.com (2603:10b6:303:89:cafe::21) by MW4PR04CA0288.outlook.office365.com (2603:10b6:303:89::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6277.35 via Frontend Transport; Sun, 9 Apr 2023 15:32:23 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.160) 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.160 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.160; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.160) by CO1NAM11FT009.mail.protection.outlook.com (10.13.175.61) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6298.25 via Frontend Transport; Sun, 9 Apr 2023 15:32:22 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.5; Sun, 9 Apr 2023 08:32:11 -0700 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, 9 Apr 2023 08:32:10 -0700 From: Xueming Li To: Huisong Li CC: Dongdong Liu , dpdk stable Subject: patch 'net/hns3: separate setting hash algorithm' has been queued to stable release 22.11.2 Date: Sun, 9 Apr 2023 23:24:25 +0800 Message-ID: <20230409152529.5308-78-xuemingl@nvidia.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230409152529.5308-1-xuemingl@nvidia.com> References: <20230227062349.13764-1-xuemingl@nvidia.com> <20230409152529.5308-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: rnnvmail203.nvidia.com (10.129.68.9) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1NAM11FT009:EE_|DM6PR12MB4563:EE_ X-MS-Office365-Filtering-Correlation-Id: 9eacb5d0-e074-4d8f-8d3b-08db390f9cf2 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: cXaiUc/i5Bs1+pUR/TT2g4DpWYvvacbxPZbST7tAOxtqpICUWlvc9hYKKLLNnmLTCtYx1pdkhJYg56BW887YM9xCPca4aD5Nq9Z9OohDHEeRhBxAMHF2t/F6pEesSnAcqLpLovk7zDpZlDx+zUON1EcxRYvGRjCSlkgwmFgfNyoOuHjiDIcR1h948YXoc+zKq5AW12xMSJFXO+1BMXs2JI2SHgXM23I0VFS+vSkJi69lZObMCDT+BwOXC5M8FN3AvHVFSvDX9I+EPc2/cVoRQa3WldbDAOUBggV9j3pe13b7J5GIQ9/D73Ut5mL9mL6MMOk88dCxqNNnMg32HkTHXwqfK6KPqP9kNtjBWx/s9vIYZgTm0wB6g7b4ouKo0ZrWzsUBsku1NSqUffyIDyN+B+QpjLuK07qtVHOr6ecB1tkt8Kn+ZdD1HxMgFoRleUfp3V4gjVkqr3tpi7s4Nwg8IIQ78rJ4f6XQ8QugDMUOIMujy3j3eqak7sadmH+VSB1LobHgMEFb64UYTZKdxjblUVxKnxkqxiL7gLObFqjal25+k7cRaFcKweOFFtRzrvDgMwqcPsNc5/eLJds0FfrCgyB9cr0OJZxtiA0fsDaxMKtEnIGEtFSADvGg6XLXIumr7DUIe8XO9/kVSiqkIk8fCN32SfsuT1Kai7mCU3REPO4PXdWjdAQibfXLS6WGOrHPoOWL2wFvwOOcMdly0UrSZRP0JJX3aSUFwcj7/C2rXVNXGhqeRvcclpndmpJrkFR6L8tXpKHkJeo5VoqKURa/b7WVcStdCh6vP3zdvS4PeUhorTkZfCgqiVBSGDETnCuY3pmTH6v4KFO1hrCST82ABg== X-Forefront-Antispam-Report: CIP:216.228.117.160; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc6edge1.nvidia.com; CAT:NONE; SFS:(13230028)(4636009)(346002)(136003)(39860400002)(376002)(396003)(451199021)(46966006)(36840700001)(40470700004)(86362001)(36756003)(316002)(41300700001)(70586007)(8676002)(4326008)(6916009)(966005)(7696005)(70206006)(54906003)(478600001)(40480700001)(55016003)(82310400005)(5660300002)(2906002)(8936002)(36860700001)(82740400003)(356005)(7636003)(16526019)(6286002)(186003)(6666004)(53546011)(1076003)(26005)(336012)(2616005)(426003)(47076005)(83380400001)(40460700003); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Apr 2023 15:32:22.2553 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 9eacb5d0-e074-4d8f-8d3b-08db390f9cf2 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.160]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CO1NAM11FT009.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB4563 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 04/11/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/log/?h=22.11-staging/commit/9c24ae1b2df9e3875bd77de52ea8f5eb116a0190 Thanks. Xueming Li --- >From 9c24ae1b2df9e3875bd77de52ea8f5eb116a0190 Mon Sep 17 00:00:00 2001 From: Huisong Li Date: Fri, 10 Mar 2023 17:35:08 +0800 Subject: [PATCH] net/hns3: separate setting hash algorithm Cc: Xueming Li [ upstream commit 1fcbef5ccb993b6028a3f8a68a7b01f9b8c67413 ] Currently, the setting of hash algorithm comes from the default configuration in driver and the rte_flow interface. The hash algorithm that is set to hardware in both ways is saved in hw->rss_info.conf.func. But the 'func' in struct rte_flow_action_rss is usually used in rte flow interface. And the ethdev ops interface may also set hash algorithm in the future. It is not appropriate and is a little messy for ethdev ops interface and driver default configuration to use struct rte_flow_action_rss. So we have to separate the RSS configuration from ethdev ops and rte flow interface to make codes more easier to maintain. This patch separates hash algorithm by following ways: 1) 'hash_algo' in struct hns3_rss_conf is used for ethdev ops interface or default configuration in driver. 2) Add a 'rte_flow_hash_algo' field in struct hns3_rss_conf to save algorithm from rte flow interface. The main reasons are as follows: Currently, only the last rule is used to restore the rte flow rule. If 'func' in RSS action is 'DEFAULT', it means that this rule doesn't modify algorithm and driver need to save current algorithm for restoring algorithm during reset phase. Fixes: c37ca66f2b27 ("net/hns3: support RSS") Signed-off-by: Huisong Li Signed-off-by: Dongdong Liu --- drivers/net/hns3/hns3_flow.c | 60 +++++++++++++++++++++--------------- drivers/net/hns3/hns3_rss.c | 14 +-------- drivers/net/hns3/hns3_rss.h | 1 + 3 files changed, 37 insertions(+), 38 deletions(-) diff --git a/drivers/net/hns3/hns3_flow.c b/drivers/net/hns3/hns3_flow.c index e80ec0f053..0cb6914982 100644 --- a/drivers/net/hns3/hns3_flow.c +++ b/drivers/net/hns3/hns3_flow.c @@ -1438,30 +1438,40 @@ hns3_disable_rss(struct hns3_hw *hw) } static int -hns3_parse_rss_algorithm(struct hns3_hw *hw, enum rte_eth_hash_function *func, +hns3_parse_rss_algorithm(struct hns3_hw *hw, enum rte_eth_hash_function func, uint8_t *hash_algo) { - enum rte_eth_hash_function algo_func = *func; - switch (algo_func) { - case RTE_ETH_HASH_FUNCTION_DEFAULT: - /* Keep *hash_algo as what it used to be */ - algo_func = hw->rss_info.conf.func; - break; - case RTE_ETH_HASH_FUNCTION_TOEPLITZ: - *hash_algo = HNS3_RSS_HASH_ALGO_TOEPLITZ; - break; - case RTE_ETH_HASH_FUNCTION_SIMPLE_XOR: - *hash_algo = HNS3_RSS_HASH_ALGO_SIMPLE; - break; - case RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ: - *hash_algo = HNS3_RSS_HASH_ALGO_SYMMETRIC_TOEP; - break; - default: - hns3_err(hw, "Invalid RSS algorithm configuration(%d)", - algo_func); - return -EINVAL; + const uint8_t hash_func_map[] = { + [RTE_ETH_HASH_FUNCTION_DEFAULT] = HNS3_RSS_HASH_ALGO_TOEPLITZ, + [RTE_ETH_HASH_FUNCTION_TOEPLITZ] = HNS3_RSS_HASH_ALGO_TOEPLITZ, + [RTE_ETH_HASH_FUNCTION_SIMPLE_XOR] = HNS3_RSS_HASH_ALGO_SIMPLE, + [RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ] = HNS3_RSS_HASH_ALGO_SYMMETRIC_TOEP, + }; + uint8_t key[HNS3_RSS_KEY_SIZE_MAX] = {0}; + int ret; + + if (func == RTE_ETH_HASH_FUNCTION_DEFAULT) { + ret = hns3_rss_get_algo_key(hw, hash_algo, key, + hw->rss_key_size); + if (ret != 0) { + hns3_err(hw, "fail to get current RSS hash algorithm, ret = %d", + ret); + return ret; + } + + /* + * During the phase of reset recovery, the hash algorithm + * obtained from hardware may not be the one used(saved in + * rte_flow_hash_algo) when this rule is delivered. + */ + if (__atomic_load_n(&hw->reset.resetting, __ATOMIC_RELAXED) && + *hash_algo != hw->rss_info.rte_flow_hash_algo) + *hash_algo = hw->rss_info.rte_flow_hash_algo; + + return 0; } - *func = algo_func; + + *hash_algo = hash_func_map[func]; return 0; } @@ -1471,6 +1481,7 @@ 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; + uint8_t hash_algo; int ret; if (rss_config->key == NULL || rss_config->key_len != hw->rss_key_size) { @@ -1480,18 +1491,17 @@ hns3_hw_rss_hash_set(struct hns3_hw *hw, struct rte_flow_action_rss *rss_config) use_default_key = true; } - ret = hns3_parse_rss_algorithm(hw, &rss_config->func, - &hw->rss_info.hash_algo); + ret = hns3_parse_rss_algorithm(hw, rss_config->func, &hash_algo); if (ret) return ret; - ret = hns3_rss_set_algo_key(hw, hw->rss_info.hash_algo, + ret = hns3_rss_set_algo_key(hw, hash_algo, use_default_key ? rss_key : rss_config->key, hw->rss_key_size); if (ret) return ret; - hw->rss_info.conf.func = rss_config->func; + hw->rss_info.rte_flow_hash_algo = hash_algo; ret = hns3_set_rss_tuple_by_rss_hf(hw, rss_config->types); if (ret) diff --git a/drivers/net/hns3/hns3_rss.c b/drivers/net/hns3/hns3_rss.c index 7dc4e03d83..dcd42b554a 100644 --- a/drivers/net/hns3/hns3_rss.c +++ b/drivers/net/hns3/hns3_rss.c @@ -1022,7 +1022,7 @@ hns3_rss_set_default_args(struct hns3_hw *hw) uint16_t i; /* Default hash algorithm */ - rss_cfg->conf.func = RTE_ETH_HASH_FUNCTION_TOEPLITZ; + rss_cfg->hash_algo = HNS3_RSS_HASH_ALGO_TOEPLITZ; memcpy(rss_cfg->key, hns3_hash_key, RTE_MIN(sizeof(hns3_hash_key), hw->rss_key_size)); @@ -1046,18 +1046,6 @@ hns3_config_rss(struct hns3_adapter *hns) enum rte_eth_rx_mq_mode mq_mode = hw->data->dev_conf.rxmode.mq_mode; - switch (hw->rss_info.conf.func) { - case RTE_ETH_HASH_FUNCTION_SIMPLE_XOR: - hw->rss_info.hash_algo = HNS3_RSS_HASH_ALGO_SIMPLE; - break; - case RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ: - hw->rss_info.hash_algo = HNS3_RSS_HASH_ALGO_SYMMETRIC_TOEP; - break; - default: - hw->rss_info.hash_algo = HNS3_RSS_HASH_ALGO_TOEPLITZ; - break; - } - ret = hns3_rss_set_algo_key(hw, rss_cfg->hash_algo, hash_key, hw->rss_key_size); if (ret) diff --git a/drivers/net/hns3/hns3_rss.h b/drivers/net/hns3/hns3_rss.h index 17473e70e2..6e679b709b 100644 --- a/drivers/net/hns3/hns3_rss.h +++ b/drivers/net/hns3/hns3_rss.h @@ -42,6 +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 rte_flow_hash_algo; 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 */ -- 2.25.1 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2023-04-09 21:45:40.754105900 +0800 +++ 0077-net-hns3-separate-setting-hash-algorithm.patch 2023-04-09 21:45:38.689042200 +0800 @@ -1 +1 @@ -From 1fcbef5ccb993b6028a3f8a68a7b01f9b8c67413 Mon Sep 17 00:00:00 2001 +From 9c24ae1b2df9e3875bd77de52ea8f5eb116a0190 Mon Sep 17 00:00:00 2001 @@ -4,0 +5,3 @@ +Cc: Xueming Li + +[ upstream commit 1fcbef5ccb993b6028a3f8a68a7b01f9b8c67413 ] @@ -32 +34,0 @@ -Cc: stable@dpdk.org @@ -43 +45 @@ -index 881d70613c..2faeb9ca52 100644 +index e80ec0f053..0cb6914982 100644