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

add centec E530 arm64 platform support #10

Merged
merged 2 commits into from
Mar 13, 2020
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
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
url = https://github.com/Azure/sonic-swss-common
[submodule "sonic-linux-kernel"]
path = src/sonic-linux-kernel
url = https://github.com/Azure/sonic-linux-kernel
url = https://github.com/CentecNetworks/sonic-linux-kernel
[submodule "sonic-sairedis"]
path = src/sonic-sairedis
url = https://github.com/Azure/sonic-sairedis
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
{# Default values which will be used if no actual configura available #}
{% set default_cable = '40m' %}
{% set default_ports_num = 54 -%}

{# Port configuration to cable length look-up table #}
{# Each record describes mapping of DUT (DUT port) role and neighbor role to cable length #}
{# Roles described in the minigraph #}
{% set ports2cable = {
'torrouter_server' : '5m',
'leafrouter_torrouter' : '40m',
'spinerouter_leafrouter' : '300m'
}
%}

{%- macro cable_length(port_name) -%}
{%- set cable_len = [] -%}
{%- for local_port in DEVICE_NEIGHBOR -%}
{%- if local_port == port_name -%}
{%- if DEVICE_NEIGHBOR_METADATA[DEVICE_NEIGHBOR[local_port].name] -%}
{%- set neighbor = DEVICE_NEIGHBOR_METADATA[DEVICE_NEIGHBOR[local_port].name] -%}
{%- set neighbor_role = neighbor.type -%}
{%- set roles1 = switch_role + '_' + neighbor_role %}
{%- set roles2 = neighbor_role + '_' + switch_role -%}
{%- set roles1 = roles1 | lower -%}
{%- set roles2 = roles2 | lower -%}
{%- if roles1 in ports2cable -%}
{%- if cable_len.append(ports2cable[roles1]) -%}{%- endif -%}
{%- elif roles2 in ports2cable -%}
{%- if cable_len.append(ports2cable[roles2]) -%}{%- endif -%}
{%- endif -%}
{%- endif -%}
{%- endif -%}
{%- endfor -%}
{%- if cable_len -%}
{{ cable_len.0 }}
{%- else -%}
{{ default_cable }}
{%- endif -%}
{% endmacro %}

{%- if DEVICE_METADATA is defined %}
{%- set switch_role = DEVICE_METADATA['localhost']['type'] %}
{%- endif -%}

{# Generate list of ports if not defined #}
{% if PORT is not defined %}
{% set PORT = [] %}
{% for port_idx in range(1,default_ports_num+1) %}
{% if PORT.append("Ethernet%d" % (port_idx)) %}{% endif %}
{% endfor %}
{% endif -%}

{% set port_names_list = [] %}
{% for port in PORT %}
{%- if port_names_list.append(port) %}{% endif %}
{% endfor %}
{% set port_names = port_names_list | join(',') -%}

{
"CABLE_LENGTH": {
"AZURE": {
{% for port in PORT %}
{% set cable = cable_length(port) -%}
"{{ port }}": "{{ cable }}"{%- if not loop.last -%},{% endif %}

{% endfor %}
}
}
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# PG lossless profiles.
# speed cable size xon xoff threshold
1000 5m 34816 18432 16384 0
10000 5m 34816 18432 16384 0
25000 5m 34816 18432 16384 0
40000 5m 34816 18432 16384 0
50000 5m 34816 18432 16384 0
100000 5m 36864 18432 18432 0
1000 40m 36864 18432 18432 0
10000 40m 36864 18432 18432 0
25000 40m 39936 18432 21504 0
40000 40m 41984 18432 23552 0
50000 40m 41984 18432 23552 0
100000 40m 54272 18432 35840 0
1000 300m 49152 18432 30720 0
10000 300m 49152 18432 30720 0
25000 300m 71680 18432 53248 0
40000 300m 94208 18432 75776 0
50000 300m 94208 18432 75776 0
100000 300m 184320 18432 165888 0

Original file line number Diff line number Diff line change
@@ -0,0 +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
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{%- include 'qos_config.j2' %}
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
SAI_INIT_CONFIG_FILE=/etc/centec/E530-24x2c-chip-profile.txt
SAI_HW_PORT_PROFILE_ID_CONFIG_FILE=/etc/centec/E530-24x2c-datapath-cfg.txt
1 change: 1 addition & 0 deletions device/centec/arm64-centec_e530_24x2c-r0/default_sku
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
E530-24x2c l2
1 change: 1 addition & 0 deletions device/centec/arm64-centec_e530_24x2c-r0/fancontrol
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Configuration file generated by pwmconfig, changes will be lost
Empty file.
31 changes: 31 additions & 0 deletions device/centec/arm64-centec_e530_24x2c-r0/plugins/eeprom.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/usr/bin/env python

#############################################################################
# Centec E550-24X8Y2C
#
# Platform and model specific eeprom subclass, inherits from the base class,
# and provides the followings:
# - the eeprom format definition
# - specific encoder/decoder if there is special need
#############################################################################

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


class board(eeprom_tlvinfo.TlvInfoDecoder):

def __init__(self, name, path, cpld_root, ro):
self.eeprom_path = "/dev/mtd3"
super(board, self).__init__(self.eeprom_path, 0, '', True)
104 changes: 104 additions & 0 deletions device/centec/arm64-centec_e530_24x2c-r0/plugins/led_control.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
#!/usr/bin/env python
#
# led_control.py
#
# Platform-specific LED control functionality for SONiC
#

try:
from sonic_led.led_control_base import LedControlBase
import swsssdk
import threading
import os
import logging
import struct
import time
import syslog
from socket import *
from select import *
except ImportError, e:
raise ImportError(str(e) + " - required module not found")


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


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


# 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

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]
else:
return self.LED_MODE_DOWN[0] if (port_idx < 25) else self.LED_MODE_DOWN[1]

def _port_led_mode_update(self, port_idx, ledMode):
with open(self.f_led.format("port{}".format(port_idx)), 'w') as led_file:
led_file.write(str(ledMode))

def _initSystemLed(self):
try:
with open(self.f_led.format("system"), 'w') as led_file:
led_file.write("1")
DBG_PRINT("init system led to normal")
with open(self.f_led.format("idn"), 'w') as led_file:
led_file.write("1")
DBG_PRINT("init idn led to off")
except IOError as e:
DBG_PRINT(str(e))

def _initPanelLed(self):
with open(self.f_led.format("port1"), 'r') as led_file:
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:
led_file.write(str(defmode))
DBG_PRINT("init port{} led to mode={}".format(idx, defmode))

def _initDefaultConfig(self):
DBG_PRINT("start init led")

self._initSystemLed()
self._initPanelLed()

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)
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())

if ledMode == saveMode:
return

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()
74 changes: 74 additions & 0 deletions device/centec/arm64-centec_e530_24x2c-r0/plugins/psuutil.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
#!/usr/bin/env python

#############################################################################
# Centec
#
# Module contains an implementation of SONiC PSU Base API and
# provides the PSUs status which are available in the platform
#
#############################################################################

import os.path

try:
from sonic_psu.psu_base import PsuBase
except ImportError as e:
raise ImportError (str(e) + "- required module not found")

class PsuUtil(PsuBase):
"""Platform-specific PSUutil class"""

def __init__(self):
PsuBase.__init__(self)

self.psu_path = "/sys/class/psu/psu{}/"
self.psu_presence = "psu_presence"
self.psu_oper_status = "psu_status"

def get_num_psus(self):
"""
Retrieves the number of PSUs available on the device

:return: An integer, the number of PSUs available on the device
"""
return 2

def get_psu_status(self, index):
"""
Retrieves the oprational status of power supply unit (PSU) defined
by 1-based index <index>

:param index: An integer, 1-based index of the PSU of which to query status
:return: Boolean, True if PSU is operating properly, False if PSU is faulty
"""
if index is None:
return False

status = 0
try:
with open(self.psu_path.format(index) + self.psu_oper_status, 'r') as power_status:
status = int(power_status.read())
except IOError:
return False

return status == 1

def get_psu_presence(self, index):
"""
Retrieves the presence status of power supply unit (PSU) defined
by 1-based index <index>

:param index: An integer, 1-based index of the PSU of which to query status
:return: Boolean, True if PSU is plugged, False if not
"""
if index is None:
return False

status = 0
try:
with open(self.psu_path.format(index) + self.psu_presence, 'r') as presence_status:
status = int(presence_status.read())
except IOError:
return False

return status == 1
Loading