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

[Juniper][QFX5210] Optoe driver for SFP management #3438

Merged
merged 5 commits into from
Sep 11, 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,65 +1,65 @@
# name lanes alias
Ethernet0 73,74,75,76 hundredGigE1
Ethernet4 65,66,67,68 hundredGigE2
Ethernet8 81,82,83,84 hundredGigE3
Ethernet12 89,90,91,92 hundredGigE4
Ethernet16 105,106,107,108 hundredGigE5
Ethernet20 97,98,99,100 hundredGigE6
Ethernet24 113,114,115,116 hundredGigE7
Ethernet28 121,122,123,124 hundredGigE8
Ethernet32 41,42,43,44 hundredGigE9
Ethernet36 33,34,35,36 hundredGigE10
Ethernet40 49,50,51,52 hundredGigE11
Ethernet44 57,58,59,60 hundredGigE12
Ethernet48 137,138,139,140 hundredGigE13
Ethernet52 129,130,131,132 hundredGigE14
Ethernet56 145,146,147,148 hundredGigE15
Ethernet60 153,154,155,156 hundredGigE16
Ethernet64 173,174,175,176 hundredGigE17
Ethernet68 165,166,167,168 hundredGigE18
Ethernet72 181,182,183,184 hundredGigE19
Ethernet76 189,190,191,192 hundredGigE20
Ethernet80 13,14,15,16 hundredGigE21
Ethernet84 5,6,7,8 hundredGigE22
Ethernet88 29,30,31,32 hundredGigE23
Ethernet92 21,22,23,24 hundredGigE24
Ethernet96 205,206,207,208 hundredGigE25
Ethernet100 197,198,199,200 hundredGigE26
Ethernet104 213,214,215,216 hundredGigE27
Ethernet108 221,222,223,224 hundredGigE28
Ethernet112 229,230,231,232 hundredGigE29
Ethernet116 237,238,239,240 hundredGigE30
Ethernet120 245,246,247,248 hundredGigE31
Ethernet124 253,254,255,256 hundredGigE32
Ethernet128 69,70,71,72 hundredGigE33
Ethernet132 77,78,79,80 hundredGigE34
Ethernet136 93,94,95,96 hundredGigE35
Ethernet140 85,86,87,88 hundredGigE36
Ethernet144 101,102,103,104 hundredGigE37
Ethernet148 109,110,111,112 hundredGigE38
Ethernet152 125,126,127,128 hundredGigE39
Ethernet156 117,118,119,120 hundredGigE40
Ethernet160 37,38,39,40 hundredGigE41
Ethernet164 45,46,47,48 hundredGigE42
Ethernet168 61,62,63,64 hundredGigE43
Ethernet172 53,54,55,56 hundredGigE44
Ethernet176 133,134,135,136 hundredGigE45
Ethernet180 141,142,143,144 hundredGigE46
Ethernet184 157,158,159,160 hundredGigE47
Ethernet188 149,150,151,152 hundredGigE48
Ethernet192 161,162,163,164 hundredGigE49
Ethernet196 169,170,171,172 hundredGigE50
Ethernet200 185,186,187,188 hundredGigE51
Ethernet204 177,178,179,180 hundredGigE52
Ethernet208 1,2,3,4 hundredGigE53
Ethernet212 9,10,11,12 hundredGigE54
Ethernet216 25,26,27,28 hundredGigE55
Ethernet220 17,18,19,20 hundredGigE56
Ethernet224 193,194,195,196 hundredGigE57
Ethernet228 201,202,203,204 hundredGigE58
Ethernet232 217,218,219,220 hundredGigE59
Ethernet236 209,210,211,212 hundredGigE60
Ethernet240 225,226,227,228 hundredGigE61
Ethernet244 233,234,235,236 hundredGigE62
Ethernet248 249,250,251,252 hundredGigE63
Ethernet252 241,242,243,244 hundredGigE64
# name lanes alias index speed
Ethernet0 73,74,75,76 hundredGigE1 0 100000
Ethernet4 65,66,67,68 hundredGigE2 1 100000
Ethernet8 81,82,83,84 hundredGigE3 2 100000
Ethernet12 89,90,91,92 hundredGigE4 3 100000
Ethernet16 105,106,107,108 hundredGigE5 4 100000
Ethernet20 97,98,99,100 hundredGigE6 5 100000
Ethernet24 113,114,115,116 hundredGigE7 6 100000
Ethernet28 121,122,123,124 hundredGigE8 7 100000
Ethernet32 41,42,43,44 hundredGigE9 8 100000
Ethernet36 33,34,35,36 hundredGigE10 9 100000
Ethernet40 49,50,51,52 hundredGigE11 10 100000
Ethernet44 57,58,59,60 hundredGigE12 11 100000
Ethernet48 137,138,139,140 hundredGigE13 12 100000
Ethernet52 129,130,131,132 hundredGigE14 13 100000
Ethernet56 145,146,147,148 hundredGigE15 14 100000
Ethernet60 153,154,155,156 hundredGigE16 15 100000
Ethernet64 173,174,175,176 hundredGigE17 16 100000
Ethernet68 165,166,167,168 hundredGigE18 17 100000
Ethernet72 181,182,183,184 hundredGigE19 18 100000
Ethernet76 189,190,191,192 hundredGigE20 19 100000
Ethernet80 13,14,15,16 hundredGigE21 20 100000
Ethernet84 5,6,7,8 hundredGigE22 21 100000
Ethernet88 29,30,31,32 hundredGigE23 22 100000
Ethernet92 21,22,23,24 hundredGigE24 23 100000
Ethernet96 205,206,207,208 hundredGigE25 24 100000
Ethernet100 197,198,199,200 hundredGigE26 25 100000
Ethernet104 213,214,215,216 hundredGigE27 26 100000
Ethernet108 221,222,223,224 hundredGigE28 27 100000
Ethernet112 229,230,231,232 hundredGigE29 28 100000
Ethernet116 237,238,239,240 hundredGigE30 29 100000
Ethernet120 245,246,247,248 hundredGigE31 30 100000
Ethernet124 253,254,255,256 hundredGigE32 31 100000
Ethernet128 69,70,71,72 hundredGigE33 32 100000
Ethernet132 77,78,79,80 hundredGigE34 33 100000
Ethernet136 93,94,95,96 hundredGigE35 34 100000
Ethernet140 85,86,87,88 hundredGigE36 35 100000
Ethernet144 101,102,103,104 hundredGigE37 36 100000
Ethernet148 109,110,111,112 hundredGigE38 37 100000
Ethernet152 125,126,127,128 hundredGigE39 38 100000
Ethernet156 117,118,119,120 hundredGigE40 39 100000
Ethernet160 37,38,39,40 hundredGigE41 40 100000
Ethernet164 45,46,47,48 hundredGigE42 41 100000
Ethernet168 61,62,63,64 hundredGigE43 42 100000
Ethernet172 53,54,55,56 hundredGigE44 43 100000
Ethernet176 133,134,135,136 hundredGigE45 44 100000
Ethernet180 141,142,143,144 hundredGigE46 45 100000
Ethernet184 157,158,159,160 hundredGigE47 46 100000
Ethernet188 149,150,151,152 hundredGigE48 47 100000
Ethernet192 161,162,163,164 hundredGigE49 48 100000
Ethernet196 169,170,171,172 hundredGigE50 49 100000
Ethernet200 185,186,187,188 hundredGigE51 50 100000
Ethernet204 177,178,179,180 hundredGigE52 51 100000
Ethernet208 1,2,3,4 hundredGigE53 52 100000
Ethernet212 9,10,11,12 hundredGigE54 53 100000
Ethernet216 25,26,27,28 hundredGigE55 54 100000
Ethernet220 17,18,19,20 hundredGigE56 55 100000
Ethernet224 193,194,195,196 hundredGigE57 56 100000
Ethernet228 201,202,203,204 hundredGigE58 57 100000
Ethernet232 217,218,219,220 hundredGigE59 58 100000
Ethernet236 209,210,211,212 hundredGigE60 59 100000
Ethernet240 225,226,227,228 hundredGigE61 60 100000
Ethernet244 233,234,235,236 hundredGigE62 61 100000
Ethernet248 249,250,251,252 hundredGigE63 62 100000
Ethernet252 241,242,243,244 hundredGigE64 63 100000
217 changes: 76 additions & 141 deletions device/juniper/x86_64-juniper_qfx5210-r0/plugins/sfputil.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,146 +43,79 @@ class SfpUtil(SfpUtilBase):
cmd = '/var/run/sfppresence'
_port_to_eeprom_mapping = {}
port_to_i2c_mapping = {
61 : 25,
62 : 26,
63 : 27,
64 : 28,
55 : 29,
56 : 30,
53 : 31,
54 : 32,
9 : 33,
10 : 34,
11 : 35,
12 : 36,
1 : 37,
2 : 38,
3 : 39,
4 : 40,
6 : 41,
5 : 42,
8 : 43,
7 : 44,
13 : 45,
14 : 46,
15 : 47,
16 : 48,
17 : 49,
18 : 50,
19 : 51,
20 : 52,
25 : 53,
26 : 54,
27 : 55,
28 : 56,
29 : 57,
30 : 58,
31 : 59,
32 : 60,
21 : 61,
22 : 62,
23 : 63,
24 : 64,
41 : 65,
42 : 66,
43 : 67,
44 : 68,
33 : 69,
34 : 70,
35 : 71,
36 : 72,
45 : 73,
46 : 74,
47 : 75,
48 : 76,
37 : 77,
38 : 78,
39 : 79,
40 : 80,
57 : 81,
58 : 82,
59 : 83,
60 : 84,
49 : 85,
50 : 86,
51 : 87,
52 : 88,}

port_to_sysfs_map = [
'/sys/bus/i2c/devices/37-0050/sfp_is_present',
'/sys/bus/i2c/devices/38-0050/sfp_is_present',
'/sys/bus/i2c/devices/39-0050/sfp_is_present',
'/sys/bus/i2c/devices/40-0050/sfp_is_present',
'/sys/bus/i2c/devices/42-0050/sfp_is_present',
'/sys/bus/i2c/devices/41-0050/sfp_is_present',
'/sys/bus/i2c/devices/44-0050/sfp_is_present',
'/sys/bus/i2c/devices/43-0050/sfp_is_present',
'/sys/bus/i2c/devices/33-0050/sfp_is_present',
'/sys/bus/i2c/devices/34-0050/sfp_is_present',
'/sys/bus/i2c/devices/35-0050/sfp_is_present',
'/sys/bus/i2c/devices/36-0050/sfp_is_present',
'/sys/bus/i2c/devices/45-0050/sfp_is_present',
'/sys/bus/i2c/devices/46-0050/sfp_is_present',
'/sys/bus/i2c/devices/47-0050/sfp_is_present',
'/sys/bus/i2c/devices/48-0050/sfp_is_present',
'/sys/bus/i2c/devices/49-0050/sfp_is_present',
'/sys/bus/i2c/devices/50-0050/sfp_is_present',
'/sys/bus/i2c/devices/51-0050/sfp_is_present',
'/sys/bus/i2c/devices/52-0050/sfp_is_present',
'/sys/bus/i2c/devices/61-0050/sfp_is_present',
'/sys/bus/i2c/devices/62-0050/sfp_is_present',
'/sys/bus/i2c/devices/63-0050/sfp_is_present',
'/sys/bus/i2c/devices/64-0050/sfp_is_present',
'/sys/bus/i2c/devices/53-0050/sfp_is_present',
'/sys/bus/i2c/devices/54-0050/sfp_is_present',
'/sys/bus/i2c/devices/55-0050/sfp_is_present',
'/sys/bus/i2c/devices/56-0050/sfp_is_present',
'/sys/bus/i2c/devices/57-0050/sfp_is_present',
'/sys/bus/i2c/devices/58-0050/sfp_is_present',
'/sys/bus/i2c/devices/59-0050/sfp_is_present',
'/sys/bus/i2c/devices/60-0050/sfp_is_present',
'/sys/bus/i2c/devices/69-0050/sfp_is_present',
'/sys/bus/i2c/devices/70-0050/sfp_is_present',
'/sys/bus/i2c/devices/71-0050/sfp_is_present',
'/sys/bus/i2c/devices/72-0050/sfp_is_present',
'/sys/bus/i2c/devices/77-0050/sfp_is_present',
'/sys/bus/i2c/devices/78-0050/sfp_is_present',
'/sys/bus/i2c/devices/79-0050/sfp_is_present',
'/sys/bus/i2c/devices/80-0050/sfp_is_present',
'/sys/bus/i2c/devices/65-0050/sfp_is_present',
'/sys/bus/i2c/devices/66-0050/sfp_is_present',
'/sys/bus/i2c/devices/67-0050/sfp_is_present',
'/sys/bus/i2c/devices/68-0050/sfp_is_present',
'/sys/bus/i2c/devices/73-0050/sfp_is_present',
'/sys/bus/i2c/devices/74-0050/sfp_is_present',
'/sys/bus/i2c/devices/75-0050/sfp_is_present',
'/sys/bus/i2c/devices/76-0050/sfp_is_present',
'/sys/bus/i2c/devices/85-0050/sfp_is_present',
'/sys/bus/i2c/devices/86-0050/sfp_is_present',
'/sys/bus/i2c/devices/87-0050/sfp_is_present',
'/sys/bus/i2c/devices/88-0050/sfp_is_present',
'/sys/bus/i2c/devices/31-0050/sfp_is_present',
'/sys/bus/i2c/devices/32-0050/sfp_is_present',
'/sys/bus/i2c/devices/29-0050/sfp_is_present',
'/sys/bus/i2c/devices/30-0050/sfp_is_present',
'/sys/bus/i2c/devices/81-0050/sfp_is_present',
'/sys/bus/i2c/devices/82-0050/sfp_is_present',
'/sys/bus/i2c/devices/83-0050/sfp_is_present',
'/sys/bus/i2c/devices/84-0050/sfp_is_present',
'/sys/bus/i2c/devices/25-0050/sfp_is_present',
'/sys/bus/i2c/devices/26-0050/sfp_is_present',
'/sys/bus/i2c/devices/27-0050/sfp_is_present',
'/sys/bus/i2c/devices/28-0050/sfp_is_present'

]
60 : 25,
61 : 26,
62 : 27,
63 : 28,
54 : 29,
55 : 30,
52 : 31,
53 : 32,
8 : 33,
9 : 34,
10 : 35,
11 : 36,
0 : 37,
1 : 38,
2 : 39,
3 : 40,
5 : 41,
4 : 42,
7 : 43,
6 : 44,
12 : 45,
13 : 46,
14 : 47,
15 : 48,
16 : 49,
17 : 50,
18 : 51,
19 : 52,
24 : 53,
25 : 54,
26 : 55,
27 : 56,
28 : 57,
29 : 58,
30 : 59,
31 : 60,
20 : 61,
21 : 62,
22 : 63,
23 : 64,
40 : 65,
41 : 66,
42 : 67,
43 : 68,
32 : 69,
33 : 70,
34 : 71,
35 : 72,
44 : 73,
45 : 74,
46 : 75,
47 : 76,
36 : 77,
37 : 78,
38 : 79,
39 : 80,
56 : 81,
57 : 82,
58 : 83,
59 : 84,
48 : 85,
49 : 86,
50 : 87,
51 : 88,}

# sys.path.append('/usr/local/bin')
_qsfp_ports = range(0, ports_in_block + 1)


def __init__(self):
eeprom_path = '/sys/bus/i2c/devices/{0}-0050/sfp_eeprom'
for x in range(0, self._port_end + 1):
port_eeprom_path = eeprom_path.format(self.port_to_i2c_mapping[x+1])
eeprom_path = '/sys/bus/i2c/devices/{0}-0050/eeprom'
for x in range(self._port_start, self._port_end + 1):
port_eeprom_path = eeprom_path.format(self.port_to_i2c_mapping[x])
self._port_to_eeprom_mapping[x] = port_eeprom_path
SfpUtilBase.__init__(self)

Expand Down Expand Up @@ -210,10 +143,9 @@ def get_presence(self, port_num):
if port_num < self._port_start or port_num > self._port_end:
return False

path = "/sys/bus/i2c/devices/{0}-0050/sfp_is_present"
port_ps = path.format(self.port_to_i2c_mapping[port_num+1])
path = "/sys/bus/i2c/devices/19-0060/module_present_{0}"
port_ps = path.format(port_num + 1)


try:
reg_file = open(port_ps)
except IOError as e:
Expand Down Expand Up @@ -278,6 +210,8 @@ def sfp_detect(self):
current_sfp_values = [0] * 64
previous_sfp_values = [0] * 64

path = "/sys/bus/i2c/devices/19-0060/module_present_{0}"

if not os.path.isfile(self.cmd):
pass
else:
Expand All @@ -287,9 +221,10 @@ def sfp_detect(self):
previous_sfp_values = self.read_from_file(self.cmd)

# Read the current values from sysfs
for x in range(len(self.port_to_sysfs_map)):
for x in range(self._port_start , self._port_end + 1):
try:
reg_file = open(self.port_to_sysfs_map[x], 'r')
new_path = path.format(x + 1)
reg_file = open(new_path, 'r')
except IOError as e:
print "Error: unable to open file: %s" % str(e)
return False, defl_dict
Expand All @@ -305,7 +240,7 @@ def sfp_detect(self):
else:
return False, defl_dict

def get_transceiver_change_event(self):
def get_transceiver_change_event(self, timeout=2000):
time.sleep(3)
return self.sfp_detect()

Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
obj-m:=x86-64-juniper-qfx5210-64x-fan.o x86-64-juniper-qfx5210-64x-sfp.o x86-64-juniper-qfx5210-64x-leds.o \
obj-m:=x86-64-juniper-qfx5210-64x-fan.o x86-64-juniper-qfx5210-64x-leds.o \
x86-64-juniper-qfx5210-64x-psu.o juniper_i2c_cpld.o ym2651y.o
Loading