Skip to contentSkip to conversation

net: stmmac: xgmac: Report the VLAN tag type from the descriptor

PATCH Applied Maxime Chevallier 6 participants 9 messages Nov 18 – Nov 21

Subsystems (4)
lore
Share & tools
lore

Maxime Chevallier

author maintainer
#0 lore raw

PATCH 1/1 net: stmmac: xgmac: Report the VLAN tag type from the descriptor

Stmmac's double VLAN handling hasn't been working great for a while, it's been recently reworked for dwmac4 by Ovidiu Panait. In that work, it was found that the tag stripping hardcodes the 8021Q tag type for XGMAC while stripping the tag, while the IP actually reports the outer tag type in the descriptor.

The tag type can be one of 6 different values (note inner/outer is reversed in the macro names):

- XGMAC_ET_LT_VLAN_STAG single S-tag
- XGMAC_ET_LT_VLAN_CTAG single C-tag
- XGMAC_ET_LT_DVLAN_CTAG_CTAG outer C-tag, inner C-tag
- XGMAC_ET_LT_DVLAN_STAG_STAG outer S-tag, inner S-tag
- XGMAC_ET_LT_DVLAN_CTAG_STAG outer S-tag, inner C-tag
- XGMAC_ET_LT_DVLAN_STAG_CTAG outer C-tag, inner S-tag

Report that tag type through a dedicated desc ops and report it to the stack.

We keep the 8021Q fallback when we don't have the ops, as we don't set NETIF_F_HW_VLAN_STAG_FILTER on the cores that don't support that.

This has been tested on AgileX5 with the vlan.py selftest.

---
 .../net/ethernet/stmicro/stmmac/dwxgmac2_descs.c    | 13 +++++++++++++
 drivers/net/ethernet/stmicro/stmmac/hwif.h          |  2 ++
 drivers/net/ethernet/stmicro/stmmac/stmmac_vlan.c   |  6 +++++-
 3 files changed, 20 insertions(+), 1 deletion(-)
drivers/net/ethernet/stmicro/stmmac/dwxgmac2_descs.c +13 -0
index 6719ac6e395b..71ce2bc9b5e1 100644
@@ -76,6 +76,18 @@ static bool dwxgmac2_wrback_get_rx_vlan_valid(struct dma_desc *p)
 	       et_lt <= XGMAC_ET_LT_DVLAN_STAG_CTAG;
 }
 
+static u16 dwxgmac2_wrback_get_rx_vlan_proto(struct dma_desc *p)
+{
+	switch (FIELD_GET(XGMAC_RDES3_ET_LT, le32_to_cpu(p->des3))) {
+	case XGMAC_ET_LT_VLAN_STAG:
+	case XGMAC_ET_LT_DVLAN_STAG_STAG:
+	case XGMAC_ET_LT_DVLAN_CTAG_STAG:
+		return ETH_P_8021AD;
+	default:
+		return ETH_P_8021Q;
+	}
+}
+
 static int dwxgmac2_get_rx_frame_len(struct dma_desc *p, int rx_coe)
 {
 	return (le32_to_cpu(p->des3) & XGMAC_RDES3_PL);
@@ -352,6 +364,7 @@ const struct stmmac_desc_ops dwxgmac210_desc_ops = {
 	.set_rx_owner = dwxgmac2_set_rx_owner,
 	.get_rx_vlan_tci = dwxgmac2_wrback_get_rx_vlan_tci,
 	.get_rx_vlan_valid = dwxgmac2_wrback_get_rx_vlan_valid,
+	.get_rx_vlan_proto = dwxgmac2_wrback_get_rx_vlan_proto,
 	.get_rx_frame_len = dwxgmac2_get_rx_frame_len,
 	.enable_tx_timestamp = dwxgmac2_enable_tx_timestamp,
 	.get_tx_timestamp_status = dwxgmac2_get_tx_timestamp_status,
drivers/net/ethernet/stmicro/stmmac/hwif.h +2 -0
index 8ae95e91a36a..047bda5cbd92 100644
@@ -60,6 +60,8 @@ struct stmmac_desc_ops {
 	u16 (*get_rx_vlan_tci)(struct dma_desc *p);
 	/* Get the valid status of descriptor */
 	bool (*get_rx_vlan_valid)(struct dma_desc *p);
+	/* Get the vlan tag proto from the descriptor */
+	u16 (*get_rx_vlan_proto)(struct dma_desc *p);
 	/* Return the transmit status looking at the TDES1 */
 	int (*tx_status)(struct stmmac_extra_stats *x,
 			 struct dma_desc *p, void __iomem *ioaddr);
drivers/net/ethernet/stmicro/stmmac/stmmac_vlan.c +5 -1
index fb9aad748cb3..bf23d82e9f38 100644
@@ -209,8 +209,12 @@ static void vlan_rx_hw(struct mac_device_info *hw,
 {
 	if (hw->desc->get_rx_vlan_valid(rx_desc)) {
 		u16 vid = hw->desc->get_rx_vlan_tci(rx_desc);
+		u16 proto = ETH_P_8021Q;
 
-		__vlan_hwaccel_put_tag(skb, htons(ETH_P_8021Q), vid);
+		if (hw->desc->get_rx_vlan_proto)
+			proto = hw->desc->get_rx_vlan_proto(rx_desc);
+
+		__vlan_hwaccel_put_tag(skb, htons(proto), vid);
 	}
 }
 
Signature · 1 line
2.56.1
Reviewed-by on v1 1/1
#1 lore raw

Hi Maxime

Quoted 19 lines · Maxime Chevallier

Stmmac's double VLAN handling hasn't been working great for a while, it's been recently reworked for dwmac4 by Ovidiu Panait. In that work, it was found that the tag stripping hardcodes the 8021Q tag type for XGMAC while stripping the tag, while the IP actually reports the outer tag type in the descriptor.

The tag type can be one of 6 different values (note inner/outer is reversed in the macro names):

- XGMAC_ET_LT_VLAN_STAG single S-tag
- XGMAC_ET_LT_VLAN_CTAG single C-tag
- XGMAC_ET_LT_DVLAN_CTAG_CTAG outer C-tag, inner C-tag
- XGMAC_ET_LT_DVLAN_STAG_STAG outer S-tag, inner S-tag
- XGMAC_ET_LT_DVLAN_CTAG_STAG outer S-tag, inner C-tag
- XGMAC_ET_LT_DVLAN_STAG_CTAG outer C-tag, inner S-tag

Report that tag type through a dedicated desc ops and report it to the stack.

Quoted 6 lines

We keep the 8021Q fallback when we don't have the ops, as we don't set NETIF_F_HW_VLAN_STAG_FILTER on the cores that don't support that.

This has been tested on AgileX5 with the vlan.py selftest.

Isn't this a fix too? I mean xgmac advertises STAG_RX but still reports S-tags as 802.1Q. Then again nobody seems to have hit it so far, so net-next is probably fine.

Anyway:

Thanks,
Nicolai

author maintainer
#2 lore raw

HI,

Quoted 25 lines · Nicolai Buchwitz

Hi Maxime

Quoted 22 lines · Maxime Chevallier

Stmmac's double VLAN handling hasn't been working great for a while, it's been recently reworked for dwmac4 by Ovidiu Panait. In that work, it was found that the tag stripping hardcodes the 8021Q tag type for XGMAC while stripping the tag, while the IP actually reports the outer tag type in the descriptor.

The tag type can be one of 6 different values (note inner/outer is reversed in the macro names):

 - XGMAC_ET_LT_VLAN_STAG       single S-tag
 - XGMAC_ET_LT_VLAN_CTAG       single C-tag
 - XGMAC_ET_LT_DVLAN_CTAG_CTAG outer C-tag, inner C-tag
 - XGMAC_ET_LT_DVLAN_STAG_STAG outer S-tag, inner S-tag
 - XGMAC_ET_LT_DVLAN_CTAG_STAG outer S-tag, inner C-tag
 - XGMAC_ET_LT_DVLAN_STAG_CTAG outer C-tag, inner S-tag

Report that tag type through a dedicated desc ops and report it to the stack.

We keep the 8021Q fallback when we don't have the ops, as we don't set NETIF_F_HW_VLAN_STAG_FILTER on the cores that don't support that.

Quoted 7 lines
Quoted 3 lines

This has been tested on AgileX5 with the vlan.py selftest.

Isn't this a fix too? I mean xgmac advertises STAG_RX but still reports S-tags as 802.1Q. Then again nobody seems to have hit it so far, so net-next is probably fine.

Yeah not only was this discovered while working on something else, it seems no-one noticed and it's always been broken... I wanted to avoid spamming net too much, both options are fine for me TBH,

Thanks for the review :)

Maxime

Quoted 7 lines

Anyway:

Thanks,
Nicolai

#3 lore raw
In reply to Nicolai Buchwitz
Quoted 36 lines · Nicolai Buchwitz

[You don't often get email from [email protected]. Learn why this is important at https://aka.ms/LearnAboutSenderIdentification ]

Hi Maxime

Quoted 19 lines · Maxime Chevallier

Stmmac's double VLAN handling hasn't been working great for a while, it's been recently reworked for dwmac4 by Ovidiu Panait. In that work, it was found that the tag stripping hardcodes the 8021Q tag type for XGMAC while stripping the tag, while the IP actually reports the outer tag type in the descriptor.

The tag type can be one of 6 different values (note inner/outer is reversed in the macro names):

 - XGMAC_ET_LT_VLAN_STAG       single S-tag
 - XGMAC_ET_LT_VLAN_CTAG       single C-tag
 - XGMAC_ET_LT_DVLAN_CTAG_CTAG outer C-tag, inner C-tag
 - XGMAC_ET_LT_DVLAN_STAG_STAG outer S-tag, inner S-tag
 - XGMAC_ET_LT_DVLAN_CTAG_STAG outer S-tag, inner C-tag
 - XGMAC_ET_LT_DVLAN_STAG_CTAG outer C-tag, inner S-tag

Report that tag type through a dedicated desc ops and report it to the stack.

Quoted 6 lines

We keep the 8021Q fallback when we don't have the ops, as we don't set NETIF_F_HW_VLAN_STAG_FILTER on the cores that don't support that.

This has been tested on AgileX5 with the vlan.py selftest.

Isn't this a fix too? I mean xgmac advertises STAG_RX but still reports S-tags as 802.1Q. Then again nobody seems to have hit it so far, so net-next is probably fine.

Quoted 6 lines

Anyway:

Thanks,
Nicolai

Tested and working fine on my end with Agilex5

#4 lore raw
In reply to Maxime Chevallier
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider.

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider.

Critical: 0 · High: 0 · Medium: 1 · Low: 1

If you believe none of the issues are legitimate, please reply to each issue of Medium severity or higher and explain why the AI is wrong. If any of them are legitimate and you plan to respin, please let patchwork know by including "pw-bot: cr" as a separate line at the end of your reply (one such reply per series is enough).

- [Medium] This patch is a bug fix but carries no Fixes: tag, and the subject reads like a new feature ("Report the VLAN tag type from the…
- [Low] The ET/LT macro names in dwxgmac2.h disagree with how the new dwxgmac2_wrback_get_rx_vlan_proto() reads them.

--

net: stmmac: xgmac: Report the VLAN tag type from the descriptor

This adds a get_rx_vlan_proto() desc op for XGMAC. The op decodes the RDES3 ET_LT field and reports either ETH_P_8021AD or ETH_P_8021Q as the stripped outer tag type. vlan_rx_hw() now uses that op when it exists and keeps ETH_P_8021Q as the fallback.

Quoted 9 lines
drivers/net/ethernet/stmicro/stmmac/dwxgmac2_descs.c +1 -0
index 6719ac6e395bc..71ce2bc9b5e11 100644
@@ -76,6 +76,18 @@ static bool dwxgmac2_wrback_get_rx_vlan_valid(struct dma_desc *p)
 	       et_lt <= XGMAC_ET_LT_DVLAN_STAG_CTAG;
 }
 
+static u16 dwxgmac2_wrback_get_rx_vlan_proto(struct dma_desc *p)

drivers/net/ethernet/stmicro/stmmac/dwxgmac2_descs.c static bool dwxgmac2_wrback_get_rx_vlan_valid(struct dma_desc *p) · line 89

Quoted 10 lines
drivers/net/ethernet/stmicro/stmmac/dwxgmac2_descs.c +10 -0
+{
+	switch (FIELD_GET(XGMAC_RDES3_ET_LT, le32_to_cpu(p->des3))) {
+	case XGMAC_ET_LT_VLAN_STAG:
+	case XGMAC_ET_LT_DVLAN_STAG_STAG:
+	case XGMAC_ET_LT_DVLAN_CTAG_STAG:
+		return ETH_P_8021AD;
+	default:
+		return ETH_P_8021Q;
+	}
+}

[Severity: Low]
This isn't a bug, but the macro names in dwxgmac2.h don't match how they are used here. The only comment on them is:

drivers/net/ethernet/stmicro/stmmac/dwxgmac2.h:
/* Error Type or L2 Type(ET/LT) Field Number */
#define XGMAC_ET_LT_VLAN_STAG 8
#define XGMAC_ET_LT_VLAN_CTAG 9
#define XGMAC_ET_LT_DVLAN_CTAG_CTAG 10
#define XGMAC_ET_LT_DVLAN_STAG_STAG 11
#define XGMAC_ET_LT_DVLAN_CTAG_STAG 12
#define XGMAC_ET_LT_DVLAN_STAG_CTAG 13

Read outer-first, XGMAC_ET_LT_DVLAN_CTAG_STAG means an outer C-tag, yet dwxgmac2_wrback_get_rx_vlan_proto() returns ETH_P_8021AD for it. Likewise XGMAC_ET_LT_DVLAN_STAG_CTAG falls through to ETH_P_8021Q.

The commit message says "note inner/outer is reversed in the macro names", but nothing in the tree records that. Could the macros be renamed (for example XGMAC_ET_LT_DVLAN_OUTER_STAG_INNER_CTAG), or could a comment in dwxgmac2.h give the tag order? Otherwise a future user of these constants could easily invert the mapping.

If the names do follow the databook's outer-first order, the mapping for values 12 and 13 would be inverted. That can't be checked without the databook, so it would help to confirm which reading is correct.

[ ... ]

Quoted 5 lines
drivers/net/ethernet/stmicro/stmmac/stmmac_vlan.c +0 -0
index fb9aad748cb34..bf23d82e9f383 100644

drivers/net/ethernet/stmicro/stmmac/stmmac_vlan.c static void vlan_rx_hw(struct mac_device_info *hw, · line 217

Quoted 10 lines
drivers/net/ethernet/stmicro/stmmac/stmmac_vlan.c +5 -1
@@ -209,8 +209,12 @@ static void vlan_rx_hw(struct mac_device_info *hw,
 {
 	if (hw->desc->get_rx_vlan_valid(rx_desc)) {
 		u16 vid = hw->desc->get_rx_vlan_tci(rx_desc);
+		u16 proto = ETH_P_8021Q;
 
-		__vlan_hwaccel_put_tag(skb, htons(ETH_P_8021Q), vid);
+		if (hw->desc->get_rx_vlan_proto)
+			proto = hw->desc->get_rx_vlan_proto(rx_desc);
+
+		__vlan_hwaccel_put_tag(skb, htons(proto), vid);

[Severity: Medium]
Should this patch carry a Fixes: tag? It looks like it fixes a user-visible regression on XGMAC.

On XGMAC, __stmmac_dvr_probe() advertises NETIF_F_HW_VLAN_STAG_RX and enables MAC-level stripping by default:

drivers/net/ethernet/stmicro/stmmac/stmmac_main.c:__stmmac_dvr_probe() {
    ...
	if (priv->plat->core_type == DWMAC_CORE_XGMAC)
		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;
	}
    ...
}

stmmac_fix_features() also keeps STAG_RX tied to CTAG_RX on XGMAC. Because of this, every frame with a stripped 802.1ad outer tag went through the old vlan_rx_hw() and reached the stack labelled as ETH_P_8021Q. 802.1ad VLAN uppers received no traffic and QinQ between hosts failed.

The sibling commit da17990421d7 ("net: stmmac: Disable S-Tag processing on dwmac4") describes this exact failure and carries a Fixes: tag. Its message says the dwxgmac2 side can be fixed using the RDES3 ET_LT field, which is what this patch does.

Without a Fixes: tag, stable trees that pick up the dwmac4 half would still mislabel S-tags on XGMAC. Would this be a suitable tag?

Fixes 534df0c1724b ("net: stmmac: dwxgmac2: Add support for HW-accelerated VLAN stripping")

That commit started XGMAC hardware stripping with the hardcoded ETH_P_8021Q proto.

The subject also reads like a new feature. The commit message only says double VLAN handling "hasn't been working great for a while". Could it state the actual failure, that S-tagged and QinQ frames are passed up as 802.1Q?

Quoted 2 lines
drivers/net/ethernet/stmicro/stmmac/stmmac_vlan.c +0 -0
 	}
 }
Signature · 1 line
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261118162136.2782405-1-maxime.chevallier%40bootlin.com
author maintainer
#5 lore raw
Quoted 68 lines · On 11/19/26 18:09, [email protected] wrote:

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider.

Critical: 0 · High: 0 · Medium: 1 · Low: 1

If you believe none of the issues are legitimate, please reply to each issue of Medium severity or higher and explain why the AI is wrong. If any of them are legitimate and you plan to respin, please let patchwork know by including "pw-bot: cr" as a separate line at the end of your reply (one such reply per series is enough).

- [Medium] This patch is a bug fix but carries no Fixes: tag, and the subject reads like a new feature ("Report the VLAN tag type from the…
- [Low] The ET/LT macro names in dwxgmac2.h disagree with how the new dwxgmac2_wrback_get_rx_vlan_proto() reads them.

--

net: stmmac: xgmac: Report the VLAN tag type from the descriptor

This adds a get_rx_vlan_proto() desc op for XGMAC. The op decodes the RDES3 ET_LT field and reports either ETH_P_8021AD or ETH_P_8021Q as the stripped outer tag type. vlan_rx_hw() now uses that op when it exists and keeps ETH_P_8021Q as the fallback.

Quoted 9 lines
drivers/net/ethernet/stmicro/stmmac/dwxgmac2_descs.c +1 -0
index 6719ac6e395bc..71ce2bc9b5e11 100644
@@ -76,6 +76,18 @@ static bool dwxgmac2_wrback_get_rx_vlan_valid(struct dma_desc *p)
 	       et_lt <= XGMAC_ET_LT_DVLAN_STAG_CTAG;
 }
 
+static u16 dwxgmac2_wrback_get_rx_vlan_proto(struct dma_desc *p)

drivers/net/ethernet/stmicro/stmmac/dwxgmac2_descs.c static bool dwxgmac2_wrback_get_rx_vlan_valid(struct dma_desc *p) · line 89

Quoted 10 lines
drivers/net/ethernet/stmicro/stmmac/dwxgmac2_descs.c +10 -0
+{
+	switch (FIELD_GET(XGMAC_RDES3_ET_LT, le32_to_cpu(p->des3))) {
+	case XGMAC_ET_LT_VLAN_STAG:
+	case XGMAC_ET_LT_DVLAN_STAG_STAG:
+	case XGMAC_ET_LT_DVLAN_CTAG_STAG:
+		return ETH_P_8021AD;
+	default:
+		return ETH_P_8021Q;
+	}
+}

[Severity: Low]
This isn't a bug, but the macro names in dwxgmac2.h don't match how they are used here. The only comment on them is:

drivers/net/ethernet/stmicro/stmmac/dwxgmac2.h:
/* Error Type or L2 Type(ET/LT) Field Number */
#define XGMAC_ET_LT_VLAN_STAG 8
#define XGMAC_ET_LT_VLAN_CTAG 9
#define XGMAC_ET_LT_DVLAN_CTAG_CTAG 10
#define XGMAC_ET_LT_DVLAN_STAG_STAG 11
#define XGMAC_ET_LT_DVLAN_CTAG_STAG 12
#define XGMAC_ET_LT_DVLAN_STAG_CTAG 13

Read outer-first, XGMAC_ET_LT_DVLAN_CTAG_STAG means an outer C-tag, yet dwxgmac2_wrback_get_rx_vlan_proto() returns ETH_P_8021AD for it. Likewise XGMAC_ET_LT_DVLAN_STAG_CTAG falls through to ETH_P_8021Q.

The commit message says "note inner/outer is reversed in the macro names", but nothing in the tree records that. Could the macros be renamed (for example XGMAC_ET_LT_DVLAN_OUTER_STAG_INNER_CTAG), or could a comment in dwxgmac2.h give the tag order? Otherwise a future user of these constants could easily invert the mapping.

Quoted 3 lines

If the names do follow the databook's outer-first order, the mapping for values 12 and 13 would be inverted. That can't be checked without the databook, so it would help to confirm which reading is correct.

I don't have the databooks. The AgileX5 doc is pretty clear about which value is what though, we could rename the macros but that's not very urgent IMO.

Quoted 49 lines

[ ... ]

Quoted 5 lines
drivers/net/ethernet/stmicro/stmmac/stmmac_vlan.c +0 -0
index fb9aad748cb34..bf23d82e9f383 100644

drivers/net/ethernet/stmicro/stmmac/stmmac_vlan.c static void vlan_rx_hw(struct mac_device_info *hw, · line 217

Quoted 10 lines
drivers/net/ethernet/stmicro/stmmac/stmmac_vlan.c +5 -1
@@ -209,8 +209,12 @@ static void vlan_rx_hw(struct mac_device_info *hw,
 {
 	if (hw->desc->get_rx_vlan_valid(rx_desc)) {
 		u16 vid = hw->desc->get_rx_vlan_tci(rx_desc);
+		u16 proto = ETH_P_8021Q;
 
-		__vlan_hwaccel_put_tag(skb, htons(ETH_P_8021Q), vid);
+		if (hw->desc->get_rx_vlan_proto)
+			proto = hw->desc->get_rx_vlan_proto(rx_desc);
+
+		__vlan_hwaccel_put_tag(skb, htons(proto), vid);

[Severity: Medium]
Should this patch carry a Fixes: tag? It looks like it fixes a user-visible regression on XGMAC.

On XGMAC, __stmmac_dvr_probe() advertises NETIF_F_HW_VLAN_STAG_RX and enables MAC-level stripping by default:

drivers/net/ethernet/stmicro/stmmac/stmmac_main.c:__stmmac_dvr_probe() {
    ...
	if (priv->plat->core_type == DWMAC_CORE_XGMAC)
		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;
	}
    ...
}

stmmac_fix_features() also keeps STAG_RX tied to CTAG_RX on XGMAC. Because of this, every frame with a stripped 802.1ad outer tag went through the old vlan_rx_hw() and reached the stack labelled as ETH_P_8021Q. 802.1ad VLAN uppers received no traffic and QinQ between hosts failed.

The sibling commit da17990421d7 ("net: stmmac: Disable S-Tag processing on dwmac4") describes this exact failure and carries a Fixes: tag. Its message says the dwxgmac2 side can be fixed using the RDES3 ET_LT field, which is what this patch does.

Quoted 4 lines

Without a Fixes: tag, stable trees that pick up the dwmac4 half would still mislabel S-tags on XGMAC. Would this be a suitable tag?

Fixes 534df0c1724b ("net: stmmac: dwxgmac2: Add support for HW-accelerated VLAN stripping")

That's not strictly speaking a regression, I'm ok sending this to net but I'm not sure this is worth.

Maxime

maintainer
#6 lore raw
In reply to Maxime Chevallier

drivers/net/ethernet/stmicro/stmmac/stmmac_vlan.c static void vlan_rx_hw(struct mac_device_info *hw, · line 217

Quoted 13 lines · On Wed, 18 Nov 2026 17:21:34 +0100 Maxime Chevallier wrote:
drivers/net/ethernet/stmicro/stmmac/stmmac_vlan.c +5 -1
@@ -209,8 +209,12 @@ static void vlan_rx_hw(struct mac_device_info *hw,
 {
 	if (hw->desc->get_rx_vlan_valid(rx_desc)) {
 		u16 vid = hw->desc->get_rx_vlan_tci(rx_desc);
+		u16 proto = ETH_P_8021Q;
 
-		__vlan_hwaccel_put_tag(skb, htons(ETH_P_8021Q), vid);
+		if (hw->desc->get_rx_vlan_proto)
+			proto = hw->desc->get_rx_vlan_proto(rx_desc);
+
+		__vlan_hwaccel_put_tag(skb, htons(proto), vid);

Heh, this function now does 3 indirect calls to get the info about the stripped vlan. Isn't this slower than disabling the offload and stripping in SW at this point? Maybe the low-end CPUs are very different :) Or there's something else I'm missing?

(not really expecting you to do any digging, to be clear, just found the level of complexity in SW to support a trivial HW offload kinda funny)

author maintainer
#7 lore raw
Quoted 9 lines · Jakub Kicinski
Quoted 8 lines · On Wed, 18 Nov 2026 17:21:34 +0100 Maxime Chevallier wrote:
drivers/net/ethernet/stmicro/stmmac/stmmac_vlan.c +1 -0
@@ -209,8 +209,12 @@ static void vlan_rx_hw(struct mac_device_info *hw,
 {
 	if (hw->desc->get_rx_vlan_valid(rx_desc)) {
 		u16 vid = hw->desc->get_rx_vlan_tci(rx_desc);
+		u16 proto = ETH_P_8021Q;
 
Quoted 10 lines

drivers/net/ethernet/stmicro/stmmac/stmmac_vlan.c static void vlan_rx_hw(struct mac_device_info *hw, · line 217

Quoted 5 lines
drivers/net/ethernet/stmicro/stmmac/stmmac_vlan.c +4 -1
-		__vlan_hwaccel_put_tag(skb, htons(ETH_P_8021Q), vid);
+		if (hw->desc->get_rx_vlan_proto)
+			proto = hw->desc->get_rx_vlan_proto(rx_desc);
+
+		__vlan_hwaccel_put_tag(skb, htons(proto), vid);

Heh, this function now does 3 indirect calls to get the info about the stripped vlan. Isn't this slower than disabling the offload and stripping in SW at this point? Maybe the low-end CPUs are very different :) Or there's something else I'm missing?

We'll do like the rest of the driver and hide these indirections with a nasty macro :)

(jk, but TBH I can't test that one at more than 1Gbps, it's very likely there's ton of room for optimisation...)

Maxime

#8 lore raw
In reply to Maxime Chevallier
This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:

Hello:

This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:

Quoted 10 lines · On Wed, 18 Nov 2026 17:21:34 +0100 you wrote:

Stmmac's double VLAN handling hasn't been working great for a while, it's been recently reworked for dwmac4 by Ovidiu Panait. In that work, it was found that the tag stripping hardcodes the 8021Q tag type for XGMAC while stripping the tag, while the IP actually reports the outer tag type in the descriptor.

The tag type can be one of 6 different values (note inner/outer is reversed in the macro names):

[...]

Here is the summary with links:
- [net-next] net: stmmac: xgmac: Report the VLAN tag type from the descriptor

    https://git.kernel.org/netdev/net-next/c/d82b4f3a8a2e

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html