net: hns3: add HNAE3_RESTORE_CLIENT interface in enet module
authorYunsheng Lin <linyunsheng@huawei.com>
Fri, 18 Jan 2019 08:13:14 +0000 (16:13 +0800)
committerDavid S. Miller <davem@davemloft.net>
Fri, 18 Jan 2019 23:10:22 +0000 (15:10 -0800)
The HNAE3_INIT_CLIENT interface is also used when changing tc
configuration, vlan/mac hardware table does not need to be restored
when tc configuration changes.

This patch adds a HNAE3_RESTORE_CLIENT interface to restore the
vlan/mac hardware table when resetting.

Signed-off-by: Yunsheng Lin <linyunsheng@huawei.com>
Signed-off-by: Peng Li <lipeng321@huawei.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/hisilicon/hns3/hnae3.h
drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c

index 81d15854478d56d8d3f4f42954c63b5076f0211f..d486748d588300a224e7c9635f9d49242d5f0ca6 100644 (file)
@@ -124,6 +124,7 @@ enum hnae3_reset_notify_type {
        HNAE3_DOWN_CLIENT,
        HNAE3_INIT_CLIENT,
        HNAE3_UNINIT_CLIENT,
+       HNAE3_RESTORE_CLIENT,
 };
 
 enum hnae3_reset_type {
index 10cc86533885d232feb92262344fd5231956c58d..9dd8949381bc67b622741f64842be77954268feb 100644 (file)
@@ -4004,35 +4004,8 @@ static int hns3_reset_notify_init_enet(struct hnae3_handle *handle)
 {
        struct net_device *netdev = handle->kinfo.netdev;
        struct hns3_nic_priv *priv = netdev_priv(netdev);
-       bool vlan_filter_enable;
        int ret;
 
-       ret = hns3_init_mac_addr(netdev, false);
-       if (ret)
-               return ret;
-
-       ret = hns3_recover_hw_addr(netdev);
-       if (ret)
-               return ret;
-
-       ret = hns3_update_promisc_mode(netdev, handle->netdev_flags);
-       if (ret)
-               return ret;
-
-       vlan_filter_enable = netdev->flags & IFF_PROMISC ? false : true;
-       hns3_enable_vlan_filter(netdev, vlan_filter_enable);
-
-       /* Hardware table is only clear when pf resets */
-       if (!(handle->flags & HNAE3_SUPPORT_VF)) {
-               ret = hns3_restore_vlan(netdev);
-               if (ret)
-                       return ret;
-       }
-
-       ret = hns3_restore_fd_rules(netdev);
-       if (ret)
-               return ret;
-
        /* Carrier off reporting is important to ethtool even BEFORE open */
        netif_carrier_off(netdev);
 
@@ -4070,6 +4043,37 @@ err_put_ring:
        return ret;
 }
 
+static int hns3_reset_notify_restore_enet(struct hnae3_handle *handle)
+{
+       struct net_device *netdev = handle->kinfo.netdev;
+       bool vlan_filter_enable;
+       int ret;
+
+       ret = hns3_init_mac_addr(netdev, false);
+       if (ret)
+               return ret;
+
+       ret = hns3_recover_hw_addr(netdev);
+       if (ret)
+               return ret;
+
+       ret = hns3_update_promisc_mode(netdev, handle->netdev_flags);
+       if (ret)
+               return ret;
+
+       vlan_filter_enable = netdev->flags & IFF_PROMISC ? false : true;
+       hns3_enable_vlan_filter(netdev, vlan_filter_enable);
+
+       /* Hardware table is only clear when pf resets */
+       if (!(handle->flags & HNAE3_SUPPORT_VF)) {
+               ret = hns3_restore_vlan(netdev);
+               if (ret)
+                       return ret;
+       }
+
+       return hns3_restore_fd_rules(netdev);
+}
+
 static int hns3_reset_notify_uninit_enet(struct hnae3_handle *handle)
 {
        struct net_device *netdev = handle->kinfo.netdev;
@@ -4125,6 +4129,9 @@ static int hns3_reset_notify(struct hnae3_handle *handle,
        case HNAE3_UNINIT_CLIENT:
                ret = hns3_reset_notify_uninit_enet(handle);
                break;
+       case HNAE3_RESTORE_CLIENT:
+               ret = hns3_reset_notify_restore_enet(handle);
+               break;
        default:
                break;
        }
index 97683a75c95d1822374cb4482ac51c017caa8375..00d7acb4d45abd46391c1dcdd502bbb6c64265a3 100644 (file)
@@ -2866,6 +2866,10 @@ static void hclge_reset(struct hclge_dev *hdev)
        if (ret)
                goto err_reset_lock;
 
+       ret = hclge_notify_client(hdev, HNAE3_RESTORE_CLIENT);
+       if (ret)
+               goto err_reset_lock;
+
        hclge_clear_reset_cause(hdev);
 
        ret = hclge_reset_prepare_up(hdev);
index 82103d5fa81592cae736257484921ef287d4825c..bb9f45200ef5e1bfe0edb99ae5fb351b6087a61d 100644 (file)
@@ -1264,7 +1264,7 @@ static int hclgevf_reset_stack(struct hclgevf_dev *hdev)
        if (ret)
                return ret;
 
-       return 0;
+       return hclgevf_notify_client(hdev, HNAE3_RESTORE_CLIENT);
 }
 
 static int hclgevf_reset_prepare_wait(struct hclgevf_dev *hdev)