Add Cortina Systems CS7542 network engine support
Subsystems (4)
v6 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, posted separately against Linux v7.4-rc4. The consumer acquires the NI, FE, TM, SCH, QM, DMA and NI-XRAM reset controls exclusively. 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. Load the low four MAC bytes as an unaligned little-endian word so the upper byte does not enter a signed shift.
The driver compiles for ARM with warnings as errors. The new changes were checked on the host.
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 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]/
To: Fil Dunsky <[email protected]>
To: Andrew Lunn <[email protected]>
To: "David S. Miller" <[email protected]>
To: Eric Dumazet <[email protected]>
To: Jakub Kicinski <[email protected]>
To: Paolo Abeni <[email protected]>
To: Rob Herring <[email protected]>
To: Krzysztof Kozlowski <[email protected]>
To: Conor Dooley <[email protected]>
To: Hans Ulli Kroll <[email protected]>
To: Linus Walleij <[email protected]>
To: Philipp Zabel <[email protected]>
To: Russell King <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [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 | 477 +++++ drivers/net/ethernet/cortina/cs752x_ne.c | 1967 ++++++++++++++++++++ drivers/net/ethernet/cortina/cs752x_ne.h | 13 + drivers/net/ethernet/cortina/cs752x_sch_tm.c | 688 +++++++ 8 files changed, 3330 insertions(+)
---
base-commit: b6a9fa34ce4187cb69d3c588a4bbffc31ce5db8f
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 v6 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 v6 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. Propagate a later -EPROBE_DEFER instead of silently generating a random address.
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. Preflight all MAC addresses against the shared five-byte prefix and reject changes that would silently alter a sibling port.
Keep packet and byte totals in the network core per-CPU statistics. Use an unaligned little-endian load for the first four MAC bytes.
Keep zero-budget NAPI polling limited to TX completions.
--- drivers/net/ethernet/cortina/Kconfig | 13 + drivers/net/ethernet/cortina/Makefile | 3 + drivers/net/ethernet/cortina/cs752x_fe.c | 477 +++++++ drivers/net/ethernet/cortina/cs752x_ne.c | 1967 ++++++++++++++++++++++++++ drivers/net/ethernet/cortina/cs752x_ne.h | 13 + drivers/net/ethernet/cortina/cs752x_sch_tm.c | 688 +++++++++ 6 files changed, 3161 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 +477 -0
477 lines not on this page · raw message
drivers/net/ethernet/cortina/cs752x_ne.c new file +1967 -0
1,967 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 +688 -0
520 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 v6 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
@@ -2961,6 +2961,13 @@ F: drivers/reset/reset-cs7542.c F: include/dt-bindings/clock/cortina,cs7542-clock.h F: include/dt-bindings/reset/cortina,cs7542-reset.h +ARM/CORTINA SYSTEMS CS7542 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_* + ARM/CORTINA SYSTEMS GEMINI ARM ARCHITECTURE M: Hans Ulli Kroll <[email protected]> M: Linus Walleij <[email protected]>
Signature · 1 line
2.53.0
Re: [PATCH net-next v6 2/3] net: cortina: Add CS7542 CPU network datapath
In reply to Fil Dunskydrivers/net/ethernet/cortina/cs752x_fe.c line 307
Quoted 10 lines
drivers/net/ethernet/cortina/cs752x_fe.c new file +10
-0+ ret =read_poll_timeout (readl, val, + !(val &FE_HASH_STATUS_INIT_IN_PROGRESS ), +FE_HASH_INIT_POLL_US ,FE_HASH_INIT_TIMEOUT_US , + true, fe +FETOP_HASH_STATUS ); +if (ret) { +dev_err (dev,"FE hash init timeout: 0x%08x\n" , val); +return ret; + } + +return 0 ;
This can be simplified to:
drivers/net/ethernet/cortina/cs752x_fe.c line 370
Quoted 13 lines
drivers/net/ethernet/cortina/cs752x_fe.c new file +12
-0+if (ret) +dev_err (dev,"FE hash init timeout: 0x%08x\n" , val); + +return ret; + } +static int fe_class_write (struct device *dev,void __iomem *fe, +unsigned int idx,unsigned int sdb_idx, +unsigned int lspid,unsigned int lspid_mask, +unsigned int rule_priority) +{ +u32 data[20 ]; +unsigned int i;
Reverse Christmas tree.
drivers/net/ethernet/cortina/cs752x_ne.c line 575
Quoted 4 lines
drivers/net/ethernet/cortina/cs752x_ne.c new file +4
-0+static int cs_ne_ni_init (struct cs_ne *ne) +{ +u32 val; +int ret, i;
Ditto
drivers/net/ethernet/cortina/cs752x_ne.c
Quoted 10 lines
drivers/net/ethernet/cortina/cs752x_ne.c new file +7
-0+/* Probe errors run before any RX address is published to hardware. */ +static void cs_ne_rx_cleanup (void *data) +{ +struct cs_ne *ne = data; +struct cs_ne_rx_buf *buf; +unsigned long index; +static void cs_ne_tx_reap (struct cs_ne *ne);
No forward declarations. Put the functions in the correct order.
Quoted 7 lines
drivers/net/ethernet/cortina/cs752x_ne.c new file +7
-0+ +static int cs_ne_rx_poll (struct napi_struct *napi,int budget) +{ + struct cs_ne_port *port = container_of(napi, struct cs_ne_port, napi); +struct cs_ne *ne = port->ne; +struct net_device *ndev = port->ndev; +struct cs_ne_rx_buf *bufs[CS_NE_RX_MAX_BUFS ];
drivers/net/ethernet/cortina/cs752x_ne.c line 853
Quoted 10 lines
drivers/net/ethernet/cortina/cs752x_ne.c new file +10
-0+dma_addr_t dma[CS_NE_RX_MAX_BUFS ]; +void __iomem *desc; +struct sk_buff *skb; +void *data; +u32 wr, rd, next, w1, hdre_hi, hdre_lo, pkt_size; +u32 off, total, dma_bytes, seg, nbufs, remaining; +unsigned int i; +int done =0 ; +bool valid, retry = false, defer = false; +unsigned long flags;
More Reverse Christmas.
Also, given the number of local variables here, maybe this function needs breaking up into helpers.
https://www.kernel.org/doc/html/latest/process/coding-style.html#functions
drivers/net/ethernet/cortina/cs752x_ne.c
Quoted 13 lines
drivers/net/ethernet/cortina/cs752x_ne.c new file +12
-0+static netdev_tx_t cs_ne_xmit_sg (struct sk_buff *skb,struct net_device *ndev) +{ +struct cs_ne_port *port =netdev_priv (ndev); +struct cs_ne *ne = port->ne; +struct cs_ne_txq *txq = &ne->txq; +int nfrags =skb_shinfo (skb)->nr_frags; +u16 first = txq->head; +struct cs_ne_tx_buf *buf; +dma_addr_t dma; +u32 free, len; +int i; +static int cs_ne_stop (struct net_device *ndev)
Probably should be a void function. If anything goes wrong, there is not much you can do about it.
drivers/net/ethernet/cortina/cs752x_ne.c line 1481
Quoted 11 lines
drivers/net/ethernet/cortina/cs752x_ne.c new file +11
-0+static int cs_ne_set_mac_address (struct net_device *ndev,void *addr) +{ +struct cs_ne_port *port =netdev_priv (ndev); +struct cs_ne *ne = port->ne; +struct sockaddr *sa = addr; +int ret, i; + + ret =eth_prepare_mac_addr_change (ndev, addr); +if (ret) +return ret; +/* NI_MAC_ADDR0/1 are shared; only the last byte is per-port. */
Can you explain that a bit more.
"ip link set address" lets you set the address on an interface, and each interface should be independent of other interfaces.
drivers/net/ethernet/cortina/cs752x_ne.c line 1575
Quoted 5 lines
drivers/net/ethernet/cortina/cs752x_ne.c new file +5
-0+if (!ret) { +if (fixed &&memcmp (base, ne->addresses[id],ETH_ALEN -1 )) { +of_node_put (np); +return dev_err_probe (ne->dev, -EINVAL , +"MACs must share their first five bytes\n" );
Why? Is the hardware broken?
drivers/net/ethernet/cortina/cs752x_ne.c line 1807
Quoted 6 lines
drivers/net/ethernet/cortina/cs752x_ne.c new file +6
-0+static int cs_ne_probe (struct platform_device *pdev) +{ +struct device *dev = &pdev->dev; +struct device_node *np; +struct cs_ne *ne; +int ret, i, nports =0 ;
Andrew
Re: [PATCH net-next v6 2/3] net: cortina: Add CS7542 CPU network datapath
Hi Andrew,
Thanks for the review. The Cortina NI has one MAC_ADDR0 register for octets 0–3 and one MAC_ADDR1 field for octet 4. Each GE port has its own CONFIG2.mac_addr6 field at 0x18 + 12 * port. The vendor driver describes the resulting address as the source for generated pause frames and the address for WoL detection. It programs a separate, full-width FE AN_BNG_MAC table for ingress destination addresses.
The v6 CPU path classifies ingress by logical source port. Our five-octet restriction came from programming the shared NI prefix for hardware pause. I have a candidate that allows independent addresses using eth_mac_addr() and leaves hardware pause disabled. I'll test arbitrary addresses on both ports, including RX and TX after changing just one port, before rerolling.
I've split packet handling out of the NAPI loop and addressed the declaration order and FE return. I'll keep the ndo_stop callback's required int signature. It returns zero after teardown.
Thanks,
Fil
Re: [PATCH net-next v6 2/3] net: cortina: Add CS7542 CPU network datapath
Quoted 6 lines · Fil Dunsky
Hi Andrew,
Thanks for the review. The Cortina NI has one
MAC_ADDR0register for octets 0–3 and oneMAC_ADDR1field for octet 4. Each GE port has its own CONFIG2.mac_addr6 field at0x18+ 12 * port. The vendor driver describes the resulting address as the source for generated pause frames
Pause frames don't really matter what address they use, they never get passed the MAC into the network stack. They also use a link local distination, the source address is ignored by the receiver. So pause will probably work with any random source address.
Quoted 2 lines
and
the address for WoL detection.
WoL is going to be messy. Basically, if the user has changed the MAC address, you cannot report the MAC supporting magic packet. Or you need to somehow give the user a way to know what address it is listening for. Maybe just rely on the PHY doing WoL?
Andrew