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 420BFA0C46; Sun, 18 Jul 2021 19:19:35 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 2746341194; Sun, 18 Jul 2021 19:19:17 +0200 (CEST) Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2054.outbound.protection.outlook.com [40.107.92.54]) by mails.dpdk.org (Postfix) with ESMTP id 504B240683 for ; Sun, 18 Jul 2021 19:19:16 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=MmxjXZn9f2ZHi5A5j9Osb+EiZe40sAAamNWkWB3dNgx+2DnqUa13PfLhjx7tlbJTmKKfQPbYeaX0e70MTgOvF6r4Fjw20BDf+ONmXMZOr45NtsiSzMXr7BHfQlXlEp6wzfYCYtHoCybrqfMiO53NfF0+l46Pcq2t/f+Zm6TUH2BMaoSlc+x7GprDntavxMMsIGXVFA/0pZX6c9HK9dZyU2SsS8H0L24TOfAmmTX3QK/is05rF7t+PcAyhEZ61tfT8L3wiyMNAtyvozVHsM/Tn07fr2EO7Ki1B4c/Pckg3szBst4mf7VBGI2ofVPhOf1Cpy0kiEkjUxaDvPG7zwhHeg== 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=KG7+3aYN3lcYIA/j23pgo2J1slIapVDfxAfSij4hVac=; b=b5FMfN/EOguT38lkZ1yFkjnjrTUOSLEDCSroUdGxMYUhBJyp7QH8lT7PE9hxiO0035hNS44N8EzTTpd9uYY/A8oXm9FTkKjgOdH9s2eXoWSdMNrbgoA39r4uWoyyFRteOXkAWXHDJ7VS2g9tzChV9kI2Nwm/h61xGa9CeP1MIwBtYIdpFlnxRLTl8U/8utKPFFjaC3YXStcEmMsQ5cAgeHctpVvKIO5xhC/sjPgadf+naRMXNwvQfTQsShidWtKglj8MTx/79Ik+0IPCKm5NTznRs+gS0KYiKEXqR/0R3vy1/3g3wbA4VC75tt6GZr7bv5vG22QSieg9vq+3sS//EA== 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=KG7+3aYN3lcYIA/j23pgo2J1slIapVDfxAfSij4hVac=; b=HtDBKnkQEKIFuu3HUSqwdNpReCIZWezky+Nh7KIoCo4MONnac7Yh6JvDs8scYc11pHHCEen3KF+KHV1NbVnxrT7ws02Aeb1k/zDcVXLlno6eDePjZQOp9rSZNQ07eAfOGYlT1pdnQs4EQTSANU+pvpwofF2VpVnpusrg1ElyJY08ma5/mhwLhPh9LiATVi/26t6GshmBWNZ4/NviA/C3U2MrmLhvbGobzZIfi5RSujuIu/qae1cxOvBn0a4tmpUepPkDFB8NQnsW+O3OqFUSWYgxO+0W8/8e1aONfPodDD67DjzWQlVg3inPJfhKOwGtT0bkeTTMorQLRoenz/xOvg== Received: from BN8PR16CA0011.namprd16.prod.outlook.com (2603:10b6:408:4c::24) by BL0PR12MB2468.namprd12.prod.outlook.com (2603:10b6:207:44::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4331.29; Sun, 18 Jul 2021 17:19:11 +0000 Received: from BN8NAM11FT057.eop-nam11.prod.protection.outlook.com (2603:10b6:408:4c:cafe::81) by BN8PR16CA0011.outlook.office365.com (2603:10b6:408:4c::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4331.22 via Frontend Transport; Sun, 18 Jul 2021 17:19:11 +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 BN8NAM11FT057.mail.protection.outlook.com (10.13.177.49) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4331.21 via Frontend Transport; Sun, 18 Jul 2021 17:19:10 +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; Sun, 18 Jul 2021 17:19:07 +0000 From: Bing Zhao To: , CC: , , , , , Date: Sun, 18 Jul 2021 20:18:16 +0300 Message-ID: <20210718171817.23822-7-bingz@nvidia.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210718171817.23822-1-bingz@nvidia.com> References: <20210705155756.21443-1-bingz@nvidia.com> <20210718171817.23822-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: 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: 396c854b-8835-4dd8-2e33-08d94a1028a6 X-MS-TrafficTypeDiagnostic: BL0PR12MB2468: X-LD-Processed: 43083d15-7273-40c1-b7db-39efd9ccc17a,ExtAddr X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:9508; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ITyLyFpFlZcRzBjrdYQJYsx/JpsIjAvMe+r8Oz1tb7xHYUrTZmbIyPxq3gu8rWBCbatIVnkwA5DhpAJFZaFGBsm8BbI+uU902M2aQ8BTpDHQFC4+GfkvmdaqeT5BWHOyup/t9XS51gXw3mw4eceFhI6FipchnzMub5cf5RQXTBJxo4SmEEusKkE32URZGucq14IKIpRdR9yiOjqwlCXpkCWft2CTKsL+xhQUjHCWEm/zwhqfsjCScwZPqcKhdXroOKj9cCqnayY3+2QNXYp6ILH+S5l9bnsF3f2YCJqOlk1pAfI/1aC3qPydPzrzvt9qHRBrXmMWqcRB2rqHIE0p6B4TI6KS5vzw9tOEtQWr8+E6qB1aAwX/eDN/Tx5Trrx37o9rf2YhT/lxit6RTKaUQSfStMV+b+zk3AV6Bs25bPi8T5cPh1n2tVbYyESEFpxv0cwzxZ/LcFJlJzlZpsDMR2mH+X7hKPoNePXpxivOVpx6HEmpTVxr16l1ErcqgbZEMXQmWVbDxDU+gqmbbihqmE10sl8EVjK3TCV7qsiuzXXj7/0xhV0F2xPtifV9Fd2wijTYiGHU7atBKQrvFDvsM3S5X6erp/xUB0KxDZquKZ6HEhDqXioVhhLPNGd3hxDUcspgx76fMZ1KERIHDeYOHgX/d3J/ibDibeLL+T3HHHEKr48jN/tYZQSpRj6tkzojpbzeay+ezJ0dVrAPtc9hoOWqVojMMPNOLscsmH9pswQ= 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)(396003)(376002)(346002)(136003)(39860400002)(46966006)(36840700001)(2906002)(34020700004)(5660300002)(36860700001)(6636002)(16526019)(83380400001)(6286002)(8936002)(47076005)(186003)(1076003)(82740400003)(8676002)(107886003)(478600001)(86362001)(336012)(36756003)(26005)(7636003)(426003)(2616005)(7696005)(54906003)(316002)(110136005)(82310400003)(70206006)(70586007)(6666004)(36906005)(356005)(4326008)(55016002); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Jul 2021 17:19:10.9848 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 396c854b-8835-4dd8-2e33-08d94a1028a6 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: BN8NAM11FT057.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL0PR12MB2468 Subject: [dpdk-dev] [PATCH v2 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 | 2 ++ drivers/net/mlx5/mlx5_flow_meter.c | 16 ++++++++++++++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/drivers/net/mlx5/mlx5.h b/drivers/net/mlx5/mlx5.h index 9832ed4189..3a8587b7cf 100644 --- a/drivers/net/mlx5/mlx5.h +++ b/drivers/net/mlx5/mlx5.h @@ -870,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_meter.c b/drivers/net/mlx5/mlx5_flow_meter.c index e9b9b22fb2..cf3fb8aa9d 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; } @@ -1136,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, @@ -1153,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