Skip to content

Commit 9f767a7

Browse files
committed
Nvidia: FW: Add an ability to control ASIC FW
* Add an ability to enable/disable FW auto-update. * Add an ability to set firmware source like: image, user. User defined fw image location should be the next: /host/mlnx/asic/fw.mfa Signed-off-by: Yevhen Fastiuk <yfastiuk@nvidia.com>
1 parent f35e6c2 commit 9f767a7

File tree

3 files changed

+61
-12
lines changed

3 files changed

+61
-12
lines changed

files/build_templates/init_cfg.json.j2

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,4 +109,13 @@
109109
"special_class": "true"
110110
}
111111
}
112+
{% if sonic_asic_platform == 'mellanox' %}
113+
,
114+
"FIRMWARE": {
115+
"asic": {
116+
"auto_update": "enable",
117+
"default": "image"
118+
}
119+
}
120+
{% endif %}
112121
}

platform/mellanox/mlnx-fw-upgrade.j2

Lines changed: 51 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -181,17 +181,33 @@ function RunCmd() {
181181
}
182182

183183
function UpgradeFW() {
184-
local -r _FS_MOUNTPOINT="$1"
184+
# Parse arguments
185+
while [ "$#" -ge "1" ]; do
186+
case "$1" in
187+
--from-file)
188+
local -r INSTALL_FROM_FILE="${YES_PARAM}"
189+
local -r _FW_USER_FILE="$2"
190+
shift
191+
;;
192+
esac
193+
shift
194+
done
185195

186-
local -r _ASIC_TYPE="$(GetAsicType)"
187-
if [[ "${_ASIC_TYPE}" = "${UNKN_ASIC}" ]]; then
188-
ExitFailure "failed to detect ASIC type"
189-
fi
196+
local -r _FS_MOUNTPOINT="$1"
190197

191-
if [ ! -z "${_FS_MOUNTPOINT}" ]; then
192-
local -r _FW_FILE="${_FS_MOUNTPOINT}/${FW_FILE_MAP[$_ASIC_TYPE]}"
198+
if [ "${INSTALL_FROM_FILE}" = "${YES_PARAM}" ]; then
199+
local -r _FW_FILE="${_FW_USER_FILE}"
193200
else
194-
local -r _FW_FILE="${FW_FILE_MAP[$_ASIC_TYPE]}"
201+
local -r _ASIC_TYPE="$(GetAsicType)"
202+
if [[ "${_ASIC_TYPE}" = "${UNKN_ASIC}" ]]; then
203+
ExitFailure "failed to detect ASIC type"
204+
fi
205+
206+
if [ ! -z "${_FS_MOUNTPOINT}" ]; then
207+
local -r _FW_FILE="${_FS_MOUNTPOINT}/${FW_FILE_MAP[$_ASIC_TYPE]}"
208+
else
209+
local -r _FW_FILE="${FW_FILE_MAP[$_ASIC_TYPE]}"
210+
fi
195211
fi
196212

197213
if [ ! -f "${_FW_FILE}" ]; then
@@ -250,22 +266,46 @@ function UpgradeFWFromImage() {
250266
fi
251267
}
252268

269+
function UpgradeFWFromFile() {
270+
local -r _FW_USER_FILE="/host/mlnx/asic/fw.mfa"
271+
272+
if [ ! -f "${_FW_USER_FILE}" ]; then
273+
LogWarning "User defined ASIC firmware file not installed"
274+
ExitFailure "Failed to upgrade ASIC firmware"
275+
fi
276+
277+
UpgradeFW --from-file "${_FW_USER_FILE}"
278+
}
279+
253280
function ExitIfQEMU() {
254281
if [ -n "$(lspci -vvv | grep SimX)" ]; then
255282
ExitSuccess "No FW upgrade for SimX platform"
256283
fi
257284
}
258285

286+
function ExitIfAutoUpdateDisabled() {
287+
local -r AUSTATE="$(sonic-cfggen -d -v FIRMWARE[\'asic\'][\'auto_update\'])"
288+
if [[ "${AUSTATE}" == "disable" ]]; then
289+
ExitSuccess "FW auto update disabled. Firmware won't be upgrade"
290+
fi
291+
}
292+
259293
ParseArguments "$@"
260294

261295
ExitIfQEMU
296+
ExitIfAutoUpdateDisabled
262297

263298
WaitForDevice
264299

265-
if [ "${IMAGE_UPGRADE}" != "${YES_PARAM}" ]; then
266-
UpgradeFW
300+
DEFAULT_SOURCE="$(sonic-cfggen -d -v FIRMWARE[\'asic\'][\'default\'])"
301+
if [ "${DEFAULT_SOURCE}" != "user" ]; then
302+
if [ "${IMAGE_UPGRADE}" != "${YES_PARAM}" ]; then
303+
UpgradeFW
304+
else
305+
UpgradeFWFromImage
306+
fi
267307
else
268-
UpgradeFWFromImage
308+
UpgradeFWFromFile
269309
fi
270310

271311
ExitSuccess "firmware upgrade is completed"

src/sonic-swss-common

0 commit comments

Comments
 (0)