mlxsw: spectrum_nve: Make tunnel initialization symmetric
authorIdo Schimmel <idosch@mellanox.com>
Thu, 20 Feb 2020 07:08:00 +0000 (09:08 +0200)
committerDavid S. Miller <davem@davemloft.net>
Thu, 20 Feb 2020 18:04:34 +0000 (10:04 -0800)
The device supports a single VTEP whose configuration is shared between
all VXLAN tunnels.

While the shared configuration is cleared upon the destruction of the
last tunnel - in mlxsw_sp_nve_tunnel_fini() - it is set in
mlxsw_sp_nve_fid_enable(), after calling mlxsw_sp_nve_tunnel_init().

Make tunnel initialization and destruction symmetric and set the
configuration in mlxsw_sp_nve_tunnel_init().

This will later allow us to protect the shared configuration with a
lock.

Signed-off-by: Ido Schimmel <idosch@mellanox.com>
Acked-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/mellanox/mlxsw/spectrum_nve.c

index 16a130c2f21ce58cbcee9885eb8a6f50d50afe03..eced553fd4effa9bc27ccc294aa2a0f412d339a3 100644 (file)
@@ -744,6 +744,8 @@ static int mlxsw_sp_nve_tunnel_init(struct mlxsw_sp *mlxsw_sp,
        if (nve->num_nve_tunnels++ != 0)
                return 0;
 
+       nve->config = *config;
+
        err = mlxsw_sp_kvdl_alloc(mlxsw_sp, MLXSW_SP_KVDL_ENTRY_TYPE_ADJ, 1,
                                  &nve->tunnel_index);
        if (err)
@@ -760,6 +762,7 @@ err_ops_init:
        mlxsw_sp_kvdl_free(mlxsw_sp, MLXSW_SP_KVDL_ENTRY_TYPE_ADJ, 1,
                           nve->tunnel_index);
 err_kvdl_alloc:
+       memset(&nve->config, 0, sizeof(nve->config));
        nve->num_nve_tunnels--;
        return err;
 }
@@ -840,8 +843,6 @@ int mlxsw_sp_nve_fid_enable(struct mlxsw_sp *mlxsw_sp, struct mlxsw_sp_fid *fid,
                goto err_fid_vni_set;
        }
 
-       nve->config = config;
-
        err = ops->fdb_replay(params->dev, params->vni, extack);
        if (err)
                goto err_fdb_replay;