* [PATCH net v4 0/3] net: stmmac: Fixes for stmmac Tx VLAN insert and EST
@ 2025-10-28 3:18 Rohan G Thomas via B4 Relay
2025-10-28 3:18 ` [PATCH net v4 1/3] net: stmmac: vlan: Disable 802.1AD tag insertion offload Rohan G Thomas via B4 Relay
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: Rohan G Thomas via B4 Relay @ 2025-10-28 3:18 UTC (permalink / raw)
To: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Maxime Coquelin, Alexandre Torgue, Jose Abreu,
Rohan G Thomas, Boon Khai Ng
Cc: netdev, linux-stm32, linux-arm-kernel, linux-kernel,
Rohan G Thomas, Matthew Gerlach
This patchset includes following fixes for stmmac Tx VLAN insert and
EST implementations:
1. Disable STAG insertion offloading, as DWMAC IPs doesn't support
offload of STAG for double VLAN packets and CTAG for single VLAN
packets when using the same register configuration. The current
configuration in the driver is undocumented and is adding an
additional 802.1Q tag with VLAN ID 0 for double VLAN packets.
2. Consider Tx VLAN offload tag length for maxSDU estimation.
3. Fix GCL bounds check
Signed-off-by: Rohan G Thomas <rohan.g.thomas@altera.com>
---
Changes in v4:
- Reworked sdu_len check to be done before stmmac_vlan_insert
- Corrected formatting of the if block in the maxSDU check
- Updated variable declarations to follow reverse christmas tree order
- Revised the commit message to clearly reflect the maxSDU requirement
- Link to v3: https://lore.kernel.org/r/20251017-qbv-fixes-v3-0-d3a42e32646a@altera.com
Changes in v3:
- Commit for disabling 802.1AD tag insertion offload is introduced in
to this patchset
- Add just VLAN_HLEN to sdu_len when 802.1Q tag offload is requested
- Link to v2: https://lore.kernel.org/r/20250915-qbv-fixes-v2-0-ec90673bb7d4@altera.com
Changes in v2:
- Use GENMASK instead of BIT for clarity and consistency
- Link to v1: https://lore.kernel.org/r/20250911-qbv-fixes-v1-0-e81e9597cf1f@altera.com
---
Rohan G Thomas (3):
net: stmmac: vlan: Disable 802.1AD tag insertion offload
net: stmmac: Consider Tx VLAN offload tag length for maxSDU
net: stmmac: est: Fix GCL bounds checks
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 32 ++++++++++-------------
drivers/net/ethernet/stmicro/stmmac/stmmac_tc.c | 4 +--
drivers/net/ethernet/stmicro/stmmac/stmmac_vlan.c | 2 +-
3 files changed, 17 insertions(+), 21 deletions(-)
---
base-commit: bfe62db5422b1a5f25752bd0877a097d436d876d
change-id: 20250911-qbv-fixes-4ae64de86ee7
Best regards,
--
Rohan G Thomas <rohan.g.thomas@altera.com>
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH net v4 1/3] net: stmmac: vlan: Disable 802.1AD tag insertion offload
2025-10-28 3:18 [PATCH net v4 0/3] net: stmmac: Fixes for stmmac Tx VLAN insert and EST Rohan G Thomas via B4 Relay
@ 2025-10-28 3:18 ` Rohan G Thomas via B4 Relay
2025-10-28 3:18 ` [PATCH net v4 2/3] net: stmmac: Consider Tx VLAN offload tag length for maxSDU Rohan G Thomas via B4 Relay
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Rohan G Thomas via B4 Relay @ 2025-10-28 3:18 UTC (permalink / raw)
To: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Maxime Coquelin, Alexandre Torgue, Jose Abreu,
Rohan G Thomas, Boon Khai Ng
Cc: netdev, linux-stm32, linux-arm-kernel, linux-kernel,
Rohan G Thomas
From: Rohan G Thomas <rohan.g.thomas@altera.com>
The DWMAC IP's VLAN tag insertion offload does not support inserting
STAG (802.1AD) and CTAG (802.1Q) types in bytes 13 and 14 using the
same MAC_VLAN_Incl and MAC_VLAN_Inner_Incl register configurations.
Currently, MAC_VLAN_Incl is configured to offload only STAG type
insertion. However, the DWMAC IP inserts a CTAG type when the inner
VLAN ID field of the descriptor is not configured, and a STAG type
when it is configured. This behavior is not documented and leads to
inconsistent double VLAN tagging.
Additionally, an unexpected CTAG with VLAN ID 0 is inserted, resulting
in frames like:
Frame 1: 110 bytes on wire (880 bits), 110 bytes captured (880 bits)
Ethernet II, Src: <src> (<src>), Dst: <dst> (<dst>)
IEEE 802.1ad, ID: 100
802.1Q Virtual LAN, PRI: 0, DEI: 0, ID: 0 (unexpected)
802.1Q Virtual LAN, PRI: 0, DEI: 0, ID: 200
Internet Protocol Version 4, Src: 192.168.4.10, Dst: 192.168.4.11
Internet Control Message Protocol
To avoid this undocumented and incorrect behavior, disable 802.1AD tag
insertion offload. Also, don't set CSVL bit. As per the data book,
when this bit is set, S-VLAN type (0x88A8) is inserted in the 13th and
14th bytes of transmitted packets and when this bit is reset, C-VLAN
type (0x8100) is inserted in the 13th and 14th bytes of transmitted
packets.
Fixes: 30d932279dc2 ("net: stmmac: Add support for VLAN Insertion Offload")
Fixes: e94e3f3b51ce ("net: stmmac: Add support for VLAN Insertion Offload in GMAC4+")
Fixes: 1d2c7a5fee31 ("net: stmmac: Refactor VLAN implementation")
Signed-off-by: Rohan G Thomas <rohan.g.thomas@altera.com>
Reviewed-by: Boon Khai Ng <boon.khai.ng@altera.com>
---
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 18 ++++--------------
drivers/net/ethernet/stmicro/stmmac/stmmac_vlan.c | 2 +-
2 files changed, 5 insertions(+), 15 deletions(-)
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index fd51068801928e138c3b483a1115b59b5ffa955a..0e2dc0a464d5516b8aabe2f9afc60c6e37f0209e 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -4107,18 +4107,11 @@ static int stmmac_release(struct net_device *dev)
static bool stmmac_vlan_insert(struct stmmac_priv *priv, struct sk_buff *skb,
struct stmmac_tx_queue *tx_q)
{
- u16 tag = 0x0, inner_tag = 0x0;
- u32 inner_type = 0x0;
struct dma_desc *p;
+ u16 tag = 0x0;
- if (!priv->dma_cap.vlins)
+ if (!priv->dma_cap.vlins || !skb_vlan_tag_present(skb))
return false;
- if (!skb_vlan_tag_present(skb))
- return false;
- if (skb->vlan_proto == htons(ETH_P_8021AD)) {
- inner_tag = skb_vlan_tag_get(skb);
- inner_type = STMMAC_VLAN_INSERT;
- }
tag = skb_vlan_tag_get(skb);
@@ -4127,7 +4120,7 @@ static bool stmmac_vlan_insert(struct stmmac_priv *priv, struct sk_buff *skb,
else
p = &tx_q->dma_tx[tx_q->cur_tx];
- if (stmmac_set_desc_vlan_tag(priv, p, tag, inner_tag, inner_type))
+ if (stmmac_set_desc_vlan_tag(priv, p, tag, 0x0, 0x0))
return false;
stmmac_set_tx_owner(priv, p);
@@ -7591,11 +7584,8 @@ int stmmac_dvr_probe(struct device *device,
ndev->features |= NETIF_F_HW_VLAN_CTAG_FILTER;
ndev->features |= NETIF_F_HW_VLAN_STAG_FILTER;
}
- if (priv->dma_cap.vlins) {
+ if (priv->dma_cap.vlins)
ndev->features |= NETIF_F_HW_VLAN_CTAG_TX;
- if (priv->dma_cap.dvlan)
- ndev->features |= NETIF_F_HW_VLAN_STAG_TX;
- }
#endif
priv->msg_enable = netif_msg_init(debug, default_msg_level);
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_vlan.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_vlan.c
index 0b6f6228ae35db3d855d8d386c3806a007a9d176..ff02a79c00d4f52a458edde1bcc08a0895b2c1c1 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_vlan.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_vlan.c
@@ -212,7 +212,7 @@ static void vlan_enable(struct mac_device_info *hw, u32 type)
value = readl(ioaddr + VLAN_INCL);
value |= VLAN_VLTI;
- value |= VLAN_CSVL; /* Only use SVLAN */
+ value &= ~VLAN_CSVL; /* Only use CVLAN */
value &= ~VLAN_VLC;
value |= (type << VLAN_VLC_SHIFT) & VLAN_VLC;
writel(value, ioaddr + VLAN_INCL);
--
2.43.7
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH net v4 2/3] net: stmmac: Consider Tx VLAN offload tag length for maxSDU
2025-10-28 3:18 [PATCH net v4 0/3] net: stmmac: Fixes for stmmac Tx VLAN insert and EST Rohan G Thomas via B4 Relay
2025-10-28 3:18 ` [PATCH net v4 1/3] net: stmmac: vlan: Disable 802.1AD tag insertion offload Rohan G Thomas via B4 Relay
@ 2025-10-28 3:18 ` Rohan G Thomas via B4 Relay
2025-10-28 3:18 ` [PATCH net v4 3/3] net: stmmac: est: Fix GCL bounds checks Rohan G Thomas via B4 Relay
2025-10-30 2:00 ` [PATCH net v4 0/3] net: stmmac: Fixes for stmmac Tx VLAN insert and EST patchwork-bot+netdevbpf
3 siblings, 0 replies; 5+ messages in thread
From: Rohan G Thomas via B4 Relay @ 2025-10-28 3:18 UTC (permalink / raw)
To: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Maxime Coquelin, Alexandre Torgue, Jose Abreu,
Rohan G Thomas, Boon Khai Ng
Cc: netdev, linux-stm32, linux-arm-kernel, linux-kernel,
Rohan G Thomas, Matthew Gerlach
From: Rohan G Thomas <rohan.g.thomas@altera.com>
Queue maxSDU requirement of 802.1 Qbv standard requires mac to drop
packets that exceeds maxSDU length and maxSDU doesn't include
preamble, destination and source address, or FCS but includes
ethernet type and VLAN header.
On hardware with Tx VLAN offload enabled, VLAN header length is not
included in the skb->len, when Tx VLAN offload is requested. This
leads to incorrect length checks and allows transmission of
oversized packets. Add the VLAN_HLEN to the skb->len before checking
the Qbv maxSDU if Tx VLAN offload is requested for the packet.
Fixes: c5c3e1bfc9e0 ("net: stmmac: Offload queueMaxSDU from tc-taprio")
Signed-off-by: Rohan G Thomas <rohan.g.thomas@altera.com>
Reviewed-by: Matthew Gerlach <matthew.gerlach@altera.com>
---
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 14 ++++++++++----
1 file changed, 10 insertions(+), 4 deletions(-)
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index 0e2dc0a464d5516b8aabe2f9afc60c6e37f0209e..042c823bbced88070fa26003c6b513257c0f2bb6 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -4518,6 +4518,7 @@ static netdev_tx_t stmmac_xmit(struct sk_buff *skb, struct net_device *dev)
bool has_vlan, set_ic;
int entry, first_tx;
dma_addr_t des;
+ u32 sdu_len;
tx_q = &priv->dma_conf.tx_queue[queue];
txq_stats = &priv->xstats.txq_stats[queue];
@@ -4536,10 +4537,15 @@ static netdev_tx_t stmmac_xmit(struct sk_buff *skb, struct net_device *dev)
}
if (priv->est && priv->est->enable &&
- priv->est->max_sdu[queue] &&
- skb->len > priv->est->max_sdu[queue]){
- priv->xstats.max_sdu_txq_drop[queue]++;
- goto max_sdu_err;
+ priv->est->max_sdu[queue]) {
+ sdu_len = skb->len;
+ /* Add VLAN tag length if VLAN tag insertion offload is requested */
+ if (priv->dma_cap.vlins && skb_vlan_tag_present(skb))
+ sdu_len += VLAN_HLEN;
+ if (sdu_len > priv->est->max_sdu[queue]) {
+ priv->xstats.max_sdu_txq_drop[queue]++;
+ goto max_sdu_err;
+ }
}
if (unlikely(stmmac_tx_avail(priv, queue) < nfrags + 1)) {
--
2.43.7
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH net v4 3/3] net: stmmac: est: Fix GCL bounds checks
2025-10-28 3:18 [PATCH net v4 0/3] net: stmmac: Fixes for stmmac Tx VLAN insert and EST Rohan G Thomas via B4 Relay
2025-10-28 3:18 ` [PATCH net v4 1/3] net: stmmac: vlan: Disable 802.1AD tag insertion offload Rohan G Thomas via B4 Relay
2025-10-28 3:18 ` [PATCH net v4 2/3] net: stmmac: Consider Tx VLAN offload tag length for maxSDU Rohan G Thomas via B4 Relay
@ 2025-10-28 3:18 ` Rohan G Thomas via B4 Relay
2025-10-30 2:00 ` [PATCH net v4 0/3] net: stmmac: Fixes for stmmac Tx VLAN insert and EST patchwork-bot+netdevbpf
3 siblings, 0 replies; 5+ messages in thread
From: Rohan G Thomas via B4 Relay @ 2025-10-28 3:18 UTC (permalink / raw)
To: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Maxime Coquelin, Alexandre Torgue, Jose Abreu,
Rohan G Thomas, Boon Khai Ng
Cc: netdev, linux-stm32, linux-arm-kernel, linux-kernel,
Rohan G Thomas, Matthew Gerlach
From: Rohan G Thomas <rohan.g.thomas@altera.com>
Fix the bounds checks for the hw supported maximum GCL entry
count and gate interval time.
Fixes: b60189e0392f ("net: stmmac: Integrate EST with TAPRIO scheduler API")
Signed-off-by: Rohan G Thomas <rohan.g.thomas@altera.com>
Reviewed-by: Matthew Gerlach <matthew.gerlach@altera.com>
---
drivers/net/ethernet/stmicro/stmmac/stmmac_tc.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_tc.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_tc.c
index ef65cf511f3e25eb512187d52775bb363bb83902..d786527185999db6bb6a18a29eee5ff5282b8ef4 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_tc.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_tc.c
@@ -981,7 +981,7 @@ static int tc_taprio_configure(struct stmmac_priv *priv,
if (qopt->cmd == TAPRIO_CMD_DESTROY)
goto disable;
- if (qopt->num_entries >= dep)
+ if (qopt->num_entries > dep)
return -EINVAL;
if (!qopt->cycle_time)
return -ERANGE;
@@ -1012,7 +1012,7 @@ static int tc_taprio_configure(struct stmmac_priv *priv,
s64 delta_ns = qopt->entries[i].interval;
u32 gates = qopt->entries[i].gate_mask;
- if (delta_ns > GENMASK(wid, 0))
+ if (delta_ns > GENMASK(wid - 1, 0))
return -ERANGE;
if (gates > GENMASK(31 - wid, 0))
return -ERANGE;
--
2.43.7
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH net v4 0/3] net: stmmac: Fixes for stmmac Tx VLAN insert and EST
2025-10-28 3:18 [PATCH net v4 0/3] net: stmmac: Fixes for stmmac Tx VLAN insert and EST Rohan G Thomas via B4 Relay
` (2 preceding siblings ...)
2025-10-28 3:18 ` [PATCH net v4 3/3] net: stmmac: est: Fix GCL bounds checks Rohan G Thomas via B4 Relay
@ 2025-10-30 2:00 ` patchwork-bot+netdevbpf
3 siblings, 0 replies; 5+ messages in thread
From: patchwork-bot+netdevbpf @ 2025-10-30 2:00 UTC (permalink / raw)
To: G, Thomas, Rohan
Cc: andrew+netdev, davem, edumazet, kuba, pabeni, mcoquelin.stm32,
alexandre.torgue, Jose.Abreu, rohan.g.thomas, boon.khai.ng,
netdev, linux-stm32, linux-arm-kernel, linux-kernel,
matthew.gerlach
Hello:
This series was applied to netdev/net.git (main)
by Jakub Kicinski <kuba@kernel.org>:
On Tue, 28 Oct 2025 11:18:42 +0800 you wrote:
> This patchset includes following fixes for stmmac Tx VLAN insert and
> EST implementations:
> 1. Disable STAG insertion offloading, as DWMAC IPs doesn't support
> offload of STAG for double VLAN packets and CTAG for single VLAN
> packets when using the same register configuration. The current
> configuration in the driver is undocumented and is adding an
> additional 802.1Q tag with VLAN ID 0 for double VLAN packets.
> 2. Consider Tx VLAN offload tag length for maxSDU estimation.
> 3. Fix GCL bounds check
>
> [...]
Here is the summary with links:
- [net,v4,1/3] net: stmmac: vlan: Disable 802.1AD tag insertion offload
https://git.kernel.org/netdev/net/c/c657f86106c8
- [net,v4,2/3] net: stmmac: Consider Tx VLAN offload tag length for maxSDU
https://git.kernel.org/netdev/net/c/ded9813d17d3
- [net,v4,3/3] net: stmmac: est: Fix GCL bounds checks
https://git.kernel.org/netdev/net/c/48b2e323c018
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2025-10-30 2:00 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-10-28 3:18 [PATCH net v4 0/3] net: stmmac: Fixes for stmmac Tx VLAN insert and EST Rohan G Thomas via B4 Relay
2025-10-28 3:18 ` [PATCH net v4 1/3] net: stmmac: vlan: Disable 802.1AD tag insertion offload Rohan G Thomas via B4 Relay
2025-10-28 3:18 ` [PATCH net v4 2/3] net: stmmac: Consider Tx VLAN offload tag length for maxSDU Rohan G Thomas via B4 Relay
2025-10-28 3:18 ` [PATCH net v4 3/3] net: stmmac: est: Fix GCL bounds checks Rohan G Thomas via B4 Relay
2025-10-30 2:00 ` [PATCH net v4 0/3] net: stmmac: Fixes for stmmac Tx VLAN insert and EST patchwork-bot+netdevbpf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).