Skip to content

Commit

Permalink
Initializing cmis_state to CMIS_STATE_UNKNOWN while spawning CmisMana…
Browse files Browse the repository at this point in the history
…gerTask
  • Loading branch information
mihirpat1 authored and prgeor committed Mar 20, 2024
1 parent 9996d63 commit 8f8326d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
7 changes: 6 additions & 1 deletion sonic-xcvrd/tests/test_xcvrd.py
Original file line number Diff line number Diff line change
Expand Up @@ -1319,7 +1319,7 @@ def test_SffManagerTask_task_worker(self, mock_chassis):
assert mock_xcvr_api.tx_disable_channel.call_count == 2
mock_sfp.get_presence = MagicMock(return_value=True)

def test_update_port_transceiver_status_table_sw_cmis_state(self):
def test_CmisManagerTask_update_port_transceiver_status_table_sw_cmis_state(self):
port_mapping = PortMapping()
stop_event = threading.Event()
task = CmisManagerTask(DEFAULT_NAMESPACE, port_mapping, stop_event)
Expand Down Expand Up @@ -1716,8 +1716,13 @@ def test_CmisManagerTask_task_worker(self, mock_chassis, mock_get_status_tbl):
port_mapping = PortMapping()
stop_event = threading.Event()
task = CmisManagerTask(DEFAULT_NAMESPACE, port_mapping, stop_event)
task.port_mapping.logical_port_list = ['Ethernet0']
task.xcvr_table_helper.get_status_tbl.return_value = mock_get_status_tbl
task.task_stopping_event.is_set = MagicMock(side_effect=[False, False, True])
task.task_worker()
assert get_cmis_state_from_state_db('Ethernet0', task.xcvr_table_helper.get_status_tbl(task.port_mapping.get_asic_id_for_logical_port('Ethernet0'))) == CMIS_STATE_UNKNOWN

task.port_mapping.logical_port_list = MagicMock()
port_change_event = PortChangeEvent('PortConfigDone', -1, 0, PortChangeEvent.PORT_SET)
task.on_port_update_event(port_change_event)
assert task.isPortConfigDone
Expand Down
10 changes: 8 additions & 2 deletions sonic-xcvrd/xcvrd/xcvrd.py
Original file line number Diff line number Diff line change
Expand Up @@ -1252,6 +1252,10 @@ def task_worker(self):
for namespace in self.namespaces:
self.wait_for_port_config_done(namespace)

logical_port_list = self.port_mapping.logical_port_list
for lport in logical_port_list:
self.update_port_transceiver_status_table_sw_cmis_state(lport, CMIS_STATE_UNKNOWN)

# APPL_DB for CONFIG updates, and STATE_DB for insertion/removal
port_change_observer = PortChangeObserver(self.namespaces, helper_logger,
self.task_stopping_event,
Expand Down Expand Up @@ -1643,8 +1647,10 @@ def get_dom_polling_from_config_db(self, lport):

"""
Checks if the port is going through CMIS initialization process
This API assumes CMIS_STATE_UNKNOWN as a transitional state since any CMIS supported platform will
eventually reach to a state in CMIS_TERMINAL_STATES irrespective of the transciver type
This API assumes CMIS_STATE_UNKNOWN as a transitional state since it is the
first state after starting CMIS state machine.
This assumption allows the DomInfoUpdateTask thread to skip polling on the port
to allow CMIS initialization to complete if needed.
Returns:
True if the port is in CMIS initialization process,
otherwise False
Expand Down

0 comments on commit 8f8326d

Please sign in to comment.