Skip to content

Commit

Permalink
[Mellanox] wait SFP ready when receive an insert event with module ho…
Browse files Browse the repository at this point in the history
…st management mode enabled
  • Loading branch information
Junchao-Mellanox committed Aug 1, 2024
1 parent 4e78b11 commit d8233e8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 2 additions & 0 deletions platform/mellanox/mlnx-platform-api/sonic_platform/chassis.py
Original file line number Diff line number Diff line change
Expand Up @@ -475,6 +475,8 @@ def get_change_event_for_module_host_management_mode(self, timeout):
if fd_type == 'hw_present':
# event could be EVENT_NOT_PRESENT or EVENT_PRESENT
event = sfp.EVENT_NOT_PRESENT if fd_value == 0 else sfp.EVENT_PRESENT
if fd_value == 1:
s.processing_insert_event = True
s.on_event(event)
elif fd_type == 'present':
if str(fd_value) == sfp.SFP_STATUS_ERROR:
Expand Down
8 changes: 7 additions & 1 deletion platform/mellanox/mlnx-platform-api/sonic_platform/sfp.py
Original file line number Diff line number Diff line change
Expand Up @@ -476,6 +476,7 @@ def __init__(self, sfp_index, sfp_type=None, slot_id=0, linecard_port_count=0, l
self.state = STATE_DOWN
else:
self.state = STATE_FCP_DOWN
self.processing_insert_event = False

def __str__(self):
return f'SFP {self.sdk_index}'
Expand Down Expand Up @@ -1504,7 +1505,12 @@ def action_on_start(cls, sfp):
sfp.set_hw_reset(1)
sfp.on_event(EVENT_RESET)
else:
sfp.on_event(EVENT_POWER_ON)
if not sfp.processing_insert_event:
sfp.on_event(EVENT_POWER_ON)
else:
sfp.processing_insert_event = False
logger.log_info(f'SFP {sfp.sdk_index} is processing insert event and needs to wait module ready')
sfp.on_event(EVENT_RESET)

@classmethod
def action_fcp_on_start(cls, sfp):
Expand Down

0 comments on commit d8233e8

Please sign in to comment.