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 B6660A034F; Thu, 29 Jul 2021 18:04:48 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id D4ECA410F9; Thu, 29 Jul 2021 18:04:47 +0200 (CEST) Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2063.outbound.protection.outlook.com [40.107.94.63]) by mails.dpdk.org (Postfix) with ESMTP id 93468410F3 for ; Thu, 29 Jul 2021 18:04:45 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=K7mRPqLTap86O6tyMr/n1FNJaZGMATIxwocwSmg/jOxR0ZIAuKSx9Axf1w3OvJmZ0uAUgvJP6W5ekF6RlG+OPZELEe1O7/i/b/FCNPP1kaukXV+ar6S3C0FktwJtfE1znoLqp5B7nHAVxc6Jn679YOMh560w6qF96gvzK+wqXy6yvIWmEvAztaFwBFdsgaCzhTFvgDe/kMQ7JjDkWiKfg3gmjB+K6NN9ooNwZFIixaotSBPUzD4FUfrHabQwXyi1qmlmjGYESjgzSAJbnqkMQu6WNOh4PVVLZ9qGrY5HQgb+c0P2XTN2L/K90VkPD+tMwAfdDtVnRaQBtMCN/4mqcw== 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=t6dPhFn1dhrHje2Xwj3VT0Ttbv3spOX6fkCpc4QNTbo=; b=VGisp9mg4WgQh15AKgd+aeYYGy3Qlipmt2a6Hi1rlXvkSQEwjbo5oFVSinyAGk1R2S6isfl9Zi+oL+ABOnLhOfccZVZ5MrTpjJoVVg83w/OI0/aSDhCyMcNNFMcAZQT5xwsIYpTvc9uvrbnXwRZbSW1hSrhVD0eYMtWxdDgDENrwk7fUFvKGNH2IWAq4qITUWy+BcgNB7ySAphjI6nTL6tjkQhqTo0UZLqf1d+R1GSciUW9zinvtpvE5X3wz53uapomqcuGizSZufWWbRixe9ZZBZ1PwZlLSjXGdss0SMKv1+rQ/TbjLsW4RxTASbKg5AE5ga4Bt3nt5MsQ28fQfcA== 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=t6dPhFn1dhrHje2Xwj3VT0Ttbv3spOX6fkCpc4QNTbo=; b=ngnF1LUoziEAjPi2IXhRQt4dkoKaxZZeLPLrBaU4l8J12KfLsOXCJWjLPNwNTV4UnL/nWftoFQ35CeyDc0McsgqjSE0Di56bvOmb/A0KzRE1+vU2Ac7IgfFictpbKpAtyKC5OboNu49H3Vx+lMQ5Sxh5mbHCQyJVCjtFU9N01b88neuLjs2NX8PLerYXpzgQwn/QITsIaqSETT6qIaIyFnWU/S6vgpoZ+fwwX3qIAj+adTcyYwQzhDUw4dPW68gsdf3fDgExI9I7dLmNzfrCiRvUpuZreVnxDcM2XquCgIYvJI+Hh59pNy7PrypQIr/ha7K6AYQy8v7OMjFkMCVR4g== Received: from BN9PR03CA0950.namprd03.prod.outlook.com (2603:10b6:408:108::25) by CH2PR12MB5562.namprd12.prod.outlook.com (2603:10b6:610:67::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4373.17; Thu, 29 Jul 2021 16:04:44 +0000 Received: from BN8NAM11FT050.eop-nam11.prod.protection.outlook.com (2603:10b6:408:108:cafe::51) by BN9PR03CA0950.outlook.office365.com (2603:10b6:408:108::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4373.18 via Frontend Transport; Thu, 29 Jul 2021 16:04:43 +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 BN8NAM11FT050.mail.protection.outlook.com (10.13.177.5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4373.18 via Frontend Transport; Thu, 29 Jul 2021 16:04:43 +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; Thu, 29 Jul 2021 16:04:40 +0000 From: Bing Zhao To: , CC: , , , Date: Thu, 29 Jul 2021 19:04:03 +0300 Message-ID: <20210729160405.161982-2-bingz@nvidia.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210729160405.161982-1-bingz@nvidia.com> References: <20210729160405.161982-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: HQMAIL105.nvidia.com (172.20.187.12) To HQMAIL107.nvidia.com (172.20.187.13) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 26253a3c-5f2b-4d86-6ad0-08d952aa9452 X-MS-TrafficTypeDiagnostic: CH2PR12MB5562: 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: ioHe/q5OnfrqjjH7wOX8Vri0FbD6sLwvTxsY605muZ+/Te4Ibs0LPkWbpAOjvZXbT9F35f0J8jFh+r6drajvs8eAztktS+ni281j6/bElC6aM1qx1v9A/G9Np9ux4q2g1Q3snXfY1f4Rq51xiiJUzyKK+Sk0vRN7lDOH4BUDRiKTy1ePPBOlRhBjAzlFfcBbLUANjxfTcBEV2smRcRTgvrHjOSZiZvzrqepEPGzCDy3RCYey2qhV6YRfbQmNzVmaUZFKse8Js4vbr0a6B2Nzetcez8UKkbFNs46fxwYLY/JzsxbCRsA/2EmF8VnB8cWqtTxfeb0BEEP88WJflJmcnAuCAPQKRbMgVelhQ/SbwH5FHFJZPDcwDzr8JJ1C6CZIuRKkplxjAYer/Ep3lLeJOx2+SxJ+T/xMGAUuLaUR0cwj2fkI2bdSNR5Nvn3mr/B29iAV0SWmeL1UvSt2XB4BEQDj8CB/blmQ80ak3MKViNhyAZY9D0YmhEPDkuvv2IoiUZh733RN58+OgkF65AhsQrt5a8HOooUoeed/YSQ+c5xDx3JzX6xEu/ULCqMdncXWv0krIIJDX5y3p42iaxLzFVp7j4aPOsvG/zNaQqbx1XSXGpeVPshuFuS9f50gNTtxgGlBQFg+rcXVIwg0C8pIwjMi+D3qwps/ivBaM9L+0EMK+Ys0S5M1NpjnHnes1AGvbQ7PBabbWSROjLwQ6oDwsA== 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)(136003)(396003)(346002)(39860400002)(46966006)(36840700001)(2906002)(336012)(4326008)(426003)(55016002)(1076003)(70206006)(86362001)(7636003)(5660300002)(8936002)(82740400003)(36860700001)(186003)(16526019)(6286002)(8676002)(110136005)(82310400003)(83380400001)(2616005)(356005)(36756003)(26005)(6666004)(6636002)(478600001)(70586007)(316002)(54906003)(36906005)(7696005)(47076005); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Jul 2021 16:04:43.4343 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 26253a3c-5f2b-4d86-6ad0-08d952aa9452 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: BN8NAM11FT050.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH2PR12MB5562 Subject: [dpdk-dev] [PATCH] net/mlx5: fix the EIR calculation 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" Before the yellow color policy was supported, the only supported profile of metering is RFC2697 and EIR is not part of the profile. When creating a meter with this profile, the EIR part was always zero. After the yellow color policy supported and RFC2698 & 4115 support was introduced, EIR is relevant and should be calculated. Usually the EIR could not be zero and the formula for calculating CIR mantissa & exponent could be reused. The EIR could be 0 and then only green and red colors will be supported from the specification. Both the mantissa and exponent parts should be set to 0. Currently, the formula wrongly sets non-zero values for the EIR=0 case. Setting the mantissa and the exponent parts to zeros when EIR is 0 will solve the issue. Fixes: 33a7493c8df8 ("net/mlx5: support meter for trTCM profiles") Signed-off-by: Bing Zhao Acked-by: Matan Azrad --- drivers/net/mlx5/mlx5_flow_meter.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/drivers/net/mlx5/mlx5_flow_meter.c b/drivers/net/mlx5/mlx5_flow_meter.c index 0f51710907..a24bd9c7ae 100644 --- a/drivers/net/mlx5/mlx5_flow_meter.c +++ b/drivers/net/mlx5/mlx5_flow_meter.c @@ -245,17 +245,23 @@ mlx5_flow_meter_profile_validate(struct rte_eth_dev *dev, static inline void mlx5_flow_meter_xir_man_exp_calc(int64_t xir, uint8_t *man, uint8_t *exp) { - int64_t _cir; + int64_t _xir; int64_t delta = INT64_MAX; uint8_t _man = 0; uint8_t _exp = 0; uint64_t m, e; + /* Special case xir == 0 ? both exp and matissa are 0. */ + if (xir == 0) { + *man = 0; + *exp = 0; + return; + } for (m = 0; m <= 0xFF; m++) { /* man width 8 bit */ for (e = 0; e <= 0x1F; e++) { /* exp width 5bit */ - _cir = (1000000000ULL * m) >> e; - if (llabs(xir - _cir) <= delta) { - delta = llabs(xir - _cir); + _xir = (1000000000ULL * m) >> e; + if (llabs(xir - _xir) <= delta) { + delta = llabs(xir - _xir); _man = m; _exp = e; } -- 2.27.0