Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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

6 changes: 6 additions & 0 deletions files/build_templates/docker_image_ctl.j2
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand All @@ -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} \
Expand Down
4 changes: 4 additions & 0 deletions files/build_templates/sonic_debian_extension.j2
Original file line number Diff line number Diff line change
Expand Up @@ -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}}
Expand Down Expand Up @@ -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}}

Expand Down
57 changes: 57 additions & 0 deletions platform/mellanox/asic_detect/asic_detect.sh
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion platform/mellanox/docker-syncd-mlnx/Dockerfile.j2
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Empty file.
1 change: 1 addition & 0 deletions platform/mellanox/docker-syncd-mlnx/sai-spc2.profile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
SAI_MIRROR_SESSION_HW_ID_RESERVATION=7
1 change: 1 addition & 0 deletions platform/mellanox/docker-syncd-mlnx/sai-spc3.profile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
SAI_MIRROR_SESSION_HW_ID_RESERVATION=7
1 change: 1 addition & 0 deletions platform/mellanox/docker-syncd-mlnx/sai-spc4.profile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
SAI_MIRROR_SESSION_HW_ID_RESERVATION=7
2 changes: 2 additions & 0 deletions platform/mellanox/docker-syncd-mlnx/sai-spc5.profile
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
SAI_MIRROR_SESSION_HW_ID_RESERVATION=7
SAI_DEFAULT_SWITCHING_MODE_STORE_FORWARD=1
46 changes: 2 additions & 44 deletions platform/mellanox/mlnx-fw-upgrade.j2
Original file line number Diff line number Diff line change
Expand Up @@ -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})
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Empty file.
2 changes: 2 additions & 0 deletions platform/nvidia-bluefield/installer/install.sh.j2
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading