Skip to contentSkip to conversation

mlxsw: Support firmware flash

PATCH Superseded Jiri Pirko 6 participants 24 messages May 23, 2017 – May 31, 2017

Subsystems (4)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Jiri Pirko

author
#0 lore raw

cover mlxsw: Support firmware flash

From: Jiri Pirko <[email protected]>

Add support for device firmware flash on mlxsw spectrum. The firmware files are expected to be in the Mellanox Firmware Archive version 2 (MFA2) format.

The firmware flash can be triggered via "ethtool -f" or on driver initialization time if the device firmware version does not meet the minimum firmware version supported by the driver.

Currently, to activate the newly flashed firmware, the user needs to reboot his system.

The first patch introduces the mlxfw module, which implements common logic needed for the firmware flash process on Mellanox products, such as the MFA2 format parsing and the firmware flash state machine logic. As the module implements common logic which will be needed by various different Mellanox drivers, it defines a set of callbacks needed to interact with the specific device.

Patches 1-5 implement the needed mlxfw callbacks in the mlxsw spectrum driver.

Patches 6-8 add the "ethtool -f" and the boot-time firmware upgrade on the mlxsw spectrum driver.

Patch 9 adds a fix needed for new firmware versions.

Ido Schimmel (1):
mlxsw: spectrum_router: Adjust RIF configuration for new firmware
versions

Yotam Gigi (8):
Add the mlxfw module for Mellanox firmware flash process
mlxsw: reg: Add Management Component Query Information register
mlxsw: reg: Add Management Component Control register
mlxsw: reg: Add Management Component Data Access register
mlxsw: spectrum: Add the needed callbacks for mlxfw integration
mlxsw: spectrum: Implement the ethtool flash_device callback
mlxsw: core: Create the mlxsw_fw_rev struct
mlxsw: spectrum: Validate firmware revision on init

 MAINTAINERS                                        |   8 +
 drivers/net/ethernet/mellanox/Kconfig              |   1 +
 drivers/net/ethernet/mellanox/Makefile             |   1 +
 drivers/net/ethernet/mellanox/mlxfw/Kconfig        |   6 +
 drivers/net/ethernet/mellanox/mlxfw/Makefile       |   2 +
 drivers/net/ethernet/mellanox/mlxfw/mlxfw.h        | 102 ++++
 drivers/net/ethernet/mellanox/mlxfw/mlxfw_fsm.c    | 273 +++++++++
 drivers/net/ethernet/mellanox/mlxfw/mlxfw_mfa2.c   | 620 +++++++++++++++++++++
 drivers/net/ethernet/mellanox/mlxfw/mlxfw_mfa2.h   |  66 +++
 .../net/ethernet/mellanox/mlxfw/mlxfw_mfa2_file.h  |  60 ++
 .../ethernet/mellanox/mlxfw/mlxfw_mfa2_format.h    | 103 ++++
 .../net/ethernet/mellanox/mlxfw/mlxfw_mfa2_tlv.h   |  98 ++++
 .../ethernet/mellanox/mlxfw/mlxfw_mfa2_tlv_multi.c | 126 +++++
 .../ethernet/mellanox/mlxfw/mlxfw_mfa2_tlv_multi.h |  71 +++
 drivers/net/ethernet/mellanox/mlxsw/Kconfig        |   1 +
 drivers/net/ethernet/mellanox/mlxsw/core.h         |  12 +-
 drivers/net/ethernet/mellanox/mlxsw/reg.h          | 219 ++++++++
 drivers/net/ethernet/mellanox/mlxsw/spectrum.c     | 266 +++++++++
 .../net/ethernet/mellanox/mlxsw/spectrum_router.c  |  22 +
 19 files changed, 2052 insertions(+), 5 deletions(-)
 create mode 100644 drivers/net/ethernet/mellanox/mlxfw/Kconfig
 create mode 100644 drivers/net/ethernet/mellanox/mlxfw/Makefile
 create mode 100644 drivers/net/ethernet/mellanox/mlxfw/mlxfw.h
 create mode 100644 drivers/net/ethernet/mellanox/mlxfw/mlxfw_fsm.c
 create mode 100644 drivers/net/ethernet/mellanox/mlxfw/mlxfw_mfa2.c
 create mode 100644 drivers/net/ethernet/mellanox/mlxfw/mlxfw_mfa2.h
 create mode 100644 drivers/net/ethernet/mellanox/mlxfw/mlxfw_mfa2_file.h
 create mode 100644 drivers/net/ethernet/mellanox/mlxfw/mlxfw_mfa2_format.h
 create mode 100644 drivers/net/ethernet/mellanox/mlxfw/mlxfw_mfa2_tlv.h
 create mode 100644 drivers/net/ethernet/mellanox/mlxfw/mlxfw_mfa2_tlv_multi.c
 create mode 100644 drivers/net/ethernet/mellanox/mlxfw/mlxfw_mfa2_tlv_multi.h
Signature · 1 line
2.9.3
author
#1 lore raw

PATCH 1/9 Add the mlxfw module for Mellanox firmware flash process

From: Yotam Gigi <[email protected]>

The mlxfw module is in charge of common logic needed to flash Mellanox devices firmware, which consists of:
- Parse the Mellanox Firmware Archive version 2 (MFA2) format, which is the format used to store the Mellanox firmware. The MFA2 format file can hold firmware for many different silicon variants, differentiated by a unique ID called PSID. In addition, the MFA2 file data section is compressed using xz compression to save both file-system space and memory at extraction time.
- Implement the firmware flash state machine logic, which is a common logic for Mellanox products needed to flash the firmware to the device.

As the module is shared between different Mellanox products, it defines a set of callbacks to be implemented by the specific driver for hardware interaction.

---
 MAINTAINERS                                        |   8 +
 drivers/net/ethernet/mellanox/Kconfig              |   1 +
 drivers/net/ethernet/mellanox/Makefile             |   1 +
 drivers/net/ethernet/mellanox/mlxfw/Kconfig        |   6 +
 drivers/net/ethernet/mellanox/mlxfw/Makefile       |   2 +
 drivers/net/ethernet/mellanox/mlxfw/mlxfw.h        | 102 ++++
 drivers/net/ethernet/mellanox/mlxfw/mlxfw_fsm.c    | 273 +++++++++
 drivers/net/ethernet/mellanox/mlxfw/mlxfw_mfa2.c   | 620 +++++++++++++++++++++
 drivers/net/ethernet/mellanox/mlxfw/mlxfw_mfa2.h   |  66 +++
 .../net/ethernet/mellanox/mlxfw/mlxfw_mfa2_file.h  |  60 ++
 .../ethernet/mellanox/mlxfw/mlxfw_mfa2_format.h    | 103 ++++
 .../net/ethernet/mellanox/mlxfw/mlxfw_mfa2_tlv.h   |  98 ++++
 .../ethernet/mellanox/mlxfw/mlxfw_mfa2_tlv_multi.c | 126 +++++
 .../ethernet/mellanox/mlxfw/mlxfw_mfa2_tlv_multi.h |  71 +++
 14 files changed, 1537 insertions(+)
 create mode 100644 drivers/net/ethernet/mellanox/mlxfw/Kconfig
 create mode 100644 drivers/net/ethernet/mellanox/mlxfw/Makefile
 create mode 100644 drivers/net/ethernet/mellanox/mlxfw/mlxfw.h
 create mode 100644 drivers/net/ethernet/mellanox/mlxfw/mlxfw_fsm.c
 create mode 100644 drivers/net/ethernet/mellanox/mlxfw/mlxfw_mfa2.c
 create mode 100644 drivers/net/ethernet/mellanox/mlxfw/mlxfw_mfa2.h
 create mode 100644 drivers/net/ethernet/mellanox/mlxfw/mlxfw_mfa2_file.h
 create mode 100644 drivers/net/ethernet/mellanox/mlxfw/mlxfw_mfa2_format.h
 create mode 100644 drivers/net/ethernet/mellanox/mlxfw/mlxfw_mfa2_tlv.h
 create mode 100644 drivers/net/ethernet/mellanox/mlxfw/mlxfw_mfa2_tlv_multi.c
 create mode 100644 drivers/net/ethernet/mellanox/mlxfw/mlxfw_mfa2_tlv_multi.h
MAINTAINERS +8 -0
index 9e98464..fcde259 100644
@@ -8320,6 +8320,14 @@ W:	http://www.mellanox.com
 Q:	http://patchwork.ozlabs.org/project/netdev/list/
 F:	drivers/net/ethernet/mellanox/mlxsw/
 
+MELLANOX FIRMWARE FLASH LIBRARY (mlxfw)
+M:	Yotam Gigi <[email protected]>
+L:	[email protected]
+S:	Supported
+W:	http://www.mellanox.com
+Q:	http://patchwork.ozlabs.org/project/netdev/list/
+F:	drivers/net/ethernet/mellanox/mlxfw/
+
 MELLANOX MLXCPLD I2C AND MUX DRIVER
 M:	Vadim Pasternak <[email protected]>
 M:	Michael Shych <[email protected]>
drivers/net/ethernet/mellanox/Kconfig +1 -0
index d547010..84a2007 100644
@@ -19,5 +19,6 @@ if NET_VENDOR_MELLANOX
 source "drivers/net/ethernet/mellanox/mlx4/Kconfig"
 source "drivers/net/ethernet/mellanox/mlx5/core/Kconfig"
 source "drivers/net/ethernet/mellanox/mlxsw/Kconfig"
+source "drivers/net/ethernet/mellanox/mlxfw/Kconfig"
 
 endif # NET_VENDOR_MELLANOX
drivers/net/ethernet/mellanox/Makefile +1 -0
index 2e2a5ec..016aa26 100644
@@ -5,3 +5,4 @@
 obj-$(CONFIG_MLX4_CORE) += mlx4/
 obj-$(CONFIG_MLX5_CORE) += mlx5/core/
 obj-$(CONFIG_MLXSW_CORE) += mlxsw/
+obj-$(CONFIG_MLXFW) += mlxfw/
drivers/net/ethernet/mellanox/mlxfw/Kconfig new file +6 -0
new file mode 100644
index 0000000..56b60ac
@@ -0,0 +1,6 @@
+#
+# Mellanox firmware flash library configuration
+#
+
+config MLXFW
+        tristate "mlxfw" if COMPILE_TEST
drivers/net/ethernet/mellanox/mlxfw/Makefile new file +2 -0
new file mode 100644
index 0000000..7448b30
@@ -0,0 +1,2 @@
+obj-$(CONFIG_MLXFW)	+= mlxfw.o
+mlxfw-objs		:= mlxfw_fsm.o mlxfw_mfa2_tlv_multi.o mlxfw_mfa2.o
drivers/net/ethernet/mellanox/mlxfw/mlxfw.h new file +102 -0

102 lines not on this page · raw message

drivers/net/ethernet/mellanox/mlxfw/mlxfw_fsm.c new file +273 -0

273 lines not on this page · raw message

drivers/net/ethernet/mellanox/mlxfw/mlxfw_mfa2.c new file +620 -0

620 lines not on this page · raw message

drivers/net/ethernet/mellanox/mlxfw/mlxfw_mfa2.h new file +66 -0

66 lines not on this page · raw message

drivers/net/ethernet/mellanox/mlxfw/mlxfw_mfa2_file.h new file +60 -0

60 lines not on this page · raw message

drivers/net/ethernet/mellanox/mlxfw/mlxfw_mfa2_format.h new file +103 -0

103 lines not on this page · raw message

drivers/net/ethernet/mellanox/mlxfw/mlxfw_mfa2_tlv.h new file +98 -0

98 lines not on this page · raw message

drivers/net/ethernet/mellanox/mlxfw/mlxfw_mfa2_tlv_multi.c new file +126 -0

126 lines not on this page · raw message

drivers/net/ethernet/mellanox/mlxfw/mlxfw_mfa2_tlv_multi.h new file +71 -0

71 lines not on this page · raw message

Signature · 1 line
2.9.3
author
#2 lore raw

PATCH 2/9 mlxsw: reg: Add Management Component Query Information register

In reply to Jiri Pirko

From: Yotam Gigi <[email protected]>

The MCQI register queries information about firmware components. It will be needed by the mlxfw module to query various options about the components, such as their max size, alignment and max write size.

---
 drivers/net/ethernet/mellanox/mlxsw/reg.h | 84 +++++++++++++++++++++++++++++++
 1 file changed, 84 insertions(+)
drivers/net/ethernet/mellanox/mlxsw/reg.h +84 -0
index 83b277c..adb385f 100644
@@ -5643,6 +5643,89 @@ static inline void mlxsw_reg_mlcr_pack(char *payload, u8 local_port,
 					   MLXSW_REG_MLCR_DURATION_MAX : 0);
 }
 
+/* MCQI - Management Component Query Information
+ * ---------------------------------------------
+ * This register allows querying information about firmware components.
+ */
+#define MLXSW_REG_MCQI_ID 0x9061
+#define MLXSW_REG_MCQI_BASE_LEN 0x18
+#define MLXSW_REG_MCQI_CAP_LEN 0x14
+#define MLXSW_REG_MCQI_LEN (MLXSW_REG_MCQI_BASE_LEN + MLXSW_REG_MCQI_CAP_LEN)
+
+MLXSW_REG_DEFINE(mcqi, MLXSW_REG_MCQI_ID, MLXSW_REG_MCQI_LEN);
+
+/* reg_mcqi_component_index
+ * Index of the accessed component.
+ * Access: Index
+ */
+MLXSW_ITEM32(reg, mcqi, component_index, 0x00, 0, 16);
+
+enum mlxfw_reg_mcqi_info_type {
+	MLXSW_REG_MCQI_INFO_TYPE_CAPABILITIES,
+};
+
+/* reg_mcqi_info_type
+ * Component properties set.
+ * Access: RW
+ */
+MLXSW_ITEM32(reg, mcqi, info_type, 0x08, 0, 5);
+
+/* reg_mcqi_offset
+ * The requested/returned data offset from the section start, given in bytes.
+ * Must be DWORD aligned.
+ * Access: RW
+ */
+MLXSW_ITEM32(reg, mcqi, offset, 0x10, 0, 32);
+
+/* reg_mcqi_data_size
+ * The requested/returned data size, given in bytes. If data_size is not DWORD
+ * aligned, the last bytes are zero padded.
+ * Access: RW
+ */
+MLXSW_ITEM32(reg, mcqi, data_size, 0x14, 0, 16);
+
+/* reg_mcqi_cap_max_component_size
+ * Maximum size for this component, given in bytes.
+ * Access: RO
+ */
+MLXSW_ITEM32(reg, mcqi, cap_max_component_size, 0x20, 0, 32);
+
+/* reg_mcqi_cap_log_mcda_word_size
+ * Log 2 of the access word size in bytes. Read and write access must be aligned
+ * to the word size. Write access must be done for an integer number of words.
+ * Access: RO
+ */
+MLXSW_ITEM32(reg, mcqi, cap_log_mcda_word_size, 0x24, 28, 4);
+
+/* reg_mcqi_cap_mcda_max_write_size
+ * Maximal write size for MCDA register
+ * Access: RO
+ */
+MLXSW_ITEM32(reg, mcqi, cap_mcda_max_write_size, 0x24, 0, 16);
+
+static inline void mlxsw_reg_mcqi_pack(char *payload, u16 component_index)
+{
+	MLXSW_REG_ZERO(mcqi, payload);
+	mlxsw_reg_mcqi_component_index_set(payload, component_index);
+	mlxsw_reg_mcqi_info_type_set(payload,
+				     MLXSW_REG_MCQI_INFO_TYPE_CAPABILITIES);
+	mlxsw_reg_mcqi_offset_set(payload, 0);
+	mlxsw_reg_mcqi_data_size_set(payload, MLXSW_REG_MCQI_CAP_LEN);
+}
+
+static inline void mlxsw_reg_mcqi_unpack(char *payload,
+					 u32 *p_cap_max_component_size,
+					 u8 *p_cap_log_mcda_word_size,
+					 u16 *p_cap_mcda_max_write_size)
+{
+	*p_cap_max_component_size =
+		mlxsw_reg_mcqi_cap_max_component_size_get(payload);
+	*p_cap_log_mcda_word_size =
+		mlxsw_reg_mcqi_cap_log_mcda_word_size_get(payload);
+	*p_cap_mcda_max_write_size =
+		mlxsw_reg_mcqi_cap_mcda_max_write_size_get(payload);
+}
+
 /* MPSC - Monitoring Packet Sampling Configuration Register
  * --------------------------------------------------------
  * MPSC Register is used to configure the Packet Sampling mechanism.
@@ -6221,6 +6304,7 @@ static const struct mlxsw_reg_info *mlxsw_reg_infos[] = {
 	MLXSW_REG(mpar),
 	MLXSW_REG(mlcr),
 	MLXSW_REG(mpsc),
+	MLXSW_REG(mcqi),
 	MLXSW_REG(mgpc),
 	MLXSW_REG(sbpr),
 	MLXSW_REG(sbcm),
Signature · 1 line
2.9.3
author
#3 lore raw

PATCH 3/9 mlxsw: reg: Add Management Component Control register

In reply to Jiri Pirko

From: Yotam Gigi <[email protected]>

The MCC register allows controlling and querying the firmware flash state machine (FSM).

---
 drivers/net/ethernet/mellanox/mlxsw/reg.h | 83 +++++++++++++++++++++++++++++++
 1 file changed, 83 insertions(+)
drivers/net/ethernet/mellanox/mlxsw/reg.h +83 -0
index adb385f..f3c768c 100644
@@ -5726,6 +5726,88 @@ static inline void mlxsw_reg_mcqi_unpack(char *payload,
 		mlxsw_reg_mcqi_cap_mcda_max_write_size_get(payload);
 }
 
+/* MCC - Management Component Control
+ * ----------------------------------
+ * Controls the firmware component and updates the FSM.
+ */
+#define MLXSW_REG_MCC_ID 0x9062
+#define MLXSW_REG_MCC_LEN 0x1C
+
+MLXSW_REG_DEFINE(mcc, MLXSW_REG_MCC_ID, MLXSW_REG_MCC_LEN);
+
+enum mlxsw_reg_mcc_instruction {
+	MLXSW_REG_MCC_INSTRUCTION_LOCK_UPDATE_HANDLE = 0x01,
+	MLXSW_REG_MCC_INSTRUCTION_RELEASE_UPDATE_HANDLE = 0x02,
+	MLXSW_REG_MCC_INSTRUCTION_UPDATE_COMPONENT = 0x03,
+	MLXSW_REG_MCC_INSTRUCTION_VERIFY_COMPONENT = 0x04,
+	MLXSW_REG_MCC_INSTRUCTION_ACTIVATE = 0x06,
+	MLXSW_REG_MCC_INSTRUCTION_CANCEL = 0x08,
+};
+
+/* reg_mcc_instruction
+ * Command to be executed by the FSM.
+ * Applicable for write operation only.
+ * Access: RW
+ */
+MLXSW_ITEM32(reg, mcc, instruction, 0x00, 0, 8);
+
+/* reg_mcc_component_index
+ * Index of the accessed component. Applicable only for commands that
+ * refer to components. Otherwise, this field is reserved.
+ * Access: Index
+ */
+MLXSW_ITEM32(reg, mcc, component_index, 0x04, 0, 16);
+
+/* reg_mcc_update_handle
+ * Token representing the current flow executed by the FSM.
+ * Access: WO
+ */
+MLXSW_ITEM32(reg, mcc, update_handle, 0x08, 0, 24);
+
+/* reg_mcc_error_code
+ * Indicates the successful completion of the instruction, or the reason it
+ * failed
+ * Access: RO
+ */
+MLXSW_ITEM32(reg, mcc, error_code, 0x0C, 8, 8);
+
+/* reg_mcc_control_state
+ * Current FSM state
+ * Access: RO
+ */
+MLXSW_ITEM32(reg, mcc, control_state, 0x0C, 0, 4);
+
+/* reg_mcc_component_size
+ * Component size in bytes. Valid for UPDATE_COMPONENT instruction. Specifying
+ * the size may shorten the update time. Value 0x0 means that size is
+ * unspecified.
+ * Access: WO
+ */
+MLXSW_ITEM32(reg, mcc, component_size, 0x10, 0, 32);
+
+static inline void mlxsw_reg_mcc_pack(char *payload,
+				      enum mlxsw_reg_mcc_instruction instr,
+				      u16 component_index, u32 update_handle,
+				      u32 component_size)
+{
+	MLXSW_REG_ZERO(mcc, payload);
+	mlxsw_reg_mcc_instruction_set(payload, instr);
+	mlxsw_reg_mcc_component_index_set(payload, component_index);
+	mlxsw_reg_mcc_update_handle_set(payload, update_handle);
+	mlxsw_reg_mcc_component_size_set(payload, component_size);
+}
+
+static inline void mlxsw_reg_mcc_unpack(char *payload, u32 *p_update_handle,
+					u8 *p_error_code, u8 *p_control_state)
+{
+	if (p_update_handle)
+		*p_update_handle = mlxsw_reg_mcc_update_handle_get(payload);
+	if (p_error_code)
+		*p_error_code = mlxsw_reg_mcc_error_code_get(payload);
+	if (p_control_state)
+		*p_control_state = mlxsw_reg_mcc_control_state_get(payload);
+}
+
 /* MPSC - Monitoring Packet Sampling Configuration Register
  * --------------------------------------------------------
  * MPSC Register is used to configure the Packet Sampling mechanism.
@@ -6305,6 +6387,7 @@ static const struct mlxsw_reg_info *mlxsw_reg_infos[] = {
 	MLXSW_REG(mlcr),
 	MLXSW_REG(mpsc),
 	MLXSW_REG(mcqi),
+	MLXSW_REG(mcc),
 	MLXSW_REG(mgpc),
 	MLXSW_REG(sbpr),
 	MLXSW_REG(sbcm),
Signature · 1 line
2.9.3
author
#4 lore raw

PATCH 4/9 mlxsw: reg: Add Management Component Data Access register

In reply to Jiri Pirko

From: Yotam Gigi <[email protected]>

The MCDA register allows reading and writing a firmware component.

---
 drivers/net/ethernet/mellanox/mlxsw/reg.h | 52 +++++++++++++++++++++++++++++++
 1 file changed, 52 insertions(+)
drivers/net/ethernet/mellanox/mlxsw/reg.h +52 -0
index f3c768c..182150a 100644
@@ -5808,6 +5808,57 @@ static inline void mlxsw_reg_mcc_unpack(char *payload, u32 *p_update_handle,
 		*p_control_state = mlxsw_reg_mcc_control_state_get(payload);
 }
 
+/* MCDA - Management Component Data Access
+ * ---------------------------------------
+ * This register allows reading and writing a firmware component.
+ */
+#define MLXSW_REG_MCDA_ID 0x9063
+#define MLXSW_REG_MCDA_BASE_LEN 0x10
+#define MLXSW_REG_MCDA_MAX_DATA_LEN 0x80
+#define MLXSW_REG_MCDA_LEN \
+		(MLXSW_REG_MCDA_BASE_LEN + MLXSW_REG_MCDA_MAX_DATA_LEN)
+
+MLXSW_REG_DEFINE(mcda, MLXSW_REG_MCDA_ID, MLXSW_REG_MCDA_LEN);
+
+/* reg_mcda_update_handle
+ * Token representing the current flow executed by the FSM.
+ * Access: RW
+ */
+MLXSW_ITEM32(reg, mcda, update_handle, 0x00, 0, 24);
+
+/* reg_mcda_offset
+ * Offset of accessed address relative to component start. Accesses must be in
+ * accordance to log_mcda_word_size in MCQI reg.
+ * Access: RW
+ */
+MLXSW_ITEM32(reg, mcda, offset, 0x04, 0, 32);
+
+/* reg_mcda_size
+ * Size of the data accessed, given in bytes.
+ * Access: RW
+ */
+MLXSW_ITEM32(reg, mcda, size, 0x08, 0, 16);
+
+/* reg_mcda_data
+ * Data block accessed.
+ * Access: RW
+ */
+MLXSW_ITEM32_INDEXED(reg, mcda, data, 0x10, 0, 32, 4, 0, false);
+
+static inline void mlxsw_reg_mcda_pack(char *payload, u32 update_handle,
+				       u32 offset, u16 size, u8 *data)
+{
+	int i;
+
+	MLXSW_REG_ZERO(mcda, payload);
+	mlxsw_reg_mcda_update_handle_set(payload, update_handle);
+	mlxsw_reg_mcda_offset_set(payload, offset);
+	mlxsw_reg_mcda_size_set(payload, size);
+
+	for (i = 0; i < size / 4; i++)
+		mlxsw_reg_mcda_data_set(payload, i, *(u32 *) &data[i * 4]);
+}
+
 /* MPSC - Monitoring Packet Sampling Configuration Register
  * --------------------------------------------------------
  * MPSC Register is used to configure the Packet Sampling mechanism.
@@ -6388,6 +6439,7 @@ static const struct mlxsw_reg_info *mlxsw_reg_infos[] = {
 	MLXSW_REG(mpsc),
 	MLXSW_REG(mcqi),
 	MLXSW_REG(mcc),
+	MLXSW_REG(mcda),
 	MLXSW_REG(mgpc),
 	MLXSW_REG(sbpr),
 	MLXSW_REG(sbcm),
Signature · 1 line
2.9.3
author
#5 lore raw

PATCH 5/9 mlxsw: spectrum: Add the needed callbacks for mlxfw integration

In reply to Jiri Pirko

From: Yotam Gigi <[email protected]>

The mlxfw module defines several needed callbacks in order to flash the device's firmware. As the mlxfw module is shared between several different drivers, those callbacks are the glue functionality that is responsible for hardware interaction. Add those callbacks using the MCQI, MCC, MCDA registers.

---
 drivers/net/ethernet/mellanox/mlxsw/spectrum.c | 166 +++++++++++++++++++++++++
 1 file changed, 166 insertions(+)
drivers/net/ethernet/mellanox/mlxsw/spectrum.c +166 -0
index 8a165bb..b533a53 100644
@@ -68,6 +68,7 @@
 #include "txheader.h"
 #include "spectrum_cnt.h"
 #include "spectrum_dpipe.h"
+#include "../mlxfw/mlxfw.h"
 
 static const char mlxsw_sp_driver_name[] = "mlxsw_spectrum";
 static const char mlxsw_sp_driver_version[] = "1.0";
@@ -140,6 +141,171 @@ MLXSW_ITEM32(tx, hdr, fid, 0x08, 0, 16);
  */
 MLXSW_ITEM32(tx, hdr, type, 0x0C, 0, 4);
 
+struct mlxsw_sp_mlxfw_dev {
+	struct mlxfw_dev mlxfw_dev;
+	struct mlxsw_sp *mlxsw_sp;
+};
+
+static int mlxsw_sp_component_query(struct mlxfw_dev *mlxfw_dev,
+				    u16 component_index, u32 *p_max_size,
+				    u8 *p_align_bits, u16 *p_max_write_size)
+{
+	struct mlxsw_sp_mlxfw_dev *mlxsw_sp_mlxfw_dev =
+		container_of(mlxfw_dev, struct mlxsw_sp_mlxfw_dev, mlxfw_dev);
+	struct mlxsw_sp *mlxsw_sp = mlxsw_sp_mlxfw_dev->mlxsw_sp;
+	char mcqi_pl[MLXSW_REG_MCQI_LEN];
+	int err;
+
+	mlxsw_reg_mcqi_pack(mcqi_pl, component_index);
+	err = mlxsw_reg_query(mlxsw_sp->core, MLXSW_REG(mcqi), mcqi_pl);
+	if (err)
+		return err;
+	mlxsw_reg_mcqi_unpack(mcqi_pl, p_max_size, p_align_bits,
+			      p_max_write_size);
+
+	*p_align_bits = max_t(u8, *p_align_bits, 2);
+	*p_max_write_size = min_t(u16, *p_max_write_size,
+				  MLXSW_REG_MCDA_MAX_DATA_LEN);
+	return 0;
+}
+
+static int mlxsw_sp_fsm_lock(struct mlxfw_dev *mlxfw_dev, u32 *fwhandle)
+{
+	struct mlxsw_sp_mlxfw_dev *mlxsw_sp_mlxfw_dev =
+		container_of(mlxfw_dev, struct mlxsw_sp_mlxfw_dev, mlxfw_dev);
+	struct mlxsw_sp *mlxsw_sp = mlxsw_sp_mlxfw_dev->mlxsw_sp;
+	char mcc_pl[MLXSW_REG_MCC_LEN];
+	u8 control_state;
+	int err;
+
+	mlxsw_reg_mcc_pack(mcc_pl, 0, 0, 0, 0);
+	err = mlxsw_reg_query(mlxsw_sp->core, MLXSW_REG(mcc), mcc_pl);
+	if (err)
+		return err;
+
+	mlxsw_reg_mcc_unpack(mcc_pl, fwhandle, NULL, &control_state);
+	if (control_state != MLXFW_FSM_STATE_IDLE)
+		return -EBUSY;
+
+	mlxsw_reg_mcc_pack(mcc_pl,
+			   MLXSW_REG_MCC_INSTRUCTION_LOCK_UPDATE_HANDLE,
+			   0, *fwhandle, 0);
+	return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(mcc), mcc_pl);
+}
+
+static int mlxsw_sp_fsm_component_update(struct mlxfw_dev *mlxfw_dev,
+					 u32 fwhandle, u16 component_index,
+					 u32 component_size)
+{
+	struct mlxsw_sp_mlxfw_dev *mlxsw_sp_mlxfw_dev =
+		container_of(mlxfw_dev, struct mlxsw_sp_mlxfw_dev, mlxfw_dev);
+	struct mlxsw_sp *mlxsw_sp = mlxsw_sp_mlxfw_dev->mlxsw_sp;
+	char mcc_pl[MLXSW_REG_MCC_LEN];
+
+	mlxsw_reg_mcc_pack(mcc_pl, MLXSW_REG_MCC_INSTRUCTION_UPDATE_COMPONENT,
+			   component_index, fwhandle, component_size);
+	return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(mcc), mcc_pl);
+}
+
+static int mlxsw_sp_fsm_block_download(struct mlxfw_dev *mlxfw_dev,
+				       u32 fwhandle, u8 *data, u16 size,
+				       u32 offset)
+{
+	struct mlxsw_sp_mlxfw_dev *mlxsw_sp_mlxfw_dev =
+		container_of(mlxfw_dev, struct mlxsw_sp_mlxfw_dev, mlxfw_dev);
+	struct mlxsw_sp *mlxsw_sp = mlxsw_sp_mlxfw_dev->mlxsw_sp;
+	char mcda_pl[MLXSW_REG_MCDA_LEN];
+
+	mlxsw_reg_mcda_pack(mcda_pl, fwhandle, offset, size, data);
+	return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(mcda), mcda_pl);
+}
+
+static int mlxsw_sp_fsm_component_verify(struct mlxfw_dev *mlxfw_dev,
+					 u32 fwhandle, u16 component_index)
+{
+	struct mlxsw_sp_mlxfw_dev *mlxsw_sp_mlxfw_dev =
+		container_of(mlxfw_dev, struct mlxsw_sp_mlxfw_dev, mlxfw_dev);
+	struct mlxsw_sp *mlxsw_sp = mlxsw_sp_mlxfw_dev->mlxsw_sp;
+	char mcc_pl[MLXSW_REG_MCC_LEN];
+
+	mlxsw_reg_mcc_pack(mcc_pl, MLXSW_REG_MCC_INSTRUCTION_VERIFY_COMPONENT,
+			   component_index, fwhandle, 0);
+	return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(mcc), mcc_pl);
+}
+
+static int mlxsw_sp_fsm_activate(struct mlxfw_dev *mlxfw_dev, u32 fwhandle)
+{
+	struct mlxsw_sp_mlxfw_dev *mlxsw_sp_mlxfw_dev =
+		container_of(mlxfw_dev, struct mlxsw_sp_mlxfw_dev, mlxfw_dev);
+	struct mlxsw_sp *mlxsw_sp = mlxsw_sp_mlxfw_dev->mlxsw_sp;
+	char mcc_pl[MLXSW_REG_MCC_LEN];
+
+	mlxsw_reg_mcc_pack(mcc_pl, MLXSW_REG_MCC_INSTRUCTION_ACTIVATE, 0,
+			   fwhandle, 0);
+	return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(mcc), mcc_pl);
+}
+
+static int mlxsw_sp_fsm_query_state(struct mlxfw_dev *mlxfw_dev, u32 fwhandle,
+				    enum mlxfw_fsm_state *fsm_state,
+				    enum mlxfw_fsm_state_err *fsm_state_err)
+{
+	struct mlxsw_sp_mlxfw_dev *mlxsw_sp_mlxfw_dev =
+		container_of(mlxfw_dev, struct mlxsw_sp_mlxfw_dev, mlxfw_dev);
+	struct mlxsw_sp *mlxsw_sp = mlxsw_sp_mlxfw_dev->mlxsw_sp;
+	char mcc_pl[MLXSW_REG_MCC_LEN];
+	u8 control_state;
+	u8 error_code;
+	int err;
+
+	mlxsw_reg_mcc_pack(mcc_pl, 0, 0, fwhandle, 0);
+	err = mlxsw_reg_query(mlxsw_sp->core, MLXSW_REG(mcc), mcc_pl);
+	if (err)
+		return err;
+
+	mlxsw_reg_mcc_unpack(mcc_pl, NULL, &error_code, &control_state);
+	*fsm_state = control_state;
+	*fsm_state_err = min_t(enum mlxfw_fsm_state_err, error_code,
+			       MLXFW_FSM_STATE_ERR_MAX);
+	return 0;
+}
+
+static void mlxsw_sp_fsm_cancel(struct mlxfw_dev *mlxfw_dev, u32 fwhandle)
+{
+	struct mlxsw_sp_mlxfw_dev *mlxsw_sp_mlxfw_dev =
+		container_of(mlxfw_dev, struct mlxsw_sp_mlxfw_dev, mlxfw_dev);
+	struct mlxsw_sp *mlxsw_sp = mlxsw_sp_mlxfw_dev->mlxsw_sp;
+	char mcc_pl[MLXSW_REG_MCC_LEN];
+
+	mlxsw_reg_mcc_pack(mcc_pl, MLXSW_REG_MCC_INSTRUCTION_CANCEL, 0,
+			   fwhandle, 0);
+	mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(mcc), mcc_pl);
+}
+
+static void mlxsw_sp_fsm_release(struct mlxfw_dev *mlxfw_dev, u32 fwhandle)
+{
+	struct mlxsw_sp_mlxfw_dev *mlxsw_sp_mlxfw_dev =
+		container_of(mlxfw_dev, struct mlxsw_sp_mlxfw_dev, mlxfw_dev);
+	struct mlxsw_sp *mlxsw_sp = mlxsw_sp_mlxfw_dev->mlxsw_sp;
+	char mcc_pl[MLXSW_REG_MCC_LEN];
+
+	mlxsw_reg_mcc_pack(mcc_pl,
+			   MLXSW_REG_MCC_INSTRUCTION_RELEASE_UPDATE_HANDLE, 0,
+			   fwhandle, 0);
+	mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(mcc), mcc_pl);
+}
+
+static const struct mlxfw_dev_ops mlxsw_sp_mlxfw_dev_ops = {
+	.component_query	= mlxsw_sp_component_query,
+	.fsm_lock		= mlxsw_sp_fsm_lock,
+	.fsm_component_update	= mlxsw_sp_fsm_component_update,
+	.fsm_block_download	= mlxsw_sp_fsm_block_download,
+	.fsm_component_verify	= mlxsw_sp_fsm_component_verify,
+	.fsm_activate		= mlxsw_sp_fsm_activate,
+	.fsm_query_state	= mlxsw_sp_fsm_query_state,
+	.fsm_cancel		= mlxsw_sp_fsm_cancel,
+	.fsm_release		= mlxsw_sp_fsm_release
+};
+
 int mlxsw_sp_flow_counter_get(struct mlxsw_sp *mlxsw_sp,
 			      unsigned int counter_index, u64 *packets,
 			      u64 *bytes)
Signature · 1 line
2.9.3
author
#6 lore raw

PATCH 6/9 mlxsw: spectrum: Implement the ethtool flash_device callback

In reply to Jiri Pirko

From: Yotam Gigi <[email protected]>

Add callback to the ethtool flash_device op. This callback uses the mlxfw module to flash the new firmware file to the device.

As the firmware burn process takes about 20 seconds and ethtool takes the rtnl lock during the flash_device callback, release the rtnl lock at the beginning of the flash process and take it again before leaving the callback. This way, the rtnl is not held during the process. To make sure the device does not get deleted during the flash process, take a reference to it before releasing the rtnl lock.

---
 drivers/net/ethernet/mellanox/mlxsw/Kconfig    |  1 +
 drivers/net/ethernet/mellanox/mlxsw/spectrum.c | 41 ++++++++++++++++++++++++++
 2 files changed, 42 insertions(+)
drivers/net/ethernet/mellanox/mlxsw/Kconfig +1 -0
index ef23eae..b9f80c2 100644
@@ -75,6 +75,7 @@ config MLXSW_SPECTRUM
 	depends on MLXSW_CORE && MLXSW_PCI && NET_SWITCHDEV && VLAN_8021Q
 	depends on PSAMPLE || PSAMPLE=n
 	select PARMAN
+	select MLXFW
 	default m
 	---help---
 	  This driver supports Mellanox Technologies Spectrum Ethernet
drivers/net/ethernet/mellanox/mlxsw/spectrum.c +41 -0

59 lines not on this page · raw message

Signature · 1 line
2.9.3
author
#7 lore raw

PATCH 7/9 mlxsw: core: Create the mlxsw_fw_rev struct

In reply to Jiri Pirko

From: Yotam Gigi <[email protected]>

This struct was previously an anonymous struct defined inside the mlxsw_bus_info struct. Extract it to a struct named mlxsw_fw_rev, as it will be needed later by the spectrum driver.

---
 drivers/net/ethernet/mellanox/mlxsw/core.h | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)
drivers/net/ethernet/mellanox/mlxsw/core.h +7 -5
index 7fb3539..6e966af 100644
@@ -344,15 +344,17 @@ struct mlxsw_bus {
 	u8 features;
 };
 
+struct mlxsw_fw_rev {
+	u16 major;
+	u16 minor;
+	u16 subminor;
+};
+
 struct mlxsw_bus_info {
 	const char *device_kind;
 	const char *device_name;
 	struct device *dev;
-	struct {
-		u16 major;
-		u16 minor;
-		u16 subminor;
-	} fw_rev;
+	struct mlxsw_fw_rev fw_rev;
 	u8 vsd[MLXSW_CMD_BOARDINFO_VSD_LEN];
 	u8 psid[MLXSW_CMD_BOARDINFO_PSID_LEN];
 };
Signature · 1 line
2.9.3
author
#8 lore raw

PATCH 8/9 mlxsw: spectrum: Validate firmware revision on init

In reply to Jiri Pirko

From: Yotam Gigi <[email protected]>

Make the spectrum module check the current device firmware version, and if it is below the supported version, use the libfirmware API to request a firmware file with the supported firmware version and flash it to the device using the mlxfw module.

The firmware file names are expected to be of Mellanox Firmware Archive version 2 (MFA2) format and their name are expected to be in the following
pattern: "mlxsw_spectrum-<major>.<minor>.<sub-minor>.mfa2".

---
 drivers/net/ethernet/mellanox/mlxsw/spectrum.c | 59 ++++++++++++++++++++++++++
 1 file changed, 59 insertions(+)
drivers/net/ethernet/mellanox/mlxsw/spectrum.c +59 -0
index 9e189fc..c846b13 100644
@@ -70,6 +70,21 @@
 #include "spectrum_dpipe.h"
 #include "../mlxfw/mlxfw.h"
 
+#define MLXSW_FWREV_MAJOR 13
+#define MLXSW_FWREV_MINOR 1420
+#define MLXSW_FWREV_SUBMINOR 122
+
+static const struct mlxsw_fw_rev mlxsw_sp_supported_fw_rev = {
+	.major = MLXSW_FWREV_MAJOR,
+	.minor = MLXSW_FWREV_MINOR,
+	.subminor = MLXSW_FWREV_SUBMINOR
+};
+
+#define MLXSW_SP_FW_FILENAME \
+	"mlxsw_spectrum-" __stringify(MLXSW_FWREV_MAJOR) \
+	"." __stringify(MLXSW_FWREV_MINOR) \
+	"." __stringify(MLXSW_FWREV_SUBMINOR) ".mfa2"
+
 static const char mlxsw_sp_driver_name[] = "mlxsw_spectrum";
 static const char mlxsw_sp_driver_version[] = "1.0";
 
@@ -321,6 +336,43 @@ static int mlxsw_sp_firmware_flash(struct mlxsw_sp *mlxsw_sp,
 	return mlxfw_firmware_flash(&mlxsw_sp_mlxfw_dev.mlxfw_dev, firmware);
 }
 
+static bool mlxsw_sp_fw_rev_ge(const struct mlxsw_fw_rev *a,
+			       const struct mlxsw_fw_rev *b)
+{
+	if (a->major != b->major)
+		return a->major > b->major;
+	if (a->minor != b->minor)
+		return a->minor > b->minor;
+	return a->subminor >= b->subminor;
+}
+
+static int mlxsw_sp_fw_rev_validate(struct mlxsw_sp *mlxsw_sp)
+{
+	const struct mlxsw_fw_rev *rev = &mlxsw_sp->bus_info->fw_rev;
+	const struct firmware *firmware;
+	int err;
+
+	if (mlxsw_sp_fw_rev_ge(rev, &mlxsw_sp_supported_fw_rev))
+		return 0;
+
+	dev_info(mlxsw_sp->bus_info->dev, "The firmware version %d.%d.%d out of data\n",
+		 rev->major, rev->minor, rev->subminor);
+	dev_info(mlxsw_sp->bus_info->dev, "Upgrading firmware using file %s\n",
+		 MLXSW_SP_FW_FILENAME);
+
+	err = request_firmware_direct(&firmware, MLXSW_SP_FW_FILENAME,
+				      mlxsw_sp->bus_info->dev);
+	if (err) {
+		dev_err(mlxsw_sp->bus_info->dev, "Could not request firmware file %s\n",
+			MLXSW_SP_FW_FILENAME);
+		return err;
+	}
+
+	err = mlxsw_sp_firmware_flash(mlxsw_sp, firmware);
+	release_firmware(firmware);
+	return err;
+}
+
 int mlxsw_sp_flow_counter_get(struct mlxsw_sp *mlxsw_sp,
 			      unsigned int counter_index, u64 *packets,
 			      u64 *bytes)
@@ -3600,6 +3652,12 @@ static int mlxsw_sp_init(struct mlxsw_core *mlxsw_core,
 	INIT_LIST_HEAD(&mlxsw_sp->fids);
 	INIT_LIST_HEAD(&mlxsw_sp->vfids.list);
 
+	err = mlxsw_sp_fw_rev_validate(mlxsw_sp);
+	if (err) {
+		dev_err(mlxsw_sp->bus_info->dev, "Could not upgrade firmware\n");
+		return err;
+	}
+
 	err = mlxsw_sp_base_mac_get(mlxsw_sp);
 	if (err) {
 		dev_err(mlxsw_sp->bus_info->dev, "Failed to get base mac\n");
@@ -4971,3 +5029,4 @@ MODULE_LICENSE("Dual BSD/GPL");
 MODULE_AUTHOR("Jiri Pirko <[email protected]>");
 MODULE_DESCRIPTION("Mellanox Spectrum driver");
 MODULE_DEVICE_TABLE(pci, mlxsw_sp_pci_id_table);
+MODULE_FIRMWARE(MLXSW_SP_FW_FILENAME);
Signature · 1 line
2.9.3
author
#9 lore raw

PATCH 9/9 mlxsw: spectrum_router: Adjust RIF configuration for new firmware versions

In reply to Jiri Pirko

From: Ido Schimmel <[email protected]>

In new firmware versions, when configuring a {Port, VID} as a router interface, the driver is responsible for enabling the STP filter and disabling learning. Otherwise, packets are discarded.

This change doesn't break existing firmware versions, but is required for newer firmware versions.

---
 .../net/ethernet/mellanox/mlxsw/spectrum_router.c  | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)
drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c +22 -0
index 3cc7d52..8165b11 100644
@@ -42,6 +42,7 @@
 #include <linux/notifier.h>
 #include <linux/inetdevice.h>
 #include <linux/netdevice.h>
+#include <linux/if_bridge.h>
 #include <net/netevent.h>
 #include <net/neighbour.h>
 #include <net/arp.h>
@@ -3109,7 +3110,9 @@ static int mlxsw_sp_vport_rif_sp_join(struct mlxsw_sp_port *mlxsw_sp_vport,
 				      struct net_device *l3_dev)
 {
 	struct mlxsw_sp *mlxsw_sp = mlxsw_sp_vport->mlxsw_sp;
+	u16 vid = mlxsw_sp_vport_vid_get(mlxsw_sp_vport);
 	struct mlxsw_sp_rif *rif;
+	int err;
 
 	rif = mlxsw_sp_rif_find_by_dev(mlxsw_sp, l3_dev);
 	if (!rif) {
@@ -3118,20 +3121,39 @@ static int mlxsw_sp_vport_rif_sp_join(struct mlxsw_sp_port *mlxsw_sp_vport,
 			return PTR_ERR(rif);
 	}
 
+	err = mlxsw_sp_port_vid_learning_set(mlxsw_sp_vport, vid, false);
+	if (err)
+		goto err_port_vid_learning_set;
+
+	err = mlxsw_sp_port_vid_stp_set(mlxsw_sp_vport, vid,
+					BR_STATE_FORWARDING);
+	if (err)
+		goto err_port_vid_stp_set;
+
 	mlxsw_sp_vport_fid_set(mlxsw_sp_vport, rif->f);
 	rif->f->ref_count++;
 
 	netdev_dbg(mlxsw_sp_vport->dev, "Joined FID=%d\n", rif->f->fid);
 
 	return 0;
+
+err_port_vid_stp_set:
+	mlxsw_sp_port_vid_learning_set(mlxsw_sp_vport, vid, true);
+err_port_vid_learning_set:
+	if (rif->f->ref_count == 0)
+		mlxsw_sp_vport_rif_sp_destroy(mlxsw_sp_vport, rif);
+	return err;
 }
 
 static void mlxsw_sp_vport_rif_sp_leave(struct mlxsw_sp_port *mlxsw_sp_vport)
 {
 	struct mlxsw_sp_fid *f = mlxsw_sp_vport_fid_get(mlxsw_sp_vport);
+	u16 vid = mlxsw_sp_vport_vid_get(mlxsw_sp_vport);
 
 	netdev_dbg(mlxsw_sp_vport->dev, "Left FID=%d\n", f->fid);
 
+	mlxsw_sp_port_vid_stp_set(mlxsw_sp_vport, vid, BR_STATE_BLOCKING);
+	mlxsw_sp_port_vid_learning_set(mlxsw_sp_vport, vid, true);
 	mlxsw_sp_vport_fid_set(mlxsw_sp_vport, NULL);
 	if (--f->ref_count == 0)
 		mlxsw_sp_vport_rif_sp_destroy(mlxsw_sp_vport, f->rif);
Signature · 1 line
2.9.3
#10 lore raw
In reply to Jiri Pirko
Quoted 19 lines

Add support for device firmware flash on mlxsw spectrum. The firmware files are expected to be in the Mellanox Firmware Archive version 2 (MFA2) format.

The firmware flash can be triggered via "ethtool -f" or on driver initialization time if the device firmware version does not meet the minimum firmware version supported by the driver.

Currently, to activate the newly flashed firmware, the user needs to reboot his system.

The first patch introduces the mlxfw module, which implements common logic needed for the firmware flash process on Mellanox products, such as the
MFA2 format parsing and the firmware flash state machine logic. As the module implements common logic which will be needed by various different Mellanox drivers, it defines a set of callbacks needed to interact with the specific device.

Quoted 5 lines

Patches 1-5 implement the needed mlxfw callbacks in the mlxsw spectrum driver.

Patches 6-8 add the "ethtool -f" and the boot-time firmware upgrade on the mlxsw spectrum driver.

When we tried using `ethtool -E' for qed we got burned for trying to use the magic value [1]. When we suggested extending it to allow some private data indications, Ben claimed that this entire ethtool infrastructure is a thing of the past, and we should try using MTD instead - a claim no one bothered to counter.

Creating proprietary file-formats, filling them with metadata and complementary driver state-machines could easily overcome the original obstacle we faced. But it raises the question of whether these APIs are valid or obsolete.

[1] http://marc.info/?l=linux-netdev&m=146093513926921&w=4
[2] http://marc.info/?l=linux-netdev&m=146514461214421&w=2

Quoted 56 lines

Patch 9 adds a fix needed for new firmware versions.

Ido Schimmel (1):
mlxsw: spectrum_router: Adjust RIF configuration for new firmware
versions

Yotam Gigi (8):
Add the mlxfw module for Mellanox firmware flash process
mlxsw: reg: Add Management Component Query Information register
mlxsw: reg: Add Management Component Control register
mlxsw: reg: Add Management Component Data Access register
mlxsw: spectrum: Add the needed callbacks for mlxfw integration
mlxsw: spectrum: Implement the ethtool flash_device callback
mlxsw: core: Create the mlxsw_fw_rev struct
mlxsw: spectrum: Validate firmware revision on init

 MAINTAINERS                                        |   8 +
 drivers/net/ethernet/mellanox/Kconfig              |   1 +
 drivers/net/ethernet/mellanox/Makefile             |   1 +
 drivers/net/ethernet/mellanox/mlxfw/Kconfig        |   6 +
 drivers/net/ethernet/mellanox/mlxfw/Makefile       |   2 +
 drivers/net/ethernet/mellanox/mlxfw/mlxfw.h        | 102 ++++
 drivers/net/ethernet/mellanox/mlxfw/mlxfw_fsm.c    | 273 +++++++++
 drivers/net/ethernet/mellanox/mlxfw/mlxfw_mfa2.c   | 620
+++++++++++++++++++++
 drivers/net/ethernet/mellanox/mlxfw/mlxfw_mfa2.h   |  66 +++
 .../net/ethernet/mellanox/mlxfw/mlxfw_mfa2_file.h  |  60 ++
 .../ethernet/mellanox/mlxfw/mlxfw_mfa2_format.h    | 103 ++++
 .../net/ethernet/mellanox/mlxfw/mlxfw_mfa2_tlv.h   |  98 ++++
 .../ethernet/mellanox/mlxfw/mlxfw_mfa2_tlv_multi.c | 126 +++++
.../ethernet/mellanox/mlxfw/mlxfw_mfa2_tlv_multi.h |  71 +++
 drivers/net/ethernet/mellanox/mlxsw/Kconfig        |   1 +
 drivers/net/ethernet/mellanox/mlxsw/core.h         |  12 +-
 drivers/net/ethernet/mellanox/mlxsw/reg.h          | 219 ++++++++
 drivers/net/ethernet/mellanox/mlxsw/spectrum.c     | 266 +++++++++
 .../net/ethernet/mellanox/mlxsw/spectrum_router.c  |  22 +
 19 files changed, 2052 insertions(+), 5 deletions(-)  create mode 100644
drivers/net/ethernet/mellanox/mlxfw/Kconfig
 create mode 100644 drivers/net/ethernet/mellanox/mlxfw/Makefile
 create mode 100644 drivers/net/ethernet/mellanox/mlxfw/mlxfw.h
 create mode 100644 drivers/net/ethernet/mellanox/mlxfw/mlxfw_fsm.c
 create mode 100644 drivers/net/ethernet/mellanox/mlxfw/mlxfw_mfa2.c
 create mode 100644 drivers/net/ethernet/mellanox/mlxfw/mlxfw_mfa2.h
 create mode 100644
drivers/net/ethernet/mellanox/mlxfw/mlxfw_mfa2_file.h
 create mode 100644
drivers/net/ethernet/mellanox/mlxfw/mlxfw_mfa2_format.h
 create mode 100644
drivers/net/ethernet/mellanox/mlxfw/mlxfw_mfa2_tlv.h
 create mode 100644
drivers/net/ethernet/mellanox/mlxfw/mlxfw_mfa2_tlv_multi.c
 create mode 100644

drivers/net/ethernet/mellanox/mlxfw/mlxfw_mfa2_tlv_multi.h

--
2.9.3

#11 lore raw
Quoted 29 lines · Yuval
Quoted 19 lines

Add support for device firmware flash on mlxsw spectrum. The firmware files are expected to be in the Mellanox Firmware Archive version 2 (MFA2) format.

The firmware flash can be triggered via "ethtool -f" or on driver initialization time if the device firmware version does not meet the minimum firmware version supported by the driver.

Currently, to activate the newly flashed firmware, the user needs to reboot his system.

The first patch introduces the mlxfw module, which implements common logic needed for the firmware flash process on Mellanox products, such as the
MFA2 format parsing and the firmware flash state machine logic. As the module implements common logic which will be needed by various different Mellanox drivers, it defines a set of callbacks needed to interact with the specific device.

Quoted 5 lines

Patches 1-5 implement the needed mlxfw callbacks in the mlxsw spectrum driver.

Patches 6-8 add the "ethtool -f" and the boot-time firmware upgrade on the mlxsw spectrum driver.

When we tried using `ethtool -E' for qed we got burned for trying to use the magic value [1]. When we suggested extending it to allow some private data indications, Ben claimed that this entire ethtool infrastructure is a thing of the past, and we should try using MTD instead - a claim no one bothered to counter.

Quoted 4 lines

Creating proprietary file-formats, filling them with metadata and complementary driver state-machines could easily overcome the original obstacle we faced. But it raises the question of whether these APIs are valid or obsolete.

The metadata in our format is needed to allow us to hold several firmware images for several spectrum silicon variants in one file, hence the metadata is used by the driver and does not get transferred to the device. Our code can only be used to transfer firmware to the device, and cannot be used to configure the device.

Quoted 60 lines

[1] http://marc.info/?l=linux-netdev&m=146093513926921&w=4
[2] http://marc.info/?l=linux-netdev&m=146514461214421&w=2

Quoted 56 lines

Patch 9 adds a fix needed for new firmware versions.

Ido Schimmel (1):
mlxsw: spectrum_router: Adjust RIF configuration for new firmware
versions

Yotam Gigi (8):
Add the mlxfw module for Mellanox firmware flash process
mlxsw: reg: Add Management Component Query Information register
mlxsw: reg: Add Management Component Control register
mlxsw: reg: Add Management Component Data Access register
mlxsw: spectrum: Add the needed callbacks for mlxfw integration
mlxsw: spectrum: Implement the ethtool flash_device callback
mlxsw: core: Create the mlxsw_fw_rev struct
mlxsw: spectrum: Validate firmware revision on init

 MAINTAINERS                                        |   8 +
 drivers/net/ethernet/mellanox/Kconfig              |   1 +
 drivers/net/ethernet/mellanox/Makefile             |   1 +
 drivers/net/ethernet/mellanox/mlxfw/Kconfig        |   6 +
 drivers/net/ethernet/mellanox/mlxfw/Makefile       |   2 +
 drivers/net/ethernet/mellanox/mlxfw/mlxfw.h        | 102 ++++
 drivers/net/ethernet/mellanox/mlxfw/mlxfw_fsm.c    | 273 +++++++++
 drivers/net/ethernet/mellanox/mlxfw/mlxfw_mfa2.c   | 620
+++++++++++++++++++++
 drivers/net/ethernet/mellanox/mlxfw/mlxfw_mfa2.h   |  66 +++
 .../net/ethernet/mellanox/mlxfw/mlxfw_mfa2_file.h  |  60 ++
 .../ethernet/mellanox/mlxfw/mlxfw_mfa2_format.h    | 103 ++++
 .../net/ethernet/mellanox/mlxfw/mlxfw_mfa2_tlv.h   |  98 ++++
 .../ethernet/mellanox/mlxfw/mlxfw_mfa2_tlv_multi.c | 126 +++++
.../ethernet/mellanox/mlxfw/mlxfw_mfa2_tlv_multi.h |  71 +++
 drivers/net/ethernet/mellanox/mlxsw/Kconfig        |   1 +
 drivers/net/ethernet/mellanox/mlxsw/core.h         |  12 +-
 drivers/net/ethernet/mellanox/mlxsw/reg.h          | 219 ++++++++
 drivers/net/ethernet/mellanox/mlxsw/spectrum.c     | 266 +++++++++
 .../net/ethernet/mellanox/mlxsw/spectrum_router.c  |  22 +
 19 files changed, 2052 insertions(+), 5 deletions(-)  create mode 100644
drivers/net/ethernet/mellanox/mlxfw/Kconfig
 create mode 100644 drivers/net/ethernet/mellanox/mlxfw/Makefile
 create mode 100644 drivers/net/ethernet/mellanox/mlxfw/mlxfw.h
 create mode 100644 drivers/net/ethernet/mellanox/mlxfw/mlxfw_fsm.c
 create mode 100644 drivers/net/ethernet/mellanox/mlxfw/mlxfw_mfa2.c
 create mode 100644 drivers/net/ethernet/mellanox/mlxfw/mlxfw_mfa2.h
 create mode 100644
drivers/net/ethernet/mellanox/mlxfw/mlxfw_mfa2_file.h
 create mode 100644
drivers/net/ethernet/mellanox/mlxfw/mlxfw_mfa2_format.h
 create mode 100644
drivers/net/ethernet/mellanox/mlxfw/mlxfw_mfa2_tlv.h
 create mode 100644
drivers/net/ethernet/mellanox/mlxfw/mlxfw_mfa2_tlv_multi.c
 create mode 100644

drivers/net/ethernet/mellanox/mlxfw/mlxfw_mfa2_tlv_multi.h

--
2.9.3

#12 lore raw
Quoted 10 lines
Quoted 1 line
Quoted 1 line

Patches 6-8 add the "ethtool -f" and the boot-time firmware upgrade on

the

Quoted 2 lines
Quoted 1 line

mlxsw spectrum driver.

When we tried using `ethtool -E' for qed we got burned for trying to use

the magic

Quoted 1 line

value [1]. When we suggested extending it to allow some private data

indications,

Quoted 3 lines

Ben claimed that this entire ethtool infrastructure is a thing of the past, and we should try using MTD instead - a claim no one bothered to counter.

Quoted 8 lines
Quoted 4 lines

Creating proprietary file-formats, filling them with metadata and complementary driver state-machines could easily overcome the original obstacle we faced. But it raises the question of whether these APIs are valid or obsolete.

The metadata in our format is needed to allow us to hold several firmware images for several spectrum silicon variants in one file, hence the metadata is used by the driver and does not get transferred to the device.

Understood; Otherwise it would have been 'data' and not 'metadata'.

Quoted 2 lines

Our code can only be used to transfer firmware to the device, and cannot be used to configure the device.

Not sure what this refers to? The differences between '-f' and '-E'? Also, assuming you haven't started selling your adapters as persistent memory for storage, what's the difference?

#13 lore raw
Quoted 17 lines · Yuval
Quoted 10 lines
Quoted 1 line
Quoted 1 line

Patches 6-8 add the "ethtool -f" and the boot-time firmware upgrade on

the

Quoted 2 lines
Quoted 1 line

mlxsw spectrum driver.

When we tried using `ethtool -E' for qed we got burned for trying to use

the magic

Quoted 1 line

value [1]. When we suggested extending it to allow some private data

indications,

Quoted 3 lines

Ben claimed that this entire ethtool infrastructure is a thing of the past, and we should try using MTD instead - a claim no one bothered to counter.

Quoted 7 lines
Quoted 4 lines

Creating proprietary file-formats, filling them with metadata and complementary driver state-machines could easily overcome the original obstacle we faced. But it raises the question of whether these APIs are valid or obsolete.

The metadata in our format is needed to allow us to hold several firmware images for several spectrum silicon variants in one file, hence the metadata is used by the driver and does not get transferred to the device.

Quoted 8 lines

Understood; Otherwise it would have been 'data' and not 'metadata'.

Quoted 2 lines

Our code can only be used to transfer firmware to the device, and cannot be used to configure the device.

Not sure what this refers to? The differences between '-f' and '-E'? Also, assuming you haven't started selling your adapters as persistent memory for storage, what's the difference?

Sorry, I am not sure I understand. You think that drivers should not implement ethtool's flash_device callback anymore? do you have an alternative for firmware flash?

#14 lore raw
Quoted 25 lines
Quoted 11 lines
Quoted 11 lines
Quoted 2 lines
Quoted 2 lines

Patches 6-8 add the "ethtool -f" and the boot-time firmware upgrade on

the

Quoted 3 lines
Quoted 1 line

mlxsw spectrum driver.

When we tried using `ethtool -E' for qed we got burned for trying to use

the magic

Quoted 1 line

value [1]. When we suggested extending it to allow some private data

indications,

Quoted 2 lines

Ben claimed that this entire ethtool infrastructure is a thing of the past, and we should try using MTD instead - a claim no one

bothered to counter.

Quoted 8 lines
Quoted 8 lines
Quoted 5 lines

Creating proprietary file-formats, filling them with metadata and complementary driver state-machines could easily overcome the original obstacle we faced. But it raises the question of whether these APIs are valid or obsolete.

The metadata in our format is needed to allow us to hold several firmware images for several spectrum silicon variants in one file, hence the metadata is used by the driver and does not get transferred to

the device.

Quoted 4 lines

Understood; Otherwise it would have been 'data' and not 'metadata'.

Quoted 2 lines

Our code can only be used to transfer firmware to the device, and cannot be used to configure the device.

Quoted 8 lines
Quoted 4 lines

Not sure what this refers to? The differences between '-f' and '-E'? Also, assuming you haven't started selling your adapters as persistent memory for storage, what's the difference?

Sorry, I am not sure I understand. You think that drivers should not implement ethtool's flash_device callback anymore? do you have an alternative for firmware flash?

That's exactly the question Ben asked in -
http://marc.info/?l=linux-netdev&m=146514461214421&w=2
Suggesting to use MTD for flash access.

I'm not saying that approach was necessarily the best; But no one shared any disagreement with it back then.

maintainer
#15 lore raw
In reply to Yotam Gigi

From: Yotam Gigi <[email protected]>
Date: Tue, 23 May 2017 18:14:15 +0300

Quoted 3 lines

Sorry, I am not sure I understand. You think that drivers should not implement ethtool's flash_device callback anymore? do you have an alternative for firmware flash?

As stated, export an MTD device.

author
#16 lore raw
Quoted 8 lines · Tue, May 23, 2017 at 05:38:59PM CEST, [email protected] wrote:

From: Yotam Gigi <[email protected]>
Date: Tue, 23 May 2017 18:14:15 +0300

Quoted 3 lines

Sorry, I am not sure I understand. You think that drivers should not implement ethtool's flash_device callback anymore? do you have an alternative for firmware flash?

As stated, export an MTD device.

Okay. We'll cut out the ethtool part of the patchset and will do mtd as a followup. Thanks

#17 lore raw
In reply to David Miller
Quoted 7 lines · David Miller

From: Yotam Gigi <[email protected]>
Date: Tue, 23 May 2017 18:14:15 +0300

Quoted 3 lines

Sorry, I am not sure I understand. You think that drivers should not implement ethtool's flash_device callback anymore? do you have an alternative for firmware flash?

As stated, export an MTD device.

So, after we have been going over MTD, it seems like it does not fit our needs at all.

MTD device provides (erasable-)block access to a flash storage, where in our case the firmware burn process is just pouring a binary BLOB into the device. The driver is not aware of the internal storage used for storing the firmware as it is not defined in our driver-hardware API.

Needless to say that block access has no meaning in our case, so any solution that will involve MTD device to burn our firmware (if there is a solution at all) will be a workaround and will not fit MTD purpose.

Apart for boot time firmware flash, which we have already pushed we would really like to allow the user to ask for a specific firmware version. Do you have any other solution for us apart from "ethtool -f"?

This problem is even more relevant in the Mellanox HCA driver team, which would like to use that code in order to burn the HCA firmware, but not intend to trigger it on boot time, which means that must have a way for the user to trigger it.

#18 lore raw
Quoted 17 lines · Yotam Gigi
Quoted 7 lines · David Miller

From: Yotam Gigi <[email protected]>
Date: Tue, 23 May 2017 18:14:15 +0300

Quoted 3 lines

Sorry, I am not sure I understand. You think that drivers should not implement ethtool's flash_device callback anymore? do you have an alternative for firmware flash?

As stated, export an MTD device.

So, after we have been going over MTD, it seems like it does not fit our needs at all.

MTD device provides (erasable-)block access to a flash storage, where in our case the firmware burn process is just pouring a binary BLOB into the device. The driver is not aware of the internal storage used for storing the firmware as it is not defined in our driver-hardware API.

Quoted 7 lines

Needless to say that block access has no meaning in our case, so any solution that will involve MTD device to burn our firmware (if there is a solution at all) will be a workaround and will not fit MTD purpose.

Apart for boot time firmware flash, which we have already pushed we would really like to allow the user to ask for a specific firmware version. Do you have any other solution for us apart from "ethtool -f"?

Could you elaborate on what the requirements are for "allowing users to ask for a specific firmware version"? How do the FWs differ? I'm asking because we are currently lacking ABI for selecting device "modes". Netronome has this problem. Cavium has recently posted a patch which used module parameter to flip between "OvS" and "basic NIC" firmwares.

For Netronome we will definitely want a way to switch between at least three applications so far - basic, OvS and eBPF - but I also feel like we shouldn't limit that list, since anyone can write their own FW for programmable NICs.

I think you were primarily concerned with writing persistent storage so far. Does "allowing the user to ask..." means write flash and reboot or also a runtime switch? I think we probably need both?

Quoted 4 lines

This problem is even more relevant in the Mellanox HCA driver team, which would like to use that code in order to burn the HCA firmware, but not intend to trigger it on boot time, which means that must have a way for the user to trigger it.

What would the requirements for the HCA team be? Is it about loading different code or loading HW settings?

#19 lore raw
Quoted 31 lines · Jakub Kicinski
Quoted 16 lines · Yotam Gigi
Quoted 7 lines · David Miller

From: Yotam Gigi <[email protected]>
Date: Tue, 23 May 2017 18:14:15 +0300

Quoted 3 lines

Sorry, I am not sure I understand. You think that drivers should not implement ethtool's flash_device callback anymore? do you have an alternative for firmware flash?

As stated, export an MTD device.

So, after we have been going over MTD, it seems like it does not fit our needs at all.

MTD device provides (erasable-)block access to a flash storage, where in our case the firmware burn process is just pouring a binary BLOB into the device. The driver is not aware of the internal storage used for storing the firmware as it is not defined in our driver-hardware API.

Quoted 7 lines

Needless to say that block access has no meaning in our case, so any solution that will involve MTD device to burn our firmware (if there is a solution at all) will be a workaround and will not fit MTD purpose.

Apart for boot time firmware flash, which we have already pushed we would really like to allow the user to ask for a specific firmware version. Do you have any other solution for us apart from "ethtool -f"?

Could you elaborate on what the requirements are for "allowing users to ask for a specific firmware version"? How do the FWs differ? I'm asking because we are currently lacking ABI for selecting device "modes". Netronome has this problem. Cavium has recently posted a patch which used module parameter to flip between "OvS" and "basic NIC" firmwares.

Quoted 4 lines

For Netronome we will definitely want a way to switch between at least three applications so far - basic, OvS and eBPF - but I also feel like we shouldn't limit that list, since anyone can write their own FW for programmable NICs.

Currently, both in the HCA and switch we only refer to FW images of different versions which naturally include bug fixes and enhancements (new features), and not configurations or hardware modes.

In the switch driver we use boot time firmware upgrade if the minimum required version is not met, so it is true that the "ethtool -f" is not really required for normal operation.

However, it is of much use for development, testing, QA, lab and PoC environments when specific bug fixes or new features which are not yet present in official FW releases and hence not yet posted to the upstream libfirmware.

I do agree, on the other hand, that the difference between firmware versions and firmware configuration is semantic, and there is no code-enforcement on that, but it will be of much convenience for the user to upgrade to a newer firmware that includes more features.

Quoted 4 lines

I think you were primarily concerned with writing persistent storage so far. Does "allowing the user to ask..." means write flash and reboot or also a runtime switch? I think we probably need both?

Currently the new firmware will be activated after reboot, but we may change it in the future.

Quoted 7 lines
Quoted 5 lines

This problem is even more relevant in the Mellanox HCA driver team, which would like to use that code in order to burn the HCA firmware, but not intend to trigger it on boot time, which means that must have a way for the user to trigger it.

What would the requirements for the HCA team be? Is it about loading different code or loading HW settings?

#20 lore raw
In reply to Jakub Kicinski
Quoted 9 lines · Jakub Kicinski
Quoted 4 lines · Yotam Gigi

This problem is even more relevant in the Mellanox HCA driver team, which would like to use that code in order to burn the HCA firmware, but not intend to trigger it on boot time, which means that must have a way for the user to trigger it.

What would the requirements for the HCA team be? Is it about loading different code or loading HW settings?

For the NIC, as of the (happily growing) large open-systems by nature install base, we
can't effort for the driver not to load when the currently burned fw isn't the latest or
the system doesn't have the latest libfirmware clone. We do have to keep the hassle of
compatibility with older FWs, etc. As part of the driver/FW API design we use cap bits
for that matter, and never ask/branch on specific FW or HW versions.

We do want to let user work with the kernel w.o the need to have them install MLNX or anyone's
tool suit and hence the large value we find in the ethtool flashing of FW image (the patches
are ready...)

Or.

#21 lore raw

[swapping Ben's email]

Quoted 21 lines · Or Gerlitz
Quoted 9 lines · Jakub Kicinski
Quoted 4 lines · Yotam Gigi

This problem is even more relevant in the Mellanox HCA driver team, which would like to use that code in order to burn the HCA firmware, but not intend to trigger it on boot time, which means that must have a way for the user to trigger it.

What would the requirements for the HCA team be? Is it about loading different code or loading HW settings?

For the NIC, as of the (happily growing) large open-systems by nature install base, we
can't effort for the driver not to load when the currently burned fw isn't the latest or
the system doesn't have the latest libfirmware clone. We do have to keep the hassle of
compatibility with older FWs, etc. As part of the driver/FW API design we use cap bits
for that matter, and never ask/branch on specific FW or HW versions.

Quoted 5 lines

We do want to let user work with the kernel w.o the need to have them install MLNX or anyone's
tool suit and hence the large value we find in the ethtool flashing of FW image (the patches
are ready...)

Thanks for the explanations Or and Yotam! That does sound like a plain version upgrade problem.

#22 lore raw
In reply to Yotam Gigi
Quoted 22 lines · Yotam Gigi
Quoted 8 lines · David Miller

From: Yotam Gigi <[email protected]>
Date: Tue, 23 May 2017 18:14:15 +0300

Quoted 3 lines

Sorry, I am not sure I understand. You think that drivers should not implement ethtool's flash_device callback anymore? do you have an alternative for firmware flash?

As stated, export an MTD device.

So, after we have been going over MTD, it seems like it does not fit our needs at all.

MTD device provides (erasable-)block access to a flash storage, where in our case the firmware burn process is just pouring a binary BLOB into the device. The driver is not aware of the internal storage used for storing the firmware as it is not defined in our driver-hardware API.

Needless to say that block access has no meaning in our case, so any solution that will involve MTD device to burn our firmware (if there is a solution at all) will be a workaround and will not fit MTD purpose.

Quoted 8 lines

Apart for boot time firmware flash, which we have already pushed we would really like to allow the user to ask for a specific firmware version. Do you have any other solution for us apart from "ethtool -f"?

This problem is even more relevant in the Mellanox HCA driver team, which would like to use that code in order to burn the HCA firmware, but not intend to trigger it on boot time, which means that must have a way for the user to trigger it.

Hi Dave,

We had few more emails on this thread with Jakub, and he's now happy with our replies, so where do we go from here? could you comment on Yotam's note.

thanks,

Or.

maintainer
#23 lore raw

From: Or Gerlitz <[email protected]>
Date: Tue, 30 May 2017 23:32:22 +0300

Quoted 33 lines · Yotam Gigi
Quoted 22 lines · David Miller
Quoted 8 lines

From: Yotam Gigi <[email protected]>
Date: Tue, 23 May 2017 18:14:15 +0300

Quoted 3 lines

Sorry, I am not sure I understand. You think that drivers should not implement ethtool's flash_device callback anymore? do you have an alternative for firmware flash?

As stated, export an MTD device.

So, after we have been going over MTD, it seems like it does not fit our needs at all.

MTD device provides (erasable-)block access to a flash storage, where in our case the firmware burn process is just pouring a binary BLOB into the device. The driver is not aware of the internal storage used for storing the firmware as it is not defined in our driver-hardware API.

Needless to say that block access has no meaning in our case, so any solution that will involve MTD device to burn our firmware (if there is a solution at all) will be a workaround and will not fit MTD purpose.

Quoted 8 lines

Apart for boot time firmware flash, which we have already pushed we would really like to allow the user to ask for a specific firmware version. Do you have any other solution for us apart from "ethtool -f"?

This problem is even more relevant in the Mellanox HCA driver team, which would like to use that code in order to burn the HCA firmware, but not intend to trigger it on boot time, which means that must have a way for the user to trigger it.

Quoted 5 lines

Hi Dave,

We had few more emails on this thread with Jakub, and he's now happy with our replies, so where do we go from here? could you comment on Yotam's note.

Ok, use ethtool -f if you must.