[Mellanox] Re-initialize SFP object when detecting a new SFP insertion (#5695)
When detecting a new SFP insertion, read its SFP type and DOM capability from EEPROM again. SFP object will be initialized to a certain type even if no SFP present. A case could be: 1. A SFP object is initialized to QSFP type by default when there is no SFP present 2. User insert a SFP with an adapter to this QSFP port 3. The SFP object fail to read EEPROM because it still treats itself as QSFP. This PR fixes this issue.
This commit is contained in:
parent
66e0298a89
commit
06b5ad02ac
@ -471,10 +471,29 @@ class Chassis(ChassisBase):
|
||||
status = self.sfp_event.check_sfp_status(port_dict, timeout)
|
||||
|
||||
if status:
|
||||
self.reinit_sfps(port_dict)
|
||||
return True, {'sfp':port_dict}
|
||||
else:
|
||||
return True, {'sfp':{}}
|
||||
|
||||
def reinit_sfps(self, port_dict):
|
||||
"""
|
||||
Re-initialize SFP if there is any newly inserted SFPs
|
||||
:param port_dict: SFP event data
|
||||
:return:
|
||||
"""
|
||||
# SFP not initialize yet, do nothing
|
||||
if not self.sfp_module_initialized:
|
||||
return
|
||||
|
||||
from . import sfp
|
||||
for index, status in port_dict.items():
|
||||
if status == sfp.SFP_STATUS_INSERTED:
|
||||
try:
|
||||
self.get_sfp(index).reinit()
|
||||
except Exception as e:
|
||||
logger.log_error("Fail to re-initialize SFP {} - {}".format(index, repr(e)))
|
||||
|
||||
def get_thermal_manager(self):
|
||||
from .thermal_manager import ThermalManager
|
||||
return ThermalManager
|
||||
|
@ -279,6 +279,9 @@ PORT_TYPE_MASK = 0xF0000000
|
||||
NVE_MASK = PORT_TYPE_MASK & (PORT_TYPE_NVE << PORT_TYPE_OFFSET)
|
||||
CPU_MASK = PORT_TYPE_MASK & (PORT_TYPE_CPU << PORT_TYPE_OFFSET)
|
||||
|
||||
# parameters for SFP presence
|
||||
SFP_STATUS_INSERTED = '1'
|
||||
|
||||
# Global logger class instance
|
||||
logger = Logger()
|
||||
|
||||
@ -316,6 +319,13 @@ class SFP(SfpBase):
|
||||
self.sdk_handle = sdk_handle
|
||||
self.sdk_index = sfp_index
|
||||
|
||||
def reinit(self):
|
||||
"""
|
||||
Re-initialize this SFP object when a new SFP inserted
|
||||
:return:
|
||||
"""
|
||||
self._detect_sfp_type(self.sfp_type)
|
||||
self._dom_capability_detect()
|
||||
|
||||
def get_presence(self):
|
||||
"""
|
||||
|
Loading…
Reference in New Issue
Block a user