[PATCH net-next v2 2/3] net: cortina: Add CS7542 CPU network datapath

Philipp Zabel p.zabel at pengutronix.de
Wed Nov 25 03:12:30 PST 2026


On Mi, 2026-11-25 at 13:36 +0300, Fil Dunsky via B4 Relay wrote:
> From: Fil Dunsky <filipp.dunsky at gmail.com>
> 
> 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; never release descriptors whose hardware ownership remains set.
> 
> Signed-off-by: Fil Dunsky <filipp.dunsky at gmail.com>
> ---
>  drivers/net/ethernet/cortina/Kconfig         |   14 +
>  drivers/net/ethernet/cortina/Makefile        |    3 +
>  drivers/net/ethernet/cortina/cs752x_fe.c     |  477 +++++++
>  drivers/net/ethernet/cortina/cs752x_ne.c     | 1869 ++++++++++++++++++++++++++
>  drivers/net/ethernet/cortina/cs752x_ne.h     |   13 +
>  drivers/net/ethernet/cortina/cs752x_sch_tm.c |  687 ++++++++++
>  6 files changed, 3063 insertions(+)
> 
> diff --git a/drivers/net/ethernet/cortina/Kconfig b/drivers/net/ethernet/cortina/Kconfig
> index aaf9e294b..52c0683be 100644
> --- a/drivers/net/ethernet/cortina/Kconfig
> +++ b/drivers/net/ethernet/cortina/Kconfig
> @@ -20,4 +20,18 @@ 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
> +	select RESET_CONTROLLER

Drop, this driver does not register a reset controller.

[...]
> diff --git a/drivers/net/ethernet/cortina/cs752x_ne.c b/drivers/net/ethernet/cortina/cs752x_ne.c
> new file mode 100644
> index 000000000..081b42079
> --- /dev/null
> +++ b/drivers/net/ethernet/cortina/cs752x_ne.c
> @@ -0,0 +1,1869 @@
[...]
> +#define CS_NE_NUM_RESETS 7
> +static const char * const cs_ne_reset_names[CS_NE_NUM_RESETS] = {
> +	"ni", "fe", "tm", "sch", "qm", "dma", "xram",
> +};
> +
> +struct cs_ne {
> +	struct device *dev;
> +	/* Shared NI registers contain fields belonging to several MACs. */
> +	spinlock_t ni_lock;
> +	struct regmap *global;
> +	struct reset_control_bulk_data resets[CS_NE_NUM_RESETS];
[...]
> +/*
> + * Try every protective assert and check every line, retaining the first error.
> + * Bulk assert must not be used here: its rollback deasserts earlier lines.

Why is this an issue?

> + */
> +static int cs_ne_assert_resets(struct cs_ne *ne)
> +{
> +	int first = 0, ret, i;
> +
> +	for (i = 0; i < CS_NE_NUM_RESETS; i++) {
> +		ret = reset_control_assert(ne->resets[i].rstc);
> +		if (ret && !first)
> +			first = ret;
> +	}
> +	for (i = 0; i < CS_NE_NUM_RESETS; i++) {
> +		ret = reset_control_status(ne->resets[i].rstc);

Why is this needed?

The reset controller driver already polls the global reset register for
the "asserted" state in cs7542_reset_update(). If this returns 0, the
corresponding assert above should already have returned -ETIMEDOUT.

> +		if (ret != 1 && !first)
> +			first = ret < 0 ? ret : -EIO;
> +	}
> +	return first;
> +}
> +
> +static int cs_ne_deassert_resets(struct cs_ne *ne)
> +{
> +	int ret, i;
> +
> +	/* Reverse the consumer's assert order, as the bulk API would. */
> +	for (i = CS_NE_NUM_RESETS - 1; i >= 0; i--) {
> +		ret = reset_control_deassert(ne->resets[i].rstc);
> +		if (ret)
> +			return ret;
> +	}
> +	for (i = 0; i < CS_NE_NUM_RESETS; i++) {
> +		ret = reset_control_status(ne->resets[i].rstc);

Same as above. The reset controller driver should guarantee that the
deasserted resets are actually deasserted at this point.

[...]
> +static int cs_ne_probe(struct platform_device *pdev)
> +{
[...]
> +	for (i = 0; i < CS_NE_NUM_RESETS; i++)
> +		ne->resets[i].id = cs_ne_reset_names[i];
> +	ret = devm_reset_control_bulk_get_exclusive(dev, CS_NE_NUM_RESETS, ne->resets);
> +	if (ret)
> +		return dev_err_probe(dev, ret, "exclusive engine resets\n");
[...]
> +
> +	ret = cs_ne_assert_resets(ne);
> +	if (ret)
> +		return dev_err_probe(dev, ret, "assert engine reset\n");
> +	/* Reset pulse width, not an inferred DMA idle condition. */

What does this mean?

> +	usleep_range(100, 200);
> +	ret = cs_ne_deassert_resets(ne);
> +	if (ret)
> +		return dev_err_probe(dev, ret, "release engine reset\n");

regards
Philipp



More information about the linux-arm-kernel mailing list