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 9828F44147 for ; Tue, 4 Jun 2024 04:52:41 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 818A1433E4; Tue, 4 Jun 2024 04:52:41 +0200 (CEST) Received: from NAM04-BN8-obe.outbound.protection.outlook.com (mail-bn8nam04on2086.outbound.protection.outlook.com [40.107.100.86]) by mails.dpdk.org (Postfix) with ESMTP id 6176A40156; Tue, 4 Jun 2024 04:52:38 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=IoAeg1WmjqMxQ4z9x0WSU2+1/vHooj/L5Y+JfNKa46F9AVSu3jUHCUUkOMmep1ENADDMlEnRqr3+MGqBmbsbR94HtU+MJaN9gEdmV5iLrYUufXxQxz5fqwns9pzmYaBJF9iQjP7B8zSehDXmzox6GHZE32RNnKUxPBs9lIlpfTK8EWZrlxR+D79HSTB3efQALuUmJ9ELHj6fRJdyjQTf9br0Oz/PnK9qKa82LOEAvPUYZduDVkLee5ej5Uw17KC0k7+VNsMs2wXUar03rTzHkVAIWTrDjxvxL/Hp43DmtkmfstA76dCYDK17okUVVq8JIlBDWM8Jg6v3ZaIGlG8eHg== 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=Oef1B6+dLD45VqQCaKw53PTsffd4S048rryjRY7gMUc=; b=ig1/hoJnNm43SjIvJ7OG2YJOOb8DxznfaiufMcpYA1LIXiCyEDqy+x7el7ZLeTvDJwcpXG2t9BfqxKSo6MB+LTyHJ1a1JE7mZhhNOoOrcdT4FWrd/YDFwqcFaK2DxIkijclIWzHU0ks2vd03JOFVVlrajvUy4MDlp2FKM0KtyJCplHPSsh2oNNLZIJ/QtyBHzLrTnZwayKm9mIxlxJ4lnN9coY5225qnZVVL2wtzgyfXcx1+DEF9Ylvp80Gdv776psIecDD9pdhgJ0HeDsgI+IFBqj0ZnAtEgbdepFVOQD7iKeI1wZmx8M2IkstU6w1scSSvPw8p/aGfN0pKWC7ejw== 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=Oef1B6+dLD45VqQCaKw53PTsffd4S048rryjRY7gMUc=; b=cdmYdAlinZ5BnJtBrEPNtSUuIcQ40xoUXj94lMdoQSnmkousHH/9F1dDdqyJ1/MWUYilhxNvJPU3e+2A8a1FG5PX0x/6zVEYbADKxrXjUZUOJbuaKvzwUA2kJR3ljMa7i/3Q0Z0ERXo8md5mgWMPI85WeeNizZLStNpU/YW9gFQ/wmHqK4r9W/3HHtqf5ruEaszQkWjnkZ2EFLZraaE6CiKN1PFdBYQo0THhmTmilnEPDq6oXERFwJooxTmMZSS7CkS5Ol3/a1FmSUd5WJ0LQFXPInT3wTYd6Fr9vjJ05a9yFgVhcvv+ZnGL/3tj0txRa3LjgLo1iZOv1/Ht9WLDkQ== Received: from SJ0PR13CA0192.namprd13.prod.outlook.com (2603:10b6:a03:2c3::17) by CY5PR12MB6179.namprd12.prod.outlook.com (2603:10b6:930:24::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7633.27; Tue, 4 Jun 2024 02:52:34 +0000 Received: from CO1PEPF000044EE.namprd05.prod.outlook.com (2603:10b6:a03:2c3:cafe::b5) by SJ0PR13CA0192.outlook.office365.com (2603:10b6:a03:2c3::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7656.15 via Frontend Transport; Tue, 4 Jun 2024 02:52:34 +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 CO1PEPF000044EE.mail.protection.outlook.com (10.167.241.68) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7633.15 via Frontend Transport; Tue, 4 Jun 2024 02:52:34 +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; Mon, 3 Jun 2024 19:52:16 -0700 Received: from nvidia.com (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; Mon, 3 Jun 2024 19:52:13 -0700 From: Shun Hao To: , , , "Dariusz Sosnowski" , Suanming Mou CC: , , Subject: [PATCH] net/mlx5: support jump in meter hierarchy Date: Tue, 4 Jun 2024 05:51:56 +0300 Message-ID: <20240604025157.1209957-1-shunh@nvidia.com> X-Mailer: git-send-email 2.20.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [10.126.231.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: CO1PEPF000044EE:EE_|CY5PR12MB6179:EE_ X-MS-Office365-Filtering-Correlation-Id: ba5e38eb-4c40-4fad-0499-08dc844162ad X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230031|376005|36860700004|1800799015|82310400017; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?KItJVhyPPhfpB1TNI4Vy1sI9Q/dzkk5Easkhp9h4NNwKazg26jIzhcfy9Bxz?= =?us-ascii?Q?WAZdR+3FBXlbUXZ9nM+2z9yjq3Y++nietVPtaHDnBAUqznTU0/N7fyS7Uk0V?= =?us-ascii?Q?swG2KuYvEDwflbSqExPn8m1cUmZ2T73yP5qggIvYqdk7rxU8GEmYKiVki5Vj?= =?us-ascii?Q?dLpbuiAurg9xF4Feykmtike5riIYIhKPgpBoRi8xiz0lfxDYibly81LAVsZ9?= =?us-ascii?Q?t5J3oN2kZJyxhxXQ0/AJWeYKNAwAnC4agHh20vV1LV6JW8Klt8L7MfJ/+iKr?= =?us-ascii?Q?R3tRSxI4yV4VyLF58YpYXQSa8eMLP6C2OCf8kMXQC890pkzSClT+K1z7XOwe?= =?us-ascii?Q?ffIdPlKrykU6uenIoDqjVXQ9OyyUhldI+BKvFL5PinT9gQoTXTXk0UBdlG+J?= =?us-ascii?Q?Ly4onNoD9A2aYWfm4HMfzdGQLA8KD3QAutC/bq7/WS8QVpMRP37ucgGCQpgU?= =?us-ascii?Q?xcRY4xjAjuvkB9PIWWQLT0tlUG1PPk3igLxEbzl/PSqLUv3UwW/NRh4MyiuK?= =?us-ascii?Q?kjxUAuwtYGq6LPSDoYn6aIZZmvs0+tgv5cGojEiDrbw7WgqUs3SwcukDO7cR?= =?us-ascii?Q?e8z29mqfhhNcvNJleQKB3SNV1lBBWnwBWgu4ENMWlS25CDGQz7KhUuo6o0u4?= =?us-ascii?Q?ucAyQR7KwX7IenJ1Qm05fPBJtJPjeKGnSbR+xhqfTVidaHn2M5c8PSoLXPUc?= =?us-ascii?Q?daCfcjGvc7NQEtUiMZD/ISNC6RL7Lc1z8nZUmxh8tObkd35ZtEKAzbz1r3ZS?= =?us-ascii?Q?tm8LvG2vAQwetI9yHjdnAO6slsG7RUCI7FxIXWfwa6ZlQ9NNCx/uHIUb498r?= =?us-ascii?Q?UIUTtW8+WrG3ZauUm5hYuWJtEllQN9ctVQV9JhLyOdPub026mktlrEEaAvpo?= =?us-ascii?Q?tdfuelvxe+mi2NDs0FFcsZC0rUugNDkFiNJh5Zzc8tR7Cxlx6DJYtM7t4rQj?= =?us-ascii?Q?0P45sCfnZfaaugtYl62BItQ+E26qrE39vZEmGhuzIywc/GZkDwamQCJx0L3o?= =?us-ascii?Q?BBaEZDW2ZrvunCMyb7lA/dKD2HQjIl+UQKj1g2L6MVzdARGj1Wm37gjUd5i0?= =?us-ascii?Q?MQ75yhQydZakpIqpCgpPNtsQTAbwnPSjUyoYmKaMgi/z1JLrY5aLP9OZzeY+?= =?us-ascii?Q?sLjPhYYbCj0rB3L/nEYmrASZgCkehZ7rXfav+dVh8EMvAZg3SaGB5s+UlnO5?= =?us-ascii?Q?KldxL5s176ZNy6gGL3qXA8xja1VQi6Ew97Zzt7e/A47d+XjS037dPvjh2UWh?= =?us-ascii?Q?caOn5px7+wBfmz+jMX34dKr5KKyN+dp174Sux2WKtvrld5V1xkmNEz9FSkHo?= =?us-ascii?Q?XcR/qHJcg6NxVctt7vTgk5BogcvDhTUr7PMedhc4GqssHPnjU64J8tl20OQr?= =?us-ascii?Q?vrJL84g=3D?= X-Forefront-Antispam-Report: CIP:216.228.117.160; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc6edge1.nvidia.com; CAT:NONE; SFS:(13230031)(376005)(36860700004)(1800799015)(82310400017); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Jun 2024 02:52:34.1295 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ba5e38eb-4c40-4fad-0499-08dc844162ad 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: CO1PEPF000044EE.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY5PR12MB6179 X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org Currently in meter hierarchy, only meter action is supported for green and yellow policy flow. This patch adds support of jump action for green or yellow policy flow. Fixes: 96ca87da4f46 ("net/mlx5: validate yellow meter action") Cc: stable@dpdk.org Signed-off-by: Shun Hao Acked-by: Suanming Mou --- drivers/net/mlx5/mlx5_flow_dv.c | 36 ++++++++++++++++++--------------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/drivers/net/mlx5/mlx5_flow_dv.c b/drivers/net/mlx5/mlx5_flow_dv.c index 6f72185916..85ea840dee 100644 --- a/drivers/net/mlx5/mlx5_flow_dv.c +++ b/drivers/net/mlx5/mlx5_flow_dv.c @@ -17949,7 +17949,7 @@ __flow_dv_create_policy_matcher(struct rte_eth_dev *dev, static int __flow_dv_create_domain_policy_rules(struct rte_eth_dev *dev, struct mlx5_flow_meter_sub_policy *sub_policy, - uint8_t egress, uint8_t transfer, bool match_src_port, + uint8_t egress, uint8_t transfer, bool *match_src_port, struct mlx5_meter_policy_acts acts[RTE_COLORS]) { struct mlx5_priv *priv = dev->data->dev_private; @@ -17964,6 +17964,7 @@ __flow_dv_create_domain_policy_rules(struct rte_eth_dev *dev, .reserved = 0, }; int i; + uint16_t priority; int ret = mlx5_flow_get_reg_id(dev, MLX5_MTR_COLOR, 0, &flow_err); struct mlx5_sub_policy_color_rule *color_rule; struct mlx5_sub_policy_color_rule *tmp_rules[RTE_COLORS] = {NULL}; @@ -17998,12 +17999,12 @@ __flow_dv_create_domain_policy_rules(struct rte_eth_dev *dev, TAILQ_INSERT_TAIL(&sub_policy->color_rules[i], color_rule, next_port); color_rule->src_port = priv->representor_id; - /* No use. */ - attr.priority = i; + priority = (match_src_port[i] == match_src_port[RTE_COLOR_GREEN]) ? + MLX5_MTR_POLICY_MATCHER_PRIO : (MLX5_MTR_POLICY_MATCHER_PRIO + 1); /* Create matchers for colors. */ if (__flow_dv_create_policy_matcher(dev, color_reg_c_idx, - MLX5_MTR_POLICY_MATCHER_PRIO, sub_policy, - &attr, match_src_port, NULL, + priority, sub_policy, + &attr, match_src_port[i], NULL, &color_rule->matcher, &flow_err)) { DRV_LOG(ERR, "Failed to create color%u matcher.", i); goto err_exit; @@ -18013,7 +18014,7 @@ __flow_dv_create_domain_policy_rules(struct rte_eth_dev *dev, color_reg_c_idx, (enum rte_color)i, color_rule->matcher, acts[i].actions_n, acts[i].dv_actions, - match_src_port, NULL, &color_rule->rule, + match_src_port[i], NULL, &color_rule->rule, &attr)) { DRV_LOG(ERR, "Failed to create color%u rule.", i); goto err_exit; @@ -18061,7 +18062,7 @@ __flow_dv_create_policy_acts_rules(struct rte_eth_dev *dev, uint8_t egress = (domain == MLX5_MTR_DOMAIN_EGRESS) ? 1 : 0; uint8_t transfer = (domain == MLX5_MTR_DOMAIN_TRANSFER) ? 1 : 0; bool mtr_first = egress || (transfer && priv->representor_id != UINT16_MAX); - bool match_src_port = false; + bool match_src_port[RTE_COLORS] = {false}; int i; /* If RSS or Queue, no previous actions / rules is created. */ @@ -18132,7 +18133,7 @@ __flow_dv_create_policy_acts_rules(struct rte_eth_dev *dev, acts[i].dv_actions[acts[i].actions_n] = port_action->action; acts[i].actions_n++; - match_src_port = true; + match_src_port[i] = true; break; case MLX5_FLOW_FATE_DROP: case MLX5_FLOW_FATE_JUMP: @@ -18184,7 +18185,7 @@ __flow_dv_create_policy_acts_rules(struct rte_eth_dev *dev, acts[i].dv_actions[acts[i].actions_n++] = tbl_data->jump.action; if (mtr_policy->act_cnt[i].modify_hdr) - match_src_port = !!transfer; + match_src_port[i] = !!transfer; break; default: /*Queue action do nothing*/ @@ -18198,9 +18199,9 @@ __flow_dv_create_policy_acts_rules(struct rte_eth_dev *dev, "Failed to create policy rules per domain."); goto err_exit; } - if (match_src_port) { - mtr_policy->match_port = match_src_port; - mtr_policy->hierarchy_match_port = match_src_port; + if (match_src_port[RTE_COLOR_GREEN] || match_src_port[RTE_COLOR_YELLOW]) { + mtr_policy->match_port = 1; + mtr_policy->hierarchy_match_port = 1; } return 0; err_exit: @@ -18262,6 +18263,7 @@ __flow_dv_create_domain_def_policy(struct rte_eth_dev *dev, uint32_t domain) uint8_t egress, transfer; struct rte_flow_error error; struct mlx5_meter_policy_acts acts[RTE_COLORS]; + bool match_src_port[RTE_COLORS] = {false}; int ret; egress = (domain == MLX5_MTR_DOMAIN_EGRESS) ? 1 : 0; @@ -18337,7 +18339,7 @@ __flow_dv_create_domain_def_policy(struct rte_eth_dev *dev, uint32_t domain) /* Create default policy rules. */ ret = __flow_dv_create_domain_policy_rules(dev, &def_policy->sub_policy, - egress, transfer, false, acts); + egress, transfer, match_src_port, acts); if (ret) { DRV_LOG(ERR, "Failed to create default policy rules."); goto def_policy_error; @@ -19920,11 +19922,13 @@ flow_dv_validate_mtr_policy_acts(struct rte_eth_dev *dev, } } if (next_mtr && *policy_mode == MLX5_MTR_POLICY_MODE_ALL) { - if (!(action_flags[RTE_COLOR_GREEN] & action_flags[RTE_COLOR_YELLOW] & - MLX5_FLOW_ACTION_METER_WITH_TERMINATED_POLICY)) + uint64_t hierarchy_type_flag = + MLX5_FLOW_ACTION_METER_WITH_TERMINATED_POLICY | MLX5_FLOW_ACTION_JUMP; + if (!(action_flags[RTE_COLOR_GREEN] & hierarchy_type_flag) || + !(action_flags[RTE_COLOR_YELLOW] & hierarchy_type_flag)) return -rte_mtr_error_set(error, EINVAL, RTE_MTR_ERROR_TYPE_METER_POLICY, NULL, - "Meter hierarchy supports meter action only."); + "Unsupported action in meter hierarchy."); } /* If both colors have RSS, the attributes should be the same. */ if (flow_dv_mtr_policy_rss_compare(rss_color[RTE_COLOR_GREEN], -- 2.20.0