Skip to contentSkip to conversation

Add Cortina Systems CS7542 network engine support

PATCH Superseded Fil Dunsky 1 participant 4 messages Nov 30

Subsystems (4)

v5 of 9 Superseded Latest is v9 →

lore
Share & tools
lore

Fil Dunsky

author
#0 lore raw

v5 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 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           |  477 +++++
 drivers/net/ethernet/cortina/cs752x_ne.c           | 1964 ++++++++++++++++++++
 drivers/net/ethernet/cortina/cs752x_ne.h           |   13 +
 drivers/net/ethernet/cortina/cs752x_sch_tm.c       |  688 +++++++
 8 files changed, 3327 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]>
author
#1 lore raw

PATCH v5 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
new file mode 100644
index 000000000..c5ba9b30e
@@ -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
author
#2 lore raw

PATCH v5 2/3 net: cortina: Add CS7542 CPU network datapath

In reply to Fil Dunsky

Add 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.

---
 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     | 1964 ++++++++++++++++++++++++++
 drivers/net/ethernet/cortina/cs752x_ne.h     |   13 +
 drivers/net/ethernet/cortina/cs752x_sch_tm.c |  688 +++++++++
 6 files changed, 3158 insertions(+)
drivers/net/ethernet/cortina/Kconfig +13 -0
index aaf9e294b..6a93e28bd 100644
@@ -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
index 4e86d398a..e998ffcc8 100644
@@ -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 +1964 -0

1,964 lines not on this page · raw message

drivers/net/ethernet/cortina/cs752x_ne.h new file +13 -0
new file mode 100644
index 000000000..1f7c08166
@@ -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

523 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.

author
#3 lore raw

PATCH v5 3/3 MAINTAINERS: Add CS7542 network engine support

In reply to Fil Dunsky

Cover 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
index 703e95e83..53d482457 100644
@@ -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