net: stmmac: Fix VLAN filtering when HW does not support it
authorJose Abreu <Jose.Abreu@synopsys.com>
Wed, 1 Apr 2020 17:29:03 +0000 (19:29 +0200)
committerDavid S. Miller <davem@davemloft.net>
Wed, 1 Apr 2020 18:25:03 +0000 (11:25 -0700)
If we don't have any filters available we can't rely upon the return
code of stmmac_add_hw_vlan_rx_fltr() / stmmac_del_hw_vlan_rx_fltr(). Add
a check for this.

Fixes: ed64639bc1e0 ("net: stmmac: Add support for VLAN Rx filtering")
Signed-off-by: Jose Abreu <Jose.Abreu@synopsys.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c

index 2fb671e61ee8cb84f8a7a557b094a6974c508adf..e6898fd5223f2987fe9611360c33ee63e6686497 100644 (file)
@@ -4566,9 +4566,13 @@ static int stmmac_vlan_rx_add_vid(struct net_device *ndev, __be16 proto, u16 vid
                return ret;
        }
 
-       ret = stmmac_add_hw_vlan_rx_fltr(priv, ndev, priv->hw, proto, vid);
+       if (priv->hw->num_vlan) {
+               ret = stmmac_add_hw_vlan_rx_fltr(priv, ndev, priv->hw, proto, vid);
+               if (ret)
+                       return ret;
+       }
 
-       return ret;
+       return 0;
 }
 
 static int stmmac_vlan_rx_kill_vid(struct net_device *ndev, __be16 proto, u16 vid)
@@ -4581,9 +4585,12 @@ static int stmmac_vlan_rx_kill_vid(struct net_device *ndev, __be16 proto, u16 vi
                is_double = true;
 
        clear_bit(vid, priv->active_vlans);
-       ret = stmmac_del_hw_vlan_rx_fltr(priv, ndev, priv->hw, proto, vid);
-       if (ret)
-               return ret;
+
+       if (priv->hw->num_vlan) {
+               ret = stmmac_del_hw_vlan_rx_fltr(priv, ndev, priv->hw, proto, vid);
+               if (ret)
+                       return ret;
+       }
 
        return stmmac_vlan_update(priv, is_double);
 }