DellEMC: Z9264-Platform2.0 Implementation [Reboot Cause] (#4246)
- Added get_reboot_cause() API implementation in chassis.py - Added new file platform.py for platform2.0 API implementation.
This commit is contained in:
parent
760e763935
commit
0b52be3e5f
@ -183,6 +183,18 @@ platform_firmware_versions()
|
||||
echo "Slave CPLD 4: $((r_maj)).$((r_min))" >> $FIRMWARE_VERSION_FILE
|
||||
}
|
||||
|
||||
get_reboot_cause() {
|
||||
REBOOT_REASON_FILE="/host/reboot-cause/platform/reboot_reason"
|
||||
resource="/sys/bus/pci/devices/0000:04:00.0/resource0"
|
||||
|
||||
# Handle First Boot into software version with reboot cause determination support
|
||||
if [[ ! -e $REBOOT_REASON_FILE ]]; then
|
||||
echo "0" > $REBOOT_REASON_FILE
|
||||
else
|
||||
/usr/bin/pcisysfs.py --get --offset 0x18 --res $resource | sed '1d; s/.*:\(.*\)$/\1/;' > $REBOOT_REASON_FILE
|
||||
fi
|
||||
/usr/bin/pcisysfs.py --set --val 0x0 --offset 0x18 --res $resource
|
||||
}
|
||||
|
||||
init_devnum
|
||||
|
||||
@ -194,6 +206,7 @@ if [ "$1" == "init" ]; then
|
||||
modprobe i2c_ocores
|
||||
modprobe dell_z9264f_fpga_ocores
|
||||
sys_eeprom "new_device"
|
||||
get_reboot_cause
|
||||
switch_board_qsfp_mux "new_device"
|
||||
switch_board_qsfp "new_device"
|
||||
switch_board_sfp "new_device"
|
||||
|
@ -1,3 +1,3 @@
|
||||
__all__ = ["chassis", "sfp", "eeprom"]
|
||||
__all__ = ["platform", "chassis", "sfp", "eeprom", "component", "psu", "thermal"]
|
||||
from sonic_platform import *
|
||||
|
||||
|
@ -30,6 +30,7 @@ class Chassis(ChassisBase):
|
||||
DELLEMC Platform-specific Chassis class
|
||||
"""
|
||||
|
||||
REBOOT_CAUSE_PATH = "/host/reboot-cause/platform/reboot_reason"
|
||||
OIR_FD_PATH = "/sys/bus/pci/devices/0000:04:00.0/port_msi"
|
||||
|
||||
oir_fd = -1
|
||||
@ -263,3 +264,40 @@ class Chassis(ChassisBase):
|
||||
values.
|
||||
"""
|
||||
return self._eeprom.system_eeprom_info()
|
||||
|
||||
def get_reboot_cause(self):
|
||||
"""
|
||||
Retrieves the cause of the previous reboot
|
||||
Returns:
|
||||
A tuple (string, string) where the first element is a string
|
||||
containing the cause of the previous reboot. This string must be
|
||||
one of the predefined strings in this class. If the first string
|
||||
is "REBOOT_CAUSE_HARDWARE_OTHER", the second string can be used
|
||||
to pass a description of the reboot cause.
|
||||
"""
|
||||
try:
|
||||
with open(self.REBOOT_CAUSE_PATH) as fd:
|
||||
reboot_cause = int(fd.read(), 16)
|
||||
except:
|
||||
return (self.REBOOT_CAUSE_NON_HARDWARE, None)
|
||||
|
||||
if reboot_cause & 0x1:
|
||||
return (self.REBOOT_CAUSE_POWER_LOSS, None)
|
||||
elif reboot_cause & 0x2:
|
||||
return (self.REBOOT_CAUSE_NON_HARDWARE, None)
|
||||
elif reboot_cause & 0x4:
|
||||
return (self.REBOOT_CAUSE_HARDWARE_OTHER, "PSU Shutdown")
|
||||
elif reboot_cause & 0x8:
|
||||
return (self.REBOOT_CAUSE_THERMAL_OVERLOAD_CPU, None)
|
||||
elif reboot_cause & 0x10:
|
||||
return (self.REBOOT_CAUSE_WATCHDOG, None)
|
||||
elif reboot_cause & 0x20:
|
||||
return (self.REBOOT_CAUSE_HARDWARE_OTHER, "BMC Shutdown")
|
||||
elif reboot_cause & 0x40:
|
||||
return (self.REBOOT_CAUSE_HARDWARE_OTHER, "Hot-Swap Shutdown")
|
||||
elif reboot_cause & 0x80:
|
||||
return (self.REBOOT_CAUSE_HARDWARE_OTHER, "Reset Button Shutdown")
|
||||
elif reboot_cause & 0x100:
|
||||
return (self.REBOOT_CAUSE_HARDWARE_OTHER, "Reset Button Cold Reboot")
|
||||
else:
|
||||
return (self.REBOOT_CAUSE_NON_HARDWARE, None)
|
||||
|
@ -0,0 +1,24 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
#############################################################################
|
||||
#
|
||||
# Module contains an implementation of SONiC Platform Base API and
|
||||
# provides the platform information
|
||||
#
|
||||
#############################################################################
|
||||
|
||||
try:
|
||||
from sonic_platform_base.platform_base import PlatformBase
|
||||
from sonic_platform.chassis import Chassis
|
||||
except ImportError as e:
|
||||
raise ImportError(str(e) + "- required module not found")
|
||||
|
||||
|
||||
class Platform(PlatformBase):
|
||||
"""
|
||||
DELLEMC Platform-specific class
|
||||
"""
|
||||
|
||||
def __init__(self):
|
||||
PlatformBase.__init__(self)
|
||||
self._chassis = Chassis()
|
Loading…
Reference in New Issue
Block a user