Subject: Re: [PATCH net-next v2 6/8] dpaa2-switch: reorganize the [pre]changeupper events

From: Simon Horman <[email-masked]>
Date: Mon, 18 Dec 2023 08:33:45 +0000

On Fri, Dec 15, 2023 at 02:08:51PM +0200, Ioana Ciornei wrote:
> On Fri, Dec 15, 2023 at 11:49:39AM +0000, Simon Horman wrote:
> > On Wed, Dec 13, 2023 at 02:14:09PM +0200, Ioana Ciornei wrote:

...

> > >  	if (!dpaa2_switch_port_dev_check(netdev))
> > > -		return NOTIFY_DONE;
> > > +		return 0;
> > >  
> > >  	extack = netdev_notifier_info_to_extack(&info->info);
> > > -
> > > -	switch (event) {
> > > -	case NETDEV_PRECHANGEUPPER:
> > > -		upper_dev = info->upper_dev;
> > > -		if (!netif_is_bridge_master(upper_dev))
> > > -			break;
> > > -
> > > +	upper_dev = info->upper_dev;
> > > +	if (netif_is_bridge_master(upper_dev)) {
> > >  		err = dpaa2_switch_prechangeupper_sanity_checks(netdev,
> > >  								upper_dev,
> > >  								extack);
> > >  		if (err)
> > > -			goto out;
> > > +			return err;
> > >  
> > >  		if (!info->linking)
> > >  			dpaa2_switch_port_pre_bridge_leave(netdev);
> > > +	}
> > 
> > FWIIW, I think that a more idomatic flow would be to return if
> > netif_is_bridge_master() is false. Something like this (completely untested!):
> > 
> > 	if (!netif_is_bridge_master(upper_dev))
> > 		return 0;
> > 
> > 	err = dpaa2_switch_prechangeupper_sanity_checks(netdev, upper_dev,
> > 							extack);
> > 	if (err)
> > 		return err;
> > 
> > 	if (!info->linking)
> > 		dpaa2_switch_port_pre_bridge_leave(netdev);
> > 
> 
> It looks better but I don't think this it's easily extensible.
> 
> I am planning to add support for LAG offloading which would mean that I
> would have to revert to the initial flow and extend it to something
> like:
> 
> 	if (netif_is_bridge_master(upper_dev)) {
> 		...
> 	} else if (netif_is_lag_master(upper_dev)) {
> 		...
> 	}
> 
> The same thing applies to the dpaa2_switch_port_changeupper() function
> below.

Understood. If this is going somewhere then don't let me derail it.

,,,