From: shenhao shenhao21@huawei.com
driver inclusion category: Feature bugzilla: NA CVE: NA DTS: DTS2021090315802
---------------------------------------------------
This reverts commit 2eeca9dad888d02764d0366d573a659ffad7f825.
This patch adds support for extended VLAN mode, as we call dynamic vlan mode. In this mode, vf vlan filter will be switch between enable and disable, according to user configuration.
This patch also adds support for QOS in vlan 802.1Q protocol.
Signed-off-by: liaoguojia liaoguojia@huawei.com Signed-off-by: shenhao shenhao21@huawei.com Reviewed-by: Zhong Zhaohui zhongzhaohui@huawei.com Signed-off-by: Yang Yingliang yangyingliang@huawei.com --- drivers/net/ethernet/hisilicon/hns3/hnae3.h | 4 +- .../net/ethernet/hisilicon/hns3/hns3_enet.c | 3 - .../ethernet/hisilicon/hns3/hns3_ethtool.c | 5 +- .../hisilicon/hns3/hns3pf/hclge_cmd.h | 2 - .../hisilicon/hns3/hns3pf/hclge_debugfs.c | 8 - .../hisilicon/hns3/hns3pf/hclge_main.c | 281 ++++-------------- .../hisilicon/hns3/hns3pf/hclge_main.h | 19 +- .../hisilicon/hns3/hns3vf/hclgevf_main.c | 5 - 8 files changed, 65 insertions(+), 262 deletions(-)
diff --git a/drivers/net/ethernet/hisilicon/hns3/hnae3.h b/drivers/net/ethernet/hisilicon/hns3/hnae3.h index 188d2ef63db4..19fac4adf371 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hnae3.h +++ b/drivers/net/ethernet/hisilicon/hns3/hnae3.h @@ -729,12 +729,10 @@ struct hnae3_unic_private_info { #define HNAE3_BPE BIT(2) /* broadcast promisc enable */ #define HNAE3_OVERFLOW_UPE BIT(3) /* unicast mac vlan overflow */ #define HNAE3_OVERFLOW_MPE BIT(4) /* multicast mac vlan overflow */ -#define HNAE3_VLAN_FLTR BIT(5) /* enable vlan filter by promisc mode */ -#define HNAE3_VF_VLAN_EN BIT(6) /* enable vf vlan filter by vlan used */ +#define HNAE3_VLAN_FLTR BIT(5) /* enable vlan filter */ #define HNAE3_UPE (HNAE3_USER_UPE | HNAE3_OVERFLOW_UPE) #define HNAE3_MPE (HNAE3_USER_MPE | HNAE3_OVERFLOW_MPE) #define HNAE3_OVERFLOW_UMPE (HNAE3_OVERFLOW_UPE | HNAE3_OVERFLOW_MPE) -#define HNAE3_VLAN_FLTR_EN (HNAE3_VLAN_FLTR | HNAE3_VF_VLAN_EN)
struct hnae3_handle { struct hnae3_client *client; diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c index dc556de21875..3a08b9cc2366 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c @@ -583,7 +583,6 @@ static int hns3_nic_mc_unsync(struct net_device *netdev,
static u8 hns3_get_netdev_flags(struct net_device *netdev) { - struct hnae3_handle *h = hns3_get_handle(netdev); u8 flags = 0;
if (netdev->flags & IFF_PROMISC) { @@ -594,8 +593,6 @@ static u8 hns3_get_netdev_flags(struct net_device *netdev) flags |= HNAE3_USER_MPE; }
- flags |= (h->netdev_flags & HNAE3_VF_VLAN_EN); - return flags; }
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c b/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c index 1bebeb3bbdf0..f302c8ff4414 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c @@ -110,8 +110,7 @@ static int hns3_lp_setup(struct net_device *ndev, enum hnae3_loop loop, bool en) } else { /* recover promisc mode before loopback test */ hns3_request_update_promisc_mode(h); - vlan_filter_enable = (h->netdev_flags & HNAE3_VLAN_FLTR_EN) ? - false : true; + vlan_filter_enable = ndev->flags & IFF_PROMISC ? false : true; hns3_enable_vlan_filter(ndev, vlan_filter_enable); }
@@ -401,7 +400,7 @@ static void hns3_self_test(struct net_device *ndev, #if IS_ENABLED(CONFIG_VLAN_8021Q) if (dis_vlan_filter) h->ae_algo->ops->enable_vlan_filter(h, - h->netdev_flags & HNAE3_VF_VLAN_EN); + ndev->flags & IFF_PROMISC); #endif
if (if_running) diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_cmd.h b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_cmd.h index 3e10dafdee0c..9c25fffb1e18 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_cmd.h +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_cmd.h @@ -498,8 +498,6 @@ struct hclge_pf_res_cmd { #define HCLGE_CFG_RSS_SIZE_M GENMASK(31, 24) #define HCLGE_CFG_SPEED_ABILITY_S 0 #define HCLGE_CFG_SPEED_ABILITY_M GENMASK(7, 0) -#define HCLGE_CFG_VLAN_MODE_S 8 -#define HCLGE_CFG_VLAN_MODE_M GENMASK(9, 8) #define HCLGE_CFG_UMV_TBL_SPACE_S 16 #define HCLGE_CFG_UMV_TBL_SPACE_M GENMASK(31, 16)
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_debugfs.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_debugfs.c index 4670059d9a70..00d474329a01 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_debugfs.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_debugfs.c @@ -2020,7 +2020,6 @@ static void hclge_dbg_dump_vlan_filter(struct hclge_dev *hdev, struct hclge_vlan_filter_ctrl_cmd *req; struct hclge_vport *vport; struct hclge_desc desc; - bool has_vlan_used; u32 vf_id; int ret;
@@ -2049,19 +2048,12 @@ static void hclge_dbg_dump_vlan_filter(struct hclge_dev *hdev, }
vport = &hdev->vport[vf_id]; - has_vlan_used = hclge_vf_vlan_need_enable(vport);
dev_info(&hdev->pdev->dev, "vf_id:%u\n", req->vf_id); dev_info(&hdev->pdev->dev, "vlan_type:%u\n", req->vlan_type); dev_info(&hdev->pdev->dev, "vlan_fe:%u\n", req->vlan_fe); - dev_info(&hdev->pdev->dev, "vf_vlan_en:%u\n", vport->vf_vlan_en); - dev_info(&hdev->pdev->dev, "vlan_mode:%s\n", - (hdev->vlan_mode == HCLGE_VLAN_DEFAULT_MODE) ? "default" : - "dynamic"); dev_info(&hdev->pdev->dev, "netdev_flags:%x\n", vport->nic.netdev_flags); - dev_info(&hdev->pdev->dev, "has_vlan_used:%s\n", - has_vlan_used ? "true" : "false"); dev_info(&hdev->pdev->dev, "port_base_vlan_cfg_state:%u\n", vport->port_base_vlan_cfg.state); } diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c index 778f1e2124d3..4c4c39ca99e9 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c @@ -68,7 +68,6 @@ static int hclge_set_default_loopback(struct hclge_dev *hdev); static void hclge_sync_mac_table(struct hclge_dev *hdev); static void hclge_restore_hw_table(struct hclge_dev *hdev); static void hclge_sync_promisc_mode(struct hclge_dev *hdev); -static int hclge_vf_vlan_filter_switch(struct hclge_vport *vport);
static struct hnae3_ae_algo ae_algo;
@@ -1305,9 +1304,6 @@ static void hclge_parse_cfg(struct hclge_cfg *cfg, struct hclge_desc *desc) HCLGE_CFG_SPEED_ABILITY_M, HCLGE_CFG_SPEED_ABILITY_S);
- cfg->vlan_mode_sel = hnae3_get_field(__le32_to_cpu(req->param[1]), - HCLGE_CFG_VLAN_MODE_M, - HCLGE_CFG_VLAN_MODE_S);
cfg->umv_space = hnae3_get_field(__le32_to_cpu(req->param[1]), HCLGE_CFG_UMV_TBL_SPACE_M, @@ -1410,7 +1406,6 @@ static int hclge_configure(struct hclge_dev *hdev) hdev->tc_max = cfg.tc_num; hdev->tm_info.hw_pfc_map = 0; hdev->wanted_umv_size = cfg.umv_space; - hdev->vlan_mode = cfg.vlan_mode_sel;
if (hnae3_dev_fd_supported(hdev)) { hdev->fd_en = true; @@ -8300,18 +8295,6 @@ static int hclge_do_ioctl(struct hnae3_handle *handle, struct ifreq *ifr, return phy_mii_ioctl(hdev->hw.mac.phydev, ifr, cmd); }
-#define HCLGE_FILTER_TYPE_VF 0 -#define HCLGE_FILTER_TYPE_PORT 1 -#define HCLGE_FILTER_FE_EGRESS_V1_B BIT(0) -#define HCLGE_FILTER_FE_NIC_INGRESS_B BIT(0) -#define HCLGE_FILTER_FE_NIC_EGRESS_B BIT(1) -#define HCLGE_FILTER_FE_ROCE_INGRESS_B BIT(2) -#define HCLGE_FILTER_FE_ROCE_EGRESS_B BIT(3) -#define HCLGE_FILTER_FE_EGRESS (HCLGE_FILTER_FE_NIC_EGRESS_B \ - | HCLGE_FILTER_FE_ROCE_EGRESS_B) -#define HCLGE_FILTER_FE_INGRESS (HCLGE_FILTER_FE_NIC_INGRESS_B \ - | HCLGE_FILTER_FE_ROCE_INGRESS_B) - static int hclge_set_vlan_filter_ctrl(struct hclge_dev *hdev, u8 vlan_type, u8 fe_type, bool filter_en, u8 vf_id) { @@ -8319,35 +8302,16 @@ static int hclge_set_vlan_filter_ctrl(struct hclge_dev *hdev, u8 vlan_type, struct hclge_desc desc; int ret;
- /* if vlan_mode set as dynamic mode, - * port vlan filter needn't to enable - */ - if (vlan_type == HCLGE_FILTER_TYPE_PORT && - hdev->vlan_mode == HCLGE_VLAN_DYNAMIC_MODE) - return 0; - - /* read current vlan filter parameter */ - hclge_cmd_setup_basic_desc(&desc, HCLGE_OPC_VLAN_FILTER_CTRL, true); + hclge_cmd_setup_basic_desc(&desc, HCLGE_OPC_VLAN_FILTER_CTRL, false); req = (struct hclge_vlan_filter_ctrl_cmd *)desc.data; req->vlan_type = vlan_type; + req->vlan_fe = filter_en ? fe_type : 0; req->vf_id = vf_id;
- ret = hclge_cmd_send(&hdev->hw, &desc, 1); - if (ret) { - dev_err(&hdev->pdev->dev, "failed to get vport%u vlan filter config, ret = %d.\n", - vf_id, ret); - return ret; - } - - /* modify and write new config parameter */ - hclge_cmd_reuse_desc(&desc, false); - req->vlan_fe = filter_en ? - (req->vlan_fe | fe_type) : (req->vlan_fe & ~fe_type); - ret = hclge_cmd_send(&hdev->hw, &desc, 1); if (ret) - dev_err(&hdev->pdev->dev, "failed to set vport%u vlan filter, ret = %d.\n", - vf_id, ret); + dev_err(&hdev->pdev->dev, + "set vlan filter fail, ret =%d.\n", ret);
return ret; } @@ -8493,41 +8457,6 @@ static int hclge_set_port_vlan_filter(struct hclge_dev *hdev, __be16 proto, return ret; }
-static bool hclge_need_update_port_vlan(struct hclge_dev *hdev, u16 vport_id, - u16 vlan_id, bool is_kill) -{ - /* vlan 0 may be added twice when 8021q module is enabled */ - if (!is_kill && !vlan_id && - test_bit(vport_id, hdev->vlan_table[vlan_id])) - return false; - - if (!is_kill && test_and_set_bit(vport_id, hdev->vlan_table[vlan_id])) { - dev_warn(&hdev->pdev->dev, - "Add port vlan failed, vport %u is already in vlan %u\n", - vport_id, vlan_id); - return false; - } - - /* if the vlan id is not in the port vlan table, just return 0, it's - * unnecessary to retry. - */ - if (is_kill && - !test_and_clear_bit(vport_id, hdev->vlan_table[vlan_id])) { - dev_warn(&hdev->pdev->dev, - "Delete port vlan failed, vport %u is not in vlan %u\n", - vport_id, vlan_id); - return false; - } - - /* if vlan mode set as HCLGE_VLAN_DYNAMIC_MODE, - * needn't to write the vlan tag to port vlan fitler - */ - if (hdev->vlan_mode == HCLGE_VLAN_DYNAMIC_MODE) - return false; - - return true; -} - static int hclge_set_vlan_filter_hw(struct hclge_dev *hdev, __be16 proto, u16 vport_id, u16 vlan_id, bool is_kill) @@ -8550,9 +8479,26 @@ static int hclge_set_vlan_filter_hw(struct hclge_dev *hdev, __be16 proto, return ret; }
- if (!hclge_need_update_port_vlan(hdev, vport_id, vlan_id, is_kill)) + /* vlan 0 may be added twice when 8021q module is enabled */ + if (!is_kill && !vlan_id && + test_bit(vport_id, hdev->vlan_table[vlan_id])) return 0;
+ if (!is_kill && test_and_set_bit(vport_id, hdev->vlan_table[vlan_id])) { + dev_err(&hdev->pdev->dev, + "Add port vlan failed, vport %u is already in vlan %u\n", + vport_id, vlan_id); + return -EINVAL; + } + + if (is_kill && + !test_and_clear_bit(vport_id, hdev->vlan_table[vlan_id])) { + dev_err(&hdev->pdev->dev, + "Delete port vlan failed, vlan %u is not in vport %u\n", + vlan_id, vport_id); + return -EINVAL; + } + for_each_set_bit(vport_idx, hdev->vlan_table[vlan_id], HCLGE_VPORT_NUM) vport_num++;
@@ -8644,7 +8590,7 @@ static int hclge_set_vlan_rx_offload_cfg(struct hclge_vport *vport)
static int hclge_vlan_offload_cfg(struct hclge_vport *vport, u16 port_base_vlan_state, - u16 vlan_tag, u8 qos) + u16 vlan_tag) { int ret;
@@ -8655,8 +8601,7 @@ static int hclge_vlan_offload_cfg(struct hclge_vport *vport, } else { vport->txvlan_cfg.accept_tag1 = false; vport->txvlan_cfg.insert_tag1_en = true; - vport->txvlan_cfg.default_tag1 = (qos << VLAN_PRIO_SHIFT) | - vlan_tag; + vport->txvlan_cfg.default_tag1 = vlan_tag; }
vport->txvlan_cfg.accept_untag1 = true; @@ -8743,12 +8688,6 @@ static int hclge_init_vlan_config(struct hclge_dev *hdev) /* for revision 0x21, vf vlan filter is per function */ for (i = 0; i < hdev->num_alloc_vport; i++) { vport = &hdev->vport[i]; - vport->vf_vlan_en = - hdev->vlan_mode == HCLGE_VLAN_DEFAULT_MODE; - - if (!vport->vf_vlan_en) - continue; - ret = hclge_set_vlan_filter_ctrl(hdev, HCLGE_FILTER_TYPE_VF, HCLGE_FILTER_FE_EGRESS, @@ -8786,15 +8725,13 @@ static int hclge_init_vlan_config(struct hclge_dev *hdev)
for (i = 0; i < hdev->num_alloc_vport; i++) { u16 vlan_tag; - u8 qos;
vport = &hdev->vport[i]; vlan_tag = vport->port_base_vlan_cfg.vlan_info.vlan_tag; - qos = vport->port_base_vlan_cfg.vlan_info.qos;
ret = hclge_vlan_offload_cfg(vport, vport->port_base_vlan_cfg.state, - vlan_tag, qos); + vlan_tag); if (ret) return ret; } @@ -8982,7 +8919,6 @@ void hclge_restore_vport_vlan_table(struct hclge_vport *vport) vlan->hd_tbl_status = true; } } - hclge_vf_vlan_filter_switch(vport);
mutex_unlock(&hdev->vport_lock); } @@ -9048,56 +8984,6 @@ int hclge_en_hw_strip_rxvtag(struct hnae3_handle *handle, bool enable) return hclge_set_vlan_rx_offload_cfg(vport); }
-bool hclge_vf_vlan_need_enable(struct hclge_vport *vport) -{ -#define VLAN_CHECK_START_NUM 1 - - struct hclge_dev *hdev = vport->back; - u16 vlan_id; - - if (hdev->vlan_mode == HCLGE_VLAN_DEFAULT_MODE || - vport->port_base_vlan_cfg.state != HNAE3_PORT_BASE_VLAN_DISABLE) - return true; - - /* check all vlan tag in vf vlan table except vlan 0 */ - for (vlan_id = VLAN_CHECK_START_NUM; vlan_id < VLAN_N_VID; vlan_id++) - if (test_bit(vport->vport_id, hdev->vlan_table[vlan_id])) - return true; - - return false; -} - -static int hclge_vf_vlan_filter_switch(struct hclge_vport *vport) -{ - struct hnae3_handle *nic = &vport->nic; - struct hclge_dev *hdev = vport->back; - bool filter_en; - int ret; - - filter_en = hclge_vf_vlan_need_enable(vport); - - if (filter_en == vport->vf_vlan_en) - return 0; - - ret = hclge_set_vlan_filter_ctrl(hdev, HCLGE_FILTER_TYPE_VF, - HCLGE_FILTER_FE_EGRESS, - filter_en, vport->vport_id); - if (ret) { - dev_err(&hdev->pdev->dev, - "failed to %s vport%u vf vlan filter, ret = %d.\n", - filter_en ? "enable" : "disable", vport->vport_id, ret); - return ret; - } - - vport->vf_vlan_en = filter_en; - if (filter_en) - nic->netdev_flags |= HNAE3_VF_VLAN_EN; - else - nic->netdev_flags &= ~HNAE3_VF_VLAN_EN; - - return 0; -} - static int hclge_update_vlan_filter_entries(struct hclge_vport *vport, u16 port_base_vlan_state, struct hclge_vlan_info *new_info, @@ -9108,11 +8994,6 @@ static int hclge_update_vlan_filter_entries(struct hclge_vport *vport,
if (port_base_vlan_state == HNAE3_PORT_BASE_VLAN_ENABLE) { hclge_rm_vport_all_vlan_table(vport, false); - /* force clear vlan 0 */ - ret = hclge_set_vf_vlan_common(hdev, vport->vport_id, true, 0, - htons(ETH_P_8021Q)); - if (ret) - return ret; return hclge_set_vlan_filter_hw(hdev, htons(new_info->vlan_proto), vport->vport_id, @@ -9147,15 +9028,10 @@ int hclge_update_port_base_vlan_cfg(struct hclge_vport *vport, u16 state,
old_vlan_info = &vport->port_base_vlan_cfg.vlan_info;
- ret = hclge_vlan_offload_cfg(vport, state, vlan_info->vlan_tag, - vlan_info->qos); + ret = hclge_vlan_offload_cfg(vport, state, vlan_info->vlan_tag); if (ret) return ret;
- /* if needn't to update vlan tag, return */ - if (old_vlan_info->vlan_tag == vlan_info->vlan_tag) - goto update; - if (state == HNAE3_PORT_BASE_VLAN_MODIFY) { /* add new VLAN tag */ ret = hclge_set_vlan_filter_hw(hdev, @@ -9167,22 +9043,13 @@ int hclge_update_port_base_vlan_cfg(struct hclge_vport *vport, u16 state, return ret; vport->port_base_vlan_cfg.tbl_sta = false; /* remove old VLAN tag */ - if (old_vlan_info->vlan_tag == 0) - ret = hclge_set_vf_vlan_common(hdev, vport->vport_id, - true, 0, - htons(ETH_P_8021Q)); - 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); + 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; } @@ -9210,27 +9077,25 @@ int hclge_update_port_base_vlan_cfg(struct hclge_vport *vport, u16 state, vport->port_base_vlan_cfg.vlan_info.vlan_proto = vlan_info->vlan_proto; vport->port_base_vlan_cfg.tbl_sta = true;
- return hclge_vf_vlan_filter_switch(vport); + return 0; }
static u16 hclge_get_port_base_vlan_state(struct hclge_vport *vport, enum hnae3_port_base_vlan_state state, - u16 vlan, u8 qos) + u16 vlan) { if (state == HNAE3_PORT_BASE_VLAN_DISABLE) { - if (!vlan && !qos) + if (!vlan) return HNAE3_PORT_BASE_VLAN_NOCHANGE; - - return HNAE3_PORT_BASE_VLAN_ENABLE; + else + return HNAE3_PORT_BASE_VLAN_ENABLE; } else { - if (!vlan && !qos) + if (!vlan) return HNAE3_PORT_BASE_VLAN_DISABLE; - - if (vport->port_base_vlan_cfg.vlan_info.vlan_tag == vlan && - vport->port_base_vlan_cfg.vlan_info.qos == qos) + else if (vport->port_base_vlan_cfg.vlan_info.vlan_tag == vlan) return HNAE3_PORT_BASE_VLAN_NOCHANGE; - - return HNAE3_PORT_BASE_VLAN_MODIFY; + else + return HNAE3_PORT_BASE_VLAN_MODIFY; } }
@@ -9258,7 +9123,7 @@ static int hclge_set_vf_vlan_filter(struct hnae3_handle *handle, int vfid,
state = hclge_get_port_base_vlan_state(vport, vport->port_base_vlan_cfg.state, - vlan, qos); + vlan); if (state == HNAE3_PORT_BASE_VLAN_NOCHANGE) return 0;
@@ -9266,45 +9131,14 @@ static int hclge_set_vf_vlan_filter(struct hnae3_handle *handle, int vfid, vlan_info.qos = qos; vlan_info.vlan_proto = ntohs(proto);
- ret = hclge_update_port_base_vlan_cfg(vport, state, &vlan_info); - if (ret) { - dev_err(&hdev->pdev->dev, - "update port base vlan for vf %d failed, ret = %d\n", - vfid, ret); - return ret; - } - - /* there is a timewindow for PF to know VF unalive, it may - * cause send mailbox fail, but it doesn't matter, VF will - * query it when reinit. - */ - if (test_bit(HCLGE_VPORT_STATE_ALIVE, &vport->state)) - (void)hclge_push_vf_port_base_vlan_info(&hdev->vport[0], + if (!test_bit(HCLGE_VPORT_STATE_ALIVE, &vport->state)) { + return hclge_update_port_base_vlan_cfg(vport, state, + &vlan_info); + } else { + ret = hclge_push_vf_port_base_vlan_info(&hdev->vport[0], vport->vport_id, state, &vlan_info); - - return 0; -} - -static void hclge_clear_vf_vlan(struct hclge_dev *hdev) -{ - struct hclge_vlan_info *vlan_info; - struct hclge_vport *vport; - int ret; - int vf; - - /* clear port base vlan for all vf */ - for (vf = HCLGE_VF_VPORT_START_NUM; vf < hdev->num_alloc_vport; vf++) { - vport = &hdev->vport[vf]; - vlan_info = &vport->port_base_vlan_cfg.vlan_info; - - ret = hclge_set_vlan_filter_hw(hdev, htons(ETH_P_8021Q), - vport->vport_id, - vlan_info->vlan_tag, true); - if (ret) - dev_err(&hdev->pdev->dev, - "failed to clear vf vlan for vf%d, ret = %d\n", - vf - HCLGE_VF_VPORT_START_NUM, ret); + return ret; } }
@@ -9351,14 +9185,7 @@ int hclge_set_vlan_filter(struct hnae3_handle *handle, __be16 proto, */ set_bit(vlan_id, vport->vlan_del_fail_bmap); } - - if (ret) { - dev_info(&hdev->pdev->dev, "failed to set vf vlan, ret = %d!\n", - ret); - return ret; - } - - return hclge_vf_vlan_filter_switch(vport); + return ret; }
static void hclge_sync_vlan_filter(struct hclge_dev *hdev) @@ -10815,7 +10642,6 @@ static void hclge_uninit_ae_dev(struct hnae3_ae_dev *ae_dev) struct hclge_mac *mac = &hdev->hw.mac;
hclge_reset_vf_rate(hdev); - hclge_clear_vf_vlan(hdev); hclge_misc_affinity_teardown(hdev); hclge_state_uninit(hdev); hclge_uninit_vport_mac_table(hdev); @@ -11463,7 +11289,6 @@ static void hclge_sync_promisc_mode(struct hclge_dev *hdev) struct hclge_vport *vport = &hdev->vport[0]; struct hnae3_handle *handle = &vport->nic; u8 tmp_flags = 0; - bool vlan_en; int ret; int i;
@@ -11478,12 +11303,8 @@ static void hclge_sync_promisc_mode(struct hclge_dev *hdev) tmp_flags & HNAE3_MPE); if (!ret) { clear_bit(HCLGE_STATE_PROMISC_CHANGED, &hdev->state); - - vlan_en = (tmp_flags & HNAE3_USER_UPE) ? - false : hclge_vf_vlan_need_enable(vport); - - vport->vf_vlan_en = vlan_en; - hclge_enable_vlan_filter(handle, vlan_en); + hclge_enable_vlan_filter(handle, + tmp_flags & HNAE3_VLAN_FLTR); } }
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h index 9719c1c39db6..01e596c216db 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h @@ -320,10 +320,17 @@ enum hclge_fc_mode { HCLGE_FC_DEFAULT };
-enum hclge_vlan_mode_sel { - HCLGE_VLAN_DEFAULT_MODE, - HCLGE_VLAN_DYNAMIC_MODE, -}; +#define HCLGE_FILTER_TYPE_VF 0 +#define HCLGE_FILTER_TYPE_PORT 1 +#define HCLGE_FILTER_FE_EGRESS_V1_B BIT(0) +#define HCLGE_FILTER_FE_NIC_INGRESS_B BIT(0) +#define HCLGE_FILTER_FE_NIC_EGRESS_B BIT(1) +#define HCLGE_FILTER_FE_ROCE_INGRESS_B BIT(2) +#define HCLGE_FILTER_FE_ROCE_EGRESS_B BIT(3) +#define HCLGE_FILTER_FE_EGRESS (HCLGE_FILTER_FE_NIC_EGRESS_B \ + | HCLGE_FILTER_FE_ROCE_EGRESS_B) +#define HCLGE_FILTER_FE_INGRESS (HCLGE_FILTER_FE_NIC_INGRESS_B \ + | HCLGE_FILTER_FE_ROCE_INGRESS_B)
enum hclge_link_fail_code { HCLGE_LF_NORMAL, @@ -365,7 +372,6 @@ struct hclge_cfg { u8 default_speed; u32 numa_node_map; u8 speed_ability; - u8 vlan_mode_sel; u16 umv_space; };
@@ -857,7 +863,6 @@ struct hclge_dev { enum HCLGE_FD_ACTIVE_RULE_TYPE fd_active_type; u8 fd_en;
- u8 vlan_mode;
u16 wanted_umv_size; /* max available unicast mac vlan space */ @@ -955,7 +960,6 @@ struct hclge_vport { u32 bw_limit; /* VSI BW Limit (0 = disabled) */ u8 dwrr;
- bool vf_vlan_en; unsigned long vlan_del_fail_bmap[BITS_TO_LONGS(VLAN_N_VID)]; struct hclge_port_base_vlan_config port_base_vlan_cfg; struct hclge_tx_vtag_cfg txvlan_cfg; @@ -1064,6 +1068,5 @@ int hclge_query_bd_num_cmd_send(struct hclge_dev *hdev, void hclge_report_hw_error(struct hclge_dev *hdev, enum hnae3_hw_error_type type); int hclge_dbg_dump_rst_info(struct hclge_dev *hdev, char *buf, int len); -bool hclge_vf_vlan_need_enable(struct hclge_vport *vport); int hclge_push_vf_link_status(struct hclge_vport *vport); #endif diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c index c00fa95834bc..9ea6eb6de4db 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c @@ -3074,11 +3074,6 @@ static int hclgevf_reset_hdev(struct hclgevf_dev *hdev) return ret; }
- /* get current port based vlan state from PF */ - ret = hclgevf_get_port_base_vlan_filter_state(hdev); - if (ret) - return ret; - set_bit(HCLGEVF_STATE_PROMISC_CHANGED, &hdev->state);
dev_info(&hdev->pdev->dev, "Reset done\n");