Skip to content

[AS5835-54X] Fix chassis health led bug #8276

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 20 commits into
base: 202012
Choose a base branch
from
Open
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
1 change: 1 addition & 0 deletions device/accton/x86_64-accton_as5835_54x-r0/installer.conf
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
CONSOLE_PORT=0x3f8
CONSOLE_DEV=0
CONSOLE_SPEED=115200
ONIE_PLATFORM_EXTRA_CMDLINE_LINUX="modprobe.blacklist=i2c-ismt,i2c_ismt,i2c-i801,i2c_i801"
135 changes: 135 additions & 0 deletions device/accton/x86_64-accton_as5835_54x-r0/pcie.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
- bus: '00'
dev: '00'
fn: '0'
id: 1980
name: 'Host bridge: Intel Corporation Atom Processor C3000 Series System Agent'
- bus: '00'
dev: '04'
fn: '0'
id: 19a1
name: 'Host bridge: Intel Corporation Atom Processor C3000 Series Error Registers'
- bus: '00'
dev: '05'
fn: '0'
id: 19a2
name: 'Generic system peripheral [0807]: Intel Corporation Atom Processor C3000 Series Root Complex Event Collector'
- bus: '00'
dev: '06'
fn: '0'
id: 19a3
name: 'PCI bridge: Intel Corporation Atom Processor C3000 Series Integrated QAT Root Port'
- bus: '00'
dev: 09
fn: '0'
id: 0x19a4
name: 'PCI bridge: Intel Corporation Atom Processor C3000 Series PCI Express Root Port #0 '
- bus: '00'
dev: 'b'
fn: '0'
id: 19a6
name: 'PCI bridge: Intel Corporation Atom Processor C3000 Series PCI Express Root Port #2'
- bus: '00'
dev: 'e'
fn: '0'
id: 19a8
name: 'PCI bridge: Intel Corporation Atom Processor C3000 Series PCI Express Root Port #4 '
- bus: '00'
dev: '10'
fn: '0'
id: 19aa
name: 'PCI bridge: Intel Corporation Atom Processor C3000 Series PCI Express Root Port #6'
- bus: '00'
dev: '12'
fn: '0'
id: 19ac
name: 'System peripheral: Intel Corporation Atom Processor C3000 Series SMBus Contoller'
- bus: '00'
dev: '013'
fn: '0'
id: 19b2
name: 'SATA controller: Intel Corporation Atom Processor C3000 Series SATA Controller 0'
- bus: '00'
dev: '15'
fn: '0'
id: 19d0
name: 'USB controller: Intel Corporation Atom Processor C3000 Series USB 3.0 xHCI Controller'
- bus: '00'
dev: '16'
fn: '0'
id: 19d1
name: 'PCI bridge: Intel Corporation Atom Processor C3000 Series Integrated LAN Root Port #0'
- bus: '00'
dev: '17'
fn: '0'
id: 19d2
name: 'PCI bridge: Intel Corporation Atom Processor C3000 Series Integrated LAN Root Port #1'
- bus: '00'
dev: '18'
fn: '0'
id: 19d3
name: 'Communication controller: Intel Corporation Atom Processor C3000 Series ME HECI 1'
- bus: '00'
dev: '1a'
fn: '0'
id: 19d8
name: 'Serial controller: Intel Corporation Atom Processor C3000 Series HSUART Controller'
- bus: '00'
dev: '1a'
fn: '1'
id: 19d8
name: 'Serial controller: Intel Corporation Atom Processor C3000 Series HSUART Controller'
- bus: '00'
dev: '1a'
fn: '2'
id: 19d8
name: 'Serial controller: Intel Corporation Atom Processor C3000 Series HSUART Controller'
- bus: '00'
dev: '1f'
fn: '0'
id: 19dc
name: 'ISA bridge: Intel Corporation Atom Processor C3000 Series LPC or eSPI'
- bus: '00'
dev: '1f'
fn: '1'
id: 19dd
name: 'Memory controller: Intel Corporation Atom Processor C3000 Series Primary to Side Band (P2SB) Bridge'
- bus: '00'
dev: '1f'
fn: '2'
id: 19de
name: 'Memory controller: Intel Corporation Atom Processor C3000 Series Power Management Controller'
- bus: '00'
dev: '1f'
fn: '4'
id: 19df
name: 'SMBus: Intel Corporation Atom Processor C3000 Series SMBus controller'
- bus: '00'
dev: '1f'
fn: '5'
id: 0x19e0
name: 'Serial bus controller [0c80]: Intel Corporation Atom Processor C3000 Series SPI Controller'
- bus: '01'
dev: '00'
fn: '0'
id: 19e2
name: 'Co-processor: Intel Corporation Atom Processor C3000 Series QuickAssist Technology'
- bus: '02'
dev: '00'
fn: '0'
id: b771
name: 'Ethernet controller: Broadcom Inc. and subsidiaries Device b771'
- bus: '05'
dev: '00'
fn: '0'
id: 1533
name: 'Ethernet controller: Intel Corporation I210 Gigabit Network Connection'
- bus: '06'
dev: '00'
fn: '0'
id: 15c2
name: 'Ethernet controller: Intel Corporation Ethernet Connection X553 Backplane'
- bus: '08'
dev: '00'
fn: '0'
id: 15e5
name: 'Ethernet controller: Intel Corporation Ethernet Connection X553 1GbE'
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ def get_cage_num(self, port_num):
cage_num = port_num
if (port_num >= self.QSFP_PORT_START):
cage_num = (port_num - self.QSFP_PORT_START)/4
cage_num = cage_num + self.QSFP_PORT_START
cage_num = int(cage_num + self.QSFP_PORT_START)

return cage_num

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{
"skip_ledd": true,
"skip_pcied": true
"skip_ledd": true
}

Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,13 @@
PMON_REBOOT_CAUSE_PATH = "/usr/share/sonic/platform/api_files/reboot-cause/"
REBOOT_CAUSE_FILE = "reboot-cause.txt"
PREV_REBOOT_CAUSE_FILE = "previous-reboot-cause.txt"
HOST_CHK_CMD = "docker > /dev/null 2>&1"
HOST_CHK_CMD = "which systemctl > /dev/null 2>&1"
SYSLED_FNODE= "/sys/class/leds/as5835_54x_led::diag/brightness"

SYSLED_MODES = {
"0" : "STATUS_LED_COLOR_OFF",
"1" : "STATUS_LED_COLOR_GREEN",
"2" : "STATUS_LED_COLOR_AMBER",
"5" : "STATUS_LED_COLOR_GREEN_BLINK"
"3" : "STATUS_LED_COLOR_AMBER"
}


Expand All @@ -45,7 +44,6 @@ class Chassis(ChassisBase):
def __init__(self):
ChassisBase.__init__(self)
self._api_helper = APIHelper()
self._api_helper = APIHelper()
self.is_host = self._api_helper.is_host()

self.config_data = {}
Expand All @@ -62,6 +60,7 @@ def __initialize_sfp(self):
for index in range(0, PORT_END):
sfp = Sfp(index)
self._sfp_list.append(sfp)
self._sfpevent = SfpEvent(self._sfp_list)
self.sfp_module_initialized = True

def __initialize_fan(self):
Expand Down Expand Up @@ -97,7 +96,7 @@ def __initialize_watchdog(self):
from sonic_platform.watchdog import Watchdog
self._watchdog = Watchdog()


def __is_host(self):
return os.system(HOST_CHK_CMD) == 0

Expand All @@ -116,8 +115,7 @@ def get_name(self):
Returns:
string: The name of the device
"""

return self._api_helper.hwsku
return self._eeprom.get_product_name()

def get_presence(self):
"""
Expand Down Expand Up @@ -193,10 +191,7 @@ def get_change_event(self, timeout=0):
# SFP event
if not self.sfp_module_initialized:
self.__initialize_sfp()

status, sfp_event = SfpEvent(self._sfp_list).get_sfp_event(timeout)

return status, sfp_event
return self._sfpevent.get_sfp_event(timeout)

def get_sfp(self, index):
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,11 @@ def __get_bios_version(self):
def __get_cpld_version(self):
# Retrieves the CPLD firmware version
cpld_version = dict()
for cpld_name in CPLD_ADDR_MAPPING:
for cpld_name in CPLD_ADDR_MAPPING:
try:
cpld_path = "{}{}{}".format(SYSFS_PATH, CPLD_ADDR_MAPPING[cpld_name], '/version')
cpld_version_raw= self._api_helper.read_txt_file(cpld_path)
cpld_version[cpld_name] = "{}".format(int(cpld_version_raw,16))
cpld_version[cpld_name] = "{}".format(int(cpld_version_raw,10))
except Exception as e:
print('Get exception when read cpld')
cpld_version[cpld_name] = 'None'
Expand All @@ -100,7 +100,7 @@ def get_description(self):
A string containing the description of the component
"""
return COMPONENT_LIST[self.index][1]
#return "testhwsku"


def get_firmware_version(self):
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class Tlv(eeprom_tlvinfo.TlvInfoDecoder):
EEPROM_DECODE_HEADLINES = 6

def __init__(self):
self._eeprom_path = "/sys/bus/i2c/devices/0-0057/eeprom"
self._eeprom_path = "/sys/bus/i2c/devices/1-0057/eeprom"
super(Tlv, self).__init__(self._eeprom_path, 0, '', True)
self._eeprom = self._load_eeprom()

Expand All @@ -33,7 +33,7 @@ def __parse_output(self, decode_output):
for line in lines:
try:
match = re.search(
'(0x[0-9a-fA-F]{2})([\s]+[\S]+[\s]+)([\S]+)', line)
'(0x[0-9a-fA-F]{2})([\s]+[\S]+[\s]+)(.+)', line)
if match is not None:
idx = match.group(1)
value = match.group(3).rstrip('\0')
Expand Down Expand Up @@ -129,3 +129,6 @@ def get_serial(self):

def get_mac(self):
return self._eeprom.get('0x24', NULL)

def get_product_name(self):
return self._eeprom.get('0x21', NULL)
47 changes: 26 additions & 21 deletions device/accton/x86_64-accton_as5835_54x-r0/sonic_platform/event.py
Original file line number Diff line number Diff line change
@@ -1,42 +1,49 @@
try:
import time
from .helper import APIHelper
from sonic_py_common.logger import Logger
except ImportError as e:
raise ImportError(repr(e) + " - required module not found")

POLL_INTERVAL_IN_SEC = 1

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

def __init__(self, sfp_list):
self._api_helper = APIHelper()
self._sfp_list = sfp_list
self._logger = Logger()
self._sfp_change_event_data = {'present': 0}

sfp_change_event_data = {'valid': 0, 'last': 0, 'present': 0}
def get_sfp_event(self, timeout=2000):
now = time.time()
port_dict = {}
change_dict = {}
change_dict['sfp'] = port_dict

if timeout < 1000:
timeout = 1000
timeout = timeout / float(1000) # Convert to secs

if now < (self.sfp_change_event_data['last'] + timeout) and self.sfp_change_event_data['valid']:
return True, change_dict

def get_presence_bitmap(self):
bitmap = 0
for sfp in self._sfp_list:
modpres = sfp.get_presence()
i=sfp.port_num-1
if modpres:
bitmap = bitmap | (1 << i)
return bitmap

changed_ports = self.sfp_change_event_data['present'] ^ bitmap
if changed_ports:
def get_sfp_event(self, timeout=2000):
port_dict = {}
change_dict = {}
change_dict['sfp'] = port_dict

if timeout < 1000:
cd_ms = 1000
else:
cd_ms = timeout

while cd_ms > 0:
bitmap = self.get_presence_bitmap()
changed_ports = self._sfp_change_event_data['present'] ^ bitmap
if changed_ports != 0:
break
time.sleep(POLL_INTERVAL_IN_SEC)
# timeout=0 means wait for event forever
if timeout != 0:
cd_ms = cd_ms - POLL_INTERVAL_IN_SEC * 1000

if changed_ports != 0:
for sfp in self._sfp_list:
i=sfp.port_num-1
if (changed_ports & (1 << i)):
Expand All @@ -47,9 +54,7 @@ def get_sfp_event(self, timeout=2000):


# Update the cache dict
self.sfp_change_event_data['present'] = bitmap
self.sfp_change_event_data['last'] = now
self.sfp_change_event_data['valid'] = 1
self._sfp_change_event_data['present'] = bitmap
return True, change_dict
else:
return True, change_dict
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ def get_position_in_parent(self):
integer: The 1-based relative physical position in parent device
or -1 if cannot determine the position
"""
return (self.fan_tray_index+1) \
return (self.fan_index+1) \
if not self.is_psu_fan else (self.psu_index+1)

def is_replaceable(self):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,17 @@ def get_position_in_parent(self):
"""
return (self.fantrayindex+1)

def set_status_led(self, color):
"""
Sets the state of the fan module status LED
Args:
color: A string representing the color with which to set the
fan module status LED
Returns:
bool: True if status LED state is set successfully, False if not
"""
return False #Not supported

def is_replaceable(self):
"""
Indicate whether this device is replaceable.
Expand Down
19 changes: 19 additions & 0 deletions device/accton/x86_64-accton_as5835_54x-r0/sonic_platform/pcie.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#############################################################################
# Edgecore
#
# Module contains an implementation of SONiC Platform Base API and
# provides the fan status which are available in the platform
# Base PCIe class
#############################################################################

try:
from sonic_platform_base.sonic_pcie.pcie_common import PcieUtil
except ImportError as e:
raise ImportError(str(e) + "- required module not found")


class Pcie(PcieUtil):
"""Edgecore Platform-specific PCIe class"""

def __init__(self, platform_path):
PcieUtil.__init__(self, platform_path)
Loading