From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5A8BD408001 for ; Tue, 30 Jun 2026 11:20:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782818403; cv=none; b=FOfXLGYzL6Po9nTaPHaaTtzlCmBghfcrkO1uUEBBhxR9HFs+DRF2gXnU4dgOpXzrSZl2hAqyDM9X3CHs2ngxAs9sTAxyi07JAJe0VUvDhZn4pupe3e8EA1AejA5ISEbw4BDd13+LEyCzXy4W0Vya1twXh6GackGh4EkCPgY1AJU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782818403; c=relaxed/simple; bh=CZvAMWugE+HYe7pENH7A63Y+ys05ZWo7Cpgg8GtVxfU=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=BdfNLCD3KUmWksjk4LCAQYYFrXE/GHza1V8Sj1QBqWtLZKtQPmyIOjRYXVSMhYiQB4LW7Ij1U1rG4tiS0w0ZpJEqv+OdyUT7IgCHa60xaE5Aqf4E+uuN+yb6rG4HfuzF5n70vPL81JTVtaB7yZNpLmWmjn+SKME6QclbPytzLo0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=RJBJwYwN; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="RJBJwYwN" Received: by smtp.kernel.org (Postfix) with ESMTPSA id B3D041F00A3A; Tue, 30 Jun 2026 11:19:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1782818401; bh=TrVCuoDIZFlW9YDg7QeeyBxIpmpVvc0EYhcX+3/G8FQ=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=RJBJwYwN4GjHH+1mVDQHNxDfxBgYNo4TqE5ItPIkK4pt4L7vrzohV3wKylrzs/379 no6+OSnTRx1qkjbLpTqO1S7kg2C27LBO2s5Jr7+NqJ7MAcbJcYABiKiCXvoxGYjYB9 ZNeUGxm4NaAaEn+cThIwcOue71FEnsXb6PQFxUoon5L/2Psp2+qQq8wFg6TB7kll5K 6FHPSkhCYmY7PrTZX6ooo3jOHofOofB13rj6MW5iFYeuQgNsLv35nXSfrA9AFxUrg3 xkLx34FC9iwYkZCFEJM+uyS96ORHvGutwms2tIDdeWAazqVdwrKENBT5GKcQS63Vb6 SSL0O+Tl+F25A== From: Linus Walleij Date: Tue, 30 Jun 2026 13:19:44 +0200 Subject: [PATCH net-next v2 4/5] net: dsa: realtek: rtl8366rb: Disable STP learning on all ports in setup Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20260630-rtl8366rb-improvements-v2-4-05eb9d6a37f5@kernel.org> References: <20260630-rtl8366rb-improvements-v2-0-05eb9d6a37f5@kernel.org> In-Reply-To: <20260630-rtl8366rb-improvements-v2-0-05eb9d6a37f5@kernel.org> To: Luiz Angelo Daros de Luca , =?utf-8?q?Alvin_=C5=A0ipraga?= , Andrew Lunn , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: netdev@vger.kernel.org, Linus Walleij X-Mailer: b4 0.15.2 When we loop over all ports in the switch .setup() callback, make sure to disable learning on all user ports. This is what is normally expected and what the RTL8365MB is doing. Move the code around to accommodate for the new call. Reviewed-by: Luiz Angelo Daros de Luca Signed-off-by: Linus Walleij --- drivers/net/dsa/realtek/rtl8366rb.c | 74 ++++++++++++++++++++----------------- 1 file changed, 40 insertions(+), 34 deletions(-) diff --git a/drivers/net/dsa/realtek/rtl8366rb.c b/drivers/net/dsa/realtek/rtl8366rb.c index 64215a0d5d6d..155bf0010d5f 100644 --- a/drivers/net/dsa/realtek/rtl8366rb.c +++ b/drivers/net/dsa/realtek/rtl8366rb.c @@ -820,6 +820,40 @@ static int rtl8366rb_port_remove_isolation(struct realtek_priv *priv, int port, RTL8366RB_PORT_ISO_PORTS(mask), 0); } +static void +rtl8366rb_port_stp_state_set(struct dsa_switch *ds, int port, u8 state) +{ + struct realtek_priv *priv = ds->priv; + u32 val; + int i; + + switch (state) { + case BR_STATE_DISABLED: + val = RTL8366RB_STP_STATE_DISABLED; + break; + case BR_STATE_BLOCKING: + case BR_STATE_LISTENING: + val = RTL8366RB_STP_STATE_BLOCKING; + break; + case BR_STATE_LEARNING: + val = RTL8366RB_STP_STATE_LEARNING; + break; + case BR_STATE_FORWARDING: + val = RTL8366RB_STP_STATE_FORWARDING; + break; + default: + dev_err(priv->dev, "unknown bridge state requested\n"); + return; + } + + /* Set the same status for the port on all the FIDs */ + for (i = 0; i < RTL8366RB_NUM_FIDS; i++) { + regmap_update_bits(priv->map, RTL8366RB_STP_STATE_BASE + i, + RTL8366RB_STP_STATE_MASK(port), + RTL8366RB_STP_STATE(port, val)); + } +} + static int rtl8366rb_setup(struct dsa_switch *ds) { struct realtek_priv *priv = ds->priv; @@ -900,6 +934,12 @@ static int rtl8366rb_setup(struct dsa_switch *ds) /* Start with all ports blocked, including unused ports */ dsa_switch_for_each_port(dp, ds) { + /* Set the initial STP state of all ports to DISABLED, otherwise + * ports will still forward frames to the CPU despite being + * administratively down by default. + */ + rtl8366rb_port_stp_state_set(ds, dp->index, BR_STATE_DISABLED); + /* Start with all ports completely isolated */ ret = rtl8366rb_port_set_isolation(priv, dp->index, 0); if (ret) @@ -1320,40 +1360,6 @@ rtl8366rb_port_bridge_flags(struct dsa_switch *ds, int port, return 0; } -static void -rtl8366rb_port_stp_state_set(struct dsa_switch *ds, int port, u8 state) -{ - struct realtek_priv *priv = ds->priv; - u32 val; - int i; - - switch (state) { - case BR_STATE_DISABLED: - val = RTL8366RB_STP_STATE_DISABLED; - break; - case BR_STATE_BLOCKING: - case BR_STATE_LISTENING: - val = RTL8366RB_STP_STATE_BLOCKING; - break; - case BR_STATE_LEARNING: - val = RTL8366RB_STP_STATE_LEARNING; - break; - case BR_STATE_FORWARDING: - val = RTL8366RB_STP_STATE_FORWARDING; - break; - default: - dev_err(priv->dev, "unknown bridge state requested\n"); - return; - } - - /* Set the same status for the port on all the FIDs */ - for (i = 0; i < RTL8366RB_NUM_FIDS; i++) { - regmap_update_bits(priv->map, RTL8366RB_STP_STATE_BASE + i, - RTL8366RB_STP_STATE_MASK(port), - RTL8366RB_STP_STATE(port, val)); - } -} - static void rtl8366rb_port_fast_age(struct dsa_switch *ds, int port) { -- 2.54.0