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 2288FA0C50; Wed, 21 Jul 2021 10:55:05 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 5424041101; Wed, 21 Jul 2021 10:54:50 +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 0E37A410DA for ; Wed, 21 Jul 2021 10:54:48 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=I/VI6PsG+XLbk4qUeX+/mYOGZ7AeJZqfcNZl34+QZNabphzLLxrIuGvXUwIM6AnBPnQgDnIpdEtrwDDXNZ20vQ37150vUdteWztPgrQCD1FypgTfbV17bjwmfIy5VqOuHo/r+vlNTDpsj2pcA8719SLOrn+6wL+6b0nk/YerRn3s9+f41am2qXaEoDfc/aRBU/6uKvpGhc2DKrHQ7tM81g3nJYQ4UxFdQJwUr1yzZ1LyFU08UVKRGWdquXND2Otgurm1N0s/uugSZIyLqDLfkmHm5L51ec+pXw5hD+ccAkGKHKrZKlPQS2mjxbKPJ6ECR3+Ma5mthDDiKmuef0mGQw== 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=S9+TxTxAHV9uSEq89RGd0TFzNErQHU9g7PfuUSoX2GQ=; b=d3n0fbNsydmIfaEGL+B6ulE1Lg3/5133sZzdg6ijDK2W24Xmp6cs2egkzOUilfIlhIfLHJanf5zOD7WH45eknJW9fyDi8ssoNgJIOBMdlyCJ/OTRfz7ccthnY8KzNgtCjqjXyagRnHPvsyKF+LLOy/WxpYAs7qxNB+mxTI7Ud9+r5khVscaMMHafV4eiiyP7B5k2i8uzhD866MD3VlaGGTVsOBXqupGdfcqkxAw/bOqyP+5twih0VJ77BeYjxmQkMtRuPR026IFDQwlM6UNT0cCSjM/oucsbeIDb6xw+zuTG7yazCpUTf/riGDxAVqzOM9Jfx+DsXVLfMlZ5NU+EVA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.112.34) smtp.rcpttodomain=monjalon.net smtp.mailfrom=nvidia.com; dmarc=pass (p=quarantine 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=S9+TxTxAHV9uSEq89RGd0TFzNErQHU9g7PfuUSoX2GQ=; b=ruwl/WO9rIdYV9tZ+DYBkCq5hv7fP/JZn75LFczkZmoLSa5uVluhnnSwbo/yE9WGzUb0UgUuB2nWwdaA656Jw8yNlesoJEXpV9GmR9EZyXqiTBqBczri7ugEekPGZEnIzjVobE7Y4dwFas7UWZGfX3sszWqXvBP6Z/51UEIEzaIUHbUPqu8baIqJlomaTjE3uyxSnHLR6PC9cEs71xHIoq0upAi/rav/sZh0MdPl2BLEZo3ZvQqnofscgDo8IfqMzIDRw1SCg1w7d7eNJxINx+fKqorwXKqSM2YPntVJQ+WYo9Ct0Xi31kEpC8wP5lbX4Chz8kR0Vn1unBE5jeZbNg== Received: from MW4PR04CA0072.namprd04.prod.outlook.com (2603:10b6:303:6b::17) by BY5PR12MB3825.namprd12.prod.outlook.com (2603:10b6:a03:1a2::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4331.29; Wed, 21 Jul 2021 08:54:46 +0000 Received: from CO1NAM11FT038.eop-nam11.prod.protection.outlook.com (2603:10b6:303:6b:cafe::e0) by MW4PR04CA0072.outlook.office365.com (2603:10b6:303:6b::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4331.23 via Frontend Transport; Wed, 21 Jul 2021 08:54:46 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.112.34) smtp.mailfrom=nvidia.com; monjalon.net; dkim=none (message not signed) header.d=none;monjalon.net; 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 CO1NAM11FT038.mail.protection.outlook.com (10.13.174.231) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4352.24 via Frontend Transport; Wed, 21 Jul 2021 08:54:45 +0000 Received: from nvidia.com (172.20.187.5) by HQMAIL107.nvidia.com (172.20.187.13) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Wed, 21 Jul 2021 08:54:43 +0000 From: Bing Zhao To: , CC: , , , , , Date: Wed, 21 Jul 2021 11:54:17 +0300 Message-ID: <20210721085421.13111-4-bingz@nvidia.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210721085421.13111-1-bingz@nvidia.com> References: <20210705155756.21443-1-bingz@nvidia.com> <20210721085421.13111-1-bingz@nvidia.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [172.20.187.5] X-ClientProxiedBy: HQMAIL101.nvidia.com (172.20.187.10) To HQMAIL107.nvidia.com (172.20.187.13) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: d0950fac-d2fa-4dd5-714d-08d94c25305e X-MS-TrafficTypeDiagnostic: BY5PR12MB3825: X-LD-Processed: 43083d15-7273-40c1-b7db-39efd9ccc17a,ExtAddr X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:7691; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: o2gg7F7KEZfvYFNDaBKBJjKLkGmO6/SG+WSUjHwWPpE4FOiC8FbkobB9TeDObSFXc6PL/SKQiHbiK4U23qxYeT5QhcSOJg/dTNRbG6hYiSvQuGJ1JJyxHEAJgZm9N2w/tkypnUQ93eshl4ayVlZNrhF4lPVKAjZVgKedBBGJbqPGPSTPI5DhEz5oizBgns9eFUWLj98G9gttyiSTG74A8Ge6CRUsl/sTnPEBXQeWyAleg+wzYx/vPG5W+/sfz/4iJXh44yA2uOgx3z0get9djTYsTs13qsccvoh+a/jSihU9g+QersNn7KULwScLuBypvQJyAVnxf0mJKXJeTXpa/Wp2HwfbPvbxHA5+2u8ff2xQR6xhs1aHoXYW6DF/T1T4vPoPZmVcbt4juBzDpmfoRoHgSe3ofZFqtK+7AgrY1ITHWVlcuVILV4ZpnxxD1NRCnmpNuZz8ic0o0yfkVukFUIkRMpKIB8/WWezZsYkUVzLPN0jpsQA71UdegAsYb5wm1GuKnRLXU9krKB6UoQ0BZlJ4Rt7N0kHRFvanZFeFBm9GpdZtgt2XTzBV0H817TJXMzSv92l0OP3BJTg4cIU5ygGLi5Caj2uHLXRcpP249SdHzEj5+K2xYH//95W6FJjYQZlg8RkWm/ppzPxXA3li+bkRqO0/vFpyOu0erAVaEz8b0ZM8rDbmhV16tWbg0ENmA3MFFblRX7kmH6OK7sE00A== 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)(396003)(39860400002)(346002)(136003)(36840700001)(46966006)(336012)(86362001)(4326008)(6286002)(6666004)(70586007)(8936002)(8676002)(36860700001)(2616005)(426003)(6636002)(316002)(55016002)(16526019)(26005)(478600001)(7696005)(110136005)(47076005)(36756003)(70206006)(82310400003)(54906003)(107886003)(82740400003)(36906005)(5660300002)(2906002)(186003)(1076003)(83380400001)(356005)(30864003)(7636003); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Jul 2021 08:54:45.6643 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: d0950fac-d2fa-4dd5-714d-08d94c25305e 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: CO1NAM11FT038.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR12MB3825 Subject: [dpdk-dev] [PATCH v3 3/7] net/mlx5: added support for yellow policy rules 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" When creating a meter policy, both / either of the action rules for green and yellow colors may be provided. After validation, usually the actions are created before the meter is using by a flow rule. If there is action specified for the yellow color, the action rules should be created together with green color in the same time. The action of green / yellow color can be empty, then the default behavior is the jump action of the rule, just the same as that of the default policy. If the fate action of either one color is queue / RSS, all the actions rules will be created on the flow splitting stage instead of the policy adding stage. Signed-off-by: Bing Zhao --- drivers/net/mlx5/mlx5_flow_dv.c | 46 ++++++++++++++------------- drivers/net/mlx5/mlx5_flow_meter.c | 50 +++++++++++++++++++----------- 2 files changed, 56 insertions(+), 40 deletions(-) diff --git a/drivers/net/mlx5/mlx5_flow_dv.c b/drivers/net/mlx5/mlx5_flow_dv.c index cfc646c5e5..2400565232 100644 --- a/drivers/net/mlx5/mlx5_flow_dv.c +++ b/drivers/net/mlx5/mlx5_flow_dv.c @@ -15214,7 +15214,7 @@ __flow_dv_create_domain_policy_acts(struct rte_eth_dev *dev, struct mlx5_priv *priv = dev->data->dev_private; struct rte_flow_error flow_err; const struct rte_flow_action *act; - uint64_t action_flags = 0; + uint64_t action_flags; struct mlx5_flow_handle dh; struct mlx5_flow dev_flow; struct mlx5_flow_dv_port_id_action_resource port_id_action; @@ -15234,21 +15234,20 @@ __flow_dv_create_domain_policy_acts(struct rte_eth_dev *dev, memset(&dh, 0, sizeof(struct mlx5_flow_handle)); memset(&dev_flow, 0, sizeof(struct mlx5_flow)); memset(&port_id_action, 0, - sizeof(struct mlx5_flow_dv_port_id_action_resource)); + sizeof(struct mlx5_flow_dv_port_id_action_resource)); memset(mhdr_res, 0, sizeof(*mhdr_res)); mhdr_res->ft_type = transfer ? MLX5DV_FLOW_TABLE_TYPE_FDB : - egress ? - MLX5DV_FLOW_TABLE_TYPE_NIC_TX : - MLX5DV_FLOW_TABLE_TYPE_NIC_RX; + (egress ? MLX5DV_FLOW_TABLE_TYPE_NIC_TX : + MLX5DV_FLOW_TABLE_TYPE_NIC_RX); dev_flow.handle = &dh; dev_flow.dv.port_id_action = &port_id_action; dev_flow.external = true; for (i = 0; i < RTE_COLORS; i++) { if (i < MLX5_MTR_RTE_COLORS) act_cnt = &mtr_policy->act_cnt[i]; + action_flags = 0; for (act = actions[i]; - act && act->type != RTE_FLOW_ACTION_TYPE_END; - act++) { + act && act->type != RTE_FLOW_ACTION_TYPE_END; act++) { switch (act->type) { case RTE_FLOW_ACTION_TYPE_MARK: { @@ -15456,7 +15455,7 @@ __flow_dv_create_domain_policy_acts(struct rte_eth_dev *dev, (1 << MLX5_SCALE_FLOW_GROUP_BIT), }; struct mlx5_flow_meter_sub_policy *sub_policy = - mtr_policy->sub_policys[domain][0]; + mtr_policy->sub_policys[domain][0]; if (i >= MLX5_MTR_RTE_COLORS) return -rte_mtr_error_set(error, @@ -15500,6 +15499,10 @@ __flow_dv_create_domain_policy_acts(struct rte_eth_dev *dev, action_flags |= MLX5_FLOW_ACTION_JUMP; break; } + /* + * No need to check meter hierarchy for Y or R colors + * here since it is done in the validation stage. + */ case RTE_FLOW_ACTION_TYPE_METER: { const struct rte_flow_action_meter *mtr; @@ -15615,6 +15618,7 @@ flow_dv_create_mtr_policy_acts(struct rte_eth_dev *dev, ret = __flow_dv_create_domain_policy_acts(dev, mtr_policy, actions, (enum mlx5_meter_domain)i, error); + /* Cleaning resource is done in the caller level. */ if (ret) return ret; } @@ -16156,16 +16160,15 @@ __flow_dv_create_policy_acts_rules(struct rte_eth_dev *dev, for (i = 0; i < RTE_COLORS; i++) { acts[i].actions_n = 0; - if (i == RTE_COLOR_YELLOW) - continue; if (i == RTE_COLOR_RED) { /* Only support drop on red. */ acts[i].dv_actions[0] = - mtr_policy->dr_drop_action[domain]; + mtr_policy->dr_drop_action[domain]; acts[i].actions_n = 1; continue; } - if (mtr_policy->act_cnt[i].fate_action == MLX5_FLOW_FATE_MTR) { + if (i == RTE_COLOR_GREEN && + mtr_policy->act_cnt[i].fate_action == MLX5_FLOW_FATE_MTR) { struct rte_flow_attr attr = { .transfer = transfer }; @@ -16199,13 +16202,12 @@ __flow_dv_create_policy_acts_rules(struct rte_eth_dev *dev, "mark action for policy."); goto err_exit; } - acts[i].dv_actions[acts[i].actions_n] = - tag->action; + acts[i].dv_actions[acts[i].actions_n] = tag->action; acts[i].actions_n++; } if (mtr_policy->act_cnt[i].modify_hdr) { acts[i].dv_actions[acts[i].actions_n] = - mtr_policy->act_cnt[i].modify_hdr->action; + mtr_policy->act_cnt[i].modify_hdr->action; acts[i].actions_n++; } if (mtr_policy->act_cnt[i].fate_action) { @@ -16220,7 +16222,7 @@ __flow_dv_create_policy_acts_rules(struct rte_eth_dev *dev, goto err_exit; } acts[i].dv_actions[acts[i].actions_n] = - port_action->action; + port_action->action; acts[i].actions_n++; mtr_policy->dev = dev; match_src_port = true; @@ -16234,15 +16236,15 @@ __flow_dv_create_policy_acts_rules(struct rte_eth_dev *dev, case MLX5_FLOW_FATE_SHARED_RSS: case MLX5_FLOW_FATE_QUEUE: hrxq = mlx5_ipool_get - (priv->sh->ipool[MLX5_IPOOL_HRXQ], - sub_policy->rix_hrxq[i]); + (priv->sh->ipool[MLX5_IPOOL_HRXQ], + sub_policy->rix_hrxq[i]); if (!hrxq) { DRV_LOG(ERR, "Failed to find " "queue action for policy."); goto err_exit; } acts[i].dv_actions[acts[i].actions_n] = - hrxq->action; + hrxq->action; acts[i].actions_n++; break; case MLX5_FLOW_FATE_MTR: @@ -16284,7 +16286,7 @@ __flow_dv_create_policy_acts_rules(struct rte_eth_dev *dev, if (__flow_dv_create_domain_policy_rules(dev, sub_policy, egress, transfer, match_src_port, acts)) { DRV_LOG(ERR, - "Failed to create policy rules per domain."); + "Failed to create policy rules per domain."); goto err_exit; } return 0; @@ -16321,8 +16323,8 @@ flow_dv_create_policy_rules(struct rte_eth_dev *dev, /* Prepare actions list and create policy rules. */ if (__flow_dv_create_policy_acts_rules(dev, mtr_policy, mtr_policy->sub_policys[i][0], i)) { - DRV_LOG(ERR, - "Failed to create policy action list per domain."); + DRV_LOG(ERR, "Failed to create policy action " + "list per domain."); return -1; } } diff --git a/drivers/net/mlx5/mlx5_flow_meter.c b/drivers/net/mlx5/mlx5_flow_meter.c index 73eba0dabd..19b2665558 100644 --- a/drivers/net/mlx5/mlx5_flow_meter.c +++ b/drivers/net/mlx5/mlx5_flow_meter.c @@ -686,21 +686,20 @@ mlx5_flow_meter_policy_add(struct rte_eth_dev *dev, if (!priv->mtr_en) return -rte_mtr_error_set(error, ENOTSUP, RTE_MTR_ERROR_TYPE_METER_POLICY, - NULL, "meter policy unsupported."); + NULL, "meter policy unsupported. "); if (policy_id == MLX5_INVALID_POLICY_ID) return -rte_mtr_error_set(error, ENOTSUP, - RTE_MTR_ERROR_TYPE_METER_POLICY_ID, NULL, - "policy ID is invalid. "); + RTE_MTR_ERROR_TYPE_METER_POLICY_ID, + NULL, "policy ID is invalid. "); if (policy_id == priv->sh->mtrmng->def_policy_id) return -rte_mtr_error_set(error, EEXIST, - RTE_MTR_ERROR_TYPE_METER_POLICY_ID, NULL, - "policy ID exists. "); - mtr_policy = mlx5_flow_meter_policy_find(dev, policy_id, - &policy_idx); + RTE_MTR_ERROR_TYPE_METER_POLICY_ID, + NULL, "default policy ID exists. "); + mtr_policy = mlx5_flow_meter_policy_find(dev, policy_id, &policy_idx); if (mtr_policy) return -rte_mtr_error_set(error, EEXIST, - RTE_MTR_ERROR_TYPE_METER_POLICY_ID, NULL, - "policy ID exists. "); + RTE_MTR_ERROR_TYPE_METER_POLICY_ID, + NULL, "policy ID exists. "); ret = mlx5_flow_validate_mtr_acts(dev, policy->actions, &attr, &is_rss, &domain_bitmap, &is_def_policy, error); if (ret) @@ -730,16 +729,22 @@ mlx5_flow_meter_policy_add(struct rte_eth_dev *dev, for (i = 0; i < MLX5_MTR_DOMAIN_MAX; i++) { if (!(domain_bitmap & (1 << i))) continue; + /* + * If RSS is found, it means that only the ingress domain can + * be supported. It is invalid to support RSS for one color + * and egress / transfer domain actions for another. Drop and + * jump action should have no impact. + */ if (is_rss) { policy_size += - sizeof(struct mlx5_flow_meter_sub_policy *) * - MLX5_MTR_RSS_MAX_SUB_POLICY; + sizeof(struct mlx5_flow_meter_sub_policy *) * + MLX5_MTR_RSS_MAX_SUB_POLICY; break; } policy_size += sizeof(struct mlx5_flow_meter_sub_policy *); } mtr_policy = mlx5_malloc(MLX5_MEM_ZERO, policy_size, - RTE_CACHE_LINE_SIZE, SOCKET_ID_ANY); + RTE_CACHE_LINE_SIZE, SOCKET_ID_ANY); if (!mtr_policy) return -rte_mtr_error_set(error, ENOMEM, RTE_MTR_ERROR_TYPE_METER_POLICY, NULL, @@ -756,10 +761,9 @@ mlx5_flow_meter_policy_add(struct rte_eth_dev *dev, mtr_policy->transfer = 1; sub_policy = mlx5_ipool_zmalloc (priv->sh->ipool[MLX5_IPOOL_MTR_POLICY], - &sub_policy_idx); - if (!sub_policy) - goto policy_add_err; - if (sub_policy_idx > MLX5_MAX_SUB_POLICY_TBL_NUM) + &sub_policy_idx); + if (!sub_policy || + sub_policy_idx > MLX5_MAX_SUB_POLICY_TBL_NUM) goto policy_add_err; sub_policy->idx = sub_policy_idx; sub_policy->main_policy = mtr_policy; @@ -768,7 +772,7 @@ mlx5_flow_meter_policy_add(struct rte_eth_dev *dev, sub_policy->main_policy_id = 1; } mtr_policy->sub_policys[i] = - (struct mlx5_flow_meter_sub_policy **) + (struct mlx5_flow_meter_sub_policy **) ((uint8_t *)mtr_policy + policy_size); mtr_policy->sub_policys[i][0] = sub_policy; sub_policy_num = (mtr_policy->sub_policy_num >> @@ -780,11 +784,17 @@ mlx5_flow_meter_policy_add(struct rte_eth_dev *dev, mtr_policy->sub_policy_num |= (sub_policy_num & MLX5_MTR_SUB_POLICY_NUM_MASK) << (MLX5_MTR_SUB_POLICY_NUM_SHIFT * i); + /* + * If RSS is found, it means that only the ingress domain can + * be supported. It is invalid to support RSS for one color + * and egress / transfer domain actions for another. Drop and + * jump action should have no impact. + */ if (is_rss) { mtr_policy->is_rss = 1; break; } - policy_size += sizeof(struct mlx5_flow_meter_sub_policy *); + policy_size += sizeof(struct mlx5_flow_meter_sub_policy *); } rte_spinlock_init(&mtr_policy->sl); ret = mlx5_flow_create_mtr_acts(dev, mtr_policy, @@ -800,6 +810,10 @@ mlx5_flow_meter_policy_add(struct rte_eth_dev *dev, goto policy_add_err; skip_rule = (final_policy->is_rss || final_policy->is_queue); } + /* + * If either Green or Yellow has queue / RSS action, all the policy + * rules will be created later in the flow splitting stage. + */ if (!is_rss && !mtr_policy->is_queue && !skip_rule) { /* Create policy rules in HW. */ ret = mlx5_flow_create_policy_rules(dev, mtr_policy); -- 2.27.0