Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp1982495imm; Sat, 29 Sep 2018 08:01:27 -0700 (PDT) X-Google-Smtp-Source: ACcGV63BBtpS5ObjBLqrRcvn8ClgCuz+f+JleMHKwX/4KiO92gRpASXys4y62py5QxjmH7yyR9L9 X-Received: by 2002:a63:cd12:: with SMTP id i18-v6mr1721629pgg.319.1538233287182; Sat, 29 Sep 2018 08:01:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538233287; cv=none; d=google.com; s=arc-20160816; b=gktI+se9Qmq85/g9ySonsyYYyJEU6xXUw5l+wz3d9in+SQk3GWTBlrS49Xu+C42fAb KdtLzAa4w6wTpaSL/dQhAA9xEZjkMPZZZuw4Wrzg2gFFcP4ZeLBB8pPNjyTGkg66od+K hn+mI2wOLpltRW8M8fO9HasotrcRO5xS4gi1RfpDzO6ySo31Z1VbfZVQQRkAsivY0i9g ae8ruyt5sMNPuUKYlgzcs69uw1LD3Gt+KJxHoxxNx76NByJ8Esrq16IickK16uXnh/mU aonpXTgQDzmOnykuPxJii74AgyQ9LvwJFiKArcBcB8B2/9Ij/9QvjXJPGK2Z69ChqWQl c6kQ== 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 d18-v6si8272807plj.82.2018.09.29.08.01.12; Sat, 29 Sep 2018 08:01:27 -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 S1728512AbeI2V1m (ORCPT + 99 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 Content-Type: text/plain 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(-) 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; } } -- 2.11.0