Skip to content

Commit 158ec85

Browse files
Paul Blakeygregkh
authored andcommitted
net/mlx5: E-Switch, Fix resetting of encap mode when entering switchdev
[ Upstream commit d7751d6 ] E-Switch encap mode is relevant only when in switchdev mode. The RDMA driver can query the encap configuration via mlx5_eswitch_get_encap_mode(). Make sure it returns the currently used mode and not the set one. This reverts the cited commit which reset the encap mode on entering switchdev and fixes the original issue properly. Fixes: 9a64144 ("net/mlx5: E-Switch, Fix default encap mode") Signed-off-by: Paul Blakey <paulb@nvidia.com> Reviewed-by: Mark Bloch <mbloch@nvidia.com> Reviewed-by: Maor Dickman <maord@nvidia.com> Signed-off-by: Saeed Mahameed <saeedm@nvidia.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent a49a9b9 commit 158ec85

3 files changed

Lines changed: 9 additions & 11 deletions

File tree

‎drivers/net/ethernet/mellanox/mlx5/core/eswitch.c‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1572,6 +1572,11 @@ int mlx5_eswitch_init(struct mlx5_core_dev *dev)
15721572
esw->enabled_vports = 0;
15731573
esw->mode = MLX5_ESWITCH_NONE;
15741574
esw->offloads.inline_mode = MLX5_INLINE_MODE_NONE;
1575+
if (MLX5_CAP_ESW_FLOWTABLE_FDB(dev, reformat) &&
1576+
MLX5_CAP_ESW_FLOWTABLE_FDB(dev, decap))
1577+
esw->offloads.encap = DEVLINK_ESWITCH_ENCAP_MODE_BASIC;
1578+
else
1579+
esw->offloads.encap = DEVLINK_ESWITCH_ENCAP_MODE_NONE;
15751580

15761581
dev->priv.eswitch = esw;
15771582
BLOCKING_INIT_NOTIFIER_HEAD(&esw->n_head);
@@ -1934,7 +1939,7 @@ int mlx5_eswitch_get_vport_stats(struct mlx5_eswitch *esw,
19341939
return err;
19351940
}
19361941

1937-
u8 mlx5_eswitch_mode(struct mlx5_core_dev *dev)
1942+
u8 mlx5_eswitch_mode(const struct mlx5_core_dev *dev)
19381943
{
19391944
struct mlx5_eswitch *esw = dev->priv.eswitch;
19401945

@@ -1948,7 +1953,7 @@ mlx5_eswitch_get_encap_mode(const struct mlx5_core_dev *dev)
19481953
struct mlx5_eswitch *esw;
19491954

19501955
esw = dev->priv.eswitch;
1951-
return mlx5_esw_allowed(esw) ? esw->offloads.encap :
1956+
return (mlx5_eswitch_mode(dev) == MLX5_ESWITCH_OFFLOADS) ? esw->offloads.encap :
19521957
DEVLINK_ESWITCH_ENCAP_MODE_NONE;
19531958
}
19541959
EXPORT_SYMBOL(mlx5_eswitch_get_encap_mode);

‎drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c‎

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3141,12 +3141,6 @@ int esw_offloads_enable(struct mlx5_eswitch *esw)
31413141
u64 mapping_id;
31423142
int err;
31433143

3144-
if (MLX5_CAP_ESW_FLOWTABLE_FDB(esw->dev, reformat) &&
3145-
MLX5_CAP_ESW_FLOWTABLE_FDB(esw->dev, decap))
3146-
esw->offloads.encap = DEVLINK_ESWITCH_ENCAP_MODE_BASIC;
3147-
else
3148-
esw->offloads.encap = DEVLINK_ESWITCH_ENCAP_MODE_NONE;
3149-
31503144
mutex_init(&esw->offloads.termtbl_mutex);
31513145
mlx5_rdma_enable_roce(esw->dev);
31523146

@@ -3244,7 +3238,6 @@ void esw_offloads_disable(struct mlx5_eswitch *esw)
32443238
esw_offloads_metadata_uninit(esw);
32453239
mlx5_rdma_disable_roce(esw->dev);
32463240
mutex_destroy(&esw->offloads.termtbl_mutex);
3247-
esw->offloads.encap = DEVLINK_ESWITCH_ENCAP_MODE_NONE;
32483241
}
32493242

32503243
static int esw_mode_from_devlink(u16 mode, u16 *mlx5_mode)

‎include/linux/mlx5/eswitch.h‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,13 +136,13 @@ u32 mlx5_eswitch_get_vport_metadata_for_set(struct mlx5_eswitch *esw,
136136
ESW_TUN_OPTS_SLOW_TABLE_GOTO_VPORT)
137137
#define ESW_TUN_SLOW_TABLE_GOTO_VPORT_MARK ESW_TUN_OPTS_MASK
138138

139-
u8 mlx5_eswitch_mode(struct mlx5_core_dev *dev);
139+
u8 mlx5_eswitch_mode(const struct mlx5_core_dev *dev);
140140
u16 mlx5_eswitch_get_total_vports(const struct mlx5_core_dev *dev);
141141
struct mlx5_core_dev *mlx5_eswitch_get_core_dev(struct mlx5_eswitch *esw);
142142

143143
#else /* CONFIG_MLX5_ESWITCH */
144144

145-
static inline u8 mlx5_eswitch_mode(struct mlx5_core_dev *dev)
145+
static inline u8 mlx5_eswitch_mode(const struct mlx5_core_dev *dev)
146146
{
147147
return MLX5_ESWITCH_NONE;
148148
}

0 commit comments

Comments
 (0)