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/files/build_templates/docker_image_ctl.j2 b/files/build_templates/docker_image_ctl.j2 index 4ca34262409..9c554d52639 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 \ @@ -697,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} \ 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..9f2748664b3 --- /dev/null +++ b/platform/mellanox/asic_detect/asic_detect.sh @@ -0,0 +1,57 @@ +#!/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. +# + +SUCCESS_CODE=0 +RC=-1 + +if [[ -f "/usr/bin/asic_detect/asic_type" ]]; then + cat /usr/bin/asic_detect/asic_type + 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" + ["cf70"]="spc3" + ["cf80"]="spc4" + ["cf82"]="spc5" + ["a2dc"]="bf3" +) +TYPE_UNKNOWN="unknown" +VENDOR_ID="15b3" +DEVICE_TYPE=$TYPE_UNKNOWN + +# 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 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/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 diff --git a/platform/nvidia-bluefield/docker-syncd-bluefield/Dockerfile.j2 b/platform/nvidia-bluefield/docker-syncd-bluefield/Dockerfile.j2 index e11ea978c2c..18b0ddb8ad8 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/mlnx/ +COPY sai-*.profile /etc/mlnx/ + 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 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