Skip to content

Commit 178a4ff

Browse files
committed
Merge tag 'mlx5-fixes-2022-11-21' of git://git.kernel.org/pub/scm/linux/kernel/git/saeed/linux
Saeed Mahameed says: ==================== mlx5 fixes 2022-11-21 This series provides bug fixes to mlx5 driver. * tag 'mlx5-fixes-2022-11-21' of git://git.kernel.org/pub/scm/linux/kernel/git/saeed/linux: net/mlx5e: Fix possible race condition in macsec extended packet number update routine net/mlx5e: Fix MACsec update SecY net/mlx5e: Fix MACsec SA initialization routine net/mlx5e: Remove leftovers from old XSK queues enumeration net/mlx5e: Offload rule only when all encaps are valid net/mlx5e: Fix missing alignment in size of MTT/KLM entries net/mlx5: Fix sync reset event handler error flow net/mlx5: E-Switch, Set correctly vport destination net/mlx5: Lag, avoid lockdep warnings net/mlx5: Fix handling of entry refcount when command is not issued to FW net/mlx5: cmdif, Print info on any firmware cmd failure to tracepoint net/mlx5: SF: Fix probing active SFs during driver probe phase net/mlx5: Fix FW tracer timestamp calculation net/mlx5: Do not query pci info while pci disabled ==================== Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
2 parents 568fe84 + 8514e32 commit 178a4ff

File tree

18 files changed

+281
-118
lines changed

18 files changed

+281
-118
lines changed

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

Lines changed: 25 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@
4545
#include "mlx5_core.h"
4646
#include "lib/eq.h"
4747
#include "lib/tout.h"
48+
#define CREATE_TRACE_POINTS
49+
#include "diag/cmd_tracepoint.h"
4850

4951
enum {
5052
CMD_IF_REV = 5,
@@ -785,27 +787,14 @@ EXPORT_SYMBOL(mlx5_cmd_out_err);
785787
static void cmd_status_print(struct mlx5_core_dev *dev, void *in, void *out)
786788
{
787789
u16 opcode, op_mod;
788-
u32 syndrome;
789-
u8 status;
790790
u16 uid;
791-
int err;
792-
793-
syndrome = MLX5_GET(mbox_out, out, syndrome);
794-
status = MLX5_GET(mbox_out, out, status);
795791

796792
opcode = MLX5_GET(mbox_in, in, opcode);
797793
op_mod = MLX5_GET(mbox_in, in, op_mod);
798794
uid = MLX5_GET(mbox_in, in, uid);
799795

800-
err = cmd_status_to_err(status);
801-
802796
if (!uid && opcode != MLX5_CMD_OP_DESTROY_MKEY)
803797
mlx5_cmd_out_err(dev, opcode, op_mod, out);
804-
else
805-
mlx5_core_dbg(dev,
806-
"%s(0x%x) op_mod(0x%x) uid(%d) failed, status %s(0x%x), syndrome (0x%x), err(%d)\n",
807-
mlx5_command_str(opcode), opcode, op_mod, uid,
808-
cmd_status_str(status), status, syndrome, err);
809798
}
810799

811800
int mlx5_cmd_check(struct mlx5_core_dev *dev, int err, void *in, void *out)
@@ -1016,14 +1005,14 @@ static void cmd_work_handler(struct work_struct *work)
10161005
cmd_ent_get(ent);
10171006
set_bit(MLX5_CMD_ENT_STATE_PENDING_COMP, &ent->state);
10181007

1008+
cmd_ent_get(ent); /* for the _real_ FW event on completion */
10191009
/* Skip sending command to fw if internal error */
10201010
if (mlx5_cmd_is_down(dev) || !opcode_allowed(&dev->cmd, ent->op)) {
10211011
ent->ret = -ENXIO;
10221012
mlx5_cmd_comp_handler(dev, 1ULL << ent->idx, true);
10231013
return;
10241014
}
10251015

1026-
cmd_ent_get(ent); /* for the _real_ FW event on completion */
10271016
/* ring doorbell after the descriptor is valid */
10281017
mlx5_core_dbg(dev, "writing 0x%x to command doorbell\n", 1 << ent->idx);
10291018
wmb();
@@ -1672,8 +1661,8 @@ static void mlx5_cmd_comp_handler(struct mlx5_core_dev *dev, u64 vec, bool force
16721661
cmd_ent_put(ent); /* timeout work was canceled */
16731662

16741663
if (!forced || /* Real FW completion */
1675-
pci_channel_offline(dev->pdev) || /* FW is inaccessible */
1676-
dev->state == MLX5_DEVICE_STATE_INTERNAL_ERROR)
1664+
mlx5_cmd_is_down(dev) || /* No real FW completion is expected */
1665+
!opcode_allowed(cmd, ent->op))
16771666
cmd_ent_put(ent);
16781667

16791668
ent->ts2 = ktime_get_ns();
@@ -1892,6 +1881,16 @@ static int cmd_exec(struct mlx5_core_dev *dev, void *in, int in_size, void *out,
18921881
return err;
18931882
}
18941883

1884+
static void mlx5_cmd_err_trace(struct mlx5_core_dev *dev, u16 opcode, u16 op_mod, void *out)
1885+
{
1886+
u32 syndrome = MLX5_GET(mbox_out, out, syndrome);
1887+
u8 status = MLX5_GET(mbox_out, out, status);
1888+
1889+
trace_mlx5_cmd(mlx5_command_str(opcode), opcode, op_mod,
1890+
cmd_status_str(status), status, syndrome,
1891+
cmd_status_to_err(status));
1892+
}
1893+
18951894
static void cmd_status_log(struct mlx5_core_dev *dev, u16 opcode, u8 status,
18961895
u32 syndrome, int err)
18971896
{
@@ -1914,16 +1913,18 @@ static void cmd_status_log(struct mlx5_core_dev *dev, u16 opcode, u8 status,
19141913
}
19151914

19161915
/* preserve -EREMOTEIO for outbox.status != OK, otherwise return err as is */
1917-
static int cmd_status_err(struct mlx5_core_dev *dev, int err, u16 opcode, void *out)
1916+
static int cmd_status_err(struct mlx5_core_dev *dev, int err, u16 opcode, u16 op_mod, void *out)
19181917
{
19191918
u32 syndrome = MLX5_GET(mbox_out, out, syndrome);
19201919
u8 status = MLX5_GET(mbox_out, out, status);
19211920

19221921
if (err == -EREMOTEIO) /* -EREMOTEIO is preserved */
19231922
err = -EIO;
19241923

1925-
if (!err && status != MLX5_CMD_STAT_OK)
1924+
if (!err && status != MLX5_CMD_STAT_OK) {
19261925
err = -EREMOTEIO;
1926+
mlx5_cmd_err_trace(dev, opcode, op_mod, out);
1927+
}
19271928

19281929
cmd_status_log(dev, opcode, status, syndrome, err);
19291930
return err;
@@ -1951,9 +1952,9 @@ int mlx5_cmd_do(struct mlx5_core_dev *dev, void *in, int in_size, void *out, int
19511952
{
19521953
int err = cmd_exec(dev, in, in_size, out, out_size, NULL, NULL, false);
19531954
u16 opcode = MLX5_GET(mbox_in, in, opcode);
1955+
u16 op_mod = MLX5_GET(mbox_in, in, op_mod);
19541956

1955-
err = cmd_status_err(dev, err, opcode, out);
1956-
return err;
1957+
return cmd_status_err(dev, err, opcode, op_mod, out);
19571958
}
19581959
EXPORT_SYMBOL(mlx5_cmd_do);
19591960

@@ -1997,8 +1998,9 @@ int mlx5_cmd_exec_polling(struct mlx5_core_dev *dev, void *in, int in_size,
19971998
{
19981999
int err = cmd_exec(dev, in, in_size, out, out_size, NULL, NULL, true);
19992000
u16 opcode = MLX5_GET(mbox_in, in, opcode);
2001+
u16 op_mod = MLX5_GET(mbox_in, in, op_mod);
20002002

2001-
err = cmd_status_err(dev, err, opcode, out);
2003+
err = cmd_status_err(dev, err, opcode, op_mod, out);
20022004
return mlx5_cmd_check(dev, err, in, out);
20032005
}
20042006
EXPORT_SYMBOL(mlx5_cmd_exec_polling);
@@ -2034,7 +2036,7 @@ static void mlx5_cmd_exec_cb_handler(int status, void *_work)
20342036
struct mlx5_async_ctx *ctx;
20352037

20362038
ctx = work->ctx;
2037-
status = cmd_status_err(ctx->dev, status, work->opcode, work->out);
2039+
status = cmd_status_err(ctx->dev, status, work->opcode, work->op_mod, work->out);
20382040
work->user_callback(status, work);
20392041
if (atomic_dec_and_test(&ctx->num_inflight))
20402042
complete(&ctx->inflight_done);
@@ -2049,6 +2051,7 @@ int mlx5_cmd_exec_cb(struct mlx5_async_ctx *ctx, void *in, int in_size,
20492051
work->ctx = ctx;
20502052
work->user_callback = callback;
20512053
work->opcode = MLX5_GET(mbox_in, in, opcode);
2054+
work->op_mod = MLX5_GET(mbox_in, in, op_mod);
20522055
work->out = out;
20532056
if (WARN_ON(!atomic_inc_not_zero(&ctx->num_inflight)))
20542057
return -EIO;
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/* SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB */
2+
/* Copyright (c) 2022, NVIDIA CORPORATION & AFFILIATES. All rights reserved. */
3+
4+
#undef TRACE_SYSTEM
5+
#define TRACE_SYSTEM mlx5
6+
7+
#if !defined(_MLX5_CMD_TP_H_) || defined(TRACE_HEADER_MULTI_READ)
8+
#define _MLX5_CMD_TP_H_
9+
10+
#include <linux/tracepoint.h>
11+
#include <linux/trace_seq.h>
12+
13+
TRACE_EVENT(mlx5_cmd,
14+
TP_PROTO(const char *command_str, u16 opcode, u16 op_mod,
15+
const char *status_str, u8 status, u32 syndrome, int err),
16+
TP_ARGS(command_str, opcode, op_mod, status_str, status, syndrome, err),
17+
TP_STRUCT__entry(__string(command_str, command_str)
18+
__field(u16, opcode)
19+
__field(u16, op_mod)
20+
__string(status_str, status_str)
21+
__field(u8, status)
22+
__field(u32, syndrome)
23+
__field(int, err)
24+
),
25+
TP_fast_assign(__assign_str(command_str, command_str);
26+
__entry->opcode = opcode;
27+
__entry->op_mod = op_mod;
28+
__assign_str(status_str, status_str);
29+
__entry->status = status;
30+
__entry->syndrome = syndrome;
31+
__entry->err = err;
32+
),
33+
TP_printk("%s(0x%x) op_mod(0x%x) failed, status %s(0x%x), syndrome (0x%x), err(%d)",
34+
__get_str(command_str), __entry->opcode, __entry->op_mod,
35+
__get_str(status_str), __entry->status, __entry->syndrome,
36+
__entry->err)
37+
);
38+
39+
#endif /* _MLX5_CMD_TP_H_ */
40+
41+
#undef TRACE_INCLUDE_PATH
42+
#define TRACE_INCLUDE_PATH ./diag
43+
#undef TRACE_INCLUDE_FILE
44+
#define TRACE_INCLUDE_FILE cmd_tracepoint
45+
#include <trace/define_trace.h>

drivers/net/ethernet/mellanox/mlx5/core/diag/fw_tracer.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -638,7 +638,7 @@ static void mlx5_tracer_handle_timestamp_trace(struct mlx5_fw_tracer *tracer,
638638
trace_timestamp = (timestamp_event.timestamp & MASK_52_7) |
639639
(str_frmt->timestamp & MASK_6_0);
640640
else
641-
trace_timestamp = ((timestamp_event.timestamp & MASK_52_7) - 1) |
641+
trace_timestamp = ((timestamp_event.timestamp - 1) & MASK_52_7) |
642642
(str_frmt->timestamp & MASK_6_0);
643643

644644
mlx5_tracer_print_trace(str_frmt, dev, trace_timestamp);

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -224,15 +224,16 @@ void mlx5e_tc_encap_flows_del(struct mlx5e_priv *priv,
224224
list_for_each_entry(flow, flow_list, tmp_list) {
225225
if (!mlx5e_is_offloaded_flow(flow) || flow_flag_test(flow, SLOW))
226226
continue;
227-
spec = &flow->attr->parse_attr->spec;
228-
229-
/* update from encap rule to slow path rule */
230-
rule = mlx5e_tc_offload_to_slow_path(esw, flow, spec);
231227

232228
attr = mlx5e_tc_get_encap_attr(flow);
233229
esw_attr = attr->esw_attr;
234230
/* mark the flow's encap dest as non-valid */
235231
esw_attr->dests[flow->tmp_entry_index].flags &= ~MLX5_ESW_DEST_ENCAP_VALID;
232+
esw_attr->dests[flow->tmp_entry_index].pkt_reformat = NULL;
233+
234+
/* update from encap rule to slow path rule */
235+
spec = &flow->attr->parse_attr->spec;
236+
rule = mlx5e_tc_offload_to_slow_path(esw, flow, spec);
236237

237238
if (IS_ERR(rule)) {
238239
err = PTR_ERR(rule);
@@ -251,6 +252,7 @@ void mlx5e_tc_encap_flows_del(struct mlx5e_priv *priv,
251252
/* we know that the encap is valid */
252253
e->flags &= ~MLX5_ENCAP_ENTRY_VALID;
253254
mlx5_packet_reformat_dealloc(priv->mdev, e->pkt_reformat);
255+
e->pkt_reformat = NULL;
254256
}
255257

256258
static void mlx5e_take_tmp_flow(struct mlx5e_tc_flow *flow,
@@ -762,8 +764,7 @@ int mlx5e_attach_encap(struct mlx5e_priv *priv,
762764
struct net_device *mirred_dev,
763765
int out_index,
764766
struct netlink_ext_ack *extack,
765-
struct net_device **encap_dev,
766-
bool *encap_valid)
767+
struct net_device **encap_dev)
767768
{
768769
struct mlx5_eswitch *esw = priv->mdev->priv.eswitch;
769770
struct mlx5e_tc_flow_parse_attr *parse_attr;
@@ -878,9 +879,8 @@ int mlx5e_attach_encap(struct mlx5e_priv *priv,
878879
if (e->flags & MLX5_ENCAP_ENTRY_VALID) {
879880
attr->esw_attr->dests[out_index].pkt_reformat = e->pkt_reformat;
880881
attr->esw_attr->dests[out_index].flags |= MLX5_ESW_DEST_ENCAP_VALID;
881-
*encap_valid = true;
882882
} else {
883-
*encap_valid = false;
883+
flow_flag_set(flow, SLOW);
884884
}
885885
mutex_unlock(&esw->offloads.encap_tbl_lock);
886886

drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun_encap.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@ int mlx5e_attach_encap(struct mlx5e_priv *priv,
1717
struct net_device *mirred_dev,
1818
int out_index,
1919
struct netlink_ext_ack *extack,
20-
struct net_device **encap_dev,
21-
bool *encap_valid);
20+
struct net_device **encap_dev);
2221

2322
int mlx5e_attach_decap(struct mlx5e_priv *priv,
2423
struct mlx5e_tc_flow *flow,

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

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -368,15 +368,15 @@ static int mlx5e_macsec_init_sa(struct macsec_context *ctx,
368368
obj_attrs.aso_pdn = macsec->aso.pdn;
369369
obj_attrs.epn_state = sa->epn_state;
370370

371-
if (is_tx) {
372-
obj_attrs.ssci = cpu_to_be32((__force u32)ctx->sa.tx_sa->ssci);
373-
key = &ctx->sa.tx_sa->key;
374-
} else {
375-
obj_attrs.ssci = cpu_to_be32((__force u32)ctx->sa.rx_sa->ssci);
376-
key = &ctx->sa.rx_sa->key;
371+
key = (is_tx) ? &ctx->sa.tx_sa->key : &ctx->sa.rx_sa->key;
372+
373+
if (sa->epn_state.epn_enabled) {
374+
obj_attrs.ssci = (is_tx) ? cpu_to_be32((__force u32)ctx->sa.tx_sa->ssci) :
375+
cpu_to_be32((__force u32)ctx->sa.rx_sa->ssci);
376+
377+
memcpy(&obj_attrs.salt, &key->salt, sizeof(key->salt));
377378
}
378379

379-
memcpy(&obj_attrs.salt, &key->salt, sizeof(key->salt));
380380
obj_attrs.replay_window = ctx->secy->replay_window;
381381
obj_attrs.replay_protect = ctx->secy->replay_protect;
382382

@@ -1155,7 +1155,7 @@ static int macsec_upd_secy_hw_address(struct macsec_context *ctx,
11551155
continue;
11561156

11571157
if (rx_sa->active) {
1158-
err = mlx5e_macsec_init_sa(ctx, rx_sa, false, false);
1158+
err = mlx5e_macsec_init_sa(ctx, rx_sa, true, false);
11591159
if (err)
11601160
goto out;
11611161
}
@@ -1536,6 +1536,8 @@ static void macsec_async_event(struct work_struct *work)
15361536

15371537
async_work = container_of(work, struct mlx5e_macsec_async_work, work);
15381538
macsec = async_work->macsec;
1539+
mutex_lock(&macsec->lock);
1540+
15391541
mdev = async_work->mdev;
15401542
obj_id = async_work->obj_id;
15411543
macsec_sa = get_macsec_tx_sa_from_obj_id(macsec, obj_id);
@@ -1557,6 +1559,7 @@ static void macsec_async_event(struct work_struct *work)
15571559

15581560
out_async_work:
15591561
kfree(async_work);
1562+
mutex_unlock(&macsec->lock);
15601563
}
15611564

15621565
static int macsec_obj_change_event(struct notifier_block *nb, unsigned long event, void *data)

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

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535
#include "en.h"
3636
#include "en/port.h"
3737
#include "en/params.h"
38-
#include "en/xsk/pool.h"
3938
#include "en/ptp.h"
4039
#include "lib/clock.h"
4140
#include "en/fs_ethtool.h"
@@ -412,15 +411,8 @@ void mlx5e_ethtool_get_channels(struct mlx5e_priv *priv,
412411
struct ethtool_channels *ch)
413412
{
414413
mutex_lock(&priv->state_lock);
415-
416414
ch->max_combined = priv->max_nch;
417415
ch->combined_count = priv->channels.params.num_channels;
418-
if (priv->xsk.refcnt) {
419-
/* The upper half are XSK queues. */
420-
ch->max_combined *= 2;
421-
ch->combined_count *= 2;
422-
}
423-
424416
mutex_unlock(&priv->state_lock);
425417
}
426418

@@ -454,16 +446,6 @@ int mlx5e_ethtool_set_channels(struct mlx5e_priv *priv,
454446

455447
mutex_lock(&priv->state_lock);
456448

457-
/* Don't allow changing the number of channels if there is an active
458-
* XSK, because the numeration of the XSK and regular RQs will change.
459-
*/
460-
if (priv->xsk.refcnt) {
461-
err = -EINVAL;
462-
netdev_err(priv->netdev, "%s: AF_XDP is active, cannot change the number of channels\n",
463-
__func__);
464-
goto out;
465-
}
466-
467449
/* Don't allow changing the number of channels if HTB offload is active,
468450
* because the numeration of the QoS SQs will change, while per-queue
469451
* qdiscs are attached.

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,10 +206,11 @@ static void mlx5e_disable_blocking_events(struct mlx5e_priv *priv)
206206
static u16 mlx5e_mpwrq_umr_octowords(u32 entries, enum mlx5e_mpwrq_umr_mode umr_mode)
207207
{
208208
u8 umr_entry_size = mlx5e_mpwrq_umr_entry_size(umr_mode);
209+
u32 sz;
209210

210-
WARN_ON_ONCE(entries * umr_entry_size % MLX5_OCTWORD);
211+
sz = ALIGN(entries * umr_entry_size, MLX5_UMR_MTT_ALIGNMENT);
211212

212-
return entries * umr_entry_size / MLX5_OCTWORD;
213+
return sz / MLX5_OCTWORD;
213214
}
214215

215216
static inline void mlx5e_build_umr_wqe(struct mlx5e_rq *rq,

0 commit comments

Comments
 (0)