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 0C07144172; Thu, 6 Jun 2024 11:56:40 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id D3E3142686; Thu, 6 Jun 2024 11:56:18 +0200 (CEST) Received: from NAM02-SN1-obe.outbound.protection.outlook.com (mail-sn1nam02on2085.outbound.protection.outlook.com [40.107.96.85]) by mails.dpdk.org (Postfix) with ESMTP id 3647D40ED2 for ; Thu, 6 Jun 2024 11:56:17 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=H6fM5fso9W5eN+9DHxOyZimyvAmgxul0hva2W8shTxE9W7UxRVSjHF1An2lkLKo5Qh05QW+J1fFUq95WJ5kleG7pxBEVdO59KPVX4/wW4AOWCFyNcJW6WoXrSzyMvvVuUEnkUeu5lxQSPexCaJr645el8Xq1glJRYB9xCttL5ZlJAaIvh67m70An7CWTQK9EVwzOt3yk7odef6+JHaFmn/znHMD366BnJgHH8IBp+eOmTAm60VTtyr0bJMBt0yBObcqUEMHWdktDwswtHkX4zUPlrFPJrGiUeN5Osgb+t6AEl7L/3vnEDBEQC/uISULdRjeHjkJFfaguxnAh7i067A== 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=WI7G+QcpqSLKBe1/ounhrc63Mw/2X+4UeqewrDAXn0g=; b=WrM9H6pzJWZdsim56tP7Yi1t8qEkLzOcb/tKFFqLJ8J3iKqxyNhwIm32ak7vqOvMtzUrJq+fwMlIr+Kzc6QAg5NT11RdPXPCw6aQUs77omUfGH3a5NWuYWRgKbs5PWdu0siISTUHNXMiGO8WxbWo4mRkEsRCCT699R7+5q3yzSrVaYq8bJTgYrA1TYOVR/MrcH6YefbAo8AyPSxWvfGL2wJGoYgIyL3idBZgZnp2c62ZCOVU2SFb/Bo6C4hqxGVe1aFL34umn045i9SmAwicubd1WlOf68JCdAGbd+1vLO7bUbMbUqhw9YQsU3BbWo6G7I+ENFfg55jMF802JqVWrA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) smtp.rcpttodomain=dpdk.org 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 (0) 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=WI7G+QcpqSLKBe1/ounhrc63Mw/2X+4UeqewrDAXn0g=; b=Dm4Z9+O74kby2zGChtUKHNoULIqqEj4jFJYOVAiRDSKoaA0tjn2wxm14d25U6Hr37qqDvoaLcgajfEcoXmY8DFF591YXi3HdWKOv9qsiy16BV4h0oT7dHSMufLXWdWG6mnj4u72R33yp45F2RQ/x1pqqT3uvz8uv9HaT2a8hLEIsTqZuH2J/bO/j7dN0rkWcIVdyFj2S4y/HLimE6x7ZEhRqjdl+22u9xdn5SrM4EowNm1WwSsUY+uKo33DfnltWbtswyUwJsZk6gP0du+jd7QYKCxnj0pUdLcLlUX/qKH/TT7Ppur7y4Y4aapMSw4c1F+qsffDeQKDIuQ9ejLFfWA== Received: from CH0PR13CA0055.namprd13.prod.outlook.com (2603:10b6:610:b2::30) by PH8PR12MB6841.namprd12.prod.outlook.com (2603:10b6:510:1c8::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7633.33; Thu, 6 Jun 2024 09:56:14 +0000 Received: from CH1PEPF0000A34B.namprd04.prod.outlook.com (2603:10b6:610:b2:cafe::e4) by CH0PR13CA0055.outlook.office365.com (2603:10b6:610:b2::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7677.9 via Frontend Transport; Thu, 6 Jun 2024 09:56:14 +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 CH1PEPF0000A34B.mail.protection.outlook.com (10.167.244.10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7633.15 via Frontend Transport; Thu, 6 Jun 2024 09:56:14 +0000 Received: from rnnvmail205.nvidia.com (10.129.68.10) 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.1544.4; Thu, 6 Jun 2024 02:56:03 -0700 Received: from rnnvmail203.nvidia.com (10.129.68.9) by rnnvmail205.nvidia.com (10.129.68.10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Thu, 6 Jun 2024 02:56:03 -0700 Received: from nvidia.com (10.127.8.14) by mail.nvidia.com (10.129.68.9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4 via Frontend Transport; Thu, 6 Jun 2024 02:56:00 -0700 From: Maayan Kashani To: CC: , , , Yevgeny Kliteynik , Viacheslav Ovsiienko , Ori Kam , Suanming Mou , Matan Azrad Subject: [PATCH v4 7/7] net/mlx5/hws: bwc - fix deleting action stes Date: Thu, 6 Jun 2024 12:55:15 +0300 Message-ID: <20240606095515.171170-8-mkashani@nvidia.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20240606095515.171170-1-mkashani@nvidia.com> References: <20240603105635.11124-1-mkashani@nvidia.com> <20240606095515.171170-1-mkashani@nvidia.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-NV-OnPremToCloud: ExternallySecured X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH1PEPF0000A34B:EE_|PH8PR12MB6841:EE_ X-MS-Office365-Filtering-Correlation-Id: f96ec878-3bb2-41d8-b34e-08dc860ee6ee X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230031|82310400017|1800799015|36860700004|376005; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?LHO97tAfJzHR2ItteGit3VuAGkF6USAIc0i8nBWx/eb4XVxSk3tLM6vtcHji?= =?us-ascii?Q?Uy831/gT9G9m5gkCBtfe+napjPht/bE4ywA2kbexPaJHbJVAR+uI2JiEK6SZ?= =?us-ascii?Q?8V3hl3fumGEHcf91Fw9f/SzHB1XnQaHiBQubiR3ri14U6neNqnQUr/OGA3FV?= =?us-ascii?Q?ytRTFh3h5NA+mRBWd+bnMv8rQgrgJO7bFtKAV1sGSW6roP7t8JUqbSypApbe?= =?us-ascii?Q?wnQfhioEHm/7TvKIbIyKWx/YWKVsGU0ppwVaiMGTc8vLw8ROFIobWUZ/GBV+?= =?us-ascii?Q?D7KUAF7Vd/HZ8MhMvJW7/D6X4Ack0nkTGo6L1rFbJ28cGw0A9XUa9RQVaFc5?= =?us-ascii?Q?ZEmn51QKlM2D5F+Tx18EsbLPa8dyws3e2Y4W6IolLCsTd5Ma81ggU1mc7Vsp?= =?us-ascii?Q?e8j5u7zNgHHdrVwbR+EFKK+YOrp+sP76+v1Tf3uVzOo4wUPxegeO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lBM84qNprHRM9ZAqw9TE8fe?= =?us-ascii?Q?A7mZanrjL4CDweKGwqmtdlwgTZMYXjibJwTNz4Hgmk4vML2MKw=3D=3D?= 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:(13230031)(82310400017)(1800799015)(36860700004)(376005); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Jun 2024 09:56:14.0272 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f96ec878-3bb2-41d8-b34e-08dc860ee6ee 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: CH1PEPF0000A34B.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH8PR12MB6841 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org From: Yevgeny Kliteynik If resized rule is deleted, the delete process also includes clearing the rule's resize_info. The problem is, this resize_info contains info on the action STEs that are freed onle when the completion of rule deletion received. This means that resize_info should be freed only after action STEs. This patch separates rule's resize_info saving and clearing into a separate calls. Saving of resize_info is done similar to saving of delete info (same as it was before this patch), and clearing is done only after mlx5dr_rule_free_action_ste_idx. Additional issue that is fixed here is using the right max_stes when calculating which STEs should be freed - max_stes is now saved as part of resize_info. Fixes: 762feceb8294 ("net/mlx5/hws: support resizable matchers") Signed-off-by: Yevgeny Kliteynik Acked-by: Dariusz Sosnowski --- drivers/net/mlx5/hws/mlx5dr_rule.c | 44 ++++++++++++++++++------------ drivers/net/mlx5/hws/mlx5dr_rule.h | 3 ++ drivers/net/mlx5/hws/mlx5dr_send.c | 8 ++++-- 3 files changed, 35 insertions(+), 20 deletions(-) diff --git a/drivers/net/mlx5/hws/mlx5dr_rule.c b/drivers/net/mlx5/hws/mlx5dr_rule.c index 550f00a4c1..74abb38163 100644 --- a/drivers/net/mlx5/hws/mlx5dr_rule.c +++ b/drivers/net/mlx5/hws/mlx5dr_rule.c @@ -157,6 +157,9 @@ static void mlx5dr_rule_save_resize_info(struct mlx5dr_rule *rule, struct mlx5dr_send_ste_attr *ste_attr) { + if (likely(!mlx5dr_matcher_is_resizable(rule->matcher))) + return; + rule->resize_info = simple_calloc(1, sizeof(*rule->resize_info)); if (unlikely(!rule->resize_info)) { assert(rule->resize_info); @@ -168,14 +171,16 @@ mlx5dr_rule_save_resize_info(struct mlx5dr_rule *rule, memcpy(rule->resize_info->data_seg, ste_attr->wqe_data, sizeof(rule->resize_info->data_seg)); + rule->resize_info->max_stes = rule->matcher->action_ste.max_stes; rule->resize_info->action_ste_pool = rule->matcher->action_ste.max_stes ? rule->matcher->action_ste.pool : NULL; } -static void mlx5dr_rule_clear_resize_info(struct mlx5dr_rule *rule) +void mlx5dr_rule_clear_resize_info(struct mlx5dr_rule *rule) { - if (rule->resize_info) { + if (unlikely(mlx5dr_matcher_is_resizable(rule->matcher) && + rule->resize_info)) { simple_free(rule->resize_info); rule->resize_info = NULL; } @@ -220,8 +225,6 @@ mlx5dr_rule_save_delete_info(struct mlx5dr_rule *rule, memcpy(&rule->tag.match, ste_attr->wqe_data->tag, MLX5DR_MATCH_TAG_SZ); return; } - - mlx5dr_rule_save_resize_info(rule, ste_attr); } static void @@ -231,11 +234,6 @@ mlx5dr_rule_clear_delete_info(struct mlx5dr_rule *rule) simple_free(rule->tag_ptr); return; } - - if (unlikely(mlx5dr_matcher_is_resizable(rule->matcher))) { - mlx5dr_rule_clear_resize_info(rule); - return; - } } static void @@ -288,19 +286,26 @@ void mlx5dr_rule_free_action_ste_idx(struct mlx5dr_rule *rule) { struct mlx5dr_matcher *matcher = rule->matcher; struct mlx5dr_pool *pool; + uint8_t max_stes; if (rule->action_ste_idx > -1 && !matcher->attr.optimize_using_rule_idx && !mlx5dr_matcher_is_insert_by_idx(matcher)) { struct mlx5dr_pool_chunk ste = {0}; + if (unlikely(mlx5dr_matcher_is_resizable(matcher))) { + /* Free the original action pool if rule was resized */ + max_stes = rule->resize_info->max_stes; + pool = rule->resize_info->action_ste_pool; + } else { + max_stes = matcher->action_ste.max_stes; + pool = matcher->action_ste.pool; + } + /* This release is safe only when the rule match part was deleted */ - ste.order = rte_log2_u32(matcher->action_ste.max_stes); + ste.order = rte_log2_u32(max_stes); ste.offset = rule->action_ste_idx; - /* Free the original action pool if rule was resized */ - pool = mlx5dr_matcher_is_resizable(matcher) ? rule->resize_info->action_ste_pool : - matcher->action_ste.pool; mlx5dr_pool_chunk_free(pool, &ste); } } @@ -442,9 +447,7 @@ static int mlx5dr_rule_create_hws_fw_wqe(struct mlx5dr_rule *rule, /* Send WQEs to FW */ mlx5dr_send_stes_fw(queue, &ste_attr); - /* Backup TAG on the rule for deletion, and save ctrl/data - * segments to be used when resizing the matcher. - */ + /* Backup TAG on the rule for deletion */ mlx5dr_rule_save_delete_info(rule, &ste_attr); mlx5dr_send_engine_inc_rule(queue); @@ -569,8 +572,10 @@ static int mlx5dr_rule_create_hws(struct mlx5dr_rule *rule, /* Backup TAG on the rule for deletion and resize info for * moving rules to a new matcher, only after insertion. */ - if (!is_update) + if (!is_update) { mlx5dr_rule_save_delete_info(rule, &ste_attr); + mlx5dr_rule_save_resize_info(rule, &ste_attr); + } mlx5dr_send_engine_inc_rule(queue); @@ -595,9 +600,12 @@ static void mlx5dr_rule_destroy_failed_hws(struct mlx5dr_rule *rule, /* Rule failed now we can safely release action STEs */ mlx5dr_rule_free_action_ste_idx(rule); - /* Clear complex tag or info that was saved for matcher resizing */ + /* Clear complex tag */ mlx5dr_rule_clear_delete_info(rule); + /* Clear info that was saved for resizing */ + mlx5dr_rule_clear_resize_info(rule); + /* If a rule that was indicated as burst (need to trigger HW) has failed * insertion we won't ring the HW as nothing is being written to the WQ. * In such case update the last WQE and ring the HW with that work diff --git a/drivers/net/mlx5/hws/mlx5dr_rule.h b/drivers/net/mlx5/hws/mlx5dr_rule.h index 33779ade48..3617fd59dd 100644 --- a/drivers/net/mlx5/hws/mlx5dr_rule.h +++ b/drivers/net/mlx5/hws/mlx5dr_rule.h @@ -44,6 +44,7 @@ struct mlx5dr_rule_resize_info { uint32_t rtc_1; uint32_t rule_idx; uint8_t state; + uint8_t max_stes; uint8_t ctrl_seg[MLX5DR_WQE_SZ_GTA_CTRL]; /* Ctrl segment of STE: 48 bytes */ uint8_t data_seg[MLX5DR_WQE_SZ_GTA_DATA]; /* Data segment of STE: 64 bytes */ }; @@ -74,6 +75,8 @@ int mlx5dr_rule_move_hws_add(struct mlx5dr_rule *rule, bool mlx5dr_rule_move_in_progress(struct mlx5dr_rule *rule); +void mlx5dr_rule_clear_resize_info(struct mlx5dr_rule *rule); + int mlx5dr_rule_create_root_no_comp(struct mlx5dr_rule *rule, const struct rte_flow_item items[], uint8_t num_actions, diff --git a/drivers/net/mlx5/hws/mlx5dr_send.c b/drivers/net/mlx5/hws/mlx5dr_send.c index 0120f03a48..3022c50260 100644 --- a/drivers/net/mlx5/hws/mlx5dr_send.c +++ b/drivers/net/mlx5/hws/mlx5dr_send.c @@ -523,9 +523,13 @@ static void mlx5dr_send_engine_update_rule(struct mlx5dr_send_engine *queue, */ priv->rule->status++; *status = RTE_FLOW_OP_SUCCESS; - /* Rule was deleted now we can safely release action STEs */ - if (priv->rule->status == MLX5DR_RULE_STATUS_DELETED) + /* Rule was deleted now we can safely release action STEs + * and clear resize info + */ + if (priv->rule->status == MLX5DR_RULE_STATUS_DELETED) { mlx5dr_rule_free_action_ste_idx(priv->rule); + mlx5dr_rule_clear_resize_info(priv->rule); + } } } } -- 2.21.0