Skip to content

Commit 84ea073

Browse files
[Mellanox] Add PCI ID detection for the mlnx-fw-upgrade.sh script (#24244)
- Why I did it Related to: #23505 Add support for detecting and storing device PCI address in asic_detect.sh: Add -p option to return PCI address (e.g., "06:00.0") Store PCI ID alongside device type for synchronization Re-detect if either cache file is missing Simplify firmware upgrade flow in mlnx-fw-upgrade.j2: Use asic_detect.sh -p to get PCI ID directly for MST device Simplify GetSPCMstDevice to directly use detected PCI address - How I did it Do not stop MST drivers from syncd.sh - How to verify it Run sonic-mgmt tests
1 parent 3ee939e commit 84ea073

File tree

3 files changed

+34
-17
lines changed

3 files changed

+34
-17
lines changed

files/scripts/syncd.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,6 @@ function stopplatform2() {
136136
if [[ x"$WARM_BOOT" != x"true" ]]; then
137137
if [ x$sonic_asic_platform == x'mellanox' ]; then
138138
/etc/init.d/sxdkernel stop
139-
/usr/bin/mst stop
140139
elif [ x"$sonic_asic_platform" == x"nvidia-bluefield" ]; then
141140
/usr/bin/bfnet.sh stop
142141
fi

platform/mellanox/asic_detect/asic_detect.sh

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,25 @@
1919

2020
SUCCESS_CODE=0
2121
RC=-1
22+
RETURN_PCI_ID=false
2223

23-
if [[ -f "/usr/bin/asic_detect/asic_type" ]]; then
24-
cat /usr/bin/asic_detect/asic_type
24+
# Parse command line arguments
25+
while getopts "p" opt; do
26+
case $opt in
27+
p)
28+
RETURN_PCI_ID=true
29+
;;
30+
*)
31+
;;
32+
esac
33+
done
34+
35+
if [[ -f "/usr/bin/asic_detect/asic_type" ]] && [[ -f "/usr/bin/asic_detect/asic_pci_id" ]]; then
36+
if [[ "$RETURN_PCI_ID" == true ]]; then
37+
cat /usr/bin/asic_detect/asic_pci_id
38+
else
39+
cat /usr/bin/asic_detect/asic_type
40+
fi
2541
exit $SUCCESS_CODE
2642
fi
2743

@@ -37,6 +53,7 @@ declare -A DEVICE_DICT=(
3753
TYPE_UNKNOWN="unknown"
3854
VENDOR_ID="15b3"
3955
DEVICE_TYPE=$TYPE_UNKNOWN
56+
DEVICE_PCI_ID=""
4057

4158
# bf3 should be the last device in the list
4259
DEVICE_ORDER=("cb84" "cf6c" "cf70" "cf80" "cf82" "a2dc")
@@ -46,12 +63,21 @@ if [[ -n "$lspci_output" ]]; then
4663
for key in "${DEVICE_ORDER[@]}"; do
4764
if echo "$lspci_output" | grep "$VENDOR_ID:$key" &>/dev/null; then
4865
DEVICE_TYPE="${DEVICE_DICT[$key]}"
66+
DEVICE_PCI_ID=$(echo "$lspci_output" | grep "$VENDOR_ID:$key" | awk '{print $1}')
4967
RC=$SUCCESS_CODE
5068
break
5169
fi
5270
done
5371
if [[ -n "$DEVICE_TYPE" ]]; then
54-
echo "$DEVICE_TYPE" | tee >( [[ "$DEVICE_TYPE" != "$TYPE_UNKNOWN" ]] && cat > /usr/bin/asic_detect/asic_type )
72+
if [[ "$RETURN_PCI_ID" == true ]]; then
73+
echo "$DEVICE_PCI_ID"
74+
else
75+
echo "$DEVICE_TYPE"
76+
fi
77+
if [[ "$DEVICE_TYPE" != "$TYPE_UNKNOWN" ]] && [[ -n "$DEVICE_PCI_ID" ]]; then
78+
echo "$DEVICE_TYPE" > /usr/bin/asic_detect/asic_type
79+
echo "$DEVICE_PCI_ID" > /usr/bin/asic_detect/asic_pci_id
80+
fi
5581
fi
5682
exit $RC
5783
fi

platform/mellanox/mlnx-fw-upgrade.j2

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,9 @@ function PrintHelp() {
9090
echo "Examples:"
9191
echo " ./${SCRIPT_NAME} --verbose"
9292
echo " ./${SCRIPT_NAME} --upgrade"
93-
echo " ./${SCRIPT_NAME} --no-mst"
9493
{% if sonic_asic_platform == "nvidia-bluefield" %}
9594
echo " ./${SCRIPT_NAME} --reset"
95+
echo " ./${SCRIPT_NAME} --no-mst"
9696
{% endif %}
9797
echo " ./${SCRIPT_NAME} --help"
9898
echo
@@ -239,10 +239,6 @@ function WaitForDevice() {
239239
if [[ "${NO_MST}" != "${YES_PARAM}" ]]; then
240240
LogInfo "Restarting MST device"
241241
/usr/bin/mst restart --with_i2cdev
242-
ERROR_CODE="$?"
243-
if [[ "${ERROR_CODE}" != "${EXIT_SUCCESS}" ]]; then
244-
ExitFailure "MST device restart failed with error: ${ERROR_CODE}"
245-
fi
246242
fi
247243

248244
while : ; do
@@ -266,15 +262,11 @@ function WaitForDevice() {
266262
}
267263

268264
function GetSPCMstDevice() {
269-
local _DEVICE_TYPE=$(GetMstDeviceType)
270-
local _MST_DEVICE=$(${QUERY_XML} | xmlstarlet sel -t -m "//Device[contains(@type,'${_DEVICE_TYPE}')]" -v @pciName | head -n 1)
271-
272-
if [[ ! -c "${_MST_DEVICE}" ]]; then
273-
echo "${UNKN_MST}"
274-
else
275-
echo "${_MST_DEVICE}"
265+
local -r _ASIC_PCI_ID="$(/usr/bin/asic_detect/asic_detect.sh -p)"
266+
if [[ "${_ASIC_PCI_ID}" = "${UNKN_PCI_ID}" ]]; then
267+
ExitFailure "failed to detect ASIC PCI ID"
276268
fi
277-
269+
echo "${_ASIC_PCI_ID}"
278270
exit "${EXIT_SUCCESS}"
279271
}
280272

0 commit comments

Comments
 (0)