From patchwork Sat Sep 29 14:56:18 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Salil Mehta X-Patchwork-Id: 147849 Delivered-To: patch@linaro.org Received: by 2002:a2e:8595:0:0:0:0:0 with SMTP id b21-v6csp1986729lji; Sat, 29 Sep 2018 07:59:30 -0700 (PDT) X-Google-Smtp-Source: ACcGV60UkD2TtM2VJnqe4Ye3ZZfLDMEofF15mV5jX3BMHHEurPBhDmUhGPkTomdUuudcY3QlgdQJ X-Received: by 2002:a63:2218:: with SMTP id i24-v6mr3279905pgi.238.1538233170689; Sat, 29 Sep 2018 07:59:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538233170; cv=none; d=google.com; s=arc-20160816; b=eiaq/RB1SdirBNeXj808hPw5yI1Vdlh6GcCI8qbJfybbgIKhVGeOUoubVa4hx6YooA v+vxqUJQ5g9wjOzw+QPyRGMm5Zp9xM9hXaoIPxP9Qf1lLZMwIf9XDySFGWdViSxu+NBl Acha43+GB4IXFR75lJCarg1wZt0fOwkYRtc1ZczoBEZtBlLVm6p+F3Hg41GgWNvW/jV4 uIFGpqYO3K+EKKzAVHf7xlhjYNpPtHzhFDqEGnNcgeMrtDJs6vpVXd3tMPGhnECMCQMR R6+ZMgiOYmcq8GGCK6a0+LCdZRfc7lkWH/Csemmlbz+SE8jO4KKYWqzdvDZj/jeLT3BE RlKA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=3zNc4pxw/dBsGCSMnozCuCRUzso8bt925ZB1Ij3xxTs=; b=gh/FyQ2x7kA4jameagngM1x0Cpe4VCQo4XvPMGCAjM/kYPesnREowHxo32W/AbsvwR AFHswN2wH5+r3KTqCWQdGYU2eCpEhe1wWLEBNxPDH5QlfYWXFRYIwrBhDrA+4Hn3SsMd LVZsPbRSvFTCFLWOTfXdCDn+ttiWlpBSzQVFQC7gp5N0N2BBLg+HK7Gc3JP+weKMQPCn R5tSIWIF0uhUutXwmO7cUXVA+C8MxkGCFTyXh0sTBuERk96i9ZOQyp5GxCJix/YWQwiT /HnuHEmJj9a2e3+pxKlFDrFvh085qn7EdLo5/+ow6tFDX48oJtLzSecHUfLu75NAk1zd olbw== ARC-Authentication-Results: i=1; mx.google.com; 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 g10-v6si7174381plt.212.2018.09.29.07.59.30; Sat, 29 Sep 2018 07:59:30 -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; 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 S1728517AbeI2V1m (ORCPT + 32 others); Sat, 29 Sep 2018 17:27:42 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:13176 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728481AbeI2V1l (ORCPT ); Sat, 29 Sep 2018 17:27:41 -0400 Received: from DGGEMS412-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id 1F3071B65BB22; Sat, 29 Sep 2018 22:58:52 +0800 (CST) Received: from S00293818-DELL1.china.huawei.com (10.47.85.66) by DGGEMS412-HUB.china.huawei.com (10.3.19.212) with Microsoft SMTP Server id 14.3.399.0; Sat, 29 Sep 2018 22:58:44 +0800 From: Salil Mehta To: CC: , , , , , , , Yunsheng Lin Subject: [PATCH V2 net-next 06/10] net: hns3: Fix for packet buffer setting bug Date: Sat, 29 Sep 2018 15:56:18 +0100 Message-ID: <20180929145622.5448-7-salil.mehta@huawei.com> X-Mailer: git-send-email 2.8.3 In-Reply-To: <20180929145622.5448-1-salil.mehta@huawei.com> References: <20180929145622.5448-1-salil.mehta@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.47.85.66] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Yunsheng Lin 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 --- drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) -- 2.11.0 diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c index fa14bb900b2d..e2dc45c9c950 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c @@ -1356,11 +1356,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 @@ -1379,13 +1381,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 { @@ -1417,11 +1419,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; } }