net: bridge: mst: Add helper to check if MST is enabled
authorTobias Waldekranz <tobias@waldekranz.com>
Wed, 16 Mar 2022 15:08:50 +0000 (16:08 +0100)
committerJakub Kicinski <kuba@kernel.org>
Thu, 17 Mar 2022 23:49:58 +0000 (16:49 -0700)
This is useful for switchdev drivers that might want to refuse to join
a bridge where MST is enabled, if the hardware can't support it.

Signed-off-by: Tobias Waldekranz <tobias@waldekranz.com>
Reviewed-by: Vladimir Oltean <olteanv@gmail.com>
Acked-by: Nikolay Aleksandrov <razor@blackwall.org>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
include/linux/if_bridge.h
net/bridge/br_mst.c

index 1cf0cc4..4efd554 100644 (file)
@@ -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);
+bool br_mst_enabled(const struct net_device *dev);
 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)
@@ -153,6 +154,11 @@ static inline int br_vlan_get_info_rcu(const struct net_device *dev, u16 vid,
        return -EINVAL;
 }
 
+static inline bool br_mst_enabled(const struct net_device *dev)
+{
+       return false;
+}
+
 static inline int br_mst_get_info(const struct net_device *dev, u16 msti,
                                  unsigned long *vids)
 {
index 00b36e6..830a574 100644 (file)
 
 DEFINE_STATIC_KEY_FALSE(br_mst_used);
 
+bool br_mst_enabled(const struct net_device *dev)
+{
+       if (!netif_is_bridge_master(dev))
+               return false;
+
+       return br_opt_get(netdev_priv(dev), BROPT_MST_ENABLED);
+}
+EXPORT_SYMBOL_GPL(br_mst_enabled);
+
 int br_mst_get_info(const struct net_device *dev, u16 msti, unsigned long *vids)
 {
        const struct net_bridge_vlan_group *vg;