net: hns3: split function hclge_update_port_base_vlan_cfg()
[ Upstream commit d25f5eddbe1ace18fa95318fd229b07a64ec4353 ] Currently the function hclge_update_port_base_vlan_cfg() is a bit long. Split it to several small functions, to improve the readability. Signed-off-by: Jian Shen <shenjian15@huawei.com> Signed-off-by: Guangbin Huang <huangguangbin2@huawei.com> Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
parent
f4c5eba876
commit
23de00c130
@ -10397,12 +10397,41 @@ static bool hclge_need_update_vlan_filter(const struct hclge_vlan_info *new_cfg,
|
||||
return false;
|
||||
}
|
||||
|
||||
static int hclge_modify_port_base_vlan_tag(struct hclge_vport *vport,
|
||||
struct hclge_vlan_info *new_info,
|
||||
struct hclge_vlan_info *old_info)
|
||||
{
|
||||
struct hclge_dev *hdev = vport->back;
|
||||
int ret;
|
||||
|
||||
/* add new VLAN tag */
|
||||
ret = hclge_set_vlan_filter_hw(hdev, htons(new_info->vlan_proto),
|
||||
vport->vport_id, new_info->vlan_tag,
|
||||
false);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
/* remove old VLAN tag */
|
||||
if (old_info->vlan_tag == 0)
|
||||
ret = hclge_set_vf_vlan_common(hdev, vport->vport_id,
|
||||
true, 0);
|
||||
else
|
||||
ret = hclge_set_vlan_filter_hw(hdev, htons(ETH_P_8021Q),
|
||||
vport->vport_id,
|
||||
old_info->vlan_tag, true);
|
||||
if (ret)
|
||||
dev_err(&hdev->pdev->dev,
|
||||
"failed to clear vport%u port base vlan %u, ret = %d.\n",
|
||||
vport->vport_id, old_info->vlan_tag, ret);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int hclge_update_port_base_vlan_cfg(struct hclge_vport *vport, u16 state,
|
||||
struct hclge_vlan_info *vlan_info)
|
||||
{
|
||||
struct hnae3_handle *nic = &vport->nic;
|
||||
struct hclge_vlan_info *old_vlan_info;
|
||||
struct hclge_dev *hdev = vport->back;
|
||||
int ret;
|
||||
|
||||
old_vlan_info = &vport->port_base_vlan_cfg.vlan_info;
|
||||
@ -10415,38 +10444,12 @@ int hclge_update_port_base_vlan_cfg(struct hclge_vport *vport, u16 state,
|
||||
if (!hclge_need_update_vlan_filter(vlan_info, old_vlan_info))
|
||||
goto out;
|
||||
|
||||
if (state == HNAE3_PORT_BASE_VLAN_MODIFY) {
|
||||
/* 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 */
|
||||
if (old_vlan_info->vlan_tag == 0)
|
||||
ret = hclge_set_vf_vlan_common(hdev, vport->vport_id,
|
||||
true, 0);
|
||||
else
|
||||
ret = hclge_set_vlan_filter_hw(hdev,
|
||||
htons(ETH_P_8021Q),
|
||||
vport->vport_id,
|
||||
old_vlan_info->vlan_tag,
|
||||
true);
|
||||
if (ret) {
|
||||
dev_err(&hdev->pdev->dev,
|
||||
"failed to clear vport%u port base vlan %u, ret = %d.\n",
|
||||
vport->vport_id, old_vlan_info->vlan_tag, ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
goto out;
|
||||
}
|
||||
|
||||
ret = hclge_update_vlan_filter_entries(vport, state, vlan_info,
|
||||
old_vlan_info);
|
||||
if (state == HNAE3_PORT_BASE_VLAN_MODIFY)
|
||||
ret = hclge_modify_port_base_vlan_tag(vport, vlan_info,
|
||||
old_vlan_info);
|
||||
else
|
||||
ret = hclge_update_vlan_filter_entries(vport, state, vlan_info,
|
||||
old_vlan_info);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user