Re: [PATCH net 2/3] net: enetc: reserve VLAN extension BDs for software TSO

From: netdev-bot+sashiko

Date: Sun Nov 15 2026 - 19:21:51 EST


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

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

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).

- [High] enetc_features_check()
(drivers/net/ethernet/freescale/enetc/enetc.c:1128) decides whether…

Pre-existing issues:
- [High] This problem wasn't introduced by this patch, but the patch
changes the threshold of the affected check.

--

net: enetc: reserve VLAN extension BDs for software TSO

This adds enetc_tso_count_descs(), which counts one extra extension BD per
segment when the skb carries a VLAN tag. The new helper replaces
tso_count_descs() in both enetc_start_xmit() and enetc_features_check(),
so a VLAN TSO skb can no longer overrun next_to_clean on a nearly full
TX ring.

> diff --git a/drivers/net/ethernet/freescale/enetc/enetc.c b/drivers/net/ethernet/freescale/enetc/enetc.c
> index 1606ac57016f3..7f089a84d9a65 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;
> +}
> +

[ ... ]

> @@ -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;
> }

[Severity: High]
This is a pre-existing issue and was not introduced by this patch, but
the patch changes the threshold of this check. Can the stop here race
with enetc_clean_tx_ring() and lose a wakeup?

enetc_start_xmit() reads next_to_clean through enetc_bd_unused(), then
calls netif_stop_subqueue() and returns NETDEV_TX_BUSY. There is no
smp_mb() and no second check after stopping.

The completion side has no barrier either, and NAPI does not take the TX
lock:

drivers/net/ethernet/freescale/enetc/enetc.c:enetc_clean_tx_ring() {
...
tx_ring->next_to_clean = i;
...
if (unlikely(tx_frm_cnt && netif_carrier_ok(ndev) &&
__netif_subqueue_stopped(ndev, tx_ring->index) &&
...
netif_wake_subqueue(ndev, tx_ring->index);
}

Consider this interleaving:

CPU0 (enetc_start_xmit) CPU1 (enetc_clean_tx_ring)
reads old next_to_clean,
not enough room
completes the last frames
writes next_to_clean
queue not stopped, skips wake
netif_stop_subqueue()
return NETDEV_TX_BUSY

Once that happens, no frames are in flight, so no further TX interrupt or
NAPI clean runs. enetc also has no ndo_tx_timeout, so the subqueue looks
like it stays stopped. On arm64, store->load reordering makes the window
wider.

Software TSO takes this BUSY path often, because the wake threshold
ENETC_TXBDS_MAX_NEEDED is much lower than enetc_tso_count_descs(). For
VLAN-tagged TSO skbs, this patch adds gso_segs BDs to the requirement, so
the path runs even more often.

Would the netif_txq_maybe_stop() / netif_txq_completed_wake() helpers
from include/net/netdev_queues.h fix this? An open-coded stop + smp_mb()
+ recheck, with a matching barrier on the completion side, would also
work.

[ ... ]

> @@ -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;

[Severity: High]
Does this guard still work for SKB_GSO_DODGY skbs? For those skbs,
skb_shinfo(skb)->gso_segs is still 0 when ndo_features_check runs.

Both parts of enetc_tso_count_descs() depend only on gso_segs: the
tso_count_descs() estimate and the new VLAN extension BD term. With
gso_segs == 0 the function returns just nr_frags. That is below
tx_bd_count, so GSO is not cleared.

Two paths appear to reach the driver this way. The first is AF_PACKET
with PACKET_QDISC_BYPASS and PACKET_VNET_HDR:

packet_xmit()
dev_direct_xmit()
__dev_direct_xmit()
validate_xmit_skb_list()

Here __virtio_net_hdr_to_skb() sets SKB_GSO_DODGY and gso_segs = 0, and
accepts a TCP gso_size as small as TCP_MIN_GSO_SIZE (8).
qdisc_pkt_len_segs_init() never runs on this path.

The second is a tc egress BPF program that calls bpf_skb_adjust_room().
bpf_skb_net_grow() and bpf_skb_net_shrink() set DODGY and gso_segs = 0
inside sch_handle_egress(). That runs after qdisc_pkt_len_segs_init() in
__dev_queue_xmit().

In both cases gso_within_dev_limits() also sees gso_segs == 0 and lets
the skb through. enetc does not advertise NETIF_F_GSO_ROBUST, so
validate_xmit_skb() calls __skb_gso_segment(). There, tcp_gso_segment()
only sets gso_segs = DIV_ROUND_UP(len, mss) and returns NULL, and the
unsegmented super-skb goes to enetc_start_xmit().

On the software TSO path, the check in enetc_start_xmit() now sees the
real count. For a 64KB skb with an mss of 8, that is about 16000 BDs.
enetc_bd_unused() returns at most bd_count - 1, so this check can never
pass:

if (enetc_bd_unused(tx_ring) < enetc_tso_count_descs(skb)) {
netif_stop_subqueue(ndev, tx_ring->index);
return NETDEV_TX_BUSY;
}

If the ring is empty, nothing wakes the queue again.
enetc_clean_tx_ring() only wakes it when tx_frm_cnt != 0, and there is
no ndo_tx_timeout.

On the direct xmit path, the skb is freed but the queue stays stopped. On
the tc egress path, the skb is requeued at the head of the qdisc forever.

Earlier in this series, "net: enetc: let core segment GSO super-skb when
TSO would not fit the TX ring" targets exactly this "never fits, queue
stalls" problem. This patch extends the same gso_segs-based estimate to
the VLAN extension BDs, so the new term has the same gap.

The later commit "net: enetc: let core segment GSO super-skb when headers
exceed TSO_HEADER_SIZE" only adds a header length check before this one.
So the gap still seems to be there at the end of the series.

Could the estimate in enetc_features_check() be computed from skb->len,
the header length and gso_size, instead of from gso_segs?

>
> return features;

--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261111233149.479596-1-vladimir.oltean%40nxp.com