From nobody Thu Apr 2 20:09:44 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 A8078262BD; Fri, 27 Mar 2026 01:00:50 +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=1774573254; cv=none; b=m8sbm1HR4yP8xC0clwHqrM4h7/ZHFCZ6KSxPJpRsVWBd1lkbmRcUj83gAYagERrCA9A8xeSfPDn8CQ7YVvJd9TDWpsD1pWTJBqwGD+xtLC1WS0ctyITBWE4X3i4NnanYVOHjUn+5tbOVToLrxzT/T5k+AKYZSJ0o+9l0RWLqogs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774573254; c=relaxed/simple; bh=eCG6Uzo18oIJ29fP9t0Sx9qOotFDl8Qp2fswfufHEBo=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=OLA7rlP8n3vTTVvh+RWth7FqB0MpHsQ33f7kdb/9xkyQOR9nQ0HyekHSr9PpWbydrvBVLWEZ/h3jl1bPapm0RGKUB0YrPF8FnVBNg9bcsRXE1cW3JVIQQb5H2N/PTmmNK4RfBPvubvu0zaNoZBY8tk1JRihhS+9AVeEeryGmMR0= 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 1w5vZ8-000000007P1-0Rs8; Fri, 27 Mar 2026 01:00:46 +0000 Date: Fri, 27 Mar 2026 01:00:43 +0000 From: Daniel Golle To: Daniel Golle , Andrew Lunn , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , David Yang , 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 v8 2/4] net: dsa: add bridge member iteration macro Message-ID: <0eb4d7ba3e09f007cbd8a9e58ed363fa1cfe19fb.1774572749.git.daniel@makrotopia.org> 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 drivers typically open-code this by combining dsa_switch_for_each_user_port() with a dsa_port_offloads_bridge_dev() check, or cache bridge membership within the driver. Add dsa_switch_for_each_bridge_member() macro to express this pattern directly, and use it for the existing dsa_bridge_ports() inline helper. Signed-off-by: Daniel Golle --- v8: no changes v7: reuse existing helper v6: new patch include/net/dsa.h | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/include/net/dsa.h b/include/net/dsa.h index e93b4feaca966..8b6d34e8a6f0d 100644 --- a/include/net/dsa.h +++ b/include/net/dsa.h @@ -831,15 +831,18 @@ dsa_tree_offloads_bridge_dev(struct dsa_switch_tree *= dst, return false; } =20 +#define dsa_switch_for_each_bridge_member(_dp, _ds, _bdev) \ + dsa_switch_for_each_user_port(_dp, _ds) \ + if (dsa_port_offloads_bridge_dev(_dp, _bdev)) + static inline u32 dsa_bridge_ports(struct dsa_switch *ds, const struct net_device *bdev) { struct dsa_port *dp; u32 mask =3D 0; =20 - dsa_switch_for_each_user_port(dp, ds) - if (dsa_port_offloads_bridge_dev(dp, bdev)) - mask |=3D BIT(dp->index); + dsa_switch_for_each_bridge_member(dp, ds, bdev) + mask |=3D BIT(dp->index); =20 return mask; } --=20 2.53.0