On Wed, Dec 02, 2020 at 10:13:54AM +0100, Tobias Waldekranz wrote: > Monitor the following events and notify the driver when: > > - A DSA port joins/leaves a LAG. > - A LAG, made up of DSA ports, joins/leaves a bridge. > - A DSA port in a LAG is enabled/disabled (enabled meaning > "distributing" in 802.3ad LACP terms). > > Each LAG interface to which a DSA port is attached is represented by a > `struct dsa_lag` which is globally reachable from the switch tree and > from each associated port. > > When a LAG joins a bridge, the DSA subsystem will treat that as each > individual port joining the bridge. The driver may look at the port's > LAG pointer to see if it is associated with any LAG, if that is > required. This is analogue to how switchdev events are replicated out > to all lower devices when reaching e.g. a LAG. > > Signed-off-by: Tobias Waldekranz <tob...@waldekranz.com> > --- > include/net/dsa.h | 97 +++++++++++++++++++++++++++++++++ > net/dsa/dsa2.c | 51 ++++++++++++++++++ > net/dsa/dsa_priv.h | 31 +++++++++++ > net/dsa/port.c | 132 +++++++++++++++++++++++++++++++++++++++++++++ > net/dsa/slave.c | 83 +++++++++++++++++++++++++--- > net/dsa/switch.c | 49 +++++++++++++++++ > 6 files changed, 437 insertions(+), 6 deletions(-) > > diff --git a/include/net/dsa.h b/include/net/dsa.h > index 4e60d2610f20..aaa350b78c55 100644 > --- a/include/net/dsa.h > +++ b/include/net/dsa.h > @@ -7,6 +7,7 @@ > #ifndef __LINUX_NET_DSA_H > #define __LINUX_NET_DSA_H > > +#include <linux/bitmap.h> > #include <linux/if.h> > #include <linux/if_ether.h> > #include <linux/list.h> > @@ -71,6 +72,7 @@ enum dsa_tag_protocol { > > struct packet_type; > struct dsa_switch; > +struct dsa_lag; > > struct dsa_device_ops { > struct sk_buff *(*xmit)(struct sk_buff *skb, struct net_device *dev); > @@ -149,6 +151,13 @@ struct dsa_switch_tree { > > /* List of DSA links composing the routing table */ > struct list_head rtable; > + > + /* Link aggregates */ > + struct { > + struct dsa_lag *pool; > + unsigned long *busy; > + unsigned int num;
Can we get rid of the busy array and just look at the refcounts? Can we also get rid of the "num" variable? > + } lags; > };