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_sfp: Support for DOM Threshold values for EEPROM dump #33

Merged
merged 6 commits into from
Jun 28, 2019
Merged
244 changes: 244 additions & 0 deletions sonic_sfp/sff8436.py
Original file line number Diff line number Diff line change
Expand Up @@ -1186,6 +1186,237 @@ def calc_rx_power(self, eeprom_data, offset, size):
'decode': {'func': calc_tx_power}}
}

dom_module_threshold_values = {
'TempHighAlarm':
{'offset':0,
'size':2,
'type': 'func',
'decode': { 'func':calc_temperature}},
'TempLowAlarm':
{'offset':2,
'size':2,
'type': 'func',
'decode': { 'func':calc_temperature}},
'TempHighWarning':
{'offset':4,
'size':2,
'type': 'func',
'decode': { 'func':calc_temperature}},
'TempLowWarning':
{'offset':6,
'size':2,
'type': 'func',
'decode': { 'func':calc_temperature}},
'VccHighAlarm':
{'offset':16,
'size':2,
'type': 'func',
'decode': { 'func':calc_voltage}},
'VccLowAlarm':
{'offset':18,
'size':2,
'type': 'func',
'decode': { 'func':calc_voltage}},
'VccHighWarning':
{'offset':20,
'size':2,
'type': 'func',
'decode': { 'func':calc_voltage}},
'VccLowWarning':
{'offset':22,
'size':2,
'type': 'func',
'decode': { 'func':calc_voltage}}}

dom_channel_threshold_values = {
'RxPowerHighAlarm':
{'offset':0,
'size':2,
'type': 'func',
'decode': { 'func':calc_rx_power}},
'RxPowerLowAlarm':
{'offset':2,
'size':2,
'type': 'func',
'decode': { 'func':calc_rx_power}},
'RxPowerHighWarning':
{'offset':4,
'size':2,
'type': 'func',
'decode': { 'func':calc_rx_power}},
'RxPowerLowWarning':
{'offset':6,
'size':2,
'type': 'func',
'decode': { 'func':calc_rx_power}},
'TxBiasHighAlarm':
{'offset':8,
'size':2,
'type': 'func',
'decode': { 'func':calc_bias}},
'TxBiasLowAlarm':
{'offset':10,
'size':2,
'type': 'func',
'decode': { 'func':calc_bias}},
'TxBiasHighWarning':
{'offset':12,
'size':2,
'type': 'func',
'decode': { 'func':calc_bias}},
'TxBiasLowWarning':
{'offset':14,
'size':2,
'type': 'func',
'decode': { 'func':calc_bias}}}

dom_channel_monitor_masks = {
'Rx1PowerHighAlarm':
{'offset':0,
'bit': 7,
'type': 'bitvalue'},
'Rx1PowerLowAlarm':
{'offset':0,
'bit': 6,
'type': 'bitvalue'},
'Rx1PowerHighWarning':
{'offset':0,
'bit': 5,
'type': 'bitvalue'},
'Rx1PowerLowWarning':
{'offset':0,
'bit': 4,
'type': 'bitvalue'},
'Rx2PowerHighAlarm':
{'offset':0,
'bit': 3,
'type': 'bitvalue'},
'Rx2PowerLowAlarm':
{'offset':0,
'bit': 2,
'type': 'bitvalue'},
'Rx2PowerHighWarning':
{'offset':0,
'bit': 1,
'type': 'bitvalue'},
'Rx2PowerLowWarning':
{'offset':0,
'bit': 0,
'type': 'bitvalue'},
'Rx3PowerHighAlarm':
{'offset':1,
'bit': 7,
'type': 'bitvalue'},
'Rx3PowerLowAlarm':
{'offset':1,
'bit': 6,
'type': 'bitvalue'},
'Rx3PowerHighWarning':
{'offset':1,
'bit': 5,
'type': 'bitvalue'},
'Rx3PowerLowWarning':
{'offset':1,
'bit': 4,
'type': 'bitvalue'},
'Rx4PowerHighAlarm':
{'offset':1,
'bit': 3,
'type': 'bitvalue'},
'Rx4PowerLowAlarm':
{'offset':1,
'bit': 2,
'type': 'bitvalue'},
'Rx4PowerHighWarning':
{'offset':1,
'bit': 1,
'type': 'bitvalue'},
'Rx4PowerLowWarning':
{'offset':1,
'bit': 0,
'type': 'bitvalue'},
'Tx1BiasHighAlarm':
{'offset':2,
'bit': 7,
'type': 'bitvalue'},
'Tx1BiasLowAlarm':
{'offset':2,
'bit': 6,
'type': 'bitvalue'},
'Tx1BiasHighWarning':
{'offset':2,
'bit': 5,
'type': 'bitvalue'},
'Tx1BiasLowWarning':
{'offset':2,
'bit': 4,
'type': 'bitvalue'},
'Tx2BiasHighAlarm':
{'offset':2,
'bit': 3,
'type': 'bitvalue'},
'Tx2BiasLowAlarm':
{'offset':2,
'bit': 2,
'type': 'bitvalue'},
'Tx2BiasHighWarning':
{'offset':2,
'bit': 1,
'type': 'bitvalue'},
'Tx2BiasLowWarning':
{'offset':2,
'bit': 0,
'type': 'bitvalue'},
'Tx3BiasHighAlarm':
{'offset':3,
'bit': 7,
'type': 'bitvalue'},
'Tx3BiasLowAlarm':
{'offset':3,
'bit': 6,
'type': 'bitvalue'},
'Tx3BiasHighWarning':
{'offset': 3,
'bit': 5,
'type': 'bitvalue'},
'Tx3BiasLowWarning':
{'offset': 3,
'bit': 4,
'type': 'bitvalue'},
'Tx4BiasHighAlarm':
{'offset': 3,
'bit': 3,
'type': 'bitvalue'},
'Tx4BiasLowAlarm':
{'offset': 3,
'bit': 2,
'type': 'bitvalue'},
'Tx4BiasHighWarning':
{'offset': 3,
'bit': 1,
'type': 'bitvalue'},
'Tx4BiasLowWarning':
{'offset': 3,
'bit': 0,
'type': 'bitvalue'}}

dom_threshold_map = {
'ChannelThresholdValues':
{'offset': 11,
'size': 2,
'type': 'nested',
'decode': dom_channel_threshold_values},
'ChannelMonitorMasks':
{'offset': 12,
'size': 2,
'type': 'nested',
'decode': dom_channel_monitor_masks},
'ModuleThresholdValues':
{'offset': 13,
'size': 2,
'type': 'nested',
'decode': dom_module_threshold_values}}

def __init__(self, eeprom_raw_data=None, calibration_type=1):
self._calibration_type = calibration_type
start_pos = 0
Expand Down Expand Up @@ -1218,6 +1449,18 @@ def parse_channel_monitor_params_with_tx_power(self, eeprom_raw_data, start_pos)
return sffbase.parse(self, self.dom_channel_monitor_params_with_tx_power, eeprom_raw_data,
start_pos)

def parse_module_threshold_values(self, eeprom_raw_data, start_pos):
return sffbase.parse(self, self.dom_module_threshold_values, eeprom_raw_data,
start_pos)

def parse_channel_threshold_values(self, eeprom_raw_data, start_pos):
return sffbase.parse(self, self.dom_channel_threshold_values, eeprom_raw_data,
start_pos)

def parse_channel_monitor_mask(self, eeprom_raw_data, start_pos):
return sffbase.parse(self, self.dom_channel_monitor_masks, eeprom_raw_data,
start_pos)

def dump_pretty(self):
if self.dom_data == None:
print('Object not initialized, nothing to print')
Expand All @@ -1229,3 +1472,4 @@ def get_data(self):

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

4 changes: 4 additions & 0 deletions sonic_sfp/sff8472.py
Original file line number Diff line number Diff line change
Expand Up @@ -1194,6 +1194,10 @@ 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_alarm_warning_threshold(self, eeprom_raw_data, start_pos):
return sffbase.parse(self, self.dom_aw_thresholds, eeprom_raw_data,
start_pos)

def dump_pretty(self):
if self.dom_data == None:
print('Object not initialized, nothing to print')
Expand Down
Loading