Skip to content

Commit

Permalink
DellEMC: Fix Z9332f xcvrd crash (sonic-net#7544)
Browse files Browse the repository at this point in the history
  • Loading branch information
aravindmani-1 authored and Carl Keene committed Aug 7, 2021
1 parent 177cdd8 commit 2cea2f4
Showing 1 changed file with 41 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -499,7 +499,7 @@ def get_transceiver_info(self):
transceiver_info_dict['ext_identifier'] = ext_id
transceiver_info_dict['ext_rateselect_compliance'] = rate_identifier
transceiver_info_dict['cable_type'] = cable_type
transceiver_info_dict['cable_length'] = cable_length
transceiver_info_dict['cable_length'] = str(float(cable_length))
transceiver_info_dict['nominal_bit_rate'] = bit_rate
transceiver_info_dict['specification_compliance'] = str(compliance_code_dict)

Expand Down Expand Up @@ -643,8 +643,8 @@ def get_transceiver_threshold_info(self):
threshold_dict_keys, 'N/A')

try:
module_threshold_data = self._get_eeprom_data('ModuleThreshold')
if self.sfp_type == 'QSFP_DD':
module_threshold_data = self._get_eeprom_data('ModuleThreshold')
transceiver_dom_threshold_dict['temphighalarm'] = module_threshold_data['data']['TempHighAlarm']['value']
transceiver_dom_threshold_dict['temphighwarning'] = module_threshold_data['data']['TempHighWarning']['value']
transceiver_dom_threshold_dict['templowalarm'] = module_threshold_data['data']['TempLowAlarm']['value']
Expand All @@ -666,7 +666,6 @@ def get_transceiver_threshold_info(self):
transceiver_dom_threshold_dict['txpowerlowalarm'] = module_threshold_data['data']['TxPowerLowAlarm']['value']
transceiver_dom_threshold_dict['txpowerlowwarning'] = module_threshold_data['data']['TxPowerLowWarning']['value']
elif self.sfp_type == 'QSFP':
module_threshold_data = self._get_eeprom_data('ModuleThreshold')
transceiver_dom_threshold_dict['temphighalarm'] = module_threshold_data['data']['TempHighAlarm']['value']
transceiver_dom_threshold_dict['temphighwarning'] = module_threshold_data['data']['TempHighWarning']['value']
transceiver_dom_threshold_dict['templowalarm'] = module_threshold_data['data']['TempLowAlarm']['value']
Expand Down Expand Up @@ -766,12 +765,15 @@ def get_transceiver_bulk_status(self):
transceiver_dom_dict['tx7bias'] = tx_bias_list[6]
transceiver_dom_dict['tx8bias'] = tx_bias_list[7]

else:
elif self.sfp_type == 'QSFP':
if tx_bias_list is not None:
transceiver_dom_dict['tx1bias'] = tx_bias_list[0]
transceiver_dom_dict['tx2bias'] = tx_bias_list[1]
transceiver_dom_dict['tx3bias'] = tx_bias_list[2]
transceiver_dom_dict['tx4bias'] = tx_bias_list[3]
else:
if tx_bias_list is not None:
transceiver_dom_dict['tx1bias'] = tx_bias_list[0]

if self.sfp_type == 'QSFP_DD':
if rx_power_list is not None:
Expand All @@ -784,12 +786,15 @@ def get_transceiver_bulk_status(self):
transceiver_dom_dict['rx7power'] = rx_power_list[6]
transceiver_dom_dict['rx8power'] = rx_power_list[7]

else:
elif self.sfp_type == 'QSFP':
if rx_power_list is not None:
transceiver_dom_dict['rx1power'] = rx_power_list[0]
transceiver_dom_dict['rx2power'] = rx_power_list[1]
transceiver_dom_dict['rx3power'] = rx_power_list[2]
transceiver_dom_dict['rx4power'] = rx_power_list[3]
else:
if rx_power_list is not None:
transceiver_dom_dict['rx1power'] = rx_power_list[0]

if self.sfp_type == 'QSFP_DD':
if tx_power_list is not None:
Expand All @@ -801,13 +806,15 @@ def get_transceiver_bulk_status(self):
transceiver_dom_dict['tx6power'] = tx_power_list[5]
transceiver_dom_dict['tx7power'] = tx_power_list[6]
transceiver_dom_dict['tx8power'] = tx_power_list[7]
else:
elif self.sfp_type == 'QSFP':
if tx_power_list is not None:
transceiver_dom_dict['tx1power'] = tx_power_list[0]
transceiver_dom_dict['tx2power'] = tx_power_list[1]
transceiver_dom_dict['tx3power'] = tx_power_list[2]
transceiver_dom_dict['tx4power'] = tx_power_list[3]

else:
if tx_power_list is not None:
transceiver_dom_dict['tx1power'] = tx_power_list[0]
transceiver_dom_dict['rx_los'] = rx_los
transceiver_dom_dict['tx_fault'] = tx_fault
transceiver_dom_dict['reset_status'] = reset_state
Expand Down Expand Up @@ -932,10 +939,10 @@ def get_tx_fault(self):
tx_fault_list = []
try:
if self.sfp_type == 'QSFP_DD':
tx_fault_list = False
tx_fault_list.append(False)
elif self.sfp_type == 'QSFP':
tx_fault_data = self._get_eeprom_data('tx_fault')
for tx_fault_id in ('Tx1Fault', 'Tx2Fault', 'Tx3Fault', 'Tx4Fault') :
for tx_fault_id in ('Tx1Fault', 'Tx2Fault', 'Tx3Fault', 'Tx4Fault') :
tx_fault_list.append(tx_fault_data['data'][tx_fault_id]['value'] == 'On')
else:
tx_fault_data = self._read_eeprom_bytes(self.eeprom_path, SFP_STATUS_CONTROL_OFFSET, SFP_STATUS_CONTROL_WIDTH)
Expand Down Expand Up @@ -1022,7 +1029,7 @@ def get_temperature(self):
"""
Retrieves the temperature of this SFP
"""
temperature = None
temperature = 0.0
try:
if self.sfp_type == 'QSFP_DD':
if self.qsfp_dd_DomInfo is None:
Expand All @@ -1032,10 +1039,10 @@ def get_temperature(self):
return None
temperature_data = self.qsfp_dd_DomInfo.parse_temperature(dom_data_raw, 0)

elif self.sfp_type == 'QSFP':
else:
temperature_data = self._get_eeprom_data('Temperature')

temperature = self._strip_unit_from_str(temperature_data['data']['Temperature']['value'])
if temperature_data is not None:
temperature = self._strip_unit_from_str(temperature_data['data']['Temperature']['value'])
except (TypeError, ValueError):
return None
return temperature
Expand All @@ -1044,7 +1051,7 @@ def get_voltage(self):
"""
Retrieves the supply voltage of this SFP
"""
voltage = None
voltage = 0.0
try:
if self.sfp_type == 'QSFP_DD':
if self.qsfp_dd_DomInfo is None:
Expand All @@ -1054,11 +1061,10 @@ def get_voltage(self):
return None
voltage_data = self.qsfp_dd_DomInfo.parse_voltage(dom_data_raw, 0)

elif self.sfp_type == 'QSFP':
else:
voltage_data = self._get_eeprom_data('Voltage')

voltage = self._strip_unit_from_str(voltage_data['data']['Vcc']['value'])

if voltage_data is not None:
voltage = self._strip_unit_from_str(voltage_data['data']['Vcc']['value'])
except (TypeError, ValueError):
return None
return voltage
Expand Down Expand Up @@ -1089,8 +1095,12 @@ def get_tx_bias(self):
tx_bias = self._strip_unit_from_str(tx_bias_data['data'][tx_bias_id]['value'])
tx_bias_list.append(tx_bias)
else:
tx1_bias = self._strip_unit_from_str(tx_bias_data['data']['TXBias']['value'])
tx_bias_list.append(tx1_bias)
tx_bias_data = self._get_eeprom_data('ChannelMonitor')
if tx_bias_data is not None:
tx1_bias = self._strip_unit_from_str(tx_bias_data['data']['TXBias']['value'])
tx_bias_list.append(tx1_bias)
else:
tx_bias_list.append(0.0)

except (TypeError, ValueError):
return None
Expand All @@ -1101,13 +1111,14 @@ def get_rx_power(self):
Retrieves the received optical power for this SFP
"""
rx_power_list = []
offset = 128
try:
if self.sfp_type == 'QSFP_DD':
if self.qsfp_dd_DomInfo is None:
return None
if not self.dom_rx_power_supported:
return None

offset = 128
rx_power_data_raw = self._read_eeprom_bytes(self.eeprom_path, offset + QSFP_DD_RXPOWER_OFFSET, QSFP_DD_TXPOWER_WIDTH)
rx_power_data = self.qsfp_dd_DomInfo.parse_dom_rx_power(rx_power_data_raw, 0)

Expand All @@ -1122,7 +1133,11 @@ def get_rx_power(self):
rx_power = rx_power_data['data'][rx_power_id]['value']
rx_power_list.append(rx_power)
else:
rx1_pw = self._strip_unit_from_str(rx_power_data['data']['RXPower']['value'])
rx_power_data = self._get_eeprom_data('ChannelMonitor')
if rx_power_data is not None:
rx1_pw = self._strip_unit_from_str(rx_power_data['data']['RXPower']['value'])
else:
rx1_pw = 0.0
rx_power_list.append(rx1_pw)
except (TypeError, ValueError):
return None
Expand Down Expand Up @@ -1171,7 +1186,10 @@ def get_tx_power(self):
tx_power_list.append(tx_pw)
else:
channel_monitor_data = self._get_eeprom_data('ChannelMonitor')
tx1_pw = self._strip_unit_from_str(channel_monitor_data['data']['TXPower']['value'])
if channel_monitor_data is not None:
tx1_pw = self._strip_unit_from_str(channel_monitor_data['data']['TXPower']['value'])
else:
tx1_pw = 0.0
tx_power_list.append(tx1_pw)
except (TypeError, ValueError):
return None
Expand Down Expand Up @@ -1290,7 +1308,6 @@ def get_port_form_factor(self):
def get_max_port_power(self):
"""
Retrieves the maximum power allowed on the port in watts
***
This method of fetching power values is not ideal.
TODO: enhance by placing power limits in config file
Expand Down

0 comments on commit 2cea2f4

Please sign in to comment.