Article View: linux.kernel.netdev
Article #22948[PATCH net-next 3/5] net: dsa: microchip: ksz9477: do not learn addresses on the CPU port
From: Oleksij Rempel
Date: Thu, 26 Nov 2026 08:07
Date: Thu, 26 Nov 2026 08:07
98 lines
14599 bytes
14599 bytes
Do not learn addresses on the CPU port of the KSZ9477 family (including
KSZ8563 and KSZ8567) and LAN937x. The bridge also learns addresses on
ports outside the switch, for example on Wi-Fi. DSA adds these as
static entries on the CPU port, so the switch does not need to learn
them there. DSA already adds the bridge's own addresses there.
This prepares for reporting the trapped link-local groups to the
tagger. The switch sends trapped frames only to the CPU. Once the
groups are reported, the bridge can forward such frames, for example
BPDUs, in software. It sends them back to the switch through the CPU
port, with the sender's source address, and a learning CPU port then
records the sender there. Frames from the other switch ports to the
sender go to the CPU, and the bridge does not send them back out. This
repeats with every such frame the bridge forwards. I saw this on a
KSZ9893 with the report patch applied.
Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
---
HSR: the HSR ports are in no bridge, so DSA adds no host entry for the
HSR MAC address. From the code, unicast to the node is now also flooded
to the other ring port, where the CPU port used to learn the address.
---
drivers/net/dsa/microchip/ksz9477.c | 15 ++++++++-------
drivers/net/dsa/microchip/lan937x_main.c | 15 ++++++++-------
2 files changed, 16 insertions(+), 14 deletions(-)
diff --git a/drivers/net/dsa/microchip/ksz9477.c b/drivers/net/dsa/microchip/ksz9477.c
index 98211d9835734c52f25dcbf7494df45166bcc8da..8271bc742ddc5c92b925b01bedfcf876cfa14078 100644
--- a/drivers/net/dsa/microchip/ksz9477.c
+++ b/drivers/net/dsa/microchip/ksz9477.c
@@ -1710,7 +1710,6 @@ static int ksz9477_setup(struct dsa_switch *ds)
struct ksz_device *dev = ds->priv;
u16 storm_mask, storm_rate;
struct dsa_port *dp;
- struct ksz_port *p;
const u16 *regs;
int ret;
@@ -1792,13 +1791,15 @@ static int ksz9477_setup(struct dsa_switch *ds)
if (ret < 0)
return ret;
- /* Start with learning disabled on standalone user ports, and enabled
- * on the CPU port. In lack of other finer mechanisms, learning on the
- * CPU port will avoid flooding bridge local addresses on the network
- * in some cases.
+ /* Ask DSA to add the addresses that the bridge learns on ports
+ * outside the switch as static entries on the CPU port. The CPU
+ * port itself does not learn: when the bridge forwards a frame in
+ * software between two ports of the switch, the switch would learn
+ * the sender on the CPU port. p->learning is never set for the CPU
+ * port, so ksz_port_stp_state_set() disables learning when DSA sets
+ * the port to forwarding.
*/
- p = &dev->ports[dev->cpu_port];
- p->learning = true;
+ ds->assisted_learning_on_cpu_port = true;
if (dev->irq > 0) {
ret = ksz_girq_setup(dev);
diff --git a/drivers/net/dsa/microchip/lan937x_main.c b/drivers/net/dsa/microchip/lan937x_main.c
index f0fb9498026120b3069b31d01bd0252be6f15403..7971d120630d173a1bbed6fb98683cee27d8fe89 100644
--- a/drivers/net/dsa/microchip/lan937x_main.c
+++ b/drivers/net/dsa/microchip/lan937x_main.c
@@ -770,7 +770,6 @@ static int lan937x_setup(struct dsa_switch *ds)
struct ksz_device *dev = ds->priv;
u16 storm_mask, storm_rate;
struct dsa_port *dp;
- struct ksz_port *p;
const u16 *regs;
int ret;
@@ -843,13 +842,15 @@ static int lan937x_setup(struct dsa_switch *ds)
if (ret < 0)
return ret;
- /* Start with learning disabled on standalone user ports, and enabled
- * on the CPU port. In lack of other finer mechanisms, learning on the
- * CPU port will avoid flooding bridge local addresses on the network
- * in some cases.
+ /* Ask DSA to add the addresses that the bridge learns on ports
+ * outside the switch as static entries on the CPU port. The CPU
+ * port itself does not learn: when the bridge forwards a frame in
+ * software between two ports of the switch, the switch would learn
+ * the sender on the CPU port. p->learning is never set for the CPU
+ * port, so ksz_port_stp_state_set() disables learning when DSA sets
+ * the port to forwarding.
*/
- p = &dev->ports[dev->cpu_port];
- p->learning = true;
+ ds->assisted_learning_on_cpu_port = true;
if (dev->irq > 0) {
ret = ksz_girq_setup(dev);
--
2.47.3
Technical Details
Message-ID:
<20261126-ksz-stp-link-local-v1-3-39aed15f6271@pengutronix.de>Path:
mbox-mo1.pugleaf.net!srv.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-371933-linux-kernel-netdev=dewy.ruReferences:
<20261126-ksz-stp-link-local-v1-0-39aed15f6271@pengutronix.de>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-371933-linux-kernel-netdev=dewy.ru From: o.rempel@pengutronix.de (Oleksij Rempel) Newsgroups: linux.kernel.netdev Subject: [PATCH net-next 3/5] net: dsa: microchip: ksz9477: do not learn addresses on the CPU port Date: Thu, 26 Nov 2026 09:07:50 +0100 Organization: Usenet Network Message-ID: <20261126-ksz-stp-link-local-v1-3-39aed15f6271@pengutronix.de> References: <20261126-ksz-stp-link-local-v1-0-39aed15f6271@pengutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Injection-Info: usenet.network; logging-data="412873"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:zx5syoHNkSKBszqOUEtvcDF0HQY= sha256:Yoz69Zq5LaZFNn5fZ+VcaEP2c4/soYbLXz1wtayQJwE= sha1:QtnZc2GGnqqyfJkyO8uL44pkNWw= sha256:U86LP2QIBGE1S44qL5ZEkjrusnddh7sXZYwT0bnrpRg= 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 5E118125EB5; Thu, 26 Nov 2026 11:08:36 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.151 X-Spam-Status: No, score=-3.151 tagged_above=-9999 required=6.31 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, HEADER_FROM_DIFFERENT_DOMAINS=0.249, MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001] autolearn=ham autolearn_force=no X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key) header.d=pengutronix.de 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 LxdGlVqFWt3d; Thu, 26 Nov 2026 11:08:33 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-371933-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> X-Authentication-Results: OpenDMARC; dmarc=none (p=none dis=none) header.from=pengutronix.de X-Received: from tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114]) by mail.dewy.ru (Postfix) with ESMTPS id 5E979125EB0; Thu, 26 Nov 2026 11:08:25 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by tor.lore.kernel.org (Postfix) with ESMTP id A5C153AF8B; Thu, 26 Nov 2026 08:08:17 +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=3; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1795680491; b=Q3hM0AXWL/yx49P/fRW3aSvnp9fVTBLG0QLQzHEyKxr/CSR78f5ScRGetOw7pvn/F2jz G0g970L8VAIsW0jUqoH4sYMhdxQqlPitpXaKsACQ3eNRGoS84WMyhEK2HwyFDWJlE4NKV 5lxkZVepzOyjBZLwQfKYyrHjBWHiYRbRD9m8iwD5q8+AoZhrFk2mNlJWnFZ/X6HeGIc8D SG2hCK23rvh+Ua7n78ohI+N1aeM0D5flfgUGA77XAHt3IN257tqFBZ4ryVSbMtaTL+gQn brTK88BMaz/OVnbcoXkVZeIgl/2JYlFF9F2YLt8zkWTmNxz/Kvg8xFd+eYJ/09pTbRQ== X-ARC-Message-Signature: i=3; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795680491; h=X-Original-To:Received:DMARC-Filter:Received:DKIM-Signature:Received: From:Date:Subject:X-Mailing-List:List-Id:List-Post:List-Help: List-Subscribe:List-Unsubscribe:List-Owner:Precedence:MIME-Version: Content-Type:Content-Transfer-Encoding:Message-Id:References: In-Reply-To:To:Cc:X-Mailer; bh=5emaesRPp85GbypB4BiWqH9+QqRCcuVwTK4b2tLxYG8=; b=BEyBylBjKcK1fbjek9FvamQSFw87SKphwKPTbOAlFQzl+rxTPwhBQ1wRXY7MpE1oGpuA tqkwheIf6U20kIyWUxKgxtMzWis0dvKl0QUFnb+mCyJpbbjnup2r/ZLlWhyX9AbVCiYhA zwGrZzrzWPsRqn+8n3qNJaSroXuq+44XIbHcSLBDnjjzJCV/11otowViaqRcIq/zA7VAz gQtl6EcZIfyx4kAsPLFXbo3Y7P2b2ieyvCoFjjIt2Rk38VJs6O7a6qlpwZPmRdnpZ59qL gtOh1qEEinEfFaiuXS/+swfGjvmZNH3INkYt48PGx3VQQF59tFYMuqz5OoqNu+GxYPQ== X-ARC-Authentication-Results: i=3; smtp.subspace.kernel.org; dkim=pass header.d=pengutronix.de header.i=@pengutronix.de header.a=rsa-sha256 header.s=20260414 header.b=ca+aD0Hf; dmarc=none header.from=pengutronix.de; spf=pass smtp.mailfrom=pengutronix.de; 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 E0430606A32D; Thu, 26 Nov 2026 08:08:10 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=pengutronix.de header.i=@pengutronix.de header.a=rsa-sha256 header.s=20260414 header.b=ca+aD0Hf X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=185.203.200.13 X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1795680485; b=yKPN1mLk3Ky4vJ9w7eD8hi5zfB5AVHn6KINT4VemlxrCx3oYA/QpiZjX3JdNGaxMoaGz tAx0Zu1l4D3eTsu26MK6No7SB1RlJumHXSkjCtybDWI4USZ/8hODZuIfOLkb8ucq1cjCp jC7a1yW75ZXJTkGzvGAML4JWnMsPLHPnC4VExnJ75EiXFngqRrTXVOZBOGUhAtoIwcUs3 JzxrtnMnbxFuWPIExIUALT+sLBNrwB+OuIhuqZQs3m1GIpCpRDX9+6aUJys5IpTx2uhpn c2uTiuoWmyvxHAsX71fAxPSV7AnVvS6wxs4RLBuzm1UaJHBql4bYXXYpGiExU1SleZQ== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795680485; h=DMARC-Filter:Received:DKIM-Signature:Received:From:Date:Subject: MIME-Version:Content-Type:Content-Transfer-Encoding:Message-Id: References:In-Reply-To:To:Cc:X-Mailer; bh=5emaesRPp85GbypB4BiWqH9+QqRCcuVwTK4b2tLxYG8=; b=f/VOiV2tZ0r2kgFIhpDSP+KtSouSnFWatGbhmeCCqe4o/wopM9LVyc62yKswif3JR0Dt bHIHSdkgrJuD8OnK4nf7BcJmQBdLWBDCbM8wR6aHlT1mBv7swHUkOVT2niWI0cSieqaNw VCpiyZjLyH9dtKhKkfSLD0RkEq87OUXJr4VzkJVb+TsR/nh67YmWPPVRMzMU60/4T0ZNa kMaGkCStF9UmFPsEu9t2xXzRxaoX/239VSBot2pk8JKkIjAHduUQuiFTy6jCZXjiP+FBJ k2ll3YYhxr7JTNosRGD4VhUhrd+9YaxEFRG7cRhzLp2fqfdcVqgpL4GYboudgemeD9g== X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=none header.from=pengutronix.de; spf=pass smtp.mailfrom=pengutronix.de; dkim=pass header.d=pengutronix.de header.i=@pengutronix.de header.a=rsa-sha256 header.s=20260414 header.b=ca+aD0Hf; arc=pass header.oldest-pass=0 smtp.remote-ip=185.203.200.13 X-Received: from mx1.white.stw.pengutronix.de (mx1.white.stw.pengutronix.de [185.203.200.13]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 82E5A606A326 for <netdev@vger.kernel.org>; Thu, 26 Nov 2026 08:08:03 +0000 (UTC) X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 82E5A606A326 X-Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=pengutronix.de X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=pengutronix.de X-Received: from dude04.red.stw.pengutronix.de (dude04.red.stw.4.pengutronix.de [10.17.1.12]) (Authenticated sender: relay-from-dude04.red.stw.pengutronix.de) by mx1.white.stw.pengutronix.de (Postfix) with ESMTPSA id D24E32007F9; Thu, 26 Nov 2026 09:08:00 +0100 (CET) X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pengutronix.de; s=20260414; t=1795680480; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=5emaesRPp85GbypB4BiWqH9+QqRCcuVwTK4b2tLxYG8=; b=ca+aD0HfLoMiuMglL7pBN9JQLeFw/pGveKR/egGTer2hq4/FuqZweY3AH2+rwrs7dLYvVa uDP5hDDQlk7TeHSjirb7zxJhCzWKA4DqmdGH5TD1g85m7yhm33VqR7GBJkx5zjEYgWD3+/ TRaw+jQVLnVUdYgZVdZGO5W3cI1oStO5p6rsEe1Z06//XLN4YclNUM9r9NV/DVs+RWx67+ JnBCitm5Meer3hz74OcUNBekZA3J/OggvvHsNpX06aBfgWK2wZyTftmW++SmPKRA8VaFUc jLCrOQjV6Icn9rDwZzhwIhSqFXFSTmnD2V2RBDO8ngC4bzahB7nChonSRjLOMw== X-ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=pengutronix.de; s=20260414; t=1795680480; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=5emaesRPp85GbypB4BiWqH9+QqRCcuVwTK4b2tLxYG8=; b=LUAetap3cMxJeeCngx7qqvWhCbB/i+u55uLrT1ItMLggLEaguWFb/GCzsepTVWXo9I9xQy 4pQuSMd/Q+oX77GZ4GFDeD42Pr6AkRluI7MQcXXUl0LOBPL0hcmaAmvABwGyZVgUdHUUwN sajWp8JcqE1Hf7wWjHGrqwoJfndRxPIINsg06v4azr1NJNZ4U6YLpGOtIMLaQqvVCPhS/P RRUVWU1Dst1ZnA8ycBs+DIHdrI8a1s8hXRTkAMfKYhPL2A8LS136gHlNSiuXgz0PLZkxY2 RfvFMY0h4m/uQMtyjgeawHUAJX5x4MAron9QSO2vU/djIkJkJ1vGLs1wcmnvjQ== X-ARC-Authentication-Results: i=1; ORIGINATING; auth=pass smtp.auth=relay-from-dude04.red.stw.pengutronix.de smtp.mailfrom=ore@pengutronix.de X-ARC-Seal: i=1; s=20260414; d=pengutronix.de; t=1795680480; a=rsa-sha256; cv=none; b=ZltF1Z+1gRdBaqYMemOjedLmkD28Tje4kKpB6Kqrv1Af70nRvUkcjdTO2OFvcMN06aFelJ hxbK+INq2k6648B+JGfEZRpby3CI2JBzi37ZV3ZIJsw1UPdQtzpNz8h3/YyO8clWGWa7/P 4Xb/yaGALhY6os9WqkWnpfWDC7Es6sMbWbH9mcfdazAZTnBAXIkEdvjoGYVgp/FlN1kNLA +pYJMr0NdcQIkwq+ud4K+RAi3nimlJpIq4zcNwXZQWJ/FmdimQrCXcQuGYPg4jC04xvdJv /YY30eQot6YwIPlsx1YNWz8SllHB/B+KQnj37l6SEFnJNxhngPXyu72yezhLGQ== X-Received: by dude04.red.stw.pengutronix.de (Postfix, from userid 1058) id B540F380B31; Thu, 26 Nov 2026 09:08:00 +0100 (CET) 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-In-Reply-To: <20261126-ksz-stp-link-local-v1-0-39aed15f6271@pengutronix.de> X-Cc: Simon Horman <horms@kernel.org>, Florian Fainelli <f.fainelli@gmail.com>, Nikolay Aleksandrov <razor@blackwall.org>, Ido Schimmel <idosch@nvidia.com>, netdev@vger.kernel.org, bridge@lists.linux.dev, kernel@pengutronix.de, Oleksij Rempel <o.rempel@pengutronix.de> X-Mailer: b4 0.14.2