Skip to content
Merged
Show file tree
Hide file tree
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
18 changes: 18 additions & 0 deletions dockers/docker-platform-monitor/start.sh.j2
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,24 @@ if [ -e /usr/share/sonic/platform/fancontrol ]; then
supervisorctl start fancontrol
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 %}
supervisorctl start ledd
{% endif %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ common/io_rd_wr.py usr/local/bin
common/dell_lpc_mon.sh usr/local/bin
common/platform_reboot usr/share/sonic/device/x86_64-dell_s6100_c2538-r0
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_disable.sh usr/local/bin
s6100/scripts/sensors usr/bin
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
z9100/scripts/platform_sensors.py usr/local/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/systemd/platform-modules-z9100.service etc/systemd/system
z9100/systemd/z9100-lpc-monitor.service etc/systemd/system
12 changes: 12 additions & 0 deletions platform/broadcom/sonic-platform-modules-dell/debian/rules
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,15 @@ override_dh_auto_build:
if [ $$mod = "s6100" ]; then \
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; \
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 \
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; \
cd $(MOD_SRC_DIR)/$${mod}; \
python2.7 setup.py bdist_wheel -d $(MOD_SRC_DIR)/$${mod}/modules; \
cd $(MOD_SRC_DIR); \
fi; \
echo "making man page alias $$mod -> $$mod APIs";\
make -C $(KERNEL_SRC)/build M=$(MOD_SRC_DIR)/$${mod}/modules; \
Expand All @@ -44,9 +50,15 @@ override_dh_clean:
if [ $$mod = "s6100" ]; then \
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/*.whl; \
rm -rf $(MOD_SRC_DIR)/$${mod}/build; \
rm -rf $(MOD_SRC_DIR)/$${mod}/build/*.egg-info; \
elif [ $$mod = "z9100" ]; then \
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/*.whl; \
rm -rf $(MOD_SRC_DIR)/$${mod}/build; \
rm -rf $(MOD_SRC_DIR)/$${mod}/build/*.egg-info; \
fi; \
make -C $(KERNEL_SRC)/build M=$(MOD_SRC_DIR)/$${mod}/modules clean; \
done)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,14 @@ reset_muxes() {
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

if [[ "$1" == "init" ]]; then
Expand All @@ -240,6 +248,9 @@ if [[ "$1" == "init" ]]; then
switch_board_qsfp "new_device"
switch_board_qsfp_lpmode "disable"
xcvr_presence_interrupts "enable"

install_python_api_package

elif [[ "$1" == "deinit" ]]; then
xcvr_presence_interrupts "disable"
switch_board_sfp "delete_device"
Expand Down
30 changes: 30 additions & 0 deletions platform/broadcom/sonic-platform-modules-dell/s6100/setup.py
Original file line number Diff line number Diff line change
@@ -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',
)

Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@


Original file line number Diff line number Diff line change
@@ -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")

Original file line number Diff line number Diff line change
Expand Up @@ -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

if [[ "$1" == "init" ]]; then
Expand All @@ -220,6 +228,7 @@ if [[ "$1" == "init" ]]; then

#Copy led_proc_init.soc
init_switch_port_led
install_python_api_package

value=0x0
echo $value > /sys/class/i2c-adapter/i2c-14/14-003e/qsfp_lpmode
Expand Down