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

net: hns3: split function hclge_init_vlan_config()

Currently the function hclge_init_vlan_config() is a bit long.
Split it to several small functions, to simplify code and
improve code readability.
Signed-off-by: default avatarJian Shen <shenjian15@huawei.com>
Signed-off-by: default avatarGuangbin Huang <huangguangbin2@huawei.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent a1cfb24d
...@@ -10194,67 +10194,80 @@ static int hclge_set_vlan_protocol_type(struct hclge_dev *hdev) ...@@ -10194,67 +10194,80 @@ static int hclge_set_vlan_protocol_type(struct hclge_dev *hdev)
return status; return status;
} }
static int hclge_init_vlan_config(struct hclge_dev *hdev) static int hclge_init_vlan_filter(struct hclge_dev *hdev)
{ {
#define HCLGE_DEF_VLAN_TYPE 0x8100
struct hnae3_handle *handle = &hdev->vport[0].nic;
struct hclge_vport *vport; struct hclge_vport *vport;
int ret; int ret;
int i; int i;
if (hdev->ae_dev->dev_version >= HNAE3_DEVICE_VERSION_V2) { if (hdev->ae_dev->dev_version < HNAE3_DEVICE_VERSION_V2)
/* for revision 0x21, vf vlan filter is per function */ return hclge_set_vlan_filter_ctrl(hdev, HCLGE_FILTER_TYPE_VF,
for (i = 0; i < hdev->num_alloc_vport; i++) { HCLGE_FILTER_FE_EGRESS_V1_B,
vport = &hdev->vport[i]; true, 0);
ret = hclge_set_vlan_filter_ctrl(hdev,
HCLGE_FILTER_TYPE_VF,
HCLGE_FILTER_FE_EGRESS,
true,
vport->vport_id);
if (ret)
return ret;
vport->cur_vlan_fltr_en = true;
}
ret = hclge_set_vlan_filter_ctrl(hdev, HCLGE_FILTER_TYPE_PORT, /* for revision 0x21, vf vlan filter is per function */
HCLGE_FILTER_FE_INGRESS, true, for (i = 0; i < hdev->num_alloc_vport; i++) {
0); vport = &hdev->vport[i];
if (ret)
return ret;
} 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, true,
true, 0); vport->vport_id);
if (ret) if (ret)
return ret; return ret;
vport->cur_vlan_fltr_en = true;
} }
hdev->vlan_type_cfg.rx_in_fst_vlan_type = HCLGE_DEF_VLAN_TYPE; return hclge_set_vlan_filter_ctrl(hdev, HCLGE_FILTER_TYPE_PORT,
hdev->vlan_type_cfg.rx_in_sec_vlan_type = HCLGE_DEF_VLAN_TYPE; HCLGE_FILTER_FE_INGRESS, true, 0);
hdev->vlan_type_cfg.rx_ot_fst_vlan_type = HCLGE_DEF_VLAN_TYPE; }
hdev->vlan_type_cfg.rx_ot_sec_vlan_type = HCLGE_DEF_VLAN_TYPE;
hdev->vlan_type_cfg.tx_ot_vlan_type = HCLGE_DEF_VLAN_TYPE;
hdev->vlan_type_cfg.tx_in_vlan_type = HCLGE_DEF_VLAN_TYPE;
ret = hclge_set_vlan_protocol_type(hdev); static int hclge_init_vlan_type(struct hclge_dev *hdev)
if (ret) {
return ret; hdev->vlan_type_cfg.rx_in_fst_vlan_type = ETH_P_8021Q;
hdev->vlan_type_cfg.rx_in_sec_vlan_type = ETH_P_8021Q;
hdev->vlan_type_cfg.rx_ot_fst_vlan_type = ETH_P_8021Q;
hdev->vlan_type_cfg.rx_ot_sec_vlan_type = ETH_P_8021Q;
hdev->vlan_type_cfg.tx_ot_vlan_type = ETH_P_8021Q;
hdev->vlan_type_cfg.tx_in_vlan_type = ETH_P_8021Q;
for (i = 0; i < hdev->num_alloc_vport; i++) { return hclge_set_vlan_protocol_type(hdev);
u16 vlan_tag; }
u8 qos;
static int hclge_init_vport_vlan_offload(struct hclge_dev *hdev)
{
struct hclge_port_base_vlan_config *cfg;
struct hclge_vport *vport;
int ret;
int i;
for (i = 0; i < hdev->num_alloc_vport; i++) {
vport = &hdev->vport[i]; vport = &hdev->vport[i];
vlan_tag = vport->port_base_vlan_cfg.vlan_info.vlan_tag; cfg = &vport->port_base_vlan_cfg;
qos = vport->port_base_vlan_cfg.vlan_info.qos;
ret = hclge_vlan_offload_cfg(vport, ret = hclge_vlan_offload_cfg(vport, cfg->state,
vport->port_base_vlan_cfg.state, cfg->vlan_info.vlan_tag,
vlan_tag, qos); cfg->vlan_info.qos);
if (ret) if (ret)
return ret; return ret;
} }
return 0;
}
static int hclge_init_vlan_config(struct hclge_dev *hdev)
{
struct hnae3_handle *handle = &hdev->vport[0].nic;
int ret;
ret = hclge_init_vlan_filter(hdev);
if (ret)
return ret;
ret = hclge_init_vlan_type(hdev);
if (ret)
return ret;
ret = hclge_init_vport_vlan_offload(hdev);
if (ret)
return ret;
return hclge_set_vlan_filter(handle, htons(ETH_P_8021Q), 0, false); return hclge_set_vlan_filter(handle, htons(ETH_P_8021Q), 0, false);
} }
......
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