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 BF05641F45; Wed, 12 Jun 2024 18:25:25 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 7868640EF1; Wed, 12 Jun 2024 18:25:14 +0200 (CEST) Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2046.outbound.protection.outlook.com [40.107.220.46]) by mails.dpdk.org (Postfix) with ESMTP id 8600040EE1 for ; Wed, 12 Jun 2024 18:25:13 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=AG2g3rCHGKcSQgL47Lc4bOODgIIikk3epdqbpIPg7CApaTqsN792PTyvmA+fEmMxc4Fn09OLZMyqG7Dtxk7rSiw7v/wMSKUoKX1Oj8TsMeIMp03OeQtqCBTYjKfovW9jZ//D6Mth6I6PyFvDCzytfeJYIM0KbPArTOdrdCg9Ypt9MIMJLVPricb1SazxqlNI1HA+QbE6jyTvm3cQQO3bvbyw31192Fl62RKwZ1leaUi20fzRbKQiL53tiVuo64JAgS2HvN9oxTbMv9hDtcsDT/axRoeeOKq11suw1LswrBRSne0Q9LDQ1Z2iPD3n+czzFamp70BW9+ZcnNavXDHT0A== 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=1zzlDbKg46c/UbbdLfjjYyOwGRENE5yWjqx4u03kxHw=; b=CrnIxw2LdDLAoXpVmCjuDy5E+CE5x/rZxSaMhvedHzDqQ6/6zgLFD8e+m7UUkSZKoDB+0NudllFvpmOVzoVcP6TgSS0QIRruwwPM4sTfdoTGZR+KrN7QXz3hyXqlom1Kxeue2vWFlgwfyIA8PkDzwF+MmHBazjT47KAaiMvak03yLy6EznBuAXoKCtSZYIdotDhD3bfZfQnnxhxzQsKS6WWgAPEjAxeR6RTRC2kN8chqfcmCzz6oA8/+gLsW+C4Fb6WOSz6eGN4C/4lg1gbG19/32oG+KW384XDWpW9OgczAE5Udk3wVO+MvZ9zHfpuw655vGTDBJUaGCnV/9Qx1Pg== 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=1zzlDbKg46c/UbbdLfjjYyOwGRENE5yWjqx4u03kxHw=; b=DL4Sd1S7ka8FmY9OEwc10TY2xjHi795z/pbTePEF9JUEg5WbRAiN0/kb+y5CNS+WwsaQ2ILf7w4PXHyIlhlu6rs4Vy0ygVx8kkjp8yw1rK5PLfwUB9BdccUtxt7RPi/6tfnfnj3FF3SZ/FkFjqFHtjHt2XbnZ0+/ULs22fUa1i5SdbQk1pPZsH259K3vhPQ/Mlbd87b1pZpacx5Yq7gvIby9yOHdJXq6i0ucItD3+galL04CSalRPss9biuiHCvgxBkrAV79FpREhIIxsgs2s9h4b1W+xjNtBj9GE/guWGf8w1eTWdg95zUK980i47FrxahoRlqSzo6vGX67JSsN1Q== Received: from BY5PR20CA0012.namprd20.prod.outlook.com (2603:10b6:a03:1f4::25) by PH7PR12MB6882.namprd12.prod.outlook.com (2603:10b6:510:1b8::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7633.36; Wed, 12 Jun 2024 16:25:09 +0000 Received: from SJ5PEPF000001D7.namprd05.prod.outlook.com (2603:10b6:a03:1f4:cafe::ae) by BY5PR20CA0012.outlook.office365.com (2603:10b6:a03:1f4::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7677.21 via Frontend Transport; Wed, 12 Jun 2024 16:25:09 +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 SJ5PEPF000001D7.mail.protection.outlook.com (10.167.242.59) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7677.15 via Frontend Transport; Wed, 12 Jun 2024 16:25:08 +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; Wed, 12 Jun 2024 09:24:55 -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, 12 Jun 2024 09:24:52 -0700 From: Dariusz Sosnowski To: Viacheslav Ovsiienko , Ori Kam , Suanming Mou , Matan Azrad CC: Subject: [PATCH v2 3/8] net/mlx5: store pattern template items Date: Wed, 12 Jun 2024 18:24:21 +0200 Message-ID: <20240612162426.978117-4-dsosnowski@nvidia.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240612162426.978117-1-dsosnowski@nvidia.com> References: <20240605183419.489323-1-dsosnowski@nvidia.com> <20240612162426.978117-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: 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: SJ5PEPF000001D7:EE_|PH7PR12MB6882:EE_ X-MS-Office365-Filtering-Correlation-Id: d2c1559d-48aa-4cf2-85cf-08dc8afc39fd X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230034|36860700007|376008|1800799018|82310400020; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?1lp9JPSdARR1NxiDh4ywEZnS/ejQo+IdNMdlRqtEiOxOjI1fI67pnQSl2HSx?= =?us-ascii?Q?9C/H9uujjD2fiCkiy2PvbSO43S1PFpo2K/iMvQiV8DvvJ71HyrG1Xr76UEUZ?= =?us-ascii?Q?eHTUH63Pvk1+G8YEq6+MqSBYECjE9LFABmJ0wkinoPgkds8fU5PcwQIaFlQS?= =?us-ascii?Q?i4Uw/f00wTZI+u3Xy3JPhsPNKpZlhWk7CA2pchJdzFgFORisrMC9vujpN795?= =?us-ascii?Q?4nsLlFHwyIDwuL2mHD1jnMjpnlIi6Ufyxih5q7QX5Aqh9e6juRx/4C3rPO4+?= =?us-ascii?Q?PKd+pJwjGaw7ZBlKDCGkktncucc3gxt80448vJzPcmsrGBuyAvxth+GvjF5o?= =?us-ascii?Q?kD9XCWWUnm5+vKHy6N2ainc8dhvimXrm+qAUyH25LkCQSOe/HNZHXuLy44dl?= =?us-ascii?Q?5/9QPAcc5MMnK78g/AUK0clb4ZbnCQgx5ezGl2nk/ocG1pOCr14jCtoB95qv?= =?us-ascii?Q?EPu7b05worfkOYEae7JaBAb0gU9KDjSa4X0mkaSPf18uZkY5p8t93rB3e9OT?= =?us-ascii?Q?AoV//Hc+mglac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ront-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:(13230034)(36860700007)(376008)(1800799018)(82310400020); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Jun 2024 16:25:08.8763 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: d2c1559d-48aa-4cf2-85cf-08dc8afc39fd 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: SJ5PEPF000001D7.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB6882 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 da7d06d033..5c2cc2b7c1 100644 --- a/drivers/net/mlx5/mlx5_flow.h +++ b/drivers/net/mlx5/mlx5_flow.h @@ -1522,6 +1522,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 aee0201cbc..0ddae54ed2 100644 --- a/drivers/net/mlx5/mlx5_flow_hw.c +++ b/drivers/net/mlx5/mlx5_flow_hw.c @@ -8767,6 +8767,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; @@ -8810,6 +8811,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, @@ -8824,6 +8850,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 | @@ -8884,6 +8911,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) @@ -8926,6 +8954,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