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