History

net: bridge: mst: Add helper to query a port's MST state

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.

Tobias Waldekranz committed 4 years ago

Commit f54fd0e1 parent 48d57b22 files · +31 −0Browse files

Unified · Split

2 files
  1. include/linux/if_bridge.h +6 −0
  2. net/bridge/br_mst.c +25 −0
include/linux/if_bridge.h+6−0
@@ -121,6 +121,7 @@ int br_vlan_get_info_rcu(const struct net_device *dev, u16 vid, · 120 unmodified lines
121121 struct bridge_vlan_info *p_vinfo);
122122 bool br_mst_enabled(const struct net_device *dev);
123123 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);
124125 #else
125126 static inline bool br_vlan_enabled(const struct net_device *dev)
126127 {
@@ -164,6 +165,11 @@ static inline int br_mst_get_info(const struct net_device *dev, u16 msti, · 37 unmodified lines
164165 {
165166 return -EINVAL;
166167 }
168+static inline int br_mst_get_state(const struct net_device *dev, u16 msti,
169+ u8 *state)
170+{
171+ return -EINVAL;
172+}
167173 #endif
168174
169175 #if IS_ENABLED(CONFIG_BRIDGE)
net/bridge/br_mst.c+25−0
@@ -48,6 +48,31 @@ int br_mst_get_info(const struct net_device *dev, u16 msti, unsigned long *vids) · 47 unmodified lines
4848 }
4949 EXPORT_SYMBOL_GPL(br_mst_get_info);
5050
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+
5176 static void br_mst_vlan_set_state(struct net_bridge_port *p, struct net_bridge_vlan *v,
5277 u8 state)
5378 {

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t