Added mlxfs backport for RHEL7.6
authorVladimir Sokolovsky <vlad@mellanox.com>
Thu, 29 Aug 2019 16:00:50 +0000 (11:00 -0500)
committerVladimir Sokolovsky <vlad@mellanox.com>
Thu, 29 Aug 2019 16:00:50 +0000 (11:00 -0500)
Signed-off-by: Vladimir Sokolovsky <vlad@mellanox.com>
patches/0008-BACKPORT-mlxfw.patch [new file with mode: 0644]

diff --git a/patches/0008-BACKPORT-mlxfw.patch b/patches/0008-BACKPORT-mlxfw.patch
new file mode 100644 (file)
index 0000000..b34f14d
--- /dev/null
@@ -0,0 +1,240 @@
+From: Vladimir Sokolovsky <vlad@mellanox.com>
+Subject: [PATCH] BACKPORT: mlxfw
+
+Signed-off-by: Vladimir Sokolovsky <vlad@mellanox.com>
+---
+ drivers/net/ethernet/mellanox/mlxfw/mlxfw.h   |  5 ++
+ .../net/ethernet/mellanox/mlxfw/mlxfw_fsm.c   | 59 +++++++++++++++++++
+ .../net/ethernet/mellanox/mlxfw/mlxfw_mfa2.c  |  3 +
+ 3 files changed, 67 insertions(+)
+
+diff --git a/drivers/net/ethernet/mellanox/mlxfw/mlxfw.h b/drivers/net/ethernet/mellanox/mlxfw/mlxfw.h
+index xxxxxxx..xxxxxxx 100644
+--- a/drivers/net/ethernet/mellanox/mlxfw/mlxfw.h
++++ b/drivers/net/ethernet/mellanox/mlxfw/mlxfw.h
+@@ -71,10 +71,15 @@ struct mlxfw_dev {
+ };
+ #if IS_REACHABLE(CONFIG_MLXFW)
++#ifdef HAVE_NETLINK_EXT_ACK
+ int mlxfw_firmware_flash(struct mlxfw_dev *mlxfw_dev,
+                        const struct firmware *firmware,
+                        struct netlink_ext_ack *extack);
+ #else
++int mlxfw_firmware_flash(struct mlxfw_dev *mlxfw_dev,
++                       const struct firmware *firmware);
++#endif
++#else
+ static inline
+ int mlxfw_firmware_flash(struct mlxfw_dev *mlxfw_dev,
+                        const struct firmware *firmware,
+diff --git a/drivers/net/ethernet/mellanox/mlxfw/mlxfw_fsm.c b/drivers/net/ethernet/mellanox/mlxfw/mlxfw_fsm.c
+index xxxxxxx..xxxxxxx 100644
+--- a/drivers/net/ethernet/mellanox/mlxfw/mlxfw_fsm.c
++++ b/drivers/net/ethernet/mellanox/mlxfw/mlxfw_fsm.c
+@@ -49,9 +49,14 @@ static void mlxfw_status_notify(struct mlxfw_dev *mlxfw_dev,
+                                     done_bytes, total_bytes);
+ }
++#ifdef HAVE_NETLINK_EXT_ACK
+ static int mlxfw_fsm_state_wait(struct mlxfw_dev *mlxfw_dev, u32 fwhandle,
+                               enum mlxfw_fsm_state fsm_state,
+                               struct netlink_ext_ack *extack)
++#else
++static int mlxfw_fsm_state_wait(struct mlxfw_dev *mlxfw_dev, u32 fwhandle,
++                              enum mlxfw_fsm_state fsm_state)
++#endif
+ {
+       enum mlxfw_fsm_state_err fsm_state_err;
+       enum mlxfw_fsm_state curr_fsm_state;
+@@ -68,13 +73,17 @@ retry:
+       if (fsm_state_err != MLXFW_FSM_STATE_ERR_OK) {
+               pr_err("Firmware flash failed: %s\n",
+                      mlxfw_fsm_state_err_str[fsm_state_err]);
++#ifdef HAVE_NETLINK_EXT_ACK
+               NL_SET_ERR_MSG_MOD(extack, "Firmware flash failed");
++#endif
+               return -EINVAL;
+       }
+       if (curr_fsm_state != fsm_state) {
+               if (--times == 0) {
+                       pr_err("Timeout reached on FSM state change");
++#ifdef HAVE_NETLINK_EXT_ACK
+                       NL_SET_ERR_MSG_MOD(extack, "Timeout reached on FSM state change");
++#endif
+                       return -ETIMEDOUT;
+               }
+               msleep(MLXFW_FSM_STATE_WAIT_CYCLE_MS);
+@@ -87,10 +96,16 @@ retry:
+ #define MLXFW_ALIGN_UP(x, align_bits) \
+               MLXFW_ALIGN_DOWN((x) + ((1 << (align_bits)) - 1), (align_bits))
++#ifdef HAVE_NETLINK_EXT_ACK
+ static int mlxfw_flash_component(struct mlxfw_dev *mlxfw_dev,
+                                u32 fwhandle,
+                                struct mlxfw_mfa2_component *comp,
+                                struct netlink_ext_ack *extack)
++#else
++static int mlxfw_flash_component(struct mlxfw_dev *mlxfw_dev,
++                               u32 fwhandle,
++                               struct mlxfw_mfa2_component *comp)
++#endif
+ {
+       u16 comp_max_write_size;
+       u8 comp_align_bits;
+@@ -113,7 +128,9 @@ static int mlxfw_flash_component(struct mlxfw_dev *mlxfw_dev,
+       if (comp->data_size > comp_max_size) {
+               pr_err("Component %d is of size %d which is bigger than limit %d\n",
+                      comp->index, comp->data_size, comp_max_size);
++#ifdef HAVE_NETLINK_EXT_ACK
+               NL_SET_ERR_MSG_MOD(extack, "Component is bigger than limit");
++#endif
+               return -EINVAL;
+       }
+@@ -129,7 +146,11 @@ static int mlxfw_flash_component(struct mlxfw_dev *mlxfw_dev,
+               return err;
+       err = mlxfw_fsm_state_wait(mlxfw_dev, fwhandle,
++#ifdef HAVE_NETLINK_EXT_ACK
+                                  MLXFW_FSM_STATE_DOWNLOAD, extack);
++#else
++                                 MLXFW_FSM_STATE_DOWNLOAD);
++#endif
+       if (err)
+               goto err_out;
+@@ -160,7 +181,11 @@ static int mlxfw_flash_component(struct mlxfw_dev *mlxfw_dev,
+               goto err_out;
+       err = mlxfw_fsm_state_wait(mlxfw_dev, fwhandle,
++#ifdef HAVE_NETLINK_EXT_ACK
+                                  MLXFW_FSM_STATE_LOCKED, extack);
++#else
++                                 MLXFW_FSM_STATE_LOCKED);
++#endif
+       if (err)
+               goto err_out;
+       return 0;
+@@ -170,9 +195,14 @@ err_out:
+       return err;
+ }
++#ifdef HAVE_NETLINK_EXT_ACK
+ static int mlxfw_flash_components(struct mlxfw_dev *mlxfw_dev, u32 fwhandle,
+                                 struct mlxfw_mfa2_file *mfa2_file,
+                                 struct netlink_ext_ack *extack)
++#else
++static int mlxfw_flash_components(struct mlxfw_dev *mlxfw_dev, u32 fwhandle,
++                                struct mlxfw_mfa2_file *mfa2_file)
++#endif
+ {
+       u32 component_count;
+       int err;
+@@ -183,7 +213,9 @@ static int mlxfw_flash_components(struct mlxfw_dev *mlxfw_dev, u32 fwhandle,
+                                             &component_count);
+       if (err) {
+               pr_err("Could not find device PSID in MFA2 file\n");
++#ifdef HAVE_NETLINK_EXT_ACK
+               NL_SET_ERR_MSG_MOD(extack, "Could not find device PSID in MFA2 file");
++#endif
+               return err;
+       }
+@@ -196,7 +228,11 @@ static int mlxfw_flash_components(struct mlxfw_dev *mlxfw_dev, u32 fwhandle,
+                       return PTR_ERR(comp);
+               pr_info("Flashing component type %d\n", comp->index);
++#ifdef HAVE_NETLINK_EXT_ACK
+               err = mlxfw_flash_component(mlxfw_dev, fwhandle, comp, extack);
++#else
++              err = mlxfw_flash_component(mlxfw_dev, fwhandle, comp);
++#endif
+               mlxfw_mfa2_file_component_put(comp);
+               if (err)
+                       return err;
+@@ -204,9 +240,14 @@ static int mlxfw_flash_components(struct mlxfw_dev *mlxfw_dev, u32 fwhandle,
+       return 0;
+ }
++#ifdef HAVE_NETLINK_EXT_ACK
+ int mlxfw_firmware_flash(struct mlxfw_dev *mlxfw_dev,
+                        const struct firmware *firmware,
+                        struct netlink_ext_ack *extack)
++#else
++int mlxfw_firmware_flash(struct mlxfw_dev *mlxfw_dev,
++                       const struct firmware *firmware)
++#endif
+ {
+       struct mlxfw_mfa2_file *mfa2_file;
+       u32 fwhandle;
+@@ -214,7 +255,9 @@ int mlxfw_firmware_flash(struct mlxfw_dev *mlxfw_dev,
+       if (!mlxfw_mfa2_check(firmware)) {
+               pr_err("Firmware file is not MFA2\n");
++#ifdef HAVE_NETLINK_EXT_ACK
+               NL_SET_ERR_MSG_MOD(extack, "Firmware file is not MFA2");
++#endif
+               return -EINVAL;
+       }
+@@ -228,16 +271,26 @@ int mlxfw_firmware_flash(struct mlxfw_dev *mlxfw_dev,
+       err = mlxfw_dev->ops->fsm_lock(mlxfw_dev, &fwhandle);
+       if (err) {
+               pr_err("Could not lock the firmware FSM\n");
++#ifdef HAVE_NETLINK_EXT_ACK
+               NL_SET_ERR_MSG_MOD(extack, "Could not lock the firmware FSM");
++#endif
+               goto err_fsm_lock;
+       }
+       err = mlxfw_fsm_state_wait(mlxfw_dev, fwhandle,
++#ifdef HAVE_NETLINK_EXT_ACK
+                                  MLXFW_FSM_STATE_LOCKED, extack);
++#else
++                                 MLXFW_FSM_STATE_LOCKED);
++#endif
+       if (err)
+               goto err_state_wait_idle_to_locked;
++#ifdef HAVE_NETLINK_EXT_ACK
+       err = mlxfw_flash_components(mlxfw_dev, fwhandle, mfa2_file, extack);
++#else
++      err = mlxfw_flash_components(mlxfw_dev, fwhandle, mfa2_file);
++#endif
+       if (err)
+               goto err_flash_components;
+@@ -246,12 +299,18 @@ int mlxfw_firmware_flash(struct mlxfw_dev *mlxfw_dev,
+       err = mlxfw_dev->ops->fsm_activate(mlxfw_dev, fwhandle);
+       if (err) {
+               pr_err("Could not activate the downloaded image\n");
++#ifdef HAVE_NETLINK_EXT_ACK
+               NL_SET_ERR_MSG_MOD(extack, "Could not activate the downloaded image");
++#endif
+               goto err_fsm_activate;
+       }
+       err = mlxfw_fsm_state_wait(mlxfw_dev, fwhandle,
++#ifdef HAVE_NETLINK_EXT_ACK
+                                  MLXFW_FSM_STATE_LOCKED, extack);
++#else
++                                 MLXFW_FSM_STATE_LOCKED);
++#endif
+       if (err)
+               goto err_state_wait_activate_to_locked;
+diff --git a/drivers/net/ethernet/mellanox/mlxfw/mlxfw_mfa2.c b/drivers/net/ethernet/mellanox/mlxfw/mlxfw_mfa2.c
+index xxxxxxx..xxxxxxx 100644
+--- a/drivers/net/ethernet/mellanox/mlxfw/mlxfw_mfa2.c
++++ b/drivers/net/ethernet/mellanox/mlxfw/mlxfw_mfa2.c
+@@ -1,6 +1,9 @@
+ // SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0
+ /* Copyright (c) 2017-2019 Mellanox Technologies. All rights reserved */
++#ifdef pr_fmt
++#undef pr_fmt
++#endif
+ #define pr_fmt(fmt) "mlxfw_mfa2: " fmt
+ #include <linux/kernel.h>