From nobody Wed Apr 1 22:20:03 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 9308D223328; Wed, 1 Apr 2026 13:34:49 +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=1775050491; cv=none; b=GtgDjPhK5f0eAmnXZHWrlpx9nUDSgU5sHhlW3pOS3b8vO4k8ldYV3zpWC0dPeRdiImdiN9XQI2WEfPoI0ZbUrZy6i3ZQWbv+7S7ZQvxV8Fi4tHSIArhLqwoEdzsR12tPlxdzVzaS7Lwqs6RLPVRuD3Lca4h+27YG26Eiz1/s5bg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775050491; c=relaxed/simple; bh=w2vx123z0kiho2g6MGL9WtrhSk5cuYR6E2U8kW/NcVA=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=W2ZlsMpWikVjD0h6nBoCEdfyjjxMOvumrR6jJGap0pAlbvGHSMXPIXKoVdMJgoTtuOWwsSILI8O1ndFo0WSomHmlDyGRZIw3stkNrZPpej54xTScudryvoJXhzHUFsC90VHFBn8/ej07LWd8ZlM9+/CZazUuFqqDYy2N8AR23Uk= 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 1w7viX-000000001gF-2CpV; Wed, 01 Apr 2026 13:34:45 +0000 Date: Wed, 1 Apr 2026 14:34:42 +0100 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 v9 2/4] net: dsa: add bridge member iteration macro 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 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 --- v9: no changes 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