From 6a10e967d2e06ebd9b07a79a1b943746682cc174 Mon Sep 17 00:00:00 2001 From: Guojia Liao Date: Fri, 11 Oct 2019 21:12:35 +0800 Subject: [PATCH] net: hns3: swaps sequence between remove and add when modifying port base vlan driver inclusion category: bugfix bugzilla: NA CVE: NA When modified the port base vlan tag, we need to add a new vlan tag and remove the old vlan tag. In original codes, removing the tag action was before adding the new tag. Onece the new tag added failed, if would cause the old tag lost. So we change the sequence. Fixes : 18fb5b0b985d ("After the vf is abnormal, delete the entries remaining in the chip.") Feature or Bugfix:Bugfix Signed-off-by: Guojia Liao Reviewed-by: lipeng Reviewed-by: Yunsheng Lin Signed-off-by: Yang Yingliang --- .../hisilicon/hns3/hns3pf/hclge_main.c | 27 +++++++++++++------ 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c index 803140f949e1..37dcb9a60844 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c @@ -8407,13 +8407,24 @@ int hclge_update_port_base_vlan_cfg(struct hclge_vport *vport, u16 state, return ret; if (state == HNAE3_PORT_BASE_VLAN_MODIFY) { - hclge_set_vlan_filter_hw(hdev, old_vlan_info->vlan_proto, - vport->vport_id, - old_vlan_info->vlan_tag, - true); - hclge_set_vlan_filter_hw(hdev, vlan_info->vlan_proto, - vport->vport_id, vlan_info->vlan_tag, - false); + /* add new VLAN tag */ + ret = hclge_set_vlan_filter_hw(hdev, + htons(vlan_info->vlan_proto), + vport->vport_id, + vlan_info->vlan_tag, + false); + if (ret) + return ret; + + /* remove old VLAN tag */ + ret = hclge_set_vlan_filter_hw(hdev, + htons(old_vlan_info->vlan_proto), + vport->vport_id, + old_vlan_info->vlan_tag, + true); + if (ret) + return ret; + goto update; } @@ -8422,7 +8433,7 @@ int hclge_update_port_base_vlan_cfg(struct hclge_vport *vport, u16 state, if (ret) return ret; - /* update state only when disable/enable port base vlan */ + /* update state only when disable/enable port based VLAN */ vport->port_base_vlan_cfg.state = state; if (state == HNAE3_PORT_BASE_VLAN_DISABLE) nic->port_base_vlan_state = HNAE3_PORT_BASE_VLAN_DISABLE; -- GitLab