Add Cortina Systems CS7542 network engine support
Subsystems (4)
v9 cover Add Cortina Systems CS7542 network engine support
Add the CS7542 CPU network datapath with phylink for three GMACs. Almond+ connects two GMACs to QCA8337 CPU ports handled by DSA.
This series depends on the combined CS7542 global controls v6 series.
The consumer exclusively acquires NI, FE, TM, SCH, QM, DMA and NI-XRAM
reset controls. Board DTS support is separate. The verified 64 MiB
no-map queue-manager reservation is required. NAND uses PIO; a separate SSP DMA consumer cannot run concurrently with the shared DMA reset domain.
Use normal NAPI weight 64 and external-DDR QM/TM setup, with no module parameters. Support scatter-gather TX and multi-buffer RX, bounded initialization, tracked DMA ownership, shared NI register serialization and protective reset before freeing active mappings. No checksum/NAT offload or performance capability is added.
The port byte counters previously wrapped at 4 GiB on 32-bit ARM. Use the network core's 64-bit per-CPU totals and preserve the existing error and drop counters. Allow independent MAC addresses on each netdev. With PAUSE temporarily enabled for testing, QCA8337 PAUSE frames stopped transmission on both GMACs with different addresses. The MAC accepts PAUSE on full-duplex fixed links to a partner described as asymmetric-only. The board DTS change uses the standard asym-pause property and is separate. On Almond+ with TX PAUSE enabled for testing, no outgoing PAUSE frames were observed when the CPU RX ring filled on either GMAC. Leave hardware generation disabled and omit symmetric PAUSE from the advertised MAC capabilities.
The driver exposes no MAC-level Wake-on-LAN support. The NI
magic-packet comparator uses the shared MAC prefix and cannot follow
arbitrary independent netdev MAC addresses. PHY-based wake support can be considered separately once the PHY capability and board wake path are verified.
The driver builds for ARM with W=1 and warnings as errors, both as a module and built in. Full allmodconfig and allyesconfig builds complete with W=1 after leaving pre-existing base-tree warnings non-fatal. On Almond+, an OpenWrt RAM build exercised LAN1 over each QCA8337 CPU port with the standard two-byte QCA tag. Five two-packet ICMP exchanges succeeded while assigning and changing different MAC addresses for the two GMACs. RX/TX counters increased on the selected GMAC in each case. All MTD partitions were read-only and the watchdog returned to OpenWrt.
Earlier combined-kernel Almond+ checks covered reset/probe/removal, LAN1 protected-data transfers and automatic watchdog return to normal OpenWrt. Separate earlier fixtures checked 600 UDP echoes, 20 ICMPv6 replies and 448 scatter-gather/jumbo frames. Protected-region hashes and flash layout matched; unrelated concurrent settings activity was excluded from any unchanged-settings claim. These observations predate the new retry/context fixes and are integration/functional checks, not throughput or offload results.
Changes in v9:
- Disable netpoll for the shared TX lock and acquire the GMAC OF node
through phylink and netdev teardown.
- Use standard drop/error counters and sleepable RX pool allocation.
- Drain RX from the refreshed write pointer and preserve the vendor
tail settle time.
- Write little-endian TX descriptors, publish the head after the full
mapping succeeds and program the shared DRR shaper once per port.
- Honour RX PAUSE on fixed asymmetric links. In an Almond+ register
A/B/A test with a congested receiver, the TCP retransmit counts were
1838 with RX PAUSE off, 75 with it on, and 1066 with it off again.
- Publish consumed RX descriptors in eight-packet batches. In paired
200 Mbit/s receive tests on the combined image, the ring was nearly
full in 3.80% and 0.89% of samples, with 142 and 38 TCP retransmits.
The combined image includes the board DTS and downstream support.
- Link to the v8 review: https://lore.kernel.org/all/[email protected]/
- Link to v8: https://patch.msgid.link/[email protected]
Changes in v8:
- Rebase onto current net-next (Willem de Bruijn).
- Anchor MAINTAINERS independently of the global-controls entry.
- Pick up Rob Herring's Reviewed-by on the unchanged binding.
- Link to v7: https://patch.msgid.link/[email protected]
Changes in v7:
- Address Andrew Lunn's review. Simplify the FE return path and order
local declarations. Separate RX packet handling from the NAPI loop.
- Allow independent MAC addresses, retain NVMEM probe deferral and
leave hardware pause disabled.
- Link to v6: https://patch.msgid.link/[email protected]
Changes in v6:
- Keep zero-budget NAPI polling limited to TX completions.
- Link to v5: https://lore.kernel.org/r/[email protected]
Changes in v5:
- Use the network core's 64-bit per-CPU packet and byte totals.
- Pack the MAC register value with get_unaligned_le32().
- Update the global-controls dependency to v6.
- Link to v4: https://lore.kernel.org/all/[email protected]/
Changes in v4:
- Bound DMA-owned RX head polling and defer retries with the IRQ masked.
- Schedule NAPI with bottom halves disabled from process context.
- Link to v3: https://lore.kernel.org/all/[email protected]/
Changes in v3:
- Include FCS in RX buffer recycling and retry transient descriptor ownership.
- Validate the shared MAC prefix and reject sibling-clobbering changes.
- Drop the RESET_CONTROLLER select from the Ethernet consumer.
- Rely on reset provider error propagation instead of redundant status reads.
- Use bulk deassert on bring-up; preserve all protective assertions on teardown.
- Link to v2: https://patch.msgid.link/[email protected]
Changes in v2:
- Use the common parent provider and all seven exclusive reset lines;
remove the virtual reset child, duplicate provider and consumer hook.
- Assert and verify every line without protective-assert rollback;
retain active DMA allocations on any error and deassert in reverse order.
- Use rgmii-id in the binding example for switch-inserted RX/TX delays.
- Remove module parameters and unused internal-buffer mode; retain the
previous default external-DDR initialization policy.
- Use NAPI weight64, plain static MMIO helpers and goto-based open cleanup;
retain the lock-protected publication and stopping gates.
- Serialize shared NI RMW and stop on the first scheduler command error.
- Keep MAC preflight before hardware cleanup registration and preserve
a late NVMEM probe defer instead of replacing it with a random MAC.
- Recycle bounded RX fragments also when the frame is dropped.
- Poll already queued RX after open and retain safe closed-port TX reaping.
- Review Sashiko 231860: existing NI/SCH/NAPI fixes address the older v1; temporary BM initialization bypass clearing follows the vendor sequence.
- Link to v1: https://lore.kernel.org/all/[email protected]/
---
Fil Dunsky (3):
dt-bindings: net: Add Cortina CS7542 network engine
net: cortina: Add CS7542 CPU network datapath
MAINTAINERS: Add CS7542 network engine support
.../bindings/net/cortina,cs7542-ethernet.yaml | 162 ++ MAINTAINERS | 7 + drivers/net/ethernet/cortina/Kconfig | 13 + drivers/net/ethernet/cortina/Makefile | 3 + drivers/net/ethernet/cortina/cs752x_fe.c | 475 +++++ drivers/net/ethernet/cortina/cs752x_ne.c | 1903 ++++++++++++++++++++ drivers/net/ethernet/cortina/cs752x_ne.h | 13 + drivers/net/ethernet/cortina/cs752x_sch_tm.c | 689 +++++++ 8 files changed, 3265 insertions(+)
---
base-commit: aea6deaf6b3c8a204242a4ca1fdb26e8e74de5fc
change-id: 20261123-b4-cs7542-ethernet-59c15dbc7e7e
prerequisite-message-id: <[email protected]>
prerequisite-patch-id: 27fe25055bcadb3c3fbc8b6788f31c2fb791df38
prerequisite-patch-id: ae69b5cca6f4604972300a89411bdca0ea19ab57
prerequisite-patch-id: 55dc4f1e91fc85340c4422438225f50fdf636799
prerequisite-patch-id: 66fccae72a8f951ac0ee182490e98543af29bd89
prerequisite-patch-id: 7fbe9405265ef3d1ec62811415a46c0061afd7c8
prerequisite-patch-id: 01ece2c91e080d5cae6af81944159373776484ca
Best regards,
Signature · 1 line
Fil Dunsky <[email protected]>
PATCH v9 1/3 dt-bindings: net: Add Cortina CS7542 network engine
Describe the CS7542 network engine register windows, interrupts, GMACs and reserved queue-manager memory. Require exclusive ownership of the seven NI/FE/TM/SCH/QM/DMA/NI-XRAM reset controls from the global provider. The shared DMA line includes both LSO and SSP. Use rgmii-id for the example switch peer which inserts RX and TX clock delays.
--- .../bindings/net/cortina,cs7542-ethernet.yaml | 162 +++++++++++++++++++++ 1 file changed, 162 insertions(+)
Documentation/devicetree/bindings/net/cortina,cs7542-ethernet.yaml new file +162 -0
@@ -0,0 +1,162 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/net/cortina,cs7542-ethernet.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Cortina Systems CS7542 network engine + +maintainers: + - Fil Dunsky <[email protected]> + +description: | + The CS7542 network engine contains three GMACs, the network interface (NI), + forwarding engine (FE), queue manager (QM), traffic manager (TM), scheduler, + CPU XRAM interface and packet DMA. The CPU datapath uses the DMA-LSO TX + queue and QM-managed RX buffers. The complete DMA-LSO/SSP register block + and the combined reset domain must be exclusively owned by this device; + a separate SSP DMA consumer cannot operate concurrently. A NAND controller + using PIO does not consume that DMA block. + The three GMAC station addresses share their first five bytes in NI + registers; only the last byte is independent for each port. + +properties: + compatible: + const: cortina,cs7542-ethernet + + reg: + items: + - description: NI registers + - description: Complete DMA-LSO and DMA-SSP registers + - description: FE registers and indirect table interfaces + - description: QM registers + - description: TM registers + - description: Scheduler registers + - description: CPU XRAM + + reg-names: + items: + - const: ni + - const: dma + - const: fe + - const: qm + - const: tm + - const: sch + - const: xram + + interrupts: + items: + - description: GMAC0 CPU receive queue interrupt + - description: GMAC1 CPU receive queue interrupt + - description: GMAC2 CPU receive queue interrupt + + interrupt-names: + items: + - const: eth0 + - const: eth1 + - const: eth2 + + cortina,global-syscon: + $ref: /schemas/types.yaml#/definitions/phandle + description: Global control syscon for network drive strength and status. + + resets: + items: + - description: Network interface reset. + - description: Forwarding engine reset. + - description: Traffic manager reset. + - description: Scheduler reset. + - description: Queue manager reset. + - description: Shared DMA-LSO/SSP reset, exclusively owned by this consumer. + - description: Network interface XRAM reset. + + reset-names: + items: + - const: ni + - const: fe + - const: tm + - const: sch + - const: qm + - const: dma + - const: xram + + memory-region: + maxItems: 1 + description: | + Reserved no-map DDR region used by the packet queue manager. Initial + support uses the upper 64 MiB of the 512 MiB DDR layout at 0x1c000000. + + "#address-cells": + const: 1 + + "#size-cells": + const: 0 + +patternProperties: + "^ethernet-port@[0-2]$": + type: object + $ref: ethernet-controller.yaml# + unevaluatedProperties: false + properties: + reg: + maxItems: 1 + phy-mode: + enum: [rgmii, rgmii-id, rgmii-rxid, rgmii-txid] + required: + - reg + - phy-mode + +required: + - compatible + - reg + - reg-names + - interrupts + - interrupt-names + - cortina,global-syscon + - resets + - reset-names + - memory-region + - "#address-cells" + - "#size-cells" + +additionalProperties: false + +examples: + - | + #include <dt-bindings/interrupt-controller/arm-gic.h> + #include <dt-bindings/reset/cortina,cs7542-reset.h> + + ethernet@f0010000 { + compatible = "cortina,cs7542-ethernet"; + reg = <0xf0010000 0x500>, <0xf0090000 0x800>, + <0xf0020000 0x4000>, <0xf0030000 0x400>, + <0xf0040000 0x800>, <0xf0060000 0x100>, + <0xf0400000 0x100000>; + reg-names = "ni", "dma", "fe", "qm", "tm", "sch", "xram"; + interrupts = <GIC_SPI 37 IRQ_TYPE_LEVEL_HIGH>, + <GIC_SPI 38 IRQ_TYPE_LEVEL_HIGH>, + <GIC_SPI 39 IRQ_TYPE_LEVEL_HIGH>; + interrupt-names = "eth0", "eth1", "eth2"; + cortina,global-syscon = <&global>; + resets = <&global CS7542_RESET_NI>, + <&global CS7542_RESET_FE>, + <&global CS7542_RESET_TM>, + <&global CS7542_RESET_SCH>, + <&global CS7542_RESET_QM>, + <&global CS7542_RESET_DMA>, + <&global CS7542_RESET_NI_XRAM>; + reset-names = "ni", "fe", "tm", "sch", "qm", "dma", "xram"; + memory-region = <&qm_reserved>; + #address-cells = <1>; + #size-cells = <0>; + + ethernet-port@1 { + reg = <1>; + /* Fixed MAC-to-switch link; peer inserts RX/TX clock delays. */ + phy-mode = "rgmii-id"; + fixed-link { + speed = <1000>; + full-duplex; + }; + }; + };
Signature · 1 line
2.53.0
PATCH v9 2/3 net: cortina: Add CS7542 CPU network datapath
In reply to Fil DunskyAdd the three-GMAC CS7542 CPU network datapath with phylink, per-port NAPI RX and a shared coherent TX ring. Support scatter-gather TX and multi-buffer RX while validating DMA addresses and ring ownership. Use the normal NAPI weight and the supported external-DDR QM/TM setup.
Bound indirect initialization and require confirmed complete-domain reset before freeing active DMA mappings. Pin mappings and context when reset fails. Keep resource publication and shared-ring timer cancellation under the TX lock so completions cannot wake a closing or failed port. Use shared ndo_open cleanup labels and let the compiler inline MMIO helpers when appropriate.
Acquire NI, FE, TM, SCH, QM, DMA and NI-XRAM controls exclusively from the global provider. Assert and verify all seven without rolling back protective assertions; preserve the first error and retain all active DMA allocations on any failure. Deassert in reverse order. The shared DMA control covers both LSO and SSP. Require the verified 64 MiB no-map queue-manager reservation on the supported DDR layout.
Serialize read-modify-write accesses to NI registers shared by the MACs. Abort initialization on the first scheduler command error before the network engine can publish DMA buffers.
Resolve NVMEM MAC deferral before installing hardware cleanup, when no reset or DMA state needs unwinding. Register the plain managed cleanup action immediately before the first reset attempt, preserving protective cleanup for that attempt and all later failures.
Count RX fragments independently of whether the frame is deliverable. Start with a masked NAPI poll to service previously queued RX descriptors. Keep TX completion reaping available while closed ports still own queued mappings. The coherent TX read pointer identifies completed descriptors; this hardware retains TX OWN after completion.
Count all DMA bytes including FCS when recycling RX fragments. Bound immediate NAPI retries of a hardware-owned head to four polls, then keep the IRQ masked and retry from delayed work without touching DMA-owned buffers. Cancel the retry when stopping the port. Disable bottom halves around NAPI scheduling from ndo_open and the retry worker, restoring locks and IRQ state before allowing the softirq to run.
Read each port's MAC address independently and use the standard Ethernet netdev address change helper. The NI control-frame MAC address has a shared five-octet prefix. Keep PAUSE transmission disabled. A full-duplex fixed link to a partner described as asymmetric-only can accept PAUSE to prevent congestion drops in the QCA8337 CPU-to-WAN path.
Keep packet and byte totals in the network core per-CPU statistics. Separate RX packet handling from NAPI polling. Keep zero-budget NAPI polling limited to TX completions.
Disable netpoll because a reentrant hard-IRQ poll could acquire the shared TX lock already held by the interrupted context. Hold the OF node until after the netdev and phylink have been torn down. Use the netdev counter helpers for drops and errors and allocate refill pages with GFP_KERNEL in the sleepable probe path.
Continue the NAPI drain when the hardware write pointer has advanced. Keep the vendor tail delay when no additional packet is visible. Publish the consumer pointer every eight completed packets to return slots before sustained traffic fills the CPU XRAM ring. Return the DMA buffers before publishing each batch and keep the final update for short and incomplete batches.
Use little-endian TX descriptors and publish the producer index only after all DMA mappings have succeeded. Program the single shared DRR shaper once after configuring the port queues.
--- drivers/net/ethernet/cortina/Kconfig | 13 + drivers/net/ethernet/cortina/Makefile | 3 + drivers/net/ethernet/cortina/cs752x_fe.c | 475 +++++++ drivers/net/ethernet/cortina/cs752x_ne.c | 1903 ++++++++++++++++++++++++++ drivers/net/ethernet/cortina/cs752x_ne.h | 13 + drivers/net/ethernet/cortina/cs752x_sch_tm.c | 689 ++++++++++ 6 files changed, 3096 insertions(+)
drivers/net/ethernet/cortina/Kconfig +13 -0
@@ -20,4 +20,17 @@ config GEMINI_ETHERNET help This driver supports StorLink SL351x (Gemini) dual Gigabit Ethernet. +config CS7542_ETHERNET + tristate "Cortina CS7542 network engine" + depends on OF && OF_RESERVED_MEM && HAS_IOMEM + select PHYLINK + select MFD_SYSCON + help + Support the CS7542 network engine GMACs with a CPU DMA datapath. + A dedicated queue-manager DDR reservation and exclusive ownership + of all seven NI, FE, TM, SCH, QM, DMA and NI-XRAM reset lines are + required. The shared DMA line covers both LSO and SSP. + To compile this driver as a module, choose M; the module is named + cs7542-eth. + endif # NET_VENDOR_CORTINA
drivers/net/ethernet/cortina/Makefile +3 -0
@@ -2,3 +2,6 @@ # Makefile for the Cortina Gemini network device drivers. obj-$(CONFIG_GEMINI_ETHERNET) += gemini.o + +obj-$(CONFIG_CS7542_ETHERNET) += cs7542-eth.o +cs7542-eth-y := cs752x_ne.o cs752x_fe.o cs752x_sch_tm.o
drivers/net/ethernet/cortina/cs752x_fe.c new file +475 -0
475 lines not on this page · raw message
drivers/net/ethernet/cortina/cs752x_ne.c new file +1903 -0
1,903 lines not on this page · raw message
drivers/net/ethernet/cortina/cs752x_ne.h new file +13 -0
@@ -0,0 +1,13 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef __CS752X_NE_H__ +#define __CS752X_NE_H__ + +#include <linux/types.h> + +struct device ; + +int cs752x_fe_init (struct device *dev,void __iomem *fe); +int cs752x_sch_init (struct device *dev,void __iomem *sch); +int cs752x_tm_init (struct device *dev,void __iomem *tm); + +#endif
drivers/net/ethernet/cortina/cs752x_sch_tm.c new file +689 -0
586 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 1 line
2.53.0
Part of the diff is not shown here. View the raw message.
PATCH v9 3/3 MAINTAINERS: Add CS7542 network engine support
In reply to Fil DunskyCover the Ethernet binding and network engine datapath. The shared global reset provider is maintained separately under global control.
--- MAINTAINERS | 7 +++++++ 1 file changed, 7 insertions(+)
MAINTAINERS +7 -0
@@ -7213,6 +7213,13 @@ M: Jaya Kumar <[email protected]> S: Maintained F: sound/pci/cs5535audio/ +CS7542 CORTINA NETWORK ENGINE +M: Fil Dunsky <[email protected]> +L: [email protected] +S: Maintained +F: Documentation/devicetree/bindings/net/cortina,cs7542-ethernet.yaml +F: drivers/net/ethernet/cortina/cs752x_* + CTU CAN FD DRIVER M: Pavel Pisa <[email protected]> M: Ondrej Ille <[email protected]>
Signature · 1 line
2.53.0