Skip to content

Commit 4ace65c

Browse files
committed
[device][platform] Add to support as7926-40xfb platform
Switch Vendor: Accton Switch SKU: Accton-AS7926-40XFB CPU: BROADWELL-DE ASIC Vendor: Broadcom Switch ASIC: Broadcom BCM88690 Port Configuration: 40xQSFP28 + 13x QSFP-DD + 2x SFP+ - Why I did it [device][platform] Add to support as7926-40xfb platform - How I did it Implement sysfs and sonic_platform - How to verify it Test sysfs / sensors cmd / sonic_platform / show platform cmd # show platform firmware status # show platform syseeprom # show platform summary # show platform psustatus # psuutil # sfputil # sensors # cat/echo sysfs attributes. - Which release branch to backport (provide reason below if selected) - [ ] 201811 - [ ] 201911 - [ ] 202006 - [X ] 202012 - Description for the changelog Initial commit Signed-off-by: Brandon Chuang <[email protected]>
1 parent 3dc879b commit 4ace65c

35 files changed

+8051
-0
lines changed
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# name lanes alias index speed
2+
Ethernet0 0,1 hundredGigE1 1 100000
3+
Ethernet2 2,3 hundredGigE2 2 100000
4+
Ethernet4 4,5 hundredGigE3 3 100000
5+
Ethernet6 6,7 hundredGigE4 4 100000
6+
Ethernet8 8,9 hundredGigE5 5 100000
7+
Ethernet10 10,11 hundredGigE6 6 100000
8+
Ethernet12 12,13 hundredGigE7 7 100000
9+
Ethernet14 14,15 hundredGigE8 8 100000
10+
Ethernet16 16,17 hundredGigE9 9 100000
11+
Ethernet18 18,19 hundredGigE10 10 100000
12+
Ethernet20 20,21 hundredGigE11 11 100000
13+
Ethernet22 22,23 hundredGigE12 12 100000
14+
Ethernet24 24,25 hundredGigE13 13 100000
15+
Ethernet26 26,27 hundredGigE14 14 100000
16+
Ethernet28 28,29 hundredGigE15 15 100000
17+
Ethernet30 30,31 hundredGigE16 16 100000
18+
Ethernet32 32,33 hundredGigE17 17 100000
19+
Ethernet34 34,35 hundredGigE18 18 100000
20+
Ethernet36 36,37 hundredGigE19 19 100000
21+
Ethernet38 38,39 hundredGigE20 20 100000
22+
Ethernet40 40,41 hundredGigE21 21 100000
23+
Ethernet42 42,43 hundredGigE22 22 100000
24+
Ethernet44 44,45 hundredGigE23 23 100000
25+
Ethernet46 46,47 hundredGigE24 24 100000
26+
Ethernet48 88,89 hundredGigE25 25 100000
27+
Ethernet50 90,91 hundredGigE26 26 100000
28+
Ethernet52 92,93 hundredGigE27 27 100000
29+
Ethernet54 94,95 hundredGigE28 28 100000
30+
Ethernet56 80,81 hundredGigE29 29 100000
31+
Ethernet58 82,83 hundredGigE30 30 100000
32+
Ethernet60 84,85 hundredGigE31 31 100000
33+
Ethernet62 86,87 hundredGigE32 32 100000
34+
Ethernet64 72,73 hundredGigE33 33 100000
35+
Ethernet66 74,75 hundredGigE34 34 100000
36+
Ethernet68 76,77 hundredGigE35 35 100000
37+
Ethernet70 78,79 hundredGigE36 36 100000
38+
Ethernet72 64,65 hundredGigE37 37 100000
39+
Ethernet74 66,67 hundredGigE38 38 100000
40+
Ethernet76 68,69 hundredGigE39 39 100000
41+
Ethernet78 70,71 hundredGigE40 40 100000
42+
Ethernet80 96,97 hundredGigE41 41 100000
43+
Ethernet82 98,99 hundredGigE42 42 100000
44+
Ethernet84 100,101 hundredGigE43 43 100000
45+
Ethernet86 102,103 hundredGigE44 44 100000
46+
Ethernet88 104,105 hundredGigE45 45 100000
47+
Ethernet90 106,107 hundredGigE46 46 100000
48+
Ethernet92 108,109 hundredGigE47 47 100000
49+
Ethernet94 110,111 hundredGigE48 48 100000
50+
Ethernet96 112,113 hundredGigE49 49 100000
51+
Ethernet98 114,115 hundredGigE50 50 100000
52+
Ethernet100 116,117 hundredGigE51 51 100000
53+
Ethernet102 118,119 hundredGigE52 52 100000
54+
Ethernet104 120,121 hundredGigE53 53 100000
55+
Ethernet105 122 twentyfiveGigE54 54 25000
56+
Ethernet106 123 twentyfiveGigE55 55 25000
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Accton-AS7926-40XFB t1
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
CONSOLE_PORT=0x3f8
2+
CONSOLE_DEV=0
3+
CONSOLE_SPEED=115200
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/usr/bin/env python
2+
3+
try:
4+
import binascii
5+
import time
6+
import optparse
7+
import warnings
8+
import os
9+
import sys
10+
from sonic_eeprom import eeprom_base
11+
from sonic_eeprom import eeprom_tlvinfo
12+
import subprocess
13+
except ImportError as e:
14+
raise ImportError(str(e) + "- required module not found")
15+
16+
class board(eeprom_tlvinfo.TlvInfoDecoder):
17+
_TLV_INFO_MAX_LEN = 256
18+
def __init__(self, name, path, cpld_root, ro):
19+
self.eeprom_path = "/sys/bus/i2c/devices/0-0057/eeprom"
20+
super(board, self).__init__(self.eeprom_path, 0, '', True)
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
#!/usr/bin/env python
2+
3+
#############################################################################
4+
# Accton
5+
#
6+
# Module contains an implementation of SONiC PSU Base API and
7+
# provides the PSUs status which are available in the platform
8+
#
9+
#############################################################################
10+
11+
import os.path
12+
13+
try:
14+
from sonic_psu.psu_base import PsuBase
15+
except ImportError as e:
16+
raise ImportError (str(e) + "- required module not found")
17+
18+
class PsuUtil(PsuBase):
19+
"""Platform-specific PSUutil class"""
20+
21+
def __init__(self):
22+
PsuBase.__init__(self)
23+
24+
self.psu_path = "/sys/devices/platform/as7926_40xfb_psu/psu"
25+
self.psu_presence = "_present"
26+
self.psu_oper_status = "_power_good"
27+
self.psu_mapping = {
28+
1: "1",
29+
2: "2"
30+
}
31+
32+
def get_num_psus(self):
33+
return len(self.psu_mapping)
34+
35+
def get_psu_status(self, index):
36+
if index is None:
37+
return False
38+
39+
status = 0
40+
node = self.psu_path + self.psu_mapping[index]+self.psu_oper_status
41+
try:
42+
with open(node, 'r') as power_status:
43+
status = int(power_status.read())
44+
except IOError:
45+
return False
46+
47+
return status == 1
48+
49+
def get_psu_presence(self, index):
50+
if index is None:
51+
return False
52+
53+
status = 0
54+
node = self.psu_path + self.psu_mapping[index] + self.psu_presence
55+
try:
56+
with open(node, 'r') as presence_status:
57+
status = int(presence_status.read())
58+
except IOError:
59+
return False
60+
61+
return status == 1
Lines changed: 228 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,228 @@
1+
# sfputil.py
2+
#
3+
# Platform-specific SFP transceiver interface for SONiC
4+
#
5+
6+
try:
7+
import sys
8+
import time
9+
import string
10+
from ctypes import create_string_buffer
11+
from sonic_sfp.sfputilbase import SfpUtilBase
12+
except ImportError as e:
13+
raise ImportError("%s - required module not found" % str(e))
14+
15+
SFP_STATUS_INSERTED = '1'
16+
SFP_STATUS_REMOVED = '0'
17+
18+
class SfpUtil(SfpUtilBase):
19+
"""Platform-specific SfpUtil class"""
20+
21+
PORT_START = 1
22+
PORT_END = 55
23+
QSFP_PORT_START = 1
24+
QSFP_PORT_END = 53
25+
CPLD_FMT = '/sys/bus/i2c/devices/{bus}-00{addr}/'
26+
27+
_port_to_eeprom_mapping = {}
28+
_port_to_i2c_mapping = {
29+
1: 33,
30+
2: 34,
31+
3: 37,
32+
4: 38,
33+
5: 41,
34+
6: 42,
35+
7: 45,
36+
8: 46,
37+
9: 49,
38+
10: 50,
39+
11: 53,
40+
12: 54,
41+
13: 57,
42+
14: 58,
43+
15: 61,
44+
16: 62,
45+
17: 65,
46+
18: 66,
47+
19: 69,
48+
20: 70,
49+
21: 35,
50+
22: 36,
51+
23: 39,
52+
24: 40,
53+
25: 43,
54+
26: 44,
55+
27: 47,
56+
28: 48,
57+
29: 51,
58+
30: 52,
59+
31: 55,
60+
32: 56,
61+
33: 59,
62+
34: 60,
63+
35: 63,
64+
36: 64,
65+
37: 67,
66+
38: 68,
67+
39: 71,
68+
40: 72,
69+
41: 93,
70+
42: 84,
71+
43: 83,
72+
44: 82,
73+
45: 81,
74+
46: 86,
75+
47: 85,
76+
48: 88,
77+
49: 87,
78+
50: 90,
79+
51: 89,
80+
52: 92,
81+
53: 91,
82+
54: 30,
83+
55: 31
84+
}
85+
86+
@property
87+
def port_start(self):
88+
return self.PORT_START
89+
90+
@property
91+
def port_end(self):
92+
return self.PORT_END
93+
94+
@property
95+
def qsfp_port_start(self):
96+
return self.QSFP_PORT_START
97+
98+
@property
99+
def qsfp_port_end(self):
100+
return self.QSFP_PORT_END
101+
102+
@property
103+
def qsfp_ports(self):
104+
return range(self.QSFP_PORT_START, self.QSFP_PORT_END + 1)
105+
106+
@property
107+
def port_to_eeprom_mapping(self):
108+
return self._port_to_eeprom_mapping
109+
110+
def __init__(self):
111+
eeprom_path = '/sys/bus/i2c/devices/{0}-0050/eeprom'
112+
for x in range(self.port_start, self.port_end+1):
113+
self.port_to_eeprom_mapping[x] = eeprom_path.format(
114+
self._port_to_i2c_mapping[x])
115+
116+
SfpUtilBase.__init__(self)
117+
118+
def get_cpld_path(self, port_num):
119+
if ((1 <= port_num <= 10) or (21 <= port_num <= 30) or (54 <= port_num <= 55)):
120+
return self.CPLD_FMT.format(bus=str(12), addr=str(62))
121+
elif ((11 <= port_num <= 20) or (31 <= port_num <= 40)):
122+
return self.CPLD_FMT.format(bus=str(13), addr=str(63))
123+
elif (41 <= port_num <= 53):
124+
return self.CPLD_FMT.format(bus=str(76), addr=str(64))
125+
126+
return str()
127+
128+
def get_presence(self, port_num):
129+
# Check for invalid port_num
130+
if port_num < self.port_start or port_num > self.port_end:
131+
return False
132+
133+
port_ps = self.get_cpld_path(port_num) + 'module_present_{0}'.format(port_num)
134+
135+
try:
136+
val_file = open(port_ps)
137+
except IOError as e:
138+
print ('Error: unable to open file: ', str(e))
139+
return False
140+
141+
content = val_file.readline().rstrip()
142+
val_file.close()
143+
144+
# content is a string, either "0" or "1"
145+
return content == "1"
146+
147+
def get_low_power_mode(self, port_num):
148+
if port_num < self.qsfp_port_start or port_num > self.qsfp_port_end:
149+
return False
150+
151+
if not self.get_presence(port_num):
152+
return False
153+
154+
try:
155+
eeprom = None
156+
157+
eeprom = open(self.port_to_eeprom_mapping[port_num], mode="rb", buffering=0)
158+
eeprom.seek(93)
159+
lpmode = ord(eeprom.read(1))
160+
161+
if not (lpmode & 0x1): # 'Power override' bit is 0
162+
return False # Default High Power Mode
163+
else:
164+
if ((lpmode & 0x2) == 0x2):
165+
return True # Low Power Mode if "Power set" bit is 1
166+
else:
167+
return False # High Power Mode if "Power set" bit is 0
168+
except IOError as e:
169+
print ('Error: unable to open file: ', str(e))
170+
return False
171+
finally:
172+
if eeprom is not None:
173+
eeprom.close()
174+
time.sleep(0.01)
175+
176+
def set_low_power_mode(self, port_num, lpmode):
177+
if port_num < self.qsfp_port_start or port_num > self.qsfp_port_end:
178+
return False
179+
180+
try:
181+
eeprom = None
182+
183+
if not self.get_presence(port_num):
184+
return False # Port is not present, unable to set the eeprom
185+
186+
# Fill in write buffer
187+
regval = 0x3 if lpmode else 0x1 # 0x3:Low Power Mode, 0x1:High Power Mode
188+
buffer = create_string_buffer(1)
189+
if sys.version_info[0] >= 3:
190+
buffer[0] = regval
191+
else:
192+
buffer[0] = chr(regval)
193+
194+
# Write to eeprom
195+
eeprom = open(self.port_to_eeprom_mapping[port_num], mode="r+b", buffering=0)
196+
eeprom.seek(93)
197+
eeprom.write(buffer[0])
198+
return True
199+
except IOError as e:
200+
print ('Error: unable to open file: ', str(e))
201+
return False
202+
finally:
203+
if eeprom is not None:
204+
eeprom.close()
205+
time.sleep(0.01)
206+
207+
def reset(self, port_num):
208+
# Check for invalid port_num
209+
if port_num < self.qsfp_port_start or port_num > self.qsfp_port_end:
210+
return False
211+
212+
port_ps = self.get_cpld_path(port_num) + 'module_reset_{0}'.format(port_num)
213+
214+
try:
215+
reg_file = open(port_ps, mode="w")
216+
except IOError as e:
217+
print ('Error: unable to open file: ', str(e))
218+
return False
219+
220+
#toggle reset
221+
reg_file.seek(0)
222+
reg_file.write('1')
223+
time.sleep(1)
224+
reg_file.seek(0)
225+
reg_file.write('0')
226+
reg_file.close()
227+
228+
return True
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"skip_ledd": true,
3+
"skip_thermalctld": true
4+
}
5+
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
__all__ = ['chassis', 'eeprom', 'platform', 'psu', 'sfp', 'thermal', 'fan', 'fan_drawer']
2+
from . import platform

0 commit comments

Comments
 (0)