From nobody Sat Apr 4 01:34:33 2026 Received: from pidgin.makrotopia.org (pidgin.makrotopia.org [185.142.180.65]) (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 A2D5B17BCA; Sun, 22 Mar 2026 00:19:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.142.180.65 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774138754; cv=none; b=dQCbR1Ra6j1aiv1kyLqbXCtUalG9nx7o8CY6dTYNy5MmxGgf7kKbqEJjbuUPqWDYiHQ65b84CQD/yG3XOxftlz9QnZG7xl6RFRcAyTYVNK7Lq59hrP+s/RPIRjwiMIoNBh1PSqgDIEcE60wujAjWPoI8nXKnKAIk4pDJMlRk4T0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774138754; c=relaxed/simple; bh=aB1XbynjqyOuURjInF/0+KoUdscONSKLPA/jyaKavQ4=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=Qytx3lXco/90Ar1DfmPDzz3ZPXOdzSAQuQEjiJbRtjED9QSvCQP2k1q0LpTUuik1NZNuj1QpPM7n0zyFM1QIQ+8NeB/5mmiXzYyOUTT33vgmlrl6eSoeQaI+SQHNO/JI7qwNQEsQrOe7puAy2T1KuTL7qlh3wi7Wz19zlCyVxMo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=makrotopia.org; spf=pass smtp.mailfrom=makrotopia.org; arc=none smtp.client-ip=185.142.180.65 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=makrotopia.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=makrotopia.org Received: from local by pidgin.makrotopia.org with esmtpsa (TLS1.3:TLS_AES_256_GCM_SHA384:256) (Exim 4.99) (envelope-from ) id 1w46X7-000000001Ms-1I8a; Sun, 22 Mar 2026 00:19:09 +0000 Date: Sun, 22 Mar 2026 00:19:06 +0000 From: Daniel Golle To: Daniel Golle , Andrew Lunn , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman , Russell King , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Frank Wunderlich , Chad Monroe , Cezary Wilmanski , Liang Xu , "Benny (Ying-Tsan) Weng" , Jose Maria Verdu Munoz , Avinash Jayaraman , John Crispin Subject: [PATCH net-next v6 2/4] net: dsa: add bridge member iteration macro and port mask helper Message-ID: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Drivers that offload bridges need to iterate over the ports that are members of a given bridge, for example to rebuild per-port forwarding bitmaps when membership changes. Currently each driver must open-code this by combining dsa_switch_for_each_user_port() with a dsa_port_offloads_bridge() check, or cache bridge membership within the driver. Add dsa_bridge_for_each_member() to express this pattern directly, and a dsa_bridge_ports() helper that returns a bitmask of member ports, matching the existing dsa_user_ports() and dsa_cpu_ports() helpers. Signed-off-by: Daniel Golle --- v6: new patch include/net/dsa.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/include/net/dsa.h b/include/net/dsa.h index 1c6f6c3b88e86..4f43d518f3de3 100644 --- a/include/net/dsa.h +++ b/include/net/dsa.h @@ -838,6 +838,22 @@ static inline bool dsa_port_tree_same(const struct dsa= _port *a, return a->ds->dst =3D=3D b->ds->dst; } =20 +#define dsa_bridge_for_each_member(_dp, _ds, _bridge) \ + dsa_switch_for_each_user_port((_dp), (_ds)) \ + if (dsa_port_offloads_bridge((_dp), (_bridge))) + +static inline u32 dsa_bridge_ports(struct dsa_switch *ds, + const struct dsa_bridge *bridge) +{ + struct dsa_port *dp; + u32 mask =3D 0; + + dsa_bridge_for_each_member(dp, ds, bridge) + mask |=3D BIT(dp->index); + + return mask; +} + typedef int dsa_fdb_dump_cb_t(const unsigned char *addr, u16 vid, bool is_static, void *data); struct dsa_switch_ops { --=20 2.53.0