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 3CA21A0A0F; Mon, 5 Jul 2021 17:58:44 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id F0AD541207; Mon, 5 Jul 2021 17:58:29 +0200 (CEST) Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2050.outbound.protection.outlook.com [40.107.236.50]) by mails.dpdk.org (Postfix) with ESMTP id 29013411FC for ; Mon, 5 Jul 2021 17:58:29 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=T0PALxF4DSdjwHyZ22B0Ic4rUIZCvv1nbwXZGyZcu8pm+YOKffElAzzs3LhHeo+fVdhLZKTyFY3mVgWbvQcasyaA3mCk2VeedzWCUHZkoC7G8aZLexGf1An/C7HlfnJJnExfIZ+k8YwivnDjY2hkNh2zvSRU6623941T1BurUg/fRtF1W+hO9P5Ct43Ur55y1e3DK4jLlqqTr7ZNGSxgRtLxEbWfV/PiwZWy1jGKNnSlNcFjyDYjFYb0NS16EUyRgEwqG3+NKzF3omLG3Vz6glQse279922XT5kjwPxZy5h+dQGRnLTtMFRyDHOc9HORlkf/xqjzeNfHJJubMFR1JQ== 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=MS+FkUsgIf/3Vo37mXZnGehWgpCx7ldwaqQ+kBzetgw=; b=ZsxdRuX6IFpH6GsaggRfRlTqp8ZHQ4QB+O7KQZ8tKr5SFh8p9mTefhrWsAczMZjzerGfRqyM30NNL/0aIP0fEAkScFGlQkF/QHn3SXNtJojuSkcHsw3+xLZpjAiaiJvrL/ZePbTW1hZb4uOspk1v36cBrMjSxdPYZ6dG4Q5TE1EXrQ3XyCzE4ZeC+Sq7jECDMACTayQsnjjZDj0D+3HddFV6/635qHTPm97NFMC6F0zupl+dTjLTj9IX+QzTZfJZn1BGrDH0m3xxaJwlhI7ZMjp0YjndDRk+1MGajloYX2XYV5iCo6nSe0rq31dnVgzFb4aJY0rVmH7RwQa2iIBqZg== 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=MS+FkUsgIf/3Vo37mXZnGehWgpCx7ldwaqQ+kBzetgw=; b=tRwi25vZlyi8ZLH7Ihcnk+VwIQr3MY1oFXgZh8ZkURU3g5I5Qh9SOuBTCZJKNltPdD34vf6hAoiwehbEBuhO60npp4Clw08eLiAjYQXemZpprcL4Qevo3S/VGKJjHd0Lktt1Ha90XRi5ekCwfGVYvQoQdo637PIAMZ/+ZfrYlmjOrEboZx3pgJFJ2eTc+cb8lSd7RE7fg1o4ywKYYF3suh+kexTPHmbJdNhU4UapfuRQYZYgfNHfRbKeYoIw0f2H1/cXNFsk+TvrVkL3PzKKeKTRQkYNNhFt0pYM5Ibl3sVAPco4ovP4Jgj/W3KxWpOIBx0x+As2ooJN9uwRjsGjoA== Received: from DM5PR13CA0051.namprd13.prod.outlook.com (2603:10b6:3:117::13) by BN6PR12MB1443.namprd12.prod.outlook.com (2603:10b6:405:e::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4287.22; Mon, 5 Jul 2021 15:58:27 +0000 Received: from DM6NAM11FT035.eop-nam11.prod.protection.outlook.com (2603:10b6:3:117:cafe::e2) by DM5PR13CA0051.outlook.office365.com (2603:10b6:3:117::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4308.8 via Frontend Transport; Mon, 5 Jul 2021 15:58:27 +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 DM6NAM11FT035.mail.protection.outlook.com (10.13.172.100) 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:27 +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:25 +0000 From: Bing Zhao To: , CC: , , Date: Mon, 5 Jul 2021 18:57:54 +0300 Message-ID: <20210705155756.21443-5-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: ae8fd7ff-df11-4570-894e-08d93fcdba4e X-MS-TrafficTypeDiagnostic: BN6PR12MB1443: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:7691; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: xDs9JA3Nk52u/IbL7fg9SKh6G3lXgYmgjV/nhJD+TXWACFMpATEeWeOcTu+OPzeiSves41W5vlynZ/Y8qo0MvqKnkoBwAgdL1dbv2gLddaJ8+iDTN4mh3f5uGJAknYIxSXZcBRgSmCSWXjmcUQ84/qlLUs8LbH68TLW+tu5/uHMUc9yC1bpUUunfxjhMqQ56ej5WaUisUCDNmMXLOc7O1Z3EEIKQAlUjc8fOzYgFWOXOngmS7ZqmFUjb0vRiyr+ylgb/YS8o3qU/wyN00g3rOeiKe+TClZ+d2IeupY6GrOpoZbVDKNo8FjKW743TJ7cTdIiiG4fMPtnwg6ntc+EJ6VY5Oo+47vdrVsb1bNK0Vv6FEx9eVFmO4NUvmFLppH5RRXMUJ0BZ4Md5prFZSR6Xu9xVzJQyxIWNGDVfnYUf4boVULjrVbOhIVgu83Pa4i4C4eFtJNN5w80SGxSl9w7On///hVj4M3zQEBIZp6LMfAA/35pXD8SzJlhic2k6iesUpCAo+sClZluNR+6p+sL1UYmpOcBY+EnmzKl7LnG35Ze8QbueDfc02aXnY6HvhBF2YvPO+AC9qoPEM4izESQbh0jXr3hMaV2uvZJyKTCR1t5wQ0sRCcz6SUEDV8EzwCyEwGuVcI3742rkTcSgPF3i0HonCgn6niyG22zSsngpnhZjfwPIFmT3mKmNSCgMTxwpCl2mHeU7nBhnsOaT18NlGg== 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)(346002)(396003)(39860400002)(136003)(376002)(36840700001)(46966006)(16526019)(86362001)(186003)(36860700001)(54906003)(5660300002)(107886003)(83380400001)(478600001)(70586007)(6286002)(110136005)(7696005)(70206006)(82310400003)(26005)(6636002)(6666004)(316002)(4326008)(8676002)(2906002)(36756003)(2616005)(47076005)(336012)(426003)(55016002)(82740400003)(8936002)(356005)(36906005)(7636003)(1076003); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Jul 2021 15:58:27.5131 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ae8fd7ff-df11-4570-894e-08d93fcdba4e 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: DM6NAM11FT035.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR12MB1443 Subject: [dpdk-dev] [PATCH 4/6] 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 | 43 +++++++++++++++++++----------- drivers/net/mlx5/mlx5_flow_meter.c | 43 ++++++++++++++++++------------ 2 files changed, 53 insertions(+), 33 deletions(-) diff --git a/drivers/net/mlx5/mlx5_flow_dv.c b/drivers/net/mlx5/mlx5_flow_dv.c index f53cf65e87..c606fa9471 100644 --- a/drivers/net/mlx5/mlx5_flow_dv.c +++ b/drivers/net/mlx5/mlx5_flow_dv.c @@ -14702,22 +14702,34 @@ __flow_dv_create_domain_policy_acts(struct rte_eth_dev *dev, sizeof(struct mlx5_modification_cmd) * (MLX5_MAX_MODIFY_NUM + 1)]; } mhdr_dummy; + struct mlx5_flow_mtr_mng *mtrmng = priv->sh->mtrmng; egress = (domain == MLX5_MTR_DOMAIN_EGRESS) ? 1 : 0; transfer = (domain == MLX5_MTR_DOMAIN_TRANSFER) ? 1 : 0; 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)); 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]; - for (act = actions[i]; - act && act->type != RTE_FLOW_ACTION_TYPE_END; - act++) { + act = actions[i]; + /* No policy action, use default. */ + if (!act || act->type == RTE_FLOW_ACTION_TYPE_END) { + if (!mtrmng->def_policy[domain]) + return -rte_mtr_error_set(error, + ENOTSUP, + RTE_MTR_ERROR_TYPE_METER_POLICY, + NULL, + "Default policy not created."); + act_cnt->dr_jump_action[domain] = + mtrmng->def_policy[domain]->dr_jump_action[i]; + continue; + } + for (; act->type != RTE_FLOW_ACTION_TYPE_END; act++) { switch (act->type) { case RTE_FLOW_ACTION_TYPE_MARK: { @@ -14933,6 +14945,7 @@ __flow_dv_create_domain_policy_acts(struct rte_eth_dev *dev, action_flags |= MLX5_FLOW_ACTION_PORT_ID; break; } + /* G & Y can use the same table by default. */ case RTE_FLOW_ACTION_TYPE_JUMP: { uint32_t jump_group = 0; @@ -14947,7 +14960,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, @@ -15036,6 +15049,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); + /* Rollback is done in mlx5 layer. */ if (ret) return ret; } @@ -15538,12 +15552,10 @@ __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; } @@ -15555,13 +15567,12 @@ __flow_dv_create_policy_acts_rules(struct rte_eth_dev *dev, "mark action for policy."); return -1; } - 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) { @@ -15576,7 +15587,7 @@ __flow_dv_create_policy_acts_rules(struct rte_eth_dev *dev, return -1; } acts[i].dv_actions[acts[i].actions_n] = - port_action->action; + port_action->action; acts[i].actions_n++; break; case MLX5_FLOW_FATE_DROP: @@ -15588,15 +15599,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."); return -1; } acts[i].dv_actions[acts[i].actions_n] = - hrxq->action; + hrxq->action; acts[i].actions_n++; break; default: @@ -15610,7 +15621,7 @@ __flow_dv_create_policy_acts_rules(struct rte_eth_dev *dev, if (__flow_dv_create_domain_policy_rules(dev, sub_policy, egress, transfer, false, acts)) { DRV_LOG(ERR, - "Failed to create policy rules per domain."); + "Failed to create policy rules per domain."); return -1; } return 0; diff --git a/drivers/net/mlx5/mlx5_flow_meter.c b/drivers/net/mlx5/mlx5_flow_meter.c index 68351db1ce..025b469a1d 100644 --- a/drivers/net/mlx5/mlx5_flow_meter.c +++ b/drivers/net/mlx5/mlx5_flow_meter.c @@ -644,21 +644,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); @@ -666,8 +665,8 @@ mlx5_flow_meter_policy_add(struct rte_eth_dev *dev, return ret; if (!domain_bitmap) return -rte_mtr_error_set(error, ENOTSUP, - RTE_MTR_ERROR_TYPE_METER_POLICY, - NULL, "fail to find policy domain."); + RTE_MTR_ERROR_TYPE_METER_POLICY, + NULL, "fail to find policy domain."); if (is_def_policy) { if (priv->sh->mtrmng->def_policy_id != MLX5_INVALID_POLICY_ID) return -rte_mtr_error_set(error, EEXIST, @@ -689,16 +688,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, @@ -715,7 +720,7 @@ 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); + &sub_policy_idx); if (!sub_policy) goto policy_add_err; if (sub_policy_idx > MLX5_MAX_SUB_POLICY_TBL_NUM) @@ -727,7 +732,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 >> @@ -743,13 +748,17 @@ mlx5_flow_meter_policy_add(struct rte_eth_dev *dev, 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, policy->actions, error); if (ret) goto policy_add_err; + /* + * 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) { /* Create policy rules in HW. */ ret = mlx5_flow_create_policy_rules(dev, mtr_policy); -- 2.27.0