Skip to content

Commit c5eb51a

Browse files
ayalevinSaeed Mahameed
authored andcommitted
net/mlx5e: Fix VXLAN synchronization after function reload
During driver reload, perform firmware tear-down which results in firmware losing the configured VXLAN ports. These ports are still available in the driver's database. Fix this by cleaning up driver's VXLAN database in the nic unload flow, before firmware tear-down. With that, minimize mlx5_vxlan_destroy() to remove only what was added in mlx5_vxlan_create() and warn on leftover UDP ports. Fixes: 18a2b7f ("net/mlx5: convert to new udp_tunnel infrastructure") Signed-off-by: Aya Levin <ayal@nvidia.com> Reviewed-by: Moshe Shemesh <moshe@nvidia.com> Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
1 parent ae35859 commit c5eb51a

3 files changed

Lines changed: 20 additions & 6 deletions

File tree

drivers/net/ethernet/mellanox/mlx5/core/en_main.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5253,6 +5253,7 @@ static void mlx5e_nic_disable(struct mlx5e_priv *priv)
52535253

52545254
mlx5e_disable_async_events(priv);
52555255
mlx5_lag_remove(mdev);
5256+
mlx5_vxlan_reset_to_default(mdev->vxlan);
52565257
}
52575258

52585259
int mlx5e_update_nic_rx(struct mlx5e_priv *priv)

drivers/net/ethernet/mellanox/mlx5/core/lib/vxlan.c

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,17 @@ struct mlx5_vxlan *mlx5_vxlan_create(struct mlx5_core_dev *mdev)
167167
}
168168

169169
void mlx5_vxlan_destroy(struct mlx5_vxlan *vxlan)
170+
{
171+
if (!mlx5_vxlan_allowed(vxlan))
172+
return;
173+
174+
mlx5_vxlan_del_port(vxlan, IANA_VXLAN_UDP_PORT);
175+
WARN_ON(!hash_empty(vxlan->htable));
176+
177+
kfree(vxlan);
178+
}
179+
180+
void mlx5_vxlan_reset_to_default(struct mlx5_vxlan *vxlan)
170181
{
171182
struct mlx5_vxlan_port *vxlanp;
172183
struct hlist_node *tmp;
@@ -175,12 +186,12 @@ void mlx5_vxlan_destroy(struct mlx5_vxlan *vxlan)
175186
if (!mlx5_vxlan_allowed(vxlan))
176187
return;
177188

178-
/* Lockless since we are the only hash table consumers*/
179189
hash_for_each_safe(vxlan->htable, bkt, tmp, vxlanp, hlist) {
180-
hash_del(&vxlanp->hlist);
181-
mlx5_vxlan_core_del_port_cmd(vxlan->mdev, vxlanp->udp_port);
182-
kfree(vxlanp);
190+
/* Don't delete default UDP port added by the HW.
191+
* Remove only user configured ports
192+
*/
193+
if (vxlanp->udp_port == IANA_VXLAN_UDP_PORT)
194+
continue;
195+
mlx5_vxlan_del_port(vxlan, vxlanp->udp_port);
183196
}
184-
185-
kfree(vxlan);
186197
}

drivers/net/ethernet/mellanox/mlx5/core/lib/vxlan.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,13 +56,15 @@ void mlx5_vxlan_destroy(struct mlx5_vxlan *vxlan);
5656
int mlx5_vxlan_add_port(struct mlx5_vxlan *vxlan, u16 port);
5757
int mlx5_vxlan_del_port(struct mlx5_vxlan *vxlan, u16 port);
5858
bool mlx5_vxlan_lookup_port(struct mlx5_vxlan *vxlan, u16 port);
59+
void mlx5_vxlan_reset_to_default(struct mlx5_vxlan *vxlan);
5960
#else
6061
static inline struct mlx5_vxlan*
6162
mlx5_vxlan_create(struct mlx5_core_dev *mdev) { return ERR_PTR(-EOPNOTSUPP); }
6263
static inline void mlx5_vxlan_destroy(struct mlx5_vxlan *vxlan) { return; }
6364
static inline int mlx5_vxlan_add_port(struct mlx5_vxlan *vxlan, u16 port) { return -EOPNOTSUPP; }
6465
static inline int mlx5_vxlan_del_port(struct mlx5_vxlan *vxlan, u16 port) { return -EOPNOTSUPP; }
6566
static inline bool mlx5_vxlan_lookup_port(struct mlx5_vxlan *vxlan, u16 port) { return false; }
67+
static inline void mlx5_vxlan_reset_to_default(struct mlx5_vxlan *vxlan) { return; }
6668
#endif
6769

6870
#endif /* __MLX5_VXLAN_H__ */

0 commit comments

Comments
 (0)