From cb8bfdc423592b0f554cdb590ea32276241f5ad3 Mon Sep 17 00:00:00 2001 From: Stephen Sun Date: Fri, 4 Jun 2021 10:53:12 +0000 Subject: [PATCH] Address comments Signed-off-by: Stephen Sun --- .../mellanox/mlnx-platform-api/sonic_platform/sfp.py | 7 +++++++ .../mlnx-platform-api/sonic_platform/sfp_event.py | 11 ++++++----- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/platform/mellanox/mlnx-platform-api/sonic_platform/sfp.py b/platform/mellanox/mlnx-platform-api/sonic_platform/sfp.py index 0bd26340b448..8222ead5081f 100644 --- a/platform/mellanox/mlnx-platform-api/sonic_platform/sfp.py +++ b/platform/mellanox/mlnx-platform-api/sonic_platform/sfp.py @@ -348,6 +348,11 @@ class SFP(SfpBase): SFP_MLNX_ERROR_DESCRIPTION_PMD_TYPE_NOT_ENABLED = 'PMD type not enabled' SFP_MLNX_ERROR_DESCRIPTION_PCIE_POWER_SLOT_EXCEEDED = 'PCIE system power slot exceeded' + SFP_MLNX_ERROR_BIT_LONGRANGE_NON_MLNX_CABLE = 0x00010000 + SFP_MLNX_ERROR_BIT_ENFORCE_PART_NUMBER_LIST = 0x00020000 + SFP_MLNX_ERROR_BIT_PMD_TYPE_NOT_ENABLED = 0x00040000 + SFP_MLNX_ERROR_BIT_PCIE_POWER_SLOT_EXCEEDED = 0x00080000 + def __init__(self, sfp_index, sfp_type, sdk_handle_getter, platform): SfpBase.__init__(self) self.index = sfp_index + 1 @@ -2238,4 +2243,6 @@ def get_error_description(self): error_description = error_description_dict[error_code] else: error_description = "Unknown error ({})".format(error_code) + else: + error_description = "Unknow SFP module status ({})".format(oper_status) return error_description diff --git a/platform/mellanox/mlnx-platform-api/sonic_platform/sfp_event.py b/platform/mellanox/mlnx-platform-api/sonic_platform/sfp_event.py index 6856d49f1ca2..289a210482f1 100644 --- a/platform/mellanox/mlnx-platform-api/sonic_platform/sfp_event.py +++ b/platform/mellanox/mlnx-platform-api/sonic_platform/sfp_event.py @@ -17,7 +17,7 @@ class MockSxFd(object): new_sx_fd_t_p = MagicMock(return_value=MockSxFd()) new_sx_user_channel_t_p = MagicMock() from sonic_py_common.logger import Logger -from sonic_platform.sfp import SFP +from .sfp import SFP # SFP status from PMAOS register # 0x1 plug in @@ -70,16 +70,17 @@ class MockSxFd(object): SDK_ERRORS_TO_ERROR_BITS = { 0x0: SFP.SFP_ERROR_BIT_POWER_BUDGET_EXCEEDED, + 0x1: SFP.SFP_MLNX_ERROR_BIT_LONGRANGE_NON_MLNX_CABLE, 0x2: SFP.SFP_ERROR_BIT_I2C_STUCK, 0x3: SFP.SFP_ERROR_BIT_BAD_EEPROM, + 0x4: SFP.SFP_MLNX_ERROR_BIT_ENFORCE_PART_NUMBER_LIST, 0x5: SFP.SFP_ERROR_BIT_UNSUPPORTED_CABLE, 0x6: SFP.SFP_ERROR_BIT_HIGH_TEMP, 0x7: SFP.SFP_ERROR_BIT_BAD_CABLE, - 0x1: 0x00010000, - 0x4: 0x00020000, - 0x8: 0x00040000, - 0xc: 0x00080000 + 0x8: SFP.SFP_MLNX_ERROR_BIT_PMD_TYPE_NOT_ENABLED, + 0xc: SFP.SFP_MLNX_ERROR_BIT_PCIE_POWER_SLOT_EXCEEDED } + SDK_ERRORS_TO_DESCRIPTION = { 0x1: SFP.SFP_MLNX_ERROR_DESCRIPTION_LONGRANGE_NON_MLNX_CABLE, 0x4: SFP.SFP_MLNX_ERROR_DESCRIPTION_ENFORCE_PART_NUMBER_LIST,