net: xilinx: axienet: Add 10G/25G (XXV) ethernet support
Subsystems (5)
v4 cover net: xilinx: axienet: Add 10G/25G (XXV) ethernet support
This patch series extends the AXI Ethernet driver to support the XXV Ethernet subsystem.
- Refactor through struct axienet_config so per-MAC behaviour is expressed as capability flags and callbacks instead of runtime MAC-type checks in the shared code.
- Document the XXV IP in Devicetree.
- Add support for the XXV Ethernet subsystem.
- Add a preparatory RMON cleanup, a statistics-ops refactor of struct axienet_config, and ethtool / ndo_get_stats64 counter reporting for XXV.
---
Notes:
- This series depends on [1], which is a pre-requisite.
That change is required for this series to compile and is not included here to avoid duplication.
- The series advertises the core's active 10G or 25G rate only. Runtime switching between 10GBASE-R and 25GBASE-R is not supported and can be added later.
[1]: https://lore.kernel.org/all/[email protected]/
Changes in v4:
- Drop the "legacy" nomenclature and use dmaengine / non-dmaengine terminology as it might confuse with MAC instead of driver flow (Andrew Lunn).
- Patch 1/6: Gate the "xlnx,txcsum" DT property behind the MAC's tx_csum capability, so TX checksum offload is not advertised for a MAC whose hardware cannot complete checksums (Sashiko bot).
- Patch 2/6: Reword the binding description to state that the PCS/PMA is integrated into the IP, and that MDIO bus unavailability and SFP module (I2C) management are detailed in the IP (Andrew Lunn).
- Patch 3/6: Reword the dma_err_handler comment from "legacy embedded-DMA (1G) path" to "non-dmaengine flow (1G MAC)" (Andrew Lunn).
- Advertise only the core's active line rate.
V3: https://lore.kernel.org/all/[email protected]/
Changes in v3:
- Dropped patch 1/7 ("clk: Add devm_clk_bulk_get_enable()"); it has been applied to mainline as commit b698927accb1.
- Patch 2/6 (dt-bindings):
* Added Reviewed-by from Rob Herring. Thanks Rob!
V2: https://lore.kernel.org/all/[email protected]/
Changes in v2:
- Patch 1/7:
* Add Reviewed-by: Brian Masney <[email protected]>. Thanks Brian!
- Patch 3/7:
* Split the XXV binding into its own schema file (xlnx,xxv-ethernet.yaml) instead of extending xlnx,axi-ethernet.yaml with if/then branches, per Rob Herring's review.
* Add a multichannel (MCDMA) example.
- Patch 4/7:
* Require both GT Wizard reset-done bits in axienet_xxv_poll_link_ready() so polling does not exit before both the TX and RX resets complete.
V1: https://lore.kernel.org/all/[email protected]/
Suraj Gupta (6):
net: xilinx: axienet: Introduce axienet_config for MAC-specific ops
dt-bindings: net: xlnx,xxv-ethernet: Add Xilinx XXV 10G/25G Ethernet
net: xilinx: axienet: Add 10G/25G (XXV) ethernet support
net: xilinx: axienet: Make axienet_rmon_ranges non-static for reuse
net: xilinx: axienet: Dispatch statistics through axienet_config ops
net: xilinx: axienet: Add statistics support for XXV ethernet
.../bindings/net/xlnx,xxv-ethernet.yaml | 110 ++++ MAINTAINERS | 1 + drivers/net/ethernet/xilinx/Makefile | 3 +- drivers/net/ethernet/xilinx/xilinx_axienet.h | 90 +++ .../net/ethernet/xilinx/xilinx_axienet_main.c | 610 ++++++++++++------ .../net/ethernet/xilinx/xilinx_axienet_xxv.c | 592 +++++++++++++++++ .../net/ethernet/xilinx/xilinx_axienet_xxv.h | 141 ++++ 7 files changed, 1364 insertions(+), 183 deletions(-) create mode 100644 Documentation/devicetree/bindings/net/xlnx,xxv-ethernet.yaml create mode 100644 drivers/net/ethernet/xilinx/xilinx_axienet_xxv.c create mode 100644 drivers/net/ethernet/xilinx/xilinx_axienet_xxv.h
Signature · 1 line
2.25.1
PATCH v4 1/6 net: xilinx: axienet: Introduce axienet_config for MAC-specific ops
Introduce an axienet_config structure to abstract MAC-type-specific operations, preparing the driver for supporting additional MAC types beyond the existing 1G Ethernet.
Add axienet_config with capability flags (mdio, mac_irq, non_dmaengine, uc_filter, mc_filter, vlan, jumbo, tx_csum, sw_padding, internal_pcs), the register-dump count and callbacks (clk_init, setoptions, probe_init, gt_reset, mac_init, mac_link_up, get_regs, phylink_set_caps, pcs_ops, stats_update), and populate it from the OF match table. Convert the common code to consult these capabilities and callbacks instead of open-coding 1G behavior, so a new MAC type can be added without adding MAC-specific conditionals to the shared paths.
No functional change intended for the existing 1G path.
--- drivers/net/ethernet/xilinx/xilinx_axienet.h | 52 +++ .../net/ethernet/xilinx/xilinx_axienet_main.c | 396 ++++++++++++------ 2 files changed, 323 insertions(+), 125 deletions(-)
drivers/net/ethernet/xilinx/xilinx_axienet.h +52 -0
@@ -545,6 +545,7 @@ struct skbuf_dma_descriptor {* @tx_ring_tail: TX skb ring buffer tail index. * @rx_ring_head: RX skb ring buffer head index. * @rx_ring_tail: RX skb ring buffer tail index. +* @axienet_config: MAC-type specific configuration and operations. */ struct axienet_local {struct net_device *ndev;
@@ -626,6 +627,57 @@ struct axienet_local {int tx_ring_tail;int rx_ring_head;int rx_ring_tail; +const struct axienet_config *axienet_config; +}; + +/** +* struct axienet_config - MAC-type specific configuration and operations +* @mdio: MAC has an MDIO bus for external PHY management +* @mac_irq: MAC has a dedicated core interrupt +* @non_dmaengine: MAC supports the non-dmaengine flow +* @uc_filter: MAC has unicast address filter registers +* @mc_filter: MAC has multicast address filter registers +* @vlan: MAC supports VLAN frames by default +* @jumbo: MAC supports jumbo frames +* @tx_csum: MAC supports TX checksum offload +* @sw_padding: Short frames must be padded in software before transmit +* @internal_pcs: MAC always drives an internal PCS +* @regs_n: Number of MAC registers exposed through ethtool -d +* @clk_init: Callback to get and enable the MAC-specific clocks +* @setoptions: Callback to program MAC hardware options +* @probe_init: Callback for MAC-specific probe-time init, or NULL if unused +* @gt_reset: Callback to reset the serial transceiver (GT), or NULL if unused +* @mac_init: Callback for MAC-specific bring-up after the DMA reset +* @mac_link_up: Callback to program link speed and pause on link up, or NULL +* @get_regs: Callback to dump the MAC registers for ethtool -d +* @phylink_set_caps: Callback to set phylink MAC capabilities +* @pcs_ops: phylink PCS operations for this MAC, or NULL if unused +* @stats_update: Callback to latch/accumulate the periodic MAC counters +*/ +struct axienet_config { +bool mdio; +bool mac_irq; +bool non_dmaengine; +bool uc_filter; +bool mc_filter; +bool vlan; +bool jumbo; +bool tx_csum; +bool sw_padding; +bool internal_pcs; +unsigned int regs_n; +int (*clk_init)(struct axienet_local *lp); +void (*setoptions)(struct net_device *ndev,u32 options); +void (*probe_init)(struct axienet_local *lp); +void (*gt_reset)(struct axienet_local *lp); +int (*mac_init)(struct net_device *ndev); +void (*mac_link_up)(struct net_device *ndev,int speed, +bool tx_pause,bool rx_pause); +void (*get_regs)(struct axienet_local *lp,u32 *data); +void (*phylink_set_caps)(struct axienet_local *lp, +struct phylink_config *config); +const struct phylink_pcs_ops *pcs_ops; +void (*stats_update)(struct axienet_local *lp); };/**
drivers/net/ethernet/xilinx/xilinx_axienet_main.c +271 -125
595 lines not on this page · raw message
Signature · 1 line
2.25.1
[email protected]
AI reviewRe: [PATCH net-next v4 1/6] net: xilinx: axienet: Introduce axienet_config for MAC-specific ops
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [Medium] net: axienet: jumbo capability flag is ignored in MTU configuration --
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] net: axienet: jumbo capability flag is ignored in MTU configuration --
commit 865179930c894853c80ee8475041f18d377414d1
Author: Suraj Gupta <[email protected]>
net: xilinx: axienet: Introduce axienet_config for MAC-specific ops
Introduce an axienet_config structure to abstract MAC-type-specific operations, preparing the driver for supporting additional MAC types beyond the existing 1G Ethernet.
Quoted 4 lines
drivers/net/ethernet/xilinx/xilinx_axienet_main.c +0
-0
[ ... ]
Quoted 16 lines
drivers/net/ethernet/xilinx/xilinx_axienet_main.c +6
-2@@ -711,19 +744,23 @@ static void axienet_dma_stop(struct axienet_local *lp)*/ static int axienet_device_reset (struct net_device *ndev) { -u32 axienet_status;struct axienet_local *lp =netdev_priv (ndev);int ret; +if (lp->axienet_config->gt_reset) + lp->axienet_config->gt_reset (lp); + lp->max_frm_size =XAE_MAX_VLAN_FRAME_SIZE ; - lp->options |=XAE_OPTION_VLAN ; + +if (lp->axienet_config->vlan) + lp->options |=XAE_OPTION_VLAN ;
drivers/net/ethernet/xilinx/xilinx_axienet_main.c static void axienet_dma_stop(struct axienet_local *lp) · line 765
Quoted 10 lines
drivers/net/ethernet/xilinx/xilinx_axienet_main.c +1
-1lp->options &= (~XAE_OPTION_JUMBO );if (ndev->mtu >XAE_MTU && ndev->mtu <=XAE_JUMBO_MTU ) { lp->max_frm_size = ndev->mtu +VLAN_ETH_HLEN +XAE_TRL_SIZE ; -if (lp->max_frm_size <= lp->rxmem) +if (lp->max_frm_size <= lp->rxmem && lp->axienet_config->jumbo) lp->options |=XAE_OPTION_JUMBO ; }
[Severity: Medium]
Does this code silently drop large frames if a MAC configuration declares jumbo = false?
Since axienet_probe() unconditionally sets ndev->max_mtu = XAE_JUMBO_MTU and axienet_change_mtu() only validates lp->rxmem:
drivers/net/ethernet/xilinx/xilinx_axienet_main.c:axienet_change_mtu() {
...
if ((new_mtu + VLAN_ETH_HLEN +
XAE_TRL_SIZE) > lp->rxmem)
return -EINVAL;
WRITE_ONCE(ndev->mtu, new_mtu);
...
}The network stack and DMA engine will allow MTUs up to 9000 bytes. However, when the interface is brought up, axienet_device_reset() will now check lp->axienet_config->jumbo and refuse to set XAE_OPTION_JUMBO on the hardware.
If an administrator runs ip link set ethX mtu 9000 on an interface that does not support jumbo frames, shouldn't axienet_probe() or axienet_change_mtu() reject the configuration instead of allowing the stack to send jumbo frames that the hardware will drop?
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
[email protected]
AI reviewRe: [PATCH net-next v4 1/6] net: xilinx: axienet: Introduce axienet_config for MAC-specific ops
In reply to Suraj GuptaThank you for your contribution! Sashiko AI review found 6 potential issue(s) to consider.
Thank you for your contribution! Sashiko AI review found 6 potential issue(s) to consider.
Critical: 0 (1) · High: 0 · Medium: 1 (3) · Low: 5
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 "No functional change intended for the existing 1G path", but the patch changes 1G behaviour in…
- [Low] axienet_dma_err_handler() ignores the return value of the new int-returning mac_init callback, then re-enables TX/RX through…
- [Low] The new axienet_config::jumbo flag is documented as "MAC supports jumbo frames", but only axienet_device_reset() reads it, and only to…
- [Low] Mismatches between the kernel-doc and the code for the optional members of struct axienet_config.
- [Low] The sw_padding and tx_csum capability flags are honoured in axienet_start_xmit_dmaengine() but not in the legacy…
- [Low] On the non-dmaengine path, axienet_device_reset() returns early when mac_init() fails, after axienet_dma_bd_init() has already…
Pre-existing issues:
- [Critical] This problem wasn't introduced by this patch, but axienet_start_xmit_dmaengine() increments lp->tx_ring_head before…
- [Medium] xlnx,axi-ethernet.yaml lists the interrupt order as Ethernet core, Tx DMA, Rx DMA.
- [Medium] axienet_open() discards the return value of axienet_device_reset() by overwriting ret with…
- [Medium] On the legacy-DMA path, the BD rings and mapped RX skbs allocated by axienet_device_reset() are leaked when axienet_open()…
--
net: xilinx: axienet: Introduce axienet_config for MAC-specific ops
This commit adds struct axienet_config, which holds capability flags and per-MAC callbacks and is filled in from the OF match table. The shared axienet paths now use it instead of open-coded 1G behaviour, to prepare for more MAC types. The commit says no functional change is intended for the existing 1G path.
Quoted 4 lines
drivers/net/ethernet/xilinx/xilinx_axienet_main.c +0
-0
[ ... ]
Quoted 4 lines
drivers/net/ethernet/xilinx/xilinx_axienet_main.c +0
-0@@ -711,19 +744,23 @@ static void axienet_dma_stop(struct axienet_local *lp)*/ static int axienet_device_reset (struct net_device *ndev) {
[ ... ]
drivers/net/ethernet/xilinx/xilinx_axienet_main.c static void axienet_dma_stop(struct axienet_local *lp) · line 764
Quoted 8 lines
drivers/net/ethernet/xilinx/xilinx_axienet_main.c +1
-1if (ndev->mtu >XAE_MTU && ndev->mtu <=XAE_JUMBO_MTU ) { lp->max_frm_size = ndev->mtu +VLAN_ETH_HLEN +XAE_TRL_SIZE ; -if (lp->max_frm_size <= lp->rxmem) +if (lp->max_frm_size <= lp->rxmem && lp->axienet_config->jumbo) lp->options |=XAE_OPTION_JUMBO ; }
[Severity: Low]
Should the new jumbo flag also limit the MTU range? The kernel-doc says @jumbo means "MAC supports jumbo frames", but this is the only place the flag is read. The MTU limits do not check it:
axienet_probe() {
...
ndev->max_mtu = XAE_JUMBO_MTU;
...
}axienet_change_mtu() {
...
if ((new_mtu + VLAN_ETH_HLEN +
XAE_TRL_SIZE) > lp->rxmem)
return -EINVAL;
...
}So a MAC with .jumbo = false would still accept an MTU of up to 9000, limited only by xlnx,rxmem. axienet_device_reset() would then raise max_frm_size to mtu + VLAN_ETH_HLEN + XAE_TRL_SIZE without setting XAE_OPTION_JUMBO.
Later in the series, axienet_10g25g_config leaves .jumbo unset but still gets a max_mtu of 9000.
Is the @jumbo description wrong for XXV, or should max_mtu and axienet_change_mtu() check .jumbo?
[ ... ]
Quoted 4 lines
drivers/net/ethernet/xilinx/xilinx_axienet_main.c +0
-0@@ -740,26 +777,18 @@ static int axienet_device_reset(struct net_device *ndev) } }
[ ... ]
drivers/net/ethernet/xilinx/xilinx_axienet_main.c static int axienet_device_reset(struct net_device *ndev) · line 781
Quoted 3 lines
drivers/net/ethernet/xilinx/xilinx_axienet_main.c +3
-0+ ret = lp->axienet_config->mac_init (ndev); +if (ret) +return ret;
[Severity: Low]
On the non-dmaengine path, axienet_dma_bd_init() has already allocated the BD rings, mapped the RX skbs and started the DMA by the time this early return runs. If mac_init() fails, does this leak the BD rings and the mapped RX skbs?
None of the configs in this series can hit this. Only axienet_1g_config allows non-dmaengine mode, and axienet_1g_mac_init() always returns 0. A future MAC with both non_dmaengine set and a mac_init() that can fail would hit it.
[Severity: Medium]
This is a pre-existing issue, but at this point in the series callers of axienet_open() never see the new mac_init() error:
axienet_open() {
...
ret = axienet_device_reset(ndev);
axienet_unlock_mii(lp);
ret = phylink_fwnode_phy_connect(lp->phylink, dev_fwnode(lp->dev), 0);
...
}The result of axienet_device_reset() is overwritten before anything checks it. axienet_1g_mac_init() always returns 0, so this patch adds no new failure.
The later patch "net: xilinx: axienet: Add 10G/25G (XXV) ethernet support" in this series adds the missing check.
[Severity: Medium]
This isn't a bug introduced by this patch, but on the legacy DMA path, does axienet_open() leak the BD rings and mapped RX skbs that axienet_device_reset() allocated if a later step fails?
A phylink_fwnode_phy_connect() failure returns straight away:
ret = phylink_fwnode_phy_connect(lp->phylink, dev_fwnode(lp->dev), 0);
if (ret) {
dev_err(lp->dev, "phylink_of_phy_connect() failed: %d\n", ret);
return ret;
}The err_phy unwind, used for the request_irq() failures in axienet_init_legacy_dma(), also calls neither axienet_dma_stop() nor axienet_dma_bd_release():
err_phy:
cancel_work_sync(&lp->rx_dim.work); cancel_delayed_work_sync(&lp->stats_work); phylink_stop(lp->phylink); phylink_disconnect_phy(lp->phylink); return ret;
ndo_stop is not called after ndo_open fails, and the next open overwrites tx_bd_v and rx_bd_v.
[ ... ]
drivers/net/ethernet/xilinx/xilinx_axienet_main.c axienet_start_xmit_dmaengine(struct sk_buff *skb, struct net_device *ndev) · line 979
Quoted 4 lines
drivers/net/ethernet/xilinx/xilinx_axienet_main.c +0
-0@@ -941,19 +977,21 @@ axienet_start_xmit_dmaengine(struct sk_buff *skb, struct net_device *ndev) goto xmit_error_drop_skb;/* Fill up app fields for checksum */
[ ... ]
[Severity: Critical]
This is a pre-existing issue and was not introduced by this patch. Can the error paths in axienet_start_xmit_dmaengine() knock the TX ring out of sync? The producer index moves forward before the steps that can fail:
lp->tx_ring_head++; sg_init_table(skbuf_dma->sgl, sg_len); ret = skb_to_sgvec(skb, skbuf_dma->sgl, 0, skb->len); if (ret < 0) goto xmit_error_drop_skb;
Neither xmit_error_unmap_sg nor xmit_error_drop_skb rolls it back. The skipped slot has no DMA transaction behind it. Its skb and sg_len still hold the previous lap's values, or NULL on the first lap.
axienet_dma_tx_cb() consumes slots strictly in order:
skbuf_dma = axienet_get_tx_desc(lp, lp->tx_ring_tail++); len = skbuf_dma->skb->len; ... dev_consume_skb_any(skbuf_dma->skb);
So the next completion would process the skipped slot. On the first lap that is a NULL pointer dereference. On later laps it calls dma_unmap_sg() on an sgl that is already unmapped, reports a stale length to BQL, and frees an skb that has already been freed. The off-by-one then stays for the rest of the ring's lifetime.
Normal load seems enough to trigger this. xilinx_dma_prep_slave_sg() returns NULL when xilinx_axidma_alloc_tx_segment() runs out of its XILINX_DMA_NUM_DESCS (512) segments, while the axienet ring allows up to TX_BD_NUM_MAX (4096) entries in flight. dma_map_sg() can also fail when swiotlb or IOMMU space runs out.
The problem is still there at the end of the series.
[ ... ]
Quoted 4 lines
drivers/net/ethernet/xilinx/xilinx_axienet_main.c +0
-0@@ -2759,29 +2819,114 @@ static void axienet_dma_err_handler(struct work_struct *work)axienet_dma_start (lp);
[ ... ]
drivers/net/ethernet/xilinx/xilinx_axienet_main.c static void axienet_dma_err_handler(struct work_struct *work) · line 2818
Quoted 1 line
drivers/net/ethernet/xilinx/xilinx_axienet_main.c +1
-0+ lp->axienet_config->mac_init (ndev);
[Severity: Low]
Should the return value of mac_init() be checked here, as it is in axienet_device_reset()? The handler re-enables TX and RX through setoptions(ndev, lp->options) either way.
This handler only runs on the non-dmaengine path, which only the 1G config can use, and axienet_1g_mac_init() always returns 0. The later XXV patch in this series adds a comment at this call site saying so. It may be clearer to add that comment here, where mac_init() first gets an int return type.
[ ... ]
Quoted 5 lines
drivers/net/ethernet/xilinx/xilinx_axienet_main.c +1
-0@@ -2943,7 +3075,17 @@ static int axienet_probe(struct platform_device *pdev)return -EINVAL ; } +if (lp->axienet_config->probe_init)
drivers/net/ethernet/xilinx/xilinx_axienet_main.c static int axienet_probe(struct platform_device *pdev) · line 3088
Quoted 10 lines
drivers/net/ethernet/xilinx/xilinx_axienet_main.c +9
-0+ lp->axienet_config->probe_init (lp); +if (!of_property_present (pdev->dev.of_node,"dmas" )) { +/* Non-dmaengine mode is only supported by some MACs */ +if (!lp->axienet_config->non_dmaengine) { +dev_err (&pdev->dev, +"Non-dmaengine mode not supported by this MAC, use dmaengine\n" ); +return -EINVAL ; + } +
[Severity: Low]
This isn't a bug, but some of the new capability flags only take effect on the dmaengine paths:
- sw_padding and tx_csum are checked in axienet_start_xmit_dmaengine() but not in axienet_start_xmit().
- mac_irq is checked in the dmaengine probe branch but not in this non-dmaengine branch.
Because of this gate, only axienet_1g_config reaches those paths today, and its flags match what the legacy code does unconditionally. A future config with non_dmaengine set and different flags would quietly get the 1G behaviour.
drivers/net/ethernet/xilinx/xilinx_axienet_main.c static int axienet_probe(struct platform_device *pdev) · line 3087
Quoted 3 lines
drivers/net/ethernet/xilinx/xilinx_axienet_main.c +0
-0/* Find the DMA node, map the DMA registers, and decode the DMA IRQs */ np =of_parse_phandle (pdev->dev.of_node,"axistream-connected" ,0 );
[Severity: Medium]
This is a pre-existing issue and not introduced by this patch. The interrupt order in Documentation/devicetree/bindings/net/xlnx,axi-ethernet.yaml doesn't seem to match what this branch reads when the DMA resources are on the Ethernet node.
The binding lists Ethernet core, Tx DMA, Rx DMA. The driver does:
lp->rx_irq = platform_get_irq(pdev, 1); lp->tx_irq = platform_get_irq(pdev, 0); lp->eth_irq = platform_get_irq_optional(pdev, 2);
Would a device tree written to match the binding text end up with its IRQs misrouted?
[ ... ]
drivers/net/ethernet/xilinx/xilinx_axienet_main.c static int axienet_probe(struct platform_device *pdev) · line 3266
Quoted 13 lines
drivers/net/ethernet/xilinx/xilinx_axienet_main.c +6
-1@@ -3109,23 +3256,21 @@ static int axienet_probe(struct platform_device *pdev) goto cleanup_mdio; }of_node_put (np); - lp->pcs.ops = &axienet_pcs_ops; + lp->pcs.ops = lp->axienet_config->pcs_ops; + lp->pcs.poll = true; + } + +if (lp->axienet_config->internal_pcs) { + lp->pcs.ops = lp->axienet_config->pcs_ops; lp->pcs.poll = true; }
[Severity: Low]
This isn't a bug, but a few kernel-doc entries for struct axienet_config don't quite match how the members are used:
- @pcs_ops is documented as "or NULL if unused", but it is assigned to lp->pcs.ops here without a NULL check. Every config in the series sets it, so nothing breaks today.
- @stats_update is NULL-checked in axienet_refresh_stats() but isn't documented as optional.
- @internal_pcs says "MAC always drives an internal PCS", but axienet_mac_select_pcs() picks the PCS by interface mode only. By the end of the series it also handles 10GBASER and 25GBASER, which covers XXV.
[ ... ]
drivers/net/ethernet/xilinx/xilinx_axienet_main.c static void axienet_remove(struct platform_device *pdev) · line 3318
Quoted 8 lines
drivers/net/ethernet/xilinx/xilinx_axienet_main.c +2
-1@@ -3168,7 +3313,8 @@ static void axienet_remove(struct platform_device *pdev)if (lp->pcs_phy)put_device (&lp->pcs_phy->dev); -axienet_mdio_teardown (lp); +if (lp->mii_bus) +axienet_mdio_teardown (lp); }
[Severity: Medium]
The commit message says:
No functional change intended for the existing 1G path.
This hunk does change 1G remove behaviour, though. Before the patch, a failed axienet_mdio_setup() left lp->mii_bus NULL:
drivers/net/ethernet/xilinx/xilinx_axienet_mdio.c:axienet_mdio_setup() {
...
unregister:
of_node_put(mdio_node);
mdiobus_free(bus);
lp->mii_bus = NULL;
return ret;
}axienet_probe() only warns and carries on. A 1G device using a fixed-link, or a PHY on another bus, could therefore probe without an MDIO bus. Unbinding it then went through:
axienet_remove()->axienet_mdio_teardown()->mdiobus_unregister(NULL)
and mdiobus_unregister() dereferences bus->state.
So the new check fixes a NULL pointer dereference. Could it be split out as a separate fix for net with a Fixes: tag, so it can reach stable, and the commit message here updated?
Signature · 1 line
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261006110550.1990213-1-suraj.gupta2%40amd.com
Re: [PATCH net-next v4 1/6] net: xilinx: axienet: Introduce axienet_config for MAC-specific ops
Quoted 91 lines · On 10/10/2026 5:25 PM, [email protected] wrote:
Thank you for your contribution! Sashiko AI review found 6 potential issue(s) to consider.
Critical: 0 (1) · High: 0 · Medium: 1 (3) · Low: 5
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 "No functional change intended for the existing 1G path", but the patch changes 1G behaviour in…
- [Low]axienet_dma_err_handler()ignores the return value of the new int-returningmac_initcallback, then re-enables TX/RX through…
- [Low] The newaxienet_config::jumboflag is documented as "MAC supports jumbo frames", but onlyaxienet_device_reset()reads it, and only to…
- [Low] Mismatches between the kernel-doc and the code for the optional members of structaxienet_config.
- [Low] Thesw_paddingandtx_csumcapability flags are honoured inaxienet_start_xmit_dmaengine()but not in the legacy…
- [Low] On the non-dmaengine path,axienet_device_reset()returns early whenmac_init()fails, afteraxienet_dma_bd_init()has already…Pre-existing issues:
- [Critical] This problem wasn't introduced by this patch, butaxienet_start_xmit_dmaengine()incrementslp->tx_ring_headbefore…
- [Medium] xlnx,axi-ethernet.yaml lists the interrupt order as Ethernet core, Tx DMA, Rx DMA.
- [Medium]axienet_open()discards the return value ofaxienet_device_reset()by overwriting ret with…
- [Medium] On the legacy-DMA path, the BD rings and mapped RX skbs allocated byaxienet_device_reset()are leaked when axienet_open()…--
net: xilinx: axienet: Introduce
axienet_configfor MAC-specific opsThis commit adds struct
axienet_config, which holds capability flags and per-MAC callbacks and is filled in from the OF match table. The shared axienet paths now use it instead of open-coded 1G behaviour, to prepare for more MAC types. The commit says no functional change is intended for the existing 1G path.Quoted 4 lines
drivers/net/ethernet/xilinx/xilinx_axienet_main.c +0
-0[ ... ]
Quoted 4 lines
drivers/net/ethernet/xilinx/xilinx_axienet_main.c +0
-0@@ -711,19 +744,23 @@ static void axienet_dma_stop(struct axienet_local *lp)*/ static int axienet_device_reset (struct net_device *ndev) {[ ... ]
drivers/net/ethernet/xilinx/xilinx_axienet_main.c static void axienet_dma_stop(struct axienet_local *lp) · line 764
Quoted 8 lines
if (ndev->mtu > XAE_MTU && ndev->mtu <= XAE_JUMBO_MTU) { lp->max_frm_size = ndev->mtu + VLAN_ETH_HLEN + XAE_TRL_SIZE;drivers/net/ethernet/xilinx/xilinx_axienet_main.c +1
-1-if (lp->max_frm_size <= lp->rxmem) +if (lp->max_frm_size <= lp->rxmem && lp->axienet_config->jumbo) lp->options |=XAE_OPTION_JUMBO ; }[Severity: Low]
Should the new jumbo flag also limit the MTU range? The kernel-doc says @jumbo means "MAC supports jumbo frames", but this is the only place the flag is read. The MTU limits do not check it:axienet_probe() { ... ndev->max_mtu = XAE_JUMBO_MTU; ... }axienet_change_mtu() { ... if ((new_mtu + VLAN_ETH_HLEN + XAE_TRL_SIZE) > lp->rxmem) return -EINVAL; ... }So a MAC with .jumbo = false would still accept an MTU of up to 9000, limited only by xlnx,rxmem.
axienet_device_reset()would then raisemax_frm_sizeto mtu +VLAN_ETH_HLEN+XAE_TRL_SIZEwithout settingXAE_OPTION_JUMBO.
Quoted 5 lines
Later in the series,
axienet_10g25g_configleaves .jumbo unset but still gets amax_mtuof 9000.Is the @jumbo description wrong for XXV, or should
max_mtuandaxienet_change_mtu()check .jumbo?
The functional path is fine: max_frm_size (the RX buffer size) is set from the MTU regardless of the flag, and XAE_OPTION_JUMBO is a 1G-TEMAC option with no entry in xxvenet_options, so for XXV it is a no-op. The problem is the flag value: axienet_10g25g_config sets .jumbo = false, which is wrong -- per PG210 XXV supports jumbo, and ctl_rx_max_packet_len already defaults to 9600, so no register programming is needed. In v5 I'll set .jumbo = true for XXV and make ndev->max_mtu honour .jumbo, so the flag, the accepted MTU range and the hardware agree. (XAE_OPTION_JUMBO itself stays a 1G-only option.)
Quoted 20 lines
[ ... ]
Quoted 4 lines
drivers/net/ethernet/xilinx/xilinx_axienet_main.c +0
-0@@ -740,26 +777,18 @@ static int axienet_device_reset(struct net_device *ndev) } }[ ... ]
drivers/net/ethernet/xilinx/xilinx_axienet_main.c static int axienet_device_reset(struct net_device *ndev) · line 781
Quoted 3 lines
drivers/net/ethernet/xilinx/xilinx_axienet_main.c +3
-0+ ret = lp->axienet_config->mac_init (ndev); +if (ret) +return ret;[Severity: Low]
On the non-dmaengine path,axienet_dma_bd_init()has already allocated the BD rings, mapped the RX skbs and started the DMA by the time this early return runs. Ifmac_init()fails, does this leak the BD rings and the mapped RX skbs?
Quoted 5 lines
None of the configs in this series can hit this. Only
axienet_1g_configallows non-dmaengine mode, andaxienet_1g_mac_init()always returns 0. A future MAC with bothnon_dmaengineset and amac_init()that can fail would hit it.
Confirmed. On that path axienet_device_reset() runs __axienet_device_reset() -> axienet_dma_bd_init() (which allocates the BD rings, maps the RX skbs and starts the DMA) and only then calls mac_init(), so a mac_init() failure returns without releasing them. It is unreachable today (only 1G uses non_dmaengine and axienet_1g_mac_init() always returns 0), but I'll restructure so a mac_init() failure on that path unwinds axienet_dma_bd_init() (axienet_dma_stop() + axienet_dma_bd_release()) before returning.
Quoted 13 lines
[Severity: Medium]
This is a pre-existing issue, but at this point in the series callers ofaxienet_open()never see the newmac_init()error:axienet_open() { ... ret = axienet_device_reset(ndev); axienet_unlock_mii(lp); ret = phylink_fwnode_phy_connect(lp->phylink, dev_fwnode(lp->dev), 0); ... }
Quoted 7 lines
The result of
axienet_device_reset()is overwritten before anything checks it.axienet_1g_mac_init()always returns 0, so this patch adds no new failure.The later patch "net: xilinx: axienet: Add 10G/25G (XXV) ethernet support" in this series adds the missing check.
Yes, as mentioned later patch fixes this.> [Severity: Medium]
Quoted 17 lines
This isn't a bug introduced by this patch, but on the legacy DMA path, does
axienet_open()leak the BD rings and mapped RX skbs thataxienet_device_reset()allocated if a later step fails?A
phylink_fwnode_phy_connect()failure returns straight away:ret = phylink_fwnode_phy_connect(lp->phylink, dev_fwnode(lp->dev), 0); if (ret) { dev_err(lp->dev, "phylink_of_phy_connect() failed: %d\n", ret); return ret; }The
err_phyunwind, used for therequest_irq()failures inaxienet_init_legacy_dma(), also calls neitheraxienet_dma_stop()noraxienet_dma_bd_release():
err_phy:
Quoted 9 lines
cancel_work_sync(&lp->rx_dim.work); cancel_delayed_work_sync(&lp->stats_work); phylink_stop(lp->phylink); phylink_disconnect_phy(lp->phylink); return ret;
ndo_stopis not called afterndo_openfails, and the next open overwritestx_bd_vandrx_bd_v.
This is a pre-existing issue and can be addressed in separate series.
Quoted 38 lines
[ ... ]
drivers/net/ethernet/xilinx/xilinx_axienet_main.c axienet_start_xmit_dmaengine(struct sk_buff *skb, struct net_device *ndev) · line 979
Quoted 4 lines
drivers/net/ethernet/xilinx/xilinx_axienet_main.c +0
-0@@ -941,19 +977,21 @@ axienet_start_xmit_dmaengine(struct sk_buff *skb, struct net_device *ndev) goto xmit_error_drop_skb;/* Fill up app fields for checksum */ [ ... ]
[Severity: Critical]
This is a pre-existing issue and was not introduced by this patch. Can the error paths inaxienet_start_xmit_dmaengine()knock the TX ring out of sync? The producer index moves forward before the steps that can fail:lp->tx_ring_head++; sg_init_table(skbuf_dma->sgl, sg_len); ret = skb_to_sgvec(skb, skbuf_dma->sgl, 0, skb->len); if (ret < 0) goto xmit_error_drop_skb;Neither
xmit_error_unmap_sgnorxmit_error_drop_skbrolls it back. The skipped slot has no DMA transaction behind it. Its skb andsg_lenstill hold the previous lap's values, or NULL on the first lap.
axienet_dma_tx_cb()consumes slots strictly in order:skbuf_dma = axienet_get_tx_desc(lp, lp->tx_ring_tail++); len = skbuf_dma->skb->len; ... dev_consume_skb_any(skbuf_dma->skb);So the next completion would process the skipped slot. On the first lap that is a NULL pointer dereference. On later laps it calls
dma_unmap_sg()on an sgl that is already unmapped, reports a stale length to BQL, and frees an skb that has already been freed. The off-by-one then stays for the rest of the ring's lifetime.
Quoted 7 lines
Normal load seems enough to trigger this.
xilinx_dma_prep_slave_sg()returns NULL whenxilinx_axidma_alloc_tx_segment()runs out of itsXILINX_DMA_NUM_DESCS(512) segments, while the axienet ring allows up toTX_BD_NUM_MAX(4096) entries in flight.dma_map_sg()can also fail when swiotlb or IOMMU space runs out.The problem is still there at the end of the series.
This is a pre-existing issue and can be addressed in separate series.
Quoted 17 lines
[ ... ]
Quoted 4 lines
drivers/net/ethernet/xilinx/xilinx_axienet_main.c +0
-0@@ -2759,29 +2819,114 @@ static void axienet_dma_err_handler(struct work_struct *work)axienet_dma_start (lp);[ ... ]
drivers/net/ethernet/xilinx/xilinx_axienet_main.c static void axienet_dma_err_handler(struct work_struct *work) · line 2818
Quoted 1 line
drivers/net/ethernet/xilinx/xilinx_axienet_main.c +1
-0+ lp->axienet_config->mac_init (ndev);[Severity: Low]
Should the return value ofmac_init()be checked here, as it is inaxienet_device_reset()? The handler re-enables TX and RX throughsetoptions(ndev, lp->options)either way.
Quoted 6 lines
This handler only runs on the non-dmaengine path, which only the 1G config can use, and
axienet_1g_mac_init()always returns 0. The later XXV patch in this series adds a comment at this call site saying so. It may be clearer to add that comment here, wheremac_init()first gets an int return type.
Agreed. The unchecked call is introduced here (patch 1) but the comment explaining it only lands in the XXV patch. I'll move that comment into this patch.> [ ... ]
Quoted 26 lines
Quoted 6 lines
drivers/net/ethernet/xilinx/xilinx_axienet_main.c +1
-0@@ -2943,7 +3075,17 @@ static int axienet_probe(struct platform_device *pdev)return -EINVAL ; } +if (lp->axienet_config->probe_init)drivers/net/ethernet/xilinx/xilinx_axienet_main.c static int axienet_probe(struct platform_device *pdev) · line 3088
Quoted 10 lines
drivers/net/ethernet/xilinx/xilinx_axienet_main.c +9
-0+ lp->axienet_config->probe_init (lp); +if (!of_property_present (pdev->dev.of_node,"dmas" )) { +/* Non-dmaengine mode is only supported by some MACs */ +if (!lp->axienet_config->non_dmaengine) { +dev_err (&pdev->dev, +"Non-dmaengine mode not supported by this MAC, use dmaengine\n" ); +return -EINVAL ; + } +[Severity: Low]
This isn't a bug, but some of the new capability flags only take effect on the dmaengine paths:-
sw_paddingandtx_csumare checked inaxienet_start_xmit_dmaengine()but not inaxienet_start_xmit().
-mac_irqis checked in the dmaengine probe branch but not in this non-dmaengine branch.
Quoted 9 lines
Because of this gate, only
axienet_1g_configreaches those paths today, and its flags match what the legacy code does unconditionally. A future config withnon_dmaengineset and different flags would quietly get the 1G behaviour.Quoted 3 lines
drivers/net/ethernet/xilinx/xilinx_axienet_main.c +0
-0/* Find the DMA node, map the DMA registers, and decode the DMA IRQs */ np =of_parse_phandle (pdev->dev.of_node,"axistream-connected" ,0 );
As mentioned in cover-letter, XXV supports dmaengine flow only.
Quoted 6 lines
[Severity: Medium]
This is a pre-existing issue and not introduced by this patch. The interrupt order inDocumentation/devicetree/bindings/net/xlnx,axi-ethernet.yamldoesn't seem to match what this branch reads when the DMA resources are on the Ethernet node.
Quoted 8 lines
The binding lists Ethernet core, Tx DMA, Rx DMA. The driver does:
lp->rx_irq = platform_get_irq(pdev, 1); lp->tx_irq = platform_get_irq(pdev, 0); lp->eth_irq = platform_get_irq_optional(pdev, 2);Would a device tree written to match the binding text end up with its IRQs misrouted?
This is a pre-existing issue and can be addressed in separate series.
Quoted 21 lines
[ ... ]
drivers/net/ethernet/xilinx/xilinx_axienet_main.c static int axienet_probe(struct platform_device *pdev) · line 3266
Quoted 13 lines
drivers/net/ethernet/xilinx/xilinx_axienet_main.c +6
-1@@ -3109,23 +3256,21 @@ static int axienet_probe(struct platform_device *pdev) goto cleanup_mdio; }of_node_put (np); - lp->pcs.ops = &axienet_pcs_ops; + lp->pcs.ops = lp->axienet_config->pcs_ops; + lp->pcs.poll = true; + } + +if (lp->axienet_config->internal_pcs) { + lp->pcs.ops = lp->axienet_config->pcs_ops; lp->pcs.poll = true; }[Severity: Low]
This isn't a bug, but a few kernel-doc entries for structaxienet_configdon't quite match how the members are used:
Quoted 10 lines
- @pcs_ops is documented as "or NULL if unused", but it is assigned to
lp->pcs.opshere without a NULL check. Every config in the series sets it, so nothing breaks today.
- @stats_update is NULL-checked inaxienet_refresh_stats()but isn't documented as optional.
- @internal_pcs says "MAC always drives an internal PCS", butaxienet_mac_select_pcs()picks the PCS by interface mode only. By the end of the series it also handles 10GBASER and 25GBASER, which covers XXV.
Will fix the kernel-doc to match usage in v5
Quoted 32 lines
[ ... ]
drivers/net/ethernet/xilinx/xilinx_axienet_main.c static void axienet_remove(struct platform_device *pdev) · line 3318
Quoted 8 lines
drivers/net/ethernet/xilinx/xilinx_axienet_main.c +2
-1@@ -3168,7 +3313,8 @@ static void axienet_remove(struct platform_device *pdev)if (lp->pcs_phy)put_device (&lp->pcs_phy->dev); -axienet_mdio_teardown (lp); +if (lp->mii_bus) +axienet_mdio_teardown (lp); }[Severity: Medium]
The commit message says:No functional change intended for the existing 1G path.
This hunk does change 1G remove behaviour, though. Before the patch, a failed
axienet_mdio_setup()leftlp->mii_busNULL:drivers/net/ethernet/xilinx/xilinx_axienet_mdio.c:axienet_mdio_setup() { ... unregister: of_node_put(mdio_node); mdiobus_free(bus); lp->mii_bus = NULL; return ret; }
axienet_probe()only warns and carries on. A 1G device using a fixed-link, or a PHY on another bus, could therefore probe without an MDIO bus. Unbinding it then went through:
Quoted 8 lines
axienet_remove()->axienet_mdio_teardown()->mdiobus_unregister(NULL)
and
mdiobus_unregister()dereferencesbus->state.So the new check fixes a NULL pointer dereference. Could it be split out as a separate fix for net with a Fixes: tag, so it can reach stable, and the commit message here updated?
Agreed, this is not a no-op. I'll pull this hunk out into a standalone [PATCH net] with a Fixes: tag so stable can pick it up, and keep this patch a genuine no-functional-change refactor.
Thanks for the thorough review.
pw-bot: cr
Suraj
PATCH v4 2/6 dt-bindings: net: xlnx,xxv-ethernet: Add Xilinx XXV 10G/25G Ethernet
In reply to Suraj GuptaThe XXV Ethernet IP integrates a 10G/25G Ethernet MAC with an in-core PCS/PMA driving a high-speed serial transceiver. Its payload is moved by an external AXI DMA (or multichannel DMA) controller referenced through the dmas/dma-names properties. Document the IP in a dedicated schema file.
Add the "xlnx,xxv-ethernet-1.0" compatible with the 10gbase-r and 25gbase-r phy-modes, the rx_core/drp/s_axi clocks and the AXI DMA channel properties.
--- .../bindings/net/xlnx,xxv-ethernet.yaml | 110 ++++++++++++++++++ MAINTAINERS | 1 + 2 files changed, 111 insertions(+) create mode 100644 Documentation/devicetree/bindings/net/xlnx,xxv-ethernet.yaml
Documentation/devicetree/bindings/net/xlnx,xxv-ethernet.yaml new file +110 -0
@@ -0,0 +1,110 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/net/xlnx,xxv-ethernet.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Xilinx XXV 10G/25G Ethernet Subsystem + +maintainers: + - Radhey Shyam Pandey <[email protected]> + - Suraj Gupta <[email protected]> + +description: + The Xilinx XXV Ethernet Subsystem implements a 10G/25G Ethernet MAC with an + in-core PCS/PMA driving a high-speed serial transceiver. It supports the + 10GBASE-R and 25GBASE-R line rates, with 25G operation following the 25G + Ethernet Consortium specification. Because the PCS/PMA is integrated into + the IP, the subsystem has no MDIO bus master and is not managed through an + external MDIO PHY; link state is read from the MAC's own status registers. + Any SFP module management (e.g. I2C) is handled by separate IP outside this + binding. Its payload is moved by an external AXI DMA (or multichannel DMA) + controller referenced through the "dmas" property. + +properties: + compatible: + const: xlnx,xxv-ethernet-1.0 + + reg: + maxItems: 1 + description: MAC control and status register space. + + clocks: + items: + - description: RX AXI4-Stream clock. + - description: GT DRP clock. + - description: AXI4-Lite register clock. + + clock-names: + items: + - const: rx_core + - const: drp + - const: s_axi + + phy-mode: + enum: + - 10gbase-r + - 25gbase-r + + xlnx,rxmem: + description: + Size in bytes of the Rx/Tx packet buffer memory built into the IP. It is + fixed by the hardware design and bounds the largest frame (jumbo MTU) the + device can accept. + $ref: /schemas/types.yaml#/definitions/uint32 + + dmas: + minItems: 2 + maxItems: 32 + description: TX and RX DMA channel phandles. + + dma-names: + items: + pattern: "^[tr]x_chan([0-9]|1[0-5])$" + description: + Should be "tx_chan0", "tx_chan1" ... "tx_chan15" for DMA Tx channel and + "rx_chan0", "rx_chan1" ... "rx_chan15" for DMA Rx channel. + minItems: 2 + maxItems: 32 + +required: + - compatible + - reg + - clocks + - clock-names + - phy-mode + - xlnx,rxmem + - dmas + - dma-names + +allOf: + - $ref: /schemas/net/ethernet-controller.yaml# + +unevaluatedProperties: false + +examples: + # Single AXI DMA channel pair + - | + ethernet@80000000 { + compatible = "xlnx,xxv-ethernet-1.0"; + reg = <0x80000000 0x10000>; + clock-names = "rx_core", "drp", "s_axi"; + clocks = <&rx_clk>, <&drp_clk>, <&axi_clk>; + dma-names = "tx_chan0", "rx_chan0"; + dmas = <&axi_dma 0>, <&axi_dma 1>; + phy-mode = "25gbase-r"; + xlnx,rxmem = <0x8000>; + }; + # Multichannel DMA (MCDMA) with multiple Tx/Rx channels + - | + ethernet@80010000 { + compatible = "xlnx,xxv-ethernet-1.0"; + reg = <0x80010000 0x10000>; + clock-names = "rx_core", "drp", "s_axi"; + clocks = <&rx_clk>, <&drp_clk>, <&axi_clk>; + dma-names = "tx_chan0", "tx_chan1", "rx_chan0", "rx_chan1"; + dmas = <&axi_mcdma 0>, <&axi_mcdma 1>, + <&axi_mcdma 16>, <&axi_mcdma 17>; + phy-mode = "10gbase-r"; + xlnx,rxmem = <0x8000>; + };
MAINTAINERS +1 -0
@@ -29904,6 +29904,7 @@ XILINX AXI ETHERNET DRIVER M: Radhey Shyam Pandey <[email protected]> S: Maintained F: Documentation/devicetree/bindings/net/xlnx,axi-ethernet.yaml +F: Documentation/devicetree/bindings/net/xlnx,xxv-ethernet.yaml F: drivers/net/ethernet/xilinx/xilinx_axienet* XILINX CAN DRIVER
Signature · 1 line
2.25.1
[email protected]
AI reviewRe: [PATCH net-next v4 2/6] dt-bindings: net: xlnx,xxv-ethernet: Add Xilinx XXV 10G/25G Ethernet
Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider.
Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider.
Critical: 0 · High: 1 · Medium: 1 · 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).
- [High] The XXV binding never says how link management works, so a node that passes the schema, including both examples in the binding, cannot…
- [Medium] The binding has no way to describe the XXV transceiver (GT) reference clock.
- [Low] The new XXV binding's dma-names schema only checks a per-item pattern (^[tr]x_chan([0-9]|1[0-5])$) and a count of 2 to 32.
--
dt-bindings: net: xlnx,xxv-ethernet: Add Xilinx XXV 10G/25G Ethernet
This adds a new DT binding schema for the Xilinx XXV 10G/25G Ethernet IP. The IP has an in-core PCS/PMA and uses an external AXI DMA or MCDMA. The binding covers the 10gbase-r/25gbase-r phy-modes, the rx_core/drp/s_axi clocks and the dmas/dma-names properties.
Quoted 6 lines
Documentation/devicetree/bindings/net/xlnx,xxv-ethernet.yaml new file +0
-0@@ -0,0 +1,110 @@
[ ... ]
Documentation/devicetree/bindings/net/xlnx,xxv-ethernet.yaml line 19
Quoted 7 lines
Documentation/devicetree/bindings/net/xlnx,xxv-ethernet.yaml new file +7
-0+description: + The Xilinx XXV Ethernet Subsystem implements a 10G/25G Ethernet MAC with an + in-core PCS/PMA driving a high-speed serial transceiver. It supports the + 10GBASE-R and 25GBASE-R line rates, with 25G operation following the 25G + Ethernet Consortium specification. Because the PCS/PMA is integrated into + the IP, the subsystem has no MDIO bus master and is not managed through an + external MDIO PHY; link state is read from the MAC's own status registers.
[Severity: High]
The binding says there is no external MDIO PHY. It does not require or show managed = "in-band-status" or a fixed-link node, though. Neither example has phy-handle, fixed-link or managed.
The XXV support added later in this series sets only mac_capabilities and supported_interfaces in axienet_xxv_phylink_set_capabilities(). It does not set phylink_config.default_an_inband, so cfg_link_an_mode stays at MLO_AN_PHY.
On open this gives:
axienet_open()
phylink_fwnode_phy_connect(lp->phylink, dev_fwnode(lp->dev), 0)
fwnode_get_phy_node() fails, since there is no phy-handle
if (pl->cfg_link_an_mode == MLO_AN_PHY)
return -ENODEV;A node that matches this binding, including either example, would then fail ndo_open with "phylink_of_phy_connect() failed". Is that expected?
Also, phylink_pcs_poll_start() only polls the internal PCS when cfg_link_an_mode == MLO_AN_INBAND.
Should the binding require managed: const: in-band-status? The other option is for the XXV phylink_set_caps to set default_an_inband = true. Either way, could the binding document the chosen mode?
Quoted 3 lines
Documentation/devicetree/bindings/net/xlnx,xxv-ethernet.yaml new file +3
-0+ Any SFP module management (e.g. I2C) is handled by separate IP outside this + binding. Its payload is moved by an external AXI DMA (or multichannel DMA) + controller referenced through the "dmas" property.
[ ... ]
Documentation/devicetree/bindings/net/xlnx,xxv-ethernet.yaml line 42
Quoted 11 lines
Documentation/devicetree/bindings/net/xlnx,xxv-ethernet.yaml new file +11
-0+ clocks: + items: + - description: RX AXI4-Stream clock. + - description: GT DRP clock. + - description: AXI4-Lite register clock. + + clock-names: + items: + - const: rx_core + - const: drp + - const: s_axi
[Severity: Medium]
How would a DT describe the transceiver (GT) reference clock here? The description says the in-core PCS/PMA drives a high-speed serial transceiver, and that transceiver has its own reference clock input.
The clocks/clock-names list is fixed at three entries, and unevaluatedProperties is false. A DT that also lists the GT refclk would fail validation. xlnx,axi-ethernet.yaml already documents mgt_clk for its optional internal PCS/PMA PHY.
Later in the series, axienet_10g25g_clk_init() claims only s_axi, rx_core and drp. axienet_xxv_poll_link_ready() then fails open when GT reset-done times out:
netdev_err(ndev, "XXV MAC GT reset not complete! Cross-check the MAC ref clock configuration\n");
On boards where a Linux-managed, gateable clock provider supplies the GT refclk, nothing claims that clock. Unused clock cleanup could then gate it. This depends on the board.
Could an optional trailing clock (minItems: 3) be added now? writing-bindings.rst asks for complete bindings even when the driver does not use every feature.
[ ... ]
Documentation/devicetree/bindings/net/xlnx,xxv-ethernet.yaml line 68
Quoted 8 lines
Documentation/devicetree/bindings/net/xlnx,xxv-ethernet.yaml new file +8
-0+ dma-names: + items: + pattern: "^[tr]x_chan([0-9]|1[0-5])$" + description: + Should be "tx_chan0", "tx_chan1" ... "tx_chan15" for DMA Tx channel and + "rx_chan0", "rx_chan1" ... "rx_chan15" for DMA Rx channel. + minItems: 2 + maxItems: 32
[Severity: Low]
This checks the name pattern and the count. It does not require "tx_chan0" and "rx_chan0", or even one TX and one RX entry. Both of these pass dt_binding_check:
dma-names = "tx_chan1", "rx_chan1";
dma-names = "tx_chan0", "tx_chan1";The driver requests fixed names, though:
axienet_probe()
tx_chan = dma_request_chan(lp->dev, "tx_chan0");
if (IS_ERR(tx_chan))
return dev_err_probe(lp->dev, PTR_ERR(tx_chan), "No Ethernet DMA (TX) channel found\n");axienet_init_dmaengine()
lp->tx_chan = dma_request_chan(lp->dev, "tx_chan0");
...
lp->rx_chan = dma_request_chan(lp->dev, "rx_chan0");Since dmas is required, XXV always takes this path. Could contains constraints for "tx_chan0" and "rx_chan0" be added? Another option is to fix the leading entries with items/additionalItems.
The pattern came from xlnx,axi-ethernet.yaml, but this patch creates a new binding with it.
[ ... ]
Signature · 1 line
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261006110550.1990213-1-suraj.gupta2%40amd.com
Re: [PATCH net-next v4 2/6] dt-bindings: net: xlnx,xxv-ethernet: Add Xilinx XXV 10G/25G Ethernet
Quoted 62 lines · On 10/10/2026 5:25 PM, [email protected] wrote:
Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider.
Critical: 0 · High: 1 · Medium: 1 · 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).
- [High] The XXV binding never says how link management works, so a node that passes the schema, including both examples in the binding, cannot…
- [Medium] The binding has no way to describe the XXV transceiver (GT) reference clock.
- [Low] The new XXV binding'sdma-namesschema only checks a per-item pattern (^[tr]x_chan([0-9]|1[0-5])$) and a count of 2 to 32.--
dt-bindings: net: xlnx,xxv-ethernet: Add Xilinx XXV 10G/25G Ethernet
This adds a new DT binding schema for the Xilinx XXV 10G/25G Ethernet IP. The IP has an in-core PCS/PMA and uses an external AXI DMA or MCDMA. The binding covers the 10gbase-r/25gbase-r phy-modes, the rx_core/drp/s_axi clocks and the dmas/dma-names properties.
Quoted 6 lines
Documentation/devicetree/bindings/net/xlnx,xxv-ethernet.yaml new file +0
-0@@ -0,0 +1,110 @@[ ... ]
Documentation/devicetree/bindings/net/xlnx,xxv-ethernet.yaml line 19
Quoted 7 lines
Documentation/devicetree/bindings/net/xlnx,xxv-ethernet.yaml new file +7
-0+description: + The Xilinx XXV Ethernet Subsystem implements a 10G/25G Ethernet MAC with an + in-core PCS/PMA driving a high-speed serial transceiver. It supports the + 10GBASE-R and 25GBASE-R line rates, with 25G operation following the 25G + Ethernet Consortium specification. Because the PCS/PMA is integrated into + the IP, the subsystem has no MDIO bus master and is not managed through an + external MDIO PHY; link state is read from the MAC's own status registers.[Severity: High]
The binding says there is no external MDIO PHY. It does not require or show managed = "in-band-status" or a fixed-link node, though. Neither example has phy-handle, fixed-link or managed.The XXV support added later in this series sets only
mac_capabilitiesandsupported_interfacesinaxienet_xxv_phylink_set_capabilities(). It does not set phylink_config.default_an_inband, socfg_link_an_modestays atMLO_AN_PHY.On open this gives:
axienet_open()
phylink_fwnode_phy_connect(lp->phylink, dev_fwnode(lp->dev), 0)fwnode_get_phy_node() fails, since there is no phy-handle if (pl->cfg_link_an_mode == MLO_AN_PHY) return -ENODEV;
Quoted 8 lines
A node that matches this binding, including either example, would then fail
ndo_openwith "phylink_of_phy_connect()failed". Is that expected?Also,
phylink_pcs_poll_start()only polls the internal PCS whencfg_link_an_mode==MLO_AN_INBAND.Should the binding require managed: const: in-band-status? The other option is for the XXV
phylink_set_capsto setdefault_an_inband= true.
Correct. The XXV subsystem has an integrated PCS/PMA and no external PHY, so link is managed in-band from the MAC status registers. The driver should therefore default to in-band mode.
Quoted 36 lines
Either way, could the binding document the chosen mode?
Quoted 3 lines
Documentation/devicetree/bindings/net/xlnx,xxv-ethernet.yaml new file +3
-0+ Any SFP module management (e.g. I2C) is handled by separate IP outside this + binding. Its payload is moved by an external AXI DMA (or multichannel DMA) + controller referenced through the "dmas" property.[ ... ]
Documentation/devicetree/bindings/net/xlnx,xxv-ethernet.yaml line 42
Quoted 11 lines
Documentation/devicetree/bindings/net/xlnx,xxv-ethernet.yaml new file +11
-0+ clocks: + items: + - description: RX AXI4-Stream clock. + - description: GT DRP clock. + - description: AXI4-Lite register clock. + + clock-names: + items: + - const: rx_core + - const: drp + - const: s_axi[Severity: Medium]
How would a DT describe the transceiver (GT) reference clock here? The description says the in-core PCS/PMA drives a high-speed serial transceiver, and that transceiver has its own reference clock input.The clocks/clock-names list is fixed at three entries, and unevaluatedProperties is false. A DT that also lists the GT refclk would fail validation. xlnx,axi-ethernet.yaml already documents
mgt_clkfor its optional internal PCS/PMA PHY.Later in the series,
axienet_10g25g_clk_init()claims onlys_axi,rx_coreand drp.axienet_xxv_poll_link_ready()then fails open when GT reset-done times out:netdev_err(ndev, "XXV MAC GT reset not complete! Cross-check the MAC ref clock configuration\n");
Quoted 8 lines
On boards where a Linux-managed, gateable clock provider supplies the GT refclk, nothing claims that clock. Unused clock cleanup could then gate it. This depends on the board.
Could an optional trailing clock (minItems: 3) be added now?
writing-bindings.rstasks for complete bindings even when the driver does not use every feature.
Agreed. The three current clocks (rx_core -> rx_core_clk, drp -> dclk, s_axi -> s_axi_aclk) are correct, but per PG210 the GT has a dedicated differential reference clock (refclk_p0/refclk_n0 -> tx_serdes_refclk) that the list cannot express today. I'll add an optional trailing clock, mirroring mgt_clk in xlnx,axi-ethernet.yaml
Quoted 31 lines
[ ... ]
Documentation/devicetree/bindings/net/xlnx,xxv-ethernet.yaml line 68
Quoted 8 lines
Documentation/devicetree/bindings/net/xlnx,xxv-ethernet.yaml new file +8
-0+ dma-names: + items: + pattern: "^[tr]x_chan([0-9]|1[0-5])$" + description: + Should be "tx_chan0", "tx_chan1" ... "tx_chan15" for DMA Tx channel and + "rx_chan0", "rx_chan1" ... "rx_chan15" for DMA Rx channel. + minItems: 2 + maxItems: 32[Severity: Low]
This checks the name pattern and the count. It does not require "tx_chan0" and "rx_chan0", or even one TX and one RX entry. Both of these passdt_binding_check:dma-names = "tx_chan1", "rx_chan1"; dma-names = "tx_chan0", "tx_chan1";The driver requests fixed names, though:
axienet_probe()tx_chan = dma_request_chan(lp->dev, "tx_chan0"); if (IS_ERR(tx_chan)) return dev_err_probe(lp->dev, PTR_ERR(tx_chan), "No Ethernet DMA (TX) channel found\n");
axienet_init_dmaengine()lp->tx_chan = dma_request_chan(lp->dev, "tx_chan0"); ... lp->rx_chan = dma_request_chan(lp->dev, "rx_chan0");
Quoted 7 lines
Since dmas is required, XXV always takes this path. Could contains constraints for "
tx_chan0" and "rx_chan0" be added? Another option is to fix the leading entries with items/additionalItems.The pattern came from xlnx,axi-ethernet.yaml, but this patch creates a new binding with it.
Agreed, the driver hard-requests "tx_chan0"/"rx_chan0". For v5 I'll add contains constraints so at least one tx_chan0 and one rx_chan0 are required, while still allowing the additional MCDMA channels.
Thanks,
Suraj
Quoted 2 lines
[ ... ]
PATCH v4 3/6 net: xilinx: axienet: Add 10G/25G (XXV) ethernet support
In reply to Suraj GuptaThe AXI Ethernet driver currently supports only the AXI 1G Ethernet IP. Add support for the Xilinx XXV Ethernet IP[1], which implements a 10G/25G Ethernet MAC with PCS/PMA driving a high-speed serial transceiver, as specified by the 25G Ethernet Consortium.
Add the XXV-specific logic in new xilinx_axienet_xxv.c/.h files and describe the MAC through an axienet_10g25g_config that provides the capability flags and callbacks (GT reset, link-ready polling, options programming, phylink caps, PCS ops, register dump and probe-time init). No MAC-specific conditionals are added to the shared paths.
Also propagate the axienet_device_reset() failure in axienet_open(), which was previously overwritten by phylink_of_phy_connect() before being checked. This matters for XXV, whose mac_init() can fail on a GT reset-done timeout.
[1]: https://docs.amd.com/r/en-US/pg210-25g-ethernet
--- drivers/net/ethernet/xilinx/Makefile | 3 +- drivers/net/ethernet/xilinx/xilinx_axienet.h | 9 + .../net/ethernet/xilinx/xilinx_axienet_main.c | 17 +- .../net/ethernet/xilinx/xilinx_axienet_xxv.c | 323 ++++++++++++++++++ .../net/ethernet/xilinx/xilinx_axienet_xxv.h | 86 +++++ 5 files changed, 431 insertions(+), 7 deletions(-) create mode 100644 drivers/net/ethernet/xilinx/xilinx_axienet_xxv.c create mode 100644 drivers/net/ethernet/xilinx/xilinx_axienet_xxv.h
drivers/net/ethernet/xilinx/Makefile +2 -1
@@ -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
drivers/net/ethernet/xilinx/xilinx_axienet.h +9 -0
@@ -17,6 +17,8 @@#include <linux/phylink.h> #include <linux/skbuff.h> +#include "xilinx_axienet_xxv.h" +/* Packet size info */ #define XAE_HDR_SIZE 14/* Size of Ethernet header */ #define XAE_TRL_SIZE 4/* Size of Ethernet trailer (FCS) */
@@ -545,6 +547,7 @@ struct skbuf_dma_descriptor {* @tx_ring_tail: TX skb ring buffer tail index. * @rx_ring_head: RX skb ring buffer head index. * @rx_ring_tail: RX skb ring buffer tail index. +* @xxv_ip_version: XXV IP version. * @axienet_config: MAC-type specific configuration and operations. */ struct axienet_local {
@@ -627,6 +630,7 @@ struct axienet_local {int tx_ring_tail;int rx_ring_head;int rx_ring_tail; +u32 xxv_ip_version;const struct axienet_config *axienet_config; };
@@ -680,6 +684,11 @@ struct axienet_config {void (*stats_update)(struct axienet_local *lp); }; +static inline struct axienet_local *pcs_to_axienet_local (struct phylink_pcs *pcs) +{ + return container_of(pcs, struct axienet_local, pcs); +} +/** * struct axienet_option - Used to set axi ethernet hardware options * @opt: Option to be set.
drivers/net/ethernet/xilinx/xilinx_axienet_main.c +11 -6
@@ -1706,6 +1706,10 @@ static int axienet_open(struct net_device *ndev)axienet_lock_mii (lp); ret =axienet_device_reset (ndev);axienet_unlock_mii (lp); +if (ret) { +dev_err (lp->dev,"axienet_device_reset() failed: %d\n" , ret); +return ret; + } ret =phylink_fwnode_phy_connect (lp->phylink,dev_fwnode (lp->dev),0 );if (ret) {
@@ -2605,11 +2609,6 @@ static const struct ethtool_ops axienet_ethtool_dmaengine_ops = { .get_rmon_stats = axienet_ethtool_get_rmon_stats, }; -static struct axienet_local *pcs_to_axienet_local (struct phylink_pcs *pcs) -{ - return container_of(pcs, struct axienet_local, pcs); -} -static void axienet_pcs_get_state (struct phylink_pcs *pcs,unsigned int neg_mode,struct phylink_link_state *state)
@@ -2669,7 +2668,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 ;
@@ -2815,6 +2816,9 @@ static void axienet_dma_err_handler(struct work_struct *work)axienet_dma_start (lp); +/* This error handler runs only for the non-dmaengine flow (1G MAC), +* whose mac_init() cannot fail, so its return value is not checked. +*/ lp->axienet_config->mac_init (ndev);/* Sync default options with HW but leave receiver and
@@ -2918,6 +2922,7 @@ static const struct of_device_id axienet_of_match[] = { { .compatible = "xlnx,axi-ethernet-1.00.a", .data = &axienet_1g_config }, { .compatible = "xlnx,axi-ethernet-1.01.a", .data = &axienet_1g_config }, { .compatible = "xlnx,axi-ethernet-2.01.a", .data = &axienet_1g_config }, + { .compatible = "xlnx,xxv-ethernet-1.0", .data = &axienet_10g25g_config }, {}, };
drivers/net/ethernet/xilinx/xilinx_axienet_xxv.c new file +323 -0
323 lines not on this page · raw message
drivers/net/ethernet/xilinx/xilinx_axienet_xxv.h new file +86 -0
86 lines not on this page · raw message
Signature · 1 line
2.25.1
[email protected]
AI reviewThank you for your contribution! Sashiko AI review found 10 potential issue(s) to consider.
Thank you for your contribution! Sashiko AI review found 10 potential issue(s) to consider.
Critical: 0 · High: 4 · Medium: 2 (1) · 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] Under the new xlnx,xxv-ethernet binding, the interface cannot be opened.
- [High] The new early return in axienet_open() leads to a double free / use-after-free after a failed resume.
- [High] The XXV RX path takes frame lengths from a source the XXV hardware does not write.
- [High] The XXV MAC's receive max-packet-length register is never programmed to match the RX buffer size.
- [Medium] Pause is advertised and reported for XXV but never applied to the hardware.
- [Medium] The GT reset-done timeout is only 1 ms, and this patch makes missing it fatal to ndo_open.
- [Low] A real fix for an existing 1G bug is bundled into this feature patch without a Fixes: tag.
- [Low] axienet_xxv_poll_link_ready()'s kernel-doc says missing PCS block lock is expected with an unplugged cable and must not fail bring-up,…
- [Low] The jumbo-frame flag and the MTU range disagree for XXV.
- [Low] The kernel-doc for axienet_device_reset() is now wrong for XXV.
Pre-existing issues:
- [Medium] axienet_dma_rx_cb() passes rx_len = app_metadata[LEN_APP] & 0xFFFF straight to skb_put().
--
net: xilinx: axienet: Add 10G/25G (XXV) ethernet support
This patch adds support for the Xilinx XXV 10G/25G Ethernet IP to the axienet driver. The XXV-specific code lives in new xilinx_axienet_xxv.c/.h files and is described through an axienet_10g25g_config with callbacks. It also propagates axienet_device_reset() failures from axienet_open().
drivers/net/ethernet/xilinx/xilinx_axienet_main.c static int axienet_open(struct net_device *ndev) · line 1716
Quoted 12 lines
drivers/net/ethernet/xilinx/xilinx_axienet_main.c +4
-0@@ -1710,6 +1710,10 @@ static int axienet_open(struct net_device *ndev)axienet_lock_mii (lp); ret =axienet_device_reset (ndev);axienet_unlock_mii (lp); +if (ret) { +dev_err (lp->dev,"axienet_device_reset() failed: %d\n" , ret); +return ret; + }
[Severity: Low]
This isn't a bug in the new code, but this check also fixes an existing problem on the 1G path. Before this patch, phylink_fwnode_phy_connect() overwrote the ret from axienet_device_reset() before anything checked it.
On the 1G legacy DMA path, axienet_device_reset() can already fail. That happens when __axienet_device_reset() times out or when axienet_dma_bd_init() cannot allocate descriptors:
axienet_device_reset() {
...
ret = __axienet_device_reset(lp);
if (ret)
return ret;
ret = axienet_dma_bd_init(ndev);
...
}In those cases open continued into phylink_start() and axienet_init_legacy_dma(). The core had not been reset, or there were no BD rings.
The commit message only says this "matters for XXV". Could this go to net as a separate fix with a Fixes: tag, so stable picks it up?
[Severity: High]
Can this early return lead to a double free after a failed resume?
axienet_suspend() calls axienet_stop(). In dmaengine mode, the only mode XXV supports, that frees the skb rings and releases the DMA channels. It does not clear the pointers:
axienet_stop() {
...
for (i = 0; i < TX_BD_NUM_MAX; i++)
kfree(lp->tx_skb_ring[i]);
kfree(lp->tx_skb_ring);
...
dma_release_channel(lp->rx_chan);
dma_release_channel(lp->tx_chan);
...
}axienet_resume() then ignores what axienet_open() returns:
axienet_resume() {
...
rtnl_lock();
axienet_open(ndev);
rtnl_unlock();
netif_device_attach(ndev);
...
}Suppose axienet_xxv_mac_init() returns -ETIMEDOUT from the GT reset-done poll. axienet_open() now returns before axienet_init_dmaengine() runs, but the netdev is still netif_running().
The next ndo_stop can come from ifdown, from dev_close() in axienet_shutdown(), or from unregister_netdev() in axienet_remove(). It would run axienet_stop() again. That calls dmaengine_terminate_sync() on the released channels and kfree()s the already freed tx_skb_ring/rx_skb_ring arrays and their entries. It then calls dma_release_channel() a second time.
Before this patch the reset error was overwritten and open always re-allocated, so stop stayed balanced. Resume ignoring the open error predates this patch, but this early return is what makes the problem reachable.
Quoted 3 lines
drivers/net/ethernet/xilinx/xilinx_axienet_main.c +0
-0ret =phylink_fwnode_phy_connect (lp->phylink,dev_fwnode (lp->dev),0 );if (ret) {
[ ... ]
Quoted 6 lines
drivers/net/ethernet/xilinx/xilinx_axienet_xxv.c new file +0
-0@@ -0,0 +1,323 @@
[ ... ]
Quoted 11 lines
drivers/net/ethernet/xilinx/xilinx_axienet_xxv.c new file +11
-0+/* Option table for setting up XXV Ethernet hardware options */ +static struct axienet_option xxvenet_options[] = { + {/* Turn on FCS stripping on receive packets */ + .opt =XAE_OPTION_FCS_STRIP , + .reg =XXV_RCW1_OFFSET , + .m_or =XXV_RCW1_FCS_MASK , + }, {/* Turn on FCS insertion on transmit packets */ + .opt =XAE_OPTION_FCS_INSERT , + .reg =XXV_TC_OFFSET , + .m_or =XXV_TC_FCS_MASK , + }, {/* Enable transmitter */
drivers/net/ethernet/xilinx/xilinx_axienet_xxv.c line 96
Quoted 10 lines
drivers/net/ethernet/xilinx/xilinx_axienet_xxv.c new file +10
-0+ .opt = XAE_OPTION_TXEN, + .reg = XXV_TC_OFFSET, + .m_or = XXV_TC_TX_MASK, + }, { /* Enable receiver */ + .opt = XAE_OPTION_RXEN, + .reg = XXV_RCW1_OFFSET, + .m_or = XXV_RCW1_RX_MASK, + }, + {} +};
[Severity: Medium]
Is the pause configuration ever applied to the XXV MAC?
axienet_probe() sets MAC_SYM_PAUSE | MAC_ASYM_PAUSE in lp->phylink_config.mac_capabilities for every MAC type. axienet_xxv_phylink_set_capabilities() only adds speed bits, so XXV advertises both pause modes.
axienet_10g25g_config has no .mac_link_up. axienet_mac_link_up() therefore silently drops the resolved tx_pause/rx_pause:
if (lp->axienet_config->mac_link_up) lp->axienet_config->mac_link_up(ndev, speed, tx_pause, rx_pause);
This table also has no XAE_OPTION_FLOW_CONTROL entry. The XXV_CONFIG_TX_FLOW_CTRL1_OFFSET and XXV_CONFIG_RX_FLOW_CTRL1/2_OFFSET registers are only read for ethtool -d and never written.
As a result, phylink and ethtool -a/-A report and accept pause settings while the MAC stays at its reset default. Should XXV program the flow control registers from a mac_link_up callback, or stop advertising pause?
[ ... ]
Quoted 8 lines
drivers/net/ethernet/xilinx/xilinx_axienet_xxv.c new file +8
-0+/** +* axienet_xxv_gt_reset - Pulse the XXV GT reset line +* @lp: Pointer to the axienet_local structure +*/ +static void axienet_xxv_gt_reset (struct axienet_local *lp) +{ +u32 val; +
drivers/net/ethernet/xilinx/xilinx_axienet_xxv.c line 156
Quoted 10 lines
drivers/net/ethernet/xilinx/xilinx_axienet_xxv.c new file +10
-0+/* Reset GT */ + val =axienet_ior (lp,XXV_GT_RESET_OFFSET ); + val |=XXV_GT_RESET_MASK ; +axienet_iow (lp,XXV_GT_RESET_OFFSET , val); +/* Allow 1 ms for the GT reset to settle (see timeout note above) */ +usleep_range (1000 ,2000 ); + val =axienet_ior (lp,XXV_GT_RESET_OFFSET ); + val &= ~XXV_GT_RESET_MASK ; +axienet_iow (lp,XXV_GT_RESET_OFFSET , val); +}
[Severity: Low]
The kernel-doc for axienet_device_reset() in xilinx_axienet_main.c still says:
* Ethernet core. No separate hardware reset is done for the Axi Ethernet
* core.
For XXV, that function now calls config->gt_reset() first, and this pulses XXV_GT_RESET_MASK. XXV is dmaengine-only, so the DMA reset and BD init described there never happen. The function now also returns mac_init() failures such as the GT reset-done timeout.
Could the comment be updated to match?
[ ... ]
Quoted 6 lines
drivers/net/ethernet/xilinx/xilinx_axienet_xxv.c new file +6
-0+static int axienet_xxv_poll_link_ready (struct net_device *ndev) +{ +struct axienet_local *lp =netdev_priv (ndev); +u32 val; +int ret; +
drivers/net/ethernet/xilinx/xilinx_axienet_xxv.c line 183
Quoted 10 lines
drivers/net/ethernet/xilinx/xilinx_axienet_xxv.c new file +10
-0+/* Confirm XXV Ethernet is up: on IP v3.2+, wait for GT +* reset-done before further register access, then poll until +* RX PCS block lock is asserted. +*/ +if (axienet_xxv_ip_has_gtwiz_status (lp->xxv_ip_version)) { + ret =readl_poll_timeout (lp->regs +XXV_STAT_GTWIZ_OFFSET , + val, + (val &XXV_GTWIZ_RESET_DONE ) ==XXV_GTWIZ_RESET_DONE , +XXV_LINK_POLL_INTERVAL_US , +DELAY_OF_ONE_MILLISEC );
[Severity: Medium]
Is 1 ms long enough for GT reset-done?
axienet_xxv_gt_reset() releases ctl_gt_reset_all after 1-2 ms, and the GT reset sequence only starts at that release. This poll then gives the GT wizard DELAY_OF_ONE_MILLISEC to assert both TX and RX reset-done.
GT reset-done covers PLL re-lock and the RX reset sequence. With no signal present, the CDR lock wait in that sequence can run until its internal timeout. The comment at the top of the file says the bound is empirical and that PG210 does not specify it.
With the new check in axienet_open(), a timeout here now fails ndo_open. Could an unplugged cable push this past 1 ms and fail bring-up? The kernel-doc above says an unplugged cable must not do that.
Quoted 5 lines
drivers/net/ethernet/xilinx/xilinx_axienet_xxv.c new file +5
-0+if (ret) { +netdev_err (ndev,"XXV MAC GT reset not complete! Cross-check the MAC ref clock configuration\n" ); +return ret; + } + }
drivers/net/ethernet/xilinx/xilinx_axienet_xxv.c line 198
Quoted 10 lines
drivers/net/ethernet/xilinx/xilinx_axienet_xxv.c new file +10
-0+ + ret =readl_poll_timeout (lp->regs +XXV_STATRX_BLKLCK_OFFSET , + val, (val &XXV_RX_BLKLCK_MASK ), +XXV_LINK_POLL_INTERVAL_US , +DELAY_OF_ONE_MILLISEC ); +if (ret) +netdev_err (ndev,"XXV MAC block lock not complete! Cross-check the MAC ref clock configuration\n" ); + +return 0 ; +}
[Severity: Low]
The kernel-doc says a missing block lock is expected with an unplugged cable, and the function returns 0 in that case. Should this be logged below netdev_err()?
As written, every ip link set up on a port with no link partner logs an error that points at the ref clock configuration.
Quoted 11 lines
drivers/net/ethernet/xilinx/xilinx_axienet_xxv.c new file +11
-0+ +/** +* axienet_xxv_mac_init - XXV MAC-specific bring-up after the DMA reset +* @ndev: Pointer to the net_device structure +* +* Return: 0 on success or a negative error number otherwise. +*/ +static int axienet_xxv_mac_init (struct net_device *ndev) +{ +struct axienet_local *lp =netdev_priv (ndev); +int ret;
drivers/net/ethernet/xilinx/xilinx_axienet_xxv.c line 219
Quoted 10 lines
drivers/net/ethernet/xilinx/xilinx_axienet_xxv.c new file +10
-0+ + ret =axienet_xxv_poll_link_ready (ndev); +if (ret) +return ret; + + lp->options |=XAE_OPTION_FCS_STRIP ; + lp->options |=XAE_OPTION_FCS_INSERT ; + +return 0 ; +}
[Severity: High]
Should the XXV RX max packet length be programmed here?
XXV_JUM_OFFSET (CONFIGURATION_RX_MTU, ctl_rx_max_packet_len) appears only in the ethtool -d table and is never written. Its reset default is 9600 bytes.
At the default MTU, axienet_device_reset() sets lp->max_frm_size to XAE_MAX_VLAN_FRAME_SIZE (1522). axienet_rx_submit_desc() maps each RX buffer at exactly that size.
If a link partner sends frames of 1523 to 9600 bytes, the MAC accepts them and splits each one across several S2MM descriptors. axienet_dma_rx_cb() treats every completion as a whole frame. Would these fragmented frames be passed up the stack?
Changing the MTU never updates the MAC either, so the software and hardware frame limits can be out of sync in both directions. On 1G the MAC drops frames above its configured limit, so this does not happen there.
Quoted 11 lines
drivers/net/ethernet/xilinx/xilinx_axienet_xxv.c new file +11
-0+ +static void axienet_xxv_phylink_set_capabilities (struct axienet_local *lp, +struct phylink_config *cfg) +{ +u32 core_speed; + + core_speed =axienet_ior (lp,XXV_STAT_CORE_SPEED_OFFSET ); +/* Bit[1:0]: 00=25G, 01=10G, 10=runtime-switchable 25G, +* 11=runtime-switchable 10G. Bit 0 is the active rate. Advertise +* only that rate. +*/
drivers/net/ethernet/xilinx/xilinx_axienet_xxv.c line 240
Quoted 10 lines
drivers/net/ethernet/xilinx/xilinx_axienet_xxv.c new file +10
-0+if (core_speed &XXV_STAT_CORE_SPEED_10G_MASK ) { + cfg->mac_capabilities |=MAC_10000FD ; +__set_bit (PHY_INTERFACE_MODE_10GBASER , + cfg->supported_interfaces); + }else { + cfg->mac_capabilities |=MAC_25000FD ; +__set_bit (PHY_INTERFACE_MODE_25GBASER , + cfg->supported_interfaces); + } +}
[Severity: High]
Can the XXV interface be opened with a device tree that follows the new binding?
The xlnx,xxv-ethernet binding comes from "dt-bindings: net:
xlnx,xxv-ethernet: Add Xilinx XXV 10G/25G Ethernet". It requires neither phy-handle nor managed = "in-band-status", and neither of its examples has them.
Nothing sets lp->phylink_config.default_an_inband for XXV. At the end of the series there is no default_an_inband anywhere in drivers/net/ethernet/xilinx/. phylink_parse_mode() therefore leaves cfg_link_an_mode as MLO_AN_PHY.
axienet_open() then calls phylink_fwnode_phy_connect(), which does:
phy_fwnode = fwnode_get_phy_node(fwnode);
if (IS_ERR(phy_fwnode)) {
if (pl->cfg_link_an_mode == MLO_AN_PHY)
return -ENODEV;
return 0;
}axienet_open() passes that -ENODEV back to the caller, so the interface never comes up. Should this function set cfg->default_an_inband = true, or should the binding require managed = "in-band-status"?
[ ... ]
drivers/net/ethernet/xilinx/xilinx_axienet_xxv.c line 323
Quoted 13 lines
drivers/net/ethernet/xilinx/xilinx_axienet_xxv.c new file +13
-0+const struct axienet_config axienet_10g25g_config = { + .sw_padding = true, + .internal_pcs = true, + .regs_n =XXV_REGS_N , + .clk_init = axienet_10g25g_clk_init, + .setoptions = axienet_xxv_setoptions, + .probe_init = axienet_xxv_probe_init, + .gt_reset = axienet_xxv_gt_reset, + .mac_init = axienet_xxv_mac_init, + .get_regs = axienet_xxv_get_regs, + .phylink_set_caps = axienet_xxv_phylink_set_capabilities, + .pcs_ops = &axienet_xxv_pcs_ops, +};
[Severity: Low]
This leaves .jumbo false, which the kernel-doc defines as "MAC supports jumbo frames" being false. axienet_probe() still sets ndev->max_mtu = XAE_JUMBO_MTU for every MAC. axienet_change_mtu() only checks against lp->rxmem:
if ((new_mtu + VLAN_ETH_HLEN + XAE_TRL_SIZE) > lp->rxmem) return -EINVAL;
So ip link set mtu 9000 is accepted on XXV. For XXV, is the .jumbo flag wrong, or the max_mtu? xxvenet_options also has no XAE_OPTION_JUMBO entry, and XXV_JUM_OFFSET is never written.
[Severity: High]
Where does XXV get the RX frame length from?
.non_dmaengine is left false, so every XXV RX completion goes through axienet_dma_rx_cb(). That callback reads the length from AXI DMA APP word 4:
/* TODO: Derive app word index programmatically */ rx_len = (app_metadata[LEN_APP] & 0xFFFF);
On the 1G AXI Ethernet, the MAC's RX status stream writes that word. PG210 describes the XXV IP with only AXI4-Stream data interfaces and no status stream.
xilinx_dma only attaches metadata_ops when the DMA node has xlnx,axistream-connected:
if (chan->xdev->has_axistream_connected) desc->async_tx.metadata_ops = &xilinx_dma_metadata_ops;
Without that property, dmaengine_desc_get_metadata_ptr() fails and every received frame is counted as rx_dropped. With it, app4 holds stale or zero BD contents. Zero-length skbs or wrong lengths would then reach eth_type_trans() and skb_put().
The real byte count is in the BD status length field, which xilinx_dma reports as the residue. Does XXV need its own MAC-specific RX length source?
[Severity: Medium]
This is a pre-existing issue, but XXV now goes through the same callback. axienet_dma_rx_cb() passes the metadata length straight to skb_put():
rx_len = (app_metadata[LEN_APP] & 0xFFFF); skb_put(skb, rx_len);
The callback does not check the dmaengine result or residue. rx_len is not bounded by lp->max_frm_size or skb_tailroom() either. Could a length larger than the posted buffer hit skb_over_panic()? The 1G dmaengine path already had this problem.
Signature · 1 line
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261006110550.1990213-1-suraj.gupta2%40amd.com
Quoted 75 lines · On 10/10/2026 5:25 PM, [email protected] wrote:
Thank you for your contribution! Sashiko AI review found 10 potential issue(s) to consider.
Critical: 0 · High: 4 · Medium: 2 (1) · 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] Under the new xlnx,xxv-ethernet binding, the interface cannot be opened.
- [High] The new early return inaxienet_open()leads to a double free / use-after-free after a failed resume.
- [High] The XXV RX path takes frame lengths from a source the XXV hardware does not write.
- [High] The XXV MAC's receive max-packet-length register is never programmed to match the RX buffer size.
- [Medium] Pause is advertised and reported for XXV but never applied to the hardware.
- [Medium] The GT reset-done timeout is only 1 ms, and this patch makes missing it fatal tondo_open.
- [Low] A real fix for an existing 1G bug is bundled into this feature patch without a Fixes: tag.
- [Low] axienet_xxv_poll_link_ready()'s kernel-doc says missing PCS block lock is expected with an unplugged cable and must not fail bring-up,…
- [Low] The jumbo-frame flag and the MTU range disagree for XXV.
- [Low] The kernel-doc foraxienet_device_reset()is now wrong for XXV.Pre-existing issues:
- [Medium]axienet_dma_rx_cb()passesrx_len = app_metadata[LEN_APP] & 0xFFFFstraight toskb_put().--
net: xilinx: axienet: Add 10G/25G (XXV) ethernet support
This patch adds support for the Xilinx XXV 10G/25G Ethernet IP to the axienet driver. The XXV-specific code lives in new xilinx_axienet_xxv.c/.h files and is described through an
axienet_10g25g_configwith callbacks. It also propagatesaxienet_device_reset()failures fromaxienet_open().drivers/net/ethernet/xilinx/xilinx_axienet_main.c static int axienet_open(struct net_device *ndev) · line 1716
Quoted 12 lines
drivers/net/ethernet/xilinx/xilinx_axienet_main.c +4
-0@@ -1710,6 +1710,10 @@ static int axienet_open(struct net_device *ndev)axienet_lock_mii (lp); ret =axienet_device_reset (ndev);axienet_unlock_mii (lp); +if (ret) { +dev_err (lp->dev,"axienet_device_reset() failed: %d\n" , ret); +return ret; + }[Severity: Low]
This isn't a bug in the new code, but this check also fixes an existing problem on the 1G path. Before this patch,phylink_fwnode_phy_connect()overwrote the ret fromaxienet_device_reset()before anything checked it.On the 1G legacy DMA path,
axienet_device_reset()can already fail. That happens when__axienet_device_reset()times out or whenaxienet_dma_bd_init()cannot allocate descriptors:axienet_device_reset() { ... ret = __axienet_device_reset(lp); if (ret) return ret; ret = axienet_dma_bd_init(ndev); ... }
Quoted 6 lines
In those cases open continued into
phylink_start()andaxienet_init_legacy_dma(). The core had not been reset, or there were no BD rings.The commit message only says this "matters for XXV". Could this go to net as a separate fix with a Fixes: tag, so stable picks it up?
This is a pre-existing bug & can be fixed in separate series.>
Quoted 40 lines
[Severity: High]
Can this early return lead to a double free after a failed resume?
axienet_suspend()callsaxienet_stop(). In dmaengine mode, the only mode XXV supports, that frees the skb rings and releases the DMA channels. It does not clear the pointers:axienet_stop() { ... for (i = 0; i < TX_BD_NUM_MAX; i++) kfree(lp->tx_skb_ring[i]); kfree(lp->tx_skb_ring); ... dma_release_channel(lp->rx_chan); dma_release_channel(lp->tx_chan); ... }
axienet_resume()then ignores whataxienet_open()returns:axienet_resume() { ... rtnl_lock(); axienet_open(ndev); rtnl_unlock(); netif_device_attach(ndev); ... }Suppose
axienet_xxv_mac_init()returns-ETIMEDOUTfrom the GT reset-done poll.axienet_open()now returns beforeaxienet_init_dmaengine()runs, but the netdev is stillnetif_running().The next
ndo_stopcan come from ifdown, fromdev_close()inaxienet_shutdown(), or fromunregister_netdev()inaxienet_remove(). It would runaxienet_stop()again. That callsdmaengine_terminate_sync()on the released channels and kfree()s the already freed tx_skb_ring/rx_skb_ring arrays and their entries. It then callsdma_release_channel()a second time.
Quoted 6 lines
Before this patch the reset error was overwritten and open always re-allocated, so stop stayed balanced. Resume ignoring the open error predates this patch, but this early return is what makes the problem reachable.
Quoted 1 line
Agree, will fix it>> ret = phylink_fwnode_phy_connect(lp->phylink, dev_fwnode(lp->dev), 0);
Quoted 49 lines
Quoted 1 line
if (ret) {[ ... ]
Quoted 6 lines
drivers/net/ethernet/xilinx/xilinx_axienet_xxv.c new file +0
-0@@ -0,0 +1,323 @@[ ... ]
Quoted 11 lines
drivers/net/ethernet/xilinx/xilinx_axienet_xxv.c new file +11
-0+/* Option table for setting up XXV Ethernet hardware options */ +static struct axienet_option xxvenet_options[] = { + {/* Turn on FCS stripping on receive packets */ + .opt =XAE_OPTION_FCS_STRIP , + .reg =XXV_RCW1_OFFSET , + .m_or =XXV_RCW1_FCS_MASK , + }, {/* Turn on FCS insertion on transmit packets */ + .opt =XAE_OPTION_FCS_INSERT , + .reg =XXV_TC_OFFSET , + .m_or =XXV_TC_FCS_MASK , + }, {/* Enable transmitter */ drivers/net/ethernet/xilinx/xilinx_axienet_xxv.c line 96
Quoted 10 lines
drivers/net/ethernet/xilinx/xilinx_axienet_xxv.c new file +10
-0+ .opt = XAE_OPTION_TXEN, + .reg = XXV_TC_OFFSET, + .m_or = XXV_TC_TX_MASK, + }, { /* Enable receiver */ + .opt = XAE_OPTION_RXEN, + .reg = XXV_RCW1_OFFSET, + .m_or = XXV_RCW1_RX_MASK, + }, + {} +};[Severity: Medium]
Is the pause configuration ever applied to the XXV MAC?
axienet_probe()setsMAC_SYM_PAUSE|MAC_ASYM_PAUSEinlp->phylink_config.mac_capabilitiesfor every MAC type.axienet_xxv_phylink_set_capabilities()only adds speed bits, so XXV advertises both pause modes.
axienet_10g25g_confighas no .mac_link_up.axienet_mac_link_up()therefore silently drops the resolved tx_pause/rx_pause:if (lp->axienet_config->mac_link_up) lp->axienet_config->mac_link_up(ndev, speed, tx_pause, rx_pause);
Quoted 7 lines
This table also has no
XAE_OPTION_FLOW_CONTROLentry. TheXXV_CONFIG_TX_FLOW_CTRL1_OFFSETand XXV_CONFIG_RX_FLOW_CTRL1/2_OFFSET registers are only read for ethtool -d and never written.As a result, phylink and ethtool -a/-A report and accept pause settings while the MAC stays at its reset default. Should XXV program the flow control registers from a
mac_link_upcallback, or stop advertising pause?
Setting pause configurations for XXV is not validated yet, I'll stop advertising pause for now and can be added later after proper validation.
Quoted 29 lines
[ ... ]
Quoted 8 lines
drivers/net/ethernet/xilinx/xilinx_axienet_xxv.c new file +8
-0+/** +* axienet_xxv_gt_reset - Pulse the XXV GT reset line +* @lp: Pointer to the axienet_local structure +*/ +static void axienet_xxv_gt_reset (struct axienet_local *lp) +{ +u32 val; +drivers/net/ethernet/xilinx/xilinx_axienet_xxv.c line 156
Quoted 10 lines
drivers/net/ethernet/xilinx/xilinx_axienet_xxv.c new file +10
-0+/* Reset GT */ + val =axienet_ior (lp,XXV_GT_RESET_OFFSET ); + val |=XXV_GT_RESET_MASK ; +axienet_iow (lp,XXV_GT_RESET_OFFSET , val); +/* Allow 1 ms for the GT reset to settle (see timeout note above) */ +usleep_range (1000 ,2000 ); + val =axienet_ior (lp,XXV_GT_RESET_OFFSET ); + val &= ~XXV_GT_RESET_MASK ; +axienet_iow (lp,XXV_GT_RESET_OFFSET , val); +}[Severity: Low]
The kernel-doc foraxienet_device_reset()inxilinx_axienet_main.cstill says:* Ethernet core. No separate hardware reset is done for the Axi Ethernet
* core.
Quoted 6 lines
For XXV, that function now calls
config->gt_reset()first, and this pulsesXXV_GT_RESET_MASK. XXV is dmaengine-only, so the DMA reset and BD init described there never happen. The function now also returnsmac_init()failures such as the GT reset-done timeout.Could the comment be updated to match?
Sure, will update the comment.>
Quoted 35 lines
[ ... ]
Quoted 6 lines
drivers/net/ethernet/xilinx/xilinx_axienet_xxv.c new file +6
-0+static int axienet_xxv_poll_link_ready (struct net_device *ndev) +{ +struct axienet_local *lp =netdev_priv (ndev); +u32 val; +int ret; +drivers/net/ethernet/xilinx/xilinx_axienet_xxv.c line 183
Quoted 10 lines
drivers/net/ethernet/xilinx/xilinx_axienet_xxv.c new file +10
-0+/* Confirm XXV Ethernet is up: on IP v3.2+, wait for GT +* reset-done before further register access, then poll until +* RX PCS block lock is asserted. +*/ +if (axienet_xxv_ip_has_gtwiz_status (lp->xxv_ip_version)) { + ret =readl_poll_timeout (lp->regs +XXV_STAT_GTWIZ_OFFSET , + val, + (val &XXV_GTWIZ_RESET_DONE ) ==XXV_GTWIZ_RESET_DONE , +XXV_LINK_POLL_INTERVAL_US , +DELAY_OF_ONE_MILLISEC );[Severity: Medium]
Is 1 ms long enough for GT reset-done?
axienet_xxv_gt_reset()releasesctl_gt_reset_allafter 1-2 ms, and the GT reset sequence only starts at that release. This poll then gives the GT wizardDELAY_OF_ONE_MILLISECto assert both TX and RX reset-done.GT reset-done covers PLL re-lock and the RX reset sequence. With no signal present, the CDR lock wait in that sequence can run until its internal timeout. The comment at the top of the file says the bound is empirical and that PG210 does not specify it.
With the new check in
axienet_open(), a timeout here now failsndo_open. Could an unplugged cable push this past 1 ms and fail bring-up? The kernel-doc above says an unplugged cable must not do that.
Quoted 16 lines
Quoted 5 lines
drivers/net/ethernet/xilinx/xilinx_axienet_xxv.c new file +5
-0+if (ret) { +netdev_err (ndev,"XXV MAC GT reset not complete! Cross-check the MAC ref clock configuration\n" ); +return ret; + } + }drivers/net/ethernet/xilinx/xilinx_axienet_xxv.c line 198
Quoted 10 lines
drivers/net/ethernet/xilinx/xilinx_axienet_xxv.c new file +10
-0+ + ret =readl_poll_timeout (lp->regs +XXV_STATRX_BLKLCK_OFFSET , + val, (val &XXV_RX_BLKLCK_MASK ), +XXV_LINK_POLL_INTERVAL_US , +DELAY_OF_ONE_MILLISEC ); +if (ret) +netdev_err (ndev,"XXV MAC block lock not complete! Cross-check the MAC ref clock configuration\n" ); + +return 0 ; +}
reset-done is refclk-driven, independent of link partner. block-lock (signal-dependent) is already non-fatal.> [Severity: Low]
Quoted 20 lines
The kernel-doc says a missing block lock is expected with an unplugged cable, and the function returns 0 in that case. Should this be logged below
netdev_err()?As written, every ip link set up on a port with no link partner logs an error that points at the ref clock configuration.
Quoted 13 lines
drivers/net/ethernet/xilinx/xilinx_axienet_xxv.c new file +13
-0+ +/** +* axienet_xxv_mac_init - XXV MAC-specific bring-up after the DMA reset +* @ndev: Pointer to the net_device structure +* +* Return: 0 on success or a negative error number otherwise. +*/ +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);
Quoted 9 lines
drivers/net/ethernet/xilinx/xilinx_axienet_xxv.c line 219
Quoted 8 lines
drivers/net/ethernet/xilinx/xilinx_axienet_xxv.c new file +8
-0+if (ret) +return ret; + + lp->options |=XAE_OPTION_FCS_STRIP ; + lp->options |=XAE_OPTION_FCS_INSERT ; + +return 0 ; +}
Agree — block-lock-not-asserted is a normal no-link state, not an error. Demote to netdev_dbg (not ratelimited; it's once per open, so level—not rate—is the issue) and reword to drop the ref-clock blame. The genuine netdev_err stays on the GT reset-done timeout, which does imply a bring-up/refclk fault."
Quoted 32 lines
[Severity: High]
Should the XXV RX max packet length be programmed here?
XXV_JUM_OFFSET(CONFIGURATION_RX_MTU,ctl_rx_max_packet_len) appears only in the ethtool -d table and is never written. Its reset default is 9600 bytes.At the default MTU,
axienet_device_reset()setslp->max_frm_sizetoXAE_MAX_VLAN_FRAME_SIZE(1522).axienet_rx_submit_desc()maps each RX buffer at exactly that size.If a link partner sends frames of 1523 to 9600 bytes, the MAC accepts them and splits each one across several S2MM descriptors.
axienet_dma_rx_cb()treats every completion as a whole frame. Would these fragmented frames be passed up the stack?Changing the MTU never updates the MAC either, so the software and hardware frame limits can be out of sync in both directions. On 1G the MAC drops frames above its configured limit, so this does not happen there.
Quoted 13 lines
drivers/net/ethernet/xilinx/xilinx_axienet_xxv.c new file +13
-0+ +static void axienet_xxv_phylink_set_capabilities (struct axienet_local *lp, +struct phylink_config *cfg) +{ +u32 core_speed; + + core_speed =axienet_ior (lp,XXV_STAT_CORE_SPEED_OFFSET ); +/* Bit[1:0]: 00=25G, 01=10G, 10=runtime-switchable 25G, +* 11=runtime-switchable 10G. Bit 0 is the active rate. Advertise +* only that rate. +*/ +if (core_speed &XXV_STAT_CORE_SPEED_10G_MASK ) { + cfg->mac_capabilities |=MAC_10000FD ;
Quoted 9 lines
drivers/net/ethernet/xilinx/xilinx_axienet_xxv.c line 240
Quoted 8 lines
drivers/net/ethernet/xilinx/xilinx_axienet_xxv.c new file +8
-0+__set_bit (PHY_INTERFACE_MODE_10GBASER , + cfg->supported_interfaces); + }else { + cfg->mac_capabilities |=MAC_25000FD ; +__set_bit (PHY_INTERFACE_MODE_25GBASER , + cfg->supported_interfaces); + } +}
I agree, will fix it.
Quoted 22 lines
[Severity: High]
Can the XXV interface be opened with a device tree that follows the new binding?The xlnx,xxv-ethernet binding comes from "dt-bindings: net:
xlnx,xxv-ethernet: Add Xilinx XXV 10G/25G Ethernet". It requires neither phy-handle nor managed = "in-band-status", and neither of its examples has them.Nothing sets
lp->phylink_config.default_an_inbandfor XXV. At the end of the series there is nodefault_an_inbandanywhere indrivers/net/ethernet/xilinx/.phylink_parse_mode()therefore leavescfg_link_an_modeasMLO_AN_PHY.
axienet_open()then callsphylink_fwnode_phy_connect(), which does:phy_fwnode = fwnode_get_phy_node(fwnode); if (IS_ERR(phy_fwnode)) { if (pl->cfg_link_an_mode == MLO_AN_PHY) return -ENODEV; return 0; }
Quoted 3 lines
axienet_open()passes that-ENODEVback to the caller, so the interface never comes up. Should this function setcfg->default_an_inband= true, or should the binding require managed = "in-band-status"?
I agree, will modify example to indicate inband in DT yaml& set cfg->default_an_inband = true in driver .>
Quoted 21 lines
[ ... ]
drivers/net/ethernet/xilinx/xilinx_axienet_xxv.c line 323
Quoted 13 lines
drivers/net/ethernet/xilinx/xilinx_axienet_xxv.c new file +13
-0+const struct axienet_config axienet_10g25g_config = { + .sw_padding = true, + .internal_pcs = true, + .regs_n =XXV_REGS_N , + .clk_init = axienet_10g25g_clk_init, + .setoptions = axienet_xxv_setoptions, + .probe_init = axienet_xxv_probe_init, + .gt_reset = axienet_xxv_gt_reset, + .mac_init = axienet_xxv_mac_init, + .get_regs = axienet_xxv_get_regs, + .phylink_set_caps = axienet_xxv_phylink_set_capabilities, + .pcs_ops = &axienet_xxv_pcs_ops, +};[Severity: Low]
This leaves .jumbo false, which the kernel-doc defines as "MAC supports jumbo frames" being false.axienet_probe()still setsndev->max_mtu=XAE_JUMBO_MTUfor every MAC.axienet_change_mtu()only checks againstlp->rxmem:
Quoted 7 lines
if ((new_mtu + VLAN_ETH_HLEN + XAE_TRL_SIZE) > lp->rxmem) return -EINVAL;So ip link set mtu 9000 is accepted on XXV. For XXV, is the .jumbo flag wrong, or the
max_mtu?xxvenet_optionsalso has noXAE_OPTION_JUMBOentry, andXXV_JUM_OFFSETis never written.
Agree — set .jumbo=true for XXV (no reg programming needed).
Quoted 19 lines
[Severity: High]
Where does XXV get the RX frame length from?.non_dmaengine is left false, so every XXV RX completion goes through
axienet_dma_rx_cb(). That callback reads the length from AXI DMA APP word 4:/* TODO: Derive app word index programmatically */ rx_len = (app_metadata[LEN_APP] & 0xFFFF);On the 1G AXI Ethernet, the MAC's RX status stream writes that word. PG210 describes the XXV IP with only AXI4-Stream data interfaces and no status stream.
xilinx_dmaonly attachesmetadata_opswhen the DMA node has xlnx,axistream-connected:if (chan->xdev->has_axistream_connected) desc->async_tx.metadata_ops = &xilinx_dma_metadata_ops;
Quoted 8 lines
Without that property,
dmaengine_desc_get_metadata_ptr()fails and every received frame is counted asrx_dropped. With it, app4 holds stale or zero BD contents. Zero-length skbs or wrong lengths would then reacheth_type_trans()andskb_put().The real byte count is in the BD status length field, which
xilinx_dmareports as the residue. Does XXV need its own MAC-specific RX length source?
Resolved by rebasing on Srinivas' residue series (97f9c11a6dd9, rx_len = max_frm_size - residue); note dependency.> [Severity: Medium]
Quoted 11 lines
This is a pre-existing issue, but XXV now goes through the same callback.
axienet_dma_rx_cb()passes the metadata length straight toskb_put():rx_len = (app_metadata[LEN_APP] & 0xFFFF); skb_put(skb, rx_len);The callback does not check the dmaengine result or residue.
rx_lenis not bounded bylp->max_frm_sizeorskb_tailroom()either. Could a length larger than the posted buffer hitskb_over_panic()? The 1G dmaengine path already had this problem.
Bounded by residue series; note dependency.
Regards,
Suraj
PATCH v4 4/6 net: xilinx: axienet: Make axienet_rmon_ranges non-static for reuse
In reply to Suraj GuptaThe RMON histogram range table axienet_rmon_ranges[] is MAC-agnostic. Make it non-static and declare it in the shared xilinx_axienet.h so the upcoming XXV RMON callback can reuse the same table instead of duplicating it. Include <linux/ethtool.h> for the range element type.
No functional change intended.
--- drivers/net/ethernet/xilinx/xilinx_axienet.h | 4 ++++ drivers/net/ethernet/xilinx/xilinx_axienet_main.c | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-)
drivers/net/ethernet/xilinx/xilinx_axienet.h +4 -0
@@ -10,6 +10,7 @@#define XILINX_AXIENET_H #include <linux/dim.h> +#include <linux/ethtool.h> #include <linux/netdevice.h> #include <linux/spinlock.h> #include <linux/interrupt.h>
@@ -802,4 +803,7 @@ static inline void axienet_dma_out_addr(struct axienet_local *lp, off_t reg,int axienet_mdio_setup (struct axienet_local *lp);void axienet_mdio_teardown (struct axienet_local *lp); +/* RMON histogram ranges shared by all MAC types */ +extern const struct ethtool_rmon_hist_range axienet_rmon_ranges[]; +#endif /* XILINX_AXI_ENET_H */
drivers/net/ethernet/xilinx/xilinx_axienet_main.c +1 -1
@@ -2499,7 +2499,7 @@ axienet_ethtool_get_eth_ctrl_stats(struct net_device *dev, }while (read_seqcount_retry (&lp->hw_stats_seqcount, start)); } -static const struct ethtool_rmon_hist_range axienet_rmon_ranges[] = { +const struct ethtool_rmon_hist_range axienet_rmon_ranges[] = { {64 ,64 }, {65 ,127 }, {128 ,255 },
Signature · 1 line
2.25.1
PATCH v4 5/6 net: xilinx: axienet: Dispatch statistics through axienet_config ops
In reply to Suraj GuptaThe ndo_get_stats64() and ethtool statistics callbacks read the 1G MAC hardware counters directly. Supporting a second MAC type this way would require an "if (mactype == ...)" dispatch branch in each of the eight statistics callbacks.
Add statistics operation function pointers to struct axienet_config and route get_stats64, get_ethtool_stats, get_strings, get_sset_count, get_pause_stats, get_eth_mac_stats, get_eth_ctrl_stats and get_rmon_stats through them. Factor the existing 1G counter reads into axienet_1g_*() helpers and populate axienet_1g_config with them.
A NULL op means the MAC does not expose that statistics group, so a MAC without control-frame counters simply leaves get_eth_ctrl_stats unset instead of open-coding the special case in the callback.
No functional change intended.
--- drivers/net/ethernet/xilinx/xilinx_axienet.h | 23 +++ .../net/ethernet/xilinx/xilinx_axienet_main.c | 171 +++++++++++++----- 2 files changed, 146 insertions(+), 48 deletions(-)
drivers/net/ethernet/xilinx/xilinx_axienet.h +23 -0
@@ -658,6 +658,15 @@ struct axienet_local {* @phylink_set_caps: Callback to set phylink MAC capabilities * @pcs_ops: phylink PCS operations for this MAC, or NULL if unused * @stats_update: Callback to latch/accumulate the periodic MAC counters +* @get_stats64: Callback to read MAC counters into rtnl_link_stats64 +* @get_ethtool_stats: Callback to read MAC counters for ethtool -S +* @get_strings: Callback to fill the ethtool -S statistic name strings +* @get_sset_count: Callback returning the number of ethtool -S statistics +* @get_pause_stats: Callback to read MAC pause-frame counters +* @get_eth_mac_stats: Callback to read IEEE 802.3 MAC counters +* @get_eth_ctrl_stats: Callback to read MAC-control frame counters, or NULL +* if the MAC exposes no control-frame counters +* @get_rmon_stats: Callback to read RMON counters and histogram ranges */ struct axienet_config {bool mdio;
@@ -683,6 +692,20 @@ struct axienet_config { struct phylink_config *config);const struct phylink_pcs_ops *pcs_ops;void (*stats_update)(struct axienet_local *lp); +void (*get_stats64)(struct axienet_local *lp, +struct rtnl_link_stats64 *stats); +void (*get_ethtool_stats)(struct axienet_local *lp,u64 *data); +void (*get_strings)(u8 *data); +int (*get_sset_count)(void ); +void (*get_pause_stats)(struct axienet_local *lp, +struct ethtool_pause_stats *pause_stats); +void (*get_eth_mac_stats)(struct axienet_local *lp, +struct ethtool_eth_mac_stats *mac_stats); +void (*get_eth_ctrl_stats)(struct axienet_local *lp, +struct ethtool_eth_ctrl_stats *ctrl_stats); +void (*get_rmon_stats)(struct axienet_local *lp, +struct ethtool_rmon_stats *rmon_stats, +const struct ethtool_rmon_hist_range **ranges); };static inline struct axienet_local *pcs_to_axienet_local (struct phylink_pcs *pcs)
drivers/net/ethernet/xilinx/xilinx_axienet_main.c +123 -48
275 lines not on this page · raw message
Signature · 1 line
2.25.1
PATCH v4 6/6 net: xilinx: axienet: Add statistics support for XXV ethernet
In reply to Suraj GuptaThe XXV ethernet exposes a dedicated statistics block whose counters are clear-on-tick (PG210): writing TICK_REG latches the internal accumulators into the readable registers and clears them, so each post-TICK read yields the count for the interval since the previous TICK. Software accumulates those intervals, so no last-counter delta (as used by the 1G MAC) is needed.
Feed both ndo_get_stats64() and the ethtool statistics (-S, pause, MAC and RMON) from this accumulator path through the axienet_config statistics ops. MAC control statistics stay unsupported as the hardware exposes no matching counters.
--- drivers/net/ethernet/xilinx/xilinx_axienet.h | 2 + .../net/ethernet/xilinx/xilinx_axienet_main.c | 24 +- .../net/ethernet/xilinx/xilinx_axienet_xxv.c | 269 ++++++++++++++++++ .../net/ethernet/xilinx/xilinx_axienet_xxv.h | 55 ++++ 4 files changed, 348 insertions(+), 2 deletions(-)
drivers/net/ethernet/xilinx/xilinx_axienet.h +2 -0
@@ -549,6 +549,7 @@ struct skbuf_dma_descriptor {* @rx_ring_head: RX skb ring buffer head index. * @rx_ring_tail: RX skb ring buffer tail index. * @xxv_ip_version: XXV IP version. +* @xxv_stat_base: Software accumulators for the XXV clear-on-tick counters. * @axienet_config: MAC-type specific configuration and operations. */ struct axienet_local {
@@ -603,6 +604,7 @@ struct axienet_local {u64 hw_stat_base[STAT_COUNT ];u32 hw_last_counter[STAT_COUNT ]; +u64 xxv_stat_base[XXV_STAT_COUNT ];seqcount_mutex_t hw_stats_seqcount;struct mutex stats_lock;struct delayed_work stats_work;
drivers/net/ethernet/xilinx/xilinx_axienet_main.c +22 -2
@@ -593,7 +593,11 @@ static void axienet_refresh_stats(struct work_struct *work)mutex_unlock (&lp->stats_lock); } -/* Just less than 2^32 bytes at 2.5 GBit/s */ +/* Re-arm the poll before any counter can overflow between updates: the +* 1G byte counter reaches just under 2^32 in this interval at 2.5 Gbit/s, +* and the XXV internal accumulators must be latched (via TICK in +* axienet_xxv_stats_update()) before they saturate at line rate. +*/ schedule_delayed_work (&lp->stats_work,13 *HZ ); }
@@ -602,7 +606,16 @@ static int __axienet_device_reset(struct axienet_local *lp)u32 value;int ret; -/* Save statistics counters in case they will be reset */ +/* Save statistics counters in case they will be reset. +* +* The XAE_FEATURE_STATS blocks in this function read the TEMAC +* statistics registers at XAE_STATS_OFFSET, i.e. they assume the 1G +* counter layout. This is safe because __axienet_device_reset() is +* only reached on the non-dmaengine path, which the +* non_dmaengine capability restricts to the 1G MAC. MACs that use their +* own statistics mechanism (e.g. XXV, which is dmaengine-only) never +* execute this path. +*/ mutex_lock (&lp->stats_lock);if (lp->features &XAE_FEATURE_STATS )axienet_stats_update (lp, true);
@@ -1785,6 +1798,13 @@ static int axienet_stop(struct net_device *ndev) lp->axienet_config->setoptions (ndev, lp->options & ~(XAE_OPTION_TXEN |XAE_OPTION_RXEN )); +/* Final snapshot after RX/TX is disabled, so no frames are missed. */ +if (lp->axienet_config->stats_update) { +mutex_lock (&lp->stats_lock); + lp->axienet_config->stats_update (lp); +mutex_unlock (&lp->stats_lock); + } +if (!lp->use_dmaengine) {axienet_dma_stop (lp);cancel_work_sync (&lp->dma_err_task);
drivers/net/ethernet/xilinx/xilinx_axienet_xxv.c +269 -0
300 lines not on this page · raw message
drivers/net/ethernet/xilinx/xilinx_axienet_xxv.h +55 -0
73 lines not on this page · raw message
Signature · 1 line
2.25.1
[email protected]
AI reviewRe: [PATCH net-next v4 6/6] net: xilinx: axienet: Add statistics support for XXV ethernet
Thank you for your contribution! Sashiko AI review found 5 potential issue(s) to consider.
Thank you for your contribution! Sashiko AI review found 5 potential issue(s) to consider.
Critical: 0 · High: 0 · Medium: 1 (1) · 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).
- [Medium] The driver uses PG210 STAT_RX_BAD_FCS (0x8C0) as its only RX FCS-error source.
- [Low] The new 'final snapshot' block in axienet_stop() only checks if (lp->axienet_config->stats_update).
- [Low] The struct axienet_local kernel-doc is out of date.
- [Low] The kernel-doc for axienet_xxv_get_rmon_stats() says '@ranges:
Set to the RMON histogram range table', but the function always sets…
- [Low] The 'Throwaway tick to drain pre-open counts so stats start from zero' in axienet_xxv_probe_init() does not achieve what its comment…
Pre-existing issues:
- [Medium] This problem wasn't introduced by this patch, but the new XXV readers inherit it.
--
net: xilinx: axienet: Add statistics support for XXV ethernet
This commit adds statistics support for the XXV (10G/25G) MAC in the axienet driver. The driver writes TICK_REG to latch the PG210 clear-on-tick counters and adds each interval's values to xxv_stat_base[] in software. These accumulators feed ndo_get_stats64() and the ethtool -S, pause, MAC and RMON callbacks.
drivers/net/ethernet/xilinx/xilinx_axienet.h struct skbuf_dma_descriptor { · line 552
Quoted 9 lines
drivers/net/ethernet/xilinx/xilinx_axienet.h +1
-0@@ -549,6 +549,7 @@ struct skbuf_dma_descriptor {* @rx_ring_head: RX skb ring buffer head index. * @rx_ring_tail: RX skb ring buffer tail index. * @xxv_ip_version: XXV IP version. +* @xxv_stat_base: Software accumulators for the XXV clear-on-tick counters.
[Severity: Low]
This isn't a bug, but should the @hw_stats_seqcount kernel-doc be updated too? It still reads:
* @hw_stats_seqcount: Sequence counter for @hw_stat_base, @hw_last_counter,
* and @reset_in_progress.
axienet_xxv_stats_update() now writes xxv_stat_base[] inside the hw_stats_seqcount write section. All of the XXV getters read it under read_seqcount_begin()/read_seqcount_retry().
The new @xxv_stat_base line doesn't say what protects it either.
Quoted 3 lines
drivers/net/ethernet/xilinx/xilinx_axienet.h +0
-0* @axienet_config: MAC-type specific configuration and operations. */ struct axienet_local {
[ ... ]
Quoted 4 lines
drivers/net/ethernet/xilinx/xilinx_axienet_main.c +0
-0
[ ... ]
drivers/net/ethernet/xilinx/xilinx_axienet_main.c static int axienet_stop(struct net_device *ndev) · line 1810
Quoted 10 lines
drivers/net/ethernet/xilinx/xilinx_axienet_main.c +6
-0@@ -1789,6 +1802,13 @@ static int axienet_stop(struct net_device *ndev) lp->axienet_config->setoptions (ndev, lp->options & ~(XAE_OPTION_TXEN |XAE_OPTION_RXEN )); +/* Final snapshot after RX/TX is disabled, so no frames are missed. */ +if (lp->axienet_config->stats_update) { +mutex_lock (&lp->stats_lock); + lp->axienet_config->stats_update (lp); +mutex_unlock (&lp->stats_lock); + }
[Severity: Low]
Should this check lp->features & XAE_FEATURE_STATS?
axienet_1g_config always sets .stats_update = axienet_1g_stats_update, but the statistics block is optional on 1G:
axienet_1g_probe_init() {
if (axienet_ior(lp, XAE_ABILITY_OFFSET) & XAE_ABILITY_STATS)
lp->features |= XAE_FEATURE_STATS;
}So on a 1G core built without the statistics block, every ifdown now reads XAE_STATS_OFFSET registers that the core doesn't implement. __axienet_device_reset() and the stats export callbacks all check XAE_FEATURE_STATS before reading these registers.
axienet_refresh_stats() is also missing this check, but that was already true before this patch.
This also changes 1G behaviour. On the 1G dmaengine path it adds a new register read at stop. On the 1G non-dmaengine path it repeats the axienet_stats_update(lp, true) that axienet_dma_stop()->__axienet_device_reset() already does a few lines later.
The commit message describes the patch as XXV-only. Could it mention the 1G change, or could this snapshot be limited to the MACs that need it?
Quoted 8 lines
drivers/net/ethernet/xilinx/xilinx_axienet_main.c +1
-0+if (!lp->use_dmaengine) {axienet_dma_stop (lp);cancel_work_sync (&lp->dma_err_task);drivers/net/ethernet/xilinx/xilinx_axienet_xxv.c +0
-0
[ ... ]
drivers/net/ethernet/xilinx/xilinx_axienet_xxv.c static void axienet_xxv_setoptions(struct net_device *ndev, u32 options) · line 205
Quoted 8 lines
drivers/net/ethernet/xilinx/xilinx_axienet_xxv.c +4
-0@@ -134,6 +199,10 @@ static void axienet_xxv_setoptions(struct net_device *ndev, u32 options)static void axienet_xxv_probe_init (struct axienet_local *lp) { lp->xxv_ip_version =axienet_ior (lp,XXV_CONFIG_REVISION ); + lp->features |=XAE_FEATURE_STATS ; + +/* Throwaway tick to drain pre-open counts so stats start from zero. */ +axienet_iow (lp,XXV_TICKREG_OFFSET ,XXV_TICKREG_STATEN_MASK );
[Severity: Low]
Does this tick actually make the stats start from zero at open?
It runs only once, from axienet_probe()->probe_init, before any GT reset or GTWIZ reset-done poll. axienet_xxv_poll_link_ready() says register access should wait for that on IP v3.2+:
/* Confirm XXV Ethernet is up: on IP v3.2+, wait for GT * reset-done before further register access, then poll until * RX PCS block lock is asserted. */
Nothing between probe and the first ndo_open clears the RX/TX enables. The first setoptions() call that clears TXEN/RXEN is in axienet_device_reset() at open.
If the MAC comes out of reset with RX enabled, as the PG210 CONFIGURATION_RX_REG1 default suggests, frames received between probe and the first open stay in the internal accumulators. The first stats_work after open, queued by schedule_delayed_work(&lp->stats_work, 0) in axienet_open(), would then latch them into xxv_stat_base[].
If the statistics clock domain isn't running yet at probe, this tick might not latch anything at all.
Would it make more sense to drain on the open path, after GT reset-done and before RX/TX are enabled and stats_work is armed? Later opens look less affected, since axienet_stop() disables RX/TX and takes a final snapshot.
Quoted 4 lines
drivers/net/ethernet/xilinx/xilinx_axienet_xxv.c +0
-0}/** @@ -308,6 +377,198 @@ static int axienet_10g25g_clk_init(struct axienet_local *lp)
[ ... ]
drivers/net/ethernet/xilinx/xilinx_axienet_xxv.c static int axienet_10g25g_clk_init(struct axienet_local *lp) · line 422
Quoted 8 lines
drivers/net/ethernet/xilinx/xilinx_axienet_xxv.c +8
-0+static void axienet_xxv_get_stats64 (struct axienet_local *lp, +struct rtnl_link_stats64 *stats) +{ +unsigned int start; +u64 tx_hw_errors; + + do { + start = read_seqcount_begin(&lp->hw_stats_seqcount);
[Severity: Medium]
This isn't a bug introduced by this patch, but the new XXV readers inherit it.
hw_stats_seqcount is a seqcount_mutex_t associated with stats_lock (see seqcount_mutex_init() in axienet_probe()). On PREEMPT_RT, a reader that sees an odd sequence takes and drops the associated mutex:
include/linux/seqlock.h:SEQCOUNT_LOCKNAME() {
...
if (preemptible && unlikely(seq & 1)) {
__SEQ_LOCK(lockbase##_lock(s->lock));
__SEQ_LOCK(lockbase##_unlock(s->lock));
...
}axienet_xxv_get_stats64() is reached through dev_get_stats(). That can be called under rcu_read_lock() (dev_seq_show() for /proc/net/dev) or under a caller's spinlock (bond_get_stats()).
If such a read races with the write section in axienet_xxv_stats_update() from stats_work or axienet_stop(), can the reader end up calling mutex_lock() from atomic context on RT?
The 1G readers have used this seqcount the same way since before this series. This patch adds more readers of the same kind.
Quoted 4 lines
drivers/net/ethernet/xilinx/xilinx_axienet_xxv.c +4
-0+ stats->rx_crc_errors = lp->xxv_stat_base[XXV_STAT_RX_BAD_FCS ]; +/* Both in-range length errors and frame-too-long (oversize) +* frames are IEEE 802.3 length errors, so fold them together +* into rx_length_errors; rx_over_errors is reserved for receiver
drivers/net/ethernet/xilinx/xilinx_axienet_xxv.c static int axienet_10g25g_clk_init(struct axienet_local *lp) · line 436
Quoted 10 lines
drivers/net/ethernet/xilinx/xilinx_axienet_xxv.c +10
-0+* FIFO/ring overflow, which the XXV MAC does not expose. +*/ + stats->rx_length_errors = + lp->xxv_stat_base[XXV_STAT_RX_INRANGEERR ] + + lp->xxv_stat_base[XXV_STAT_RX_OVERSIZE ]; + stats->rx_errors = lp->xxv_stat_base[XXV_STAT_RX_UNDERSIZE ] + + lp->xxv_stat_base[XXV_STAT_RX_FRAGMENT ] + + lp->xxv_stat_base[XXV_STAT_RX_JABBER ] + + stats->rx_crc_errors + + stats->rx_length_errors;
[Severity: Medium]
Can rx_errors count fragment and jabber frames twice here?
XXV_STAT_RX_BAD_FCS_OFFSET is 0x8C0, which is stat_rx_bad_fcs in PG210. As far as I can tell, that counter covers every received frame with a bad FCS, whatever its length. It would then include fragments, which are also counted in STAT_RX_FRAGMENT (0x8A0), and jabbers, which are also counted in STAT_RX_JABBER (0x8B8).
Adding RX_FRAGMENT, RX_JABBER and rx_crc_errors together would then count those frames twice.
The same counter also feeds FrameCheckSequenceErrors in axienet_xxv_get_eth_mac_stats(). IEEE 802.3 aFrameCheckSequenceErrors excludes too-short and too-long frames.
Would STAT_RX_PACKET_BAD_FCS (0x8C8, frames from 64 bytes up to the max packet length) be a better source for both rx_crc_errors and FrameCheckSequenceErrors?
Quoted 1 line
drivers/net/ethernet/xilinx/xilinx_axienet_xxv.c +1
-0+ stats->multicast = lp->xxv_stat_base[XXV_STAT_RX_MULTICAST ];
[ ... ]
Quoted 10 lines
drivers/net/ethernet/xilinx/xilinx_axienet_xxv.c +10
-0+/** +* axienet_xxv_get_rmon_stats - Fill RMON statistics and histogram ranges +* @lp: Pointer to the axienet_local structure +* @rmon_stats: Output ethtool_rmon_stats structure to populate +* @ranges: Set to the RMON histogram range table +*/ +static void axienet_xxv_get_rmon_stats (struct axienet_local *lp, +struct ethtool_rmon_stats *rmon_stats, +const struct ethtool_rmon_hist_range **ranges) +{
[ ... ]
drivers/net/ethernet/xilinx/xilinx_axienet_xxv.c static int axienet_10g25g_clk_init(struct axienet_local *lp) · line 569
Quoted 4 lines
drivers/net/ethernet/xilinx/xilinx_axienet_xxv.c +4
-0+/* XXV currently exposes only aggregate RMON counters, not per-bin +* histogram buckets. Keep ranges NULL until histogram bins are wired. +*/ + *ranges =NULL ;
[Severity: Low]
This isn't a bug, but the @ranges kernel-doc says it is "Set to the RMON histogram range table". The function always sets *ranges = NULL, and the comment just above says to keep it NULL until histogram bins are wired.
Could the kernel-doc say that ranges is set to NULL?
Quoted 1 line
+}
Signature · 1 line
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261006110550.1990213-1-suraj.gupta2%40amd.com