[devices]: DELL Platform 2.0 API Infra and Reboot Reason support in Z9100 & S6100 (#3063)
This commit is contained in:
parent
206ca1b092
commit
56608bf06b
@ -37,6 +37,24 @@ if [ -e /usr/share/sonic/platform/fancontrol ]; then
|
|||||||
supervisorctl start fancontrol
|
supervisorctl start fancontrol
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
# If the sonic-platform package is not installed, try to install it
|
||||||
|
pip show sonic-platform > /dev/null 2>&1
|
||||||
|
if [ $? -ne 0 ]; then
|
||||||
|
SONIC_PLATFORM_WHEEL="/usr/share/sonic/platform/sonic_platform-1.0-py2-none-any.whl"
|
||||||
|
echo "sonic-platform package not installed, attempting to install..."
|
||||||
|
if [ -e ${SONIC_PLATFORM_WHEEL} ]; then
|
||||||
|
pip install ${SONIC_PLATFORM_WHEEL}
|
||||||
|
if [ $? -eq 0 ]; then
|
||||||
|
echo "Successfully installed ${SONIC_PLATFORM_WHEEL}"
|
||||||
|
else
|
||||||
|
echo "Error: Failed to install ${SONIC_PLATFORM_WHEEL}"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo "Error: Unable to locate ${SONIC_PLATFORM_WHEEL}"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
{% if not skip_ledd %}
|
{% if not skip_ledd %}
|
||||||
supervisorctl start ledd
|
supervisorctl start ledd
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
@ -5,6 +5,7 @@ common/io_rd_wr.py usr/local/bin
|
|||||||
common/dell_lpc_mon.sh usr/local/bin
|
common/dell_lpc_mon.sh usr/local/bin
|
||||||
common/platform_reboot usr/share/sonic/device/x86_64-dell_s6100_c2538-r0
|
common/platform_reboot usr/share/sonic/device/x86_64-dell_s6100_c2538-r0
|
||||||
s6100/scripts/platform_sensors.py usr/local/bin
|
s6100/scripts/platform_sensors.py usr/local/bin
|
||||||
|
s6100/modules/sonic_platform-1.0-py2-none-any.whl usr/share/sonic/device/x86_64-dell_s6100_c2538-r0
|
||||||
s6100/scripts/platform_watchdog_enable.sh usr/local/bin
|
s6100/scripts/platform_watchdog_enable.sh usr/local/bin
|
||||||
s6100/scripts/platform_watchdog_disable.sh usr/local/bin
|
s6100/scripts/platform_watchdog_disable.sh usr/local/bin
|
||||||
s6100/scripts/sensors usr/bin
|
s6100/scripts/sensors usr/bin
|
||||||
|
@ -6,6 +6,7 @@ common/io_rd_wr.py usr/local/bin
|
|||||||
common/platform_reboot usr/share/sonic/device/x86_64-dell_z9100_c2538-r0
|
common/platform_reboot usr/share/sonic/device/x86_64-dell_z9100_c2538-r0
|
||||||
z9100/scripts/platform_sensors.py usr/local/bin
|
z9100/scripts/platform_sensors.py usr/local/bin
|
||||||
z9100/scripts/sensors usr/bin
|
z9100/scripts/sensors usr/bin
|
||||||
|
z9100/modules/sonic_platform-1.0-py2-none-any.whl usr/share/sonic/device/x86_64-dell_z9100_c2538-r0
|
||||||
z9100/cfg/z9100-modules.conf etc/modules-load.d
|
z9100/cfg/z9100-modules.conf etc/modules-load.d
|
||||||
z9100/systemd/platform-modules-z9100.service etc/systemd/system
|
z9100/systemd/platform-modules-z9100.service etc/systemd/system
|
||||||
z9100/systemd/z9100-lpc-monitor.service etc/systemd/system
|
z9100/systemd/z9100-lpc-monitor.service etc/systemd/system
|
||||||
|
@ -16,9 +16,15 @@ override_dh_auto_build:
|
|||||||
if [ $$mod = "s6100" ]; then \
|
if [ $$mod = "s6100" ]; then \
|
||||||
cp $(COMMON_DIR)/dell_pmc.c $(MOD_SRC_DIR)/$${mod}/modules/dell_s6100_lpc.c; \
|
cp $(COMMON_DIR)/dell_pmc.c $(MOD_SRC_DIR)/$${mod}/modules/dell_s6100_lpc.c; \
|
||||||
cp $(COMMON_DIR)/dell_ich.c $(MOD_SRC_DIR)/$${mod}/modules/dell_ich.c; \
|
cp $(COMMON_DIR)/dell_ich.c $(MOD_SRC_DIR)/$${mod}/modules/dell_ich.c; \
|
||||||
|
cd $(MOD_SRC_DIR)/$${mod}; \
|
||||||
|
python2.7 setup.py bdist_wheel -d $(MOD_SRC_DIR)/$${mod}/modules; \
|
||||||
|
cd $(MOD_SRC_DIR); \
|
||||||
elif [ $$mod = "z9100" ]; then \
|
elif [ $$mod = "z9100" ]; then \
|
||||||
cp $(COMMON_DIR)/dell_pmc.c $(MOD_SRC_DIR)/$${mod}/modules/dell_mailbox.c; \
|
cp $(COMMON_DIR)/dell_pmc.c $(MOD_SRC_DIR)/$${mod}/modules/dell_mailbox.c; \
|
||||||
cp $(COMMON_DIR)/dell_ich.c $(MOD_SRC_DIR)/$${mod}/modules/dell_ich.c; \
|
cp $(COMMON_DIR)/dell_ich.c $(MOD_SRC_DIR)/$${mod}/modules/dell_ich.c; \
|
||||||
|
cd $(MOD_SRC_DIR)/$${mod}; \
|
||||||
|
python2.7 setup.py bdist_wheel -d $(MOD_SRC_DIR)/$${mod}/modules; \
|
||||||
|
cd $(MOD_SRC_DIR); \
|
||||||
fi; \
|
fi; \
|
||||||
echo "making man page alias $$mod -> $$mod APIs";\
|
echo "making man page alias $$mod -> $$mod APIs";\
|
||||||
make -C $(KERNEL_SRC)/build M=$(MOD_SRC_DIR)/$${mod}/modules; \
|
make -C $(KERNEL_SRC)/build M=$(MOD_SRC_DIR)/$${mod}/modules; \
|
||||||
@ -44,9 +50,15 @@ override_dh_clean:
|
|||||||
if [ $$mod = "s6100" ]; then \
|
if [ $$mod = "s6100" ]; then \
|
||||||
rm -f $(MOD_SRC_DIR)/$${mod}/modules/dell_s6100_lpc.c; \
|
rm -f $(MOD_SRC_DIR)/$${mod}/modules/dell_s6100_lpc.c; \
|
||||||
rm -f $(MOD_SRC_DIR)/$${mod}/modules/dell_ich.c; \
|
rm -f $(MOD_SRC_DIR)/$${mod}/modules/dell_ich.c; \
|
||||||
|
rm -f $(MOD_SRC_DIR)/$${mod}/modules/*.whl; \
|
||||||
|
rm -rf $(MOD_SRC_DIR)/$${mod}/build; \
|
||||||
|
rm -rf $(MOD_SRC_DIR)/$${mod}/build/*.egg-info; \
|
||||||
elif [ $$mod = "z9100" ]; then \
|
elif [ $$mod = "z9100" ]; then \
|
||||||
rm -f $(MOD_SRC_DIR)/$${mod}/modules/dell_mailbox.c; \
|
rm -f $(MOD_SRC_DIR)/$${mod}/modules/dell_mailbox.c; \
|
||||||
rm -f $(MOD_SRC_DIR)/$${mod}/modules/dell_ich.c; \
|
rm -f $(MOD_SRC_DIR)/$${mod}/modules/dell_ich.c; \
|
||||||
|
rm -f $(MOD_SRC_DIR)/$${mod}/modules/*.whl; \
|
||||||
|
rm -rf $(MOD_SRC_DIR)/$${mod}/build; \
|
||||||
|
rm -rf $(MOD_SRC_DIR)/$${mod}/build/*.egg-info; \
|
||||||
fi; \
|
fi; \
|
||||||
make -C $(KERNEL_SRC)/build M=$(MOD_SRC_DIR)/$${mod}/modules clean; \
|
make -C $(KERNEL_SRC)/build M=$(MOD_SRC_DIR)/$${mod}/modules clean; \
|
||||||
done)
|
done)
|
||||||
|
@ -217,6 +217,14 @@ reset_muxes() {
|
|||||||
io_rd_wr.py --set --val 0xff --offset 0x20b
|
io_rd_wr.py --set --val 0xff --offset 0x20b
|
||||||
}
|
}
|
||||||
|
|
||||||
|
install_python_api_package() {
|
||||||
|
device="/usr/share/sonic/device"
|
||||||
|
platform=$(/usr/local/bin/sonic-cfggen -H -v DEVICE_METADATA.localhost.platform)
|
||||||
|
|
||||||
|
rv=$(pip install $device/$platform/sonic_platform-1.0-py2-none-any.whl)
|
||||||
|
echo "pip install result = $rv"
|
||||||
|
}
|
||||||
|
|
||||||
init_devnum
|
init_devnum
|
||||||
|
|
||||||
if [[ "$1" == "init" ]]; then
|
if [[ "$1" == "init" ]]; then
|
||||||
@ -240,6 +248,9 @@ if [[ "$1" == "init" ]]; then
|
|||||||
switch_board_qsfp "new_device"
|
switch_board_qsfp "new_device"
|
||||||
switch_board_qsfp_lpmode "disable"
|
switch_board_qsfp_lpmode "disable"
|
||||||
xcvr_presence_interrupts "enable"
|
xcvr_presence_interrupts "enable"
|
||||||
|
|
||||||
|
install_python_api_package
|
||||||
|
|
||||||
elif [[ "$1" == "deinit" ]]; then
|
elif [[ "$1" == "deinit" ]]; then
|
||||||
xcvr_presence_interrupts "disable"
|
xcvr_presence_interrupts "disable"
|
||||||
switch_board_sfp "delete_device"
|
switch_board_sfp "delete_device"
|
||||||
|
30
platform/broadcom/sonic-platform-modules-dell/s6100/setup.py
Executable file
30
platform/broadcom/sonic-platform-modules-dell/s6100/setup.py
Executable file
@ -0,0 +1,30 @@
|
|||||||
|
from setuptools import setup
|
||||||
|
|
||||||
|
setup(
|
||||||
|
name='sonic-platform',
|
||||||
|
version='1.0',
|
||||||
|
description='SONiC platform API implementation on DellEmc Platforms',
|
||||||
|
license='Apache 2.0',
|
||||||
|
author='SONiC Team',
|
||||||
|
author_email='linuxnetdev@microsoft.com',
|
||||||
|
url='https://github.com/Azure/sonic-buildimage',
|
||||||
|
maintainer='DellEMC',
|
||||||
|
maintainer_email='dell-sonic@dell.com',
|
||||||
|
packages=[
|
||||||
|
'sonic_platform',
|
||||||
|
],
|
||||||
|
classifiers=[
|
||||||
|
'Development Status :: 3 - Alpha',
|
||||||
|
'Environment :: Plugins',
|
||||||
|
'Intended Audience :: Developers',
|
||||||
|
'Intended Audience :: Information Technology',
|
||||||
|
'Intended Audience :: System Administrators',
|
||||||
|
'License :: OSI Approved :: Apache Software License',
|
||||||
|
'Natural Language :: English',
|
||||||
|
'Operating System :: POSIX :: Linux',
|
||||||
|
'Programming Language :: Python :: 2.7',
|
||||||
|
'Topic :: Utilities',
|
||||||
|
],
|
||||||
|
keywords='sonic SONiC platform PLATFORM',
|
||||||
|
)
|
||||||
|
|
@ -0,0 +1,2 @@
|
|||||||
|
|
||||||
|
|
@ -0,0 +1,82 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
|
||||||
|
#############################################################################
|
||||||
|
# DELLEMC
|
||||||
|
#
|
||||||
|
# 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
|
||||||
|
"""
|
||||||
|
|
||||||
|
HWMON_DIR = "/sys/devices/platform/SMF.512/hwmon/"
|
||||||
|
HWMON_NODE = os.listdir(HWMON_DIR)[0]
|
||||||
|
MAILBOX_DIR = HWMON_DIR + HWMON_NODE
|
||||||
|
|
||||||
|
reset_reason_dict = {}
|
||||||
|
reset_reason_dict[11] = ChassisBase.REBOOT_CAUSE_POWER_LOSS
|
||||||
|
reset_reason_dict[33] = ChassisBase.REBOOT_CAUSE_WATCHDOG
|
||||||
|
reset_reason_dict[44] = ChassisBase.REBOOT_CAUSE_NON_HARDWARE
|
||||||
|
reset_reason_dict[55] = ChassisBase.REBOOT_CAUSE_NON_HARDWARE
|
||||||
|
|
||||||
|
power_reason_dict = {}
|
||||||
|
power_reason_dict[11] = ChassisBase.REBOOT_CAUSE_POWER_LOSS
|
||||||
|
power_reason_dict[22] = ChassisBase.REBOOT_CAUSE_THERMAL_OVERLOAD_CPU
|
||||||
|
power_reason_dict[33] = ChassisBase.REBOOT_CAUSE_THERMAL_OVERLOAD_ASIC
|
||||||
|
power_reason_dict[44] = ChassisBase.REBOOT_CAUSE_INSUFFICIENT_FAN_SPEED
|
||||||
|
|
||||||
|
def __init__(self):
|
||||||
|
ChassisBase.__init__(self)
|
||||||
|
|
||||||
|
def get_pmc_register(self, reg_name):
|
||||||
|
rv = 'ERR'
|
||||||
|
mb_reg_file = self.MAILBOX_DIR+'/'+reg_name
|
||||||
|
|
||||||
|
if (not os.path.isfile(mb_reg_file)):
|
||||||
|
print mb_reg_file, 'not found !'
|
||||||
|
return rv
|
||||||
|
|
||||||
|
try:
|
||||||
|
with open(mb_reg_file, 'r') as fd:
|
||||||
|
rv = fd.read()
|
||||||
|
except Exception as error:
|
||||||
|
logging.error("Unable to open ", mb_reg_file, "file !")
|
||||||
|
|
||||||
|
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_pmc_register('smf_reset_reason'))
|
||||||
|
power_reason = int(self.get_pmc_register('smf_poweron_reason'))
|
||||||
|
|
||||||
|
# Reset_Reason = 11 ==> PowerLoss
|
||||||
|
# So return the reboot reason from Last Power_Reason Dictionary
|
||||||
|
# If Reset_Reason is not 11 return from Reset_Reason dictionary
|
||||||
|
# Also check if power_reason, reset_reason are valid values by
|
||||||
|
# checking key presence in dictionary else return
|
||||||
|
# REBOOT_CAUSE_HARDWARE_OTHER as the Power_Reason and Reset_Reason
|
||||||
|
# registers returned invalid data
|
||||||
|
if (reset_reason == 11):
|
||||||
|
if (power_reason in self.power_reason_dict):
|
||||||
|
return (self.power_reason_dict[power_reason], None)
|
||||||
|
else:
|
||||||
|
if (reset_reason in self.reset_reason_dict):
|
||||||
|
return (self.reset_reason_dict[reset_reason], None)
|
||||||
|
|
||||||
|
return (ChassisBase.REBOOT_CAUSE_HARDWARE_OTHER, "Invalid Reason")
|
||||||
|
|
@ -200,6 +200,14 @@ init_switch_port_led() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
install_python_api_package() {
|
||||||
|
device="/usr/share/sonic/device"
|
||||||
|
platform=$(/usr/local/bin/sonic-cfggen -H -v DEVICE_METADATA.localhost.platform)
|
||||||
|
|
||||||
|
rv=$(pip install $device/$platform/sonic_platform-1.0-py2-none-any.whl)
|
||||||
|
echo "pip install result = $rv"
|
||||||
|
}
|
||||||
|
|
||||||
init_devnum
|
init_devnum
|
||||||
|
|
||||||
if [[ "$1" == "init" ]]; then
|
if [[ "$1" == "init" ]]; then
|
||||||
@ -220,6 +228,7 @@ if [[ "$1" == "init" ]]; then
|
|||||||
|
|
||||||
#Copy led_proc_init.soc
|
#Copy led_proc_init.soc
|
||||||
init_switch_port_led
|
init_switch_port_led
|
||||||
|
install_python_api_package
|
||||||
|
|
||||||
value=0x0
|
value=0x0
|
||||||
echo $value > /sys/class/i2c-adapter/i2c-14/14-003e/qsfp_lpmode
|
echo $value > /sys/class/i2c-adapter/i2c-14/14-003e/qsfp_lpmode
|
||||||
|
1
platform/broadcom/sonic-platform-modules-dell/z9100/setup.py
Symbolic link
1
platform/broadcom/sonic-platform-modules-dell/z9100/setup.py
Symbolic link
@ -0,0 +1 @@
|
|||||||
|
../s6100/setup.py
|
@ -0,0 +1 @@
|
|||||||
|
../../s6100/sonic_platform/__init__.py
|
@ -0,0 +1 @@
|
|||||||
|
../../s6100/sonic_platform/chassis.py
|
Loading…
Reference in New Issue
Block a user