From b125401fee264a59096fd266a1385b21623b2242 Mon Sep 17 00:00:00 2001 From: Andriy Yurkiv <70649192+ayurkiv-nvda@users.noreply.github.com> Date: Tue, 1 Dec 2020 18:15:28 +0200 Subject: [PATCH] [mellanox] Use 'mlxfwmanager -l' for extracting available firmware version from FW images (#5915) Signed-off-by: Andriy Yurkiv --- platform/mellanox/fw.mk | 5 ---- platform/mellanox/mlnx-fw-upgrade.j2 | 37 ++++++++++++---------------- 2 files changed, 16 insertions(+), 26 deletions(-) diff --git a/platform/mellanox/fw.mk b/platform/mellanox/fw.mk index 05e7ca7cc0..4eccd9e882 100644 --- a/platform/mellanox/fw.mk +++ b/platform/mellanox/fw.mk @@ -36,11 +36,6 @@ endif MLNX_FILES += $(MLNX_FW_FILES) -export MLNX_SPC_FW_VERSION export MLNX_SPC_FW_FILE - -export MLNX_SPC2_FW_VERSION export MLNX_SPC2_FW_FILE - -export MLNX_SPC3_FW_VERSION export MLNX_SPC3_FW_FILE diff --git a/platform/mellanox/mlnx-fw-upgrade.j2 b/platform/mellanox/mlnx-fw-upgrade.j2 index c24c5b006f..69f3d621cc 100755 --- a/platform/mellanox/mlnx-fw-upgrade.j2 +++ b/platform/mellanox/mlnx-fw-upgrade.j2 @@ -19,9 +19,11 @@ declare -r EXIT_SUCCESS="0" declare -r EXIT_FAILURE="1" declare -r QUERY_CMD="mlxfwmanager --query" +declare -r LIST_CONTENT_CMD="mlxfwmanager --list-content" declare -r BURN_CMD="mlxfwmanager -u -f -y" declare -r QUERY_FILE="/tmp/mlxfwmanager-query.log" +declare -r LIST_CONTENT_FILE="/tmp/mlxfwmanager-list-content.log" declare -r SPC1_ASIC="spc1" declare -r SPC2_ASIC="spc2" @@ -33,11 +35,6 @@ declare -rA FW_FILE_MAP=( \ [$SPC2_ASIC]="/etc/mlnx/fw-SPC2.mfa" \ [$SPC3_ASIC]="/etc/mlnx/fw-SPC3.mfa" \ ) -declare -rA FW_REQUIRED_MAP=( \ - [$SPC1_ASIC]="{{ MLNX_SPC_FW_VERSION }}" \ - [$SPC2_ASIC]="{{ MLNX_SPC2_FW_VERSION }}" \ - [$SPC3_ASIC]="{{ MLNX_SPC3_FW_VERSION }}" \ -) IMAGE_UPGRADE="${NO_PARAM}" VERBOSE_LEVEL="${VERBOSE_MIN}" @@ -180,26 +177,24 @@ function UpgradeFW() { if [ ! -z "${_FS_MOUNTPOINT}" ]; then local -r _FW_FILE="${_FS_MOUNTPOINT}/${FW_FILE_MAP[$_ASIC_TYPE]}" - - if [ ! -f "${_FW_FILE}" ]; then - ExitFailure "no such file: ${_FW_FILE}" - fi - - RunCmd "${QUERY_CMD} -i ${_FW_FILE} -L ${QUERY_FILE}" &>/dev/null - - local -r _FW_INFO="$(grep FW ${QUERY_FILE})" - local -r _FW_CURRENT="$(echo ${_FW_INFO} | cut -f2 -d' ')" - local -r _FW_AVAILABLE="$(echo ${_FW_INFO} | cut -f3 -d' ')" else local -r _FW_FILE="${FW_FILE_MAP[$_ASIC_TYPE]}" - - RunCmd "${QUERY_CMD} -L ${QUERY_FILE}" &>/dev/null - - local -r _FW_INFO="$(grep FW ${QUERY_FILE})" - local -r _FW_CURRENT="$(echo ${_FW_INFO} | cut -f2 -d' ')" - local -r _FW_AVAILABLE="${FW_REQUIRED_MAP[$_ASIC_TYPE]}" fi + if [ ! -f "${_FW_FILE}" ]; then + ExitFailure "no such file: ${_FW_FILE}" + fi + + RunCmd "${QUERY_CMD} -o ${QUERY_FILE}" + local -r _FW_CURRENT_INFO="$(grep FW ${QUERY_FILE})" + local -r _FW_CURRENT="$(echo ${_FW_CURRENT_INFO} | cut -f2 -d' ')" + local -r _PSID_INFO="$(grep PSID ${QUERY_FILE})" + local -r _PSID="$(echo ${_PSID_INFO} | cut -f2 -d' ')" + + RunCmd "${LIST_CONTENT_CMD} -i ${_FW_FILE} -o ${LIST_CONTENT_FILE}" + local -r _FW_AVAILABLE_INFO="$(grep ${_PSID} ${LIST_CONTENT_FILE})" + local -r _FW_AVAILABLE="$(echo ${_FW_AVAILABLE_INFO} | cut -f4 -d' ')" + if [[ -z "${_FW_CURRENT}" ]]; then ExitFailure "could not retreive current FW version" fi