Received: by 2002:a89:413:0:b0:1fd:dba5:e537 with SMTP id m19csp1101441lqs; Fri, 14 Jun 2024 15:28:49 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCX1iMco0iKNObRdNx65eqCwyXIgDBlIYBI6rOAlDKSnQci5V3eVt3+/M0xcCbGb4ae/IoAhSSG3+i0dQlmnUTBU7UdQaAASzfwIijLpwA== X-Google-Smtp-Source: AGHT+IHSez4LEukImm6g/nraaS/9g0/WpvpAjxxkrlhnYN9qpP0Jntd6OP5a3GwFMoBemfhYngf1 X-Received: by 2002:a17:906:2314:b0:a6d:fbed:7953 with SMTP id a640c23a62f3a-a6f5245cefdmr473224166b.27.1718404129185; Fri, 14 Jun 2024 15:28:49 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1718404129; cv=pass; d=google.com; s=arc-20160816; b=AdD/ekJ7TGMr62vLfhKotMQ5rI5wmW/HcdnV5NdsyLG0hOwTLt/uCSsGmUzs3Wmpkl gu9fIA0phM95Rdf2pCFrxAIbHblsFf4odrLxQypA0Ve6nfp2gD1tMP66NAVn5oZ1Svbp /rPYgCirZgxt6olYFubn3TQPIpKpl7IA0o7gwMYBb0GTxxzNDNiFLIHg37E8YTAxVYqJ U0yx0bLm6z7g5eSCxdYHAj2L8gew3BOg2gP8MN6oUB8Zze6tpva4TTj7oxANrQwXLrtp 6xd9oExtTXFwPEO7uDevaA8sdRYbAxv2NTTTPMJZfesyCwbfysQ3AyjeWwMC53twyC3p nwAw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from; bh=rgKv1nf2InzknbbhRxhqes0hIrFbLNhzNu3kfbETYm8=; fh=gUMpjBs7ss4AUQHr0dRCXAZTR6QahUKM3AoWruz0a7w=; b=bkqVnW49pyU+6kQ6O0dX6ePAfHBncxDRk4bEaYO4zK4JCPHRi56gBBwP8FBq/i7WQG up3+Ui//NvGaIDYx0bbacvF67kCbfeUGwNafg+0pKKr1Sc/kdl0D19OdO2XyKYYaRJws kye5y09bdtfsrcKJy7ZVAYQBkNVQL3JuQpu7trqqsT0q7vHHV5TTS8rOoYo8I37s7pH9 1FOsXDkGdBEhf+vTKatAMkSPwz7ecf/XTI8SZHClZfiS4qSioQ+PHq2fNEbjBSUll2X3 M+XiTd3CZ/kRPPLSKRaV753VMzhgLywrL53hDdZVzo9r3ztMylB/lej4lds9FaU+xsrw q91w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=universe-factory.net); spf=pass (google.com: domain of linux-kernel+bounces-215526-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-215526-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id a640c23a62f3a-a6f56e80fcasi204634466b.1009.2024.06.14.15.28.49 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Jun 2024 15:28:49 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-215526-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=universe-factory.net); spf=pass (google.com: domain of linux-kernel+bounces-215526-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-215526-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id E2AB41F22744 for ; Fri, 14 Jun 2024 22:28:48 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 967A6186E5C; Fri, 14 Jun 2024 22:28:33 +0000 (UTC) Received: from orthanc.universe-factory.net (orthanc.universe-factory.net [104.238.176.138]) (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 951FD18413E; Fri, 14 Jun 2024 22:28:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=104.238.176.138 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718404113; cv=none; b=XCMng6wOA0/8WHx7MDauEKIOKl7gNHuaM0yhj+uL1OAwF+s38iheNahlIFTwHqpyW1h+xxfX2ug0o7NJvouZS/knS/O8351SoMD6h8hgCKfyfIEnEqaX15WX8dhKW3e8NvvVpdE4Lj39gOTMNfcboCCDd9GSQ23AKjNB7N6oels= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718404113; c=relaxed/simple; bh=YgBEElz9a1qV299JjQkHepcA71rQZdHyGk+Q6GQtrQg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=G/mH58j5GGf96gNNykESRMOpw2TQfjRckWvkHi0YNDWriNNwC+CcP8kvBJdelfAaUbtoSYJ/iNtXMC74tJs4EddMSfaz1b/4kWcdhdO6FVaA/TMbBytwvxUH5x9WN8CzVdMTgeAQEt3oohaWUNTE06AJhJilDkSVFgKH3K+Uou4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=universe-factory.net; spf=pass smtp.mailfrom=universe-factory.net; arc=none smtp.client-ip=104.238.176.138 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=universe-factory.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=universe-factory.net Received: from avalon.fritz.box (unknown [IPv6:2001:19f0:6c01:100::2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by orthanc.universe-factory.net (Postfix) with ESMTPSA id 1A8BF1FC32; Sat, 15 Jun 2024 00:22:28 +0200 (CEST) From: Matthias Schiffer To: =?UTF-8?q?Ar=C4=B1n=C3=A7=20=C3=9CNAL?= , Daniel Golle , DENG Qingfang , Sean Wang Cc: Andrew Lunn , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Matthias Brugger , AngeloGioacchino Del Regno , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, Matthias Schiffer Subject: [PATCH net-next 2/2] net: dsa: mt7530: add support for bridge port isolation Date: Sat, 15 Jun 2024 00:21:54 +0200 Message-ID: <15263cb9bbc63d5cc66428e7438e0b5324306aa4.1718400508.git.mschiffer@universe-factory.net> X-Mailer: git-send-email 2.45.2 In-Reply-To: <378bc964b49f9e9954336e99009932ac22bfe172.1718400508.git.mschiffer@universe-factory.net> References: <378bc964b49f9e9954336e99009932ac22bfe172.1718400508.git.mschiffer@universe-factory.net> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Remove a pair of ports from the port matrix when both ports have the isolated flag set. Signed-off-by: Matthias Schiffer --- drivers/net/dsa/mt7530.c | 21 ++++++++++++++++++--- drivers/net/dsa/mt7530.h | 1 + 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/drivers/net/dsa/mt7530.c b/drivers/net/dsa/mt7530.c index ecacaefdd694..44939379aba8 100644 --- a/drivers/net/dsa/mt7530.c +++ b/drivers/net/dsa/mt7530.c @@ -1303,7 +1303,8 @@ mt7530_stp_state_set(struct dsa_switch *ds, int port, u8 state) } static void mt7530_update_port_member(struct mt7530_priv *priv, int port, - const struct net_device *bridge_dev, bool join) + const struct net_device *bridge_dev, + bool join) __must_hold(&priv->reg_mutex) { struct dsa_port *dp = dsa_to_port(priv->ds, port), *other_dp; @@ -1311,6 +1312,7 @@ static void mt7530_update_port_member(struct mt7530_priv *priv, int port, struct dsa_port *cpu_dp = dp->cpu_dp; u32 port_bitmap = BIT(cpu_dp->index); int other_port; + bool isolated; dsa_switch_for_each_user_port(other_dp, priv->ds) { other_port = other_dp->index; @@ -1327,7 +1329,9 @@ static void mt7530_update_port_member(struct mt7530_priv *priv, int port, if (!dsa_port_offloads_bridge_dev(other_dp, bridge_dev)) continue; - if (join) { + isolated = p->isolated && other_p->isolated; + + if (join && !isolated) { other_p->pm |= PCR_MATRIX(BIT(port)); port_bitmap |= BIT(other_port); } else { @@ -1352,7 +1356,7 @@ mt7530_port_pre_bridge_flags(struct dsa_switch *ds, int port, struct netlink_ext_ack *extack) { if (flags.mask & ~(BR_LEARNING | BR_FLOOD | BR_MCAST_FLOOD | - BR_BCAST_FLOOD)) + BR_BCAST_FLOOD | BR_ISOLATED)) return -EINVAL; return 0; @@ -1381,6 +1385,17 @@ mt7530_port_bridge_flags(struct dsa_switch *ds, int port, mt7530_rmw(priv, MT753X_MFC, BC_FFP(BIT(port)), flags.val & BR_BCAST_FLOOD ? BC_FFP(BIT(port)) : 0); + if (flags.mask & BR_ISOLATED) { + struct dsa_port *dp = dsa_to_port(ds, port); + struct net_device *bridge_dev = dsa_port_bridge_dev_get(dp); + + priv->ports[port].isolated = !!(flags.val & BR_ISOLATED); + + mutex_lock(&priv->reg_mutex); + mt7530_update_port_member(priv, port, bridge_dev, true); + mutex_unlock(&priv->reg_mutex); + } + return 0; } diff --git a/drivers/net/dsa/mt7530.h b/drivers/net/dsa/mt7530.h index 2ea4e24628c6..28592123070b 100644 --- a/drivers/net/dsa/mt7530.h +++ b/drivers/net/dsa/mt7530.h @@ -721,6 +721,7 @@ struct mt7530_fdb { */ struct mt7530_port { bool enable; + bool isolated; u32 pm; u16 pvid; struct phylink_pcs *sgmii_pcs; -- 2.45.2