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 5717944144 for ; Tue, 4 Jun 2024 04:47:08 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 486A3433DC; Tue, 4 Jun 2024 04:47:08 +0200 (CEST) Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2044.outbound.protection.outlook.com [40.107.244.44]) by mails.dpdk.org (Postfix) with ESMTP id 42C7E402D2; Tue, 4 Jun 2024 04:47:05 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Vojwgf0Ih8HNFyW0w2Dm5MIgbgviaiJ+vw6xk1NcAvnSwpbPXbE2ja1BGVMXgO8D3btb/DHux9RRRh3Tt04fH+/SBgO7zIdpeIe8NzJ41d2YpSUFqPcPUSAqJ/Z0JBidvPmJDtXHGFqico7vpLfTC8o0eb0Ui4wONZeniEiu6hU8Qs9KOIXxOXbR7xWIh//zAxOon5ZfOVebIN0W3umQ15JfknIe+aQRBpFFno7C25lLY34cOs3UMaCCpc6Zbcn0MqEgCM62THGBF/jcN3zk8TmMlam0ddYNrr8roHtp0Dabr79XdTf/ePujX4ynUKLyHVuWAuIizZG6lhVIqSOp0g== 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=JSBY/i++eUs8r4kEQTHdP3/Gn9M8OR0EvmIM5XrYwjY=; b=SxgzZ+GKSCBSaMyYaXTYhemHMvXLYCBuFD20Kr9q3GHgiNGQORuC1v4pw7cQgI5H5N22yzC1bOebI6Q6eFZIDonmBjOLssnk4x69eXoRqUPu5ABwUJzfviTvoxJ7sMg8lqDKLTpMKlLMfpKWH8rWdZT6cJSleUgljhdvmG+yG88ve74bFOMlIaFdunrXIVS98D4Osv461J9zjyap4+SdjD7p2lMb9P3lA36ZMXRhm4KLObE2I40lABxNqLP8Wg6FSvHAFJ2/9O6I5SFmE1TPmHvImgz6KwourRtlZUNiUuBQjFWBord7DrgI+YQzZnNORHyjzW0DaZk3dwFBdX4bMQ== 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=JSBY/i++eUs8r4kEQTHdP3/Gn9M8OR0EvmIM5XrYwjY=; b=QaTfADTDlZWiqJ1QUMekhdO7gp0l/nKaxwHOQYnzKNxYJpS0J3Sn0r/TQnWQTo/BUoAVVEAX4a/Z4969o8tzCO7Wq4j1XKUJgYHroS7owlndfcjuCy3XEKiimdTnmn7nrCpK9MiTQ8Pu4o6ZU5DXb4RV+PqLJJYBGAuabAI2B/MtKVHijPnabOhyQyg0LHK5P5z3oU8PEG4FlHlk3wqDwcXwoncOBtfvktQ19c45pa3LAaOo3X00VrX1m3/MXgWO41koCIM2Pr4j6N0ESaPsaHXwWIkCvl0QtZrCf1dsu9zx1OnvXjdQsl72TrlSaO1Veq7jFmvmIhlaMXjfO7h0Tg== Received: from BYAPR02CA0066.namprd02.prod.outlook.com (2603:10b6:a03:54::43) by PH7PR12MB6739.namprd12.prod.outlook.com (2603:10b6:510:1aa::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7633.24; Tue, 4 Jun 2024 02:46:42 +0000 Received: from SJ1PEPF00002322.namprd03.prod.outlook.com (2603:10b6:a03:54:cafe::b7) by BYAPR02CA0066.outlook.office365.com (2603:10b6:a03:54::43) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7633.30 via Frontend Transport; Tue, 4 Jun 2024 02:46:42 +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 SJ1PEPF00002322.mail.protection.outlook.com (10.167.242.84) 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:46:41 +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; Mon, 3 Jun 2024 19:46:28 -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:46:25 -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:46:09 +0300 Message-ID: <20240604024610.1209376-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: SJ1PEPF00002322:EE_|PH7PR12MB6739:EE_ X-MS-Office365-Filtering-Correlation-Id: 74924495-d4dc-4784-5319-08dc844090bc X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230031|376005|1800799015|36860700004|82310400017; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?nI1svfAJ+LJQ+mgfxXcmDIvXwnz9j1M54VNUpbVW/W182SlGlmLlwxkCgk3d?= =?us-ascii?Q?7U4/QP6aMzvFSE0OsgfuVO3GMMq8ZCW02xaZ12gzImrkBKgqJOOLrsq++8Am?= =?us-ascii?Q?EdZB8LZYqWOs2tCdlWlOqJzRQGis3j5NMTWyeW/UBzlFLQITlHaefSd/n+uy?= =?us-ascii?Q?nBbKyANG6y1CdSLMhyTAKi1zKXNOv2Inm2jEh08he7KEywWMSGPx4KmpmX+C?= =?us-ascii?Q?cp9jXsbBGZ1OaKe2MdT6PEaKpvJsvCedZXDjvc+NBqEWmKz41lu6n52j8XHy?= =?us-ascii?Q?PTe5LZj8Lh7bs8apfuRMHMoutA1+LpQ/zXw4IY7Yl5Bh28kb80sCNwKXZYj3?= =?us-ascii?Q?F3sfsrXbrLlAfALFyxHCEvAtYS2cOjqHPQFXxQQ8+Yq3U1lTISfQ4QHEWydL?= =?us-ascii?Q?58R4B/ZL0zr74JXiDDRivu+N1ZRrHXHe2wAuE7xS+EFpHNsk7RTEjTokCLod?= =?us-ascii?Q?PMbAhEWtggWqR+vvAFDTZOpSi9gk/RklFE9USlFSYw0Qtpd8lK8J+so/xoD1?= =?us-ascii?Q?D2xVpoR7JuecoxpZH03WIGbkQEbvdjchx2jK4cudJSc4XvMrHi9qLbbPsGGs?= =?us-ascii?Q?/qHPbmD7b8uGxDPp9H/W8V1+HKZ2Ov/aLZ38PMDchQvx2Cy2PzqbCOIr8LjX?= =?us-ascii?Q?DPJQR/xtqeTBhhcJbG4+K1m62jUzSoKs7hogOaJ6FKTgyMXnBhro6ETG3ijd?= =?us-ascii?Q?RUlubomRzlaTjYkj6gHrXHInARDiWNDjo+fLrCXHBqXhtnAEnJqEbYzHfDfx?= =?us-ascii?Q?zISJCClOWzl3cnlAP71jP04RLx59tfcEUQGTvRITZOtT7hDWquW4T6gqsh1M?= =?us-ascii?Q?Oe2ZL+kRzueud+v5i069i+rorrpb+i5DxyTEXC/76vfZXdnGwjOt7XkcuIJv?= =?us-ascii?Q?OYsJHFtVie7ebawOH2q4F0LuG4a3irzcMXNOVhu8aNaJ3uiXndT90Jvn27pu?= =?us-ascii?Q?vuCMS32loC3FNmyE3r0ap9f3CW7rRJ3nFQDnF1EIws6i0rx8gOZr/84o+LBt?= =?us-ascii?Q?j3pJlxCvqmOtrFRsh3BXA5YGrf2nZkZ/GJm3GPku8N43dMhYmWSHcBvFFs5A?= =?us-ascii?Q?6S3Kc2DUWC2PGGMJbjmzzQGABbj3YPW7wIByd6EHPQvaBdzatBXMAfYu1EQz?= =?us-ascii?Q?XEJqgcNG06Ej9xde1B6Z5RNZtqvw3H9TDaB3iGPbW1YAF5biIjloSNcYNyxw?= =?us-ascii?Q?Ya13xV3bBB1+96nKbLRFHyP4y9DRUEvEBYRJyq6YvV/B621sOZs44BxxOaZU?= =?us-ascii?Q?mDNEJLq0HxBrlkorCsqieiPxwIwMR645XKrrhxhSh+4LxlUg7TvX5gACuIOV?= =?us-ascii?Q?vOb/mqmB0qNc8KPQSJXn2neMjR1pAnRKZV9u4oU0IH/1VDeJWV7Xmz7czJ/J?= =?us-ascii?Q?LD2m24E=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)(376005)(1800799015)(36860700004)(82310400017); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Jun 2024 02:46:41.9396 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 74924495-d4dc-4784-5319-08dc844090bc 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: SJ1PEPF00002322.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB6739 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 hierarhcy, 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