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 BED05A0C50; Wed, 21 Jul 2021 10:55:27 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id B14554113A; Wed, 21 Jul 2021 10:54:57 +0200 (CEST) Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2059.outbound.protection.outlook.com [40.107.223.59]) by mails.dpdk.org (Postfix) with ESMTP id 95AF741137 for ; Wed, 21 Jul 2021 10:54:54 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=T3ByT1ldB6GJzm3akvYNcLV3L0i62WqRmVRDB5memqD9Dh6q60a82RsRF8Xj+qFNuxuj1izOTeNPvzreJCk3f1P8n72kXhdbJUv15elXPuyu3Hw02uAr91Ojkn/+5kXmNIJbvWu7o+0AmG4tOYVw09hRRWnO179daRfF61BOHkTm14ZHVeVBP5Ftdd0Dmf1VteBdC19aCm74r2cHLnZz6gHAwIRKgaT7VoUZ6sB6Z+4WNM1I0EG7x3E+KqjLcuWijSHHAX5kmowDpUbjCT3Fl16ma8EXjxlYDLKkb2TN7w5cbFrrwIR3++5tqQWqrmNDNh78XmFwHAiPfSV2s5orCg== 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=lBBJ1mjxIHgwWyI4nTOodywZIuS6w49I9FEIc8kp3+4=; b=NLsjgtEV/RtdoJPnv6T9GqMZJK+OJQAqMEqKRHhgtaGKkG1jtZhxDhAiSVcXUw9lir9dA19aLw1ygPgd34/I2oXtwDkJF0hw5N2h9fgBY9Z2tdmhkrN4pJWNGM5uemv5BBFhxToWO3KJVWUvFeRx8E6M2wTBHktYcGB7C7upUy5VXFoi4OaVewB7t2PFfI4d17XdPkTWRAXOnvtO0HAHcPS3DIGNLfJvI1A8sO0H9s6/h0lILx/Pq7nfaWkKt8eWRNjMEQGDy7t7tg/BCBv88WDlzpHhokwiZYxqMm7drmFzudaMR9pLMxm7ihSjAqxQIDMH9cRxwr4ATKP9y2bgDA== 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=lBBJ1mjxIHgwWyI4nTOodywZIuS6w49I9FEIc8kp3+4=; b=KouUsyCcd5S/lfpLqFWbKEov5zvKYCZ9zeuDAkgG/2IAbkQk/4uLwk2hl/p5lvwkYHDKLhzfv7bNRtO3/Du89TGCPY+mxSAAmEFhpHonnDOsxMfDrg5pdzXjZ9K8L1JC7GLpZixjYRoLfEuXu77t0pDsTWayBrW/iMu27PXylmfBhB8RBvJ2CXvOLq4ieyNgio2U3zPA50XhnMdRhl1TamdAMKvLFR0JnAj/yEq47ngMBBnjw7H7R+OleYoDwnsTYe4YcpaTpiiNsrIYYPkSJHQf0UD8W62YpzcyvN3aJICtQ46FgpIRmvKptJ1s/MY0zqL/Vk/6B4LHCjzA1yVHpw== Received: from MW4PR04CA0063.namprd04.prod.outlook.com (2603:10b6:303:6b::8) by MN2PR12MB3008.namprd12.prod.outlook.com (2603:10b6:208:c8::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4331.23; Wed, 21 Jul 2021 08:54:53 +0000 Received: from CO1NAM11FT038.eop-nam11.prod.protection.outlook.com (2603:10b6:303:6b:cafe::1) by MW4PR04CA0063.outlook.office365.com (2603:10b6:303:6b::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4331.22 via Frontend Transport; Wed, 21 Jul 2021 08:54:52 +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:52 +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:50 +0000 From: Bing Zhao To: , CC: , , , , , Date: Wed, 21 Jul 2021 11:54:20 +0300 Message-ID: <20210721085421.13111-7-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: 98f5ba3b-7d7e-4b95-5253-08d94c25348b X-MS-TrafficTypeDiagnostic: MN2PR12MB3008: X-LD-Processed: 43083d15-7273-40c1-b7db-39efd9ccc17a,ExtAddr X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:8882; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: MnZKyWInSxmV/m8KOy6k5d6luFT4IVaSTqOS6U/M6tzWak1bhXQ6kr5eJWJLmTp41w1IYpt0C8DlbX0uFcT/U2wwDdFsM7wOR7fyKV9R9jKo53jkC5SEI0Wp/DWh4PgOzFRkZr7zVy0QR1Wt2GrFICcdCLEeiqtw/2M4+NQlHLN8jcMeGQZkkKvneIk9VACKuoygVgs6zA8n2sJArDrUj0fydABfy2ZZYfp0yF3EofHyJ3CpCcQKC+SB8ZE4Eq8kcnkLRxEZMOJ9B1J+O/r6tW5Or0Gocc3vx0A1tTFaqGp+ewF/0632+YnsYlnd1lnMRB8/2tRt72hwRHLycBmvkknYzoGfuSTPQjXK6S4/5CIATr+rBdi1yy9wt146SFc/IjNb0HIRVoC62dfEbajigTImSqrftJON7pOiaT6hTPw2iyg16lG85TKfaq9f4RqnAp+AIVR7S+YbobBPMiW4m2e77tuSS8wWWp4QoYyiWzaT/Rs9NivW9l0iEl1HmkjeiE5fvVScDyyZMJ0fq1LOqf2zz3qJPeSx1SPJRzR8g6CjLLWimw0jk41nDhB3UkGOTQZpmPzn6vucXDS5s5yukpbmbNUdWDH7VrYw1enm3B3MUMshK28vl2I+4pTrRV4lHNat09FyK3bMN+OsMgMDvDh7btClaNJKI3OW0bZW4/Cr//+5rX6sjN9RWJEO5ApBG/WZIFLT78T7+EhGpYam5Q== 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)(46966006)(36840700001)(1076003)(47076005)(6666004)(7636003)(55016002)(70586007)(36756003)(6636002)(8676002)(2616005)(426003)(70206006)(508600001)(110136005)(2906002)(336012)(82310400003)(5660300002)(36906005)(4326008)(83380400001)(16526019)(26005)(86362001)(186003)(107886003)(356005)(36860700001)(8936002)(316002)(7696005)(6286002)(54906003); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Jul 2021 08:54:52.7633 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 98f5ba3b-7d7e-4b95-5253-08d94c25348b 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: MN2PR12MB3008 Subject: [dpdk-dev] [PATCH v3 6/7] net/mlx5: check consistency of meter policy and profile 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" In the previous implementation, only green color policy was supported in mlx5 PMD. Since yellow color policy is supported now, the consistency of meter policy and profile should be checked. 1. If the profile supports yellow but the policy doesn't, an error should be returned when creating the meter. Or else, there is no explicit steering action for the packets marked with yellow. 2. If the policy supports yellow but the profile doesn't, it will be considered as a valid case. Even if no packet will be handled with the yellow steering action, it is just like that only the green policy presents. Usually the green color is supported by default, but when it is disabled intentionally with setting the CBS to a small value like zero in the profile, the similar checking on green policy and profile should also be done. Signed-off-by: Bing Zhao --- drivers/net/mlx5/mlx5.h | 6 ++++++ drivers/net/mlx5/mlx5_flow_dv.c | 4 ++++ drivers/net/mlx5/mlx5_flow_meter.c | 20 ++++++++++++++++++-- 3 files changed, 28 insertions(+), 2 deletions(-) diff --git a/drivers/net/mlx5/mlx5.h b/drivers/net/mlx5/mlx5.h index ea16109972..3a8587b7cf 100644 --- a/drivers/net/mlx5/mlx5.h +++ b/drivers/net/mlx5/mlx5.h @@ -746,6 +746,10 @@ struct mlx5_flow_meter_policy { /* Is queue action in policy table. */ uint32_t is_hierarchy:1; /* Is meter action in policy table. */ + uint32_t skip_y:1; + /* If yellow color policy is skipped. */ + uint32_t skip_g:1; + /* If green color policy is skipped. */ rte_spinlock_t sl; uint32_t ref_cnt; /* Use count. */ @@ -866,6 +870,8 @@ struct mlx5_flow_meter_profile { /**< srtcm_rfc2697 struct. */ }; uint32_t ref_cnt; /**< Use count. */ + uint32_t g_support:1; /**< If G color will be generated. */ + uint32_t y_support:1; /**< If Y color will be generated. */ }; /* 2 meters in each ASO cache line */ diff --git a/drivers/net/mlx5/mlx5_flow_dv.c b/drivers/net/mlx5/mlx5_flow_dv.c index 97e297d5c2..7ea04ba6e5 100644 --- a/drivers/net/mlx5/mlx5_flow_dv.c +++ b/drivers/net/mlx5/mlx5_flow_dv.c @@ -15245,6 +15245,10 @@ __flow_dv_create_domain_policy_acts(struct rte_eth_dev *dev, for (i = 0; i < RTE_COLORS; i++) { if (i < MLX5_MTR_RTE_COLORS) act_cnt = &mtr_policy->act_cnt[i]; + /* Skip the color policy actions creation. */ + if ((i == RTE_COLOR_YELLOW && mtr_policy->skip_y) || + (i == RTE_COLOR_GREEN && mtr_policy->skip_g)) + continue; action_flags = 0; for (act = actions[i]; act && act->type != RTE_FLOW_ACTION_TYPE_END; act++) { diff --git a/drivers/net/mlx5/mlx5_flow_meter.c b/drivers/net/mlx5/mlx5_flow_meter.c index 32ad4ea133..4f57b7e04e 100644 --- a/drivers/net/mlx5/mlx5_flow_meter.c +++ b/drivers/net/mlx5/mlx5_flow_meter.c @@ -333,6 +333,10 @@ mlx5_flow_meter_param_fill(struct mlx5_flow_meter_profile *fmp, ebs_exp = exp; srtcm->ebs_eir = rte_cpu_to_be_32(ebs_exp << ASO_DSEG_EBS_EXP_OFFSET | ebs_man << ASO_DSEG_EBS_MAN_OFFSET); + if (srtcm->cbs_cir) + fmp->g_support = 1; + if (srtcm->ebs_eir) + fmp->y_support = 1; return 0; } @@ -750,6 +754,10 @@ mlx5_flow_meter_policy_add(struct rte_eth_dev *dev, return -rte_mtr_error_set(error, ENOMEM, RTE_MTR_ERROR_TYPE_METER_POLICY, NULL, "Memory alloc failed for meter policy."); + if (policy_mode == MLX5_MTR_POLICY_MODE_OG) + mtr_policy->skip_y = 1; + else if (policy_mode == MLX5_MTR_POLICY_MODE_OY) + mtr_policy->skip_g = 1; policy_size = sizeof(struct mlx5_flow_meter_policy); for (i = 0; i < MLX5_MTR_DOMAIN_MAX; i++) { if (!(domain_bitmap & (1 << i))) @@ -1132,13 +1140,13 @@ mlx5_flow_meter_create(struct rte_eth_dev *dev, uint32_t meter_id, if (!priv->config.dv_esw_en) domain_bitmap &= ~MLX5_MTR_DOMAIN_TRANSFER_BIT; } else { - mtr_policy = mlx5_flow_meter_policy_find(dev, - params->meter_policy_id, &policy_idx); if (!priv->sh->meter_aso_en) return -rte_mtr_error_set(error, ENOTSUP, RTE_MTR_ERROR_TYPE_UNSPECIFIED, NULL, "Part of the policies cannot be " "supported without ASO "); + mtr_policy = mlx5_flow_meter_policy_find(dev, + params->meter_policy_id, &policy_idx); if (!mtr_policy) return -rte_mtr_error_set(error, ENOENT, RTE_MTR_ERROR_TYPE_METER_POLICY_ID, @@ -1149,6 +1157,14 @@ mlx5_flow_meter_create(struct rte_eth_dev *dev, uint32_t meter_id, MLX5_MTR_DOMAIN_EGRESS_BIT : 0) | (mtr_policy->transfer ? MLX5_MTR_DOMAIN_TRANSFER_BIT : 0); + if (fmp->g_support && mtr_policy->skip_g) + return -rte_mtr_error_set(error, ENOTSUP, + RTE_MTR_ERROR_TYPE_METER_POLICY_ID, + NULL, "Meter green policy is empty."); + if (fmp->y_support && mtr_policy->skip_y) + return -rte_mtr_error_set(error, ENOTSUP, + RTE_MTR_ERROR_TYPE_METER_POLICY_ID, + NULL, "Meter yellow policy is empty."); } /* Allocate the flow meter memory. */ if (priv->sh->meter_aso_en) { -- 2.27.0