Dell: S6100 fix xcvrd crash (#9206)
This commit is contained in:
parent
e2bffdf9e7
commit
b31220530a
@ -12,11 +12,12 @@ try:
|
||||
import re
|
||||
import struct
|
||||
import time
|
||||
import syslog
|
||||
from sonic_platform_base.sfp_base import SfpBase
|
||||
from sonic_platform_base.sonic_sfp.sff8436 import sff8436InterfaceId
|
||||
from sonic_platform_base.sonic_sfp.sff8436 import sff8436Dom
|
||||
except ImportError as e:
|
||||
raise ImportError(str(e) + "- required module not found")
|
||||
except ImportError as err:
|
||||
raise ImportError(str(err) + "- required module not found")
|
||||
|
||||
|
||||
PAGE_OFFSET = 0
|
||||
@ -422,28 +423,24 @@ class Sfp(SfpBase):
|
||||
presence_ctrl = self.sfp_control + 'qsfp_modprs'
|
||||
try:
|
||||
reg_file = open(presence_ctrl)
|
||||
except IOError as e:
|
||||
return False
|
||||
|
||||
reg_hex = reg_file.readline().rstrip()
|
||||
|
||||
# content is a string containing the hex
|
||||
# representation of the register
|
||||
reg_value = int(reg_hex, 16)
|
||||
|
||||
# Mask off the bit corresponding to our port
|
||||
if (self.sfp_ctrl_idx > 15):
|
||||
index = self.sfp_ctrl_idx % 16
|
||||
else:
|
||||
index = self.sfp_ctrl_idx
|
||||
|
||||
# Mask off the bit corresponding to our port
|
||||
mask = (1 << index)
|
||||
|
||||
# ModPrsL is active low
|
||||
if ((reg_value & mask) == 0):
|
||||
return True
|
||||
reg_hex = reg_file.readline().rstrip()
|
||||
# content is a string containing the hex
|
||||
# representation of the register
|
||||
reg_value = int(reg_hex, 16)
|
||||
# Mask off the bit corresponding to our port
|
||||
if (self.sfp_ctrl_idx > 15):
|
||||
index = self.sfp_ctrl_idx % 16
|
||||
else:
|
||||
index = self.sfp_ctrl_idx
|
||||
|
||||
# Mask off the bit corresponding to our port
|
||||
mask = (1 << index)
|
||||
# ModPrsL is active low
|
||||
if ((reg_value & mask) == 0):
|
||||
return True
|
||||
except (IOError, ValueError) as err:
|
||||
syslog.syslog(syslog.LOG_ERR, str(err))
|
||||
return False
|
||||
|
||||
def get_model(self):
|
||||
@ -478,28 +475,27 @@ class Sfp(SfpBase):
|
||||
reset_ctrl = self.sfp_control + 'qsfp_reset'
|
||||
try:
|
||||
reg_file = open(reset_ctrl, "r+")
|
||||
except IOError as e:
|
||||
|
||||
reg_hex = reg_file.readline().rstrip()
|
||||
# content is a string containing the hex
|
||||
# representation of the register
|
||||
reg_value = int(reg_hex, 16)
|
||||
# Mask off the bit corresponding to our port
|
||||
if (self.sfp_ctrl_idx > 15):
|
||||
index = self.sfp_ctrl_idx % 16
|
||||
else:
|
||||
index = self.sfp_ctrl_idx
|
||||
|
||||
mask = (1 << index)
|
||||
|
||||
if ((reg_value & mask) == 0):
|
||||
reset_status = True
|
||||
else:
|
||||
reset_status = False
|
||||
|
||||
except (IOError, ValueError) as err:
|
||||
syslog.syslog(syslog.LOG_ERR, str(err))
|
||||
return False
|
||||
|
||||
reg_hex = reg_file.readline().rstrip()
|
||||
|
||||
# content is a string containing the hex
|
||||
# representation of the register
|
||||
reg_value = int(reg_hex, 16)
|
||||
|
||||
# Mask off the bit corresponding to our port
|
||||
if (self.sfp_ctrl_idx > 15):
|
||||
index = self.sfp_ctrl_idx % 16
|
||||
else:
|
||||
index = self.sfp_ctrl_idx
|
||||
|
||||
mask = (1 << index)
|
||||
|
||||
if ((reg_value & mask) == 0):
|
||||
reset_status = True
|
||||
else:
|
||||
reset_status = False
|
||||
|
||||
return reset_status
|
||||
|
||||
def get_rx_los(self):
|
||||
@ -615,28 +611,30 @@ class Sfp(SfpBase):
|
||||
lpmode_ctrl = self.sfp_control + 'qsfp_lpmode'
|
||||
try:
|
||||
reg_file = open(lpmode_ctrl, "r+")
|
||||
except IOError as e:
|
||||
|
||||
reg_hex = reg_file.readline().rstrip()
|
||||
|
||||
# content is a string containing the hex
|
||||
# representation of the register
|
||||
reg_value = int(reg_hex, 16)
|
||||
|
||||
# Mask off the bit corresponding to our port
|
||||
if (self.sfp_ctrl_idx > 15):
|
||||
index = self.sfp_ctrl_idx % 16
|
||||
else:
|
||||
index = self.sfp_ctrl_idx
|
||||
|
||||
mask = (1 << index)
|
||||
|
||||
if ((reg_value & mask) == 0):
|
||||
lpmode_state = False
|
||||
else:
|
||||
lpmode_state = True
|
||||
|
||||
except (IOError, ValueError) as err:
|
||||
syslog.syslog(syslog.LOG_ERR, str(err))
|
||||
return False
|
||||
|
||||
reg_hex = reg_file.readline().rstrip()
|
||||
|
||||
# content is a string containing the hex
|
||||
# representation of the register
|
||||
reg_value = int(reg_hex, 16)
|
||||
|
||||
# Mask off the bit corresponding to our port
|
||||
if (self.sfp_ctrl_idx > 15):
|
||||
index = self.sfp_ctrl_idx % 16
|
||||
else:
|
||||
index = self.sfp_ctrl_idx
|
||||
|
||||
mask = (1 << index)
|
||||
|
||||
if ((reg_value & mask) == 0):
|
||||
lpmode_state = False
|
||||
else:
|
||||
lpmode_state = True
|
||||
|
||||
return lpmode_state
|
||||
|
||||
def get_power_override(self):
|
||||
@ -731,45 +729,41 @@ class Sfp(SfpBase):
|
||||
try:
|
||||
# Open reset_ctrl in both read & write mode
|
||||
reg_file = open(reset_ctrl, "r+")
|
||||
except IOError as e:
|
||||
return False
|
||||
|
||||
reg_hex = reg_file.readline().rstrip()
|
||||
reg_value = int(reg_hex, 16)
|
||||
reg_hex = reg_file.readline().rstrip()
|
||||
reg_value = int(reg_hex, 16)
|
||||
# Mask off the bit corresponding to our port
|
||||
if (self.sfp_ctrl_idx > 15):
|
||||
index = self.sfp_ctrl_idx % 16
|
||||
else:
|
||||
index = self.sfp_ctrl_idx
|
||||
|
||||
# Mask off the bit corresponding to our port
|
||||
if (self.sfp_ctrl_idx > 15):
|
||||
index = self.sfp_ctrl_idx % 16
|
||||
else:
|
||||
index = self.sfp_ctrl_idx
|
||||
# Mask off the bit corresponding to our port
|
||||
mask = (1 << index)
|
||||
|
||||
# Mask off the bit corresponding to our port
|
||||
mask = (1 << index)
|
||||
# ResetL is active low
|
||||
reg_value = (reg_value & ~mask)
|
||||
|
||||
# ResetL is active low
|
||||
reg_value = (reg_value & ~mask)
|
||||
# Convert our register value back to a
|
||||
# hex string and write back
|
||||
reg_file.seek(0)
|
||||
reg_file.write(hex(reg_value))
|
||||
reg_file.close()
|
||||
|
||||
# Convert our register value back to a
|
||||
# hex string and write back
|
||||
reg_file.seek(0)
|
||||
reg_file.write(hex(reg_value))
|
||||
reg_file.close()
|
||||
|
||||
# Sleep 1 second to allow it to settle
|
||||
time.sleep(1)
|
||||
|
||||
# Flip the bit back high and write back to the
|
||||
# register to take port out of reset
|
||||
try:
|
||||
# Sleep 1 second to allow it to settle
|
||||
time.sleep(1)
|
||||
# Flip the bit back high and write back to the
|
||||
# register to take port out of reset
|
||||
reg_file = open(reset_ctrl, "w")
|
||||
except IOError as e:
|
||||
|
||||
reg_value = reg_value | mask
|
||||
reg_file.seek(0)
|
||||
reg_file.write(hex(reg_value))
|
||||
reg_file.close()
|
||||
|
||||
except (IOError, ValueError) as err:
|
||||
syslog.syslog(syslog.LOG_ERR, str(err))
|
||||
return False
|
||||
|
||||
reg_value = reg_value | mask
|
||||
reg_file.seek(0)
|
||||
reg_file.write(hex(reg_value))
|
||||
reg_file.close()
|
||||
|
||||
return True
|
||||
|
||||
def set_lpmode(self, lpmode):
|
||||
@ -779,36 +773,36 @@ class Sfp(SfpBase):
|
||||
lpmode_ctrl = self.sfp_control + 'qsfp_lpmode'
|
||||
try:
|
||||
reg_file = open(lpmode_ctrl, "r+")
|
||||
except IOError as e:
|
||||
|
||||
reg_hex = reg_file.readline().rstrip()
|
||||
# content is a string containing the hex
|
||||
# representation of the register
|
||||
reg_value = int(reg_hex, 16)
|
||||
|
||||
# Mask off the bit corresponding to our port
|
||||
if (self.sfp_ctrl_idx > 15):
|
||||
index = self.sfp_ctrl_idx % 16
|
||||
else:
|
||||
index = self.sfp_ctrl_idx
|
||||
|
||||
mask = (1 << index)
|
||||
|
||||
# LPMode is active high; set or clear the bit accordingly
|
||||
if lpmode is True:
|
||||
reg_value = (reg_value | mask)
|
||||
else:
|
||||
reg_value = (reg_value & ~mask)
|
||||
|
||||
# Convert our register value back to a hex string and write back
|
||||
content = hex(reg_value)
|
||||
|
||||
reg_file.seek(0)
|
||||
reg_file.write(content)
|
||||
reg_file.close()
|
||||
except (IOError, ValueError) as err:
|
||||
syslog.syslog(syslog.LOG_ERR, str(err))
|
||||
return False
|
||||
|
||||
reg_hex = reg_file.readline().rstrip()
|
||||
|
||||
# content is a string containing the hex
|
||||
# representation of the register
|
||||
reg_value = int(reg_hex, 16)
|
||||
|
||||
# Mask off the bit corresponding to our port
|
||||
if (self.sfp_ctrl_idx > 15):
|
||||
index = self.sfp_ctrl_idx % 16
|
||||
else:
|
||||
index = self.sfp_ctrl_idx
|
||||
|
||||
mask = (1 << index)
|
||||
|
||||
# LPMode is active high; set or clear the bit accordingly
|
||||
if lpmode is True:
|
||||
reg_value = (reg_value | mask)
|
||||
else:
|
||||
reg_value = (reg_value & ~mask)
|
||||
|
||||
# Convert our register value back to a hex string and write back
|
||||
content = hex(reg_value)
|
||||
|
||||
reg_file.seek(0)
|
||||
reg_file.write(content)
|
||||
reg_file.close()
|
||||
|
||||
return True
|
||||
|
||||
def tx_disable(self, tx_disable):
|
||||
|
Reference in New Issue
Block a user