Skip to content
Merged
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
51 changes: 46 additions & 5 deletions platform/mellanox/sonic-bfb-installer.sh
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,10 @@ PLATFORM_JSON=/usr/share/sonic/device/$PLATFORM/platform.json
declare -A rshim2dpu
declare -r bfsoc_dev_id="15b3:c2d5"
declare -r cx7_dev_id="15b3:a2dc"
declare -r REBOOT_HELPER_SCRIPT="/usr/local/bin/reboot_smartswitch_helper"

# Source reboot helper script at initialization if available
[[ -f "$REBOOT_HELPER_SCRIPT" ]] && source "$REBOOT_HELPER_SCRIPT"

# Local functions to replace dpumap.sh
rshim2dpu_map() {
Expand Down Expand Up @@ -199,6 +203,47 @@ remove_cx_pci_device() {
fi
}

# Function to check if CHASSIS_MODULE_TABLE entry exists for a specific DPU
is_chassis_module_table_present() {
local dpu_name=$1
local output
output=$(sonic-db-cli STATE_DB KEYS "CHASSIS_MODULE_TABLE|${dpu_name}" 2>/dev/null)
if [[ -z "$output" ]]; then
return 1
fi
return 0
}

# Function to execute dpuctl dpu-reset command
run_dpuctl_reset() {
local dpu=$1
local use_verbose=$2
local reset_cmd="dpuctl dpu-reset --force $dpu"
if [[ "$use_verbose" == true ]]; then
reset_cmd="$reset_cmd -v"
fi
eval $reset_cmd
}

# Function to reset DPU using reboot helper or fallback to dpuctl
reset_dpu() {
local dpu=$1
local use_verbose=$2
local dpu_upper="${dpu^^}" # Convert to uppercase (e.g., dpu0 -> DPU0)

# Check if reboot helper is available and CHASSIS_MODULE_TABLE entry exists for this DPU
if [[ -f "$REBOOT_HELPER_SCRIPT" ]] && is_chassis_module_table_present "$dpu_upper"; then
log_info "Using reboot helper pre/post shutdown methods while resetting $dpu_upper"
module_pre_shutdown "$dpu_upper"
run_dpuctl_reset "$dpu" "$use_verbose"
module_post_startup "$dpu_upper"
else
# Fallback to dpuctl
log_info "Using dpuctl to reset $dpu"
run_dpuctl_reset "$dpu" "$use_verbose"
fi
}

monitor_installation() {
local -r rid=$1
local -r pid=$2
Expand Down Expand Up @@ -311,11 +356,7 @@ bfb_install_call() {
stop_rshim_daemon "$rid"
log_info "$rid: Resetting DPU $dpu"

local reset_cmd="dpuctl dpu-reset --force $dpu"
if [[ $verbose == true ]]; then
reset_cmd="$reset_cmd -v"
fi
eval $reset_cmd
reset_dpu "$dpu" "$verbose"
}

file_cleanup(){
Expand Down
Loading