Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix sfp eeprom unreadable after switching from SW to FW control mode #9

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -499,16 +499,20 @@ def get_change_event_for_module_host_management_mode(self, timeout):
s.on_event(event)

if s.in_stable_state():
if s.get_control_type() == 0 and not self.sfp_module.SFP.wait_sfp_eeprom_ready([s], 2):
logger.log_error(f'SFP {sfp_index} eeprom is not readable')
s.fill_change_event(port_dict)
s.refresh_poll_obj(self.poll_obj, self.registered_fds)
else:
logger.log_debug(f'SFP {sfp_index} does not reach stable state, state={s.state}')

ready_sfp_set = wait_ready_task.get_ready_set()
for sfp_index in ready_sfp_set:
s = self._sfp_list[sfp_index]
s.on_event(sfp.EVENT_RESET_DONE)
if s.in_stable_state():
if s.get_control_type() == 0 and not self.sfp_module.SFP.wait_sfp_eeprom_ready([s], 2):
logger.log_error(f'SFP {sfp_index} eeprom is not readable')
s.fill_change_event(port_dict)
s.refresh_poll_obj(self.poll_obj, self.registered_fds)
else:
Expand Down
18 changes: 17 additions & 1 deletion platform/mellanox/mlnx-platform-api/sonic_platform/sfp.py
Original file line number Diff line number Diff line change
Expand Up @@ -488,6 +488,21 @@ def get_presence(self):
return False
eeprom_raw = self._read_eeprom(0, 1, log_on_error=False)
return eeprom_raw is not None

@classmethod
def wait_sfp_eeprom_ready(cls, sfp_list, wait_time):
not_ready_list = sfp_list

while wait_time > 0:
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]
if not_ready_list:
time.sleep(0.1)
wait_time -= 0.1
else:
return

for s in not_ready_list:
logger.log_error(f'SFP {s.sdk_index} eeprom is not ready')

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


cls.wait_sfp_eeprom_ready(sfp_list, 2)

class RJ45Port(NvidiaSFPCommon):
"""class derived from SFP, representing RJ45 ports"""

Expand Down