From nobody Fri Apr 3 01:25:05 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 2AAAF3EB7E3; Wed, 25 Mar 2026 17:54:47 +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=1774461290; cv=none; b=Z4Ouso68pYBReGFComEa5TJwksxh09gl+4rJnyryCGSyjJ1k8gO19Tq86YtCm02AzSpTXptcTd9vibCI9di6WWIAqsLXHZDwTgGM0tWxkUhaJIa200pIlTMgO6zWzlbDMGvWtSdqeCpu33O+0z+WCm1NySq0Rt5fuQE58vA1nOE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774461290; c=relaxed/simple; bh=mMKmSEVB4KJWsFl2mjqcbipnQ1wms5iprOUdb4T6vz4=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=C3/AqhU0VhimmbVf61wb1F0Bitj8u1XN7CkVs4nKdBITTl7pxfXnuzDCwtQShA5sitI+t+03eX6heHsFrHcJnZTrU6NMu1l1mw1Kr4vSVAirkAy0LTLGvBUCjYqcSQHOZOaHWAH5wk4lssZtfxFRBjOQJHVmsd1HhkRWYRMTQaY= 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 1w5SRI-000000002aa-21xv; Wed, 25 Mar 2026 17:54:44 +0000 Date: Wed, 25 Mar 2026 17:54:41 +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 v7 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 --- 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 e93b4feaca96..8b6d34e8a6f0 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