mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: netdev-bot+sashiko@kernel.org
To: vladimir.oltean@nxp.com
Cc: netdev@vger.kernel.org, zefir.kurtisi@westermo.com,
	claudiu.manoil@nxp.com, wei.fang@nxp.com, xiaoning.wang@nxp.com,
	andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@google.com,
	kuba@kernel.org, pabeni@redhat.com, ast@kernel.org,
	daniel@iogearbox.net, hawk@kernel.org, john.fastabend@gmail.com,
	sdf@fomichev.me, horms@kernel.org, richardcochran@gmail.com,
	yangbo.lu@nxp.com, ioana.ciornei@nxp.com, imx@lists.linux.dev,
	linux-kernel@vger.kernel.org, bpf@vger.kernel.org
Subject: Re: [PATCH v3 net 5/7] net: enetc: pad short XDP frames coming from devmap
Date: Wed, 16 Sep 2026 23:35:57 +0000	[thread overview]
Message-ID: <178960175738.22033.7342785947465842406@kernel.org> (raw)
In-Reply-To: <20260915222735.1016937-6-vladimir.oltean@nxp.com>

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

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

- [Medium] In enetc_xdp_xmit()
  (drivers/net/ethernet/freescale/enetc/enetc.c), the newly added short-…

--

net: enetc: pad short XDP frames coming from devmap

This adds a generic best-effort xdp_frame_pad() helper and calls it from
enetc_xdp_xmit(), together with a direct check of the head buffer length
against ENETC_MIN_BUFF_SIZE, so that short XDP frames redirected into
ENETC are padded or dropped instead of being transmitted.

> diff --git a/drivers/net/ethernet/freescale/enetc/enetc.c b/drivers/net/ethernet/freescale/enetc/enetc.c
> index bbad942041f5a..8a9ba168eab1e 100644
> --- a/drivers/net/ethernet/freescale/enetc/enetc.c
> +++ b/drivers/net/ethernet/freescale/enetc/enetc.c
> @@ -1838,15 +1838,23 @@ int enetc_xdp_xmit(struct net_device *ndev, int num_frames,
>  	prefetchw(ENETC_TXBD(*tx_ring, tx_ring->next_to_use));
>  
>  	for (k = 0; k < num_frames; k++) {
> -		if (xdp_frame_has_frags(frames[k])) {
> -			shinfo = xdp_get_shared_info_from_frame(frames[k]);
> +		struct xdp_frame *xdpf = frames[k];
> +
> +		if (xdp_frame_has_frags(xdpf)) {
> +			shinfo = xdp_get_shared_info_from_frame(xdpf);
>  			if (unlikely((shinfo->nr_frags + 1) > ENETC_MAX_SKB_FRAGS))
>  				break;
>  		}
>  
> +		if (unlikely(xdp_frame_pad(xdpf) ||
> +			     xdpf->len < ENETC_MIN_BUFF_SIZE)) {
> +			tx_ring->stats.xdp_tx_drops++;
> +			break;
> +		}

[Severity: Medium]
Does this count the rejected frame twice in tx_ring->stats.xdp_tx_drops?

The new branch increments the counter and then breaks with k still pointing
at the frame that was just rejected, and the epilogue of enetc_xdp_xmit()
charges everything from k onwards again:

	tx_ring->stats.xdp_tx += k;
	tx_ring->stats.xdp_tx_drops += num_frames - k;

so the counter grows by 1 + (num_frames - k) rather than num_frames - k.

The other three break sites in this loop (the shinfo->nr_frags overflow
check, the enetc_xdp_frame_to_xdp_tx_swbd() failure and the enetc_xdp_tx()
failure) rely only on the remainder-based accounting added earlier in this
series by "net: enetc: consistenly track dropped frames in
enetc_xdp_xmit()", whose message states that the counter should be
incremented "by the remainder, not just by 1".

Would dropping the explicit increment here keep this site consistent with
the other break paths?

The branch is reachable when xdp_frame_pad() returns -EOPNOTSUPP (frame
shorter than ETH_ZLEN and fragmented) or -ENOMEM (no tailroom before the
shared info), and also when the frame total is at least ETH_ZLEN but the
head buffer is shorter than ENETC_MIN_BUFF_SIZE, which is the
XDP_REDIRECT-from-veth case described in the commit message.

Since xdp_tx_drops is exported to userspace by enetc_get_ethtool_stats()
via ethtool -S, can the reported drop count end up larger than the number
of frames the core passed to ndo_xdp_xmit()?

> +
>  		xdp_tx_bd_cnt = enetc_xdp_frame_to_xdp_tx_swbd(tx_ring,
>  							       xdp_redirect_arr,
> -							       frames[k]);
> +							       xdpf);
>  		if (unlikely(xdp_tx_bd_cnt < 0))
>  			break;
>  

[ ... ]

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

  reply	other threads:[~2026-09-16 23:35 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-15 22:27 [PATCH v3 net 0/7] Fix short frame transmission in enetc vladimir.oltean
2026-09-15 22:27 ` [PATCH v3 net 1/7] net: enetc: consistenly track dropped frames in enetc_xdp_xmit() vladimir.oltean
2026-09-16  2:16   ` Wei Fang
2026-09-16 23:35   ` netdev-bot+sashiko
2026-09-15 22:27 ` [PATCH v3 net 2/7] net: enetc: ensure enetc_xdp_xmit() calls enetc_update_tx_ring_tail() vladimir.oltean
2026-09-16  2:20   ` Wei Fang
2026-09-16 23:35   ` netdev-bot+sashiko
2026-09-15 22:27 ` [PATCH v3 net 3/7] net: enetc: fix bogus TX ring consumer index after reinitialization vladimir.oltean
2026-09-15 22:27 ` [PATCH v3 net 4/7] net: enetc: pad short frames in software vladimir.oltean
2026-09-16 23:35   ` netdev-bot+sashiko
2026-09-17 10:11   ` David Laight
2026-09-15 22:27 ` [PATCH v3 net 5/7] net: enetc: pad short XDP frames coming from devmap vladimir.oltean
2026-09-16 23:35   ` netdev-bot+sashiko [this message]
2026-09-15 22:27 ` [PATCH v3 net 6/7] net: enetc: linearize PTP event packets with one-step TX timestamping vladimir.oltean
2026-09-16  1:59   ` Wei Fang
2026-09-16  9:50     ` Vladimir Oltean
2026-09-16 23:35   ` netdev-bot+sashiko
2026-09-15 22:27 ` [PATCH v3 net 7/7] net: enetc: drain and cancel one-step TX tstamp queue when going down vladimir.oltean
2026-09-16 23:36   ` netdev-bot+sashiko

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=178960175738.22033.7342785947465842406@kernel.org \
    --to=netdev-bot+sashiko@kernel.org \
    --cc=andrew+netdev@lunn.ch \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=claudiu.manoil@nxp.com \
    --cc=daniel@iogearbox.net \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=hawk@kernel.org \
    --cc=horms@kernel.org \
    --cc=imx@lists.linux.dev \
    --cc=ioana.ciornei@nxp.com \
    --cc=john.fastabend@gmail.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=richardcochran@gmail.com \
    --cc=sdf@fomichev.me \
    --cc=vladimir.oltean@nxp.com \
    --cc=wei.fang@nxp.com \
    --cc=xiaoning.wang@nxp.com \
    --cc=yangbo.lu@nxp.com \
    --cc=zefir.kurtisi@westermo.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®