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 974B343BC0 for ; Fri, 1 Mar 2024 09:46:41 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 8C5EA4025C; Fri, 1 Mar 2024 09:46:41 +0100 (CET) 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 0BE03400D5; Fri, 1 Mar 2024 09:46:40 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=YWYDGKoiS+dihTeioP3zz/JyRmi60Rn7P9h9XWzzCpN7uZE2J1BhH2NjarHrgcP+yafJJFCFFd8/XIKf/toqYB81Puj+71PeBjKYTXdpzqOHIuJVgAtT4uydt6NX+LJ8dwdAXPTLSpXJa1iFUAp/no5MP6aBHnrDzlXjhboqqDbcjY7roQ6HPclv5wvC/15MYbaBSyOpKZaYeovgDbwXI1TVIQu1Z5QInNbRmzdVhO8zAGWo8QXg5EnYtR48XCnaVHxvdCx7cadtCKNLITLgm/mhRxcp8MX5urxJKdoUsQB5o50VZPmNQsqW1i8pYXy4dVAJRHNetIPFrI06sqNAyw== 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=7eKQs4dmWwf83BpZ1J8g7MKwimVhPWpXRQhfHlM4UHA=; b=eYooFE7b1KhaVJ0+7Af7OXVWGdBrv7H8HVDXnfxSD51VJTxABScsswKv9Qbi2zzU/oSKxw4/RaifcfDRk0LGjEMmNoBnNLFkqdPYojK7He3kW3ziUEXXNPwdUXrzwEn/qS2bwczezgIM6BNzVvkWv8EnmHp8lZ99mf4KIlVS0incHNm5ifuNeF/2yMtHt4MVHZ9SSHa+pAK9ZJ+xxJ/USyf9aT315sz4JDbJ27539apam1KLL1860qWMvncH/hjdHaX0uUMftk91wOCTnVPRnXrgSRmR+atyaGTDzu9pAyMUEG/XSN0sz6tczigkDxmOOWJcQcnqjFXySSWEd/mi9g== 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=7eKQs4dmWwf83BpZ1J8g7MKwimVhPWpXRQhfHlM4UHA=; b=g4U14d7vT1SbfpfF5StiuR1oviarRBZrhrjmZLxcpvWBXSZXjiv4bkOc4BlPSmC4hKHJ5d0hVzxTiK6Ng5Yfktw8ONw5T7h1w5w8525PA3vSbxMizknwdyNtvvPJxp70e5JwENAxlqVxV0YkaxCExDDI414bjKS/rdmama9W66nAB68ckH05ZRFN9EFuUUGMLZXYxrtHU7n5Ktmuan+HHPX+r5eGzWQnMTDnf2+IcFUtZueup/CCcIRXmjGWphl/2REVGKPFJcqhHk8ZUEt3wmvdK+V6ijXxM3OYR+4i75AWOHv9ldxT3c0YiZtEWGkmMpimYteCPn9+AJuq7IvMKA== Received: from BYAPR04CA0022.namprd04.prod.outlook.com (2603:10b6:a03:40::35) by IA1PR12MB6411.namprd12.prod.outlook.com (2603:10b6:208:388::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7316.24; Fri, 1 Mar 2024 08:46:37 +0000 Received: from MWH0EPF000989E5.namprd02.prod.outlook.com (2603:10b6:a03:40:cafe::5e) by BYAPR04CA0022.outlook.office365.com (2603:10b6:a03:40::35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7339.30 via Frontend Transport; Fri, 1 Mar 2024 08:46:36 +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 MWH0EPF000989E5.mail.protection.outlook.com (10.167.241.132) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7362.11 via Frontend Transport; Fri, 1 Mar 2024 08:46:36 +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.41; Fri, 1 Mar 2024 00:46:20 -0800 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.1258.12; Fri, 1 Mar 2024 00:46:18 -0800 From: Shun Hao To: , , , "Suanming Mou" , Bing Zhao CC: , , Subject: [PATCH] net/mlx5: set correct priority for meter policy Date: Fri, 1 Mar 2024 10:46:05 +0200 Message-ID: <20240301084605.1652351-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.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: MWH0EPF000989E5:EE_|IA1PR12MB6411:EE_ X-MS-Office365-Filtering-Correlation-Id: 540042b9-95f4-4f66-ddf0-08dc39cc1aae X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: uJWw64hfaUsM5UG4/S2UxvV/jBOBII08Mi9XhDkzH9jqLC1Ghyftf+RsosMEM17muL49v7AVmoALicsJbLWOZKNQnZ1i52GuWdMHankDxBorCWiAymuwk9mFe/LY6rUs6AalQuUHz8zwzvCFYRdrFkdbsjzusgFVizTVMDwseQJHos+DghjIa3hbv4nZIKXKEjo1mtxWJ35m8iWpcpp4JECtpsUZaLyxTU2S1fUCNImODHzzsie5xd02FG7LPduWQrsHMvO1rX9emvdyVov8ET1/VizkOd6wZ37y22VH/gItc3eBTJKRlhIJB6OdtgPFxSs5DdbXNNgnKKmNyAdxzMc3s2cLl9R73kCSo9ljIVOIORzVvX5JlxOJAphVzAoeC1HK+cTtnMFZtcTqKMeIoUYDt6ZPPQ5qhc0Focb2OAlW4/BFFHAXDkHMPrD2h9vd+lpK2x1kLbUTq10K2qLWdAX6UgyvGV7H/ruV2s2mLuBL8IGS++D8/+JcfTQz5IRnnM/Jdl7F6gjKSAygQptnK4oh4Kd0kMrR+3ZdYk4hX4TQ3QiPSc9iU7ehZyF4w81Hj8RrEa4O42+DcoTartT1SQVvs1pLWu1cP9J0xWxELcGG3FsRZUubiLgJPZNFa35CxuxDXokGGvFf8mL2mQNYxHBcp+WlTkD6aluaIFXzf2jx5NzQsv9V8sInoqlOYXuioPZnuQn4NjS5R3gSd5BWnLhWwdFfG2FH8WtNIDkvw0xmx17v3Yl9FeEXeWKWGglz 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)(36860700004)(82310400014); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Mar 2024 08:46:36.2609 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 540042b9-95f4-4f66-ddf0-08dc39cc1aae 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: MWH0EPF000989E5.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR12MB6411 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 a meter policy's flows are always using the same priority for all colors, so the red color flow might be before green/yellow ones. This will impact the performance cause green/yellow packets will check red flow first and got miss, then match green/yellow flows, introducing more hops. This patch fixes this by giving the same priority to flows for all colors. Fixes: 363db9b00f ("net/mlx5: handle yellow case in default meter policy") CC: stable@dpdk.org Signed-off-by: Shun Hao Acked-by: Bing Zhao Acked-by: Matan Azrad --- drivers/net/mlx5/mlx5_flow_dv.c | 41 +++++++++++++++++++-------------- 1 file changed, 24 insertions(+), 17 deletions(-) diff --git a/drivers/net/mlx5/mlx5_flow_dv.c b/drivers/net/mlx5/mlx5_flow_dv.c index 18f09b22be..f1584ed6e0 100644 --- a/drivers/net/mlx5/mlx5_flow_dv.c +++ b/drivers/net/mlx5/mlx5_flow_dv.c @@ -17922,9 +17922,8 @@ __flow_dv_create_policy_matcher(struct rte_eth_dev *dev, } } tbl_data = container_of(tbl_rsc, struct mlx5_flow_tbl_data_entry, tbl); - if (priority < RTE_COLOR_RED) - flow_dv_match_meta_reg(matcher.mask.buf, - (enum modify_reg)color_reg_c_idx, color_mask, color_mask); + flow_dv_match_meta_reg(matcher.mask.buf, + (enum modify_reg)color_reg_c_idx, color_mask, color_mask); matcher.priority = priority; matcher.crc = rte_raw_cksum((const void *)matcher.mask.buf, matcher.mask.size); @@ -17975,7 +17974,6 @@ __flow_dv_create_domain_policy_rules(struct rte_eth_dev *dev, int i; int ret = mlx5_flow_get_reg_id(dev, MLX5_MTR_COLOR, 0, &flow_err); struct mlx5_sub_policy_color_rule *color_rule; - bool svport_match; struct mlx5_sub_policy_color_rule *tmp_rules[RTE_COLORS] = {NULL}; if (ret < 0) @@ -18011,10 +18009,9 @@ __flow_dv_create_domain_policy_rules(struct rte_eth_dev *dev, /* No use. */ attr.priority = i; /* Create matchers for colors. */ - svport_match = (i != RTE_COLOR_RED) ? match_src_port : false; if (__flow_dv_create_policy_matcher(dev, color_reg_c_idx, MLX5_MTR_POLICY_MATCHER_PRIO, sub_policy, - &attr, svport_match, NULL, + &attr, match_src_port, NULL, &color_rule->matcher, &flow_err)) { DRV_LOG(ERR, "Failed to create color%u matcher.", i); goto err_exit; @@ -18024,7 +18021,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, - svport_match, NULL, &color_rule->rule, + match_src_port, NULL, &color_rule->rule, &attr)) { DRV_LOG(ERR, "Failed to create color%u rule.", i); goto err_exit; @@ -18907,7 +18904,7 @@ flow_dv_meter_hierarchy_rule_create(struct rte_eth_dev *dev, struct { struct mlx5_flow_meter_policy *fm_policy; struct mlx5_flow_meter_info *next_fm; - struct mlx5_sub_policy_color_rule *tag_rule[MLX5_MTR_RTE_COLORS]; + struct mlx5_sub_policy_color_rule *tag_rule[RTE_COLORS]; } fm_info[MLX5_MTR_CHAIN_MAX_NUM] = { {0} }; uint32_t fm_cnt = 0; uint32_t i, j; @@ -18941,14 +18938,22 @@ flow_dv_meter_hierarchy_rule_create(struct rte_eth_dev *dev, mtr_policy = fm_info[i].fm_policy; rte_spinlock_lock(&mtr_policy->sl); sub_policy = mtr_policy->sub_policys[domain][0]; - for (j = 0; j < MLX5_MTR_RTE_COLORS; j++) { + for (j = 0; j < RTE_COLORS; j++) { uint8_t act_n = 0; - struct mlx5_flow_dv_modify_hdr_resource *modify_hdr; + struct mlx5_flow_dv_modify_hdr_resource *modify_hdr = NULL; struct mlx5_flow_dv_port_id_action_resource *port_action; + uint8_t fate_action; - if (mtr_policy->act_cnt[j].fate_action != MLX5_FLOW_FATE_MTR && - mtr_policy->act_cnt[j].fate_action != MLX5_FLOW_FATE_PORT_ID) - continue; + if (j == RTE_COLOR_RED) { + fate_action = MLX5_FLOW_FATE_DROP; + } else { + fate_action = mtr_policy->act_cnt[j].fate_action; + modify_hdr = mtr_policy->act_cnt[j].modify_hdr; + if (fate_action != MLX5_FLOW_FATE_MTR && + fate_action != MLX5_FLOW_FATE_PORT_ID && + fate_action != MLX5_FLOW_FATE_DROP) + continue; + } color_rule = mlx5_malloc(MLX5_MEM_ZERO, sizeof(struct mlx5_sub_policy_color_rule), 0, SOCKET_ID_ANY); @@ -18960,9 +18965,8 @@ flow_dv_meter_hierarchy_rule_create(struct rte_eth_dev *dev, goto err_exit; } color_rule->src_port = src_port; - modify_hdr = mtr_policy->act_cnt[j].modify_hdr; /* Prepare to create color rule. */ - if (mtr_policy->act_cnt[j].fate_action == MLX5_FLOW_FATE_MTR) { + if (fate_action == MLX5_FLOW_FATE_MTR) { next_fm = fm_info[i].next_fm; if (mlx5_flow_meter_attach(priv, next_fm, &attr, error)) { mlx5_free(color_rule); @@ -18989,7 +18993,7 @@ flow_dv_meter_hierarchy_rule_create(struct rte_eth_dev *dev, } acts.dv_actions[act_n++] = tbl_data->jump.action; acts.actions_n = act_n; - } else { + } else if (fate_action == MLX5_FLOW_FATE_PORT_ID) { port_action = mlx5_ipool_get(priv->sh->ipool[MLX5_IPOOL_PORT_ID], mtr_policy->act_cnt[j].rix_port_id_action); @@ -19002,6 +19006,9 @@ flow_dv_meter_hierarchy_rule_create(struct rte_eth_dev *dev, acts.dv_actions[act_n++] = modify_hdr->action; acts.dv_actions[act_n++] = port_action->action; acts.actions_n = act_n; + } else { + acts.dv_actions[act_n++] = mtr_policy->dr_drop_action[domain]; + acts.actions_n = act_n; } fm_info[i].tag_rule[j] = color_rule; TAILQ_INSERT_TAIL(&sub_policy->color_rules[j], color_rule, next_port); @@ -19033,7 +19040,7 @@ flow_dv_meter_hierarchy_rule_create(struct rte_eth_dev *dev, mtr_policy = fm_info[i].fm_policy; rte_spinlock_lock(&mtr_policy->sl); sub_policy = mtr_policy->sub_policys[domain][0]; - for (j = 0; j < MLX5_MTR_RTE_COLORS; j++) { + for (j = 0; j < RTE_COLORS; j++) { color_rule = fm_info[i].tag_rule[j]; if (!color_rule) continue; -- 2.20.0