OSDN Git Service

net/mlx5e: Add LAG warning for unsupported tx type
authorJianbo Liu <jianbol@mellanox.com>
Fri, 17 Apr 2020 02:55:46 +0000 (02:55 +0000)
committerSaeed Mahameed <saeedm@nvidia.com>
Tue, 15 Sep 2020 18:59:51 +0000 (11:59 -0700)
If bond tx type is not active-backup or hash, LAG offload can't be
enabled. When CHANGEUPPER event is received, and both PFs (and only
them) under the same lag master are about to be enslaved, a warning
is returned for user to know the offload failure, otherwise PFs are
enslaved silently without LAG offload activated.

Signed-off-by: Jianbo Liu <jianbol@mellanox.com>
Reviewed-by: Raed Salem <raeds@mellanox.com>
Reviewed-by: Roi Dayan <roid@mellanox.com>
Reviewed-by: Jiri Pirko <jiri@nvidia.com>
Reviewed-by: Raed Salem <raeds@nvidia.com>
Reviewed-by: Roi Dayan <roid@nvidia.com>
Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
drivers/net/ethernet/mellanox/mlx5/core/lag.c

index 8b6e2aa..191d3d5 100644 (file)
@@ -355,7 +355,7 @@ static int mlx5_handle_changeupper_event(struct mlx5_lag *ldev,
 {
        struct net_device *upper = info->upper_dev, *ndev_tmp;
        struct netdev_lag_upper_info *lag_upper_info = NULL;
-       bool is_bonded;
+       bool is_bonded, is_in_lag, mode_supported;
        int bond_status = 0;
        int num_slaves = 0;
        int idx;
@@ -391,13 +391,18 @@ static int mlx5_handle_changeupper_event(struct mlx5_lag *ldev,
        /* Determine bonding status:
         * A device is considered bonded if both its physical ports are slaves
         * of the same lag master, and only them.
-        * Lag mode must be activebackup or hash.
         */
-       is_bonded = (num_slaves == MLX5_MAX_PORTS) &&
-                   (bond_status == 0x3) &&
-                   ((tracker->tx_type == NETDEV_LAG_TX_TYPE_ACTIVEBACKUP) ||
-                    (tracker->tx_type == NETDEV_LAG_TX_TYPE_HASH));
+       is_in_lag = num_slaves == MLX5_MAX_PORTS && bond_status == 0x3;
 
+       /* Lag mode must be activebackup or hash. */
+       mode_supported = tracker->tx_type == NETDEV_LAG_TX_TYPE_ACTIVEBACKUP ||
+                        tracker->tx_type == NETDEV_LAG_TX_TYPE_HASH;
+
+       if (is_in_lag && !mode_supported)
+               NL_SET_ERR_MSG_MOD(info->info.extack,
+                                  "Can't activate LAG offload, TX type isn't supported");
+
+       is_bonded = is_in_lag && mode_supported;
        if (tracker->is_bonded != is_bonded) {
                tracker->is_bonded = is_bonded;
                return 1;