Skip to content

Commit

Permalink
[Platform] Accton add to support as4630-54te platform. (sonic-net#6683)
Browse files Browse the repository at this point in the history
Add support for Accton as4630-54te platform
  • Loading branch information
ec-michael-shih authored and yxieca committed Mar 3, 2021
1 parent edd7fa1 commit d606b72
Show file tree
Hide file tree
Showing 42 changed files with 6,428 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# name lanes alias index speed autoneg
Ethernet0 26 thousandE1 1 1000 1
Ethernet1 25 thousandE2 2 1000 1
Ethernet2 28 thousandE3 3 1000 1
Ethernet3 27 thousandE4 4 1000 1
Ethernet4 30 thousandE5 5 1000 1
Ethernet5 29 thousandE6 6 1000 1
Ethernet6 32 thousandE7 7 1000 1
Ethernet7 31 thousandE8 8 1000 1
Ethernet8 38 thousandE9 9 1000 1
Ethernet9 37 thousandE10 10 1000 1
Ethernet10 40 thousandE11 11 1000 1
Ethernet11 39 thousandE12 12 1000 1
Ethernet12 34 thousandE13 13 1000 1
Ethernet13 33 thousandE14 14 1000 1
Ethernet14 36 thousandE15 15 1000 1
Ethernet15 35 thousandE16 16 1000 1
Ethernet16 46 thousandE17 17 1000 1
Ethernet17 45 thousandE18 18 1000 1
Ethernet18 48 thousandE19 19 1000 1
Ethernet19 47 thousandE20 20 1000 1
Ethernet20 42 thousandE21 21 1000 1
Ethernet21 41 thousandE22 22 1000 1
Ethernet22 44 thousandE23 23 1000 1
Ethernet23 43 thousandE24 24 1000 1
Ethernet24 2 thousandE25 25 1000 1
Ethernet25 1 thousandE26 26 1000 1
Ethernet26 4 thousandE27 27 1000 1
Ethernet27 3 thousandE28 28 1000 1
Ethernet28 6 thousandE29 29 1000 1
Ethernet29 5 thousandE30 30 1000 1
Ethernet30 8 thousandE31 31 1000 1
Ethernet31 7 thousandE32 32 1000 1
Ethernet32 10 thousandE33 33 1000 1
Ethernet33 9 thousandE34 34 1000 1
Ethernet34 12 thousandE35 35 1000 1
Ethernet35 11 thousandE36 36 1000 1
Ethernet36 14 thousandE37 37 1000 1
Ethernet37 13 thousandE38 38 1000 1
Ethernet38 16 thousandE39 39 1000 1
Ethernet39 15 thousandE40 40 1000 1
Ethernet40 18 thousandE41 41 1000 1
Ethernet41 17 thousandE42 42 1000 1
Ethernet42 20 thousandE43 43 1000 1
Ethernet43 19 thousandE44 44 1000 1
Ethernet44 22 thousandE45 45 1000 1
Ethernet45 21 thousandE46 46 1000 1
Ethernet46 24 thousandE47 47 1000 1
Ethernet47 23 thousandE48 48 1000 1
Ethernet48 67 twentyfiveGigE49 49 25000 0
Ethernet49 66 twentyfiveGigE50 50 25000 0
Ethernet50 65 twentyfiveGigE51 51 25000 0
Ethernet51 68 twentyfiveGigE52 52 25000 0
Ethernet52 73,74,75,76 hundredGigE53 53 100000 0
Ethernet56 69,70,71,72 hundredGigE54 54 100000 0
1 change: 1 addition & 0 deletions device/accton/x86_64-accton_as4630_54te-r0/default_sku
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Accton-AS4630-54TE t1
3 changes: 3 additions & 0 deletions device/accton/x86_64-accton_as4630_54te-r0/installer.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
CONSOLE_PORT=0x3f8
CONSOLE_DEV=0
CONSOLE_SPEED=115200
13 changes: 13 additions & 0 deletions device/accton/x86_64-accton_as4630_54te-r0/plugins/eeprom.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
try:
from sonic_eeprom import eeprom_tlvinfo

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


class board(eeprom_tlvinfo.TlvInfoDecoder):
_TLV_INFO_MAX_LEN = 256

def __init__(self, name, path, cpld_root, ro):
self.eeprom_path = "/sys/bus/i2c/devices/1-0057/eeprom"
super(board, self).__init__(self.eeprom_path, 0, '', True)
61 changes: 61 additions & 0 deletions device/accton/x86_64-accton_as4630_54te-r0/plugins/psuutil.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
#!/usr/bin/env python

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


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/bus/i2c/devices/"
self.psu_presence = "/psu_present"
self.psu_oper_status = "/psu_power_good"
self.psu_mapping = {
1: "10-0050",
2: "11-0051",
}

def get_num_psus(self):
return len(self.psu_mapping)

def get_psu_status(self, index):
if index is None:
return False

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

return status == 1

def get_psu_presence(self, index):
if index is None:
return False

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

return status == 1
196 changes: 196 additions & 0 deletions device/accton/x86_64-accton_as4630_54te-r0/plugins/sfputil.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,196 @@
# sfputil.py
#
# Platform-specific SFP transceiver interface for SONiC
#

try:
import sys
import time
from ctypes import create_string_buffer
from sonic_sfp.sfputilbase import SfpUtilBase
except ImportError as e:
raise ImportError("%s - required module not found" % str(e))

SFP_STATUS_INSERTED = '1'
SFP_STATUS_REMOVED = '0'


class SfpUtil(SfpUtilBase):
"""Platform-specific SfpUtil class"""

PORT_START = 49
PORT_END = 54
PORTS_IN_BLOCK = 54
QSFP_START = 53

BASE_OOM_PATH = "/sys/bus/i2c/devices/{0}-0050/"
BASE_CPLD_PATH = "/sys/bus/i2c/devices/3-0060/"

_port_to_is_present = {}
_port_to_lp_mode = {}

_port_to_eeprom_mapping = {}
_port_to_i2c_mapping = {
49: [18],
50: [19],
51: [20],
52: [21],
53: [22],
54: [23],
}

@property
def port_start(self):
return self.PORT_START

@property
def port_end(self):
return self.PORT_END

@property
def qsfp_ports(self):
return range(self.PORT_START, self.PORTS_IN_BLOCK + 1)

@property
def port_to_eeprom_mapping(self):
return self._port_to_eeprom_mapping

def __init__(self):
eeprom_path = self.BASE_OOM_PATH + "eeprom"
for x in range(self.port_start, self.port_end + 1):
self.port_to_eeprom_mapping[x] = eeprom_path.format(
self._port_to_i2c_mapping[x][0])
SfpUtilBase.__init__(self)

def get_presence(self, port_num):
# Check for invalid port_num
if port_num < self.port_start or port_num > self.port_end:
return False

present_path = self.BASE_CPLD_PATH + "module_present_" + str(port_num)
self.__port_to_is_present = present_path

try:
val_file = open(self.__port_to_is_present)
content = val_file.readline().rstrip()
val_file.close()
except IOError as e:
print ('Error: unable to access file: %s') % str(e)
return False

if content == "1":
return True

return False

def get_low_power_mode(self, port_num):
# Check for invalid port_num
if port_num < self.QSFP_START or port_num > self.port_end:
return False

try:
eeprom = None
if not self.get_presence(port_num):
return False
eeprom = open(self.port_to_eeprom_mapping[port_num], "rb")
eeprom.seek(93)
lpmode = ord(eeprom.read(1))

# if "Power override" bit is 1 and "Power set" bit is 1
if ((lpmode & 0x3) == 0x3):
return True

# High Power Mode if one of the following conditions is matched:
# 1. "Power override" bit is 0
# 2. "Power override" bit is 1 and "Power set" bit is 0
else:
return False

except IOError as e:
print ('Error: unable to open file: %s') % str(e)
return False
finally:
if eeprom is not None:
eeprom.close()
time.sleep(0.01)

def set_low_power_mode(self, port_num, lpmode):
# Check for invalid port_num
if port_num < self.QSFP_START or port_num > self.port_end:
return False

try:
eeprom = None
if not self.get_presence(port_num):
return False # Port is not present, unable to set the eeprom

# Fill in write buffer
# 0x3:Low Power Mode, 0x1:High Power Mode
regval = 0x3 if lpmode else 0x1

buffer = create_string_buffer(1)
if sys.version_info[0] >= 3:
buffer[0] = regval
else:
buffer[0] = chr(regval)

# Write to eeprom
eeprom = open(self.port_to_eeprom_mapping[port_num], "r+b")
eeprom.seek(93)
eeprom.write(buffer[0])
return True
except IOError as e:
print ('Error: unable to open file: %s') % str(e)
return False
finally:
if eeprom is not None:
eeprom.close()
time.sleep(0.01)

def reset(self, port_num):
raise NotImplementedError

@property
def _get_presence_bitmap(self):

bits = []
for x in range(self.port_start, self.port_end + 1):
bits.append(str(int(self.get_presence(x))))

rev = "".join(bits[::-1])
return int(rev, 2)

data = {'present': 0}

def get_transceiver_change_event(self, timeout=0):
port_dict = {}

if timeout == 0:
cd_ms = sys.maxsize
else:
cd_ms = timeout

# poll per second
while cd_ms > 0:
reg_value = self._get_presence_bitmap
changed_ports = self.data['present'] ^ reg_value
if changed_ports != 0:
break
time.sleep(1)
cd_ms = cd_ms - 1000

if changed_ports != 0:
for port in range(self.port_start, self.port_end + 1):
# Mask off the bit corresponding to our port
mask = (1 << (port - self.port_start))
if changed_ports & mask:
if (reg_value & mask) == 0:
port_dict[port] = SFP_STATUS_REMOVED
else:
port_dict[port] = SFP_STATUS_INSERTED

# Update cache
self.data['present'] = reg_value
return True, port_dict
else:
return True, {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"skip_ledd": true,
"skip_thermalctld": true
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
__all__ = ['chassis', 'eeprom', 'platform', 'psu', 'sfp', 'thermal', 'fan']
from . import platform
Loading

0 comments on commit d606b72

Please sign in to comment.