Skip to content

Commit

Permalink
[sfputil]Fix issue: xcvrd is broken. (#3258)
Browse files Browse the repository at this point in the history
xcvrd is broken because a newly introduced interface get_transceiver_dom_threshold_info_dict in common code calls a unsupported interface _read_eeprom_specific_bytes.
Fix the issue by implement get_transceiver_dom_threshold_info_dict to avoid calling the unsupported interface.
  • Loading branch information
stephenxs authored and jleveque committed Aug 1, 2019
1 parent e77c36b commit b9a806b
Showing 1 changed file with 73 additions and 0 deletions.
73 changes: 73 additions & 0 deletions device/mellanox/x86_64-mlnx_msn2700-r0/plugins/sfputil.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@

# sfp supports dom
XCVR_DOM_CAPABILITY_DOM_SUPPORT_BIT = 0x40

# sfp module threshold offset and width
SFP_MODULE_THRESHOLD_OFFSET = 0
SFP_MODULE_THRESHOLD_WIDTH = 56

# I2C page size for sfp
SFP_I2C_PAGE_SIZE = 256

Expand Down Expand Up @@ -556,3 +561,71 @@ def get_transceiver_dom_info_dict(self, port_num):
transceiver_dom_info_dict['tx1power'] = dom_channel_monitor_data['data']['TXPower']['value']

return transceiver_dom_info_dict

def get_transceiver_dom_threshold_info_dict(self, port_num):
transceiver_dom_threshold_info_dict = {}

dom_info_dict_keys = ['temphighalarm', 'temphighwarning',
'templowalarm', 'templowwarning',
'vcchighalarm', 'vcchighwarning',
'vcclowalarm', 'vcclowwarning',
'rxpowerhighalarm', 'rxpowerhighwarning',
'rxpowerlowalarm', 'rxpowerlowwarning',
'txpowerhighalarm', 'txpowerhighwarning',
'txpowerlowalarm', 'txpowerlowwarning',
'txbiashighalarm', 'txbiashighwarning',
'txbiaslowalarm', 'txbiaslowwarning'
]
transceiver_dom_threshold_info_dict = dict.fromkeys(dom_info_dict_keys, 'N/A')

if port_num in self.qsfp_ports:
# current we don't support qsfp since threshold data is on page 3 and the way to read this page is under discussion.
return transceiver_dom_threshold_info_dict
else:
offset = SFP_I2C_PAGE_SIZE

eeprom_raw = ['0'] * SFP_I2C_PAGE_SIZE
eeprom_raw[XCVR_DOM_CAPABILITY_OFFSET : XCVR_DOM_CAPABILITY_OFFSET + XCVR_DOM_CAPABILITY_WIDTH] = \
self._read_eeprom_specific_bytes_via_ethtool(port_num, XCVR_DOM_CAPABILITY_OFFSET, XCVR_DOM_CAPABILITY_WIDTH)
sfp_obj = sff8472InterfaceId()
calibration_type = sfp_obj._get_calibration_type(eeprom_raw)

dom_supported = (int(eeprom_raw[XCVR_DOM_CAPABILITY_OFFSET], 16) & XCVR_DOM_CAPABILITY_DOM_SUPPORT_BIT != 0)
if not dom_supported:
return transceiver_dom_threshold_info_dict

sfpd_obj = sff8472Dom(None, calibration_type)
if sfpd_obj is None:
return transceiver_dom_threshold_info_dict

dom_module_threshold_raw = self._read_eeprom_specific_bytes_via_ethtool(port_num,
(offset + SFP_MODULE_THRESHOLD_OFFSET),
SFP_MODULE_THRESHOLD_WIDTH)
if dom_module_threshold_raw is not None:
dom_module_threshold_data = sfpd_obj.parse_alarm_warning_threshold(dom_module_threshold_raw, 0)
else:
return transceiver_dom_threshold_info_dict

# Threshold Data
transceiver_dom_threshold_info_dict['temphighalarm'] = dom_module_threshold_data['data']['TempHighAlarm']['value']
transceiver_dom_threshold_info_dict['templowalarm'] = dom_module_threshold_data['data']['TempLowAlarm']['value']
transceiver_dom_threshold_info_dict['temphighwarning'] = dom_module_threshold_data['data']['TempHighWarning']['value']
transceiver_dom_threshold_info_dict['templowwarning'] = dom_module_threshold_data['data']['TempLowWarning']['value']
transceiver_dom_threshold_info_dict['vcchighalarm'] = dom_module_threshold_data['data']['VoltageHighAlarm']['value']
transceiver_dom_threshold_info_dict['vcclowalarm'] = dom_module_threshold_data['data']['VoltageLowAlarm']['value']
transceiver_dom_threshold_info_dict['vcchighwarning'] = dom_module_threshold_data['data']['VoltageHighWarning']['value']
transceiver_dom_threshold_info_dict['vcclowwarning'] = dom_module_threshold_data['data']['VoltageLowWarning']['value']
transceiver_dom_threshold_info_dict['txbiashighalarm'] = dom_module_threshold_data['data']['BiasHighAlarm']['value']
transceiver_dom_threshold_info_dict['txbiaslowalarm'] = dom_module_threshold_data['data']['BiasLowAlarm']['value']
transceiver_dom_threshold_info_dict['txbiashighwarning'] = dom_module_threshold_data['data']['BiasHighWarning']['value']
transceiver_dom_threshold_info_dict['txbiaslowwarning'] = dom_module_threshold_data['data']['BiasLowWarning']['value']
transceiver_dom_threshold_info_dict['txpowerhighalarm'] = dom_module_threshold_data['data']['TXPowerHighAlarm']['value']
transceiver_dom_threshold_info_dict['txpowerlowalarm'] = dom_module_threshold_data['data']['TXPowerLowAlarm']['value']
transceiver_dom_threshold_info_dict['txpowerhighwarning'] = dom_module_threshold_data['data']['TXPowerHighWarning']['value']
transceiver_dom_threshold_info_dict['txpowerlowwarning'] = dom_module_threshold_data['data']['TXPowerLowWarning']['value']
transceiver_dom_threshold_info_dict['rxpowerhighalarm'] = dom_module_threshold_data['data']['RXPowerHighAlarm']['value']
transceiver_dom_threshold_info_dict['rxpowerlowalarm'] = dom_module_threshold_data['data']['RXPowerLowAlarm']['value']
transceiver_dom_threshold_info_dict['rxpowerhighwarning'] = dom_module_threshold_data['data']['RXPowerHighWarning']['value']
transceiver_dom_threshold_info_dict['rxpowerlowwarning'] = dom_module_threshold_data['data']['RXPowerLowWarning']['value']

return transceiver_dom_threshold_info_dict

0 comments on commit b9a806b

Please sign in to comment.