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 BA76FA034F; Mon, 7 Feb 2022 14:29:04 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 25A69410FF; Mon, 7 Feb 2022 14:29:04 +0100 (CET) Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2065.outbound.protection.outlook.com [40.107.94.65]) by mails.dpdk.org (Postfix) with ESMTP id D09FF410EA; Mon, 7 Feb 2022 14:29:01 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JYHNb+Mm07eMSU4+Mwvnimr04TF4uX5BddeBPfJwY9bxyCJakFGmsuZ5qWnzipcQAajmLcnuHK+p3+vIJW8uFdsUSyTGNSWV12EOyk7bQDJ5jlWXRAGKQKnNz0nQMBxIdQbZkRhnvqEgMR/BJI1NpOB3Q/6dxhhdrwB+sa46+k7iyTAdvPp+dOv5eCR+haZWX1OAQw6iF7eK/R54/SPiAe5MiYfcGKnjgNWTUIDWM2IFtw5jMCM3E+596IgYjk6HVt9f/2tNOTFFchHtyouzKDzdEQnp/bWl0bNjTVY9zF1hJkCA8EluNZDs8/MrjsuiMGhJm/oq84u8UWJf3HOJVw== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=BeNT5HrNryo9IGP82XEk1ZLPC2f7n8kPthnHJprXz3E=; b=IAxspzPv9CWwZKt4+vAhDbrxiehN1Lc4i6dsrt1DdzyHXu+dnILm1I8+9NgKuHlQIzc7x11y51Zx4uObM7/RAgDBlvamscL+yVMPvQJEE+75WO0C2FqYdFl/VRiw/z4AKS0p89ZJZ2N9Pss0YhfuSeYZexESFg/P8u9CriveBazO5M4deDcwjSDjvh+JZTJHpt2+LYd8G074vXQHIUHLkgB8IHuVW0DhWzY99u2g5ha5uTkalEO4OFq4VRZ2pr8tyn4zgxif9cmPZIQOugYz1PXOnmJacrmzWTl/m7Mk6jy6LFxkGAJQ4SNE03LUHjos0nJ0jLRD/kLDSLAL+gusrA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 12.22.5.238) smtp.rcpttodomain=dpdk.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject 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=BeNT5HrNryo9IGP82XEk1ZLPC2f7n8kPthnHJprXz3E=; b=SZkZ46YCd9redw7TLVoVb8ZmbyXXMIxTXVPpMbxGdxzgQWrnZEHQ6tzawdWp4lY75EP1XmaFE7k8ygRMTSCgdbwkXc1p49JypeEPD+6qenar4Bsr3vjYH2s707AziQE+3rxQS2IWOyTcQr5gxwCMN5SVgrPWou8RQa5gm3ji95zoPJ/MkicWtUkr/zwVLnwRnN/RHzpA0AGJw99+98weADr1dUBHSoAbDAH2/KhiAfBSuRIVN1iC0VzZ8SrEjuqza6iEpP9M2UYgN1x2Jw19DkWOemcVUqL8T7I8PXc7MvCNY9LaUUtqsDSzNxl8qhbljnP8N0jTcghmaf6IcgromQ== Received: from MW2PR16CA0014.namprd16.prod.outlook.com (2603:10b6:907::27) by BL1PR12MB5271.namprd12.prod.outlook.com (2603:10b6:208:315::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4951.12; Mon, 7 Feb 2022 13:28:59 +0000 Received: from CO1NAM11FT025.eop-nam11.prod.protection.outlook.com (2603:10b6:907:0:cafe::3e) by MW2PR16CA0014.outlook.office365.com (2603:10b6:907::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4951.19 via Frontend Transport; Mon, 7 Feb 2022 13:28:58 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 12.22.5.238) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 12.22.5.238 as permitted sender) receiver=protection.outlook.com; client-ip=12.22.5.238; helo=mail.nvidia.com; Received: from mail.nvidia.com (12.22.5.238) by CO1NAM11FT025.mail.protection.outlook.com (10.13.175.232) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4951.14 via Frontend Transport; Mon, 7 Feb 2022 13:28:58 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by DRHQMAIL105.nvidia.com (10.27.9.14) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Mon, 7 Feb 2022 13:28:57 +0000 Received: from pegasus01.mtr.labs.mlnx (10.126.231.35) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.9; Mon, 7 Feb 2022 05:28:55 -0800 From: Alexander Kozyrev To: CC: , , , , Subject: [PATCH] net/mlx5: fix Committed Bucket Size calculation Date: Mon, 7 Feb 2022 15:28:40 +0200 Message-ID: <20220207132840.929116-1-akozyrev@nvidia.com> X-Mailer: git-send-email 2.18.2 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.126.231.35] X-ClientProxiedBy: rnnvmail202.nvidia.com (10.129.68.7) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 8bce17c9-c6a1-4f62-c3fd-08d9ea3dcbd1 X-MS-TrafficTypeDiagnostic: BL1PR12MB5271:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:7219; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: FhwivjKcFFpL0zB2EcrQxw/p7pLyVUXhSkuAckDsN6xEvXtE0ySRId8KzgwVROQQCy7qVvRxrO3v9/mSiJIPOmvr2X3ZiPqNGNAz/nhtCuv8oZMrpBZpCqO5+STBcOwpW2HSloFFkqM93hGDdXTXw7TtLdjsDGaCVu3A7eUobkee6v3rcFyQPhN4903410CjzYmHgP7bQDuLLN/Bh+47Ytjs8yZnzWgD+bLYtRMWdCXKdXiP301KQJT9bIywvsTXv54IVbYBmO52iC2ejcJ2eWq5svEosRrOLwdswTHHgHgsxi51TTUlDagwjsTHbkWhqEvWePPm4Z9KFffti3aFK6Yx1PmZublxq05WGwIqKQzlNSWPOMlnLZdPXSr92OTkjlWYdcO1USAmqU8UR5CtUqi2ydKxGpHG6SiwhGQDV5YrKUaGRwYZIBnzH0Y3Xdg7ykiUpWn0rCfcjLXFlyFdhiLN5ZqdrMjJYArIXeGbGvzLVKRg/RES+9ObANnjIeCfqgqYxvgcxe4xG3qqr4zRtbWn+MexThnEKOXVu2s8Bpc0zkv4jdzJg9OVo0HfUmiYw7kGmgLj4YAwK/o0LILrdYl6e63JswhNuYuv6R/qcRkrNgWU7WlRaQYz6hubFEanmmWrrdrHvHech58AbMsbAQzO+ECHuJh7G/1ywGCiVNMv16Tonvkce+udm/5oGjpxcxRFD/zBdU+ohVanFIHwkA== X-Forefront-Antispam-Report: CIP:12.22.5.238; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:mail.nvidia.com; PTR:InfoNoRecords; CAT:NONE; SFS:(13230001)(4636009)(46966006)(36840700001)(40470700004)(2906002)(6666004)(40460700003)(81166007)(508600001)(356005)(54906003)(70586007)(70206006)(6916009)(450100002)(8676002)(82310400004)(4326008)(8936002)(2616005)(316002)(16526019)(186003)(1076003)(26005)(107886003)(83380400001)(36860700001)(426003)(86362001)(47076005)(336012)(36756003)(5660300002)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Feb 2022 13:28:58.1812 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 8bce17c9-c6a1-4f62-c3fd-08d9ea3dcbd1 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[12.22.5.238]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CO1NAM11FT025.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL1PR12MB5271 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 Committed Bucket Size calculation tries to fit into 8-bit wide mantissa field by setting 256 as a maximum value for it. To compensate for this increase in the mantissa value the exponent value has to be reduced by 8. But it gives a negative exponent value for CBS less than 128. And negative exponent value is not supported by the NIC. Adjust CSB calculation only for values bigger than 128 to allow both small and big bucket sizes. Fixes: 3bd26b23cef ("net/mlx5: support meter profile operations") Cc: stable@dpdk.org Signed-off-by: Alexander Kozyrev Acked-by: Viacheslav Ovsiienko --- drivers/net/mlx5/mlx5_flow_meter.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/net/mlx5/mlx5_flow_meter.c b/drivers/net/mlx5/mlx5_flow_meter.c index 0dc7fbfb32..d0f8bcd100 100644 --- a/drivers/net/mlx5/mlx5_flow_meter.c +++ b/drivers/net/mlx5/mlx5_flow_meter.c @@ -295,8 +295,10 @@ mlx5_flow_meter_xbs_man_exp_calc(uint64_t xbs, uint8_t *man, uint8_t *exp) } /* xbs = xbs_mantissa * 2^xbs_exponent */ _man = frexp(xbs, &_exp); - _man = _man * pow(2, MLX5_MAN_WIDTH); - _exp = _exp - MLX5_MAN_WIDTH; + if (_exp >= MLX5_MAN_WIDTH) { + _man = _man * pow(2, MLX5_MAN_WIDTH); + _exp = _exp - MLX5_MAN_WIDTH; + } *man = (uint8_t)ceil(_man); *exp = _exp; } -- 2.18.2