Skip to content
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

[AS7326-56X] Support API2.0 #7443

Open
wants to merge 34 commits into
base: 202012
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
dbbad6b
[AS7326-56X] Support API2.0
Apr 27, 2021
9ce97de
Fix LGTM alerts
Apr 27, 2021
7dccda3
Fix error path in install file
Apr 28, 2021
6d2b4a2
Add port evt change api and update psu.py
May 6, 2021
52d87fd
Fix error path for get serial_num
May 7, 2021
a81b709
Add import sys to chassis.py
May 10, 2021
5bcfd9a
Fix port range error for port-30
May 19, 2021
bb1dc4a
Fix to use QSFP_CONTROL_OFFSET for dom_control_raw
May 21, 2021
0fc6abd
Fix write api in sfp.py
May 28, 2021
7e5b86a
Add fan get_name() and get_status()
Jun 11, 2021
bc267e4
Add retrun fan_name to fan.py
Jun 11, 2021
44e58c3
Modify get_status_led() in psu.py
Jun 11, 2021
314f093
Fix set_lpmode() in sfp.py
Jun 21, 2021
22d32d8
Support show system-health
Jul 15, 2021
fac7842
Remove not need import os
Jul 15, 2021
81d57db
Remvoe not needed code and support python3 for util
Jul 15, 2021
a47d083
Add system-health needed json file
Aug 9, 2021
2b0901f
Fix booting to green_blink for health-monitor
Aug 20, 2021
7534afd
Fix qsfp threshold offset
Aug 31, 2021
85c2529
Modify get_name to use product_name
Sep 16, 2021
239c6b5
Fix get_position_in_parent in fan and thermal
Sep 17, 2021
b868e04
Correct the wait and timeout mechanism for better CPU usage
Oct 15, 2021
104e559
Fix read cpld_version from hex to dec.
Apr 15, 2022
b918b6a
Merge branch '202012' into as7326_20210427_api2.0_202012br
jostar-yang Apr 15, 2022
ba84c90
Merge branch '202012' into as7326_20210427_api2.0_202012br
jostar-yang May 10, 2022
5928195
Fix wrong system eeprom data of 0x25 field
May 10, 2022
0bde3d7
Merge branch 'as7326_20210427_api2.0_202012br' of https://github.com/…
May 10, 2022
ca3c39a
Add pcie.py to fix show pcieinfo fail log
Jul 14, 2022
c74a2c9
Fix LGM alert
Jul 14, 2022
ed97225
Add pcie.yaml file
Jul 22, 2022
3d506e8
Remove "skip_pcied": true
Aug 8, 2022
cda162f
Add set_status_led to fan_drawer.py
jostar-yang Oct 4, 2022
0b5a6a9
Add check power_good for get psu-fan status
jostar-yang Oct 14, 2022
14a0d72
Fix to show psu-fan dir when no power
jostar-yang Oct 17, 2022
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
459 changes: 459 additions & 0 deletions device/accton/x86_64-accton_as7326_56x-r0/pcie.yaml

Large diffs are not rendered by default.

16 changes: 10 additions & 6 deletions device/accton/x86_64-accton_as7326_56x-r0/plugins/eeprom.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,24 @@
#!/usr/bin/env python

try:
import binascii
import time
import optparse
import warnings
import os
import sys
from sonic_eeprom import eeprom_base
from sonic_eeprom import eeprom_tlvinfo
import subprocess
except ImportError as e:
raise ImportError(str(e) + "- required module not found")

except ImportError, e:
raise ImportError (str(e) + "- required module not found")

class board(eeprom_tlvinfo.TlvInfoDecoder):
_TLV_INFO_MAX_LEN = 256

def __init__(self, name, path, cpld_root, ro):
self.eeprom_path = "/sys/bus/i2c/devices/0-0056/eeprom"
exists = os.path.isfile('/sys/bus/i2c/devices/0-0056/eeprom')
if (exists is True):
self.eeprom_path = "/sys/bus/i2c/devices/0-0056/eeprom"
else:
self.eeprom_path = "/sys/bus/i2c/devices/0-0057/eeprom"

super(board, self).__init__(self.eeprom_path, 0, '', True)
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{
"skip_ledd": true,
"skip_thermalctld": true
"skip_ledd": true
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
__all__ = [ "platform", "chassis", "sfp", "eeprom", "component", "psu", "thermal", "fan", "fan_drawer" ]
from . import platform
266 changes: 266 additions & 0 deletions device/accton/x86_64-accton_as7326_56x-r0/sonic_platform/chassis.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,266 @@
#############################################################################
# Edgecore
#
# Module contains an implementation of SONiC Platform Base API and
# provides the Chassis information which are available in the platform
#
#############################################################################

import os
import sys

try:
from sonic_platform_base.chassis_base import ChassisBase
from .event import SfpEvent
from sonic_py_common import device_info

except ImportError as e:
raise ImportError(str(e) + "- required module not found")

NUM_FAN_TRAY = 6
NUM_PSU = 2
NUM_THERMAL = 4
NUM_PORT = 58
NUM_COMPONENT = 4

HOST_REBOOT_CAUSE_PATH = "/host/reboot-cause/"
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 = "which systemctl > /dev/null 2>&1"
SYSLED_FNODE= "/sys/class/leds/accton_as7326_56x_led::diag/brightness"
SYSLED_MODES = {
"0" : "STATUS_LED_COLOR_OFF",
"1" : "STATUS_LED_COLOR_GREEN",
"3" : "STATUS_LED_COLOR_RED",
"5" : "STATUS_LED_COLOR_GREEN_BLINK"
}


class Chassis(ChassisBase):
"""Platform-specific Chassis class"""

def __init__(self):
ChassisBase.__init__(self)
self.config_data = {}
(self.platform, self.hwsku) = device_info.get_platform_and_hwsku()

self.__initialize_fan()
self.__initialize_psu()
self.__initialize_thermals()
self.__initialize_components()
self.__initialize_sfp()
self.__initialize_eeprom()

def __initialize_sfp(self):
from sonic_platform.sfp import Sfp
for index in range(NUM_PORT):
sfp = Sfp(index)
self._sfp_list.append(sfp)
self._sfpevent = SfpEvent(self._sfp_list)
self.sfp_module_initialized = True

def __initialize_fan(self):
from sonic_platform.fan_drawer import FanDrawer
for fant_index in range(NUM_FAN_TRAY):
fandrawer = FanDrawer(fant_index)
self._fan_drawer_list.append(fandrawer)
self._fan_list.extend(fandrawer._fan_list)

def __initialize_psu(self):
from sonic_platform.psu import Psu
for index in range(NUM_PSU):
psu = Psu(index)
self._psu_list.append(psu)

def __initialize_thermals(self):
from sonic_platform.thermal import Thermal
for index in range(NUM_THERMAL):
thermal = Thermal(index)
self._thermal_list.append(thermal)

def __initialize_eeprom(self):
from sonic_platform.eeprom import Tlv
self._eeprom = Tlv()

def __initialize_components(self):
from sonic_platform.component import Component
for index in range(NUM_COMPONENT):
component = Component(index)
self._component_list.append(component)

def __initialize_watchdog(self):
self._watchdog = Watchdog()

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

def __read_txt_file(self, file_path):
try:
with open(file_path, 'r') as fd:
return fd.read().strip()
except IOError:
pass
return None

def __write_txt_file(self, file_path, value):
try:
with open(file_path, 'w') as fd:
fd.write(str(value))
except Exception:
return False
return True

def get_name(self):
"""
Retrieves the name of the device
Returns:
string: The name of the device
"""
return self._eeprom.get_product_name()

def get_presence(self):
"""
Retrieves the presence of the Chassis
Returns:
bool: True if Chassis is present, False if not
"""
return True

def get_status(self):
"""
Retrieves the operational status of the device
Returns:
A boolean value, True if device is operating properly, False if not
"""
return True
def get_base_mac(self):
"""
Retrieves the base MAC address for the chassis
Returns:
A string containing the MAC address in the format
'XX:XX:XX:XX:XX:XX'
"""
return self._eeprom.get_mac()

def get_model(self):
"""
Retrieves the model number (or part number) of the device
Returns:
string: Model/part number of device
"""
return self._eeprom.get_pn()

def get_serial(self):
"""
Retrieves the hardware serial number for the chassis
Returns:
A string containing the hardware serial number for this chassis.
"""
return self._eeprom.get_serial()

def get_system_eeprom_info(self):
"""
Retrieves the full content of system EEPROM information for the chassis
Returns:
A dictionary where keys are the type code defined in
OCP ONIE TlvInfo EEPROM format and values are their corresponding
values.
"""
return self._eeprom.get_eeprom()

def get_reboot_cause(self):
"""
Retrieves the cause of the previous reboot

Returns:
A tuple (string, string) where the first element is a string
containing the cause of the previous reboot. This string must be
one of the predefined strings in this class. If the first string
is "REBOOT_CAUSE_HARDWARE_OTHER", the second string can be used
to pass a description of the reboot cause.
"""
description = 'None'

reboot_cause_path = (HOST_REBOOT_CAUSE_PATH + REBOOT_CAUSE_FILE) if self.__is_host(
) else (PMON_REBOOT_CAUSE_PATH + REBOOT_CAUSE_FILE)
prev_reboot_cause_path = (HOST_REBOOT_CAUSE_PATH + PREV_REBOOT_CAUSE_FILE) if self.__is_host(
) else (PMON_REBOOT_CAUSE_PATH + PREV_REBOOT_CAUSE_FILE)

sw_reboot_cause = self.__read_txt_file(reboot_cause_path) or "Unknown"
prev_sw_reboot_cause = self.__read_txt_file(prev_reboot_cause_path) or "Unknown"

if sw_reboot_cause != "Unknown":
reboot_cause = self.REBOOT_CAUSE_NON_HARDWARE
description = sw_reboot_cause
elif prev_reboot_cause_path != "Unknown":
reboot_cause = self.REBOOT_CAUSE_NON_HARDWARE
description = prev_sw_reboot_cause

return (reboot_cause, description)

def get_change_event(self, timeout=0):
# SFP event
if not self.sfp_module_initialized:
self.__initialize_sfp()
return self._sfpevent.get_sfp_event(timeout)

def get_sfp(self, index):
"""
Retrieves sfp represented by (1-based) index <index>
Args:
index: An integer, the index (1-based) of the sfp to retrieve.
The index should be the sequence of a physical port in a chassis,
starting from 1.
For example, 1 for Ethernet0, 2 for Ethernet4 and so on.
Returns:
An object dervied from SfpBase representing the specified sfp
"""
sfp = None
if not self.sfp_module_initialized:
self.__initialize_sfp()

try:
# The index will start from 1
sfp = self._sfp_list[index-1]
except IndexError:
sys.stderr.write("SFP index {} out of range (1-{})\n".format(
index, len(self._sfp_list)))
return sfp

def get_position_in_parent(self):
"""
Retrieves 1-based relative physical position in parent device. If the agent cannot determine the parent-relative position
for some reason, or if the associated value of entPhysicalContainedIn is '0', then the value '-1' is returned
Returns:
integer: The 1-based relative physical position in parent device or -1 if cannot determine the position
"""
return -1

def is_replaceable(self):
"""
Indicate whether this device is replaceable.
Returns:
bool: True if it is replaceable.
"""
return False


def initizalize_system_led(self):
return True

def get_status_led(self):
val = self.__read_txt_file(SYSLED_FNODE)
return SYSLED_MODES[val] if val in SYSLED_MODES else "UNKNOWN"

def set_status_led(self, color):
mode = None
for key, val in SYSLED_MODES.items():
if val == color:
mode = key
break
if mode is None:
return False
else:
return self.__write_txt_file(SYSLED_FNODE, mode)

Loading