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 1C97A44144; Mon, 3 Jun 2024 10:26:38 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 0A62B42E16; Mon, 3 Jun 2024 10:26:38 +0200 (CEST) Received: from NAM02-SN1-obe.outbound.protection.outlook.com (mail-sn1nam02on2082.outbound.protection.outlook.com [40.107.96.82]) by mails.dpdk.org (Postfix) with ESMTP id 5EF8342E0D for ; Mon, 3 Jun 2024 10:26:36 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ZtnS0WAtw/tFnRANFoe3/RxwuOac/jSYlBAwr+CFmD7goudoC9TY3pUZYhdxvjNqTh4JqDCKfvsoy57DqKeglTs+jhC6AQEPIQcuijxOZC/7h/LkwXadjUxsxpPRgk/MB08MM2dVoslMqDSsHTcWZcJ95zBai8WOztrnDKLF+84Eaf3PSw+k+K3lk4NOjsZlzmwQZGCX5Ihbj4PQ/KhJm8vegWKEO8iIq5DsXQGkVf4oIfmaeQIGOOCrXiuelayCABXPHmtkJGNTOGOWRHMfsGOJ6fZdNvX05+9pS152sd1GycxiAB6nS7XZCGaww5eieECOgRRZRyXF0TEp7vCCYA== 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=eMgy0s9N78sZYHW09epMU9WPrdZUU+DRnaQmOWnz/d0=; b=JRB48XafyxAmVP2gZ9b0easkbr3bKvSQzFUHz96HXT8K7uzm3JBUAxWeiDcoHpxw3v0yRL4DJCr7yysmE/luGdrGYP3WLdXm4bBaSYymgn2AA7LGpocWHCKy9AJcdTPU0ij18EVWA0PzKYedki5jzDT6Iznel9RXF9INuYt5NBYWQYIm5VmIbFh2JifWUKpNop9IMFAP7B86k3p0wiW5w0O2TXcpl1TPpMKKwPMkS7U/WSSVGWoTs6RHBBwxhPaf1UF+tQnskT08CHGzn3UrkCK/xMxoVljNQ6oGhbwPzea8gwckBsPHOSGxY0jE18h7Yh+urlKAj7YZX6c/7KL7hA== 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=eMgy0s9N78sZYHW09epMU9WPrdZUU+DRnaQmOWnz/d0=; b=mrsp+ExGhxbrXpNOSFqDfzcizYJILj2+l+/kC8M7iGRLM9RFA9aWiUM246md2MBjl20I5rTlNMtRoL7lPU0XwFX9qrxgvSVN07d95ZYZK8fCCRQs4Ar1QAHX2mzAyMNQfxR8ultZP6BYKxak/NjjX3Ur+rExi9OwjC+3iZTYQZd8aF9qMlcymgaE9OE3y9AzFFcmqWHMQFJ7Oxf08E3hwYKJxbj7hSEy8mZ7HPVYr9hPW3O4WnpoTZ3Nv1Xk+VU4qyMp5ERI6o4hEJcGYGeB9v7eSCLHSEjPcHU/Pofgscku662Gi74X7N63/+0LAlex9PZ2RjVGIqYStBgT4vxznQ== Received: from CH2PR10CA0025.namprd10.prod.outlook.com (2603:10b6:610:4c::35) by MW4PR12MB7429.namprd12.prod.outlook.com (2603:10b6:303:21b::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7633.17; Mon, 3 Jun 2024 08:26:32 +0000 Received: from CH1PEPF0000AD7A.namprd04.prod.outlook.com (2603:10b6:610:4c:cafe::fc) by CH2PR10CA0025.outlook.office365.com (2603:10b6:610:4c::35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7633.30 via Frontend Transport; Mon, 3 Jun 2024 08:26:31 +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 CH1PEPF0000AD7A.mail.protection.outlook.com (10.167.244.59) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7633.15 via Frontend Transport; Mon, 3 Jun 2024 08:26:31 +0000 Received: from rnnvmail204.nvidia.com (10.129.68.6) 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, 3 Jun 2024 01:26:17 -0700 Received: from rnnvmail201.nvidia.com (10.129.68.8) by rnnvmail204.nvidia.com (10.129.68.6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Mon, 3 Jun 2024 01:26:16 -0700 Received: from nvidia.com (10.127.8.14) by mail.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 via Frontend Transport; Mon, 3 Jun 2024 01:26:14 -0700 From: Maayan Kashani To: CC: , , , Yevgeny Kliteynik , Viacheslav Ovsiienko , Ori Kam , Suanming Mou , Matan Azrad Subject: [PATCH v2 28/34] net/mlx5/hws: bwc - adding rules with larger action template Date: Mon, 3 Jun 2024 11:25:56 +0300 Message-ID: <20240603082601.4173-3-mkashani@nvidia.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20240603082601.4173-1-mkashani@nvidia.com> References: <20240602102937.197117-1-mkashani@nvidia.com> <20240603082601.4173-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: CH1PEPF0000AD7A:EE_|MW4PR12MB7429:EE_ X-MS-Office365-Filtering-Correlation-Id: 6476ca6f-7b8d-49da-c331-08dc83a6df93 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230031|1800799015|82310400017|376005|36860700004; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?YnM1Y6cVbOgev4/B0pK488c30AKedT+o00q4KgJHZBfec+f9nHrrKzFThK7c?= =?us-ascii?Q?mlKUfIPfSgrf9JkReKePwVsOUVuYkBlwQIMVSdT/k3lBD9cBe6OZH9GJgqov?= =?us-ascii?Q?owu7qhBF/tOVDUCrCr5HAdPkRwCD8qg6RcfdTr5M1GsdMk+fHcPTSBI1G3MQ?= =?us-ascii?Q?8+lUzBcPzHvzhRvaxqR1ybxqsd2NZMdHkdIfFJxkBWd6Vbyz7gBllRErE0+s?= =?us-ascii?Q?WG696uOUryX3PrNLlYDz7hWX73fKCR6Ym/MBDFzqzgubpZxTnWNSNcf1tCKv?= =?us-ascii?Q?4fYxKHLXt6rnTjKhAvIzB6yEM4oE+rZRsnsRFX7xsE34BKSa0afdHUy6d5yo?= =?us-ascii?Q?1H7eVKcr4qj2wLX3+Gw5s8l2ipYkVzWGUMXjtme1rk1tQ/Di84amt8WoH8li?= =?us-ascii?Q?EnRtgctKkoh4g4yQNJrTP7qy5olP6JupuHPO+0Jy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Cijhc8pCYAHjf2AC3LVhRtZyQfNXtRyUlSDqbQaps8uMQCG4pB5fV?= =?us-ascii?Q?PKhto/E=3D?= 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)(1800799015)(82310400017)(376005)(36860700004); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Jun 2024 08:26:31.6861 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 6476ca6f-7b8d-49da-c331-08dc83a6df93 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: CH1PEPF0000AD7A.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW4PR12MB7429 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 Current BWC implementation doesn't support a case when a rule is added with AT that requires more action STEs than any other AT that already exists on this matcher. This patch adds this support: if such AT is required, we will add the new AT and do full rehash to a new matcher that is created with all the action templates, including the new larger AT. Signed-off-by: Yevgeny Kliteynik --- drivers/net/mlx5/hws/mlx5dr_bwc.c | 68 ++++++++++++++++++++------- drivers/net/mlx5/hws/mlx5dr_matcher.c | 4 +- 2 files changed, 52 insertions(+), 20 deletions(-) diff --git a/drivers/net/mlx5/hws/mlx5dr_bwc.c b/drivers/net/mlx5/hws/mlx5dr_bwc.c index bfc7dbf100..8a8a143f17 100644 --- a/drivers/net/mlx5/hws/mlx5dr_bwc.c +++ b/drivers/net/mlx5/hws/mlx5dr_bwc.c @@ -712,7 +712,7 @@ mlx5dr_bwc_matcher_move(struct mlx5dr_bwc_matcher *bwc_matcher) } static int -mlx5dr_bwc_matcher_rehash(struct mlx5dr_bwc_matcher *bwc_matcher, bool rehash_size) +mlx5dr_bwc_matcher_rehash_size(struct mlx5dr_bwc_matcher *bwc_matcher) { uint32_t num_of_rules; int ret; @@ -730,8 +730,7 @@ mlx5dr_bwc_matcher_rehash(struct mlx5dr_bwc_matcher *bwc_matcher, bool rehash_si */ num_of_rules = rte_atomic_load_explicit(&bwc_matcher->num_of_rules, rte_memory_order_relaxed); - if (rehash_size && - !mlx5dr_bwc_matcher_rehash_size_needed(bwc_matcher, num_of_rules)) + if (!mlx5dr_bwc_matcher_rehash_size_needed(bwc_matcher, num_of_rules)) return 0; /* Now we're done all the checking - do the rehash: @@ -748,6 +747,19 @@ mlx5dr_bwc_matcher_rehash(struct mlx5dr_bwc_matcher *bwc_matcher, bool rehash_si return mlx5dr_bwc_matcher_move(bwc_matcher); } +static int +mlx5dr_bwc_matcher_rehash_at(struct mlx5dr_bwc_matcher *bwc_matcher) +{ + /* Rehash by action template doesn't require any additional checking. + * The bwc_matcher already contains the new action template. + * Just do the usual rehash: + * - create new matcher + * - move all the rules to the new matcher + * - destroy the old matcher + */ + return mlx5dr_bwc_matcher_move(bwc_matcher); +} + static struct mlx5dr_bwc_rule * mlx5dr_bwc_rule_create_root(struct mlx5dr_bwc_matcher *bwc_matcher, const struct rte_flow_item flow_items[], @@ -775,7 +787,6 @@ mlx5dr_bwc_rule_create_hws(struct mlx5dr_bwc_matcher *bwc_matcher, struct mlx5dr_bwc_rule *bwc_rule = NULL; struct mlx5dr_rule_attr rule_attr; rte_spinlock_t *queue_lock; - bool rehash_size = false; uint32_t num_of_rules; uint16_t idx; int at_idx; @@ -791,7 +802,7 @@ mlx5dr_bwc_rule_create_hws(struct mlx5dr_bwc_matcher *bwc_matcher, /* check if rehash needed due to missing action template */ at_idx = mlx5dr_bwc_matcher_find_at(bwc_matcher, rule_actions); - if (at_idx < 0) { + if (unlikely(at_idx < 0)) { /* we need to extend BWC matcher action templates array */ rte_spinlock_unlock(queue_lock); mlx5dr_bwc_lock_all_queues(ctx); @@ -810,13 +821,22 @@ mlx5dr_bwc_rule_create_hws(struct mlx5dr_bwc_matcher *bwc_matcher, ret = mlx5dr_matcher_attach_at(bwc_matcher->matcher, bwc_matcher->at[at_idx]); if (unlikely(ret)) { - mlx5dr_action_template_destroy(bwc_matcher->at[at_idx]); - bwc_matcher->at[at_idx] = NULL; - bwc_matcher->num_of_at--; - - mlx5dr_bwc_unlock_all_queues(ctx); - DR_LOG(ERR, "BWC rule: failed attaching action template - %d", ret); - return NULL; + /* Action template attach failed, possibly due to + * requiring more action STEs. + * Need to attempt creating new matcher with all + * the action templates, including the new one. + */ + ret = mlx5dr_bwc_matcher_rehash_at(bwc_matcher); + if (unlikely(ret)) { + mlx5dr_action_template_destroy(bwc_matcher->at[at_idx]); + bwc_matcher->at[at_idx] = NULL; + bwc_matcher->num_of_at--; + + mlx5dr_bwc_unlock_all_queues(ctx); + + DR_LOG(ERR, "BWC rule insertion: rehash AT failed - %d", ret); + return NULL; + } } mlx5dr_bwc_unlock_all_queues(ctx); @@ -826,9 +846,22 @@ mlx5dr_bwc_rule_create_hws(struct mlx5dr_bwc_matcher *bwc_matcher, /* check if number of rules require rehash */ num_of_rules = rte_atomic_load_explicit(&bwc_matcher->num_of_rules, rte_memory_order_relaxed); - if (mlx5dr_bwc_matcher_rehash_size_needed(bwc_matcher, num_of_rules)) { - rehash_size = true; - goto rehash; + if (unlikely(mlx5dr_bwc_matcher_rehash_size_needed(bwc_matcher, num_of_rules))) { + rte_spinlock_unlock(queue_lock); + + mlx5dr_bwc_lock_all_queues(ctx); + ret = mlx5dr_bwc_matcher_rehash_size(bwc_matcher); + mlx5dr_bwc_unlock_all_queues(ctx); + + if (ret) { + DR_LOG(ERR, "BWC rule insertion: rehash size [%d -> %d] failed - %d", + bwc_matcher->size_log - MLX5DR_BWC_MATCHER_SIZE_LOG_STEP, + bwc_matcher->size_log, + ret); + return NULL; + } + + rte_spinlock_lock(queue_lock); } bwc_rule = mlx5dr_bwc_rule_create_hws_sync(bwc_matcher, @@ -847,14 +880,13 @@ mlx5dr_bwc_rule_create_hws(struct mlx5dr_bwc_matcher *bwc_matcher, * It could be because there was collision, or some other problem. * If we don't dive deeper than API, the only thing we know is that * the status of completion is RTE_FLOW_OP_ERROR. - * Try rehash and insert rule again - last chance. + * Try rehash by size and insert rule again - last chance. */ -rehash: rte_spinlock_unlock(queue_lock); mlx5dr_bwc_lock_all_queues(ctx); - ret = mlx5dr_bwc_matcher_rehash(bwc_matcher, rehash_size); + ret = mlx5dr_bwc_matcher_rehash_size(bwc_matcher); mlx5dr_bwc_unlock_all_queues(ctx); if (ret) { diff --git a/drivers/net/mlx5/hws/mlx5dr_matcher.c b/drivers/net/mlx5/hws/mlx5dr_matcher.c index 2a84145566..aa5ab96d23 100644 --- a/drivers/net/mlx5/hws/mlx5dr_matcher.c +++ b/drivers/net/mlx5/hws/mlx5dr_matcher.c @@ -1347,7 +1347,7 @@ int mlx5dr_matcher_attach_at(struct mlx5dr_matcher *matcher, int ret; if (!matcher->attr.max_num_of_at_attach) { - DR_LOG(ERR, "Num of current at (%d) exceed allowed value", + DR_LOG(DEBUG, "Num of current at (%d) exceed allowed value", matcher->num_of_at); rte_errno = ENOTSUP; return -rte_errno; @@ -1359,7 +1359,7 @@ int mlx5dr_matcher_attach_at(struct mlx5dr_matcher *matcher, required_stes = at->num_of_action_stes - (!is_jumbo || at->only_term); if (matcher->action_ste.max_stes < required_stes) { - DR_LOG(ERR, "Required STEs [%d] exceeds initial action template STE [%d]", + DR_LOG(DEBUG, "Required STEs [%d] exceeds initial action template STE [%d]", required_stes, matcher->action_ste.max_stes); rte_errno = ENOMEM; return -rte_errno; -- 2.25.1