From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.216.41 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1792852846; b=uDcguEiS5DFsn07x2VrNDlBxAOk0LByBSFPvJ90zh1JMO6+AILISDGY1dKpdm3xukwqf e4rxHq3eS1WvI9d4Ed605rJYhOhk0TPHpclY2pJ46ZrZUl0VAX/Zk8mvIyWdUpASazY/x mASx50aQc+ieqRHgud6z1OrGcIzwZXllTM0pf5nCKtHrOal7C4hHSeLDiAKT8fEnxX4CC FEg63C/LblRFiXOR5YAEGIgYF3ea1r9D46sGiVS+r5bBaqwrLO691rG47idGgRmEjRhAs 2NAD8xJV0E4PLtXY/Tf3yyM2cgswhOwCGGbSGRwWXjgt62EeibHXYkVo78C0uOAyZ+Q== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1792852846; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: From:To:Cc:Subject:Date:Message-ID:X-Mailer:MIME-Version: Content-Transfer-Encoding; bh=UMCW9KMFviFrZMbcsiEVVmmLV6m2nQyWTUUSuyYETI4=; b=0uAol68U5VuVP7bMFxAtEQTj6bw63zQWfiy2bERAxD6UXXA3b6Od+MbXz43iFHYIKjn/ YILAro4O3DJ2bUpvRED92rTkxHqGqO0Fy00Shj2b8QxJi3esIiv1xLTIbcfOc6VmHXUtt 2pFVdCGvH+1uMHr57v145hkPhPaupm4HrQb0zdxo9GI7XnaOZj/tTwb1bL9B7RboRQZ51 MIBMagp+NFYcYaWC2SvJ2YXAqhzQqBgq5utVBr52XfvLxrhU1EHVzPRWDntMfXKJRgfMy m3BOKiF+9jsssEFjciVsVwZcc1Ltr5T3SXkry5DKdi5g3WooJtcwIqQ2LarcVsXGDLQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20251104 header.b=spL3Ckb7; arc=none smtp.remote-ip=209.85.216.41 Received: from mail-pj1-f41.google.com (mail-pj1-f41.google.com [209.85.216.41]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A76D2606A31A for ; Sat, 24 Oct 2026 14:40:45 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org A76D2606A31A Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20251104 header.b=spL3Ckb7 Received: by mail-pj1-f41.google.com with SMTP id 98e67ed59e1d1-38ec1402b05so897229a91.2 for ; Sat, 24 Oct 2026 07:40:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1792852845; x=1793457645; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to:content-type; bh=UMCW9KMFviFrZMbcsiEVVmmLV6m2nQyWTUUSuyYETI4=; b=spL3Ckb7csO6ZzHNYpTHnI4ICzIzAgO64oB3o9VXkCZ8QvUn7cQtuzjgXjOSKpq0TD NgWHVFGcni02/eCQq91UXt9h3cNZt8SBtU/tgCy2MVFsx98eYelJKF2MSbzWvK8okmmA teCDD9/CxCT1tykPIWG7UNagd2Gak4FcNkiRSbRzwamLLFZU6imjdgNu8700sqba2aUc ydc239QXbjjUEA/Ul5FPGnQ5fDyXT6J+I4UmOi1n6B2hQHncmTX4HH6bPPMnKEaYmmtX mHuO6JyIoN0OCSLGDvh4XImDCl8jolPJVkoi/L9jvV1KDqbXoIMyp6hLiSGO8x8rwFFM tOSg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1792852845; x=1793457645; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=UMCW9KMFviFrZMbcsiEVVmmLV6m2nQyWTUUSuyYETI4=; b=tiwHcTPihzhInALZT4+CG4p8NA2utPeGL9t+fJ91QNCnQltkkHUrpBb1ij6zgWh1Ju 2RxXPl3kxFpew76bTI/+43Ffc+lbTlzVeK/OxutYjvYE6A8vkwfIBCMuTa0BAzDG0Yuv IzBOmLIsjl71oeU6hei6Nzf7h/F3lEfV9bu/mJCTkEWK5hgjznfqo7fz8o3khpj2JeB+ yfo94riK459+AlBBKvhpu8p8uBNdvrsTV3U8kvP4QkmsEBrX0PQ8mdn/eq1gv2KTQGQ2 L6hz0XA3/ZewwoEPvuG6Cklytaa46jRh+h1XW8frSdroYrazMls/DZsqt3p2GqIADvGs T1NA== X-Forwarded-Encrypted: i=1; AKwUvBwUNGbEEf2i/GG2nhaYhlnvcdCXkBriBNl7UB+18RevXNTlHYfpBxe0ithD99mH5nBo8kZeOMELvbwjIJY=@vger.kernel.org X-Gm-Message-State: AFq9FYLD2wkp7REKjZMW4Bj5ZRhlAuPLRYJ+3D3TdvRzRVxV4m79piPM vbsvnD6AVpY1VGZ195HbQXETySicdrq0aVV0wXGGD/S8cvjWnpjgLhfL X-Gm-Gg: AYBFou2TefBkoosSyQJp57kpm2bUf5ZJsCxIxQnHUr3MlK3SL8zRLI+vM39aw45R7zK L1Chq7dHilgoGNd4FcA/D3qXUwwAeaeqOWvT8B0InEdzKxwA7TNUxMVTjQ9jCJteMkd1OQ/4fYi KDocaRP1tZxHy2A8g3zb0Wbt8TCD9B0ICrKT2NfSud2hsXkXBlIALuvaP06OyGotgIxvMYGXd7R FsaXshCNl9jZeu6FDSy1+AMAO85jKqyeUZsw/GOdqnfHWPhV1FPITGboZct0UmrwrXzztBPLMS1 Rl1RTIShhnhbMyv0exzunakKad4pRPWQkK9Vig7zU6ormg8w6l97r2k1y9YvstNaRV2DgwlWdMY 5QAZlGgug0CNha8iArV6N/sJnTCOhGO2pIRMAvjdi2fAicRg0XUO31T6vdla9yxRSBk1gUBh5ON +UVXDy8AiTVag/oUo7qo7sj0mP2EMlJzUy/k3/8OnXT+99nx8hVPKhJNNZr827WDcgFSpalNPDF AlXgSTNKYisF/JCTxJ7PXUMjOEml3Hojc0lOJDD1WD6K25ketFwZDAU+rsAk53Ya8VYZzgH+AKS Y9MW8S9oSeDXmHoIraZXbmDggeCD X-Received: by 2002:a17:90b:2642:b0:3ac:b867:81df with SMTP id 98e67ed59e1d1-3adead4c63emr1965774a91.39.1792852844862; Sat, 24 Oct 2026 07:40:44 -0700 (PDT) Received: from d.home.yangfl.dn42 ([2a09:bac5:6216:1250::1d3:c4]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-3adebb29031sm1877918a91.4.2026.10.24.07.40.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 24 Oct 2026 07:40:44 -0700 (PDT) From: David Yang To: netdev@vger.kernel.org Cc: David Yang , Andrew Lunn , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , linux-kernel@vger.kernel.org Subject: [PATCH net] net: dsa: motorcomm: Isolate all ports during chip setup Date: Sat, 24 Oct 2026 22:40:21 +0800 Message-ID: <20261024144023.1010237-1-mmyangfl@gmail.com> X-Mailer: git-send-email 2.53.0 X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit The chip setup only blocked unknown unicast and unknown multicast frames, known multicast and broadcast were left open (though the former cannot appear while the FDB is still empty). Before port_setup() runs, this leaks in two ways: frames pumped untagged into the conduit port reach the fabric and loop back to the CPU, where the tag driver warns about and drops them; and broadcast frames received on a user port flood out of the other user ports. Close the window by fully isolating every port right after the hardware reset. The CPU port one-way isolation is also applied during chip setup instead of port_setup(), and yt921x_userport_standalone(), which port_setup() also runs for CPU ports, keeps it intact. Fixes: 186623f4aa72 ("net: dsa: yt921x: Add support for Motorcomm YT921x") Signed-off-by: David Yang --- drivers/net/dsa/motorcomm/chip.c | 56 ++++++++++++-------------------- 1 file changed, 20 insertions(+), 36 deletions(-) diff --git a/drivers/net/dsa/motorcomm/chip.c b/drivers/net/dsa/motorcomm/chip.c index d4fc20c52a58..f1762273dd6a 100644 --- a/drivers/net/dsa/motorcomm/chip.c +++ b/drivers/net/dsa/motorcomm/chip.c @@ -1164,10 +1164,13 @@ static int yt921x_userport_standalone(struct yt921x_priv *priv, int port) u32 ctrl; int res; - ctrl = ~priv->cpu_ports_mask; - res = yt921x_reg_write(priv, YT921X_PORTn_ISOLATION(port), ctrl); - if (res) - return res; + if (!(BIT(port) & priv->cpu_ports_mask)) { + ctrl = ~priv->cpu_ports_mask; + res = yt921x_reg_write(priv, YT921X_PORTn_ISOLATION(port), + ctrl); + if (res) + return res; + } /* Turn off FDB learning to prevent FDB pollution */ mask = YT921X_PORT_LEARN_DIS; @@ -1942,8 +1945,6 @@ yt921x_dsa_phylink_get_caps(struct dsa_switch *ds, int port, static int yt921x_port_setup(struct yt921x_priv *priv, int port) { - struct dsa_switch *ds = &priv->ds; - u32 ctrl; int res; res = yt921x_userport_standalone(priv, port); @@ -1957,27 +1958,6 @@ static int yt921x_port_setup(struct yt921x_priv *priv, int port) if (res) return res; - if (dsa_is_cpu_port(ds, port)) { - /* Egress of CPU port is supposed to be completely controlled - * via tagging, so set to oneway isolated (drop all packets - * without tag). - */ - ctrl = ~(u32)0; - res = yt921x_reg_write(priv, YT921X_PORTn_ISOLATION(port), - ctrl); - if (res) - return res; - - /* To simplify FDB "isolation" simulation, we also disable - * learning on the CPU port, and let software identify packets - * towarding CPU (either trapped or a static FDB entry is - * matched, no matter which bridge that entry is for), which is - * already done by yt921x_userport_standalone(). As a result, - * VLAN-awareness becomes unrelated on the CPU port (set to - * VLAN-unaware by the way). - */ - } - return 0; } @@ -2221,6 +2201,7 @@ static int yt921x_chip_reset(struct yt921x_priv *priv) { struct device *dev = yt921x_priv_to_device(priv); u16 eth_p_tag; + u32 ctrl; u32 val; int res; @@ -2258,6 +2239,17 @@ static int yt921x_chip_reset(struct yt921x_priv *priv) return -EINVAL; } + /* Block all traffic as soon as we reset the hardware since it now acts + * as a dump switch. + */ + for (int port = 0; port < YT921X_PORT_NUM; port++) { + ctrl = ~(u32)0; + res = yt921x_reg_write(priv, YT921X_PORTn_ISOLATION(port), + ctrl); + if (res) + return res; + } + return 0; } @@ -2285,7 +2277,7 @@ static int yt921x_chip_setup_dsa(struct yt921x_priv *priv) if (res) return res; - ctrl = GENMASK(10, 0); + ctrl = GENMASK(10, 0) & ~priv->cpu_ports_mask; res = yt921x_reg_write(priv, YT921X_FILTER_UNK_UCAST, ctrl); if (res) return res; @@ -2308,14 +2300,6 @@ static int yt921x_chip_setup_dsa(struct yt921x_priv *priv) ctrl = 0; for (int i = 0; i < YT921X_PORT_NUM; i++) ctrl |= YT921X_ACT_UNK_ACTn_TRAP(i); - /* Except for CPU ports, if any packets are sent via CPU ports without - * tag, they should be dropped. - */ - cpu_ports_mask = priv->cpu_ports_mask; - for_each_set_bit(port, &cpu_ports_mask, YT921X_PORT_NUM) { - ctrl &= ~YT921X_ACT_UNK_ACTn_M(port); - ctrl |= YT921X_ACT_UNK_ACTn_DROP(port); - } res = yt921x_reg_write(priv, YT921X_ACT_UNK_UCAST, ctrl); if (res) return res; -- 2.53.0