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 BB96744165; Wed, 5 Jun 2024 20:35:25 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 4723D40E78; Wed, 5 Jun 2024 20:35:19 +0200 (CEST) Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2086.outbound.protection.outlook.com [40.107.244.86]) by mails.dpdk.org (Postfix) with ESMTP id D942540A6B for ; Wed, 5 Jun 2024 20:35:17 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=HP+XD0cYcA4bx/TvXRSEKBopzP8e/zijPAfr8l3K8xjN6Lk/Rzh2wGxeHesdLeaIAkxKqXYXBhoKJm2Jl8IHsBh1RPbifgglMFaurpMmCrR2Jxhxe5pPHShPtCWEWuLr3bcG/VSdbuZBMdzokUWkX/7i9jZDMT0mRthL9F8oIf9QIzxUgVsv7P59GHEocNFP0DiYSZZKmavyqCnNBkCaviivKcZGPq8gxf1IuyZ4f5D+bD9cqdTllPQcH6rND4IFShxWZE999DTSOzGE/XaGKoNfMNDSav2qxuGRtoz5jBsJc4aV2yrRjcNZfGfN58wfMYw2YVAU3MHlWEftgwyZUQ== 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=Kt3oARjqiG/qKCPV88asq/zMgHRG52X50eRZNKnCIvc=; b=MHAzqf4XidKgWjIU8rOsRlaAAUv6c52MHvYLn84IlgK57rT+mXCZi3NPFiN01zJXtIENmzse2Q0rAYzektgVLQFPBkVbePNyHc0iPxZGiySziq5tif3YTm3f0BAHA6Bge6wc0ylAAxkHUDr7yucuuMYL4am9gWoKUat6lkaDgWEGuKW68hGZhGfK1K2cfRqTm6S/mD4Z25aU0TPMxA5KprDZhYDYal4LjoxLolFprSYiTORa1MV2Zxu3+bvPeuPrP71+ozX/4lkF6Wc/U0lBEz3H6C0vdFaYKpskHtdwCrq6NWayw/F81CH7PuQNvckxubFcuolJ98DJClr5QDcN2A== 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=Kt3oARjqiG/qKCPV88asq/zMgHRG52X50eRZNKnCIvc=; b=maIibUay+jgMrEGvc8EamjOH/DGW3qsoVqqPQumGJ2cnhLyyE/32OI2DI6ehGLg/1bGp90gdgwPNXcKz52SXpVi4jjWJ3HoPOpXYJ1/IIVsobvPlUR9esW9tI+PwxmqMZ3Xv0VkiTM/4OyXsF4Hy8eCMZGqFvOBqNp5akdVWmuZKhHN2EEL7zMaR0gZu19VJC5lfso+vkgVsnIhxlciOnthHCRC/NugabwXO1aDBpGmh4VvnBb8b13Sg+h7LhYOJNhiNvo41MxiLJHc/Oq3hBWjPYjZWnlKdge8xgWrCZd1D+RCKcFfzjqN49wSRMwiCg+1Eob20cWaeY+/Vql2/eQ== Received: from MN2PR03CA0020.namprd03.prod.outlook.com (2603:10b6:208:23a::25) by CY8PR12MB7490.namprd12.prod.outlook.com (2603:10b6:930:91::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7633.31; Wed, 5 Jun 2024 18:35:14 +0000 Received: from BN3PEPF0000B076.namprd04.prod.outlook.com (2603:10b6:208:23a:cafe::43) by MN2PR03CA0020.outlook.office365.com (2603:10b6:208:23a::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7633.31 via Frontend Transport; Wed, 5 Jun 2024 18:35:14 +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 BN3PEPF0000B076.mail.protection.outlook.com (10.167.243.121) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7633.15 via Frontend Transport; Wed, 5 Jun 2024 18:35:14 +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; Wed, 5 Jun 2024 11:34:51 -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.1544.4; Wed, 5 Jun 2024 11:34:49 -0700 From: Dariusz Sosnowski To: Viacheslav Ovsiienko , Ori Kam , Suanming Mou , Matan Azrad CC: Subject: [PATCH 4/9] net/mlx5: store pattern template items Date: Wed, 5 Jun 2024 20:34:14 +0200 Message-ID: <20240605183419.489323-5-dsosnowski@nvidia.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240605183419.489323-1-dsosnowski@nvidia.com> References: <20240605183419.489323-1-dsosnowski@nvidia.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [10.126.230.35] X-ClientProxiedBy: rnnvmail201.nvidia.com (10.129.68.8) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN3PEPF0000B076:EE_|CY8PR12MB7490:EE_ X-MS-Office365-Filtering-Correlation-Id: 57bf541f-11ff-49d5-9c54-08dc858e3db7 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230031|36860700004|376005|1800799015|82310400017; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?ovB937qhI9kil9Vj0w5nty9lpQHSwDaPXs4Y6PZs8lww7+cgS7r8+bceSbmc?= =?us-ascii?Q?yTlKOKpv+hnQDV7O0WK8YA7qi/HKw6n6x8aFUlryEX2B+915hIodlvBdCQwv?= =?us-ascii?Q?3D/DNHNDhHcXnrfpnwgHe5uF7ncbe+/otzbPWiNPsff7KojMZ7Utlnlke///?= =?us-ascii?Q?yQQ3QD5NFZpZXfcF0aLX9z3zE7zlErV3evoQNNxG/ZeRMzlFwB+hI+yQX2Yh?= =?us-ascii?Q?doP2jqfztFGO+G7s3iaCntGXI9lI3ALFOCmHtcf8vMUVrT0jlYbS/BO3uQ2K?= =?us-ascii?Q?NeZsyVc7IRWYMXwUbN0+pwU1wzC+HV9TGpy+L4kWXckdwBMfAwN0c+CGj6Vn?= =?us-ascii?Q?GfmJEujLcyh4TbJToWTOt+0Bd26cL5P7bTuWKM+PfhCumJdFyS6Jts5ukk7L?= =?us-ascii?Q?UM4ugO6WaokwgsB1tHE3Xf5KtsLI+LsY7OpQkfyT4Fxu6JoEbadju5uSJBQO?= =?us-ascii?Q?16oBNdSPmejib7+1Dha1d+aqDdZkkaKnlZCbAf89hqw24xaDPJSBuL5Wtp79?= =?us-ascii?Q?xCGGSYKMMLvTBKY3rffRZ7wsSO7xM4Jhz4r3LpNdvW3btigf1T8GjqjhSJVq?= =?us-ascii?Q?BsAYssvxc/aW6buK5SHmVXJXyDXZ/SqnwxoPpujznu1H6zDF2N4wm5vra06F?= =?us-ascii?Q?WVkgejg1hpql04eWs2Rlc7jFpPR8bkw3Lzqv3LwzxZldufFdbDIamo150w34?= =?us-ascii?Q?ZsK+Z6K8YIyh8+awAcP28hC0Eq/Rh+1v6bE3NJOsEDpZOg6zOLnVsGt7gXDh?= =?us-ascii?Q?7JRolrqnyRU0KmuywrWLGJxi6/VEmxb9M3eTQ2LPfn+jLTZ/y+PcZpEb9IsX?= =?us-ascii?Q?rXq+ECwb7Z0p6mzA5Q9RF7xunlcb9wp1bwK7+2qKHsqUmQLQMT7+X3CXAACP?= =?us-ascii?Q?kwIr7EEQp8Waha1qO31kNn8/iNFynEqiM8yV2cYZETu3qCWuEVcHwFzdYKiv?= =?us-ascii?Q?dYVAcdH5rCO10akgadB2o23xFvSe3At6zZhWuxfL86vknHWZTKZAcCPlPCvi?= =?us-ascii?Q?GA/AswWSZewP5egQv8z+ZOl8DROsEAPT9S6+riw4mMaX/mLHlG0YPOENkLZP?= =?us-ascii?Q?3eqqiRHqAhM/86oICvQpt6tipWk3Ct4Q7w6FapvJ/WPZ5N8XTwQPUoHZBMY9?= =?us-ascii?Q?OaLDIOoyztP7xsobwE+87rW+NQkasFcsMLFYK02aKucCtdpX64IWm5/2QDIz?= =?us-ascii?Q?Tia7QXsg9C1rIk3ziVvqN9xl61bRRdTOVBKRjWXX2n/fq6B/K4r8vphzxnMw?= =?us-ascii?Q?/CJfAsUQWDd3DD5YJGaXNROMZveuN3sH5joBHh07y+Ni4/QX4Dk9PS0fQnoK?= =?us-ascii?Q?u6XPflWGhhsUDA5PdA6nql52qkhkgdqr6t3tl9WOUFnLYX1GWUpWSOua4y8K?= =?us-ascii?Q?JTyzwp2MnQ4D5lAxFPgxlFNAwoBvc8jtWeKizZvaLYE4ZCosFQ=3D=3D?= X-Forefront-Antispam-Report: CIP:216.228.117.161; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc6edge2.nvidia.com; CAT:NONE; SFS:(13230031)(36860700004)(376005)(1800799015)(82310400017); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Jun 2024 18:35:14.5030 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 57bf541f-11ff-49d5-9c54-08dc858e3db7 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: BN3PEPF0000B076.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY8PR12MB7490 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 Store items which define the pattern template on creation. This allows validation of items, provided by the user during flow rule creation, against pattern template. Signed-off-by: Dariusz Sosnowski Acked-by: Ori Kam --- drivers/net/mlx5/mlx5_flow.h | 2 ++ drivers/net/mlx5/mlx5_flow_hw.c | 29 +++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/drivers/net/mlx5/mlx5_flow.h b/drivers/net/mlx5/mlx5_flow.h index 7be95a7d18..5997ffb5e0 100644 --- a/drivers/net/mlx5/mlx5_flow.h +++ b/drivers/net/mlx5/mlx5_flow.h @@ -1489,6 +1489,8 @@ struct rte_flow_pattern_template { /* Manages all GENEVE TLV options used by this pattern template. */ struct mlx5_geneve_tlv_options_mng geneve_opt_mng; uint8_t flex_item; /* flex item index. */ + /* Items on which this pattern template is based on. */ + struct rte_flow_item *items; }; /* Flow action template struct. */ diff --git a/drivers/net/mlx5/mlx5_flow_hw.c b/drivers/net/mlx5/mlx5_flow_hw.c index 24b86535b1..132f6ca264 100644 --- a/drivers/net/mlx5/mlx5_flow_hw.c +++ b/drivers/net/mlx5/mlx5_flow_hw.c @@ -8401,6 +8401,7 @@ flow_hw_pattern_template_create(struct rte_eth_dev *dev, .mask = &tag_m, .last = NULL }; + int it_items_size; unsigned int i = 0; int rc; @@ -8444,6 +8445,31 @@ flow_hw_pattern_template_create(struct rte_eth_dev *dev, it->attr = *attr; it->item_flags = item_flags; it->orig_item_nb = orig_item_nb; + it_items_size = rte_flow_conv(RTE_FLOW_CONV_OP_PATTERN, NULL, 0, tmpl_items, error); + if (it_items_size <= 0) { + rte_flow_error_set(error, ENOMEM, + RTE_FLOW_ERROR_TYPE_UNSPECIFIED, + NULL, + "Failed to determine buffer size for pattern"); + goto error; + } + it_items_size = RTE_ALIGN(it_items_size, 16); + it->items = mlx5_malloc(MLX5_MEM_ZERO, it_items_size, 0, rte_dev_numa_node(dev->device)); + if (it->items == NULL) { + rte_flow_error_set(error, ENOMEM, + RTE_FLOW_ERROR_TYPE_UNSPECIFIED, + NULL, + "Cannot allocate memory for pattern"); + goto error; + } + rc = rte_flow_conv(RTE_FLOW_CONV_OP_PATTERN, it->items, it_items_size, tmpl_items, error); + if (rc <= 0) { + rte_flow_error_set(error, ENOMEM, + RTE_FLOW_ERROR_TYPE_UNSPECIFIED, + NULL, + "Failed to store pattern"); + goto error; + } it->mt = mlx5dr_match_template_create(tmpl_items, attr->relaxed_matching); if (!it->mt) { rte_flow_error_set(error, rte_errno, @@ -8458,6 +8484,7 @@ flow_hw_pattern_template_create(struct rte_eth_dev *dev, else if (attr->egress) it->implicit_tag = true; mlx5_free(copied_items); + copied_items = NULL; } /* Either inner or outer, can't both. */ if (it->item_flags & (MLX5_FLOW_ITEM_OUTER_IPV6_ROUTING_EXT | @@ -8518,6 +8545,7 @@ flow_hw_pattern_template_create(struct rte_eth_dev *dev, mlx5_geneve_tlv_options_unregister(priv, &it->geneve_opt_mng); if (it->mt) claim_zero(mlx5dr_match_template_destroy(it->mt)); + mlx5_free(it->items); mlx5_free(it); } if (copied_items) @@ -8560,6 +8588,7 @@ flow_hw_pattern_template_destroy(struct rte_eth_dev *dev, flow_hw_flex_item_release(dev, &template->flex_item); mlx5_geneve_tlv_options_unregister(priv, &template->geneve_opt_mng); claim_zero(mlx5dr_match_template_destroy(template->mt)); + mlx5_free(template->items); mlx5_free(template); return 0; } -- 2.39.2