Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3487571imu; Sun, 11 Nov 2018 16:12:54 -0800 (PST) X-Google-Smtp-Source: AJdET5fjNkn9fi/8Ky6zGkIn4MnXpNqaeH4kIEt3WytvJO1ehslrXITb0q4+CVs1rxYT+daLgOw1 X-Received: by 2002:a65:5bc4:: with SMTP id o4mr15761197pgr.426.1541981574870; Sun, 11 Nov 2018 16:12:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541981574; cv=none; d=google.com; s=arc-20160816; b=Xbcj41h1tpexNwcQtEW/gJ//8/ABjxXot9NA9z1tNy6Z8lLwdZKnCiEfrJNULO9b/G L+3DvxwU0uSvpWEEzpYQFw4DAarEpFF7c4bRNs/qQlhDswwmqscKc5dmDZrQgfARthqQ 2+nOS0jBACRXa/gr+9kG+oPjNmk/CfD74rHvlz/T0h6vl7qT1yGq2FMZOVbdQzweNsA9 y1xzuRRzYFenHEBsqxQaGSifdBgUTiXW9jEJORyJt5IfMVokoIKd9UgLjRKBe881UahL 7TgpYjWP8i4n3amGTcSsOawQE3LNwhYU7i371JwYZ5Hz3wAbBJAjQR7x4g5y76QoHwms czrQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=e3zrwbM07PTrpPKMQAoEmmz2XtIjpA0asNJQIu8T2G4=; b=oKqBy+3QJK3rGbTUqNmb9NZKGmd/y2msFUSFXDZ0ctrE/RH/eRMuw3HhWvOOvf1FgJ CuConnlL7HFqNLa8W+jqMfgcLwUO6nav2C0YAPTjMjikbQN3c7YSav+Nh9nKu8692uZu KABNoa7MzhtDgd0XpVnUl53yiP1q/pHIpL2QXE6iErSQuUPXNNHes+egW+oohuiMV12Q hGZc9cASKA+X12uo6uQMxdOgByD+RG/yvBIvC7sp2W8US9QkQYr8Yv2Ni80ToVXNgPck C27GmGrh8E4WwMSrw2LU4PI6BbT15DdKSMgTnOOCnwYpjfDjFiqSXjFVVvDSlVVL1aXm eDHw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=i7kMgirr; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t124-v6si16839216pfc.262.2018.11.11.16.12.40; Sun, 11 Nov 2018 16:12:54 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=i7kMgirr; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731921AbeKLKCm (ORCPT + 99 others); Mon, 12 Nov 2018 05:02:42 -0500 Received: from mail.kernel.org ([198.145.29.99]:59904 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730501AbeKLIRS (ORCPT ); Mon, 12 Nov 2018 03:17:18 -0500 Received: from localhost (unknown [206.108.79.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id DFDD421508; Sun, 11 Nov 2018 22:27:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1541975242; bh=LNGe5LCWQ53yS+R+14KLr+gFLNBoQq9GsqCohKmAkXM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=i7kMgirrvdmY6N9ekaufG+ZdhUrgXLZ6u5qB9pEDsPUk84xX6iNAIoWezguMVBNCj V8yOvYwTqmLNO1CooAUu2tpX0A22Vxofq2F57csTakuOL94lQO6/j1dpVsdfB0E77V WNUqKHX8b7HpclIZMBq4FPU2YduRWSQ8bq2T/AOI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Yunsheng Lin , Peng Li , Salil Mehta , "David S. Miller" , Sasha Levin Subject: [PATCH 4.19 090/361] net: hns3: Fix for packet buffer setting bug Date: Sun, 11 Nov 2018 14:17:17 -0800 Message-Id: <20181111221632.326563179@linuxfoundation.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181111221619.915519183@linuxfoundation.org> References: <20181111221619.915519183@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.19-stable review patch. If anyone has any objections, please let me know. ------------------ From: Yunsheng Lin [ Upstream commit 996ff91840eb6f288826e472685abde78bac20ea ] The hardware expects a unit of 128 bytes when setting packet buffer. When calculating the packet buffer size, hclge_rx_buffer_calc does not round up the size as a unit of 128 byte, which may casue packet lost problem when stress testing. This patch fixes it by rounding up packet size when calculating. Fixes: 46a3df9f9718 ("net: hns3: Add HNS3 Acceleration Engine & Compatibility Layer Support") Signed-off-by: Yunsheng Lin Signed-off-by: Peng Li Signed-off-by: Salil Mehta Signed-off-by: David S. Miller Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c @@ -1657,11 +1657,13 @@ static int hclge_tx_buffer_calc(struct h static int hclge_rx_buffer_calc(struct hclge_dev *hdev, struct hclge_pkt_buf_alloc *buf_alloc) { - u32 rx_all = hdev->pkt_buf_size; +#define HCLGE_BUF_SIZE_UNIT 128 + u32 rx_all = hdev->pkt_buf_size, aligned_mps; int no_pfc_priv_num, pfc_priv_num; struct hclge_priv_buf *priv; int i; + aligned_mps = round_up(hdev->mps, HCLGE_BUF_SIZE_UNIT); rx_all -= hclge_get_tx_buff_alloced(buf_alloc); /* When DCB is not supported, rx private @@ -1680,13 +1682,13 @@ static int hclge_rx_buffer_calc(struct h if (hdev->hw_tc_map & BIT(i)) { priv->enable = 1; if (hdev->tm_info.hw_pfc_map & BIT(i)) { - priv->wl.low = hdev->mps; - priv->wl.high = priv->wl.low + hdev->mps; + priv->wl.low = aligned_mps; + priv->wl.high = priv->wl.low + aligned_mps; priv->buf_size = priv->wl.high + HCLGE_DEFAULT_DV; } else { priv->wl.low = 0; - priv->wl.high = 2 * hdev->mps; + priv->wl.high = 2 * aligned_mps; priv->buf_size = priv->wl.high; } } else { @@ -1718,11 +1720,11 @@ static int hclge_rx_buffer_calc(struct h if (hdev->tm_info.hw_pfc_map & BIT(i)) { priv->wl.low = 128; - priv->wl.high = priv->wl.low + hdev->mps; + priv->wl.high = priv->wl.low + aligned_mps; priv->buf_size = priv->wl.high + HCLGE_DEFAULT_DV; } else { priv->wl.low = 0; - priv->wl.high = hdev->mps; + priv->wl.high = aligned_mps; priv->buf_size = priv->wl.high; } }