Skip to content
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
9afd8ce
[Edgecore][AS7726/PDDF] Enhance sonic_platform feature
jostar-yang Dec 8, 2022
e5cedd9
Fix LGTM alerts
jostar-yang Dec 9, 2022
cdad806
Add get_name to pass pytest
jostar-yang Dec 12, 2022
be7af5c
Modify fan direction name to lower case
jostar-yang Dec 12, 2022
2b3e8a5
Add platform.json to pass pytest
jostar-yang Dec 21, 2022
2315510
Add compoment.py
jostar-yang Dec 22, 2022
f3637e4
Add enable fan-wdt and kick
jostar-yang Jan 19, 2023
045a8df
Fix Semgrep check
jostar-yang Feb 9, 2023
122fd25
Modify CPLD name to more detail
jostar-yang Feb 10, 2023
d2b2118
Modify sys_led attr name
jostar-yang Feb 14, 2023
0fcffa2
Modify eeprom.py to support cache
jostar-yang Feb 16, 2023
bc460f6
Modify devices_to_ignore for pus_fan
jostar-yang Feb 17, 2023
dbe07a3
Add psu_fan target speed
jostar-yang Feb 21, 2023
cb2be41
Modify system_health_monitoring_config.json led_color string
jostar-yang Feb 21, 2023
2a96a94
Fix pytest issue
roger530-ho Mar 15, 2023
c64e384
Fix incorrect variable
roger530-ho Apr 13, 2023
459bf03
Support to show CPU all core temp
jostar-yang May 2, 2023
4f1c650
Add CPU all core temp
roger530-ho Jun 20, 2023
66fa15a
[Edgecore][AS7726-32X] Read the data when the PSU is in the power-goo…
roger530-ho Aug 15, 2023
c352370
Fix port33,34 to use optoe2 for sfp
jostar-yang Sep 28, 2023
6c8cab5
Add reset() in sfp.py for check sfp_port to avoid fail
jostar-yang Sep 4, 2024
fee0c25
Disable fan_wdt when set fan_speed
jostar-yang Dec 5, 2024
e034689
Add get_lpmode to set lpmode default setting is disable
jostar-yang May 22, 2025
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
471 changes: 471 additions & 0 deletions device/accton/x86_64-accton_as7726_32x-r0/pcie.yaml

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@

"duty_cycle_to_pwm": "lambda dc: ((dc*100)/625 -1)",

"pwm_to_duty_cycle": "lambda pwm: (((pwm+1)*625+75)/100)"
"pwm_to_duty_cycle": "lambda pwm: (((pwm+1)*625)/100)"
}

}
31 changes: 29 additions & 2 deletions device/accton/x86_64-accton_as7726_32x-r0/pddf/pddf-device.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"num_fantrays":6,
"num_fans_pertray":2,
"num_ports":34,
"num_temps":5,
"num_temps":7,
"pddf_dev_types":
{
"description":"AS7726 - Below is the list of supported PDDF device types (chip names) for various components. If any component uses some other driver, we will create the client using 'echo <dev-address> <dev-type> > <path>/new_device' method",
Expand Down Expand Up @@ -1865,7 +1865,34 @@
]
}
},

"TEMP6" :
{
"dev_info": { "device_type":"TEMP_SENSOR", "device_name":"TEMP6"},
"dev_attr": { "display_name":"pch_haswell-virtual-0"},
"i2c":
{
"path_info": {"sysfs_base_path": "/sys/class/hwmon/hwmon0"},
"attr_list":
[
{ "attr_name": "temp1_input"}
]
}
},
"TEMP7" :
{
"dev_info": { "device_type":"TEMP_SENSOR", "device_name":"TEMP7"},
"dev_attr": { "display_name":"coretemp-isa-0000"},
"i2c":
{
"path_info": {"sysfs_base_path": "/sys/class/hwmon/hwmon1"},
"attr_list":
[
{ "attr_name": "temp1_high_crit_threshold", "drv_attr_name":"temp1_crit"},
{ "attr_name": "temp1_high_threshold", "drv_attr_name":"temp1_max"},
{ "attr_name": "temp1_input"}
]
}
},
"SYSSTATUS":
{
"dev_info":{ "device_type":"SYSSTAT", "device_name":"SYSSTATUS"},
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
@@ -0,0 +1,17 @@
{
"services_to_ignore": [],
"devices_to_ignore": [
"asic",
"psu.voltage",
"psu.temperature",
"PSU1_FAN1.speed",
"PSU2_FAN1.speed"
],
"user_defined_checkers": [],
"polling_interval": 60,
"led_color": {
"fault": "STATUS_LED_COLOR_AMBER",
"normal": "STATUS_LED_COLOR_GREEN",
"booting": "STATUS_LED_COLOR_OFF"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,58 +8,59 @@

try:
import sys
import time
from sonic_platform_pddf_base.pddf_chassis import PddfChassis
from .event import SfpEvent
from .helper import APIHelper
except ImportError as e:
raise ImportError(str(e) + "- required module not found")

NUM_COMPONENT = 6
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"

class Chassis(PddfChassis):
"""
PDDF Platform-specific Chassis class
"""

SYSLED_DEV_NAME = "DIAG_LED"

def __init__(self, pddf_data=None, pddf_plugin_data=None):
PddfChassis.__init__(self, pddf_data, pddf_plugin_data)
self.__initialize_components()
self._api_helper = APIHelper()
self._sfpevent = SfpEvent(self.get_all_sfps())


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

# Provide the functions/variables below for which implementation is to be overwritten
sfp_change_event_data = {'valid': 0, 'last': 0, 'present': 0}
def get_change_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

bitmap = 0
for i in range(34):
modpres = self.get_sfp(i+1).get_presence()
if modpres:
bitmap = bitmap | (1 << i)

changed_ports = self.sfp_change_event_data['present'] ^ bitmap
if changed_ports:
for i in range(34):
if (changed_ports & (1 << i)):
if (bitmap & (1 << i)) == 0:
port_dict[i+1] = '0'
else:
port_dict[i+1] = '1'


# Update teh cache dict
self.sfp_change_event_data['present'] = bitmap
self.sfp_change_event_data['last'] = now
self.sfp_change_event_data['valid'] = 1
return True, change_dict
else:
return True, change_dict
def get_change_event(self, timeout=0):
return self._sfpevent.get_sfp_event(timeout)

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.
"""

reboot_cause_path = (HOST_REBOOT_CAUSE_PATH + REBOOT_CAUSE_FILE)
sw_reboot_cause = self._api_helper.read_txt_file(
reboot_cause_path) or "Unknown"


return ('REBOOT_CAUSE_NON_HARDWARE', sw_reboot_cause)


def get_sfp(self, index):
Expand All @@ -84,3 +85,19 @@ def get_sfp(self, index):
sys.stderr.write("SFP index {} out of range (1-{})\n".format(
index, len(self._sfp_list)))
return sfp

def initizalize_system_led(self):
return

def get_status_led(self):
return self.get_system_led(self.SYSLED_DEV_NAME)

def set_status_led(self, color):
return self.set_system_led(self.SYSLED_DEV_NAME, color)

def get_port_or_cage_type(self, port):
from sonic_platform_base.sfp_base import SfpBase
if port in range(1, 32):
return SfpBase.SFP_PORT_TYPE_BIT_QSFP | SfpBase.SFP_PORT_TYPE_BIT_QSFP_PLUS | SfpBase.SFP_PORT_TYPE_BIT_QSFP28
else:
return SfpBase.SFP_PORT_TYPE_BIT_SFP | SfpBase.SFP_PORT_TYPE_BIT_SFP_PLUS
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
import os
import struct
import subprocess
from mmap import *
from sonic_py_common import device_info

HOST_CHK_CMD = "docker > /dev/null 2>&1"
EMPTY_STRING = ""


class APIHelper():

def __init__(self):
(self.platform, self.hwsku) = device_info.get_platform_and_hwsku()

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

def pci_get_value(self, resource, offset):
status = True
result = ""
try:
fd = os.open(resource, os.O_RDWR)
mm = mmap(fd, 0)
mm.seek(int(offset))
read_data_stream = mm.read(4)
result = struct.unpack('I', read_data_stream)
except Exception:
status = False
return status, result

def run_command(self, cmd):
status = True
result = ""
try:
p = subprocess.Popen(
cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
raw_data, err = p.communicate()
if err == '':
result = raw_data.strip()
except Exception:
status = False
return status, result

def run_interactive_command(self, cmd):
try:
os.system(cmd)
except Exception:
return False
return True

def read_txt_file(self, file_path):
try:
with open(file_path, 'r', errors='replace') as fd:
data = fd.read()
return data.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 IOError:
return False
return True

def ipmi_raw(self, netfn, cmd):
status = True
result = ""
try:
cmd = "ipmitool raw {} {}".format(str(netfn), str(cmd))
p = subprocess.Popen(
cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
raw_data, err = p.communicate()
if err == '':
result = raw_data.strip()
else:
status = False
except Exception:
status = False
return status, result

def ipmi_fru_id(self, id, key=None):
status = True
result = ""
try:
cmd = "ipmitool fru print {}".format(str(
id)) if not key else "ipmitool fru print {0} | grep '{1}' ".format(str(id), str(key))

p = subprocess.Popen(
cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
raw_data, err = p.communicate()
if err == '':
result = raw_data.strip()
else:
status = False
except Exception:
status = False
return status, result

def ipmi_set_ss_thres(self, id, threshold_key, value):
status = True
result = ""
try:
cmd = "ipmitool sensor thresh '{}' {} {}".format(str(id), str(threshold_key), str(value))
p = subprocess.Popen(
cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
raw_data, err = p.communicate()
if err == '':
result = raw_data.strip()
else:
status = False
except Exception:
status = False
return status, result
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)
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,9 @@ def __init__(self, index, pddf_data=None, pddf_plugin_data=None, is_psu_thermal=
PddfThermal.__init__(self, index, pddf_data, pddf_plugin_data, is_psu_thermal, psu_index)

# Provide the functions/variables below for which implementation is to be overwritten
def get_status(self):
get_temp=self.get_temperature()

if get_temp is not None:
return True if get_temp else False