OSDN Git Service

net/mlx5: E-switch, Reduce dependency on num_vfs during mode set
authorParav Pandit <parav@mellanox.com>
Fri, 26 Jun 2020 20:15:12 +0000 (23:15 +0300)
committerSaeed Mahameed <saeedm@mellanox.com>
Thu, 16 Jul 2020 23:36:40 +0000 (16:36 -0700)
Currently only ECPF allows enabling eswitch when SR-IOV is disabled.

Enable PF also to enable eswitch when SR-IOV is disabled.
Load VF vports when eswitch is already enabled.

Signed-off-by: Parav Pandit <parav@mellanox.com>
Reviewed-by: Roi Dayan <roid@mellanox.com>
Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
drivers/net/ethernet/mellanox/mlx5/core/eswitch.c
drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c

index c181f6b..e8f900e 100644 (file)
@@ -1652,7 +1652,17 @@ int mlx5_eswitch_enable(struct mlx5_eswitch *esw, int num_vfs)
                return 0;
 
        mutex_lock(&esw->mode_lock);
-       ret = mlx5_eswitch_enable_locked(esw, MLX5_ESWITCH_LEGACY, num_vfs);
+       if (esw->mode == MLX5_ESWITCH_NONE) {
+               ret = mlx5_eswitch_enable_locked(esw, MLX5_ESWITCH_LEGACY, num_vfs);
+       } else {
+               enum mlx5_eswitch_vport_event vport_events;
+
+               vport_events = (esw->mode == MLX5_ESWITCH_LEGACY) ?
+                                       MLX5_LEGACY_SRIOV_VPORT_EVENTS : MLX5_VPORT_UC_ADDR_CHANGE;
+               ret = mlx5_eswitch_load_vf_vports(esw, num_vfs, vport_events);
+               if (!ret)
+                       esw->esw_funcs.num_vfs = num_vfs;
+       }
        mutex_unlock(&esw->mode_lock);
        return ret;
 }
@@ -1699,6 +1709,7 @@ void mlx5_eswitch_disable(struct mlx5_eswitch *esw, bool clear_vf)
 
        mutex_lock(&esw->mode_lock);
        mlx5_eswitch_disable_locked(esw, clear_vf);
+       esw->esw_funcs.num_vfs = 0;
        mutex_unlock(&esw->mode_lock);
 }
 
index 74a2b76..db856d7 100644 (file)
@@ -1578,13 +1578,6 @@ static int esw_offloads_start(struct mlx5_eswitch *esw,
 {
        int err, err1;
 
-       if (esw->mode != MLX5_ESWITCH_LEGACY &&
-           !mlx5_core_is_ecpf_esw_manager(esw->dev)) {
-               NL_SET_ERR_MSG_MOD(extack,
-                                  "Can't set offloads mode, SRIOV legacy not enabled");
-               return -EINVAL;
-       }
-
        mlx5_eswitch_disable_locked(esw, false);
        err = mlx5_eswitch_enable_locked(esw, MLX5_ESWITCH_OFFLOADS,
                                         esw->dev->priv.sriov.num_vfs);
@@ -2293,7 +2286,7 @@ int mlx5_devlink_eswitch_mode_set(struct devlink *devlink, u16 mode,
 {
        u16 cur_mlx5_mode, mlx5_mode = 0;
        struct mlx5_eswitch *esw;
-       int err;
+       int err = 0;
 
        esw = mlx5_devlink_eswitch_get(devlink);
        if (IS_ERR(esw))
@@ -2303,12 +2296,7 @@ int mlx5_devlink_eswitch_mode_set(struct devlink *devlink, u16 mode,
                return -EINVAL;
 
        mutex_lock(&esw->mode_lock);
-       err = eswitch_devlink_esw_mode_check(esw);
-       if (err)
-               goto unlock;
-
        cur_mlx5_mode = esw->mode;
-
        if (cur_mlx5_mode == mlx5_mode)
                goto unlock;