diff mbox series

[RFC,net-next,05/16] net: mscc: ocelot: don't refuse bonding interfaces we can't offload

Message ID 20201208120802.1268708-6-vladimir.oltean@nxp.com (mailing list archive)
State RFC
Delegated to: Netdev Maintainers
Headers show
Series LAG offload for Ocelot DSA switches | expand

Checks

Context Check Description
netdev/cover_letter success Link
netdev/fixes_present success Link
netdev/patch_count fail Series longer than 15 patches
netdev/tree_selection success Clearly marked for net-next
netdev/subject_prefix success Link
netdev/source_inline success Was 0 now: 0
netdev/verify_signedoff success Link
netdev/module_param success Was 0 now: 0
netdev/build_32bit fail Errors and warnings before: 4 this patch: 4
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/verify_fixes success Link
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 60 lines checked
netdev/build_allmodconfig_warn fail Errors and warnings before: 4 this patch: 4
netdev/header_inline success Link
netdev/stable success Stable not CCed

Commit Message

Vladimir Oltean Dec. 8, 2020, 12:07 p.m. UTC
Since switchdev/DSA exposes network interfaces that fulfill many of the
same user space expectations that dedicated NICs do, it makes sense to
not deny bonding interfaces with a bonding policy that we cannot offload,
but instead allow the bonding driver to select the egress interface in
software.

Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
---
 drivers/net/ethernet/mscc/ocelot_net.c | 38 ++++++++++----------------
 1 file changed, 15 insertions(+), 23 deletions(-)

Comments

Alexandre Belloni Dec. 15, 2020, 3:56 p.m. UTC | #1
On 08/12/2020 14:07:51+0200, Vladimir Oltean wrote:
> Since switchdev/DSA exposes network interfaces that fulfill many of the
> same user space expectations that dedicated NICs do, it makes sense to
> not deny bonding interfaces with a bonding policy that we cannot offload,
> but instead allow the bonding driver to select the egress interface in
> software.
> 
> Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Reviewed-by: Alexandre Belloni <alexandre.belloni@bootlin.com>

> ---
>  drivers/net/ethernet/mscc/ocelot_net.c | 38 ++++++++++----------------
>  1 file changed, 15 insertions(+), 23 deletions(-)
> 
> diff --git a/drivers/net/ethernet/mscc/ocelot_net.c b/drivers/net/ethernet/mscc/ocelot_net.c
> index 47b620967156..77957328722a 100644
> --- a/drivers/net/ethernet/mscc/ocelot_net.c
> +++ b/drivers/net/ethernet/mscc/ocelot_net.c
> @@ -1022,6 +1022,15 @@ static int ocelot_netdevice_changeupper(struct net_device *dev,
>  		}
>  	}
>  	if (netif_is_lag_master(info->upper_dev)) {
> +		struct netdev_lag_upper_info *lag_upper_info;
> +
> +		lag_upper_info = info->upper_info;
> +
> +		/* Only offload what we can */
> +		if (lag_upper_info &&
> +		    lag_upper_info->tx_type != NETDEV_LAG_TX_TYPE_HASH)
> +			return NOTIFY_DONE;
> +
>  		if (info->linking)
>  			err = ocelot_port_lag_join(ocelot, port,
>  						   info->upper_dev);
> @@ -1037,10 +1046,16 @@ static int
>  ocelot_netdevice_lag_changeupper(struct net_device *dev,
>  				 struct netdev_notifier_changeupper_info *info)
>  {
> +	struct netdev_lag_upper_info *lag_upper_info = info->upper_info;
>  	struct net_device *lower;
>  	struct list_head *iter;
>  	int err = NOTIFY_DONE;
>  
> +	/* Can't offload LAG => also do bridging in software */
> +	if (lag_upper_info &&
> +	    lag_upper_info->tx_type != NETDEV_LAG_TX_TYPE_HASH)
> +		return NOTIFY_DONE;
> +
>  	netdev_for_each_lower_dev(dev, lower, iter) {
>  		err = ocelot_netdevice_changeupper(lower, info);
>  		if (err)
> @@ -1056,29 +1071,6 @@ static int ocelot_netdevice_event(struct notifier_block *unused,
>  	struct net_device *dev = netdev_notifier_info_to_dev(ptr);
>  
>  	switch (event) {
> -	case NETDEV_PRECHANGEUPPER: {
> -		struct netdev_notifier_changeupper_info *info = ptr;
> -		struct netdev_lag_upper_info *lag_upper_info;
> -		struct netlink_ext_ack *extack;
> -
> -		if (!ocelot_netdevice_dev_check(dev))
> -			break;
> -
> -		if (!netif_is_lag_master(info->upper_dev))
> -			break;
> -
> -		lag_upper_info = info->upper_info;
> -
> -		if (lag_upper_info &&
> -		    lag_upper_info->tx_type != NETDEV_LAG_TX_TYPE_HASH) {
> -			extack = netdev_notifier_info_to_extack(&info->info);
> -			NL_SET_ERR_MSG_MOD(extack, "LAG device using unsupported Tx type");
> -
> -			return NOTIFY_BAD;
> -		}
> -
> -		break;
> -	}
>  	case NETDEV_CHANGEUPPER: {
>  		struct netdev_notifier_changeupper_info *info = ptr;
>  
> -- 
> 2.25.1
>
diff mbox series

Patch

diff --git a/drivers/net/ethernet/mscc/ocelot_net.c b/drivers/net/ethernet/mscc/ocelot_net.c
index 47b620967156..77957328722a 100644
--- a/drivers/net/ethernet/mscc/ocelot_net.c
+++ b/drivers/net/ethernet/mscc/ocelot_net.c
@@ -1022,6 +1022,15 @@  static int ocelot_netdevice_changeupper(struct net_device *dev,
 		}
 	}
 	if (netif_is_lag_master(info->upper_dev)) {
+		struct netdev_lag_upper_info *lag_upper_info;
+
+		lag_upper_info = info->upper_info;
+
+		/* Only offload what we can */
+		if (lag_upper_info &&
+		    lag_upper_info->tx_type != NETDEV_LAG_TX_TYPE_HASH)
+			return NOTIFY_DONE;
+
 		if (info->linking)
 			err = ocelot_port_lag_join(ocelot, port,
 						   info->upper_dev);
@@ -1037,10 +1046,16 @@  static int
 ocelot_netdevice_lag_changeupper(struct net_device *dev,
 				 struct netdev_notifier_changeupper_info *info)
 {
+	struct netdev_lag_upper_info *lag_upper_info = info->upper_info;
 	struct net_device *lower;
 	struct list_head *iter;
 	int err = NOTIFY_DONE;
 
+	/* Can't offload LAG => also do bridging in software */
+	if (lag_upper_info &&
+	    lag_upper_info->tx_type != NETDEV_LAG_TX_TYPE_HASH)
+		return NOTIFY_DONE;
+
 	netdev_for_each_lower_dev(dev, lower, iter) {
 		err = ocelot_netdevice_changeupper(lower, info);
 		if (err)
@@ -1056,29 +1071,6 @@  static int ocelot_netdevice_event(struct notifier_block *unused,
 	struct net_device *dev = netdev_notifier_info_to_dev(ptr);
 
 	switch (event) {
-	case NETDEV_PRECHANGEUPPER: {
-		struct netdev_notifier_changeupper_info *info = ptr;
-		struct netdev_lag_upper_info *lag_upper_info;
-		struct netlink_ext_ack *extack;
-
-		if (!ocelot_netdevice_dev_check(dev))
-			break;
-
-		if (!netif_is_lag_master(info->upper_dev))
-			break;
-
-		lag_upper_info = info->upper_info;
-
-		if (lag_upper_info &&
-		    lag_upper_info->tx_type != NETDEV_LAG_TX_TYPE_HASH) {
-			extack = netdev_notifier_info_to_extack(&info->info);
-			NL_SET_ERR_MSG_MOD(extack, "LAG device using unsupported Tx type");
-
-			return NOTIFY_BAD;
-		}
-
-		break;
-	}
 	case NETDEV_CHANGEUPPER: {
 		struct netdev_notifier_changeupper_info *info = ptr;