Skip to content

Commit

Permalink
[sfp-refactor] Add initial support for SFF-8636 in sonic_xcvr (#218)
Browse files Browse the repository at this point in the history
QSFP28 pluggable transceiver support based upon SFP refactor changes
  • Loading branch information
andywongarista authored Oct 7, 2021
1 parent 221fb8a commit 2ebd786
Show file tree
Hide file tree
Showing 12 changed files with 973 additions and 25 deletions.
59 changes: 52 additions & 7 deletions sonic_platform_base/sonic_xcvr/api/public/sff8436.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@ def get_transceiver_bulk_status(self):
return None

bulk_status = {
"rx_los": all(rx_los),
"tx_fault": all(tx_fault),
"rx_los": all(rx_los) if self.get_rx_los_support() else 'N/A',
"tx_fault": all(tx_fault) if self.get_tx_fault_support() else 'N/A',
"tx_disable": all(tx_disable),
"tx_disabled_channel": tx_disabled_channel,
"temperature": temp,
Expand All @@ -111,10 +111,10 @@ def get_transceiver_threshold_info(self):
'txbiaslowalarm', 'txbiaslowwarning'
]
threshold_info_dict = dict.fromkeys(threshold_info_keys, 'N/A')
flat_mem = self.is_flat_memory()
if flat_mem is None:
thresh_support = self.get_transceiver_thresholds_support()
if thresh_support is None:
return None
if flat_mem:
if not thresh_support:
return threshold_info_dict

temp_thresholds = self.xcvr_eeprom.read(consts.TEMP_THRESHOLDS_FIELD)
Expand Down Expand Up @@ -161,18 +161,33 @@ def get_rx_los(self):
return [bool(rx_los & (1 << i)) for i in range(self.NUM_CHANNELS)]

def get_tx_fault(self):
tx_fault_support = self.get_tx_fault_support()
if tx_fault_support is None:
return None
if not tx_fault_support:
return ["N/A" for _ in range(self.NUM_CHANNELS)]
tx_fault = self.xcvr_eeprom.read(consts.TX_FAULT_FIELD)
if tx_fault is None:
return None
return [bool(tx_fault & (1 << i)) for i in range(self.NUM_CHANNELS)]

def get_tx_disable(self):
tx_disable_support = self.get_tx_disable_support()
if tx_disable_support is None:
return None
if not tx_disable_support:
return ["N/A" for _ in range(self.NUM_CHANNELS)]
tx_disable = self.xcvr_eeprom.read(consts.TX_DISABLE_FIELD)
if tx_disable is None:
return None
return [bool(tx_disable & (1 << i)) for i in range(self.NUM_CHANNELS)]

def get_tx_disable_channel(self):
tx_disable_support = self.get_tx_disable_support()
if tx_disable_support is None:
return None
if not tx_disable_support:
return 'N/A'
return self.xcvr_eeprom.read(consts.TX_DISABLE_FIELD)

def get_module_temperature(self):
Expand Down Expand Up @@ -208,7 +223,7 @@ def tx_disable(self, tx_disable):

def tx_disable_channel(self, channel, disable):
channel_state = self.get_tx_disable_channel()
if channel_state is None:
if channel_state is None or channel_state == "N/A":
return False

for i in range(self.NUM_CHANNELS):
Expand All @@ -225,18 +240,24 @@ def tx_disable_channel(self, channel, disable):
def get_power_override(self):
return self.xcvr_eeprom.read(consts.POWER_OVERRIDE_FIELD)

def get_power_set(self):
return self.xcvr_eeprom.read(consts.POWER_SET_FIELD)

def set_power_override(self, power_override, power_set):
ret = self.xcvr_eeprom.write(consts.POWER_OVERRIDE_FIELD, power_override)
if power_override:
ret &= self.xcvr_eeprom.write(consts.POWER_SET_FIELD, power_set)
return ret
return ret

def is_flat_memory(self):
return self.xcvr_eeprom.read(consts.FLAT_MEM_FIELD)

def get_tx_power_support(self):
return False

def get_rx_power_support(self):
return True

def is_copper(self):
eth_compliance = self.xcvr_eeprom.read(consts.ETHERNET_10_40G_COMPLIANCE_FIELD)
if eth_compliance is None:
Expand All @@ -248,3 +269,27 @@ def get_temperature_support(self):

def get_voltage_support(self):
return True

def get_rx_los_support(self):
return True

def get_tx_bias_support(self):
return True

def get_tx_fault_support(self):
return self.xcvr_eeprom.read(consts.TX_FAULT_SUPPORT_FIELD)

def get_tx_disable_support(self):
return self.xcvr_eeprom.read(consts.TX_DISABLE_SUPPORT_FIELD)

def get_transceiver_thresholds_support(self):
return not self.is_flat_memory()

def get_lpmode_support(self):
power_class = self.xcvr_eeprom.read(consts.POWER_CLASS_FIELD)
if power_class is None:
return False
return "Power Class 1" not in power_class

def get_power_override_support(self):
return not self.is_copper()
Loading

0 comments on commit 2ebd786

Please sign in to comment.