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 C3E40A0A0F; Mon, 5 Jul 2021 17:58:28 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id F1F04411EA; Mon, 5 Jul 2021 17:58:25 +0200 (CEST) Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2052.outbound.protection.outlook.com [40.107.220.52]) by mails.dpdk.org (Postfix) with ESMTP id 8BB47411E3 for ; Mon, 5 Jul 2021 17:58:24 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=D/1dqk4hyaDLyDwyr6DwUTKlgLzIcpWDMWUHSceRZe8UApx1jJAv2kzTbVYyZygC3rJ3Jlbp3U8N7FYQ9+HC3Zj9uDl8MfWd5o1EdlyhJa23HusNGK+NQynF1J8tAxj/ou40sk2SLd3ceuWJeqZe4UKkP+/aCqRHa+DpNM5IgiV3eI80NFL+RIZMA8vpPMIyR9rMx6qdAD4tRNItPwLpjUWI8SoK8XaG3q2YTRDDgYDyB6Je8VRbJoRa0RaIydSW8NBJD5RMYeHtF0Ifffetyx4w6m0RuQaGLo+PLmqlZj0UdeDIceXe3M/eiiGhAaw3mi37S66CkiXlDXghUoMaAQ== 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-SenderADCheck; bh=X99pLgNI0UU34gCkOxvrqvdmrffdg5ODBLg8qKfhma4=; b=gN/1GgdYaXrq64uvE32/Vj/UtouRtiN1wnSCU72iTJujg697V38/AHq4hTJ/Ht3f1HgJbdvd4qVYbN3j3ROd0O+joMgknZaP2MCJ2kAnRtI7dZ+1S3QWSj4VQkf1ugie1Q5bkmOo0sN1HCJqq+XuZ9sFsfA++XbJ+HFQjjqWNkinVciMS9faWwlFQSqOBaNbjAIu2YuKDcSMaMYvcIABBCRVxe58sMObjRHdZjVeZWx33QkCGXLiZR+iYM1N9SJ5zxhesa8FmD4R1hqXnL7ACEWxjbZIyHKTAo8+BL8kJfqbZEtDuGzqVUk9xfiw821+kQPiReQzQUgrkPaBzIzf+A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.112.34) smtp.rcpttodomain=dpdk.org smtp.mailfrom=nvidia.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none 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=X99pLgNI0UU34gCkOxvrqvdmrffdg5ODBLg8qKfhma4=; b=mIuE/PGga1wRcITv19rW5gSW7rpUwZIEZ05VDnYl1dQn3wQiu0sn1NcfWousdF+gT11f8Lp+GYL0Ie+DSsRWaBG7BLOMwfg7bNT04nkORsc3HOFNyQ5Lb93g3FlswZ2vViyZ270smpiHiMJ46eliZMb8cZPGtz7PDCMaEqky3jonyMtlDoQW7jYuqGiEqmK+CkJpfC0w4qtwmpDpJzwShOALk5Wfez8jGIzPB58VmYJaW8ln+LlG9GLFkPzB3Sy2+ufnYkhuQQMAUgzC0GNXrJPj1f04pGL0sB41rb5bOBnGFzrZWBSSNNACS+6UzHhoTtlyjjQ3YZ9rbeHMkT7KQA== Received: from DM6PR03CA0049.namprd03.prod.outlook.com (2603:10b6:5:100::26) by CY4PR1201MB0213.namprd12.prod.outlook.com (2603:10b6:910:21::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4287.33; Mon, 5 Jul 2021 15:58:23 +0000 Received: from DM6NAM11FT059.eop-nam11.prod.protection.outlook.com (2603:10b6:5:100:cafe::3d) by DM6PR03CA0049.outlook.office365.com (2603:10b6:5:100::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4287.21 via Frontend Transport; Mon, 5 Jul 2021 15:58:23 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.112.34) smtp.mailfrom=nvidia.com; dpdk.org; dkim=none (message not signed) header.d=none;dpdk.org; dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.112.34 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.112.34; helo=mail.nvidia.com; Received: from mail.nvidia.com (216.228.112.34) by DM6NAM11FT059.mail.protection.outlook.com (10.13.172.92) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4287.22 via Frontend Transport; Mon, 5 Jul 2021 15:58:22 +0000 Received: from nvidia.com (172.20.187.6) by HQMAIL107.nvidia.com (172.20.187.13) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Mon, 5 Jul 2021 15:58:20 +0000 From: Bing Zhao To: , CC: , , Date: Mon, 5 Jul 2021 18:57:51 +0300 Message-ID: <20210705155756.21443-2-bingz@nvidia.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210705155756.21443-1-bingz@nvidia.com> References: <20210705155756.21443-1-bingz@nvidia.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [172.20.187.6] X-ClientProxiedBy: HQMAIL107.nvidia.com (172.20.187.13) To HQMAIL107.nvidia.com (172.20.187.13) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 7de8562b-6fe8-4b34-31c5-08d93fcdb767 X-MS-TrafficTypeDiagnostic: CY4PR1201MB0213: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:1013; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: smwCbr45uZoQ9ApOPs7nfaaxILqiAzZ7dxW4RrsOv8qR/yYcez4mkMWwMzNokc6UtuB9t5pKiEwV3ooRrq+5HMCcWHUF4ReD83iBb/hj3E1n2bK+npjAcIBoTLek662hlGpHA92nf40AElnVtyzzKb6jRw01J+yIc+ZvoU74wG8zC0r8H6F7VtwUKLX7inqoVlxhvvHAZkMjivqBkLxgr3x/ga0nR5Nb2gBH+7BYWQnKJll/0M/k7BnY4RHV0vcRC72VHtXbp5NcPOeicc4GmqFM6rbzZL+P+8KpLO2bfrXFLamW61F1foC8Buz0rNoieXedk+2ylelg/Z7hZKcLIQj1EiWx+I+ZTZb4r+RjOBUWH25cH2wRDyEMu3luxaBzXsS25EKvzRxu0F9V24uHabnx0muT1VrjoVL/9Pf8QiwbhcQRXbHAcjPKpts3Kd2G6wjzbYOzLoSTRv6398ydsxGVZRhrkSiyE2QnILPKcWDgR/CrciWTKtZrBt9U2dK45qQV+48vBYtx2DgV5Vg+75WmNsHbujhAqoLWaD0rThsOFM9yJXQP333gsuorf2TmjGldtq2X2DFNL7fd0/zZaRWYIzMqIbx/AlbkV+878kU6P4J3rPUmXN6x3I+JEJDiDr06WIChCj33DpRD8RiPVYFRS20C3dT9RnSYFuRrmSAd/oHRhfHQmtW870tJ1IfK4rcGX+lHLRu5WBtaXJ4Zhw== X-Forefront-Antispam-Report: CIP:216.228.112.34; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:schybrid03.nvidia.com; CAT:NONE; SFS:(4636009)(376002)(39860400002)(346002)(136003)(396003)(46966006)(36840700001)(83380400001)(336012)(4326008)(26005)(186003)(1076003)(36860700001)(6666004)(5660300002)(54906003)(8936002)(107886003)(110136005)(6636002)(82310400003)(2906002)(8676002)(36756003)(7696005)(426003)(316002)(86362001)(7636003)(16526019)(2616005)(6286002)(356005)(478600001)(70586007)(36906005)(82740400003)(55016002)(70206006)(47076005); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Jul 2021 15:58:22.6465 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 7de8562b-6fe8-4b34-31c5-08d93fcdb767 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.112.34]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: DM6NAM11FT059.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR1201MB0213 Subject: [dpdk-dev] [PATCH 1/6] net/mlx5: add yellow color default policy 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 Sender: "dev" To support the yellow color for the default meter policy, the default policy action for yellow should be created together with the green policy. The default policy action for yellow action is the same as that for green. In the same table, the same matcher will be reused for yellow and the destination group will be the same. Signed-off-by: Bing Zhao --- drivers/net/mlx5/mlx5_flow_dv.c | 88 +++++++++++++++++++++------------ 1 file changed, 57 insertions(+), 31 deletions(-) diff --git a/drivers/net/mlx5/mlx5_flow_dv.c b/drivers/net/mlx5/mlx5_flow_dv.c index a04a3c2bb8..c6a06d9def 100644 --- a/drivers/net/mlx5/mlx5_flow_dv.c +++ b/drivers/net/mlx5/mlx5_flow_dv.c @@ -15365,19 +15365,18 @@ __flow_dv_create_policy_flow(struct rte_eth_dev *dev, if (!is_default_policy && (priv->representor || priv->master)) { if (flow_dv_translate_item_port_id(dev, matcher.buf, value.buf, NULL, attr)) { - DRV_LOG(ERR, - "Failed to create meter policy flow with port."); + DRV_LOG(ERR, "Failed to create meter policy%d flow's" + " value with port.", color); return -1; } } flow_dv_match_meta_reg(matcher.buf, value.buf, - (enum modify_reg)color_reg_c_idx, - rte_col_2_mlx5_col(color), - UINT32_MAX); - ret = mlx5_flow_os_create_flow(matcher_object, - (void *)&value, actions_n, actions, rule); + (enum modify_reg)color_reg_c_idx, + rte_col_2_mlx5_col(color), UINT32_MAX); + ret = mlx5_flow_os_create_flow(matcher_object, (void *)&value, + actions_n, actions, rule); if (ret) { - DRV_LOG(ERR, "Failed to create meter policy flow."); + DRV_LOG(ERR, "Failed to create meter policy%d flow.", color); return -1; } return 0; @@ -15416,8 +15415,8 @@ __flow_dv_create_policy_matcher(struct rte_eth_dev *dev, if (!is_default_policy && (priv->representor || priv->master)) { if (flow_dv_translate_item_port_id(dev, matcher.mask.buf, value.buf, NULL, attr)) { - DRV_LOG(ERR, - "Failed to register meter drop matcher with port."); + DRV_LOG(ERR, "Failed to register meter policy%d matcher" + " with port.", priority); return -1; } } @@ -15425,9 +15424,11 @@ __flow_dv_create_policy_matcher(struct rte_eth_dev *dev, if (priority < RTE_COLOR_RED) flow_dv_match_meta_reg(matcher.mask.buf, value.buf, (enum modify_reg)color_reg_c_idx, 0, color_mask); - matcher.priority = priority; + /* Adjust the priority */ + matcher.priority = (priority == RTE_COLOR_YELLOW) ? + RTE_COLOR_GREEN : priority; matcher.crc = rte_raw_cksum((const void *)matcher.mask.buf, - matcher.mask.size); + matcher.mask.size); entry = mlx5_cache_register(&tbl_data->matchers, &ctx); if (!entry) { DRV_LOG(ERR, "Failed to register meter drop matcher."); @@ -15490,15 +15491,18 @@ __flow_dv_create_domain_policy_rules(struct rte_eth_dev *dev, /* Prepare matchers. */ color_reg_c_idx = ret; for (i = 0; i < RTE_COLORS; i++) { - if (i == RTE_COLOR_YELLOW || !acts[i].actions_n) + if (!acts[i].actions_n) continue; attr.priority = i; if (!sub_policy->color_matcher[i]) { /* Create matchers for Color. */ if (__flow_dv_create_policy_matcher(dev, color_reg_c_idx, i, sub_policy, - &attr, is_default_policy, &flow_err)) + &attr, is_default_policy, &flow_err)) { + DRV_LOG(ERR, + "Failed to create color%u matcher.", i); return -1; + } } /* Create flow, matching color. */ if (acts[i].actions_n) @@ -15509,8 +15513,11 @@ __flow_dv_create_domain_policy_rules(struct rte_eth_dev *dev, acts[i].dv_actions, is_default_policy, &sub_policy->color_rule[i], - &attr)) + &attr)) { + DRV_LOG(ERR, + "Failed to create color%u rule.", i); return -1; + } } return 0; } @@ -15665,8 +15672,7 @@ __flow_dv_create_domain_def_policy(struct rte_eth_dev *dev, uint32_t domain) sizeof(struct mlx5_flow_meter_def_policy), RTE_CACHE_LINE_SIZE, SOCKET_ID_ANY); if (!def_policy) { - DRV_LOG(ERR, "Failed to alloc " - "default policy table."); + DRV_LOG(ERR, "Failed to alloc default policy table."); goto def_policy_error; } mtrmng->def_policy[domain] = def_policy; @@ -15682,26 +15688,46 @@ __flow_dv_create_domain_def_policy(struct rte_eth_dev *dev, uint32_t domain) } def_policy->sub_policy.jump_tbl[RTE_COLOR_GREEN] = jump_tbl; tbl_data = container_of(jump_tbl, - struct mlx5_flow_tbl_data_entry, tbl); + struct mlx5_flow_tbl_data_entry, tbl); def_policy->dr_jump_action[RTE_COLOR_GREEN] = tbl_data->jump.action; - acts[RTE_COLOR_GREEN].dv_actions[0] = - tbl_data->jump.action; + acts[RTE_COLOR_GREEN].dv_actions[0] = tbl_data->jump.action; acts[RTE_COLOR_GREEN].actions_n = 1; + /* + * YELLOW has the same default policy as GREEN does. + * G & Y share the same table and action. + */ + jump_tbl = flow_dv_tbl_resource_get(dev, + MLX5_FLOW_TABLE_LEVEL_METER, + egress, transfer, false, NULL, 0, + 0, MLX5_MTR_TABLE_ID_SUFFIX, &error); + if (!jump_tbl) { + DRV_LOG(ERR, + "Failed to get meter suffix table."); + goto def_policy_error; + } + def_policy->sub_policy.jump_tbl[RTE_COLOR_YELLOW] = jump_tbl; + tbl_data = container_of(jump_tbl, + struct mlx5_flow_tbl_data_entry, tbl); + def_policy->dr_jump_action[RTE_COLOR_YELLOW] = + tbl_data->jump.action; + acts[RTE_COLOR_YELLOW].dv_actions[0] = tbl_data->jump.action; + acts[RTE_COLOR_YELLOW].actions_n = 1; /* Create jump action to the drop table. */ if (!mtrmng->drop_tbl[domain]) { mtrmng->drop_tbl[domain] = flow_dv_tbl_resource_get (dev, MLX5_FLOW_TABLE_LEVEL_METER, - egress, transfer, false, NULL, 0, - 0, MLX5_MTR_TABLE_ID_DROP, &error); + egress, transfer, false, NULL, 0, + 0, MLX5_MTR_TABLE_ID_DROP, &error); if (!mtrmng->drop_tbl[domain]) { - DRV_LOG(ERR, "Failed to create " - "meter drop table for default policy."); + DRV_LOG(ERR, "Failed to create meter " + "drop table for default policy."); goto def_policy_error; } } + /* all RED: unique Drop table for jump action. */ tbl_data = container_of(mtrmng->drop_tbl[domain], - struct mlx5_flow_tbl_data_entry, tbl); + struct mlx5_flow_tbl_data_entry, tbl); def_policy->dr_jump_action[RTE_COLOR_RED] = tbl_data->jump.action; acts[RTE_COLOR_RED].dv_actions[0] = tbl_data->jump.action; @@ -15711,15 +15737,14 @@ __flow_dv_create_domain_def_policy(struct rte_eth_dev *dev, uint32_t domain) &def_policy->sub_policy, egress, transfer, true, acts); if (ret) { - DRV_LOG(ERR, "Failed to create " - "default policy rules."); - goto def_policy_error; + DRV_LOG(ERR, "Failed to create default policy rules."); + goto def_policy_error; } } return 0; def_policy_error: __flow_dv_destroy_domain_def_policy(dev, - (enum mlx5_meter_domain)domain); + (enum mlx5_meter_domain)domain); return -1; } @@ -15742,8 +15767,9 @@ flow_dv_create_def_policy(struct rte_eth_dev *dev) if (!priv->config.dv_esw_en && i == MLX5_MTR_DOMAIN_TRANSFER) continue; if (__flow_dv_create_domain_def_policy(dev, i)) { - DRV_LOG(ERR, - "Failed to create default policy"); + DRV_LOG(ERR, "Failed to create default policy"); + /* Rollback the created default policies for others. */ + flow_dv_destroy_def_policy(dev); return -1; } } -- 2.27.0