🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #26834

Re: [PATCH net-next 1/3] net: ethernet: ti: cpsw_new: bypass ALE in promiscuous mode

#26834
From: netdev-bot+sashiko
Date: Fri, 04 Dec 2026 08:53
251 lines
17495 bytes
Thank you for your contribution! Sashiko AI review found 6 potential
issue(s) to consider.

Critical: 0 · High: 0 · Medium: 4 · Low: 2

If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).

- [Medium] The patch leaves two owners of the global ALE_BYPASS bit and
  only handles one direction of the conflict.
- [Medium] ALE_BYPASS is a global ALE_CONTROL bit
  (ale_controls[ALE_BYPASS] has port_offset=0 and port_shift=0, so the…
- [Medium] Promiscuous-originated ALE_BYPASS can survive a switch-mode
  transition made while all interfaces are down.
- [Medium] After this patch, two paths read and write the ALE_BYPASS bit
  and its shadow cpsw->ale_bypass, and no common lock serializes them.
- [Low] The commit message's root cause is incomplete.
- [Low]…

--

net: ethernet: ti: cpsw_new: bypass ALE in promiscuous mode

This commit changes cpsw_set_promiscious() in the cpsw_new driver so that
a promiscuous dual-MAC port enables ALE_BYPASS instead of
ALE_P0_UNI_FLOOD. With that, frames tagged with VIDs the ALE doesn't know
reach the host. On leaving promiscuous mode the devlink-configured bypass
value is restored, and cpsw_dl_switch_mode_set() re-applies rx mode after
a switch mode change.

> In dual-MAC mode the ALE is VLAN-aware and the Unknown VLAN register is
> left at its reset value, so frames tagged with a VID the ALE doesn't know
> are dropped even if the interface is promiscuous. ALE_P0_UNI_FLOOD only
> helps with unknown unicast in known VLANs.

[Severity: Low]
Is this root cause description complete? In dual-MAC mode
cpsw_port_add_dual_emac_def_ale_entries() also sets the per-port
drop-unknown-VLAN bit explicitly:

drivers/net/ethernet/ti/cpsw_new.c:cpsw_port_add_dual_emac_def_ale_entries() {
    ...
	cpsw_ale_control_set(cpsw->ale, priv->emac_port,
			     ALE_PORT_DROP_UNKNOWN_VLAN, 1);
    ...
}

So programming the Unknown VLAN register alone would not be enough in
dual-MAC mode. In switch mode, cpsw_port_add_switch_def_ale_entries()
clears this bit.

Could the commit message mention this as well?

> diff --git a/drivers/net/ethernet/ti/cpsw_new.c b/drivers/net/ethernet/ti/cpsw_new.c
> index 9ea7b6ffc992b..5f0fe96814f0c 100644
> --- a/drivers/net/ethernet/ti/cpsw_new.c
> +++ b/drivers/net/ethernet/ti/cpsw_new.c
> @@ -100,15 +100,13 @@ static void cpsw_set_promiscious(struct net_device *ndev, bool enable)
>  	}
>  
>  	if (enable) {
> -		/* Enable unknown unicast, reg/unreg mcast */
> -		cpsw_ale_control_set(cpsw->ale, HOST_PORT_NUM,
> -				     ALE_P0_UNI_FLOOD, 1);
> +		/* Bypass also delivers frames of VLANs unknown to the ALE */
> +		cpsw_ale_control_set(cpsw->ale, HOST_PORT_NUM, ALE_BYPASS, 1);

[Severity: Medium]
ALE_BYPASS is a global ALE_CONTROL bit, and the port argument is ignored:

drivers/net/ethernet/ti/cpsw_ale.c:
	[ALE_BYPASS]		= {
		.name		= "bypass",
		.offset		= ALE_CONTROL,
		.port_offset	= 0,
		.shift		= 4,
		.port_shift	= 0,
		.bits		= 1,
	},

If one dual-MAC port becomes promiscuous, does this also switch off
hardware filtering for the other, non-promiscuous port? Unicast
destination, multicast and VLAN membership filtering would all be
bypassed.

For example, with the DSA conduit on port 1 in promiscuous mode, the port
2 netdev would receive every frame on its wire and have to drop them in
software. Before this patch, the only setting shared between the ports
was P0_UNI_FLOOD.

The commit message says port separation is preserved. That holds for
forwarding. Should it also say that the sibling port loses its hardware
filtering?

[Severity: Low]
The documentation now contradicts this. The Dual mac mode section of
Documentation/networking/device_drivers/ethernet/ti/cpsw_switchdev.rst
still says:

 - optimized promiscuous mode: The P0_UNI_FLOOD (both ports) is enabled in
   addition to ALLMULTI (current port) instead of ALE_BYPASS.
   So, Ports in promiscuous mode will keep possibility of mcast and vlan
   filtering, ...

Should that text be updated together with this change?

>  
>  		dev_dbg(cpsw->dev, "promiscuity enabled\n");
>  	} else {
> -		/* Disable unknown unicast */
> -		cpsw_ale_control_set(cpsw->ale, HOST_PORT_NUM,
> -				     ALE_P0_UNI_FLOOD, 0);
> +		cpsw_ale_control_set(cpsw->ale, HOST_PORT_NUM, ALE_BYPASS,
> +				     cpsw->ale_bypass);

[Severity: Medium]
This restores the devlink value when leaving promiscuous mode. What about
the other direction? cpsw_dl_ale_ctrl_set() still writes the register
directly:

drivers/net/ethernet/ti/cpsw_new.c:cpsw_dl_ale_ctrl_set() {
    ...
	case CPSW_DL_PARAM_ALE_BYPASS:
		ret = cpsw_ale_control_set(cpsw->ale, 0, ALE_BYPASS,
					   ctx->val.vbool);
		if (!ret) {
			cpsw->ale_bypass = ctx->val.vbool;
			cpsw_port_offload_fwd_mark_update(cpsw);
		}
    ...
}

Suppose ale_bypass is set to false through devlink while a dual-MAC port,
such as the DSA conduit, is promiscuous. Wouldn't that clear ALE_BYPASS
while IFF_PROMISC stays set? Frames with unknown VIDs would then be
dropped again until a later rx_mode event re-runs
cpsw_set_promiscious().

cpsw_dl_ale_ctrl_get() also reports the hardware bit, not
cpsw->ale_bypass:

	ctx->val.vbool = cpsw_ale_control_get(cpsw->ale, 0, ALE_BYPASS);

Would devlink param show now report ale_bypass as true whenever a
dual-MAC port is promiscuous, even though it was never enabled through
devlink? Documentation/networking/devlink/ti-cpsw-switch.rst describes
this parameter as a bypass mode that the user enables for debugging.

The patch already re-applies rx mode after the switch_mode writer of
ALE_BYPASS. Could cpsw_dl_ale_ctrl_set() do the same, or write the
effective value (cpsw->ale_bypass or any promiscuous dual-MAC slave)?
The getter could then return cpsw->ale_bypass.

The later patches in this series don't appear to touch cpsw_new.c, so
this would remain in the final state.

[Severity: Medium]
Is anything serializing this read of cpsw->ale_bypass with
cpsw_dl_ale_ctrl_set()?

cpsw_ndo_set_rx_mode_work() holds rtnl_lock and netif_addr_lock_bh.
devlink_param_set() calls param->set() under the devlink instance lock
only, and cpsw_dl_ale_ctrl_set() doesn't take rtnl, unlike
cpsw_dl_switch_mode_set().

One possible interleaving:

rx_mode work (leaving promisc)          devlink set ale_bypass=false
cpsw_set_promiscious(ndev, false)
  reads cpsw->ale_bypass == true
                                        cpsw_dl_ale_ctrl_set()
                                          ALE_BYPASS = 0
                                          cpsw->ale_bypass = false
  cpsw_ale_control_set(..., ALE_BYPASS, 1)

Wouldn't the hardware then stay in bypass while cpsw->ale_bypass is
false? The getter would also report true right after the parameter was
set to false.

The unlocked read-modify-write of ALE_CONTROL already existed through
ALE_P0_UNI_FLOOD. What's new is that both paths now share the same bit
and the same shadow variable. Taking rtnl_lock in cpsw_dl_ale_ctrl_set()
and re-applying rx mode there might address both this and the issue
above.

[ ... ]

> @@ -1769,6 +1767,14 @@ static int cpsw_dl_switch_mode_set(struct devlink *dl, u32 id,
>  		cpsw_ale_control_set(cpsw->ale, 0, ALE_BYPASS, 0);
>  		cpsw->data.dual_emac = true;
>  	}
> +
> +	/* ALE_BYPASS has been reset above, re-apply promiscuity */
> +	for (i = 0; i < cpsw->data.slaves; i++) {
> +		struct net_device *sl_ndev = cpsw->slaves[i].ndev;
> +
> +		if (sl_ndev && netif_running(sl_ndev))
> +			cpsw_ndo_set_rx_mode(sl_ndev);
> +	}
>  exit:
>  	rtnl_unlock();

[Severity: Medium]
What happens if the switch mode is changed while all interfaces are
down? The !if_running path jumps straight to exit:

	if (!if_running) {
		/* all ndevs are down */
		cpsw->data.dual_emac = !switch_en;
		...
		goto exit;
	}

That skips both the ALE_BYPASS reset and this new loop.

The sequence would be:

1. A dual-MAC port is promiscuous, so ALE_BYPASS is 1.

2. All ports are brought down. cpsw_ndo_stop()->cpsw_ale_stop() only
   sets ALE_CLEAR and clears ALE_ENABLE.

3. devlink switch_mode is set to true, which takes the !if_running path.

4. A port is opened. cpsw_ale_start() and cpsw_init_host_port_switch()
   don't write ALE_BYPASS. cpsw_set_promiscious() returns early because
   cpsw_is_switch_en() is true.

If ALE_CONTROL survives the soft reset or runtime PM idle, could the
switch end up running with ALE bypass on while cpsw->ale_bypass is
false?

Once both ports are bridged, cpsw_port_offload_fwd_mark_update() decides
from the software flag:

	if (!cpsw->ale_bypass &&
	    (cpsw->br_members == (ALE_PORT_1 | ALE_PORT_2)))
		set_val = 1;

With offload_fwd_mark set, the software bridge would not forward, and the
hardware would not forward either. Before this patch the leftover state
was only P0_UNI_FLOOD, and cpsw_init_host_port_switch() sets that anyway.

I haven't confirmed whether the hardware resets ALE_CONTROL here.

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261203080514.577407-1-alexander.sverdlin%40siemens.com
Technical Details
Message-ID: <179637441476.3146.34017527871295106@kernel.org>
Path: mbox-mo1.pugleaf.net!feed-eu-txt.newsdeef.eu!feed-eu-ch.newsdeef.eu!srl.newsdeef.eu!news.mb-net.net!open-news-network.org!2.eu.feeder.erje.net!feeder.erje.net!feeder1.feed.ams11.usenet.farm!feed.usenet.farm!peer03.ams4!peer.am4.highwinds-media.com!news.highwinds-media.com!feeder.usenetexpress.com!tr3.eu1.usenetexpress.com!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-377188-linux-kernel-netdev=dewy.ru
References: <20261203080514.577407-2-alexander.sverdlin@siemens.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!feed-eu-txt.newsdeef.eu!feed-eu-ch.newsdeef.eu!srl.newsdeef.eu!news.mb-net.net!open-news-network.org!2.eu.feeder.erje.net!feeder.erje.net!feeder1.feed.ams11.usenet.farm!feed.usenet.farm!peer03.ams4!peer.am4.highwinds-media.com!news.highwinds-media.com!feeder.usenetexpress.com!tr3.eu1.usenetexpress.com!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-377188-linux-kernel-netdev=dewy.ru
From: netdev-bot+sashiko@kernel.org
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net-next 1/3] net: ethernet: ti: cpsw_new: bypass ALE in promiscuous mode
Date: Fri, 04 Dec 2026 08:53:34 +0000
Organization: Usenet Network
Message-ID: <179637441476.3146.34017527871295106@kernel.org>
References: <20261203080514.577407-2-alexander.sverdlin@siemens.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network; logging-data="2720892"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:lW4/G6sMrV8O7L8I2gE+dXgnGYQ= sha256:oA91VFru/Yn0bnKMymfdoVSlBdgYO8oCr62X5Z5wRkI= sha1:6d+LrBoGLNOF584u0O1wjg8hhrI= sha256:OSL4rHhGcW7m4StSM1qMj46V8ve07BfwNj5ym4gRtS8=
List-ID: <netdev.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1]) by mail.dewy.ru (Postfix) with ESMTP id 5A7D4117B6C; Fri,  4 Dec 2026 11:53:54 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.739
X-Spam-Status: No, score=-3.739 tagged_above=-9999 required=6.31 tests=[DKIMWL_WL_HIGH=-0.24, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key) header.d=kernel.org
X-Received: from mail.dewy.ru ([127.0.0.1]) by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 7h66V-nwjp_s; Fri,  4 Dec 2026 11:53:50 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.232.135.74; helo=sto.lore.kernel.org; envelope-from=netdev+bounces-377188-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN>
X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org
X-Received: from sto.lore.kernel.org (sto.lore.kernel.org [172.232.135.74]) by mail.dewy.ru (Postfix) with ESMTPS id CDDD9117B6A; Fri,  4 Dec 2026 11:53:39 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by sto.lore.kernel.org (Postfix) with ESMTP id DB327602B4A; Fri,  4 Dec 2026 08:53:38 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1796374417; b=F6NyokEZPHXnY0KnKjE+gy8BzG97fFxsdiinmYQEV3x11YOGIZkabR1uATluhKVN5b0B 16EXWDODVEiLXhU7pC/6t5myphu/jwy9XC/ZWwENLTp2uOeUe6hRwTrCxYKQ6kC065pbc hpNaf9c/Gs/iZveVCfy8jDmYWZbZkLcCU/52wftLlmWnZAHfTnLZXPinpnw0iYaeRVpWd nbGwllJpLljOH//CMEdhkraDwvv5BdiLzvZMXfJQnoMX1PLcNKhU7KeQ5TiJ6KFfNCCdi YN6truUwURU+7plwyniU34wvnvZh61QANoocqzS2p6ZLKpYZQ8bK3mzmEtSVeZB5yeQ==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796374417; h=X-Original-To:Received:Received:DKIM-Signature:Subject:From:To:Cc: Date:Message-ID:In-Reply-To:References:X-sashiko-severity: Content-Type:Content-Transfer-Encoding:X-Mailing-List:List-Id: List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner: Precedence:MIME-Version; bh=cIWu3a/joKxGoD49JFCxIDTtaTTOI9olxW0glxfhKAQ=; b=RPfodyq/C1wH8opBwTBx1MrOA9PFKoIFFz64FagGqMB+6We3pCfmTHqCW9KgyPMl5yEV uiX7RLtGbIdjbkCqxxMGMUBihGLDlYYBwCwrW3DudkwqRL5K4CrAnCS8VITpKBUIKu0JZ LBJYqK5FYoINEebfqSJW1Hkrw0ms3Yu6E0VjyTJLXveVi+5dFz/ZxBRpmqUg6PpnXdRMu j1z6BHlb875PSzQj+WGOvtSTjTLszEpxqSli2OP7QmqEhKjh+La8i9EBp/o3Qq25flADh Wqy3/l0WFE7AQySAA2hu78U5k6Rjasy6Su4LUlvzlHddZSdTyPMMbYVc7W1KL5JrJCw==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=mH6idouo; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 84B6D606A33B; Fri,  4 Dec 2026 08:53:37 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=mH6idouo
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796374416; b=AXbV90CfK4UOrKWDpTIis2oRMkmf3+Nak9NL3nHbSe+S8xxjwXocV3BaB2timp6VPMYN wtoNB3qRJmLVolS2XvKvCJ1npxStW951z5NXObuASzdxm+3UndWuOONErhhnnzY8IX+l8 EVPzLYrTY0vc1OfP0xV70p6sGt3kYUEJKQ8CSfFfUFEPUXyyajshiA018aINwT97r6odA XDZcyuaW/vNTUOkt1JSwZz4EHP0BAxOXaIjkxgAN8wpVKP9IqG3v/cMrbGoTanwHIZbso ZOxvy6oEqbFWkh8V2M85bzcizk18kanY55krYbpkFbo7Ni9zxgBw7d4OtylUXaNQ2Vg==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796374416; h=Received:DKIM-Signature:Subject:From:To:Cc:Date:Message-ID: In-Reply-To:References:X-sashiko-severity:Content-Type: Content-Transfer-Encoding:MIME-Version; bh=cIWu3a/joKxGoD49JFCxIDTtaTTOI9olxW0glxfhKAQ=; b=mTMNVSaD03JKPx/vJtCDI5jEossJ9TA4C3KztQ7VRIVhH1I0G/zmK4YGHnSyC6zJlFRZ OcdzNNiH1f46f1fUDLSQ/PhGgSGFRPmlIcIMC/YZ5VMNw4E/z3XbeFSO2g14ydf0MI36x hRiwR5yNxWJtfTGFREiVcOUgajyXttzT/8w8AfHod2Zow4MOGWZ8bv5UEMMxylf5z1dqV j4sNo7gz61zs5XQfm20nSwOFvNd0cN/XrLvfCShslxFxmugG6ByJ/vlQGkVGuWvVYckrl wFmwAzII/81FJBy5D2O+kQrVeBD3lZgrnqmhasHCQd8DkUUkymTdUsjD0hKctpQftOw==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=mH6idouo; arc=none smtp.remote-ip=100.103.45.18
X-Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A167A606A332; Fri,  4 Dec 2026 08:53:36 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 363261F0092C; Fri,  4 Dec 2026 08:53:35 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796374416; bh=cIWu3a/joKxGoD49JFCxIDTtaTTOI9olxW0glxfhKAQ=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=mH6idouoQnk2BU4xv2X/G6ecYltvBd9lCRHf1wSs5UN6PHhf57+ReiaUO0c6qAfdC Bfue+B1oNVmTpp2L8eG7mojjLm7ca7ugy/3HOj+CZg/s2TfphgL4PAs7/UQjGeDM0X DLbs7N6nfg7Ix86eRZX1STOG441Xz21OM7syrfKEJQWc7ZAnYI0ExpAhRkGGKqwYWy oo3+8j5hB6A1Tog9ebKmv8Yh8CaxkAOrDtoyVmiJYYLKtUBN6Va9NtCtCYvPpdIxlO 3FBZ6F2Ta5JYV/vVlVs9hVMxjQXPVb/WyX6tJP+yOsMmqifNL1KpMZkmXmWTbFOGMy JI/3VIlN+Yd5g==
X-Cc: netdev@vger.kernel.org, s-vadapalli@ti.com, rogerq@kernel.org, andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com, kmehltretter@gmail.com, haokexin@gmail.com, lgs201920130244@gmail.com, aleksandr.loktionov@intel.com, ilias.apalodimas@linaro.org, m-karicheri2@ti.com, grygorii.strashko@ti.com, mugunthanvnm@ti.com, linux-omap@vger.kernel.org, lukas.stockmann@siemens.com
X-In-Reply-To: <20261203080514.577407-2-alexander.sverdlin@siemens.com>
X-sashiko-severity: Medium
X-Mailing-List: netdev@vger.kernel.org
X-List-Post: <mailto:netdev@vger.kernel.org>
X-List-Help: <mailto:netdev+help@vger.kernel.org>
X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>
X-List-Owner: <mailto:netdev+owner@vger.kernel.org>
X-Precedence: list
X-Received-Bytes: 17182