From 9b1dea5c9e063ffddd7d1fdc82ce9796a26c19d2 Mon Sep 17 00:00:00 2001 From: shilimkarvg <58078339+shilimkarvg@users.noreply.github.com> Date: Fri, 20 Mar 2020 10:13:54 +0530 Subject: [PATCH] SFP(sff8472 attributes) transciever eeprom attribute support. (#74) --- sonic_platform_base/sonic_sfp/sff8472.py | 97 +++++++++++++++++++- sonic_platform_base/sonic_sfp/sfputilbase.py | 13 ++- 2 files changed, 101 insertions(+), 9 deletions(-) diff --git a/sonic_platform_base/sonic_sfp/sff8472.py b/sonic_platform_base/sonic_sfp/sff8472.py index d0d3441b3e83..d72b2897859d 100644 --- a/sonic_platform_base/sonic_sfp/sff8472.py +++ b/sonic_platform_base/sonic_sfp/sff8472.py @@ -513,7 +513,7 @@ class sff8472InterfaceId(sffbase): 'size':3, 'type' : 'hex'} } - + vendor_date = { 'VendorDataCode(YYYY-MM-DD Lot)': {'offset':0, @@ -569,7 +569,7 @@ def parse_vendor_date(self, sn_raw_data, start_pos): def parse_vendor_oui(self, sn_raw_data, start_pos): return sffbase.parse(self, self.vendor_oui, sn_raw_data, start_pos) - + def dump_pretty(self): if self.interface_data == None: print('Object not initialized, nothing to print') @@ -1175,6 +1175,90 @@ def calc_rx_power(self, eeprom_data, offset, size): 'type': 'func', 'decode': {'func': calc_rx_power}} } + dom_module_monitor = { + 'TempHighAlarm': + {'offset':0, + 'bit':7, + 'type': 'bitvalue'}, + 'TempLowAlarm': + {'offset':0, + 'bit':6, + 'type': 'bitvalue'}, + 'TempHighWarning': + {'offset': 4, + 'bit': 7, + 'type': 'bitvalue'}, + 'TempLowWarning': + {'offset': 4, + 'bit': 6, + 'type': 'bitvalue'}, + 'VccHighAlarm': + {'offset': 0, + 'bit': 5, + 'type': 'bitvalue'}, + 'VccLowAlarm': + {'offset': 0, + 'bit': 4, + 'type': 'bitvalue'}, + 'VccHighWarning': + {'offset': 4, + 'bit': 5, + 'type': 'bitvalue'}, + 'VccLowWarning': + {'offset': 4, + 'bit': 4, + 'type': 'bitvalue'}} + + dom_channel_thresh_monitor_params = { + 'BiasHighAlarm': + {'offset':0, + 'bit':3, + 'type': 'bitvalue'}, + 'BiasLowAlarm': + {'offset':0, + 'bit':2, + 'type': 'bitvalue'}, + 'BiasHighWarning': + {'offset':4, + 'bit':3, + 'type': 'bitvalue'}, + 'BiasLowWarning': + {'offset':4, + 'bit':2, + 'type': 'bitvalue'}, + 'TxPowerHighAlarm': + {'offset':0, + 'bit':1, + 'type': 'bitvalue'}, + 'TxPowerLowAlarm': + {'offset':0, + 'bit':0, + 'type': 'bitvalue'}, + 'TxPowerHighWarning': + {'offset':4, + 'bit':1, + 'type': 'bitvalue'}, + 'TxPowerLowWarning': + {'offset':4, + 'bit':0, + 'type': 'bitvalue'}, + 'RxPowerHighAlarm': + {'offset':1, + 'bit':7, + 'type': 'bitvalue'}, + 'RxPowerLowAlarm': + {'offset':1, + 'bit':6, + 'type': 'bitvalue'}, + 'RxPowerHighWarning': + {'offset':5, + 'bit':7, + 'type': 'bitvalue'}, + 'RxPowerLowWarning': + {'offset':5, + 'bit':6, + 'type': 'bitvalue'} + } def __init__(self, eeprom_raw_data=None, calibration_type=0): self._calibration_type = calibration_type @@ -1200,6 +1284,14 @@ def parse_channel_monitor_params(self, eeprom_raw_data, start_pos): return sffbase.parse(self, self.dom_channel_monitor_params, eeprom_raw_data, start_pos) + def parse_module_monitor_params(self, eeprom_raw_data, start_pos): + return sffbase.parse(self, self.dom_module_monitor, eeprom_raw_data, + start_pos) + + def parse_channel_thresh_monitor_params(self, eeprom_raw_data, start_pos): + return sffbase.parse(self, self.dom_channel_thresh_monitor_params, eeprom_raw_data, + start_pos) + def parse_alarm_warning_threshold(self, eeprom_raw_data, start_pos): return sffbase.parse(self, self.dom_aw_thresholds, eeprom_raw_data, start_pos) @@ -1217,3 +1309,4 @@ def get_data(self): def get_data_pretty(self): return sffbase.get_data_pretty(self, self.dom_data) + diff --git a/sonic_platform_base/sonic_sfp/sfputilbase.py b/sonic_platform_base/sonic_sfp/sfputilbase.py index 7ec223966e15..30ad04bacfb8 100644 --- a/sonic_platform_base/sonic_sfp/sfputilbase.py +++ b/sonic_platform_base/sonic_sfp/sfputilbase.py @@ -88,9 +88,10 @@ SFP_VOLT_WIDTH = 2 SFP_CHANNL_MON_OFFSET = 100 SFP_CHANNL_MON_WIDTH = 6 -SFP_MODULE_THRESHOLD_OFFSET = 0 -SFP_MODULE_THRESHOLD_WIDTH = 56 - +SFP_MODULE_THRESHOLD_OFFSET = 112 +SFP_MODULE_THRESHOLD_WIDTH = 5 +SFP_CHANNL_THRESHOLD_OFFSET = 112 +SFP_CHANNL_THRESHOLD_WIDTH = 6 qsfp_cable_length_tup = ('Length(km)', 'Length OM3(2m)', 'Length OM2(m)', 'Length OM1(m)', @@ -450,7 +451,6 @@ def read_porttab_mappings(self, porttabfile): print("logical to physical: " + self.logical_to_physical) print("physical to logical: " + self.physical_to_logical) """ - def read_phytab_mappings(self, phytabfile): logical = [] phytab_mappings = {} @@ -1045,7 +1045,6 @@ def get_transceiver_dom_info_dict(self, port_num): sfpd_obj = sff8472Dom() if sfpd_obj is None: return None - dom_temperature_raw = self._read_eeprom_specific_bytes(sysfsfile_eeprom, (offset + SFP_TEMPE_OFFSET), SFP_TEMPE_WIDTH) if dom_temperature_raw is not None: dom_temperature_data = sfpd_obj.parse_temperature(dom_temperature_raw, 0) @@ -1086,7 +1085,6 @@ def get_transceiver_dom_info_dict(self, port_num): transceiver_dom_info_dict['tx4power'] = 'N/A' return transceiver_dom_info_dict - def get_transceiver_dom_threshold_info_dict(self, port_num): transceiver_dom_threshold_info_dict = {} @@ -1195,7 +1193,7 @@ def get_transceiver_dom_threshold_info_dict(self, port_num): (offset + SFP_CHANNL_THRESHOLD_OFFSET), SFP_CHANNL_THRESHOLD_WIDTH) if dom_channel_threshold_raw is not None: - dom_channel_threshold_data = sfpd_obj.parse_channel_monitor_params(dom_channel_threshold_raw, 0) + dom_channel_threshold_data = sfpd_obj.parse_channel_thresh_monitor_params(dom_channel_threshold_raw, 0) else: return None @@ -1279,3 +1277,4 @@ def get_transceiver_change_event(self, timeout=0): like {'-1':'system_not_ready'}. """ return +