Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp649052pxb; Tue, 2 Feb 2021 14:19:37 -0800 (PST) X-Google-Smtp-Source: ABdhPJw7M1C/0nV5N8gNahFrB1umbYnR7x+GHfQc5yNdTaABkzigTrzZv61dSJy8S+LGogbLTHLj X-Received: by 2002:a05:6402:524f:: with SMTP id t15mr244783edd.158.1612304377016; Tue, 02 Feb 2021 14:19:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612304377; cv=none; d=google.com; s=arc-20160816; b=pbkbm8INEQhdui4vfbZtW1gfWpjYuWAyDF/p8/D+4Rxqz+3JHAr3TaQo0z99aM3yhX tj7t8wsJwOiAizPczNo7TOj1r8ax9UT7Lj4Dn9luZwVi6l2D53qZ2J0UohsGJluQvk5I zK3WpgmH09DCkRmX92djvp8a9kvY3Q8yO3A4vjLrcTX5GjudyvWfeaPg4K7p9s5ykeYO CCLiCZN/bJ2k8HP8N3HkI/sC+BADjnGQYjT1yFxU0IrIz1NlnWuTAzp77rRXpN+2u0yw 45nh4uFb9kc2MTTvBSZXUZPzE3A/ccT18OsYFjfXlvjaj3O/54OnzDfwD0TxNegPmuVC AEgg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=36xxBiprGG0Vwybm70/olC5wbj3Wl6wK3A4qJvTOLQ0=; b=Gx0q1TIyctjNJFAsEjHljCKEpdC7EMC0PvDS4DOoSjGtpqkqgQzjLoQlrcVuK0AJeI 4NS4Uue4BmKjCdzOD3KaXYoJf2VPW7cB/e5rjNfxY9RYJIz4cWKI+TIb36L6q9wRNo0i 5CufB9kX2wUr5DuW47+uPjAHPInQ0sPB1fBhdPtq5tLPAHesTmkJA5IGekfYIcXEOXm6 aYBtSYU7PsM0/RnLtVeDIqu001hWeY1JF9X/aV+YAsjg4eUYbxi6hIQetKOUxvgnznRe G1CQ1Ck0gXr6Z5zV23kd0UqyrMBNxd4IvoeATL5WMRNRgZNlBabZpDuibSbxEL7LL+gs 2E+g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=SYGc47s4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id gn20si105014ejc.578.2021.02.02.14.19.09; Tue, 02 Feb 2021 14:19:36 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=SYGc47s4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233789AbhBBOEd (ORCPT + 99 others); Tue, 2 Feb 2021 09:04:33 -0500 Received: from mail.kernel.org ([198.145.29.99]:45974 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233361AbhBBN5t (ORCPT ); Tue, 2 Feb 2021 08:57:49 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 3210C64FEA; Tue, 2 Feb 2021 13:45:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1612273546; bh=NSrbssA9N5mouLo0H74iiWH8EjvtzwTJ54NEysIocvg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SYGc47s4jDEzrusJjZof2GEB2PKDVE3/vl68ASsBgAI+O32/bFVlt4Z/FuYQFcz3t dULdkzMFQz3zQfLZqRk1to1Jk5Kit2LgSAIwXt50Xqsf9k/CSEkp8KEgC/eaZL2mhB sijcSk93PXsoQ20klOUfkH2LlZZSbrgtVFDqBw1k= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Parav Pandit , Eli Cohen , Saeed Mahameed , Sasha Levin Subject: [PATCH 5.10 115/142] net/mlx5e: E-switch, Fix rate calculation for overflow Date: Tue, 2 Feb 2021 14:37:58 +0100 Message-Id: <20210202133002.454474982@linuxfoundation.org> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210202132957.692094111@linuxfoundation.org> References: <20210202132957.692094111@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Parav Pandit [ Upstream commit 1fe3e3166b35240615ab7f8276af2bbf2e51f559 ] rate_bytes_ps is a 64-bit field. It passed as 32-bit field to apply_police_params(). Due to this when police rate is higher than 4Gbps, 32-bit calculation ignores the carry. This results in incorrect rate configurationn the device. Fix it by performing 64-bit calculation. Fixes: fcb64c0f5640 ("net/mlx5: E-Switch, add ingress rate support") Signed-off-by: Parav Pandit Reviewed-by: Eli Cohen Signed-off-by: Saeed Mahameed Signed-off-by: Sasha Levin --- drivers/net/ethernet/mellanox/mlx5/core/en_tc.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c index ce710f22b1fff..98cd5d8b0cd8b 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c @@ -67,6 +67,7 @@ #include "lib/geneve.h" #include "lib/fs_chains.h" #include "diag/en_tc_tracepoint.h" +#include #define nic_chains(priv) ((priv)->fs.tc.chains) #define MLX5_MH_ACT_SZ MLX5_UN_SZ_BYTES(set_add_copy_action_in_auto) @@ -5009,13 +5010,13 @@ errout: return err; } -static int apply_police_params(struct mlx5e_priv *priv, u32 rate, +static int apply_police_params(struct mlx5e_priv *priv, u64 rate, struct netlink_ext_ack *extack) { struct mlx5e_rep_priv *rpriv = priv->ppriv; struct mlx5_eswitch *esw; + u32 rate_mbps = 0; u16 vport_num; - u32 rate_mbps; int err; vport_num = rpriv->rep->vport; @@ -5032,7 +5033,11 @@ static int apply_police_params(struct mlx5e_priv *priv, u32 rate, * Moreover, if rate is non zero we choose to configure to a minimum of * 1 mbit/sec. */ - rate_mbps = rate ? max_t(u32, (rate * 8 + 500000) / 1000000, 1) : 0; + if (rate) { + rate = (rate * BITS_PER_BYTE) + 500000; + rate_mbps = max_t(u32, do_div(rate, 1000000), 1); + } + err = mlx5_esw_modify_vport_rate(esw, vport_num, rate_mbps); if (err) NL_SET_ERR_MSG_MOD(extack, "failed applying action to hardware"); -- 2.27.0