From patchwork Tue Oct 15 16:35:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Kozyrev X-Patchwork-Id: 146022 X-Patchwork-Delegate: rasland@nvidia.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 8327F45B44; Tue, 15 Oct 2024 18:36:57 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 042594064C; Tue, 15 Oct 2024 18:36:53 +0200 (CEST) Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2073.outbound.protection.outlook.com [40.107.236.73]) by mails.dpdk.org (Postfix) with ESMTP id 3BE1E400D7 for ; Tue, 15 Oct 2024 18:36:50 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Ek7aSi2GSYPGVuLKIGqqDOnuUo0v3y8GsqOolxxs6FlE5rTCif7bgHGlAYzNVacJJruuPxoRCOsRhfORI/rgpWbv6bHdjrUWMWGVOXsdcEhz1FsbOoqT4QRfguvdlp3CJQ+c1CK1LocCnX138QjPXt1sAR4oGPRBTfDTE4KfKXd9vrhe4BZZCQJqwfOS49UFp9mt/nh6ZdPPOeCpnmv7diXHUxWKgbnS4euRoy9g9zcuI57wWyhJfPOcza1EFGQY9tO9u9MnxuozmHDX5j8ZGlXtz5Er2N1kAavDYWJZ/NqFc65703uzjRFRwhJ5Hiw+LVmYBmCZX3A4uP5rTUqIRQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=8Rq0xRfU6i6YHAnODTrzcKd0hEB8/f8k0Udq5/FrpEo=; b=HzRGaC2sD/l88tdmfc15LF0W49jBvquVX7Usmf8zq0CMPvbTjLPnAjCBhLfj/FvWdea0M/VZBk6609GEHDPuyB1mnFxxCNLsc6Ct8RTFstPtgEPytekkLK3ZzuHUDgyulFfPGqcNe+OCdq0ObfKZzGbKAGKB0IRdiq8Q/IcW4jNA7OV78mX7hE03i7CztXKKuq3muj18pXwYHHVAoLAkGsvuSZl5AERK94p+2uSMV6bm3F6doNLB/e511xkeG6TjCkxTMn9kC2Z9TYZeuq6g7wEV96CPyT7c586jUDC3XXUv00Ak8Y7IzwygcMLoba5zoqb1fGKsRoIl8na31q880g== 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=8Rq0xRfU6i6YHAnODTrzcKd0hEB8/f8k0Udq5/FrpEo=; b=RwlrLFOVuUToA9H8jzVpdobu3MwOdvNIxxlyBJA5TOh0UXH0UtQDtBllWfV80Lk0q4OukukvTIzEtjFBnRb9Gsq/qxsDNgM6yyDA7pAnPAi1/OlM/YP+bOj65ATQRGk141wrtYbXh06K7jG3KOhDQXANMzuxoz4gOKbjaoA9V9OL7oxP8jvDFZi1Yol/5pIBZ4ZavJliE91CVbSpGlb5DRPJgSJAhcj4/NxcxJVMoL/+rWwi9dunxD8/KsaTSN6vB3Sl8a/dnUZ+uStFlW21y68eaus3Ydzyzx6UD+W7VIbkIf6bFHwipzA9lD2Vby4nqK0J9Il2bL6PpRGnpP/eAQ== Received: from SJ0PR13CA0113.namprd13.prod.outlook.com (2603:10b6:a03:2c5::28) by CH2PR12MB4294.namprd12.prod.outlook.com (2603:10b6:610:a9::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.27; Tue, 15 Oct 2024 16:36:44 +0000 Received: from CO1PEPF000042A7.namprd03.prod.outlook.com (2603:10b6:a03:2c5:cafe::e1) by SJ0PR13CA0113.outlook.office365.com (2603:10b6:a03:2c5::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.17 via Frontend Transport; Tue, 15 Oct 2024 16:36:43 +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 CO1PEPF000042A7.mail.protection.outlook.com (10.167.243.36) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.17 via Frontend Transport; Tue, 15 Oct 2024 16:36:43 +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; Tue, 15 Oct 2024 09:36:25 -0700 Received: from pegasus01.mtr.labs.mlnx (10.126.231.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; Tue, 15 Oct 2024 09:36:22 -0700 From: Alexander Kozyrev To: CC: , , , , , , , , Subject: [PATCH 1/5] net/mlx5/hws: introduce new matcher type Date: Tue, 15 Oct 2024 19:35:53 +0300 Message-ID: <20241015163557.581447-1-akozyrev@nvidia.com> X-Mailer: git-send-email 2.18.2 MIME-Version: 1.0 X-Originating-IP: [10.126.231.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: CO1PEPF000042A7:EE_|CH2PR12MB4294:EE_ X-MS-Office365-Filtering-Correlation-Id: 590e2e66-b374-41e4-d099-08dced378dcf X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|82310400026|1800799024|376014|36860700013; X-Microsoft-Antispam-Message-Info: tDqeKysB4BkMF3X+QhSp478b9tiDhSNamEBYwmQ8TguV7lcjwaiJKaLaCuv1wUvh5tMw8xtEbGxA8BkvGbID+nGkmuNttY/5XerYBVPiw5diZ4SgcoOqQH/R2Ir0toWQxV8blFh+GhojCXo5vDGXzPmf9EJLl5pQGA/fsmD6jrTpZZPyv7F0v+bQCKHlUNTRzo4voWSvIsthR1qiHaWvFvO4kCff9ktwhF42kY8KjZ7ZJTCvzB2Pc3cxGlYAAHkKT4YzrfVMxHC348fvSplpYMc5EasVwfM3/07sksJa9HK3dmEP5ndoQFMjjOZLKyan0X6hWUJ3X9mttHMVJnk4kJAgdCNp4TFGTtXEqRaS0LkgiVOLme+LAgo4jOoKKs1S9bszQTrTeDi5+nRxts9Q/ERDkHcZxGOqoHsBbEVKr+jeo+/XyfOlDQ1S/98c4aIUoiQG5AD6FzG42AeFcnWTtjBjMMdsmBvjbrisuGUP1yCOvFYIcZRrBiaYEED3koqaHAH63+9kpO0T8JWfJA93oSZobtTr9bZ16OT68nxB2buogu3OaZfb9/TIHCyemM60idCjXA7wU1Dx5TqaSHHakEtoZOJRp5HMA5CB1vCU5hb6KonIQfGGVaWHFQKJNBpcmMziqRAFyuKX+Wu7lM0QT9q+o1QMm2+PF8o/Pmd2hMheKfvICzT7/YWvOQYwRu5Dn8ZxB0UOs1cSBN1TgGpy1vP0QNMtr54lx7CnL49E706pbUDnv/oQ7YTecHzBn78eqp6DkAopDLI0oUzTuA9ZX1Y8liN+0669zPTYIArgxwd9+hjuLycfbuauIpDkt3EhiuGSCotFC966Xuiz4vnG7hiqvRLx+X/uz1S56Jg+oPVX/pUU8EDEt6coRLGGyJhQAH0RV0Q3u66fwRmlrgRr3gpNt8iGXgA8BCd7T6K/7qUOXqHGV8qDdHtkjKjw5dCra2GJiPz61cHaROFGq52ILsd4qGZPHnu3VbygkRxTaPhiQHWkVjTPlhswdBxLJdWzOO0r2flrBIMIACzs3sy+mpjiuTu6MLns6JZDXEFt9Vm4qaczi7KUszj04J/HDuDL5qVuiatuwcnHoBIlQGXzUIoU/+oIjKrWNkB4PWkR82biNLuFW73Dt/vWjj2sDCLOZR+M2czJz4D6Si++2EU9ktKlHuHy6D0/A2jzwoaGRVghdV5qVnumh9gqZ+l2EbqOTBZBByd+OnSnw+9NQnV62fBZkKAU8wNbqx3ptqS010B31JZzhkPI9Yrr9p00NafJ4f5JM+fSW70h3rqrr4nJqXUGzeieZNfhn5Phe3b8aYus5/SV8wJPKC+SagpimJOPt/hEp3fIiqt/arikCOAVfw9cNX46mvPj2Zqw+DMQ/fVYOQfiyLDZXwIkvvKYky58 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:(13230040)(82310400026)(1800799024)(376014)(36860700013); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Oct 2024 16:36:43.6708 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 590e2e66-b374-41e4-d099-08dced378dcf 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: CO1PEPF000042A7.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH2PR12MB4294 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: Hamdan Igbaria introduce STE array matcher, where this matcher can only be isolated under a parent table and not chained to the table matchers chain. Signed-off-by: Hamdan Igbaria --- drivers/net/mlx5/hws/mlx5dr.h | 13 +++++- drivers/net/mlx5/hws/mlx5dr_debug.c | 12 +++++- drivers/net/mlx5/hws/mlx5dr_matcher.c | 58 +++++++++++++++++++++++-- drivers/net/mlx5/hws/mlx5dr_matcher.h | 6 +++ drivers/net/mlx5/hws/mlx5dr_rule.c | 2 +- drivers/net/mlx5/hws/mlx5dr_table.c | 61 +++++++++++++++++++-------- drivers/net/mlx5/hws/mlx5dr_table.h | 8 +++- drivers/net/mlx5/mlx5_flow_hw.c | 2 + 8 files changed, 135 insertions(+), 27 deletions(-) diff --git a/drivers/net/mlx5/hws/mlx5dr.h b/drivers/net/mlx5/hws/mlx5dr.h index 0fe39e9c76..8a1a389a3f 100644 --- a/drivers/net/mlx5/hws/mlx5dr.h +++ b/drivers/net/mlx5/hws/mlx5dr.h @@ -130,6 +130,14 @@ enum mlx5dr_matcher_distribute_mode { MLX5DR_MATCHER_DISTRIBUTE_BY_LINEAR = 0x1, }; +/* Match mode describes the behavior of the matcher STE's when a packet arrives */ +enum mlx5dr_matcher_match_mode { + /* Packet arriving at this matcher STE's will match according it's tag and match definer */ + MLX5DR_MATCHER_MATCH_MODE_DEFAULT = 0x0, + /* Packet arriving at this matcher STE's will always hit and perform the actions */ + MLX5DR_MATCHER_MATCH_MODE_ALWAYS_HIT = 0x1, +}; + enum mlx5dr_rule_hash_calc_mode { MLX5DR_RULE_HASH_CALC_MODE_RAW, MLX5DR_RULE_HASH_CALC_MODE_IDX, @@ -144,11 +152,14 @@ struct mlx5dr_matcher_attr { enum mlx5dr_matcher_resource_mode mode; /* Optimize insertion in case packet origin is the same for all rules */ enum mlx5dr_matcher_flow_src optimize_flow_src; - /* Define the insertion and distribution modes for this matcher */ + /* Define the insertion, distribution and match modes for this matcher */ enum mlx5dr_matcher_insert_mode insert_mode; enum mlx5dr_matcher_distribute_mode distribute_mode; + enum mlx5dr_matcher_match_mode match_mode; /* Define whether the created matcher supports resizing into a bigger matcher */ bool resizable; + /* This will imply that this matcher is not part of the matchers chain of parent table */ + bool isolated; union { struct { uint8_t sz_row_log; diff --git a/drivers/net/mlx5/hws/mlx5dr_debug.c b/drivers/net/mlx5/hws/mlx5dr_debug.c index 741a725842..f15ad96598 100644 --- a/drivers/net/mlx5/hws/mlx5dr_debug.c +++ b/drivers/net/mlx5/hws/mlx5dr_debug.c @@ -182,7 +182,7 @@ mlx5dr_debug_dump_matcher_attr(FILE *f, struct mlx5dr_matcher *matcher) struct mlx5dr_matcher_attr *attr = &matcher->attr; int ret; - ret = fprintf(f, "%d,0x%" PRIx64 ",%d,%d,%d,%d,%d,%d,%d,%d\n", + ret = fprintf(f, "%d,0x%" PRIx64 ",%d,%d,%d,%d,%d,%d,%d,%d,%d,%d\n", MLX5DR_DEBUG_RES_TYPE_MATCHER_ATTR, (uint64_t)(uintptr_t)matcher, attr->priority, @@ -192,7 +192,9 @@ mlx5dr_debug_dump_matcher_attr(FILE *f, struct mlx5dr_matcher *matcher) attr->optimize_using_rule_idx, attr->optimize_flow_src, attr->insert_mode, - attr->distribute_mode); + attr->distribute_mode, + attr->match_mode, + attr->isolated); if (ret < 0) { rte_errno = EINVAL; return rte_errno; @@ -377,6 +379,12 @@ static int mlx5dr_debug_dump_table(FILE *f, struct mlx5dr_table *tbl) return ret; } + LIST_FOREACH(matcher, &tbl->isolated_matchers, next) { + ret = mlx5dr_debug_dump_matcher(f, matcher); + if (ret) + return ret; + } + return 0; out_err: diff --git a/drivers/net/mlx5/hws/mlx5dr_matcher.c b/drivers/net/mlx5/hws/mlx5dr_matcher.c index dfa2cd435c..54460cc82b 100644 --- a/drivers/net/mlx5/hws/mlx5dr_matcher.c +++ b/drivers/net/mlx5/hws/mlx5dr_matcher.c @@ -198,6 +198,18 @@ static int mlx5dr_matcher_connect(struct mlx5dr_matcher *matcher) struct mlx5dr_matcher *tmp_matcher; int ret; + if (matcher->attr.isolated) { + LIST_INSERT_HEAD(&tbl->isolated_matchers, matcher, next); + ret = mlx5dr_table_connect_src_ft_to_miss_table(tbl, matcher->end_ft, + tbl->default_miss.miss_tbl); + if (ret) { + DR_LOG(ERR, "Failed to connect the new matcher to the miss_tbl"); + goto remove_from_list; + } + + return 0; + } + /* Find location in matcher list */ if (LIST_EMPTY(&tbl->head)) { LIST_INSERT_HEAD(&tbl->head, matcher, next); @@ -230,7 +242,7 @@ static int mlx5dr_matcher_connect(struct mlx5dr_matcher *matcher) } } else { /* Connect last matcher to next miss_tbl if exists */ - ret = mlx5dr_table_connect_to_miss_table(tbl, tbl->default_miss.miss_tbl); + ret = mlx5dr_table_connect_to_miss_table(tbl, tbl->default_miss.miss_tbl, true); if (ret) { DR_LOG(ERR, "Failed connect new matcher to miss_tbl"); goto remove_from_list; @@ -284,6 +296,11 @@ static int mlx5dr_matcher_disconnect(struct mlx5dr_matcher *matcher) struct mlx5dr_matcher *next; int ret; + if (matcher->attr.isolated) { + LIST_REMOVE(matcher, next); + return 0; + } + prev_ft = tbl->ft; prev_matcher = LIST_FIRST(&tbl->head); LIST_FOREACH(tmp_matcher, &tbl->head, next) { @@ -309,7 +326,7 @@ static int mlx5dr_matcher_disconnect(struct mlx5dr_matcher *matcher) goto matcher_reconnect; } } else { - ret = mlx5dr_table_connect_to_miss_table(tbl, tbl->default_miss.miss_tbl); + ret = mlx5dr_table_connect_to_miss_table(tbl, tbl->default_miss.miss_tbl, true); if (ret) { DR_LOG(ERR, "Failed to disconnect last matcher"); goto matcher_reconnect; @@ -518,14 +535,17 @@ static int mlx5dr_matcher_create_rtc(struct mlx5dr_matcher *matcher, } } else if (attr->insert_mode == MLX5DR_MATCHER_INSERT_BY_INDEX) { rtc_attr.update_index_mode = MLX5_IFC_RTC_STE_UPDATE_MODE_BY_OFFSET; - rtc_attr.num_hash_definer = 1; if (attr->distribute_mode == MLX5DR_MATCHER_DISTRIBUTE_BY_HASH) { /* Hash Split Table */ + if (mlx5dr_matcher_is_always_hit(matcher)) + rtc_attr.num_hash_definer = 1; + rtc_attr.access_index_mode = MLX5_IFC_RTC_STE_ACCESS_MODE_BY_HASH; rtc_attr.match_definer_0 = mlx5dr_definer_get_id(mt->definer); } else if (attr->distribute_mode == MLX5DR_MATCHER_DISTRIBUTE_BY_LINEAR) { /* Linear Lookup Table */ + rtc_attr.num_hash_definer = 1; rtc_attr.access_index_mode = MLX5_IFC_RTC_STE_ACCESS_MODE_LINEAR; rtc_attr.match_definer_0 = ctx->caps->linear_match_definer; } @@ -973,10 +993,17 @@ mlx5dr_matcher_validate_insert_mode(struct mlx5dr_cmd_query_caps *caps, if (attr->distribute_mode == MLX5DR_MATCHER_DISTRIBUTE_BY_HASH) { /* Hash Split Table */ - if (!caps->rtc_hash_split_table) { + if (attr->match_mode == MLX5DR_MATCHER_MATCH_MODE_ALWAYS_HIT && + !caps->rtc_hash_split_table) { DR_LOG(ERR, "FW doesn't support insert by index and hash distribute"); goto not_supported; } + + if (attr->match_mode == MLX5DR_MATCHER_MATCH_MODE_DEFAULT && + !attr->isolated) { + DR_LOG(ERR, "STE array matcher supported only as an isolated matcher"); + goto not_supported; + } } else if (attr->distribute_mode == MLX5DR_MATCHER_DISTRIBUTE_BY_LINEAR) { /* Linear Lookup Table */ if (!caps->rtc_linear_lookup_table || @@ -991,6 +1018,12 @@ mlx5dr_matcher_validate_insert_mode(struct mlx5dr_cmd_query_caps *caps, MLX5_IFC_RTC_LINEAR_LOOKUP_TBL_LOG_MAX); goto not_supported; } + + if (attr->match_mode != MLX5DR_MATCHER_MATCH_MODE_ALWAYS_HIT) { + DR_LOG(ERR, "Linear lookup tables will always hit, given match mode is not supported %d\n", + attr->match_mode); + goto not_supported; + } } else { DR_LOG(ERR, "Matcher has unsupported distribute mode"); goto not_supported; @@ -1032,6 +1065,11 @@ mlx5dr_matcher_process_attr(struct mlx5dr_cmd_query_caps *caps, DR_LOG(ERR, "Root matcher does not support resizing"); goto not_supported; } + if (attr->isolated) { + DR_LOG(ERR, "Root matcher can not be isolated"); + goto not_supported; + } + return 0; } @@ -1045,6 +1083,18 @@ mlx5dr_matcher_process_attr(struct mlx5dr_cmd_query_caps *caps, attr->insert_mode == MLX5DR_MATCHER_INSERT_BY_HASH) attr->table.sz_col_log = mlx5dr_matcher_rules_to_tbl_depth(attr->rule.num_log); + if (attr->isolated) { + if (attr->insert_mode != MLX5DR_MATCHER_INSERT_BY_INDEX || + attr->distribute_mode != MLX5DR_MATCHER_DISTRIBUTE_BY_HASH || + attr->match_mode != MLX5DR_MATCHER_MATCH_MODE_DEFAULT) { + DR_LOG(ERR, "Isolated matcher only supported for STE array matcher"); + goto not_supported; + } + + /* We reach here only in case of STE array */ + matcher->flags |= MLX5DR_MATCHER_FLAGS_STE_ARRAY; + } + matcher->flags |= attr->resizable ? MLX5DR_MATCHER_FLAGS_RESIZABLE : 0; return mlx5dr_matcher_check_attr_sz(caps, attr); diff --git a/drivers/net/mlx5/hws/mlx5dr_matcher.h b/drivers/net/mlx5/hws/mlx5dr_matcher.h index ca6a5298d9..ef42b7de6b 100644 --- a/drivers/net/mlx5/hws/mlx5dr_matcher.h +++ b/drivers/net/mlx5/hws/mlx5dr_matcher.h @@ -28,6 +28,7 @@ enum mlx5dr_matcher_flags { MLX5DR_MATCHER_FLAGS_COLLISION = 1 << 2, MLX5DR_MATCHER_FLAGS_RESIZABLE = 1 << 3, MLX5DR_MATCHER_FLAGS_COMPARE = 1 << 4, + MLX5DR_MATCHER_FLAGS_STE_ARRAY = 1 << 5, }; struct mlx5dr_match_template { @@ -146,6 +147,11 @@ static inline bool mlx5dr_matcher_is_insert_by_idx(struct mlx5dr_matcher *matche return matcher->attr.insert_mode == MLX5DR_MATCHER_INSERT_BY_INDEX; } +static inline bool mlx5dr_matcher_is_always_hit(struct mlx5dr_matcher *matcher) +{ + return matcher->attr.match_mode == MLX5DR_MATCHER_MATCH_MODE_ALWAYS_HIT; +} + int mlx5dr_matcher_free_rtc_pointing(struct mlx5dr_context *ctx, uint32_t fw_ft_type, enum mlx5dr_table_type type, diff --git a/drivers/net/mlx5/hws/mlx5dr_rule.c b/drivers/net/mlx5/hws/mlx5dr_rule.c index 5d66d81ea5..519328ccf3 100644 --- a/drivers/net/mlx5/hws/mlx5dr_rule.c +++ b/drivers/net/mlx5/hws/mlx5dr_rule.c @@ -539,7 +539,7 @@ static int mlx5dr_rule_create_hws(struct mlx5dr_rule *rule, * will always match and perform the specified actions, which * makes the tag irrelevant. */ - if (likely(!mlx5dr_matcher_is_insert_by_idx(matcher) && !is_update)) + if (likely(!mlx5dr_matcher_is_always_hit(matcher) && !is_update)) mlx5dr_definer_create_tag(items, mt->fc, mt->fc_sz, (uint8_t *)dep_wqe->wqe_data.action); else if (unlikely(is_update)) diff --git a/drivers/net/mlx5/hws/mlx5dr_table.c b/drivers/net/mlx5/hws/mlx5dr_table.c index ab73017ade..634b484a94 100644 --- a/drivers/net/mlx5/hws/mlx5dr_table.c +++ b/drivers/net/mlx5/hws/mlx5dr_table.c @@ -429,7 +429,7 @@ int mlx5dr_table_destroy(struct mlx5dr_table *tbl) { struct mlx5dr_context *ctx = tbl->ctx; pthread_spin_lock(&ctx->ctrl_lock); - if (!LIST_EMPTY(&tbl->head)) { + if (!LIST_EMPTY(&tbl->head) || !LIST_EMPTY(&tbl->isolated_matchers)) { DR_LOG(ERR, "Cannot destroy table containing matchers"); rte_errno = EBUSY; goto unlock_err; @@ -531,7 +531,7 @@ int mlx5dr_table_update_connected_miss_tables(struct mlx5dr_table *dst_tbl) return 0; LIST_FOREACH(src_tbl, &dst_tbl->default_miss.head, default_miss.next) { - ret = mlx5dr_table_connect_to_miss_table(src_tbl, dst_tbl); + ret = mlx5dr_table_connect_to_miss_table(src_tbl, dst_tbl, false); if (ret) { DR_LOG(ERR, "Failed to update source miss table, unexpected behavior"); return ret; @@ -541,34 +541,32 @@ int mlx5dr_table_update_connected_miss_tables(struct mlx5dr_table *dst_tbl) return 0; } -int mlx5dr_table_connect_to_miss_table(struct mlx5dr_table *src_tbl, - struct mlx5dr_table *dst_tbl) +int mlx5dr_table_connect_src_ft_to_miss_table(struct mlx5dr_table *src_tbl, + struct mlx5dr_devx_obj *ft, + struct mlx5dr_table *dst_tbl) { - struct mlx5dr_devx_obj *last_ft; struct mlx5dr_matcher *matcher; int ret; - last_ft = mlx5dr_table_get_last_ft(src_tbl); - if (dst_tbl) { if (LIST_EMPTY(&dst_tbl->head)) { - /* Connect src_tbl last_ft to dst_tbl start anchor */ - ret = mlx5dr_table_ft_set_next_ft(last_ft, + /* Connect src_tbl ft to dst_tbl start anchor */ + ret = mlx5dr_table_ft_set_next_ft(ft, src_tbl->fw_ft_type, dst_tbl->ft->id); if (ret) return ret; - /* Reset last_ft RTC to default RTC */ - ret = mlx5dr_table_ft_set_next_rtc(last_ft, + /* Reset ft RTC to default RTC */ + ret = mlx5dr_table_ft_set_next_rtc(ft, src_tbl->fw_ft_type, NULL, NULL); if (ret) return ret; } else { - /* Connect src_tbl last_ft to first matcher RTC */ + /* Connect src_tbl ft to first matcher RTC */ matcher = LIST_FIRST(&dst_tbl->head); - ret = mlx5dr_table_ft_set_next_rtc(last_ft, + ret = mlx5dr_table_ft_set_next_rtc(ft, src_tbl->fw_ft_type, matcher->match_ste.rtc_0, matcher->match_ste.rtc_1); @@ -576,24 +574,51 @@ int mlx5dr_table_connect_to_miss_table(struct mlx5dr_table *src_tbl, return ret; /* Reset next miss FT to default */ - ret = mlx5dr_table_ft_set_default_next_ft(src_tbl, last_ft); + ret = mlx5dr_table_ft_set_default_next_ft(src_tbl, ft); if (ret) return ret; } } else { /* Reset next miss FT to default */ - ret = mlx5dr_table_ft_set_default_next_ft(src_tbl, last_ft); + ret = mlx5dr_table_ft_set_default_next_ft(src_tbl, ft); if (ret) return ret; - /* Reset last_ft RTC to default RTC */ - ret = mlx5dr_table_ft_set_next_rtc(last_ft, + /* Reset ft RTC to default RTC */ + ret = mlx5dr_table_ft_set_next_rtc(ft, src_tbl->fw_ft_type, NULL, NULL); if (ret) return ret; } + return 0; +} + +int mlx5dr_table_connect_to_miss_table(struct mlx5dr_table *src_tbl, + struct mlx5dr_table *dst_tbl, + bool only_update_last_ft) +{ + struct mlx5dr_matcher *matcher; + struct mlx5dr_devx_obj *ft; + int ret; + + /* Connect last FT in the src_tbl matchers chain */ + ft = mlx5dr_table_get_last_ft(src_tbl); + ret = mlx5dr_table_connect_src_ft_to_miss_table(src_tbl, ft, dst_tbl); + if (ret) + return ret; + + if (!only_update_last_ft) { + /* Connect isolated matchers FT */ + LIST_FOREACH(matcher, &src_tbl->isolated_matchers, next) { + ft = matcher->end_ft; + ret = mlx5dr_table_connect_src_ft_to_miss_table(src_tbl, ft, dst_tbl); + if (ret) + return ret; + } + } + src_tbl->default_miss.miss_tbl = dst_tbl; return 0; @@ -633,7 +658,7 @@ int mlx5dr_table_set_default_miss(struct mlx5dr_table *tbl, pthread_spin_lock(&ctx->ctrl_lock); old_miss_tbl = tbl->default_miss.miss_tbl; - ret = mlx5dr_table_connect_to_miss_table(tbl, miss_tbl); + ret = mlx5dr_table_connect_to_miss_table(tbl, miss_tbl, false); if (ret) goto out; diff --git a/drivers/net/mlx5/hws/mlx5dr_table.h b/drivers/net/mlx5/hws/mlx5dr_table.h index b2fbb47416..32f2574a97 100644 --- a/drivers/net/mlx5/hws/mlx5dr_table.h +++ b/drivers/net/mlx5/hws/mlx5dr_table.h @@ -23,6 +23,7 @@ struct mlx5dr_table { uint32_t fw_ft_type; uint32_t level; LIST_HEAD(matcher_head, mlx5dr_matcher) head; + LIST_HEAD(isolated_matchers_head, mlx5dr_matcher) isolated_matchers; LIST_ENTRY(mlx5dr_table) next; struct mlx5dr_default_miss default_miss; }; @@ -54,7 +55,8 @@ void mlx5dr_table_destroy_default_ft(struct mlx5dr_table *tbl, struct mlx5dr_devx_obj *ft_obj); int mlx5dr_table_connect_to_miss_table(struct mlx5dr_table *src_tbl, - struct mlx5dr_table *dst_tbl); + struct mlx5dr_table *dst_tbl, + bool only_update_last_ft); int mlx5dr_table_update_connected_miss_tables(struct mlx5dr_table *dst_tbl); @@ -66,4 +68,8 @@ int mlx5dr_table_ft_set_next_rtc(struct mlx5dr_devx_obj *ft, struct mlx5dr_devx_obj *rtc_0, struct mlx5dr_devx_obj *rtc_1); +int mlx5dr_table_connect_src_ft_to_miss_table(struct mlx5dr_table *src_tbl, + struct mlx5dr_devx_obj *ft, + struct mlx5dr_table *dst_tbl); + #endif /* MLX5DR_TABLE_H_ */ diff --git a/drivers/net/mlx5/mlx5_flow_hw.c b/drivers/net/mlx5/mlx5_flow_hw.c index c5ddd1d404..b9807f347d 100644 --- a/drivers/net/mlx5/mlx5_flow_hw.c +++ b/drivers/net/mlx5/mlx5_flow_hw.c @@ -5157,6 +5157,8 @@ flow_hw_table_create(struct rte_eth_dev *dev, matcher_attr.optimize_using_rule_idx = true; matcher_attr.mode = MLX5DR_MATCHER_RESOURCE_MODE_RULE; matcher_attr.insert_mode = flow_hw_matcher_insert_mode_get(attr->insertion_type); + if (matcher_attr.insert_mode == MLX5DR_MATCHER_INSERT_BY_INDEX) + matcher_attr.match_mode = MLX5DR_MATCHER_MATCH_MODE_ALWAYS_HIT; if (attr->hash_func == RTE_FLOW_TABLE_HASH_FUNC_CRC16) { DRV_LOG(ERR, "16-bit checksum hash type is not supported"); rte_errno = ENOTSUP; From patchwork Tue Oct 15 16:35:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Kozyrev X-Patchwork-Id: 146021 X-Patchwork-Delegate: rasland@nvidia.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 4C27645B44; Tue, 15 Oct 2024 18:36:52 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id CD821400D7; Tue, 15 Oct 2024 18:36:51 +0200 (CEST) Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2072.outbound.protection.outlook.com [40.107.237.72]) by mails.dpdk.org (Postfix) with ESMTP id D8346400D6 for ; Tue, 15 Oct 2024 18:36:49 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=APe+VoGnE7xBp78BP5WA93vKb5/VsvBH61j5hy2gTHL89m/0ABuHZPAOwIKzyrpTTEk3lV02biv56nJijukwkTe4f6uzNAfZy5OyHXxdCg924IV8W/kpgK8Q7RzEu5Xtv41S8VXc4l1IFamwfe/cuDJ/p6Md6g0QBCpB8tIssMzcwUb3wnb6yGF7oSaEbYJz1/nZcGNfIjrvbeZXKyhwc+xSalp5qhsUjtc0wALLvC32ZbNfLgBa6l1LC5Ew2oVeBeeC/aJg/VjLgykPsraHBXM/rPerZyyQsmfThj7qaCBY8hfIGGJCgUt3ZMEJFd+0PhN9u1bllN9arW9GGSzkLQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=efdFdpgfHyldk74uvRDSpv9jWAsdlH0LRAHFIutdVsY=; b=uVyBF42ONPWGC993590l7TUpIcWVbE5wBMEXSVclsps2Jjz0pMa3Vefu326biNvr60KvY369mCPhUVzLq2AEpzQ2Jq7uTdNRuZlH1xcTuuwxCrdByrV7P6pArkzfyitGddl2AxwOx+yZ100ISO7Ty0Q7dlB7vceXJ8ftJlN4XyCVbpa/oCeBf1ZWWYIVFuawBYW6qIs2bhOowbmo9BN4EBTp9Epx4e2HujY1KlIImZStidRyJfwHOasceeqbuq0SJV+q/9J4XtDGIuTcy89PlqJ6zNFlGOc7J03ucpFvyyGZGPOXCkmN2SvhWbTiSl3O+0V+Nes/h2kVqEvqICMNHQ== 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=efdFdpgfHyldk74uvRDSpv9jWAsdlH0LRAHFIutdVsY=; b=p9c177WmDO/ssUwjyetn9eToRWQSM6OK6X8sAfbmCz+h2fNT5tNZmyUqHmIpZl9zRzlMO3snb3dlW95AGd8zLgA0hqnEmrNkK0foYUgxcx2l6t+GxvopYuYBQ8o7b0NnrHKvde/7IhmQbJo8IwBC87dd0wEJK/OudsnseJqlXpTKdHIiLG8IhYNCByljinIvdQ2HcFst1967JFmQCwc1ZIQsBNf75a14uc9ZAU1F9vE3kQi8f55P5J+ChnKuUJfGJ5xD0hsOeCAI6m/uiMmYSSPlxNE2EhgcJGLTwwFQrGm2PKNPz8vZyKZMT0B5ONReab5l3NKnZAKKkCxWcjrQbg== Received: from PH7P223CA0005.NAMP223.PROD.OUTLOOK.COM (2603:10b6:510:338::7) by LV8PR12MB9232.namprd12.prod.outlook.com (2603:10b6:408:182::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.21; Tue, 15 Oct 2024 16:36:44 +0000 Received: from CY4PEPF0000EE30.namprd05.prod.outlook.com (2603:10b6:510:338:cafe::23) by PH7P223CA0005.outlook.office365.com (2603:10b6:510:338::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.18 via Frontend Transport; Tue, 15 Oct 2024 16:36:43 +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 CY4PEPF0000EE30.mail.protection.outlook.com (10.167.242.36) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.17 via Frontend Transport; Tue, 15 Oct 2024 16:36:43 +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; Tue, 15 Oct 2024 09:36:28 -0700 Received: from pegasus01.mtr.labs.mlnx (10.126.231.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; Tue, 15 Oct 2024 09:36:25 -0700 From: Alexander Kozyrev To: CC: , , , , , , , , Subject: [PATCH 2/5] net/mlx5/hws: introduce jump to matcher action Date: Tue, 15 Oct 2024 19:35:54 +0300 Message-ID: <20241015163557.581447-2-akozyrev@nvidia.com> X-Mailer: git-send-email 2.18.2 In-Reply-To: <20241015163557.581447-1-akozyrev@nvidia.com> References: <20241015163557.581447-1-akozyrev@nvidia.com> MIME-Version: 1.0 X-Originating-IP: [10.126.231.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: CY4PEPF0000EE30:EE_|LV8PR12MB9232:EE_ X-MS-Office365-Filtering-Correlation-Id: d927c8c5-8626-49a8-232b-08dced378d76 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|36860700013|376014|82310400026|1800799024; X-Microsoft-Antispam-Message-Info: 0WRXnGy/dfxre8nvmbNTVUuSle4SNBn+M3eYP7U1FphPHs46xeuW7MN3cu2AGv9rugzNfzE8hA6HGSVARQDnsBM4kClrhJqHfsL4Yyd94zqul3lTMX7FLJ1oO822bvosHKMKynzN2WMYvnFOjVmaaleO4B6MS9PbwxGHfyaqn2vY5PzbDR+izsFJDu+vRDzxDnoCcZFc60I0sofKrIZbb9Tl19jPs84ujw0khg2vYBb9vLoLdS/CwR9Im/BAFgoMRzfh6kFzCOJ8quBnovFDPUIT66UvlB0Z4zi2Zp1asx+NHhzwk/ZmlnYRdvS2RWlCCK5WVjLLAGimP3lJki6F8Tj88fvKkRQI1pYNYu5HoFC4BJROoobDbVXSi5EezVSACkHo9RgETVTKXOIS1LIcslPrCI4xRDjLTqjhritNeU3+rh9IvSl2qiNhGZ87ySyQwVzs5mnhKvF4ugCKdeP0wpQT4c1t6aRbM5H/XRESAKzhEYUvTGX37w7lc93VtPmXtlNr9Lzf8NffdT5AVZV50cm7dyy4cn/YuLOEP+ohvz7IFTi4bHEqlMycsUsLNbPDqkC5IGdoX5xUqTWb80G9a27YBGUoddiTlWv4kU3QJ1TLKTyAr5C+1bF+4DUd40b/INtu+JzyhitXORGC7S4q11bu6zd6EWVUasr2fqkCL6n85Wxtx+P8ledK7TfWFPKXWszFRgOJtntBEpoWjn6TDXiK2UdjxNVRcdC8rUxSN/NngZHOAEm6dsw5J/UnjVzwfC/Z52TnwXHPf/QpjAnHgjtN632TEabqoKEFaFErTPlFaBS/hPFMW5lCM/eOOTj+zukV8C2FRWYFaA1qO/N9F/g/yuypQGjKf1RDpO9ERASfsAccGfVouNG+DjL/1brmrm8xEhNdjQWlYhyrASesoBl4UmV8VBVo1q4Xxf0LfI+Z/QWc1ER/HfM2nGwkzkzlVWDEostj56aKwf6uInrcfIKyZU/C4ikQ9JpkTVLJaXPT8sSFNcT1dwUYLlIRFokhN04CdiPKecTxscKE4k/o5jXrGXhermpTGSkUT7BI7gUs7VZkYb8iZqbMyc3lOPoXW8Ajxm0yXGsv4NBsyoMc34LnVq6AhvX+hlC7jMdXePUgAMkdqn7N7djnlvdA7QbFemnHFPRQrvR0NuZ+sENFcQoEIoGRncp1hEfPkS/TOQ2/OsvPUEXz/0NRE/qjRJMvOP4F5iI/IpwCkPkyKG+bMH1bHpVxfFp2d/WCyD/e/KlKDyQ9hBE2uBvQpgDkorKrX+xZN0k6K6KE1hOrE3PAfW44s9zorMu8m/E8ldKltgMCUv+P+X3r1AzGIjyqDM10I38OOK4KRfWGf6FrrQz/yykO6jtNBgyR3VKrlZh8VUMzTv8H5CsNSJCmWMnXqxtj 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:(13230040)(36860700013)(376014)(82310400026)(1800799024); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Oct 2024 16:36:43.0987 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: d927c8c5-8626-49a8-232b-08dced378d76 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: CY4PEPF0000EE30.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: LV8PR12MB9232 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: Hamdan Igbaria Introduce jump to matcher action, this action will allow jumping to another matcher. For now this jump restricted to STE array matchers and matchers of size 1. Signed-off-by: Hamdan Igbaria --- drivers/net/mlx5/hws/mlx5dr.h | 29 ++++++++++ drivers/net/mlx5/hws/mlx5dr_action.c | 87 +++++++++++++++++++++++++++- drivers/net/mlx5/hws/mlx5dr_action.h | 3 + drivers/net/mlx5/hws/mlx5dr_debug.c | 1 + 4 files changed, 117 insertions(+), 3 deletions(-) diff --git a/drivers/net/mlx5/hws/mlx5dr.h b/drivers/net/mlx5/hws/mlx5dr.h index 8a1a389a3f..1b58eeb2c7 100644 --- a/drivers/net/mlx5/hws/mlx5dr.h +++ b/drivers/net/mlx5/hws/mlx5dr.h @@ -52,6 +52,7 @@ enum mlx5dr_action_type { MLX5DR_ACTION_TYP_POP_IPV6_ROUTE_EXT, MLX5DR_ACTION_TYP_PUSH_IPV6_ROUTE_EXT, MLX5DR_ACTION_TYP_NAT64, + MLX5DR_ACTION_TYP_JUMP_TO_MATCHER, MLX5DR_ACTION_TYP_MAX, }; @@ -287,6 +288,10 @@ struct mlx5dr_rule_action { uint32_t offset; enum mlx5dr_action_aso_ct_flags direction; } aso_ct; + + struct { + uint32_t offset; + } jump_to_matcher; }; }; @@ -304,6 +309,15 @@ struct mlx5dr_action_dest_attr { } reformat; }; +enum mlx5dr_action_jump_to_matcher_type { + MLX5DR_ACTION_JUMP_TO_MATCHER_BY_INDEX, +}; + +struct mlx5dr_action_jump_to_matcher_attr { + enum mlx5dr_action_jump_to_matcher_type type; + struct mlx5dr_matcher *matcher; +}; + union mlx5dr_crc_encap_entropy_hash_ip_field { uint8_t ipv6_addr[16]; struct { @@ -938,6 +952,21 @@ mlx5dr_action_create_nat64(struct mlx5dr_context *ctx, struct mlx5dr_action_nat64_attr *attr, uint32_t flags); +/* Create direct rule jump to matcher action. + * + * @param[in] ctx + * The context in which the new action will be created. + * @param[in] attr + * The relevant attribute of the action. + * @param[in] flags + * Action creation flags. (enum mlx5dr_action_flags) + * @return pointer to mlx5dr_action on success NULL otherwise. + */ +struct mlx5dr_action * +mlx5dr_action_create_jump_to_matcher(struct mlx5dr_context *ctx, + struct mlx5dr_action_jump_to_matcher_attr *attr, + uint32_t flags); + /* Destroy direct rule action. * * @param[in] action diff --git a/drivers/net/mlx5/hws/mlx5dr_action.c b/drivers/net/mlx5/hws/mlx5dr_action.c index 3fceb96de2..3412a96894 100644 --- a/drivers/net/mlx5/hws/mlx5dr_action.c +++ b/drivers/net/mlx5/hws/mlx5dr_action.c @@ -42,7 +42,8 @@ static const uint32_t action_order_arr[MLX5DR_TABLE_TYPE_MAX][MLX5DR_ACTION_TYP_ BIT(MLX5DR_ACTION_TYP_TIR) | BIT(MLX5DR_ACTION_TYP_DROP) | BIT(MLX5DR_ACTION_TYP_DEST_ROOT) | - BIT(MLX5DR_ACTION_TYP_DEST_ARRAY), + BIT(MLX5DR_ACTION_TYP_DEST_ARRAY) | + BIT(MLX5DR_ACTION_TYP_JUMP_TO_MATCHER), BIT(MLX5DR_ACTION_TYP_LAST), }, [MLX5DR_TABLE_TYPE_NIC_TX] = { @@ -62,7 +63,8 @@ static const uint32_t action_order_arr[MLX5DR_TABLE_TYPE_MAX][MLX5DR_ACTION_TYP_ BIT(MLX5DR_ACTION_TYP_TBL) | BIT(MLX5DR_ACTION_TYP_MISS) | BIT(MLX5DR_ACTION_TYP_DROP) | - BIT(MLX5DR_ACTION_TYP_DEST_ROOT), + BIT(MLX5DR_ACTION_TYP_DEST_ROOT) | + BIT(MLX5DR_ACTION_TYP_JUMP_TO_MATCHER), BIT(MLX5DR_ACTION_TYP_LAST), }, [MLX5DR_TABLE_TYPE_FDB] = { @@ -88,7 +90,8 @@ static const uint32_t action_order_arr[MLX5DR_TABLE_TYPE_MAX][MLX5DR_ACTION_TYP_ BIT(MLX5DR_ACTION_TYP_VPORT) | BIT(MLX5DR_ACTION_TYP_DROP) | BIT(MLX5DR_ACTION_TYP_DEST_ROOT) | - BIT(MLX5DR_ACTION_TYP_DEST_ARRAY), + BIT(MLX5DR_ACTION_TYP_DEST_ARRAY) | + BIT(MLX5DR_ACTION_TYP_JUMP_TO_MATCHER), BIT(MLX5DR_ACTION_TYP_LAST), }, }; @@ -1091,6 +1094,13 @@ static void mlx5dr_action_fill_stc_attr(struct mlx5dr_action *action, attr->action_offset = MLX5DR_ACTION_OFFSET_DW5; attr->reparse_mode = MLX5_IFC_STC_REPARSE_ALWAYS; break; + case MLX5DR_ACTION_TYP_JUMP_TO_MATCHER: + attr->action_type = MLX5_IFC_STC_ACTION_TYPE_JUMP_TO_STE_TABLE; + attr->action_offset = MLX5DR_ACTION_OFFSET_HIT; + attr->ste_table.ste = action->jump_to_matcher.matcher->match_ste.ste; + attr->ste_table.ste_pool = action->jump_to_matcher.matcher->match_ste.pool; + attr->ste_table.match_definer_id = action->ctx->caps->trivial_match_definer; + break; default: DR_LOG(ERR, "Invalid action type %d", action->type); assert(false); @@ -3078,6 +3088,57 @@ mlx5dr_action_create_nat64(struct mlx5dr_context *ctx, return NULL; } +struct mlx5dr_action * +mlx5dr_action_create_jump_to_matcher(struct mlx5dr_context *ctx, + struct mlx5dr_action_jump_to_matcher_attr *attr, + uint32_t flags) +{ + struct mlx5dr_matcher *matcher = attr->matcher; + struct mlx5dr_matcher_attr *m_attr; + struct mlx5dr_action *action; + + if (attr->type != MLX5DR_ACTION_JUMP_TO_MATCHER_BY_INDEX) { + DR_LOG(ERR, "Only jump to matcher by index is supported"); + goto enotsup; + } + + if (mlx5dr_action_is_root_flags(flags)) { + DR_LOG(ERR, "Action flags must be only non root (HWS)"); + goto enotsup; + } + + if (mlx5dr_table_is_root(matcher->tbl)) { + DR_LOG(ERR, "Root matcher cannot be set as destination"); + goto enotsup; + } + + m_attr = &matcher->attr; + + if (!(matcher->flags & MLX5DR_MATCHER_FLAGS_STE_ARRAY) && + (m_attr->resizable || m_attr->table.sz_col_log || m_attr->table.sz_row_log)) { + DR_LOG(ERR, "Only STE array or matcher of size 1 can be set as destination"); + goto enotsup; + } + + action = mlx5dr_action_create_generic(ctx, flags, MLX5DR_ACTION_TYP_JUMP_TO_MATCHER); + if (!action) + return NULL; + + action->jump_to_matcher.matcher = matcher; + + if (mlx5dr_action_create_stcs(action, NULL)) { + DR_LOG(ERR, "Failed to create action jump to matcher STC"); + simple_free(action); + return NULL; + } + + return action; + +enotsup: + rte_errno = ENOTSUP; + return NULL; +} + static void mlx5dr_action_destroy_hws(struct mlx5dr_action *action) { struct mlx5dr_devx_obj *obj = NULL; @@ -3100,6 +3161,7 @@ static void mlx5dr_action_destroy_hws(struct mlx5dr_action *action) case MLX5DR_ACTION_TYP_PUSH_VLAN: case MLX5DR_ACTION_TYP_REMOVE_HEADER: case MLX5DR_ACTION_TYP_VPORT: + case MLX5DR_ACTION_TYP_JUMP_TO_MATCHER: mlx5dr_action_destroy_stcs(action); break; case MLX5DR_ACTION_TYP_DEST_ROOT: @@ -3618,6 +3680,19 @@ mlx5dr_action_setter_default_hit(struct mlx5dr_actions_apply_data *apply, htobe32(apply->common_res->default_stc->default_hit.offset); } +static void +mlx5dr_action_setter_hit_matcher(struct mlx5dr_actions_apply_data *apply, + struct mlx5dr_actions_wqe_setter *setter) +{ + struct mlx5dr_rule_action *rule_action; + + rule_action = &apply->rule_action[setter->idx_hit]; + + apply->wqe_data[MLX5DR_ACTION_OFFSET_HIT_LSB] = + htobe32(rule_action->jump_to_matcher.offset << 6); + mlx5dr_action_apply_stc(apply, MLX5DR_ACTION_STC_IDX_HIT, setter->idx_hit); +} + static void mlx5dr_action_setter_hit_next_action(struct mlx5dr_actions_apply_data *apply, __rte_unused struct mlx5dr_actions_wqe_setter *setter) @@ -3965,6 +4040,12 @@ int mlx5dr_action_template_process(struct mlx5dr_action_template *at) } break; + case MLX5DR_ACTION_TYP_JUMP_TO_MATCHER: + last_setter->flags |= ASF_HIT; + last_setter->set_hit = &mlx5dr_action_setter_hit_matcher; + last_setter->idx_hit = i; + break; + default: DR_LOG(ERR, "Unsupported action type: %d", action_type[i]); rte_errno = ENOTSUP; diff --git a/drivers/net/mlx5/hws/mlx5dr_action.h b/drivers/net/mlx5/hws/mlx5dr_action.h index ba4ce55228..8ce4ecd5ba 100644 --- a/drivers/net/mlx5/hws/mlx5dr_action.h +++ b/drivers/net/mlx5/hws/mlx5dr_action.h @@ -223,6 +223,9 @@ struct mlx5dr_action { struct { struct mlx5dr_action *stages[MLX5DR_ACTION_NAT64_STAGES]; } nat64; + struct { + struct mlx5dr_matcher *matcher; + } jump_to_matcher; }; }; diff --git a/drivers/net/mlx5/hws/mlx5dr_debug.c b/drivers/net/mlx5/hws/mlx5dr_debug.c index f15ad96598..8684a8197a 100644 --- a/drivers/net/mlx5/hws/mlx5dr_debug.c +++ b/drivers/net/mlx5/hws/mlx5dr_debug.c @@ -29,6 +29,7 @@ const char *mlx5dr_debug_action_type_str[] = { [MLX5DR_ACTION_TYP_POP_IPV6_ROUTE_EXT] = "POP_IPV6_ROUTE_EXT", [MLX5DR_ACTION_TYP_PUSH_IPV6_ROUTE_EXT] = "PUSH_IPV6_ROUTE_EXT", [MLX5DR_ACTION_TYP_NAT64] = "NAT64", + [MLX5DR_ACTION_TYP_JUMP_TO_MATCHER] = "JUMP_TO_MATCHER", }; static_assert(ARRAY_SIZE(mlx5dr_debug_action_type_str) == MLX5DR_ACTION_TYP_MAX, From patchwork Tue Oct 15 16:35:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Kozyrev X-Patchwork-Id: 146024 X-Patchwork-Delegate: rasland@nvidia.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 83C2045B44; Tue, 15 Oct 2024 18:37:12 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 1DCF340670; Tue, 15 Oct 2024 18:37:00 +0200 (CEST) Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2079.outbound.protection.outlook.com [40.107.244.79]) by mails.dpdk.org (Postfix) with ESMTP id 501C94066F for ; Tue, 15 Oct 2024 18:36:58 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=WcPfOP/kqtrAP1MfzeJ7e1zdILc8BzWd9Cr5pvS1+jw6zq++BY5RvEpCUr7hklG0F2gW5I2ylk7ruvmOMll/XY1ASN4iOr4VFjZ6WyxXXziUKkhnNQqhBi8/lOTG6HtWQKSyBe1R3yz7wH9kkaKbqBgSNBQD3kymX9qHlOSldihtlanylhovI03UCH70DmXxNdQSgKhPR7UcVnVeiwD1W5Wyo7d92s5kkuvn9UgfOeeMZavttIJRkEeZDloSlYcxX9Ttta0dCSGN+3nqwdbevgHB81tSD5nvNvvHodQC2mXEDAjgsRa1Xa9qKXb1Q7IHoxO/eypuLQ26jyOQPonEEA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=Jan8FYSG6p/Toh86LmFFRkgtW9Wzund03shXxWe9ehY=; b=tV/DfnVpUz9Q+nVzL8AI6RAylV1CxJBCWi3Qr1wRHnp6aH1u6Ts6ZrEDBMX0+TWMFhPzX2yYa3ukf9KxPYYWwm8Oyqz0N/Ag8/laKqUV+PALLIhUCWT8+B+xeBrVhXvYD9rvL9igZUVBFmjUt+e2uf3x18WNbHAvbJegHlLlOAiw6KXioChKhvXj5qyXqJqvBEdsjVb0ut/PZRbIawVhTqVN43d2z1f9+o6T6bJ3kG6552t1w0bMtaoKUvpAZebLpdRVCFoZODy35FfIwI0H0ABDYjQEnFFtQzq16ymPbVYJmWeGLwxXh1doR7YYnTA4XvgzMO1OkS0JsFAKWGgeiQ== 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=Jan8FYSG6p/Toh86LmFFRkgtW9Wzund03shXxWe9ehY=; b=ELz8pcA2jWeJbDtSkszRJ0HfBQmAuTssOiQLqUzjm4J1QrcHFFo+lddVUI8HVZGdlkNNdegfna5dsEXcUoi1cRFfk9hsX5d7eHR1Xa+BAIHkGn/hxA983zfZJCQMkHxOyTUD+IquauANx0bQHC87R9zV3PSpFIGFoCYxMbw7bNBYiivL21lNbH2gJ7qie4kC4lMxBYC37yXurTlx/NSHtN/f+grDEEVCQOPV67GEtXi0WrWl6MjLsvHBFTCQTtVanalnbke1NdpCyCdxaYFTqZP+V64Ke+w9FQWcqjOPxsDGDeASvzzpa52mVbApdR5xXssJ2cVlB/BlIYQNseMRxA== Received: from BYAPR07CA0041.namprd07.prod.outlook.com (2603:10b6:a03:60::18) by SA1PR12MB7294.namprd12.prod.outlook.com (2603:10b6:806:2b8::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.26; Tue, 15 Oct 2024 16:36:49 +0000 Received: from CO1PEPF000042A8.namprd03.prod.outlook.com (2603:10b6:a03:60:cafe::b6) by BYAPR07CA0041.outlook.office365.com (2603:10b6:a03:60::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.17 via Frontend Transport; Tue, 15 Oct 2024 16:36:49 +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 CO1PEPF000042A8.mail.protection.outlook.com (10.167.243.37) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.17 via Frontend Transport; Tue, 15 Oct 2024 16:36:48 +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; Tue, 15 Oct 2024 09:36:31 -0700 Received: from pegasus01.mtr.labs.mlnx (10.126.231.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; Tue, 15 Oct 2024 09:36:28 -0700 From: Alexander Kozyrev To: CC: , , , , , , , , Subject: [PATCH 3/5] net/mlx5: create array ste matcher Date: Tue, 15 Oct 2024 19:35:55 +0300 Message-ID: <20241015163557.581447-3-akozyrev@nvidia.com> X-Mailer: git-send-email 2.18.2 In-Reply-To: <20241015163557.581447-1-akozyrev@nvidia.com> References: <20241015163557.581447-1-akozyrev@nvidia.com> MIME-Version: 1.0 X-Originating-IP: [10.126.231.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: CO1PEPF000042A8:EE_|SA1PR12MB7294:EE_ X-MS-Office365-Filtering-Correlation-Id: 97b438e3-9b9f-40d1-3edf-08dced3790eb X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|36860700013|1800799024|376014|82310400026; X-Microsoft-Antispam-Message-Info: 5s9re2QOHhTKbzqZsBPy2RLrEX9PYk6W+O6DZoWXTYlaZmfqvKgBS/eqe+PWmGAAao3fk3As9HbDOI6rj0BOvRpwC41xHazyLKisxTGC/5wzGgyBOnoRGNoIa1jt74NIyS9G9R0lotjlt6PKbJq2rKcW5XzcqHLRxSqQ76+R0V/E5dvykWQueNUv9xGvMqnvnhFmzRBWhxPmr1lrMEx3djhB4E1Tp5pfhFJIdzELmJwqdZi8YUOSozyWssMDYsqmELpMzSG2SRiWtcTcEIOX4l3fOMeF3Td1GLcRGt4TvW7P1vczCDf5Ke57fT4gWId2QKrRmGzMKJY88hn6S+CM3HU0l15nd+tS6zxueiHsWvTvz+rGA6AOo0GmlPL9m+A2nQ5nlFzxwDINvKOeff2ejjA608bHcwe9gbXQPMaVuLbHOHGJ/D/UrB/MOmlQQzBuoL6acaegnBhc2Yq1jmZ7fzaqkioJahNQLm4uWbXALUCFcra5j6vNAU8u2pIKH0FMnCZTWiZk1VaEyAfr092FmUJ9heQns6Mu24Uegns6bWcv5gpb5upTM613FSxAQHQeyNKaGGuMa1FNu/8PGoegu6vquvJ99jBL7dqThryNjOMfI1CY21fBSTHWutbGy2OdQ7cSLbLTb2Y4t+3kbzG3dqQ0AHD3buBeVII9BLQ2TORs5nPzK6uKDIHkKWtvYxAat3m2N4TIyi4nOMeagjsTikrtYZcRxrKRbmLI0XzBkg5QuvU+fujiwDUx4EGTtq+8aADpHT7nLdAB9uL6FGWp3cfUQcFqPeQdoEMe6LpOfiaTgklm9Qkl4zXiOuWl9H5sLUXUJXVRNWHly7Aa7Y8c9LJegAR578dB4mLY6ACblICRnwJ5kH6XcYI1Ht8W5VcTIOBMquMx569aqcd97umnONzNrAtQYKkRSYRaXRlm2YbAPkOT3N4qNwX9gqlZEAJkGrMzzV7PlAYpF4VJqy5NRNONuSjRXTVlwAgALKldCfAzYkyPPgAMWsl6lPhk75Im9DeK5Exihls778X+lyaRWFnP1uyUXATqBFBIxm2iWJTv2zu/TYZMoui6doIaOsLeYqSJ2tN47aJlaWbdYPlImkTD3VIy4g60eNdPzULjbXFdE/We+FcSW0gUZHlJrLSG4NeP4Y+o3aMEKtkbOBbxzrQTZ6pvjS1RQOUe6Tf2VFFPmbxroEf5rXQBJlxXw8lBTl23Wq/PVcm+1t+LuFpVSikQ1Wz75S/Vv1U6okgzg49simpeSkh7kq5msiE7yJRdLVrrz1zKWkJgFOODIB1t5TRzbiCN/SErhtw5zOFw8fQ4rEjPS09Lv9vuTRQF9wh/WSAx9Ki/6Z6+7WakFDDXjIczBE2buyvGPOGOb3pPoK8AUY+tEQydr7Kju75xkdQ6 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:(13230040)(36860700013)(1800799024)(376014)(82310400026); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Oct 2024 16:36:48.8681 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 97b438e3-9b9f-40d1-3edf-08dced3790eb 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: CO1PEPF000042A8.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR12MB7294 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 Create an array STE matcher for a template table in case of insertion by index with pattern is selected. Packets will be matched on a pattern at the index. This table is isolated from any other tables in a group. That means packets missed the rule won't go to a lower priority tables, but proceed with the default miss instead. Signed-off-by: Alexander Kozyrev --- drivers/net/mlx5/mlx5_flow_hw.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/drivers/net/mlx5/mlx5_flow_hw.c b/drivers/net/mlx5/mlx5_flow_hw.c index b9807f347d..6434937562 100644 --- a/drivers/net/mlx5/mlx5_flow_hw.c +++ b/drivers/net/mlx5/mlx5_flow_hw.c @@ -5157,8 +5157,15 @@ flow_hw_table_create(struct rte_eth_dev *dev, matcher_attr.optimize_using_rule_idx = true; matcher_attr.mode = MLX5DR_MATCHER_RESOURCE_MODE_RULE; matcher_attr.insert_mode = flow_hw_matcher_insert_mode_get(attr->insertion_type); - if (matcher_attr.insert_mode == MLX5DR_MATCHER_INSERT_BY_INDEX) - matcher_attr.match_mode = MLX5DR_MATCHER_MATCH_MODE_ALWAYS_HIT; + if (matcher_attr.insert_mode == MLX5DR_MATCHER_INSERT_BY_INDEX) { + if (attr->insertion_type == RTE_FLOW_TABLE_INSERTION_TYPE_INDEX_WITH_PATTERN) { + matcher_attr.isolated = true; + matcher_attr.match_mode = MLX5DR_MATCHER_MATCH_MODE_DEFAULT; + } else { + matcher_attr.isolated = false; + matcher_attr.match_mode = MLX5DR_MATCHER_MATCH_MODE_ALWAYS_HIT; + } + } if (attr->hash_func == RTE_FLOW_TABLE_HASH_FUNC_CRC16) { DRV_LOG(ERR, "16-bit checksum hash type is not supported"); rte_errno = ENOTSUP; From patchwork Tue Oct 15 16:35:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Kozyrev X-Patchwork-Id: 146023 X-Patchwork-Delegate: rasland@nvidia.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id D6C9945B44; Tue, 15 Oct 2024 18:37:05 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id E78AC40274; Tue, 15 Oct 2024 18:36:55 +0200 (CEST) Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2069.outbound.protection.outlook.com [40.107.93.69]) by mails.dpdk.org (Postfix) with ESMTP id 02F424065F for ; Tue, 15 Oct 2024 18:36:53 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Iyew2awPGqj1sFQKWcqyiWHmR9zIF4z4Lp7pmNO+t+68GBx5087uYQ4WeE1mcLg7GPv15sd9R37ThdQUBovO8Oc2wzSE8o2252eQJ21oZnoW+h6K0YNIbDaUHWUOcWBDviMPNrggWStDf0EvYHJ6faMs0UbgUEFekapW3JZMu8JauBObbnc5UQcQC4VY0YTAghsyKjq/Ko7BqpJNN6M5UKZK3alUFl2XM7q8CvLskHVAnme7f3Z6smW55WHGWeHhAZyED2Oc9MYunZHIn8yBMFUxCqmxuL2jmmBCaL1bkqu6a1lCcUfoI4gf/5Gd1TEpBFUj4551fZ8wdLQSp9XQPg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=smmGrjW3OJmVR6oWbJn9CuAp9z8c7K0O4FgOtdIV9Q4=; b=YTzl0z28N+L8QGynzw4XwLYk/6EKjXKKvNiFLmJ/L6Mi9U3hLn76gxsJIduXWBwcT12CXQg6KvRtyqEDEn34nMBUFnjQyrTbxESqeTAYn5v5hY80IFXYgDnbTYgwslWO0Htx8Kgo4yvsLkKlNo5G2YiN5DTX3AYyjJCSYqm4Q6PpBTAMpNSj2CWuNL+5UG+vTyQzOtuGBzOGEE6meICbn5t1QkIRdYhEVF2jfTcbXeigNtxk9/Mgu95KMnslRdaNsszUX9fZBuUoxi34wuXwIybWlex5p6ACShTkBIzWgqA9ngpwPb0jjU52H6SsS+25ud7cImG4BnPuBWcO9zCWCA== 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=smmGrjW3OJmVR6oWbJn9CuAp9z8c7K0O4FgOtdIV9Q4=; b=W4xBMPKt3M4KUI1wMr7vCWC18iox/YgX2KCkfSvgFRN44tgrWX89P+iBR3RMeb32NVTxu5yWyPyqrSw5EVFeI5YcP9FJkeGtF0bZXWm6ULg94VUT17nbEZrkMosfZXYUjgA6+aSWIz1pTgcz5zOlcn2I8BhRMzmT3S+PpqmNDORfgpjcV6ay5hJlja4Cw1x90TsNvCedF95mnNR4ypTvxVxT+szcOnFUybVniZbnvWYMrHvsYY2NCJc0xW30lwwBWnmwEeLDei7ncsxh3ltbjnCiVYaQ3AOjK32yKQElhSghFAPVKh4Zydv9y81FQCpOxF25f0+fPh3VIGEVM6Yc+g== Received: from PH8PR22CA0006.namprd22.prod.outlook.com (2603:10b6:510:2d1::10) by PH7PR12MB7139.namprd12.prod.outlook.com (2603:10b6:510:1ef::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.18; Tue, 15 Oct 2024 16:36:51 +0000 Received: from CY4PEPF0000EE37.namprd05.prod.outlook.com (2603:10b6:510:2d1:cafe::99) by PH8PR22CA0006.outlook.office365.com (2603:10b6:510:2d1::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.28 via Frontend Transport; Tue, 15 Oct 2024 16:36:50 +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 CY4PEPF0000EE37.mail.protection.outlook.com (10.167.242.43) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.17 via Frontend Transport; Tue, 15 Oct 2024 16:36:50 +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; Tue, 15 Oct 2024 09:36:35 -0700 Received: from pegasus01.mtr.labs.mlnx (10.126.231.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; Tue, 15 Oct 2024 09:36:32 -0700 From: Alexander Kozyrev To: CC: , , , , , , , , Subject: [PATCH 4/5] net/mlx5: add flow rule insertion by index with pattern Date: Tue, 15 Oct 2024 19:35:56 +0300 Message-ID: <20241015163557.581447-4-akozyrev@nvidia.com> X-Mailer: git-send-email 2.18.2 In-Reply-To: <20241015163557.581447-1-akozyrev@nvidia.com> References: <20241015163557.581447-1-akozyrev@nvidia.com> MIME-Version: 1.0 X-Originating-IP: [10.126.231.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: CY4PEPF0000EE37:EE_|PH7PR12MB7139:EE_ X-MS-Office365-Filtering-Correlation-Id: eb2e6314-6eaf-41d7-ddc6-08dced3791f1 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|376014|1800799024|36860700013|82310400026; X-Microsoft-Antispam-Message-Info: RRxtX3TD9eXcewDA68cT7WlsPJVWq4qMiJYcRiWgQxUP5TYIi+wqkMQJrxiNYRuOw58d7RQrhH6hO+o0avhFkBqhhJsX+7F0HoQTsZu4WcdxzDKtweZtfvFmDwQb31PM6BNehwuhP6jSiOjBQaF5aumcsl5IfojMLYMmpojv5u9VNTHcikSA1PUHv7GgUPuAExYUu8wdCWDYv4YNvfRfKDjgELFFEnKVmhn1Ks1xVUa2cH/s+FEmTrsmun2kBX5uiP2RrAntMz8MlociBg50yEF595lAFIncO1Q42OgbGWXibcC5aNyvmFmLsFZHJDKbzjIF4eOXzS+7GQmVzrQ6t1wloCcaHSgxqklw481GKdfcPgbqU3LcS7RQNEznzDENSKnzXrQ1NnQe9GEzS82VLwvEW+UbSU2hdoK08EHSh1wLBr1+h0yEN53xqJdWt4ypSjiy2htyD30AX+bREEheqA+sm3sYgRiR9WJgZV8xCMCBHWBRGH3ojapAbmEHuhTdQNwEzGQdnhqeY57lNmIP30Ty7RyQ0gMsrBC1XiJGVKGvk2Y0+XxCWokjuFGNu71BwE2A9f3uq8sLVBfCMFSWE4b90bVLhHx0NXwKGQxfqRxT0nvR7OHuCNAJcwGBfhxcyRwOWDOGFS3w96ZyHcv/VHuSINp13IXer57jOsAyKN1zdmnMWKSis/XkpGnFCBOR0Gja6PMakUkwdp1G5Z8g84nrECT4RCfLLa7CVVpLeYY7qaz9wd6Xtpb+MHFYLvNe865gBQwanbe3WH/au+d9mpFn6jyHqyo5iOSfXT8xxQhqlCUeD5R0BaF/hY1q8STVfr1FQBQ6IingDA7KXn7h2NECj0FZLYQYCspfxE2GDChoUzeMxTJukYlBgD0zmuJ0GpyavBiRgdApOS/dyRd/Ybw/CI6q4wmzRe8KfYpejEiT98x1Sv7ymZT0aNaRW3mHkSzA0GHE2y0sIiW3mHXFEmxuOcdvgiAk2EORrkzkNhbW8ohwoydvKcW0G0IW+cM6vVtAa6c6q8JgZLXoJoYdpz+3wHgAaEmLEM5zs7eWrp5DahDtYaP1nm2eR/VFigs01mX3DtAcEgRw865OCXnzAlQZlwf5RzSfCDSVSlfzHRm0i7nAy6CdRdvkfv4kjALX765ZtkjUWm6AZTQENC2WKX7JtfqICci++6kJ8YCBpTow1vYDV82dTsby+/dJZqI7qsYOxt0AL7g4hleg8sei2gv4YkAOI19YoFOjE0ivYUOJTJSfyMulPPOrBperB7UVir7CyYjo732R4kUuzBm+5gu9A/cJh58J9rV8M26Y2fS0IIDOcx7mKE+9hDDcaWSRsoS2mPrP2LKw19ciYeLp6rmDAejWyXIliXnBxDwDfqEcIgz9CqX+oCK2izCiyLP/ 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:(13230040)(376014)(1800799024)(36860700013)(82310400026); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Oct 2024 16:36:50.6205 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: eb2e6314-6eaf-41d7-ddc6-08dced3791f1 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: CY4PEPF0000EE37.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB7139 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 Implement rte_flow_async_create_by_index_with_pattern() function. Rework the driver implementaion to reduce the code duplication by providing a signle flow insertion routine, that can be called with different parameters depending on the insertion type. Signed-off-by: Alexander Kozyrev --- drivers/net/mlx5/mlx5_flow_hw.c | 281 +++++++++----------------------- 1 file changed, 81 insertions(+), 200 deletions(-) diff --git a/drivers/net/mlx5/mlx5_flow_hw.c b/drivers/net/mlx5/mlx5_flow_hw.c index 6434937562..6c8404ee2c 100644 --- a/drivers/net/mlx5/mlx5_flow_hw.c +++ b/drivers/net/mlx5/mlx5_flow_hw.c @@ -335,18 +335,13 @@ static __rte_always_inline uint32_t flow_hw_tx_tag_regc_value(struct rte_eth_dev static int flow_hw_async_create_validate(struct rte_eth_dev *dev, const uint32_t queue, const struct rte_flow_template_table *table, + enum rte_flow_table_insertion_type insertion_type, + const uint32_t rule_index, const struct rte_flow_item items[], const uint8_t pattern_template_index, const struct rte_flow_action actions[], const uint8_t action_template_index, struct rte_flow_error *error); -static int flow_hw_async_create_by_index_validate(struct rte_eth_dev *dev, - const uint32_t queue, - const struct rte_flow_template_table *table, - const uint32_t rule_index, - const struct rte_flow_action actions[], - const uint8_t action_template_index, - struct rte_flow_error *error); static int flow_hw_async_update_validate(struct rte_eth_dev *dev, const uint32_t queue, const struct rte_flow_hw *flow, @@ -3884,6 +3879,12 @@ flow_hw_get_rule_items(struct rte_eth_dev *dev, * The queue to create the flow. * @param[in] attr * Pointer to the flow operation attributes. + * @param[in] table + * Pointer to the template table. + * @param[in] insertion_type + * Insertion type for flow rules. + * @param[in] rule_index + * The item pattern flow follows from the table. * @param[in] items * Items with flow spec value. * @param[in] pattern_template_index @@ -3900,17 +3901,19 @@ flow_hw_get_rule_items(struct rte_eth_dev *dev, * @return * Flow pointer on success, NULL otherwise and rte_errno is set. */ -static struct rte_flow * -flow_hw_async_flow_create(struct rte_eth_dev *dev, - uint32_t queue, - const struct rte_flow_op_attr *attr, - struct rte_flow_template_table *table, - const struct rte_flow_item items[], - uint8_t pattern_template_index, - const struct rte_flow_action actions[], - uint8_t action_template_index, - void *user_data, - struct rte_flow_error *error) +static __rte_always_inline struct rte_flow * +flow_hw_async_flow_create_generic(struct rte_eth_dev *dev, + uint32_t queue, + const struct rte_flow_op_attr *attr, + struct rte_flow_template_table *table, + enum rte_flow_table_insertion_type insertion_type, + uint32_t rule_index, + const struct rte_flow_item items[], + uint8_t pattern_template_index, + const struct rte_flow_action actions[], + uint8_t action_template_index, + void *user_data, + struct rte_flow_error *error) { struct mlx5_priv *priv = dev->data->dev_private; struct mlx5dr_rule_attr rule_attr = { @@ -3928,8 +3931,8 @@ flow_hw_async_flow_create(struct rte_eth_dev *dev, int ret; if (mlx5_fp_debug_enabled()) { - if (flow_hw_async_create_validate(dev, queue, table, items, pattern_template_index, - actions, action_template_index, error)) + if (flow_hw_async_create_validate(dev, queue, table, insertion_type, rule_index, + items, pattern_template_index, actions, action_template_index, error)) return NULL; } flow = mlx5_ipool_malloc(table->flow, &flow_idx); @@ -3967,7 +3970,7 @@ flow_hw_async_flow_create(struct rte_eth_dev *dev, * Indexed pool returns 1-based indices, but mlx5dr expects 0-based indices * for rule insertion hints. */ - flow->rule_idx = flow->res_idx - 1; + flow->rule_idx = (rule_index == UINT32_MAX) ? flow->res_idx - 1 : rule_index; rule_attr.rule_idx = flow->rule_idx; /* * Construct the flow actions based on the input actions. @@ -4023,33 +4026,26 @@ flow_hw_async_flow_create(struct rte_eth_dev *dev, return NULL; } -/** - * Enqueue HW steering flow creation by index. - * - * The flow will be applied to the HW only if the postpone bit is not set or - * the extra push function is called. - * The flow creation status should be checked from dequeue result. - * - * @param[in] dev - * Pointer to the rte_eth_dev structure. - * @param[in] queue - * The queue to create the flow. - * @param[in] attr - * Pointer to the flow operation attributes. - * @param[in] rule_index - * The item pattern flow follows from the table. - * @param[in] actions - * Action with flow spec value. - * @param[in] action_template_index - * The action pattern flow follows from the table. - * @param[in] user_data - * Pointer to the user_data. - * @param[out] error - * Pointer to error structure. - * - * @return - * Flow pointer on success, NULL otherwise and rte_errno is set. - */ +static struct rte_flow * +flow_hw_async_flow_create(struct rte_eth_dev *dev, + uint32_t queue, + const struct rte_flow_op_attr *attr, + struct rte_flow_template_table *table, + const struct rte_flow_item items[], + uint8_t pattern_template_index, + const struct rte_flow_action actions[], + uint8_t action_template_index, + void *user_data, + struct rte_flow_error *error) +{ + uint32_t rule_index = UINT32_MAX; + + return flow_hw_async_flow_create_generic(dev, queue, attr, table, + RTE_FLOW_TABLE_INSERTION_TYPE_PATTERN, rule_index, + items, pattern_template_index, actions, action_template_index, + user_data, error); +} + static struct rte_flow * flow_hw_async_flow_create_by_index(struct rte_eth_dev *dev, uint32_t queue, @@ -4062,105 +4058,31 @@ flow_hw_async_flow_create_by_index(struct rte_eth_dev *dev, struct rte_flow_error *error) { struct rte_flow_item items[] = {{.type = RTE_FLOW_ITEM_TYPE_END,}}; - struct mlx5_priv *priv = dev->data->dev_private; - struct mlx5dr_rule_attr rule_attr = { - .queue_id = queue, - .user_data = user_data, - .burst = attr->postpone, - }; - struct mlx5dr_rule_action *rule_acts; - struct mlx5_flow_hw_action_params ap; - struct rte_flow_hw *flow = NULL; - uint32_t flow_idx = 0; - uint32_t res_idx = 0; - int ret; + uint8_t pattern_template_index = 0; - if (mlx5_fp_debug_enabled()) { - if (flow_hw_async_create_by_index_validate(dev, queue, table, rule_index, - actions, action_template_index, error)) - return NULL; - } - flow = mlx5_ipool_malloc(table->flow, &flow_idx); - if (!flow) { - rte_errno = ENOMEM; - goto error; - } - rule_acts = flow_hw_get_dr_action_buffer(priv, table, action_template_index, queue); - /* - * Set the table here in order to know the destination table - * when free the flow afterwards. - */ - flow->table = table; - flow->mt_idx = 0; - flow->idx = flow_idx; - if (table->resource) { - mlx5_ipool_malloc(table->resource, &res_idx); - if (!res_idx) { - rte_errno = ENOMEM; - goto error; - } - flow->res_idx = res_idx; - } else { - flow->res_idx = flow_idx; - } - flow->flags = 0; - /* - * Set the flow operation type here in order to know if the flow memory - * should be freed or not when get the result from dequeue. - */ - flow->operation_type = MLX5_FLOW_HW_FLOW_OP_TYPE_CREATE; - flow->user_data = user_data; - rule_attr.user_data = flow; - /* Set the rule index. */ - flow->rule_idx = rule_index; - rule_attr.rule_idx = flow->rule_idx; - /* - * Construct the flow actions based on the input actions. - * The implicitly appended action is always fixed, like metadata - * copy action from FDB to NIC Rx. - * No need to copy and contrust a new "actions" list based on the - * user's input, in order to save the cost. - */ - if (flow_hw_actions_construct(dev, flow, &ap, - &table->ats[action_template_index], - table->its[0]->item_flags, table, - actions, rule_acts, queue, error)) { - rte_errno = EINVAL; - goto error; - } - if (likely(!rte_flow_template_table_resizable(dev->data->port_id, &table->cfg.attr))) { - ret = mlx5dr_rule_create(table->matcher_info[0].matcher, - 0, items, action_template_index, - rule_acts, &rule_attr, - (struct mlx5dr_rule *)flow->rule); - } else { - struct rte_flow_hw_aux *aux = mlx5_flow_hw_aux(dev->data->port_id, flow); - uint32_t selector; + return flow_hw_async_flow_create_generic(dev, queue, attr, table, + RTE_FLOW_TABLE_INSERTION_TYPE_INDEX, rule_index, + items, pattern_template_index, actions, action_template_index, + user_data, error); +} - flow->operation_type = MLX5_FLOW_HW_FLOW_OP_TYPE_RSZ_TBL_CREATE; - rte_rwlock_read_lock(&table->matcher_replace_rwlk); - selector = table->matcher_selector; - ret = mlx5dr_rule_create(table->matcher_info[selector].matcher, - 0, items, action_template_index, - rule_acts, &rule_attr, - (struct mlx5dr_rule *)flow->rule); - rte_rwlock_read_unlock(&table->matcher_replace_rwlk); - aux->matcher_selector = selector; - flow->flags |= MLX5_FLOW_HW_FLOW_FLAG_MATCHER_SELECTOR; - } - if (likely(!ret)) { - flow_hw_q_inc_flow_ops(priv, queue); - return (struct rte_flow *)flow; - } -error: - if (table->resource && res_idx) - mlx5_ipool_free(table->resource, res_idx); - if (flow_idx) - mlx5_ipool_free(table->flow, flow_idx); - rte_flow_error_set(error, rte_errno, - RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL, - "fail to create rte flow"); - return NULL; +static struct rte_flow * +flow_hw_async_flow_create_by_index_with_pattern(struct rte_eth_dev *dev, + uint32_t queue, + const struct rte_flow_op_attr *attr, + struct rte_flow_template_table *table, + uint32_t rule_index, + const struct rte_flow_item items[], + uint8_t pattern_template_index, + const struct rte_flow_action actions[], + uint8_t action_template_index, + void *user_data, + struct rte_flow_error *error) +{ + return flow_hw_async_flow_create_generic(dev, queue, attr, table, + RTE_FLOW_TABLE_INSERTION_TYPE_INDEX_WITH_PATTERN, rule_index, + items, pattern_template_index, actions, action_template_index, + user_data, error); } /** @@ -16579,6 +16501,8 @@ flow_hw_async_op_validate(struct rte_eth_dev *dev, * The queue to create the flow. * @param[in] table * Pointer to template table. + * @param[in] rule_index + * The item pattern flow follows from the table. * @param[in] items * Items with flow spec value. * @param[in] pattern_template_index @@ -16598,6 +16522,8 @@ static int flow_hw_async_create_validate(struct rte_eth_dev *dev, const uint32_t queue, const struct rte_flow_template_table *table, + enum rte_flow_table_insertion_type insertion_type, + uint32_t rule_index, const struct rte_flow_item items[], const uint8_t pattern_template_index, const struct rte_flow_action actions[], @@ -16607,63 +16533,18 @@ flow_hw_async_create_validate(struct rte_eth_dev *dev, if (flow_hw_async_op_validate(dev, queue, table, error)) return -rte_errno; - if (table->cfg.attr.insertion_type != RTE_FLOW_TABLE_INSERTION_TYPE_PATTERN) - return rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL, - "Only pattern insertion is allowed on this table"); - - if (flow_hw_validate_rule_pattern(dev, table, pattern_template_index, items, error)) - return -rte_errno; - - if (flow_hw_validate_rule_actions(dev, table, action_template_index, actions, error)) - return -rte_errno; - - return 0; -} + if (insertion_type != table->cfg.attr.insertion_type) + return rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_UNSPECIFIED, + NULL, "Flow rule insertion type mismatch with table configuration"); -/** - * Validate user input for rte_flow_async_create_by_index() implementation. - * - * If RTE_LIBRTE_MLX5_DEBUG macro is not defined, this function is a no-op. - * - * @param[in] dev - * Pointer to the rte_eth_dev structure. - * @param[in] queue - * The queue to create the flow. - * @param[in] table - * Pointer to template table. - * @param[in] rule_index - * Rule index in the table. - * Inserting a rule to already occupied index results in undefined behavior. - * @param[in] actions - * Action with flow spec value. - * @param[in] action_template_index - * The action pattern flow follows from the table. - * @param[out] error - * Pointer to error structure. - * - * @return - * 0 if user input is valid. - * Negative errno otherwise, rte_errno and error struct is set. - */ -static int -flow_hw_async_create_by_index_validate(struct rte_eth_dev *dev, - const uint32_t queue, - const struct rte_flow_template_table *table, - const uint32_t rule_index, - const struct rte_flow_action actions[], - const uint8_t action_template_index, - struct rte_flow_error *error) -{ - if (flow_hw_async_op_validate(dev, queue, table, error)) - return -rte_errno; + if (table->cfg.attr.insertion_type != RTE_FLOW_TABLE_INSERTION_TYPE_PATTERN) + if (rule_index >= table->cfg.attr.nb_flows) + return rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_UNSPECIFIED, + NULL, "Flow rule index exceeds table size"); if (table->cfg.attr.insertion_type != RTE_FLOW_TABLE_INSERTION_TYPE_INDEX) - return rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL, - "Only index insertion is allowed on this table"); - - if (rule_index >= table->cfg.attr.nb_flows) - return rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL, - "Flow rule index exceeds table size"); + if (flow_hw_validate_rule_pattern(dev, table, pattern_template_index, items, error)) + return -rte_errno; if (flow_hw_validate_rule_actions(dev, table, action_template_index, actions, error)) return -rte_errno; @@ -16671,7 +16552,6 @@ flow_hw_async_create_by_index_validate(struct rte_eth_dev *dev, return 0; } - /** * Validate user input for rte_flow_async_update() implementation. * @@ -16744,6 +16624,7 @@ flow_hw_async_destroy_validate(struct rte_eth_dev *dev, static struct rte_flow_fp_ops mlx5_flow_hw_fp_ops = { .async_create = flow_hw_async_flow_create, .async_create_by_index = flow_hw_async_flow_create_by_index, + .async_create_by_index_with_pattern = flow_hw_async_flow_create_by_index_with_pattern, .async_actions_update = flow_hw_async_flow_update, .async_destroy = flow_hw_async_flow_destroy, .push = flow_hw_push, From patchwork Tue Oct 15 16:35:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Kozyrev X-Patchwork-Id: 146025 X-Patchwork-Delegate: rasland@nvidia.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 03A1745B44; Tue, 15 Oct 2024 18:37:20 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id A00004068A; Tue, 15 Oct 2024 18:37:02 +0200 (CEST) Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2043.outbound.protection.outlook.com [40.107.92.43]) by mails.dpdk.org (Postfix) with ESMTP id BFEC840663 for ; Tue, 15 Oct 2024 18:36:59 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=eE3nsWqce7Thl80IimbUozC/Sn40yHRar+LTavPDsRjkEzlgahjQoT2LMqMxlacav1Isxm7YyubMKrheSnHF9B2QJfnzdoZNgk053kuW7FItHk4NpnFLw1yOmcenuxlGsvof59aO0Bl3Qah8UH/RLOEMoLsIkF/jh+iWli7WpzjvPm3jM6g9TJP6szZCVxxmobMLMUE3wZUnoi8HOG0w4vxolkm+H+2MAKCPz6Mgxc9n/xnLhfR2x8oSDdIAgAdiJlAfTMZAkq4SP6rRRcQLel9VLgS8ZRZqUGIFZ0aR8bQ4oQUeJNjx8jxwHukMy7BiQoLeJTO3PxmDp+kbZ5JtMg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=B3IKqwMqxwr3GYJ8Hww9a49BvL8+LA3RzBMj0XjS0XQ=; b=PYEX+ISFsM+0DGtUg2jZwOrKBtMfWX9K55lsJXh2Du4/B75zm19FnMH5MzgqTDSNci7hVuWLd6OTJvnFo+vyxE/vp3e6FVNGkPLuqk6k5YAIaSg1c2r/R8QF7jM9WBti6eh+EEsn6OmK9VBpUueGyp4nUWRSKR3DFe5gqbpk8uAC4ef6mSxnmFnIB/Z3NCAfKauyI2qjEhMMq+sQQU9Mqp+iCDahCwBZFgFJM6MpptC8736ehUL3Ke6nvkozIDgwuN2lhXbHxbnIvk7HgBwTz443Ey6LjLFHYRTLWr+mBQsHU7xpFCgugfz8bn32U6KPJnsCTa3G/QeObDiGPr2beg== 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=B3IKqwMqxwr3GYJ8Hww9a49BvL8+LA3RzBMj0XjS0XQ=; b=YtRnq/oLGB+1Jxok8uwFW0Tpf0a3n11THt3fmtnSc0doefRy+oD+JTziYwNuDjD+XLjK8KxLIZe5ksfS8Zx6wUKwWOAHJqKYACgVA+lxmpqQe9MO1QhlkEAOy7+U2Gu27SsegPJon2OvmUOK0nF6vDQbkgOQlL4ZCA3uLSnOzzsMVkPE22/RWupn1GEnUbEnC9ENJH84TF92rCV5D2OdEi/kEAv0le+KTnriVKhuNMAfNN81TGGXo0YL6S3u1o14q6PA0sKbGO5brIFQeLGOfwgbQDvi6y7pHExoPJOzl/jAxfRCGoBG6eXYMieLerqeO3uQMDllN0PpnY/x6nt3sA== Received: from BYAPR06CA0039.namprd06.prod.outlook.com (2603:10b6:a03:14b::16) by DS7PR12MB6312.namprd12.prod.outlook.com (2603:10b6:8:93::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.25; Tue, 15 Oct 2024 16:36:55 +0000 Received: from CO1PEPF000042AA.namprd03.prod.outlook.com (2603:10b6:a03:14b:cafe::61) by BYAPR06CA0039.outlook.office365.com (2603:10b6:a03:14b::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.27 via Frontend Transport; Tue, 15 Oct 2024 16:36: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 CO1PEPF000042AA.mail.protection.outlook.com (10.167.243.39) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.17 via Frontend Transport; Tue, 15 Oct 2024 16:36: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.1544.4; Tue, 15 Oct 2024 09:36:38 -0700 Received: from pegasus01.mtr.labs.mlnx (10.126.231.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; Tue, 15 Oct 2024 09:36:35 -0700 From: Alexander Kozyrev To: CC: , , , , , , , , Subject: [PATCH 5/5] net/mlx5: implement jump to table index action Date: Tue, 15 Oct 2024 19:35:57 +0300 Message-ID: <20241015163557.581447-5-akozyrev@nvidia.com> X-Mailer: git-send-email 2.18.2 In-Reply-To: <20241015163557.581447-1-akozyrev@nvidia.com> References: <20241015163557.581447-1-akozyrev@nvidia.com> MIME-Version: 1.0 X-Originating-IP: [10.126.231.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: CO1PEPF000042AA:EE_|DS7PR12MB6312:EE_ X-MS-Office365-Filtering-Correlation-Id: ad055842-a44a-4b1c-f203-08dced3794a5 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|36860700013|376014|1800799024|82310400026; X-Microsoft-Antispam-Message-Info: 6qx63qo8S5N5Sk/xpny4cIIrQIKmfHYqCKym52ct0l72IM1nEzl1wLu9RM2Dp4i09ilXeR5o/QquD8xZDXKG47rGvWCDGM2xS6AvlAKAKHdek6dAx90soIdDVXiZdwrKe7fAE7pxnPcblCgU7JZxxRjyWKjeYlQRSl1YO7WCvSHsMMZcnSHxhATPrCWT+SNmLAZMLJbyUiuYyGm6Kisu76H93SCTDVIwfD2EkcLMEApY6RO37MedHObJvP4NxpRpVLhv9ToWEBTUU46XMUQahMOt7CwKQh5A9sgYlK6vgn2jDYI8sR+OI9pZNovCdkJqRKxaxNnxnJ/EhZcR8KiBfnpDILYMNlCdMgczHXdZhGRiEt++GB3xSIUbJTqnWf00jp40Z6NwrATYmN0E/h8LatdjGQN1M82JaXmfToIFjdC3okK7iWgrVwPeIYZMw2FYx9NvboMyOzn+TmXySbmCL+pQiFCC5zjj/M8la6906SWPGxsxbk+siI39rZsoZ2XA7XtACWIx4P1X6C9M7OVT2m26/iK2LefdLEDbychNWuW1mcXHfef9iLb+A620ul65gtoK8IbTke0c0RqFy6II1Z+850jmgCtNqRintcWL9poJtNmXwbbH3GI3d8phm4xUKDN4PWWNNydpXkSYG60/AJ1EhwmP5X7xt0lYRTr2U+/2ZCUH6ly8Zcf+JmpZkmp6DC5oK4PrgnTPXtr97nKgTeLjzGJt3qxSe840QboZpfPMQDASnkgLMRv+RClMNPDX+rLOEvdbjrUnG1A1ZVts1zvVc3nezymRDlftGGASwsgHHHMbMKTwRnsJ83dsix11pgKl3pmG24J4DIm9DxwTuXXZ13GrchXB60pd0sDsIWAp5mcknMEglU0WHPeD9xx/kqf1zdAYyWc5KzFxFQe2lQR9WoQjK5xPegp4mpp2iIsbvouAWxsvaCZNqJkl9k8wIT+tK+l1Aj3Z86XnZBGxlcb+1XKyEsVVi3oX8lSy9xo8w2/+Qx8Gbckp0eo0Mp8aEowcBbyY4HrjWNfSTy0deT4/t4LGRXogTJuC1vhhv5cyfjM1A4LQI/IlwRsUwS6kRHDSdetI5tAqU6DcX4Bh/c9Koatrxp75TJbw3YiLPLz29wEnwWRuPGCtvLJkUtyozif/kiQBpevHk58/JFXR+/8MnJeYv6a3Jq8lX1Z0+awsvXIFh8hH2f38oqUtwdM7JYy7vi2HJjQhvfRQsVl9llMI213XWQBk16q1i5sw9MCL40e0z7BXP1F7SVo4ogHBrtsnmjmFBdNyDNSGZ6oL4Xfl6gXQSE/mtF2+hykLiMIpzIUvcVwzMxJ136hW8GkyVo3uhEpoOsPfL6q86JV2OqeLAg+mrtNWD3jna9yW9r0= 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:(13230040)(36860700013)(376014)(1800799024)(82310400026); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Oct 2024 16:36:55.1092 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ad055842-a44a-4b1c-f203-08dced3794a5 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: CO1PEPF000042AA.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR12MB6312 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 Implement RTE_FLOW_ACTION_TYPE_JUMP_TO_TABLE_INDEX action. Create the hardware steering jump to matcher action, assosiated with the template matcher. Use this action and provided rule index as an offset in the matcher. Note that it is only supported by the isolated matcher, i.e. the table insertion type is by index with pattern. Signed-off-by: Alexander Kozyrev --- drivers/net/mlx5/mlx5_flow.h | 8 +- drivers/net/mlx5/mlx5_flow_hw.c | 145 ++++++++++++++++++++++++++++++++ 2 files changed, 151 insertions(+), 2 deletions(-) diff --git a/drivers/net/mlx5/mlx5_flow.h b/drivers/net/mlx5/mlx5_flow.h index 86a1476879..3708e4d5bf 100644 --- a/drivers/net/mlx5/mlx5_flow.h +++ b/drivers/net/mlx5/mlx5_flow.h @@ -398,6 +398,7 @@ enum mlx5_feature_name { #define MLX5_FLOW_ACTION_IPV6_ROUTING_REMOVE (1ull << 48) #define MLX5_FLOW_ACTION_IPV6_ROUTING_PUSH (1ull << 49) #define MLX5_FLOW_ACTION_NAT64 (1ull << 50) +#define MLX5_FLOW_ACTION_JUMP_TO_TABLE_INDEX (1ull << 51) #define MLX5_FLOW_DROP_INCLUSIVE_ACTIONS \ (MLX5_FLOW_ACTION_COUNT | MLX5_FLOW_ACTION_SAMPLE | MLX5_FLOW_ACTION_AGE) @@ -408,12 +409,14 @@ enum mlx5_feature_name { MLX5_FLOW_ACTION_DEFAULT_MISS | \ MLX5_FLOW_ACTION_METER_WITH_TERMINATED_POLICY | \ MLX5_FLOW_ACTION_SEND_TO_KERNEL | \ - MLX5_FLOW_ACTION_PORT_REPRESENTOR) + MLX5_FLOW_ACTION_PORT_REPRESENTOR | \ + MLX5_FLOW_ACTION_JUMP_TO_TABLE_INDEX) #define MLX5_FLOW_FATE_ESWITCH_ACTIONS \ (MLX5_FLOW_ACTION_DROP | MLX5_FLOW_ACTION_PORT_ID | \ MLX5_FLOW_ACTION_SEND_TO_KERNEL | \ - MLX5_FLOW_ACTION_JUMP | MLX5_FLOW_ACTION_METER_WITH_TERMINATED_POLICY) + MLX5_FLOW_ACTION_JUMP | MLX5_FLOW_ACTION_METER_WITH_TERMINATED_POLICY | \ + MLX5_FLOW_ACTION_JUMP_TO_TABLE_INDEX) #define MLX5_FLOW_MODIFY_HDR_ACTIONS (MLX5_FLOW_ACTION_SET_IPV4_SRC | \ MLX5_FLOW_ACTION_SET_IPV4_DST | \ @@ -1704,6 +1707,7 @@ struct mlx5_flow_template_table_cfg { struct mlx5_matcher_info { struct mlx5dr_matcher *matcher; /* Template matcher. */ + struct mlx5dr_action *jump; /* Jump to matcher action. */ RTE_ATOMIC(uint32_t) refcnt; }; diff --git a/drivers/net/mlx5/mlx5_flow_hw.c b/drivers/net/mlx5/mlx5_flow_hw.c index 6c8404ee2c..2de89ab58e 100644 --- a/drivers/net/mlx5/mlx5_flow_hw.c +++ b/drivers/net/mlx5/mlx5_flow_hw.c @@ -729,6 +729,9 @@ flow_hw_action_flags_get(const struct rte_flow_action actions[], case MLX5_RTE_FLOW_ACTION_TYPE_DEFAULT_MISS: action_flags |= MLX5_FLOW_ACTION_DEFAULT_MISS; break; + case RTE_FLOW_ACTION_TYPE_JUMP_TO_TABLE_INDEX: + action_flags |= MLX5_FLOW_ACTION_JUMP_TO_TABLE_INDEX; + break; case RTE_FLOW_ACTION_TYPE_VOID: case RTE_FLOW_ACTION_TYPE_END: break; @@ -2925,6 +2928,34 @@ __flow_hw_translate_actions_template(struct rte_eth_dev *dev, src_pos, dr_pos)) goto err; break; + case RTE_FLOW_ACTION_TYPE_JUMP_TO_TABLE_INDEX: + if (masks->conf && + ((const struct rte_flow_action_jump_to_table_index *) + masks->conf)->table) { + struct rte_flow_template_table *jump_table = + ((const struct rte_flow_action_jump_to_table_index *) + actions->conf)->table; + acts->rule_acts[dr_pos].jump_to_matcher.offset = + ((const struct rte_flow_action_jump_to_table_index *) + actions->conf)->index; + if (likely(!rte_flow_template_table_resizable(dev->data->port_id, + &jump_table->cfg.attr))) { + acts->rule_acts[dr_pos].action = + jump_table->matcher_info[0].jump; + } else { + uint32_t selector; + rte_rwlock_read_lock(&jump_table->matcher_replace_rwlk); + selector = jump_table->matcher_selector; + acts->rule_acts[dr_pos].action = + jump_table->matcher_info[selector].jump; + rte_rwlock_read_unlock(&jump_table->matcher_replace_rwlk); + } + } else if (__flow_hw_act_data_general_append + (priv, acts, actions->type, + src_pos, dr_pos)){ + goto err; + } + break; case RTE_FLOW_ACTION_TYPE_END: actions_end = true; break; @@ -3527,6 +3558,7 @@ flow_hw_actions_construct(struct rte_eth_dev *dev, cnt_id_t cnt_id; uint32_t *cnt_queue; uint32_t mtr_id; + struct rte_flow_template_table *jump_table; action = &actions[act_data->action_src]; /* @@ -3759,6 +3791,25 @@ flow_hw_actions_construct(struct rte_eth_dev *dev, rule_acts[act_data->action_dst].action = priv->action_nat64[table->type][nat64_c->type]; break; + case RTE_FLOW_ACTION_TYPE_JUMP_TO_TABLE_INDEX: + jump_table = ((const struct rte_flow_action_jump_to_table_index *) + action->conf)->table; + if (likely(!rte_flow_template_table_resizable(dev->data->port_id, + &table->cfg.attr))) { + rule_acts[act_data->action_dst].action = + jump_table->matcher_info[0].jump; + } else { + uint32_t selector; + rte_rwlock_read_lock(&table->matcher_replace_rwlk); + selector = table->matcher_selector; + rule_acts[act_data->action_dst].action = + jump_table->matcher_info[selector].jump; + rte_rwlock_read_unlock(&table->matcher_replace_rwlk); + } + rule_acts[act_data->action_dst].jump_to_matcher.offset = + ((const struct rte_flow_action_jump_to_table_index *) + action->conf)->index; + break; default: break; } @@ -4963,6 +5014,10 @@ flow_hw_table_create(struct rte_eth_dev *dev, }; struct mlx5_priv *priv = dev->data->dev_private; struct mlx5dr_matcher_attr matcher_attr = {0}; + struct mlx5dr_action_jump_to_matcher_attr jump_attr = { + .type = MLX5DR_ACTION_JUMP_TO_MATCHER_BY_INDEX, + .matcher = NULL, + }; struct rte_flow_template_table *tbl = NULL; struct mlx5_flow_group *grp; struct mlx5dr_match_template *mt[MLX5_HW_TBL_MAX_ITEM_TEMPLATE]; @@ -5153,6 +5208,13 @@ flow_hw_table_create(struct rte_eth_dev *dev, tbl->type = attr->flow_attr.transfer ? MLX5DR_TABLE_TYPE_FDB : (attr->flow_attr.egress ? MLX5DR_TABLE_TYPE_NIC_TX : MLX5DR_TABLE_TYPE_NIC_RX); + if (matcher_attr.isolated) { + jump_attr.matcher = tbl->matcher_info[0].matcher; + tbl->matcher_info[0].jump = mlx5dr_action_create_jump_to_matcher(priv->dr_ctx, + &jump_attr, mlx5_hw_act_flag[!!attr->flow_attr.group][tbl->type]); + if (!tbl->matcher_info[0].jump) + goto jtm_error; + } /* * Only the matcher supports update and needs more than 1 WQE, an additional * index is needed. Or else the flow index can be reused. @@ -5175,6 +5237,9 @@ flow_hw_table_create(struct rte_eth_dev *dev, rte_rwlock_init(&tbl->matcher_replace_rwlk); return tbl; res_error: + if (tbl->matcher_info[0].jump) + mlx5dr_action_destroy(tbl->matcher_info[0].jump); +jtm_error: if (tbl->matcher_info[0].matcher) (void)mlx5dr_matcher_destroy(tbl->matcher_info[0].matcher); at_error: @@ -5439,8 +5504,12 @@ flow_hw_table_destroy(struct rte_eth_dev *dev, 1, rte_memory_order_relaxed); } flow_hw_destroy_table_multi_pattern_ctx(table); + if (table->matcher_info[0].jump) + mlx5dr_action_destroy(table->matcher_info[0].jump); if (table->matcher_info[0].matcher) mlx5dr_matcher_destroy(table->matcher_info[0].matcher); + if (table->matcher_info[1].jump) + mlx5dr_action_destroy(table->matcher_info[1].jump); if (table->matcher_info[1].matcher) mlx5dr_matcher_destroy(table->matcher_info[1].matcher); mlx5_hlist_unregister(priv->sh->groups, &table->grp->entry); @@ -6545,6 +6614,7 @@ flow_hw_template_expand_modify_field(struct rte_flow_action actions[], case RTE_FLOW_ACTION_TYPE_DROP: case RTE_FLOW_ACTION_TYPE_SEND_TO_KERNEL: case RTE_FLOW_ACTION_TYPE_JUMP: + case RTE_FLOW_ACTION_TYPE_JUMP_TO_TABLE_INDEX: case RTE_FLOW_ACTION_TYPE_QUEUE: case RTE_FLOW_ACTION_TYPE_RSS: case RTE_FLOW_ACTION_TYPE_REPRESENTED_PORT: @@ -6761,6 +6831,43 @@ flow_hw_validate_action_jump(struct rte_eth_dev *dev, return 0; } +static int +mlx5_flow_validate_action_jump_to_table_index(const struct rte_flow_action *action, + const struct rte_flow_action *mask, + struct rte_flow_error *error) +{ + const struct rte_flow_action_jump_to_table_index *m = mask->conf; + const struct rte_flow_action_jump_to_table_index *v = action->conf; + struct mlx5dr_action *jump_action; + uint32_t t_group = 0; + + if (!m || !m->table) + return 0; + if (!v) + return rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ACTION, action, + "Invalid jump to matcher action configuration"); + t_group = v->table->grp->group_id; + if (t_group == 0) + return rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ACTION, action, + "Unsupported action - jump to root table"); + if (likely(!rte_flow_template_table_resizable(0, &v->table->cfg.attr))) { + jump_action = v->table->matcher_info[0].jump; + } else { + uint32_t selector; + rte_rwlock_read_lock(&v->table->matcher_replace_rwlk); + selector = v->table->matcher_selector; + jump_action = v->table->matcher_info[selector].jump; + rte_rwlock_read_unlock(&v->table->matcher_replace_rwlk); + } + if (jump_action == NULL) + return rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ACTION, action, + "Unsupported action - table is not an rule array"); + return 0; +} + static int mlx5_hw_validate_action_mark(struct rte_eth_dev *dev, const struct rte_flow_action *template_action, @@ -7242,6 +7349,12 @@ mlx5_flow_hw_actions_validate(struct rte_eth_dev *dev, return ret; action_flags |= MLX5_FLOW_ACTION_DEFAULT_MISS; break; + case RTE_FLOW_ACTION_TYPE_JUMP_TO_TABLE_INDEX: + ret = mlx5_flow_validate_action_jump_to_table_index(action, mask, error); + if (ret < 0) + return ret; + action_flags |= MLX5_FLOW_ACTION_JUMP_TO_TABLE_INDEX; + break; default: return rte_flow_error_set(error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ACTION, @@ -7286,6 +7399,7 @@ static enum mlx5dr_action_type mlx5_hw_dr_action_types[] = { [RTE_FLOW_ACTION_TYPE_IPV6_EXT_PUSH] = MLX5DR_ACTION_TYP_PUSH_IPV6_ROUTE_EXT, [RTE_FLOW_ACTION_TYPE_IPV6_EXT_REMOVE] = MLX5DR_ACTION_TYP_POP_IPV6_ROUTE_EXT, [RTE_FLOW_ACTION_TYPE_NAT64] = MLX5DR_ACTION_TYP_NAT64, + [RTE_FLOW_ACTION_TYPE_JUMP_TO_TABLE_INDEX] = MLX5DR_ACTION_TYP_JUMP_TO_MATCHER, }; static inline void @@ -7513,6 +7627,11 @@ flow_hw_parse_flow_actions_to_dr_actions(struct rte_eth_dev *dev, at->dr_off[i] = curr_off; action_types[curr_off++] = MLX5DR_ACTION_TYP_MISS; break; + case RTE_FLOW_ACTION_TYPE_JUMP_TO_TABLE_INDEX: + *tmpl_flags |= MLX5DR_ACTION_TEMPLATE_FLAG_RELAXED_ORDER; + at->dr_off[i] = curr_off; + action_types[curr_off++] = MLX5DR_ACTION_TYP_JUMP_TO_MATCHER; + break; default: type = mlx5_hw_dr_action_types[at->actions[i].type]; at->dr_off[i] = curr_off; @@ -13949,6 +14068,7 @@ mlx5_mirror_destroy_clone(struct rte_eth_dev *dev, case RTE_FLOW_ACTION_TYPE_JUMP: flow_hw_jump_release(dev, clone->action_ctx); break; + case RTE_FLOW_ACTION_TYPE_JUMP_TO_TABLE_INDEX: case RTE_FLOW_ACTION_TYPE_REPRESENTED_PORT: case RTE_FLOW_ACTION_TYPE_PORT_REPRESENTOR: case RTE_FLOW_ACTION_TYPE_RAW_ENCAP: @@ -13982,6 +14102,7 @@ mlx5_mirror_terminal_action(const struct rte_flow_action *action) case RTE_FLOW_ACTION_TYPE_QUEUE: case RTE_FLOW_ACTION_TYPE_REPRESENTED_PORT: case RTE_FLOW_ACTION_TYPE_PORT_REPRESENTOR: + case RTE_FLOW_ACTION_TYPE_JUMP_TO_TABLE_INDEX: return true; default: break; @@ -14024,6 +14145,8 @@ mlx5_mirror_validate_sample_action(struct rte_eth_dev *dev, action[1].type != RTE_FLOW_ACTION_TYPE_RAW_ENCAP) return false; break; + case RTE_FLOW_ACTION_TYPE_JUMP_TO_TABLE_INDEX: + break; default: return false; } @@ -14758,8 +14881,14 @@ flow_hw_table_resize(struct rte_eth_dev *dev, struct mlx5dr_action_template *at[MLX5_HW_TBL_MAX_ACTION_TEMPLATE]; struct mlx5dr_match_template *mt[MLX5_HW_TBL_MAX_ITEM_TEMPLATE]; struct mlx5dr_matcher_attr matcher_attr = table->matcher_attr; + struct mlx5dr_action_jump_to_matcher_attr jump_attr = { + .type = MLX5DR_ACTION_JUMP_TO_MATCHER_BY_INDEX, + .matcher = NULL, + }; struct mlx5_multi_pattern_segment *segment = NULL; struct mlx5dr_matcher *matcher = NULL; + struct mlx5dr_action *jump = NULL; + struct mlx5_priv *priv = dev->data->dev_private; uint32_t i, selector = table->matcher_selector; uint32_t other_selector = (selector + 1) & 1; int ret; @@ -14807,6 +14936,17 @@ flow_hw_table_resize(struct rte_eth_dev *dev, table, "failed to create new matcher"); goto error; } + if (matcher_attr.isolated) { + jump_attr.matcher = matcher; + jump = mlx5dr_action_create_jump_to_matcher(priv->dr_ctx, &jump_attr, + mlx5_hw_act_flag[!!table->cfg.attr.flow_attr.group][table->type]); + if (!jump) { + ret = rte_flow_error_set(error, rte_errno, + RTE_FLOW_ERROR_TYPE_UNSPECIFIED, + table, "failed to create jump to matcher action"); + goto error; + } + } rte_rwlock_write_lock(&table->matcher_replace_rwlk); ret = mlx5dr_matcher_resize_set_target (table->matcher_info[selector].matcher, matcher); @@ -14819,6 +14959,7 @@ flow_hw_table_resize(struct rte_eth_dev *dev, } table->cfg.attr.nb_flows = nb_flows; table->matcher_info[other_selector].matcher = matcher; + table->matcher_info[other_selector].jump = jump; table->matcher_selector = other_selector; rte_atomic_store_explicit(&table->matcher_info[other_selector].refcnt, 0, rte_memory_order_relaxed); @@ -14827,6 +14968,8 @@ flow_hw_table_resize(struct rte_eth_dev *dev, error: if (segment) mlx5_destroy_multi_pattern_segment(segment); + if (jump) + mlx5dr_action_destroy(jump); if (matcher) { ret = mlx5dr_matcher_destroy(matcher); return rte_flow_error_set(error, rte_errno, @@ -14857,6 +15000,8 @@ flow_hw_table_resize_complete(__rte_unused struct rte_eth_dev *dev, return rte_flow_error_set(error, EBUSY, RTE_FLOW_ERROR_TYPE_UNSPECIFIED, table, "cannot complete table resize"); + if (matcher_info->jump) + mlx5dr_action_destroy(matcher_info->jump); ret = mlx5dr_matcher_destroy(matcher_info->matcher); if (ret) return rte_flow_error_set(error, rte_errno,