Received: by 10.213.65.68 with SMTP id h4csp1031644imn; Wed, 21 Mar 2018 00:21:54 -0700 (PDT) X-Google-Smtp-Source: AG47ELsDnPJVV0PPeBfRczFHPDoRNR8J7FhU3qOf1eyTpt8FiY19opZiFfuOnUsnL9wfzHh5cF8T X-Received: by 2002:a17:902:5814:: with SMTP id m20-v6mr18599555pli.311.1521616914929; Wed, 21 Mar 2018 00:21:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521616914; cv=none; d=google.com; s=arc-20160816; b=SUG7KR/ac/PYB26l/X62y2guciiftNmD9yQK3pNAIcpMxjGx/68Kqv0qLAaejXZaTq Ilnhc33IVTdWfEBsv7hZ3OX4v4QzsOQjHTTiwmoW7/Lj/wkFi6HVZGKC1KTlEKp3Z+GH CkHNNuPRVgmb0kr+Lw3ArogNfMpZNlzF0VIru6QPqBLXmm/BPMCa+EKUDOB6q3vC5XzC B3jhbVz+0f43QUCv/uMMA/7KTM5WIhfoeyREh1Meo81DcoB30UW72DCS4UkmTQXJEFYH v9VXziDcm3fRPWCLQ7TkT/2x9bILm/2DIxnv/9EFTgZoqXXamic+PCQC5g4qSimKayAj CVNQ== 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:arc-authentication-results; bh=Pl9M7zxJs8qF/vzwdSZjgoOQfIPvoAH9ZeEVNfJqzAM=; b=a2YIs2D3TcA4rxKaTN+dGoyXRcLN6Xl08A4SeJHjNFR9U1ObyRvyRx9OV9Bf/Whqf6 8ioq21hIAEUG6DW+ud478V9uxWUtsfIzxtYhbPaUAuiDUsEvk8HUdoL6iK3FyA9Vr7gH MTE/hRqs04OuNj9rUK9iDLtxt47R3cnXd96jV+R9w8NCNN2jY+K1n51lKY5FeAhyvfTw 6OT2cvMlXaOH8suJNtKuNNTpkhUxEsXyvXFP9at+MP1UqShAgrPJbZSCW0UDdLYiluRu 69EerS3Xt4IoXoL8qnLGaC09lNLtdEk0k/6vRTIE1oCL5QgQG7U2gQCvqfmQTNq6EI+k 57PA== 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 a4-v6si3619465plm.660.2018.03.21.00.21.41; Wed, 21 Mar 2018 00:21:54 -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 S1751998AbeCUHUL (ORCPT + 99 others); Wed, 21 Mar 2018 03:20:11 -0400 Received: from szxga04-in.huawei.com ([45.249.212.190]:6663 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751539AbeCUHSU (ORCPT ); Wed, 21 Mar 2018 03:18:20 -0400 Received: from DGGEMS402-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id 130DD9D5A8813; Wed, 21 Mar 2018 15:18:01 +0800 (CST) Received: from linux-ioko.site (10.71.200.31) by DGGEMS402-HUB.china.huawei.com (10.3.19.202) with Microsoft SMTP Server id 14.3.361.1; Wed, 21 Mar 2018 15:17:51 +0800 From: Peng Li To: CC: , , , , Subject: [PATCH net-next 01/11] net: hns3: reallocate tx/rx buffer after changing mtu Date: Wed, 21 Mar 2018 15:49:20 +0800 Message-ID: <1521618570-129694-2-git-send-email-lipeng321@huawei.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1521618570-129694-1-git-send-email-lipeng321@huawei.com> References: <1521618570-129694-1-git-send-email-lipeng321@huawei.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.71.200.31] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Fuyun Liang When changing the mtu, the max frame size also will be changed. The tx buffer size and the rx buffer size to be allocated are determined by max frame size. So when max frame size is changed, the tx buffer and rx buffer need to be reallocated. When the tc_num is changed, the tx buffer and rx buffer need to be reallocated too. So calling set_mtu and buffer_alloc separately is better. Signed-off-by: Fuyun Liang Signed-off-by: Peng Li --- .../ethernet/hisilicon/hns3/hns3pf/hclge_main.c | 36 +++++++++++++--------- 1 file changed, 22 insertions(+), 14 deletions(-) diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c index d70619b..e110c65 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c @@ -4772,11 +4772,9 @@ static int hclge_en_hw_strip_rxvtag(struct hnae3_handle *handle, bool enable) return hclge_set_vlan_rx_offload_cfg(vport); } -static int hclge_set_mtu(struct hnae3_handle *handle, int new_mtu) +static int hclge_set_mac_mtu(struct hclge_dev *hdev, int new_mtu) { - struct hclge_vport *vport = hclge_get_vport(handle); struct hclge_config_max_frm_size_cmd *req; - struct hclge_dev *hdev = vport->back; struct hclge_desc desc; int max_frm_size; int ret; @@ -4805,6 +4803,27 @@ static int hclge_set_mtu(struct hnae3_handle *handle, int new_mtu) return 0; } +static int hclge_set_mtu(struct hnae3_handle *handle, int new_mtu) +{ + struct hclge_vport *vport = hclge_get_vport(handle); + struct hclge_dev *hdev = vport->back; + int ret; + + ret = hclge_set_mac_mtu(hdev, new_mtu); + if (ret) { + dev_err(&hdev->pdev->dev, + "Change mtu fail, ret =%d\n", ret); + return ret; + } + + ret = hclge_buffer_alloc(hdev); + if (ret) + dev_err(&hdev->pdev->dev, + "Allocate buffer fail, ret =%d\n", ret); + + return ret; +} + static int hclge_send_reset_tqp_cmd(struct hclge_dev *hdev, u16 queue_id, bool enable) { @@ -5392,11 +5411,6 @@ static int hclge_init_ae_dev(struct hnae3_ae_dev *ae_dev) dev_err(&pdev->dev, "Mac init error, ret = %d\n", ret); return ret; } - ret = hclge_buffer_alloc(hdev); - if (ret) { - dev_err(&pdev->dev, "Buffer allocate fail, ret =%d\n", ret); - return ret; - } ret = hclge_config_tso(hdev, HCLGE_TSO_MSS_MIN, HCLGE_TSO_MSS_MAX); if (ret) { @@ -5503,12 +5517,6 @@ static int hclge_reset_ae_dev(struct hnae3_ae_dev *ae_dev) return ret; } - ret = hclge_buffer_alloc(hdev); - if (ret) { - dev_err(&pdev->dev, "Buffer allocate fail, ret =%d\n", ret); - return ret; - } - ret = hclge_config_tso(hdev, HCLGE_TSO_MSS_MIN, HCLGE_TSO_MSS_MAX); if (ret) { dev_err(&pdev->dev, "Enable tso fail, ret =%d\n", ret); -- 2.9.3