net: hns3: don't configure new VLAN ID into VF VLAN table when it's full
authorJian Shen <shenjian15@huawei.com>
Mon, 3 Jun 2019 02:09:14 +0000 (10:09 +0800)
committerDavid S. Miller <davem@davemloft.net>
Mon, 3 Jun 2019 22:32:50 +0000 (15:32 -0700)
VF VLAN table can only support no more than 256 VLANs. When user
adds too many VLANs, the VF VLAN table will be full, and firmware
will close the VF VLAN table for the function. When VF VLAN table
is full, and user keeps adding new VLANs, it's unnecessary to
configure the VF VLAN table, because it will always fail, and print
warning message. The worst case is adding 4K VLANs, and doing reset,
it will take much time to restore these VLANs, which may cause VF
reset fail by timeout.

Fixes: 6c251711b37f ("net: hns3: Disable vf vlan filter when vf vlan table is full")
Signed-off-by: Jian Shen <shenjian15@huawei.com>
Signed-off-by: Peng Li <lipeng321@huawei.com>
Signed-off-by: Huazhong Tan <tanhuazhong@huawei.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h

index f0f618d..1215455 100644 (file)
@@ -7025,6 +7025,12 @@ static int hclge_set_vf_vlan_common(struct hclge_dev *hdev, int vfid,
        u8 vf_byte_off;
        int ret;
 
+       /* if vf vlan table is full, firmware will close vf vlan filter, it
+        * is unable and unnecessary to add new vlan id to vf vlan filter
+        */
+       if (test_bit(vfid, hdev->vf_vlan_full) && !is_kill)
+               return 0;
+
        hclge_cmd_setup_basic_desc(&desc[0],
                                   HCLGE_OPC_VLAN_FILTER_VF_CFG, false);
        hclge_cmd_setup_basic_desc(&desc[1],
@@ -7060,6 +7066,7 @@ static int hclge_set_vf_vlan_common(struct hclge_dev *hdev, int vfid,
                        return 0;
 
                if (req0->resp_code == HCLGE_VF_VLAN_NO_ENTRY) {
+                       set_bit(vfid, hdev->vf_vlan_full);
                        dev_warn(&hdev->pdev->dev,
                                 "vf vlan table is full, vf vlan filter is disabled\n");
                        return 0;
@@ -8621,6 +8628,7 @@ static int hclge_reset_ae_dev(struct hnae3_ae_dev *ae_dev)
 
        hclge_stats_clear(hdev);
        memset(hdev->vlan_table, 0, sizeof(hdev->vlan_table));
+       memset(hdev->vf_vlan_full, 0, sizeof(hdev->vf_vlan_full));
 
        ret = hclge_cmd_init(hdev);
        if (ret) {
index 2b3bc95..414f7db 100644 (file)
@@ -820,6 +820,7 @@ struct hclge_dev {
        struct hclge_vlan_type_cfg vlan_type_cfg;
 
        unsigned long vlan_table[VLAN_N_VID][BITS_TO_LONGS(HCLGE_VPORT_NUM)];
+       unsigned long vf_vlan_full[BITS_TO_LONGS(HCLGE_VPORT_NUM)];
 
        struct hclge_fd_cfg fd_cfg;
        struct hlist_head fd_rule_list;