From: Yunsheng Lin linyunsheng@huawei.com
mainline inclusion from mainline-v4.17-rc1 commit f96818a7cc864ac612c157b5c5e8c57c4b3e0136 category: bugfix bugzilla: NA CVE: NA
----------------------------
When vlan ctag filter is enabled, the loopback selftest fails because loopback selftest does not support vlan.
This patch fixes it by disabling the vlan ctag filter when runnig loopback selftest.
Signed-off-by: Yunsheng Lin linyunsheng@huawei.com Signed-off-by: Peng Li lipeng321@huawei.com Signed-off-by: David S. Miller davem@davemloft.net Signed-off-by: Yonglong Liu liuyonglong@huawei.com Reviewed-by: Yongxin Li liyongxin1@huawei.com Signed-off-by: Yang Yingliang yangyingliang@huawei.com --- .../net/ethernet/hisilicon/hns3/hns3_ethtool.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+)
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c b/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c index bc92a4eb1e47..d04a61e39b68 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c @@ -320,6 +320,9 @@ static void hns3_self_test(struct net_device *ndev, struct hnae3_handle *h = priv->ae_handle; int st_param[HNS3_SELF_TEST_TYPE_NUM][2]; bool if_running = netif_running(ndev); +#if IS_ENABLED(CONFIG_VLAN_8021Q) + bool dis_vlan_filter; +#endif int test_index = 0; u32 i;
@@ -355,6 +358,14 @@ static void hns3_self_test(struct net_device *ndev, if (if_running) ndev->netdev_ops->ndo_stop(ndev);
+#if IS_ENABLED(CONFIG_VLAN_8021Q) + /* Disable the vlan filter for selftest does not support it */ + dis_vlan_filter = (ndev->features & NETIF_F_HW_VLAN_CTAG_FILTER) && + h->ae_algo->ops->enable_vlan_filter; + if (dis_vlan_filter) + h->ae_algo->ops->enable_vlan_filter(h, false); +#endif + /* Tell firmware to stop mac autoneg before loopback test start, * otherwise loopback test may be failed when the port is still * negotiating. @@ -386,6 +397,13 @@ static void hns3_self_test(struct net_device *ndev,
if (h->ae_algo->ops->halt_autoneg) h->ae_algo->ops->halt_autoneg(h, false); + +#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); +#endif + if (if_running) ndev->netdev_ops->ndo_open(ndev);