lkml.org 
[lkml]   [2022]   [Mar]   [16]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v5 net-next 09/15] net: bridge: mst: Add helper to query a port's MST state
On Wed, Mar 16, 2022 at 04:08:51PM +0100, Tobias Waldekranz wrote:
> This is useful for switchdev drivers who are offloading MST states
> into hardware. As an example, a driver may wish to flush the FDB for a
> port when it transitions from forwarding to blocking - which means
> that the previous state must be discoverable.
>
> Signed-off-by: Tobias Waldekranz <tobias@waldekranz.com>
> ---

Reviewed-by: Vladimir Oltean <olteanv@gmail.com>

> include/linux/if_bridge.h | 6 ++++++
> net/bridge/br_mst.c | 25 +++++++++++++++++++++++++
> 2 files changed, 31 insertions(+)
>
> diff --git a/include/linux/if_bridge.h b/include/linux/if_bridge.h
> index 4efd5540279a..d62ef428e3aa 100644
> --- a/include/linux/if_bridge.h
> +++ b/include/linux/if_bridge.h
> @@ -121,6 +121,7 @@ int br_vlan_get_info_rcu(const struct net_device *dev, u16 vid,
> struct bridge_vlan_info *p_vinfo);
> bool br_mst_enabled(const struct net_device *dev);
> int br_mst_get_info(const struct net_device *dev, u16 msti, unsigned long *vids);
> +int br_mst_get_state(const struct net_device *dev, u16 msti, u8 *state);
> #else
> static inline bool br_vlan_enabled(const struct net_device *dev)
> {
> @@ -164,6 +165,11 @@ static inline int br_mst_get_info(const struct net_device *dev, u16 msti,
> {
> return -EINVAL;
> }
> +static inline int br_mst_get_state(const struct net_device *dev, u16 msti,
> + u8 *state)
> +{
> + return -EINVAL;
> +}
> #endif
>
> #if IS_ENABLED(CONFIG_BRIDGE)
> diff --git a/net/bridge/br_mst.c b/net/bridge/br_mst.c
> index 830a5746479f..ee680adcee17 100644
> --- a/net/bridge/br_mst.c
> +++ b/net/bridge/br_mst.c
> @@ -48,6 +48,31 @@ int br_mst_get_info(const struct net_device *dev, u16 msti, unsigned long *vids)
> }
> EXPORT_SYMBOL_GPL(br_mst_get_info);
>
> +int br_mst_get_state(const struct net_device *dev, u16 msti, u8 *state)
> +{
> + const struct net_bridge_port *p = NULL;
> + const struct net_bridge_vlan_group *vg;
> + const struct net_bridge_vlan *v;
> +
> + ASSERT_RTNL();
> +
> + p = br_port_get_check_rtnl(dev);
> + if (!p || !br_opt_get(p->br, BROPT_MST_ENABLED))
> + return -EINVAL;
> +
> + vg = nbp_vlan_group(p);
> +
> + list_for_each_entry(v, &vg->vlan_list, vlist) {
> + if (v->brvlan->msti == msti) {
> + *state = v->state;
> + return 0;
> + }
> + }
> +
> + return -ENOENT;
> +}
> +EXPORT_SYMBOL_GPL(br_mst_get_state);
> +
> static void br_mst_vlan_set_state(struct net_bridge_port *p, struct net_bridge_vlan *v,
> u8 state)
> {
> --
> 2.25.1
>

\
 
 \ /
  Last update: 2022-03-17 01:42    [W:0.188 / U:0.748 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site