Re: [PATCH net v2 2/6] net: stmmac: Enable double VLAN processing only when supported
From: Maxime Chevallier
Date: Sun Aug 23 2026 - 03:50:13 EST
Hi,
On 8/21/26 19:09, Ovidiu Panait wrote:
> stmmac_vlan_update() turns on double/S-VLAN processing whenever an
> 802.1ad VLAN is registered, without checking whether the MAC actually
> supports double VLAN processing. That capability is reported in
> dma_cap.dvlan.
>
> This was found while investigating a separate bug in the double VLAN RX
> stripping path. The outer 802.1ad tags were unexpectedly stripped by the
> MAC (because the ESVL bit was set).
>
> Check dma_cap.dvlan before enabling EDVLP/ESVL/DOVLTC bits, so that double
> VLAN processing is enabled only on supported hardware. Also, advertise
> NETIF_F_HW_VLAN_STAG_RX and NETIF_F_HW_VLAN_STAG_FILTER only when
> dma_cap.dvlan is set.
>
> Fixes: 3cd1cfcba26e ("net: stmmac: Implement VLAN Hash Filtering in XGMAC")
> Signed-off-by: Ovidiu Panait <ovidiu.panait.rb@xxxxxxxxxxx>
Reviewed-by: Maxime Chevallier <maxime.chevallier@xxxxxxxxxxx>
Maxime
> ---
> v2 changes:
> - Advertised NETIF_F_HW_VLAN_STAG_RX and NETIF_F_HW_VLAN_STAG_FILTER only
> when dma_cap.dvlan is set (reported by Sashiko).
>
> drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 11 +++++++++--
> 1 file changed, 9 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> index 16fe56a1f617..880cf3fab913 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> @@ -6820,6 +6820,9 @@ static int stmmac_vlan_update(struct stmmac_priv *priv, bool is_double)
> if (!netif_running(priv->dev))
> return 0;
>
> + if (!priv->dma_cap.dvlan)
> + is_double = false;
> +
> return stmmac_update_vlan_hash(priv, priv->hw, hash, is_double);
> }
>
> @@ -7954,14 +7957,18 @@ static int __stmmac_dvr_probe(struct device *device,
> ndev->watchdog_timeo = msecs_to_jiffies(watchdog);
> #ifdef STMMAC_VLAN_TAG_USED
> /* Both mac100 and gmac support receive VLAN tag detection */
> - ndev->features |= NETIF_F_HW_VLAN_CTAG_RX | NETIF_F_HW_VLAN_STAG_RX;
> + ndev->features |= NETIF_F_HW_VLAN_CTAG_RX;
> + if (priv->dma_cap.dvlan)
> + ndev->features |= NETIF_F_HW_VLAN_STAG_RX;
> +
> if (dwmac_is_xmac(priv->plat->core_type)) {
> ndev->hw_features |= NETIF_F_HW_VLAN_CTAG_RX;
> priv->hw->hw_vlan_en = true;
> }
> if (priv->dma_cap.vlhash) {
> ndev->features |= NETIF_F_HW_VLAN_CTAG_FILTER;
> - ndev->features |= NETIF_F_HW_VLAN_STAG_FILTER;
> + if (priv->dma_cap.dvlan)
> + ndev->features |= NETIF_F_HW_VLAN_STAG_FILTER;
> }
> if (priv->dma_cap.vlins)
> ndev->features |= NETIF_F_HW_VLAN_CTAG_TX;