Skip to content

Commit

Permalink
SFP(sff8472 attributes) transciever eeprom attribute support. (#74)
Browse files Browse the repository at this point in the history
  • Loading branch information
shilimkarvg authored Mar 20, 2020
1 parent dc59b10 commit 9b1dea5
Show file tree
Hide file tree
Showing 2 changed files with 101 additions and 9 deletions.
97 changes: 95 additions & 2 deletions sonic_platform_base/sonic_sfp/sff8472.py
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,7 @@ class sff8472InterfaceId(sffbase):
'size':3,
'type' : 'hex'}
}

vendor_date = {
'VendorDataCode(YYYY-MM-DD Lot)':
{'offset':0,
Expand Down Expand Up @@ -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')
Expand Down Expand Up @@ -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
Expand All @@ -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)
Expand All @@ -1217,3 +1309,4 @@ def get_data(self):

def get_data_pretty(self):
return sffbase.get_data_pretty(self, self.dom_data)

13 changes: 6 additions & 7 deletions sonic_platform_base/sonic_sfp/sfputilbase.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)',
Expand Down Expand Up @@ -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 = {}
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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 = {}

Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -1279,3 +1277,4 @@ def get_transceiver_change_event(self, timeout=0):
like {'-1':'system_not_ready'}.
"""
return

0 comments on commit 9b1dea5

Please sign in to comment.