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 A9D9343EDC for ; Mon, 22 Apr 2024 18:51:49 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id A3E4340A6C; Mon, 22 Apr 2024 18:51:49 +0200 (CEST) Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2049.outbound.protection.outlook.com [40.107.244.49]) by mails.dpdk.org (Postfix) with ESMTP id 5EE71402F1 for ; Mon, 22 Apr 2024 18:51:48 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=RH7UR64L2SRSlpPj63uO8gR/TmYbh81idbAxiEgr3okUUGYCkOdEfKYG2Hlt5BjrzkegRfykC0xk5nMt1wCwVVD7aJ+59+M52NRr5YasfJZDURVkYvH8USGPKXYIGsIi4QWHDIh97DMMbZS19yYqk462iCn513We0/F1fw4tO9cG+J2UBMRXCLFmtjrS7VLF2L9CLPJdyrBltv0HHO6knOXwrEZW2Ua0AhbDZs0HibSAa2Hm/B43ItKTNB+atvmUZu1eCKAul9loTWHZZs68V4OtjIx66EWoI0aEsLBuSYS/B15PSqAZ7OON4Fb920PL/Q1NkycXpZaxT30Sgdz/jw== 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=0iBQU/SRrA76pPrtVg4o83PtFrzQ/nPohSFgQcVR1n4=; b=d83BKkQexmlpL6gSr/L3mbPQSKZMw0tnpzTcFM9zeJUH655Y0iGcOwvpXtYYliR3qs8OfqCs/j8TVwBa9gEDEnyspmagrGb6VkiDY74V0Vh9bAg0HlhY5kCbOzLmUOjwbbOpnV5Hr7p5w8zLcI1u5jxv+7Y0TXa4E36mJrAzWVnzvmt8DpTR5n5n1ku01st7l2vjcZlxn+Zce6KIqcgii9e7anA8j+v5VzXsiVzWoRBhze20z83HPVD3LssvF22QGgB8J/yoNGWmz6b4e5FB60K2yEdTGrBnb6UETFyZb8DD1eZpL27LGAa3e8ldO7X7YndswF1b6kb+v3+vD69Tow== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) 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=0iBQU/SRrA76pPrtVg4o83PtFrzQ/nPohSFgQcVR1n4=; b=B1kMrqDbl7MYYZVrYTQ0LStMwDsbpE+RvL9wqI09hub6lirYaV4kL1B2iSgwmXjCIygAAlE7QHG45x1S7j/X1FJhmTL5oSEpmTLang+ZIVJIvJIMteFEQDLa1Yo48+6H3a6ED+5ePUcrBacKmKP0M0Di5NNz0EOo1vqEIRfihiEffwm4/IpWKn07i4PIkxjp5CCTnvcD9+BjtZUd34FFLIDXw8m3oMzPdlj5Up9rJiSOa3mZJ68+CZQVhJ16/fUp66JURVuFNGfMs5EKbhhqNfDSF3QgVNRtydDiOmBai0boBYimvVnoWpTlapwS3E5sx1aFSg8vNb8fz2e7EyZ0Tg== Received: from PH8P222CA0016.NAMP222.PROD.OUTLOOK.COM (2603:10b6:510:2d7::26) by IA1PR12MB6332.namprd12.prod.outlook.com (2603:10b6:208:3e2::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7472.44; Mon, 22 Apr 2024 16:51:38 +0000 Received: from CY4PEPF0000EDD3.namprd03.prod.outlook.com (2603:10b6:510:2d7:cafe::78) by PH8P222CA0016.outlook.office365.com (2603:10b6:510:2d7::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7495.34 via Frontend Transport; Mon, 22 Apr 2024 16:51:38 +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 CY4PEPF0000EDD3.mail.protection.outlook.com (10.167.241.207) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7519.19 via Frontend Transport; Mon, 22 Apr 2024 16:51:38 +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.1544.4; Mon, 22 Apr 2024 09:51:16 -0700 Received: from nvidia.com (10.126.230.35) 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.1544.4; Mon, 22 Apr 2024 09:51:14 -0700 From: Dariusz Sosnowski To: Viacheslav Ovsiienko , Ori Kam , Suanming Mou , Matan Azrad CC: Subject: [PATCH 23.11 2/3] net/mlx5: fix async flow create error handling Date: Mon, 22 Apr 2024 18:50:15 +0200 Message-ID: <20240422165016.197542-3-dsosnowski@nvidia.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240422165016.197542-1-dsosnowski@nvidia.com> References: <20240422165016.197542-1-dsosnowski@nvidia.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [10.126.230.35] 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: CY4PEPF0000EDD3:EE_|IA1PR12MB6332:EE_ X-MS-Office365-Filtering-Correlation-Id: dda19d78-aad6-4bfd-75e1-08dc62ec7a4f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?a2zcYfxb4f0sbeuvgoRP1jSEb62aJhuCY0vRhuHIzpsvuDq7uh+LWJpSeRSK?= =?us-ascii?Q?5Xai66FcJwBn25QwjhoGxhrn1PK1M71TuvGL6rf2bA0pmiZ+MJ6XWlMTMIX8?= =?us-ascii?Q?QplxOLxmBd6PXUA7DcnpWkYdSohVic3orpumcXjiOdM+aEHNWZhHyCm8YSMH?= =?us-ascii?Q?KW3syh3XnRHcx8w35vzLbzMRDMFaeL43TtXfUXyo5JZA6gzRVzE3qJ4NBrAq?= =?us-ascii?Q?09sXy3WHv/ObX9x3cQY3bvuHKM7D9h5IlsuHQKouZ2E74HhaliPjqNOQhZCI?= =?us-ascii?Q?f8DCGo/fbpBtoSSAOnBq8Kw32xbm6ZO5ZWkiAFzoeawBZ/8RBTBMazBlQI2k?= =?us-ascii?Q?1RcHzdGJQef1ODZED2yczrlu1DPR/aWTsDkmzrjfbHBJkf+lezFje/OUspCC?= =?us-ascii?Q?PtHXrMEBmYSkuTCH1v99uD0z7QKegWJbztbUkp9w2skFnx6sNSzzy7YFmdJq?= =?us-ascii?Q?0Dansrkt4J3h73Pl97SyR+K+4TDS+T9CMMKXgNT9JtjdU78w0YU07ix728xs?= =?us-ascii?Q?YvgHASf0mDalKxLLidawFvjJfnFApnRr/OevSG5dCBuH7SKTFpNohs+q4zBI?= =?us-ascii?Q?7cmk/CiBv5myRiKpHaYraflBnR+dG9OxrIuk2Pi87X0laFQaqXAgU+Kt1KSZ?= =?us-ascii?Q?yQ6B91kQYgnFoyy5atoQUAzoXbqrRDFxPsx4BXcRa+VrIAKgdaVYoF4Qnosj?= =?us-ascii?Q?MNBTB/mfKddsBUgGmGR050m8PHJZOh2lYBtvHyLPrvOqzGQKYuBKz9GkEHRN?= =?us-ascii?Q?VNFX356WX9Gv1IHtlrUVvgKExzrDRPD8vcYT8x1QB9zQ23b8Bl9p4x/ercvW?= =?us-ascii?Q?kUQ3hswcmAn05fyKfmvoRyWAU1ufIheaF/DRS+EBA49mHRuF1l2Dkv254Tdg?= =?us-ascii?Q?ovgaO5nadDyd32vTANlIhci3iJb5u8yjptA2A5wIad5YVARC0PSWJMJQnj9Y?= =?us-ascii?Q?TcL+Q8pWg1G/72SjKZbIKySAoxV8d7+X8BPR3tRpbDBUq1KjMbR4ClyCRolJ?= =?us-ascii?Q?8H/jeEpM+qzWr3jZyagQjDJZ/0iiNliNPQpUmRWnY8GPzDyZkC1ze7ZUKoSK?= =?us-ascii?Q?VQJGkiw/VkK7A8hUuOtXzijQWo5KA+iXlnqOSn2onXV50YKWHqS1Je8VKs/H?= =?us-ascii?Q?vtm1wc2VlhqpCrii/q5KT995gA9S565hoVsOdYSgBAK6D0zt/PgV+hY9p/Z2?= =?us-ascii?Q?UML+inhxsp+SBYbRnJ2fvNf+Lg4EvX2q5htsFjU0gQ3pzHOT/dC5zWlTi+fC?= =?us-ascii?Q?8RN+wIBApB7nyxiQ+ID3lSjbmtiCVPX2iQI6RLxUWgzlVi97ZNqoFf+Ave4i?= =?us-ascii?Q?LCuJeDEpW/WWt6wztZMmwCOkDqav8NNvoEwUYiGbfySFPyDv2uG4M/eUvsnY?= =?us-ascii?Q?dJoxWMSIVXFHghrIYtR6RqOVDGMY?= 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:(13230031)(36860700004)(376005)(1800799015)(82310400014); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Apr 2024 16:51:38.2194 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: dda19d78-aad6-4bfd-75e1-08dc62ec7a4f 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: CY4PEPF0000EDD3.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR12MB6332 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 [ upstream commit 5ecc8df4fad3411a53c20406f99b59dc736a6d1e ] Whenever processing of asynchronous flow rule create operation failed, but after some dynamic flow actions had already been allocated, these actions were not freed during error handling flow. That behavior lead to leaks e.g., RSS/QUEUE action objects were leaked which triggered assertions during device cleanup. This patch adds flow rule cleanup handling in case of an error during async flow rule creation. Fixes: 3a2f674b6aa8 ("net/mlx5: add queue and RSS HW steering action") Cc: stable@dpdk.org Signed-off-by: Dariusz Sosnowski Acked-by: Ori Kam --- drivers/net/mlx5/mlx5_flow_hw.c | 71 +++++++++++++++++++++++---------- 1 file changed, 51 insertions(+), 20 deletions(-) diff --git a/drivers/net/mlx5/mlx5_flow_hw.c b/drivers/net/mlx5/mlx5_flow_hw.c index 47fbbd0818..b51a4bb837 100644 --- a/drivers/net/mlx5/mlx5_flow_hw.c +++ b/drivers/net/mlx5/mlx5_flow_hw.c @@ -111,6 +111,10 @@ flow_hw_action_job_init(struct mlx5_priv *priv, uint32_t queue, enum mlx5_hw_job_type type, enum mlx5_hw_indirect_type indirect_type, struct rte_flow_error *error); +static void +flow_hw_age_count_release(struct mlx5_priv *priv, uint32_t queue, struct rte_flow_hw *flow, + struct rte_flow_error *error); + static int mlx5_tbl_multi_pattern_process(struct rte_eth_dev *dev, struct rte_flow_template_table *tbl, @@ -2865,6 +2869,30 @@ flow_hw_modify_field_construct(struct mlx5_hw_q_job *job, return 0; } +/** + * Release any actions allocated for the flow rule during actions construction. + * + * @param[in] flow + * Pointer to flow structure. + */ +static void +flow_hw_release_actions(struct rte_eth_dev *dev, + uint32_t queue, + struct rte_flow_hw *flow) +{ + struct mlx5_priv *priv = dev->data->dev_private; + struct mlx5_aso_mtr_pool *pool = priv->hws_mpool; + + if (flow->fate_type == MLX5_FLOW_FATE_JUMP) + flow_hw_jump_release(dev, flow->jump); + else if (flow->fate_type == MLX5_FLOW_FATE_QUEUE) + mlx5_hrxq_obj_release(dev, flow->hrxq); + if (mlx5_hws_cnt_id_valid(flow->cnt_id)) + flow_hw_age_count_release(priv, queue, flow, NULL); + if (flow->mtr_id) + mlx5_ipool_free(pool->idx_pool, flow->mtr_id); +} + /** * Construct flow action array. * @@ -2980,7 +3008,7 @@ flow_hw_actions_construct(struct rte_eth_dev *dev, (dev, queue, action, table, it_idx, at->action_flags, job->flow, &rule_acts[act_data->action_dst])) - return -1; + goto error; break; case RTE_FLOW_ACTION_TYPE_VOID: break; @@ -3000,7 +3028,7 @@ flow_hw_actions_construct(struct rte_eth_dev *dev, jump = flow_hw_jump_action_register (dev, &table->cfg, jump_group, NULL); if (!jump) - return -1; + goto error; rule_acts[act_data->action_dst].action = (!!attr.group) ? jump->hws_action : jump->root_action; job->flow->jump = jump; @@ -3012,7 +3040,7 @@ flow_hw_actions_construct(struct rte_eth_dev *dev, ft_flag, action); if (!hrxq) - return -1; + goto error; rule_acts[act_data->action_dst].action = hrxq->action; job->flow->hrxq = hrxq; job->flow->fate_type = MLX5_FLOW_FATE_QUEUE; @@ -3022,19 +3050,19 @@ flow_hw_actions_construct(struct rte_eth_dev *dev, if (flow_hw_shared_action_get (dev, act_data, item_flags, &rule_acts[act_data->action_dst])) - return -1; + goto error; break; case RTE_FLOW_ACTION_TYPE_VXLAN_ENCAP: enc_item = ((const struct rte_flow_action_vxlan_encap *) action->conf)->definition; if (flow_dv_convert_encap_data(enc_item, buf, &encap_len, NULL)) - return -1; + goto error; break; case RTE_FLOW_ACTION_TYPE_NVGRE_ENCAP: enc_item = ((const struct rte_flow_action_nvgre_encap *) action->conf)->definition; if (flow_dv_convert_encap_data(enc_item, buf, &encap_len, NULL)) - return -1; + goto error; break; case RTE_FLOW_ACTION_TYPE_RAW_ENCAP: raw_encap_data = @@ -3063,12 +3091,12 @@ flow_hw_actions_construct(struct rte_eth_dev *dev, hw_acts, action); if (ret) - return -1; + goto error; break; case RTE_FLOW_ACTION_TYPE_REPRESENTED_PORT: port_action = action->conf; if (!priv->hw_vport[port_action->port_id]) - return -1; + goto error; rule_acts[act_data->action_dst].action = priv->hw_vport[port_action->port_id]; break; @@ -3088,7 +3116,7 @@ flow_hw_actions_construct(struct rte_eth_dev *dev, jump = flow_hw_jump_action_register (dev, &table->cfg, aso_mtr->fm.group, NULL); if (!jump) - return -1; + goto error; MLX5_ASSERT (!rule_acts[act_data->action_dst + 1].action); rule_acts[act_data->action_dst + 1].action = @@ -3097,7 +3125,7 @@ flow_hw_actions_construct(struct rte_eth_dev *dev, job->flow->jump = jump; job->flow->fate_type = MLX5_FLOW_FATE_JUMP; if (mlx5_aso_mtr_wait(priv, aso_mtr, true)) - return -1; + goto error; break; case RTE_FLOW_ACTION_TYPE_AGE: age = action->conf; @@ -3112,7 +3140,7 @@ flow_hw_actions_construct(struct rte_eth_dev *dev, job->flow->res_idx, error); if (age_idx == 0) - return -rte_errno; + goto error; job->flow->age_idx = age_idx; if (at->action_flags & MLX5_FLOW_ACTION_INDIRECT_COUNT) /* @@ -3126,7 +3154,7 @@ flow_hw_actions_construct(struct rte_eth_dev *dev, cnt_queue = mlx5_hws_cnt_get_queue(priv, &queue); ret = mlx5_hws_cnt_pool_get(priv->hws_cpool, cnt_queue, &cnt_id, age_idx); if (ret != 0) - return ret; + goto error; ret = mlx5_hws_cnt_pool_get_action_offset (priv->hws_cpool, cnt_id, @@ -3134,7 +3162,7 @@ flow_hw_actions_construct(struct rte_eth_dev *dev, &rule_acts[act_data->action_dst].counter.offset ); if (ret != 0) - return ret; + goto error; job->flow->cnt_id = cnt_id; break; case MLX5_RTE_FLOW_ACTION_TYPE_COUNT: @@ -3145,7 +3173,7 @@ flow_hw_actions_construct(struct rte_eth_dev *dev, &rule_acts[act_data->action_dst].counter.offset ); if (ret != 0) - return ret; + goto error; job->flow->cnt_id = act_data->shared_counter.id; break; case RTE_FLOW_ACTION_TYPE_CONNTRACK: @@ -3153,7 +3181,7 @@ flow_hw_actions_construct(struct rte_eth_dev *dev, ((uint32_t)(uintptr_t)action->conf); if (flow_hw_ct_compile(dev, queue, ct_idx, &rule_acts[act_data->action_dst])) - return -1; + goto error; break; case MLX5_RTE_FLOW_ACTION_TYPE_METER_MARK: mtr_id = act_data->shared_meter.id & @@ -3161,7 +3189,7 @@ flow_hw_actions_construct(struct rte_eth_dev *dev, /* Find ASO object. */ aso_mtr = mlx5_ipool_get(pool->idx_pool, mtr_id); if (!aso_mtr) - return -1; + goto error; rule_acts[act_data->action_dst].action = pool->action; rule_acts[act_data->action_dst].aso_meter.offset = @@ -3176,7 +3204,7 @@ flow_hw_actions_construct(struct rte_eth_dev *dev, act_data->action_dst, action, rule_acts, &job->flow->mtr_id, MLX5_HW_INV_QUEUE); if (ret != 0) - return ret; + goto error; break; default: break; @@ -3214,6 +3242,11 @@ flow_hw_actions_construct(struct rte_eth_dev *dev, if (mlx5_hws_cnt_id_valid(hw_acts->cnt_id)) job->flow->cnt_id = hw_acts->cnt_id; return 0; + +error: + flow_hw_release_actions(dev, queue, job->flow); + rte_errno = EINVAL; + return -rte_errno; } static const struct rte_flow_item * @@ -3363,10 +3396,8 @@ flow_hw_async_flow_create(struct rte_eth_dev *dev, if (flow_hw_actions_construct(dev, job, &table->ats[action_template_index], pattern_template_index, actions, - rule_acts, queue, error)) { - rte_errno = EINVAL; + rule_acts, queue, error)) goto error; - } rule_items = flow_hw_get_rule_items(dev, table, items, pattern_template_index, job); if (!rule_items) -- 2.39.2