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 17DD244172; Thu, 6 Jun 2024 11:56:07 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id F3FC7410D3; Thu, 6 Jun 2024 11:56:06 +0200 (CEST) Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2074.outbound.protection.outlook.com [40.107.94.74]) by mails.dpdk.org (Postfix) with ESMTP id 29A2840EF0 for ; Thu, 6 Jun 2024 11:56:04 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=FWIOVHRgTphOyuspo9YMc30hRF5dDIsP0FnQTMG7fgzp7nQJIWmZe2bZrYjD/HIegPaskRI+WR0U7twehGo+ExF8vWBlLE7B3QvLs477ODmkemcCz5cn1tmoxiFr7wwXJxoYGvtqt4UdLDNSKHDMgAwpRQq2e1CQ5BV/MpjL2uoXwB6HCDju3fvR9g3EftDFh2+I+/DfvgaWMA/WXI5ttIbeWsrz0vH2CBL1jyKnsfLMDi4/7P1JTdqnUq0hr3rHqDehD3H6f7Utj1JVhnmf9M0eqqYIJtFrP8reKVPCIP04rsU+DH1TuQeztK2Jrz/unHMfQwqFfaHBD2jD+qZZ3Q== 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=1nG07SJJ7Xe3isN9Gp5TisH84z5uRNUzK8heqs6L8M0=; b=FmU4d7fRAgL2/PvpXusU5BQ75+AYBBlkuZ7twdcVRrkUdk/ajmyyChap1cA278UauDTEXkYHBER1nbk95WifAtJ47AHXuC1lGegH2PZX10AZG93GxpJOuD3XhbvPeAd63LnQOQsBUZ9Rhk2Y4U5MBA4dkoRje9ZM++EjwuOCMeLFgP4TREsKFlh1sxAEEoTKX1Gk93lk6Nj8p5GEFyKuAxuHTH+HOL+9k+z/UB46jYUgYKrdtkZoDFUwYfeEyRkDa0SwqYtdL8O5F+h6kNAgIimKnkJKzebgi14872wQkAO+6T5pw8ThDEzjb+/dwOhhfVk7SKx1zw2S3hKPIJAV3g== 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=1nG07SJJ7Xe3isN9Gp5TisH84z5uRNUzK8heqs6L8M0=; b=UN8C4odDefnsiVQbuWu+nozz4XXIsAjdQaATF6VnH7rx+9b5x9XCrDcpmamTxG8sdGS9CJWnSMhMNkDLUjhxBJy8L3pxpTwjcaPO81lkSejYBQFeVGoGWQqrzZX99Qylk2s9C7XI09S6a88d0x5rLNKzFWvwEB936iDdtP3YvDVgLHYwUQ/NKHowOfMXd6Z4baH0TqcvP/mnjr15m9os0NUeiKiPM2QxmGQevN2RuYxCfKpp0ARldHZYz348t0e9Z6lnAVsCBtejHDxCtlX1UXcWhgYintC88KE90POtmMCNtJCJWFCMpLbIsAZSxxFJB5VTnG++LyZXPgNcwULy2g== Received: from CH2PR04CA0003.namprd04.prod.outlook.com (2603:10b6:610:52::13) by CH2PR12MB4149.namprd12.prod.outlook.com (2603:10b6:610:7c::13) 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:01 +0000 Received: from CH1PEPF0000A34A.namprd04.prod.outlook.com (2603:10b6:610:52:cafe::4b) by CH2PR04CA0003.outlook.office365.com (2603:10b6:610:52::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7656.18 via Frontend Transport; Thu, 6 Jun 2024 09:56:01 +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 CH1PEPF0000A34A.mail.protection.outlook.com (10.167.244.5) 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:01 +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; Thu, 6 Jun 2024 02:55:44 -0700 Received: from rnnvmail203.nvidia.com (10.129.68.9) 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; Thu, 6 Jun 2024 02:55:43 -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:55:41 -0700 From: Maayan Kashani To: CC: , , , Yevgeny Kliteynik , Viacheslav Ovsiienko , Ori Kam , Suanming Mou , Matan Azrad Subject: [PATCH v4 3/7] net/mlx5/hws: bwc - adding rules with larger action template Date: Thu, 6 Jun 2024 12:55:11 +0300 Message-ID: <20240606095515.171170-4-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: CH1PEPF0000A34A:EE_|CH2PR12MB4149:EE_ X-MS-Office365-Filtering-Correlation-Id: 4a2d2744-cea0-42ed-c320-08dc860edf47 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230031|1800799015|36860700004|376005|82310400017; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?Ve6yBSbLaSB6MVAebxfhsvjSO7jyvuDumBu16WNXWL8Z5cloq2MxbnxnbZzB?= =?us-ascii?Q?Ez+6WhaO/OHRzGuWcWbF7kvxWvH6ooY5KE6iVwVZBjO+DSS40dg4U8e7ipJu?= =?us-ascii?Q?7an+2FBM4O/9iyPb7uzcmQOVCCKi38bXyIMVXJgj2hqXrmyv9fgv3Ti0pi5A?= =?us-ascii?Q?nEtN6oNqFtSoLf/i6qyyeU/tqodFT5o+0ALXWjpVBf5Scq4G6PLZyZqSMc9s?= =?us-ascii?Q?3UPW/4vKDXm+HefSmp/yTeiGG7PmMUm3xPz+LdBMrU1d6XMcFVYEmdd6Izgj?= =?us-ascii?Q?WoBXKfJlHcY4RZTcJKbFNm7v9wPODQP8YmMQ736ciQRKjlOmnnlW0BCj8ze5?= =?us-ascii?Q?bGhKAZWi4iRRk//bm8jdTo4k0w68ZIx9k8bQLCmF4/gv0fGzdqRXDIGNBquV?= =?us-ascii?Q?rRgWlVMaAzos3v4+1kUD+p0GEaAiSxiJCU4MPro0ooOEBGkVNbekqeV6885t?= =?us-ascii?Q?5MhPTCU96bWENRpbF3ihS95QzKDZulIUNm6ynf56d6JPmGSQ5YRMy69LcWM5?= =?us-ascii?Q?h8X54GgxJbf7rNJmuFWAu4uPepbq3CXgq+V0N2eD+/lsCprdTXaFzNiNlD4S?= =?us-ascii?Q?XW0br0cX8pAIPehKWFwOeJigEY3E/HGHl1UrPf7sWna4qFOX8i0B90o4IfzX?= =?us-ascii?Q?6YDjOScylSlpGg3OJiTdmJvIfHNaHxQI6v8oMvkufH0EjzSWLoPQafux5T8i?= =?us-ascii?Q?xkQXiQ/vFwfPFV/ZkE9lytjxcjDC/0/09u/E9AwhSFhLpeBucPjBbbj1EBq/?= =?us-ascii?Q?SfBZri1QivxnmnT6UH2PHtkYBBafbKEFXaf0/9W+lS20entOcga174FXTQHK?= =?us-ascii?Q?E/VHi/ogXvh+3WDLKjO8H+mmnJtN1kGka/T69uT/N4bF6fURPPC3V4b/KVv3?= =?us-ascii?Q?GLgZ/dlQw05ekEojTv27C0JiGneKV+6tKd5CCwpUwzinGZLzVTqTprA63bET?= =?us-ascii?Q?+wS49V2VKYFLHePoa9xyUL2XNZxs0pNqyCKCrCIAdjqckiDDoVuuoBPQCtLD?= =?us-ascii?Q?MVuFAsM1q9X9z1JZWM+oZ3LEjiYBRNleM183iX0Ic/rdqSYEgjrPDbr03cVY?= =?us-ascii?Q?/6jPBFzUTiT5VnWlxQBj5fca1BA91jz5w5h+xdEEQ9O8+oWNPmsplzxVx7it?= =?us-ascii?Q?nYcxO0NqLbtBQplbb2YriVMedsefPh+Nubl5pbwdOUP4mv80p/CBqIC/5RFi?= =?us-ascii?Q?Hz685WMkfjR09RZsFZ41W+kU13nnbZVpUPv2JSxDlxn87iQkinyoLBkjUcDL?= =?us-ascii?Q?8sP5aiUNHggoCpYn1o3cphYqvY6pibj7V6aO6prjmHKMLKW4VaoCUAJmSs42?= =?us-ascii?Q?FFitLk8xORy7BO/p67eTuHciPLXw4B0tAo1tAG9auppE2JZcCeMiqvouVGL6?= =?us-ascii?Q?/Kqyj47OQX0GeKltexhgrMAFqYegi+gHpO9BUn8wn1IULJ+9bg=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)(1800799015)(36860700004)(376005)(82310400017); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Jun 2024 09:56:01.1735 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 4a2d2744-cea0-42ed-c320-08dc860edf47 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: CH1PEPF0000A34A.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH2PR12MB4149 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 Acked-by: Dariusz Sosnowski --- 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.21.0