Skip to content

Commit 4cc84c6

Browse files
authored
[Mellanox] Improve FW upgrade logging (#13465)
- Why I did it To improve ASIC FW upgrade logging and have information about the cause of FW update failure in the log. - How I did it Added syslog logger support In case the FW update has failed the update tool will give the cause of the failure in the output in the last line, starting with "Fail". When running the tool, in case of a failed update, we will parse the output to retrieve the cause and log it. Device #1: ---------- Device Type: ConnectX6DX Part Number: MCX623106AN-CDA_Ax Description: ConnectX-6 Dx EN adapter card; 100GbE; Dual-port QSFP56; PCIe 4.0/3.0 x16; PSID: MT_0000000359 PCI Device Name: /dev/mst/mt4125_pciconf0 Base GUID: 0c42a103007d22d4 Base MAC: 0c42a17d22d4 Versions: Current Available FW 22.32.0498 22.32.0498 PXE 3.6.0500 3.6.0500 UEFI 14.25.0015 14.25.0015 Status: Forced update required --------- Found 1 device(s) requiring firmware update... Device #1: Updating FW ... FSMST_INITIALIZE - OK Writing Boot image component - OK Fail : The Digest in the signature is wrong - How to verify it mlnx-fw-upgrade.sh --upgrade
1 parent 9a49aec commit 4cc84c6

File tree

1 file changed

+43
-3
lines changed

1 file changed

+43
-3
lines changed

platform/mellanox/mlnx-fw-upgrade.j2

+43-3
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ declare -rA FW_FILE_MAP=( \
4040
)
4141

4242
IMAGE_UPGRADE="${NO_PARAM}"
43+
SYSLOG_LOGGER="${NO_PARAM}"
4344
VERBOSE_LEVEL="${VERBOSE_MIN}"
4445

4546
function PrintHelp() {
@@ -48,7 +49,8 @@ function PrintHelp() {
4849
echo
4950
echo "OPTIONS:"
5051
echo " -u, --upgrade Upgrade ASIC firmware using next boot image (useful after SONiC-To-SONiC update)"
51-
echo " -v, --verbose Verbose mode"
52+
echo " -s, --syslog Use syslog logger (enabled when -u|--upgrade)"
53+
echo " -v, --verbose Verbose mode (enabled when -u|--upgrade)"
5254
echo " -h, --help Print help"
5355
echo
5456
echo "Examples:"
@@ -63,10 +65,14 @@ function ParseArguments() {
6365
case "$1" in
6466
-u|--upgrade)
6567
IMAGE_UPGRADE="${YES_PARAM}"
68+
SYSLOG_LOGGER="${YES_PARAM}"
6669
;;
6770
-v|--verbose)
6871
VERBOSE_LEVEL="${VERBOSE_MAX}"
6972
;;
73+
-s|--syslog)
74+
SYSLOG_LOGGER="${YES_PARAM}"
75+
;;
7076
-h|--help)
7177
PrintHelp
7278
exit "${EXIT_SUCCESS}"
@@ -79,25 +85,42 @@ function ParseArguments() {
7985
function LogError() {
8086
if [[ "${VERBOSE_LEVEL}" -ge "${VERBOSE_ERROR}" ]]; then
8187
echo "ERROR: $*"
88+
logger -p "ERROR" -t "${SCRIPT_NAME}" "$*"
89+
fi
90+
91+
if [[ "${SYSLOG_LOGGER}" = "${YES_PARAM}" ]]; then
92+
logger -p "ERROR" -t "${SCRIPT_NAME}" "$*"
8293
fi
8394
}
8495

8596
function LogWarning() {
8697
if [[ "${VERBOSE_LEVEL}" -ge "${VERBOSE_WARNING}" ]]; then
8798
echo "WARNING: $*"
8899
fi
100+
101+
if [[ "${SYSLOG_LOGGER}" = "${YES_PARAM}" ]]; then
102+
logger -p "WARNING" -t "${SCRIPT_NAME}" "$*"
103+
fi
89104
}
90105

91106
function LogNotice() {
92107
if [[ "${VERBOSE_LEVEL}" -ge "${VERBOSE_NOTICE}" ]]; then
93108
echo "NOTICE: $*"
94109
fi
110+
111+
if [[ "${SYSLOG_LOGGER}" = "${YES_PARAM}" ]]; then
112+
logger -p "NOTICE" -t "${SCRIPT_NAME}" "$*"
113+
fi
95114
}
96115

97116
function LogInfo() {
98117
if [[ "${VERBOSE_LEVEL}" -ge "${VERBOSE_INFO}" ]]; then
99118
echo "INFO: $*"
100119
fi
120+
121+
if [[ "${SYSLOG_LOGGER}" = "${YES_PARAM}" ]]; then
122+
logger -p "INFO" -t "${SCRIPT_NAME}" "$*"
123+
fi
101124
}
102125

103126
function ExitFailure() {
@@ -186,6 +209,23 @@ function RunCmd() {
186209
fi
187210
}
188211

212+
function RunFwUpdateCmd() {
213+
local ERROR_CODE="${EXIT_SUCCESS}"
214+
local COMMAND="${BURN_CMD} $@"
215+
216+
if [[ "${VERBOSE_LEVEL}" -eq "${VERBOSE_MAX}" ]]; then
217+
output=$(eval "${COMMAND}")
218+
else
219+
output=$(eval "${COMMAND}") >/dev/null 2>&1
220+
fi
221+
222+
ERROR_CODE="$?"
223+
if [[ "${ERROR_CODE}" != "${EXIT_SUCCESS}" ]]; then
224+
failure_msg="${output#*Fail : }"
225+
ExitFailure "FW Update command: ${COMMAND} failed with error: ${failure_msg}"
226+
fi
227+
}
228+
189229
function UpgradeFW() {
190230
local -r _FS_MOUNTPOINT="$1"
191231

@@ -229,9 +269,9 @@ function UpgradeFW() {
229269
local -r _MST_DEVICE="$(GetMstDevice)"
230270
if [[ "${_MST_DEVICE}" = "${UNKN_MST}" ]]; then
231271
LogWarning "could not find fastest mst device, using default device"
232-
RunCmd "${BURN_CMD} -i ${_FW_FILE}"
272+
RunFwUpdateCmd "-i ${_FW_FILE}"
233273
else
234-
RunCmd "${BURN_CMD} -d ${_MST_DEVICE} -i ${_FW_FILE}"
274+
RunFwUpdateCmd "-d ${_MST_DEVICE} -i ${_FW_FILE}"
235275
fi
236276
fi
237277
}

0 commit comments

Comments
 (0)