Skip to content

Commit f72e8df

Browse files
yuazhemssonicbld
authored andcommitted
[Mellanox] fix sfp eeprom unreadable after switching from SW to FW control mode (sonic-net#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 3387a1f commit f72e8df

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
@@ -499,16 +499,18 @@ def get_change_event_for_module_host_management_mode(self, timeout):
499499
s.on_event(event)
500500

501501
if s.in_stable_state():
502+
self.sfp_module.SFP.wait_sfp_eeprom_ready([s], 2)
502503
s.fill_change_event(port_dict)
503504
s.refresh_poll_obj(self.poll_obj, self.registered_fds)
504505
else:
505506
logger.log_debug(f'SFP {sfp_index} does not reach stable state, state={s.state}')
506-
507+
507508
ready_sfp_set = wait_ready_task.get_ready_set()
508509
for sfp_index in ready_sfp_set:
509510
s = self._sfp_list[sfp_index]
510511
s.on_event(sfp.EVENT_RESET_DONE)
511512
if s.in_stable_state():
513+
self.sfp_module.SFP.wait_sfp_eeprom_ready([s], 2)
512514
s.fill_change_event(port_dict)
513515
s.refresh_poll_obj(self.poll_obj, self.registered_fds)
514516
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):
@@ -1723,7 +1738,8 @@ def initialize_sfp_modules(cls, sfp_list):
17231738
logger.log_error(f'SFP {index} is not in stable state after initializing, state={s.state}')
17241739
logger.log_notice(f'SFP {index} is in state {s.state} after module initialization')
17251740

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

0 commit comments

Comments
 (0)