net: bridge: Multiple Spanning Trees
Subsystems (6)
v2 cover net: bridge: Multiple Spanning Trees
The bridge has had per-VLAN STP support for a while now, since:
https://lore.kernel.org/netdev/[email protected]/
The current implementation has some problems:
- The mapping from VLAN to STP state is fixed as 1:1, i.e. each VLAN is managed independently. This is awkward from an MSTP (802.1Q-2018, Clause 13.5) point of view, where the model is that multiple VLANs are grouped into MST instances.
Because of the way that the standard is written, presumably, this is also reflected in hardware implementations. It is not uncommon for a switch to support the full 4k range of VIDs, but that the pool of MST instances is much smaller. Some examples:
Marvell LinkStreet (mv88e6xxx): 4k VLANs, but only 64 MSTIs Marvell Prestera: 4k VLANs, but only 128 MSTIs Microchip SparX-5i: 4k VLANs, but only 128 MSTIs
- By default, the feature is enabled, and there is no way to disable it. This makes it hard to add offloading in a backwards compatible way, since any underlying switchdevs have no way to refuse the function if the hardware does not support it
- The port-global STP state has precedence over per-VLAN states. In MSTP, as far as I understand it, all VLANs will use the common spanning tree (CST) by default - through traffic engineering you can then optimize your network to group subsets of VLANs to use different trees (MSTI). To my understanding, the way this is typically managed in silicon is roughly:
Incoming packet:
.----.----.--------------.----.-------------
| DA | SA | 802.1Q VID=X | ET | Payload ...
'----'----'--------------'----'-------------
|
'->|\ .----------------------------.
| +--> | VID | Members | ... | MSTI |
PVID -->|/ |-----|---------|-----|------|
| 1 | 0001001 | ... | 0 |
| 2 | 0001010 | ... | 10 |
| 3 | 0001100 | ... | 10 |
'----------------------------'
|
.-----------------------------'
| .------------------------.
'->| MSTI | Fwding | Lrning |
|------|--------|--------|
| 0 | 111110 | 111110 |
| 10 | 110111 | 110111 |
'------------------------'What this is trying to show is that the STP state (whether MSTP is used, or ye olde STP) is always accessed via the VLAN table. If STP is running, all MSTI pointers in that table will reference the same index in the STP stable - if MSTP is running, some VLANs may point to other trees (like in this example).
The fact that in the Linux bridge, the global state (think: index 0 in most hardware implementations) is supposed to override the per-VLAN state, is very awkward to offload. In effect, this means that when the global state changes to blocking, drivers will have to iterate over all MSTIs in use, and alter them all to match. This also means that you have to cache whether the hardware state is currently tracking the global state or the per-VLAN state. In the first case, you also have to cache the per-VLAN state so that you can restore it if the global state transitions back to forwarding.
This series adds a new mst_enable bridge setting (as suggested by Nik) that can only be changed when no VLANs are configured on the bridge. Enabling this mode has the following effect:
- The port-global STP state is used to represent the CST (Common Spanning Tree) (1/10)
- Ingress STP filtering is deferred until the frame's VLAN has been resolved (1/10)
- The preexisting per-VLAN states can no longer be controlled directly (1/10). They are instead placed under the MST module's control, which is managed using a new netlink interface (described in 3/10)
- VLANs can br mapped to MSTIs in an arbitrary M:N fashion, using a new global VLAN option (2/10)
4-5/10 adds switchdev notifications so that a driver can track VID to MSTI mappings and MST port states.
An offloading implementation is this provided for mv88e6xxx.
A proposal for the corresponding iproute2 interface is available here:
https://github.com/wkz/iproute2/tree/mst
Tobias Waldekranz (10):
net: bridge: mst: Multiple Spanning Tree (MST) mode
net: bridge: mst: Allow changing a VLAN's MSTI
net: bridge: mst: Support setting and reporting MST port states
net: bridge: mst: Notify switchdev drivers of VLAN MSTI migrations
net: bridge: mst: Notify switchdev drivers of MST state changes
net: dsa: Pass VLAN MSTI migration notifications to driver
net: dsa: Pass MST state changes to driver
net: dsa: mv88e6xxx: Disentangle STU from VTU
net: dsa: mv88e6xxx: Export STU as devlink region
net: dsa: mv88e6xxx: MST Offloading
drivers/net/dsa/mv88e6xxx/chip.c | 232 ++++++++++++++ drivers/net/dsa/mv88e6xxx/chip.h | 38 +++ drivers/net/dsa/mv88e6xxx/devlink.c | 94 ++++++ drivers/net/dsa/mv88e6xxx/global1.h | 10 + drivers/net/dsa/mv88e6xxx/global1_vtu.c | 311 ++++++++++-------- include/net/dsa.h | 5 + include/net/switchdev.h | 17 + include/uapi/linux/if_bridge.h | 17 + include/uapi/linux/if_link.h | 1 + include/uapi/linux/rtnetlink.h | 5 + net/bridge/Makefile | 2 +- net/bridge/br_input.c | 17 +- net/bridge/br_mst.c | 402 ++++++++++++++++++++++++ net/bridge/br_netlink.c | 17 +- net/bridge/br_private.h | 31 ++ net/bridge/br_stp.c | 3 + net/bridge/br_switchdev.c | 57 ++++ net/bridge/br_vlan.c | 20 +- net/bridge/br_vlan_options.c | 24 +- net/dsa/dsa_priv.h | 3 + net/dsa/port.c | 40 +++ net/dsa/slave.c | 12 + 22 files changed, 1216 insertions(+), 142 deletions(-) create mode 100644 net/bridge/br_mst.c
Signature · 1 line
2.25.1
PATCH v2 1/10 net: bridge: mst: Multiple Spanning Tree (MST) mode
Allow the user to switch from the current per-VLAN STP mode to an MST mode.
Up to this point, per-VLAN STP states where always isolated from each other. This is in contrast to the MSTP standard (802.1Q-2018, Clause 13.5), where VLANs are grouped into MST instances (MSTIs), and the state is managed on a per-MSTI level, rather that at the per-VLAN level.
Perhaps due to the prevalence of the standard, many switching ASICs are built after the same model. Therefore, add a corresponding MST mode to the bridge, which we can later add offloading support for in a straight-forward way.
For now, all VLANs are fixed to MSTI 0, also called the Common Spanning Tree (CST). That is, all VLANs will follow the port-global state.
Upcoming changes will make this actually useful by allowing VLANs to be mapped to arbitrary MSTIs and allow individual MSTI states to be changed.
--- include/uapi/linux/if_link.h | 1 + net/bridge/Makefile | 2 +- net/bridge/br_input.c | 17 +++++++- net/bridge/br_mst.c | 83 ++++++++++++++++++++++++++++++++++++ net/bridge/br_netlink.c | 14 +++++- net/bridge/br_private.h | 26 +++++++++++ net/bridge/br_stp.c | 3 ++ net/bridge/br_vlan.c | 20 ++++++++- net/bridge/br_vlan_options.c | 5 +++ 9 files changed, 166 insertions(+), 5 deletions(-) create mode 100644 net/bridge/br_mst.c
include/uapi/linux/if_link.h +1 -0
@@ -482,6 +482,7 @@ enum {IFLA_BR_VLAN_STATS_PER_PORT ,IFLA_BR_MULTI_BOOLOPT ,IFLA_BR_MCAST_QUERIER_STATE , +IFLA_BR_MST_ENABLED , __IFLA_BR_MAX, };
net/bridge/Makefile +1 -1
@@ -20,7 +20,7 @@ obj-$(CONFIG_BRIDGE_NETFILTER) += br_netfilter.o bridge-$(CONFIG_BRIDGE_IGMP_SNOOPING) += br_multicast.o br_mdb.o br_multicast_eht.o -bridge-$(CONFIG_BRIDGE_VLAN_FILTERING) += br_vlan.o br_vlan_tunnel.o br_vlan_options.o +bridge-$(CONFIG_BRIDGE_VLAN_FILTERING) += br_vlan.o br_vlan_tunnel.o br_vlan_options.o br_mst.o bridge-$(CONFIG_NET_SWITCHDEV) += br_switchdev.o
net/bridge/br_input.c +15 -2
@@ -78,13 +78,22 @@ int br_handle_frame_finish(struct net *net, struct sock *sk, struct sk_buff *skbu16 vid =0 ;u8 state; -if (!p || p->state ==BR_STATE_DISABLED ) +if (!p) goto drop; br = p->br; + +if (br_mst_is_enabled (br)) { + state =BR_STATE_FORWARDING ; + }else { +if (p->state ==BR_STATE_DISABLED ) + goto drop; + + state = p->state; + } + brmctx = &p->br->multicast_ctx; pmctx = &p->multicast_ctx; - state = p->state;if (!br_allowed_ingress (p->br,nbp_vlan_group_rcu (p), skb, &vid, &state, &vlan)) goto out;
@@ -370,9 +379,13 @@ static rx_handler_result_t br_handle_frame(struct sk_buff **pskb)return RX_HANDLER_PASS ; forward: +if (br_mst_is_enabled (p->br)) + goto defer_stp_filtering; +switch (p->state) {case BR_STATE_FORWARDING :case BR_STATE_LEARNING : +defer_stp_filtering:if (ether_addr_equal (p->br->dev->dev_addr, dest)) skb->pkt_type =PACKET_HOST ;
net/bridge/br_mst.c new file +83 -0
83 lines not on this page · raw message
net/bridge/br_netlink.c +13 -1
@@ -1163,6 +1163,7 @@ static const struct nla_policy br_policy[IFLA_BR_MAX + 1] = { [IFLA_BR_MCAST_IGMP_VERSION] = { .type = NLA_U8 }, [IFLA_BR_MCAST_MLD_VERSION] = { .type = NLA_U8 }, [IFLA_BR_VLAN_STATS_PER_PORT] = { .type = NLA_U8 }, + [IFLA_BR_MST_ENABLED] = { .type = NLA_U8 }, [IFLA_BR_MULTI_BOOLOPT ] = NLA_POLICY_EXACT_LEN(sizeof(struct br_boolopt_multi)), };
@@ -1255,6 +1256,14 @@ static int br_changelink(struct net_device *brdev, struct nlattr *tb[],if (err) return err; } + +if (data[IFLA_BR_MST_ENABLED ]) { +__u8 mst =nla_get_u8 (data[IFLA_BR_MST_ENABLED ]); + + err =br_mst_set_enabled (br, mst); +if (err) +return err; + }#endif if (data[IFLA_BR_GROUP_FWD_MASK ]) {
@@ -1475,6 +1484,7 @@ static size_t br_get_size(const struct net_device *brdev)nla_total_size (sizeof (u16)) +/* IFLA_BR_VLAN_DEFAULT_PVID */ nla_total_size (sizeof (u8)) +/* IFLA_BR_VLAN_STATS_ENABLED */ nla_total_size (sizeof (u8)) +/* IFLA_BR_VLAN_STATS_PER_PORT */ +nla_total_size (sizeof (u8)) +/* IFLA_BR_MST_ENABLED */ #endifnla_total_size (sizeof (u16)) +/* IFLA_BR_GROUP_FWD_MASK */ nla_total_size(sizeof(struct ifla_bridge_id)) + /* IFLA_BR_ROOT_ID */
@@ -1572,7 +1582,9 @@ static int br_fill_info(struct sk_buff *skb, const struct net_device *brdev)nla_put_u8 (skb,IFLA_BR_VLAN_STATS_ENABLED ,br_opt_get (br,BROPT_VLAN_STATS_ENABLED )) ||nla_put_u8 (skb,IFLA_BR_VLAN_STATS_PER_PORT , - br_opt_get(br, BROPT_VLAN_STATS_PER_PORT))) +br_opt_get (br,BROPT_VLAN_STATS_PER_PORT )) || +nla_put_u8 (skb,IFLA_BR_MST_ENABLED , + br_opt_get(br, BROPT_MST_ENABLED))) return -EMSGSIZE;#endif #ifdef CONFIG_BRIDGE_IGMP_SNOOPING
net/bridge/br_private.h +26 -0
@@ -178,6 +178,7 @@ enum {* @br_mcast_ctx: if MASTER flag set, this is the global vlan multicast context * @port_mcast_ctx: if MASTER flag unset, this is the per-port/vlan multicast * context +* @msti: if MASTER flag set, this holds the VLANs MST instance * @vlist: sorted list of VLAN entries * @rcu: used for entry destruction *
@@ -210,6 +211,8 @@ struct net_bridge_vlan {struct net_bridge_mcast_port port_mcast_ctx; }; +u16 msti; +struct list_head vlist;struct rcu_head rcu;
@@ -445,6 +448,7 @@ enum net_bridge_opts {BROPT_NO_LL_LEARN ,BROPT_VLAN_BRIDGE_BINDING ,BROPT_MCAST_VLAN_SNOOPING_ENABLED , + BROPT_MST_ENABLED, }; struct net_bridge {
@@ -1765,6 +1769,28 @@ static inline bool br_vlan_state_allowed(u8 state, bool learn_allow) }#endif +/* br_mst.c */ +#ifdef CONFIG_BRIDGE_VLAN_FILTERING +DECLARE_STATIC_KEY_FALSE (br_mst_used); +static inline bool br_mst_is_enabled (struct net_bridge *br) +{ +return static_branch_unlikely (&br_mst_used) && +br_opt_get (br,BROPT_MST_ENABLED ); +} + +void br_mst_set_state (struct net_bridge_port *p,u16 msti,u8 state); +void br_mst_vlan_init_state (struct net_bridge_vlan *v); +int br_mst_set_enabled (struct net_bridge *br,unsigned long val); +#else +static inline bool br_mst_is_enabled (struct net_bridge *br) +{ +return false; +} + +static inline void br_mst_set_state (struct net_bridge_port *p, +u16 msti,u8 state) {} +#endif +struct nf_br_ops {int (*br_dev_xmit_hook)(struct sk_buff *skb); };
net/bridge/br_stp.c +3 -0
@@ -43,6 +43,9 @@ void br_set_state(struct net_bridge_port *p, unsigned int state)return ; p->state = state; +if (br_opt_get (p->br,BROPT_MST_ENABLED )) +br_mst_set_state (p,0 , state); + err =switchdev_port_attr_set (p->dev, &attr,NULL );if (err && err != -EOPNOTSUPP ) br_warn(p->br, "error setting offload STP state on port %u(%s)\n",
net/bridge/br_vlan.c +19 -1
@@ -226,6 +226,24 @@ static void nbp_vlan_rcu_free(struct rcu_head *rcu)kfree (v); } +static void br_vlan_init_state (struct net_bridge_vlan *v) +{ +struct net_bridge *br; + +if (br_vlan_is_master (v)) + br = v->br; +else + br = v->port->br; + +if (br_opt_get (br,BROPT_MST_ENABLED )) { +br_mst_vlan_init_state (v); +return ; + } + + v->state =BR_STATE_FORWARDING ; + v->msti =0 ; +} +/* This is the shared VLAN add function which works for both ports and bridge * devices. There are four possible calls to this function in terms of the * vlan entry type:
@@ -322,7 +340,7 @@ static int __vlan_add(struct net_bridge_vlan *v, u16 flags, }/* set the state before publishing */ - v->state =BR_STATE_FORWARDING ; +br_vlan_init_state (v); err =rhashtable_lookup_insert_fast (&vg->vlan_hash, &v->vnode, br_vlan_rht_params);
net/bridge/br_vlan_options.c +5 -0
@@ -99,6 +99,11 @@ static int br_vlan_modify_state(struct net_bridge_vlan_group *vg,return -EBUSY ; } +if (br_opt_get (br,BROPT_MST_ENABLED )) { +NL_SET_ERR_MSG_MOD (extack,"Can't modify vlan state directly when MST is enabled" ); +return -EBUSY ; + } +if (v->state == state)return 0 ;
Signature · 1 line
2.25.1
Nikolay Aleksandrov
maintainerRe: [PATCH v2 net-next 01/10] net: bridge: mst: Multiple Spanning Tree (MST) mode
Quoted 34 lines · Tobias Waldekranz
Allow the user to switch from the current per-VLAN STP mode to an MST mode.
Up to this point, per-VLAN STP states where always isolated from each other. This is in contrast to the MSTP standard (802.1Q-2018, Clause 13.5), where VLANs are grouped into MST instances (MSTIs), and the state is managed on a per-MSTI level, rather that at the per-VLAN level.
Perhaps due to the prevalence of the standard, many switching ASICs are built after the same model. Therefore, add a corresponding MST mode to the bridge, which we can later add offloading support for in a straight-forward way.
For now, all VLANs are fixed to MSTI 0, also called the Common Spanning Tree (CST). That is, all VLANs will follow the port-global state.
Upcoming changes will make this actually useful by allowing VLANs to be mapped to arbitrary MSTIs and allow individual MSTI states to be changed.
Signed-off-by Tobias Waldekranz <[email protected]>---
include/uapi/linux/if_link.h | 1 + net/bridge/Makefile | 2 +- net/bridge/br_input.c | 17 +++++++- net/bridge/br_mst.c | 83 ++++++++++++++++++++++++++++++++++++ net/bridge/br_netlink.c | 14 +++++- net/bridge/br_private.h | 26 +++++++++++ net/bridge/br_stp.c | 3 ++ net/bridge/br_vlan.c | 20 ++++++++- net/bridge/br_vlan_options.c | 5 +++ 9 files changed, 166 insertions(+), 5 deletions(-)
Quoted 2 lines
create mode 100644
net/bridge/br_mst.c
Hi,
As I mentioned in another review, I'm currently traveling and will have pc access end of this week (Sun), I'll try to review the set as much as I can through my phone in the meantime. Thanks for reworking it, generally looks good.
A few comments below,
include/uapi/linux/if_link.h enum { · line 485
Quoted 9 lines
include/uapi/linux/if_link.h +1
-0@@ -482,6 +482,7 @@ enum {IFLA_BR_VLAN_STATS_PER_PORT ,IFLA_BR_MULTI_BOOLOPT ,IFLA_BR_MCAST_QUERIER_STATE , + IFLA_BR_MST_ENABLED,
Please use the boolopt api for new bridge boolean options like this one.
Quoted 320 lines
include/uapi/linux/if_link.h +0
-0__IFLA_BR_MAX, };net/bridge/Makefile +0
-0@@ -20,7 +20,7 @@ obj-$(CONFIG_BRIDGE_NETFILTER) += br_netfilter.obridge-$(CONFIG_BRIDGE_IGMP_SNOOPING) += br_multicast.o br_mdb.o br_multicast_eht.o
net/bridge/Makefile +1
-1-bridge-$(CONFIG_BRIDGE_VLAN_FILTERING) += br_vlan.o br_vlan_tunnel.o br_vlan_options.o +bridge-$(CONFIG_BRIDGE_VLAN_FILTERING) += br_vlan.o br_vlan_tunnel.o br_vlan_options.o br_mst.obridge-$(CONFIG_NET_SWITCHDEV) += br_switchdev.o
net/bridge/br_input.c +11
-2@@ -78,13 +78,22 @@ int br_handle_frame_finish(struct net *net, struct sock *sk, struct sk_buff *skbu16 vid =0 ;u8 state; -if (!p || p->state ==BR_STATE_DISABLED ) +if (!p) goto drop; br = p->br; + +if (br_mst_is_enabled (br)) { + state =BR_STATE_FORWARDING ; + }else { +if (p->state ==BR_STATE_DISABLED ) + goto drop; + + state = p->state; + } + brmctx = &p->br->multicast_ctx; pmctx = &p->multicast_ctx; - state = p->state;if (!br_allowed_ingress (p->br,nbp_vlan_group_rcu (p), skb, &vid, &state, &vlan)) goto out;@@ -370,9 +379,13 @@ static rx_handler_result_t br_handle_frame(struct sk_buff **pskb)return RX_HANDLER_PASS ;forward:
net/bridge/br_input.c +3
-0+if (br_mst_is_enabled (p->br)) + goto defer_stp_filtering; +switch (p->state) { case BR_STATE_FORWARDING: case BR_STATE_LEARNING: +defer_stp_filtering: if (ether_addr_equal(p->br->dev->dev_addr, dest)) skb->pkt_type = PACKET_HOST;net/bridge/br_mst.c new file +83
-0@@ -0,0 +1,83 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* +* Bridge Multiple Spanning Tree Support +* +* Authors: +* Tobias Waldekranz <[email protected]> +*/ + +#include <linux/kernel.h> + +#include "br_private.h" + +DEFINE_STATIC_KEY_FALSE (br_mst_used); + +void br_mst_vlan_set_state (struct net_bridge_port *p,struct net_bridge_vlan *v, +u8 state) +{ +struct net_bridge_vlan_group *vg =nbp_vlan_group (p); + +if (v->state == state) +return ; + +br_vlan_set_state (v, state); + +if (v->vid == vg->pvid) +br_vlan_set_pvid_state (vg, state); +} + +void br_mst_set_state (struct net_bridge_port *p,u16 msti,u8 state) +{ +struct net_bridge_vlan_group *vg; +struct net_bridge_vlan *v; + + vg =nbp_vlan_group (p); +if (!vg) +return ; + +list_for_each_entry (v, &vg->vlan_list, vlist) { +if (v->brvlan->msti != msti) +continue ; + +br_mst_vlan_set_state (p, v, state); + } +} + +void br_mst_vlan_init_state (struct net_bridge_vlan *v) +{ +/* VLANs always start out in MSTI 0 (CST) */ + v->msti =0 ; + +if (br_vlan_is_master (v)) + v->state =BR_STATE_FORWARDING ; +else + v->state = v->port->state; +} + +int br_mst_set_enabled (struct net_bridge *br,unsigned long val) +{ +struct net_bridge_vlan_group *vg; +struct net_bridge_port *p; + +/* Mode may only be changed when there are no port VLANs. */ +list_for_each_entry (p, &br->port_list, list) { + vg =nbp_vlan_group (p); + +if (vg->num_vlans) +return -EBUSY ; + } + +if (val >1 ) +return -EINVAL ; + +if (!!val ==br_opt_get (br,BROPT_MST_ENABLED )) +return 0 ; + +if (val) +static_branch_enable (&br_mst_used); +else +static_branch_disable (&br_mst_used); + +br_opt_toggle (br,BROPT_MST_ENABLED , !!val); +return 0 ; +}net/bridge/br_netlink.c +13
-1@@ -1163,6 +1163,7 @@ static const struct nla_policy br_policy[IFLA_BR_MAX + 1] = { [IFLA_BR_MCAST_IGMP_VERSION] = { .type = NLA_U8 }, [IFLA_BR_MCAST_MLD_VERSION] = { .type = NLA_U8 }, [IFLA_BR_VLAN_STATS_PER_PORT] = { .type = NLA_U8 }, + [IFLA_BR_MST_ENABLED] = { .type = NLA_U8 }, [IFLA_BR_MULTI_BOOLOPT ] = NLA_POLICY_EXACT_LEN(sizeof(struct br_boolopt_multi)), };@@ -1255,6 +1256,14 @@ static int br_changelink(struct net_device *brdev, struct nlattr *tb[],if (err) return err; } + +if (data[IFLA_BR_MST_ENABLED ]) { +__u8 mst =nla_get_u8 (data[IFLA_BR_MST_ENABLED ]); + + err =br_mst_set_enabled (br, mst); +if (err) +return err; + }#endif if (data[IFLA_BR_GROUP_FWD_MASK ]) {@@ -1475,6 +1484,7 @@ static size_t br_get_size(const struct net_device *brdev)nla_total_size (sizeof (u16)) +/* IFLA_BR_VLAN_DEFAULT_PVID */ nla_total_size (sizeof (u8)) +/* IFLA_BR_VLAN_STATS_ENABLED */ nla_total_size (sizeof (u8)) +/* IFLA_BR_VLAN_STATS_PER_PORT */ +nla_total_size (sizeof (u8)) +/* IFLA_BR_MST_ENABLED */ #endifnla_total_size (sizeof (u16)) +/* IFLA_BR_GROUP_FWD_MASK */ nla_total_size(sizeof(struct ifla_bridge_id)) + /* IFLA_BR_ROOT_ID */@@ -1572,7 +1582,9 @@ static int br_fill_info(struct sk_buff *skb, const struct net_device *brdev)nla_put_u8 (skb,IFLA_BR_VLAN_STATS_ENABLED ,br_opt_get (br,BROPT_VLAN_STATS_ENABLED )) ||nla_put_u8 (skb,IFLA_BR_VLAN_STATS_PER_PORT , - br_opt_get(br, BROPT_VLAN_STATS_PER_PORT))) +br_opt_get (br,BROPT_VLAN_STATS_PER_PORT )) || +nla_put_u8 (skb,IFLA_BR_MST_ENABLED , + br_opt_get(br, BROPT_MST_ENABLED))) return -EMSGSIZE;#endif #ifdef CONFIG_BRIDGE_IGMP_SNOOPING net/bridge/br_private.h +26
-0@@ -178,6 +178,7 @@ enum {* @br_mcast_ctx: if MASTER flag set, this is the global vlan multicast context * @port_mcast_ctx: if MASTER flag unset, this is the per-port/vlan multicast * context +* @msti: if MASTER flag set, this holds the VLANs MST instance * @vlist: sorted list of VLAN entries * @rcu: used for entry destruction * @@ -210,6 +211,8 @@ struct net_bridge_vlan {struct net_bridge_mcast_port port_mcast_ctx; }; +u16 msti; +struct list_head vlist;struct rcu_head rcu;@@ -445,6 +448,7 @@ enum net_bridge_opts {BROPT_NO_LL_LEARN ,BROPT_VLAN_BRIDGE_BINDING ,BROPT_MCAST_VLAN_SNOOPING_ENABLED , + BROPT_MST_ENABLED, }; struct net_bridge {@@ -1765,6 +1769,28 @@ static inline bool br_vlan_state_allowed(u8 state, bool learn_allow) }#endif +/* br_mst.c */ +#ifdef CONFIG_BRIDGE_VLAN_FILTERING +DECLARE_STATIC_KEY_FALSE (br_mst_used); +static inline bool br_mst_is_enabled (struct net_bridge *br) +{ +return static_branch_unlikely (&br_mst_used) && +br_opt_get (br,BROPT_MST_ENABLED ); +} + +void br_mst_set_state (struct net_bridge_port *p,u16 msti,u8 state); +void br_mst_vlan_init_state (struct net_bridge_vlan *v); +int br_mst_set_enabled (struct net_bridge *br,unsigned long val); +#else +static inline bool br_mst_is_enabled (struct net_bridge *br) +{ +return false; +} + +static inline void br_mst_set_state (struct net_bridge_port *p, +u16 msti,u8 state) {} +#endif +struct nf_br_ops {int (*br_dev_xmit_hook)(struct sk_buff *skb); };net/bridge/br_stp.c +3
-0@@ -43,6 +43,9 @@ void br_set_state(struct net_bridge_port *p, unsigned int state)return ; p->state = state; +if (br_opt_get (p->br,BROPT_MST_ENABLED )) +br_mst_set_state (p,0 , state); + err =switchdev_port_attr_set (p->dev, &attr,NULL );if (err && err != -EOPNOTSUPP ) br_warn(p->br, "error setting offload STP state on port %u(%s)\n",net/bridge/br_vlan.c +19
-1@@ -226,6 +226,24 @@ static void nbp_vlan_rcu_free(struct rcu_head *rcu)kfree (v); } +static void br_vlan_init_state (struct net_bridge_vlan *v) +{ +struct net_bridge *br; + +if (br_vlan_is_master (v)) + br = v->br; +else + br = v->port->br; + +if (br_opt_get (br,BROPT_MST_ENABLED )) { +br_mst_vlan_init_state (v); +return ; + } + + v->state =BR_STATE_FORWARDING ; + v->msti =0 ; +} +/* This is the shared VLAN add function which works for both ports and bridge * devices. There are four possible calls to this function in terms of the * vlan entry type: @@ -322,7 +340,7 @@ static int __vlan_add(struct net_bridge_vlan *v, u16 flags, }/* set the state before publishing */ - v->state =BR_STATE_FORWARDING ; +br_vlan_init_state (v); err =rhashtable_lookup_insert_fast (&vg->vlan_hash, &v->vnode, br_vlan_rht_params);net/bridge/br_vlan_options.c +5
-0@@ -99,6 +99,11 @@ static int br_vlan_modify_state(struct net_bridge_vlan_group *vg,return -EBUSY ; } +if (br_opt_get (br,BROPT_MST_ENABLED )) { +NL_SET_ERR_MSG_MOD (extack,"Can't modify vlan state directly when MST is enabled" ); +return -EBUSY ; + } +if (v->state == state)return 0 ;
Re: [PATCH v2 net-next 01/10] net: bridge: mst: Multiple Spanning Tree (MST) mode
Quoted 45 lines · Nikolay Aleksandrov
Quoted 34 lines · Tobias Waldekranz
Allow the user to switch from the current per-VLAN STP mode to an MST mode.
Up to this point, per-VLAN STP states where always isolated from each other. This is in contrast to the MSTP standard (802.1Q-2018, Clause 13.5), where VLANs are grouped into MST instances (MSTIs), and the state is managed on a per-MSTI level, rather that at the per-VLAN level.
Perhaps due to the prevalence of the standard, many switching ASICs are built after the same model. Therefore, add a corresponding MST mode to the bridge, which we can later add offloading support for in a straight-forward way.
For now, all VLANs are fixed to MSTI 0, also called the Common Spanning Tree (CST). That is, all VLANs will follow the port-global state.
Upcoming changes will make this actually useful by allowing VLANs to be mapped to arbitrary MSTIs and allow individual MSTI states to be changed.
Signed-off-by Tobias Waldekranz <[email protected]>---
include/uapi/linux/if_link.h | 1 + net/bridge/Makefile | 2 +- net/bridge/br_input.c | 17 +++++++- net/bridge/br_mst.c | 83 ++++++++++++++++++++++++++++++++++++ net/bridge/br_netlink.c | 14 +++++- net/bridge/br_private.h | 26 +++++++++++ net/bridge/br_stp.c | 3 ++ net/bridge/br_vlan.c | 20 ++++++++- net/bridge/br_vlan_options.c | 5 +++ 9 files changed, 166 insertions(+), 5 deletions(-)Quoted 2 lines
create mode 100644
net/bridge/br_mst.cHi,
As I mentioned in another review, I'm currently traveling and will have pc access end of this week (Sun), I'll try to review the set as much as I can through my phone in the meantime. Thanks for reworking it, generally looks good.
A few comments below,
Quoted 11 lines
include/uapi/linux/if_link.h enum { · line 485
Quoted 9 lines
include/uapi/linux/if_link.h +1
-0@@ -482,6 +482,7 @@ enum {IFLA_BR_VLAN_STATS_PER_PORT ,IFLA_BR_MULTI_BOOLOPT ,IFLA_BR_MCAST_QUERIER_STATE , + IFLA_BR_MST_ENABLED,Please use the boolopt api for new bridge boolean options like this one.
Ahh, I was not aware of that. Will change it in v3. Thanks.
Vladimir Oltean
maintainerRe: [PATCH v2 net-next 01/10] net: bridge: mst: Multiple Spanning Tree (MST) mode
In reply to Tobias WaldekranzQuoted 24 lines · Tobias Waldekranz
Allow the user to switch from the current per-VLAN STP mode to an MST mode.
Up to this point, per-VLAN STP states where always isolated from each other. This is in contrast to the MSTP standard (802.1Q-2018, Clause 13.5), where VLANs are grouped into MST instances (MSTIs), and the state is managed on a per-MSTI level, rather that at the per-VLAN level.
Perhaps due to the prevalence of the standard, many switching ASICs are built after the same model. Therefore, add a corresponding MST mode to the bridge, which we can later add offloading support for in a straight-forward way.
For now, all VLANs are fixed to MSTI 0, also called the Common Spanning Tree (CST). That is, all VLANs will follow the port-global state.
Upcoming changes will make this actually useful by allowing VLANs to be mapped to arbitrary MSTIs and allow individual MSTI states to be changed.
Signed-off-by Tobias Waldekranz <[email protected]>---
net/bridge/br_mst.c line 16
Quoted 2 lines
net/bridge/br_mst.c new file +2
-0+void br_mst_vlan_set_state (struct net_bridge_port *p,struct net_bridge_vlan *v, +u8 state)
Function can be static.
Quoted 11 lines
net/bridge/br_mst.c new file +11
-0+{ +struct net_bridge_vlan_group *vg =nbp_vlan_group (p); + +if (v->state == state) +return ; + +br_vlan_set_state (v, state); + +if (v->vid == vg->pvid) +br_vlan_set_pvid_state (vg, state); +}
PATCH v2 2/10 net: bridge: mst: Allow changing a VLAN's MSTI
In reply to Tobias WaldekranzAllow a VLAN to move out of the CST (MSTI 0), to an independent tree.
The user manages the VID to MSTI mappings via a global VLAN setting. The proposed iproute2 interface would be:
bridge vlan global set dev br0 vid <VID> msti <MSTI>
Changing the state in non-zero MSTIs is still not supported, but will be addressed in upcoming changes.
--- include/uapi/linux/if_bridge.h | 1 + net/bridge/br_mst.c | 39 ++++++++++++++++++++++++++++++++++ net/bridge/br_private.h | 1 + net/bridge/br_vlan_options.c | 19 +++++++++++++++-- 4 files changed, 58 insertions(+), 2 deletions(-)
include/uapi/linux/if_bridge.h +1 -0
@@ -564,6 +564,7 @@ enum {BRIDGE_VLANDB_GOPTS_MCAST_QUERIER ,BRIDGE_VLANDB_GOPTS_MCAST_ROUTER_PORTS ,BRIDGE_VLANDB_GOPTS_MCAST_QUERIER_STATE , +BRIDGE_VLANDB_GOPTS_MSTI , __BRIDGE_VLANDB_GOPTS_MAX };#define BRIDGE_VLANDB_GOPTS_MAX (__BRIDGE_VLANDB_GOPTS_MAX - 1)
net/bridge/br_mst.c +39 -0
@@ -43,6 +43,45 @@ void br_mst_set_state(struct net_bridge_port *p, u16 msti, u8 state) } } +static void br_mst_vlan_sync_state (struct net_bridge_vlan *pv,u16 msti) +{ +struct net_bridge_vlan_group *vg =nbp_vlan_group (pv->port); +struct net_bridge_vlan *v; + +list_for_each_entry (v, &vg->vlan_list, vlist) { +/* If this port already has a defined state in this +* MSTI (through some other VLAN membership), inherit +* it. +*/ +if (v != pv && v->brvlan->msti == msti) { +br_mst_vlan_set_state (pv->port, pv, v->state); +return ; + } + } + +/* Otherwise, start out in a new MSTI with all ports disabled. */ +return br_mst_vlan_set_state (pv->port, pv,BR_STATE_DISABLED ); +} + +int br_mst_vlan_set_msti (struct net_bridge_vlan *mv,u16 msti) +{ +struct net_bridge_vlan_group *vg; +struct net_bridge_vlan *pv; +struct net_bridge_port *p; + + mv->msti = msti; + +list_for_each_entry (p, &mv->br->port_list, list) { + vg =nbp_vlan_group (p); + + pv =br_vlan_find (vg, mv->vid); +if (pv) +br_mst_vlan_sync_state (pv, msti); + } + +return 0 ; +} +void br_mst_vlan_init_state (struct net_bridge_vlan *v) {/* VLANs always start out in MSTI 0 (CST) */
net/bridge/br_private.h +1 -0
@@ -1779,6 +1779,7 @@ static inline bool br_mst_is_enabled(struct net_bridge *br) }void br_mst_set_state (struct net_bridge_port *p,u16 msti,u8 state); +int br_mst_vlan_set_msti (struct net_bridge_vlan *v,u16 msti);void br_mst_vlan_init_state (struct net_bridge_vlan *v);int br_mst_set_enabled (struct net_bridge *br,unsigned long val);#else
net/bridge/br_vlan_options.c +17 -2
@@ -44,8 +44,8 @@ bool br_vlan_opts_eq_range(const struct net_bridge_vlan *v_curr,u8 curr_mc_rtr =br_vlan_multicast_router (v_curr);return v_curr->state == range_end->state && -__vlan_tun_can_enter_range (v_curr, range_end) && - curr_mc_rtr == range_mc_rtr; +__vlan_tun_can_enter_range (v_curr, range_end) && + curr_mc_rtr == range_mc_rtr; }bool br_vlan_opts_fill (struct sk_buff *skb,const struct net_bridge_vlan *v)
@@ -296,6 +296,7 @@ bool br_vlan_global_opts_can_enter_range(const struct net_bridge_vlan *v_curr, const struct net_bridge_vlan *r_end) {return v_curr->vid - r_end->vid ==1 && + v_curr->msti == r_end->msti && ((v_curr->priv_flags ^ r_end->priv_flags) &BR_VLFLAG_GLOBAL_MCAST_ENABLED ) ==0 && br_multicast_ctx_options_equal(&v_curr->br_mcast_ctx,
@@ -384,6 +385,9 @@ bool br_vlan_global_opts_fill(struct sk_buff *skb, u16 vid, u16 vid_range,#endif #endif +if (nla_put_u16 (skb,BRIDGE_VLANDB_GOPTS_MSTI , v_opts->msti)) + goto out_err; +nla_nest_end (skb, nest);return true;
@@ -415,6 +419,7 @@ static size_t rtnl_vlan_global_opts_nlmsg_size(const struct net_bridge_vlan *v) +nla_total_size (0 )/* BRIDGE_VLANDB_GOPTS_MCAST_ROUTER_PORTS */ + br_rports_size(&v->br_mcast_ctx) /* BRIDGE_VLANDB_GOPTS_MCAST_ROUTER_PORTS */#endif + +nla_total_size (sizeof (u16))/* BRIDGE_VLANDB_GOPTS_MSTI */ +nla_total_size (sizeof (u16));/* BRIDGE_VLANDB_GOPTS_RANGE */ }
@@ -564,6 +569,15 @@ static int br_vlan_process_global_one_opts(const struct net_bridge *br, }#endif #endif +if (tb[BRIDGE_VLANDB_GOPTS_MSTI ]) { +u16 msti; + + msti =nla_get_u16 (tb[BRIDGE_VLANDB_GOPTS_MSTI ]); + err =br_mst_vlan_set_msti (v, msti); +if (err) +return err; + *changed = true; + }return 0 ; }
@@ -583,6 +597,7 @@ static const struct nla_policy br_vlan_db_gpol[BRIDGE_VLANDB_GOPTS_MAX + 1] = { [BRIDGE_VLANDB_GOPTS_MCAST_QUERIER_INTVL] = { .type = NLA_U64 }, [BRIDGE_VLANDB_GOPTS_MCAST_STARTUP_QUERY_INTVL] = { .type = NLA_U64 }, [BRIDGE_VLANDB_GOPTS_MCAST_QUERY_RESPONSE_INTVL] = { .type = NLA_U64 }, + [BRIDGE_VLANDB_GOPTS_MSTI] = NLA_POLICY_MAX(NLA_U16, VLAN_N_VID - 1), }; int br_vlan_rtm_process_global_options(struct net_device *dev,
Signature · 1 line
2.25.1
Vladimir Oltean
maintainerRe: [PATCH v2 net-next 02/10] net: bridge: mst: Allow changing a VLAN's MSTI
Quoted 28 lines · Tobias Waldekranz
Allow a VLAN to move out of the CST (MSTI 0), to an independent tree.
The user manages the VID to MSTI mappings via a global VLAN setting. The proposed iproute2 interface would be:
bridge vlan global set dev br0 vid <VID> msti <MSTI>
Changing the state in non-zero MSTIs is still not supported, but will be addressed in upcoming changes.
Signed-off-by Tobias Waldekranz <[email protected]>---
net/bridge/br_mst.c +15
-0+static void br_mst_vlan_sync_state (struct net_bridge_vlan *pv,u16 msti) +{ +struct net_bridge_vlan_group *vg =nbp_vlan_group (pv->port); +struct net_bridge_vlan *v; + +list_for_each_entry (v, &vg->vlan_list, vlist) { +/* If this port already has a defined state in this +* MSTI (through some other VLAN membership), inherit +* it. +*/ +if (v != pv && v->brvlan->msti == msti) { +br_mst_vlan_set_state (pv->port, pv, v->state); +return ; + } + }
net/bridge/br_mst.c void br_mst_set_state(struct net_bridge_port *p, u16 msti, u8 state) · line 70
Quoted 10 lines
net/bridge/br_mst.c +10
-0+ +/* Otherwise, start out in a new MSTI with all ports disabled. */ +return br_mst_vlan_set_state (pv->port, pv,BR_STATE_DISABLED ); +} + +int br_mst_vlan_set_msti (struct net_bridge_vlan *mv,u16 msti) +{ +struct net_bridge_vlan_group *vg; +struct net_bridge_vlan *pv; +struct net_bridge_port *p;
No attempt to detect non-changes to the MSTI, and exit early? In a later patch you will also notify switchdev uselessly because of this.
Quoted 13 lines
net/bridge/br_mst.c +13
-0+ + mv->msti = msti; + +list_for_each_entry (p, &mv->br->port_list, list) { + vg =nbp_vlan_group (p); + + pv =br_vlan_find (vg, mv->vid); +if (pv) +br_mst_vlan_sync_state (pv, msti); + } + +return 0 ; +}
Re: [PATCH v2 net-next 02/10] net: bridge: mst: Allow changing a VLAN's MSTI
Quoted 34 lines · Vladimir Oltean
Quoted 33 lines · Tobias Waldekranz
Allow a VLAN to move out of the CST (MSTI 0), to an independent tree.
The user manages the VID to MSTI mappings via a global VLAN setting. The proposed iproute2 interface would be:
bridge vlan global set dev br0 vid <VID> msti <MSTI>
Changing the state in non-zero MSTIs is still not supported, but will be addressed in upcoming changes.
Signed-off-by Tobias Waldekranz <[email protected]>---
net/bridge/br_mst.c +20
-0+static void br_mst_vlan_sync_state (struct net_bridge_vlan *pv,u16 msti) +{ +struct net_bridge_vlan_group *vg =nbp_vlan_group (pv->port); +struct net_bridge_vlan *v; + +list_for_each_entry (v, &vg->vlan_list, vlist) { +/* If this port already has a defined state in this +* MSTI (through some other VLAN membership), inherit +* it. +*/ +if (v != pv && v->brvlan->msti == msti) { +br_mst_vlan_set_state (pv->port, pv, v->state); +return ; + } + } + +/* Otherwise, start out in a new MSTI with all ports disabled. */ +return br_mst_vlan_set_state (pv->port, pv,BR_STATE_DISABLED ); +} +
Quoted 8 lines
net/bridge/br_mst.c void br_mst_set_state(struct net_bridge_port *p, u16 msti, u8 state) · line 70
Quoted 5 lines
net/bridge/br_mst.c +5
-0+int br_mst_vlan_set_msti (struct net_bridge_vlan *mv,u16 msti) +{ +struct net_bridge_vlan_group *vg; +struct net_bridge_vlan *pv; +struct net_bridge_port *p;No attempt to detect non-changes to the MSTI, and exit early? In a later patch you will also notify switchdev uselessly because of this.
Yeah you're right. Will fix in v3. Thanks
PATCH v2 3/10 net: bridge: mst: Support setting and reporting MST port states
In reply to Tobias WaldekranzMake it possible to change the port state in a given MSTI. This is done through a new netlink interface, since the MSTIs are objects in their own right. The proposed iproute2 interface would be:
bridge mst set dev <PORT> msti <MSTI> state <STATE>
Current states in all applicable MSTIs can also be dumped. The proposed iproute interface looks like this:
$ bridge mst port msti vb1 0 state forwarding 100 state disabled vb2 0 state forwarding 100 state forwarding
The preexisting per-VLAN states are still valid in the MST mode (although they are read-only), and can be queried as usual if one is interested in knowing a particular VLAN's state without having to care about the VID to MSTI mapping (in this example VLAN 20 and 30 are bound to MSTI 100):
$ bridge -d vlan port vlan-id vb1 10 state forwarding mcast_router 1 20 state disabled mcast_router 1 30 state disabled mcast_router 1 40 state forwarding mcast_router 1 vb2 10 state forwarding mcast_router 1 20 state forwarding mcast_router 1 30 state forwarding mcast_router 1 40 state forwarding mcast_router 1
--- include/uapi/linux/if_bridge.h | 16 +++ include/uapi/linux/rtnetlink.h | 5 + net/bridge/br_mst.c | 244 +++++++++++++++++++++++++++++++++ net/bridge/br_netlink.c | 3 + net/bridge/br_private.h | 4 + 5 files changed, 272 insertions(+)
include/uapi/linux/if_bridge.h +16 -0
@@ -785,4 +785,20 @@ enum {__BRIDGE_QUERIER_MAX };#define BRIDGE_QUERIER_MAX (__BRIDGE_QUERIER_MAX - 1) + +enum { +BRIDGE_MST_UNSPEC , +BRIDGE_MST_ENTRY , + __BRIDGE_MST_MAX, +}; +#define BRIDGE_MST_MAX (__BRIDGE_MST_MAX - 1) + +enum { +BRIDGE_MST_ENTRY_UNSPEC , +BRIDGE_MST_ENTRY_MSTI , +BRIDGE_MST_ENTRY_STATE , + __BRIDGE_MST_ENTRY_MAX, +}; +#define BRIDGE_MST_ENTRY_MAX (__BRIDGE_MST_ENTRY_MAX - 1) +#endif /* _UAPI_LINUX_IF_BRIDGE_H */
include/uapi/linux/rtnetlink.h +5 -0
@@ -192,6 +192,11 @@ enum { RTM_GETTUNNEL,#define RTM_GETTUNNEL RTM_GETTUNNEL + RTM_GETMST = 124 + 2, +#define RTM_GETMST RTM_GETMST + RTM_SETMST, +#define RTM_SETMST RTM_SETMST + __RTM_MAX,#define RTM_MAX (((__RTM_MAX + 3) & ~3) - 1) };
net/bridge/br_mst.c +244 -0
247 lines not on this page · raw message
net/bridge/br_netlink.c +3 -0
@@ -1813,6 +1813,7 @@ int __init br_netlink_init(void)br_mdb_init ();br_vlan_rtnl_init (); +br_mst_rtnl_init ();rtnl_af_register (&br_af_ops); err =rtnl_link_register (&br_link_ops);
@@ -1824,6 +1825,7 @@ int __init br_netlink_init(void) out_af:rtnl_af_unregister (&br_af_ops);br_mdb_uninit (); +br_mst_rtnl_uninit ();return err; }
@@ -1831,6 +1833,7 @@ void br_netlink_fini(void) {br_mdb_uninit ();br_vlan_rtnl_uninit (); +br_mst_rtnl_uninit ();rtnl_af_unregister (&br_af_ops);rtnl_link_unregister (&br_link_ops); }
net/bridge/br_private.h +4 -0
@@ -1782,6 +1782,8 @@ void br_mst_set_state(struct net_bridge_port *p, u16 msti, u8 state);int br_mst_vlan_set_msti (struct net_bridge_vlan *v,u16 msti);void br_mst_vlan_init_state (struct net_bridge_vlan *v);int br_mst_set_enabled (struct net_bridge *br,unsigned long val); +void br_mst_rtnl_init (void ); +void br_mst_rtnl_uninit (void );#else static inline bool br_mst_is_enabled (struct net_bridge *br) {
@@ -1790,6 +1792,8 @@ static inline bool br_mst_is_enabled(struct net_bridge *br)static inline void br_mst_set_state (struct net_bridge_port *p,u16 msti,u8 state) {} +static inline void br_mst_rtnl_init (void ) {} +static inline void br_mst_rtnl_uninit (void ) {}#endif struct nf_br_ops {
Signature · 1 line
2.25.1
Nikolay Aleksandrov
maintainerRe: [PATCH v2 net-next 03/10] net: bridge: mst: Support setting and reporting MST port states
Quoted 84 lines · Tobias Waldekranz
Make it possible to change the port state in a given MSTI. This is done through a new netlink interface, since the MSTIs are objects in their own right. The proposed iproute2 interface would be:
bridge mst set dev <PORT> msti <MSTI> state <STATE>
Current states in all applicable MSTIs can also be dumped. The proposed iproute interface looks like this:
$ bridge mst port msti vb1 0 state forwarding 100 state disabled vb2 0 state forwarding 100 state forwardingThe preexisting per-VLAN states are still valid in the MST mode (although they are read-only), and can be queried as usual if one is interested in knowing a particular VLAN's state without having to care about the VID to MSTI mapping (in this example VLAN 20 and 30 are bound to MSTI 100):
$ bridge -d vlan port vlan-id vb1 10 state forwarding mcast_router 1 20 state disabled mcast_router 1 30 state disabled mcast_router 1 40 state forwarding mcast_router 1 vb2 10 state forwarding mcast_router 1 20 state forwarding mcast_router 1 30 state forwarding mcast_router 1 40 state forwarding mcast_router 1Signed-off-by Tobias Waldekranz <[email protected]>---
include/uapi/linux/if_bridge.h | 16 +++ include/uapi/linux/rtnetlink.h | 5 + net/bridge/br_mst.c | 244 +++++++++++++++++++++++++++++++++ net/bridge/br_netlink.c | 3 + net/bridge/br_private.h | 4 + 5 files changed, 272 insertions(+)include/uapi/linux/if_bridge.h +16
-0@@ -785,4 +785,20 @@ enum {__BRIDGE_QUERIER_MAX };#define BRIDGE_QUERIER_MAX (__BRIDGE_QUERIER_MAX - 1) + +enum { +BRIDGE_MST_UNSPEC , +BRIDGE_MST_ENTRY , + __BRIDGE_MST_MAX, +}; +#define BRIDGE_MST_MAX (__BRIDGE_MST_MAX - 1) + +enum { +BRIDGE_MST_ENTRY_UNSPEC , +BRIDGE_MST_ENTRY_MSTI , +BRIDGE_MST_ENTRY_STATE , + __BRIDGE_MST_ENTRY_MAX, +}; +#define BRIDGE_MST_ENTRY_MAX (__BRIDGE_MST_ENTRY_MAX - 1) +#endif /* _UAPI_LINUX_IF_BRIDGE_H */ include/uapi/linux/rtnetlink.h +0
-0
include/uapi/linux/rtnetlink.h enum { · line 199
Quoted 8 lines
include/uapi/linux/rtnetlink.h +5
-0@@ -192,6 +192,11 @@ enum { RTM_GETTUNNEL,#define RTM_GETTUNNEL RTM_GETTUNNEL + RTM_GETMST = 124 + 2, +#define RTM_GETMST RTM_GETMST + RTM_SETMST, +#define RTM_SETMST RTM_SETMST +
I think you should also update selinux (see nlmsgtab.c)
I'll think about this one, if there is some nice way to avoid the new rtm types.
Quoted 13 lines
include/uapi/linux/rtnetlink.h +0
-0__RTM_MAX,#define RTM_MAX (((__RTM_MAX + 3) & ~3) - 1) };net/bridge/br_mst.c +2
-0@@ -120,3 +120,247 @@ int br_mst_set_enabled(struct net_bridge *br, unsigned long val)br_opt_toggle (br,BROPT_MST_ENABLED , !!val);return 0 ; } + +static int br_mst_nl_get_one(struct net_bridge_port *p, struct sk_buff *skb,
net/bridge/br_mst.c int br_mst_set_enabled(struct net_bridge *br, unsigned long val) · line 134
Quoted 10 lines
net/bridge/br_mst.c +10
-0+ struct netlink_callback *cb) +{ +struct net_bridge_vlan_group *vg =nbp_vlan_group (p); +int err =0 , idx =0 , s_idx = cb->args[1 ]; +struct net_bridge_vlan *v; +struct br_port_msg *bpm; +struct nlmsghdr *nlh; +struct nlattr *nest; +unsigned long *seen; +
Reverse xmas tree
Quoted 282 lines
net/bridge/br_mst.c +232
-0+ nlh =nlmsg_put (skb,NETLINK_CB (cb->skb).portid, cb->nlh->nlmsg_seq, +RTM_GETMST ,sizeof (*bpm),NLM_F_MULTI ); +if (!nlh) +return -EMSGSIZE ; + + bpm =nlmsg_data (nlh); +memset (bpm,0 ,sizeof (*bpm)); + bpm->ifindex = p->dev->ifindex; + + seen =bitmap_zalloc (VLAN_N_VID ,0 ); +if (!seen) +return -ENOMEM ; + +list_for_each_entry (v, &vg->vlan_list, vlist) { +if (test_bit (v->brvlan->msti, seen)) +continue ; + +if (idx < s_idx) + goto skip; + + nest =nla_nest_start_noflag (skb,BRIDGE_MST_ENTRY ); +if (!nest || +nla_put_u16 (skb,BRIDGE_MST_ENTRY_MSTI , v->brvlan->msti) || +nla_put_u8 (skb,BRIDGE_MST_ENTRY_STATE , v->state)) { + err = -EMSGSIZE ; +break ; + } +nla_nest_end (skb, nest); + +set_bit (v->brvlan->msti, seen); +skip: + idx++; + } + +kfree (seen); +nlmsg_end (skb, nlh); +return err; +} + +static struct net_bridge_port *br_mst_nl_get_parse (struct net *net, +struct netlink_callback *cb) +{ +struct netlink_ext_ack *extack = cb->extack; +const struct nlmsghdr *nlh = cb->nlh; +struct net_bridge_port *p; +struct br_port_msg *bpm; +struct net_device *dev; + +if (nlh->nlmsg_len <nlmsg_msg_size (sizeof (*bpm))) { +NL_SET_ERR_MSG_MOD (extack,"Invalid header for mst get request" ); +return ERR_PTR (-EINVAL ); + } + +if (nlmsg_attrlen (nlh,sizeof (*bpm))) { +NL_SET_ERR_MSG (extack,"Invalid data after header in mst get request" ); +return ERR_PTR (-EINVAL ); + } + + bpm =nlmsg_data (nlh); +if (!bpm->ifindex) +return NULL ; + + dev =__dev_get_by_index (net, bpm->ifindex); +if (!dev) +return ERR_PTR (-ENODEV ); + +if (!netif_is_bridge_port (dev)) { +NL_SET_ERR_MSG_MOD (extack,"The device is not a valid bridge port" ); +return ERR_PTR (-EINVAL ); + } + + p =br_port_get_rtnl (dev); +if (WARN_ON (!p)) +return ERR_PTR (-ENODEV ); + +if (!br_opt_get (p->br,BROPT_MST_ENABLED )) { +NL_SET_ERR_MSG_MOD (extack,"Can't query MST state when MST is disabled" ); +return ERR_PTR (-EINVAL ); + } + +return p; +} + +static int br_mst_nl_get (struct sk_buff *skb,struct netlink_callback *cb) +{ +int err =0 , idx =0 , s_idx = cb->args[0 ]; +struct net *net =sock_net (skb->sk); +struct net_bridge_port *p; +struct net_device *dev; + + p =br_mst_nl_get_parse (net, cb); +if (IS_ERR (p)) +return PTR_ERR (p); + +if (p) { + err =br_mst_nl_get_one (p, skb, cb); +if (err != -EMSGSIZE ) +return err; + }else { +for_each_netdev (net, dev) { +if (!netif_is_bridge_port (dev)) +continue ; + +if (idx < s_idx) + goto skip; + + p =br_port_get_rtnl (dev); +if (WARN_ON (!p)) +return -ENODEV ; + + err =br_mst_nl_get_one (p, skb, cb); +if (err == -EMSGSIZE ) +break ; +skip: + idx++; + } + } + + cb->args[0 ] = idx; +return skb->len; +} + +static const struct nla_policy br_mst_nl_policy[BRIDGE_MST_ENTRY_MAX +1 ] = { + [BRIDGE_MST_ENTRY_MSTI ] =NLA_POLICY_RANGE (NLA_U16 , +1 ,/* 0 reserved for CST */ +VLAN_N_VID -1 ), + [BRIDGE_MST_ENTRY_STATE ] =NLA_POLICY_RANGE (NLA_U8 , +BR_STATE_DISABLED , +BR_STATE_BLOCKING ), +}; + +static int br_mst_nl_set_one (struct net_bridge_port *p, +const struct nlattr *attr, +struct netlink_ext_ack *extack) +{ +struct nlattr *tb[BRIDGE_MST_ENTRY_MAX +1 ]; +u16 msti; +u8 state; +int err; + + err =nla_parse_nested (tb,BRIDGE_MST_ENTRY_MAX , attr, + br_mst_nl_policy, extack); +if (err) +return err; + +if (!tb[BRIDGE_MST_ENTRY_MSTI ]) { +NL_SET_ERR_MSG_MOD (extack,"MSTI not specified" ); +return -EINVAL ; + } + +if (!tb[BRIDGE_MST_ENTRY_STATE ]) { +NL_SET_ERR_MSG_MOD (extack,"State not specified" ); +return -EINVAL ; + } + + msti =nla_get_u16 (tb[BRIDGE_MST_ENTRY_MSTI ]); + state =nla_get_u8 (tb[BRIDGE_MST_ENTRY_STATE ]); + +br_mst_set_state (p, msti, state); +return 0 ; +} + +static int br_mst_nl_set (struct sk_buff *skb,struct nlmsghdr *nlh, +struct netlink_ext_ack *extack) +{ +struct net *net =sock_net (skb->sk); +struct net_bridge_port *p; +struct br_port_msg *bpm; +struct net_device *dev; +struct nlattr *attr; +int err, msts =0 ; +int rem; + + err =nlmsg_parse (nlh,sizeof (*bpm),NULL ,BRIDGE_MST_MAX ,NULL , + extack); +if (err <0 ) +return err; + + bpm =nlmsg_data (nlh); + dev =__dev_get_by_index (net, bpm->ifindex); +if (!dev) +return -ENODEV ; + +if (!netif_is_bridge_port (dev)) { +NL_SET_ERR_MSG_MOD (extack,"The device is not a valid bridge port" ); +return -EINVAL ; + } + + p =br_port_get_rtnl (dev); +if (WARN_ON (!p)) +return -ENODEV ; + +if (!br_opt_get (p->br,BROPT_MST_ENABLED )) { +NL_SET_ERR_MSG_MOD (extack,"Can't modify MST state when MST is disabled" ); +return -EBUSY ; + } + +nlmsg_for_each_attr (attr, nlh,sizeof (*bpm), rem) { +switch (nla_type (attr)) { +case BRIDGE_MST_ENTRY : + err =br_mst_nl_set_one (p, attr, extack); +break ; +default : +continue ; + } + + msts++; +if (err) +break ; + } + +if (!msts) { +NL_SET_ERR_MSG_MOD (extack,"Found no MST entries to process" ); + err = -EINVAL ; + } + +return err; +} + +void br_mst_rtnl_init (void ) +{ +rtnl_register_module (THIS_MODULE ,PF_BRIDGE ,RTM_GETMST ,NULL , + br_mst_nl_get,0 ); +rtnl_register_module (THIS_MODULE ,PF_BRIDGE ,RTM_SETMST , + br_mst_nl_set,NULL ,0 ); +} + +void br_mst_rtnl_uninit (void ) +{ +rtnl_unregister (PF_BRIDGE ,RTM_SETMST ); +rtnl_unregister (PF_BRIDGE ,RTM_GETMST ); +}net/bridge/br_netlink.c +1
-0@@ -1813,6 +1813,7 @@ int __init br_netlink_init(void)br_mdb_init ();br_vlan_rtnl_init (); +br_mst_rtnl_init ();rtnl_af_register (&br_af_ops); err =rtnl_link_register (&br_link_ops);@@ -1824,6 +1825,7 @@ int __init br_netlink_init(void)
out_af:rtnl_af_unregister(&br_af_ops); br_mdb_uninit();net/bridge/br_netlink.c +1
-0+br_mst_rtnl_uninit ();return err; }net/bridge/br_netlink.c +1
-0@@ -1831,6 +1833,7 @@ void br_netlink_fini(void) {br_mdb_uninit ();br_vlan_rtnl_uninit (); +br_mst_rtnl_uninit ();rtnl_af_unregister (&br_af_ops);rtnl_link_unregister (&br_link_ops); }net/bridge/br_private.h +4
-0@@ -1782,6 +1782,8 @@ void br_mst_set_state(struct net_bridge_port *p, u16 msti, u8 state);int br_mst_vlan_set_msti (struct net_bridge_vlan *v,u16 msti);void br_mst_vlan_init_state (struct net_bridge_vlan *v);int br_mst_set_enabled (struct net_bridge *br,unsigned long val); +void br_mst_rtnl_init (void ); +void br_mst_rtnl_uninit (void );#else static inline bool br_mst_is_enabled (struct net_bridge *br) {@@ -1790,6 +1792,8 @@ static inline bool br_mst_is_enabled(struct net_bridge *br)static inline void br_mst_set_state (struct net_bridge_port *p,u16 msti,u8 state) {} +static inline void br_mst_rtnl_init (void ) {} +static inline void br_mst_rtnl_uninit (void ) {}#endif struct nf_br_ops {
Re: [PATCH v2 net-next 03/10] net: bridge: mst: Support setting and reporting MST port states
Quoted 88 lines · Nikolay Aleksandrov
Quoted 87 lines · Tobias Waldekranz
Make it possible to change the port state in a given MSTI. This is done through a new netlink interface, since the MSTIs are objects in their own right. The proposed iproute2 interface would be:
bridge mst set dev <PORT> msti <MSTI> state <STATE>
Current states in all applicable MSTIs can also be dumped. The proposed iproute interface looks like this:
$ bridge mst port msti vb1 0 state forwarding 100 state disabled vb2 0 state forwarding 100 state forwardingThe preexisting per-VLAN states are still valid in the MST mode (although they are read-only), and can be queried as usual if one is interested in knowing a particular VLAN's state without having to care about the VID to MSTI mapping (in this example VLAN 20 and 30 are bound to MSTI 100):
$ bridge -d vlan port vlan-id vb1 10 state forwarding mcast_router 1 20 state disabled mcast_router 1 30 state disabled mcast_router 1 40 state forwarding mcast_router 1 vb2 10 state forwarding mcast_router 1 20 state forwarding mcast_router 1 30 state forwarding mcast_router 1 40 state forwarding mcast_router 1Signed-off-by Tobias Waldekranz <[email protected]>---
include/uapi/linux/if_bridge.h | 16 +++ include/uapi/linux/rtnetlink.h | 5 + net/bridge/br_mst.c | 244 +++++++++++++++++++++++++++++++++ net/bridge/br_netlink.c | 3 + net/bridge/br_private.h | 4 + 5 files changed, 272 insertions(+)include/uapi/linux/if_bridge.h +16
-0@@ -785,4 +785,20 @@ enum {__BRIDGE_QUERIER_MAX };#define BRIDGE_QUERIER_MAX (__BRIDGE_QUERIER_MAX - 1) + +enum { +BRIDGE_MST_UNSPEC , +BRIDGE_MST_ENTRY , + __BRIDGE_MST_MAX, +}; +#define BRIDGE_MST_MAX (__BRIDGE_MST_MAX - 1) + +enum { +BRIDGE_MST_ENTRY_UNSPEC , +BRIDGE_MST_ENTRY_MSTI , +BRIDGE_MST_ENTRY_STATE , + __BRIDGE_MST_ENTRY_MAX, +}; +#define BRIDGE_MST_ENTRY_MAX (__BRIDGE_MST_ENTRY_MAX - 1) +#endif /* _UAPI_LINUX_IF_BRIDGE_H */ include/uapi/linux/rtnetlink.h +0
-0@@ -192,6 +192,11 @@ enum { RTM_GETTUNNEL,#define RTM_GETTUNNEL RTM_GETTUNNEL
Quoted 7 lines
include/uapi/linux/rtnetlink.h enum { · line 199
Quoted 5 lines
include/uapi/linux/rtnetlink.h +5
-0+ RTM_GETMST = 124 + 2, +#define RTM_GETMST RTM_GETMST + RTM_SETMST, +#define RTM_SETMST RTM_SETMST +I think you should also update selinux (see
nlmsgtab.c)
I'll think about this one, if there is some nice way to avoid the new rtm types.
yes, since these are all port attributes, seems like 'bridge link set' should work
Tobias, can you pls check if extending RTM_SETLINK (with AF_BRIDGE) is an option here ?
ie via br_setlink
Re: [PATCH v2 net-next 03/10] net: bridge: mst: Support setting and reporting MST port states
Quoted 97 lines · Roopa Prabhu
Quoted 88 lines · Nikolay Aleksandrov
Quoted 87 lines · Tobias Waldekranz
Make it possible to change the port state in a given MSTI. This is done through a new netlink interface, since the MSTIs are objects in their own right. The proposed iproute2 interface would be:
bridge mst set dev <PORT> msti <MSTI> state <STATE>
Current states in all applicable MSTIs can also be dumped. The proposed iproute interface looks like this:
$ bridge mst port msti vb1 0 state forwarding 100 state disabled vb2 0 state forwarding 100 state forwardingThe preexisting per-VLAN states are still valid in the MST mode (although they are read-only), and can be queried as usual if one is interested in knowing a particular VLAN's state without having to care about the VID to MSTI mapping (in this example VLAN 20 and 30 are bound to MSTI 100):
$ bridge -d vlan port vlan-id vb1 10 state forwarding mcast_router 1 20 state disabled mcast_router 1 30 state disabled mcast_router 1 40 state forwarding mcast_router 1 vb2 10 state forwarding mcast_router 1 20 state forwarding mcast_router 1 30 state forwarding mcast_router 1 40 state forwarding mcast_router 1Signed-off-by Tobias Waldekranz <[email protected]>---
include/uapi/linux/if_bridge.h | 16 +++ include/uapi/linux/rtnetlink.h | 5 + net/bridge/br_mst.c | 244 +++++++++++++++++++++++++++++++++ net/bridge/br_netlink.c | 3 + net/bridge/br_private.h | 4 + 5 files changed, 272 insertions(+)include/uapi/linux/if_bridge.h +16
-0@@ -785,4 +785,20 @@ enum {__BRIDGE_QUERIER_MAX };#define BRIDGE_QUERIER_MAX (__BRIDGE_QUERIER_MAX - 1) + +enum { +BRIDGE_MST_UNSPEC , +BRIDGE_MST_ENTRY , + __BRIDGE_MST_MAX, +}; +#define BRIDGE_MST_MAX (__BRIDGE_MST_MAX - 1) + +enum { +BRIDGE_MST_ENTRY_UNSPEC , +BRIDGE_MST_ENTRY_MSTI , +BRIDGE_MST_ENTRY_STATE , + __BRIDGE_MST_ENTRY_MAX, +}; +#define BRIDGE_MST_ENTRY_MAX (__BRIDGE_MST_ENTRY_MAX - 1) +#endif /* _UAPI_LINUX_IF_BRIDGE_H */ include/uapi/linux/rtnetlink.h +0
-0@@ -192,6 +192,11 @@ enum { RTM_GETTUNNEL,#define RTM_GETTUNNEL RTM_GETTUNNELQuoted 7 lines
include/uapi/linux/rtnetlink.h enum { · line 199
Quoted 5 lines
include/uapi/linux/rtnetlink.h +5
-0+ RTM_GETMST = 124 + 2, +#define RTM_GETMST RTM_GETMST + RTM_SETMST, +#define RTM_SETMST RTM_SETMST +I think you should also update selinux (see
nlmsgtab.c)
I'll think about this one, if there is some nice way to avoid the new rtm types.
Quoted 7 lines
yes, since these are all port attributes, seems like 'bridge link set' should work
Tobias, can you pls check if extending
RTM_SETLINK(withAF_BRIDGE) is an option here ?ie via
br_setlink
Yeah that makes sense. Not sure how I convinced myself that I needed a separate rtm type for it. I will give it a try. Thanks!
Re: [PATCH v2 net-next 03/10] net: bridge: mst: Support setting and reporting MST port states
In reply to Nikolay AleksandrovQuoted 114 lines · Nikolay Aleksandrov
Quoted 84 lines · Tobias Waldekranz
Make it possible to change the port state in a given MSTI. This is done through a new netlink interface, since the MSTIs are objects in their own right. The proposed iproute2 interface would be:
bridge mst set dev <PORT> msti <MSTI> state <STATE>
Current states in all applicable MSTIs can also be dumped. The proposed iproute interface looks like this:
$ bridge mst port msti vb1 0 state forwarding 100 state disabled vb2 0 state forwarding 100 state forwardingThe preexisting per-VLAN states are still valid in the MST mode (although they are read-only), and can be queried as usual if one is interested in knowing a particular VLAN's state without having to care about the VID to MSTI mapping (in this example VLAN 20 and 30 are bound to MSTI 100):
$ bridge -d vlan port vlan-id vb1 10 state forwarding mcast_router 1 20 state disabled mcast_router 1 30 state disabled mcast_router 1 40 state forwarding mcast_router 1 vb2 10 state forwarding mcast_router 1 20 state forwarding mcast_router 1 30 state forwarding mcast_router 1 40 state forwarding mcast_router 1Signed-off-by Tobias Waldekranz <[email protected]>---
include/uapi/linux/if_bridge.h | 16 +++ include/uapi/linux/rtnetlink.h | 5 + net/bridge/br_mst.c | 244 +++++++++++++++++++++++++++++++++ net/bridge/br_netlink.c | 3 + net/bridge/br_private.h | 4 + 5 files changed, 272 insertions(+)include/uapi/linux/if_bridge.h +16
-0@@ -785,4 +785,20 @@ enum {__BRIDGE_QUERIER_MAX };#define BRIDGE_QUERIER_MAX (__BRIDGE_QUERIER_MAX - 1) + +enum { +BRIDGE_MST_UNSPEC , +BRIDGE_MST_ENTRY , + __BRIDGE_MST_MAX, +}; +#define BRIDGE_MST_MAX (__BRIDGE_MST_MAX - 1) + +enum { +BRIDGE_MST_ENTRY_UNSPEC , +BRIDGE_MST_ENTRY_MSTI , +BRIDGE_MST_ENTRY_STATE , + __BRIDGE_MST_ENTRY_MAX, +}; +#define BRIDGE_MST_ENTRY_MAX (__BRIDGE_MST_ENTRY_MAX - 1) +#endif /* _UAPI_LINUX_IF_BRIDGE_H */ include/uapi/linux/rtnetlink.h +0
-0include/uapi/linux/rtnetlink.h enum { · line 199
Quoted 8 lines
include/uapi/linux/rtnetlink.h +5
-0@@ -192,6 +192,11 @@ enum { RTM_GETTUNNEL,#define RTM_GETTUNNEL RTM_GETTUNNEL + RTM_GETMST = 124 + 2, +#define RTM_GETMST RTM_GETMST + RTM_SETMST, +#define RTM_SETMST RTM_SETMST +I think you should also update selinux (see
nlmsgtab.c)
I'll think about this one, if there is some nice way to avoid the new rtm types.Quoted 17 lines
include/uapi/linux/rtnetlink.h +0
-0__RTM_MAX,#define RTM_MAX (((__RTM_MAX + 3) & ~3) - 1) };net/bridge/br_mst.c +6
-0@@ -120,3 +120,247 @@ int br_mst_set_enabled(struct net_bridge *br, unsigned long val)br_opt_toggle (br,BROPT_MST_ENABLED , !!val);return 0 ; } + +static int br_mst_nl_get_one (struct net_bridge_port *p,struct sk_buff *skb, +struct netlink_callback *cb) +{ +struct net_bridge_vlan_group *vg =nbp_vlan_group (p); +int err =0 , idx =0 , s_idx = cb->args[1 ];
Quoted 8 lines
net/bridge/br_mst.c int br_mst_set_enabled(struct net_bridge *br, unsigned long val) · line 134
Quoted 6 lines
net/bridge/br_mst.c +6
-0+struct net_bridge_vlan *v; +struct br_port_msg *bpm; +struct nlmsghdr *nlh; +struct nlattr *nest; +unsigned long *seen; +Reverse xmas tree
Both of these lines end at the 28th column. Is there some other tiebreaking mechanism that forces the reverse ordering of nest and seen?
In a variable-width font, the nest declaration does appear shorter. I remember that you did not have your laptop with you, could that be it?
Nikolay Aleksandrov
maintainerRe: [PATCH v2 net-next 03/10] net: bridge: mst: Support setting and reporting MST port states
Quoted 124 lines · Tobias Waldekranz
Quoted 114 lines · Nikolay Aleksandrov
Quoted 84 lines · Tobias Waldekranz
Make it possible to change the port state in a given MSTI. This is done through a new netlink interface, since the MSTIs are objects in their own right. The proposed iproute2 interface would be:
bridge mst set dev <PORT> msti <MSTI> state <STATE>
Current states in all applicable MSTIs can also be dumped. The proposed iproute interface looks like this:
$ bridge mst port msti vb1 0 state forwarding 100 state disabled vb2 0 state forwarding 100 state forwardingThe preexisting per-VLAN states are still valid in the MST mode (although they are read-only), and can be queried as usual if one is interested in knowing a particular VLAN's state without having to care about the VID to MSTI mapping (in this example VLAN 20 and 30 are bound to MSTI 100):
$ bridge -d vlan port vlan-id vb1 10 state forwarding mcast_router 1 20 state disabled mcast_router 1 30 state disabled mcast_router 1 40 state forwarding mcast_router 1 vb2 10 state forwarding mcast_router 1 20 state forwarding mcast_router 1 30 state forwarding mcast_router 1 40 state forwarding mcast_router 1Signed-off-by Tobias Waldekranz <[email protected]>---
include/uapi/linux/if_bridge.h | 16 +++ include/uapi/linux/rtnetlink.h | 5 + net/bridge/br_mst.c | 244 +++++++++++++++++++++++++++++++++ net/bridge/br_netlink.c | 3 + net/bridge/br_private.h | 4 + 5 files changed, 272 insertions(+)include/uapi/linux/if_bridge.h +16
-0@@ -785,4 +785,20 @@ enum {__BRIDGE_QUERIER_MAX };#define BRIDGE_QUERIER_MAX (__BRIDGE_QUERIER_MAX - 1) + +enum { +BRIDGE_MST_UNSPEC , +BRIDGE_MST_ENTRY , + __BRIDGE_MST_MAX, +}; +#define BRIDGE_MST_MAX (__BRIDGE_MST_MAX - 1) + +enum { +BRIDGE_MST_ENTRY_UNSPEC , +BRIDGE_MST_ENTRY_MSTI , +BRIDGE_MST_ENTRY_STATE , + __BRIDGE_MST_ENTRY_MAX, +}; +#define BRIDGE_MST_ENTRY_MAX (__BRIDGE_MST_ENTRY_MAX - 1) +#endif /* _UAPI_LINUX_IF_BRIDGE_H */ include/uapi/linux/rtnetlink.h +0
-0include/uapi/linux/rtnetlink.h enum { · line 199
Quoted 8 lines
include/uapi/linux/rtnetlink.h +5
-0@@ -192,6 +192,11 @@ enum { RTM_GETTUNNEL,#define RTM_GETTUNNEL RTM_GETTUNNEL + RTM_GETMST = 124 + 2, +#define RTM_GETMST RTM_GETMST + RTM_SETMST, +#define RTM_SETMST RTM_SETMST +I think you should also update selinux (see
nlmsgtab.c)
I'll think about this one, if there is some nice way to avoid the new rtm types.Quoted 17 lines
include/uapi/linux/rtnetlink.h +0
-0__RTM_MAX,#define RTM_MAX (((__RTM_MAX + 3) & ~3) - 1) };net/bridge/br_mst.c +6
-0@@ -120,3 +120,247 @@ int br_mst_set_enabled(struct net_bridge *br, unsigned long val)br_opt_toggle (br,BROPT_MST_ENABLED , !!val);return 0 ; } + +static int br_mst_nl_get_one (struct net_bridge_port *p,struct sk_buff *skb, +struct netlink_callback *cb) +{ +struct net_bridge_vlan_group *vg =nbp_vlan_group (p); +int err =0 , idx =0 , s_idx = cb->args[1 ];Quoted 8 lines
net/bridge/br_mst.c int br_mst_set_enabled(struct net_bridge *br, unsigned long val) · line 134
Quoted 6 lines
net/bridge/br_mst.c +6
-0+struct net_bridge_vlan *v; +struct br_port_msg *bpm; +struct nlmsghdr *nlh; +struct nlattr *nest; +unsigned long *seen; +Reverse xmas tree
Quoted 5 lines
Both of these lines end at the 28th column. Is there some other tiebreaking mechanism that forces the reverse ordering of nest and seen?
In a variable-width font, the nest declaration does appear shorter. I remember that you did not have your laptop with you, could that be it?
Ah yes, you're right. :) Sorry for the noise.
PATCH v2 4/10 net: bridge: mst: Notify switchdev drivers of VLAN MSTI migrations
In reply to Tobias WaldekranzWhenever a VLAN moves to a new MSTI, send a switchdev notification so that switchdevs can...
...either refuse the migration if the hardware does not support offloading of MST...
..or track a bridge's VID to MSTI mapping when offloading is supported.
--- include/net/switchdev.h | 10 +++++++ net/bridge/br_mst.c | 15 +++++++++++ net/bridge/br_switchdev.c | 57 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 82 insertions(+)
include/net/switchdev.h +10 -0
@@ -28,6 +28,7 @@ enum switchdev_attr_id {SWITCHDEV_ATTR_ID_BRIDGE_MC_DISABLED ,SWITCHDEV_ATTR_ID_BRIDGE_MROUTER ,SWITCHDEV_ATTR_ID_MRP_PORT_ROLE , + SWITCHDEV_ATTR_ID_VLAN_MSTI, }; struct switchdev_brport_flags {
@@ -35,6 +36,14 @@ struct switchdev_brport_flags {unsigned long mask; }; +struct switchdev_vlan_attr { +u16 vid; + +union { +u16 msti; + }; +}; +struct switchdev_attr {struct net_device *orig_dev;enum switchdev_attr_id id;
@@ -50,6 +59,7 @@ struct switchdev_attr {u16 vlan_protocol;/* BRIDGE_VLAN_PROTOCOL */ bool mc_disabled;/* MC_DISABLED */ u8 mrp_port_role;/* MRP_PORT_ROLE */ +struct switchdev_vlan_attr vlan_attr;/* VLAN_* */ } u; };
net/bridge/br_mst.c +15 -0
@@ -7,6 +7,7 @@*/ #include <linux/kernel.h> +#include <net/switchdev.h> #include "br_private.h"
@@ -65,9 +66,23 @@ static void br_mst_vlan_sync_state(struct net_bridge_vlan *pv, u16 msti)int br_mst_vlan_set_msti (struct net_bridge_vlan *mv,u16 msti) { +struct switchdev_attr attr = { + .id =SWITCHDEV_ATTR_ID_VLAN_MSTI , + .flags =SWITCHDEV_F_DEFER , + .orig_dev = mv->br->dev, + .u.vlan_attr = { + .vid = mv->vid, + .msti = msti, + }, + };struct net_bridge_vlan_group *vg;struct net_bridge_vlan *pv;struct net_bridge_port *p; +int err; + + err =switchdev_port_attr_set (mv->br->dev, &attr,NULL ); +if (err && err != -EOPNOTSUPP ) +return err; mv->msti = msti;
net/bridge/br_switchdev.c +57 -0
75 lines not on this page · raw message
Signature · 1 line
2.25.1
Vladimir Oltean
maintainerRe: [PATCH v2 net-next 04/10] net: bridge: mst: Notify switchdev drivers of VLAN MSTI migrations
Quoted 29 lines · Tobias Waldekranz
Whenever a VLAN moves to a new MSTI, send a switchdev notification so that switchdevs can...
...either refuse the migration if the hardware does not support offloading of MST...
..or track a bridge's VID to MSTI mapping when offloading is supported.
Signed-off-by Tobias Waldekranz <[email protected]>--- include/net/switchdev.h | 10 +++++++ net/bridge/br_mst.c | 15 +++++++++++ net/bridge/br_switchdev.c | 57 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 82 insertions(+)include/net/switchdev.h +1
-0@@ -28,6 +28,7 @@ enum switchdev_attr_id {SWITCHDEV_ATTR_ID_BRIDGE_MC_DISABLED ,SWITCHDEV_ATTR_ID_BRIDGE_MROUTER ,SWITCHDEV_ATTR_ID_MRP_PORT_ROLE , + SWITCHDEV_ATTR_ID_VLAN_MSTI, }; struct switchdev_brport_flags {
include/net/switchdev.h struct switchdev_brport_flags { · line 44
Quoted 9 lines
include/net/switchdev.h +6
-0@@ -35,6 +36,14 @@ struct switchdev_brport_flags {unsigned long mask; }; +struct switchdev_vlan_attr { +u16 vid; + +union { +u16 msti; + };
Do you see other VLAN attributes that would be added in the future, such as to justify making this a single-element union from the get-go? Anyway if that is the case, we're lacking an id for the attribute type, so we'd end up needing to change drivers when a second union element appears. Otherwise they'd all expect an u16 msti.
Quoted 26 lines
include/net/switchdev.h +3
-0+}; +struct switchdev_attr {struct net_device *orig_dev;enum switchdev_attr_id id;@@ -50,6 +59,7 @@ struct switchdev_attr {u16 vlan_protocol;/* BRIDGE_VLAN_PROTOCOL */ bool mc_disabled;/* MC_DISABLED */ u8 mrp_port_role;/* MRP_PORT_ROLE */ +struct switchdev_vlan_attr vlan_attr;/* VLAN_* */ } u; };net/bridge/br_mst.c +1
-0@@ -7,6 +7,7 @@*/ #include <linux/kernel.h> +#include <net/switchdev.h> #include "br_private.h"
net/bridge/br_mst.c static void br_mst_vlan_sync_state(struct net_bridge_vlan *pv, u16 msti) · line 71
Quoted 6 lines
net/bridge/br_mst.c +3
-0@@ -65,9 +66,23 @@ static void br_mst_vlan_sync_state(struct net_bridge_vlan *pv, u16 msti)int br_mst_vlan_set_msti (struct net_bridge_vlan *mv,u16 msti) { +struct switchdev_attr attr = { + .id =SWITCHDEV_ATTR_ID_VLAN_MSTI , + .flags =SWITCHDEV_F_DEFER ,
Is the bridge spinlock held (atomic context), or otherwise why is SWITCHDEV_F_DEFER needed here?
net/bridge/br_mst.c static void br_mst_vlan_sync_state(struct net_bridge_vlan *pv, u16 msti) · line 83
Quoted 12 lines
net/bridge/br_mst.c +9
-0+ .orig_dev = mv->br->dev, + .u.vlan_attr = { + .vid = mv->vid, + .msti = msti, + }, + };struct net_bridge_vlan_group *vg;struct net_bridge_vlan *pv;struct net_bridge_port *p; +int err; + + err =switchdev_port_attr_set (mv->br->dev, &attr,NULL );
Treating a "VLAN attribute" as a "port attribute of the bridge" is pushing the taxonomy just a little, but I don't have a better suggestion.
Quoted 10 lines
net/bridge/br_mst.c +2
-0+if (err && err != -EOPNOTSUPP ) +return err; mv->msti = msti;net/bridge/br_switchdev.c +0
-0
net/bridge/br_switchdev.c static int br_switchdev_vlan_replay(struct net_device *br_dev, · line 434
Quoted 7 lines
net/bridge/br_switchdev.c +4
-0@@ -428,6 +428,57 @@ static int br_switchdev_vlan_replay(struct net_device *br_dev,return 0 ; } +static int br_switchdev_mst_replay (struct net_device *br_dev, +const void *ctx,bool adding, +struct notifier_block *nb, +struct netlink_ext_ack *extack)
"bool adding" is unused, and replaying the VLAN to MSTI associations before deleting them makes little sense anyway.
I understand the appeal of symmetry, so maybe put an
if (adding) {
err = br_switchdev_vlan_attr_replay(...);
if (err && err != -EOPNOTSUPP)
return err;
}at the end of br_switchdev_vlan_replay()?
Quoted 17 lines
net/bridge/br_switchdev.c +17
-0+{ +struct switchdev_notifier_port_attr_info attr_info = { + .info = { + .dev = br_dev, + .extack = extack, + .ctx = ctx, + }, + }; +struct net_bridge *br =netdev_priv (br_dev); +struct net_bridge_vlan_group *vg; +struct net_bridge_vlan *v; +int err; + +ASSERT_RTNL (); + +if (!nb) +return 0 ;
net/bridge/br_switchdev.c static int br_switchdev_vlan_replay(struct net_device *br_dev, · line 461
Quoted 10 lines
net/bridge/br_switchdev.c +10
-0+ +if (!netif_is_bridge_master (br_dev)) +return -EINVAL ; + + vg =br_vlan_group (br); + +list_for_each_entry (v, &vg->vlan_list, vlist) { +struct switchdev_attr attr = { + .id =SWITCHDEV_ATTR_ID_VLAN_MSTI , + .flags =SWITCHDEV_F_DEFER ,
I don't think SWITCHDEV_F_DEFER has any effect on a replay.
Quoted 46 lines
net/bridge/br_switchdev.c +26
-0+ .orig_dev = br_dev, + .u.vlan_attr = { + .vid = v->vid, + .msti = v->msti, + } + }; + +if (!v->msti) +continue ; + + attr_info.attr = &attr; + err = nb->notifier_call (nb,SWITCHDEV_PORT_ATTR_SET , &attr_info); + err =notifier_to_errno (err); +if (err) +return err; + } + +return 0 ; +} + #ifdef CONFIG_BRIDGE_IGMP_SNOOPING struct br_switchdev_mdb_complete_info { struct net_bridge_port *port;@@ -695,6 +746,10 @@ static int nbp_switchdev_sync_objs(struct net_bridge_port *p, const void *ctx,if (err && err != -EOPNOTSUPP )return err; + err =br_switchdev_mst_replay (br_dev, ctx, true, blocking_nb, extack); +if (err && err != -EOPNOTSUPP ) +return err; + err =br_switchdev_mdb_replay (br_dev, dev, ctx, true, blocking_nb, extack);if (err && err != -EOPNOTSUPP )@@ -719,6 +774,8 @@ static void nbp_switchdev_unsync_objs(struct net_bridge_port *p,br_switchdev_mdb_replay (br_dev, dev, ctx, false, blocking_nb,NULL ); +br_switchdev_mst_replay (br_dev, ctx, false, blocking_nb,NULL ); +br_switchdev_vlan_replay (br_dev, ctx, false, blocking_nb,NULL ); }Signature · 1 line
2.25.1
Re: [PATCH v2 net-next 04/10] net: bridge: mst: Notify switchdev drivers of VLAN MSTI migrations
Quoted 33 lines · Vladimir Oltean
Quoted 32 lines · Tobias Waldekranz
Whenever a VLAN moves to a new MSTI, send a switchdev notification so that switchdevs can...
...either refuse the migration if the hardware does not support offloading of MST...
..or track a bridge's VID to MSTI mapping when offloading is supported.
Signed-off-by Tobias Waldekranz <[email protected]>--- include/net/switchdev.h | 10 +++++++ net/bridge/br_mst.c | 15 +++++++++++ net/bridge/br_switchdev.c | 57 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 82 insertions(+)include/net/switchdev.h +1
-0@@ -28,6 +28,7 @@ enum switchdev_attr_id {SWITCHDEV_ATTR_ID_BRIDGE_MC_DISABLED ,SWITCHDEV_ATTR_ID_BRIDGE_MROUTER ,SWITCHDEV_ATTR_ID_MRP_PORT_ROLE , + SWITCHDEV_ATTR_ID_VLAN_MSTI, }; struct switchdev_brport_flags {@@ -35,6 +36,14 @@ struct switchdev_brport_flags {unsigned long mask; };
Quoted 9 lines
include/net/switchdev.h struct switchdev_brport_flags { · line 44
Quoted 6 lines
include/net/switchdev.h +6
-0+struct switchdev_vlan_attr { +u16 vid; + +union { +u16 msti; + };Do you see other VLAN attributes that would be added in the future, such as to justify making this a single-element union from the get-go?
I could imagine being able to control things like multicast snooping on a per-VLAN basis. Being able to act as a multicast router in one VLAN but not another.
Quoted 3 lines
Anyway if that is the case, we're lacking an id for the attribute type, so we'd end up needing to change drivers when a second union element appears. Otherwise they'd all expect an u16 msti.
My idea was that enum switchdev_attr_id would hold all of that information. In this example SWITCHDEV_ATTR_ID_VLAN_MSTI, denotes both that vlan_attr is the valid member of u and that msti is the valid member of vlan_attr. If we add SWITCHDEV_ATTR_ID_VLAN_SNOOPING, that would point to both vlan_attr and a new bool snooping in the union.
Do you think we should just have a SWITCHDEV_ATTR_ID_VLAN_ATTR for all per-VLAN attributes and then have a separate union?
Quoted 27 lines
Quoted 27 lines
include/net/switchdev.h +3
-0+}; +struct switchdev_attr {struct net_device *orig_dev;enum switchdev_attr_id id;@@ -50,6 +59,7 @@ struct switchdev_attr {u16 vlan_protocol;/* BRIDGE_VLAN_PROTOCOL */ bool mc_disabled;/* MC_DISABLED */ u8 mrp_port_role;/* MRP_PORT_ROLE */ +struct switchdev_vlan_attr vlan_attr;/* VLAN_* */ } u; };net/bridge/br_mst.c +1
-0@@ -7,6 +7,7 @@*/ #include <linux/kernel.h> +#include <net/switchdev.h> #include "br_private.h" @@ -65,9 +66,23 @@ static void br_mst_vlan_sync_state(struct net_bridge_vlan *pv, u16 msti)
Quoted 8 lines
net/bridge/br_mst.c static void br_mst_vlan_sync_state(struct net_bridge_vlan *pv, u16 msti) · line 71
Quoted 5 lines
net/bridge/br_mst.c +3
-0int br_mst_vlan_set_msti (struct net_bridge_vlan *mv,u16 msti) { +struct switchdev_attr attr = { + .id =SWITCHDEV_ATTR_ID_VLAN_MSTI , + .flags =SWITCHDEV_F_DEFER ,Is the bridge spinlock held (atomic context), or otherwise why is
SWITCHDEV_F_DEFERneeded here?
Nope, just copypasta. In fact, it shouldn't be needed when setting the state either, as you can only change the state via a netlink message. I will remove it.
Quoted 7 lines
Quoted 7 lines
net/bridge/br_mst.c +6
-0+ .orig_dev = mv->br->dev, + .u.vlan_attr = { + .vid = mv->vid, + .msti = msti, + }, + };struct net_bridge_vlan_group *vg;
Quoted 8 lines
net/bridge/br_mst.c static void br_mst_vlan_sync_state(struct net_bridge_vlan *pv, u16 msti) · line 83
Quoted 5 lines
net/bridge/br_mst.c +3
-0struct net_bridge_vlan *pv;struct net_bridge_port *p; +int err; + + err =switchdev_port_attr_set (mv->br->dev, &attr,NULL );Treating a "VLAN attribute" as a "port attribute of the bridge" is pushing the taxonomy just a little, but I don't have a better suggestion.
Isn't there prior art here? I thought things like VLAN filtering already worked like this?
Quoted 23 lines
Quoted 10 lines
net/bridge/br_mst.c +2
-0+if (err && err != -EOPNOTSUPP ) +return err; mv->msti = msti;net/bridge/br_switchdev.c +0
-0net/bridge/br_switchdev.c static int br_switchdev_vlan_replay(struct net_device *br_dev, · line 434
Quoted 7 lines
net/bridge/br_switchdev.c +4
-0@@ -428,6 +428,57 @@ static int br_switchdev_vlan_replay(struct net_device *br_dev,return 0 ; } +static int br_switchdev_mst_replay (struct net_device *br_dev, +const void *ctx,bool adding, +struct notifier_block *nb, +struct netlink_ext_ack *extack)"bool adding" is unused, and replaying the VLAN to MSTI associations before deleting them makes little sense anyway.
I understand the appeal of symmetry, so maybe put an
Quoted 7 lines
if (adding) { err = br_switchdev_vlan_attr_replay(...); if (err && err != -EOPNOTSUPP) return err; }at the end of
br_switchdev_vlan_replay()?
Yeah, that is better. Will change.
Quoted 21 lines
Quoted 21 lines
net/bridge/br_switchdev.c +21
-0+{ +struct switchdev_notifier_port_attr_info attr_info = { + .info = { + .dev = br_dev, + .extack = extack, + .ctx = ctx, + }, + }; +struct net_bridge *br =netdev_priv (br_dev); +struct net_bridge_vlan_group *vg; +struct net_bridge_vlan *v; +int err; + +ASSERT_RTNL (); + +if (!nb) +return 0 ; + +if (!netif_is_bridge_master (br_dev)) +return -EINVAL ; +
Quoted 8 lines
net/bridge/br_switchdev.c static int br_switchdev_vlan_replay(struct net_device *br_dev, · line 461
Quoted 6 lines
net/bridge/br_switchdev.c +6
-0+ vg =br_vlan_group (br); + +list_for_each_entry (v, &vg->vlan_list, vlist) { +struct switchdev_attr attr = { + .id =SWITCHDEV_ATTR_ID_VLAN_MSTI , + .flags =SWITCHDEV_F_DEFER ,I don't think
SWITCHDEV_F_DEFERhas any effect on a replay.
Right, will fix.
Quoted 46 lines
Quoted 46 lines
net/bridge/br_switchdev.c +26
-0+ .orig_dev = br_dev, + .u.vlan_attr = { + .vid = v->vid, + .msti = v->msti, + } + }; + +if (!v->msti) +continue ; + + attr_info.attr = &attr; + err = nb->notifier_call (nb,SWITCHDEV_PORT_ATTR_SET , &attr_info); + err =notifier_to_errno (err); +if (err) +return err; + } + +return 0 ; +} + #ifdef CONFIG_BRIDGE_IGMP_SNOOPING struct br_switchdev_mdb_complete_info { struct net_bridge_port *port;@@ -695,6 +746,10 @@ static int nbp_switchdev_sync_objs(struct net_bridge_port *p, const void *ctx,if (err && err != -EOPNOTSUPP )return err; + err =br_switchdev_mst_replay (br_dev, ctx, true, blocking_nb, extack); +if (err && err != -EOPNOTSUPP ) +return err; + err =br_switchdev_mdb_replay (br_dev, dev, ctx, true, blocking_nb, extack);if (err && err != -EOPNOTSUPP )@@ -719,6 +774,8 @@ static void nbp_switchdev_unsync_objs(struct net_bridge_port *p,br_switchdev_mdb_replay (br_dev, dev, ctx, false, blocking_nb,NULL ); +br_switchdev_mst_replay (br_dev, ctx, false, blocking_nb,NULL ); +br_switchdev_vlan_replay (br_dev, ctx, false, blocking_nb,NULL ); }Signature · 1 line
2.25.1
Vladimir Oltean
maintainerRe: [PATCH v2 net-next 04/10] net: bridge: mst: Notify switchdev drivers of VLAN MSTI migrations
Quoted 52 lines · Tobias Waldekranz
Quoted 33 lines · Vladimir Oltean
Quoted 32 lines · Tobias Waldekranz
Whenever a VLAN moves to a new MSTI, send a switchdev notification so that switchdevs can...
...either refuse the migration if the hardware does not support offloading of MST...
..or track a bridge's VID to MSTI mapping when offloading is supported.
Signed-off-by Tobias Waldekranz <[email protected]>--- include/net/switchdev.h | 10 +++++++ net/bridge/br_mst.c | 15 +++++++++++ net/bridge/br_switchdev.c | 57 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 82 insertions(+)include/net/switchdev.h +1
-0@@ -28,6 +28,7 @@ enum switchdev_attr_id {SWITCHDEV_ATTR_ID_BRIDGE_MC_DISABLED ,SWITCHDEV_ATTR_ID_BRIDGE_MROUTER ,SWITCHDEV_ATTR_ID_MRP_PORT_ROLE , + SWITCHDEV_ATTR_ID_VLAN_MSTI, }; struct switchdev_brport_flags {@@ -35,6 +36,14 @@ struct switchdev_brport_flags {unsigned long mask; };Quoted 9 lines
include/net/switchdev.h struct switchdev_brport_flags { · line 44
Quoted 6 lines
include/net/switchdev.h +6
-0+struct switchdev_vlan_attr { +u16 vid; + +union { +u16 msti; + };Do you see other VLAN attributes that would be added in the future, such as to justify making this a single-element union from the get-go?
I could imagine being able to control things like multicast snooping on a per-VLAN basis. Being able to act as a multicast router in one VLAN but not another.
Quoted 3 lines
Anyway if that is the case, we're lacking an id for the attribute type, so we'd end up needing to change drivers when a second union element appears. Otherwise they'd all expect an u16 msti.
Quoted 8 lines
My idea was that
enum switchdev_attr_idwould hold all of that information. In this exampleSWITCHDEV_ATTR_ID_VLAN_MSTI, denotes both thatvlan_attris the valid member ofuand thatmstiis the valid member ofvlan_attr. If we addSWITCHDEV_ATTR_ID_VLAN_SNOOPING, that would point to bothvlan_attrand a newbool snoopingin the union.Do you think we should just have a
SWITCHDEV_ATTR_ID_VLAN_ATTRfor all per-VLAN attributes and then have a separate union?
It's the first nested union that I see, and a bit confusing.
I think it would be better if we had a
struct switchdev_vlan_attr_msti {
u16 vid;
u16 msti;
};and different structures for other, future VLAN attributes. Basically keep a 1:1 mapping between an attribute id and a union.
Quoted 56 lines
Quoted 27 lines
Quoted 27 lines
include/net/switchdev.h +3
-0+}; +struct switchdev_attr {struct net_device *orig_dev;enum switchdev_attr_id id;@@ -50,6 +59,7 @@ struct switchdev_attr {u16 vlan_protocol;/* BRIDGE_VLAN_PROTOCOL */ bool mc_disabled;/* MC_DISABLED */ u8 mrp_port_role;/* MRP_PORT_ROLE */ +struct switchdev_vlan_attr vlan_attr;/* VLAN_* */ } u; };net/bridge/br_mst.c +1
-0@@ -7,6 +7,7 @@*/ #include <linux/kernel.h> +#include <net/switchdev.h> #include "br_private.h" @@ -65,9 +66,23 @@ static void br_mst_vlan_sync_state(struct net_bridge_vlan *pv, u16 msti)Quoted 8 lines
net/bridge/br_mst.c static void br_mst_vlan_sync_state(struct net_bridge_vlan *pv, u16 msti) · line 71
Quoted 5 lines
net/bridge/br_mst.c +3
-0int br_mst_vlan_set_msti (struct net_bridge_vlan *mv,u16 msti) { +struct switchdev_attr attr = { + .id =SWITCHDEV_ATTR_ID_VLAN_MSTI , + .flags =SWITCHDEV_F_DEFER ,Is the bridge spinlock held (atomic context), or otherwise why is
SWITCHDEV_F_DEFERneeded here?Nope, just copypasta. In fact, it shouldn't be needed when setting the state either, as you can only change the state via a netlink message. I will remove it.
Quoted 7 lines
Quoted 7 lines
net/bridge/br_mst.c +6
-0+ .orig_dev = mv->br->dev, + .u.vlan_attr = { + .vid = mv->vid, + .msti = msti, + }, + };struct net_bridge_vlan_group *vg;Quoted 8 lines
net/bridge/br_mst.c static void br_mst_vlan_sync_state(struct net_bridge_vlan *pv, u16 msti) · line 83
Quoted 5 lines
net/bridge/br_mst.c +3
-0struct net_bridge_vlan *pv;struct net_bridge_port *p; +int err; + + err =switchdev_port_attr_set (mv->br->dev, &attr,NULL );Treating a "VLAN attribute" as a "port attribute of the bridge" is pushing the taxonomy just a little, but I don't have a better suggestion.
Quoted 2 lines
Isn't there prior art here? I thought things like VLAN filtering already worked like this?
Hmm, I can think of VLAN filtering as being an attribute of the bridge device, but 'which MSTI does VLAN X belong to' is an attribute of the VLAN (in itself a switchdev object, i.e. something countable).
If the prior art would apply as straightforward as you say, then we'd be replaying the VLAN MSTIs together with the other port attributes - in "pull" mode, in dsa_port_switchdev_sync_attrs(), rather than in "push" mode with the rest of the objects - in nbp_switchdev_sync_objs(). But we're not doing that.
To prove that there is a difference between VLAN filtering as a port property of the bridge device, and VLAN MSTIs (or other per-VLAN global bridge options), consider this.
You create a bridge, add 10 VLANs on br0, enable VLAN filtering, then delete the 10 VLANs and re-create them. The bridge is still VLAN filtering.
So VLAN filtering is a property of the bridge.
Next you create a bridge, add 10 VLANs on br0, run your new command:
'bridge vlan global set dev br0 vid <VID> msti <MSTI>'
then delete the 10 VLANs and create them back.
Their MSTI is 0, not what was set via the bridge vlan global options... Because the MSTI is a property of the VLANs, not of the bridge.
A real port attribute wouldn't behave like that.
At least this is what I understand from your patch set, I haven't run it; sorry if I'm mistaken about something, but I can't find a clearer way to express what I find strange.
Anyway, I'll stop uselessly commenting here - I can understand the practical reasons why you wouldn't want to bother expanding the taxonomy to describe this for what it really is - an "object attribute" of sorts - because a port attribute for the bridge device has the call path you need already laid out, including replication towards all bridge ports.
Re: [PATCH v2 net-next 04/10] net: bridge: mst: Notify switchdev drivers of VLAN MSTI migrations
Quoted 66 lines · Vladimir Oltean
Quoted 52 lines · Tobias Waldekranz
Quoted 33 lines · Vladimir Oltean
Quoted 32 lines · Tobias Waldekranz
Whenever a VLAN moves to a new MSTI, send a switchdev notification so that switchdevs can...
...either refuse the migration if the hardware does not support offloading of MST...
..or track a bridge's VID to MSTI mapping when offloading is supported.
Signed-off-by Tobias Waldekranz <[email protected]>--- include/net/switchdev.h | 10 +++++++ net/bridge/br_mst.c | 15 +++++++++++ net/bridge/br_switchdev.c | 57 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 82 insertions(+)include/net/switchdev.h +1
-0@@ -28,6 +28,7 @@ enum switchdev_attr_id {SWITCHDEV_ATTR_ID_BRIDGE_MC_DISABLED ,SWITCHDEV_ATTR_ID_BRIDGE_MROUTER ,SWITCHDEV_ATTR_ID_MRP_PORT_ROLE , + SWITCHDEV_ATTR_ID_VLAN_MSTI, }; struct switchdev_brport_flags {@@ -35,6 +36,14 @@ struct switchdev_brport_flags {unsigned long mask; };Quoted 9 lines
include/net/switchdev.h struct switchdev_brport_flags { · line 44
Quoted 6 lines
include/net/switchdev.h +6
-0+struct switchdev_vlan_attr { +u16 vid; + +union { +u16 msti; + };Do you see other VLAN attributes that would be added in the future, such as to justify making this a single-element union from the get-go?
I could imagine being able to control things like multicast snooping on a per-VLAN basis. Being able to act as a multicast router in one VLAN but not another.
Quoted 3 lines
Anyway if that is the case, we're lacking an id for the attribute type, so we'd end up needing to change drivers when a second union element appears. Otherwise they'd all expect an u16 msti.
Quoted 8 lines
My idea was that
enum switchdev_attr_idwould hold all of that information. In this exampleSWITCHDEV_ATTR_ID_VLAN_MSTI, denotes both thatvlan_attris the valid member ofuand thatmstiis the valid member ofvlan_attr. If we addSWITCHDEV_ATTR_ID_VLAN_SNOOPING, that would point to bothvlan_attrand a newbool snoopingin the union.Do you think we should just have a
SWITCHDEV_ATTR_ID_VLAN_ATTRfor all per-VLAN attributes and then have a separate union?It's the first nested union that I see, and a bit confusing.
I think it would be better if we had a
Quoted 7 lines
struct switchdev_vlan_attr_msti { u16 vid; u16 msti; };and different structures for other, future VLAN attributes. Basically keep a 1:1 mapping between an attribute id and a union.
Yeah, I like the simplicity of that. Changing.
Quoted 89 lines
Quoted 56 lines
Quoted 27 lines
Quoted 27 lines
include/net/switchdev.h +3
-0+}; +struct switchdev_attr {struct net_device *orig_dev;enum switchdev_attr_id id;@@ -50,6 +59,7 @@ struct switchdev_attr {u16 vlan_protocol;/* BRIDGE_VLAN_PROTOCOL */ bool mc_disabled;/* MC_DISABLED */ u8 mrp_port_role;/* MRP_PORT_ROLE */ +struct switchdev_vlan_attr vlan_attr;/* VLAN_* */ } u; };net/bridge/br_mst.c +1
-0@@ -7,6 +7,7 @@*/ #include <linux/kernel.h> +#include <net/switchdev.h> #include "br_private.h" @@ -65,9 +66,23 @@ static void br_mst_vlan_sync_state(struct net_bridge_vlan *pv, u16 msti)Quoted 8 lines
net/bridge/br_mst.c static void br_mst_vlan_sync_state(struct net_bridge_vlan *pv, u16 msti) · line 71
Quoted 5 lines
net/bridge/br_mst.c +3
-0int br_mst_vlan_set_msti (struct net_bridge_vlan *mv,u16 msti) { +struct switchdev_attr attr = { + .id =SWITCHDEV_ATTR_ID_VLAN_MSTI , + .flags =SWITCHDEV_F_DEFER ,Is the bridge spinlock held (atomic context), or otherwise why is
SWITCHDEV_F_DEFERneeded here?Nope, just copypasta. In fact, it shouldn't be needed when setting the state either, as you can only change the state via a netlink message. I will remove it.
Quoted 7 lines
Quoted 7 lines
net/bridge/br_mst.c +6
-0+ .orig_dev = mv->br->dev, + .u.vlan_attr = { + .vid = mv->vid, + .msti = msti, + }, + };struct net_bridge_vlan_group *vg;Quoted 8 lines
net/bridge/br_mst.c static void br_mst_vlan_sync_state(struct net_bridge_vlan *pv, u16 msti) · line 83
Quoted 5 lines
net/bridge/br_mst.c +3
-0struct net_bridge_vlan *pv;struct net_bridge_port *p; +int err; + + err =switchdev_port_attr_set (mv->br->dev, &attr,NULL );Treating a "VLAN attribute" as a "port attribute of the bridge" is pushing the taxonomy just a little, but I don't have a better suggestion.
Quoted 2 lines
Isn't there prior art here? I thought things like VLAN filtering already worked like this?
Hmm, I can think of VLAN filtering as being an attribute of the bridge device, but 'which MSTI does VLAN X belong to' is an attribute of the VLAN (in itself a switchdev object, i.e. something countable).
If the prior art would apply as straightforward as you say, then we'd be replaying the VLAN MSTIs together with the other port attributes - in "pull" mode, in
dsa_port_switchdev_sync_attrs(), rather than in "push" mode with the rest of the objects - innbp_switchdev_sync_objs(). But we're not doing that.To prove that there is a difference between VLAN filtering as a port property of the bridge device, and VLAN MSTIs (or other per-VLAN global bridge options), consider this.
You create a bridge, add 10 VLANs on br0, enable VLAN filtering, then delete the 10 VLANs and re-create them. The bridge is still VLAN filtering.
So VLAN filtering is a property of the bridge.Next you create a bridge, add 10 VLANs on br0, run your new command:
'bridge vlan global set dev br0 vid <VID> msti <MSTI>'
then delete the 10 VLANs and create them back.
Their MSTI is 0, not what was set via the bridge vlan global options... Because the MSTI is a property of the VLANs, not of the bridge.A real port attribute wouldn't behave like that.
At least this is what I understand from your patch set, I haven't run it; sorry if I'm mistaken about something, but I can't find a clearer way to express what I find strange.
Quoted 5 lines
Anyway, I'll stop uselessly commenting here - I can understand the practical reasons why you wouldn't want to bother expanding the taxonomy to describe this for what it really is - an "object attribute" of sorts - because a port attribute for the bridge device has the call path you need already laid out, including replication towards all bridge ports.
I yield, I yield! :)
PATCH v2 5/10 net: bridge: mst: Notify switchdev drivers of MST state changes
In reply to Tobias WaldekranzGenerate a switchdev notification whenever an MST state changes. This notification is keyed by the VLANs MSTI rather than the VID, since multiple VLANs may share the same MST instance.
--- include/net/switchdev.h | 7 +++++++ net/bridge/br_mst.c | 21 +++++++++++++++++++++ 2 files changed, 28 insertions(+)
include/net/switchdev.h +7 -0
@@ -19,6 +19,7 @@enum switchdev_attr_id {SWITCHDEV_ATTR_ID_UNDEFINED ,SWITCHDEV_ATTR_ID_PORT_STP_STATE , +SWITCHDEV_ATTR_ID_PORT_MST_STATE ,SWITCHDEV_ATTR_ID_PORT_BRIDGE_FLAGS ,SWITCHDEV_ATTR_ID_PORT_PRE_BRIDGE_FLAGS ,SWITCHDEV_ATTR_ID_PORT_MROUTER ,
@@ -31,6 +32,11 @@ enum switchdev_attr_id { SWITCHDEV_ATTR_ID_VLAN_MSTI, }; +struct switchdev_mst_state { +u16 msti; +u8 state; +}; +struct switchdev_brport_flags {unsigned long val;unsigned long mask;
@@ -52,6 +58,7 @@ struct switchdev_attr {void (*complete)(struct net_device *dev,int err,void *priv);union {u8 stp_state;/* PORT_STP_STATE */ +struct switchdev_mst_state mst_state;/* PORT_MST_STATE */ struct switchdev_brport_flags brport_flags;/* PORT_BRIDGE_FLAGS */ bool mrouter;/* PORT_MROUTER */ clock_t ageing_time;/* BRIDGE_AGEING_TIME */
net/bridge/br_mst.c +21 -0
@@ -29,8 +29,18 @@ void br_mst_vlan_set_state(struct net_bridge_port *p, struct net_bridge_vlan *v,void br_mst_set_state (struct net_bridge_port *p,u16 msti,u8 state) { +struct switchdev_attr attr = { + .id =SWITCHDEV_ATTR_ID_PORT_MST_STATE , + .flags =SWITCHDEV_F_DEFER , + .orig_dev = p->dev, + .u.mst_state = { + .msti = msti, + .state = state, + }, + };struct net_bridge_vlan_group *vg;struct net_bridge_vlan *v; +int err; vg =nbp_vlan_group (p);if (!vg)
@@ -42,6 +52,17 @@ void br_mst_set_state(struct net_bridge_port *p, u16 msti, u8 state)br_mst_vlan_set_state (p, v, state); } + +if (!msti) +/* MSTI 0 (CST) state changes are notified via the +* regular SWITCHDEV_ATTR_ID_PORT_STP_STATE. +*/ +return ; + + err =switchdev_port_attr_set (p->dev, &attr,NULL ); +if (err && err != -EOPNOTSUPP ) +br_warn (p->br,"unable to offload MST state on %s in MSTI %u" , +netdev_name (p->dev), msti); }static void br_mst_vlan_sync_state (struct net_bridge_vlan *pv,u16 msti)
Signature · 1 line
2.25.1
PATCH v2 6/10 net: dsa: Pass VLAN MSTI migration notifications to driver
In reply to Tobias WaldekranzAdd the usual trampoline functionality from the generic DSA layer down to the drivers for VLAN MSTI migrations.
--- include/net/dsa.h | 3 +++ net/dsa/dsa_priv.h | 1 + net/dsa/port.c | 10 ++++++++++ net/dsa/slave.c | 6 ++++++ 4 files changed, 20 insertions(+)
include/net/dsa.h +3 -0
@@ -962,6 +962,9 @@ struct dsa_switch_ops { struct netlink_ext_ack *extack);int (*port_vlan_del)(struct dsa_switch *ds,int port,const struct switchdev_obj_port_vlan *vlan); +int (*vlan_msti_set)(struct dsa_switch *ds, +const struct switchdev_attr *attr); +/* * Forwarding database */
net/dsa/dsa_priv.h +1 -0
@@ -217,6 +217,7 @@ int dsa_port_vlan_filtering(struct dsa_port *dp, bool vlan_filtering, struct netlink_ext_ack *extack);bool dsa_port_skip_vlan_configuration (struct dsa_port *dp);int dsa_port_ageing_time (struct dsa_port *dp,clock_t ageing_clock); +int dsa_port_vlan_msti (struct dsa_port *dp,const struct switchdev_attr *attr);int dsa_port_mtu_change (struct dsa_port *dp,int new_mtu,bool targeted_match); int dsa_port_fdb_add(struct dsa_port *dp, const unsigned char *addr,
net/dsa/port.c +10 -0
@@ -778,6 +778,16 @@ int dsa_port_bridge_flags(struct dsa_port *dp,return 0 ; } +int dsa_port_vlan_msti (struct dsa_port *dp,const struct switchdev_attr *attr) +{ +struct dsa_switch *ds = dp->ds; + +if (!ds->ops->vlan_msti_set) +return -EOPNOTSUPP ; + +return ds->ops->vlan_msti_set (ds, attr); +} +int dsa_port_mtu_change (struct dsa_port *dp,int new_mtu,bool targeted_match) {
net/dsa/slave.c +6 -0
@@ -314,6 +314,12 @@ static int dsa_slave_port_attr_set(struct net_device *dev, const void *ctx, ret =dsa_port_bridge_flags (dp, attr->u.brport_flags, extack);break ; +case SWITCHDEV_ATTR_ID_VLAN_MSTI : +if (!dsa_port_offloads_bridge_dev (dp, attr->orig_dev)) +return -EOPNOTSUPP ; + + ret =dsa_port_vlan_msti (dp, attr); +break ;default : ret = -EOPNOTSUPP ;break ;
Signature · 1 line
2.25.1
Vladimir Oltean
maintainerRe: [PATCH v2 net-next 06/10] net: dsa: Pass VLAN MSTI migration notifications to driver
Quoted 16 lines · Tobias Waldekranz
Add the usual trampoline functionality from the generic DSA layer down to the drivers for VLAN MSTI migrations.
Signed-off-by Tobias Waldekranz <[email protected]>--- include/net/dsa.h | 3 +++ net/dsa/dsa_priv.h | 1 + net/dsa/port.c | 10 ++++++++++ net/dsa/slave.c | 6 ++++++ 4 files changed, 20 insertions(+)include/net/dsa.h +0
-0
include/net/dsa.h struct dsa_switch_ops { · line 966
Quoted 5 lines
include/net/dsa.h +2
-0@@ -962,6 +962,9 @@ struct dsa_switch_ops { struct netlink_ext_ack *extack);int (*port_vlan_del)(struct dsa_switch *ds,int port,const struct switchdev_obj_port_vlan *vlan); +int (*vlan_msti_set)(struct dsa_switch *ds, +const struct switchdev_attr *attr);
I would rather pass the struct switchdev_vlan_attr and the orig_dev (bridge) as separate arguments here. Or even the struct dsa_bridge, for consistency to the API changes for database isolation.
Quoted 22 lines
include/net/dsa.h +1
-0+/* * Forwarding database */ net/dsa/dsa_priv.h +1
-0@@ -217,6 +217,7 @@ int dsa_port_vlan_filtering(struct dsa_port *dp, bool vlan_filtering, struct netlink_ext_ack *extack);bool dsa_port_skip_vlan_configuration (struct dsa_port *dp);int dsa_port_ageing_time (struct dsa_port *dp,clock_t ageing_clock); +int dsa_port_vlan_msti (struct dsa_port *dp,const struct switchdev_attr *attr);int dsa_port_mtu_change (struct dsa_port *dp,int new_mtu,bool targeted_match); int dsa_port_fdb_add(struct dsa_port *dp, const unsigned char *addr,net/dsa/port.c +0
-0@@ -778,6 +778,16 @@ int dsa_port_bridge_flags(struct dsa_port *dp,return 0 ;
net/dsa/port.c int dsa_port_bridge_flags(struct dsa_port *dp, · line 788
Quoted 10 lines
net/dsa/port.c +8
-0} +int dsa_port_vlan_msti (struct dsa_port *dp,const struct switchdev_attr *attr) +{ +struct dsa_switch *ds = dp->ds; + +if (!ds->ops->vlan_msti_set) +return -EOPNOTSUPP ; + +return ds->ops->vlan_msti_set (ds, attr);
I guess this doesn't need to be a cross-chip notifier event for all switches, because replication to all bridge ports is handled by switchdev_handle_port_attr_set(). Ok. But isn't it called too many times per switch?
Quoted 25 lines
net/dsa/port.c +2
-0+} +int dsa_port_mtu_change (struct dsa_port *dp,int new_mtu,bool targeted_match) {net/dsa/slave.c +6
-0@@ -314,6 +314,12 @@ static int dsa_slave_port_attr_set(struct net_device *dev, const void *ctx, ret =dsa_port_bridge_flags (dp, attr->u.brport_flags, extack);break ; +case SWITCHDEV_ATTR_ID_VLAN_MSTI : +if (!dsa_port_offloads_bridge_dev (dp, attr->orig_dev)) +return -EOPNOTSUPP ; + + ret =dsa_port_vlan_msti (dp, attr); +break ;default : ret = -EOPNOTSUPP ;break ;Signature · 1 line
2.25.1
Re: [PATCH v2 net-next 06/10] net: dsa: Pass VLAN MSTI migration notifications to driver
Quoted 12 lines · Vladimir Oltean
Quoted 11 lines · Tobias Waldekranz
Add the usual trampoline functionality from the generic DSA layer down to the drivers for VLAN MSTI migrations.
Signed-off-by Tobias Waldekranz <[email protected]>--- include/net/dsa.h | 3 +++ net/dsa/dsa_priv.h | 1 + net/dsa/port.c | 10 ++++++++++ net/dsa/slave.c | 6 ++++++ 4 files changed, 20 insertions(+)
Quoted 14 lines
include/net/dsa.h struct dsa_switch_ops { · line 966
Quoted 10 lines
include/net/dsa.h +2
-0@@ -962,6 +962,9 @@ struct dsa_switch_ops { struct netlink_ext_ack *extack);int (*port_vlan_del)(struct dsa_switch *ds,int port,const struct switchdev_obj_port_vlan *vlan); +int (*vlan_msti_set)(struct dsa_switch *ds, +const struct switchdev_attr *attr);I would rather pass the struct
switchdev_vlan_attrand theorig_dev(bridge) as separate arguments here. Or even the structdsa_bridge, for consistency to the API changes for database isolation.
Fair point. I'll change.
Quoted 24 lines
Quoted 24 lines
include/net/dsa.h +1
-0+/* * Forwarding database */ net/dsa/dsa_priv.h +1
-0@@ -217,6 +217,7 @@ int dsa_port_vlan_filtering(struct dsa_port *dp, bool vlan_filtering, struct netlink_ext_ack *extack);bool dsa_port_skip_vlan_configuration (struct dsa_port *dp);int dsa_port_ageing_time (struct dsa_port *dp,clock_t ageing_clock); +int dsa_port_vlan_msti (struct dsa_port *dp,const struct switchdev_attr *attr);int dsa_port_mtu_change (struct dsa_port *dp,int new_mtu,bool targeted_match); int dsa_port_fdb_add(struct dsa_port *dp, const unsigned char *addr,net/dsa/port.c +0
-0@@ -778,6 +778,16 @@ int dsa_port_bridge_flags(struct dsa_port *dp,return 0 ; }
Quoted 13 lines
net/dsa/port.c int dsa_port_bridge_flags(struct dsa_port *dp, · line 788
Quoted 8 lines
net/dsa/port.c +8
-0+int dsa_port_vlan_msti (struct dsa_port *dp,const struct switchdev_attr *attr) +{ +struct dsa_switch *ds = dp->ds; + +if (!ds->ops->vlan_msti_set) +return -EOPNOTSUPP ; + +return ds->ops->vlan_msti_set (ds, attr);I guess this doesn't need to be a cross-chip notifier event for all switches, because replication to all bridge ports is handled by
switchdev_handle_port_attr_set(). Ok. But isn't it called too many times per switch?
It is certainly called more times than necessary. But I'm not aware of any way to limit it. Just as with other bridge-global settings like ageing timeout, the bridge will just replicate the event to each port, not knowing whether some of them belong to the same underlying ASIC or not.
We could leverage hwdoms in the bridge to figure that out, but then:
- Drivers that do not implement forward offloading would miss out on this optimization. Unfortunate but not a big deal.
- Since DSA presents multi-chip trees as a single switchdev, the DSA layer would have to replicate the event out to each device. Doable, but feels like a series of its own.
Quoted 25 lines
Quoted 25 lines
net/dsa/port.c +2
-0+} +int dsa_port_mtu_change (struct dsa_port *dp,int new_mtu,bool targeted_match) {net/dsa/slave.c +6
-0@@ -314,6 +314,12 @@ static int dsa_slave_port_attr_set(struct net_device *dev, const void *ctx, ret =dsa_port_bridge_flags (dp, attr->u.brport_flags, extack);break ; +case SWITCHDEV_ATTR_ID_VLAN_MSTI : +if (!dsa_port_offloads_bridge_dev (dp, attr->orig_dev)) +return -EOPNOTSUPP ; + + ret =dsa_port_vlan_msti (dp, attr); +break ;default : ret = -EOPNOTSUPP ;break ;Signature · 1 line
2.25.1
Vladimir Oltean
maintainerRe: [PATCH v2 net-next 06/10] net: dsa: Pass VLAN MSTI migration notifications to driver
Quoted 14 lines · Tobias Waldekranz
Quoted 5 lines
Quoted 5 lines
net/dsa/port.c +5
-0+int dsa_port_vlan_msti (struct dsa_port *dp,const struct switchdev_attr *attr) +{ +struct dsa_switch *ds = dp->ds; + +if (!ds->ops->vlan_msti_set)Quoted 8 lines
net/dsa/port.c int dsa_port_bridge_flags(struct dsa_port *dp, · line 788
Quoted 3 lines
net/dsa/port.c +3
-0+return -EOPNOTSUPP ; + +return ds->ops->vlan_msti_set (ds, attr);I guess this doesn't need to be a cross-chip notifier event for all switches, because replication to all bridge ports is handled by
switchdev_handle_port_attr_set(). Ok. But isn't it called too many times per switch?
Quoted 7 lines
It is certainly called more times than necessary. But I'm not aware of any way to limit it. Just as with other bridge-global settings like ageing timeout, the bridge will just replicate the event to each port, not knowing whether some of them belong to the same underlying ASIC or not.
We could leverage hwdoms in the bridge to figure that out, but then:
Hmm, uncalled for. Also, not sure how it helps (it just plain doesn't work, as you've pointed out below yourself).
Quoted 6 lines
- Drivers that do not implement forward offloading would miss out on this optimization. Unfortunate but not a big deal.
- Since DSA presents multi-chip trees as a single switchdev, the DSA layer would have to replicate the event out to each device. Doable, but feels like a series of its own.
I've mentally walked through the alternatives and I don't see a practical alternative than letting the driver cut out the duplicate calls.
Maybe it's worth raising awareness by adding a comment above the dsa_switch_ops :: vlan_msti_set definition that drivers should be prepared to handle such calls.
Case in point, in mv88e6xxx_vlan_msti_set() you could avoid some useless MDIO transactions (a call to mv88e6xxx_vtu_loadpurge) with a simple "if (vlan.sid != new_sid)" check. Basically just go through a refcount bump followed by an immediate drop.
PATCH v2 7/10 net: dsa: Pass MST state changes to driver
In reply to Tobias WaldekranzAdd the usual trampoline functionality from the generic DSA layer down to the drivers for MST state changes.
--- include/net/dsa.h | 2 ++ net/dsa/dsa_priv.h | 2 ++ net/dsa/port.c | 30 ++++++++++++++++++++++++++++++ net/dsa/slave.c | 6 ++++++ 4 files changed, 40 insertions(+)
include/net/dsa.h +2 -0
@@ -943,6 +943,8 @@ struct dsa_switch_ops { struct dsa_bridge bridge);void (*port_stp_state_set)(struct dsa_switch *ds,int port,u8 state); +int (*port_mst_state_set)(struct dsa_switch *ds,int port, +const struct switchdev_mst_state *state);void (*port_fast_age)(struct dsa_switch *ds,int port); int (*port_pre_bridge_flags)(struct dsa_switch *ds, int port, struct switchdev_brport_flags flags,
net/dsa/dsa_priv.h +2 -0
@@ -198,6 +198,8 @@ static inline struct net_device *dsa_master_find_slave(struct net_device *dev,void dsa_port_set_tag_protocol (struct dsa_port *cpu_dp,const struct dsa_device_ops *tag_ops);int dsa_port_set_state (struct dsa_port *dp,u8 state,bool do_fast_age); +int dsa_port_set_mst_state (struct dsa_port *dp, +const struct switchdev_mst_state *state);int dsa_port_enable_rt (struct dsa_port *dp,struct phy_device *phy);int dsa_port_enable (struct dsa_port *dp,struct phy_device *phy);void dsa_port_disable_rt (struct dsa_port *dp);
net/dsa/port.c +30 -0
@@ -108,6 +108,36 @@ int dsa_port_set_state(struct dsa_port *dp, u8 state, bool do_fast_age)return 0 ; } +int dsa_port_set_mst_state (struct dsa_port *dp, +const struct switchdev_mst_state *state) +{ +struct dsa_switch *ds = dp->ds; +int err, port = dp->index; + +if (!ds->ops->port_mst_state_set) +return -EOPNOTSUPP ; + + err = ds->ops->port_mst_state_set (ds, port, state); +if (err) +return err; + +if (!dsa_port_can_configure_learning (dp) || dp->learning) { +switch (state->state) { +case BR_STATE_DISABLED : +case BR_STATE_BLOCKING : +case BR_STATE_LISTENING : +/* Ideally we would only fast age entries +* belonging to VLANs controlled by this +* MST. +*/ +dsa_port_fast_age (dp); +break ; + } + } + +return 0 ; +} +static void dsa_port_set_state_now (struct dsa_port *dp,u8 state,bool do_fast_age) {
net/dsa/slave.c +6 -0
@@ -288,6 +288,12 @@ static int dsa_slave_port_attr_set(struct net_device *dev, const void *ctx, ret =dsa_port_set_state (dp, attr->u.stp_state, true);break ; +case SWITCHDEV_ATTR_ID_PORT_MST_STATE : +if (!dsa_port_offloads_bridge_port (dp, attr->orig_dev)) +return -EOPNOTSUPP ; + + ret =dsa_port_set_mst_state (dp, &attr->u.mst_state); +break ;case SWITCHDEV_ATTR_ID_BRIDGE_VLAN_FILTERING :if (!dsa_port_offloads_bridge_dev (dp, attr->orig_dev))return -EOPNOTSUPP ;
Signature · 1 line
2.25.1
Vladimir Oltean
maintainerRe: [PATCH v2 net-next 07/10] net: dsa: Pass MST state changes to driver
Quoted 58 lines · Tobias Waldekranz
Add the usual trampoline functionality from the generic DSA layer down to the drivers for MST state changes.
Signed-off-by Tobias Waldekranz <[email protected]>--- include/net/dsa.h | 2 ++ net/dsa/dsa_priv.h | 2 ++ net/dsa/port.c | 30 ++++++++++++++++++++++++++++++ net/dsa/slave.c | 6 ++++++ 4 files changed, 40 insertions(+)include/net/dsa.h +2
-0@@ -943,6 +943,8 @@ struct dsa_switch_ops { struct dsa_bridge bridge);void (*port_stp_state_set)(struct dsa_switch *ds,int port,u8 state); +int (*port_mst_state_set)(struct dsa_switch *ds,int port, +const struct switchdev_mst_state *state);void (*port_fast_age)(struct dsa_switch *ds,int port); int (*port_pre_bridge_flags)(struct dsa_switch *ds, int port, struct switchdev_brport_flags flags,net/dsa/dsa_priv.h +2
-0@@ -198,6 +198,8 @@ static inline struct net_device *dsa_master_find_slave(struct net_device *dev,void dsa_port_set_tag_protocol (struct dsa_port *cpu_dp,const struct dsa_device_ops *tag_ops);int dsa_port_set_state (struct dsa_port *dp,u8 state,bool do_fast_age); +int dsa_port_set_mst_state (struct dsa_port *dp, +const struct switchdev_mst_state *state);int dsa_port_enable_rt (struct dsa_port *dp,struct phy_device *phy);int dsa_port_enable (struct dsa_port *dp,struct phy_device *phy);void dsa_port_disable_rt (struct dsa_port *dp);net/dsa/port.c +13
-0@@ -108,6 +108,36 @@ int dsa_port_set_state(struct dsa_port *dp, u8 state, bool do_fast_age)return 0 ; } +int dsa_port_set_mst_state (struct dsa_port *dp, +const struct switchdev_mst_state *state) +{ +struct dsa_switch *ds = dp->ds; +int err, port = dp->index; + +if (!ds->ops->port_mst_state_set) +return -EOPNOTSUPP ; + + err = ds->ops->port_mst_state_set (ds, port, state); +if (err) +return err; +
net/dsa/port.c int dsa_port_set_state(struct dsa_port *dp, u8 state, bool do_fast_age) · line 133
Quoted 10 lines
net/dsa/port.c +10
-0+if (!dsa_port_can_configure_learning (dp) || dp->learning) { +switch (state->state) { +case BR_STATE_DISABLED : +case BR_STATE_BLOCKING : +case BR_STATE_LISTENING : +/* Ideally we would only fast age entries +* belonging to VLANs controlled by this +* MST. +*/ +dsa_port_fast_age (dp);
Does mv88e6xxx support this? If it does, you might just as well introduce another variant of ds->ops->port_fast_age() for an msti.
And since it is new code, you could require that drivers _do_ support configuring learning before they could support MSTP. After all, we don't want to keep legacy mechanisms in place forever.
Quoted 30 lines
net/dsa/port.c +7
-0+break ; + } + } + +return 0 ; +} +static void dsa_port_set_state_now (struct dsa_port *dp,u8 state,bool do_fast_age) {net/dsa/slave.c +6
-0@@ -288,6 +288,12 @@ static int dsa_slave_port_attr_set(struct net_device *dev, const void *ctx, ret =dsa_port_set_state (dp, attr->u.stp_state, true);break ; +case SWITCHDEV_ATTR_ID_PORT_MST_STATE : +if (!dsa_port_offloads_bridge_port (dp, attr->orig_dev)) +return -EOPNOTSUPP ; + + ret =dsa_port_set_mst_state (dp, &attr->u.mst_state); +break ;case SWITCHDEV_ATTR_ID_BRIDGE_VLAN_FILTERING :if (!dsa_port_offloads_bridge_dev (dp, attr->orig_dev))return -EOPNOTSUPP ;Signature · 1 line
2.25.1
Re: [PATCH v2 net-next 07/10] net: dsa: Pass MST state changes to driver
Quoted 64 lines · Vladimir Oltean
Quoted 63 lines · Tobias Waldekranz
Add the usual trampoline functionality from the generic DSA layer down to the drivers for MST state changes.
Signed-off-by Tobias Waldekranz <[email protected]>--- include/net/dsa.h | 2 ++ net/dsa/dsa_priv.h | 2 ++ net/dsa/port.c | 30 ++++++++++++++++++++++++++++++ net/dsa/slave.c | 6 ++++++ 4 files changed, 40 insertions(+)include/net/dsa.h +2
-0@@ -943,6 +943,8 @@ struct dsa_switch_ops { struct dsa_bridge bridge);void (*port_stp_state_set)(struct dsa_switch *ds,int port,u8 state); +int (*port_mst_state_set)(struct dsa_switch *ds,int port, +const struct switchdev_mst_state *state);void (*port_fast_age)(struct dsa_switch *ds,int port); int (*port_pre_bridge_flags)(struct dsa_switch *ds, int port, struct switchdev_brport_flags flags,net/dsa/dsa_priv.h +2
-0@@ -198,6 +198,8 @@ static inline struct net_device *dsa_master_find_slave(struct net_device *dev,void dsa_port_set_tag_protocol (struct dsa_port *cpu_dp,const struct dsa_device_ops *tag_ops);int dsa_port_set_state (struct dsa_port *dp,u8 state,bool do_fast_age); +int dsa_port_set_mst_state (struct dsa_port *dp, +const struct switchdev_mst_state *state);int dsa_port_enable_rt (struct dsa_port *dp,struct phy_device *phy);int dsa_port_enable (struct dsa_port *dp,struct phy_device *phy);void dsa_port_disable_rt (struct dsa_port *dp);net/dsa/port.c +18
-0@@ -108,6 +108,36 @@ int dsa_port_set_state(struct dsa_port *dp, u8 state, bool do_fast_age)return 0 ; } +int dsa_port_set_mst_state (struct dsa_port *dp, +const struct switchdev_mst_state *state) +{ +struct dsa_switch *ds = dp->ds; +int err, port = dp->index; + +if (!ds->ops->port_mst_state_set) +return -EOPNOTSUPP ; + + err = ds->ops->port_mst_state_set (ds, port, state); +if (err) +return err; + +if (!dsa_port_can_configure_learning (dp) || dp->learning) { +switch (state->state) { +case BR_STATE_DISABLED : +case BR_STATE_BLOCKING : +case BR_STATE_LISTENING :
Quoted 8 lines
net/dsa/port.c int dsa_port_set_state(struct dsa_port *dp, u8 state, bool do_fast_age) · line 133
Quoted 5 lines
net/dsa/port.c +5
-0+/* Ideally we would only fast age entries +* belonging to VLANs controlled by this +* MST. +*/ +dsa_port_fast_age (dp);Does mv88e6xxx support this? If it does, you might just as well introduce another variant of
ds->ops->port_fast_age()for an msti.
You can limit ATU operations to a particular FID. So the way I see it we could either have:
int (*port_vlan_fast_age)(struct dsa_switch *ds, int port, u16 vid)
+ Maybe more generic. You could imagine there being a way to trigger this operation from userspace for example.
- We would have to keep the VLAN<->MSTI mapping in the DSA layer in order to be able to do the fan-out in dsa_port_set_mst_state.
or:
int (*port_msti_fast_age)(struct dsa_switch *ds, int port, u16 msti)
+ Let's the mapping be an internal affair in the driver.
- Perhaps, less generically useful.
Which one do you prefer? Or is there a hidden third option? :)
Quoted 3 lines
And since it is new code, you could require that drivers _do_ support configuring learning before they could support MSTP. After all, we don't want to keep legacy mechanisms in place forever.
By "configuring learning", do you mean this new fast-age-per-vid/msti, or being able to enable/disable learning per port? If it's the latter, I'm not sure I understand how those two are related.
Vladimir Oltean
maintainerRe: [PATCH v2 net-next 07/10] net: dsa: Pass MST state changes to driver
Quoted 24 lines · Tobias Waldekranz
Quoted 5 lines
Quoted 5 lines
net/dsa/port.c +5
-0+if (!dsa_port_can_configure_learning (dp) || dp->learning) { +switch (state->state) { +case BR_STATE_DISABLED : +case BR_STATE_BLOCKING : +case BR_STATE_LISTENING :Quoted 8 lines
net/dsa/port.c int dsa_port_set_state(struct dsa_port *dp, u8 state, bool do_fast_age) · line 133
Quoted 5 lines
net/dsa/port.c +5
-0+/* Ideally we would only fast age entries +* belonging to VLANs controlled by this +* MST. +*/ +dsa_port_fast_age (dp);Does mv88e6xxx support this? If it does, you might just as well introduce another variant of
ds->ops->port_fast_age()for an msti.You can limit ATU operations to a particular FID. So the way I see it we could either have:
int (*port_vlan_fast_age)(struct
dsa_switch*ds, int port, u16 vid)+ Maybe more generic. You could imagine there being a way to trigger this operation from userspace for example.
- We would have to keep the VLAN<->MSTI mapping in the DSA layer in order to be able to do the fan-out indsa_port_set_mst_state.
Quoted 8 lines
or:
int (*port_msti_fast_age)(struct
dsa_switch*ds, int port, u16 msti)+ Let's the mapping be an internal affair in the driver.
- Perhaps, less generically useful.Which one do you prefer? Or is there a hidden third option? :)
Yes, I was thinking of "port_msti_fast_age". I don't see a cheap way of keeping VLAN to MSTI associations in the DSA layer. Only if we could retrieve this mapping from the bridge layer - maybe with something analogous to br_vlan_get_info(), but br_mst_get_info(), and this gets passed a VLAN_N_VID sized bitmap, which the bridge populates with ones and zeroes.
The reason why I asked for this is because I'm not sure of the implications of flushing the entire FDB of the port for a single MSTP state change. It would trigger temporary useless flooding in other MSTIs at the very least. There isn't any backwards compatibility concern to speak of, so we can at least try from the beginning to limit the flushing to the required VLANs.
What I didn't think about, and will be a problem, is dsa_port_notify_bridge_fdb_flush() - we don't know the vid to flush. The easy way out here would be to export dsa_port_notify_bridge_fdb_flush(), add a "vid" argument to it, and let drivers call it. Thoughts?
Alternatively, if you think that cross-flushing FDBs of multiple MSTIs isn't a real problem, I suppose we could keep the "port_fast_age" method.
Quoted 7 lines
Quoted 3 lines
And since it is new code, you could require that drivers _do_ support configuring learning before they could support MSTP. After all, we don't want to keep legacy mechanisms in place forever.
By "configuring learning", do you mean this new fast-age-per-vid/msti, or being able to enable/disable learning per port? If it's the latter, I'm not sure I understand how those two are related.
The code from dsa_port_set_state() which you've copied:
if (!dsa_port_can_configure_learning(dp) ||
(do_fast_age && dp->learning)) {has this explanation:
1. DSA keeps standalone ports in the FORWARDING state.
2. DSA also disables address learning on standalone ports, where this is possible (dsa_port_can_configure_learning(dp) == true).
3. When a port joins a bridge, it leaves its FORWARDING state from standalone mode and inherits the bridge port's BLOCKING state
4. dsa_port_set_state() treats a port transition from FORWARDING to BLOCKING as a transition requiring an FDB flush
5. due to (2), the FDB flush at stage (4) is in fact not needed, because the FDB of that port should already be empty. Flushing the FDB may be a costly operation for some drivers, so it is avoided if possible.
So this is why the "dsa_port_can_configure_learning()" check is there - for compatibility with drivers that can't configure learning => they keep learning enabled also in standalone mode => they need an FDB flush when a standalone port joins a bridge.
What I'm saying is: for drivers that offload MSTP, let's force them to get the basics right first (have configurable learning), rather than go forward forever with a backwards compatibility mode.
Re: [PATCH v2 net-next 07/10] net: dsa: Pass MST state changes to driver
Quoted 32 lines · Vladimir Oltean
Quoted 31 lines · Tobias Waldekranz
Quoted 5 lines
Quoted 5 lines
net/dsa/port.c +5
-0+if (!dsa_port_can_configure_learning (dp) || dp->learning) { +switch (state->state) { +case BR_STATE_DISABLED : +case BR_STATE_BLOCKING : +case BR_STATE_LISTENING :Quoted 8 lines
net/dsa/port.c int dsa_port_set_state(struct dsa_port *dp, u8 state, bool do_fast_age) · line 133
Quoted 5 lines
net/dsa/port.c +5
-0+/* Ideally we would only fast age entries +* belonging to VLANs controlled by this +* MST. +*/ +dsa_port_fast_age (dp);Does mv88e6xxx support this? If it does, you might just as well introduce another variant of
ds->ops->port_fast_age()for an msti.You can limit ATU operations to a particular FID. So the way I see it we could either have:
int (*port_vlan_fast_age)(struct
dsa_switch*ds, int port, u16 vid)+ Maybe more generic. You could imagine there being a way to trigger this operation from userspace for example.
- We would have to keep the VLAN<->MSTI mapping in the DSA layer in order to be able to do the fan-out indsa_port_set_mst_state.or:
int (*port_msti_fast_age)(struct
dsa_switch*ds, int port, u16 msti)+ Let's the mapping be an internal affair in the driver.
- Perhaps, less generically useful.
Quoted 8 lines
Quoted 1 line
Which one do you prefer? Or is there a hidden third option? :)
Yes, I was thinking of "
port_msti_fast_age". I don't see a cheap way of keeping VLAN to MSTI associations in the DSA layer. Only if we could retrieve this mapping from the bridge layer - maybe with something analogous tobr_vlan_get_info(), butbr_mst_get_info(), and this gets passed aVLAN_N_VIDsized bitmap, which the bridge populates with ones and zeroes.
That can easily be done. Given that, should we go for port_vlan_fast_age instead? port_msti_fast_age feels like an awkward interface, since I don't think there is any hardware out there that can actually perform that operation without internally fanning it out over all affected VIDs (or FIDs in the case of mv88e6xxx).
Quoted 6 lines
The reason why I asked for this is because I'm not sure of the implications of flushing the entire FDB of the port for a single MSTP state change. It would trigger temporary useless flooding in other MSTIs at the very least. There isn't any backwards compatibility concern to speak of, so we can at least try from the beginning to limit the flushing to the required VLANs.
Aside from the performance implications of flows being temporarily flooded I don't think there are any.
I suppose if you've disabled flooding of unknown unicast on that port, you would loose the flow until you see some return traffic (or when one side gives up and ARPs). While somewhat esoteric, it would be nice to handle this case if the hardware supports it.
Quoted 4 lines
What I didn't think about, and will be a problem, is
dsa_port_notify_bridge_fdb_flush()- we don't know the vid to flush. The easy way out here would be to exportdsa_port_notify_bridge_fdb_flush(), add a "vid" argument to it, and let drivers call it. Thoughts?
To me, this seems to be another argument in favor of port_vlan_fast_age. That way you would know the VIDs being flushed at the DSA layer, and driver writers needn't concern themselves with having to remember to generate the proper notifications back to the bridge.
Quoted 2 lines
Alternatively, if you think that cross-flushing FDBs of multiple MSTIs isn't a real problem, I suppose we could keep the "
port_fast_age" method.
What about falling back to it if the driver doesn't support per-VLAN flushing? Flushing all entries will work in most cases, at the cost of some temporary flooding. Seems more useful than refusing the offload completely.
Quoted 26 lines
Quoted 7 lines
Quoted 3 lines
And since it is new code, you could require that drivers _do_ support configuring learning before they could support MSTP. After all, we don't want to keep legacy mechanisms in place forever.
By "configuring learning", do you mean this new fast-age-per-vid/msti, or being able to enable/disable learning per port? If it's the latter, I'm not sure I understand how those two are related.
The code from
dsa_port_set_state()which you've copied:if (!dsa_port_can_configure_learning(dp) || (do_fast_age && dp->learning)) {has this explanation:
1. DSA keeps standalone ports in the FORWARDING state.
2. DSA also disables address learning on standalone ports, where this is possible (dsa_port_can_configure_learning(dp)== true).
3. When a port joins a bridge, it leaves its FORWARDING state from standalone mode and inherits the bridge port's BLOCKING state
4.dsa_port_set_state()treats a port transition from FORWARDING to BLOCKING as a transition requiring an FDB flush
5. due to (2), the FDB flush at stage (4) is in fact not needed, because the FDB of that port should already be empty. Flushing the FDB may be a costly operation for some drivers, so it is avoided if possible.
Quoted 8 lines
So this is why the "
dsa_port_can_configure_learning()" check is there - for compatibility with drivers that can't configure learning => they keep learning enabled also in standalone mode => they need an FDB flush when a standalone port joins a bridge.What I'm saying is: for drivers that offload MSTP, let's force them to get the basics right first (have configurable learning), rather than go forward forever with a backwards compatibility mode.
Makes sense, I'll just move it up to the initial capability check.
Vladimir Oltean
maintainerRe: [PATCH v2 net-next 07/10] net: dsa: Pass MST state changes to driver
Quoted 42 lines · Tobias Waldekranz
Quoted 32 lines · Vladimir Oltean
Quoted 31 lines · Tobias Waldekranz
Quoted 5 lines
Quoted 5 lines
net/dsa/port.c +5
-0+if (!dsa_port_can_configure_learning (dp) || dp->learning) { +switch (state->state) { +case BR_STATE_DISABLED : +case BR_STATE_BLOCKING : +case BR_STATE_LISTENING :Quoted 8 lines
net/dsa/port.c int dsa_port_set_state(struct dsa_port *dp, u8 state, bool do_fast_age) · line 133
Quoted 5 lines
net/dsa/port.c +5
-0+/* Ideally we would only fast age entries +* belonging to VLANs controlled by this +* MST. +*/ +dsa_port_fast_age (dp);Does mv88e6xxx support this? If it does, you might just as well introduce another variant of
ds->ops->port_fast_age()for an msti.You can limit ATU operations to a particular FID. So the way I see it we could either have:
int (*port_vlan_fast_age)(struct
dsa_switch*ds, int port, u16 vid)+ Maybe more generic. You could imagine there being a way to trigger this operation from userspace for example.
- We would have to keep the VLAN<->MSTI mapping in the DSA layer in order to be able to do the fan-out indsa_port_set_mst_state.or:
int (*port_msti_fast_age)(struct
dsa_switch*ds, int port, u16 msti)+ Let's the mapping be an internal affair in the driver.
- Perhaps, less generically useful.Quoted 8 lines
Quoted 1 line
Which one do you prefer? Or is there a hidden third option? :)
Yes, I was thinking of "
port_msti_fast_age". I don't see a cheap way of keeping VLAN to MSTI associations in the DSA layer. Only if we could retrieve this mapping from the bridge layer - maybe with something analogous tobr_vlan_get_info(), butbr_mst_get_info(), and this gets passed aVLAN_N_VIDsized bitmap, which the bridge populates with ones and zeroes.
Quoted 5 lines
That can easily be done. Given that, should we go for
port_vlan_fast_ageinstead?port_msti_fast_agefeels like an awkward interface, since I don't think there is any hardware out there that can actually perform that operation without internally fanning it out over all affected VIDs (or FIDs in the case of mv88e6xxx).
Yup, yup. My previous email was all over the place with regard to the available options, because I wrote it in multiple phases so it wasn't chronologically ordered top-to-bottom. But port_vlan_fast_age() makes the most sense if you can implement br_mst_get_info(). Same goes for dsa_port_notify_bridge_fdb_flush().
Quoted 7 lines
Quoted 6 lines
The reason why I asked for this is because I'm not sure of the implications of flushing the entire FDB of the port for a single MSTP state change. It would trigger temporary useless flooding in other MSTIs at the very least. There isn't any backwards compatibility concern to speak of, so we can at least try from the beginning to limit the flushing to the required VLANs.
Quoted 7 lines
Aside from the performance implications of flows being temporarily flooded I don't think there are any.
I suppose if you've disabled flooding of unknown unicast on that port, you would loose the flow until you see some return traffic (or when one side gives up and ARPs). While somewhat esoteric, it would be nice to handle this case if the hardware supports it.
If by "handle this case" you mean "flush only the affected VLANs", then yes, I fully agree.
Quoted 9 lines
Quoted 4 lines
What I didn't think about, and will be a problem, is
dsa_port_notify_bridge_fdb_flush()- we don't know the vid to flush. The easy way out here would be to exportdsa_port_notify_bridge_fdb_flush(), add a "vid" argument to it, and let drivers call it. Thoughts?To me, this seems to be another argument in favor of
port_vlan_fast_age. That way you would know the VIDs being flushed at the DSA layer, and driver writers needn't concern themselves with having to remember to generate the proper notifications back to the bridge.
See above.
Quoted 7 lines
Quoted 2 lines
Alternatively, if you think that cross-flushing FDBs of multiple MSTIs isn't a real problem, I suppose we could keep the "
port_fast_age" method.What about falling back to it if the driver doesn't support per-VLAN flushing? Flushing all entries will work in most cases, at the cost of some temporary flooding. Seems more useful than refusing the offload completely.
So here's what I don't understand. Do you expect a driver other than mv88e6xxx to do something remotely reasonable under a bridge with MSTP enabled? The idea being to handle gracefully the case where a port is BLOCKING in an MSTI but FORWARDING in another. Because if not, let's just outright not offload that kind of bridge, and only concern ourselves with what MST-capable drivers can do.
I'm shadowing you with a prototype (and untested so far) MSTP implementation for the ocelot/felix drivers, and those switches can flush the MAC table per VLAN too. So I don't see an immediate need to have a fallback implementation if you'll also provide it for mv88e6xxx. Let's treat that only if the need arises.
Quoted 36 lines
Quoted 26 lines
Quoted 7 lines
Quoted 3 lines
And since it is new code, you could require that drivers _do_ support configuring learning before they could support MSTP. After all, we don't want to keep legacy mechanisms in place forever.
By "configuring learning", do you mean this new fast-age-per-vid/msti, or being able to enable/disable learning per port? If it's the latter, I'm not sure I understand how those two are related.
The code from
dsa_port_set_state()which you've copied:if (!dsa_port_can_configure_learning(dp) || (do_fast_age && dp->learning)) {has this explanation:
1. DSA keeps standalone ports in the FORWARDING state.
2. DSA also disables address learning on standalone ports, where this is possible (dsa_port_can_configure_learning(dp)== true).
3. When a port joins a bridge, it leaves its FORWARDING state from standalone mode and inherits the bridge port's BLOCKING state
4.dsa_port_set_state()treats a port transition from FORWARDING to BLOCKING as a transition requiring an FDB flush
5. due to (2), the FDB flush at stage (4) is in fact not needed, because the FDB of that port should already be empty. Flushing the FDB may be a costly operation for some drivers, so it is avoided if possible.Quoted 8 lines
So this is why the "
dsa_port_can_configure_learning()" check is there - for compatibility with drivers that can't configure learning => they keep learning enabled also in standalone mode => they need an FDB flush when a standalone port joins a bridge.What I'm saying is: for drivers that offload MSTP, let's force them to get the basics right first (have configurable learning), rather than go forward forever with a backwards compatibility mode.
Makes sense, I'll just move it up to the initial capability check.
Re: [PATCH v2 net-next 07/10] net: dsa: Pass MST state changes to driver
Quoted 93 lines · Vladimir Oltean
Quoted 42 lines · Tobias Waldekranz
Quoted 32 lines · Vladimir Oltean
Quoted 31 lines · Tobias Waldekranz
Quoted 5 lines
Quoted 5 lines
net/dsa/port.c +5
-0+if (!dsa_port_can_configure_learning (dp) || dp->learning) { +switch (state->state) { +case BR_STATE_DISABLED : +case BR_STATE_BLOCKING : +case BR_STATE_LISTENING :Quoted 8 lines
net/dsa/port.c int dsa_port_set_state(struct dsa_port *dp, u8 state, bool do_fast_age) · line 133
Quoted 5 lines
net/dsa/port.c +5
-0+/* Ideally we would only fast age entries +* belonging to VLANs controlled by this +* MST. +*/ +dsa_port_fast_age (dp);Does mv88e6xxx support this? If it does, you might just as well introduce another variant of
ds->ops->port_fast_age()for an msti.You can limit ATU operations to a particular FID. So the way I see it we could either have:
int (*port_vlan_fast_age)(struct
dsa_switch*ds, int port, u16 vid)+ Maybe more generic. You could imagine there being a way to trigger this operation from userspace for example.
- We would have to keep the VLAN<->MSTI mapping in the DSA layer in order to be able to do the fan-out indsa_port_set_mst_state.or:
int (*port_msti_fast_age)(struct
dsa_switch*ds, int port, u16 msti)+ Let's the mapping be an internal affair in the driver.
- Perhaps, less generically useful.Quoted 8 lines
Quoted 1 line
Which one do you prefer? Or is there a hidden third option? :)
Yes, I was thinking of "
port_msti_fast_age". I don't see a cheap way of keeping VLAN to MSTI associations in the DSA layer. Only if we could retrieve this mapping from the bridge layer - maybe with something analogous tobr_vlan_get_info(), butbr_mst_get_info(), and this gets passed aVLAN_N_VIDsized bitmap, which the bridge populates with ones and zeroes.Quoted 5 lines
That can easily be done. Given that, should we go for
port_vlan_fast_ageinstead?port_msti_fast_agefeels like an awkward interface, since I don't think there is any hardware out there that can actually perform that operation without internally fanning it out over all affected VIDs (or FIDs in the case of mv88e6xxx).Yup, yup. My previous email was all over the place with regard to the available options, because I wrote it in multiple phases so it wasn't chronologically ordered top-to-bottom. But
port_vlan_fast_age()makes the most sense if you can implementbr_mst_get_info(). Same goes fordsa_port_notify_bridge_fdb_flush().Quoted 7 lines
Quoted 6 lines
The reason why I asked for this is because I'm not sure of the implications of flushing the entire FDB of the port for a single MSTP state change. It would trigger temporary useless flooding in other MSTIs at the very least. There isn't any backwards compatibility concern to speak of, so we can at least try from the beginning to limit the flushing to the required VLANs.
Quoted 7 lines
Aside from the performance implications of flows being temporarily flooded I don't think there are any.
I suppose if you've disabled flooding of unknown unicast on that port, you would loose the flow until you see some return traffic (or when one side gives up and ARPs). While somewhat esoteric, it would be nice to handle this case if the hardware supports it.
If by "handle this case" you mean "flush only the affected VLANs", then yes, I fully agree.
Quoted 9 lines
Quoted 4 lines
What I didn't think about, and will be a problem, is
dsa_port_notify_bridge_fdb_flush()- we don't know the vid to flush. The easy way out here would be to exportdsa_port_notify_bridge_fdb_flush(), add a "vid" argument to it, and let drivers call it. Thoughts?To me, this seems to be another argument in favor of
port_vlan_fast_age. That way you would know the VIDs being flushed at the DSA layer, and driver writers needn't concern themselves with having to remember to generate the proper notifications back to the bridge.See above.
Quoted 7 lines
Quoted 2 lines
Alternatively, if you think that cross-flushing FDBs of multiple MSTIs isn't a real problem, I suppose we could keep the "
port_fast_age" method.What about falling back to it if the driver doesn't support per-VLAN flushing? Flushing all entries will work in most cases, at the cost of some temporary flooding. Seems more useful than refusing the offload completely.
Quoted 6 lines
So here's what I don't understand. Do you expect a driver other than mv88e6xxx to do something remotely reasonable under a bridge with MSTP enabled? The idea being to handle gracefully the case where a port is BLOCKING in an MSTI but FORWARDING in another. Because if not, let's just outright not offload that kind of bridge, and only concern ourselves with what MST-capable drivers can do.
I think you're right. I was trying to make it easier for other driver writers, but it will just be more confusing and error prone.
Alright, so v3 will have something like this:
bool dsa_port_can_offload_mst(struct dsa_port *dp)
{
return ds->ops->vlan_msti_set &&
ds->ops->port_mst_state_set &&
ds->ops->port_vlan_fast_age &&
dsa_port_can_configure_learning(dp);
}If this returns false, we have two options:
1. Return -EOPNOTSUPP, which the bridge will be unable to discriminate from a non-switchdev port saying "I have no idea what you're talking about". I.e. the bridge will happily apply the config, but the hardware won't match. I don't like this, but it lines up with most other stuff.
2. Return a hard error, e.g. -EINVAL/-ENOSYS. This will keep the bridge in sync with the hardware and also gives some feedback to the user. This seems like the better approach to me, but it is a new kind of paradigm.
What do you think?
Quoted 5 lines
I'm shadowing you with a prototype (and untested so far) MSTP implementation for the ocelot/felix drivers, and those switches can flush the MAC table per VLAN too. So I don't see an immediate need to have a fallback implementation if you'll also provide it for mv88e6xxx. Let's treat that only if the need arises.
Cool. Agreed, v3 will implement .port_vlan_fast_age for mv88e6xxx.
Vladimir Oltean
maintainerRe: [PATCH v2 net-next 07/10] net: dsa: Pass MST state changes to driver
Quoted 122 lines · Tobias Waldekranz
Quoted 93 lines · Vladimir Oltean
Quoted 42 lines · Tobias Waldekranz
Quoted 32 lines · Vladimir Oltean
Quoted 31 lines · Tobias Waldekranz
Quoted 5 lines
Quoted 5 lines
(quoted diff) +5
-0+ if (!dsa_port_can_configure_learning(dp) || dp->learning) { + switch (state->state) { + case BR_STATE_DISABLED: + case BR_STATE_BLOCKING: + case BR_STATE_LISTENING:Quoted 8 lines
Review
Quoted 5 lines
(quoted diff) +5
-0+ /* Ideally we would only fast age entries + * belonging to VLANs controlled by this + * MST. + */ + dsa_port_fast_age(dp);Does mv88e6xxx support this? If it does, you might just as well introduce another variant of
ds->ops->port_fast_age()for an msti.You can limit ATU operations to a particular FID. So the way I see it we could either have:
int (*port_vlan_fast_age)(struct
dsa_switch*ds, int port, u16 vid)+ Maybe more generic. You could imagine there being a way to trigger this operation from userspace for example.
- We would have to keep the VLAN<->MSTI mapping in the DSA layer in order to be able to do the fan-out indsa_port_set_mst_state.or:
int (*port_msti_fast_age)(struct
dsa_switch*ds, int port, u16 msti)+ Let's the mapping be an internal affair in the driver.
- Perhaps, less generically useful.Quoted 8 lines
Quoted 1 line
Which one do you prefer? Or is there a hidden third option? :)
Yes, I was thinking of "
port_msti_fast_age". I don't see a cheap way of keeping VLAN to MSTI associations in the DSA layer. Only if we could retrieve this mapping from the bridge layer - maybe with something analogous tobr_vlan_get_info(), butbr_mst_get_info(), and this gets passed aVLAN_N_VIDsized bitmap, which the bridge populates with ones and zeroes.Quoted 5 lines
That can easily be done. Given that, should we go for
port_vlan_fast_ageinstead?port_msti_fast_agefeels like an awkward interface, since I don't think there is any hardware out there that can actually perform that operation without internally fanning it out over all affected VIDs (or FIDs in the case of mv88e6xxx).Yup, yup. My previous email was all over the place with regard to the available options, because I wrote it in multiple phases so it wasn't chronologically ordered top-to-bottom. But
port_vlan_fast_age()makes the most sense if you can implementbr_mst_get_info(). Same goes fordsa_port_notify_bridge_fdb_flush().Quoted 7 lines
Quoted 6 lines
The reason why I asked for this is because I'm not sure of the implications of flushing the entire FDB of the port for a single MSTP state change. It would trigger temporary useless flooding in other MSTIs at the very least. There isn't any backwards compatibility concern to speak of, so we can at least try from the beginning to limit the flushing to the required VLANs.
Quoted 7 lines
Aside from the performance implications of flows being temporarily flooded I don't think there are any.
I suppose if you've disabled flooding of unknown unicast on that port, you would loose the flow until you see some return traffic (or when one side gives up and ARPs). While somewhat esoteric, it would be nice to handle this case if the hardware supports it.
If by "handle this case" you mean "flush only the affected VLANs", then yes, I fully agree.
Quoted 9 lines
Quoted 4 lines
What I didn't think about, and will be a problem, is
dsa_port_notify_bridge_fdb_flush()- we don't know the vid to flush. The easy way out here would be to exportdsa_port_notify_bridge_fdb_flush(), add a "vid" argument to it, and let drivers call it. Thoughts?To me, this seems to be another argument in favor of
port_vlan_fast_age. That way you would know the VIDs being flushed at the DSA layer, and driver writers needn't concern themselves with having to remember to generate the proper notifications back to the bridge.See above.
Quoted 7 lines
Quoted 2 lines
Alternatively, if you think that cross-flushing FDBs of multiple MSTIs isn't a real problem, I suppose we could keep the "
port_fast_age" method.What about falling back to it if the driver doesn't support per-VLAN flushing? Flushing all entries will work in most cases, at the cost of some temporary flooding. Seems more useful than refusing the offload completely.
Quoted 6 lines
So here's what I don't understand. Do you expect a driver other than mv88e6xxx to do something remotely reasonable under a bridge with MSTP enabled? The idea being to handle gracefully the case where a port is BLOCKING in an MSTI but FORWARDING in another. Because if not, let's just outright not offload that kind of bridge, and only concern ourselves with what MST-capable drivers can do.
I think you're right. I was trying to make it easier for other driver writers, but it will just be more confusing and error prone.
Alright, so v3 will have something like this:
bool
dsa_port_can_offload_mst(struct dsa_port *dp){ return ds->ops->vlan_msti_set && ds->ops->port_mst_state_set && ds->ops->port_vlan_fast_age && dsa_port_can_configure_learning(dp); }If this returns false, we have two options:
1. Return
-EOPNOTSUPP, which the bridge will be unable to discriminate from a non-switchdev port saying "I have no idea what you're talking about". I.e. the bridge will happily apply the config, but the hardware won't match. I don't like this, but it lines up with most other stuff.
Quoted 6 lines
2. Return a hard error, e.g. -EINVAL/-ENOSYS. This will keep the bridge in sync with the hardware and also gives some feedback to the user. This seems like the better approach to me, but it is a new kind of paradigm.
What do you think?
Wait, what? It matters a lot where you place the call to dsa_port_can_offload_mst(), too. You don't have to propagate a hard error code, either, at least if you make dsa_port_bridge_join() return -EOPNOTSUPP prior to calling switchdev_bridge_port_offload(), no? DSA transforms this error code into 0, and dsa_port_offloads_bridge*() starts returning false, which makes us ignore all MSTP related switchdev notifiers.
The important part will be to make sure that MSTP is enabled for this bridge from the get-go (that being the only case in which we can offload an MSTP aware bridge), and refusing to offload dynamic changes to its MSTP state. I didn't re-check now, but I think I remember there being limitations even in the software bridge related to dynamic MSTP mode changes anyway - there had to not be any port VLANs, which IIUC means that you actually need to _delete_ the port PVIDs which are automatically created before you could change the MSTP mode.
This is the model, what's wrong with it? I said "don't offload the bridge", not "don't offload specific MSTP operations".
Quoted 7 lines
Quoted 5 lines
I'm shadowing you with a prototype (and untested so far) MSTP implementation for the ocelot/felix drivers, and those switches can flush the MAC table per VLAN too. So I don't see an immediate need to have a fallback implementation if you'll also provide it for mv88e6xxx. Let's treat that only if the need arises.
Cool. Agreed, v3 will implement .port_vlan_fast_age for mv88e6xxx.
Re: [PATCH v2 net-next 07/10] net: dsa: Pass MST state changes to driver
Quoted 130 lines · Vladimir Oltean
Quoted 122 lines · Tobias Waldekranz
Quoted 93 lines · Vladimir Oltean
Quoted 42 lines · Tobias Waldekranz
Quoted 32 lines · Vladimir Oltean
Quoted 31 lines · Tobias Waldekranz
Quoted 5 lines
Quoted 5 lines
(quoted diff) +5
-0+ if (!dsa_port_can_configure_learning(dp) || dp->learning) { + switch (state->state) { + case BR_STATE_DISABLED: + case BR_STATE_BLOCKING: + case BR_STATE_LISTENING:Quoted 8 lines
Review
Quoted 5 lines
(quoted diff) +5
-0+ /* Ideally we would only fast age entries + * belonging to VLANs controlled by this + * MST. + */ + dsa_port_fast_age(dp);Does mv88e6xxx support this? If it does, you might just as well introduce another variant of
ds->ops->port_fast_age()for an msti.You can limit ATU operations to a particular FID. So the way I see it we could either have:
int (*port_vlan_fast_age)(struct
dsa_switch*ds, int port, u16 vid)+ Maybe more generic. You could imagine there being a way to trigger this operation from userspace for example.
- We would have to keep the VLAN<->MSTI mapping in the DSA layer in order to be able to do the fan-out indsa_port_set_mst_state.or:
int (*port_msti_fast_age)(struct
dsa_switch*ds, int port, u16 msti)+ Let's the mapping be an internal affair in the driver.
- Perhaps, less generically useful.Quoted 8 lines
Quoted 1 line
Which one do you prefer? Or is there a hidden third option? :)
Yes, I was thinking of "
port_msti_fast_age". I don't see a cheap way of keeping VLAN to MSTI associations in the DSA layer. Only if we could retrieve this mapping from the bridge layer - maybe with something analogous tobr_vlan_get_info(), butbr_mst_get_info(), and this gets passed aVLAN_N_VIDsized bitmap, which the bridge populates with ones and zeroes.Quoted 5 lines
That can easily be done. Given that, should we go for
port_vlan_fast_ageinstead?port_msti_fast_agefeels like an awkward interface, since I don't think there is any hardware out there that can actually perform that operation without internally fanning it out over all affected VIDs (or FIDs in the case of mv88e6xxx).Yup, yup. My previous email was all over the place with regard to the available options, because I wrote it in multiple phases so it wasn't chronologically ordered top-to-bottom. But
port_vlan_fast_age()makes the most sense if you can implementbr_mst_get_info(). Same goes fordsa_port_notify_bridge_fdb_flush().Quoted 7 lines
Quoted 6 lines
The reason why I asked for this is because I'm not sure of the implications of flushing the entire FDB of the port for a single MSTP state change. It would trigger temporary useless flooding in other MSTIs at the very least. There isn't any backwards compatibility concern to speak of, so we can at least try from the beginning to limit the flushing to the required VLANs.
Quoted 7 lines
Aside from the performance implications of flows being temporarily flooded I don't think there are any.
I suppose if you've disabled flooding of unknown unicast on that port, you would loose the flow until you see some return traffic (or when one side gives up and ARPs). While somewhat esoteric, it would be nice to handle this case if the hardware supports it.
If by "handle this case" you mean "flush only the affected VLANs", then yes, I fully agree.
Quoted 9 lines
Quoted 4 lines
What I didn't think about, and will be a problem, is
dsa_port_notify_bridge_fdb_flush()- we don't know the vid to flush. The easy way out here would be to exportdsa_port_notify_bridge_fdb_flush(), add a "vid" argument to it, and let drivers call it. Thoughts?To me, this seems to be another argument in favor of
port_vlan_fast_age. That way you would know the VIDs being flushed at the DSA layer, and driver writers needn't concern themselves with having to remember to generate the proper notifications back to the bridge.See above.
Quoted 7 lines
Quoted 2 lines
Alternatively, if you think that cross-flushing FDBs of multiple MSTIs isn't a real problem, I suppose we could keep the "
port_fast_age" method.What about falling back to it if the driver doesn't support per-VLAN flushing? Flushing all entries will work in most cases, at the cost of some temporary flooding. Seems more useful than refusing the offload completely.
Quoted 6 lines
So here's what I don't understand. Do you expect a driver other than mv88e6xxx to do something remotely reasonable under a bridge with MSTP enabled? The idea being to handle gracefully the case where a port is BLOCKING in an MSTI but FORWARDING in another. Because if not, let's just outright not offload that kind of bridge, and only concern ourselves with what MST-capable drivers can do.
I think you're right. I was trying to make it easier for other driver writers, but it will just be more confusing and error prone.
Alright, so v3 will have something like this:
bool
dsa_port_can_offload_mst(struct dsa_port *dp){ return ds->ops->vlan_msti_set && ds->ops->port_mst_state_set && ds->ops->port_vlan_fast_age && dsa_port_can_configure_learning(dp); }If this returns false, we have two options:
1. Return
-EOPNOTSUPP, which the bridge will be unable to discriminate from a non-switchdev port saying "I have no idea what you're talking about". I.e. the bridge will happily apply the config, but the hardware won't match. I don't like this, but it lines up with most other stuff.Quoted 6 lines
2. Return a hard error, e.g. -EINVAL/-ENOSYS. This will keep the bridge in sync with the hardware and also gives some feedback to the user. This seems like the better approach to me, but it is a new kind of paradigm.
What do you think?
Quoted 7 lines
Wait, what? It matters a lot where you place the call to
dsa_port_can_offload_mst(), too. You don't have to propagate a hard error code, either, at least if you makedsa_port_bridge_join()return-EOPNOTSUPPprior to callingswitchdev_bridge_port_offload(), no? DSA transforms this error code into 0, and dsa_port_offloads_bridge*() starts returning false, which makes us ignore all MSTP related switchdev notifiers.
Right. So we also need:
1. A br_mst_enabled() that we can call from dsa_port_bridge_join to validate the initial state.
2. A switchdev attr event sent out when enabling/disabling MST on the bridge, so that we can NAK the change.
Quoted 4 lines
The important part will be to make sure that MSTP is enabled for this bridge from the get-go (that being the only case in which we can offload an MSTP aware bridge), and refusing to offload dynamic changes to its MSTP state. I didn't re-check now, but I think I remember there being
Hang on though. Won't that mean that this sequence...
ip link add dev br0 type bridge \
vlan_filtering 1 vlan_default_pvid 0 mst_enable 1
ip link set dev swp1 master br0
...will work, but offloading will be disabled on swp0; whereas this sequence...
ip link add dev br0 type bridge \
vlan_filtering 1 vlan_default_pvid 0
ip link set dev swp1 master br0
ip link set dev br0 type bridge mst_enable 1
...will fail on the final command? Even though they are logically equivalent? But maybe that's just the way the cookie crumbles.
Quoted 4 lines
limitations even in the software bridge related to dynamic MSTP mode changes anyway - there had to not be any port VLANs, which IIUC means that you actually need to _delete_ the port PVIDs which are automatically created before you could change the MSTP mode.
There are some ergonomic issues there, yes. I might look at it again and see if there is some reasonable way of allowing the mode to be changed even when VLANs are present.
Quoted 2 lines
This is the model, what's wrong with it? I said "don't offload the bridge", not "don't offload specific MSTP operations".
Nothing is wrong, I just couldn't see the whole picture.
This is the way.
Vladimir Oltean
maintainerRe: [PATCH v2 net-next 07/10] net: dsa: Pass MST state changes to driver
Quoted 139 lines · Tobias Waldekranz
Quoted 130 lines · Vladimir Oltean
Quoted 122 lines · Tobias Waldekranz
Quoted 93 lines · Vladimir Oltean
Quoted 42 lines · Tobias Waldekranz
Quoted 32 lines · Vladimir Oltean
Quoted 31 lines · Tobias Waldekranz
Quoted 5 lines
Quoted 5 lines
(quoted diff) +5
-0+ if (!dsa_port_can_configure_learning(dp) || dp->learning) { + switch (state->state) { + case BR_STATE_DISABLED: + case BR_STATE_BLOCKING: + case BR_STATE_LISTENING:Quoted 8 lines
Review
Quoted 5 lines
(quoted diff) +5
-0+ /* Ideally we would only fast age entries + * belonging to VLANs controlled by this + * MST. + */ + dsa_port_fast_age(dp);Does mv88e6xxx support this? If it does, you might just as well introduce another variant of
ds->ops->port_fast_age()for an msti.You can limit ATU operations to a particular FID. So the way I see it we could either have:
int (*port_vlan_fast_age)(struct
dsa_switch*ds, int port, u16 vid)+ Maybe more generic. You could imagine there being a way to trigger this operation from userspace for example.
- We would have to keep the VLAN<->MSTI mapping in the DSA layer in order to be able to do the fan-out indsa_port_set_mst_state.or:
int (*port_msti_fast_age)(struct
dsa_switch*ds, int port, u16 msti)+ Let's the mapping be an internal affair in the driver.
- Perhaps, less generically useful.Quoted 8 lines
Quoted 1 line
Which one do you prefer? Or is there a hidden third option? :)
Yes, I was thinking of "
port_msti_fast_age". I don't see a cheap way of keeping VLAN to MSTI associations in the DSA layer. Only if we could retrieve this mapping from the bridge layer - maybe with something analogous tobr_vlan_get_info(), butbr_mst_get_info(), and this gets passed aVLAN_N_VIDsized bitmap, which the bridge populates with ones and zeroes.Quoted 5 lines
That can easily be done. Given that, should we go for
port_vlan_fast_ageinstead?port_msti_fast_agefeels like an awkward interface, since I don't think there is any hardware out there that can actually perform that operation without internally fanning it out over all affected VIDs (or FIDs in the case of mv88e6xxx).Yup, yup. My previous email was all over the place with regard to the available options, because I wrote it in multiple phases so it wasn't chronologically ordered top-to-bottom. But
port_vlan_fast_age()makes the most sense if you can implementbr_mst_get_info(). Same goes fordsa_port_notify_bridge_fdb_flush().Quoted 7 lines
Quoted 6 lines
The reason why I asked for this is because I'm not sure of the implications of flushing the entire FDB of the port for a single MSTP state change. It would trigger temporary useless flooding in other MSTIs at the very least. There isn't any backwards compatibility concern to speak of, so we can at least try from the beginning to limit the flushing to the required VLANs.
Quoted 7 lines
Aside from the performance implications of flows being temporarily flooded I don't think there are any.
I suppose if you've disabled flooding of unknown unicast on that port, you would loose the flow until you see some return traffic (or when one side gives up and ARPs). While somewhat esoteric, it would be nice to handle this case if the hardware supports it.
If by "handle this case" you mean "flush only the affected VLANs", then yes, I fully agree.
Quoted 9 lines
Quoted 4 lines
What I didn't think about, and will be a problem, is
dsa_port_notify_bridge_fdb_flush()- we don't know the vid to flush. The easy way out here would be to exportdsa_port_notify_bridge_fdb_flush(), add a "vid" argument to it, and let drivers call it. Thoughts?To me, this seems to be another argument in favor of
port_vlan_fast_age. That way you would know the VIDs being flushed at the DSA layer, and driver writers needn't concern themselves with having to remember to generate the proper notifications back to the bridge.See above.
Quoted 7 lines
Quoted 2 lines
Alternatively, if you think that cross-flushing FDBs of multiple MSTIs isn't a real problem, I suppose we could keep the "
port_fast_age" method.What about falling back to it if the driver doesn't support per-VLAN flushing? Flushing all entries will work in most cases, at the cost of some temporary flooding. Seems more useful than refusing the offload completely.
Quoted 6 lines
So here's what I don't understand. Do you expect a driver other than mv88e6xxx to do something remotely reasonable under a bridge with MSTP enabled? The idea being to handle gracefully the case where a port is BLOCKING in an MSTI but FORWARDING in another. Because if not, let's just outright not offload that kind of bridge, and only concern ourselves with what MST-capable drivers can do.
I think you're right. I was trying to make it easier for other driver writers, but it will just be more confusing and error prone.
Alright, so v3 will have something like this:
bool
dsa_port_can_offload_mst(struct dsa_port *dp){ return ds->ops->vlan_msti_set && ds->ops->port_mst_state_set && ds->ops->port_vlan_fast_age && dsa_port_can_configure_learning(dp); }If this returns false, we have two options:
1. Return
-EOPNOTSUPP, which the bridge will be unable to discriminate from a non-switchdev port saying "I have no idea what you're talking about". I.e. the bridge will happily apply the config, but the hardware won't match. I don't like this, but it lines up with most other stuff.Quoted 6 lines
2. Return a hard error, e.g. -EINVAL/-ENOSYS. This will keep the bridge in sync with the hardware and also gives some feedback to the user. This seems like the better approach to me, but it is a new kind of paradigm.
What do you think?
Quoted 7 lines
Wait, what? It matters a lot where you place the call to
dsa_port_can_offload_mst(), too. You don't have to propagate a hard error code, either, at least if you makedsa_port_bridge_join()return-EOPNOTSUPPprior to callingswitchdev_bridge_port_offload(), no? DSA transforms this error code into 0, and dsa_port_offloads_bridge*() starts returning false, which makes us ignore all MSTP related switchdev notifiers.
Quoted 7 lines
Right. So we also need:
1. A
br_mst_enabled()that we can call fromdsa_port_bridge_jointo validate the initial state.2. A switchdev attr event sent out when enabling/disabling MST on the bridge, so that we can NAK the change.
So far, so good. This, to me, is analogous to the way in which a hypothetical VLAN-unaware switchdev driver wouldn't deny VLAN additions or removals, but it would only accept a VLAN-unaware bridge, and refuse to transition into a VLAN-aware one. So even though we wouldn't deny the bridge from keeping state that would have effect when VLAN awareness is on, we would just deny the bridge from making that state active. Same with MSTP awareness in my view - don't deny MSTI migrations, per-MSTI port state changes etc, just the ability to turn on MSTP awareness.
In practice I have only seen things done the other way around - the dpaa2-switch driver refuses VLAN-unaware bridges, so it doesn't need to handle ignoring VLAN switchdev notifiers - a slightly simpler task. Also, the concept of unoffloaded uppers seems to be pretty unique to DSA so far, among switchdev drivers.
Quoted 14 lines
Quoted 4 lines
The important part will be to make sure that MSTP is enabled for this bridge from the get-go (that being the only case in which we can offload an MSTP aware bridge), and refusing to offload dynamic changes to its MSTP state. I didn't re-check now, but I think I remember there being
Hang on though. Won't that mean that this sequence...
ip link add dev br0 type bridge \
vlan_filtering1vlan_default_pvid0mst_enable1
ip link set dev swp1 master br0...will work, but offloading will be disabled on swp0; whereas this sequence...
Quoted 7 lines
ip link add dev br0 type bridge \
vlan_filtering1vlan_default_pvid0
ip link set dev swp1 master br0
ip link set dev br0 type bridgemst_enable1...will fail on the final command? Even though they are logically equivalent? But maybe that's just the way the cookie crumbles.
Well, they could be made equivalent for academic purposes, if you're prepared to dynamically unoffload a bridge port from the MST awareness notifier, be my guest, I never tried it... I suppose we could try it, in theory it's just a call to dsa_port_pre_bridge_leave() + dsa_port_bridge_leave() after all. But it's effort to be spent in work and testing, and I'm not sure whether anyone will see the benefit or use case. During initial bridge join, at least it's an established code path, the drivers which don't implement ds->ops->port_bridge_join() have exercised it. Alvin Šipraga has fixed a few bugs related to rtl8365mb and this after some recent rework, it should work just fine now.
Quoted 15 lines
Quoted 4 lines
limitations even in the software bridge related to dynamic MSTP mode changes anyway - there had to not be any port VLANs, which IIUC means that you actually need to _delete_ the port PVIDs which are automatically created before you could change the MSTP mode.
There are some ergonomic issues there, yes. I might look at it again and see if there is some reasonable way of allowing the mode to be changed even when VLANs are present.
Quoted 2 lines
This is the model, what's wrong with it? I said "don't offload the bridge", not "don't offload specific MSTP operations".
Nothing is wrong, I just couldn't see the whole picture.
This is the way.
Re: [PATCH v2 net-next 07/10] net: dsa: Pass MST state changes to driver
Quoted 185 lines · Vladimir Oltean
Quoted 139 lines · Tobias Waldekranz
Quoted 130 lines · Vladimir Oltean
Quoted 122 lines · Tobias Waldekranz
Quoted 93 lines · Vladimir Oltean
Quoted 42 lines · Tobias Waldekranz
Quoted 32 lines · Vladimir Oltean
Quoted 31 lines · Tobias Waldekranz
Quoted 5 lines
Quoted 5 lines
(quoted diff) +5
-0+ if (!dsa_port_can_configure_learning(dp) || dp->learning) { + switch (state->state) { + case BR_STATE_DISABLED: + case BR_STATE_BLOCKING: + case BR_STATE_LISTENING:Quoted 8 lines
Review
Quoted 5 lines
(quoted diff) +5
-0+ /* Ideally we would only fast age entries + * belonging to VLANs controlled by this + * MST. + */ + dsa_port_fast_age(dp);Does mv88e6xxx support this? If it does, you might just as well introduce another variant of
ds->ops->port_fast_age()for an msti.You can limit ATU operations to a particular FID. So the way I see it we could either have:
int (*port_vlan_fast_age)(struct
dsa_switch*ds, int port, u16 vid)+ Maybe more generic. You could imagine there being a way to trigger this operation from userspace for example.
- We would have to keep the VLAN<->MSTI mapping in the DSA layer in order to be able to do the fan-out indsa_port_set_mst_state.or:
int (*port_msti_fast_age)(struct
dsa_switch*ds, int port, u16 msti)+ Let's the mapping be an internal affair in the driver.
- Perhaps, less generically useful.Quoted 8 lines
Quoted 1 line
Which one do you prefer? Or is there a hidden third option? :)
Yes, I was thinking of "
port_msti_fast_age". I don't see a cheap way of keeping VLAN to MSTI associations in the DSA layer. Only if we could retrieve this mapping from the bridge layer - maybe with something analogous tobr_vlan_get_info(), butbr_mst_get_info(), and this gets passed aVLAN_N_VIDsized bitmap, which the bridge populates with ones and zeroes.Quoted 5 lines
That can easily be done. Given that, should we go for
port_vlan_fast_ageinstead?port_msti_fast_agefeels like an awkward interface, since I don't think there is any hardware out there that can actually perform that operation without internally fanning it out over all affected VIDs (or FIDs in the case of mv88e6xxx).Yup, yup. My previous email was all over the place with regard to the available options, because I wrote it in multiple phases so it wasn't chronologically ordered top-to-bottom. But
port_vlan_fast_age()makes the most sense if you can implementbr_mst_get_info(). Same goes fordsa_port_notify_bridge_fdb_flush().Quoted 7 lines
Quoted 6 lines
The reason why I asked for this is because I'm not sure of the implications of flushing the entire FDB of the port for a single MSTP state change. It would trigger temporary useless flooding in other MSTIs at the very least. There isn't any backwards compatibility concern to speak of, so we can at least try from the beginning to limit the flushing to the required VLANs.
Quoted 7 lines
Aside from the performance implications of flows being temporarily flooded I don't think there are any.
I suppose if you've disabled flooding of unknown unicast on that port, you would loose the flow until you see some return traffic (or when one side gives up and ARPs). While somewhat esoteric, it would be nice to handle this case if the hardware supports it.
If by "handle this case" you mean "flush only the affected VLANs", then yes, I fully agree.
Quoted 9 lines
Quoted 4 lines
What I didn't think about, and will be a problem, is
dsa_port_notify_bridge_fdb_flush()- we don't know the vid to flush. The easy way out here would be to exportdsa_port_notify_bridge_fdb_flush(), add a "vid" argument to it, and let drivers call it. Thoughts?To me, this seems to be another argument in favor of
port_vlan_fast_age. That way you would know the VIDs being flushed at the DSA layer, and driver writers needn't concern themselves with having to remember to generate the proper notifications back to the bridge.See above.
Quoted 7 lines
Quoted 2 lines
Alternatively, if you think that cross-flushing FDBs of multiple MSTIs isn't a real problem, I suppose we could keep the "
port_fast_age" method.What about falling back to it if the driver doesn't support per-VLAN flushing? Flushing all entries will work in most cases, at the cost of some temporary flooding. Seems more useful than refusing the offload completely.
Quoted 6 lines
So here's what I don't understand. Do you expect a driver other than mv88e6xxx to do something remotely reasonable under a bridge with MSTP enabled? The idea being to handle gracefully the case where a port is BLOCKING in an MSTI but FORWARDING in another. Because if not, let's just outright not offload that kind of bridge, and only concern ourselves with what MST-capable drivers can do.
I think you're right. I was trying to make it easier for other driver writers, but it will just be more confusing and error prone.
Alright, so v3 will have something like this:
bool
dsa_port_can_offload_mst(struct dsa_port *dp){ return ds->ops->vlan_msti_set && ds->ops->port_mst_state_set && ds->ops->port_vlan_fast_age && dsa_port_can_configure_learning(dp); }If this returns false, we have two options:
1. Return
-EOPNOTSUPP, which the bridge will be unable to discriminate from a non-switchdev port saying "I have no idea what you're talking about". I.e. the bridge will happily apply the config, but the hardware won't match. I don't like this, but it lines up with most other stuff.Quoted 6 lines
2. Return a hard error, e.g. -EINVAL/-ENOSYS. This will keep the bridge in sync with the hardware and also gives some feedback to the user. This seems like the better approach to me, but it is a new kind of paradigm.
What do you think?
Quoted 7 lines
Wait, what? It matters a lot where you place the call to
dsa_port_can_offload_mst(), too. You don't have to propagate a hard error code, either, at least if you makedsa_port_bridge_join()return-EOPNOTSUPPprior to callingswitchdev_bridge_port_offload(), no? DSA transforms this error code into 0, and dsa_port_offloads_bridge*() starts returning false, which makes us ignore all MSTP related switchdev notifiers.Quoted 7 lines
Right. So we also need:
1. A
br_mst_enabled()that we can call fromdsa_port_bridge_jointo validate the initial state.2. A switchdev attr event sent out when enabling/disabling MST on the bridge, so that we can NAK the change.
So far, so good. This, to me, is analogous to the way in which a hypothetical VLAN-unaware switchdev driver wouldn't deny VLAN additions or removals, but it would only accept a VLAN-unaware bridge, and refuse to transition into a VLAN-aware one. So even though we wouldn't deny the bridge from keeping state that would have effect when VLAN awareness is on, we would just deny the bridge from making that state active. Same with MSTP awareness in my view - don't deny MSTI migrations, per-MSTI port state changes etc, just the ability to turn on MSTP awareness.
In practice I have only seen things done the other way around - the dpaa2-switch driver refuses VLAN-unaware bridges, so it doesn't need to handle ignoring VLAN switchdev notifiers - a slightly simpler task. Also, the concept of unoffloaded uppers seems to be pretty unique to DSA so far, among switchdev drivers.
Quoted 14 lines
Quoted 4 lines
The important part will be to make sure that MSTP is enabled for this bridge from the get-go (that being the only case in which we can offload an MSTP aware bridge), and refusing to offload dynamic changes to its MSTP state. I didn't re-check now, but I think I remember there being
Hang on though. Won't that mean that this sequence...
ip link add dev br0 type bridge \
vlan_filtering1vlan_default_pvid0mst_enable1
ip link set dev swp1 master br0...will work, but offloading will be disabled on swp0; whereas this sequence...
Quoted 7 lines
ip link add dev br0 type bridge \
vlan_filtering1vlan_default_pvid0
ip link set dev swp1 master br0
ip link set dev br0 type bridgemst_enable1...will fail on the final command? Even though they are logically equivalent? But maybe that's just the way the cookie crumbles.
Quoted 10 lines
Well, they could be made equivalent for academic purposes, if you're prepared to dynamically unoffload a bridge port from the MST awareness notifier, be my guest, I never tried it... I suppose we could try it, in theory it's just a call to
dsa_port_pre_bridge_leave()+dsa_port_bridge_leave()after all. But it's effort to be spent in work and testing, and I'm not sure whether anyone will see the benefit or use case. During initial bridge join, at least it's an established code path, the drivers which don't implementds->ops->port_bridge_join()have exercised it. Alvin Šipraga has fixed a few bugs related to rtl8365mb and this after some recent rework, it should work just fine now.
I completely agree. Just wanted to make sure that I had understood it correctly. Thanks.
Quoted 15 lines
Quoted 15 lines
Quoted 4 lines
limitations even in the software bridge related to dynamic MSTP mode changes anyway - there had to not be any port VLANs, which IIUC means that you actually need to _delete_ the port PVIDs which are automatically created before you could change the MSTP mode.
There are some ergonomic issues there, yes. I might look at it again and see if there is some reasonable way of allowing the mode to be changed even when VLANs are present.
Quoted 2 lines
This is the model, what's wrong with it? I said "don't offload the bridge", not "don't offload specific MSTP operations".
Nothing is wrong, I just couldn't see the whole picture.
This is the way.
Re: [PATCH v2 net-next 07/10] net: dsa: Pass MST state changes to driver
In reply to Tobias WaldekranzQuoted 73 lines · Tobias Waldekranz
Quoted 32 lines · Vladimir Oltean
Quoted 31 lines · Tobias Waldekranz
Quoted 5 lines
Quoted 5 lines
net/dsa/port.c +5
-0+if (!dsa_port_can_configure_learning (dp) || dp->learning) { +switch (state->state) { +case BR_STATE_DISABLED : +case BR_STATE_BLOCKING : +case BR_STATE_LISTENING :Quoted 8 lines
net/dsa/port.c int dsa_port_set_state(struct dsa_port *dp, u8 state, bool do_fast_age) · line 133
Quoted 5 lines
net/dsa/port.c +5
-0+/* Ideally we would only fast age entries +* belonging to VLANs controlled by this +* MST. +*/ +dsa_port_fast_age (dp);Does mv88e6xxx support this? If it does, you might just as well introduce another variant of
ds->ops->port_fast_age()for an msti.You can limit ATU operations to a particular FID. So the way I see it we could either have:
int (*port_vlan_fast_age)(struct
dsa_switch*ds, int port, u16 vid)+ Maybe more generic. You could imagine there being a way to trigger this operation from userspace for example.
- We would have to keep the VLAN<->MSTI mapping in the DSA layer in order to be able to do the fan-out indsa_port_set_mst_state.or:
int (*port_msti_fast_age)(struct
dsa_switch*ds, int port, u16 msti)+ Let's the mapping be an internal affair in the driver.
- Perhaps, less generically useful.Quoted 8 lines
Quoted 1 line
Which one do you prefer? Or is there a hidden third option? :)
Yes, I was thinking of "
port_msti_fast_age". I don't see a cheap way of keeping VLAN to MSTI associations in the DSA layer. Only if we could retrieve this mapping from the bridge layer - maybe with something analogous tobr_vlan_get_info(), butbr_mst_get_info(), and this gets passed aVLAN_N_VIDsized bitmap, which the bridge populates with ones and zeroes.That can easily be done. Given that, should we go for
port_vlan_fast_ageinstead?port_msti_fast_agefeels like an awkward interface, since I don't think there is any hardware out there that can actually perform that operation without internally fanning it out over all affected VIDs (or FIDs in the case of mv88e6xxx).Quoted 6 lines
The reason why I asked for this is because I'm not sure of the implications of flushing the entire FDB of the port for a single MSTP state change. It would trigger temporary useless flooding in other MSTIs at the very least. There isn't any backwards compatibility concern to speak of, so we can at least try from the beginning to limit the flushing to the required VLANs.
Aside from the performance implications of flows being temporarily flooded I don't think there are any.
I suppose if you've disabled flooding of unknown unicast on that port, you would loose the flow until you see some return traffic (or when one side gives up and ARPs). While somewhat esoteric, it would be nice to handle this case if the hardware supports it.
Quoted 4 lines
What I didn't think about, and will be a problem, is
dsa_port_notify_bridge_fdb_flush()- we don't know the vid to flush. The easy way out here would be to exportdsa_port_notify_bridge_fdb_flush(), add a "vid" argument to it, and let drivers call it. Thoughts?To me, this seems to be another argument in favor of
port_vlan_fast_age. That way you would know the VIDs being flushed at the DSA layer, and driver writers needn't concern themselves with having to remember to generate the proper notifications back to the bridge.
Quoted 7 lines
Quoted 2 lines
Alternatively, if you think that cross-flushing FDBs of multiple MSTIs isn't a real problem, I suppose we could keep the "
port_fast_age" method.What about falling back to it if the driver doesn't support per-VLAN flushing? Flushing all entries will work in most cases, at the cost of some temporary flooding. Seems more useful than refusing the offload completely.
Actually now that I think about it, maybe it is more reasonable to risk having stale entries in the VLANs where the topology changed, rather than nuking flows in unrelated VLANs.
Quoted 36 lines
Quoted 26 lines
Quoted 7 lines
Quoted 3 lines
And since it is new code, you could require that drivers _do_ support configuring learning before they could support MSTP. After all, we don't want to keep legacy mechanisms in place forever.
By "configuring learning", do you mean this new fast-age-per-vid/msti, or being able to enable/disable learning per port? If it's the latter, I'm not sure I understand how those two are related.
The code from
dsa_port_set_state()which you've copied:if (!dsa_port_can_configure_learning(dp) || (do_fast_age && dp->learning)) {has this explanation:
1. DSA keeps standalone ports in the FORWARDING state.
2. DSA also disables address learning on standalone ports, where this is possible (dsa_port_can_configure_learning(dp)== true).
3. When a port joins a bridge, it leaves its FORWARDING state from standalone mode and inherits the bridge port's BLOCKING state
4.dsa_port_set_state()treats a port transition from FORWARDING to BLOCKING as a transition requiring an FDB flush
5. due to (2), the FDB flush at stage (4) is in fact not needed, because the FDB of that port should already be empty. Flushing the FDB may be a costly operation for some drivers, so it is avoided if possible.Quoted 8 lines
So this is why the "
dsa_port_can_configure_learning()" check is there - for compatibility with drivers that can't configure learning => they keep learning enabled also in standalone mode => they need an FDB flush when a standalone port joins a bridge.What I'm saying is: for drivers that offload MSTP, let's force them to get the basics right first (have configurable learning), rather than go forward forever with a backwards compatibility mode.
Makes sense, I'll just move it up to the initial capability check.
PATCH v2 8/10 net: dsa: mv88e6xxx: Disentangle STU from VTU
In reply to Tobias WaldekranzIn early LinkStreet silicon (e.g. 6095/6185), the per-VLAN STP states were kept in the VTU - there was no concept of a SID. Later, the information was split into two tables, where the VTU only tracked memberships and deferred the STP state tracking to the STU via a pointer (SID). This meant that a group of VLANs could share the same STU entry. Most likely, this was done to align with MSTP (802.1Q-2018, Clause 13), which is built on this principle.
While the VTU is still 4k lines on most devices, the STU is capped at 64 entries. This means that the current stategy, updating STU info whenever a VTU entry is updated, can not easily support MSTP because:
- The maximum number of VIDs would also be capped at 64, as we would have to allocate one SID for every VTU entry - even if many VLANs would effectively share the same MST.
- MSTP updates would be unnecessarily slow as you would have to iterate over all VLANs that share the same MST.
In order to support MSTP offloading in the future, manage the STU as a separate entity from the VTU.
Only add support for newer hardware with separate VTU and STU. VTU-only devices can also be supported, but essentially this requires a software implementation of an STU (fanning out state changed to all VLANs tied to the same MST).
--- drivers/net/dsa/mv88e6xxx/chip.c | 54 ++++ drivers/net/dsa/mv88e6xxx/chip.h | 24 ++ drivers/net/dsa/mv88e6xxx/global1.h | 10 + drivers/net/dsa/mv88e6xxx/global1_vtu.c | 311 ++++++++++++++---------- 4 files changed, 264 insertions(+), 135 deletions(-)
drivers/net/dsa/mv88e6xxx/chip.c +54 -0
@@ -1791,6 +1791,33 @@ static int mv88e6xxx_atu_new(struct mv88e6xxx_chip *chip, u16 *fid)return mv88e6xxx_g1_atu_flush (chip, *fid, true); } +static int mv88e6xxx_stu_loadpurge (struct mv88e6xxx_chip *chip, +struct mv88e6xxx_stu_entry *entry) +{ +if (!chip->info->ops->stu_loadpurge) +return -EOPNOTSUPP ; + +return chip->info->ops->stu_loadpurge (chip, entry); +} + +static int mv88e6xxx_stu_setup (struct mv88e6xxx_chip *chip) +{ +struct mv88e6xxx_stu_entry stu = { + .valid = true, + .sid =0 + }; + +if (!mv88e6xxx_has_stu (chip)) +return 0 ; + +/* Make sure that SID 0 is always valid. This is used by VTU +* entries that do not make use of the STU, e.g. when creating +* a VLAN upper on a port that is also part of a VLAN +* filtering bridge. +*/ +return mv88e6xxx_stu_loadpurge (chip, &stu); +} +static int mv88e6xxx_port_check_hw_vlan (struct dsa_switch *ds,int port,u16 vid) {
@@ -3427,6 +3454,13 @@ static int mv88e6xxx_setup(struct dsa_switch *ds)if (err) goto unlock; +/* Must be called after mv88e6xxx_vtu_setup (which flushes the +* VTU, thereby also flushing the STU). +*/ + err =mv88e6xxx_stu_setup (chip); +if (err) + goto unlock; +/* Setup Switch Port Registers */ for (i =0 ; i <mv88e6xxx_num_ports (chip); i++) {if (dsa_is_unused_port (ds, i))
@@ -3882,6 +3916,8 @@ static const struct mv88e6xxx_ops mv88e6097_ops = { .vtu_getnext = mv88e6352_g1_vtu_getnext, .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge, .phylink_get_caps = mv88e6095_phylink_get_caps, + .stu_getnext = mv88e6352_g1_stu_getnext, + .stu_loadpurge = mv88e6352_g1_stu_loadpurge, .set_max_frame_size = mv88e6185_g1_set_max_frame_size, };
@@ -4968,6 +5004,8 @@ static const struct mv88e6xxx_ops mv88e6352_ops = { .atu_set_hash = mv88e6165_g1_atu_set_hash, .vtu_getnext = mv88e6352_g1_vtu_getnext, .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge, + .stu_getnext = mv88e6352_g1_stu_getnext, + .stu_loadpurge = mv88e6352_g1_stu_loadpurge, .serdes_get_lane = mv88e6352_serdes_get_lane, .serdes_pcs_get_state = mv88e6352_serdes_pcs_get_state, .serdes_pcs_config = mv88e6352_serdes_pcs_config,
@@ -5033,6 +5071,8 @@ static const struct mv88e6xxx_ops mv88e6390_ops = { .atu_set_hash = mv88e6165_g1_atu_set_hash, .vtu_getnext = mv88e6390_g1_vtu_getnext, .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge, + .stu_getnext = mv88e6390_g1_stu_getnext, + .stu_loadpurge = mv88e6390_g1_stu_loadpurge, .serdes_power = mv88e6390_serdes_power, .serdes_get_lane = mv88e6390_serdes_get_lane,/* Check status register pause & lpa register */
@@ -5098,6 +5138,8 @@ static const struct mv88e6xxx_ops mv88e6390x_ops = { .atu_set_hash = mv88e6165_g1_atu_set_hash, .vtu_getnext = mv88e6390_g1_vtu_getnext, .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge, + .stu_getnext = mv88e6390_g1_stu_getnext, + .stu_loadpurge = mv88e6390_g1_stu_loadpurge, .serdes_power = mv88e6390_serdes_power, .serdes_get_lane = mv88e6390x_serdes_get_lane, .serdes_pcs_get_state = mv88e6390_serdes_pcs_get_state,
@@ -5166,6 +5208,8 @@ static const struct mv88e6xxx_ops mv88e6393x_ops = { .atu_set_hash = mv88e6165_g1_atu_set_hash, .vtu_getnext = mv88e6390_g1_vtu_getnext, .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge, + .stu_getnext = mv88e6390_g1_stu_getnext, + .stu_loadpurge = mv88e6390_g1_stu_loadpurge, .serdes_power = mv88e6393x_serdes_power, .serdes_get_lane = mv88e6393x_serdes_get_lane, .serdes_pcs_get_state = mv88e6393x_serdes_pcs_get_state,
@@ -5234,6 +5278,7 @@ static const struct mv88e6xxx_info mv88e6xxx_table[] = { .num_ports = 11, .num_internal_phys = 8, .max_vid = 4095, + .max_sid = 63, .port_base_addr = 0x10, .phy_base_addr = 0x0, .global1_addr = 0x1b,
@@ -5487,6 +5532,7 @@ static const struct mv88e6xxx_info mv88e6xxx_table[] = { .num_internal_phys = 9, .num_gpio = 16, .max_vid = 8191, + .max_sid = 63, .port_base_addr = 0x0, .phy_base_addr = 0x0, .global1_addr = 0x1b,
@@ -5510,6 +5556,7 @@ static const struct mv88e6xxx_info mv88e6xxx_table[] = { .num_internal_phys = 9, .num_gpio = 16, .max_vid = 8191, + .max_sid = 63, .port_base_addr = 0x0, .phy_base_addr = 0x0, .global1_addr = 0x1b,
@@ -5532,6 +5579,7 @@ static const struct mv88e6xxx_info mv88e6xxx_table[] = { .num_ports = 11, /* 10 + Z80 */ .num_internal_phys = 9, .max_vid = 8191, + .max_sid = 63, .port_base_addr = 0x0, .phy_base_addr = 0x0, .global1_addr = 0x1b,
@@ -5554,6 +5602,7 @@ static const struct mv88e6xxx_info mv88e6xxx_table[] = { .num_ports = 11, /* 10 + Z80 */ .num_internal_phys = 9, .max_vid = 8191, + .max_sid = 63, .port_base_addr = 0x0, .phy_base_addr = 0x0, .global1_addr = 0x1b,
@@ -5576,6 +5625,7 @@ static const struct mv88e6xxx_info mv88e6xxx_table[] = { .num_ports = 11, /* 10 + Z80 */ .num_internal_phys = 9, .max_vid = 8191, + .max_sid = 63, .port_base_addr = 0x0, .phy_base_addr = 0x0, .global1_addr = 0x1b,
@@ -5815,6 +5865,7 @@ static const struct mv88e6xxx_info mv88e6xxx_table[] = { .num_internal_phys = 5, .num_gpio = 15, .max_vid = 4095, + .max_sid = 63, .port_base_addr = 0x10, .phy_base_addr = 0x0, .global1_addr = 0x1b,
@@ -5839,6 +5890,7 @@ static const struct mv88e6xxx_info mv88e6xxx_table[] = { .num_internal_phys = 9, .num_gpio = 16, .max_vid = 8191, + .max_sid = 63, .port_base_addr = 0x0, .phy_base_addr = 0x0, .global1_addr = 0x1b,
@@ -5863,6 +5915,7 @@ static const struct mv88e6xxx_info mv88e6xxx_table[] = { .num_internal_phys = 9, .num_gpio = 16, .max_vid = 8191, + .max_sid = 63, .port_base_addr = 0x0, .phy_base_addr = 0x0, .global1_addr = 0x1b,
@@ -5886,6 +5939,7 @@ static const struct mv88e6xxx_info mv88e6xxx_table[] = { .num_ports = 11, /* 10 + Z80 */ .num_internal_phys = 9, .max_vid = 8191, + .max_sid = 63, .port_base_addr = 0x0, .phy_base_addr = 0x0, .global1_addr = 0x1b,
drivers/net/dsa/mv88e6xxx/chip.h +24 -0
@@ -20,6 +20,7 @@#define EDSA_HLEN 8#define MV88E6XXX_N_FID 4096 +#define MV88E6XXX_N_SID 64#define MV88E6XXX_FID_STANDALONE 0#define MV88E6XXX_FID_BRIDGED 1
@@ -130,6 +131,7 @@ struct mv88e6xxx_info {unsigned int num_internal_phys;unsigned int num_gpio;unsigned int max_vid; +unsigned int max_sid;unsigned int port_base_addr;unsigned int phy_base_addr;unsigned int global1_addr;
@@ -181,6 +183,12 @@ struct mv88e6xxx_vtu_entry {bool valid;bool policy;u8 member[DSA_MAX_PORTS ]; +u8 state[DSA_MAX_PORTS ];/* Older silicon has no STU */ +}; + +struct mv88e6xxx_stu_entry { +u8 sid; +bool valid;u8 state[DSA_MAX_PORTS ]; };
@@ -602,6 +610,12 @@ struct mv88e6xxx_ops {int (*vtu_loadpurge)(struct mv88e6xxx_chip *chip,struct mv88e6xxx_vtu_entry *entry); +/* Spanning Tree Unit operations */ +int (*stu_getnext)(struct mv88e6xxx_chip *chip, +struct mv88e6xxx_stu_entry *entry); +int (*stu_loadpurge)(struct mv88e6xxx_chip *chip, +struct mv88e6xxx_stu_entry *entry); +/* GPIO operations */ const struct mv88e6xxx_gpio_ops *gpio_ops;
@@ -700,6 +714,11 @@ struct mv88e6xxx_hw_stat {int type; }; +static inline bool mv88e6xxx_has_stu (struct mv88e6xxx_chip *chip) +{ +return chip->info->max_sid >0 ; +} +static inline bool mv88e6xxx_has_pvt (struct mv88e6xxx_chip *chip) {return chip->info->pvt;
@@ -730,6 +749,11 @@ static inline unsigned int mv88e6xxx_max_vid(struct mv88e6xxx_chip *chip)return chip->info->max_vid; } +static inline unsigned int mv88e6xxx_max_sid (struct mv88e6xxx_chip *chip) +{ +return chip->info->max_sid; +} +static inline u16 mv88e6xxx_port_mask (struct mv88e6xxx_chip *chip) {return GENMASK ((s32 )mv88e6xxx_num_ports (chip) -1 ,0 );
drivers/net/dsa/mv88e6xxx/global1.h +10 -0
@@ -348,6 +348,16 @@ int mv88e6390_g1_vtu_getnext(struct mv88e6xxx_chip *chip,int mv88e6390_g1_vtu_loadpurge (struct mv88e6xxx_chip *chip,struct mv88e6xxx_vtu_entry *entry);int mv88e6xxx_g1_vtu_flush (struct mv88e6xxx_chip *chip); +int mv88e6xxx_g1_stu_getnext (struct mv88e6xxx_chip *chip, +struct mv88e6xxx_stu_entry *entry); +int mv88e6352_g1_stu_getnext (struct mv88e6xxx_chip *chip, +struct mv88e6xxx_stu_entry *entry); +int mv88e6352_g1_stu_loadpurge (struct mv88e6xxx_chip *chip, +struct mv88e6xxx_stu_entry *entry); +int mv88e6390_g1_stu_getnext (struct mv88e6xxx_chip *chip, +struct mv88e6xxx_stu_entry *entry); +int mv88e6390_g1_stu_loadpurge (struct mv88e6xxx_chip *chip, +struct mv88e6xxx_stu_entry *entry);int mv88e6xxx_g1_vtu_prob_irq_setup (struct mv88e6xxx_chip *chip);void mv88e6xxx_g1_vtu_prob_irq_free (struct mv88e6xxx_chip *chip);int mv88e6xxx_g1_atu_get_next (struct mv88e6xxx_chip *chip,u16 fid);
drivers/net/dsa/mv88e6xxx/global1_vtu.c +176 -135
506 lines not on this page · raw message
Signature · 1 line
2.25.1
PATCH v2 9/10 net: dsa: mv88e6xxx: Export STU as devlink region
In reply to Tobias WaldekranzExport the raw STU data in a devlink region so that it can be inspected from userspace and compared to the current bridge configuration.
--- drivers/net/dsa/mv88e6xxx/chip.h | 1 + drivers/net/dsa/mv88e6xxx/devlink.c | 94 +++++++++++++++++++++++++++++ 2 files changed, 95 insertions(+)
drivers/net/dsa/mv88e6xxx/chip.h +1 -0
@@ -287,6 +287,7 @@ enum mv88e6xxx_region_id {MV88E6XXX_REGION_GLOBAL2 ,MV88E6XXX_REGION_ATU ,MV88E6XXX_REGION_VTU , +MV88E6XXX_REGION_STU ,MV88E6XXX_REGION_PVT , _MV88E6XXX_REGION_MAX,
drivers/net/dsa/mv88e6xxx/devlink.c +94 -0
118 lines not on this page · raw message
Signature · 1 line
2.25.1
PATCH v2 10/10 net: dsa: mv88e6xxx: MST Offloading
In reply to Tobias WaldekranzAllocate a SID in the STU for each MSTID in use by a bridge and handle the mapping of MSTIDs to VLANs using the SID field of each VTU entry.
--- drivers/net/dsa/mv88e6xxx/chip.c | 178 +++++++++++++++++++++++++++++++ drivers/net/dsa/mv88e6xxx/chip.h | 13 +++ 2 files changed, 191 insertions(+)
drivers/net/dsa/mv88e6xxx/chip.c +178 -0
@@ -1818,6 +1818,137 @@ static int mv88e6xxx_stu_setup(struct mv88e6xxx_chip *chip)return mv88e6xxx_stu_loadpurge (chip, &stu); } +static int mv88e6xxx_sid_new (struct mv88e6xxx_chip *chip,u8 *sid) +{ + DECLARE_BITMAP(busy, MV88E6XXX_N_SID) = { 0 }; +struct mv88e6xxx_mst *mst; + +set_bit (0 , busy); + +list_for_each_entry (mst, &chip->msts, node) { +set_bit (mst->stu.sid, busy); + } + + *sid =find_first_zero_bit (busy,MV88E6XXX_N_SID ); + +return (*sid >=mv88e6xxx_max_sid (chip)) ? -ENOSPC :0 ; +} + +static int mv88e6xxx_sid_put (struct mv88e6xxx_chip *chip,u8 sid) +{ +struct mv88e6xxx_mst *mst, *tmp; +int err =0 ; + +list_for_each_entry_safe (mst, tmp, &chip->msts, node) { +if (mst->stu.sid == sid) { +if (refcount_dec_and_test (&mst->refcnt)) { + mst->stu.valid = false; + err =mv88e6xxx_stu_loadpurge (chip, &mst->stu); +list_del (&mst->node); +kfree (mst); + } + +return err; + } + } + +return -ENOENT ; +} + +static int mv88e6xxx_sid_get (struct mv88e6xxx_chip *chip,struct net_device *br, +u16 msti,u8 *sid) +{ +struct mv88e6xxx_mst *mst; +int err, i; + +if (!br) +return 0 ; + +if (!mv88e6xxx_has_stu (chip)) +return -EOPNOTSUPP ; + +list_for_each_entry (mst, &chip->msts, node) { +if (mst->br == br && mst->msti == msti) { +refcount_inc (&mst->refcnt); + *sid = mst->stu.sid; +return 0 ; + } + } + + err =mv88e6xxx_sid_new (chip, sid); +if (err) +return err; + + mst =kzalloc (sizeof (*mst),GFP_KERNEL ); +if (!mst) +return -ENOMEM ; + +INIT_LIST_HEAD (&mst->node); +refcount_set (&mst->refcnt,1 ); + mst->br = br; + mst->msti = msti; + mst->stu.valid = true; + mst->stu.sid = *sid; + +/* The bridge starts out all ports in the disabled state. But +* a STU state of disabled means to go by the port-global +* state. So we set all user port's initial state to blocking, +* to match the bridge's behavior. +*/ +for (i =0 ; i <mv88e6xxx_num_ports (chip); i++) + mst->stu.state[i] =dsa_is_user_port (chip->ds, i) ? +MV88E6XXX_PORT_CTL0_STATE_BLOCKING : +MV88E6XXX_PORT_CTL0_STATE_DISABLED ; + +list_add_tail (&mst->node, &chip->msts); +return mv88e6xxx_stu_loadpurge (chip, &mst->stu); +} + +static int mv88e6xxx_port_mst_state_set (struct dsa_switch *ds,int port, +const struct switchdev_mst_state *st) +{ +struct dsa_port *dp =dsa_to_port (ds, port); +struct mv88e6xxx_chip *chip = ds->priv; +struct mv88e6xxx_mst *mst; +u8 state; +int err; + +if (!mv88e6xxx_has_stu (chip)) +return -EOPNOTSUPP ; + +switch (st->state) { +case BR_STATE_DISABLED : +case BR_STATE_BLOCKING : +case BR_STATE_LISTENING : + state =MV88E6XXX_PORT_CTL0_STATE_BLOCKING ; +break ; +case BR_STATE_LEARNING : + state =MV88E6XXX_PORT_CTL0_STATE_LEARNING ; +break ; +case BR_STATE_FORWARDING : + state =MV88E6XXX_PORT_CTL0_STATE_FORWARDING ; +break ; +default : +return -EINVAL ; + } + +list_for_each_entry (mst, &chip->msts, node) { +if (mst->br ==dsa_port_bridge_dev_get (dp) && + mst->msti == st->msti) { +if (mst->stu.state[port] == state) +return 0 ; + + mst->stu.state[port] = state; +mv88e6xxx_reg_lock (chip); + err =mv88e6xxx_stu_loadpurge (chip, &mst->stu); +mv88e6xxx_reg_unlock (chip); +return err; + } + } + +return -ENOENT ; +} +static int mv88e6xxx_port_check_hw_vlan (struct dsa_switch *ds,int port,u16 vid) {
@@ -2437,6 +2568,12 @@ static int mv88e6xxx_port_vlan_leave(struct mv88e6xxx_chip *chip,if (err)return err; +if (!vlan.valid && vlan.sid) { + err =mv88e6xxx_sid_put (chip, vlan.sid); +if (err) +return err; + } +return mv88e6xxx_g1_atu_remove (chip, vlan.fid, port, false); }
@@ -2482,6 +2619,44 @@ static int mv88e6xxx_port_vlan_del(struct dsa_switch *ds, int port,return err; } +static int mv88e6xxx_vlan_msti_set (struct dsa_switch *ds, +const struct switchdev_attr *attr) +{ +const struct switchdev_vlan_attr *vattr = &attr->u.vlan_attr; +struct mv88e6xxx_chip *chip = ds->priv; +struct mv88e6xxx_vtu_entry vlan; +u8 new_sid; +int err; + +mv88e6xxx_reg_lock (chip); + + err =mv88e6xxx_vtu_get (chip, vattr->vid, &vlan); +if (err) + goto unlock; + +if (!vlan.valid) { + err = -EINVAL ; + goto unlock; + } + + err =mv88e6xxx_sid_get (chip, attr->orig_dev, vattr->msti, &new_sid); +if (err) + goto unlock; + +if (vlan.sid) { + err =mv88e6xxx_sid_put (chip, vlan.sid); +if (err) + goto unlock; + } + + vlan.sid = new_sid; + err =mv88e6xxx_vtu_loadpurge (chip, &vlan); + +unlock: +mv88e6xxx_reg_unlock (chip); +return err; +} +static int mv88e6xxx_port_fdb_add (struct dsa_switch *ds,int port,const unsigned char *addr,u16 vid,struct dsa_db db)
@@ -6008,6 +6183,7 @@ static struct mv88e6xxx_chip *mv88e6xxx_alloc_chip(struct device *dev)mutex_init (&chip->reg_lock);INIT_LIST_HEAD (&chip->mdios);idr_init (&chip->policies); +INIT_LIST_HEAD (&chip->msts);return chip; }
@@ -6540,10 +6716,12 @@ static const struct dsa_switch_ops mv88e6xxx_switch_ops = { .port_pre_bridge_flags = mv88e6xxx_port_pre_bridge_flags, .port_bridge_flags = mv88e6xxx_port_bridge_flags, .port_stp_state_set = mv88e6xxx_port_stp_state_set, + .port_mst_state_set = mv88e6xxx_port_mst_state_set, .port_fast_age = mv88e6xxx_port_fast_age, .port_vlan_filtering = mv88e6xxx_port_vlan_filtering, .port_vlan_add = mv88e6xxx_port_vlan_add, .port_vlan_del = mv88e6xxx_port_vlan_del, + .vlan_msti_set = mv88e6xxx_vlan_msti_set, .port_fdb_add = mv88e6xxx_port_fdb_add, .port_fdb_del = mv88e6xxx_port_fdb_del, .port_fdb_dump = mv88e6xxx_port_fdb_dump,
drivers/net/dsa/mv88e6xxx/chip.h +13 -0
@@ -297,6 +297,16 @@ struct mv88e6xxx_region_priv {enum mv88e6xxx_region_id id; }; +struct mv88e6xxx_mst { +struct list_head node; + +refcount_t refcnt; +struct net_device *br; +u16 msti; + +struct mv88e6xxx_stu_entry stu; +}; +struct mv88e6xxx_chip {const struct mv88e6xxx_info *info;
@@ -397,6 +407,9 @@ struct mv88e6xxx_chip {/* devlink regions */ struct devlink_region *regions[_MV88E6XXX_REGION_MAX]; + +/* Bridge MST to SID mappings */ +struct list_head msts; };struct mv88e6xxx_bus_ops {
Signature · 1 line
2.25.1
Vladimir Oltean
maintainerRe: [PATCH v2 net-next 10/10] net: dsa: mv88e6xxx: MST Offloading
Quoted 33 lines · Tobias Waldekranz
Allocate a SID in the STU for each MSTID in use by a bridge and handle the mapping of MSTIDs to VLANs using the SID field of each VTU entry.
Signed-off-by Tobias Waldekranz <[email protected]>--- drivers/net/dsa/mv88e6xxx/chip.c | 178 +++++++++++++++++++++++++++++++ drivers/net/dsa/mv88e6xxx/chip.h | 13 +++ 2 files changed, 191 insertions(+)drivers/net/dsa/mv88e6xxx/chip.c +16
-0@@ -1818,6 +1818,137 @@ static int mv88e6xxx_stu_setup(struct mv88e6xxx_chip *chip)return mv88e6xxx_stu_loadpurge (chip, &stu); } +static int mv88e6xxx_sid_new (struct mv88e6xxx_chip *chip,u8 *sid) +{ + DECLARE_BITMAP(busy, MV88E6XXX_N_SID) = { 0 }; +struct mv88e6xxx_mst *mst; + +set_bit (0 , busy); + +list_for_each_entry (mst, &chip->msts, node) { +set_bit (mst->stu.sid, busy); + } + + *sid =find_first_zero_bit (busy,MV88E6XXX_N_SID ); + +return (*sid >=mv88e6xxx_max_sid (chip)) ? -ENOSPC :0 ; +} +
drivers/net/dsa/mv88e6xxx/chip.c static int mv88e6xxx_stu_setup(struct mv88e6xxx_chip *chip) · line 1846
Quoted 10 lines
drivers/net/dsa/mv88e6xxx/chip.c +10
-0+static int mv88e6xxx_sid_put (struct mv88e6xxx_chip *chip,u8 sid) +{ +struct mv88e6xxx_mst *mst, *tmp; +int err =0 ; + +list_for_each_entry_safe (mst, tmp, &chip->msts, node) { +if (mst->stu.sid == sid) { +if (refcount_dec_and_test (&mst->refcnt)) { + mst->stu.valid = false; + err =mv88e6xxx_stu_loadpurge (chip, &mst->stu);
It is interesting what to do if this fails. Possibly not this, because the entry remains in hardware but not in software.
Quoted 9 lines
drivers/net/dsa/mv88e6xxx/chip.c +9
-0+list_del (&mst->node); +kfree (mst); + } + +return err; + } + } + +return -ENOENT ;
drivers/net/dsa/mv88e6xxx/chip.c static int mv88e6xxx_stu_setup(struct mv88e6xxx_chip *chip) · line 1865
Quoted 10 lines
drivers/net/dsa/mv88e6xxx/chip.c +10
-0+} + +static int mv88e6xxx_sid_get (struct mv88e6xxx_chip *chip,struct net_device *br, +u16 msti,u8 *sid) +{ +struct mv88e6xxx_mst *mst; +int err, i; + +if (!br) +return 0 ;
Is this condition possible?
Quoted 9 lines
drivers/net/dsa/mv88e6xxx/chip.c +9
-0+ +if (!mv88e6xxx_has_stu (chip)) +return -EOPNOTSUPP ; + +list_for_each_entry (mst, &chip->msts, node) { +if (mst->br == br && mst->msti == msti) { +refcount_inc (&mst->refcnt); + *sid = mst->stu.sid; +return 0 ;
drivers/net/dsa/mv88e6xxx/chip.c static int mv88e6xxx_stu_setup(struct mv88e6xxx_chip *chip) · line 1884
Quoted 10 lines
drivers/net/dsa/mv88e6xxx/chip.c +10
-0+ } + } + + err =mv88e6xxx_sid_new (chip, sid); +if (err) +return err; + + mst =kzalloc (sizeof (*mst),GFP_KERNEL ); +if (!mst) +return -ENOMEM ;
This leaks the new SID.
Quoted 10 lines
drivers/net/dsa/mv88e6xxx/chip.c +10
-0+ +INIT_LIST_HEAD (&mst->node); +refcount_set (&mst->refcnt,1 ); + mst->br = br; + mst->msti = msti; + mst->stu.valid = true; + mst->stu.sid = *sid; + +/* The bridge starts out all ports in the disabled state. But +* a STU state of disabled means to go by the port-global
drivers/net/dsa/mv88e6xxx/chip.c static int mv88e6xxx_stu_setup(struct mv88e6xxx_chip *chip) · line 1904
Quoted 10 lines
drivers/net/dsa/mv88e6xxx/chip.c +10
-0+* state. So we set all user port's initial state to blocking, +* to match the bridge's behavior. +*/ +for (i =0 ; i <mv88e6xxx_num_ports (chip); i++) + mst->stu.state[i] =dsa_is_user_port (chip->ds, i) ? +MV88E6XXX_PORT_CTL0_STATE_BLOCKING : +MV88E6XXX_PORT_CTL0_STATE_DISABLED ; + +list_add_tail (&mst->node, &chip->msts); +return mv88e6xxx_stu_loadpurge (chip, &mst->stu);
And this doesn't behave too well on failure (the MSTID exists in software but not in hardware).
Quoted 89 lines
drivers/net/dsa/mv88e6xxx/chip.c +75
-0+} + +static int mv88e6xxx_port_mst_state_set (struct dsa_switch *ds,int port, +const struct switchdev_mst_state *st) +{ +struct dsa_port *dp =dsa_to_port (ds, port); +struct mv88e6xxx_chip *chip = ds->priv; +struct mv88e6xxx_mst *mst; +u8 state; +int err; + +if (!mv88e6xxx_has_stu (chip)) +return -EOPNOTSUPP ; + +switch (st->state) { +case BR_STATE_DISABLED : +case BR_STATE_BLOCKING : +case BR_STATE_LISTENING : + state =MV88E6XXX_PORT_CTL0_STATE_BLOCKING ; +break ; +case BR_STATE_LEARNING : + state =MV88E6XXX_PORT_CTL0_STATE_LEARNING ; +break ; +case BR_STATE_FORWARDING : + state =MV88E6XXX_PORT_CTL0_STATE_FORWARDING ; +break ; +default : +return -EINVAL ; + } + +list_for_each_entry (mst, &chip->msts, node) { +if (mst->br ==dsa_port_bridge_dev_get (dp) && + mst->msti == st->msti) { +if (mst->stu.state[port] == state) +return 0 ; + + mst->stu.state[port] = state; +mv88e6xxx_reg_lock (chip); + err =mv88e6xxx_stu_loadpurge (chip, &mst->stu); +mv88e6xxx_reg_unlock (chip); +return err; + } + } + +return -ENOENT ; +} +static int mv88e6xxx_port_check_hw_vlan (struct dsa_switch *ds,int port,u16 vid) {@@ -2437,6 +2568,12 @@ static int mv88e6xxx_port_vlan_leave(struct mv88e6xxx_chip *chip,if (err)return err; +if (!vlan.valid && vlan.sid) { + err =mv88e6xxx_sid_put (chip, vlan.sid); +if (err) +return err; + } +return mv88e6xxx_g1_atu_remove (chip, vlan.fid, port, false); }@@ -2482,6 +2619,44 @@ static int mv88e6xxx_port_vlan_del(struct dsa_switch *ds, int port,return err; } +static int mv88e6xxx_vlan_msti_set (struct dsa_switch *ds, +const struct switchdev_attr *attr) +{ +const struct switchdev_vlan_attr *vattr = &attr->u.vlan_attr; +struct mv88e6xxx_chip *chip = ds->priv; +struct mv88e6xxx_vtu_entry vlan; +u8 new_sid; +int err; + +mv88e6xxx_reg_lock (chip); + + err =mv88e6xxx_vtu_get (chip, vattr->vid, &vlan); +if (err) + goto unlock; + +if (!vlan.valid) { + err = -EINVAL ; + goto unlock; + } + + err =mv88e6xxx_sid_get (chip, attr->orig_dev, vattr->msti, &new_sid); +if (err)
drivers/net/dsa/mv88e6xxx/chip.c static int mv88e6xxx_port_vlan_del(struct dsa_switch *ds, int port, · line 2653
Quoted 10 lines
drivers/net/dsa/mv88e6xxx/chip.c +10
-0+ goto unlock; + +if (vlan.sid) { + err =mv88e6xxx_sid_put (chip, vlan.sid); +if (err) + goto unlock; + } + + vlan.sid = new_sid; + err =mv88e6xxx_vtu_loadpurge (chip, &vlan);
Maybe you could move mv88e6xxx_sid_put() after this succeeds?
Quoted 64 lines
drivers/net/dsa/mv88e6xxx/chip.c +9
-0+ +unlock: +mv88e6xxx_reg_unlock (chip); +return err; +} +static int mv88e6xxx_port_fdb_add (struct dsa_switch *ds,int port,const unsigned char *addr,u16 vid,struct dsa_db db)@@ -6008,6 +6183,7 @@ static struct mv88e6xxx_chip *mv88e6xxx_alloc_chip(struct device *dev)mutex_init (&chip->reg_lock);INIT_LIST_HEAD (&chip->mdios);idr_init (&chip->policies); +INIT_LIST_HEAD (&chip->msts);return chip; }@@ -6540,10 +6716,12 @@ static const struct dsa_switch_ops mv88e6xxx_switch_ops = { .port_pre_bridge_flags = mv88e6xxx_port_pre_bridge_flags, .port_bridge_flags = mv88e6xxx_port_bridge_flags, .port_stp_state_set = mv88e6xxx_port_stp_state_set, + .port_mst_state_set = mv88e6xxx_port_mst_state_set, .port_fast_age = mv88e6xxx_port_fast_age, .port_vlan_filtering = mv88e6xxx_port_vlan_filtering, .port_vlan_add = mv88e6xxx_port_vlan_add, .port_vlan_del = mv88e6xxx_port_vlan_del, + .vlan_msti_set = mv88e6xxx_vlan_msti_set, .port_fdb_add = mv88e6xxx_port_fdb_add, .port_fdb_del = mv88e6xxx_port_fdb_del, .port_fdb_dump = mv88e6xxx_port_fdb_dump,drivers/net/dsa/mv88e6xxx/chip.h +13
-0@@ -297,6 +297,16 @@ struct mv88e6xxx_region_priv {enum mv88e6xxx_region_id id; }; +struct mv88e6xxx_mst { +struct list_head node; + +refcount_t refcnt; +struct net_device *br; +u16 msti; + +struct mv88e6xxx_stu_entry stu; +}; +struct mv88e6xxx_chip {const struct mv88e6xxx_info *info;@@ -397,6 +407,9 @@ struct mv88e6xxx_chip {/* devlink regions */ struct devlink_region *regions[_MV88E6XXX_REGION_MAX]; + +/* Bridge MST to SID mappings */ +struct list_head msts; };struct mv88e6xxx_bus_ops {Signature · 1 line
2.25.1
Re: [PATCH v2 net-next 10/10] net: dsa: mv88e6xxx: MST Offloading
Quoted 39 lines · Vladimir Oltean
Quoted 38 lines · Tobias Waldekranz
Allocate a SID in the STU for each MSTID in use by a bridge and handle the mapping of MSTIDs to VLANs using the SID field of each VTU entry.
Signed-off-by Tobias Waldekranz <[email protected]>--- drivers/net/dsa/mv88e6xxx/chip.c | 178 +++++++++++++++++++++++++++++++ drivers/net/dsa/mv88e6xxx/chip.h | 13 +++ 2 files changed, 191 insertions(+)drivers/net/dsa/mv88e6xxx/chip.c +21
-0@@ -1818,6 +1818,137 @@ static int mv88e6xxx_stu_setup(struct mv88e6xxx_chip *chip)return mv88e6xxx_stu_loadpurge (chip, &stu); } +static int mv88e6xxx_sid_new (struct mv88e6xxx_chip *chip,u8 *sid) +{ + DECLARE_BITMAP(busy, MV88E6XXX_N_SID) = { 0 }; +struct mv88e6xxx_mst *mst; + +set_bit (0 , busy); + +list_for_each_entry (mst, &chip->msts, node) { +set_bit (mst->stu.sid, busy); + } + + *sid =find_first_zero_bit (busy,MV88E6XXX_N_SID ); + +return (*sid >=mv88e6xxx_max_sid (chip)) ? -ENOSPC :0 ; +} + +static int mv88e6xxx_sid_put (struct mv88e6xxx_chip *chip,u8 sid) +{ +struct mv88e6xxx_mst *mst, *tmp; +int err =0 ; +
Quoted 8 lines
drivers/net/dsa/mv88e6xxx/chip.c static int mv88e6xxx_stu_setup(struct mv88e6xxx_chip *chip) · line 1846
Quoted 5 lines
drivers/net/dsa/mv88e6xxx/chip.c +5
-0+list_for_each_entry_safe (mst, tmp, &chip->msts, node) { +if (mst->stu.sid == sid) { +if (refcount_dec_and_test (&mst->refcnt)) { + mst->stu.valid = false; + err =mv88e6xxx_stu_loadpurge (chip, &mst->stu);It is interesting what to do if this fails. Possibly not this, because the entry remains in hardware but not in software.
True, I will let the error bubble up and keep the SW state in sync with the hardware.
Quoted 13 lines
Quoted 13 lines
drivers/net/dsa/mv88e6xxx/chip.c +13
-0+list_del (&mst->node); +kfree (mst); + } + +return err; + } + } + +return -ENOENT ; +} + +static int mv88e6xxx_sid_get (struct mv88e6xxx_chip *chip,struct net_device *br, +u16 msti,u8 *sid)
Quoted 8 lines
drivers/net/dsa/mv88e6xxx/chip.c static int mv88e6xxx_stu_setup(struct mv88e6xxx_chip *chip) · line 1865
Quoted 6 lines
drivers/net/dsa/mv88e6xxx/chip.c +6
-0+{ +struct mv88e6xxx_mst *mst; +int err, i; + +if (!br) +return 0 ;Is this condition possible?
Removing.
Quoted 13 lines
Quoted 13 lines
drivers/net/dsa/mv88e6xxx/chip.c +13
-0+ +if (!mv88e6xxx_has_stu (chip)) +return -EOPNOTSUPP ; + +list_for_each_entry (mst, &chip->msts, node) { +if (mst->br == br && mst->msti == msti) { +refcount_inc (&mst->refcnt); + *sid = mst->stu.sid; +return 0 ; + } + } + + err =mv88e6xxx_sid_new (chip, sid);
Quoted 8 lines
drivers/net/dsa/mv88e6xxx/chip.c static int mv88e6xxx_stu_setup(struct mv88e6xxx_chip *chip) · line 1884
Quoted 6 lines
drivers/net/dsa/mv88e6xxx/chip.c +6
-0+if (err) +return err; + + mst =kzalloc (sizeof (*mst),GFP_KERNEL ); +if (!mst) +return -ENOMEM ;This leaks the new SID.
I don't think so, the SID is just calculated based on what is in chip->msts. However:
- The naming is bad. Will change.
Quoted 15 lines
Quoted 15 lines
drivers/net/dsa/mv88e6xxx/chip.c +15
-0+ +INIT_LIST_HEAD (&mst->node); +refcount_set (&mst->refcnt,1 ); + mst->br = br; + mst->msti = msti; + mst->stu.valid = true; + mst->stu.sid = *sid; + +/* The bridge starts out all ports in the disabled state. But +* a STU state of disabled means to go by the port-global +* state. So we set all user port's initial state to blocking, +* to match the bridge's behavior. +*/ +for (i =0 ; i <mv88e6xxx_num_ports (chip); i++) + mst->stu.state[i] = dsa_is_user_port(chip->ds, i) ?
Quoted 8 lines
drivers/net/dsa/mv88e6xxx/chip.c static int mv88e6xxx_stu_setup(struct mv88e6xxx_chip *chip) · line 1904
Quoted 5 lines
drivers/net/dsa/mv88e6xxx/chip.c +5
-0+ MV88E6XXX_PORT_CTL0_STATE_BLOCKING : +MV88E6XXX_PORT_CTL0_STATE_DISABLED ; + +list_add_tail (&mst->node, &chip->msts); +return mv88e6xxx_stu_loadpurge (chip, &mst->stu);And this doesn't behave too well on failure (the MSTID exists in software but not in hardware).
Yes, fixing in v3.
Quoted 93 lines
Quoted 93 lines
drivers/net/dsa/mv88e6xxx/chip.c +79
-0+} + +static int mv88e6xxx_port_mst_state_set (struct dsa_switch *ds,int port, +const struct switchdev_mst_state *st) +{ +struct dsa_port *dp =dsa_to_port (ds, port); +struct mv88e6xxx_chip *chip = ds->priv; +struct mv88e6xxx_mst *mst; +u8 state; +int err; + +if (!mv88e6xxx_has_stu (chip)) +return -EOPNOTSUPP ; + +switch (st->state) { +case BR_STATE_DISABLED : +case BR_STATE_BLOCKING : +case BR_STATE_LISTENING : + state =MV88E6XXX_PORT_CTL0_STATE_BLOCKING ; +break ; +case BR_STATE_LEARNING : + state =MV88E6XXX_PORT_CTL0_STATE_LEARNING ; +break ; +case BR_STATE_FORWARDING : + state =MV88E6XXX_PORT_CTL0_STATE_FORWARDING ; +break ; +default : +return -EINVAL ; + } + +list_for_each_entry (mst, &chip->msts, node) { +if (mst->br ==dsa_port_bridge_dev_get (dp) && + mst->msti == st->msti) { +if (mst->stu.state[port] == state) +return 0 ; + + mst->stu.state[port] = state; +mv88e6xxx_reg_lock (chip); + err =mv88e6xxx_stu_loadpurge (chip, &mst->stu); +mv88e6xxx_reg_unlock (chip); +return err; + } + } + +return -ENOENT ; +} +static int mv88e6xxx_port_check_hw_vlan (struct dsa_switch *ds,int port,u16 vid) {@@ -2437,6 +2568,12 @@ static int mv88e6xxx_port_vlan_leave(struct mv88e6xxx_chip *chip,if (err)return err; +if (!vlan.valid && vlan.sid) { + err =mv88e6xxx_sid_put (chip, vlan.sid); +if (err) +return err; + } +return mv88e6xxx_g1_atu_remove (chip, vlan.fid, port, false); }@@ -2482,6 +2619,44 @@ static int mv88e6xxx_port_vlan_del(struct dsa_switch *ds, int port,return err; } +static int mv88e6xxx_vlan_msti_set (struct dsa_switch *ds, +const struct switchdev_attr *attr) +{ +const struct switchdev_vlan_attr *vattr = &attr->u.vlan_attr; +struct mv88e6xxx_chip *chip = ds->priv; +struct mv88e6xxx_vtu_entry vlan; +u8 new_sid; +int err; + +mv88e6xxx_reg_lock (chip); + + err =mv88e6xxx_vtu_get (chip, vattr->vid, &vlan); +if (err) + goto unlock; + +if (!vlan.valid) { + err = -EINVAL ; + goto unlock; + } + + err =mv88e6xxx_sid_get (chip, attr->orig_dev, vattr->msti, &new_sid); +if (err) + goto unlock; + +if (vlan.sid) { + err =mv88e6xxx_sid_put (chip, vlan.sid);
Quoted 8 lines
drivers/net/dsa/mv88e6xxx/chip.c static int mv88e6xxx_port_vlan_del(struct dsa_switch *ds, int port, · line 2653
Quoted 6 lines
drivers/net/dsa/mv88e6xxx/chip.c +6
-0+if (err) + goto unlock; + } + + vlan.sid = new_sid; + err =mv88e6xxx_vtu_loadpurge (chip, &vlan);Maybe you could move
mv88e6xxx_sid_put()after this succeeds?
Yep. Also made sure to avoid needless updates of the VTU entry if it already belonged to the correct SID.
Thanks for the great review!
Vladimir Oltean
maintainerRe: [PATCH v2 net-next 10/10] net: dsa: mv88e6xxx: MST Offloading
Quoted 49 lines · Tobias Waldekranz
Quoted 39 lines · Vladimir Oltean
Quoted 38 lines · Tobias Waldekranz
Allocate a SID in the STU for each MSTID in use by a bridge and handle the mapping of MSTIDs to VLANs using the SID field of each VTU entry.
Signed-off-by Tobias Waldekranz <[email protected]>--- drivers/net/dsa/mv88e6xxx/chip.c | 178 +++++++++++++++++++++++++++++++ drivers/net/dsa/mv88e6xxx/chip.h | 13 +++ 2 files changed, 191 insertions(+)drivers/net/dsa/mv88e6xxx/chip.c +21
-0@@ -1818,6 +1818,137 @@ static int mv88e6xxx_stu_setup(struct mv88e6xxx_chip *chip)return mv88e6xxx_stu_loadpurge (chip, &stu); } +static int mv88e6xxx_sid_new (struct mv88e6xxx_chip *chip,u8 *sid) +{ + DECLARE_BITMAP(busy, MV88E6XXX_N_SID) = { 0 }; +struct mv88e6xxx_mst *mst; + +set_bit (0 , busy); + +list_for_each_entry (mst, &chip->msts, node) { +set_bit (mst->stu.sid, busy); + } + + *sid =find_first_zero_bit (busy,MV88E6XXX_N_SID ); + +return (*sid >=mv88e6xxx_max_sid (chip)) ? -ENOSPC :0 ; +} + +static int mv88e6xxx_sid_put (struct mv88e6xxx_chip *chip,u8 sid) +{ +struct mv88e6xxx_mst *mst, *tmp; +int err =0 ; +Quoted 8 lines
drivers/net/dsa/mv88e6xxx/chip.c static int mv88e6xxx_stu_setup(struct mv88e6xxx_chip *chip) · line 1846
Quoted 5 lines
drivers/net/dsa/mv88e6xxx/chip.c +5
-0+list_for_each_entry_safe (mst, tmp, &chip->msts, node) { +if (mst->stu.sid == sid) { +if (refcount_dec_and_test (&mst->refcnt)) { + mst->stu.valid = false; + err =mv88e6xxx_stu_loadpurge (chip, &mst->stu);It is interesting what to do if this fails. Possibly not this, because the entry remains in hardware but not in software.
Quoted 2 lines
True, I will let the error bubble up and keep the SW state in sync with the hardware.
Ok. For what it's worth, if you bump a refcount from 0 to 1 as part of the error handling here, you need to do so using refcount_set(1), not refcount_inc(). I found this out in commit 232deb3f9567 ("net: dsa:
avoid refcount warnings when ->port_{fdb,mdb}_del returns error"). Just thought I'd mention it in case you didn't know, to avoid a future respin for that reason.
Quoted 46 lines
Quoted 13 lines
Quoted 13 lines
drivers/net/dsa/mv88e6xxx/chip.c +13
-0+list_del (&mst->node); +kfree (mst); + } + +return err; + } + } + +return -ENOENT ; +} + +static int mv88e6xxx_sid_get (struct mv88e6xxx_chip *chip,struct net_device *br, +u16 msti,u8 *sid)Quoted 8 lines
drivers/net/dsa/mv88e6xxx/chip.c static int mv88e6xxx_stu_setup(struct mv88e6xxx_chip *chip) · line 1865
Quoted 6 lines
drivers/net/dsa/mv88e6xxx/chip.c +6
-0+{ +struct mv88e6xxx_mst *mst; +int err, i; + +if (!br) +return 0 ;Is this condition possible?
Removing.
Quoted 13 lines
Quoted 13 lines
drivers/net/dsa/mv88e6xxx/chip.c +13
-0+ +if (!mv88e6xxx_has_stu (chip)) +return -EOPNOTSUPP ; + +list_for_each_entry (mst, &chip->msts, node) { +if (mst->br == br && mst->msti == msti) { +refcount_inc (&mst->refcnt); + *sid = mst->stu.sid; +return 0 ; + } + } + + err =mv88e6xxx_sid_new (chip, sid);Quoted 8 lines
drivers/net/dsa/mv88e6xxx/chip.c static int mv88e6xxx_stu_setup(struct mv88e6xxx_chip *chip) · line 1884
Quoted 6 lines
drivers/net/dsa/mv88e6xxx/chip.c +6
-0+if (err) +return err; + + mst =kzalloc (sizeof (*mst),GFP_KERNEL ); +if (!mst) +return -ENOMEM ;This leaks the new SID.
Quoted 4 lines
I don't think so, the SID is just calculated based on what is in
chip->msts. However:- The naming is bad. Will change.
I see now. My bad. What are you renaming it to? If it isn't as concise you could still keep it sid_new(). I see atu_new() is based on the same find_first_zero_bit() concept.
Quoted 128 lines
Quoted 15 lines
Quoted 15 lines
drivers/net/dsa/mv88e6xxx/chip.c +15
-0+ +INIT_LIST_HEAD (&mst->node); +refcount_set (&mst->refcnt,1 ); + mst->br = br; + mst->msti = msti; + mst->stu.valid = true; + mst->stu.sid = *sid; + +/* The bridge starts out all ports in the disabled state. But +* a STU state of disabled means to go by the port-global +* state. So we set all user port's initial state to blocking, +* to match the bridge's behavior. +*/ +for (i =0 ; i <mv88e6xxx_num_ports (chip); i++) + mst->stu.state[i] = dsa_is_user_port(chip->ds, i) ?Quoted 8 lines
drivers/net/dsa/mv88e6xxx/chip.c static int mv88e6xxx_stu_setup(struct mv88e6xxx_chip *chip) · line 1904
Quoted 5 lines
drivers/net/dsa/mv88e6xxx/chip.c +5
-0+ MV88E6XXX_PORT_CTL0_STATE_BLOCKING : +MV88E6XXX_PORT_CTL0_STATE_DISABLED ; + +list_add_tail (&mst->node, &chip->msts); +return mv88e6xxx_stu_loadpurge (chip, &mst->stu);And this doesn't behave too well on failure (the MSTID exists in software but not in hardware).
Yes, fixing in v3.
Quoted 93 lines
Quoted 93 lines
drivers/net/dsa/mv88e6xxx/chip.c +79
-0+} + +static int mv88e6xxx_port_mst_state_set (struct dsa_switch *ds,int port, +const struct switchdev_mst_state *st) +{ +struct dsa_port *dp =dsa_to_port (ds, port); +struct mv88e6xxx_chip *chip = ds->priv; +struct mv88e6xxx_mst *mst; +u8 state; +int err; + +if (!mv88e6xxx_has_stu (chip)) +return -EOPNOTSUPP ; + +switch (st->state) { +case BR_STATE_DISABLED : +case BR_STATE_BLOCKING : +case BR_STATE_LISTENING : + state =MV88E6XXX_PORT_CTL0_STATE_BLOCKING ; +break ; +case BR_STATE_LEARNING : + state =MV88E6XXX_PORT_CTL0_STATE_LEARNING ; +break ; +case BR_STATE_FORWARDING : + state =MV88E6XXX_PORT_CTL0_STATE_FORWARDING ; +break ; +default : +return -EINVAL ; + } + +list_for_each_entry (mst, &chip->msts, node) { +if (mst->br ==dsa_port_bridge_dev_get (dp) && + mst->msti == st->msti) { +if (mst->stu.state[port] == state) +return 0 ; + + mst->stu.state[port] = state; +mv88e6xxx_reg_lock (chip); + err =mv88e6xxx_stu_loadpurge (chip, &mst->stu); +mv88e6xxx_reg_unlock (chip); +return err; + } + } + +return -ENOENT ; +} +static int mv88e6xxx_port_check_hw_vlan (struct dsa_switch *ds,int port,u16 vid) {@@ -2437,6 +2568,12 @@ static int mv88e6xxx_port_vlan_leave(struct mv88e6xxx_chip *chip,if (err)return err; +if (!vlan.valid && vlan.sid) { + err =mv88e6xxx_sid_put (chip, vlan.sid); +if (err) +return err; + } +return mv88e6xxx_g1_atu_remove (chip, vlan.fid, port, false); }@@ -2482,6 +2619,44 @@ static int mv88e6xxx_port_vlan_del(struct dsa_switch *ds, int port,return err; } +static int mv88e6xxx_vlan_msti_set (struct dsa_switch *ds, +const struct switchdev_attr *attr) +{ +const struct switchdev_vlan_attr *vattr = &attr->u.vlan_attr; +struct mv88e6xxx_chip *chip = ds->priv; +struct mv88e6xxx_vtu_entry vlan; +u8 new_sid; +int err; + +mv88e6xxx_reg_lock (chip); + + err =mv88e6xxx_vtu_get (chip, vattr->vid, &vlan); +if (err) + goto unlock; + +if (!vlan.valid) { + err = -EINVAL ; + goto unlock; + } + + err =mv88e6xxx_sid_get (chip, attr->orig_dev, vattr->msti, &new_sid); +if (err) + goto unlock; + +if (vlan.sid) { + err =mv88e6xxx_sid_put (chip, vlan.sid);Quoted 8 lines
drivers/net/dsa/mv88e6xxx/chip.c static int mv88e6xxx_port_vlan_del(struct dsa_switch *ds, int port, · line 2653
Quoted 6 lines
drivers/net/dsa/mv88e6xxx/chip.c +6
-0+if (err) + goto unlock; + } + + vlan.sid = new_sid; + err =mv88e6xxx_vtu_loadpurge (chip, &vlan);Maybe you could move
mv88e6xxx_sid_put()after this succeeds?
Quoted 4 lines
Yep. Also made sure to avoid needless updates of the VTU entry if it already belonged to the correct SID.
Thanks for the great review!
I realize I gave you conflicting advice here, first with inverting the refcount_inc() with the refcount_dec(), then with having fast handling of noop-changes to vlan.sid. I hope you're able to make some sense out of that and avoid the obvious issue with the refcount temporarily dropping to zero before going back to 1, which makes the sanity checker complain.
Vladimir Oltean
maintainerRe: [PATCH v2 net-next 10/10] net: dsa: mv88e6xxx: MST Offloading
Quoted 18 lines · Vladimir Oltean
Quoted 15 lines
Quoted 6 lines
Quoted 6 lines
drivers/net/dsa/mv88e6xxx/chip.c +6
-0+ err =mv88e6xxx_sid_get (chip, attr->orig_dev, vattr->msti, &new_sid); +if (err) + goto unlock; + +if (vlan.sid) { + err =mv88e6xxx_sid_put (chip, vlan.sid);Quoted 8 lines
drivers/net/dsa/mv88e6xxx/chip.c static int mv88e6xxx_port_vlan_del(struct dsa_switch *ds, int port, · line 2653
Quoted 6 lines
drivers/net/dsa/mv88e6xxx/chip.c +6
-0+if (err) + goto unlock; + } + + vlan.sid = new_sid; + err =mv88e6xxx_vtu_loadpurge (chip, &vlan);Maybe you could move
mv88e6xxx_sid_put()after this succeeds?Quoted 2 lines
Yep. Also made sure to avoid needless updates of the VTU entry if it already belonged to the correct SID.
Quoted 6 lines
I realize I gave you conflicting advice here, first with inverting the
refcount_inc()with therefcount_dec(), then with having fast handling of noop-changes to vlan.sid. I hope you're able to make some sense out of that and avoid the obvious issue with the refcount temporarily dropping to zero before going back to 1, which makes the sanity checker complain.
Oh wow... I didn't look at the code again, and commented based on a false memory. Disregard, sorry. You aren't reversing sid_get with sid_put, nor did I suggest that. There's a lot that happened just in my head, apparently.
Vladimir Oltean
maintainerHi Tobias,
Quoted 3 lines · Tobias Waldekranz
A proposal for the corresponding iproute2 interface is available here:
Please pardon my ignorance. Is there a user-mode STP protocol application that supports MSTP, and that you've tested these patches with? I'd like to give it a try.
Quoted 10 lines · On Tue, 1 Mar 2022 18:21:42 +0200 Vladimir Oltean <[email protected]> wrote:
Hi Tobias,
Quoted 3 lines · Tobias Waldekranz
A proposal for the corresponding iproute2 interface is available here:
Please pardon my ignorance. Is there a user-mode STP protocol application that supports MSTP, and that you've tested these patches with? I'd like to give it a try.
Quoted 10 lines · Vladimir Oltean
Hi Tobias,
Quoted 3 lines · Tobias Waldekranz
A proposal for the corresponding iproute2 interface is available here:
Please pardon my ignorance. Is there a user-mode STP protocol application that supports MSTP, and that you've tested these patches with? I'd like to give it a try.
I see that Stephen has already pointed you to mstpd in a sibling message.
It is important to note though, that AFAIK mstpd does not actually support MSTP on a vanilla Linux system. The protocol implementation is in place, and they have a plugin architecture that makes it easy for people to hook it up to various userspace SDKs and whatnot, but you can't use it with a regular bridge.
A colleague of mine has been successfully running a modified version of mstpd which was tailored for v1 of this series (RFC). But I do not believe he has had the time to rework it for v2. That should mostly be a matter of removing code though, as v2 allows you to manage the MSTIs directly, rather than having to translate it to an associated VLAN.
Quoted 21 lines · Tobias Waldekranz
Quoted 10 lines · Vladimir Oltean
Hi Tobias,
Quoted 3 lines · Tobias Waldekranz
A proposal for the corresponding iproute2 interface is available here:
Please pardon my ignorance. Is there a user-mode STP protocol application that supports MSTP, and that you've tested these patches with? I'd like to give it a try.
I see that Stephen has already pointed you to mstpd in a sibling message.
It is important to note though, that AFAIK mstpd does not actually support MSTP on a vanilla Linux system. The protocol implementation is in place, and they have a plugin architecture that makes it easy for people to hook it up to various userspace SDKs and whatnot, but you can't use it with a regular bridge.
Quoted 5 lines
A colleague of mine has been successfully running a modified version of mstpd which was tailored for v1 of this series (RFC). But I do not believe he has had the time to rework it for v2. That should mostly be a matter of removing code though, as v2 allows you to manage the MSTIs directly, rather than having to translate it to an associated VLAN.
Hello,
we experimented with mstpd with pretty reasonable kernel modifications. Vanilla kernel wasn't capable of transferring the correct mapping from mstpd to the hardware due to lack of vlan2msti mapping and per-msti port state (rather than just per-vlan port state).
https://github.com/mstpd/mstpd/pull/112
I didn't pursue this for a while, though.
Regards,
Pavel