From 385d5d5623e16af96abb6503a0dd1704d959cb4f Mon Sep 17 00:00:00 2001 From: noaOrMlnx Date: Thu, 10 Jul 2025 16:34:33 +0300 Subject: [PATCH 1/6] [Mellanox] Add common asic_detect script and use if in mlnx-fw-upgrade.sh --- files/build_templates/docker_image_ctl.j2 | 1 + .../build_templates/sonic_debian_extension.j2 | 4 ++ platform/mellanox/asic_detect/asic_detect.sh | 28 +++++++++++ platform/mellanox/mlnx-fw-upgrade.j2 | 46 +------------------ 4 files changed, 35 insertions(+), 44 deletions(-) create mode 100644 platform/mellanox/asic_detect/asic_detect.sh diff --git a/files/build_templates/docker_image_ctl.j2 b/files/build_templates/docker_image_ctl.j2 index 4ca34262409..c7f9d507f34 100644 --- a/files/build_templates/docker_image_ctl.j2 +++ b/files/build_templates/docker_image_ctl.j2 @@ -682,6 +682,7 @@ start() { -v /tmp/nv-syncd-shared/:/tmp \ -v /dev/shm:/dev/shm:rw \ -v /var/log/sai_failure_dump:/var/log/sai_failure_dump:rw \ + -v /usr/bin/asic_detect:/usr/bin/asic_detect:rw \ -e SX_API_SOCKET_FILE=/var/run/sx_sdk/sx_api.sock \ {%- elif docker_container_name == "pmon" %} -v /var/run/hw-management:/var/run/hw-management:rw \ diff --git a/files/build_templates/sonic_debian_extension.j2 b/files/build_templates/sonic_debian_extension.j2 index 0fc41fd1ed0..76bca1adfff 100644 --- a/files/build_templates/sonic_debian_extension.j2 +++ b/files/build_templates/sonic_debian_extension.j2 @@ -1095,6 +1095,8 @@ sudo cp platform/mellanox/cmis_host_mgmt/cmis_host_mgmt.py $FILESYSTEM_ROOT/usr/ sudo chmod 755 $FILESYSTEM_ROOT/usr/bin/cmis_host_mgmt.py j2 platform/mellanox/mlnx-fw-upgrade.j2 | sudo tee $FILESYSTEM_ROOT/usr/bin/mlnx-fw-upgrade.sh sudo chmod 755 $FILESYSTEM_ROOT/usr/bin/mlnx-fw-upgrade.sh +sudo cp -r platform/mellanox/asic_detect $FILESYSTEM_ROOT/usr/bin/asic_detect +sudo chmod -R 777 $FILESYSTEM_ROOT/usr/bin/asic_detect/ # Install mlnx-sonic-platform Python 3 package install_pip_package {{mlnx_platform_api_py3_wheel_path}} @@ -1131,6 +1133,8 @@ done sudo install -m 755 platform/nvidia-bluefield/byo/sonic-byo.py $FILESYSTEM_ROOT/usr/bin/sonic-byo.py SONIC_PLATFORM={{sonic_asic_platform}} j2 platform/mellanox/mlnx-fw-upgrade.j2 | sudo tee $FILESYSTEM_ROOT/usr/bin/mlnx-fw-upgrade.sh sudo chmod 755 $FILESYSTEM_ROOT/usr/bin/mlnx-fw-upgrade.sh +sudo cp -r platform/mellanox/asic_detect $FILESYSTEM_ROOT/usr/bin/asic_detect +sudo chmod -R 777 $FILESYSTEM_ROOT/usr/bin/asic_detect/ install_pip_package {{platform_api_py3_wheel_path}} diff --git a/platform/mellanox/asic_detect/asic_detect.sh b/platform/mellanox/asic_detect/asic_detect.sh new file mode 100644 index 00000000000..f542ae27600 --- /dev/null +++ b/platform/mellanox/asic_detect/asic_detect.sh @@ -0,0 +1,28 @@ +#!/usr/bin/env bash + +if [[ -f "/usr/bin/asic_detect/asic_type" ]]; then + cat /usr/bin/asic_detect/asic_type +else + declare -A DEVICE_DICT=( + ["cb84"]="spc1" + ["cf6c"]="spc2" + ["cf70"]="spc3" + ["cf80"]="spc4" + ["cf82"]="spc5" + ["a2dc"]="bf3" + ) + TYPE_UNKNOWN="unknown" + VENDOR_ID="15b3" + DEVICE_TYPE=$TYPE_UNKNOWN + + DEVICE_ID=$(lspci -n | awk -v vid="$VENDOR_ID" '$0 ~ vid {print $NF}' | cut -d: -f2) + # Check if DEVICE_ID exists in the DEVICE_DICT + if [[ -n "${DEVICE_DICT[$DEVICE_ID]}" ]]; then + DEVICE_TYPE="${DEVICE_DICT[$DEVICE_ID]}" + else + DEVICE_TYPE=$TYPE_UNKNOWN + fi + + echo "$DEVICE_TYPE" | tee >( [[ "$DEVICE_TYPE" != "$TYPE_UNKNOWN" ]] && cat > /usr/bin/asic_detect/asic_type ) + +fi diff --git a/platform/mellanox/mlnx-fw-upgrade.j2 b/platform/mellanox/mlnx-fw-upgrade.j2 index 3f156b8b2f9..ecb0225a68c 100755 --- a/platform/mellanox/mlnx-fw-upgrade.j2 +++ b/platform/mellanox/mlnx-fw-upgrade.j2 @@ -204,7 +204,7 @@ function UnlockStateChange() { } function GetMstDeviceType() { - local -r asic_type=$(GetAsicType) + local -r asic_type=$(/usr/bin/asic_detect/asic_detect.sh) case $asic_type in ${SPC1_ASIC}|${SPC2_ASIC}|${SPC3_ASIC}|${SPC4_ASIC}) @@ -249,48 +249,6 @@ function WaitForDevice() { LogInfo "${DEVICE_TYPE} ASIC successfully detected at ${SPC_MST_DEV}" } -function GetAsicType() { - local -r VENDOR_ID="15b3" - - local -r SPC1_PRODUCT_ID="cb84" - local -r SPC2_PRODUCT_ID="cf6c" - local -r SPC3_PRODUCT_ID="cf70" - local -r SPC4_PRODUCT_ID="cf80" - local -r BF3_PRODUCT_ID="a2dc" - - local -i QUERY_RETRY_COUNT="0" - local -i QUERY_RETRY_COUNT_MAX="10" - local pcitree=$(lspci -n 2>/dev/null) - ERROR_CODE="$?" - - while [[ ("${QUERY_RETRY_COUNT}" -lt "QUERY_RETRY_COUNT_MAX") && ("${ERROR_CODE}" != "${EXIT_SUCCESS}") ]]; do - sleep 1s - ((QUERY_RETRY_COUNT++)) - pcitree=$(lspci -n 2>/dev/null) - ERROR_CODE="$?" - done - - if echo $pcitree | grep "${VENDOR_ID}:${SPC1_PRODUCT_ID}" &>/dev/null; then - echo "${SPC1_ASIC}" - exit "${EXIT_SUCCESS}" - elif echo $pcitree | grep "${VENDOR_ID}:${SPC2_PRODUCT_ID}" &>/dev/null; then - echo "${SPC2_ASIC}" - exit "${EXIT_SUCCESS}" - elif echo $pcitree | grep "${VENDOR_ID}:${SPC3_PRODUCT_ID}" &>/dev/null; then - echo "${SPC3_ASIC}" - exit "${EXIT_SUCCESS}" - elif echo $pcitree | grep "${VENDOR_ID}:${SPC4_PRODUCT_ID}" &>/dev/null; then - echo "${SPC4_ASIC}" - exit "${EXIT_SUCCESS}" - elif echo $pcitree | grep "${VENDOR_ID}:${BF3_PRODUCT_ID}" &>/dev/null; then - echo "${BF3_NIC}" - exit "${EXIT_SUCCESS}" - fi - - echo "${UNKN_ASIC}" - exit "${EXIT_FAILURE}" -} - function GetSPCMstDevice() { local _DEVICE_TYPE=$(GetMstDeviceType) local _MST_DEVICE=$(${QUERY_XML} | xmlstarlet sel -t -m "//Device[contains(@type,'${_DEVICE_TYPE}')]" -v @pciName | head -n 1) @@ -412,7 +370,7 @@ function GetAvailableFwVersion() { function UpgradeFW() { local -r _FW_BIN_PATH="$1" - local -r _ASIC_TYPE="$(GetAsicType)" + local -r _ASIC_TYPE="$(/usr/bin/asic_detect/asic_detect.sh)" if [[ "${_ASIC_TYPE}" = "${UNKN_ASIC}" ]]; then ExitFailure "failed to detect ASIC type" fi From 6e9e603e2f2c01d88a6a15e3c0da4a5a302c5e88 Mon Sep 17 00:00:00 2001 From: noaOrMlnx Date: Thu, 10 Jul 2025 16:36:42 +0300 Subject: [PATCH 2/6] Add per-asic sai.profile with relevant parameters and copy them to syncd docker --- .../Mellanox-SN5640-C448O16/sai.profile | 1 - .../Mellanox-SN5640-C512S2/sai.profile | 1 - .../ACS-SN5640/sai.profile | 2 -- platform/mellanox/asic_detect/asic_detect.sh | 17 +++++++++++++++++ .../mellanox/docker-syncd-mlnx/Dockerfile.j2 | 2 +- .../mellanox/docker-syncd-mlnx/sai-spc1.profile | 0 .../mellanox/docker-syncd-mlnx/sai-spc2.profile | 1 + .../mellanox/docker-syncd-mlnx/sai-spc3.profile | 1 + .../mellanox/docker-syncd-mlnx/sai-spc4.profile | 1 + .../mellanox/docker-syncd-mlnx/sai-spc5.profile | 2 ++ .../docker-syncd-bluefield/Dockerfile.j2 | 3 +++ .../docker-syncd-bluefield/sai-bf3.profile | 0 12 files changed, 26 insertions(+), 5 deletions(-) create mode 100644 platform/mellanox/docker-syncd-mlnx/sai-spc1.profile create mode 100644 platform/mellanox/docker-syncd-mlnx/sai-spc2.profile create mode 100644 platform/mellanox/docker-syncd-mlnx/sai-spc3.profile create mode 100644 platform/mellanox/docker-syncd-mlnx/sai-spc4.profile create mode 100644 platform/mellanox/docker-syncd-mlnx/sai-spc5.profile create mode 100644 platform/nvidia-bluefield/docker-syncd-bluefield/sai-bf3.profile diff --git a/device/mellanox/x86_64-nvidia_sn5640-r0/Mellanox-SN5640-C448O16/sai.profile b/device/mellanox/x86_64-nvidia_sn5640-r0/Mellanox-SN5640-C448O16/sai.profile index 0c60c551ce6..a3aadc160ed 100644 --- a/device/mellanox/x86_64-nvidia_sn5640-r0/Mellanox-SN5640-C448O16/sai.profile +++ b/device/mellanox/x86_64-nvidia_sn5640-r0/Mellanox-SN5640-C448O16/sai.profile @@ -1,3 +1,2 @@ SAI_INIT_CONFIG_FILE=/usr/share/sonic/hwsku/sai_5640_448x100g_16x400g.xml SAI_KEY_SPC5_LOSSY_SCHEDULING=1 -SAI_DEFAULT_SWITCHING_MODE_STORE_FORWARD=1 diff --git a/device/mellanox/x86_64-nvidia_sn5640-r0/Mellanox-SN5640-C512S2/sai.profile b/device/mellanox/x86_64-nvidia_sn5640-r0/Mellanox-SN5640-C512S2/sai.profile index f4841177945..17a6eea55d0 100644 --- a/device/mellanox/x86_64-nvidia_sn5640-r0/Mellanox-SN5640-C512S2/sai.profile +++ b/device/mellanox/x86_64-nvidia_sn5640-r0/Mellanox-SN5640-C512S2/sai.profile @@ -1,3 +1,2 @@ SAI_INIT_CONFIG_FILE=/usr/share/sonic/hwsku/sai_5640_512x100g.xml SAI_KEY_SPC5_LOSSY_SCHEDULING=1 -SAI_DEFAULT_SWITCHING_MODE_STORE_FORWARD=1 diff --git a/device/mellanox/x86_64-nvidia_sn5640_simx-r0/ACS-SN5640/sai.profile b/device/mellanox/x86_64-nvidia_sn5640_simx-r0/ACS-SN5640/sai.profile index fc98a5ebf90..b31cf264e80 100644 --- a/device/mellanox/x86_64-nvidia_sn5640_simx-r0/ACS-SN5640/sai.profile +++ b/device/mellanox/x86_64-nvidia_sn5640_simx-r0/ACS-SN5640/sai.profile @@ -1,4 +1,2 @@ SAI_INIT_CONFIG_FILE=/usr/share/sonic/hwsku/sai_5640.xml SAI_KEY_SPC5_LOSSY_SCHEDULING=1 -SAI_DEFAULT_SWITCHING_MODE_STORE_FORWARD=1 - diff --git a/platform/mellanox/asic_detect/asic_detect.sh b/platform/mellanox/asic_detect/asic_detect.sh index f542ae27600..92ba28617b8 100644 --- a/platform/mellanox/asic_detect/asic_detect.sh +++ b/platform/mellanox/asic_detect/asic_detect.sh @@ -1,4 +1,21 @@ #!/usr/bin/env bash +# +# SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES +# Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# SPDX-License-Identifier: 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. +# See the License for the specific language governing permissions and +# limitations under the License. +# if [[ -f "/usr/bin/asic_detect/asic_type" ]]; then cat /usr/bin/asic_detect/asic_type diff --git a/platform/mellanox/docker-syncd-mlnx/Dockerfile.j2 b/platform/mellanox/docker-syncd-mlnx/Dockerfile.j2 index 7b418ab8582..64ab18c8331 100755 --- a/platform/mellanox/docker-syncd-mlnx/Dockerfile.j2 +++ b/platform/mellanox/docker-syncd-mlnx/Dockerfile.j2 @@ -71,7 +71,7 @@ COPY ["critical_processes", "/etc/supervisor/"] COPY ["platform_syncd_dump.sh", "/usr/bin/"] RUN mkdir -p /etc/mlnx/ -COPY ["sai-common.profile", "/etc/mlnx/"] +COPY sai-*.profile /etc/mlnx/ RUN mkdir -p /etc/supervisor/conf.d/ RUN sonic-cfggen -a "{\"ENABLE_ASAN\":\"{{ENABLE_ASAN}}\"}" -t /usr/share/sonic/templates/supervisord.conf.j2 > /etc/supervisor/conf.d/supervisord.conf diff --git a/platform/mellanox/docker-syncd-mlnx/sai-spc1.profile b/platform/mellanox/docker-syncd-mlnx/sai-spc1.profile new file mode 100644 index 00000000000..e69de29bb2d diff --git a/platform/mellanox/docker-syncd-mlnx/sai-spc2.profile b/platform/mellanox/docker-syncd-mlnx/sai-spc2.profile new file mode 100644 index 00000000000..37560da3af2 --- /dev/null +++ b/platform/mellanox/docker-syncd-mlnx/sai-spc2.profile @@ -0,0 +1 @@ +SAI_MIRROR_SESSION_HW_ID_RESERVATION=7 diff --git a/platform/mellanox/docker-syncd-mlnx/sai-spc3.profile b/platform/mellanox/docker-syncd-mlnx/sai-spc3.profile new file mode 100644 index 00000000000..37560da3af2 --- /dev/null +++ b/platform/mellanox/docker-syncd-mlnx/sai-spc3.profile @@ -0,0 +1 @@ +SAI_MIRROR_SESSION_HW_ID_RESERVATION=7 diff --git a/platform/mellanox/docker-syncd-mlnx/sai-spc4.profile b/platform/mellanox/docker-syncd-mlnx/sai-spc4.profile new file mode 100644 index 00000000000..37560da3af2 --- /dev/null +++ b/platform/mellanox/docker-syncd-mlnx/sai-spc4.profile @@ -0,0 +1 @@ +SAI_MIRROR_SESSION_HW_ID_RESERVATION=7 diff --git a/platform/mellanox/docker-syncd-mlnx/sai-spc5.profile b/platform/mellanox/docker-syncd-mlnx/sai-spc5.profile new file mode 100644 index 00000000000..3afdf264714 --- /dev/null +++ b/platform/mellanox/docker-syncd-mlnx/sai-spc5.profile @@ -0,0 +1,2 @@ +SAI_MIRROR_SESSION_HW_ID_RESERVATION=7 +SAI_DEFAULT_SWITCHING_MODE_STORE_FORWARD=1 diff --git a/platform/nvidia-bluefield/docker-syncd-bluefield/Dockerfile.j2 b/platform/nvidia-bluefield/docker-syncd-bluefield/Dockerfile.j2 index e11ea978c2c..e6d1d81518c 100644 --- a/platform/nvidia-bluefield/docker-syncd-bluefield/Dockerfile.j2 +++ b/platform/nvidia-bluefield/docker-syncd-bluefield/Dockerfile.j2 @@ -56,4 +56,7 @@ COPY ["supervisord.conf", "/etc/supervisor/conf.d/"] COPY ["files/supervisor-proc-exit-listener", "/usr/bin"] COPY ["critical_processes", "/etc/supervisor/"] +RUN mkdir -p /etc/nv-bf/ +COPY sai-*.profile /etc/nv-bf/ + ENTRYPOINT ["/usr/local/bin/supervisord"] diff --git a/platform/nvidia-bluefield/docker-syncd-bluefield/sai-bf3.profile b/platform/nvidia-bluefield/docker-syncd-bluefield/sai-bf3.profile new file mode 100644 index 00000000000..e69de29bb2d From 3dd95c36b44e3565e39639103535c56119359675 Mon Sep 17 00:00:00 2001 From: noaOrMlnx Date: Tue, 15 Jul 2025 11:55:33 +0300 Subject: [PATCH 3/6] Fix CR comments: RC for asic_detect and right folder to nv bluefield --- platform/mellanox/asic_detect/asic_detect.sh | 46 ++++++++++--------- .../docker-syncd-bluefield/Dockerfile.j2 | 4 +- 2 files changed, 27 insertions(+), 23 deletions(-) diff --git a/platform/mellanox/asic_detect/asic_detect.sh b/platform/mellanox/asic_detect/asic_detect.sh index 92ba28617b8..7e31da10102 100644 --- a/platform/mellanox/asic_detect/asic_detect.sh +++ b/platform/mellanox/asic_detect/asic_detect.sh @@ -17,29 +17,33 @@ # limitations under the License. # +ERROR_CODE=-1 +RC=0 + if [[ -f "/usr/bin/asic_detect/asic_type" ]]; then cat /usr/bin/asic_detect/asic_type -else - declare -A DEVICE_DICT=( - ["cb84"]="spc1" - ["cf6c"]="spc2" - ["cf70"]="spc3" - ["cf80"]="spc4" - ["cf82"]="spc5" - ["a2dc"]="bf3" - ) - TYPE_UNKNOWN="unknown" - VENDOR_ID="15b3" - DEVICE_TYPE=$TYPE_UNKNOWN - - DEVICE_ID=$(lspci -n | awk -v vid="$VENDOR_ID" '$0 ~ vid {print $NF}' | cut -d: -f2) - # Check if DEVICE_ID exists in the DEVICE_DICT - if [[ -n "${DEVICE_DICT[$DEVICE_ID]}" ]]; then - DEVICE_TYPE="${DEVICE_DICT[$DEVICE_ID]}" - else - DEVICE_TYPE=$TYPE_UNKNOWN - fi + exit $RC +fi - echo "$DEVICE_TYPE" | tee >( [[ "$DEVICE_TYPE" != "$TYPE_UNKNOWN" ]] && cat > /usr/bin/asic_detect/asic_type ) +declare -A DEVICE_DICT=( + ["cb84"]="spc1" + ["cf6c"]="spc2" + ["cf70"]="spc3" + ["cf80"]="spc4" + ["cf82"]="spc5" + ["a2dc"]="bf3" +) +TYPE_UNKNOWN="unknown" +VENDOR_ID="15b3" +DEVICE_TYPE=$TYPE_UNKNOWN +DEVICE_ID=$(lspci -n | awk -v vid="$VENDOR_ID" '$0 ~ vid {print $NF}' | cut -d: -f2) +# Check if DEVICE_ID exists in the DEVICE_DICT +if [[ -n "${DEVICE_DICT[$DEVICE_ID]}" ]]; then + DEVICE_TYPE="${DEVICE_DICT[$DEVICE_ID]}" +else + DEVICE_TYPE=$TYPE_UNKNOWN + RC=$ERROR_CODE fi +echo "$DEVICE_TYPE" | tee >( [[ "$DEVICE_TYPE" != "$TYPE_UNKNOWN" ]] && cat > /usr/bin/asic_detect/asic_type ) +exit $RC diff --git a/platform/nvidia-bluefield/docker-syncd-bluefield/Dockerfile.j2 b/platform/nvidia-bluefield/docker-syncd-bluefield/Dockerfile.j2 index e6d1d81518c..18b0ddb8ad8 100644 --- a/platform/nvidia-bluefield/docker-syncd-bluefield/Dockerfile.j2 +++ b/platform/nvidia-bluefield/docker-syncd-bluefield/Dockerfile.j2 @@ -56,7 +56,7 @@ COPY ["supervisord.conf", "/etc/supervisor/conf.d/"] COPY ["files/supervisor-proc-exit-listener", "/usr/bin"] COPY ["critical_processes", "/etc/supervisor/"] -RUN mkdir -p /etc/nv-bf/ -COPY sai-*.profile /etc/nv-bf/ +RUN mkdir -p /etc/mlnx/ +COPY sai-*.profile /etc/mlnx/ ENTRYPOINT ["/usr/local/bin/supervisord"] From 508557fd35bbc894c1224e128345c037b9f25cf5 Mon Sep 17 00:00:00 2001 From: noaOrMlnx Date: Thu, 17 Jul 2025 08:50:28 +0300 Subject: [PATCH 4/6] Add mount to asic_detect in nv-bluefield syncd container --- files/build_templates/docker_image_ctl.j2 | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/files/build_templates/docker_image_ctl.j2 b/files/build_templates/docker_image_ctl.j2 index c7f9d507f34..9c554d52639 100644 --- a/files/build_templates/docker_image_ctl.j2 +++ b/files/build_templates/docker_image_ctl.j2 @@ -698,6 +698,11 @@ start() { {%- endif %} {%- endif %} {%- endif %} +{%- if sonic_asic_platform == "nvidia-bluefield" %} +{%- if docker_container_name == "syncd" %} + -v /usr/bin/asic_detect:/usr/bin/asic_detect:rw \ +{%- endif %} +{%- endif %} {%- if sonic_asic_platform == "broadcom" %} {%- if docker_container_name == "syncd" %} --shm-size=${SYNCD_SHM_SIZE:-512m} \ From 8a5361245a8e67f61034387c7704675e42b619f3 Mon Sep 17 00:00:00 2001 From: noaOrMlnx Date: Wed, 30 Jul 2025 21:51:19 +0300 Subject: [PATCH 5/6] Update asic_detect.sh to fit ARM for nvidia-bluefield --- platform/mellanox/asic_detect/asic_detect.sh | 32 ++++++++++++-------- 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/platform/mellanox/asic_detect/asic_detect.sh b/platform/mellanox/asic_detect/asic_detect.sh index 7e31da10102..9f2748664b3 100644 --- a/platform/mellanox/asic_detect/asic_detect.sh +++ b/platform/mellanox/asic_detect/asic_detect.sh @@ -17,14 +17,15 @@ # limitations under the License. # -ERROR_CODE=-1 -RC=0 +SUCCESS_CODE=0 +RC=-1 if [[ -f "/usr/bin/asic_detect/asic_type" ]]; then cat /usr/bin/asic_detect/asic_type - exit $RC + exit $SUCCESS_CODE fi +# make sure that DEVICE_DICT keys are the same as values in DEVICE_ORDER declare -A DEVICE_DICT=( ["cb84"]="spc1" ["cf6c"]="spc2" @@ -37,13 +38,20 @@ TYPE_UNKNOWN="unknown" VENDOR_ID="15b3" DEVICE_TYPE=$TYPE_UNKNOWN -DEVICE_ID=$(lspci -n | awk -v vid="$VENDOR_ID" '$0 ~ vid {print $NF}' | cut -d: -f2) -# Check if DEVICE_ID exists in the DEVICE_DICT -if [[ -n "${DEVICE_DICT[$DEVICE_ID]}" ]]; then - DEVICE_TYPE="${DEVICE_DICT[$DEVICE_ID]}" -else - DEVICE_TYPE=$TYPE_UNKNOWN - RC=$ERROR_CODE +# bf3 should be the last device in the list +DEVICE_ORDER=("cb84" "cf6c" "cf70" "cf80" "cf82" "a2dc") + +lspci_output=$(lspci -n 2>/dev/null) +if [[ -n "$lspci_output" ]]; then + for key in "${DEVICE_ORDER[@]}"; do + if echo "$lspci_output" | grep "$VENDOR_ID:$key" &>/dev/null; then + DEVICE_TYPE="${DEVICE_DICT[$key]}" + RC=$SUCCESS_CODE + break + fi + done + if [[ -n "$DEVICE_TYPE" ]]; then + echo "$DEVICE_TYPE" | tee >( [[ "$DEVICE_TYPE" != "$TYPE_UNKNOWN" ]] && cat > /usr/bin/asic_detect/asic_type ) + fi + exit $RC fi -echo "$DEVICE_TYPE" | tee >( [[ "$DEVICE_TYPE" != "$TYPE_UNKNOWN" ]] && cat > /usr/bin/asic_detect/asic_type ) -exit $RC From 304ee464970ddcc317a24b74d6de7d68b13f1c8d Mon Sep 17 00:00:00 2001 From: noaOrMlnx Date: Thu, 31 Jul 2025 08:19:04 +0300 Subject: [PATCH 6/6] Update nvidia-bluefield install.sh.j2 to copy asic_detect folder --- platform/nvidia-bluefield/installer/install.sh.j2 | 2 ++ 1 file changed, 2 insertions(+) diff --git a/platform/nvidia-bluefield/installer/install.sh.j2 b/platform/nvidia-bluefield/installer/install.sh.j2 index 44ad659932e..394b0f00799 100755 --- a/platform/nvidia-bluefield/installer/install.sh.j2 +++ b/platform/nvidia-bluefield/installer/install.sh.j2 @@ -246,6 +246,8 @@ if [[ $SKIP_FIRMWARE_UPGRADE != "true" ]]; then ex mst start + cp -R $sonic_fs_mountpoint/usr/bin/asic_detect/ /usr/bin/ + if function_exists bfb_pre_fw_install; then log "Running bfb_pre_fw_install from bf.cfg" bfb_pre_fw_install