Commit 178a4ff1 authored by Jakub Kicinski's avatar Jakub Kicinski
Browse files

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/20221122022559.89459-1-saeed@kernel.org


Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parents 568fe849 8514e325
Loading
Loading
Loading
Loading
+25 −22
Original line number Diff line number Diff line
@@ -45,6 +45,8 @@
#include "mlx5_core.h"
#include "lib/eq.h"
#include "lib/tout.h"
#define CREATE_TRACE_POINTS
#include "diag/cmd_tracepoint.h"

enum {
	CMD_IF_REV = 5,
@@ -785,27 +787,14 @@ EXPORT_SYMBOL(mlx5_cmd_out_err);
static void cmd_status_print(struct mlx5_core_dev *dev, void *in, void *out)
{
	u16 opcode, op_mod;
	u32 syndrome;
	u8  status;
	u16 uid;
	int err;

	syndrome = MLX5_GET(mbox_out, out, syndrome);
	status = MLX5_GET(mbox_out, out, status);

	opcode = MLX5_GET(mbox_in, in, opcode);
	op_mod = MLX5_GET(mbox_in, in, op_mod);
	uid    = MLX5_GET(mbox_in, in, uid);

	err = cmd_status_to_err(status);

	if (!uid && opcode != MLX5_CMD_OP_DESTROY_MKEY)
		mlx5_cmd_out_err(dev, opcode, op_mod, out);
	else
		mlx5_core_dbg(dev,
			"%s(0x%x) op_mod(0x%x) uid(%d) failed, status %s(0x%x), syndrome (0x%x), err(%d)\n",
			mlx5_command_str(opcode), opcode, op_mod, uid,
			cmd_status_str(status), status, syndrome, err);
}

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

	cmd_ent_get(ent); /* for the _real_ FW event on completion */
	/* Skip sending command to fw if internal error */
	if (mlx5_cmd_is_down(dev) || !opcode_allowed(&dev->cmd, ent->op)) {
		ent->ret = -ENXIO;
@@ -1023,7 +1013,6 @@ static void cmd_work_handler(struct work_struct *work)
		return;
	}

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

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

			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,
	return err;
}

static void mlx5_cmd_err_trace(struct mlx5_core_dev *dev, u16 opcode, u16 op_mod, void *out)
{
	u32 syndrome = MLX5_GET(mbox_out, out, syndrome);
	u8 status = MLX5_GET(mbox_out, out, status);

	trace_mlx5_cmd(mlx5_command_str(opcode), opcode, op_mod,
		       cmd_status_str(status), status, syndrome,
		       cmd_status_to_err(status));
}

static void cmd_status_log(struct mlx5_core_dev *dev, u16 opcode, u8 status,
			   u32 syndrome, int err)
{
@@ -1914,7 +1913,7 @@ static void cmd_status_log(struct mlx5_core_dev *dev, u16 opcode, u8 status,
}

/* preserve -EREMOTEIO for outbox.status != OK, otherwise return err as is */
static int cmd_status_err(struct mlx5_core_dev *dev, int err, u16 opcode, void *out)
static int cmd_status_err(struct mlx5_core_dev *dev, int err, u16 opcode, u16 op_mod, void *out)
{
	u32 syndrome = MLX5_GET(mbox_out, out, syndrome);
	u8 status = MLX5_GET(mbox_out, out, status);
@@ -1922,8 +1921,10 @@ static int cmd_status_err(struct mlx5_core_dev *dev, int err, u16 opcode, void *
	if (err == -EREMOTEIO) /* -EREMOTEIO is preserved */
		err = -EIO;

	if (!err && status != MLX5_CMD_STAT_OK)
	if (!err && status != MLX5_CMD_STAT_OK) {
		err = -EREMOTEIO;
		mlx5_cmd_err_trace(dev, opcode, op_mod, out);
	}

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

	err = cmd_status_err(dev, err, opcode, out);
	return err;
	return cmd_status_err(dev, err, opcode, op_mod, out);
}
EXPORT_SYMBOL(mlx5_cmd_do);

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

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

	ctx = work->ctx;
	status = cmd_status_err(ctx->dev, status, work->opcode, work->out);
	status = cmd_status_err(ctx->dev, status, work->opcode, work->op_mod, work->out);
	work->user_callback(status, work);
	if (atomic_dec_and_test(&ctx->num_inflight))
		complete(&ctx->inflight_done);
@@ -2049,6 +2051,7 @@ int mlx5_cmd_exec_cb(struct mlx5_async_ctx *ctx, void *in, int in_size,
	work->ctx = ctx;
	work->user_callback = callback;
	work->opcode = MLX5_GET(mbox_in, in, opcode);
	work->op_mod = MLX5_GET(mbox_in, in, op_mod);
	work->out = out;
	if (WARN_ON(!atomic_inc_not_zero(&ctx->num_inflight)))
		return -EIO;
+45 −0
Original line number Diff line number Diff line
/* SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB */
/* Copyright (c) 2022, NVIDIA CORPORATION & AFFILIATES. All rights reserved. */

#undef TRACE_SYSTEM
#define TRACE_SYSTEM mlx5

#if !defined(_MLX5_CMD_TP_H_) || defined(TRACE_HEADER_MULTI_READ)
#define _MLX5_CMD_TP_H_

#include <linux/tracepoint.h>
#include <linux/trace_seq.h>

TRACE_EVENT(mlx5_cmd,
	    TP_PROTO(const char *command_str, u16 opcode, u16 op_mod,
		     const char *status_str, u8 status, u32 syndrome, int err),
	    TP_ARGS(command_str, opcode, op_mod, status_str, status, syndrome, err),
	    TP_STRUCT__entry(__string(command_str, command_str)
			     __field(u16, opcode)
			     __field(u16, op_mod)
			    __string(status_str, status_str)
			    __field(u8, status)
			    __field(u32, syndrome)
			    __field(int, err)
			    ),
	    TP_fast_assign(__assign_str(command_str, command_str);
			__entry->opcode = opcode;
			__entry->op_mod = op_mod;
			__assign_str(status_str, status_str);
			__entry->status = status;
			__entry->syndrome = syndrome;
			__entry->err = err;
	    ),
	    TP_printk("%s(0x%x) op_mod(0x%x) failed, status %s(0x%x), syndrome (0x%x), err(%d)",
		      __get_str(command_str), __entry->opcode, __entry->op_mod,
		      __get_str(status_str), __entry->status, __entry->syndrome,
		      __entry->err)
);

#endif /* _MLX5_CMD_TP_H_ */

#undef TRACE_INCLUDE_PATH
#define TRACE_INCLUDE_PATH ./diag
#undef TRACE_INCLUDE_FILE
#define TRACE_INCLUDE_FILE cmd_tracepoint
#include <trace/define_trace.h>
+1 −1
Original line number Diff line number Diff line
@@ -638,7 +638,7 @@ static void mlx5_tracer_handle_timestamp_trace(struct mlx5_fw_tracer *tracer,
			trace_timestamp = (timestamp_event.timestamp & MASK_52_7) |
					  (str_frmt->timestamp & MASK_6_0);
		else
			trace_timestamp = ((timestamp_event.timestamp & MASK_52_7) - 1) |
			trace_timestamp = ((timestamp_event.timestamp - 1) & MASK_52_7) |
					  (str_frmt->timestamp & MASK_6_0);

		mlx5_tracer_print_trace(str_frmt, dev, trace_timestamp);
+8 −8
Original line number Diff line number Diff line
@@ -224,15 +224,16 @@ void mlx5e_tc_encap_flows_del(struct mlx5e_priv *priv,
	list_for_each_entry(flow, flow_list, tmp_list) {
		if (!mlx5e_is_offloaded_flow(flow) || flow_flag_test(flow, SLOW))
			continue;
		spec = &flow->attr->parse_attr->spec;

		/* update from encap rule to slow path rule */
		rule = mlx5e_tc_offload_to_slow_path(esw, flow, spec);

		attr = mlx5e_tc_get_encap_attr(flow);
		esw_attr = attr->esw_attr;
		/* mark the flow's encap dest as non-valid */
		esw_attr->dests[flow->tmp_entry_index].flags &= ~MLX5_ESW_DEST_ENCAP_VALID;
		esw_attr->dests[flow->tmp_entry_index].pkt_reformat = NULL;

		/* update from encap rule to slow path rule */
		spec = &flow->attr->parse_attr->spec;
		rule = mlx5e_tc_offload_to_slow_path(esw, flow, spec);

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

static void mlx5e_take_tmp_flow(struct mlx5e_tc_flow *flow,
@@ -762,8 +764,7 @@ int mlx5e_attach_encap(struct mlx5e_priv *priv,
		       struct net_device *mirred_dev,
		       int out_index,
		       struct netlink_ext_ack *extack,
		       struct net_device **encap_dev,
		       bool *encap_valid)
		       struct net_device **encap_dev)
{
	struct mlx5_eswitch *esw = priv->mdev->priv.eswitch;
	struct mlx5e_tc_flow_parse_attr *parse_attr;
@@ -878,9 +879,8 @@ int mlx5e_attach_encap(struct mlx5e_priv *priv,
	if (e->flags & MLX5_ENCAP_ENTRY_VALID) {
		attr->esw_attr->dests[out_index].pkt_reformat = e->pkt_reformat;
		attr->esw_attr->dests[out_index].flags |= MLX5_ESW_DEST_ENCAP_VALID;
		*encap_valid = true;
	} else {
		*encap_valid = false;
		flow_flag_set(flow, SLOW);
	}
	mutex_unlock(&esw->offloads.encap_tbl_lock);

+1 −2
Original line number Diff line number Diff line
@@ -17,8 +17,7 @@ int mlx5e_attach_encap(struct mlx5e_priv *priv,
		       struct net_device *mirred_dev,
		       int out_index,
		       struct netlink_ext_ack *extack,
		       struct net_device **encap_dev,
		       bool *encap_valid);
		       struct net_device **encap_dev);

int mlx5e_attach_decap(struct mlx5e_priv *priv,
		       struct mlx5e_tc_flow *flow,
Loading