From: GuoJia Liao liaoguojia@huawei.com
driver inclusion category: bugfix bugzilla: NA CVE: NA
-----------------------------
The VF VLAN filter state is depended on: 1) default VLAN mode on; 2) dynamic VLAN mode on and the function is a non-zero VLAN ID; 3) dynamic VLAN mode on and port base VLAN of this function is enabled.
Either is true, the VF VLAN filter should be enabled.
Currently, there are two separtely functions to handle the VF VLAN filter state. It can be simplified by merging them to a new one, named hclge_vf_vlan_filter_need_enable().
change log: V2->V3: change the commit message style reviewed by tanhuazhong; V1->V2: rewrite the commit log reviewed by shenjian;
Signed-off-by: GuoJia Liao liaoguojia@huawei.com Reviewed-by: Peng Li lipeng321@huawei.com Reviewed-by: Weiwei Deng dengweiwei@huawei.com Reviewed-by: Zhaohui Zhong zhongzhaohui@huawei.com Reviewed-by: Junxin Chen chenjunxin1@huawei.com Signed-off-by: Shengzui You youshengzui@huawei.com Signed-off-by: Yang Yingliang yangyingliang@huawei.com --- .../hisilicon/hns3/hns3pf/hclge_debugfs.c | 2 +- .../ethernet/hisilicon/hns3/hns3pf/hclge_main.c | 17 ++++++++--------- .../ethernet/hisilicon/hns3/hns3pf/hclge_main.h | 2 +- 3 files changed, 10 insertions(+), 11 deletions(-)
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_debugfs.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_debugfs.c index d85aaf78808e..78f13dd77cf1 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_debugfs.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_debugfs.c @@ -1650,7 +1650,7 @@ static void hclge_dbg_dump_vlan_filter(struct hclge_dev *hdev, }
vport = &hdev->vport[vf_id]; - has_vlan_used = hclge_has_vlan_used(hdev, vport->vport_id); + has_vlan_used = hclge_vf_vlan_need_enable(vport);
dev_info(&hdev->pdev->dev, "vf_id:%u\n", req->vf_id); dev_info(&hdev->pdev->dev, "vlan_type:%u\n", req->vlan_type); diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c index 674c75794835..7e2eb7dccc20 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c @@ -9013,18 +9013,19 @@ int hclge_en_hw_strip_rxvtag(struct hnae3_handle *handle, bool enable) return hclge_set_vlan_rx_offload_cfg(vport); }
-bool hclge_has_vlan_used(struct hclge_dev *hdev, u16 vport_id) +bool hclge_vf_vlan_need_enable(struct hclge_vport *vport) { #define VLAN_CHECK_START_NUM 1 + struct hclge_dev *hdev = vport->back; u16 vlan_id;
- /* if set as vlan normal mode, vf vlan filter always on */ - if (hdev->vlan_mode == HCLGE_VLAN_DEFAULT_MODE) + if (hdev->vlan_mode == HCLGE_VLAN_DEFAULT_MODE || + vport->port_base_vlan_cfg.state != HNAE3_PORT_BASE_VLAN_DISABLE) return true;
- /* check all vlan tag in vf vlan table except 0 */ + /* check all vlan tag in vf vlan table except vlan 0 */ for (vlan_id = VLAN_CHECK_START_NUM; vlan_id < VLAN_N_VID; vlan_id++) - if (test_bit(vport_id, hdev->vlan_table[vlan_id])) + if (test_bit(vport->vport_id, hdev->vlan_table[vlan_id])) return true;
return false; @@ -9037,8 +9038,7 @@ static int hclge_vf_vlan_filter_switch(struct hclge_vport *vport) bool filter_en; int ret;
- filter_en = hclge_has_vlan_used(hdev, vport->vport_id) || - vport->port_base_vlan_cfg.state == HNAE3_PORT_BASE_VLAN_ENABLE; + filter_en = hclge_vf_vlan_need_enable(vport);
if (filter_en == vport->vf_vlan_en) return 0; @@ -11374,8 +11374,7 @@ static void hclge_sync_promisc_mode(struct hclge_dev *hdev) tmp_flags & HNAE3_MPE); if (!ret) { clear_bit(HCLGE_STATE_PROMISC_CHANGED, &hdev->state); - /* promisc set for pf, so vport id as 0 */ - filter_en = hclge_has_vlan_used(hdev, 0) ? + filter_en = hclge_vf_vlan_need_enable(vport) ? HNAE3_VLAN_FLTR : 0; hclge_enable_vlan_filter(handle, tmp_flags & filter_en); } diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h index 2435b154ba80..522b238c5b57 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h @@ -1041,5 +1041,5 @@ int hclge_query_bd_num_cmd_send(struct hclge_dev *hdev, struct hclge_desc *desc); void hclge_inform_vf_promisc_info(struct hclge_vport *vport); void hclge_dbg_dump_rst_info(struct hclge_dev *hdev); -bool hclge_has_vlan_used(struct hclge_dev *hdev, u16 vport_id); +bool hclge_vf_vlan_need_enable(struct hclge_vport *vport); #endif