From patchwork Wed Sep 26 18:28:36 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Salil Mehta X-Patchwork-Id: 147626 Delivered-To: patch@linaro.org Received: by 2002:a2e:8595:0:0:0:0:0 with SMTP id b21-v6csp1059229lji; Wed, 26 Sep 2018 11:30:28 -0700 (PDT) X-Google-Smtp-Source: ACcGV61r/QmJWMhQRNJN65+f5g8CfdMWg86RMm7DJY+lzVrRT5/ElzVDIvt11zRyr83en1ZFkuVD X-Received: by 2002:a63:4b25:: with SMTP id y37-v6mr6787327pga.14.1537986627867; Wed, 26 Sep 2018 11:30:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537986627; cv=none; d=google.com; s=arc-20160816; b=SgWsBUnmKd2B9XtMRjwVV+ommPMXp/felvSwleWbvZPnteyyweodUxmzpvKRtI1iI4 /4Wtj4iiZDf8QU/rfr5wEMbm/T/aOUxGiBvstegeVLLONtwglDmkWtVtSu5eOuIDZlO7 hpVHEYV8nLXEnIq8ZmVsQpdKXHfwI+N0UTyFCuAeSmz7wggyRXQCJHhc2jgc4aPxB0+1 YbhQAVw8hUsUWGOefEMeDCcdYgdw3YZFw55oT1UTMDg1ZeSvc58h7d6oTmRpZey+6TOd tncXCDCjkhy2tF38FcDvYkjI7JQR+E3+jp+p4mpiNYQEhWKffHU3VgIlonzaNM8uvnO0 Co6w== 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=OL1zEAi9ZBbmKQuB+DJ8oObp/txtyZ/SbCQXaosaURs=; b=gt+bMgJWh5U1Im5yDR3MXofcJ0YhX+ZSPwHY1cPR32Vj2qjkdXJ3ko0RoJ1i0gd9O4 wxbl5cp/sYaEzxw1OhoxY1Aeye3kpU8lCg2qZTMAFpipRF332OCe1nthDXzzmNxBNgBY u/j/+Hdlph2MeMFV8TH1ODxiRoeRYok8FAuL0kO4DQ2S/h2pvlTzQefJmO74ih1fQLmQ VkQYa1aJ1vzCaPkS9uNn9vOLr1f3PD6n2LjJVPvDH1BgbFXjpEMCoW0xG7IekWkJy4dG EnDzmDkc4QWfxurV3DHQHa6ocFhZ5kEKXTW+DG4tb9PAjgGiSz1bXqBBuRVeHZAFZhyD vTqg== 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 x8-v6si6095226pgh.454.2018.09.26.11.30.27; Wed, 26 Sep 2018 11:30: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 S1728978AbeI0Aoj (ORCPT + 32 others); Wed, 26 Sep 2018 20:44:39 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:13154 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727064AbeI0AoB (ORCPT ); Wed, 26 Sep 2018 20:44:01 -0400 Received: from DGGEMS405-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id BFDBF19CCE877; Thu, 27 Sep 2018 02:29:43 +0800 (CST) Received: from S00293818-DELL1.china.huawei.com (10.202.226.54) by DGGEMS405-HUB.china.huawei.com (10.3.19.205) with Microsoft SMTP Server id 14.3.399.0; Thu, 27 Sep 2018 02:29:37 +0800 From: Salil Mehta To: CC: , , , , , , , Yunsheng Lin Subject: [PATCH net-next 06/10] net: hns3: Fix for packet buffer setting bug Date: Wed, 26 Sep 2018 19:28:36 +0100 Message-ID: <20180926182840.28392-7-salil.mehta@huawei.com> X-Mailer: git-send-email 2.8.3 In-Reply-To: <20180926182840.28392-1-salil.mehta@huawei.com> References: <20180926182840.28392-1-salil.mehta@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.202.226.54] 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.7.4 diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c index 72bc8c3..d8b0d16 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; } }