From 09d4c8b7dde16c41eb22628f5505b022ecf6b167 Mon Sep 17 00:00:00 2001 From: Vivek Reddy Date: Fri, 3 May 2024 05:02:34 +0000 Subject: [PATCH] [Mellanox] Use the explicit mst device of SPC during fw-upgrade Signed-off-by: Vivek Reddy --- platform/mellanox/mlnx-fw-upgrade.j2 | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/platform/mellanox/mlnx-fw-upgrade.j2 b/platform/mellanox/mlnx-fw-upgrade.j2 index 7a36a2ebd92d..5a398ba331df 100755 --- a/platform/mellanox/mlnx-fw-upgrade.j2 +++ b/platform/mellanox/mlnx-fw-upgrade.j2 @@ -1,10 +1,13 @@ {#- - Copyright (c) 2020-2023 NVIDIA CORPORATION & AFFILIATES. + Copyright (c) 2024 NVIDIA CORPORATION & AFFILIATES. Apache-2.0 + Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + http://www.apache.org/licenses/LICENSE-2.0 + Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -163,12 +166,12 @@ function WaitForDevice() { local -i QUERY_RETRY_COUNT_MAX="10" local -i QUERY_RETRY_COUNT="0" - ${QUERY_CMD} > /dev/null + ${QUERY_CMD} -d $(GetSPCMstDevice) > /dev/null while [[ ("${QUERY_RETRY_COUNT}" -lt "${QUERY_RETRY_COUNT_MAX}") && ("$?" -ne "${EXIT_SUCCESS}") ]]; do sleep 1s ((QUERY_RETRY_COUNT++)) - output=$(eval ${MFT_DIAGNOSIS_FLAGS} ${QUERY_CMD}) > /dev/null + output=$(eval ${MFT_DIAGNOSIS_FLAGS} ${QUERY_CMD} -d $(GetSPCMstDevice)) > /dev/null done ERROR_CODE="$?" @@ -176,7 +179,7 @@ function WaitForDevice() { # Exit failure and print the detailed information echo "$output" failure_msg="${output#*Fail : }" - ExitFailure "FW Query command: ${QUERY_CMD} failed to wait for device with error: ${failure_msg}" + ExitFailure "FW Query command: ${QUERY_CMD} -d $(GetSPCMstDevice) failed to wait for device with error: ${failure_msg}" fi } @@ -206,8 +209,10 @@ function GetAsicType() { exit "${EXIT_FAILURE}" } -function GetMstDevice() { - local _MST_DEVICE="$(ls /dev/mst/*_pci_cr0 2>&1)" +function GetSPCMstDevice() { + # mt5????_pci_cr0 -> Spectrum Family + # mt5??_pci_cr0 -> Bluefield + local _MST_DEVICE="$(ls /dev/mst/mt5????_pci_cr0 2>&1)" if [[ ! -c "${_MST_DEVICE}" ]]; then echo "${UNKN_MST}" @@ -247,7 +252,7 @@ function RunFwUpdateCmd() { if [[ "${ERROR_CODE}" == "${FW_ALREADY_UPDATED_FAILURE}" ]]; then LogInfo "FW reactivation is required. Reactivating and updating FW ..." - local -r _MST_DEVICE="$(GetMstDevice)" + local -r _MST_DEVICE="$(GetSPCMstDevice)" local -r _CMD="flint -d ${_MST_DEVICE} ir" output=$(eval "${_CMD}") @@ -285,13 +290,13 @@ function UpgradeFW() { ExitFailure "no such file: ${_FW_FILE}" fi - RunCmd "${QUERY_CMD} -o ${QUERY_FILE}" + RunCmd "${QUERY_CMD} -d $(GetSPCMstDevice) -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}" + RunCmd "${LIST_CONTENT_CMD} -i ${_FW_FILE} -o ${LIST_CONTENT_FILE} -d $(GetSPCMstDevice)" local -r _FW_AVAILABLE_INFO="$(grep ${_PSID} ${LIST_CONTENT_FILE})" local -r _FW_AVAILABLE="$(echo ${_FW_AVAILABLE_INFO} | cut -f4 -d' ')" @@ -307,7 +312,7 @@ function UpgradeFW() { ExitSuccess "firmware is up to date" else LogNotice "firmware upgrade is required. Installing compatible version..." - local -r _MST_DEVICE="$(GetMstDevice)" + local -r _MST_DEVICE="$(GetSPCMstDevice)" if [[ "${_MST_DEVICE}" = "${UNKN_MST}" ]]; then LogWarning "could not find fastest mst device, using default device" RunFwUpdateCmd "-i ${_FW_FILE}"