Received: by 2002:ac0:98c7:0:0:0:0:0 with SMTP id g7-v6csp176567imd; Wed, 31 Oct 2018 16:51:41 -0700 (PDT) X-Google-Smtp-Source: AJdET5ejMW+tFSMx1zicZ7o3rH9QDCQDZO1h23bvw616ZHrs0w8VtZV8gopcml8NxEcP4yzxDR4/ X-Received: by 2002:a63:3204:: with SMTP id y4mr5017635pgy.41.1541029901201; Wed, 31 Oct 2018 16:51:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1541029901; cv=none; d=google.com; s=arc-20160816; b=Ecx2/MpP+eJ4S4jWhSOcKLGmsVShrMjv1J41bnRIgkGWt3ZOvokEXMCRbHLdyLrsr9 eDJ839zVJqyUmb+nk6fiGqrcbskhsc0hVGy+DTpn8kl1sikbfZ3OHJwQGwd+ZFnZg2GG u6BaLdiVp1z1rvCBvEozgBPdk3RYj64kTuhjQtoN+WIaJ4ruLCY6Vr7paI5/Ifzcdb+v pVZ+XznK8OENMOqLoFcD0z6CR3NHQV4NTDZOO+8tYjAHIYVxUMRU5VcSi5lcyha3rMYH 1/oUAhiGimgEhVzUyUGUtgcrF2HRdADKty2NCGd4ufKuyBwddGr0vi0jsikeutPRm3zu i8ug== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=lOk9WJJDV06Bhea8qNYT/uZzLfYClfLwLT4G1i/tLq4=; b=z+vCfRHQYIIxbcyG5KXHxMziy1m928H+d+5lFvG+TQHGtwkKLwRv1YjFXis6CumDxr ay2Re2c1kArhxWXkQwOz2rZTW5eYMgRzJ/5yFzrKPVHPKhLd0lEv2d69WzPAKTXLSk5D Hf9pkk8/AwolJbY5WXtYFkbNDSWx/2uT7Ts4QQtqsCWP53GHvcs9BjwouGU3hZEzi0fx RqxP0Ty6qAHOMvS4w6RFNbZ3iYaFNicnerWz3TUWTNhlDRmRhz3x6Y0VfzpOwO8G37lR CR9+K7WaXozjbUjUCWuuGVVy+Yy5MxEUI5ImdTEIMRzr5TXtWPFoWLN2EKBTLbonHYdC Ez/w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=HGRO94Vb; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f12-v6si27377403pgo.136.2018.10.31.16.51.25; Wed, 31 Oct 2018 16:51:41 -0700 (PDT) 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=HGRO94Vb; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728122AbeKAIGf (ORCPT + 99 others); Thu, 1 Nov 2018 04:06:35 -0400 Received: from mail.kernel.org ([198.145.29.99]:53560 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727984AbeKAIGe (ORCPT ); Thu, 1 Nov 2018 04:06:34 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id B465B20843; Wed, 31 Oct 2018 23:06:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1541027183; bh=SYlUz+5LaDSURpKfbJR8lBKb/o70zFxoVbwW6Og2P3A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HGRO94VblgUIcJ/pdX03BRpFN4bNzj/P7YztXBPVEVnY1MA61leRr5v1Y8E74au2w gU4rlj6Q0ObhEih0vh3hTn9Veu7p+pE7dBvzIOXDahkxKUCIAH/hbyoy8/kv/Zu8RX fHuq/mYmtziRw+WGT/R6iHquQlOHlX89RGXDIbUg= From: Sasha Levin To: stable@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Yunsheng Lin , Peng Li , Salil Mehta , "David S . Miller" , Sasha Levin Subject: [PATCH AUTOSEL 4.19 045/146] net: hns3: Fix for packet buffer setting bug Date: Wed, 31 Oct 2018 19:04:00 -0400 Message-Id: <20181031230541.28822-45-sashal@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181031230541.28822-1-sashal@kernel.org> References: <20181031230541.28822-1-sashal@kernel.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- .../ethernet/hisilicon/hns3/hns3pf/hclge_main.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c index 8577dfc799ad..023910abc831 100644 --- 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 hclge_dev *hdev, 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 hclge_dev *hdev, 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 hclge_dev *hdev, 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; } } -- 2.17.1