Skip to content

Commit 1c98550

Browse files
IronShendavem330
authored andcommitted
net: hns3: fix VF ID issue for setting VF VLAN
Previously, when set VF VLAN with command "ip link set <pf name> vf <vf id> vlan <vlan id>", the VF ID 0 is handled as PF incorrectly, which should be the first VF. This patch fixes it. Fixes: 21e043c ("net: hns3: fix set port based VLAN for PF") Signed-off-by: Jian Shen <[email protected]> Signed-off-by: Huazhong Tan <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent d1a37de commit 1c98550

File tree

1 file changed

+6
-12
lines changed

1 file changed

+6
-12
lines changed

drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8438,13 +8438,16 @@ static int hclge_set_vf_vlan_filter(struct hnae3_handle *handle, int vfid,
84388438
if (hdev->pdev->revision == 0x20)
84398439
return -EOPNOTSUPP;
84408440

8441+
vport = hclge_get_vf_vport(hdev, vfid);
8442+
if (!vport)
8443+
return -EINVAL;
8444+
84418445
/* qos is a 3 bits value, so can not be bigger than 7 */
8442-
if (vfid >= hdev->num_alloc_vfs || vlan > VLAN_N_VID - 1 || qos > 7)
8446+
if (vlan > VLAN_N_VID - 1 || qos > 7)
84438447
return -EINVAL;
84448448
if (proto != htons(ETH_P_8021Q))
84458449
return -EPROTONOSUPPORT;
84468450

8447-
vport = &hdev->vport[vfid];
84488451
state = hclge_get_port_base_vlan_state(vport,
84498452
vport->port_base_vlan_cfg.state,
84508453
vlan);
@@ -8455,21 +8458,12 @@ static int hclge_set_vf_vlan_filter(struct hnae3_handle *handle, int vfid,
84558458
vlan_info.qos = qos;
84568459
vlan_info.vlan_proto = ntohs(proto);
84578460

8458-
/* update port based VLAN for PF */
8459-
if (!vfid) {
8460-
hclge_notify_client(hdev, HNAE3_DOWN_CLIENT);
8461-
ret = hclge_update_port_base_vlan_cfg(vport, state, &vlan_info);
8462-
hclge_notify_client(hdev, HNAE3_UP_CLIENT);
8463-
8464-
return ret;
8465-
}
8466-
84678461
if (!test_bit(HCLGE_VPORT_STATE_ALIVE, &vport->state)) {
84688462
return hclge_update_port_base_vlan_cfg(vport, state,
84698463
&vlan_info);
84708464
} else {
84718465
ret = hclge_push_vf_port_base_vlan_info(&hdev->vport[0],
8472-
(u8)vfid, state,
8466+
vport->vport_id, state,
84738467
vlan, qos,
84748468
ntohs(proto));
84758469
return ret;

0 commit comments

Comments
 (0)