Skip to content
Merged
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
54 changes: 27 additions & 27 deletions device/centec/arm64-centec_e530_24x2c-r0/E530-24x2c/port_config.ini
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
# name lanes alias speed
Ethernet1 0 eth-0-1 10000
Ethernet2 1 eth-0-2 10000
Ethernet3 2 eth-0-3 10000
Ethernet4 3 eth-0-4 10000
Ethernet5 8 eth-0-5 10000
Ethernet6 9 eth-0-6 10000
Ethernet7 10 eth-0-7 10000
Ethernet8 11 eth-0-8 10000
Ethernet9 20 eth-0-9 10000
Ethernet10 21 eth-0-10 10000
Ethernet11 22 eth-0-11 10000
Ethernet12 23 eth-0-12 10000
Ethernet13 12 eth-0-13 10000
Ethernet14 13 eth-0-14 10000
Ethernet15 14 eth-0-15 10000
Ethernet16 15 eth-0-16 10000
Ethernet17 24 eth-0-17 10000
Ethernet18 25 eth-0-18 10000
Ethernet19 26 eth-0-19 10000
Ethernet20 27 eth-0-20 10000
Ethernet21 28 eth-0-21 10000
Ethernet22 29 eth-0-22 10000
Ethernet23 30 eth-0-23 10000
Ethernet24 31 eth-0-24 10000
Ethernet25 61,60,63,62 eth-0-25 100000
Ethernet26 45,44,47,46 eth-0-26 100000
# name lanes alias index speed fec
Ethernet0 0 eth-0-1 0 10000 none
Ethernet1 1 eth-0-2 1 10000 none
Ethernet2 2 eth-0-3 2 10000 none
Ethernet3 3 eth-0-4 3 10000 none
Ethernet4 8 eth-0-5 4 10000 none
Ethernet5 9 eth-0-6 5 10000 none
Ethernet6 10 eth-0-7 6 10000 none
Ethernet7 11 eth-0-8 7 10000 none
Ethernet8 20 eth-0-9 8 10000 none
Ethernet9 21 eth-0-10 9 10000 none
Ethernet10 22 eth-0-11 10 10000 none
Ethernet11 23 eth-0-12 11 10000 none
Ethernet12 12 eth-0-13 12 10000 none
Ethernet13 13 eth-0-14 13 10000 none
Ethernet14 14 eth-0-15 14 10000 none
Ethernet15 15 eth-0-16 15 10000 none
Ethernet16 24 eth-0-17 16 10000 none
Ethernet17 25 eth-0-18 17 10000 none
Ethernet18 26 eth-0-19 18 10000 none
Ethernet19 27 eth-0-20 19 10000 none
Ethernet20 28 eth-0-21 20 10000 none
Ethernet21 29 eth-0-22 21 10000 none
Ethernet22 30 eth-0-23 22 10000 none
Ethernet23 31 eth-0-24 23 10000 none
Ethernet24 61,60,63,62 eth-0-25 24 100000 none
Ethernet25 45,44,47,46 eth-0-26 25 100000 none
11 changes: 11 additions & 0 deletions device/centec/arm64-centec_e530_24x2c-r0/fancontrol
Original file line number Diff line number Diff line change
@@ -1 +1,12 @@
# Configuration file generated by pwmconfig, changes will be lost
INTERVAL=10
DEVPATH=hwmon1=devices/platform/soc/soc:fan-ctc5236
DEVNAME=hwmon1=ctc5236fan
FCTEMPS=hwmon1/pwm1=hwmon1/temp1_input hwmon1/pwm2=hwmon1/temp1_input hwmon1/pwm3=hwmon1/temp1_input
FCFANS=hwmon1/pwm1=hwmon1/fan1_input hwmon1/pwm2=hwmon1/fan2_input hwmon1/pwm3=hwmon1/fan3_input
MINTEMP=hwmon1/pwm1=30 hwmon1/pwm2=30 hwmon1/pwm3=30
MAXTEMP=hwmon1/pwm1=90 hwmon1/pwm2=90 hwmon1/pwm3=90
MINSTART=hwmon1/pwm1=12 hwmon1/pwm2=12 hwmon1/pwm3=12
MINSTOP=hwmon1/pwm1=6 hwmon1/pwm2=6 hwmon1/pwm3=6
MINPWM=hwmon1/pwm1=6 hwmon1/pwm2=6 hwmon1/pwm3=6
MAXPWM=hwmon1/pwm1=18 hwmon1/pwm2=18 hwmon1/pwm3=18
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"chassis": {
"E530-24x2c": {
"component": {
}
}
}
}
11 changes: 11 additions & 0 deletions device/centec/arm64-centec_e530_24x2c-r0/platform_reboot
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/usr/bin/python
import os

def main():
# reboot the system
os.system('echo 502 > /sys/class/gpio/export')
os.system('echo out > /sys/class/gpio/gpio502/direction')
os.system('echo 1 > /sys/class/gpio/gpio502/value')

if __name__ == "__main__":
main()
4 changes: 3 additions & 1 deletion device/centec/arm64-centec_e530_24x2c-r0/plugins/eeprom.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/usr/bin/env python

#############################################################################
# Centec E550-24X8Y2C
#
Expand All @@ -10,7 +12,7 @@
try:
from sonic_eeprom import eeprom_tlvinfo
except ImportError as e:
raise ImportError(str(e) + "- required module not found")
raise ImportError (str(e) + "- required module not found")


class board(eeprom_tlvinfo.TlvInfoDecoder):
Expand Down
123 changes: 96 additions & 27 deletions device/centec/arm64-centec_e530_24x2c-r0/plugins/led_control.py
Original file line number Diff line number Diff line change
@@ -1,41 +1,115 @@
#!/usr/bin/env python
#
# led_control.py
#
# Platform-specific LED control functionality for SONiC
#

try:
from sonic_led.led_control_base import LedControlBase
import os
import re
import syslog
from socket import *
from select import *
import collections
from sonic_led.led_control_base import LedControlBase
from sonic_py_common import device_info
except ImportError as e:
raise ImportError(str(e) + " - required module not found")

USR_SHARE_SONIC_PATH = "/usr/share/sonic"
HOST_DEVICE_PATH = USR_SHARE_SONIC_PATH + "/device"
CONTAINER_PLATFORM_PATH = USR_SHARE_SONIC_PATH + "/platform"

def DBG_PRINT(str):
syslog.openlog("centec-led")
syslog.syslog(syslog.LOG_INFO, str)
syslog.closelog()


class LedControl(LedControlBase):
"""Platform specific LED control class"""

# Constructor
def __init__(self):

self.mac_to_led = {
0: 1,
1: 2,
2: 3,
3: 4,
8: 5,
9: 6,
10: 7,
11: 8,
20: 9,
21:10,
22:11,
23:12,
12:13,
13:14,
14:15,
15:16,
24:17,
25:18,
26:19,
27:20,
28:21,
29:22,
30:23,
31:24,
61:-1,
60:25,
63:-1,
62:-1,
45:-1,
44:26,
47:-1,
46:-1,
}

if os.path.isdir(CONTAINER_PLATFORM_PATH):
platform_path = CONTAINER_PLATFORM_PATH
else:
platform = device_info.get_platform()
if platform is None:
raise
platform_path = os.path.join(HOST_DEVICE_PATH, platform)

port_config_file = "/".join([platform_path, "E530-24x2c", "port_config.ini"])
try:
f = open(port_config_file)
except:
raise
for line in f:
line.strip()
if re.search('^#', line) is not None:
Port_cfg = collections.namedtuple('Port_cfg', line.split()[1:])
break
f.close()
f = open(port_config_file)
self._port_cfgs = [Port_cfg(*tuple((line.strip().split())))
for line in f if re.search('^#', line) is None]
f.close()

self.LED_MODE_UP = [11, 11]
self.LED_MODE_DOWN = [7, 7]
self.f_led = "/sys/class/leds/{}/brightness"
self._initDefaultConfig()

# Helper method to map SONiC port name to index
def _port_name_to_index(self, port_name):
# Strip "Ethernet" off port name
if not port_name.startswith(self.SONIC_PORT_NAME_PREFIX):
return -1

port_idx = int(port_name[len(self.SONIC_PORT_NAME_PREFIX):])
return port_idx
for port_cfg in self._port_cfgs:
if port_name == port_cfg.name:
macs = [int(x) for x in (port_cfg.lanes.split(','))]
led = self.mac_to_led[min(macs)]
if led < 0:
return None
return led
return None

def _port_state_to_mode(self, port_idx, state):
if state == "up":
return self.LED_MODE_UP[0] if (port_idx < 25) else self.LED_MODE_UP[1]
return self.LED_MODE_UP[1] if port_idx == 25 or port_idx == 26 else self.LED_MODE_UP[0]
else:
return self.LED_MODE_DOWN[0] if (port_idx < 25) else self.LED_MODE_DOWN[1]
return self.LED_MODE_DOWN[1] if port_idx == 25 or port_idx == 26 else self.LED_MODE_DOWN[0]

def _port_led_mode_update(self, port_idx, ledMode):
with open(self.f_led.format("port{}".format(port_idx)), 'w') as led_file:
Expand All @@ -57,11 +131,15 @@ def _initPanelLed(self):
shouldInit = (int(led_file.read()) == 0)

if shouldInit == True:
for idx in range(1, 27):
defmode = self._port_state_to_mode(idx, "down")
with open(self.f_led.format("port{}".format(idx)), 'w') as led_file:
for port_cfg in self._port_cfgs:
macs = [int(x) for x in (port_cfg.lanes.split(','))]
led = self.mac_to_led[min(macs)]
if led < 0:
continue
defmode = self._port_state_to_mode(led, "down")
with open(self.f_led.format("port{}".format(led)), 'w') as led_file:
led_file.write(str(defmode))
DBG_PRINT("init port{} led to mode={}".format(idx, defmode))
DBG_PRINT("init port{} led to mode={}".format(led, defmode))

def _initDefaultConfig(self):
DBG_PRINT("start init led")
Expand All @@ -72,9 +150,10 @@ def _initDefaultConfig(self):
DBG_PRINT("init led done")

# Concrete implementation of port_link_state_change() method

def port_link_state_change(self, portname, state):
port_idx = self._port_name_to_index(portname)
if port_idx is None:
return
ledMode = self._port_state_to_mode(port_idx, state)
with open(self.f_led.format("port{}".format(port_idx)), 'r') as led_file:
saveMode = int(led_file.read())
Expand All @@ -84,13 +163,3 @@ def port_link_state_change(self, portname, state):

self._port_led_mode_update(port_idx, ledMode)
DBG_PRINT("update {} led mode from {} to {}".format(portname, saveMode, ledMode))

# Constructor

def __init__(self):
self.SONIC_PORT_NAME_PREFIX = "Ethernet"
self.LED_MODE_UP = [11, 11]
self.LED_MODE_DOWN = [7, 7]

self.f_led = "/sys/class/leds/{}/brightness"
self._initDefaultConfig()
5 changes: 3 additions & 2 deletions device/centec/arm64-centec_e530_24x2c-r0/plugins/psuutil.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/usr/bin/env python

#############################################################################
# Centec
#
Expand All @@ -9,8 +11,7 @@
try:
from sonic_psu.psu_base import PsuBase
except ImportError as e:
raise ImportError(str(e) + "- required module not found")

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

class PsuUtil(PsuBase):
"""Platform-specific PSUutil class"""
Expand Down
Loading