Skip to content

Commit

Permalink
Address comments
Browse files Browse the repository at this point in the history
Signed-off-by: Stephen Sun <[email protected]>
  • Loading branch information
stephenxs committed Jun 7, 2021
1 parent 661507d commit cb8bfdc
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
7 changes: 7 additions & 0 deletions platform/mellanox/mlnx-platform-api/sonic_platform/sfp.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
11 changes: 6 additions & 5 deletions platform/mellanox/mlnx-platform-api/sonic_platform/sfp_event.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit cb8bfdc

Please sign in to comment.