Skip to content

Commit 9b9da85

Browse files
[Mellanox] get_error_description should return Not supported for modules that does not support this API (#21196)
- Why I did it Not all xcvr API support get_error_description, for example sff8636. For those API types, get_error_description should return "Not supported". - How I did it get_error_description should return "Not supported". - How to verify it Manual test unit test
1 parent d3d65e6 commit 9b9da85

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

platform/mellanox/mlnx-platform-api/sonic_platform/sfp.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,7 @@ def get_error_info_from_sdk_error_type(self):
359359
Returns:
360360
tuple: (error state, error description)
361361
"""
362-
error_type = utils.read_int_from_file(f'/sys/module/sx_core/asic0/module{self.sdk_index}/temperature/statuserror', default=-1)
362+
error_type = utils.read_int_from_file(f'/sys/module/sx_core/asic0/module{self.sdk_index}/statuserror', default=-1)
363363
sfp_state_bits = NvidiaSFPCommon.SDK_ERRORS_TO_ERROR_BITS.get(error_type)
364364
if sfp_state_bits is None:
365365
logger.log_error(f"Unrecognized error {error_type} detected on SFP {self.sdk_index}")
@@ -678,7 +678,9 @@ def get_error_description(self):
678678
if self.is_sw_control():
679679
api = self.get_xcvr_api()
680680
return api.get_error_description() if api else None
681-
except:
681+
except NotImplementedError:
682+
return 'Not supported'
683+
except Exception:
682684
return self.SFP_STATUS_INITIALIZING
683685

684686
oper_status, error_code = self._get_module_info(self.sdk_index)

platform/mellanox/mlnx-platform-api/tests/test_sfp.py

+4
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,10 @@ def test_sfp_get_error_status(self, mock_get_error_code, mock_control):
9494
mock_control.side_effect = RuntimeError('')
9595
description = sfp.get_error_description()
9696
assert description == 'Initializing'
97+
98+
mock_control.side_effect = NotImplementedError('')
99+
description = sfp.get_error_description()
100+
assert description == 'Not supported'
97101

98102
@mock.patch('sonic_platform.sfp.SFP._get_page_and_page_offset')
99103
@mock.patch('sonic_platform.sfp.SFP._is_write_protected')

0 commit comments

Comments
 (0)