Skip to content

Commit

Permalink
Add parser support for Tx_RxLos,TxFault, PowerControl, ResetStatus in…
Browse files Browse the repository at this point in the history
… sff8436.py (sonic-net#45)
  • Loading branch information
sridhar-ravindran authored and jleveque committed Jul 29, 2019
1 parent d4cec20 commit 3bb3703
Show file tree
Hide file tree
Showing 3 changed files with 260 additions and 3 deletions.
55 changes: 54 additions & 1 deletion sonic_platform_base/sfp_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,60 @@ def get_transceiver_bulk_status(self):
========================================================================
"""
return NotImplementedError


def get_transceiver_threshold_info(self):
"""
Retrieves transceiver threshold info of this SFP
Returns:
A dict which contains following keys/values :
========================================================================
keys |Value Format |Information
---------------------------|---------------|----------------------------
Temperature High Alarm |FLOAT |High Alarm Threshold value,
| |of temperature in Celsius.
Temperature Low Alarm |FLOAT |Low Alarm Threshold value,
| |of temperature in Celsius.
Temperature High Warning |FLOAT |High Warning Threshold value,
| |of temperature in Celsius.
Temperature Low Warning |FLOAT |Low Warning Threshold value,
| |of temperature in Celsius.
Voltage High Alarm |FLOAT |High Alarm Threshold value,
| |of supply voltage in mV.
Voltage Low Alarm |FLOAT |Low Alarm Threshold value,
| |of supply voltage in mV.
Voltage High Warning |FLOAT |High Warning Threshold value,
| |of supply voltage in mV.
Voltage Low Warning |FLOAT |Low Warning Threshold value,
| |of supply voltage in mV.
Rx Power High Alarm |FLOAT |High Alarm Threshold value,
| |of received power in dBm.
Rx Power Low Alarm |FLOAT |Low Alarm Threshold value,
| |of received power in dBm.
Rx Power High Warning |FLOAT |High Warning Threshold value,
| |of received power in dBm.
Rx Power Low Warning |FLOAT |Low Warning Threshold value,
| |of received power in dBm.
Tx Power High Alarm |FLOAT |High Alarm Threshold value,
| |of transmit power in dBm.
Tx Power Low Alarm |FLOAT |Low Alarm Threshold value,
| |of transmit power in dBm.
Tx Power High Warning |FLOAT |High Warning Threshold value,
| |of transmit power in dBm.
Tx Power Low Warning |FLOAT |Low Warning Threshold value,
| |of transmit power in dBm.
Tx Bias High Alarm |FLOAT |High Alarm Threshold value,
| |of tx Bias Current in mA.
Tx Bias Low Alarm |FLOAT |Low Alarm Threshold value,
| |of tx Bias Current in mA.
Tx Bias High Warning |FLOAT |High Warning Threshold value,
| |of tx Bias Current in mA.
Tx Bias Low Warning |FLOAT |Low Warning Threshold value,
| |of tx Bias Current in mA.
========================================================================
"""
return NotImplementedError

def get_reset_status(self):
"""
Retrieves the reset status of SFP
Expand Down
104 changes: 103 additions & 1 deletion sonic_platform_base/sonic_sfp/sff8436.py
Original file line number Diff line number Diff line change
Expand Up @@ -764,7 +764,7 @@ def calc_rx_power(self, eeprom_data, offset, size):

dom_status_indicator = {
'DataNotReady':
{'offset': 2,
{'offset': 0,
'bit': 0,
'type': 'bitvalue'}}

Expand Down Expand Up @@ -818,6 +818,56 @@ def calc_rx_power(self, eeprom_data, offset, size):
'bit': 0,
'type': 'bitvalue'}}

dom_tx_rx_los = {'Tx4LOS':
{'offset': 0,
'bit': 7,
'type': 'bitvalue'},
'Tx3LOS':
{'offset': 0,
'bit': 6,
'type': 'bitvalue'},
'Tx2LOS':
{'offset': 0,
'bit': 5,
'type': 'bitvalue'},
'Tx1LOS':
{'offset': 0,
'bit': 4,
'type': 'bitvalue'},
'Rx4LOS':
{'offset': 0,
'bit': 3,
'type': 'bitvalue'},
'Rx3LOS':
{'offset': 0,
'bit': 2,
'type': 'bitvalue'},
'Rx2LOS':
{'offset': 0,
'bit': 1,
'type': 'bitvalue'},
'Rx1LOS':
{'offset': 0,
'bit': 0,
'type': 'bitvalue'}}

dom_tx_fault = {'Tx4Fault':
{'offset': 0,
'bit': 3,
'type': 'bitvalue'},
'Tx3Fault':
{'offset': 0,
'bit': 2,
'type': 'bitvalue'},
'Tx2Fault':
{'offset': 0,
'bit': 1,
'type': 'bitvalue'},
'Tx1Fault':
{'offset': 0,
'bit': 0,
'type': 'bitvalue'}}

dom_module_monitor = {
'TempHighAlarm':
{'offset': 6,
Expand Down Expand Up @@ -1409,6 +1459,34 @@ def calc_rx_power(self, eeprom_data, offset, size):
'bit': 0,
'type': 'bitvalue'}}

dom_tx_disable = {
'Tx4Disable':
{'offset':0,
'bit': 3,
'type': 'bitvalue'},
'Tx3Disable':
{'offset':0,
'bit': 2,
'type': 'bitvalue'},
'Tx2Disable':
{'offset':0,
'bit': 1,
'type': 'bitvalue'},
'Tx1Disable':
{'offset':0,
'bit': 0,
'type': 'bitvalue'}}

dom_power_control = {
'PowerSet':
{'offset': 0,
'bit': 1,
'type': 'bitvalue'},
'PowerOverRide':
{'offset': 0,
'bit': 0,
'type': 'bitvalue'}}

dom_threshold_map = {
'ChannelThresholdValues':
{'offset': 11,
Expand Down Expand Up @@ -1579,6 +1657,30 @@ def parse_option_params(self, eeprom_raw_data, start_pos):
return sffbase.parse(self, self.dom_option_value_masks, eeprom_raw_data,
start_pos)

def parse_dom_status_indicator(self, eeprom_raw_data, start_pos):
return sffbase.parse(self, self.dom_status_indicator, eeprom_raw_data,
start_pos)

def parse_dom_channel_status(self, eeprom_raw_data, start_pos):
return sffbase.parse(self, self.dom_channel_status, eeprom_raw_data,
start_pos)

def parse_dom_tx_rx_los(self, eeprom_raw_data, start_pos):
return sffbase.parse(self, self.dom_tx_rx_los, eeprom_raw_data,
start_pos)

def parse_dom_tx_fault(self, eeprom_raw_data, start_pos):
return sffbase.parse(self, self.dom_tx_fault, eeprom_raw_data,
start_pos)

def parse_dom_tx_disable (self, eeprom_raw_data, start_pos):
return sffbase.parse(self, self.dom_tx_disable, eeprom_raw_data,
start_pos)

def parse_dom_power_control(self, eeprom_raw_data, start_pos):
return sffbase.parse(self, self.dom_power_control, eeprom_raw_data,
start_pos)

def dump_pretty(self):
if self.dom_data == None:
print('Object not initialized, nothing to print')
Expand Down
104 changes: 103 additions & 1 deletion sonic_sfp/sff8436.py
Original file line number Diff line number Diff line change
Expand Up @@ -770,7 +770,7 @@ def calc_rx_power(self, eeprom_data, offset, size):

dom_status_indicator = {
'DataNotReady':
{'offset': 2,
{'offset': 0,
'bit': 0,
'type': 'bitvalue'}}

Expand Down Expand Up @@ -824,6 +824,56 @@ def calc_rx_power(self, eeprom_data, offset, size):
'bit': 0,
'type': 'bitvalue'}}

dom_tx_rx_los = {'Tx4LOS':
{'offset': 0,
'bit': 7,
'type': 'bitvalue'},
'Tx3LOS':
{'offset': 0,
'bit': 6,
'type': 'bitvalue'},
'Tx2LOS':
{'offset': 0,
'bit': 5,
'type': 'bitvalue'},
'Tx1LOS':
{'offset': 0,
'bit': 4,
'type': 'bitvalue'},
'Rx4LOS':
{'offset': 0,
'bit': 3,
'type': 'bitvalue'},
'Rx3LOS':
{'offset': 0,
'bit': 2,
'type': 'bitvalue'},
'Rx2LOS':
{'offset': 0,
'bit': 1,
'type': 'bitvalue'},
'Rx1LOS':
{'offset': 0,
'bit': 0,
'type': 'bitvalue'}}

dom_tx_fault = {'Tx4Fault':
{'offset': 0,
'bit': 3,
'type': 'bitvalue'},
'Tx3Fault':
{'offset': 0,
'bit': 2,
'type': 'bitvalue'},
'Tx2Fault':
{'offset': 0,
'bit': 1,
'type': 'bitvalue'},
'Tx1Fault':
{'offset': 0,
'bit': 0,
'type': 'bitvalue'}}

dom_module_monitor = {
'TempHighAlarm':
{'offset': 6,
Expand Down Expand Up @@ -1415,6 +1465,34 @@ def calc_rx_power(self, eeprom_data, offset, size):
'bit': 0,
'type': 'bitvalue'}}

dom_tx_disable = {
'Tx4Disable':
{'offset':0,
'bit': 3,
'type': 'bitvalue'},
'Tx3Disable':
{'offset':0,
'bit': 2,
'type': 'bitvalue'},
'Tx2Disable':
{'offset':0,
'bit': 1,
'type': 'bitvalue'},
'Tx1Disable':
{'offset':0,
'bit': 0,
'type': 'bitvalue'}}

dom_power_control = {
'PowerSet':
{'offset': 0,
'bit': 1,
'type': 'bitvalue'},
'PowerOverRide':
{'offset': 0,
'bit': 0,
'type': 'bitvalue'}}

dom_threshold_map = {
'ChannelThresholdValues':
{'offset': 11,
Expand Down Expand Up @@ -1585,6 +1663,30 @@ def parse_option_params(self, eeprom_raw_data, start_pos):
return sffbase.parse(self, self.dom_option_value_masks, eeprom_raw_data,
start_pos)

def parse_dom_status_indicator(self, eeprom_raw_data, start_pos):
return sffbase.parse(self, self.dom_status_indicator, eeprom_raw_data,
start_pos)

def parse_dom_channel_status(self, eeprom_raw_data, start_pos):
return sffbase.parse(self, self.dom_channel_status, eeprom_raw_data,
start_pos)

def parse_dom_tx_rx_los(self, eeprom_raw_data, start_pos):
return sffbase.parse(self, self.dom_tx_rx_los, eeprom_raw_data,
start_pos)

def parse_dom_tx_fault(self, eeprom_raw_data, start_pos):
return sffbase.parse(self, self.dom_tx_fault, eeprom_raw_data,
start_pos)

def parse_dom_tx_disable (self, eeprom_raw_data, start_pos):
return sffbase.parse(self, self.dom_tx_disable, eeprom_raw_data,
start_pos)

def parse_dom_power_control(self, eeprom_raw_data, start_pos):
return sffbase.parse(self, self.dom_power_control, eeprom_raw_data,
start_pos)

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

0 comments on commit 3bb3703

Please sign in to comment.