-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[DellEMC] S6100 Last Reboot Reason Thermal Support (#3767)
- Loading branch information
1 parent
936749c
commit 2626565
Showing
11 changed files
with
337 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
97 changes: 97 additions & 0 deletions
97
platform/broadcom/sonic-platform-modules-dell/common/nvram_rd_wr.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
#!/usr/bin/python | ||
#Script to read/write the nvram | ||
|
||
import sys | ||
import os | ||
import getopt | ||
import struct | ||
|
||
nvram_resource='/dev/nvram' | ||
|
||
def usage(): | ||
''' This is the Usage Method ''' | ||
|
||
print 'Utility for NVRAM read/write' | ||
print '\t\t nvram_rd_wr.py --get --offset <offset>' | ||
print '\t\t nvram_rd_wr.py --set --val <val> --offset <offset>' | ||
sys.exit(1) | ||
|
||
def nvram_reg_read(nvram_resource,offset): | ||
fd=os.open(nvram_resource, os.O_RDONLY) | ||
if(fd<0): | ||
print 'file open failed %s"%nvram_resource' | ||
return | ||
if(os.lseek(fd, offset, os.SEEK_SET) != offset): | ||
print 'lseek failed on %s'%nvram_resource | ||
return | ||
buf=os.read(fd,1) | ||
reg_val1=ord(buf) | ||
print 'value %x'%reg_val1 | ||
os.close(fd) | ||
|
||
def nvram_reg_write(nvram_resource,offset,val): | ||
fd=os.open(nvram_resource,os.O_RDWR) | ||
if(fd<0): | ||
print 'file open failed %s"%nvram_resource' | ||
return | ||
if(os.lseek(fd, offset, os.SEEK_SET) != offset): | ||
print 'lseek failed on %s'%nvram_resource | ||
return | ||
ret=os.write(fd,struct.pack('B',val)) | ||
if(ret != 1): | ||
print 'write failed %d'%ret | ||
return | ||
os.close(fd) | ||
|
||
def main(argv): | ||
|
||
''' The main function will read the user input from the | ||
command line argument and process the request ''' | ||
|
||
opts = '' | ||
val = '' | ||
choice = '' | ||
resouce = '' | ||
offset = '' | ||
|
||
try: | ||
opts, args = getopt.getopt(argv, "hgs:" , \ | ||
["val=","offset=","help", "get", "set"]) | ||
|
||
except getopt.GetoptError: | ||
usage() | ||
|
||
if not os.path.exists(nvram_resource): | ||
print 'NVRAM is not initialized' | ||
sys.exit(1) | ||
|
||
for opt,arg in opts: | ||
|
||
if opt in ('-h','--help'): | ||
choice = 'help' | ||
|
||
elif opt in ('-g', '--get'): | ||
choice = 'get' | ||
|
||
elif opt in ('-s', '--set'): | ||
choice = 'set' | ||
|
||
elif opt == '--offset': | ||
offset = int(arg,16) - 0xE | ||
|
||
elif opt == '--val': | ||
val = int(arg,16) | ||
|
||
if choice == 'get' and offset != '': | ||
nvram_reg_read(nvram_resource,offset) | ||
|
||
elif choice == 'set' and offset != '' and val != '': | ||
nvram_reg_write(nvram_resource,offset,val) | ||
|
||
else: | ||
usage() | ||
|
||
#Calling the main method | ||
if __name__ == "__main__": | ||
main(sys.argv[1:]) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 6 additions & 0 deletions
6
platform/broadcom/sonic-platform-modules-dell/s6100/scripts/fast-reboot_plugin
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#!/bin/bash | ||
|
||
if [[ -d /sys/devices/platform/SMF.512/hwmon/ ]]; then | ||
cd /sys/devices/platform/SMF.512/hwmon/* | ||
echo 0xcc > mb_poweron_reason | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
168 changes: 168 additions & 0 deletions
168
platform/broadcom/sonic-platform-modules-dell/s6100/scripts/track_reboot_reason.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,168 @@ | ||
#!/bin/bash | ||
|
||
reboot_dir_found=false | ||
reboot_file_found=false | ||
smf_dir_missing=0 | ||
nvram_missing=0 | ||
|
||
REBOOT_CAUSE_FILE=/host/reboot-cause/reboot-cause.txt | ||
REBOOT_REASON_FILE=/host/reboot-cause/platform/reboot_reason | ||
BIOS_VERSION_FILE=/host/reboot-cause/platform/bios_minor_version | ||
SMF_POWERON_REASON=/sys/devices/platform/SMF.512/hwmon/*/smf_poweron_reason | ||
SMF_RESET_REASON=/sys/devices/platform/SMF.512/hwmon/*/smf_reset_reason | ||
MAILBOX_POWERON_REASON=/sys/devices/platform/SMF.512/hwmon/*/mb_poweron_reason | ||
NVRAM_DEVICE_FILE=/dev/nvram | ||
RESET_REASON_FILE=/host/reboot-cause/platform/reset_reason | ||
SMF_DIR=/sys/devices/platform/SMF.512/hwmon/ | ||
|
||
while [[ ! -d $SMF_DIR ]] | ||
do | ||
sleep 0.5 | ||
let smf_dir_missing=$smf_dir_missing+1 | ||
if [[ "$smf_dir_missing" = "5" ]]; then | ||
echo "SMF is not initialized" | ||
smf_dir_missing=0 | ||
fi | ||
done | ||
|
||
SMF_RESET=$(cat $SMF_RESET_REASON) | ||
|
||
if [[ -d /host/reboot-cause/platform ]]; then | ||
reboot_dir_found=true | ||
if [[ -f $REBOOT_REASON_FILE ]]; then | ||
reboot_file_found=true | ||
fi | ||
fi | ||
|
||
SMF_BIOS_REG=$(io_rd_wr.py --get --offset 0x203 | cut -d " " -f 3) | ||
SMF_BIOS_REG=$((16#$SMF_BIOS_REG)) | ||
bios_secondary_boot=$(($SMF_BIOS_REG & 1)) | ||
|
||
_get_smf_reset_register(){ | ||
BIOS_VERSION=$(/usr/sbin/dmidecode -s system-version) | ||
BIOS_VERSION_MINOR=$(echo $BIOS_VERSION | cut -d'-' -f 2) | ||
|
||
if [[ $BIOS_VERSION_MINOR -gt 7 ]]; then | ||
echo $BIOS_VERSION > $BIOS_VERSION_FILE | ||
elif [[ "$bios_secondary_boot" = "0" ]]; then | ||
# For Primary BIOS with older version | ||
if [[ -e $BIOS_VERSION_FILE ]]; then | ||
rm $BIOS_VERSION_FILE | ||
fi | ||
fi | ||
|
||
if [[ -e $BIOS_VERSION_FILE ]]; then | ||
while [[ ! -e $NVRAM_DEVICE_FILE ]] | ||
do | ||
sleep 1 | ||
let nvram_missing=$nvram_missing+1 | ||
if [[ "$nvram_missing" = "5" ]]; then | ||
echo "NVRAM is not initialized" | ||
nvram_missing=0 | ||
fi | ||
done | ||
first_reset=$(nvram_rd_wr.py --get --offset 0x5c | cut -d " " -f 2) | ||
second_reset=$(nvram_rd_wr.py --get --offset 0x5d | cut -d " " -f 2) | ||
third_reset=$(nvram_rd_wr.py --get --offset 0x5e | cut -d " " -f 2) | ||
fourth_reset=$(nvram_rd_wr.py --get --offset 0x5f | cut -d " " -f 2) | ||
|
||
if [[ "$first_reset" != "ee" ]]; then | ||
SMF_RESET=$first_reset | ||
fi | ||
|
||
# Saving NVRAM values for future debugging | ||
if [[ $reboot_dir_found = true ]]; then | ||
echo "First reset - $first_reset" > $RESET_REASON_FILE | ||
echo "Second reset - $second_reset" >> $RESET_REASON_FILE | ||
echo "Third reset - $third_reset" >> $RESET_REASON_FILE | ||
echo "Fourth reset - $fourth_reset" >> $RESET_REASON_FILE | ||
fi | ||
|
||
# Clearing NVRAM values to holding next reset values | ||
nvram_rd_wr.py --set --val 0xee --offset 0x58 | ||
nvram_rd_wr.py --set --val 0xee --offset 0x5c | ||
nvram_rd_wr.py --set --val 0xee --offset 0x5d | ||
nvram_rd_wr.py --set --val 0xee --offset 0x5e | ||
nvram_rd_wr.py --set --val 0xee --offset 0x5f | ||
fi | ||
} | ||
|
||
_is_thermal_reset() { | ||
prev_thermal=$(cat $REBOOT_REASON_FILE) | ||
curr_poweron_reason=$(cat $SMF_POWERON_REASON) | ||
if [[ $curr_poweron_reason = "11" ]]; then | ||
echo 0 | ||
return | ||
fi | ||
if [[ $prev_thermal = $curr_poweron_reason ]]; then | ||
echo 2 | ||
return | ||
else | ||
echo "$curr_poweron_reason" > $REBOOT_REASON_FILE | ||
echo 1 | ||
return | ||
fi | ||
|
||
echo 0 | ||
return | ||
} | ||
|
||
_is_watchdog_reset(){ | ||
curr_reset_reason=$SMF_RESET | ||
if [[ $curr_reset_reason = "33" ]]; then | ||
echo 1 | ||
return | ||
fi | ||
|
||
echo 0 | ||
return | ||
} | ||
|
||
_is_unknown_reset(){ | ||
if [[ -f $REBOOT_CAUSE_FILE ]]; then | ||
if [[ $1 = 0 ]]; then | ||
echo "Unknown software reboot" > $REBOOT_CAUSE_FILE | ||
return | ||
fi | ||
curr_poweron_reason=$(cat $SMF_POWERON_REASON) | ||
curr_reset_reason=$SMF_RESET | ||
mb_poweron_reason=$(cat $MAILBOX_POWERON_REASON) | ||
echo "Unknown POR: $curr_poweron_reason RST: $curr_reset_reason MBR: $mb_poweron_reason" > $REBOOT_CAUSE_FILE | ||
fi | ||
|
||
} | ||
|
||
update_mailbox_register(){ | ||
if [[ "$bios_secondary_boot" = "1" ]]; then | ||
echo "Secondary BIOS booted" | ||
fi | ||
|
||
if [[ $reboot_file_found = false ]]; then | ||
echo "None" > $REBOOT_REASON_FILE | ||
fi | ||
|
||
_get_smf_reset_register | ||
if [[ -d /sys/devices/platform/SMF.512/hwmon/ ]]; then | ||
is_thermal_reboot=$(_is_thermal_reset) | ||
|
||
is_wd_reboot=$(_is_watchdog_reset) | ||
|
||
mbr=$(cat $MAILBOX_POWERON_REASON) | ||
reason=$(echo $mbr | cut -d 'x' -f2) | ||
if [[ $reason = "ff" ]]; then | ||
echo "None" > $REBOOT_REASON_FILE | ||
echo 0xbb > $MAILBOX_POWERON_REASON | ||
elif [[ $is_thermal_reboot = 1 ]]; then | ||
echo 0xee > $MAILBOX_POWERON_REASON | ||
elif [[ $is_wd_reboot = 1 ]] && [[ $reason != "cc" ]]; then | ||
echo 0xdd > $MAILBOX_POWERON_REASON | ||
elif [[ $reason = "cc" ]]; then | ||
echo 0xaa > $MAILBOX_POWERON_REASON | ||
else | ||
_is_unknown_reset $is_thermal_reboot | ||
echo 0x99 > $MAILBOX_POWERON_REASON | ||
fi | ||
fi | ||
} | ||
|
||
update_mailbox_register |
1 change: 1 addition & 0 deletions
1
platform/broadcom/sonic-platform-modules-dell/s6100/scripts/warm-reboot_plugin
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
fast-reboot_plugin |
Oops, something went wrong.