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

[sonic_platform/sfp_base] Add common definition for get SFP error status #194

Merged
merged 4 commits into from
Jun 16, 2021
Merged
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
44 changes: 44 additions & 0 deletions sonic_platform_base/sfp_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,41 @@ class SfpBase(device_base.DeviceBase):
# Device type definition. Note, this is a constant.
DEVICE_TYPE = "sfp"

# Generic error types definition
SFP_STATUS_INITIALIZING = 'Initializing'
SFP_STATUS_OK = 'OK'
SFP_STATUS_UNPLUGGED = 'Unplugged'
SFP_STATUS_DISABLED = 'Disabled'
SFP_ERROR_DESCRIPTION_BLOCKING = 'Blocking EEPROM from being read'
SFP_ERROR_DESCRIPTION_POWER_BUDGET_EXCEEDED = 'Power budget exceeded'
SFP_ERROR_DESCRIPTION_I2C_STUCK = 'Bus stuck (I2C data or clock shorted)'
SFP_ERROR_DESCRIPTION_BAD_EEPROM = 'Bad or unsupported EEPROM'
SFP_ERROR_DESCRIPTION_UNSUPPORTED_CABLE = 'Unsupported cable'
SFP_ERROR_DESCRIPTION_HIGH_TEMP = 'High temperature'
SFP_ERROR_DESCRIPTION_BAD_CABLE = 'Bad cable (module/cable is shorted)'

# SFP status
SFP_STATUS_BIT_REMOVED = 0x00000000
SFP_STATUS_BIT_INSERTED = 0x00000001
# SFP error status
SFP_ERROR_BIT_BLOCKING = 0x00000002
SFP_ERROR_BIT_POWER_BUDGET_EXCEEDED = 0x00000004
SFP_ERROR_BIT_I2C_STUCK = 0x00000008
SFP_ERROR_BIT_BAD_EEPROM = 0x00000010
SFP_ERROR_BIT_UNSUPPORTED_CABLE = 0x00000020
SFP_ERROR_BIT_HIGH_TEMP = 0x00000040
SFP_ERROR_BIT_BAD_CABLE = 0x00000080

SFP_ERROR_BIT_TO_DESCRIPTION_DICT = {
SFP_ERROR_BIT_BLOCKING: SFP_ERROR_DESCRIPTION_BLOCKING,
SFP_ERROR_BIT_POWER_BUDGET_EXCEEDED: SFP_ERROR_DESCRIPTION_POWER_BUDGET_EXCEEDED,
SFP_ERROR_BIT_I2C_STUCK: SFP_ERROR_DESCRIPTION_I2C_STUCK,
SFP_ERROR_BIT_BAD_EEPROM: SFP_ERROR_DESCRIPTION_BAD_EEPROM,
SFP_ERROR_BIT_UNSUPPORTED_CABLE: SFP_ERROR_DESCRIPTION_UNSUPPORTED_CABLE,
SFP_ERROR_BIT_HIGH_TEMP: SFP_ERROR_DESCRIPTION_HIGH_TEMP,
SFP_ERROR_BIT_BAD_CABLE: SFP_ERROR_DESCRIPTION_BAD_CABLE
}

def __init__(self):
# List of ThermalBase-derived objects representing all thermals
# available on the SFP
Expand Down Expand Up @@ -384,4 +419,13 @@ def write_eeprom(self, offset, num_bytes, write_buffer):
"""
raise NotImplementedError

def get_error_description(self):
"""
Retrives the error descriptions of the SFP module

Returns:
String that represents the current error descriptions of vendor specific errors
In case there are multiple errors, they should be joined by '|',
like: "Bad EEPROM|Unsupported cable"
"""
raise NotImplementedError