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

[Mellanox] get_error_descripton should return Not supported for modules that does not support this API #21196

Merged
merged 1 commit into from
Jan 23, 2025
Merged
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
6 changes: 4 additions & 2 deletions platform/mellanox/mlnx-platform-api/sonic_platform/sfp.py
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ def get_error_info_from_sdk_error_type(self):
Returns:
tuple: (error state, error description)
"""
error_type = utils.read_int_from_file(f'/sys/module/sx_core/asic0/module{self.sdk_index}/temperature/statuserror', default=-1)
error_type = utils.read_int_from_file(f'/sys/module/sx_core/asic0/module{self.sdk_index}/statuserror', default=-1)
sfp_state_bits = NvidiaSFPCommon.SDK_ERRORS_TO_ERROR_BITS.get(error_type)
if sfp_state_bits is None:
logger.log_error(f"Unrecognized error {error_type} detected on SFP {self.sdk_index}")
Expand Down Expand Up @@ -678,7 +678,9 @@ def get_error_description(self):
if self.is_sw_control():
api = self.get_xcvr_api()
return api.get_error_description() if api else None
except:
except NotImplementedError:
return 'Not supported'
except Exception:
return self.SFP_STATUS_INITIALIZING

oper_status, error_code = self._get_module_info(self.sdk_index)
Expand Down
4 changes: 4 additions & 0 deletions platform/mellanox/mlnx-platform-api/tests/test_sfp.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,10 @@ def test_sfp_get_error_status(self, mock_get_error_code, mock_control):
mock_control.side_effect = RuntimeError('')
description = sfp.get_error_description()
assert description == 'Initializing'

mock_control.side_effect = NotImplementedError('')
description = sfp.get_error_description()
assert description == 'Not supported'

@mock.patch('sonic_platform.sfp.SFP._get_page_and_page_offset')
@mock.patch('sonic_platform.sfp.SFP._is_write_protected')
Expand Down
Loading