From: Ido Schimmel Date: Thu, 20 Feb 2020 07:08:00 +0000 (+0200) Subject: mlxsw: spectrum_nve: Make tunnel initialization symmetric X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=9ef87b244ec5118ed5f7cd61c25487f98af64cfb;p=linux.git mlxsw: spectrum_nve: Make tunnel initialization symmetric 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 Acked-by: Jiri Pirko Signed-off-by: David S. Miller --- diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_nve.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_nve.c index 16a130c2f21ce..eced553fd4eff 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_nve.c +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_nve.c @@ -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;