Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751851AbeAEJvW (ORCPT + 1 other); Fri, 5 Jan 2018 04:51:22 -0500 Received: from szxga04-in.huawei.com ([45.249.212.190]:3691 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751501AbeAEJtT (ORCPT ); Fri, 5 Jan 2018 04:49:19 -0500 From: Peng Li To: CC: , , , , Subject: [PATCH net-next 17/20] net: hns3: add MTU initialization for hardware Date: Fri, 5 Jan 2018 18:18:21 +0800 Message-ID: <1515147504-86802-18-git-send-email-lipeng321@huawei.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1515147504-86802-1-git-send-email-lipeng321@huawei.com> References: <1515147504-86802-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 List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Return-Path: From: Fuyun Liang When initializing the MAC, the MTU vlaue need to be set to the hardware too. Otherwise, the MTU value of software will be different from the MTU value of hardware. Fixes: 46a3df9f9718 ("net: hns3: Add HNS3 Acceleration Engine & Compatibility Layer Support") Signed-off-by: Fuyun Liang Signed-off-by: Peng Li --- .../ethernet/hisilicon/hns3/hns3pf/hclge_main.c | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c index f1702db..f8dbd1e 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c @@ -36,6 +36,7 @@ static int hclge_set_mta_filter_mode(struct hclge_dev *hdev, enum hclge_mta_dmac_sel_type mta_mac_sel, bool enable); +static int hclge_set_mtu(struct hnae3_handle *handle, int new_mtu); static int hclge_init_vlan_config(struct hclge_dev *hdev); static int hclge_reset_ae_dev(struct hnae3_ae_dev *ae_dev); @@ -2208,8 +2209,11 @@ static int hclge_set_default_mac_vlan_mask(struct hclge_dev *hdev, static int hclge_mac_init(struct hclge_dev *hdev) { + struct hnae3_handle *handle = &hdev->vport[0].nic; + struct net_device *netdev = handle->kinfo.netdev; struct hclge_mac *mac = &hdev->hw.mac; u8 mac_mask[ETH_ALEN] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; + int mtu; int ret; ret = hclge_cfg_mac_speed_dup(hdev, hdev->hw.mac.speed, HCLGE_MAC_FULL); @@ -2243,11 +2247,25 @@ static int hclge_mac_init(struct hclge_dev *hdev) } ret = hclge_set_default_mac_vlan_mask(hdev, true, mac_mask); - if (ret) + if (ret) { dev_err(&hdev->pdev->dev, "set default mac_vlan_mask fail ret=%d\n", ret); + return ret; + } - return ret; + if (netdev) + mtu = netdev->mtu; + else + mtu = ETH_DATA_LEN; + + ret = hclge_set_mtu(handle, mtu); + if (ret) { + dev_err(&hdev->pdev->dev, + "set mtu failed ret=%d\n", ret); + return ret; + } + + return 0; } static void hclge_mbx_task_schedule(struct hclge_dev *hdev) -- 1.9.1