Skip to content

Commit

Permalink
[Mellanox] Use the explicit mst device of SPC during fw-upgrade
Browse files Browse the repository at this point in the history
Signed-off-by: Vivek Reddy <vkarri@nvidia.com>
  • Loading branch information
vivekrnv committed May 3, 2024
1 parent ca25b3b commit 09d4c8b
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions platform/mellanox/mlnx-fw-upgrade.j2
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -163,20 +166,20 @@ 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="$?"
if [[ "${ERROR_CODE}" != "${EXIT_SUCCESS}" ]]; then
# 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
}

Expand Down Expand Up @@ -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}"
Expand Down Expand Up @@ -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}")

Expand Down Expand Up @@ -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' ')"

Expand All @@ -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}"
Expand Down

0 comments on commit 09d4c8b

Please sign in to comment.