Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp1093895imm; Wed, 26 Sep 2018 11:31:18 -0700 (PDT) X-Google-Smtp-Source: ACcGV61t4mDJLi4NGn7ZYoKpcx7nulpT7JFeipQFImkYUOTVJjBQXhkw5H0ScOHxeXWK36IbesRN X-Received: by 2002:a17:902:28aa:: with SMTP id f39-v6mr7369443plb.150.1537986678059; Wed, 26 Sep 2018 11:31:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537986678; cv=none; d=google.com; s=arc-20160816; b=VwyOOmFuUMWnqb7C1Yi+8gtqLUDXpN57OlZ+JC+d3R021fr9tWId1I24JO3id0VBJ6 LDJ+BAndWWsmLSs1aE4urD6mWTZtmKPa3pf7j40aCPqLSVxIZ1z+jiQj0ZOAvz4pyRSR gqf+9Fqi4a0k0t3x6N8ZctohC1Lp4ErRJbTB1Cy6aNeR2XhCLs4E6uH1yqa5C2oaPpad 2Zu9fiLQlZTcd5va7hmCKnl2MbItYDsRjhqhy7Mk8D9LufOocKJJNV8yLHGDirTCb33o G73Vby98hzVRev8EQwEMVoDVbzmqzvlR52LjPSGjs35gVeqY6TSt/mV8cbreLlCa/zof JHew== 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 e22-v6si5613323pfb.185.2018.09.26.11.31.03; Wed, 26 Sep 2018 11:31:18 -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 S1728972AbeI0Aoi (ORCPT + 99 others); Wed, 26 Sep 2018 20:44:38 -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 Content-Type: text/plain 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(-) 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; } } -- 2.7.4