Skip to content

Commit 8a0beaf

Browse files
yuazhemssonicbld
authored andcommitted
[Mellanox] fix sfp eeprom unreadable after switching from SW to FW control mode (#19563)
- Why I did it The reading of eeprom instantly after switch the module from sw control to fw control might fail, so add a delay Signed-off-by: Yuanzhe, Liu <[email protected]>
1 parent 03f651e commit 8a0beaf

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

platform/mellanox/mlnx-platform-api/sonic_platform/chassis.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -513,16 +513,18 @@ def get_change_event_for_module_host_management_mode(self, timeout):
513513
s.on_event(event)
514514

515515
if s.in_stable_state():
516+
self.sfp_module.SFP.wait_sfp_eeprom_ready([s], 2)
516517
s.fill_change_event(port_dict)
517518
s.refresh_poll_obj(self.poll_obj, self.registered_fds)
518519
else:
519520
logger.log_debug(f'SFP {sfp_index} does not reach stable state, state={s.state}')
520-
521+
521522
ready_sfp_set = wait_ready_task.get_ready_set()
522523
for sfp_index in ready_sfp_set:
523524
s = self._sfp_list[sfp_index]
524525
s.on_event(sfp.EVENT_RESET_DONE)
525526
if s.in_stable_state():
527+
self.sfp_module.SFP.wait_sfp_eeprom_ready([s], 2)
526528
s.fill_change_event(port_dict)
527529
s.refresh_poll_obj(self.poll_obj, self.registered_fds)
528530
else:

platform/mellanox/mlnx-platform-api/sonic_platform/sfp.py

+17-1
Original file line numberDiff line numberDiff line change
@@ -500,6 +500,21 @@ def get_presence(self):
500500
return False
501501
eeprom_raw = self._read_eeprom(0, 1, log_on_error=False)
502502
return eeprom_raw is not None
503+
504+
@classmethod
505+
def wait_sfp_eeprom_ready(cls, sfp_list, wait_time):
506+
not_ready_list = sfp_list
507+
508+
while wait_time > 0:
509+
not_ready_list = [s for s in not_ready_list if s.state == STATE_FW_CONTROL and s._read_eeprom(0, 2,False) is None]
510+
if not_ready_list:
511+
time.sleep(0.1)
512+
wait_time -= 0.1
513+
else:
514+
return
515+
516+
for s in not_ready_list:
517+
logger.log_error(f'SFP {s.sdk_index} eeprom is not ready')
503518

504519
# read eeprom specfic bytes beginning from offset with size as num_bytes
505520
def read_eeprom(self, offset, num_bytes):
@@ -1724,7 +1739,8 @@ def initialize_sfp_modules(cls, sfp_list):
17241739
logger.log_error(f'SFP {index} is not in stable state after initializing, state={s.state}')
17251740
logger.log_notice(f'SFP {index} is in state {s.state} after module initialization')
17261741

1727-
1742+
cls.wait_sfp_eeprom_ready(sfp_list, 2)
1743+
17281744
class RJ45Port(NvidiaSFPCommon):
17291745
"""class derived from SFP, representing RJ45 ports"""
17301746

0 commit comments

Comments
 (0)