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.
Unified · Split
| @@ -121,6 +121,7 @@ int br_vlan_get_info_rcu(const struct net_device *dev, u16 vid, · 120 unmodified lines | ||
| 121 | 121 | struct bridge_vlan_info *p_vinfo); |
| 122 | 122 | bool br_mst_enabled(const struct net_device *dev); |
| 123 | 123 | int br_mst_get_info(const struct net_device *dev, u16 msti, unsigned long *vids); |
| 124 | +int br_mst_get_state(const struct net_device *dev, u16 msti, u8 *state); | |
| 124 | 125 | #else |
| 125 | 126 | static inline bool br_vlan_enabled(const struct net_device *dev) |
| 126 | 127 | { |
| @@ -164,6 +165,11 @@ static inline int br_mst_get_info(const struct net_device *dev, u16 msti, · 37 unmodified lines | ||
| 164 | 165 | { |
| 165 | 166 | return -EINVAL; |
| 166 | 167 | } |
| 168 | +static inline int br_mst_get_state(const struct net_device *dev, u16 msti, | |
| 169 | + u8 *state) | |
| 170 | +{ | |
| 171 | + return -EINVAL; | |
| 172 | +} | |
| 167 | 173 | #endif |
| 168 | 174 | |
| 169 | 175 | #if IS_ENABLED(CONFIG_BRIDGE) |
| @@ -48,6 +48,31 @@ int br_mst_get_info(const struct net_device *dev, u16 msti, unsigned long *vids) · 47 unmodified lines | ||
| 48 | 48 | } |
| 49 | 49 | EXPORT_SYMBOL_GPL(br_mst_get_info); |
| 50 | 50 | |
| 51 | +int br_mst_get_state(const struct net_device *dev, u16 msti, u8 *state) | |
| 52 | +{ | |
| 53 | + const struct net_bridge_port *p = NULL; | |
| 54 | + const struct net_bridge_vlan_group *vg; | |
| 55 | + const struct net_bridge_vlan *v; | |
| 56 | + | |
| 57 | + ASSERT_RTNL(); | |
| 58 | + | |
| 59 | + p = br_port_get_check_rtnl(dev); | |
| 60 | + if (!p || !br_opt_get(p->br, BROPT_MST_ENABLED)) | |
| 61 | + return -EINVAL; | |
| 62 | + | |
| 63 | + vg = nbp_vlan_group(p); | |
| 64 | + | |
| 65 | + list_for_each_entry(v, &vg->vlan_list, vlist) { | |
| 66 | + if (v->brvlan->msti == msti) { | |
| 67 | + *state = v->state; | |
| 68 | + return 0; | |
| 69 | + } | |
| 70 | + } | |
| 71 | + | |
| 72 | + return -ENOENT; | |
| 73 | +} | |
| 74 | +EXPORT_SYMBOL_GPL(br_mst_get_state); | |
| 75 | + | |
| 51 | 76 | static void br_mst_vlan_set_state(struct net_bridge_port *p, struct net_bridge_vlan *v, |
| 52 | 77 | u8 state) |
| 53 | 78 | { |