]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
net: hns3: fix port base vlan add fail when concurrent with reset
authorJian Shen <shenjian15@huawei.com>
Thu, 24 Mar 2022 12:54:48 +0000 (20:54 +0800)
committerJakub Kicinski <kuba@kernel.org>
Fri, 25 Mar 2022 23:37:45 +0000 (16:37 -0700)
Currently, Port base vlan is initiated by PF and configured to its VFs,
by using command "ip link set <pf name> vf <vf id> vlan <vlan id>".
When a global reset was triggered, the hardware vlan table and the soft
recorded vlan information will be cleared by PF, and restored them until
VFs were ready. There is a short time window between the table had been
cleared and before table restored. If configured a new port base vlan tag
at this moment, driver will check the soft recorded vlan information,
and find there hasn't the old tag in it, which causing a warning print.

Due to the port base vlan is managed by PF, so the VFs's port base vlan
restoring should be handled by PF when PF was ready.

This patch fixes it.

Fixes: 039ba863e8d7 ("net: hns3: optimize the filter table entries handling when resetting")
Signed-off-by: Jian Shen <shenjian15@huawei.com>
Signed-off-by: Guangbin Huang <huangguangbin2@huawei.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h

index 0e1a110e7847f29cc3873963f254f8d7b4096725..34c6280c9af2bc7e927d97234c51d0649a856e70 100644 (file)
@@ -1872,6 +1872,7 @@ static int hclge_alloc_vport(struct hclge_dev *hdev)
                vport->vf_info.link_state = IFLA_VF_LINK_STATE_AUTO;
                vport->mps = HCLGE_MAC_DEFAULT_FRAME;
                vport->port_base_vlan_cfg.state = HNAE3_PORT_BASE_VLAN_DISABLE;
+               vport->port_base_vlan_cfg.tbl_sta = true;
                vport->rxvlan_cfg.rx_vlan_offload_en = true;
                vport->req_vlan_fltr_en = true;
                INIT_LIST_HEAD(&vport->vlan_list);
@@ -9915,34 +9916,52 @@ void hclge_uninit_vport_vlan_table(struct hclge_dev *hdev)
        }
 }
 
-void hclge_restore_vport_vlan_table(struct hclge_vport *vport)
+void hclge_restore_vport_port_base_vlan_config(struct hclge_dev *hdev)
 {
-       struct hclge_vport_vlan_cfg *vlan, *tmp;
-       struct hclge_dev *hdev = vport->back;
+       struct hclge_vlan_info *vlan_info;
+       struct hclge_vport *vport;
        u16 vlan_proto;
        u16 vlan_id;
        u16 state;
+       int vf_id;
        int ret;
 
-       vlan_proto = vport->port_base_vlan_cfg.vlan_info.vlan_proto;
-       vlan_id = vport->port_base_vlan_cfg.vlan_info.vlan_tag;
-       state = vport->port_base_vlan_cfg.state;
+       /* PF should restore all vfs port base vlan */
+       for (vf_id = 0; vf_id < hdev->num_alloc_vfs; vf_id++) {
+               vport = &hdev->vport[vf_id + HCLGE_VF_VPORT_START_NUM];
+               vlan_info = vport->port_base_vlan_cfg.tbl_sta ?
+                           &vport->port_base_vlan_cfg.vlan_info :
+                           &vport->port_base_vlan_cfg.old_vlan_info;
 
-       if (state != HNAE3_PORT_BASE_VLAN_DISABLE) {
-               clear_bit(vport->vport_id, hdev->vlan_table[vlan_id]);
-               hclge_set_vlan_filter_hw(hdev, htons(vlan_proto),
-                                        vport->vport_id, vlan_id,
-                                        false);
-               return;
+               vlan_id = vlan_info->vlan_tag;
+               vlan_proto = vlan_info->vlan_proto;
+               state = vport->port_base_vlan_cfg.state;
+
+               if (state != HNAE3_PORT_BASE_VLAN_DISABLE) {
+                       clear_bit(vport->vport_id, hdev->vlan_table[vlan_id]);
+                       ret = hclge_set_vlan_filter_hw(hdev, htons(vlan_proto),
+                                                      vport->vport_id,
+                                                      vlan_id, false);
+                       vport->port_base_vlan_cfg.tbl_sta = ret == 0;
+               }
        }
+}
 
-       list_for_each_entry_safe(vlan, tmp, &vport->vlan_list, node) {
-               ret = hclge_set_vlan_filter_hw(hdev, htons(ETH_P_8021Q),
-                                              vport->vport_id,
-                                              vlan->vlan_id, false);
-               if (ret)
-                       break;
-               vlan->hd_tbl_status = true;
+void hclge_restore_vport_vlan_table(struct hclge_vport *vport)
+{
+       struct hclge_vport_vlan_cfg *vlan, *tmp;
+       struct hclge_dev *hdev = vport->back;
+       int ret;
+
+       if (vport->port_base_vlan_cfg.state == HNAE3_PORT_BASE_VLAN_DISABLE) {
+               list_for_each_entry_safe(vlan, tmp, &vport->vlan_list, node) {
+                       ret = hclge_set_vlan_filter_hw(hdev, htons(ETH_P_8021Q),
+                                                      vport->vport_id,
+                                                      vlan->vlan_id, false);
+                       if (ret)
+                               break;
+                       vlan->hd_tbl_status = true;
+               }
        }
 }
 
@@ -9983,6 +10002,7 @@ static void hclge_restore_hw_table(struct hclge_dev *hdev)
        struct hnae3_handle *handle = &vport->nic;
 
        hclge_restore_mac_table_common(vport);
+       hclge_restore_vport_port_base_vlan_config(hdev);
        hclge_restore_vport_vlan_table(vport);
        set_bit(HCLGE_STATE_FD_USER_DEF_CHANGED, &hdev->state);
        hclge_restore_fd_entries(handle);
@@ -10039,6 +10059,8 @@ static int hclge_update_vlan_filter_entries(struct hclge_vport *vport,
                                                 false);
        }
 
+       vport->port_base_vlan_cfg.tbl_sta = false;
+
        /* force add VLAN 0 */
        ret = hclge_set_vf_vlan_common(hdev, vport->vport_id, false, 0);
        if (ret)
@@ -10128,7 +10150,9 @@ out:
        else
                nic->port_base_vlan_state = HNAE3_PORT_BASE_VLAN_ENABLE;
 
+       vport->port_base_vlan_cfg.old_vlan_info = *old_vlan_info;
        vport->port_base_vlan_cfg.vlan_info = *vlan_info;
+       vport->port_base_vlan_cfg.tbl_sta = true;
        hclge_set_vport_vlan_fltr_change(vport);
 
        return 0;
index fc92ae385e305b2dac09a30a0df56c91f40123c7..a0f619c77eae790060ac0d4afc3e0d8c09af696b 100644 (file)
@@ -985,7 +985,9 @@ struct hclge_vlan_info {
 
 struct hclge_port_base_vlan_config {
        u16 state;
+       bool tbl_sta;
        struct hclge_vlan_info vlan_info;
+       struct hclge_vlan_info old_vlan_info;
 };
 
 struct hclge_vf_info {
@@ -1100,6 +1102,7 @@ void hclge_rm_vport_all_mac_table(struct hclge_vport *vport, bool is_del_list,
 void hclge_rm_vport_all_vlan_table(struct hclge_vport *vport, bool is_del_list);
 void hclge_uninit_vport_vlan_table(struct hclge_dev *hdev);
 void hclge_restore_mac_table_common(struct hclge_vport *vport);
+void hclge_restore_vport_port_base_vlan_config(struct hclge_dev *hdev);
 void hclge_restore_vport_vlan_table(struct hclge_vport *vport);
 int hclge_update_port_base_vlan_cfg(struct hclge_vport *vport, u16 state,
                                    struct hclge_vlan_info *vlan_info);