[dell/Z9100] Fix for optics not detected in fanout mode (#2496)

* [dell/Z9100] Fix for optics not detected in fanout mode

This commit fixes the issue of optics not detected
error while running sfputil show eeprom command. The root
casuse was the value of port index from port_config.ini for
fan out scenario. The port index should be starting from 0
and not 1. Platform cpld registers are assuming the port
numbers to start from 0 (lowermost bit), sfputils.py uses this
port number in get_presence function. Since the indexing passed
is wrong the optics was not detected and gave SFP EEPROM not
detected message.

Signed-off-by: Harish Venkatraman <Harish_Venkatraman@Dell.com>

* [dell/z9100] Fix for optics not detected in fanout mode

This commit fixes the issue of optics not detected error
while running sfputil show eeprom command. The root cause
was wrong port_index in fan out scenarios. Earlier fix of
changing the port_config.ini is reverted and changes made
in z9100 platform specific sfputil.py file. The port number
is decrement and tested for both 100G and 50G fanout cases.
Tested for the following show commands and test was succesful
show interfaces status, show interfaces transceiver eeprom,
show interfaces transceiver lpmode, show interface tranceiver
presence.

Signed-off-by: Harish Venkatraman <Harish_Venkatraman@Dell.com>
This commit is contained in:
Harish Venkatraman 2019-02-16 09:59:51 -08:00 committed by lguohan
parent 2dd769bf46
commit 43aa19ca9b

View File

@ -16,15 +16,15 @@ except ImportError as e:
class SfpUtil(SfpUtilBase): class SfpUtil(SfpUtilBase):
"""Platform-specific SfpUtil class""" """Platform-specific SfpUtil class"""
PORT_START = 0 PORT_START = 1
PORT_END = 31 PORT_END = 32
PORTS_IN_BLOCK = 32 PORTS_IN_BLOCK = 32
IOM_1_PORT_START = 0 IOM_1_PORT_START = 1
IOM_1_PORT_END = 11 IOM_1_PORT_END = 12
IOM_2_PORT_START = 12 IOM_2_PORT_START = 13
IOM_2_PORT_END = 21 IOM_2_PORT_END = 22
IOM_3_PORT_START = 22 IOM_3_PORT_START = 23
IOM_3_PORT_END = 31 IOM_3_PORT_END = 32
BASE_VAL_PATH = "/sys/class/i2c-adapter/i2c-{0}/{0}-003e/" BASE_VAL_PATH = "/sys/class/i2c-adapter/i2c-{0}/{0}-003e/"
OIR_FD_PATH = "/sys/devices/platform/dell_ich.0/sci_int_gpio_sus6" OIR_FD_PATH = "/sys/devices/platform/dell_ich.0/sci_int_gpio_sus6"
@ -33,38 +33,39 @@ class SfpUtil(SfpUtilBase):
epoll = -1 epoll = -1
_port_to_eeprom_mapping = {} _port_to_eeprom_mapping = {}
_port_to_i2c_mapping = { _port_to_i2c_mapping = {
0: [9, 18], 0: [0, 00], # Dummy Entry
1: [9, 19], 1: [9, 18],
2: [9, 20], 2: [9, 19],
3: [9, 21], 3: [9, 20],
4: [9, 22], 4: [9, 21],
5: [9, 23], 5: [9, 22],
6: [9, 24], 6: [9, 23],
7: [9, 25], 7: [9, 24],
8: [8, 26], 8: [9, 25],
9: [8, 27], 9: [8, 26],
10: [8, 28], 10: [8, 27],
11: [8, 29], 11: [8, 28],
12: [8, 31], # reordered 12: [8, 29],
13: [8, 30], 13: [8, 31], # reordered
14: [8, 33], # reordered 14: [8, 30],
15: [8, 32], 15: [8, 33], # reordered
16: [7, 34], 16: [8, 32],
17: [7, 35], 17: [7, 34],
18: [7, 36], 18: [7, 35],
19: [7, 37], 19: [7, 36],
20: [7, 38], 20: [7, 37],
21: [7, 39], 21: [7, 38],
22: [7, 40], 22: [7, 39],
23: [7, 41], 23: [7, 40],
24: [6, 42], 24: [7, 41],
25: [6, 43], 25: [6, 42],
26: [6, 44], 26: [6, 43],
27: [6, 45], 27: [6, 44],
28: [6, 46], 28: [6, 45],
29: [6, 47], 29: [6, 46],
30: [6, 48], 30: [6, 47],
31: [6, 49] 31: [6, 48],
32: [6, 49]
} }
@property @property
@ -127,13 +128,10 @@ class SfpUtil(SfpUtilBase):
self.epoll.close() self.epoll.close()
self.oir_fd.close() self.oir_fd.close()
def get_presence(self, port_num): def normalize_port(self, port_num):
global i2c_line
# Check for invalid port_num # Check for invalid port_num
if port_num < self.port_start or port_num > self.port_end: if port_num < self.port_start or port_num > self.port_end:
return False return -1, -1
# port_num and i2c match # port_num and i2c match
if port_num >= self.iom1_port_start and port_num <= self.iom1_port_end: if port_num >= self.iom1_port_start and port_num <= self.iom1_port_end:
i2c_line = 14 i2c_line = 14
@ -144,6 +142,24 @@ class SfpUtil(SfpUtilBase):
port_num <= self.iom3_port_end): port_num <= self.iom3_port_end):
i2c_line = 16 i2c_line = 16
# Rationalize port settings
if port_num >= self.iom1_port_start and port_num <= self.iom1_port_end:
port_num = port_num - 1
elif port_num >= self.iom2_port_start and port_num <= self.iom2_port_end:
port_num = (port_num - 1) % 12
elif (port_num >= self.iom3_port_start and
port_num <= self.iom3_port_end):
port_num = (port_num - 1) % 22
return i2c_line, port_num
def get_presence(self, port_num):
i2c_line, port_num = self.normalize_port(port_num)
if port_num == -1:
return False
try: try:
qsfp_path = self.BASE_VAL_PATH.format(i2c_line)+"qsfp_modprs" qsfp_path = self.BASE_VAL_PATH.format(i2c_line)+"qsfp_modprs"
reg_file = open(qsfp_path, "r") reg_file = open(qsfp_path, "r")
@ -161,13 +177,6 @@ class SfpUtil(SfpUtilBase):
# content is a string containing the hex representation of the register # content is a string containing the hex representation of the register
reg_value = int(content, 16) reg_value = int(content, 16)
# Rationalize port settings
if port_num >= self.iom2_port_start and port_num <= self.iom2_port_end:
port_num = port_num % 12
elif (port_num >= self.iom3_port_start and
port_num <= self.iom3_port_end):
port_num = port_num % 22
# Mask off the bit corresponding to our port # Mask off the bit corresponding to our port
mask = (1 << port_num) mask = (1 << port_num)
@ -179,20 +188,10 @@ class SfpUtil(SfpUtilBase):
def get_low_power_mode(self, port_num): def get_low_power_mode(self, port_num):
# Check for invalid port_num i2c_line, port_num = self.normalize_port(port_num)
if port_num < self.port_start or port_num > self.port_end: if port_num == -1:
return False return False
# port_num and i2c match
if port_num >= self.iom1_port_start and port_num <= self.iom1_port_end:
i2c_line = 14
elif (port_num >= self.iom2_port_start and
port_num <= self.iom2_port_end):
i2c_line = 15
elif (port_num >= self.iom3_port_start and
port_num <= self.iom3_port_end):
i2c_line = 16
try: try:
qsfp_path = self.BASE_VAL_PATH.format(i2c_line)+"qsfp_lpmode" qsfp_path = self.BASE_VAL_PATH.format(i2c_line)+"qsfp_lpmode"
reg_file = open(qsfp_path, "r") reg_file = open(qsfp_path, "r")
@ -210,13 +209,6 @@ class SfpUtil(SfpUtilBase):
# content is a string containing the hex representation of the register # content is a string containing the hex representation of the register
reg_value = int(content, 16) reg_value = int(content, 16)
# Rationalize port settings
if port_num >= self.iom2_port_start and port_num <= self.iom2_port_end:
port_num = port_num % 12
elif (port_num >= self.iom3_port_start and
port_num <= self.iom3_port_end):
port_num = port_num % 22
# Mask off the bit corresponding to our port # Mask off the bit corresponding to our port
mask = (1 << port_num) mask = (1 << port_num)
@ -228,24 +220,15 @@ class SfpUtil(SfpUtilBase):
def set_low_power_mode(self, port_num, lpmode): def set_low_power_mode(self, port_num, lpmode):
# Check for invalid port_num i2c_line, port_num = self.normalize_port(port_num)
if port_num < self.port_start or port_num > self.port_end: if port_num == -1:
return False return False
# port_num and i2c match
if port_num >= self.iom1_port_start and port_num <= self.iom1_port_end:
i2c_line = 14
elif (port_num >= self.iom2_port_start and
port_num <= self.iom2_port_end):
i2c_line = 15
elif (port_num >= self.iom3_port_start and
port_num <= self.iom3_port_end):
i2c_line = 16
try: try:
qsfp_path = self.BASE_VAL_PATH.format(i2c_line)+"qsfp_lpmode" qsfp_path = self.BASE_VAL_PATH.format(i2c_line)+"qsfp_lpmode"
reg_file = open(qsfp_path, "r+") reg_file = open(qsfp_path, "r+")
except IOError as e: except IOError as e:
print "Error: unable to open file: %s" % str(e) print "Error: unable to open file: %s" % str(e)
return False return False
@ -259,13 +242,6 @@ class SfpUtil(SfpUtilBase):
# content is a string containing the hex representation of the register # content is a string containing the hex representation of the register
reg_value = int(content, 16) reg_value = int(content, 16)
# Rationalize port settings
if port_num >= self.iom2_port_start and port_num <= self.iom2_port_end:
port_num = port_num % 12
elif (port_num >= self.iom3_port_start and
port_num <= self.iom3_port_end):
port_num = port_num % 22
# Mask off the bit corresponding to our port # Mask off the bit corresponding to our port
mask = (1 << port_num) mask = (1 << port_num)
# LPMode is active high; set or clear the bit accordingly # LPMode is active high; set or clear the bit accordingly
@ -285,20 +261,10 @@ class SfpUtil(SfpUtilBase):
def reset(self, port_num): def reset(self, port_num):
# Check for invalid port_num i2c_line, port_num = self.normalize_port(port_num)
if port_num < self.port_start or port_num > self.port_end: if port_num == -1:
return False return False
# port_num and i2c match
if port_num >= self.iom1_port_start and port_num <= self.iom1_port_end:
i2c_line = 14
elif (port_num >= self.iom2_port_start and
port_num <= self.iom2_port_end):
i2c_line = 15
elif (port_num >= self.iom3_port_start and
port_num <= self.iom3_port_end):
i2c_line = 16
try: try:
qsfp_path = self.BASE_VAL_PATH.format(i2c_line)+"qsfp_lpmode" qsfp_path = self.BASE_VAL_PATH.format(i2c_line)+"qsfp_lpmode"
reg_file = open(qsfp_path, "r+") reg_file = open(qsfp_path, "r+")
@ -312,13 +278,6 @@ class SfpUtil(SfpUtilBase):
# File content is a string containing the hex representation of th # File content is a string containing the hex representation of th
reg_value = int(content, 16) reg_value = int(content, 16)
# Rationalize port settings
if port_num >= self.iom2_port_start and port_num <= self.iom2_port_end:
port_num = port_num % 12
elif (port_num >= self.iom3_port_start and
port_num <= self.iom3_port_end):
port_num = port_num % 22
# Mask off the bit corresponding to our port # Mask off the bit corresponding to our port
mask = (1 << port_num) mask = (1 << port_num)