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 5CD3C43DE5 for ; Wed, 3 Apr 2024 10:38:59 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 52479402CE; Wed, 3 Apr 2024 10:38:59 +0200 (CEST) Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2085.outbound.protection.outlook.com [40.107.220.85]) by mails.dpdk.org (Postfix) with ESMTP id 520084025C for ; Wed, 3 Apr 2024 10:38:58 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=KQK5nJF/Cj5rMBQkguh9tYRk6RMqDGW2xBHi4bC0KG4m27NN8fHeG8bsIWwA3QuxKfxOfIAwkF/YQM+QCx6z0AKRjNrPq5g1L8ONmpp8wqDncNrnQ7ZUVEAuX5Yt3AmRAX0PDYkK2SKmEjSgHmbvNWZjta8CcVRYnu9ugpmt2nvzw8J1NV8pVHniN6eiwWRpjbjpjH5MPE810ABGv3Lk4v3gUTtNSwyb2UfZn8sSFjNQpvltGJVCciuS0A+/WBytlpD6Mj6i7fRRXtTVQAmZIDW+CStGrvVzpoVXkbbLmTTcixgpP6Xm8fyIch4r7fix/SHv1k1FPkoIdsQmxjrC6g== 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=QIH8n6OPZLYYI9p2P0TW0Tz2fAINycvdguaaj6eXZNg=; b=l8CZZGhtlXbfElfaZpx3KLJB0Dgm2HTmuQjiqbKQnBStysVQGqyGPLj2rZ10RRLjjIrwqec2s8IATktrvun08tWUbHl29fXEauqpPc+m9r7kjS7EiV2GkSog4RXTMehx/9RLkeDE/2Peays87JwFmIrAti3rG/SGGDZoqRb+/3ZDxB5NvH8xKAryBcZGxvVZW+V0C0O1M3daAXAAvEHx8mwg51XfyN1EU/DUcHfEmZhHSlePWWxIMZBk/1eJj6wDKLqI283pfXwdx+FSNZ12yVtzs77F8lPECWyfwOh6gzhKmC83hcdvp0gSsTF9bln6g0VHvU8Bczjzbg2gvATkTg== 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=QIH8n6OPZLYYI9p2P0TW0Tz2fAINycvdguaaj6eXZNg=; b=reA47oxArxnVfkrP+S+JBagzi6rd4WTuCzV6UpGlqe/4VgRy71BUEqmR1PBRomHi2RKdV/YaXuVrfGCm3qmVwkhUfTje7vNdUKsnpDX2Nxr/0IRSQu0LtRy5dzwecdMtccB//nueZmm7RitSfZ3ucnrzedzdqpD6Hlc8DbazYeh1eNu1wPso1Amfj7qofVDyzYEsvadO3vy9RXAIvFrJYtvj251gvCB413MNRXz7xE1skytNZYRm5rx41BUiMBemhxK3cMZ9kDAtg1qzQdJAy+A8xetBRwf0KaXZ3eaUm7Pq4k2KLLJATFm8LqWfhCSJfRUjqJhtr8lf3WLepntuaA== Received: from CH0PR13CA0025.namprd13.prod.outlook.com (2603:10b6:610:b1::30) by PH7PR12MB6720.namprd12.prod.outlook.com (2603:10b6:510:1b3::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7409.46; Wed, 3 Apr 2024 08:38:55 +0000 Received: from CH2PEPF00000144.namprd02.prod.outlook.com (2603:10b6:610:b1:cafe::8f) by CH0PR13CA0025.outlook.office365.com (2603:10b6:610:b1::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7292.11 via Frontend Transport; Wed, 3 Apr 2024 08:38:55 +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 CH2PEPF00000144.mail.protection.outlook.com (10.167.244.101) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7452.22 via Frontend Transport; Wed, 3 Apr 2024 08:38:55 +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.41; Wed, 3 Apr 2024 01:38:43 -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.1258.12; Wed, 3 Apr 2024 01:38:41 -0700 From: Dariusz Sosnowski To: Matan Azrad , Viacheslav Ovsiienko , Suanming Mou CC: , Ori Kam Subject: [PATCH 22.11] net/mlx5: fix async flow create error handling Date: Wed, 3 Apr 2024 10:38:05 +0200 Message-ID: <20240403083805.23622-1-dsosnowski@nvidia.com> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [10.126.230.35] 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: CH2PEPF00000144:EE_|PH7PR12MB6720:EE_ X-MS-Office365-Filtering-Correlation-Id: 04109b93-c633-4766-05f9-08dc53b97f92 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: iDfPQaTRwDGK9eytTZVDRk3fJlbyCyoP7JXY3tBdtVnrHQzFnb9t8m2Mlu+ZSYlvDRm+2yxzTzauOd3BJOwBDp7XyBV+zyuczZAd6PKTxGuTmmnWfEsQtAMdDu1g1Wk+l3oAFU8Uy9Dpp84KWpVOL6rZA/QtaKif5mkUdsLocPZPZzt00BsYuKPm5iF3n3yVDItM8cS4owfKcR2TQk5NVsvyVtrOitfjl8WaVJUjt7+AKY0ospFP+R46Qxv+uqu23u8AxMu/liQARCqY9I61q2d0lMwX8HG2SRMXyB4Hpz8ci/5E884VfhRxiHsogXZOLfJzfjAhV8aBh7DlWHIiBOaW8TEyovNdKG78UUAoy5XlhFUbHyaXTKB/w4XMSQYTydf5cj1tY7RH6tVO33E43agJnNxZXC1yTzmKBjaJodbDB9JUS1EqglDFjQe0tGpur2gVKgarjerqVNVzZ/qSGoi1zckclyzNQD0RXUaUR+rVD8przmn3tOp1t0DYOCdvaMkjZW5SFSRPMlcAWsCDnYw45dU22PXp/bmvcwa1Tdk9xGmFD8thUoSJop2p9Gfs0pak0H0STih1Z0UOZASF0tKyGWfBSZxHN0uBBO7ySOrLraVzP3scBqKKZsojGCt67VXT0TzgViZ+jAMM9CjGMST7uiGVwLEfwx2BqFGH9bfkbbALefHsTkArsZ2nL8/GD16tXDgJl8wPkO/rprjYpY01am/cy1kn9RQ0rFtVP2jE6Xvt6R2QGRVvWb1+++nt 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)(376005)(82310400014)(36860700004)(1800799015); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Apr 2024 08:38:55.2067 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 04109b93-c633-4766-05f9-08dc53b97f92 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: CH2PEPF00000144.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB6720 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 f4e125667f..87d29ec0da 100644 --- a/drivers/net/mlx5/mlx5_flow_hw.c +++ b/drivers/net/mlx5/mlx5_flow_hw.c @@ -72,6 +72,10 @@ flow_hw_set_vlan_vid_construct(struct rte_eth_dev *dev, static __rte_always_inline uint32_t flow_hw_tx_tag_regc_mask(struct rte_eth_dev *dev); static __rte_always_inline uint32_t flow_hw_tx_tag_regc_value(struct rte_eth_dev *dev); +static void +flow_hw_age_count_release(struct mlx5_priv *priv, uint32_t queue, struct rte_flow_hw *flow, + struct rte_flow_error *error); + const struct mlx5_flow_driver_ops mlx5_flow_hw_drv_ops; /* DR action flags with different table. */ @@ -2082,6 +2086,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. * @@ -2191,7 +2219,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; @@ -2211,7 +2239,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; @@ -2223,7 +2251,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; @@ -2233,19 +2261,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 = @@ -2267,12 +2295,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; @@ -2287,7 +2315,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 = @@ -2296,7 +2324,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->sh, MLX5_HW_INV_QUEUE, aso_mtr)) - return -1; + goto error; break; case RTE_FLOW_ACTION_TYPE_AGE: age = action->conf; @@ -2311,7 +2339,7 @@ flow_hw_actions_construct(struct rte_eth_dev *dev, job->flow->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) /* @@ -2325,7 +2353,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, @@ -2333,7 +2361,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: @@ -2344,7 +2372,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: @@ -2352,7 +2380,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 & @@ -2360,7 +2388,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 = @@ -2378,7 +2406,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; @@ -2411,6 +2439,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 * @@ -2553,10 +2586,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 free; - } rule_items = flow_hw_get_rule_items(dev, table, items, pattern_template_index, job); if (!rule_items) -- 2.39.2