Re: [PATCH net-next 2/4] net: dsa: Link aggregation support

2020-11-28 Thread Andrew Lunn
> > OK I think I finally see what you are saying. Sorry it took me this > > long. I do not mean to be difficult, I just want to understand. Not a problem. This is a bit different to normal, the complexity of the stack means you need to handle this different to most drivers. If you have done any de

Re: [PATCH net-next 2/4] net: dsa: Link aggregation support

2020-11-28 Thread Tobias Waldekranz
On Sat Nov 28, 2020 at 6:38 PM CET, Andrew Lunn wrote: > > > OK I think I finally see what you are saying. Sorry it took me this > > > long. I do not mean to be difficult, I just want to understand. > > Not a problem. This is a bit different to normal, the complexity of > the stack means you need t

Re: [PATCH net-next 2/4] net: dsa: Link aggregation support

2020-11-28 Thread Florian Fainelli
On 11/27/2020 3:19 PM, Tobias Waldekranz wrote: >> The initial design of switchdev was transactions. First there was a >> prepare call, where you validated the requested action is possible, >> and allocate resources needed, but don't actually do it. This prepare >> call is allowed to fail. Then

Re: [PATCH net-next 2/4] net: dsa: Link aggregation support

2020-11-27 Thread Tobias Waldekranz
On Fri, Nov 27, 2020 at 17:28, Andrew Lunn wrote: >> This is a digression, but I really do not get this shift from using >> BUG()s to WARN()s in the kernel when you detect a violated invariant. It >> smells of "On Error Resume Next" to me. > > A WARN() gives you a chance to actually use the machin

Re: [PATCH net-next 2/4] net: dsa: Link aggregation support

2020-11-27 Thread Andrew Lunn
> This is a digression, but I really do not get this shift from using > BUG()s to WARN()s in the kernel when you detect a violated invariant. It > smells of "On Error Resume Next" to me. A WARN() gives you a chance to actually use the machine to collect logs, the kernel dump, etc. You might be abl

Re: [PATCH net-next 2/4] net: dsa: Link aggregation support

2020-11-27 Thread Tobias Waldekranz
On Thu, Nov 26, 2020 at 23:57, Andrew Lunn wrote: >> If you go with the static array, you theoretically can not get the >> equivalent of an ENOMEM. Practically though you have to iterate through >> the array and look for a free entry, but you still have to put a return >> statement at the bottom o

Re: [PATCH net-next 2/4] net: dsa: Link aggregation support

2020-11-26 Thread Andrew Lunn
> If you go with the static array, you theoretically can not get the > equivalent of an ENOMEM. Practically though you have to iterate through > the array and look for a free entry, but you still have to put a return > statement at the bottom of that function, right? Or panic I suppose. My > guess

Re: [PATCH net-next 2/4] net: dsa: Link aggregation support

2020-11-26 Thread Tobias Waldekranz
On Fri, Nov 20, 2020 at 14:30, Andrew Lunn wrote: > On Thu, Nov 19, 2020 at 06:43:38PM -0800, Florian Fainelli wrote: >> > >> > Hi Tobias >> > >> > My comment last time was to statically allocated them at probe >> > time. Worse case scenario is each port is alone in a LAG. Pointless, >> > but so

Re: [PATCH net-next 2/4] net: dsa: Link aggregation support

2020-11-20 Thread Andrew Lunn
On Thu, Nov 19, 2020 at 06:43:38PM -0800, Florian Fainelli wrote: > > > On 11/19/2020 4:30 PM, Andrew Lunn wrote: > >> +static struct dsa_lag *dsa_lag_get(struct dsa_switch_tree *dst, > >> + struct net_device *dev) > >> +{ > >> + unsigned long busy = 0; > >> + struct

Re: [PATCH net-next 2/4] net: dsa: Link aggregation support

2020-11-19 Thread Florian Fainelli
On 11/19/2020 4:30 PM, Andrew Lunn wrote: >> +static struct dsa_lag *dsa_lag_get(struct dsa_switch_tree *dst, >> + struct net_device *dev) >> +{ >> +unsigned long busy = 0; >> +struct dsa_lag *lag; >> +int id; >> + >> +list_for_each_entry(lag, &dst->

Re: [PATCH net-next 2/4] net: dsa: Link aggregation support

2020-11-19 Thread Andrew Lunn
> +static struct dsa_lag *dsa_lag_get(struct dsa_switch_tree *dst, > +struct net_device *dev) > +{ > + unsigned long busy = 0; > + struct dsa_lag *lag; > + int id; > + > + list_for_each_entry(lag, &dst->lags, list) { > + set_bit(lag->id, &

[PATCH net-next 2/4] net: dsa: Link aggregation support

2020-11-19 Thread Tobias Waldekranz
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