Skip to contentSkip to conversation

Add Cortina Systems CS7542 network engine support

PATCH Superseded Fil Dunsky 1 participant 4 messages Nov 27

Subsystems (4)

v4 of 9 Superseded Latest is v9 →

lore
Share & tools
lore

Fil Dunsky

author
#0 lore raw

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

Changes in this revision:
- Bound immediate polling of a DMA-owned RX head to four NAPI polls. Thereafter complete NAPI with the interrupt masked and defer the next attempt to delayed work. Never recycle the hardware-owned descriptor; cancel retry work when closing or removing the port.
- Disable bottom halves when scheduling NAPI from ndo_open and the retry worker. Restore the RX lock and IRQ state before enabling bottom halves.

Validation of these changes:
- Actual-source ownership/backoff cases cover transient and persistently owned heads, recovery without a new IRQ edge, stop and retry cancellation.
- Nine actual callback cases per GCC and Clang ASan/UBSan exercise process and softirq scheduling contexts. The pre-fix source reproduces two context defects. Native ARM, basic Ethernet ARM and integrated OpenWrt 6.18 ARM compilation pass with W=1 and KCFLAGS=-Werror.
- These new retry/context fault cases are host checks; they were not injected on the board. The final folded source matches the already reviewed and compiled source byte for byte.

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. The old hardware matrix was not repeated for this reroll.

---
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           | 1965 ++++++++++++++++++++
 drivers/net/ethernet/cortina/cs752x_ne.h           |   13 +
 drivers/net/ethernet/cortina/cs752x_sch_tm.c       |  688 +++++++
 8 files changed, 3328 insertions(+)

---
base-commit: b6a9fa34ce4187cb69d3c588a4bbffc31ce5db8f
change-id: 20261123-b4-cs7542-ethernet-59c15dbc7e7e
prerequisite-message-id: <[email protected]>
prerequisite-patch-id: a9208276c628f8741a807d0e5c5945d4bf211c8a
prerequisite-patch-id: 65d46bb3caaa8518ee561f65d3f603ade396fff9
prerequisite-patch-id: a0ed5fbcfa308b16eaf265371a6697ad0aea6802
prerequisite-patch-id: bb8ffd99cb30e5a0b47881f6ba19a36329d5f4f2
prerequisite-patch-id: 7fbe9405265ef3d1ec62811415a46c0061afd7c8
prerequisite-patch-id: 01ece2c91e080d5cae6af81944159373776484ca

Best regards,

Signature · 1 line
Fil Dunsky <[email protected]>
author
#1 lore raw

PATCH v4 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 v4 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.

---
 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     | 1965 ++++++++++++++++++++++++++
 drivers/net/ethernet/cortina/cs752x_ne.h     |   13 +
 drivers/net/ethernet/cortina/cs752x_sch_tm.c |  688 +++++++++
 6 files changed, 3159 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 +1965 -0

1,965 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

522 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 v4 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