Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[device][accton] as7312-54xs: Validate access to peripherals. #3140

Merged
merged 8 commits into from
Jul 18, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,55 +1,55 @@
# name lanes alias index
Ethernet0 41 twentyfiveGigE1 0
Ethernet1 42 twentyfiveGigE2 1
Ethernet2 43 twentyfiveGigE3 2
Ethernet3 44 twentyfiveGigE4 3
Ethernet4 49 twentyfiveGigE5 4
Ethernet5 50 twentyfiveGigE6 5
Ethernet6 51 twentyfiveGigE7 6
Ethernet7 52 twentyfiveGigE8 7
Ethernet8 53 twentyfiveGigE9 8
Ethernet9 54 twentyfiveGigE10 9
Ethernet10 55 twentyfiveGigE11 10
Ethernet11 56 twentyfiveGigE12 11
Ethernet12 65 twentyfiveGigE13 12
Ethernet13 66 twentyfiveGigE14 13
Ethernet14 67 twentyfiveGigE15 14
Ethernet15 68 twentyfiveGigE16 15
Ethernet16 33 twentyfiveGigE17 16
Ethernet17 34 twentyfiveGigE18 17
Ethernet18 35 twentyfiveGigE19 18
Ethernet19 36 twentyfiveGigE20 19
Ethernet20 37 twentyfiveGigE21 20
Ethernet21 38 twentyfiveGigE22 21
Ethernet22 39 twentyfiveGigE23 22
Ethernet23 40 twentyfiveGigE24 23
Ethernet24 69 twentyfiveGigE25 24
Ethernet25 70 twentyfiveGigE26 25
Ethernet26 71 twentyfiveGigE27 26
Ethernet27 72 twentyfiveGigE28 27
Ethernet28 81 twentyfiveGigE29 28
Ethernet29 82 twentyfiveGigE30 29
Ethernet30 83 twentyfiveGigE31 30
Ethernet31 84 twentyfiveGigE32 31
Ethernet32 85 twentyfiveGigE33 32
Ethernet33 86 twentyfiveGigE34 33
Ethernet34 87 twentyfiveGigE35 34
Ethernet35 88 twentyfiveGigE36 35
Ethernet36 97 twentyfiveGigE37 36
Ethernet37 98 twentyfiveGigE38 37
Ethernet38 99 twentyfiveGigE39 38
Ethernet39 100 twentyfiveGigE40 39
Ethernet40 101 twentyfiveGigE41 40
Ethernet41 102 twentyfiveGigE42 41
Ethernet42 103 twentyfiveGigE43 42
Ethernet43 104 twentyfiveGigE44 43
Ethernet44 105 twentyfiveGigE45 44
Ethernet45 106 twentyfiveGigE46 45
Ethernet46 107 twentyfiveGigE47 46
Ethernet47 108 twentyfiveGigE48 47
Ethernet48 5,6,7,8 hundredGigE49 48
Ethernet52 1,2,3,4 hundredGigE50 52
Ethernet56 109,110,111,112 hundredGigE51 56
Ethernet60 21,22,23,24 hundredGigE52 60
Ethernet64 9,10,11,12 hundredGigE53 64
Ethernet68 117,118,119,120 hundredGigE54 68
# name lanes alias index speed
Ethernet0 41 twentyfiveGigE1 1 25000
Ethernet1 42 twentyfiveGigE2 2 25000
Ethernet2 43 twentyfiveGigE3 3 25000
Ethernet3 44 twentyfiveGigE4 4 25000
Ethernet4 49 twentyfiveGigE5 5 25000
Ethernet5 50 twentyfiveGigE6 6 25000
Ethernet6 51 twentyfiveGigE7 7 25000
Ethernet7 52 twentyfiveGigE8 8 25000
Ethernet8 53 twentyfiveGigE9 9 25000
Ethernet9 54 twentyfiveGigE10 10 25000
Ethernet10 55 twentyfiveGigE11 11 25000
Ethernet11 56 twentyfiveGigE12 12 25000
Ethernet12 65 twentyfiveGigE13 13 25000
Ethernet13 66 twentyfiveGigE14 14 25000
Ethernet14 67 twentyfiveGigE15 15 25000
Ethernet15 68 twentyfiveGigE16 16 25000
Ethernet16 33 twentyfiveGigE17 17 25000
Ethernet17 34 twentyfiveGigE18 18 25000
Ethernet18 35 twentyfiveGigE19 19 25000
Ethernet19 36 twentyfiveGigE20 20 25000
Ethernet20 37 twentyfiveGigE21 21 25000
Ethernet21 38 twentyfiveGigE22 22 25000
Ethernet22 39 twentyfiveGigE23 23 25000
Ethernet23 40 twentyfiveGigE24 24 25000
Ethernet24 69 twentyfiveGigE25 25 25000
Ethernet25 70 twentyfiveGigE26 26 25000
Ethernet26 71 twentyfiveGigE27 27 25000
Ethernet27 72 twentyfiveGigE28 28 25000
Ethernet28 81 twentyfiveGigE29 29 25000
Ethernet29 82 twentyfiveGigE30 30 25000
Ethernet30 83 twentyfiveGigE31 31 25000
Ethernet31 84 twentyfiveGigE32 32 25000
Ethernet32 85 twentyfiveGigE33 33 25000
Ethernet33 86 twentyfiveGigE34 34 25000
Ethernet34 87 twentyfiveGigE35 35 25000
Ethernet35 88 twentyfiveGigE36 36 25000
Ethernet36 97 twentyfiveGigE37 37 25000
Ethernet37 98 twentyfiveGigE38 38 25000
Ethernet38 99 twentyfiveGigE39 39 25000
Ethernet39 100 twentyfiveGigE40 40 25000
Ethernet40 101 twentyfiveGigE41 41 25000
Ethernet41 102 twentyfiveGigE42 42 25000
Ethernet42 103 twentyfiveGigE43 43 25000
Ethernet43 104 twentyfiveGigE44 44 25000
Ethernet44 105 twentyfiveGigE45 45 25000
Ethernet45 106 twentyfiveGigE46 46 25000
Ethernet46 107 twentyfiveGigE47 47 25000
Ethernet47 108 twentyfiveGigE48 48 25000
Ethernet48 5,6,7,8 hundredGigE49 49 100000
Ethernet52 1,2,3,4 hundredGigE50 50 100000
Ethernet56 109,110,111,112 hundredGigE51 51 100000
Ethernet60 21,22,23,24 hundredGigE52 52 100000
Ethernet64 9,10,11,12 hundredGigE53 53 100000
Ethernet68 117,118,119,120 hundredGigE54 54 100000
160 changes: 64 additions & 96 deletions device/accton/x86_64-accton_as7312_54xs-r0/plugins/sfputil.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@
class SfpUtil(SfpUtilBase):
"""Platform-specific SfpUtil class"""

PORT_START = 0
PORT_END = 71
PORTS_IN_BLOCK = 72
QSFP_PORT_START = 48
QSFP_PORT_END = 72
PORT_START = 1
PORT_END = 54
PORTS_IN_BLOCK = 54
QSFP_PORT_START = 49
QSFP_PORT_END = 54

BASE_VAL_PATH = "/sys/class/i2c-adapter/i2c-{0}/{1}-0050/"

Expand All @@ -33,78 +33,60 @@ class SfpUtil(SfpUtilBase):
2: "6-0064",
}
_port_to_i2c_mapping = {
0: 18,
1: 19,
2: 20,
3: 21,
4: 22,
5: 23,
6: 24,
7: 25,
8: 26,
9: 27,
10: 28,
11: 29,
12: 30,
13: 31,
14: 32,
15: 33,
16: 34,
17: 35,
18: 36,
19: 37,
20: 38,
21: 39,
22: 40,
23: 41,
24: 42,
25: 43,
26: 44,
27: 45,
28: 46,
29: 47,
30: 48,
31: 49,
32: 50,
33: 51,
34: 52,
35: 53,
36: 54,
37: 55,
38: 56,
39: 57,
40: 58,
41: 59,
42: 60,
43: 61,
44: 62,
45: 63,
46: 64,
47: 65,
48: 66, #QSFP49
49: 66,
50: 66,
51: 66,
52: 67, #QSFP50
53: 67,
54: 67,
55: 67,
56: 68, #QSFP51
57: 68,
58: 68,
59: 68,
60: 69, #QSFP52
61: 69,
62: 69,
63: 69,
64: 70, #QSFP53
65: 70,
66: 70,
67: 70,
68: 71, #QSFP54
69: 71,
70: 71,
71: 71,
1: 18,
2: 19,
3: 20,
4: 21,
5: 22,
6: 23,
7: 24,
8: 25,
9: 26,
10: 27,
11: 28,
12: 29,
13: 30,
14: 31,
15: 32,
16: 33,
17: 34,
18: 35,
19: 36,
20: 37,
21: 38,
22: 39,
23: 40,
24: 41,
25: 42,
26: 43,
27: 44,
28: 45,
29: 46,
30: 47,
31: 48,
32: 49,
33: 50,
34: 51,
35: 52,
36: 53,
37: 54,
38: 55,
39: 56,
40: 57,
41: 58,
42: 59,
43: 60,
44: 61,
45: 62,
46: 63,
47: 64,
48: 65,
49: 66, #QSFP49
50: 67,
51: 68,
52: 69,
53: 70,
54: 71, #QSFP54
}

@property
Expand Down Expand Up @@ -133,30 +115,18 @@ def port_to_eeprom_mapping(self):

def __init__(self):
eeprom_path = '/sys/bus/i2c/devices/{0}-0050/eeprom'
for x in range(0, self.port_end+1):
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])

SfpUtilBase.__init__(self)


# For port 48~51 are QSFP, here presumed they're all split to 4 lanes.
def get_cage_num(self, port_num):
cage_num = port_num
if (port_num >= self.QSFP_PORT_START):
cage_num = (port_num - self.QSFP_PORT_START)/4
cage_num = cage_num + self.QSFP_PORT_START

return cage_num

# For cage 0~23 and 48~51 are at cpld2, others are at cpld3.
def get_cpld_num(self, port_num):
cpld_i = 1
cage_num = self.get_cage_num(port_num)
if (port_num > 23 and port_num < self.QSFP_PORT_START):
if (port_num > 24 and port_num < self.qsfp_port_start):
cpld_i = 2

if (cage_num >= 52):
if (port_num > 52):
cpld_i = 2

return cpld_i
Expand All @@ -166,12 +136,11 @@ def get_presence(self, port_num):
if port_num < self.port_start or port_num > self.port_end:
return False

cage_num = self.get_cage_num(port_num)
cpld_i = self.get_cpld_num(port_num)

cpld_ps = self._cpld_mapping[cpld_i]
path = "/sys/bus/i2c/devices/{0}/module_present_{1}"
port_ps = path.format(cpld_ps, cage_num+1)
port_ps = path.format(cpld_ps, port_num)

try:
val_file = open(port_ps)
Expand Down Expand Up @@ -250,11 +219,10 @@ def reset(self, port_num):
if port_num < self.qsfp_port_start or port_num > self.qsfp_port_end:
return False

cage_num = self.get_cage_num(port_num)
cpld_i = self.get_cpld_num(port_num)
cpld_ps = self._cpld_mapping[cpld_i]
path = "/sys/bus/i2c/devices/{0}/module_reset_{1}"
port_ps = path.format(cpld_ps, cage_num+1)
port_ps = path.format(cpld_ps, port_num)
try:
reg_file = open(port_ps, 'w')
except IOError as e:
Expand Down
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_AS5835_54X_PLATFORM_MODULE) \
$(ACCTON_AS9716_32D_PLATFORM_MODULE) \
$(ACCTON_AS5835_54T_PLATFORM_MODULE) \
$(ACCTON_AS7312_54XS_PLATFORM_MODULE) \
$(INVENTEC_D7032Q28B_PLATFORM_MODULE) \
$(INVENTEC_D7054Q28B_PLATFORM_MODULE) \
$(INVENTEC_D7264Q28B_PLATFORM_MODULE) \
Expand Down
7 changes: 6 additions & 1 deletion platform/broadcom/platform-modules-accton.mk
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ ACCTON_AS5812_54X_PLATFORM_MODULE_VERSION = 1.1
ACCTON_AS5835_54X_PLATFORM_MODULE_VERSION = 1.1
ACCTON_AS9716_32D_PLATFORM_MODULE_VERSION = 1.1
ACCTON_AS5835_54T_PLATFORM_MODULE_VERSION = 1.1
ACCTON_AS7312_54XS_PLATFORM_MODULE_VERSION = 1.1

export ACCTON_AS7712_32X_PLATFORM_MODULE_VERSION
export ACCTON_AS5712_54X_PLATFORM_MODULE_VERSION
Expand All @@ -31,6 +32,7 @@ export ACCTON_AS5812_54X_PLATFORM_MODULE_VERSION
export ACCTON_AS5835_54X_PLATFORM_MODULE_VERSION
export ACCTON_AS9716_32D_PLATFORM_MODULE_VERSION
export ACCTON_AS5835_54T_PLATFORM_MODULE_VERSION
export ACCTON_AS7312_54XS_PLATFORM_MODULE_VERSION

ACCTON_AS7712_32X_PLATFORM_MODULE = sonic-platform-accton-as7712-32x_$(ACCTON_AS7712_32X_PLATFORM_MODULE_VERSION)_amd64.deb
$(ACCTON_AS7712_32X_PLATFORM_MODULE)_SRC_PATH = $(PLATFORM_PATH)/sonic-platform-modules-accton
Expand All @@ -54,6 +56,10 @@ ACCTON_AS7312_54X_PLATFORM_MODULE = sonic-platform-accton-as7312-54x_$(ACCTON_AS
$(ACCTON_AS7312_54X_PLATFORM_MODULE)_PLATFORM = x86_64-accton_as7312_54x-r0
$(eval $(call add_extra_package,$(ACCTON_AS7712_32X_PLATFORM_MODULE),$(ACCTON_AS7312_54X_PLATFORM_MODULE)))

ACCTON_AS7312_54XS_PLATFORM_MODULE = sonic-platform-accton-as7312-54xs_$(ACCTON_AS7312_54XS_PLATFORM_MODULE_VERSION)_amd64.deb
$(ACCTON_AS7312_54XS_PLATFORM_MODULE)_PLATFORM = x86_64-accton_as7312_54xs-r0
$(eval $(call add_extra_package,$(ACCTON_AS7712_32X_PLATFORM_MODULE),$(ACCTON_AS7312_54XS_PLATFORM_MODULE)))

ACCTON_AS7326_56X_PLATFORM_MODULE = sonic-platform-accton-as7326-56x_$(ACCTON_AS7326_56X_PLATFORM_MODULE_VERSION)_amd64.deb
$(ACCTON_AS7326_56X_PLATFORM_MODULE)_PLATFORM = x86_64-accton_as7326_56x-r0
$(eval $(call add_extra_package,$(ACCTON_AS7712_32X_PLATFORM_MODULE),$(ACCTON_AS7326_56X_PLATFORM_MODULE)))
Expand All @@ -74,7 +80,6 @@ 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_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
Loading