Skip to content

Commit

Permalink
[CMIS] Add power up duration for power up timeout (#345)
Browse files Browse the repository at this point in the history
* [CMIS] Add power up duration for power up timeout

Signed-off-by: chiourung_huang <chiourung_huang@edge-core.com>

* modify function name after code review

---------

Signed-off-by: chiourung_huang <chiourung_huang@edge-core.com>
  • Loading branch information
chiourung authored and yxieca committed May 4, 2023
1 parent cc32493 commit f913e9c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
1 change: 1 addition & 0 deletions sonic-xcvrd/tests/test_xcvrd.py
Original file line number Diff line number Diff line change
Expand Up @@ -778,6 +778,7 @@ def test_CmisManagerTask_task_worker(self, mock_chassis):
mock_xcvr_api.get_laser_config_freq = MagicMock(return_value=0)
mock_xcvr_api.get_module_type_abbreviation = MagicMock(return_value='QSFP-DD')
mock_xcvr_api.get_datapath_init_duration = MagicMock(return_value=60000.0)
mock_xcvr_api.get_module_pwr_up_duration = MagicMock(return_value=70000.0)
mock_xcvr_api.get_datapath_deinit_duration = MagicMock(return_value=600000.0)
mock_xcvr_api.get_cmis_rev = MagicMock(return_value='5.0')
mock_xcvr_api.get_dpinit_pending = MagicMock(return_value={
Expand Down
12 changes: 10 additions & 2 deletions sonic-xcvrd/xcvrd/xcvrd.py
Original file line number Diff line number Diff line change
Expand Up @@ -1089,6 +1089,12 @@ def get_cmis_dp_init_duration_secs(self, api):
def get_cmis_dp_deinit_duration_secs(self, api):
return api.get_datapath_deinit_duration()/1000

def get_cmis_module_power_up_duration_secs(self, api):
return api.get_module_pwr_up_duration()/1000

def get_cmis_module_power_down_duration_secs(self, api):
return api.get_module_pwr_down_duration()/1000

def get_cmis_host_lanes_mask(self, api, appl, host_lane_count, subport):
"""
Retrieves mask of active host lanes based on appl, host lane count and subport
Expand Down Expand Up @@ -1560,8 +1566,10 @@ def task_worker(self):
api.set_lpmode(False)
self.port_dict[lport]['cmis_state'] = self.CMIS_STATE_AP_CONF
dpDeinitDuration = self.get_cmis_dp_deinit_duration_secs(api)
self.log_notice("{}: DpDeinit duration {} secs".format(lport, dpDeinitDuration))
self.port_dict[lport]['cmis_expired'] = now + datetime.timedelta(seconds=dpDeinitDuration)
modulePwrUpDuration = self.get_cmis_module_power_up_duration_secs(api)
self.log_notice("{}: DpDeinit duration {} secs, modulePwrUp duration {} secs".format(lport, dpDeinitDuration, modulePwrUpDuration))
self.port_dict[lport]['cmis_expired'] = now + datetime.timedelta(seconds = max(modulePwrUpDuration, dpDeinitDuration))

elif state == self.CMIS_STATE_AP_CONF:
# TODO: Use fine grained time when the CMIS memory map is available
if not self.check_module_state(api, ['ModuleReady']):
Expand Down

0 comments on commit f913e9c

Please sign in to comment.