diff options
| author | Serge Semin <fancer.lancer@gmail.com> | 2025-03-27 14:40:42 +0300 |
|---|---|---|
| committer | Serge Semin <fancer.lancer@gmail.com> | 2026-08-13 20:34:38 +0300 |
| commit | 58cf7d6e3073700c2c34186a2fec3afcac332411 (patch) | |
| tree | e90855df167adeeae5e02b822dc80b2a456b6215 | |
| parent | 95abad53e336074aed686ad64f37281ae1114e61 (diff) | |
| download | linux-58cf7d6e3073700c2c34186a2fec3afcac332411.tar.gz linux-58cf7d6e3073700c2c34186a2fec3afcac332411.zip | |
net: stmmac: vlan: Convert to being agnostic from hw::num_vlan
Indeed there has been no need in adding the
stmmac_vlan_ops::add_hw_vlan_rx_fltr() and
stmmac_vlan_ops::del_hw_vlan_rx_fltr()
execution dependent from the mac_device_info::num_vlan field value. If the
VLAN perfect filters feature is supported by the driver (DW QoS Ether and
DW XGMAC) then mac_device_info::num_vlan will be always initialized at
least with one. That's because the modern IP-cores (DW QoS Ether and DW
XGMAC) always support at least a Basic VLAN perfect filter engine. If the
driver doesn't support the VLAN perfect filters functionality for the
particular IP-core then the denoted callbacks just won't be available and
their execution attempt will cause the -EINVAL error returned. Thus let's
just correctly parse the return value of the methods call and drop the
mac_device_info::num_vlan conditional statement.
This change is a short preparation before adding a comprehensive
VLAN-engine support to the driver.
Signed-off-by: Serge Semin <fancer.lancer@gmail.com>
---
Note if the dma_features::nrvf_num was accessible in the VLAN-related
callbacks the mac_device_info::num_vlan field could have been completely
dropped as redundant. Do that when it is.
| -rw-r--r-- | drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 24 | ||||
| -rw-r--r-- | drivers/net/ethernet/stmicro/stmmac/stmmac_vlan.c | 4 |
2 files changed, 12 insertions, 16 deletions
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c index f120c64a8bf3..ae2dea6b3d3c 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c @@ -7159,13 +7159,11 @@ static int stmmac_vlan_rx_add_vid(struct net_device *ndev, __be16 proto, u16 vid goto err_pm_put; } - if (priv->hw->num_vlan) { - ret = stmmac_add_hw_vlan_rx_fltr(priv, ndev, priv->hw, proto, vid); - if (ret) { - clear_bit(vid, priv->active_vlans); - stmmac_vlan_update(priv, priv->num_svlans); - goto err_pm_put; - } + ret = stmmac_add_hw_vlan_rx_fltr(priv, ndev, priv->hw, proto, vid); + if (ret && ret != -EINVAL) { + clear_bit(vid, priv->active_vlans); + stmmac_vlan_update(priv, priv->num_svlans); + goto err_pm_put; } priv->num_svlans = num_svlans; @@ -7201,13 +7199,11 @@ static int stmmac_vlan_rx_kill_vid(struct net_device *ndev, __be16 proto, u16 vi goto del_vlan_error; } - if (priv->hw->num_vlan) { - ret = stmmac_del_hw_vlan_rx_fltr(priv, ndev, priv->hw, proto, vid); - if (ret) { - set_bit(vid, priv->active_vlans); - stmmac_vlan_update(priv, priv->num_svlans); - goto del_vlan_error; - } + ret = stmmac_del_hw_vlan_rx_fltr(priv, ndev, priv->hw, proto, vid); + if (ret && ret != -EINVAL) { + set_bit(vid, priv->active_vlans); + stmmac_vlan_update(priv, priv->num_svlans); + goto del_vlan_error; } priv->num_svlans = num_svlans; diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_vlan.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_vlan.c index c7cc2ee22366..77fe0ea31c33 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_vlan.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_vlan.c @@ -31,7 +31,7 @@ static int vlan_write_filter(struct net_device *dev, u32 val; if (index >= hw->num_vlan) - return -EINVAL; + return -ENOSPC; /* Indirect VLAN Tag filter access inteface requires PHY RXC clock to * be running. Retry when the interface is up. @@ -72,7 +72,7 @@ static int vlan_add_hw_rx_fltr(struct net_device *dev, int i, ret; if (vid > 4095) - return -EINVAL; + return -ENXIO; is_stag = proto == htons(ETH_P_8021AD); |
