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
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
"skip_ledd": true,
"skip_xcvrd": false,
"skip_psud": false,
"skip_syseepromd": false
"skip_syseepromd": false,
"skip_fancontrol": true
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
{
"eeprom": "/sys/class/i2c-adapter/i2c-0/0-0056/eeprom",
"get_reboot_cause": {
"output_source": "ipmitool",
"command": "ipmitool raw 0x3a 0x0c 0x0 0x2 0x06",
"output_translator": {
"00": "Hardware - Other",
"11": "Hardware - Other",
"22": "Non-Hardware",
"33": "Hardware - Other",
"44": "Non-Hardware",
"55": "Non-Hardware",
"77": "Watchdog",
"88": "Thermal Overload: CPU",
"99": "Thermal Overload: ASIC"
}
},
"get_reboot_description": {
"output_source": "ipmitool",
"command": "ipmitool raw 0x3a 0x0c 0x0 0x2 0x06",
"output_translator": {
"00": "The last reset is power cycle reset (set register 0xA164)",
"11": "The last reset is Power on reset",
"22": "The last reset is soft-set CPU warm reset",
"33": "The last reset is soft-set CPU cold reset",
"44": "The last reset is CPU warm reset",
"55": "The last reset is CPU cold reset",
"77": "The last reset is watchdog reset",
"88": "The last reset is CPU thermal overload",
"99": "The last reset is ASIC thermal overload"
}
},
"get_watchdog": {
"output_source": "class",
"host_path": "/usr/share/sonic/device/x86_64-cel_seastone_2-r0/sonic_platform_config/watchdog.py",
"pmon_path": "/usr/share/sonic/platform/sonic_platform_config/watchdog.py",
"class": "Watchdog"
},
"get_change_event": {
"output_source": "class",
"host_path": "/usr/share/sonic/device/x86_64-cel_seastone_2-r0/sonic_platform_config/event.py",
"pmon_path": "/usr/share/sonic/platform/sonic_platform_config/event.py",
"class": "SfpEvent"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
{
"component_num": 5,
"get_name": {
"output_source": "value_list",
"value_list": [
"BIOS",
"CPLD_BASEBOARD",
"CPLD_SWITCHBOARD",
"FPGA",
"BMC"
]
},
"get_description": {
"output_source": "value_list",
"value_list": [
"Used to perform hardware initialization during the booting process",
"Used to control the system power & reset, Control FAN, UART Mux etc",
"Used for managing QSFP ports",
"Used for managing I2C, SPI, PCIe etc",
"Used for monitoring and managing whole system"
]
},
"get_firmware_version": {
"output_source": "function",
"function": [
"_get_bios_ver",
"_get_base_cpld_ver",
"_get_sw_cpld_ver",
"_get_fpga_ver",
"_get_bmc_ver"
]
},
"_get_bmc_ver": {
"output_source": "ipmitool",
"command": "ipmitool mc info | grep 'Firmware Revision'",
"output_translator": "'{}'.split(':')[-1].strip()"
},
"_get_bios_ver": {
"output_source": "txt_file",
"path": "/sys/class/dmi/id/bios_version"
},
"_get_base_cpld_ver": {
"output_source": "hex_version_file",
"num_of_points": 1,
"num_of_bits": 8,
"path": "/sys/devices/platform/baseboard/version"
},
"_get_sw_cpld_ver": {
"output_source": "hex_version_getreg",
"num_of_points": 1,
"num_of_bits": 8,
"reg_addr": "0x00",
"path": "/sys/devices/platform/switchboard/CPLD1/getreg"
},
"_get_fpga_ver": {
"output_source": "hex_version_getreg",
"num_of_points": 1,
"num_of_bits": 32,
"reg_addr": "0x00",
"path": "/sys/devices/platform/switchboard/FPGA/getreg"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
#!/usr/bin/env python

#############################################################################
# Celestica Seastone2
#
# SfpEvent contains an implementation of SONiC Platform Base API
#
#############################################################################
try:
import time
import os
from sonic_platform.common import Common
except ImportError as e:
raise ImportError(str(e) + "- required module not found")


PLATFORM_PATH = "/sys/devices/platform/"
SWITCH_BRD_PLATFORM = "switchboard"
POLL_INTERVAL = 1


class SfpEvent:
''' Listen to insert/remove sfp events '''

PORT_INFO_DIR = 'SFF'
PATH_INT_SYSFS = "{0}/{port_name}/{type_prefix}_isr_flags"
PATH_INTMASK_SYSFS = "{0}/{port_name}/{type_prefix}_isr_mask"
PATH_PRS_SYSFS = "{0}/{port_name}/{prs_file_name}"
PRESENT_EN = 0x01

def __init__(self, sfp_list):
self.num_sfp = len(sfp_list)
self._api_common = Common()
self._initialize_interrupts()

def _initialize_interrupts(self):
sfp_info_obj = {}
port_info_path = os.path.join(
PLATFORM_PATH, SWITCH_BRD_PLATFORM, self.PORT_INFO_DIR)

for index in range(self.num_sfp):
port_num = index + 1
port_name = "QSFP{}".format(port_num)
port_type = "qsfp"
sysfs_prs_file = "{}_modprs".format(port_type)

sfp_info_obj[index] = {}
sfp_info_obj[index]['intmask_sysfs'] = self.PATH_INTMASK_SYSFS.format(
port_info_path,
port_name=port_name,
type_prefix=port_type)

sfp_info_obj[index]['int_sysfs'] = self.PATH_INT_SYSFS.format(
port_info_path,
port_name=port_name,
type_prefix=port_type)

sfp_info_obj[index]['prs_sysfs'] = self.PATH_PRS_SYSFS.format(
port_info_path,
port_name=port_name,
prs_file_name=sysfs_prs_file)

self._api_common.write_txt_file(
sfp_info_obj[index]["intmask_sysfs"], hex(self.PRESENT_EN))

self.sfp_info_obj = sfp_info_obj

def _is_port_device_present(self, port_idx):
prs_path = self.sfp_info_obj[port_idx]["prs_sysfs"]
is_present = 1 - int(self._api_common.read_txt_file(prs_path))
return is_present

def _update_port_event_object(self, interrup_devices, port_dict):
for port_idx in interrup_devices:
device_id = str(port_idx + 1)
port_dict[device_id] = str(self._is_port_device_present(port_idx))
return port_dict

def _clear_event_flag(self, path):
self._api_common.write_txt_file(path, hex(0xff))
time.sleep(0.1)
self._api_common.write_txt_file(path, hex(0x0))

def _check_all_port_interrupt_event(self):
interrupt_devices = {}
for i in range(self.num_sfp):
int_sysfs = self.sfp_info_obj[i]["int_sysfs"]
interrupt_flags = self._api_common.read_txt_file(int_sysfs)
if interrupt_flags != '0x00':
interrupt_devices[i] = 1
self._clear_event_flag(int_sysfs)
return interrupt_devices

def get_event(self, timeout):
sleep_time = min(
timeout, POLL_INTERVAL) if timeout != 0 else POLL_INTERVAL
start_milli_time = int(round(time.time() * 1000))
int_sfp = {}

while True:
chk_sfp = self._check_all_port_interrupt_event()
int_sfp = self._update_port_event_object(
chk_sfp, int_sfp) if chk_sfp else int_sfp
current_milli_time = int(round(time.time() * 1000))
if (int_sfp) or \
(timeout != 0 and current_milli_time - start_milli_time > timeout):
break

time.sleep(sleep_time)

change_dict = dict()
change_dict['sfp'] = int_sfp

return True, change_dict
Loading