Skip to content

Commit

Permalink
[Platform] Accton add to support as4630-54te platform.
Browse files Browse the repository at this point in the history
  • Loading branch information
ec-michael-shih committed Feb 4, 2021
1 parent 984c1cd commit 638a205
Show file tree
Hide file tree
Showing 30 changed files with 4,135 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
23 changes: 23 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,23 @@
#!/usr/bin/env python

try:
import exceptions
import binascii
import time
import optparse
import warnings
import os
import sys
from sonic_eeprom import eeprom_base
from sonic_eeprom import eeprom_tlvinfo
import subprocess
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)
62 changes: 62 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,62 @@
#!/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
#
#############################################################################

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/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
import string
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

content = "0"
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)
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, {}
return False, {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"skip_ledd": true,
"skip_thermalctld": true
}

1 change: 1 addition & 0 deletions platform/broadcom/one-image.mk
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ $(SONIC_ONE_IMAGE)_LAZY_INSTALLS += $(DELL_S6000_PLATFORM_MODULE) \
$(ACCTON_AS6712_32X_PLATFORM_MODULE) \
$(ACCTON_AS7726_32X_PLATFORM_MODULE) \
$(ACCTON_AS4630_54PE_PLATFORM_MODULE) \
$(ACCTON_AS4630_54TE_PLATFORM_MODULE) \
$(ACCTON_MINIPACK_PLATFORM_MODULE) \
$(ACCTON_AS5812_54X_PLATFORM_MODULE) \
$(ACCTON_AS5812_54T_PLATFORM_MODULE) \
Expand Down
6 changes: 6 additions & 0 deletions platform/broadcom/platform-modules-accton.mk
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ ACCTON_AS7716_32XB_PLATFORM_MODULE_VERSION = 1.1
ACCTON_AS6712_32X_PLATFORM_MODULE_VERSION = 1.1
ACCTON_AS7726_32X_PLATFORM_MODULE_VERSION = 1.1
ACCTON_AS4630_54PE_PLATFORM_MODULE_VERSION = 1.1
ACCTON_AS4630_54TE_PLATFORM_MODULE_VERSION = 1.1
ACCTON_MINIPACK_PLATFORM_MODULE_VERSION = 1.1
ACCTON_AS5812_54X_PLATFORM_MODULE_VERSION = 1.1
ACCTON_AS5812_54T_PLATFORM_MODULE_VERSION = 1.1
Expand All @@ -29,6 +30,7 @@ export ACCTON_AS7716_32XB_PLATFORM_MODULE_VERSION
export ACCTON_AS6712_32X_PLATFORM_MODULE_VERSION
export ACCTON_AS7726_32X_PLATFORM_MODULE_VERSION
export ACCTON_AS4630_54PE_PLATFORM_MODULE_VERSION
export ACCTON_AS4630_54TE_PLATFORM_MODULE_VERSION
export ACCTON_MINIPACK_PLATFORM_MODULE_VERSION
export ACCTON_AS5812_54X_PLATFORM_MODULE_VERSION
export ACCTON_AS5812_54T_PLATFORM_MODULE_VERSION
Expand Down Expand Up @@ -84,6 +86,10 @@ ACCTON_AS4630_54PE_PLATFORM_MODULE = sonic-platform-accton-as4630-54pe_$(ACCTON_
$(ACCTON_AS4630_54PE_PLATFORM_MODULE)_PLATFORM = x86_64-accton_as4630_54pe-r0
$(eval $(call add_extra_package,$(ACCTON_AS7712_32X_PLATFORM_MODULE),$(ACCTON_AS4630_54PE_PLATFORM_MODULE)))

ACCTON_AS4630_54TE_PLATFORM_MODULE = sonic-platform-accton-as4630-54te_$(ACCTON_AS4630_54TE_PLATFORM_MODULE_VERSION)_amd64.deb
$(ACCTON_AS4630_54TE_PLATFORM_MODULE)_PLATFORM = x86_64-accton_as4630_54te-r0
$(eval $(call add_extra_package,$(ACCTON_AS7712_32X_PLATFORM_MODULE),$(ACCTON_AS4630_54TE_PLATFORM_MODULE)))

ACCTON_MINIPACK_PLATFORM_MODULE = sonic-platform-accton-minipack_$(ACCTON_MINIPACK_PLATFORM_MODULE_VERSION)_amd64.deb
$(ACCTON_MINIPACK_PLATFORM_MODULE)_PLATFORM = x86_64-accton_minipack-r0
$(eval $(call add_extra_package,$(ACCTON_AS7712_32X_PLATFORM_MODULE),$(ACCTON_MINIPACK_PLATFORM_MODULE)))
Expand Down
Empty file.
Loading

0 comments on commit 638a205

Please sign in to comment.