Received: by 10.213.65.68 with SMTP id h4csp1030872imn; Wed, 21 Mar 2018 00:20:33 -0700 (PDT) X-Google-Smtp-Source: AG47ELvnddF54YciwIOsLokzMe3U4MMwwSu0nuz0s1jyQ9HUVJ1of+tiRherr6Q26nO85YiB3XMX X-Received: by 2002:a17:902:9a42:: with SMTP id x2-v6mr7069952plv.201.1521616833233; Wed, 21 Mar 2018 00:20:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521616833; cv=none; d=google.com; s=arc-20160816; b=OQ+Y27if3FbE7RFFxl602gU889DXFbz88npaAhN5EzCoH8cl9hqbdBUJYHPGjlehz3 MteqQihv3QP1aCJGVF17otaALEHS/6/bHntCTlKgVQTyGKAhht4wh9F7fWgDcsMcB5a0 Zz1VSfYD3j6uN+RP6ea9vKhp0vVUEyiTW1ecg5PlaKG/CR8aItD33pCdM8pYM8d1h7HI vPOGV4iK+jYR/BiBfciEIQu7g5zh/FZvYWOyHz8BWhwe9EohQ9ADDIMLrekzXid35NrH YINe35Tt7a8DMVDmySJWKhDq4ySI133ozxXRXJqewRzYUKgf9GgUiiBakiK08BIKEmWz DCVA== 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=4Z+HYj+Ktot+BgOAn0d5bpUeUkAwsHLibb5Cqncz9F0=; b=zqJB2MEsgupY78QLI6Bl8kzpf6qsp8e5ASTmuGM5ceh/R01FF6W45YLyMgN/h5C8Wr KELu7HvHqRdYnND8oRmrBPb/2Dbg+5UB3UfTglvQHbRcOIb8M5hAiClIO/9AU0bSR/AB tOK7vV8+cqb0xdnOvudT2sm/Y9GMx5v3KETD5JedmDgOU+L3UkZXtNWELkNxxBu0UQ0u nyHdRxyf7MjgK7B7OEhYiVrh2K62cj4aHiqcYHw4Oob0gb4ZdzitBBiSnbIGWZS9lie0 ntGX0wEr8HYlomFC9TqWG3463wqTnidxJ7+N8hsC4tRmXUpvvrIDzYSZ6wpaGwETnc44 /D4A== 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 67-v6si3411538pla.612.2018.03.21.00.20.04; Wed, 21 Mar 2018 00:20:33 -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 S1751671AbeCUHSZ (ORCPT + 99 others); Wed, 21 Mar 2018 03:18:25 -0400 Received: from szxga04-in.huawei.com ([45.249.212.190]:6660 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751319AbeCUHSP (ORCPT ); Wed, 21 Mar 2018 03:18:15 -0400 Received: from DGGEMS402-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id 211F2E48E752; 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:52 +0800 From: Peng Li To: CC: , , , , Subject: [PATCH net-next 03/11] net: hns3: fix for vlan table lost problem when resetting Date: Wed, 21 Mar 2018 15:49:22 +0800 Message-ID: <1521618570-129694-4-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: Yunsheng Lin The vlan table in hardware is clear after PF/Core/IMP/Global reset, which will cause vlan tagged packets not being received problem. This patch fixes it by restoring the vlan table after reset. Signed-off-by: Yunsheng Lin Signed-off-by: Peng Li --- drivers/net/ethernet/hisilicon/hns3/hns3_enet.c | 26 +++++++++++++++++++++++++ drivers/net/ethernet/hisilicon/hns3/hns3_enet.h | 3 +++ 2 files changed, 29 insertions(+) diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c index 94f0b92..f700ec1 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c @@ -1404,11 +1404,15 @@ static int hns3_vlan_rx_add_vid(struct net_device *netdev, __be16 proto, u16 vid) { struct hnae3_handle *h = hns3_get_handle(netdev); + struct hns3_nic_priv *priv = netdev_priv(netdev); int ret = -EIO; if (h->ae_algo->ops->set_vlan_filter) ret = h->ae_algo->ops->set_vlan_filter(h, proto, vid, false); + if (!ret) + set_bit(vid, priv->active_vlans); + return ret; } @@ -1416,14 +1420,32 @@ static int hns3_vlan_rx_kill_vid(struct net_device *netdev, __be16 proto, u16 vid) { struct hnae3_handle *h = hns3_get_handle(netdev); + struct hns3_nic_priv *priv = netdev_priv(netdev); int ret = -EIO; if (h->ae_algo->ops->set_vlan_filter) ret = h->ae_algo->ops->set_vlan_filter(h, proto, vid, true); + if (!ret) + clear_bit(vid, priv->active_vlans); + return ret; } +static void hns3_restore_vlan(struct net_device *netdev) +{ + struct hns3_nic_priv *priv = netdev_priv(netdev); + u16 vid; + int ret; + + for_each_set_bit(vid, priv->active_vlans, VLAN_N_VID) { + ret = hns3_vlan_rx_add_vid(netdev, htons(ETH_P_8021Q), vid); + if (ret) + netdev_warn(netdev, "Restore vlan: %d filter, ret:%d\n", + vid, ret); + } +} + static int hns3_ndo_set_vf_vlan(struct net_device *netdev, int vf, u16 vlan, u8 qos, __be16 vlan_proto) { @@ -3341,6 +3363,10 @@ static int hns3_reset_notify_init_enet(struct hnae3_handle *handle) hns3_nic_set_rx_mode(netdev); hns3_recover_hw_addr(netdev); + /* Hardware table is only clear when pf resets */ + if (!(handle->flags & HNAE3_SUPPORT_VF)) + hns3_restore_vlan(netdev); + /* Carrier off reporting is important to ethtool even BEFORE open */ netif_carrier_off(netdev); diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.h b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.h index a5f4550..c313780 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.h +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.h @@ -10,6 +10,8 @@ #ifndef __HNS3_ENET_H #define __HNS3_ENET_H +#include + #include "hnae3.h" extern const char hns3_driver_version[]; @@ -539,6 +541,7 @@ struct hns3_nic_priv { struct notifier_block notifier_block; /* Vxlan/Geneve information */ struct hns3_udp_tunnel udp_tnl[HNS3_UDP_TNL_MAX]; + unsigned long active_vlans[BITS_TO_LONGS(VLAN_N_VID)]; }; union l3_hdr_info { -- 2.9.3