Linux-ARM-Kernel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: netdev-bot+sashiko@kernel.org
To: suraj.gupta2@amd.com
Cc: radhey.shyam.pandey@amd.com, andrew+netdev@lunn.ch,
	davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org,
	pabeni@redhat.com, robh@kernel.org, krzk+dt@kernel.org,
	conor+dt@kernel.org, michal.simek@amd.com, linux@armlinux.org.uk,
	netdev@vger.kernel.org, devicetree@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH net-next v5 4/6] net: xilinx: axienet: Add 10G/25G (XXV) ethernet support
Date: Mon, 16 Nov 2026 04:12:30 +0000	[thread overview]
Message-ID: <179480235080.3136.8103502035761762075@kernel.org> (raw)
In-Reply-To: <20261114182947.2908628-5-suraj.gupta2@amd.com>

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

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

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] XXV receive is routed through the shared dmaengine RX callback,
  axienet_dma_rx_cb()…
- [Medium] axienet_mac_select_pcs() is shared by all MAC types.
- [Medium] PG210's XXV MAC flags bad-FCS, oversize/length-error and
  truncated frames only through rx_axis_tuser at end of packet, and…
- [Low] axienet_xxv_get_regs() reads every STAT_* status register on each
  'ethtool -d'.
- [Low] axienet_ethtools_get_regs() always sets regs->version = 0 and
  regs->len = sizeof(u32) * regs_n, then dispatches to…
- [Low] The patch builds xilinx_axienet_xxv.o into xilinx_emac under
  CONFIG_XILINX_AXI_EMAC, adding 10G/25G XXV support to that option, but…
- [Low] In axienet_open(), axienet_device_reset() runs first.

--

net: xilinx: axienet: Add 10G/25G (XXV) ethernet support

This commit adds support for the Xilinx XXV 10G/25G Ethernet MAC to the
axienet driver. The XXV-specific code goes into new xilinx_axienet_xxv.c/.h
files and is described by an axienet_10g25g_config. The shared paths use
the callbacks from that config, and axienet_mac_select_pcs() now also
handles 10GBASER and 25GBASER.

> diff --git a/drivers/net/ethernet/xilinx/Makefile b/drivers/net/ethernet/xilinx/Makefile
> index 7d7dc1771423e..db90e691fec58 100644
> --- a/drivers/net/ethernet/xilinx/Makefile
> +++ b/drivers/net/ethernet/xilinx/Makefile
> @@ -6,5 +6,6 @@
>  ll_temac-objs := ll_temac_main.o ll_temac_mdio.o
>  obj-$(CONFIG_XILINX_LL_TEMAC) += ll_temac.o
>  obj-$(CONFIG_XILINX_EMACLITE) += xilinx_emaclite.o
> -xilinx_emac-objs := xilinx_axienet_main.o xilinx_axienet_mdio.o
> +xilinx_emac-objs := xilinx_axienet_main.o xilinx_axienet_mdio.o \
> +		    xilinx_axienet_xxv.o
>  obj-$(CONFIG_XILINX_AXI_EMAC) += xilinx_emac.o

[Severity: Low]
This isn't a bug, but should the XILINX_AXI_EMAC Kconfig entry be updated
too? XXV support now builds under this option, but the prompt still reads:

    tristate "Xilinx 10/100/1000 AXI Ethernet support"

The help text also still says "This driver supports the 10/100/1000
Ethernet from Xilinx...". It is unchanged at the end of the series, so
nothing points someone configuring an XXV-based board at this option.

> diff --git a/drivers/net/ethernet/xilinx/xilinx_axienet_main.c b/drivers/net/ethernet/xilinx/xilinx_axienet_main.c
> index a553150faa89b..47c84014921c8 100644
> --- a/drivers/net/ethernet/xilinx/xilinx_axienet_main.c
> +++ b/drivers/net/ethernet/xilinx/xilinx_axienet_main.c
> @@ -801,6 +801,12 @@ static int axienet_1g_mac_init(struct net_device *ndev)
>   * Ethernet core. No separate hardware reset is done for the Axi Ethernet
>   * core.
>   *
> + * It also recomputes @max_frm_size from the current MTU and runs the
> + * MAC-specific mac_init() callback, so it is the point at which length-related
> + * MAC configuration (such as the XXV RX max-packet-length) is reprogrammed.
> + * Because it is reached from the open path, a new MTU takes effect on the next
> + * interface up.
> + *
>   * Return: 0 on success or a negative error number otherwise.
>   */
>  static int axienet_device_reset(struct net_device *ndev)

[Severity: Low]
Is the ordering in axienet_open() safe for XXV? The XXV receiver is
enabled before any RX DMA buffer is posted:

axienet_open()
    axienet_device_reset()
        axienet_setoptions(ndev, lp->options)   <- sets XXV_RCW1_RX_MASK
    phylink_start()
    axienet_init_dmaengine()                    <- RX channel and buffers

PG210 describes the XXV RX AXI4-Stream as having no tready backpressure.
If a frame arrives before the S2MM channel accepts data, could the first
RX buffer capture only the tail of that frame (ending at tlast) and pass
it up as a frame?

On the 1G core, its internal RX FIFO made this ordering safe. With XXV it
depends on the FPGA logic between the MAC and the DMA.

[ ... ]

> @@ -2788,7 +2789,9 @@ static struct phylink_pcs *axienet_mac_select_pcs(struct phylink_config *config,
>  	struct axienet_local *lp = netdev_priv(ndev);
>  
>  	if (interface == PHY_INTERFACE_MODE_1000BASEX ||
> -	    interface ==  PHY_INTERFACE_MODE_SGMII)
> +	    interface == PHY_INTERFACE_MODE_SGMII ||
> +	    interface == PHY_INTERFACE_MODE_10GBASER ||
> +	    interface == PHY_INTERFACE_MODE_25GBASER)
>  		return &lp->pcs;
>  
>  	return NULL;

[Severity: Medium]
Can this hand phylink a PCS with NULL ops on a 1G MAC?

axienet_mac_select_pcs() is shared by all MAC types. On the 1G config,
axienet_probe() sets lp->pcs.ops only for SGMII/1000BASEX, and
axienet_1g_config has no internal_pcs.

axienet_1g_phylink_set_caps() still does this for any phy_mode:

    __set_bit(lp->phy_mode, config->supported_interfaces);

So a 1G compatible node with phy-mode = "10gbase-r" or "25gbase-r" is not
rejected at probe.

With fixed-link, probe still succeeds. phylink_validate() prints
"uninitialised PCS" with a dump_stack() and returns -EINVAL, but both
phylink_create() and phylink_parse_fixedlink() ignore that result. Then
on ifup:

axienet_open()
    phylink_start()
        phylink_major_config()
            pl->pcs = &lp->pcs;
            phylink_pcs_pre_config(pl->pcs, ...)
                if (pcs && pcs->ops->pcs_pre_config)   <- pcs->ops is NULL

Before this patch, these modes returned NULL here. Should &lp->pcs only be
returned when lp->pcs.ops is set?

[ ... ]

> diff --git a/drivers/net/ethernet/xilinx/xilinx_axienet_xxv.c b/drivers/net/ethernet/xilinx/xilinx_axienet_xxv.c
> new file mode 100644
> index 0000000000000..3c204dbbf6aec
> --- /dev/null
> +++ b/drivers/net/ethernet/xilinx/xilinx_axienet_xxv.c
> @@ -0,0 +1,351 @@

[ ... ]

> +static int axienet_xxv_mac_init(struct net_device *ndev)
> +{
> +	struct axienet_local *lp = netdev_priv(ndev);
> +	int ret;
> +
> +	ret = axienet_xxv_poll_link_ready(ndev);
> +	if (ret)
> +		return ret;
> +
> +	/* Bound the MAC's RX max packet length to the posted buffer size so an
> +	 * oversized frame is truncated to a single buffer instead of spilling
> +	 * across several DMA descriptors (PG210 CONFIGURATION_RX_MTU).
> +	 */
> +	axienet_iow(lp, XXV_JUM_OFFSET,
> +		    FIELD_PREP(XXV_RX_MAX_LEN_MASK, lp->max_frm_size) |
> +		    XXV_RX_MIN_LEN_DEFAULT);

[Severity: High]
Where does XXV get the RX frame length from? axienet_10g25g_config does
not set non_dmaengine, so every XXV RX completion goes through the shared
dmaengine callback:

drivers/net/ethernet/xilinx/xilinx_axienet_main.c:axienet_dma_rx_cb() {
    ...
	if (IS_ERR(app_metadata)) {
		if (net_ratelimit())
			netdev_err(lp->ndev, "Failed to get RX metadata pointer\n");
		dev_kfree_skb_any(skb);
		lp->ndev->stats.rx_dropped++;
		goto rx_submit;
	}

	/* TODO: Derive app word index programmatically */
	rx_len = (app_metadata[LEN_APP] & 0xFFFF);
	skb_put(skb, rx_len);
    ...
}

app_metadata[LEN_APP] is APP4. Only the 1G AXI Ethernet IP fills that
word, through its RX status stream. The PG210 MAC has no status stream,
and nothing in the XXV config or binding provides one.

In xilinx_dma.c, software never writes the S2MM app words: hw->app is
copied only for DMA_MEM_TO_DEV, and segments are zeroed. For MCDMA, which
the XXV binding example uses, xilinx_dma_get_metadata_ptr() returns
&seg->hw.s2mm_status for DEV_TO_MEM, so index 4 lands on app[2] and not
on a length field.

What happens then depends on the DMA setup:

- Without xlnx,axistream-connected on the DMA, no metadata_ops are
  attached. Every frame is dropped with "Failed to get RX metadata
  pointer".

- With it, rx_len comes from a zeroed or unrelated word. Each frame
  becomes a zero-length skb and rx_bytes stays at 0.

- If that word ever holds a stale non-zero value, rx_len is not checked
  against lp->max_frm_size. Anything above the skb tailroom (up to
  0xFFFF) reaches skb_put() and hits skb_over_panic().

The DMA does report the real transfer count, via
xilinx_dma_get_residue() into result->residue, but the callback ignores
it.

The comment above says CONFIGURATION_RX_MTU keeps frames within one
buffer. However, the length passed to skb_put() never comes from the MAC.

The last patch in the series ("net: xilinx: axienet: Add statistics
support for XXV ethernet") does not change axienet_dma_rx_cb() either.
Does XXV receive work on any of the documented DMA configurations?

> +
> +	lp->options |= XAE_OPTION_FCS_STRIP;
> +	lp->options |= XAE_OPTION_FCS_INSERT;
> +
> +	return 0;
> +}

[Severity: Medium]
How are errored frames dropped on XXV? Per PG210, the XXV MAC reports
bad-FCS, length-error and truncated frames only through rx_axis_tuser at
end of packet. It still forwards those frames on the stream.

AXI DMA S2MM does not record tuser. axienet_dma_rx_cb() also checks no
per-frame error status before it calls __netif_rx().

With XAE_OPTION_FCS_STRIP set here, the FCS is gone before software
could check it. The oversized frames that ctl_rx_max_packet_len
truncates, per the comment above, would also go up as valid packets.

The 1G core drops errored frames in its own RX FIFO and raises
XAE_INT_RXRJECT, so the shared datapath never needed this check.

Does the FPGA design need a tuser-aware drop stage between the MAC and
the DMA? If so, should that be documented or detected?

[ ... ]

> +static void axienet_xxv_get_regs(struct axienet_local *lp, u32 *data)
> +{
> +	bool has_gt_status = axienet_xxv_ip_has_gt_status(lp->xxv_ip_version);
> +	unsigned int i;
> +
> +	for (i = 0; i < ARRAY_SIZE(axienet_xxv_reg_dump_offsets); i++) {
> +		u32 off = axienet_xxv_reg_dump_offsets[i];
> +
> +		/* The GT registers only exist on the IP versions that report
> +		 * reset-done. Leave their slots zero on the others so the
> +		 * dump keeps a fixed layout.
> +		 */
> +		if (!has_gt_status && (off == XXV_GT_CTRL_OFFSET ||
> +				       off == XXV_STAT_GT_OFFSET))
> +			continue;
> +
> +		data[i] = axienet_ior(lp, off);

[Severity: Low]
Can an ethtool -d dump interfere with link reporting? This reads every
STAT_* register, including XXV_STAT_RX_STATUS_OFFSET. PG210 describes
that register's bit 0 as latched and cleared on read.
axienet_xxv_pcs_get_state() uses the same bit for the link:

	state->link = axienet_ior(lp, XXV_STAT_RX_STATUS_OFFSET) &
		      XXV_STAT_RX_STATUS_MASK;

lp->pcs.poll is true for internal_pcs. A dump taken between two phylink
polls could therefore clear a latched link-down event, and phylink would
never see the flap. STAT_RX_BLOCK_LOCK, STAT_TX_STATUS and the AN/LT/FEC
status registers are read the same way.

The skip logic is also uneven. GT_CTRL/STAT_GT are skipped on IP older
than v3.2. But STAT_CORE_SPEED is read unconditionally, and the commit
message says it exists only on 64-bit AXI4-Stream builds. The same goes
for the build-optional RS-FEC/AN/LT/1588 registers.

> +	}
> +}

[Severity: Low]
Should the dump version tell the two layouts apart? The caller reports
version 0 for every MAC type:

drivers/net/ethernet/xilinx/xilinx_axienet_main.c:axienet_ethtools_get_regs() {
    ...
	len = sizeof(u32) * lp->axienet_config->regs_n;
	regs->version = 0;
	regs->len = len;
    ...
}

After this patch, the driver produces both the 1G layout (AXIENET_REGS_N
words with the DMA registers at fixed indices) and this 46-word PG210
layout, both under version 0. That leaves userspace decoders no way to
tell which format they have.

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261114182947.2908628-1-suraj.gupta2%40amd.com


  reply	other threads:[~2026-11-16  4:12 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-14 18:29 [PATCH net-next v5 0/6] net: xilinx: axienet: Add 10G/25G (XXV) ethernet support Suraj Gupta
2026-11-14 18:29 ` [PATCH net-next v5 1/6] net: xilinx: axienet: Introduce axienet_config for MAC-specific ops Suraj Gupta
2026-11-16  4:12   ` netdev-bot+sashiko
2026-11-14 18:29 ` [PATCH net-next v5 2/6] dt-bindings: net: xlnx,xxv-ethernet: Add Xilinx XXV 10G/25G Ethernet Suraj Gupta
2026-11-16  4:12   ` netdev-bot+sashiko
2026-11-14 18:29 ` [PATCH net-next v5 3/6] net: xilinx: axienet: Propagate device reset failure from ndo_open Suraj Gupta
2026-11-16  4:12   ` netdev-bot+sashiko
2026-11-14 18:29 ` [PATCH net-next v5 4/6] net: xilinx: axienet: Add 10G/25G (XXV) ethernet support Suraj Gupta
2026-11-16  4:12   ` netdev-bot+sashiko [this message]
2026-11-14 18:29 ` [PATCH net-next v5 5/6] net: xilinx: axienet: Dispatch statistics through axienet_config ops Suraj Gupta
2026-11-14 18:29 ` [PATCH net-next v5 6/6] net: xilinx: axienet: Add statistics support for XXV ethernet Suraj Gupta
2026-11-16  4:12   ` 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=179480235080.3136.8103502035761762075@kernel.org \
    --to=netdev-bot+sashiko@kernel.org \
    --cc=andrew+netdev@lunn.ch \
    --cc=conor+dt@kernel.org \
    --cc=davem@davemloft.net \
    --cc=devicetree@vger.kernel.org \
    --cc=edumazet@kernel.org \
    --cc=krzk+dt@kernel.org \
    --cc=kuba@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=michal.simek@amd.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=radhey.shyam.pandey@amd.com \
    --cc=robh@kernel.org \
    --cc=suraj.gupta2@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