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

Edgecore 4630/5835/7326/7816 API2.0 platform support #10053

Merged
merged 47 commits into from
Mar 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
acaba4d
Initial pass of EdgeCore platform changes.
Nov 29, 2021
32f7ded
Remove libevent dependency from lldpd.
Nov 30, 2021
683cb22
Remove python2 dependencies python3.7 force from platform install scr…
Dec 1, 2021
0e2a038
Include usbmount support changes.
Dec 3, 2021
bdc8ff3
Add missing 4630 install file.
Dec 3, 2021
eb1380f
Update a few file permissions. Add umask line to Makefile. Specify …
Dec 6, 2021
ee5b6b6
Misc platform updates:
Dec 8, 2021
fa74861
- Fix file permissions on source files
jeffhtgt Dec 21, 2021
343ec1b
Fix missing/extra parens in 4630 util script.
jeffhtgt Dec 21, 2021
8f953c1
Fix indentation in fanutil.py.
jeffhtgt Dec 22, 2021
5b17898
Integrate deltas from Edgecore to ec_platform branch.
jeffhtgt Dec 23, 2021
2ec059d
Installer update from Edgecore to resolve smbus serial console errors.
jeffhtgt Dec 25, 2021
6fea699
Update stable_size for warm boot.
jeffhtgt Dec 30, 2021
659181f
Merge branch 'master' into ec_platform
jeffhtgt Jan 4, 2022
31588af
Fix SFP dictionary key to match xcvrd.
jeffhtgt Jan 5, 2022
1bed721
- Add missing define in event.py files needed for xcvrd
jeffhtgt Jan 5, 2022
db15996
5835 platform file updates including installer and 5835 utility.
jeffhtgt Jan 7, 2022
e825fde
5835 fix for DMAR errors on serial console.
jeffhtgt Jan 8, 2022
c9b3008
Don't skip starting thermalctld in the pmon container.
jeffhtgt Jan 8, 2022
70244b1
Revert several changes that were not related to platform.
jeffhtgt Jan 12, 2022
7b0be33
Run thermalctld in pmon container.
jeffhtgt Jan 13, 2022
c11b886
Don't disable thermalctld in the pmon container.
jeffhtgt Jan 14, 2022
b18db21
Fix prints/parens in 7816 install utility.
jeffhtgt Jan 14, 2022
319f60e
- Incorporate 7816 changes from Edgecore
jeffhtgt Jan 17, 2022
1247da3
Update kernel modules to use kernel_read().
jeffhtgt Jan 17, 2022
91dbd89
Fix compile errors with 7816 and 7326 driver modules.
jeffhtgt Jan 18, 2022
7eda78c
Fix some indents preventing platform files from loading.
jeffhtgt Jan 18, 2022
13f93cd
Update 7816 platform sfp dictionary to match field names in xcvrd.
jeffhtgt Jan 20, 2022
eabd689
Add missing service and util files for 7816.
jeffhtgt Jan 21, 2022
33b530d
Update file names, etc. based on full SKU for 7816.
jeffhtgt Jan 21, 2022
6ff3d93
Delete pddf files not needed. These were causing conflicts with API2.0
jeffhtgt Jan 25, 2022
896abed
Merge branch 'master' into ec_platform
jeffhtgt Jan 26, 2022
44cef2b
Remove pddf files suggested by Edgecore that were preventing API2.0 s…
jeffhtgt Jan 27, 2022
4fae8ab
Install API2.0 file instead of pddf.
jeffhtgt Jan 27, 2022
7070a68
Update 7326 mac service file to not use pddf. Fix syntax errors in 7…
jeffhtgt Jan 28, 2022
f68b9da
Fix sonic_platform setup file for 7326.
jeffhtgt Jan 28, 2022
3c2693a
Fix syntax errors in python scripts.
jeffhtgt Jan 31, 2022
bc73bba
Updates to 7326 platform files.
jeffhtgt Feb 11, 2022
b0842cd
Merge branch 'master' into ec_platform
jeffhtgt Feb 11, 2022
c67eb74
Fix some tab errors pulled down from master merge.
jeffhtgt Feb 11, 2022
aa3f3f6
Remove pddf files that were added from previous merge.
jeffhtgt Feb 14, 2022
1052be0
Updates for 5835.
jeffhtgt Feb 17, 2022
8dcd2f4
Fix missing command byte for 5835 psu status.
jeffhtgt Feb 21, 2022
06cee0b
Fix permission bits on 4630 service files.
jeffhtgt Feb 28, 2022
accd010
Update platforms to use new SFP refactoring.
jeffhtgt Mar 3, 2022
993c48e
Merge branch 'master' into ec_platform
jeffhtgt Mar 10, 2022
2068e66
Fix unused var warnings.
jeffhtgt Mar 15, 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
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
stable_size=71303168
stable_size=76303168

#polarity/lanemap is using TH2 style.
core_clock_frequency=893
Expand Down
66 changes: 0 additions & 66 deletions device/accton/x86_64-accton_as4630_54pe-r0/pddf/pd-plugin.json

This file was deleted.

Empty file.
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
255 changes: 255 additions & 0 deletions device/accton/x86_64-accton_as4630_54pe-r0/sonic_platform/chassis.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,255 @@
#############################################################################
# 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 .helper import APIHelper
from .event import SfpEvent
except ImportError as e:
raise ImportError(str(e) + "- required module not found")

NUM_FAN_TRAY = 3
NUM_FAN = 2
NUM_PSU = 2
NUM_THERMAL = 3
PORT_START = 49
PORT_END = 54
NUM_COMPONENT = 2
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/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"
}


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

def __init__(self):
ChassisBase.__init__(self)
self._api_helper = APIHelper()
self.is_host = self._api_helper.is_host()

self.config_data = {}

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(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):
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(0, NUM_PSU):
psu = Psu(index)
self._psu_list.append(psu)

def __initialize_thermals(self):
from sonic_platform.thermal import Thermal
for index in range(0, 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(0, NUM_COMPONENT):
component = Component(index)
self._component_list.append(component)

def __initialize_watchdog(self):
from sonic_platform.watchdog import Watchdog
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:
data = fd.read()
return data.strip()
except IOError:
pass
return None

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

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_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._api_helper.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._api_helper.write_txt_file(SYSLED_FNODE, mode)

Loading