[mellanox] Use 'mlxfwmanager -l' for extracting available firmware version from FW images (#5915)

Signed-off-by: Andriy Yurkiv <ayurkiv@nvidia.com>
This commit is contained in:
Andriy Yurkiv 2020-12-01 18:15:28 +02:00 committed by GitHub
parent 112eb08f39
commit b125401fee
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 26 deletions

View File

@ -36,11 +36,6 @@ endif
MLNX_FILES += $(MLNX_FW_FILES) MLNX_FILES += $(MLNX_FW_FILES)
export MLNX_SPC_FW_VERSION
export MLNX_SPC_FW_FILE export MLNX_SPC_FW_FILE
export MLNX_SPC2_FW_VERSION
export MLNX_SPC2_FW_FILE export MLNX_SPC2_FW_FILE
export MLNX_SPC3_FW_VERSION
export MLNX_SPC3_FW_FILE export MLNX_SPC3_FW_FILE

View File

@ -19,9 +19,11 @@ declare -r EXIT_SUCCESS="0"
declare -r EXIT_FAILURE="1" declare -r EXIT_FAILURE="1"
declare -r QUERY_CMD="mlxfwmanager --query" declare -r QUERY_CMD="mlxfwmanager --query"
declare -r LIST_CONTENT_CMD="mlxfwmanager --list-content"
declare -r BURN_CMD="mlxfwmanager -u -f -y" declare -r BURN_CMD="mlxfwmanager -u -f -y"
declare -r QUERY_FILE="/tmp/mlxfwmanager-query.log" 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 SPC1_ASIC="spc1"
declare -r SPC2_ASIC="spc2" declare -r SPC2_ASIC="spc2"
@ -33,11 +35,6 @@ declare -rA FW_FILE_MAP=( \
[$SPC2_ASIC]="/etc/mlnx/fw-SPC2.mfa" \ [$SPC2_ASIC]="/etc/mlnx/fw-SPC2.mfa" \
[$SPC3_ASIC]="/etc/mlnx/fw-SPC3.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}" IMAGE_UPGRADE="${NO_PARAM}"
VERBOSE_LEVEL="${VERBOSE_MIN}" VERBOSE_LEVEL="${VERBOSE_MIN}"
@ -180,25 +177,23 @@ function UpgradeFW() {
if [ ! -z "${_FS_MOUNTPOINT}" ]; then if [ ! -z "${_FS_MOUNTPOINT}" ]; then
local -r _FW_FILE="${_FS_MOUNTPOINT}/${FW_FILE_MAP[$_ASIC_TYPE]}" local -r _FW_FILE="${_FS_MOUNTPOINT}/${FW_FILE_MAP[$_ASIC_TYPE]}"
else
local -r _FW_FILE="${FW_FILE_MAP[$_ASIC_TYPE]}"
fi
if [ ! -f "${_FW_FILE}" ]; then if [ ! -f "${_FW_FILE}" ]; then
ExitFailure "no such file: ${_FW_FILE}" ExitFailure "no such file: ${_FW_FILE}"
fi fi
RunCmd "${QUERY_CMD} -i ${_FW_FILE} -L ${QUERY_FILE}" &>/dev/null 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' ')"
local -r _FW_INFO="$(grep FW ${QUERY_FILE})" RunCmd "${LIST_CONTENT_CMD} -i ${_FW_FILE} -o ${LIST_CONTENT_FILE}"
local -r _FW_CURRENT="$(echo ${_FW_INFO} | cut -f2 -d' ')" local -r _FW_AVAILABLE_INFO="$(grep ${_PSID} ${LIST_CONTENT_FILE})"
local -r _FW_AVAILABLE="$(echo ${_FW_INFO} | cut -f3 -d' ')" local -r _FW_AVAILABLE="$(echo ${_FW_AVAILABLE_INFO} | cut -f4 -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 [[ -z "${_FW_CURRENT}" ]]; then if [[ -z "${_FW_CURRENT}" ]]; then
ExitFailure "could not retreive current FW version" ExitFailure "could not retreive current FW version"