Skip to content

Commit e4cae4e

Browse files
cytsai0409lguohan
authored andcommitted
[Ingrasys] update port_config.ini and sfputil for ingrasys platforms (#952)
* [Ingrasys] update port_config.ini and sfputil for ingrasys platforms - What I did Update port_config.ini on S8810-32Q/S8900-54XC/S8900-64XC/S9100-C32 platforms - How I did it Update alias field and add port field in port_config.ini - How to verify it Check with the "sfputil show eeprom" command. If no error occurs, it is passed. - Description for the changelog Update port_config.ini on S8810-32Q/S8900-54XC/S8900-64XC/S9100-C32 platforms * [Ingrasys] remove debug message in sfputil.py on S8810-32Q - What I did remove debug message in sfputil.py on S8810-32Q - How I did it remove print in get_low_power_mode() and set_low_power_mode() - How to verify it There should be no debug message when executing "sfputil show lpmode" and "sfputil lpmode on Ethernet0"command. - Description for the changelog remove debug message in sfputil.py on S8810-32Q - A picture of a cute animal (not mandatory but encouraged)
1 parent 686e227 commit e4cae4e

File tree

6 files changed

+540
-257
lines changed

6 files changed

+540
-257
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,33 @@
1-
# name lanes alias
2-
Ethernet0 37,38,39,40
3-
Ethernet4 33,34,35,36
4-
Ethernet8 45,46,47,48
5-
Ethernet12 41,42,43,44
6-
Ethernet16 53,54,55,56
7-
Ethernet20 49,50,51,52
8-
Ethernet24 61,62,63,64
9-
Ethernet28 57,58,59,60
10-
Ethernet32 69,70,71,72
11-
Ethernet36 65,66,67,68
12-
Ethernet40 77,78,79,80
13-
Ethernet44 73,74,75,76
14-
Ethernet48 85,86,87,88
15-
Ethernet52 81,82,83,84
16-
Ethernet56 93,94,95,96
17-
Ethernet60 89,90,91,92
18-
Ethernet64 101,102,103,104
19-
Ethernet68 97,98,99,100
20-
Ethernet72 109,110,111,112
21-
Ethernet76 105,106,107,108
22-
Ethernet80 117,118,119,120
23-
Ethernet84 113,114,115,116
24-
Ethernet88 125,126,127,128
25-
Ethernet92 121,122,123,124
26-
Ethernet96 5,6,7,8
27-
Ethernet100 1,2,3,4
28-
Ethernet104 13,14,15,16
29-
Ethernet108 9,10,11,12
30-
Ethernet112 21,22,23,24
31-
Ethernet116 17,18,19,20
32-
Ethernet120 29,30,31,32
33-
Ethernet124 25,26,27,28
1+
# name lanes alias port
2+
Ethernet0 37,38,39,40 Ethernet1/1 0
3+
Ethernet4 33,34,35,36 Ethernet2/1 1
4+
Ethernet8 45,46,47,48 Ethernet3/1 2
5+
Ethernet12 41,42,43,44 Ethernet4/1 3
6+
Ethernet16 53,54,55,56 Ethernet5/1 4
7+
Ethernet20 49,50,51,52 Ethernet6/1 5
8+
Ethernet24 61,62,63,64 Ethernet7/1 6
9+
Ethernet28 57,58,59,60 Ethernet8/1 7
10+
Ethernet32 69,70,71,72 Ethernet9/1 8
11+
Ethernet36 65,66,67,68 Ethernet10/1 9
12+
Ethernet40 77,78,79,80 Ethernet11/1 10
13+
Ethernet44 73,74,75,76 Ethernet12/1 11
14+
Ethernet48 85,86,87,88 Ethernet13/1 12
15+
Ethernet52 81,82,83,84 Ethernet14/1 13
16+
Ethernet56 93,94,95,96 Ethernet15/1 14
17+
Ethernet60 89,90,91,92 Ethernet16/1 15
18+
Ethernet64 101,102,103,104 Ethernet17/1 16
19+
Ethernet68 97,98,99,100 Ethernet18/1 17
20+
Ethernet72 109,110,111,112 Ethernet19/1 18
21+
Ethernet76 105,106,107,108 Ethernet20/1 19
22+
Ethernet80 117,118,119,120 Ethernet21/1 20
23+
Ethernet84 113,114,115,116 Ethernet22/1 21
24+
Ethernet88 125,126,127,128 Ethernet23/1 22
25+
Ethernet92 121,122,123,124 Ethernet24/1 23
26+
Ethernet96 5,6,7,8 Ethernet25/1 24
27+
Ethernet100 1,2,3,4 Ethernet26/1 25
28+
Ethernet104 13,14,15,16 Ethernet27/1 26
29+
Ethernet108 9,10,11,12 Ethernet28/1 27
30+
Ethernet112 21,22,23,24 Ethernet29/1 28
31+
Ethernet116 17,18,19,20 Ethernet30/1 29
32+
Ethernet120 29,30,31,32 Ethernet31/1 30
33+
Ethernet124 25,26,27,28 Ethernet32/1 31
Original file line numberDiff line numberDiff line change
@@ -1,61 +1,147 @@
1-
#!/usr/bin/env python
1+
# sfputil.py
2+
#
3+
# Platform-specific SFP transceiver interface for SONiC
4+
#
25

36
try:
4-
from sonic_sfp.sfputilbase import sfputilbase
5-
except ImportError, e:
6-
raise ImportError (str(e) + "- required module not found")
7-
8-
9-
class sfputil(sfputilbase):
10-
"""Platform specific sfputil class"""
11-
12-
port_start = 0
13-
port_end = 31
14-
ports_in_block = 32
15-
16-
port_to_eeprom_mapping = {}
17-
#FIXME
18-
port_to_i2c_mapping = {
19-
0: 18,
20-
1: 19,
21-
2: 20,
22-
3: 21,
23-
4: 22,
24-
5: 23,
25-
6: 24,
26-
7: 25,
27-
8: 26,
28-
9: 27,
29-
10: 28,
30-
11: 29,
31-
12: 30,
32-
13: 31,
33-
14: 32,
34-
15: 33,
35-
16: 34,
36-
17: 35,
37-
18: 36,
38-
19: 37,
39-
20: 38,
40-
21: 39,
41-
22: 40,
42-
23: 41,
43-
24: 42,
44-
25: 43,
45-
26: 44,
46-
27: 45,
47-
28: 46,
48-
29: 47,
49-
30: 48,
50-
31: 49
51-
}
52-
53-
_qsfp_ports = range(0, ports_in_block + 1)
54-
55-
def __init__(self, port_num):
7+
import time
8+
from sonic_sfp.sfputilbase import SfpUtilBase
9+
except ImportError as e:
10+
raise ImportError("%s - required module not found" % str(e))
11+
12+
13+
class SfpUtil(SfpUtilBase):
14+
"""Platform-specific SfpUtil class"""
15+
16+
PORT_START = 0
17+
PORT_END = 31
18+
PORTS_IN_BLOCK = 32
19+
20+
EEPROM_OFFSET = 18
21+
22+
ABS_GPIO_BASE = 224
23+
#INT_GPIO_BASE = 192
24+
LP_GPIO_BASE = 160
25+
RST_GPIO_BASE = 128
26+
27+
BASE_DIR_PATH = "/sys/class/gpio/gpio{0}/direction"
28+
BASE_VAL_PATH = "/sys/class/gpio/gpio{0}/value"
29+
30+
_port_to_eeprom_mapping = {}
31+
32+
@property
33+
def port_start(self):
34+
return self.PORT_START
35+
36+
@property
37+
def port_end(self):
38+
return self.PORT_END
39+
40+
@property
41+
def qsfp_ports(self):
42+
return range(0, self.PORTS_IN_BLOCK + 1)
43+
44+
@property
45+
def port_to_eeprom_mapping(self):
46+
return self._port_to_eeprom_mapping
47+
48+
def __init__(self):
5649
# Override port_to_eeprom_mapping for class initialization
57-
eeprom_path = '/sys/class/i2c-adapter/i2c-{0}/{0}-0050/eeprom'
50+
eeprom_path = "/sys/class/i2c-adapter/i2c-{0}/{0}-0050/eeprom"
51+
5852
for x in range(self.port_start, self.port_end + 1):
59-
port_eeprom_path = eeprom_path.format(self.port_to_i2c_mapping[x])
60-
self.port_to_eeprom_mapping[x] = port_eeprom_path
61-
sfputilbase.__init__(self, port_num)
53+
self._port_to_eeprom_mapping[x] = eeprom_path.format(x + self.EEPROM_OFFSET)
54+
55+
SfpUtilBase.__init__(self)
56+
57+
def get_presence(self, port_num):
58+
# Check for invalid port_num
59+
if port_num < self.port_start or port_num > self.port_end:
60+
return False
61+
62+
try:
63+
abs_device_file = self.BASE_VAL_PATH.format(
64+
port_num + self.ABS_GPIO_BASE)
65+
val_file = open(abs_device_file)
66+
except IOError as e:
67+
print "Error: unable to open file: %s" % str(e)
68+
return False
69+
70+
content = val_file.readline().rstrip()
71+
72+
# content is a string, either "0" or "1"
73+
if content == "1":
74+
return True
75+
76+
return False
77+
78+
def get_low_power_mode(self, port_num):
79+
# Check for invalid port_num
80+
if port_num < self.port_start or port_num > self.port_end:
81+
return False
82+
83+
try:
84+
lpmode_val_device_file = self.BASE_VAL_PATH.format(
85+
port_num + self.LP_GPIO_BASE)
86+
val_file = open(lpmode_val_device_file)
87+
except IOError as e:
88+
print "Error: unable to open file: %s" % str(e)
89+
return False
90+
91+
content = val_file.readline().rstrip()
92+
93+
# content is a string, either "0" or "1"
94+
if content == "1":
95+
return True
96+
97+
return False
98+
99+
def set_low_power_mode(self, port_num, lpmode):
100+
# Check for invalid port_num
101+
if port_num < self.port_start or port_num > self.port_end:
102+
return False
103+
104+
try:
105+
lpmode_val_device_file = self.BASE_VAL_PATH.format(
106+
port_num + self.LP_GPIO_BASE)
107+
val_file = open(lpmode_val_device_file, "w")
108+
except IOError as e:
109+
print "Error: unable to open file: %s" % str(e)
110+
return False
111+
112+
val_file.write("1" if lpmode is True else "0")
113+
val_file.close()
114+
115+
return True
116+
117+
def reset(self, port_num):
118+
# Check for invalid port_num
119+
if port_num < self.port_start or port_num > self.port_end:
120+
return False
121+
122+
try:
123+
reset_val_device_file = self.BASE_VAL_PATH.format(
124+
port_num + self.RST_GPIO_BASE)
125+
val_file = open(reset_val_device_file, "w")
126+
except IOError as e:
127+
print "Error: unable to open file: %s" % str(e)
128+
return False
129+
130+
val_file.write("1")
131+
val_file.close()
132+
133+
# Sleep 1 second to allow it to settle
134+
time.sleep(1)
135+
136+
try:
137+
reset_val_device_file = self.BASE_VAL_PATH.format(
138+
port_num + self.RST_GPIO_BASE)
139+
val_file = open(reset_val_device_file, "w")
140+
except IOError as e:
141+
print "Error: unable to open file: %s" % str(e)
142+
return False
143+
144+
val_file.write("0")
145+
val_file.close()
146+
147+
return True
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,55 @@
1-
# name lanes alias
2-
Ethernet0 1
3-
Ethernet1 2
4-
Ethernet2 3
5-
Ethernet3 4
6-
Ethernet4 5
7-
Ethernet5 6
8-
Ethernet6 7
9-
Ethernet7 8
10-
Ethernet8 9
11-
Ethernet9 10
12-
Ethernet10 11
13-
Ethernet11 12
14-
Ethernet12 21
15-
Ethernet13 22
16-
Ethernet14 23
17-
Ethernet15 24
18-
Ethernet16 33
19-
Ethernet17 34
20-
Ethernet18 35
21-
Ethernet19 36
22-
Ethernet20 37
23-
Ethernet21 38
24-
Ethernet22 39
25-
Ethernet23 40
26-
Ethernet24 41
27-
Ethernet25 42
28-
Ethernet26 43
29-
Ethernet27 44
30-
Ethernet28 49
31-
Ethernet29 50
32-
Ethernet30 51
33-
Ethernet31 52
34-
Ethernet32 53
35-
Ethernet33 54
36-
Ethernet34 55
37-
Ethernet35 56
38-
Ethernet36 65
39-
Ethernet37 66
40-
Ethernet38 67
41-
Ethernet39 68
42-
Ethernet40 69
43-
Ethernet41 70
44-
Ethernet42 71
45-
Ethernet43 72
46-
Ethernet44 81
47-
Ethernet45 82
48-
Ethernet46 83
49-
Ethernet47 84
50-
Ethernet48 85,86,87,88
51-
Ethernet52 97,98,99,100
52-
Ethernet56 101,102,103,104
53-
Ethernet60 105,106,107,108
54-
Ethernet64 109,110,111,112
55-
Ethernet68 117,118,119,120
1+
# name lanes alias port
2+
Ethernet0 1 Ethernet1 0
3+
Ethernet1 2 Ethernet2 1
4+
Ethernet2 3 Ethernet3 2
5+
Ethernet3 4 Ethernet4 3
6+
Ethernet4 5 Ethernet5 4
7+
Ethernet5 6 Ethernet6 5
8+
Ethernet6 7 Ethernet7 6
9+
Ethernet7 8 Ethernet8 7
10+
Ethernet8 9 Ethernet9 8
11+
Ethernet9 10 Ethernet10 9
12+
Ethernet10 11 Ethernet11 10
13+
Ethernet11 12 Ethernet12 11
14+
Ethernet12 21 Ethernet13 12
15+
Ethernet13 22 Ethernet14 13
16+
Ethernet14 23 Ethernet15 14
17+
Ethernet15 24 Ethernet16 15
18+
Ethernet16 33 Ethernet17 16
19+
Ethernet17 34 Ethernet18 17
20+
Ethernet18 35 Ethernet19 18
21+
Ethernet19 36 Ethernet20 19
22+
Ethernet20 37 Ethernet21 20
23+
Ethernet21 38 Ethernet22 21
24+
Ethernet22 39 Ethernet23 22
25+
Ethernet23 40 Ethernet24 23
26+
Ethernet24 41 Ethernet25 24
27+
Ethernet25 42 Ethernet26 25
28+
Ethernet26 43 Ethernet27 26
29+
Ethernet27 44 Ethernet28 27
30+
Ethernet28 49 Ethernet29 28
31+
Ethernet29 50 Ethernet30 29
32+
Ethernet30 51 Ethernet31 30
33+
Ethernet31 52 Ethernet32 31
34+
Ethernet32 53 Ethernet33 32
35+
Ethernet33 54 Ethernet34 33
36+
Ethernet34 55 Ethernet35 34
37+
Ethernet35 56 Ethernet36 35
38+
Ethernet36 65 Ethernet37 36
39+
Ethernet37 66 Ethernet38 37
40+
Ethernet38 67 Ethernet39 38
41+
Ethernet39 68 Ethernet40 39
42+
Ethernet40 69 Ethernet41 40
43+
Ethernet41 70 Ethernet42 41
44+
Ethernet42 71 Ethernet43 42
45+
Ethernet43 72 Ethernet44 43
46+
Ethernet44 81 Ethernet45 44
47+
Ethernet45 82 Ethernet46 45
48+
Ethernet46 83 Ethernet47 46
49+
Ethernet47 84 Ethernet48 47
50+
Ethernet48 85,86,87,88 Ethernet49/1 48
51+
Ethernet52 97,98,99,100 Ethernet50/1 49
52+
Ethernet56 101,102,103,104 Ethernet51/1 50
53+
Ethernet60 105,106,107,108 Ethernet52/1 51
54+
Ethernet64 109,110,111,112 Ethernet53/1 52
55+
Ethernet68 117,118,119,120 Ethernet54/1 53

0 commit comments

Comments
 (0)