Introduce new options on devlink reload API to enable the user to select
the reload action required and contrains limits on these actions that he
may want to ensure. Complete support for reload actions in mlx5.
The following reload actions are supported:
driver_reinit: driver entities re-initialization, applying devlink-param
and devlink-resource values.
fw_activate: firmware activate.
The uAPI is backward compatible, if the reload action option is omitted
from the reload command, the driver reinit action will be used.
Note that when required to do firmware activation some drivers may need
to reload the driver. On the other hand some drivers may need to reset
the firmware to reinitialize the driver entities. Therefore, the devlink
reload command returns the actions which were actually performed.
By default reload actions are not limited and driver implementation may
include reset or downtime as needed to perform the actions.
However, if limit_level is selected, the driver should perform only if
it can do it while keeping the limit level constrains.
Reload action limit level added:
no_reset: No reset allowed, no down time allowed, no link flap and no
configuration is lost.
Each driver which supports devlink reload command should expose the
reload actions and limit levels supported.
Add reload action stats to hold the history per reload action per limit
level. For example, the number of times fw_activate has been done on
this device since the driver module was added or if the firmware
activation was done with or without reset.
Patch 1-2 add the new API reload action and reload action limit level
option to devlink reload.
Patch 3 adds reload actions stats.
Patch 4 exposes the reload actions stats on devlink dev get.
Patches 5-10 add support on mlx5 for devlink reload action fw_activate
and handle the firmware reset events.
Patches 11-12 add devlink enable remote dev reset parameter and use it
in mlx5.
Patches 13-14 mlx5 add devlink reload action limit level no_reset
support for fw_activate reload action.
Patch 14 adds documentation file devlink-reload.rst
Moshe Shemesh (15):
devlink: Add reload action option to devlink reload command
devlink: Add reload action limit level
devlink: Add reload action stats
devlink: Add reload actions stats to dev get
net/mlx5: Add functions to set/query MFRL register
net/mlx5: Set cap for pci sync for fw update event
net/mlx5: Handle sync reset request event
net/mlx5: Handle sync reset now event
net/mlx5: Handle sync reset abort event
net/mlx5: Add support for devlink reload action fw activate
devlink: Add enable_remote_dev_reset generic parameter
net/mlx5: Add devlink param enable_remote_dev_reset support
net/mlx5: Add support for fw live patch event
net/mlx5: Add support for devlink reload action limit level no reset
devlink: Add Documentation/networking/devlink/devlink-reload.rst
.../networking/devlink/devlink-params.rst | 6 +
.../networking/devlink/devlink-reload.rst | 80 +++
Documentation/networking/devlink/index.rst | 1 +
drivers/net/ethernet/mellanox/mlx4/main.c | 17 +-
.../net/ethernet/mellanox/mlx5/core/Makefile | 2 +-
.../net/ethernet/mellanox/mlx5/core/devlink.c | 124 ++++-
.../mellanox/mlx5/core/diag/fw_tracer.c | 31 ++
.../mellanox/mlx5/core/diag/fw_tracer.h | 1 +
.../ethernet/mellanox/mlx5/core/fw_reset.c | 454 ++++++++++++++++++
.../ethernet/mellanox/mlx5/core/fw_reset.h | 19 +
.../net/ethernet/mellanox/mlx5/core/health.c | 35 +-
.../net/ethernet/mellanox/mlx5/core/main.c | 13 +
.../ethernet/mellanox/mlx5/core/mlx5_core.h | 2 +
drivers/net/ethernet/mellanox/mlxsw/core.c | 28 +-
drivers/net/netdevsim/dev.c | 18 +-
include/linux/mlx5/device.h | 1 +
include/linux/mlx5/driver.h | 4 +
include/net/devlink.h | 20 +-
include/uapi/linux/devlink.h | 39 ++
net/core/devlink.c | 243 +++++++++-
20 files changed, 1089 insertions(+), 49 deletions(-)
create mode 100644 Documentation/networking/devlink/devlink-reload.rst
create mode 100644 drivers/net/ethernet/mellanox/mlx5/core/fw_reset.c
create mode 100644 drivers/net/ethernet/mellanox/mlx5/core/fw_reset.h
--
2.17.1
Add functions to query and set the MFRL reset options supported by
firmware.
Signed-off-by: Moshe Shemesh <[email protected]>
---
.../net/ethernet/mellanox/mlx5/core/Makefile | 2 +-
.../ethernet/mellanox/mlx5/core/fw_reset.c | 46 +++++++++++++++++++
.../ethernet/mellanox/mlx5/core/fw_reset.h | 13 ++++++
3 files changed, 60 insertions(+), 1 deletion(-)
create mode 100644 drivers/net/ethernet/mellanox/mlx5/core/fw_reset.c
create mode 100644 drivers/net/ethernet/mellanox/mlx5/core/fw_reset.h
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/Makefile b/drivers/net/ethernet/mellanox/mlx5/core/Makefile
index 9826a041e407..380a51747599 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/Makefile
+++ b/drivers/net/ethernet/mellanox/mlx5/core/Makefile
@@ -16,7 +16,7 @@ mlx5_core-y := main.o cmd.o debugfs.o fw.o eq.o uar.o pagealloc.o \
transobj.o vport.o sriov.o fs_cmd.o fs_core.o pci_irq.o \
fs_counters.o rl.o lag.o dev.o events.o wq.o lib/gid.o \
lib/devcom.o lib/pci_vsc.o lib/dm.o diag/fs_tracepoint.o \
- diag/fw_tracer.o diag/crdump.o devlink.o diag/rsc_dump.o
+ diag/fw_tracer.o diag/crdump.o devlink.o diag/rsc_dump.o fw_reset.o
#
# Netdev basic
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/fw_reset.c b/drivers/net/ethernet/mellanox/mlx5/core/fw_reset.c
new file mode 100644
index 000000000000..76d2cece29ac
--- /dev/null
+++ b/drivers/net/ethernet/mellanox/mlx5/core/fw_reset.c
@@ -0,0 +1,46 @@
+// SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB
+/* Copyright (c) 2020, Mellanox Technologies inc. All rights reserved. */
+
+#include "fw_reset.h"
+
+static int mlx5_reg_mfrl_set(struct mlx5_core_dev *dev, u8 reset_level,
+ u8 reset_type_sel, u8 sync_resp, bool sync_start)
+{
+ u32 out[MLX5_ST_SZ_DW(mfrl_reg)] = {};
+ u32 in[MLX5_ST_SZ_DW(mfrl_reg)] = {};
+
+ MLX5_SET(mfrl_reg, in, reset_level, reset_level);
+ MLX5_SET(mfrl_reg, in, rst_type_sel, reset_type_sel);
+ MLX5_SET(mfrl_reg, in, pci_sync_for_fw_update_resp, sync_resp);
+ MLX5_SET(mfrl_reg, in, pci_sync_for_fw_update_start, sync_start);
+
+ return mlx5_core_access_reg(dev, in, sizeof(in), out, sizeof(out), MLX5_REG_MFRL, 0, 1);
+}
+
+int mlx5_reg_mfrl_query(struct mlx5_core_dev *dev, u8 *reset_level, u8 *reset_type)
+{
+ u32 out[MLX5_ST_SZ_DW(mfrl_reg)] = {};
+ u32 in[MLX5_ST_SZ_DW(mfrl_reg)] = {};
+ int err;
+
+ err = mlx5_core_access_reg(dev, in, sizeof(in), out, sizeof(out), MLX5_REG_MFRL, 0, 0);
+ if (err)
+ return err;
+
+ if (reset_level)
+ *reset_level = MLX5_GET(mfrl_reg, out, reset_level);
+ if (reset_type)
+ *reset_type = MLX5_GET(mfrl_reg, out, reset_type);
+
+ return 0;
+}
+
+int mlx5_fw_set_reset_sync(struct mlx5_core_dev *dev, u8 reset_type_sel)
+{
+ return mlx5_reg_mfrl_set(dev, MLX5_MFRL_REG_RESET_LEVEL3, reset_type_sel, 0, true);
+}
+
+int mlx5_fw_set_live_patch(struct mlx5_core_dev *dev)
+{
+ return mlx5_reg_mfrl_set(dev, MLX5_MFRL_REG_RESET_LEVEL0, 0, 0, false);
+}
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/fw_reset.h b/drivers/net/ethernet/mellanox/mlx5/core/fw_reset.h
new file mode 100644
index 000000000000..1bbd95182ca6
--- /dev/null
+++ b/drivers/net/ethernet/mellanox/mlx5/core/fw_reset.h
@@ -0,0 +1,13 @@
+/* SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB */
+/* Copyright (c) 2020, Mellanox Technologies inc. All rights reserved. */
+
+#ifndef __MLX5_FW_RESET_H
+#define __MLX5_FW_RESET_H
+
+#include "mlx5_core.h"
+
+int mlx5_reg_mfrl_query(struct mlx5_core_dev *dev, u8 *reset_level, u8 *reset_type);
+int mlx5_fw_set_reset_sync(struct mlx5_core_dev *dev, u8 reset_type_sel);
+int mlx5_fw_set_live_patch(struct mlx5_core_dev *dev);
+
+#endif
--
2.17.1