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 031CC42568; Sun, 10 Sep 2023 16:04:23 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 0D556402D3; Sun, 10 Sep 2023 16:04:20 +0200 (CEST) Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2067.outbound.protection.outlook.com [40.107.237.67]) by mails.dpdk.org (Postfix) with ESMTP id 427A6402D2 for ; Sun, 10 Sep 2023 16:04:18 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=K0RWCnWCWEIHH7Y4lAlbu34MnY9alLv3F+m4UM1kUMzHYVbVqa5v8HPhoyETv+fOxe+IyJcJNI5Pi+ayB4WykrQs/qBlRT84l7UX9yxnLfcRTk16L6/f8ez6GOGs/9r8LFroAMhhqV7nG3/dFxAdIvBMSRj4XNTHij68G6F9K7l02Kcz9KVzU5Bjjzx8BVrVmoT0PO34GfNeawtXQbItj9Vljh6ZWh5RATUs3S6i5WUxJx+Ke08PFK9UlC9keu+rXWMca8fTU2UmCirh1b6k0sPNPHngb5+vUkUCSyWxMf79DbnDgabxsVLEVzkBft0YmCcxTa6b6ZrP9crSHRkFWA== 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=0/nTPp2lBGGKuvUezPfpcFmXlCGiiFGSXdYLGYjwfEE=; b=CzPfDTjCv9JT8IzsqkglA/JHbRO3kH5Iyfnd32kRb2UUNJ7kgUXgtG5F6CpKCrT9Yq8EFrI8Jq6OJXp0mRfUfWvMzlU+F5ZRg2oDzheSJ2s7/sXj6W6v0ZlU8pVsJRJoRDAdn9upfEs/7KkU8x8b1YacCcCfV5gax6dNm3y1rJz8sFuZYBnukNS1lblWkJIcQ3leTLwbDt0YRKA9URpLA3n21Hx7NyJLe+AT2WAltStfoC2m+bClQnkORH/Wyj+LCBxn7ersalNkbnczY0bE8vukoj5Og2g/RUvXUFxXix3KEOBpeTzzdd7BjUgJDIzTk0tIm7ApBo9dfJaeSsLT7Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) smtp.rcpttodomain=monjalon.net 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 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=0/nTPp2lBGGKuvUezPfpcFmXlCGiiFGSXdYLGYjwfEE=; b=LRc1Z+HnGlZPB0THHs36qb1FhQEMXGng2ZVC6T2zn5PjCZViRE5uNvA7Zz6B2fh5LnGHtMmzb1InTgAsZQUxWgvs2J6KNUPdKEqT0BJh3sW9UEoNKbDHXu1a9lznkI7iNPeRy0cFRYBFzU7lA/HS9fzUgxj2KiXDIH5hV8lHNIFFjIREfikmDyCEPWBWgvgXtv+K0UiUVQ1qI8kfJXJ9iuvWIkOd1spht4AKLpl5nbw0MtAkCCvDvIru8nZ/sia5AN8MMRiihBlNFUcZFYurmQnbuwlUCwiyFPcZUA4LJ9/zZt++tAdftV5UUMZDP+Zi0XGetVoynulDBYhl/jVgqg== Received: from BLAPR05CA0039.namprd05.prod.outlook.com (2603:10b6:208:335::20) by SJ2PR12MB8111.namprd12.prod.outlook.com (2603:10b6:a03:4fe::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6768.30; Sun, 10 Sep 2023 14:04:16 +0000 Received: from MN1PEPF0000ECD6.namprd02.prod.outlook.com (2603:10b6:208:335:cafe::55) by BLAPR05CA0039.outlook.office365.com (2603:10b6:208:335::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6792.15 via Frontend Transport; Sun, 10 Sep 2023 14:04:15 +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 MN1PEPF0000ECD6.mail.protection.outlook.com (10.167.242.135) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6792.11 via Frontend Transport; Sun, 10 Sep 2023 14:04:15 +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.986.5; Sun, 10 Sep 2023 07:04:07 -0700 Received: from nvidia.com (10.126.230.35) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.37; Sun, 10 Sep 2023 07:04:05 -0700 From: Erez Shitrit To: , , , "Matan Azrad" , Viacheslav Ovsiienko , "Ori Kam" CC: Subject: [PATCH 2/4] net/mlx5/hws: allow attaching action template to matcher Date: Sun, 10 Sep 2023 17:03:17 +0300 Message-ID: <20230910140319.3064208-2-erezsh@nvidia.com> X-Mailer: git-send-email 2.18.2 In-Reply-To: <20230910140319.3064208-1-erezsh@nvidia.com> References: <20230910140319.3064208-1-erezsh@nvidia.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.126.230.35] X-ClientProxiedBy: rnnvmail202.nvidia.com (10.129.68.7) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MN1PEPF0000ECD6:EE_|SJ2PR12MB8111:EE_ X-MS-Office365-Filtering-Correlation-Id: 75409076-a527-461c-73b9-08dbb206d186 X-LD-Processed: 43083d15-7273-40c1-b7db-39efd9ccc17a,ExtAddr X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: bZtA1VkvFQZwpeXYjwzIAyN7lxlZRz/trSa6s/CkU6L0IMqKcAvGDT4iONIPWa/NXS+JdrTfZXF130V/N6cn2YnnP/WPz02ebs9qHlyI/R2dmXmRWfUwNcVsnPCcibVSuXirzzzDMpwbYC2dYxyV1ebnESZLmjmm9Tt3bks3ebZsFWyN70NH/y1YjnZj9BvvRiG9ki80OEQTnE4R0uosvSdqGlJ2iGvNtEXxIL0cX4AjRuZ4qydmBuM0b+yxvPA8oWNImI6bjXAisVtdOe0zvdioWXfKaVGRiMtrS9yxjpfzCoXtQ/mhvMIGfp4lE8hGEj5itJ39YXEoUPCeGuh4guyVoJeEmWmA7PH3OFqRp+DyrZ308H9Tyafd86AmP8NQoqDgeZ84WyG7k3sQkmUUvRl8zQZig10fxSRGIZ6Jq0RgG/FHzXyX3LNG13ILIUYabdnNYmO7599lO1WRTYDVx34RMNACE+wZqOrxpCkASELNxJeCXZ7wfc/vYJkBAZArxJh/uURFr19ve3mOJLqo3ssxEQhFyjK7eigg+knBC3U7d9MgoTevYhD7XQmJizwLF5E1PRQuz7dkD0aGqiEC77FvNOPlT86V9oGiv9vPTvCznLhq70sac/idOBGGwXMZxBmF4bcHXes+AH0nkD5PuBvMFdxpfIHzS8fm9xqMYnWypeWQIQyI//i/w1Y+Js4NdVKUrFpZaEgXLGKvPhqtJ7gi3r19VMoxdDYaqOC74vQKpXyCbXByKG4oejClRuNg 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)(4636009)(39860400002)(376002)(346002)(396003)(136003)(186009)(1800799009)(451199024)(82310400011)(40470700004)(36840700001)(46966006)(70586007)(8676002)(5660300002)(8936002)(4326008)(41300700001)(40480700001)(70206006)(110136005)(316002)(6636002)(2906002)(40460700003)(47076005)(36860700001)(83380400001)(7636003)(55016003)(82740400003)(2616005)(6286002)(1076003)(16526019)(26005)(336012)(426003)(86362001)(356005)(478600001)(36756003)(6666004)(7696005); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Sep 2023 14:04:15.5823 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 75409076-a527-461c-73b9-08dbb206d186 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: MN1PEPF0000ECD6.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ2PR12MB8111 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 Allow user to add new action-template after the creation of the matcher. It is allowed only if the user indicates in the mlx5dr_matcher_attr that he might add new AT in the future by indicating the max_num_of_at and if needed the max_num_of_actions_in_at value. With these two values the matcher is configured to get new AT in the future. Signed-off-by: Erez Shitrit Signed-off-by: Alex Vesker Acked-by: Matan Azrad --- drivers/net/mlx5/hws/mlx5dr.h | 13 +++++ drivers/net/mlx5/hws/mlx5dr_matcher.c | 82 +++++++++++++++++++++++---- 2 files changed, 83 insertions(+), 12 deletions(-) diff --git a/drivers/net/mlx5/hws/mlx5dr.h b/drivers/net/mlx5/hws/mlx5dr.h index 5592af93c9..184de8feaf 100644 --- a/drivers/net/mlx5/hws/mlx5dr.h +++ b/drivers/net/mlx5/hws/mlx5dr.h @@ -139,6 +139,8 @@ struct mlx5dr_matcher_attr { uint8_t num_log; } rule; }; + /* Optional AT attach configuration - Max number of additional AT */ + uint8_t max_num_of_at_attach; }; struct mlx5dr_rule_attr { @@ -328,6 +330,17 @@ mlx5dr_matcher_create(struct mlx5dr_table *table, */ int mlx5dr_matcher_destroy(struct mlx5dr_matcher *matcher); +/* Attach new action template to direct rule matcher. + * + * @param[in] matcher + * Matcher to attach at to. + * @param[in] at + * Action template to be attached to the matcher. + * @return zero on success non zero otherwise. + */ +int mlx5dr_matcher_attach_at(struct mlx5dr_matcher *matcher, + struct mlx5dr_action_template *at); + /* Get the size of the rule handle (mlx5dr_rule) to be used on rule creation. * * @return size in bytes of rule handle struct. diff --git a/drivers/net/mlx5/hws/mlx5dr_matcher.c b/drivers/net/mlx5/hws/mlx5dr_matcher.c index 1fe7ec1bc3..a02f42a7e8 100644 --- a/drivers/net/mlx5/hws/mlx5dr_matcher.c +++ b/drivers/net/mlx5/hws/mlx5dr_matcher.c @@ -680,6 +680,30 @@ static void mlx5dr_matcher_set_pool_attr(struct mlx5dr_pool_attr *attr, } } +static int mlx5dr_matcher_check_and_process_at(struct mlx5dr_matcher *matcher, + struct mlx5dr_action_template *at) +{ + bool valid; + int ret; + + /* Check if action combinabtion is valid */ + valid = mlx5dr_action_check_combo(at->action_type_arr, matcher->tbl->type); + if (!valid) { + DR_LOG(ERR, "Invalid combination in action template"); + rte_errno = EINVAL; + return rte_errno; + } + + /* Process action template to setters */ + ret = mlx5dr_action_template_process(at); + if (ret) { + DR_LOG(ERR, "Failed to process action template"); + return ret; + } + + return 0; +} + static int mlx5dr_matcher_bind_at(struct mlx5dr_matcher *matcher) { bool is_jumbo = mlx5dr_matcher_mt_is_jumbo(matcher->mt); @@ -689,22 +713,13 @@ static int mlx5dr_matcher_bind_at(struct mlx5dr_matcher *matcher) struct mlx5dr_context *ctx = tbl->ctx; uint32_t required_stes; int i, ret; - bool valid; for (i = 0; i < matcher->num_of_at; i++) { struct mlx5dr_action_template *at = &matcher->at[i]; - /* Check if action combinabtion is valid */ - valid = mlx5dr_action_check_combo(at->action_type_arr, matcher->tbl->type); - if (!valid) { - DR_LOG(ERR, "Invalid combination in action template %d", i); - return rte_errno; - } - - /* Process action template to setters */ - ret = mlx5dr_action_template_process(at); + ret = mlx5dr_matcher_check_and_process_at(matcher, at); if (ret) { - DR_LOG(ERR, "Failed to process action template %d", i); + DR_LOG(ERR, "Invalid at %d", i); return rte_errno; } @@ -924,6 +939,10 @@ mlx5dr_matcher_process_attr(struct mlx5dr_cmd_query_caps *caps, DR_LOG(ERR, "Root matcher can't specify FDB direction"); goto not_supported; } + if (attr->max_num_of_at_attach) { + DR_LOG(ERR, "Root matcher does not support at attaching"); + goto not_supported; + } return 0; } @@ -1039,6 +1058,8 @@ mlx5dr_matcher_create_col_matcher(struct mlx5dr_matcher *matcher) if (col_matcher->attr.table.sz_row_log > MLX5DR_MATCHER_ASSURED_ROW_RATIO) col_matcher->attr.table.sz_row_log -= MLX5DR_MATCHER_ASSURED_ROW_RATIO; + col_matcher->attr.max_num_of_at_attach = matcher->attr.max_num_of_at_attach; + ret = mlx5dr_matcher_process_attr(ctx->caps, col_matcher, false); if (ret) goto free_col_matcher; @@ -1212,6 +1233,42 @@ static int mlx5dr_matcher_uninit_root(struct mlx5dr_matcher *matcher) return ret; } +int mlx5dr_matcher_attach_at(struct mlx5dr_matcher *matcher, + struct mlx5dr_action_template *at) +{ + bool is_jumbo = mlx5dr_matcher_mt_is_jumbo(matcher->mt); + uint32_t required_stes; + int ret; + + if (!matcher->attr.max_num_of_at_attach) { + DR_LOG(ERR, "Num of current at (%d) exceed allowed value", + matcher->num_of_at); + rte_errno = ENOTSUP; + return -rte_errno; + } + + ret = mlx5dr_matcher_check_and_process_at(matcher, at); + if (ret) + return -rte_errno; + + 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]", + required_stes, matcher->action_ste.max_stes); + rte_errno = ENOMEM; + return -rte_errno; + } + + matcher->at[matcher->num_of_at] = *at; + matcher->num_of_at += 1; + matcher->attr.max_num_of_at_attach -= 1; + + if (matcher->col_matcher) + matcher->col_matcher->num_of_at = matcher->num_of_at; + + return 0; +} + static int mlx5dr_matcher_set_templates(struct mlx5dr_matcher *matcher, struct mlx5dr_match_template *mt[], @@ -1241,7 +1298,8 @@ mlx5dr_matcher_set_templates(struct mlx5dr_matcher *matcher, return rte_errno; } - matcher->at = simple_calloc(num_of_at, sizeof(*matcher->at)); + matcher->at = simple_calloc(num_of_at + matcher->attr.max_num_of_at_attach, + sizeof(*matcher->at)); if (!matcher->at) { DR_LOG(ERR, "Failed to allocate action template array"); rte_errno = ENOMEM; -- 2.18.2