-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[centec]update centec e582 platform drivers and libsai (#2043)
* update centec e582 platform drivers and libsai * delete minigraph.xml * remove minigraph * update psuutil.py comments * update device qos config file and clean minigraph
- Loading branch information
1 parent
3b4d852
commit 0b3a885
Showing
52 changed files
with
5,095 additions
and
2,233 deletions.
There are no files selected for viewing
70 changes: 70 additions & 0 deletions
70
device/centec/x86_64-centec_e582_48x2q4z-r0/E582-48x2q4z/buffers.json.j2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 %} | ||
} | ||
} | ||
} | ||
|
21 changes: 21 additions & 0 deletions
21
device/centec/x86_64-centec_e582_48x2q4z-r0/E582-48x2q4z/pg_profile_lookup.ini
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|
55 changes: 55 additions & 0 deletions
55
device/centec/x86_64-centec_e582_48x2q4z-r0/E582-48x2q4z/port_config.ini
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
# name lanes alias speed | ||
Ethernet1 75 eth-0-1 1000 | ||
Ethernet2 73 eth-0-2 1000 | ||
Ethernet3 72 eth-0-3 1000 | ||
Ethernet4 70 eth-0-4 1000 | ||
Ethernet5 69 eth-0-5 1000 | ||
Ethernet6 67 eth-0-6 1000 | ||
Ethernet7 66 eth-0-7 1000 | ||
Ethernet8 64 eth-0-8 1000 | ||
Ethernet9 63 eth-0-9 1000 | ||
Ethernet10 61 eth-0-10 1000 | ||
Ethernet11 60 eth-0-11 1000 | ||
Ethernet12 58 eth-0-12 1000 | ||
Ethernet13 57 eth-0-13 10000 | ||
Ethernet14 56 eth-0-14 10000 | ||
Ethernet15 55 eth-0-15 10000 | ||
Ethernet16 53 eth-0-16 10000 | ||
Ethernet17 52 eth-0-17 10000 | ||
Ethernet18 50 eth-0-18 10000 | ||
Ethernet19 49 eth-0-19 10000 | ||
Ethernet20 48 eth-0-20 10000 | ||
Ethernet21 0 eth-0-21 10000 | ||
Ethernet22 1 eth-0-22 10000 | ||
Ethernet23 3 eth-0-23 10000 | ||
Ethernet24 2 eth-0-24 10000 | ||
Ethernet25 4 eth-0-25 10000 | ||
Ethernet26 5 eth-0-26 10000 | ||
Ethernet27 6 eth-0-27 10000 | ||
Ethernet28 7 eth-0-28 10000 | ||
Ethernet29 8 eth-0-29 10000 | ||
Ethernet30 9 eth-0-30 10000 | ||
Ethernet31 10 eth-0-31 10000 | ||
Ethernet32 12 eth-0-32 10000 | ||
Ethernet33 13 eth-0-33 10000 | ||
Ethernet34 15 eth-0-34 10000 | ||
Ethernet35 16 eth-0-35 10000 | ||
Ethernet36 18 eth-0-36 10000 | ||
Ethernet37 19 eth-0-37 10000 | ||
Ethernet38 21 eth-0-38 10000 | ||
Ethernet39 22 eth-0-39 10000 | ||
Ethernet40 24 eth-0-40 10000 | ||
Ethernet41 25 eth-0-41 10000 | ||
Ethernet42 27 eth-0-42 10000 | ||
Ethernet43 28 eth-0-43 10000 | ||
Ethernet44 30 eth-0-44 10000 | ||
Ethernet45 31 eth-0-45 10000 | ||
Ethernet46 33 eth-0-46 10000 | ||
Ethernet47 34 eth-0-47 10000 | ||
Ethernet48 36 eth-0-48 10000 | ||
Ethernet49 42,41,43,40 eth-0-49 40000 | ||
Ethernet50 45,46,44,47 eth-0-50 40000 | ||
Ethernet51 94,93,95,92 eth-0-51 100000 | ||
Ethernet52 89,90,88,91 eth-0-52 100000 | ||
Ethernet53 85,86,84,87 eth-0-53 100000 | ||
Ethernet54 81,82,80,83 eth-0-54 100000 |
1 change: 1 addition & 0 deletions
1
device/centec/x86_64-centec_e582_48x2q4z-r0/E582-48x2q4z/qos.json.j2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{%- include 'qos_config.j2' %} |
2 changes: 2 additions & 0 deletions
2
device/centec/x86_64-centec_e582_48x2q4z-r0/E582-48x2q4z/sai.profile
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
SAI_INIT_CONFIG_FILE=/etc/centec/E582-48x2q4z-chip-profile.txt | ||
SAI_HW_PORT_PROFILE_ID_CONFIG_FILE=/etc/centec/E582-48x2q4z-datapath-cfg.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
E582-48x2q4z t1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# Configuration file generated by pwmconfig, changes will be lost | ||
INTERVAL=10 | ||
DEVPATH=hwmon1=devices/platform/coretemp.0 hwmon5=devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-15/15-002f | ||
DEVNAME=hwmon1=coretemp hwmon5=adt7470 | ||
FCTEMPS=hwmon5/pwm4=hwmon1/temp1_input hwmon5/pwm3=hwmon1/temp1_input hwmon5/pwm2=hwmon1/temp1_input hwmon5/pwm1=hwmon1/temp1_input | ||
FCFANS=hwmon5/pwm4=hwmon5/fan4_input hwmon5/pwm3=hwmon5/fan3_input hwmon5/pwm2=hwmon5/fan2_input hwmon5/pwm1=hwmon5/fan1_input | ||
MINTEMP=hwmon5/pwm4=20 hwmon5/pwm3=20 hwmon5/pwm2=20 hwmon5/pwm1=20 | ||
MAXTEMP=hwmon5/pwm4=60 hwmon5/pwm3=60 hwmon5/pwm2=60 hwmon5/pwm1=60 | ||
MINSTART=hwmon5/pwm4=150 hwmon5/pwm3=150 hwmon5/pwm2=150 hwmon5/pwm1=150 | ||
MINSTOP=hwmon5/pwm4=0 hwmon5/pwm3=0 hwmon5/pwm2=0 hwmon5/pwm1=100 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
CONSOLE_SPEED=115200 | ||
ONIE_PLATFORM_EXTRA_CMDLINE_LINUX="acpi_enforce_resources=no" |
31 changes: 31 additions & 0 deletions
31
device/centec/x86_64-centec_e582_48x2q4z-r0/plugins/eeprom.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#!/usr/bin/env python | ||
|
||
############################################################################# | ||
# Centec E582-48X6Q | ||
# | ||
# 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 = "/sys/class/i2c-adapter/i2c-0/0-0057/eeprom" | ||
super(board, self).__init__(self.eeprom_path, 0, '', True) |
153 changes: 153 additions & 0 deletions
153
device/centec/x86_64-centec_e582_48x2q4z-r0/plugins/led_control.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,153 @@ | ||
#!/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""" | ||
SONIC_PORT_NAME_PREFIX = "Ethernet" | ||
LED_MODE_UP = [11, 1] | ||
LED_MODE_DOWN = [7, 2] | ||
|
||
def _initSystemLed(self): | ||
try: | ||
with open(self.f_led.format("system"), 'w') as led_file: | ||
led_file.write("5") | ||
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 (port, ctlid, defmode) in self.led_mapping[1:59]: | ||
data = struct.pack('=HHHBBH', 0, 7, 4, ctlid, defmode, port) | ||
self.udpClient.sendto(data, ('localhost', 8101)) | ||
|
||
data = struct.pack('=HHHBB30B', 0, 3, 32, 30, 0, *[x[0] for x in self.led_mapping[21:51]]) | ||
self.udpClient.sendto(data, ('localhost', 8101)) | ||
data = struct.pack('=HHHBB28B', 0, 3, 30, 28, 1, *[x[0] for x in (self.led_mapping[1:21]+self.led_mapping[51:59])]) | ||
self.udpClient.sendto(data, ('localhost', 8101)) | ||
|
||
data = struct.pack('=HHHB', 0, 5, 1, 1) | ||
self.udpClient.sendto(data, ('localhost', 8101)) | ||
|
||
for idx in range(1, 55): | ||
(port, ctlid, defmode) = self.led_mapping[idx] | ||
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)) | ||
|
||
for idx in range(1, 55): | ||
(port, ctlid, defmode) = self.led_mapping[idx] | ||
with open(self.f_led.format("port{}".format(idx)), 'r') as led_file: | ||
defmode = int(led_file.read()) | ||
data = struct.pack('=HHHBBH', 0, 7, 4, ctlid, defmode, port) | ||
self.udpClient.sendto(data, ('localhost', 8101)) | ||
DBG_PRINT("init port{} led to mode={}".format(idx, defmode)) | ||
|
||
def _initDefaultConfig(self): | ||
DBG_PRINT("start init led") | ||
while True: | ||
try: | ||
r_sel = [self.udpClient] | ||
echo_req = struct.pack('=HHH', 0, 1, 0) | ||
self.udpClient.sendto(echo_req, ('localhost', 8101)) | ||
result = select(r_sel, [], [], 1) | ||
if self.udpClient in result[0]: | ||
echo_rsp, srv_addr = self.udpClient.recvfrom(1024) | ||
if echo_rsp: | ||
break | ||
DBG_PRINT("connect to sdk rpc server timeout, try again.") | ||
except IOError as e: | ||
DBG_PRINT(str(e)) | ||
|
||
DBG_PRINT("connect to sdk rpc server success.") | ||
|
||
self._initSystemLed() | ||
self._initPanelLed() | ||
|
||
DBG_PRINT("init led done") | ||
|
||
|
||
# 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 < 49) else self.LED_MODE_UP[1] | ||
else: | ||
return self.LED_MODE_DOWN[0] if (port_idx < 49) 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)) | ||
(port, ctlid) = (self.led_mapping[port_idx][0], self.led_mapping[port_idx][1]) | ||
data = struct.pack('=HHHBBH', 0, 7, 4, ctlid, ledMode, port) | ||
self.udpClient.sendto(data, ('localhost', 8101)) | ||
|
||
# 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): | ||
# [macid, ctlid, defaultmode] | ||
self.led_mapping = [(0, 0, 0)] # resv | ||
self.led_mapping.extend([(27, 1, 7), (25, 1, 7), (24, 1, 7), (22, 1, 7), (21, 1, 7), (19, 1, 7), (18, 1, 7), (16, 1, 7)]) # panel port 1~8 | ||
self.led_mapping.extend([(15, 1, 7), (13, 1, 7), (12, 1, 7), (10, 1, 7), (9, 1, 7), (8, 1, 7), (7, 1, 7), (5, 1, 7)]) # panel port 9~16 | ||
self.led_mapping.extend([(4, 1, 7), (2, 1, 7), (1, 1, 7), (0, 1, 7), (0, 0, 7), (1, 0, 7), (3, 0, 7), (2, 0, 7)]) # panel port 17~24 | ||
self.led_mapping.extend([(4, 0, 7), (5, 0, 7), (6, 0, 7), (7, 0, 7), (8, 0, 7), (9, 0, 7), (10, 0, 7), (12, 0, 7)]) # panel port 25~32 | ||
self.led_mapping.extend([(13, 0, 7), (15, 0, 7), (16, 0, 7), (18, 0, 7), (19, 0, 7), (21, 0, 7), (22, 0, 7), (24, 0, 7)]) # panel port 33~40 | ||
self.led_mapping.extend([(25, 0, 7), (27, 0, 7), (28, 0, 7), (30, 0, 7), (31, 0, 7), (33, 0, 7), (34, 0, 7), (48, 0, 7)]) # panel port 41~48 | ||
self.led_mapping.extend([(36, 0, 2), (52, 0, 2), (52, 1, 2), (36, 1, 2), (48, 1, 2), (32, 1, 2)]) # panel port 49~54 | ||
self.led_mapping.extend([(11, 1, 2), (11, 1, 2), (11, 1, 2), (11, 1, 2), (11, 1, 2), (11, 1, 2)]) | ||
|
||
self.f_led = "/sys/class/leds/{}/brightness" | ||
|
||
self.udpClient = socket(AF_INET, SOCK_DGRAM) | ||
|
||
self._initDefaultConfig() | ||
|
Oops, something went wrong.