net: stmmac: selftests: Guard VLAN Perfect test against non supported HW
authorJose Abreu <Jose.Abreu@synopsys.com>
Tue, 14 Jan 2020 16:09:23 +0000 (17:09 +0100)
committerDavid S. Miller <davem@davemloft.net>
Wed, 15 Jan 2020 22:11:18 +0000 (23:11 +0100)
When HW does not support perfect filtering the feature will not be
enabled in the net_device. Add a check for this to prevent failures.

Fixes: 1b2250a04c1f ("net: stmmac: selftests: Add tests for VLAN Perfect 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_selftests.c

index 7edee3c..450d7da 100644 (file)
@@ -971,6 +971,9 @@ static int stmmac_test_vlanfilt_perfect(struct stmmac_priv *priv)
 {
        int ret, prev_cap = priv->dma_cap.vlhash;
 
+       if (!(priv->dev->features & NETIF_F_HW_VLAN_CTAG_FILTER))
+               return -EOPNOTSUPP;
+
        priv->dma_cap.vlhash = 0;
        ret = __stmmac_test_vlanfilt(priv);
        priv->dma_cap.vlhash = prev_cap;
@@ -1063,6 +1066,9 @@ static int stmmac_test_dvlanfilt_perfect(struct stmmac_priv *priv)
 {
        int ret, prev_cap = priv->dma_cap.vlhash;
 
+       if (!(priv->dev->features & NETIF_F_HW_VLAN_STAG_FILTER))
+               return -EOPNOTSUPP;
+
        priv->dma_cap.vlhash = 0;
        ret = __stmmac_test_dvlanfilt(priv);
        priv->dma_cap.vlhash = prev_cap;