Skip to content

Commit 4daa873

Browse files
committed
Merge tag 'mlx5-fixes-2024-03-01' of git://git.kernel.org/pub/scm/linux/kernel/git/saeed/linux
Saeed Mahameed says: ==================== mlx5 fixes 2024-03-01 This series provides bug fixes to mlx5 driver. Please pull and let me know if there is any problem. * tag 'mlx5-fixes-2024-03-01' of git://git.kernel.org/pub/scm/linux/kernel/git/saeed/linux: net/mlx5e: Switch to using _bh variant of of spinlock API in port timestamping NAPI poll context net/mlx5e: Use a memory barrier to enforce PTP WQ xmit submission tracking occurs after populating the metadata_map net/mlx5e: Fix MACsec state loss upon state update in offload path net/mlx5e: Change the warning when ignore_flow_level is not supported net/mlx5: Check capability for fw_reset net/mlx5: Fix fw reporter diagnose output net/mlx5: E-switch, Change flow rule destination checking Revert "net/mlx5e: Check the number of elements before walk TC rhashtable" Revert "net/mlx5: Block entering switchdev mode with ns inconsistency" ==================== Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
2 parents 47fe2fc + 90502d4 commit 4daa873

File tree

10 files changed

+105
-75
lines changed

10 files changed

+105
-75
lines changed

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,12 @@ static int mlx5_devlink_reload_down(struct devlink *devlink, bool netns_change,
157157
return -EOPNOTSUPP;
158158
}
159159

160+
if (action == DEVLINK_RELOAD_ACTION_FW_ACTIVATE &&
161+
!dev->priv.fw_reset) {
162+
NL_SET_ERR_MSG_MOD(extack, "FW activate is unsupported for this function");
163+
return -EOPNOTSUPP;
164+
}
165+
160166
if (mlx5_core_is_pf(dev) && pci_num_vf(pdev))
161167
NL_SET_ERR_MSG_MOD(extack, "reload while VFs are present is unfavorable");
162168

drivers/net/ethernet/mellanox/mlx5/core/en/ptp.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,9 @@ mlx5e_ptp_port_ts_cqe_list_add(struct mlx5e_ptp_port_ts_cqe_list *list, u8 metad
4242

4343
WARN_ON_ONCE(tracker->inuse);
4444
tracker->inuse = true;
45-
spin_lock(&list->tracker_list_lock);
45+
spin_lock_bh(&list->tracker_list_lock);
4646
list_add_tail(&tracker->entry, &list->tracker_list_head);
47-
spin_unlock(&list->tracker_list_lock);
47+
spin_unlock_bh(&list->tracker_list_lock);
4848
}
4949

5050
static void
@@ -54,9 +54,9 @@ mlx5e_ptp_port_ts_cqe_list_remove(struct mlx5e_ptp_port_ts_cqe_list *list, u8 me
5454

5555
WARN_ON_ONCE(!tracker->inuse);
5656
tracker->inuse = false;
57-
spin_lock(&list->tracker_list_lock);
57+
spin_lock_bh(&list->tracker_list_lock);
5858
list_del(&tracker->entry);
59-
spin_unlock(&list->tracker_list_lock);
59+
spin_unlock_bh(&list->tracker_list_lock);
6060
}
6161

6262
void mlx5e_ptpsq_track_metadata(struct mlx5e_ptpsq *ptpsq, u8 metadata)
@@ -155,7 +155,7 @@ static void mlx5e_ptpsq_mark_ts_cqes_undelivered(struct mlx5e_ptpsq *ptpsq,
155155
struct mlx5e_ptp_metadata_map *metadata_map = &ptpsq->metadata_map;
156156
struct mlx5e_ptp_port_ts_cqe_tracker *pos, *n;
157157

158-
spin_lock(&cqe_list->tracker_list_lock);
158+
spin_lock_bh(&cqe_list->tracker_list_lock);
159159
list_for_each_entry_safe(pos, n, &cqe_list->tracker_list_head, entry) {
160160
struct sk_buff *skb =
161161
mlx5e_ptp_metadata_map_lookup(metadata_map, pos->metadata_id);
@@ -170,7 +170,7 @@ static void mlx5e_ptpsq_mark_ts_cqes_undelivered(struct mlx5e_ptpsq *ptpsq,
170170
pos->inuse = false;
171171
list_del(&pos->entry);
172172
}
173-
spin_unlock(&cqe_list->tracker_list_lock);
173+
spin_unlock_bh(&cqe_list->tracker_list_lock);
174174
}
175175

176176
#define PTP_WQE_CTR2IDX(val) ((val) & ptpsq->ts_cqe_ctr_mask)

drivers/net/ethernet/mellanox/mlx5/core/en/tc/post_act.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ mlx5e_tc_post_act_init(struct mlx5e_priv *priv, struct mlx5_fs_chains *chains,
3737

3838
if (!MLX5_CAP_FLOWTABLE_TYPE(priv->mdev, ignore_flow_level, table_type)) {
3939
if (priv->mdev->coredev_type == MLX5_COREDEV_PF)
40-
mlx5_core_warn(priv->mdev, "firmware level support is missing\n");
40+
mlx5_core_dbg(priv->mdev, "firmware flow level support is missing\n");
4141
err = -EOPNOTSUPP;
4242
goto err_check;
4343
}

drivers/net/ethernet/mellanox/mlx5/core/en_accel/macsec.c

Lines changed: 51 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -310,9 +310,9 @@ static void mlx5e_macsec_destroy_object(struct mlx5_core_dev *mdev, u32 macsec_o
310310
mlx5_cmd_exec(mdev, in, sizeof(in), out, sizeof(out));
311311
}
312312

313-
static void mlx5e_macsec_cleanup_sa(struct mlx5e_macsec *macsec,
314-
struct mlx5e_macsec_sa *sa,
315-
bool is_tx, struct net_device *netdev, u32 fs_id)
313+
static void mlx5e_macsec_cleanup_sa_fs(struct mlx5e_macsec *macsec,
314+
struct mlx5e_macsec_sa *sa, bool is_tx,
315+
struct net_device *netdev, u32 fs_id)
316316
{
317317
int action = (is_tx) ? MLX5_ACCEL_MACSEC_ACTION_ENCRYPT :
318318
MLX5_ACCEL_MACSEC_ACTION_DECRYPT;
@@ -322,20 +322,49 @@ static void mlx5e_macsec_cleanup_sa(struct mlx5e_macsec *macsec,
322322

323323
mlx5_macsec_fs_del_rule(macsec->mdev->macsec_fs, sa->macsec_rule, action, netdev,
324324
fs_id);
325-
mlx5e_macsec_destroy_object(macsec->mdev, sa->macsec_obj_id);
326325
sa->macsec_rule = NULL;
327326
}
328327

328+
static void mlx5e_macsec_cleanup_sa(struct mlx5e_macsec *macsec,
329+
struct mlx5e_macsec_sa *sa, bool is_tx,
330+
struct net_device *netdev, u32 fs_id)
331+
{
332+
mlx5e_macsec_cleanup_sa_fs(macsec, sa, is_tx, netdev, fs_id);
333+
mlx5e_macsec_destroy_object(macsec->mdev, sa->macsec_obj_id);
334+
}
335+
336+
static int mlx5e_macsec_init_sa_fs(struct macsec_context *ctx,
337+
struct mlx5e_macsec_sa *sa, bool encrypt,
338+
bool is_tx, u32 *fs_id)
339+
{
340+
struct mlx5e_priv *priv = macsec_netdev_priv(ctx->netdev);
341+
struct mlx5_macsec_fs *macsec_fs = priv->mdev->macsec_fs;
342+
struct mlx5_macsec_rule_attrs rule_attrs;
343+
union mlx5_macsec_rule *macsec_rule;
344+
345+
rule_attrs.macsec_obj_id = sa->macsec_obj_id;
346+
rule_attrs.sci = sa->sci;
347+
rule_attrs.assoc_num = sa->assoc_num;
348+
rule_attrs.action = (is_tx) ? MLX5_ACCEL_MACSEC_ACTION_ENCRYPT :
349+
MLX5_ACCEL_MACSEC_ACTION_DECRYPT;
350+
351+
macsec_rule = mlx5_macsec_fs_add_rule(macsec_fs, ctx, &rule_attrs, fs_id);
352+
if (!macsec_rule)
353+
return -ENOMEM;
354+
355+
sa->macsec_rule = macsec_rule;
356+
357+
return 0;
358+
}
359+
329360
static int mlx5e_macsec_init_sa(struct macsec_context *ctx,
330361
struct mlx5e_macsec_sa *sa,
331362
bool encrypt, bool is_tx, u32 *fs_id)
332363
{
333364
struct mlx5e_priv *priv = macsec_netdev_priv(ctx->netdev);
334365
struct mlx5e_macsec *macsec = priv->macsec;
335-
struct mlx5_macsec_rule_attrs rule_attrs;
336366
struct mlx5_core_dev *mdev = priv->mdev;
337367
struct mlx5_macsec_obj_attrs obj_attrs;
338-
union mlx5_macsec_rule *macsec_rule;
339368
int err;
340369

341370
obj_attrs.next_pn = sa->next_pn;
@@ -357,20 +386,12 @@ static int mlx5e_macsec_init_sa(struct macsec_context *ctx,
357386
if (err)
358387
return err;
359388

360-
rule_attrs.macsec_obj_id = sa->macsec_obj_id;
361-
rule_attrs.sci = sa->sci;
362-
rule_attrs.assoc_num = sa->assoc_num;
363-
rule_attrs.action = (is_tx) ? MLX5_ACCEL_MACSEC_ACTION_ENCRYPT :
364-
MLX5_ACCEL_MACSEC_ACTION_DECRYPT;
365-
366-
macsec_rule = mlx5_macsec_fs_add_rule(mdev->macsec_fs, ctx, &rule_attrs, fs_id);
367-
if (!macsec_rule) {
368-
err = -ENOMEM;
369-
goto destroy_macsec_object;
389+
if (sa->active) {
390+
err = mlx5e_macsec_init_sa_fs(ctx, sa, encrypt, is_tx, fs_id);
391+
if (err)
392+
goto destroy_macsec_object;
370393
}
371394

372-
sa->macsec_rule = macsec_rule;
373-
374395
return 0;
375396

376397
destroy_macsec_object:
@@ -526,9 +547,7 @@ static int mlx5e_macsec_add_txsa(struct macsec_context *ctx)
526547
goto destroy_sa;
527548

528549
macsec_device->tx_sa[assoc_num] = tx_sa;
529-
if (!secy->operational ||
530-
assoc_num != tx_sc->encoding_sa ||
531-
!tx_sa->active)
550+
if (!secy->operational)
532551
goto out;
533552

534553
err = mlx5e_macsec_init_sa(ctx, tx_sa, tx_sc->encrypt, true, NULL);
@@ -595,7 +614,7 @@ static int mlx5e_macsec_upd_txsa(struct macsec_context *ctx)
595614
goto out;
596615

597616
if (ctx_tx_sa->active) {
598-
err = mlx5e_macsec_init_sa(ctx, tx_sa, tx_sc->encrypt, true, NULL);
617+
err = mlx5e_macsec_init_sa_fs(ctx, tx_sa, tx_sc->encrypt, true, NULL);
599618
if (err)
600619
goto out;
601620
} else {
@@ -604,7 +623,7 @@ static int mlx5e_macsec_upd_txsa(struct macsec_context *ctx)
604623
goto out;
605624
}
606625

607-
mlx5e_macsec_cleanup_sa(macsec, tx_sa, true, ctx->secy->netdev, 0);
626+
mlx5e_macsec_cleanup_sa_fs(macsec, tx_sa, true, ctx->secy->netdev, 0);
608627
}
609628
out:
610629
mutex_unlock(&macsec->lock);
@@ -1030,8 +1049,9 @@ static int mlx5e_macsec_del_rxsa(struct macsec_context *ctx)
10301049
goto out;
10311050
}
10321051

1033-
mlx5e_macsec_cleanup_sa(macsec, rx_sa, false, ctx->secy->netdev,
1034-
rx_sc->sc_xarray_element->fs_id);
1052+
if (rx_sa->active)
1053+
mlx5e_macsec_cleanup_sa(macsec, rx_sa, false, ctx->secy->netdev,
1054+
rx_sc->sc_xarray_element->fs_id);
10351055
mlx5_destroy_encryption_key(macsec->mdev, rx_sa->enc_key_id);
10361056
kfree(rx_sa);
10371057
rx_sc->rx_sa[assoc_num] = NULL;
@@ -1112,8 +1132,8 @@ static int macsec_upd_secy_hw_address(struct macsec_context *ctx,
11121132
if (!rx_sa || !rx_sa->macsec_rule)
11131133
continue;
11141134

1115-
mlx5e_macsec_cleanup_sa(macsec, rx_sa, false, ctx->secy->netdev,
1116-
rx_sc->sc_xarray_element->fs_id);
1135+
mlx5e_macsec_cleanup_sa_fs(macsec, rx_sa, false, ctx->secy->netdev,
1136+
rx_sc->sc_xarray_element->fs_id);
11171137
}
11181138
}
11191139

@@ -1124,8 +1144,8 @@ static int macsec_upd_secy_hw_address(struct macsec_context *ctx,
11241144
continue;
11251145

11261146
if (rx_sa->active) {
1127-
err = mlx5e_macsec_init_sa(ctx, rx_sa, true, false,
1128-
&rx_sc->sc_xarray_element->fs_id);
1147+
err = mlx5e_macsec_init_sa_fs(ctx, rx_sa, true, false,
1148+
&rx_sc->sc_xarray_element->fs_id);
11291149
if (err)
11301150
goto out;
11311151
}
@@ -1178,7 +1198,7 @@ static int mlx5e_macsec_upd_secy(struct macsec_context *ctx)
11781198
if (!tx_sa)
11791199
continue;
11801200

1181-
mlx5e_macsec_cleanup_sa(macsec, tx_sa, true, ctx->secy->netdev, 0);
1201+
mlx5e_macsec_cleanup_sa_fs(macsec, tx_sa, true, ctx->secy->netdev, 0);
11821202
}
11831203

11841204
for (i = 0; i < MACSEC_NUM_AN; ++i) {
@@ -1187,7 +1207,7 @@ static int mlx5e_macsec_upd_secy(struct macsec_context *ctx)
11871207
continue;
11881208

11891209
if (tx_sa->assoc_num == tx_sc->encoding_sa && tx_sa->active) {
1190-
err = mlx5e_macsec_init_sa(ctx, tx_sa, tx_sc->encrypt, true, NULL);
1210+
err = mlx5e_macsec_init_sa_fs(ctx, tx_sa, tx_sc->encrypt, true, NULL);
11911211
if (err)
11921212
goto out;
11931213
}

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -401,6 +401,8 @@ mlx5e_txwqe_complete(struct mlx5e_txqsq *sq, struct sk_buff *skb,
401401
mlx5e_skb_cb_hwtstamp_init(skb);
402402
mlx5e_ptp_metadata_map_put(&sq->ptpsq->metadata_map, skb,
403403
metadata_index);
404+
/* ensure skb is put on metadata_map before tracking the index */
405+
wmb();
404406
mlx5e_ptpsq_track_metadata(sq->ptpsq, metadata_index);
405407
if (!netif_tx_queue_stopped(sq->txq) &&
406408
mlx5e_ptpsq_metadata_freelist_empty(sq->ptpsq)) {

drivers/net/ethernet/mellanox/mlx5/core/esw/ipsec_fs.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ void mlx5_esw_ipsec_restore_dest_uplink(struct mlx5_core_dev *mdev)
152152

153153
xa_for_each(&esw->offloads.vport_reps, i, rep) {
154154
rpriv = rep->rep_data[REP_ETH].priv;
155-
if (!rpriv || !rpriv->netdev || !atomic_read(&rpriv->tc_ht.nelems))
155+
if (!rpriv || !rpriv->netdev)
156156
continue;
157157

158158
rhashtable_walk_enter(&rpriv->tc_ht, &iter);

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

Lines changed: 14 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -535,21 +535,26 @@ esw_src_port_rewrite_supported(struct mlx5_eswitch *esw)
535535
}
536536

537537
static bool
538-
esw_dests_to_vf_pf_vports(struct mlx5_flow_destination *dests, int max_dest)
538+
esw_dests_to_int_external(struct mlx5_flow_destination *dests, int max_dest)
539539
{
540-
bool vf_dest = false, pf_dest = false;
540+
bool internal_dest = false, external_dest = false;
541541
int i;
542542

543543
for (i = 0; i < max_dest; i++) {
544-
if (dests[i].type != MLX5_FLOW_DESTINATION_TYPE_VPORT)
544+
if (dests[i].type != MLX5_FLOW_DESTINATION_TYPE_VPORT &&
545+
dests[i].type != MLX5_FLOW_DESTINATION_TYPE_UPLINK)
545546
continue;
546547

547-
if (dests[i].vport.num == MLX5_VPORT_UPLINK)
548-
pf_dest = true;
548+
/* Uplink dest is external, but considered as internal
549+
* if there is reformat because firmware uses LB+hairpin to support it.
550+
*/
551+
if (dests[i].vport.num == MLX5_VPORT_UPLINK &&
552+
!(dests[i].vport.flags & MLX5_FLOW_DEST_VPORT_REFORMAT_ID))
553+
external_dest = true;
549554
else
550-
vf_dest = true;
555+
internal_dest = true;
551556

552-
if (vf_dest && pf_dest)
557+
if (internal_dest && external_dest)
553558
return true;
554559
}
555560

@@ -695,9 +700,9 @@ mlx5_eswitch_add_offloaded_rule(struct mlx5_eswitch *esw,
695700

696701
/* Header rewrite with combined wire+loopback in FDB is not allowed */
697702
if ((flow_act.action & MLX5_FLOW_CONTEXT_ACTION_MOD_HDR) &&
698-
esw_dests_to_vf_pf_vports(dest, i)) {
703+
esw_dests_to_int_external(dest, i)) {
699704
esw_warn(esw->dev,
700-
"FDB: Header rewrite with forwarding to both PF and VF is not allowed\n");
705+
"FDB: Header rewrite with forwarding to both internal and external dests is not allowed\n");
701706
rule = ERR_PTR(-EINVAL);
702707
goto err_esw_get;
703708
}
@@ -3658,22 +3663,6 @@ static int esw_inline_mode_to_devlink(u8 mlx5_mode, u8 *mode)
36583663
return 0;
36593664
}
36603665

3661-
static bool esw_offloads_devlink_ns_eq_netdev_ns(struct devlink *devlink)
3662-
{
3663-
struct mlx5_core_dev *dev = devlink_priv(devlink);
3664-
struct net *devl_net, *netdev_net;
3665-
bool ret = false;
3666-
3667-
mutex_lock(&dev->mlx5e_res.uplink_netdev_lock);
3668-
if (dev->mlx5e_res.uplink_netdev) {
3669-
netdev_net = dev_net(dev->mlx5e_res.uplink_netdev);
3670-
devl_net = devlink_net(devlink);
3671-
ret = net_eq(devl_net, netdev_net);
3672-
}
3673-
mutex_unlock(&dev->mlx5e_res.uplink_netdev_lock);
3674-
return ret;
3675-
}
3676-
36773666
int mlx5_eswitch_block_mode(struct mlx5_core_dev *dev)
36783667
{
36793668
struct mlx5_eswitch *esw = dev->priv.eswitch;
@@ -3718,13 +3707,6 @@ int mlx5_devlink_eswitch_mode_set(struct devlink *devlink, u16 mode,
37183707
if (esw_mode_from_devlink(mode, &mlx5_mode))
37193708
return -EINVAL;
37203709

3721-
if (mode == DEVLINK_ESWITCH_MODE_SWITCHDEV &&
3722-
!esw_offloads_devlink_ns_eq_netdev_ns(devlink)) {
3723-
NL_SET_ERR_MSG_MOD(extack,
3724-
"Can't change E-Switch mode to switchdev when netdev net namespace has diverged from the devlink's.");
3725-
return -EPERM;
3726-
}
3727-
37283710
mlx5_lag_disable_change(esw->dev);
37293711
err = mlx5_esw_try_lock(esw);
37303712
if (err < 0) {

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

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -703,19 +703,30 @@ void mlx5_fw_reset_events_start(struct mlx5_core_dev *dev)
703703
{
704704
struct mlx5_fw_reset *fw_reset = dev->priv.fw_reset;
705705

706+
if (!fw_reset)
707+
return;
708+
706709
MLX5_NB_INIT(&fw_reset->nb, fw_reset_event_notifier, GENERAL_EVENT);
707710
mlx5_eq_notifier_register(dev, &fw_reset->nb);
708711
}
709712

710713
void mlx5_fw_reset_events_stop(struct mlx5_core_dev *dev)
711714
{
712-
mlx5_eq_notifier_unregister(dev, &dev->priv.fw_reset->nb);
715+
struct mlx5_fw_reset *fw_reset = dev->priv.fw_reset;
716+
717+
if (!fw_reset)
718+
return;
719+
720+
mlx5_eq_notifier_unregister(dev, &fw_reset->nb);
713721
}
714722

715723
void mlx5_drain_fw_reset(struct mlx5_core_dev *dev)
716724
{
717725
struct mlx5_fw_reset *fw_reset = dev->priv.fw_reset;
718726

727+
if (!fw_reset)
728+
return;
729+
719730
set_bit(MLX5_FW_RESET_FLAGS_DROP_NEW_REQUESTS, &fw_reset->reset_flags);
720731
cancel_work_sync(&fw_reset->fw_live_patch_work);
721732
cancel_work_sync(&fw_reset->reset_request_work);
@@ -733,9 +744,13 @@ static const struct devlink_param mlx5_fw_reset_devlink_params[] = {
733744

734745
int mlx5_fw_reset_init(struct mlx5_core_dev *dev)
735746
{
736-
struct mlx5_fw_reset *fw_reset = kzalloc(sizeof(*fw_reset), GFP_KERNEL);
747+
struct mlx5_fw_reset *fw_reset;
737748
int err;
738749

750+
if (!MLX5_CAP_MCAM_REG(dev, mfrl))
751+
return 0;
752+
753+
fw_reset = kzalloc(sizeof(*fw_reset), GFP_KERNEL);
739754
if (!fw_reset)
740755
return -ENOMEM;
741756
fw_reset->wq = create_singlethread_workqueue("mlx5_fw_reset_events");
@@ -771,6 +786,9 @@ void mlx5_fw_reset_cleanup(struct mlx5_core_dev *dev)
771786
{
772787
struct mlx5_fw_reset *fw_reset = dev->priv.fw_reset;
773788

789+
if (!fw_reset)
790+
return;
791+
774792
devl_params_unregister(priv_to_devlink(dev),
775793
mlx5_fw_reset_devlink_params,
776794
ARRAY_SIZE(mlx5_fw_reset_devlink_params));

0 commit comments

Comments
 (0)