Commit 30ebc576 authored by Jian Shen's avatar Jian Shen Committed by David S. Miller

net: hns3: enable VF VLAN filter for each VF when initializing

For revision 0x21, the switch of VF VLAN filter is per function.
It's necessary to enable VF VLAN filter for each VF when initializing.
Otherwise, VF will be able to receive broadcast packets with unknown
VLAN when PF enters promisc mode.

Fixes: 64d114f0 ("net: hns3: Add egress/ingress vlan filter for revision 0x21")
Signed-off-by: default avatarJian Shen <shenjian15@huawei.com>
Signed-off-by: default avatarPeng Li <lipeng321@huawei.com>
Signed-off-by: default avatarHuazhong Tan <tanhuazhong@huawei.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent c0425944
...@@ -693,7 +693,9 @@ struct hclge_mac_vlan_remove_cmd { ...@@ -693,7 +693,9 @@ struct hclge_mac_vlan_remove_cmd {
struct hclge_vlan_filter_ctrl_cmd { struct hclge_vlan_filter_ctrl_cmd {
u8 vlan_type; u8 vlan_type;
u8 vlan_fe; u8 vlan_fe;
u8 rsv[22]; u8 rsv1[2];
u8 vf_id;
u8 rsv2[19];
}; };
struct hclge_vlan_filter_pf_cfg_cmd { struct hclge_vlan_filter_pf_cfg_cmd {
......
...@@ -6337,7 +6337,7 @@ static int hclge_do_ioctl(struct hnae3_handle *handle, struct ifreq *ifr, ...@@ -6337,7 +6337,7 @@ static int hclge_do_ioctl(struct hnae3_handle *handle, struct ifreq *ifr,
} }
static int hclge_set_vlan_filter_ctrl(struct hclge_dev *hdev, u8 vlan_type, static int hclge_set_vlan_filter_ctrl(struct hclge_dev *hdev, u8 vlan_type,
u8 fe_type, bool filter_en) u8 fe_type, bool filter_en, u8 vf_id)
{ {
struct hclge_vlan_filter_ctrl_cmd *req; struct hclge_vlan_filter_ctrl_cmd *req;
struct hclge_desc desc; struct hclge_desc desc;
...@@ -6348,6 +6348,7 @@ static int hclge_set_vlan_filter_ctrl(struct hclge_dev *hdev, u8 vlan_type, ...@@ -6348,6 +6348,7 @@ static int hclge_set_vlan_filter_ctrl(struct hclge_dev *hdev, u8 vlan_type,
req = (struct hclge_vlan_filter_ctrl_cmd *)desc.data; req = (struct hclge_vlan_filter_ctrl_cmd *)desc.data;
req->vlan_type = vlan_type; req->vlan_type = vlan_type;
req->vlan_fe = filter_en ? fe_type : 0; req->vlan_fe = filter_en ? fe_type : 0;
req->vf_id = vf_id;
ret = hclge_cmd_send(&hdev->hw, &desc, 1); ret = hclge_cmd_send(&hdev->hw, &desc, 1);
if (ret) if (ret)
...@@ -6376,12 +6377,13 @@ static void hclge_enable_vlan_filter(struct hnae3_handle *handle, bool enable) ...@@ -6376,12 +6377,13 @@ static void hclge_enable_vlan_filter(struct hnae3_handle *handle, bool enable)
if (hdev->pdev->revision >= 0x21) { if (hdev->pdev->revision >= 0x21) {
hclge_set_vlan_filter_ctrl(hdev, HCLGE_FILTER_TYPE_VF, hclge_set_vlan_filter_ctrl(hdev, HCLGE_FILTER_TYPE_VF,
HCLGE_FILTER_FE_EGRESS, enable); HCLGE_FILTER_FE_EGRESS, enable, 0);
hclge_set_vlan_filter_ctrl(hdev, HCLGE_FILTER_TYPE_PORT, hclge_set_vlan_filter_ctrl(hdev, HCLGE_FILTER_TYPE_PORT,
HCLGE_FILTER_FE_INGRESS, enable); HCLGE_FILTER_FE_INGRESS, enable, 0);
} else { } else {
hclge_set_vlan_filter_ctrl(hdev, HCLGE_FILTER_TYPE_VF, hclge_set_vlan_filter_ctrl(hdev, HCLGE_FILTER_TYPE_VF,
HCLGE_FILTER_FE_EGRESS_V1_B, enable); HCLGE_FILTER_FE_EGRESS_V1_B, enable,
0);
} }
if (enable) if (enable)
handle->netdev_flags |= HNAE3_VLAN_FLTR; handle->netdev_flags |= HNAE3_VLAN_FLTR;
...@@ -6689,19 +6691,27 @@ static int hclge_init_vlan_config(struct hclge_dev *hdev) ...@@ -6689,19 +6691,27 @@ static int hclge_init_vlan_config(struct hclge_dev *hdev)
int i; int i;
if (hdev->pdev->revision >= 0x21) { if (hdev->pdev->revision >= 0x21) {
ret = hclge_set_vlan_filter_ctrl(hdev, HCLGE_FILTER_TYPE_VF, /* for revision 0x21, vf vlan filter is per function */
HCLGE_FILTER_FE_EGRESS, true); for (i = 0; i < hdev->num_alloc_vport; i++) {
vport = &hdev->vport[i];
ret = hclge_set_vlan_filter_ctrl(hdev,
HCLGE_FILTER_TYPE_VF,
HCLGE_FILTER_FE_EGRESS,
true,
vport->vport_id);
if (ret) if (ret)
return ret; return ret;
}
ret = hclge_set_vlan_filter_ctrl(hdev, HCLGE_FILTER_TYPE_PORT, ret = hclge_set_vlan_filter_ctrl(hdev, HCLGE_FILTER_TYPE_PORT,
HCLGE_FILTER_FE_INGRESS, true); HCLGE_FILTER_FE_INGRESS, true,
0);
if (ret) if (ret)
return ret; return ret;
} else { } else {
ret = hclge_set_vlan_filter_ctrl(hdev, HCLGE_FILTER_TYPE_VF, ret = hclge_set_vlan_filter_ctrl(hdev, HCLGE_FILTER_TYPE_VF,
HCLGE_FILTER_FE_EGRESS_V1_B, HCLGE_FILTER_FE_EGRESS_V1_B,
true); true, 0);
if (ret) if (ret)
return ret; return ret;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment