forked from sonic-net/sonic-buildimage
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[DELLEMC][S6000] Platform 2.0 Reboot Reason and fixed issue in proces…
…s-reboot-cause (sonic-net#3156) Added Reboot Reason for S6000 in platform 2.0 Fixed issue in process-reboot-cause Added package uninstall code in platform de-init code for z9100, s6100 - How I did it -> Added support for S6000 Reboot Reason -> Added platform.py for all platforms -> Verified show reboot-cause command with the code changes. Added UT logs with show reboot-cause -> Modified process-reboot-cause service to start after pmon.service. In S6000, we have to wait for nvram to be loaded. -> If reboot-cause service starts before pmon.service, show reboot-cause is showing incorrect reason. -> Bug fix in process-reboot-cause file - import sonic_platform + import sonic_platform.platform
- Loading branch information
1 parent
efe9438
commit 95558ad
Showing
16 changed files
with
309 additions
and
80 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
4 changes: 4 additions & 0 deletions
4
platform/broadcom/sonic-platform-modules-dell/debian/platform-modules-s6000.install
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 |
---|---|---|
@@ -1,2 +1,6 @@ | ||
s6000/scripts/s6000_platform.sh usr/local/bin | ||
s6000/scripts/reset-qsfp usr/local/bin | ||
s6000/scripts/set-fan-speed usr/local/bin | ||
s6000/systemd/platform-modules-s6000.service etc/systemd/system | ||
common/io_rd_wr.py usr/local/bin | ||
s6000/modules/sonic_platform-1.0-py2-none-any.whl usr/share/sonic/device/x86_64-dell_s6000_s1220-r0 |
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
98 changes: 98 additions & 0 deletions
98
platform/broadcom/sonic-platform-modules-dell/s6000/scripts/s6000_platform.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,98 @@ | ||
#!/bin/bash | ||
|
||
### BEGIN INIT INFO | ||
# Provides: setup-board | ||
# Required-Start: | ||
# Required-Stop: | ||
# Should-Start: | ||
# Should-Stop: | ||
# Default-Start: S | ||
# Default-Stop: 0 6 | ||
# Short-Description: Setup S6000 board. | ||
### END INIT INFO | ||
|
||
add_i2c_devices() { | ||
|
||
echo 24c02 0x50 > /sys/class/i2c-adapter/i2c-1/new_device | ||
echo 24c02 0x51 > /sys/class/i2c-adapter/i2c-1/new_device | ||
echo dni_dps460 0x58 > /sys/class/i2c-adapter/i2c-1/new_device | ||
echo dni_dps460 0x59 > /sys/class/i2c-adapter/i2c-1/new_device | ||
echo jc42 0x18 > /sys/class/i2c-adapter/i2c-10/new_device | ||
echo emc1403 0x4d > /sys/class/i2c-adapter/i2c-10/new_device | ||
echo spd 0x50 > /sys/class/i2c-adapter/i2c-10/new_device | ||
echo 24c02 0x53 > /sys/class/i2c-adapter/i2c-10/new_device | ||
echo max6620 0x29 > /sys/class/i2c-adapter/i2c-11/new_device | ||
echo max6620 0x2a > /sys/class/i2c-adapter/i2c-11/new_device | ||
echo ltc4215 0x40 > /sys/class/i2c-adapter/i2c-11/new_device | ||
echo ltc4215 0x42 > /sys/class/i2c-adapter/i2c-11/new_device | ||
echo tmp75 0x4c > /sys/class/i2c-adapter/i2c-11/new_device | ||
echo tmp75 0x4d > /sys/class/i2c-adapter/i2c-11/new_device | ||
echo tmp75 0x4e > /sys/class/i2c-adapter/i2c-11/new_device | ||
echo 24c02 0x51 > /sys/class/i2c-adapter/i2c-11/new_device | ||
echo 24c02 0x52 > /sys/class/i2c-adapter/i2c-11/new_device | ||
echo 24c02 0x53 > /sys/class/i2c-adapter/i2c-11/new_device | ||
for i in `seq 0 31`; do | ||
echo sff8436 0x50 > /sys/class/i2c-adapter/i2c-$((20+i))/new_device | ||
done | ||
} | ||
|
||
remove_i2c_devices() { | ||
echo 0x50 > /sys/class/i2c-adapter/i2c-1/delete_device | ||
echo 0x51 > /sys/class/i2c-adapter/i2c-1/delete_device | ||
echo 0x58 > /sys/class/i2c-adapter/i2c-1/delete_device | ||
echo 0x59 > /sys/class/i2c-adapter/i2c-1/delete_device | ||
echo 0x18 > /sys/class/i2c-adapter/i2c-10/delete_device | ||
echo 0x4d > /sys/class/i2c-adapter/i2c-10/delete_device | ||
echo 0x50 > /sys/class/i2c-adapter/i2c-10/delete_device | ||
echo 0x53 > /sys/class/i2c-adapter/i2c-10/delete_device | ||
echo 0x29 > /sys/class/i2c-adapter/i2c-11/delete_device | ||
echo 0x2a > /sys/class/i2c-adapter/i2c-11/delete_device | ||
echo 0x40 > /sys/class/i2c-adapter/i2c-11/delete_device | ||
echo 0x42 > /sys/class/i2c-adapter/i2c-11/delete_device | ||
echo 0x4c > /sys/class/i2c-adapter/i2c-11/delete_device | ||
echo 0x4d > /sys/class/i2c-adapter/i2c-11/delete_device | ||
echo 0x4e > /sys/class/i2c-adapter/i2c-11/delete_device | ||
echo 0x51 > /sys/class/i2c-adapter/i2c-11/delete_device | ||
echo 0x52 > /sys/class/i2c-adapter/i2c-11/delete_device | ||
echo 0x53 > /sys/class/i2c-adapter/i2c-11/delete_device | ||
for i in `seq 0 31`; do | ||
echo 0x50 > /sys/class/i2c-adapter/i2c-$((20+i))/delete_device | ||
done | ||
} | ||
|
||
install_python_api_package() { | ||
device="/usr/share/sonic/device" | ||
platform=$(/usr/local/bin/sonic-cfggen -H -v DEVICE_METADATA.localhost.platform) | ||
|
||
if [ -e $device/$platform/sonic_platform-1.0-py2-none-any.whl ]; then | ||
rv=$(pip install $device/$platform/sonic_platform-1.0-py2-none-any.whl) | ||
fi | ||
} | ||
|
||
remove_python_api_package() { | ||
rv=$(pip show sonic-platform > /dev/null 2>/dev/null) | ||
if [ $? -eq 0 ]; then | ||
rv = $(pip uninstall -y sonic-platform > /dev/null 2>/dev/null) | ||
fi | ||
} | ||
|
||
if [[ "$1" == "init" ]]; then | ||
depmod -a | ||
modprobe nvram | ||
modprobe i2c_mux_gpio | ||
modprobe dell_s6000_platform | ||
install_python_api_package | ||
|
||
add_i2c_devices | ||
|
||
/usr/local/bin/set-fan-speed 15000 | ||
/usr/local/bin/reset-qsfp | ||
elif [[ "$1" == "deinit" ]]; then | ||
remove_i2c_devices | ||
rmmod dell_s6000_platform | ||
rmmod nvram | ||
rmmod i2c_mux_gpio | ||
remove_python_api_package | ||
else | ||
echo "s6000_platform : Invalid option !" | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../s6100/setup.py |
2 changes: 2 additions & 0 deletions
2
platform/broadcom/sonic-platform-modules-dell/s6000/sonic_platform/__init__.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,2 @@ | ||
__all__ = ["platform", "chassis"] | ||
from sonic_platform import * |
61 changes: 61 additions & 0 deletions
61
platform/broadcom/sonic-platform-modules-dell/s6000/sonic_platform/chassis.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,61 @@ | ||
#!/usr/bin/env python | ||
|
||
############################################################################# | ||
# | ||
# Module contains an implementation of SONiC Platform Base API and | ||
# provides the platform information | ||
# | ||
############################################################################# | ||
|
||
try: | ||
import os | ||
from sonic_platform_base.chassis_base import ChassisBase | ||
except ImportError as e: | ||
raise ImportError(str(e) + "- required module not found") | ||
|
||
|
||
class Chassis(ChassisBase): | ||
""" | ||
DELLEMC Platform-specific Chassis class | ||
""" | ||
|
||
MAILBOX_DIR = "/sys/devices/platform/dell-s6000-cpld.0" | ||
|
||
reset_reason_dict = {} | ||
reset_reason_dict[0xe] = ChassisBase.REBOOT_CAUSE_NON_HARDWARE | ||
reset_reason_dict[0x6] = ChassisBase.REBOOT_CAUSE_NON_HARDWARE | ||
|
||
def __init__(self): | ||
ChassisBase.__init__(self) | ||
|
||
def get_register(self, reg_name): | ||
rv = 'ERR' | ||
mb_reg_file = self.MAILBOX_DIR+'/'+reg_name | ||
|
||
if (not os.path.isfile(mb_reg_file)): | ||
return rv | ||
|
||
try: | ||
with open(mb_reg_file, 'r') as fd: | ||
rv = fd.read() | ||
except Exception as error: | ||
rv = 'ERR' | ||
|
||
rv = rv.rstrip('\r\n') | ||
rv = rv.lstrip(" ") | ||
return rv | ||
|
||
def get_reboot_cause(self): | ||
""" | ||
Retrieves the cause of the previous reboot | ||
""" | ||
reset_reason = int(self.get_register('last_reboot_reason'), base=16) | ||
|
||
# In S6000, We track the reboot reason by writing the reason in | ||
# NVRAM. Only Warmboot and Coldboot reason are supported here. | ||
|
||
if (reset_reason in self.reset_reason_dict): | ||
return (self.reset_reason_dict[reset_reason], None) | ||
|
||
return (ChassisBase.REBOOT_CAUSE_HARDWARE_OTHER, "Invalid Reason") | ||
|
26 changes: 26 additions & 0 deletions
26
platform/broadcom/sonic-platform-modules-dell/s6000/sonic_platform/platform.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,26 @@ | ||
#!/usr/bin/env python | ||
|
||
############################################################################# | ||
# | ||
# Module contains an implementation of SONiC Platform Base API and | ||
# provides the platform information | ||
# | ||
############################################################################# | ||
|
||
try: | ||
import os | ||
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() | ||
|
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
Oops, something went wrong.