Netdev List
 help / color / mirror / Atom feed
From: netdev-bot+sashiko@kernel.org
To: srinivas.neeli@amd.com
Cc: radhey.shyam.pandey@amd.com, andrew+netdev@lunn.ch,
	davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org,
	pabeni@redhat.com, michal.simek@amd.com, horms@kernel.org,
	netdev@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org, git@amd.com
Subject: Re: [PATCH net-next v2] net: xilinx: axienet: Derive RX frame length from residue in dmaengine path
Date: Tue, 24 Nov 2026 16:46:16 +0000	[thread overview]
Message-ID: <179553877690.3135.3125454257939180385@kernel.org> (raw)
In-Reply-To: <20261123164251.48234-1-srinivas.neeli@amd.com>

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

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

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

- [Medium] The commit message says the residue-based length is "correct
  across all designs, including multi-descriptor frames".
- [Medium] The commit message says that summing the residue over the
  chain gives the correct length for multi-descriptor frames.
- [Low] This patch fixes a real, user-visible RX failure in the dmaengine
  path of axienet_dma_rx_cb()…

--

net: xilinx: axienet: Derive RX frame length from residue in dmaengine path

This commit changes axienet_dma_rx_cb() so that the dmaengine RX path
computes the received frame length as the posted buffer length minus
result->residue. Previously the length came from the APP4 descriptor
metadata word. It also detects failed transfers through
dmaengine_result.result and removes the unused LEN_APP macro.

> diff --git a/drivers/net/ethernet/xilinx/xilinx_axienet_main.c b/drivers/net/ethernet/xilinx/xilinx_axienet_main.c
> index 7e83c4b5f1931..5b4998e2ca148 100644
> --- a/drivers/net/ethernet/xilinx/xilinx_axienet_main.c
> +++ b/drivers/net/ethernet/xilinx/xilinx_axienet_main.c

[ ... ]

> @@ -1219,30 +1218,27 @@ axienet_start_xmit(struct sk_buff *skb, struct net_device *ndev)
>  static void axienet_dma_rx_cb(void *data, const struct dmaengine_result *result)
>  {

[ ... ]

> -	/* TODO: Derive app word index programmatically */
> -	rx_len = (app_metadata[LEN_APP] & 0xFFFF);
> +	/* Actual length = posted buffer length - residue. */
> +	rx_len = lp->max_frm_size - result->residue;

[Severity: Low]
This fixes a receive failure that users can see. Should it carry a Fixes:
tag and go through net rather than net-next?

The line being replaced came in with commit 6a91b846af85 ("net: axienet:
Introduce dmaengine support"). On designs without the status/control
stream, the old code had two failure modes.

If the channel has no metadata_ops, dmaengine_desc_get_metadata_ptr()
returns ERR_PTR(-ENOTSUPP) and every frame is dropped here:

	if (IS_ERR(app_metadata)) {
		...
		dev_kfree_skb_any(skb);
		lp->ndev->stats.rx_dropped++;
		goto rx_submit;
	}

Before commit 8bbceba7dc5090, that ERR_PTR was dereferenced instead.

If metadata_ops is present but the status stream is absent, the invalid
APP4 value is passed straight to skb_put().

The stable trees that carry the dmaengine RX path won't pick this up unless
it has something like:

Fixes: 6a91b846af85 ("net: axienet: Introduce dmaengine support")

>  	skb_put(skb, rx_len);
>  	skb->protocol = eth_type_trans(skb, lp->ndev);

[Severity: Medium]
The commit message says the residue-based length is "correct across all
designs, including multi-descriptor frames where the residue is summed over
the chain". Does that hold for a frame longer than one posted RX buffer?

axienet_rx_submit_desc() posts each skb as its own dmaengine descriptor
with a single sg entry:

	sg_dma_len(skbuf_dma->sgl) = lp->max_frm_size;
	dma_rx_desc = dmaengine_prep_slave_sg(lp->rx_chan, skbuf_dma->sgl,
					      1, DMA_DEV_TO_MEM,

xilinx_dma_get_residue() only sums the segments of that one descriptor:

	residue += (axidma_hw->control & chan->xdev->max_buffer_len) -
		   (axidma_hw->status & chan->xdev->max_buffer_len);

So the residue is never summed across the several descriptors that make up
one frame.

When the MTU is above 1500, axienet_device_reset() sets max_frm_size to
mtu + VLAN_ETH_HLEN + XAE_TRL_SIZE and enables XAE_OPTION_JUMBO. No maximum
receive frame length is programmed into the MAC.

If the MAC then accepts frames longer than max_frm_size, any L2 peer can
send one. For example, a double-tagged frame at MTU size is mtu + 26 bytes.
AXI DMA S2MM fills the current BD without EOF and continues into the next
BD, which belongs to the next descriptor and the next skb:

  first callback:  residue == 0, so a truncated max_frm_size frame is
                   passed to __netif_rx()
  second callback: rx_len == remainder, so eth_type_trans() parses bytes
                   from the sender's payload as a new Ethernet header

Could a remote peer use this to inject a frame with its own choice of MAC
addresses, ethertype and VLAN tag, getting past hardware MAC filtering and
VLAN separation?

If the remainder is shorter than ETH_HLEN, eth_skb_pull_mac() silently
fails and the short skb is still passed up the stack.

axienet_dma_rx_cb() never checks XAXIDMA_BD_STS_RXSOF_MASK or
XAXIDMA_BD_STS_RXEOF_MASK, and dmaengine_result does not carry them.

The missing SOF/EOF handling predates this patch. Before it, APP4 on the
EOF BD held the full frame length, so skb_put() hit skb_over_panic(). With
this change the same input instead becomes silent frame splitting.

Should buffers that don't carry both SOF and EOF be dropped? Alternatively,
could the MAC's accepted frame size be limited to max_frm_size?

[Severity: Medium]
A related case can happen inside a single descriptor. Is the summed
residue still correct when the dmaengine provider splits the single RX sg
into several BDs?

xilinx_dma_prep_slave_sg() caps each hardware BD at xdev->max_buffer_len
through xilinx_dma_calc_copysize(). max_buffer_len comes from
xlnx,sg-length-width, which can be 8 to 26 bits.

Nothing in axienet checks lp->max_frm_size against that per-BD limit. Two
examples where one descriptor ends up with several BDs:

  width 13 (8191) with MTU 9000 (max_frm_size 9022)
  width 10 (1023) with the default 1522 byte max_frm_size

AXI DMA S2MM ends a BD at TLAST and starts each packet in a new BD. The
legacy axienet_rx_poll() relies on the same behaviour.
xilinx_dma_complete_descriptor() only checks the last segment:

	if (!(seg->hw.status & XILINX_DMA_BD_COMP_MASK) && chan->has_sg)
		break;

With a frame A shorter than BD0, the sequence would be:

  frame A lands in BD0, and the descriptor stays pending
  frame B lands in BD1, which is the same skb at offset BD0-size
  BD1 completes, and the residue sum gives rx_len = len(A) + len(B)

Would axienet_dma_rx_cb() then deliver frame A followed by len(B) bytes of
stale buffer data, and lose frame B? If B is longer than BD1, it spills
into the next descriptor as described above.

The old APP4 method was also wrong here, because it reported B's length
from the last BD. However, the commit message explicitly says the
summed-residue case is handled correctly.

>  	skb->ip_summed = CHECKSUM_NONE;

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261123164251.48234-1-srinivas.neeli%40amd.com

      parent reply	other threads:[~2026-11-24 16:46 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-23 16:42 [PATCH net-next v2] net: xilinx: axienet: Derive RX frame length from residue in dmaengine path Srinivas Neeli
2026-11-24  5:39 ` Gupta, Suraj
2026-11-24 16:46 ` netdev-bot+sashiko [this message]

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=179553877690.3135.3125454257939180385@kernel.org \
    --to=netdev-bot+sashiko@kernel.org \
    --cc=andrew+netdev@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=edumazet@kernel.org \
    --cc=git@amd.com \
    --cc=horms@kernel.org \
    --cc=kuba@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=michal.simek@amd.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=radhey.shyam.pandey@amd.com \
    --cc=srinivas.neeli@amd.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