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 8549144145; Mon, 3 Jun 2024 12:57:11 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 8680142E7C; Mon, 3 Jun 2024 12:57:10 +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 68CE042E7C for ; Mon, 3 Jun 2024 12:57:08 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=MK/Vqau2Lp5ExWdhXlDkws4/Atqd9FF9+hTv3HPiemyG3LZ1Yomk8/6S3NO+FwtdavHReq6l3JiMwqns37l0NprHJAu0WZXyFAoFQ+PFFqzLbrnnTtx7Uwt4p3tKfl2MaPkFUr/yx2s/yL9xOZtvM9JmnM2341+o3zv5J/oo+SYbpIkVC9NzE9V7KIv2G69VKQbeWNmhlNjg7nDJRJx6QRI712liU8DAv5qzdmWVfX0YIGVdJV46uFCSNwE6/JgZUkMvyT3k/hHXU0nup3+btuZpOpuoA+0I7PtEbd+0WnCPkNlttMBZZJE4aJKKtWzxFkt/j9ycYjnJmoMmsRXaKA== 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=Vh6gCb8KwxxBlkLKJf9zz7khpPEyhJdvMp/SpygOPDygWe30Kz+K3v0nmbxxiuFQj36bKj0F9mZZNC2khmY2gcxFVz5zn/fHyQpfGWXbIADUuyE+ZZOwyqVG553oFUcF69+o+GVmb0Ep3vAz4WgcrvARRiHY4GkCnrIZ0oTv3WIQMVD+3NM8lY8hZN3QxtBD6c0vxwradDmPSbVcCzOlQnwDno/yodJLrRY+N6SqdP6JDWgIH653uRODZxR59f1U+xQus6Yh5Ro4G10ZVfHk/jrdGKHFV3Kp9Jl3GlgZlzrqkbqniIrdhiBzqEByV8AFFUjHZCU+PpYQBrlI/65wTQ== 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=eMgy0s9N78sZYHW09epMU9WPrdZUU+DRnaQmOWnz/d0=; b=Ls046MIrL+p54vPIaqQFOzJNw+KxLiZVW5Sj7Z9zqtvR90LqeNWnjLTYQH5NtBbjsAJzFxG/jl6ejlH2jqco9luvBbn7FC8gfkM6hHfBOJmmV1jTmStWDi298HvLqhNFP8P65WDSkUhipzXa8/SRkOaPxp4hOqnuyByNw9nTtuu0oimplvEFcMLYd9H5ap2yY4phey9z0jYD1qly8PStS1sOIhAeXkI0w1CM5NgwKDlfGAwb3n+qpluepYMO+4fb5ggigX5Q+WXc20lPDp+69xyHfCJXA14oNpZ4EK342C5+JxcaFxLu8JCHFvysMuW0f0ybZMd4VVnZs/Of4WeP3A== Received: from BY3PR10CA0028.namprd10.prod.outlook.com (2603:10b6:a03:255::33) by PH7PR12MB6694.namprd12.prod.outlook.com (2603:10b6:510:1b1::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7633.25; Mon, 3 Jun 2024 10:57:05 +0000 Received: from SJ1PEPF0000231B.namprd03.prod.outlook.com (2603:10b6:a03:255:cafe::86) by BY3PR10CA0028.outlook.office365.com (2603:10b6:a03:255::33) 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 10:57:05 +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 SJ1PEPF0000231B.mail.protection.outlook.com (10.167.242.232) 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 10:57:05 +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.1544.4; Mon, 3 Jun 2024 03:56:51 -0700 Received: from rnnvmail204.nvidia.com (10.129.68.6) 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, 3 Jun 2024 03:56:51 -0700 Received: from nvidia.com (10.127.8.14) by mail.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 via Frontend Transport; Mon, 3 Jun 2024 03:56:48 -0700 From: Maayan Kashani To: CC: , , , Yevgeny Kliteynik , Viacheslav Ovsiienko , Ori Kam , Suanming Mou , Matan Azrad Subject: [PATCH v3 3/7] net/mlx5/hws: bwc - adding rules with larger action template Date: Mon, 3 Jun 2024 13:56:30 +0300 Message-ID: <20240603105635.11124-3-mkashani@nvidia.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20240603105635.11124-1-mkashani@nvidia.com> References: <20240602102937.197117-1-mkashani@nvidia.com> <20240603105635.11124-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: SJ1PEPF0000231B:EE_|PH7PR12MB6694:EE_ X-MS-Office365-Filtering-Correlation-Id: 87f168f9-18cb-4ccb-d8e2-08dc83bbe7df X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230031|36860700004|376005|1800799015|82310400017; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?nssotLvFoZJ3Odpfs4TfHpyilYUiIHiLH58h06JdYlWSPSbCvpgXpdoya3dZ?= =?us-ascii?Q?1ocdGAwsYDzlxjGyzQ1F+Bjqje+QZlztCRfyHUu/2xY+rXAFOzRgjx7aw2gA?= =?us-ascii?Q?rlq5u+bPLx6eekKzNscX5b63BpneMl445WPUKCaRGfWcIvjNfwujD8aTHlAc?= =?us-ascii?Q?U9seo4EDosdYSsbquMNAAM6C1YgTdj1LtGJX3mo720qcLhCqu6UqtZDf8Y4m?= =?us-ascii?Q?82OyP2bjTpVBMyLMOtzu84VKqUAi7zAuKbhDgMZYPcJ3G9v9rHB48jvN5fDS?= =?us-ascii?Q?x2MB91iwafI3faPjCkgIleWxT4gR0nss1AqDrlqiv3+4dyoCHd1W+cK3tKSz?= =?us-ascii?Q?tAwlDnTPRp7ellCq9bg2q3/WFMGl1d74Z4UAtsYsO+b5HR1wfzd6qHAHwmwG?= =?us-ascii?Q?0fWZS4eDa9hxu57TN/KGxvxB7/kmHCqO0dJdiuu8HMxLN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eps5x1yibPT2GBEtwxGN0P1p6i1Af4Q71iPzAy31TBM?= =?us-ascii?Q?oSbXcfw=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)(36860700004)(376005)(1800799015)(82310400017); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Jun 2024 10:57:05.1785 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 87f168f9-18cb-4ccb-d8e2-08dc83bbe7df 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: SJ1PEPF0000231B.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB6694 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