* [PATCH net v5 1/5] net: stmmac: Remove VLAN perfect matching dead code
2026-09-20 15:35 [PATCH net v5 0/5] net: stmmac: Fix double VLAN 802.1ad tag handling Ovidiu Panait
@ 2026-09-20 15:35 ` Ovidiu Panait
2026-09-20 15:35 ` [PATCH net v5 2/5] net: stmmac: Stop toggling the EDVLP bit Ovidiu Panait
` (4 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Ovidiu Panait @ 2026-09-20 15:35 UTC (permalink / raw)
To: maxime.chevallier, recv.jo, andrew+netdev, davem, edumazet, kuba,
pabeni, mcoquelin.stm32, alexandre.torgue, joabreu, jun.ann.lai,
yi.fang.gan
Cc: netdev, linux-stm32, linux-arm-kernel, linux-kernel, Ovidiu Panait
stmmac_vlan_update() falls back to "perfect matching" when the VLAN hash
filter is unavailable (!priv->dma_cap.vlhash). This fallback has been
unreachable in normal operation since its introduction in
commit c7ab0b8088d7 ("net: stmmac: Fallback to VLAN Perfect filtering if
HASH is not available") because the NETIF_F_HW_VLAN_{CTAG,STAG}_FILTER
features are advertised only when priv->dma_cap.vlhash is true.
The fallback is also duplicating the code in vlan_add_hw_rx_fltr(), which
is always available since stmmac_get_num_vlan() returns at least 1.
Therefore, remove it.
Fixes: c7ab0b8088d7 ("net: stmmac: Fallback to VLAN Perfect filtering if HASH is not available")
Signed-off-by: Ovidiu Panait <ovidiu.panait.rb@renesas.com>
Reviewed-by: Maxime Chevallier <maxime.chevallier@bootlin.com>
---
v5 changes: None
v4 changes: None.
drivers/net/ethernet/stmicro/stmmac/hwif.h | 2 +-
.../net/ethernet/stmicro/stmmac/stmmac_main.c | 13 +-----
.../net/ethernet/stmicro/stmmac/stmmac_vlan.c | 41 +------------------
3 files changed, 4 insertions(+), 52 deletions(-)
diff --git a/drivers/net/ethernet/stmicro/stmmac/hwif.h b/drivers/net/ethernet/stmicro/stmmac/hwif.h
index 9314bcb85c22..734e30caea81 100644
--- a/drivers/net/ethernet/stmicro/stmmac/hwif.h
+++ b/drivers/net/ethernet/stmicro/stmmac/hwif.h
@@ -633,7 +633,7 @@ struct stmmac_est_ops {
struct stmmac_vlan_ops {
/* VLAN */
void (*update_vlan_hash)(struct mac_device_info *hw, u32 hash,
- u16 perfect_match, bool is_double);
+ bool is_double);
void (*enable_vlan)(struct mac_device_info *hw, u32 type);
void (*rx_hw_vlan)(struct mac_device_info *hw, struct dma_desc *rx_desc,
struct sk_buff *skb);
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index 1fb5f804ea23..d0643a30db1c 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -6835,29 +6835,18 @@ static u32 stmmac_vid_crc32_le(__le16 vid_le)
static int stmmac_vlan_update(struct stmmac_priv *priv, bool is_double)
{
u32 crc, hash = 0;
- u16 pmatch = 0;
- int count = 0;
u16 vid = 0;
for_each_set_bit(vid, priv->active_vlans, VLAN_N_VID) {
__le16 vid_le = cpu_to_le16(vid);
crc = bitrev32(~stmmac_vid_crc32_le(vid_le)) >> 28;
hash |= (1 << crc);
- count++;
- }
-
- if (!priv->dma_cap.vlhash) {
- if (count > 2) /* VID = 0 always passes filter */
- return -EOPNOTSUPP;
-
- pmatch = vid;
- hash = 0;
}
if (!netif_running(priv->dev))
return 0;
- return stmmac_update_vlan_hash(priv, priv->hw, hash, pmatch, is_double);
+ return stmmac_update_vlan_hash(priv, priv->hw, hash, is_double);
}
/* FIXME: This may need RXC to be running, but it may be called with BH
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_vlan.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_vlan.c
index e24efe3bfedb..983a90cb9767 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_vlan.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_vlan.c
@@ -162,7 +162,7 @@ static void vlan_restore_hw_rx_fltr(struct net_device *dev,
}
static void vlan_update_hash(struct mac_device_info *hw, u32 hash,
- u16 perfect_match, bool is_double)
+ bool is_double)
{
void __iomem *ioaddr = hw->pcsr;
u32 value;
@@ -184,20 +184,6 @@ static void vlan_update_hash(struct mac_device_info *hw, u32 hash,
}
writel(value, ioaddr + VLAN_TAG);
- } else if (perfect_match) {
- u32 value = VLAN_ETV;
-
- if (is_double) {
- value |= VLAN_EDVLP;
- value |= VLAN_ESVL;
- value |= VLAN_DOVLTC;
- } else {
- value &= ~VLAN_EDVLP;
- value &= ~VLAN_ESVL;
- value &= ~VLAN_DOVLTC;
- }
-
- writel(value | perfect_match, ioaddr + VLAN_TAG);
} else {
value &= ~(VLAN_VTHM | VLAN_ETV);
value &= ~(VLAN_EDVLP | VLAN_ESVL);
@@ -251,7 +237,7 @@ static void vlan_set_hw_mode(struct mac_device_info *hw)
}
static void dwxgmac2_update_vlan_hash(struct mac_device_info *hw, u32 hash,
- u16 perfect_match, bool is_double)
+ bool is_double)
{
void __iomem *ioaddr = hw->pcsr;
@@ -279,29 +265,6 @@ static void dwxgmac2_update_vlan_hash(struct mac_device_info *hw, u32 hash,
value &= ~VLAN_VID;
writel(value, ioaddr + VLAN_TAG);
- } else if (perfect_match) {
- u32 value = readl(ioaddr + XGMAC_PACKET_FILTER);
-
- value |= XGMAC_FILTER_VTFE;
-
- writel(value, ioaddr + XGMAC_PACKET_FILTER);
-
- value = readl(ioaddr + VLAN_TAG);
-
- value &= ~VLAN_VTHM;
- value |= VLAN_ETV;
- if (is_double) {
- value |= VLAN_EDVLP;
- value |= VLAN_ESVL;
- value |= VLAN_DOVLTC;
- } else {
- value &= ~VLAN_EDVLP;
- value &= ~VLAN_ESVL;
- value &= ~VLAN_DOVLTC;
- }
-
- value &= ~VLAN_VID;
- writel(value | perfect_match, ioaddr + VLAN_TAG);
} else {
u32 value = readl(ioaddr + XGMAC_PACKET_FILTER);
--
2.34.1
^ permalink raw reply [flat|nested] 7+ messages in thread* [PATCH net v5 2/5] net: stmmac: Stop toggling the EDVLP bit
2026-09-20 15:35 [PATCH net v5 0/5] net: stmmac: Fix double VLAN 802.1ad tag handling Ovidiu Panait
2026-09-20 15:35 ` [PATCH net v5 1/5] net: stmmac: Remove VLAN perfect matching dead code Ovidiu Panait
@ 2026-09-20 15:35 ` Ovidiu Panait
2026-09-20 15:35 ` [PATCH net v5 3/5] net: stmmac: Rename double VLAN references to svlan Ovidiu Panait
` (3 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Ovidiu Panait @ 2026-09-20 15:35 UTC (permalink / raw)
To: maxime.chevallier, recv.jo, andrew+netdev, davem, edumazet, kuba,
pabeni, mcoquelin.stm32, alexandre.torgue, joabreu, jun.ann.lai,
yi.fang.gan
Cc: netdev, linux-stm32, linux-arm-kernel, linux-kernel, Ovidiu Panait
Currently, the double VLAN EDVLP bit is toggled whenever an 802.1ad VLAN
is registered. This bit enables processing of the inner VLAN tag, which
is completely unrelated to S-Tag VLAN handling.
Move EDVLP handling into vlan_set_hw_mode() instead, and keep it always
enabled, so that COE can work for packets with an inner VLAN header.
Add a dedicated callback for dwxlgmac2, as it doesn't implement the
set_hw_vlan_mode callback, like the other cores.
Suggested-by: Joseph Steel <recv.jo@gmail.com>
Signed-off-by: Ovidiu Panait <ovidiu.panait.rb@renesas.com>
---
v5 changes: None.
v4 changes:
- New patch.
.../net/ethernet/stmicro/stmmac/stmmac_vlan.c | 20 +++++++++++--------
1 file changed, 12 insertions(+), 8 deletions(-)
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_vlan.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_vlan.c
index 983a90cb9767..200b34588c7f 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_vlan.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_vlan.c
@@ -174,19 +174,16 @@ static void vlan_update_hash(struct mac_device_info *hw, u32 hash,
if (hash) {
value |= VLAN_VTHM | VLAN_ETV;
if (is_double) {
- value |= VLAN_EDVLP;
value |= VLAN_ESVL;
value |= VLAN_DOVLTC;
} else {
- value &= ~VLAN_EDVLP;
value &= ~VLAN_ESVL;
value &= ~VLAN_DOVLTC;
}
writel(value, ioaddr + VLAN_TAG);
} else {
- value &= ~(VLAN_VTHM | VLAN_ETV);
- value &= ~(VLAN_EDVLP | VLAN_ESVL);
+ value &= ~(VLAN_VTHM | VLAN_ETV | VLAN_ESVL);
value &= ~VLAN_DOVLTC;
value &= ~VLAN_VID;
@@ -222,6 +219,7 @@ static void vlan_set_hw_mode(struct mac_device_info *hw)
void __iomem *ioaddr = hw->pcsr;
u32 value = readl(ioaddr + VLAN_TAG);
+ value |= VLAN_EDVLP;
value &= ~VLAN_TAG_CTRL_EVLS_MASK;
if (hw->hw_vlan_en)
@@ -254,11 +252,9 @@ static void dwxgmac2_update_vlan_hash(struct mac_device_info *hw, u32 hash,
value |= VLAN_VTHM | VLAN_ETV;
if (is_double) {
- value |= VLAN_EDVLP;
value |= VLAN_ESVL;
value |= VLAN_DOVLTC;
} else {
- value &= ~VLAN_EDVLP;
value &= ~VLAN_ESVL;
value &= ~VLAN_DOVLTC;
}
@@ -274,8 +270,7 @@ static void dwxgmac2_update_vlan_hash(struct mac_device_info *hw, u32 hash,
value = readl(ioaddr + VLAN_TAG);
- value &= ~(VLAN_VTHM | VLAN_ETV);
- value &= ~(VLAN_EDVLP | VLAN_ESVL);
+ value &= ~(VLAN_VTHM | VLAN_ETV | VLAN_ESVL);
value &= ~VLAN_DOVLTC;
value &= ~VLAN_VID;
@@ -283,6 +278,14 @@ static void dwxgmac2_update_vlan_hash(struct mac_device_info *hw, u32 hash,
}
}
+static void dwxlgmac2_set_hw_vlan_mode(struct mac_device_info *hw)
+{
+ void __iomem *ioaddr = hw->pcsr;
+ u32 value = readl(ioaddr + VLAN_TAG);
+
+ writel(value | VLAN_EDVLP, ioaddr + VLAN_TAG);
+}
+
const struct stmmac_vlan_ops dwmac_vlan_ops = {
.update_vlan_hash = vlan_update_hash,
.enable_vlan = vlan_enable,
@@ -296,6 +299,7 @@ const struct stmmac_vlan_ops dwmac_vlan_ops = {
const struct stmmac_vlan_ops dwxlgmac2_vlan_ops = {
.update_vlan_hash = dwxgmac2_update_vlan_hash,
.enable_vlan = vlan_enable,
+ .set_hw_vlan_mode = dwxlgmac2_set_hw_vlan_mode,
};
const struct stmmac_vlan_ops dwxgmac210_vlan_ops = {
--
2.34.1
^ permalink raw reply [flat|nested] 7+ messages in thread* [PATCH net v5 3/5] net: stmmac: Rename double VLAN references to svlan
2026-09-20 15:35 [PATCH net v5 0/5] net: stmmac: Fix double VLAN 802.1ad tag handling Ovidiu Panait
2026-09-20 15:35 ` [PATCH net v5 1/5] net: stmmac: Remove VLAN perfect matching dead code Ovidiu Panait
2026-09-20 15:35 ` [PATCH net v5 2/5] net: stmmac: Stop toggling the EDVLP bit Ovidiu Panait
@ 2026-09-20 15:35 ` Ovidiu Panait
2026-09-20 15:35 ` [PATCH net v5 4/5] net: stmmac: Do not advertise S-VLAN stripping when it is disabled Ovidiu Panait
` (2 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Ovidiu Panait @ 2026-09-20 15:35 UTC (permalink / raw)
To: maxime.chevallier, recv.jo, andrew+netdev, davem, edumazet, kuba,
pabeni, mcoquelin.stm32, alexandre.torgue, joabreu, jun.ann.lai,
yi.fang.gan
Cc: netdev, linux-stm32, linux-arm-kernel, linux-kernel, Ovidiu Panait
The ESVL and DOVLTC bits control S-VLAN tag processing and have
nothing to do with the double VLAN feature, which only provides a way
to process an additional inner VLAN tag. However, the driver code
that handles them always refers to "double VLAN", which is unrelated
and makes the implementation confusing. The driver does not use any
of the inner VLAN tag features, and the networking core does not
support offloads for the inner tag anyway.
To reduce the confusion regarding S-Tag vs double VLAN handling,
rename double -> svlan.
No functional change intended.
Suggested-by: Joseph Steel <recv.jo@gmail.com>
Signed-off-by: Ovidiu Panait <ovidiu.panait.rb@renesas.com>
---
v5 changes: New patch.
drivers/net/ethernet/stmicro/stmmac/hwif.h | 2 +-
drivers/net/ethernet/stmicro/stmmac/stmmac.h | 2 +-
.../net/ethernet/stmicro/stmmac/stmmac_main.c | 34 +++++++++----------
.../stmicro/stmmac/stmmac_selftests.c | 30 ++++++++--------
.../net/ethernet/stmicro/stmmac/stmmac_vlan.c | 8 ++---
5 files changed, 38 insertions(+), 38 deletions(-)
diff --git a/drivers/net/ethernet/stmicro/stmmac/hwif.h b/drivers/net/ethernet/stmicro/stmmac/hwif.h
index 734e30caea81..a8ddbedec9ca 100644
--- a/drivers/net/ethernet/stmicro/stmmac/hwif.h
+++ b/drivers/net/ethernet/stmicro/stmmac/hwif.h
@@ -633,7 +633,7 @@ struct stmmac_est_ops {
struct stmmac_vlan_ops {
/* VLAN */
void (*update_vlan_hash)(struct mac_device_info *hw, u32 hash,
- bool is_double);
+ bool is_svlan);
void (*enable_vlan)(struct mac_device_info *hw, u32 type);
void (*rx_hw_vlan)(struct mac_device_info *hw, struct dma_desc *rx_desc,
struct sk_buff *skb);
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac.h b/drivers/net/ethernet/stmicro/stmmac/stmmac.h
index 7582fca63741..d2d387f45c10 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac.h
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac.h
@@ -344,7 +344,7 @@ struct stmmac_priv {
void __iomem *ptpaddr;
void __iomem *estaddr;
unsigned long active_vlans[BITS_TO_LONGS(VLAN_N_VID)];
- unsigned int num_double_vlans;
+ unsigned int num_svlans;
int sfty_irq;
struct stmmac_msi *msi;
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index d0643a30db1c..77a8bcf5bf14 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -6832,7 +6832,7 @@ static u32 stmmac_vid_crc32_le(__le16 vid_le)
return crc;
}
-static int stmmac_vlan_update(struct stmmac_priv *priv, bool is_double)
+static int stmmac_vlan_update(struct stmmac_priv *priv, bool is_svlan)
{
u32 crc, hash = 0;
u16 vid = 0;
@@ -6846,7 +6846,7 @@ static int stmmac_vlan_update(struct stmmac_priv *priv, bool is_double)
if (!netif_running(priv->dev))
return 0;
- return stmmac_update_vlan_hash(priv, priv->hw, hash, is_double);
+ return stmmac_update_vlan_hash(priv, priv->hw, hash, is_svlan);
}
/* FIXME: This may need RXC to be running, but it may be called with BH
@@ -6855,8 +6855,8 @@ static int stmmac_vlan_update(struct stmmac_priv *priv, bool is_double)
static int stmmac_vlan_rx_add_vid(struct net_device *ndev, __be16 proto, u16 vid)
{
struct stmmac_priv *priv = netdev_priv(ndev);
- unsigned int num_double_vlans;
- bool is_double = false;
+ unsigned int num_svlans;
+ bool is_svlan = false;
int ret;
ret = pm_runtime_resume_and_get(priv->device);
@@ -6864,11 +6864,11 @@ static int stmmac_vlan_rx_add_vid(struct net_device *ndev, __be16 proto, u16 vid
return ret;
if (be16_to_cpu(proto) == ETH_P_8021AD)
- is_double = true;
+ is_svlan = true;
set_bit(vid, priv->active_vlans);
- num_double_vlans = priv->num_double_vlans + is_double;
- ret = stmmac_vlan_update(priv, num_double_vlans);
+ num_svlans = priv->num_svlans + is_svlan;
+ ret = stmmac_vlan_update(priv, num_svlans);
if (ret) {
clear_bit(vid, priv->active_vlans);
goto err_pm_put;
@@ -6878,12 +6878,12 @@ static int stmmac_vlan_rx_add_vid(struct net_device *ndev, __be16 proto, u16 vid
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_double_vlans);
+ stmmac_vlan_update(priv, priv->num_svlans);
goto err_pm_put;
}
}
- priv->num_double_vlans = num_double_vlans;
+ priv->num_svlans = num_svlans;
err_pm_put:
pm_runtime_put(priv->device);
@@ -6897,8 +6897,8 @@ static int stmmac_vlan_rx_add_vid(struct net_device *ndev, __be16 proto, u16 vid
static int stmmac_vlan_rx_kill_vid(struct net_device *ndev, __be16 proto, u16 vid)
{
struct stmmac_priv *priv = netdev_priv(ndev);
- unsigned int num_double_vlans;
- bool is_double = false;
+ unsigned int num_svlans;
+ bool is_svlan = false;
int ret;
ret = pm_runtime_resume_and_get(priv->device);
@@ -6906,11 +6906,11 @@ static int stmmac_vlan_rx_kill_vid(struct net_device *ndev, __be16 proto, u16 vi
return ret;
if (be16_to_cpu(proto) == ETH_P_8021AD)
- is_double = true;
+ is_svlan = true;
clear_bit(vid, priv->active_vlans);
- num_double_vlans = priv->num_double_vlans - is_double;
- ret = stmmac_vlan_update(priv, num_double_vlans);
+ num_svlans = priv->num_svlans - is_svlan;
+ ret = stmmac_vlan_update(priv, num_svlans);
if (ret) {
set_bit(vid, priv->active_vlans);
goto del_vlan_error;
@@ -6920,12 +6920,12 @@ static int stmmac_vlan_rx_kill_vid(struct net_device *ndev, __be16 proto, u16 vi
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_double_vlans);
+ stmmac_vlan_update(priv, priv->num_svlans);
goto del_vlan_error;
}
}
- priv->num_double_vlans = num_double_vlans;
+ priv->num_svlans = num_svlans;
del_vlan_error:
pm_runtime_put(priv->device);
@@ -6941,7 +6941,7 @@ static void stmmac_vlan_restore(struct stmmac_priv *priv)
if (priv->hw->num_vlan)
stmmac_restore_hw_vlan_rx_fltr(priv, priv->dev, priv->hw);
- stmmac_vlan_update(priv, priv->num_double_vlans);
+ stmmac_vlan_update(priv, priv->num_svlans);
}
static int stmmac_bpf(struct net_device *dev, struct netdev_bpf *bpf)
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_selftests.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_selftests.c
index 6372ec7c3f31..b710eb99b1e7 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_selftests.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_selftests.c
@@ -237,7 +237,7 @@ struct stmmac_test_priv {
struct stmmac_packet_attrs *packet;
struct packet_type pt;
struct completion comp;
- int double_vlan;
+ int svlan;
int vlan_id;
int ok;
};
@@ -279,7 +279,7 @@ static int stmmac_test_loopback_validate(struct sk_buff *skb,
}
ihdr = ip_hdr(skb);
- if (tpriv->double_vlan)
+ if (tpriv->svlan)
ihdr = (struct iphdr *)(skb_network_header(skb) + 4);
if (tpriv->packet->tcp) {
@@ -855,7 +855,7 @@ static int stmmac_test_vlan_validate(struct sk_buff *skb,
struct iphdr *ihdr;
u16 proto;
- proto = tpriv->double_vlan ? ETH_P_8021AD : ETH_P_8021Q;
+ proto = tpriv->svlan ? ETH_P_8021AD : ETH_P_8021Q;
skb = skb_unshare(skb, GFP_ATOMIC);
if (!skb)
@@ -881,7 +881,7 @@ static int stmmac_test_vlan_validate(struct sk_buff *skb,
goto out;
ihdr = ip_hdr(skb);
- if (tpriv->double_vlan)
+ if (tpriv->svlan)
ihdr = (struct iphdr *)(skb_network_header(skb) + 4);
if (ihdr->protocol != IPPROTO_UDP)
goto out;
@@ -995,7 +995,7 @@ static int stmmac_test_vlanfilt_perfect(struct stmmac_priv *priv)
return ret;
}
-static int __stmmac_test_dvlanfilt(struct stmmac_priv *priv)
+static int __stmmac_test_svlanfilt(struct stmmac_priv *priv)
{
struct stmmac_packet_attrs attr = { };
struct stmmac_test_priv *tpriv;
@@ -1007,7 +1007,7 @@ static int __stmmac_test_dvlanfilt(struct stmmac_priv *priv)
return -ENOMEM;
tpriv->ok = false;
- tpriv->double_vlan = true;
+ tpriv->svlan = true;
init_completion(&tpriv->comp);
tpriv->pt.type = htons(ETH_P_8021Q);
@@ -1067,15 +1067,15 @@ static int __stmmac_test_dvlanfilt(struct stmmac_priv *priv)
return ret;
}
-static int stmmac_test_dvlanfilt(struct stmmac_priv *priv)
+static int stmmac_test_svlanfilt(struct stmmac_priv *priv)
{
if (!priv->dma_cap.vlhash)
return -EOPNOTSUPP;
- return __stmmac_test_dvlanfilt(priv);
+ return __stmmac_test_svlanfilt(priv);
}
-static int stmmac_test_dvlanfilt_perfect(struct stmmac_priv *priv)
+static int stmmac_test_svlanfilt_perfect(struct stmmac_priv *priv)
{
int ret, prev_cap = priv->dma_cap.vlhash;
@@ -1083,7 +1083,7 @@ static int stmmac_test_dvlanfilt_perfect(struct stmmac_priv *priv)
return -EOPNOTSUPP;
priv->dma_cap.vlhash = 0;
- ret = __stmmac_test_dvlanfilt(priv);
+ ret = __stmmac_test_svlanfilt(priv);
priv->dma_cap.vlhash = prev_cap;
return ret;
@@ -1284,7 +1284,7 @@ static int stmmac_test_vlanoff_common(struct stmmac_priv *priv, bool svlan)
proto = svlan ? ETH_P_8021AD : ETH_P_8021Q;
tpriv->ok = false;
- tpriv->double_vlan = svlan;
+ tpriv->svlan = svlan;
init_completion(&tpriv->comp);
tpriv->pt.type = svlan ? htons(ETH_P_8021Q) : htons(ETH_P_IP);
@@ -1867,11 +1867,11 @@ static const struct stmmac_test {
.name = "VLAN Filtering (perf) ",
.fn = stmmac_test_vlanfilt_perfect,
}, {
- .name = "Double VLAN Filter ",
- .fn = stmmac_test_dvlanfilt,
+ .name = "SVLAN Filtering ",
+ .fn = stmmac_test_svlanfilt,
}, {
- .name = "Double VLAN Filter (perf) ",
- .fn = stmmac_test_dvlanfilt_perfect,
+ .name = "SVLAN Filtering (perf) ",
+ .fn = stmmac_test_svlanfilt_perfect,
}, {
.name = "Flexible RX Parser ",
.fn = stmmac_test_rxp,
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_vlan.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_vlan.c
index 200b34588c7f..fb9aad748cb3 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_vlan.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_vlan.c
@@ -162,7 +162,7 @@ static void vlan_restore_hw_rx_fltr(struct net_device *dev,
}
static void vlan_update_hash(struct mac_device_info *hw, u32 hash,
- bool is_double)
+ bool is_svlan)
{
void __iomem *ioaddr = hw->pcsr;
u32 value;
@@ -173,7 +173,7 @@ static void vlan_update_hash(struct mac_device_info *hw, u32 hash,
if (hash) {
value |= VLAN_VTHM | VLAN_ETV;
- if (is_double) {
+ if (is_svlan) {
value |= VLAN_ESVL;
value |= VLAN_DOVLTC;
} else {
@@ -235,7 +235,7 @@ static void vlan_set_hw_mode(struct mac_device_info *hw)
}
static void dwxgmac2_update_vlan_hash(struct mac_device_info *hw, u32 hash,
- bool is_double)
+ bool is_svlan)
{
void __iomem *ioaddr = hw->pcsr;
@@ -251,7 +251,7 @@ static void dwxgmac2_update_vlan_hash(struct mac_device_info *hw, u32 hash,
value = readl(ioaddr + VLAN_TAG);
value |= VLAN_VTHM | VLAN_ETV;
- if (is_double) {
+ if (is_svlan) {
value |= VLAN_ESVL;
value |= VLAN_DOVLTC;
} else {
--
2.34.1
^ permalink raw reply [flat|nested] 7+ messages in thread* [PATCH net v5 4/5] net: stmmac: Do not advertise S-VLAN stripping when it is disabled
2026-09-20 15:35 [PATCH net v5 0/5] net: stmmac: Fix double VLAN 802.1ad tag handling Ovidiu Panait
` (2 preceding siblings ...)
2026-09-20 15:35 ` [PATCH net v5 3/5] net: stmmac: Rename double VLAN references to svlan Ovidiu Panait
@ 2026-09-20 15:35 ` Ovidiu Panait
2026-09-20 15:35 ` [PATCH net v5 5/5] net: stmmac: Disable S-Tag processing on dwmac4 Ovidiu Panait
2026-09-24 16:30 ` [PATCH net v5 0/5] net: stmmac: Fix double VLAN 802.1ad tag handling Jakub Kicinski
5 siblings, 0 replies; 7+ messages in thread
From: Ovidiu Panait @ 2026-09-20 15:35 UTC (permalink / raw)
To: maxime.chevallier, recv.jo, andrew+netdev, davem, edumazet, kuba,
pabeni, mcoquelin.stm32, alexandre.torgue, joabreu, jun.ann.lai,
yi.fang.gan
Cc: netdev, linux-stm32, linux-arm-kernel, linux-kernel, Ovidiu Panait
C-VLAN and S-VLAN tag stripping are both controlled by the EVLS bit,
so disabling rx-vlan-offload also disables S-VLAN tag stripping.
However, rx-vlan-stag-hw-parse keeps being advertised as enabled:
root@rzv2h-evk:~# ethtool -K end1 rx-vlan-offload off
root@rzv2h-evk:~# ethtool -k end1 | grep -i vlan
rx-vlan-offload: off
tx-vlan-offload: off [fixed]
rx-vlan-filter: on [fixed]
vlan-challenged: off [fixed]
tx-vlan-stag-hw-insert: off [fixed]
rx-vlan-stag-hw-parse: on [fixed]
rx-vlan-stag-filter: on [fixed]
Fix this inconsistency by making NETIF_F_HW_VLAN_STAG_RX follow
NETIF_F_HW_VLAN_CTAG_RX.
Fixes: 750011e239a5 ("net: stmmac: Add support for HW-accelerated VLAN stripping")
Signed-off-by: Ovidiu Panait <ovidiu.panait.rb@renesas.com>
---
v5 changes:
- Rebased on top of the rename patch: used dwmac_is_xmac() instead of
the dropped hw_svlan_en flag.
v4 changes:
- New patch.
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index 77a8bcf5bf14..c06eed76e3d9 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -6208,6 +6208,13 @@ static netdev_features_t stmmac_fix_features(struct net_device *dev,
if (priv->plat->bugged_jumbo && (dev->mtu > ETH_DATA_LEN))
features &= ~NETIF_F_CSUM_MASK;
+ if (dwmac_is_xmac(priv->plat->core_type)) {
+ if (features & NETIF_F_HW_VLAN_CTAG_RX)
+ features |= NETIF_F_HW_VLAN_STAG_RX;
+ else
+ features &= ~NETIF_F_HW_VLAN_STAG_RX;
+ }
+
return features;
}
--
2.34.1
^ permalink raw reply [flat|nested] 7+ messages in thread* [PATCH net v5 5/5] net: stmmac: Disable S-Tag processing on dwmac4
2026-09-20 15:35 [PATCH net v5 0/5] net: stmmac: Fix double VLAN 802.1ad tag handling Ovidiu Panait
` (3 preceding siblings ...)
2026-09-20 15:35 ` [PATCH net v5 4/5] net: stmmac: Do not advertise S-VLAN stripping when it is disabled Ovidiu Panait
@ 2026-09-20 15:35 ` Ovidiu Panait
2026-09-24 16:30 ` [PATCH net v5 0/5] net: stmmac: Fix double VLAN 802.1ad tag handling Jakub Kicinski
5 siblings, 0 replies; 7+ messages in thread
From: Ovidiu Panait @ 2026-09-20 15:35 UTC (permalink / raw)
To: maxime.chevallier, recv.jo, andrew+netdev, davem, edumazet, kuba,
pabeni, mcoquelin.stm32, alexandre.torgue, joabreu, jun.ann.lai,
yi.fang.gan
Cc: netdev, linux-stm32, linux-arm-kernel, linux-kernel, Ovidiu Panait
Currently, hardware VLAN stripping is broken for 802.1ad tags. vlan_rx_hw()
hardcodes ETH_P_8021Q when putting the hardware tag into the skb, rather
than using the actual protocol from the packet. Because of this, packets
that contain a 802.1ad outer tag are incorrectly passed up the stack as
having an 802.1Q tag. This causes QinQ ping between two hosts to fail.
vlan_rx_hw() is shared by dwxgmac2 and dwmac4: on dwxgmac2 the tag type
is available in the RDES3 write-back descriptor (the ET_LT field), so the
outer tag type can be determined based on that info. However, dwmac4
doesn't seem to provide the tag type. The Length/Type field in RDES3 only
indicates whether the packet is single or double-tagged, not which tag
type was stripped.
Since dwmac4 cannot report the stripped tag type, it cannot support
hardware S-Tag stripping correctly. Therefore, restrict the
NETIF_F_HW_VLAN_STAG_RX and NETIF_F_HW_VLAN_STAG_FILTER advertisement
to dwxgmac2 only.
With this, 802.1ad tags are left in place and handled by the software
VLAN path.
Fixes: 750011e239a5 ("net: stmmac: Add support for HW-accelerated VLAN stripping")
Signed-off-by: Ovidiu Panait <ovidiu.panait.rb@renesas.com>
Reviewed-by: Maxime Chevallier <maxime.chevallier@bootlin.com>
---
v5 changes:
- Rebased on top of latest changes.
- Added Reviewed-by tag from Maxime.
v4 changes:
- Dropped all "double VLAN" references from the commit title/message.
- Rebased on top of the S-VLAN rework.
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index c06eed76e3d9..e812a9c206ea 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -6208,7 +6208,7 @@ static netdev_features_t stmmac_fix_features(struct net_device *dev,
if (priv->plat->bugged_jumbo && (dev->mtu > ETH_DATA_LEN))
features &= ~NETIF_F_CSUM_MASK;
- if (dwmac_is_xmac(priv->plat->core_type)) {
+ if (priv->plat->core_type == DWMAC_CORE_XGMAC) {
if (features & NETIF_F_HW_VLAN_CTAG_RX)
features |= NETIF_F_HW_VLAN_STAG_RX;
else
@@ -7987,14 +7987,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->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;
}
if (priv->dma_cap.vlhash) {
ndev->features |= NETIF_F_HW_VLAN_CTAG_FILTER;
- ndev->features |= NETIF_F_HW_VLAN_STAG_FILTER;
+ if (priv->plat->core_type == DWMAC_CORE_XGMAC)
+ ndev->features |= NETIF_F_HW_VLAN_STAG_FILTER;
}
if (priv->dma_cap.vlins)
ndev->features |= NETIF_F_HW_VLAN_CTAG_TX;
--
2.34.1
^ permalink raw reply [flat|nested] 7+ messages in thread* Re: [PATCH net v5 0/5] net: stmmac: Fix double VLAN 802.1ad tag handling
2026-09-20 15:35 [PATCH net v5 0/5] net: stmmac: Fix double VLAN 802.1ad tag handling Ovidiu Panait
` (4 preceding siblings ...)
2026-09-20 15:35 ` [PATCH net v5 5/5] net: stmmac: Disable S-Tag processing on dwmac4 Ovidiu Panait
@ 2026-09-24 16:30 ` Jakub Kicinski
5 siblings, 0 replies; 7+ messages in thread
From: Jakub Kicinski @ 2026-09-24 16:30 UTC (permalink / raw)
To: Ovidiu Panait
Cc: maxime.chevallier, recv.jo, andrew+netdev, davem, edumazet,
pabeni, mcoquelin.stm32, alexandre.torgue, joabreu, jun.ann.lai,
yi.fang.gan, netdev, linux-stm32, linux-arm-kernel, linux-kernel
On Sun, 20 Sep 2026 15:35:11 +0000 Ovidiu Panait wrote:
> Currently, hardware VLAN stripping is broken for 802.1ad tags. vlan_rx_hw()
> hardcodes ETH_P_8021Q when putting the hardware tag into the skb, rather
> than using the actual protocol from the packet. Because of this, packets
> that contain an 802.1ad outer tag are incorrectly passed up the stack as
> having an 802.1Q tag.
Failed to apply patch:
Applying: net: stmmac: Remove VLAN perfect matching dead code
Applying: net: stmmac: Stop toggling the EDVLP bit
Applying: net: stmmac: Rename double VLAN references to svlan
error: sha1 information is lacking or useless (drivers/net/ethernet/stmicro/stmmac/hwif.h).
error: could not build fake ancestor
hint: Use 'git am --show-current-patch=diff' to see the failed patch
hint: When you have resolved this problem, run "git am --continue".
hint: If you prefer to skip this patch, run "git am --skip" instead.
hint: To restore the original branch and stop patching, run "git am --abort".
hint: Disable this message with "git config set advice.mergeConflict false"
Patch failed at 0003 net: stmmac: Rename double VLAN references to svlan
--
pw-bot: cr
^ permalink raw reply [flat|nested] 7+ messages in thread