From: Vladimir Oltean <vladimir.oltean@nxp.com>
To: netdev@vger.kernel.org
Cc: Andrew Lunn <andrew+netdev@lunn.ch>,
"David S . Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@kernel.org>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Claudiu Manoil <claudiu.manoil@nxp.com>,
Wei Fang <wei.fang@nxp.com>, Clark Wang <xiaoning.wang@nxp.com>,
Ioana Ciornei <ioana.ciornei@nxp.com>,
Willem de Bruijn <willemdebruijn.kernel@gmail.com>,
imx@lists.linux.dev, linux-kernel@vger.kernel.org
Subject: [PATCH net 2/3] net: enetc: reserve VLAN extension BDs for software TSO
Date: Thu, 12 Nov 2026 01:31:48 +0200 [thread overview]
Message-ID: <20261111233149.479596-3-vladimir.oltean@nxp.com> (raw)
In-Reply-To: <20261111233149.479596-1-vladimir.oltean@nxp.com>
enetc_start_xmit() uses tso_count_descs() to check whether the TX ring
has enough free BDs for a software TSO frame. That estimates one header
BD and one data BD per segment, plus one BD per frag. However, when the
skb carries a VLAN tag, enetc_map_tx_tso_hdr() also adds an extension
BD to every segment, which is not accounted for.
With a highly segmented VLAN TSO skb and a nearly full ring, the driver
can then write past next_to_clean and overwrite BDs still owned by the
hardware.
Add enetc_tso_count_descs() which accounts for the extension BD of each
segment when VLAN insertion is needed.
Fixes: fb8629e2cbfc ("net: enetc: add support for software TSO")
Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
---
This comes from the previous patch set:
https://lore.kernel.org/netdev/20261021145314.1435049-2-vladimir.oltean@nxp.com/
v5->v1: also patch enetc_features_check()
v4->v5: patch is new
---
drivers/net/ethernet/freescale/enetc/enetc.c | 15 +++++++++++++--
1 file changed, 13 insertions(+), 2 deletions(-)
diff --git a/drivers/net/ethernet/freescale/enetc/enetc.c b/drivers/net/ethernet/freescale/enetc/enetc.c
index 1606ac57016f..7f089a84d9a6 100644
--- a/drivers/net/ethernet/freescale/enetc/enetc.c
+++ b/drivers/net/ethernet/freescale/enetc/enetc.c
@@ -674,6 +674,17 @@ static void enetc_tso_complete_csum(struct enetc_bdr *tx_ring, struct tso_t *tso
}
}
+static int enetc_tso_count_descs(const struct sk_buff *skb)
+{
+ int count = tso_count_descs(skb);
+
+ /* Each segment also needs an extension BD for VLAN insertion */
+ if (skb_vlan_tag_present(skb))
+ count += skb_shinfo(skb)->gso_segs;
+
+ return count;
+}
+
static int enetc_lso_count_descs(const struct sk_buff *skb)
{
/* 4 BDs: 1 BD for LSO header + 1 BD for extended BD + 1 BD
@@ -1034,7 +1045,7 @@ static netdev_tx_t enetc_start_xmit(struct sk_buff *skb,
count = enetc_lso_hw_offload(tx_ring, skb);
} else {
- if (enetc_bd_unused(tx_ring) < tso_count_descs(skb)) {
+ if (enetc_bd_unused(tx_ring) < enetc_tso_count_descs(skb)) {
netif_stop_subqueue(ndev, tx_ring->index);
return NETDEV_TX_BUSY;
}
@@ -1114,7 +1125,7 @@ netdev_features_t enetc_features_check(struct sk_buff *skb,
if (!skb_is_gso(skb) || enetc_skb_uses_lso(priv, skb))
return features;
- if (tso_count_descs(skb) >= priv->tx_bd_count)
+ if (enetc_tso_count_descs(skb) >= priv->tx_bd_count)
features &= ~NETIF_F_GSO_MASK;
return features;
--
2.53.0
next prev parent reply other threads:[~2026-11-11 23:32 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-11 23:31 [PATCH net 0/3] ENETC GSO fixes Vladimir Oltean
2026-11-11 23:31 ` [PATCH net 1/3] net: enetc: let core segment GSO super-skb when TSO would not fit the TX ring Vladimir Oltean
2026-11-11 23:31 ` Vladimir Oltean [this message]
2026-11-11 23:31 ` [PATCH net 3/3] net: enetc: let core segment GSO super-skb when headers exceed TSO_HEADER_SIZE Vladimir Oltean
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261111233149.479596-3-vladimir.oltean@nxp.com \
--to=vladimir.oltean@nxp.com \
--cc=andrew+netdev@lunn.ch \
--cc=claudiu.manoil@nxp.com \
--cc=davem@davemloft.net \
--cc=edumazet@kernel.org \
--cc=imx@lists.linux.dev \
--cc=ioana.ciornei@nxp.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=wei.fang@nxp.com \
--cc=willemdebruijn.kernel@gmail.com \
--cc=xiaoning.wang@nxp.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®