Skip to content

Commit d32ba90

Browse files
committed
Merge branch 'mlx5-misc-fixes-2026-01-26'
Tariq Toukan says: ==================== mlx5 misc fixes 2026-01-26 misc bug fixes from the team to the mlx5 core and Eth drivers. ==================== Link: https://patch.msgid.link/1769411695-18820-1-git-send-email-tariqt@nvidia.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2 parents e9acda5 + 476681f commit d32ba90

6 files changed

Lines changed: 70 additions & 15 deletions

File tree

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

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -575,3 +575,17 @@ bool mlx5_same_hw_devs(struct mlx5_core_dev *dev, struct mlx5_core_dev *peer_dev
575575
return plen && flen && flen == plen &&
576576
!memcmp(fsystem_guid, psystem_guid, flen);
577577
}
578+
579+
void mlx5_core_reps_aux_devs_remove(struct mlx5_core_dev *dev)
580+
{
581+
struct mlx5_priv *priv = &dev->priv;
582+
583+
if (priv->adev[MLX5_INTERFACE_PROTOCOL_ETH])
584+
device_lock_assert(&priv->adev[MLX5_INTERFACE_PROTOCOL_ETH]->adev.dev);
585+
else
586+
mlx5_core_err(dev, "ETH driver already removed\n");
587+
if (priv->adev[MLX5_INTERFACE_PROTOCOL_IB_REP])
588+
del_adev(&priv->adev[MLX5_INTERFACE_PROTOCOL_IB_REP]->adev);
589+
if (priv->adev[MLX5_INTERFACE_PROTOCOL_ETH_REP])
590+
del_adev(&priv->adev[MLX5_INTERFACE_PROTOCOL_ETH_REP]->adev);
591+
}

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

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4052,6 +4052,8 @@ mlx5e_get_stats(struct net_device *dev, struct rtnl_link_stats64 *stats)
40524052
mlx5e_queue_update_stats(priv);
40534053
}
40544054

4055+
netdev_stats_to_stats64(stats, &dev->stats);
4056+
40554057
if (mlx5e_is_uplink_rep(priv)) {
40564058
struct mlx5e_vport_stats *vstats = &priv->stats.vport;
40574059

@@ -4068,21 +4070,21 @@ mlx5e_get_stats(struct net_device *dev, struct rtnl_link_stats64 *stats)
40684070
mlx5e_fold_sw_stats64(priv, stats);
40694071
}
40704072

4071-
stats->rx_missed_errors = priv->stats.qcnt.rx_out_of_buffer;
4072-
stats->rx_dropped = PPORT_2863_GET(pstats, if_in_discards);
4073+
stats->rx_missed_errors += priv->stats.qcnt.rx_out_of_buffer;
4074+
stats->rx_dropped += PPORT_2863_GET(pstats, if_in_discards);
40734075

4074-
stats->rx_length_errors =
4076+
stats->rx_length_errors +=
40754077
PPORT_802_3_GET(pstats, a_in_range_length_errors) +
40764078
PPORT_802_3_GET(pstats, a_out_of_range_length_field) +
40774079
PPORT_802_3_GET(pstats, a_frame_too_long_errors) +
40784080
VNIC_ENV_GET(&priv->stats.vnic, eth_wqe_too_small);
4079-
stats->rx_crc_errors =
4081+
stats->rx_crc_errors +=
40804082
PPORT_802_3_GET(pstats, a_frame_check_sequence_errors);
4081-
stats->rx_frame_errors = PPORT_802_3_GET(pstats, a_alignment_errors);
4082-
stats->tx_aborted_errors = PPORT_2863_GET(pstats, if_out_discards);
4083-
stats->rx_errors = stats->rx_length_errors + stats->rx_crc_errors +
4084-
stats->rx_frame_errors;
4085-
stats->tx_errors = stats->tx_aborted_errors + stats->tx_carrier_errors;
4083+
stats->rx_frame_errors += PPORT_802_3_GET(pstats, a_alignment_errors);
4084+
stats->tx_aborted_errors += PPORT_2863_GET(pstats, if_out_discards);
4085+
stats->rx_errors += stats->rx_length_errors + stats->rx_crc_errors +
4086+
stats->rx_frame_errors;
4087+
stats->tx_errors += stats->tx_aborted_errors + stats->tx_carrier_errors;
40864088
}
40874089

40884090
static void mlx5e_nic_set_rx_mode(struct mlx5e_priv *priv)
@@ -6842,6 +6844,7 @@ static void _mlx5e_remove(struct auxiliary_device *adev)
68426844
struct mlx5e_priv *priv = netdev_priv(netdev);
68436845
struct mlx5_core_dev *mdev = edev->mdev;
68446846

6847+
mlx5_eswitch_safe_aux_devs_remove(mdev);
68456848
mlx5_core_uplink_netdev_set(mdev, NULL);
68466849

68476850
if (priv->profile)

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

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2147,11 +2147,14 @@ static void mlx5e_tc_del_fdb_peer_flow(struct mlx5e_tc_flow *flow,
21472147

21482148
static void mlx5e_tc_del_fdb_peers_flow(struct mlx5e_tc_flow *flow)
21492149
{
2150+
struct mlx5_devcom_comp_dev *devcom;
2151+
struct mlx5_devcom_comp_dev *pos;
2152+
struct mlx5_eswitch *peer_esw;
21502153
int i;
21512154

2152-
for (i = 0; i < MLX5_MAX_PORTS; i++) {
2153-
if (i == mlx5_get_dev_index(flow->priv->mdev))
2154-
continue;
2155+
devcom = flow->priv->mdev->priv.eswitch->devcom;
2156+
mlx5_devcom_for_each_peer_entry(devcom, peer_esw, pos) {
2157+
i = mlx5_get_dev_index(peer_esw->dev);
21552158
mlx5e_tc_del_fdb_peer_flow(flow, i);
21562159
}
21572160
}
@@ -5513,12 +5516,16 @@ int mlx5e_tc_num_filters(struct mlx5e_priv *priv, unsigned long flags)
55135516

55145517
void mlx5e_tc_clean_fdb_peer_flows(struct mlx5_eswitch *esw)
55155518
{
5519+
struct mlx5_devcom_comp_dev *devcom;
5520+
struct mlx5_devcom_comp_dev *pos;
55165521
struct mlx5e_tc_flow *flow, *tmp;
5522+
struct mlx5_eswitch *peer_esw;
55175523
int i;
55185524

5519-
for (i = 0; i < MLX5_MAX_PORTS; i++) {
5520-
if (i == mlx5_get_dev_index(esw->dev))
5521-
continue;
5525+
devcom = esw->devcom;
5526+
5527+
mlx5_devcom_for_each_peer_entry(devcom, peer_esw, pos) {
5528+
i = mlx5_get_dev_index(peer_esw->dev);
55225529
list_for_each_entry_safe(flow, tmp, &esw->offloads.peer_flows[i], peer[i])
55235530
mlx5e_tc_del_fdb_peers_flow(flow);
55245531
}

drivers/net/ethernet/mellanox/mlx5/core/eswitch.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -929,6 +929,7 @@ int mlx5_esw_ipsec_vf_packet_offload_set(struct mlx5_eswitch *esw, struct mlx5_v
929929
int mlx5_esw_ipsec_vf_packet_offload_supported(struct mlx5_core_dev *dev,
930930
u16 vport_num);
931931
bool mlx5_esw_host_functions_enabled(const struct mlx5_core_dev *dev);
932+
void mlx5_eswitch_safe_aux_devs_remove(struct mlx5_core_dev *dev);
932933
#else /* CONFIG_MLX5_ESWITCH */
933934
/* eswitch API stubs */
934935
static inline int mlx5_eswitch_init(struct mlx5_core_dev *dev) { return 0; }
@@ -1012,6 +1013,9 @@ mlx5_esw_vport_vhca_id(struct mlx5_eswitch *esw, u16 vportn, u16 *vhca_id)
10121013
return false;
10131014
}
10141015

1016+
static inline void
1017+
mlx5_eswitch_safe_aux_devs_remove(struct mlx5_core_dev *dev) {}
1018+
10151019
#endif /* CONFIG_MLX5_ESWITCH */
10161020

10171021
#endif /* __MLX5_ESWITCH_H__ */

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

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3981,6 +3981,32 @@ static bool mlx5_devlink_switchdev_active_mode_change(struct mlx5_eswitch *esw,
39813981
return true;
39823982
}
39833983

3984+
#define MLX5_ESW_HOLD_TIMEOUT_MS 7000
3985+
#define MLX5_ESW_HOLD_RETRY_DELAY_MS 500
3986+
3987+
void mlx5_eswitch_safe_aux_devs_remove(struct mlx5_core_dev *dev)
3988+
{
3989+
unsigned long timeout;
3990+
bool hold_esw = true;
3991+
3992+
/* Wait for any concurrent eswitch mode transition to complete. */
3993+
if (!mlx5_esw_hold(dev)) {
3994+
timeout = jiffies + msecs_to_jiffies(MLX5_ESW_HOLD_TIMEOUT_MS);
3995+
while (!mlx5_esw_hold(dev)) {
3996+
if (!time_before(jiffies, timeout)) {
3997+
hold_esw = false;
3998+
break;
3999+
}
4000+
msleep(MLX5_ESW_HOLD_RETRY_DELAY_MS);
4001+
}
4002+
}
4003+
if (hold_esw) {
4004+
if (mlx5_eswitch_mode(dev) == MLX5_ESWITCH_OFFLOADS)
4005+
mlx5_core_reps_aux_devs_remove(dev);
4006+
mlx5_esw_release(dev);
4007+
}
4008+
}
4009+
39844010
int mlx5_devlink_eswitch_mode_set(struct devlink *devlink, u16 mode,
39854011
struct netlink_ext_ack *extack)
39864012
{

drivers/net/ethernet/mellanox/mlx5/core/mlx5_core.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,7 @@ int mlx5_register_device(struct mlx5_core_dev *dev);
290290
void mlx5_unregister_device(struct mlx5_core_dev *dev);
291291
void mlx5_dev_set_lightweight(struct mlx5_core_dev *dev);
292292
bool mlx5_dev_is_lightweight(struct mlx5_core_dev *dev);
293+
void mlx5_core_reps_aux_devs_remove(struct mlx5_core_dev *dev);
293294

294295
void mlx5_fw_reporters_create(struct mlx5_core_dev *dev);
295296
int mlx5_query_mtpps(struct mlx5_core_dev *dev, u32 *mtpps, u32 mtpps_size);

0 commit comments

Comments
 (0)