From 088c240079c1f62d7fff8ba6d7f7c75a00cb977c Mon Sep 17 00:00:00 2001 From: liora Date: Thu, 21 Jan 2021 17:37:56 +0000 Subject: [PATCH 1/3] [mellanox] Use 'mlxfwmanager -d' for specifying MST device in FW burn operation. --- platform/mellanox/mlnx-fw-upgrade.j2 | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/platform/mellanox/mlnx-fw-upgrade.j2 b/platform/mellanox/mlnx-fw-upgrade.j2 index 69f3d621cc44..1066556a8ff0 100755 --- a/platform/mellanox/mlnx-fw-upgrade.j2 +++ b/platform/mellanox/mlnx-fw-upgrade.j2 @@ -36,6 +36,12 @@ declare -rA FW_FILE_MAP=( \ [$SPC3_ASIC]="/etc/mlnx/fw-SPC3.mfa" \ ) +declare -rA MST_DEVICE_MAP=( \ + [$SPC1_ASIC]="/dev/mst/mt52100_pci_cr0" \ + [$SPC2_ASIC]="/dev/mst/mt53100_pci_cr0" \ + [$SPC3_ASIC]="/dev/mst/mt53104_pci_cr0" \ +) + IMAGE_UPGRADE="${NO_PARAM}" VERBOSE_LEVEL="${VERBOSE_MIN}" @@ -175,6 +181,11 @@ function UpgradeFW() { ExitFailure "failed to detect ASIC type" fi + local -r _MST_DEVICE="${MST_DEVICE_MAP[$_ASIC_TYPE]}" + if [ ! -c "${_MST_DEVICE}" ]; then + ExitFailure "no such device: ${_MST_DEVICE}" + fi + if [ ! -z "${_FS_MOUNTPOINT}" ]; then local -r _FW_FILE="${_FS_MOUNTPOINT}/${FW_FILE_MAP[$_ASIC_TYPE]}" else @@ -207,7 +218,7 @@ function UpgradeFW() { ExitSuccess "firmware is up to date" else LogNotice "firmware upgrade is required. Installing compatible version..." - RunCmd "${BURN_CMD} -i ${_FW_FILE}" + RunCmd "${BURN_CMD} -d ${_MST_DEVICE} -i ${_FW_FILE}" fi } From 0c36cdd81f1fb2808621647b2a339401d879cead Mon Sep 17 00:00:00 2001 From: liora Date: Thu, 21 Jan 2021 17:49:37 +0000 Subject: [PATCH 2/3] Revert "[mellanox] Use 'mlxfwmanager -d' for specifying MST device in FW burn operation." This reverts commit 088c240079c1f62d7fff8ba6d7f7c75a00cb977c. --- platform/mellanox/mlnx-fw-upgrade.j2 | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/platform/mellanox/mlnx-fw-upgrade.j2 b/platform/mellanox/mlnx-fw-upgrade.j2 index 1066556a8ff0..69f3d621cc44 100755 --- a/platform/mellanox/mlnx-fw-upgrade.j2 +++ b/platform/mellanox/mlnx-fw-upgrade.j2 @@ -36,12 +36,6 @@ declare -rA FW_FILE_MAP=( \ [$SPC3_ASIC]="/etc/mlnx/fw-SPC3.mfa" \ ) -declare -rA MST_DEVICE_MAP=( \ - [$SPC1_ASIC]="/dev/mst/mt52100_pci_cr0" \ - [$SPC2_ASIC]="/dev/mst/mt53100_pci_cr0" \ - [$SPC3_ASIC]="/dev/mst/mt53104_pci_cr0" \ -) - IMAGE_UPGRADE="${NO_PARAM}" VERBOSE_LEVEL="${VERBOSE_MIN}" @@ -181,11 +175,6 @@ function UpgradeFW() { ExitFailure "failed to detect ASIC type" fi - local -r _MST_DEVICE="${MST_DEVICE_MAP[$_ASIC_TYPE]}" - if [ ! -c "${_MST_DEVICE}" ]; then - ExitFailure "no such device: ${_MST_DEVICE}" - fi - if [ ! -z "${_FS_MOUNTPOINT}" ]; then local -r _FW_FILE="${_FS_MOUNTPOINT}/${FW_FILE_MAP[$_ASIC_TYPE]}" else @@ -218,7 +207,7 @@ function UpgradeFW() { ExitSuccess "firmware is up to date" else LogNotice "firmware upgrade is required. Installing compatible version..." - RunCmd "${BURN_CMD} -d ${_MST_DEVICE} -i ${_FW_FILE}" + RunCmd "${BURN_CMD} -i ${_FW_FILE}" fi } From 5ebb9ca8a8b0119a07a08b8608df00049e7583c0 Mon Sep 17 00:00:00 2001 From: liora Date: Thu, 21 Jan 2021 17:58:41 +0000 Subject: [PATCH 3/3] [Mellanox] Use 'mlxfwmanager -d' for specifying MST device in FW burn operation. --- platform/mellanox/mlnx-fw-upgrade.j2 | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/platform/mellanox/mlnx-fw-upgrade.j2 b/platform/mellanox/mlnx-fw-upgrade.j2 index 69f3d621cc44..245ce75d5f18 100755 --- a/platform/mellanox/mlnx-fw-upgrade.j2 +++ b/platform/mellanox/mlnx-fw-upgrade.j2 @@ -29,6 +29,7 @@ declare -r SPC1_ASIC="spc1" declare -r SPC2_ASIC="spc2" declare -r SPC3_ASIC="spc3" declare -r UNKN_ASIC="unknown" +declare -r UNKN_MST="unknown" declare -rA FW_FILE_MAP=( \ [$SPC1_ASIC]="/etc/mlnx/fw-SPC.mfa" \ @@ -152,6 +153,18 @@ function GetAsicType() { exit "${EXIT_FAILURE}" } +function GetMstDevice() { + local _MST_DEVICE="$(ls /dev/mst/*_pci_cr0 2>&1)" + + if [[ ! -c "${_MST_DEVICE}" ]]; then + echo "${UNKN_MST}" + else + echo "${_MST_DEVICE}" + fi + + exit "${EXIT_SUCCESS}" +} + function RunCmd() { local ERROR_CODE="${EXIT_SUCCESS}" @@ -207,7 +220,13 @@ function UpgradeFW() { ExitSuccess "firmware is up to date" else LogNotice "firmware upgrade is required. Installing compatible version..." - RunCmd "${BURN_CMD} -i ${_FW_FILE}" + local -r _MST_DEVICE="$(GetMstDevice)" + if [[ "${_MST_DEVICE}" = "${UNKN_MST}" ]]; then + LogWarning "could not find fastest mst device, using default device" + RunCmd "${BURN_CMD} -i ${_FW_FILE}" + else + RunCmd "${BURN_CMD} -d ${_MST_DEVICE} -i ${_FW_FILE}" + fi fi }