Skip to content

Commit ad62000

Browse files
authored
Edgecore 4630/5835/7326/7816 API2.0 platform support (#10053)
* Initial pass of EdgeCore platform changes. * Remove libevent dependency from lldpd. * Remove python2 dependencies python3.7 force from platform install script. * Include usbmount support changes. * Add missing 4630 install file. * Update a few file permissions. Add umask line to Makefile. Specify python3.9 in install script. * Misc platform updates: - Add missing fan drawer component to sonic_platform - Remove kernel version specification from Makefile - Update to 4630 utility * - Fix file permissions on source files - Fix compile issue with 4630 driver modules (set_fs, get_fs, no longer supported in kernel 5.10) * Fix missing/extra parens in 4630 util script. * Fix indentation in fanutil.py. * Integrate deltas from Edgecore to ec_platform branch. * Installer update from Edgecore to resolve smbus serial console errors. * Update stable_size for warm boot. * Fix SFP dictionary key to match xcvrd. * - Add missing define in event.py files needed for xcvrd - Fix SFP info dict key for 7xxx switches * 5835 platform file updates including installer and 5835 utility. * 5835 fix for DMAR errors on serial console. * Don't skip starting thermalctld in the pmon container. * Revert several changes that were not related to platform. * Run thermalctld in pmon container. * Don't disable thermalctld in the pmon container. * Fix prints/parens in 7816 install utility. * - Incorporate 7816 changes from Edgecore - Fix 7326 driver file using old kernel function * Update kernel modules to use kernel_read(). * Fix compile errors with 7816 and 7326 driver modules. * Fix some indents preventing platform files from loading. * Update 7816 platform sfp dictionary to match field names in xcvrd. * Add missing service and util files for 7816. * Update file names, etc. based on full SKU for 7816. * Delete pddf files not needed. These were causing conflicts with API2.0 implementation. * Remove pddf files suggested by Edgecore that were preventing API2.0 support from starting. * Install API2.0 file instead of pddf. * Update 7326 mac service file to not use pddf. Fix syntax errors in 7326 utility script. * Fix sonic_platform setup file for 7326. * Fix syntax errors in python scripts. * Updates to 7326 platform files. * Fix some tab errors pulled down from master merge. * Remove pddf files that were added from previous merge. * Updates for 5835. * Fix missing command byte for 5835 psu status. * Fix permission bits on 4630 service files. * Update platforms to use new SFP refactoring. * Fix unused var warnings.
1 parent 52c2a3a commit ad62000

File tree

99 files changed

+7422
-4357
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

99 files changed

+7422
-4357
lines changed

device/accton/x86_64-accton_as4630_54pe-r0/Accton-AS4630-54PE/hx5-as4630-48x1G+4x25G+2x100G.bcm

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
stable_size=71303168
1+
stable_size=76303168
22

33
#polarity/lanemap is using TH2 style.
44
core_clock_frequency=893

device/accton/x86_64-accton_as4630_54pe-r0/pddf/pd-plugin.json

-66
This file was deleted.

device/accton/x86_64-accton_as4630_54pe-r0/pddf_support

Whitespace-only changes.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
__all__ = [ "platform", "chassis", "sfp", "eeprom", "component", "psu", "thermal", "fan", "fan_drawer" ]
2+
from . import platform
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,255 @@
1+
#############################################################################
2+
# Edgecore
3+
#
4+
# Module contains an implementation of SONiC Platform Base API and
5+
# provides the Chassis information which are available in the platform
6+
#
7+
#############################################################################
8+
9+
import os
10+
import sys
11+
12+
try:
13+
from sonic_platform_base.chassis_base import ChassisBase
14+
from .helper import APIHelper
15+
from .event import SfpEvent
16+
except ImportError as e:
17+
raise ImportError(str(e) + "- required module not found")
18+
19+
NUM_FAN_TRAY = 3
20+
NUM_FAN = 2
21+
NUM_PSU = 2
22+
NUM_THERMAL = 3
23+
PORT_START = 49
24+
PORT_END = 54
25+
NUM_COMPONENT = 2
26+
HOST_REBOOT_CAUSE_PATH = "/host/reboot-cause/"
27+
PMON_REBOOT_CAUSE_PATH = "/usr/share/sonic/platform/api_files/reboot-cause/"
28+
REBOOT_CAUSE_FILE = "reboot-cause.txt"
29+
PREV_REBOOT_CAUSE_FILE = "previous-reboot-cause.txt"
30+
HOST_CHK_CMD = "which systemctl > /dev/null 2>&1"
31+
SYSLED_FNODE = "/sys/class/leds/diag/brightness"
32+
SYSLED_MODES = {
33+
"0" : "STATUS_LED_COLOR_OFF",
34+
"1" : "STATUS_LED_COLOR_GREEN",
35+
"2" : "STATUS_LED_COLOR_AMBER",
36+
"5" : "STATUS_LED_COLOR_GREEN_BLINK"
37+
}
38+
39+
40+
class Chassis(ChassisBase):
41+
"""Platform-specific Chassis class"""
42+
43+
def __init__(self):
44+
ChassisBase.__init__(self)
45+
self._api_helper = APIHelper()
46+
self.is_host = self._api_helper.is_host()
47+
48+
self.config_data = {}
49+
50+
self.__initialize_fan()
51+
self.__initialize_psu()
52+
self.__initialize_thermals()
53+
self.__initialize_components()
54+
self.__initialize_sfp()
55+
self.__initialize_eeprom()
56+
57+
def __initialize_sfp(self):
58+
from sonic_platform.sfp import Sfp
59+
for index in range(0, PORT_END):
60+
sfp = Sfp(index)
61+
self._sfp_list.append(sfp)
62+
self._sfpevent = SfpEvent(self._sfp_list)
63+
self.sfp_module_initialized = True
64+
65+
def __initialize_fan(self):
66+
from sonic_platform.fan_drawer import FanDrawer
67+
for fant_index in range(NUM_FAN_TRAY):
68+
fandrawer = FanDrawer(fant_index)
69+
self._fan_drawer_list.append(fandrawer)
70+
self._fan_list.extend(fandrawer._fan_list)
71+
72+
def __initialize_psu(self):
73+
from sonic_platform.psu import Psu
74+
for index in range(0, NUM_PSU):
75+
psu = Psu(index)
76+
self._psu_list.append(psu)
77+
78+
def __initialize_thermals(self):
79+
from sonic_platform.thermal import Thermal
80+
for index in range(0, NUM_THERMAL):
81+
thermal = Thermal(index)
82+
self._thermal_list.append(thermal)
83+
84+
def __initialize_eeprom(self):
85+
from sonic_platform.eeprom import Tlv
86+
self._eeprom = Tlv()
87+
88+
def __initialize_components(self):
89+
from sonic_platform.component import Component
90+
for index in range(0, NUM_COMPONENT):
91+
component = Component(index)
92+
self._component_list.append(component)
93+
94+
def __initialize_watchdog(self):
95+
from sonic_platform.watchdog import Watchdog
96+
self._watchdog = Watchdog()
97+
98+
99+
def __is_host(self):
100+
return os.system(HOST_CHK_CMD) == 0
101+
102+
def __read_txt_file(self, file_path):
103+
try:
104+
with open(file_path, 'r') as fd:
105+
data = fd.read()
106+
return data.strip()
107+
except IOError:
108+
pass
109+
return None
110+
111+
def get_name(self):
112+
"""
113+
Retrieves the name of the device
114+
Returns:
115+
string: The name of the device
116+
"""
117+
118+
return self._eeprom.get_product_name()
119+
120+
def get_presence(self):
121+
"""
122+
Retrieves the presence of the Chassis
123+
Returns:
124+
bool: True if Chassis is present, False if not
125+
"""
126+
return True
127+
128+
def get_status(self):
129+
"""
130+
Retrieves the operational status of the device
131+
Returns:
132+
A boolean value, True if device is operating properly, False if not
133+
"""
134+
return True
135+
136+
def get_base_mac(self):
137+
"""
138+
Retrieves the base MAC address for the chassis
139+
Returns:
140+
A string containing the MAC address in the format
141+
'XX:XX:XX:XX:XX:XX'
142+
"""
143+
return self._eeprom.get_mac()
144+
145+
def get_model(self):
146+
"""
147+
Retrieves the model number (or part number) of the device
148+
Returns:
149+
string: Model/part number of device
150+
"""
151+
return self._eeprom.get_pn()
152+
153+
def get_serial(self):
154+
"""
155+
Retrieves the hardware serial number for the chassis
156+
Returns:
157+
A string containing the hardware serial number for this chassis.
158+
"""
159+
return self._eeprom.get_serial()
160+
161+
def get_system_eeprom_info(self):
162+
"""
163+
Retrieves the full content of system EEPROM information for the chassis
164+
Returns:
165+
A dictionary where keys are the type code defined in
166+
OCP ONIE TlvInfo EEPROM format and values are their corresponding
167+
values.
168+
"""
169+
return self._eeprom.get_eeprom()
170+
171+
def get_reboot_cause(self):
172+
"""
173+
Retrieves the cause of the previous reboot
174+
175+
Returns:
176+
A tuple (string, string) where the first element is a string
177+
containing the cause of the previous reboot. This string must be
178+
one of the predefined strings in this class. If the first string
179+
is "REBOOT_CAUSE_HARDWARE_OTHER", the second string can be used
180+
to pass a description of the reboot cause.
181+
"""
182+
183+
reboot_cause_path = (HOST_REBOOT_CAUSE_PATH + REBOOT_CAUSE_FILE)
184+
sw_reboot_cause = self._api_helper.read_txt_file(
185+
reboot_cause_path) or "Unknown"
186+
187+
188+
return ('REBOOT_CAUSE_NON_HARDWARE', sw_reboot_cause)
189+
190+
def get_change_event(self, timeout=0):
191+
# SFP event
192+
if not self.sfp_module_initialized:
193+
self.__initialize_sfp()
194+
195+
return self._sfpevent.get_sfp_event(timeout)
196+
197+
def get_sfp(self, index):
198+
"""
199+
Retrieves sfp represented by (1-based) index <index>
200+
Args:
201+
index: An integer, the index (1-based) of the sfp to retrieve.
202+
The index should be the sequence of a physical port in a chassis,
203+
starting from 1.
204+
For example, 1 for Ethernet0, 2 for Ethernet4 and so on.
205+
Returns:
206+
An object dervied from SfpBase representing the specified sfp
207+
"""
208+
sfp = None
209+
if not self.sfp_module_initialized:
210+
self.__initialize_sfp()
211+
212+
try:
213+
# The index will start from 1
214+
sfp = self._sfp_list[index-1]
215+
except IndexError:
216+
sys.stderr.write("SFP index {} out of range (1-{})\n".format(
217+
index, len(self._sfp_list)))
218+
return sfp
219+
220+
def get_position_in_parent(self):
221+
"""
222+
Retrieves 1-based relative physical position in parent device. If the agent cannot determine the parent-relative position
223+
for some reason, or if the associated value of entPhysicalContainedIn is '0', then the value '-1' is returned
224+
Returns:
225+
integer: The 1-based relative physical position in parent device or -1 if cannot determine the position
226+
"""
227+
return -1
228+
229+
def is_replaceable(self):
230+
"""
231+
Indicate whether this device is replaceable.
232+
Returns:
233+
bool: True if it is replaceable.
234+
"""
235+
return False
236+
237+
238+
def initizalize_system_led(self):
239+
return True
240+
241+
def get_status_led(self):
242+
val = self._api_helper.read_txt_file(SYSLED_FNODE)
243+
return SYSLED_MODES[val] if val in SYSLED_MODES else "UNKNOWN"
244+
245+
def set_status_led(self, color):
246+
mode = None
247+
for key, val in SYSLED_MODES.items():
248+
if val == color:
249+
mode = key
250+
break
251+
if mode is None:
252+
return False
253+
else:
254+
return self._api_helper.write_txt_file(SYSLED_FNODE, mode)
255+

0 commit comments

Comments
 (0)