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
121 struct bridge_vlan_info *p_vinfo);121 struct bridge_vlan_info *p_vinfo);
122bool br_mst_enabled(const struct net_device *dev);122bool br_mst_enabled(const struct net_device *dev);
123int br_mst_get_info(const struct net_device *dev, u16 msti, unsigned long *vids);123int br_mst_get_info(const struct net_device *dev, u16 msti, unsigned long *vids);
124int br_mst_get_state(const struct net_device *dev, u16 msti, u8 *state);
124#else125#else
125static inline bool br_vlan_enabled(const struct net_device *dev)126static 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 return -EINVAL;166 return -EINVAL;
166}167}
168static inline int br_mst_get_state(const struct net_device *dev, u16 msti,
169 u8 *state)
170{
171 return -EINVAL;
172}
167#endif173#endif
168 174
169#if IS_ENABLED(CONFIG_BRIDGE)175#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
48}48}
49EXPORT_SYMBOL_GPL(br_mst_get_info);49EXPORT_SYMBOL_GPL(br_mst_get_info);
50 50
51int 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}
74EXPORT_SYMBOL_GPL(br_mst_get_state);
75
51static void br_mst_vlan_set_state(struct net_bridge_port *p, struct net_bridge_vlan *v,76static void br_mst_vlan_set_state(struct net_bridge_port *p, struct net_bridge_vlan *v,
52 u8 state)77 u8 state)
53{78{

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