net: xilinx: axienet: Add 10G/25G (XXV) ethernet support
Subsystems (5)
v3 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:
- The devm_clk_bulk_get_enable() helper posted as patch 1/7 in v2 is now in mainline as commit b698927accb1 ("clk: Add devm_clk_bulk_get_enable()"), so it is dropped from this series.
- This series depends on [1], which is sent as part of another series. That change is required for this series to compile and is not included here to avoid duplication.
- Due to phylink limitations, we aren't able to advertise both 10G and 25G base-r interfaces and switch between them using ethtool. We are open to suggestions on how to handle this.
[1]: 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 | 107 ++++ MAINTAINERS | 1 + drivers/net/ethernet/xilinx/Makefile | 3 +- drivers/net/ethernet/xilinx/xilinx_axienet.h | 90 +++ .../net/ethernet/xilinx/xilinx_axienet_main.c | 603 ++++++++++++------ .../net/ethernet/xilinx/xilinx_axienet_xxv.c | 595 +++++++++++++++++ .../net/ethernet/xilinx/xilinx_axienet_xxv.h | 141 ++++ 7 files changed, 1358 insertions(+), 182 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
base-commit: 1bb784eb6e38fd73143f021608e4ef3095d0c0d7
Signature · 1 line
2.25.1
PATCH v3 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, legacy_dma, uc_filter, mc_filter, vlan, jumbo, dma_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 | 391 ++++++++++++------ 2 files changed, 319 insertions(+), 124 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 +* @legacy_dma: MAC supports the legacy (non-dmaengine) DMA mode +* @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 +* @dma_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 legacy_dma; +bool uc_filter; +bool mc_filter; +bool vlan; +bool jumbo; +bool dma_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 +267 -124
595 lines not on this page · raw message
Signature · 1 line
2.25.1
[email protected]
AI reviewRe: [PATCH net-next v3 1/6] net: xilinx: axienet: Introduce axienet_config for MAC-specific ops
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
New issues:
- [High] Incomplete abstraction for TX checksum offload leads to broken checksums if misconfigured.
Pre-existing issues:
- [Critical] TX ring desynchronization in axienet_start_xmit_dmaengine() error paths leads to use-after-free and double-free in DMA callbacks. --
commit 166384442bde8d7169bb6c9fd071e535fa3f9c73
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 6 lines
drivers/net/ethernet/xilinx/xilinx_axienet_main.c +0
-2@@ -939,19 +976,21 @@ axienet_start_xmit_dmaengine(struct sk_buff *skb, struct net_device *ndev) goto xmit_error_drop_skb;/* Fill up app fields for checksum */ -if (skb->ip_summed ==CHECKSUM_PARTIAL ) { -if (lp->features &XAE_FEATURE_FULL_TX_CSUM ) {
drivers/net/ethernet/xilinx/xilinx_axienet_main.c axienet_start_xmit_dmaengine(struct sk_buff *skb, struct net_device *ndev) · line 980
Quoted 10 lines
drivers/net/ethernet/xilinx/xilinx_axienet_main.c +2
-8-/* Tx Full Checksum Offload Enabled */ - app_metadata[0 ] |=2 ; - }else if (lp->features &XAE_FEATURE_PARTIAL_TX_CSUM ) { - csum_start_off =skb_transport_offset (skb); - csum_index_off = csum_start_off + skb->csum_offset; -/* Tx Partial Checksum Offload Enabled */ - app_metadata[0 ] |=1 ; - app_metadata[1 ] = (csum_start_off <<16 ) | csum_index_off; +if (lp->axienet_config->dma_tx_csum) { +if (skb->ip_summed ==CHECKSUM_PARTIAL ) {
[Severity: Critical]
This is a pre-existing issue, but does this error path permanently desynchronize the software ring from the hardware ring?
Looking at axienet_start_xmit_dmaengine(), if a failure occurs during mapping or preparation, the code jumps to xmit_error_drop_skb. However, lp->tx_ring_head was already incremented earlier and is not rolled back. This leaves the abandoned ring slot containing the skb pointer and sg_len from the previous time the slot was used.
When the next successful packet finishes transmission, axienet_dma_tx_cb() will pop the oldest entry using lp->tx_ring_tail++ and retrieve this abandoned slot. Can this lead to unmapping the wrong scatterlist and double-freeing the old skb?
[ ... ]
Quoted 10 lines
drivers/net/ethernet/xilinx/xilinx_axienet_main.c +0
-3@@ -2861,9 +2993,6 @@ static int axienet_probe(struct platform_device *pdev)/* Setup checksum offload, but default to off if not specified */ lp->features =0 ; -if (axienet_ior (lp,XAE_ABILITY_OFFSET ) &XAE_ABILITY_STATS ) - lp->features |=XAE_FEATURE_STATS ; - ret =of_property_read_u32 (pdev->dev.of_node,"xlnx,txcsum" , &value);if (!ret) {switch (value) {
drivers/net/ethernet/xilinx/xilinx_axienet_main.c
Quoted 4 lines
drivers/net/ethernet/xilinx/xilinx_axienet_main.c +0
-0case 1 : lp->features |=XAE_FEATURE_PARTIAL_TX_CSUM ;/* Can checksum any contiguous range */ ndev->features |=NETIF_F_HW_CSUM ;
[Severity: High]
Does axienet_probe() advertise hardware checksum capabilities without verifying the new MAC capability flag?
While axienet_start_xmit_dmaengine() now correctly gates the DMA metadata setup behind lp->axienet_config->dma_tx_csum, axienet_probe() still parses the xlnx,txcsum device tree property and unconditionally sets NETIF_F_HW_CSUM.
If the device tree specifies this property for a MAC that does not support TX checksums, will the network stack pass partial checksums that the hardware never completes?
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Re: [PATCH net-next v3 1/6] net: xilinx: axienet: Introduce axienet_config for MAC-specific ops
Quoted 50 lines · On 9/1/2026 8:39 PM, [email protected] wrote:
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
New issues:
- [High] Incomplete abstraction for TX checksum offload leads to broken checksums if misconfigured.Pre-existing issues:
- [Critical] TX ring desynchronization inaxienet_start_xmit_dmaengine()error paths leads to use-after-free and double-free in DMA callbacks. --commit
166384442bde8d7169bb6c9fd071e535fa3f9c73
Author: Suraj Gupta <[email protected]>net: xilinx: axienet: Introduce
axienet_configfor MAC-specific opsIntroduce an
axienet_configstructure 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 6 lines
drivers/net/ethernet/xilinx/xilinx_axienet_main.c +0
-2@@ -939,19 +976,21 @@ axienet_start_xmit_dmaengine(struct sk_buff *skb, struct net_device *ndev) goto xmit_error_drop_skb;/* Fill up app fields for checksum */ -if (skb->ip_summed ==CHECKSUM_PARTIAL ) { -if (lp->features &XAE_FEATURE_FULL_TX_CSUM ) {drivers/net/ethernet/xilinx/xilinx_axienet_main.c axienet_start_xmit_dmaengine(struct sk_buff *skb, struct net_device *ndev) · line 980
Quoted 10 lines
drivers/net/ethernet/xilinx/xilinx_axienet_main.c +2
-8-/* Tx Full Checksum Offload Enabled */ - app_metadata[0 ] |=2 ; - }else if (lp->features &XAE_FEATURE_PARTIAL_TX_CSUM ) { - csum_start_off =skb_transport_offset (skb); - csum_index_off = csum_start_off + skb->csum_offset; -/* Tx Partial Checksum Offload Enabled */ - app_metadata[0 ] |=1 ; - app_metadata[1 ] = (csum_start_off <<16 ) | csum_index_off; +if (lp->axienet_config->dma_tx_csum) { +if (skb->ip_summed ==CHECKSUM_PARTIAL ) {[Severity: Critical]
This is a pre-existing issue, but does this error path permanently desynchronize the software ring from the hardware ring?Looking at
axienet_start_xmit_dmaengine(), if a failure occurs during mapping or preparation, the code jumps toxmit_error_drop_skb. However,lp->tx_ring_headwas already incremented earlier and is not rolled back. This leaves the abandoned ring slot containing the skb pointer andsg_lenfrom the previous time the slot was used.
Quoted 5 lines
When the next successful packet finishes transmission,
axienet_dma_tx_cb()will pop the oldest entry using lp->tx_ring_tail++ and retrieve this abandoned slot. Can this lead to unmapping the wrong scatterlist and double-freeing the old skb?
This is a pre-existing issue. I'll address it separately.
Quoted 20 lines
[ ... ]
Quoted 10 lines
drivers/net/ethernet/xilinx/xilinx_axienet_main.c +0
-3@@ -2861,9 +2993,6 @@ static int axienet_probe(struct platform_device *pdev)/* Setup checksum offload, but default to off if not specified */ lp->features =0 ; -if (axienet_ior (lp,XAE_ABILITY_OFFSET ) &XAE_ABILITY_STATS ) - lp->features |=XAE_FEATURE_STATS ; - ret =of_property_read_u32 (pdev->dev.of_node,"xlnx,txcsum" , &value);if (!ret) {switch (value) {Quoted 4 lines
case 1: lp->features |= XAE_FEATURE_PARTIAL_TX_CSUM; /* Can checksum any contiguous range */ ndev->features |= NETIF_F_HW_CSUM;[Severity: High]
Doesaxienet_probe()advertise hardware checksum capabilities without verifying the new MAC capability flag?
Quoted 9 lines
While
axienet_start_xmit_dmaengine()now correctly gates the DMA metadata setup behindlp->axienet_config->dma_tx_csum,axienet_probe()still parses the xlnx,txcsum device tree property and unconditionally setsNETIF_F_HW_CSUM.If the device tree specifies this property for a MAC that does not support TX checksums, will the network stack pass partial checksums that the hardware never completes?
I agree, axienet_probe() should verify MAC capability flag before checking for checksum capabilities, otherwise it might be problematic if device tree wrongly specifies this property for unsupported MAC. I'll address this in next version.
Thanks,
Suraj
PATCH v3 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 | 107 ++++++++++++++++++ MAINTAINERS | 1 + 2 files changed, 108 insertions(+) create mode 100644 Documentation/devicetree/bindings/net/xlnx,xxv-ethernet.yaml
Documentation/devicetree/bindings/net/xlnx,xxv-ethernet.yaml new file +107 -0
@@ -0,0 +1,107 @@ +# 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. It has no external MDIO PHY, and 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 phandle. + + 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
@@ -29557,6 +29557,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
Re: [PATCH net-next v3 2/6] dt-bindings: net: xlnx,xxv-ethernet: Add Xilinx XXV 10G/25G Ethernet
Documentation/devicetree/bindings/net/xlnx,xxv-ethernet.yaml
Quoted 4 lines
Documentation/devicetree/bindings/net/xlnx,xxv-ethernet.yaml new file +4
-0+ 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. It has no external MDIO PHY
What about MDIO bus?
Andrew
Re: [PATCH net-next v3 2/6] dt-bindings: net: xlnx,xxv-ethernet: Add Xilinx XXV 10G/25G Ethernet
Quoted 8 lines · Andrew Lunn
Documentation/devicetree/bindings/net/xlnx,xxv-ethernet.yaml
Quoted 4 lines
Documentation/devicetree/bindings/net/xlnx,xxv-ethernet.yaml new file +4
-0+ 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. It has no external MDIO PHYWhat about MDIO bus?
Andrew
The 10G/25G (XXV) Ethernet Subsystem IP does not provide an MDIO master. The contents of the appropriate MDIO registers are available in the IP control & status registers.
Regards,
Suraj
Re: [PATCH net-next v3 2/6] dt-bindings: net: xlnx,xxv-ethernet: Add Xilinx XXV 10G/25G Ethernet
Quoted 8 lines · Suraj
Quoted 5 lines · Andrew Lunn
Quoted 4 lines
Documentation/devicetree/bindings/net/xlnx,xxv-ethernet.yaml new file +4
-0+ 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. It has no external MDIO PHY
Quoted 5 lines
Quoted 3 lines
What about MDIO bus?
Andrew
The 10G/25G (XXV) Ethernet Subsystem IP does not provide an MDIO master.
O.K. Please change the wording to make that clear. There are plenty to 10G PHYs available, but it seems like you do not consider that a use case.
Has the MDIO bus master been replaced with I2C? I assume you intend this device to be paired by an SFP cage, so an I2C bus will be required. Is that a different IP which needs to be licensed?
Quoted 2 lines
The contents of the appropriate MDIO registers are available in the IP control & status registers.
What does that mean?
Andrew
Re: [PATCH net-next v3 2/6] dt-bindings: net: xlnx,xxv-ethernet: Add Xilinx XXV 10G/25G Ethernet
Quoted 9 lines · Andrew Lunn
Quoted 8 lines · Suraj
Quoted 5 lines · Andrew Lunn
Quoted 4 lines
Documentation/devicetree/bindings/net/xlnx,xxv-ethernet.yaml new file +4
-0+ 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. It has no external MDIO PHY
Quoted 6 lines
Quoted 5 lines
Quoted 3 lines
What about MDIO bus?
Andrew
The 10G/25G (XXV) Ethernet Subsystem IP does not provide an MDIO master.
I'll try to make the overall architecture clear, please let me know if I miss something and additional details needed. The datapath is:
DMA (AXIDMA/ MCDMA) <-> (XXV MAC + PCS/PMA) <-> GT serial transceiver <-> optical module / backplane.
MAC's in-core PCS/PMA drives a hardened GT (SerDes) transceiver directly at 10GBASE-R / 25GBASE-R, and the GT is configured over its DRP interface (the "drp" clock in this binding). There is no discrete PHY chip and no MDIO or I2C master inside the IP.
XXV ethernet PG: https://docs.amd.com/r/en-US/pg210-25g-ethernet
Quoted 4 lines
O.K. Please change the wording to make that clear. There are plenty to 10G PHYs available, but it seems like you do not consider that a use case.
Correct, the IP has no MDIO bus master, so an externally MDIO-managed PHY is not a supported use case. I will reword the description in v4 to state that explicitly, e.g.:
"The subsystem has an in-core PCS/PMA that drives a GT serial transceiver; it has no MDIO bus master and is therefore not managed through an external MDIO PHY. Link state is taken from the MAC's own status registers."
Quoted 4 lines
Has the MDIO bus master been replaced with I2C? I assume you intend this device to be paired by an SFP cage, so an I2C bus will be required. Is that a different IP which needs to be licensed?
The XXV Ethernet core contains neither an MDIO nor an I2C master. When a hardware design pairs it with an SFP/SFP+ cage, only the high-speed data path runs through this IP: the in-core PCS/PMA drives the GT transceiver, whose serial TX/RX lanes connect to the module. The module management side-band -- I2C for the module EEPROM/diagnostics is not part of this IP. It is provided by separate board logic, i.e. a different IP: a standard AXI IIC controller. Those are general-purpose soft cores from the standard Vivado IP catalog; each has its own devicetree node and binding, so the SFP management path looks outside the scope of this Ethernet binding. Please let me know if I should describe sfp in this binding.
Quoted 6 lines
Quoted 2 lines
The contents of the appropriate MDIO registers are available in the IP control & status registers.
What does that mean?
Andrew
I meant that the PCS/link state a driver would normally read from a PHY over MDIO (link up, resolved speed, block-lock/RX status) is exposed directly in the XXV IP's control & status registers, because the PCS/PMA is in-core.
Thanks,
Suraj
Re: [PATCH net-next v3 2/6] dt-bindings: net: xlnx,xxv-ethernet: Add Xilinx XXV 10G/25G Ethernet
Hi Andrew,
Quoted 53 lines · Suraj
Quoted 12 lines · Andrew Lunn
Quoted 11 lines · Suraj
Quoted 8 lines · Andrew Lunn
Quoted 7 lines
+ 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. It has no external MDIO PHYQuoted 6 lines
Quoted 5 lines
Quoted 3 lines
What about MDIO bus?
Andrew
The 10G/25G (XXV) Ethernet Subsystem IP does not provide an MDIO master.
I'll try to make the overall architecture clear, please let me know if I miss something and additional details needed. The datapath is:
DMA (AXIDMA/ MCDMA) <-> (XXV MAC + PCS/PMA) <-> GT serial transceiver <-
Quoted 1 line
optical module / backplane.
MAC's in-core PCS/PMA drives a hardened GT (SerDes) transceiver directly at 10GBASE-R / 25GBASE-R, and the GT is configured over its DRP interface (the "drp" clock in this binding). There is no discrete PHY chip and no MDIO or I2C master inside the IP.
XXV ethernet PG: https://docs.amd.com/r/en-US/pg210-25g-ethernet
Quoted 4 lines
O.K. Please change the wording to make that clear. There are plenty to 10G PHYs available, but it seems like you do not consider that a use case.
Correct, the IP has no MDIO bus master, so an externally MDIO-managed PHY is not a supported use case. I will reword the description in v4 to state that explicitly, e.g.:
"The subsystem has an in-core PCS/PMA that drives a GT serial transceiver; it has no MDIO bus master and is therefore not managed through an external MDIO PHY. Link state is taken from the MAC's own status registers."Quoted 4 lines
Has the MDIO bus master been replaced with I2C? I assume you intend this device to be paired by an SFP cage, so an I2C bus will be required. Is that a different IP which needs to be licensed?
The XXV Ethernet core contains neither an MDIO nor an I2C master. When a hardware design pairs it with an SFP/SFP+ cage, only the high-speed data path runs through this IP: the in-core PCS/PMA drives the GT transceiver, whose serial TX/RX lanes connect to the module. The module management side-band -- I2C for the module EEPROM/diagnostics is not part of this IP. It is provided by separate board logic, i.e. a different IP: a standard AXI IIC controller. Those are general-purpose soft cores from the standard Vivado IP catalog; each has its own devicetree node and binding, so the SFP management path looks outside the scope of this Ethernet binding. Please let me know if I should describe sfp in this binding.
Quoted 5 lines
Quoted 2 lines
The contents of the appropriate MDIO registers are available in the IP control & status registers.
What does that mean?
Quoted 7 lines
Quoted 1 line
Andrew
I meant that the PCS/link state a driver would normally read from a PHY over MDIO (link up, resolved speed, block-lock/RX status) is exposed directly in the XXV IP's control & status registers, because the PCS/PMA is in-core.
Thanks,
Suraj
Please let me know if I should provide any additional details.
Also, would you recommend that I send a v4 addressing the commit message and comment updates we discussed, or should I wait for further review feedback on the series?
Thanks,
Suraj
PATCH v3 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 | 329 ++++++++++++++++++ .../net/ethernet/xilinx/xilinx_axienet_xxv.h | 86 +++++ 5 files changed, 437 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
@@ -1705,6 +1705,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_of_phy_connect (lp->phylink, lp->dev->of_node,0 );if (ret) {
@@ -2604,11 +2608,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)
@@ -2668,7 +2667,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 ;
@@ -2814,6 +2815,9 @@ static void axienet_dma_err_handler(struct work_struct *work)axienet_dma_start (lp); +/* This error handler runs only for the legacy embedded-DMA (1G) path, +* 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
@@ -2917,6 +2921,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 +329 -0
329 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
drivers/net/ethernet/xilinx/xilinx_axienet_main.c static void axienet_dma_err_handler(struct work_struct *work) · line 2820
Quoted 3 lines
drivers/net/ethernet/xilinx/xilinx_axienet_main.c +3
-0+/* This error handler runs only for the legacy embedded-DMA (1G) path, +* whose mac_init() cannot fail, so its return value is not checked. +*/
Is legacy the correct word here. Have you stopped licensing the 1G MAC?
Andrew
Quoted 8 lines · Andrew Lunn
drivers/net/ethernet/xilinx/xilinx_axienet_main.c static void axienet_dma_err_handler(struct work_struct *work) · line 2820
Quoted 3 lines
drivers/net/ethernet/xilinx/xilinx_axienet_main.c +3
-0+/* This error handler runs only for the legacy embedded-DMA (1G) path, +* whose mac_init() cannot fail, so its return value is not checked. +*/ Is legacy the correct word here. Have you stopped licensing the 1G MAC?
Andrew
By "legacy embedded-DMA (1G) path", I meant the legacy non-dmaengine flow in the driver. This path does not use the dmaengine framework and therefore does not communicate with the Xilinx DMAEngine driver; instead, the AXI Ethernet driver handles the DMA programming directly.
I agree that "legacy embedded-DMA" could be confusing here. I'll rename it to "non-dmaengine flow" in the next revision.
Thanks,
Suraj
[email protected]
AI reviewThank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider: - [High] Missing mac_link_up callback for XXV MAC causes runtime-switchable speeds and flow control to…
Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:
- [High] Missing mac_link_up callback for XXV MAC causes runtime-switchable speeds and flow control to never be programmed.
- [High] Legacy DMA descriptors and SKBs are leaked if mac_init() fails in axienet_device_reset().
- [High] Failure of axienet_xxv_mac_init() is ignored in the DMA error handler, proceeding with uninitialized hardware state. --
commit 0e020a3d14a024a203937c2f29cbb4fde9c6c31b
Author: Suraj Gupta <[email protected]>
net: xilinx: axienet: Add 10G/25G (XXV) ethernet support
This commit adds support for the Xilinx XXV Ethernet IP, introducing a new axienet_10g25g_config structure and associated callbacks. It also propagates axienet_device_reset() failures in axienet_open().
Quoted 4 lines
drivers/net/ethernet/xilinx/xilinx_axienet_main.c +0
-0
[ ... ]
drivers/net/ethernet/xilinx/xilinx_axienet_main.c static void axienet_dma_err_handler(struct work_struct *work) · line 2825
Quoted 8 lines
drivers/net/ethernet/xilinx/xilinx_axienet_main.c +3
-0@@ -2818,6 +2819,9 @@ static void axienet_dma_err_handler(struct work_struct *work)axienet_dma_start (lp); +/* This error handler runs only for the legacy embedded-DMA (1G) path, +* whose mac_init() cannot fail, so its return value is not checked. +*/ lp->axienet_config->mac_init (ndev);
[Severity: High]
If the XXV MAC falls back to legacy DMA due to a missing device tree property, couldn't this error handler run for the XXV MAC as well?
If axienet_xxv_mac_init() fails here (e.g., from a timeout), does the driver proceed to configure hardware options and re-enable packet reception on an uninitialized or failed MAC?
[ ... ]
Quoted 5 lines
drivers/net/ethernet/xilinx/xilinx_axienet_xxv.c new file +0
-0
[ ... ]
drivers/net/ethernet/xilinx/xilinx_axienet_xxv.c line 213
Quoted 8 lines
drivers/net/ethernet/xilinx/xilinx_axienet_xxv.c new file +8
-0+static int axienet_xxv_mac_init (struct net_device *ndev) +{ +struct axienet_local *lp =netdev_priv (ndev); +int ret; + + ret =axienet_xxv_poll_link_ready (ndev); +if (ret) +return ret;
[Severity: High]
If this function returns an error, are the legacy DMA descriptors leaked?
Looking at axienet_device_reset(), which calls this function when using legacy DMA:
axienet_device_reset()
...
if (!lp->use_dmaengine) {
ret = axienet_dma_bd_init(ndev);
if (ret)
return ret;
}
...
ret = lp->axienet_config->mac_init(ndev);
if (ret)
return ret;When mac_init() fails, it returns early without calling axienet_dma_bd_release(ndev). Can this cause a memory leak of the TX/RX rings and their associated SKBs?
[ ... ]
drivers/net/ethernet/xilinx/xilinx_axienet_xxv.c line 329
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: High]
Since axienet_xxv_phylink_set_capabilities() advertises runtime-switchable speeds (10G and 25G), shouldn't there be a mac_link_up callback here to program the negotiated speed and pause settings to the hardware?
Without a mac_link_up callback, when phylink resolves to a non-default speed or enables pause frames, will the hardware remain unconfigured, potentially causing the datapath to silently fail?
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=3
Quoted 33 lines · On 9/1/2026 8:39 PM, [email protected] wrote:
Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:
- [High] Missingmac_link_upcallback for XXV MAC causes runtime-switchable speeds and flow control to never be programmed.
- [High] Legacy DMA descriptors and SKBs are leaked ifmac_init()fails inaxienet_device_reset().
- [High] Failure ofaxienet_xxv_mac_init()is ignored in the DMA error handler, proceeding with uninitialized hardware state. --commit
0e020a3d14a024a203937c2f29cbb4fde9c6c31b
Author: Suraj Gupta <[email protected]>net: xilinx: axienet: Add 10G/25G (XXV) ethernet support
This commit adds support for the Xilinx XXV Ethernet IP, introducing a new
axienet_10g25g_configstructure and associated callbacks. It also propagatesaxienet_device_reset()failures inaxienet_open().Quoted 4 lines
drivers/net/ethernet/xilinx/xilinx_axienet_main.c +0
-0[ ... ]
drivers/net/ethernet/xilinx/xilinx_axienet_main.c static void axienet_dma_err_handler(struct work_struct *work) · line 2825
Quoted 8 lines
drivers/net/ethernet/xilinx/xilinx_axienet_main.c +3
-0@@ -2818,6 +2819,9 @@ static void axienet_dma_err_handler(struct work_struct *work)axienet_dma_start (lp); +/* This error handler runs only for the legacy embedded-DMA (1G) path, +* whose mac_init() cannot fail, so its return value is not checked. +*/ lp->axienet_config->mac_init (ndev);[Severity: High]
If the XXV MAC falls back to legacy DMA due to a missing device tree property, couldn't this error handler run for the XXV MAC as well?
Quoted 4 lines
If
axienet_xxv_mac_init()fails here (e.g., from a timeout), does the driver proceed to configure hardware options and re-enable packet reception on an uninitialized or failed MAC?
We don't support legacy DMA for XXV ethernet & fail probe if dmaengine properties are missing. So this is a false issue.
Quoted 34 lines
[ ... ]
Quoted 5 lines
drivers/net/ethernet/xilinx/xilinx_axienet_xxv.c new file +0
-0[ ... ]
drivers/net/ethernet/xilinx/xilinx_axienet_xxv.c line 213
Quoted 8 lines
drivers/net/ethernet/xilinx/xilinx_axienet_xxv.c new file +8
-0+static int axienet_xxv_mac_init (struct net_device *ndev) +{ +struct axienet_local *lp =netdev_priv (ndev); +int ret; + + ret =axienet_xxv_poll_link_ready (ndev); +if (ret) +return ret;[Severity: High]
If this function returns an error, are the legacy DMA descriptors leaked?Looking at
axienet_device_reset(), which calls this function when using legacy DMA:
axienet_device_reset()... if (!lp->use_dmaengine) { ret = axienet_dma_bd_init(ndev); if (ret) return ret; } ... ret = lp->axienet_config->mac_init(ndev); if (ret) return ret;
Quoted 4 lines
When
mac_init()fails, it returns early without callingaxienet_dma_bd_release(ndev). Can this cause a memory leak of the TX/RX rings and their associated SKBs?
Same here, XXV ethernet driver supports dmaengine flow only. Probe will fail if dmanegine properties are missing in XXV DT. So this condition won't occur and is false positive issue.
Quoted 20 lines
[ ... ]
drivers/net/ethernet/xilinx/xilinx_axienet_xxv.c line 329
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: High]
Sinceaxienet_xxv_phylink_set_capabilities()advertises runtime-switchable speeds (10G and 25G), shouldn't there be amac_link_upcallback here to program the negotiated speed and pause settings to the hardware?
Quoted 4 lines
Without a
mac_link_upcallback, when phylink resolves to a non-default speed or enables pause frames, will the hardware remain unconfigured, potentially causing the datapath to silently fail?
As mentioned in cover-letter, due to phylink limitations, we aren't able to advertise both 10G and 25G base-r interfaces and are open to suggestions to handle it.
Regards,
Suraj
PATCH v3 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
@@ -2498,7 +2498,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 v3 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
[email protected]
AI reviewRe: [PATCH net-next v3 5/6] net: xilinx: axienet: Dispatch statistics through axienet_config ops
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
Pre-existing issues:
- [High] Out-of-bounds array write in axienet_1g_get_ethtool_stats() due to mismatched statistics array indices.
- [High] Reading a seqcount_mutex_t from interrupt context can cause a deadlock if the writer is preempted. --
commit a22a50757854e007ab76536560cb1108e8d22fd4
Author: Suraj Gupta <[email protected]>
net: xilinx: axienet: Dispatch statistics through axienet_config ops
This commit refactors the AXI Ethernet driver's statistics reporting by dispatching stats reads through operation pointers in struct axienet_config. This prepares the driver to support different MAC types without inline branches in the statistics callbacks.
Quoted 25 lines
drivers/net/ethernet/xilinx/xilinx_axienet_main.c +2
-12@@ -1878,29 +1878,11 @@ static int axienet_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)return phylink_mii_ioctl (lp->phylink, rq, cmd); } -static void -axienet_get_stats64 (struct net_device *dev,struct rtnl_link_stats64 *stats) +static void axienet_1g_get_stats64 (struct axienet_local *lp, +struct rtnl_link_stats64 *stats) { -struct axienet_local *lp =netdev_priv (dev);unsigned int start; -netdev_stats_to_stats64 (stats, &dev->stats); - -do { - start =u64_stats_fetch_begin (&lp->rx_stat_sync); - stats->rx_packets =u64_stats_read (&lp->rx_packets); - stats->rx_bytes =u64_stats_read (&lp->rx_bytes); - }while (u64_stats_fetch_retry (&lp->rx_stat_sync, start)); - - do {
drivers/net/ethernet/xilinx/xilinx_axienet_main.c static int axienet_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) · line 1887
Quoted 10 lines
drivers/net/ethernet/xilinx/xilinx_axienet_main.c +0
-8- start =u64_stats_fetch_begin (&lp->tx_stat_sync); - stats->tx_packets =u64_stats_read (&lp->tx_packets); - stats->tx_bytes =u64_stats_read (&lp->tx_bytes); - }while (u64_stats_fetch_retry (&lp->tx_stat_sync, start)); - -if (!(lp->features &XAE_FEATURE_STATS )) -return ; - do { start = read_seqcount_begin(&lp->hw_stats_seqcount);
[Severity: High]
This is a pre-existing issue, but is it safe to read this seqcount_mutex_t from this context?
The hw_stats_seqcount writer runs in process context (a delayed work) holding a mutex, meaning it can be preempted by softirqs. The reader here in axienet_1g_get_stats64() is called via ndo_get_stats64, which can be invoked from atomic or softirq context (such as via dev_get_stats() in the Open vSwitch datapath).
If a softirq fires on the same CPU while the writer is inside the seqcount write section, won't the reader spin infinitely in read_seqcount_begin() waiting for the odd sequence number to become even, resulting in a hard deadlock?
[ ... ]
drivers/net/ethernet/xilinx/xilinx_axienet_main.c static void axienet_ethtools_get_ethtool_stats(struct net_device *dev,
Quoted 10 lines
drivers/net/ethernet/xilinx/xilinx_axienet_main.c +1
-4-static void axienet_ethtools_get_ethtool_stats (struct net_device *dev, -struct ethtool_stats *stats, -u64 *data) +static void axienet_1g_get_ethtool_stats (struct axienet_local *lp,u64 *data) { -struct axienet_local *lp =netdev_priv (dev);unsigned int start; do {@@ -2381,6 +2387,17 @@ static void axienet_ethtools_get_ethtool_stats(struct net_device *dev,
[Severity: High]
This isn't a bug introduced by this patch, but does this function overflow the data array allocated by the ethtool core?
When a user invokes ethtool -S, the core allocates a buffer for 9 elements based on the return value of axienet_1g_get_sset_count(). However, inside the seqcount loop in axienet_1g_get_ethtool_stats(), the code writes beyond these bounds:
data[8] = axienet_stat(lp, STAT_USER_DEFINED0); data[9] = axienet_stat(lp, STAT_USER_DEFINED1); data[10] = axienet_stat(lp, STAT_USER_DEFINED2);
Can this overrun the 72-byte allocated buffer by 16 bytes and cause memory corruption?
[ ... ]
Quoted 17 lines
drivers/net/ethernet/xilinx/xilinx_axienet_main.c +10
-0static const char axienet_ethtool_stats_strings[][ETH_GSTRING_LEN ] = {"Received bytes" ,"Transmitted bytes" ,@@ -2393,12 +2410,26 @@ static const char axienet_ethtool_stats_strings[][ETH_GSTRING_LEN] = { "User Defined Counter 2", }; +static void axienet_1g_get_strings (u8 *data) +{ +memcpy (data, axienet_ethtool_stats_strings, +sizeof (axienet_ethtool_stats_strings)); +} + +static int axienet_1g_get_sset_count (void ) +{ +return ARRAY_SIZE (axienet_ethtool_stats_strings); +}
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=5
Re: [PATCH net-next v3 5/6] net: xilinx: axienet: Dispatch statistics through axienet_config ops
Quoted 7 lines · On 9/1/2026 8:39 PM, [email protected] wrote:
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
Pre-existing issues:
- [High] Out-of-bounds array write inaxienet_1g_get_ethtool_stats()due to mismatched statistics array indices.
- [High] Reading aseqcount_mutex_tfrom interrupt context can cause a deadlock if the writer is preempted. --
Both are pre-existing issues, I'll address them as part of separate series.
Regards,
Suraj
Quoted 108 lines
commit
a22a50757854e007ab76536560cb1108e8d22fd4
Author: Suraj Gupta <[email protected]>net: xilinx: axienet: Dispatch statistics through
axienet_configopsThis commit refactors the AXI Ethernet driver's statistics reporting by dispatching stats reads through operation pointers in struct
axienet_config. This prepares the driver to support different MAC types without inline branches in the statistics callbacks.Quoted 25 lines
drivers/net/ethernet/xilinx/xilinx_axienet_main.c +2
-12@@ -1878,29 +1878,11 @@ static int axienet_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)return phylink_mii_ioctl (lp->phylink, rq, cmd); } -static void -axienet_get_stats64 (struct net_device *dev,struct rtnl_link_stats64 *stats) +static void axienet_1g_get_stats64 (struct axienet_local *lp, +struct rtnl_link_stats64 *stats) { -struct axienet_local *lp =netdev_priv (dev);unsigned int start; -netdev_stats_to_stats64 (stats, &dev->stats); - -do { - start =u64_stats_fetch_begin (&lp->rx_stat_sync); - stats->rx_packets =u64_stats_read (&lp->rx_packets); - stats->rx_bytes =u64_stats_read (&lp->rx_bytes); - }while (u64_stats_fetch_retry (&lp->rx_stat_sync, start)); - - do {drivers/net/ethernet/xilinx/xilinx_axienet_main.c static int axienet_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) · line 1887
Quoted 10 lines
drivers/net/ethernet/xilinx/xilinx_axienet_main.c +0
-8- start =u64_stats_fetch_begin (&lp->tx_stat_sync); - stats->tx_packets =u64_stats_read (&lp->tx_packets); - stats->tx_bytes =u64_stats_read (&lp->tx_bytes); - }while (u64_stats_fetch_retry (&lp->tx_stat_sync, start)); - -if (!(lp->features &XAE_FEATURE_STATS )) -return ; - do { start = read_seqcount_begin(&lp->hw_stats_seqcount);[Severity: High]
This is a pre-existing issue, but is it safe to read thisseqcount_mutex_tfrom this context?The
hw_stats_seqcountwriter runs in process context (a delayed work) holding a mutex, meaning it can be preempted by softirqs. The reader here inaxienet_1g_get_stats64()is called viando_get_stats64, which can be invoked from atomic or softirq context (such as viadev_get_stats()in the Open vSwitch datapath).If a softirq fires on the same CPU while the writer is inside the seqcount write section, won't the reader spin infinitely in
read_seqcount_begin()waiting for the odd sequence number to become even, resulting in a hard deadlock?[ ... ]
drivers/net/ethernet/xilinx/xilinx_axienet_main.c static void axienet_ethtools_get_ethtool_stats(struct net_device *dev,
Quoted 10 lines
drivers/net/ethernet/xilinx/xilinx_axienet_main.c +1
-4-static void axienet_ethtools_get_ethtool_stats (struct net_device *dev, -struct ethtool_stats *stats, -u64 *data) +static void axienet_1g_get_ethtool_stats (struct axienet_local *lp,u64 *data) { -struct axienet_local *lp =netdev_priv (dev);unsigned int start; do {@@ -2381,6 +2387,17 @@ static void axienet_ethtools_get_ethtool_stats(struct net_device *dev,[Severity: High]
This isn't a bug introduced by this patch, but does this function overflow the data array allocated by the ethtool core?When a user invokes ethtool -S, the core allocates a buffer for 9 elements based on the return value of
axienet_1g_get_sset_count(). However, inside the seqcount loop inaxienet_1g_get_ethtool_stats(), the code writes beyond these bounds:data[8] = axienet_stat(lp, STAT_USER_DEFINED0); data[9] = axienet_stat(lp, STAT_USER_DEFINED1); data[10] = axienet_stat(lp, STAT_USER_DEFINED2);Can this overrun the 72-byte allocated buffer by 16 bytes and cause memory corruption?
[ ... ]
Quoted 17 lines
drivers/net/ethernet/xilinx/xilinx_axienet_main.c +10
-0static const char axienet_ethtool_stats_strings[][ETH_GSTRING_LEN ] = {"Received bytes" ,"Transmitted bytes" ,@@ -2393,12 +2410,26 @@ static const char axienet_ethtool_stats_strings[][ETH_GSTRING_LEN] = { "User Defined Counter 2", }; +static void axienet_1g_get_strings (u8 *data) +{ +memcpy (data, axienet_ethtool_stats_strings, +sizeof (axienet_ethtool_stats_strings)); +} + +static int axienet_1g_get_sset_count (void ) +{ +return ARRAY_SIZE (axienet_ethtool_stats_strings); +}
PATCH v3 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 | 22 +- .../net/ethernet/xilinx/xilinx_axienet_xxv.c | 266 ++++++++++++++++++ .../net/ethernet/xilinx/xilinx_axienet_xxv.h | 55 ++++ 4 files changed, 343 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 +20 -2
@@ -592,7 +592,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 ); }
@@ -601,7 +605,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 legacy (non-dmaengine) DMA path, which the +* legacy_dma 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);
@@ -1777,6 +1790,11 @@ static int axienet_stop(struct net_device *ndev)cancel_work_sync (&lp->rx_dim.work);cancel_delayed_work_sync (&lp->stats_work); +if (lp->axienet_config->stats_update) { +mutex_lock (&lp->stats_lock); + lp->axienet_config->stats_update (lp); +mutex_unlock (&lp->stats_lock); + }phylink_stop (lp->phylink);phylink_disconnect_phy (lp->phylink);
drivers/net/ethernet/xilinx/xilinx_axienet_xxv.c +266 -0
297 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