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

Initialize unsupported values to 'N/A' in CmisApi::get_transceiver_info #545

Merged
merged 9 commits into from
Mar 1, 2025
40 changes: 27 additions & 13 deletions sonic_platform_base/sonic_xcvr/api/public/cmis.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,8 @@ def _update_vdm_dict(self, dict_to_update, new_key, vdm_raw_dict, vdm_observable
def freeze_vdm_stats(self):
'''
This function freeze all the vdm statistics reporting registers.
When raised by the host, causes the module to freeze and hold all
reported statistics reporting registers (minimum, maximum and
When raised by the host, causes the module to freeze and hold all
reported statistics reporting registers (minimum, maximum and
average values)in Pages 24h-27h.

Returns True if the provision succeeds and False incase of failure.
Expand All @@ -137,9 +137,9 @@ def get_vdm_freeze_status(self):
def unfreeze_vdm_stats(self):
'''
This function unfreeze all the vdm statistics reporting registers.
When freeze is ceased by the host, releases the freeze request, allowing the
When freeze is ceased by the host, releases the freeze request, allowing the
reported minimum, maximum and average values to update again.

Returns True if the provision succeeds and False incase of failure.
'''
return self.xcvr_eeprom.write(consts.VDM_CONTROL, VDM_UNFREEZE)
Expand Down Expand Up @@ -282,7 +282,21 @@ def get_transceiver_info(self):
"cable_length": float(admin_info[consts.LENGTH_ASSEMBLY_FIELD]),
"nominal_bit_rate": 0, # Not supported
"vendor_date": admin_info[consts.VENDOR_DATE_FIELD],
"vendor_oui": admin_info[consts.VENDOR_OUI_FIELD]
"vendor_oui": admin_info[consts.VENDOR_OUI_FIELD],
"is_replaceable": "N/A", # Not supported
"dom_capability": "N/A", # Not supported
"active_apsel_hostlane1": "N/A", # Not supported
"active_apsel_hostlane2": "N/A", # Not supported
"active_apsel_hostlane3": "N/A", # Not supported
"active_apsel_hostlane4": "N/A", # Not supported
"active_apsel_hostlane5": "N/A", # Not supported
"active_apsel_hostlane6": "N/A", # Not supported
"active_apsel_hostlane7": "N/A", # Not supported
"active_apsel_hostlane8": "N/A", # Not supported
"supported_max_tx_power": "N/A", # Not supported
"supported_min_tx_power": "N/A", # Not supported
"supported_max_laser_freq": "N/A", # Not supported
"supported_min_laser_freq": "N/A" # Not supported
}
appl_advt = self.get_application_advertisement()
xcvr_info['application_advertisement'] = str(appl_advt) if len(appl_advt) > 0 else 'N/A'
Expand Down Expand Up @@ -321,7 +335,7 @@ def get_transceiver_info_firmware_versions(self):
( _, _, _, _, _, _, _, _, ActiveFirmware, InactiveFirmware) = result['result']
except (ValueError, TypeError):
return return_dict

return_dict["active_firmware"] = ActiveFirmware
return_dict["inactive_firmware"] = InactiveFirmware
return return_dict
Expand Down Expand Up @@ -983,10 +997,10 @@ def get_media_lane_count(self, appl=1):
'''
if self.is_flat_memory():
return 0

if (appl <= 0):
return 0

appl_advt = self.get_application_advertisement()
return appl_advt[appl]['media_lane_count'] if len(appl_advt) >= appl else 0

Expand Down Expand Up @@ -1015,10 +1029,10 @@ def get_media_lane_assignment_option(self, appl=1):
'''
if self.is_flat_memory():
return 'N/A'

if (appl <= 0):
return 0

appl_advt = self.get_application_advertisement()
return appl_advt[appl]['media_lane_assignment_options'] if len(appl_advt) >= appl else 0

Expand Down Expand Up @@ -2455,7 +2469,7 @@ def get_transceiver_vdm_real_value(self):
biasyq{lane_num} = FLOAT ; modulator bias yq in percentage
biasyp{lane_num} = FLOAT ; modulator bias yq in percentage
cdshort{lane_num} = FLOAT ; chromatic dispersion, high granularity, short link in ps/nm
cdlong{lane_num} = FLOAT ; chromatic dispersion, high granularity, long link in ps/nm
cdlong{lane_num} = FLOAT ; chromatic dispersion, high granularity, long link in ps/nm
dgd{lane_num} = FLOAT ; differential group delay in ps
sopmd{lane_num} = FLOAT ; second order polarization mode dispersion in ps^2
soproc{lane_num} = FLOAT ; state of polarization rate of change in krad/s
Expand Down Expand Up @@ -2484,7 +2498,7 @@ def get_transceiver_vdm_thresholds(self):
Returns:
A dict containing the following keys/values :
========================================================================
xxx refers to HALARM/LALARM/HWARN/LWARN threshold
xxx refers to HALARM/LALARM/HWARN/LWARN threshold
;Defines Transceiver VDM high/low alarm/warning threshold for a port
key = TRANSCEIVER_VDM_XXX_THRESHOLD|ifname ; information module VDM high/low alarm/warning threshold on port
; field = value
Expand Down Expand Up @@ -2805,7 +2819,7 @@ def decommission_all_datapaths(self):
name = "DP{}State".format(lane + 1)
if dp_state[name] != 'DataPathDeactivated':
return False

name = "ConfigStatusLane{}".format(lane + 1)
if config_state[name] != 'ConfigSuccess':
return False
Expand Down
18 changes: 12 additions & 6 deletions tests/sonic_xcvr/test_cmis.py
Original file line number Diff line number Diff line change
Expand Up @@ -1498,7 +1498,13 @@ def test_module_fw_upgrade(self, input_param, mock_response, expected):
'media_lane_assignment_option': 1,
'connector': 'LC',
'host_lane_assignment_option': 1,
'vendor_date': '21010100'
'vendor_date': '21010100',
'dom_capability': 'N/A',
'is_replaceable': 'N/A',
'supported_max_laser_freq': 'N/A',
'supported_max_tx_power': 'N/A',
'supported_min_laser_freq': 'N/A',
'supported_min_tx_power': 'N/A'
}
)
])
Expand Down Expand Up @@ -1526,11 +1532,11 @@ def test_get_transceiver_info(self, mock_response, expected):
self.api.get_cmis_rev = MagicMock()
self.api.get_cmis_rev.return_value = mock_response[10]
self.api.get_module_fw_info = MagicMock()
self.api.get_module_fw_info.return_value = mock_response[14]
self.api.get_module_media_type = MagicMock()
self.api.get_module_media_type.return_value = mock_response[13]
self.api.get_module_hardware_revision = MagicMock()
self.api.get_module_hardware_revision.return_value = '0.0'
self.api.get_module_fw_info.return_value = mock_response[14]
self.api.is_flat_memory = MagicMock()
self.api.is_flat_memory.return_value = False
result = self.api.get_transceiver_info()
Expand Down Expand Up @@ -2943,7 +2949,7 @@ def test_set_application(self):
'ConfigStatusLane5': 'ConfigSuccess',
'ConfigStatusLane6': 'ConfigSuccess',
'ConfigStatusLane7': 'ConfigSuccess',
'ConfigStatusLane8': 'ConfigSuccess'
'ConfigStatusLane8': 'ConfigSuccess'
} )
])
def test_decommission_all_datapaths(self, datapath_state, config_state):
Expand Down Expand Up @@ -3082,10 +3088,10 @@ def test_get_error_description(self):
}
self.api.xcvr_eeprom.read = MagicMock()
self.api.xcvr_eeprom.read.return_value = 0x10

result = self.api.get_error_description()
assert result is 'OK'

self.api.get_config_datapath_hostlane_status.return_value = {
'ConfigStatusLane1': 'ConfigRejected',
'ConfigStatusLane2': 'ConfigRejected',
Expand All @@ -3098,7 +3104,7 @@ def test_get_error_description(self):
}
result = self.api.get_error_description()
assert result is 'ConfigRejected'

self.api.get_datapath_state.return_value = {
'DP1State': 'DataPathDeactivated',
'DP2State': 'DataPathActivated',
Expand Down
Loading