From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=epMYlP8SwfuajkjtWjH/vdDgnJLu6cKl9OWtKi8Kk94=; b=Qoted9Hr0eGzmpkCHTYGlB9GWjkE+TWEPm1lkAgM0fg8igtm6f9hjxNnovjmkFDYYg fP51yRAboD900JOQlGUtnah7kk9DgdBI1gKsMEvsfFBu1PiRII59tOUASjKEtfHIfNmC GsiLQm5utgUqyqnGBl1HB6D0OkGAvSG7ZrNk3W97LO5I3x2ccRdjBagVxbvf2OCfQ947 xaLp9TCsmOUGYcs0VB4Ir6NJtEalPEjjJLI6I+FhUnxeAvq/yIbmlz3200tabpvIudC9 QjbAmRccewrzOEva+71WXoyon9TiNTIRW0BwFSy/cCxAGZJ4A7rpsk3NVjQ+l4s+dB1B d9Ig== Date: Thu, 17 Mar 2022 02:43:26 +0200 From: Vladimir Oltean Message-ID: <20220317004326.ebsc5xjug76qqen3@skbuf> References: <20220316150857.2442916-1-tobias@waldekranz.com> <20220316150857.2442916-8-tobias@waldekranz.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220316150857.2442916-8-tobias@waldekranz.com> Subject: Re: [Bridge] [PATCH v5 net-next 07/15] net: bridge: mst: Add helper to map an MSTI to a VID set List-Id: Linux Ethernet Bridging List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Tobias Waldekranz Cc: Ivan Vecera , Andrew Lunn , Florian Fainelli , Jiri Pirko , Petr Machata , Nikolay Aleksandrov , bridge@lists.linux-foundation.org, Russell King , Vivien Didelot , Ido Schimmel , netdev@vger.kernel.org, Cooper Lees , Roopa Prabhu , kuba@kernel.org, Matt Johnston , davem@davemloft.net, linux-kernel@vger.kernel.org On Wed, Mar 16, 2022 at 04:08:49PM +0100, Tobias Waldekranz wrote: > br_mst_get_info answers the question: "On this bridge, which VIDs are > mapped to the given MSTI?" > > This is useful in switchdev drivers, which might have to fan-out > operations, relating to an MSTI, per VLAN. > > An example: When a port's MST state changes from forwarding to > blocking, a driver may choose to flush the dynamic FDB entries on that > port to get faster reconvergence of the network, but this should only > be done in the VLANs that are managed by the MSTI in question. > > Signed-off-by: Tobias Waldekranz > --- Reviewed-by: Vladimir Oltean > include/linux/if_bridge.h | 7 +++++++ > net/bridge/br_mst.c | 26 ++++++++++++++++++++++++++ > 2 files changed, 33 insertions(+) > > diff --git a/include/linux/if_bridge.h b/include/linux/if_bridge.h > index 3aae023a9353..1cf0cc46d90d 100644 > --- a/include/linux/if_bridge.h > +++ b/include/linux/if_bridge.h > @@ -119,6 +119,7 @@ int br_vlan_get_info(const struct net_device *dev, u16 vid, > struct bridge_vlan_info *p_vinfo); > int br_vlan_get_info_rcu(const struct net_device *dev, u16 vid, > struct bridge_vlan_info *p_vinfo); > +int br_mst_get_info(const struct net_device *dev, u16 msti, unsigned long *vids); > #else > static inline bool br_vlan_enabled(const struct net_device *dev) > { > @@ -151,6 +152,12 @@ static inline int br_vlan_get_info_rcu(const struct net_device *dev, u16 vid, > { > return -EINVAL; > } > + > +static inline int br_mst_get_info(const struct net_device *dev, u16 msti, > + unsigned long *vids) > +{ > + return -EINVAL; > +} > #endif > > #if IS_ENABLED(CONFIG_BRIDGE) > diff --git a/net/bridge/br_mst.c b/net/bridge/br_mst.c > index 00935a19afcc..00b36e629224 100644 > --- a/net/bridge/br_mst.c > +++ b/net/bridge/br_mst.c > @@ -13,6 +13,32 @@ > > DEFINE_STATIC_KEY_FALSE(br_mst_used); > > +int br_mst_get_info(const struct net_device *dev, u16 msti, unsigned long *vids) > +{ > + const struct net_bridge_vlan_group *vg; > + const struct net_bridge_vlan *v; > + const struct net_bridge *br; > + > + ASSERT_RTNL(); > + > + if (!netif_is_bridge_master(dev)) > + return -EINVAL; > + > + br = netdev_priv(dev); > + if (!br_opt_get(br, BROPT_MST_ENABLED)) > + return -EINVAL; > + > + vg = br_vlan_group(br); > + > + list_for_each_entry(v, &vg->vlan_list, vlist) { > + if (v->msti == msti) > + __set_bit(v->vid, vids); > + } > + > + return 0; > +} > +EXPORT_SYMBOL_GPL(br_mst_get_info); > + > static void br_mst_vlan_set_state(struct net_bridge_port *p, struct net_bridge_vlan *v, > u8 state) > { > -- > 2.25.1 >