Skip to content

Commit

Permalink
Move tx_disable/tx_disabled_channel/rx_los/tx_fault to get_transceive…
Browse files Browse the repository at this point in the history
…r_status API (#359)

* Add tx_disable in get_transceiver_status API

* Remove tx_disable from bulk_status API

* Add status API for non-cmis

* Unify display format

* Add testcases non-CMIS
  • Loading branch information
longhuan-cisco authored May 31, 2023
1 parent 8c0398e commit 285a4dd
Show file tree
Hide file tree
Showing 11 changed files with 236 additions and 98 deletions.
3 changes: 0 additions & 3 deletions sonic_platform_base/sfp_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,9 +161,6 @@ def get_transceiver_bulk_status(self):
tx_fault |BOOLEAN |TX fault status, True if has TX fault, False if not.
reset_status |BOOLEAN |reset status, True if SFP in reset, False if not.
lp_mode |BOOLEAN |low power mode status, True in lp mode, False if not.
tx_disable |BOOLEAN |TX disable status, True TX disabled, False if not.
tx_disabled_channel |HEX |disabled TX channels in hex, bits 0 to 3 represent channel 0
| |to channel 3.
temperature |INT |module temperature in Celsius
voltage |INT |supply voltage in mV
tx<n>bias |INT |TX Bias Current in mA, n is the channel number,
Expand Down
2 changes: 1 addition & 1 deletion sonic_platform_base/sonic_xcvr/api/public/c_cmis.py
Original file line number Diff line number Diff line change
Expand Up @@ -644,7 +644,7 @@ def get_transceiver_status(self):
tuning_in_progress = BOOLEAN ; tuning in progress status
wavelength_unlock_status = BOOLEAN ; laser unlocked status
target_output_power_oor = BOOLEAN ; target output power out of range flag
fine_tuning_oor = BOOLEAN ; fine tuning out of range flag
fine_tuning_oor = BOOLEAN ; fine tuning out of range flag
tuning_not_accepted = BOOLEAN ; tuning not accepted flag
invalid_channel_num = BOOLEAN ; invalid channel number flag
tuning_complete = BOOLEAN ; tuning complete flag
Expand Down
23 changes: 10 additions & 13 deletions sonic_platform_base/sonic_xcvr/api/public/cmis.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,20 +187,12 @@ def get_transceiver_info_firmware_versions(self):
return [ActiveFirmware, InactiveFirmware]

def get_transceiver_bulk_status(self):
rx_los = self.get_rx_los()
tx_fault = self.get_tx_fault()
tx_disable = self.get_tx_disable()
tx_disabled_channel = self.get_tx_disable_channel()
temp = self.get_module_temperature()
voltage = self.get_voltage()
tx_bias = self.get_tx_bias()
rx_power = self.get_rx_power()
tx_power = self.get_tx_power()
read_failed = rx_los is None or \
tx_fault is None or \
tx_disable is None or \
tx_disabled_channel is None or \
temp is None or \
read_failed = temp is None or \
voltage is None or \
tx_bias is None or \
rx_power is None or \
Expand All @@ -209,15 +201,11 @@ def get_transceiver_bulk_status(self):
return None

bulk_status = {
"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_disabled_channel": tx_disabled_channel,
"temperature": temp,
"voltage": voltage
}

for i in range(1, self.NUM_CHANNELS + 1):
bulk_status["tx%ddisable" % i] = tx_disable[i-1] if self.get_tx_disable_support() else 'N/A'
bulk_status["tx%dbias" % i] = tx_bias[i - 1]
bulk_status["rx%dpower" % i] = float("{:.3f}".format(self.mw_to_dbm(rx_power[i - 1]))) if rx_power[i - 1] != 'N/A' else 'N/A'
bulk_status["tx%dpower" % i] = float("{:.3f}".format(self.mw_to_dbm(tx_power[i - 1]))) if tx_power[i - 1] != 'N/A' else 'N/A'
Expand Down Expand Up @@ -1659,6 +1647,8 @@ def get_transceiver_status(self):
rxoutput_status_hostlane6 = BOOLEAN ; rx output status on host lane 6
rxoutput_status_hostlane7 = BOOLEAN ; rx output status on host lane 7
rxoutput_status_hostlane8 = BOOLEAN ; rx output status on host lane 8
tx_disable = BOOLEAN ; tx disable status
tx_disabled_channel = INTEGER ; disabled TX channels
txfault = BOOLEAN ; tx fault flag on media lane
txlos_hostlane1 = BOOLEAN ; tx loss of signal flag on host lane 1
txlos_hostlane2 = BOOLEAN ; tx loss of signal flag on host lane 2
Expand Down Expand Up @@ -1777,6 +1767,13 @@ def get_transceiver_status(self):
if rx_output_status_dict:
for lane in range(1, self.NUM_CHANNELS+1):
trans_status['rxoutput_status_hostlane%d' % lane] = rx_output_status_dict.get('RxOutputStatus%d' % lane)
tx_disabled_channel = self.get_tx_disable_channel()
if tx_disabled_channel is not None:
trans_status['tx_disabled_channel'] = tx_disabled_channel
tx_disable = self.get_tx_disable()
if tx_disable is not None:
for lane in range(1, self.NUM_CHANNELS+1):
trans_status['tx%ddisable' % lane] = tx_disable[lane - 1]
tx_fault = self.get_tx_fault()
if tx_fault:
for lane in range(1, self.NUM_CHANNELS+1):
Expand Down
31 changes: 21 additions & 10 deletions sonic_platform_base/sonic_xcvr/api/public/sff8436.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,21 +68,36 @@ def get_transceiver_info(self):

return xcvr_info

def get_transceiver_bulk_status(self):
def get_transceiver_status(self):
rx_los = self.get_rx_los()
tx_fault = self.get_tx_fault()
tx_disable = self.get_tx_disable()
tx_disabled_channel = self.get_tx_disable_channel()
read_failed = rx_los is None or \
tx_fault is None or \
tx_disable is None or \
tx_disabled_channel is None
if read_failed:
return None

trans_status = dict()
for lane in range(1, len(rx_los) + 1):
trans_status['rxlos%d' % lane] = rx_los[lane - 1]
for lane in range(1, len(tx_fault) + 1):
trans_status['txfault%d' % lane] = tx_fault[lane - 1]
for lane in range(1, len(tx_disable) + 1):
trans_status['tx%ddisable' % lane] = tx_disable[lane - 1]
trans_status['tx_disabled_channel'] = tx_disabled_channel

return trans_status

def get_transceiver_bulk_status(self):
temp = self.get_module_temperature()
voltage = self.get_voltage()
tx_bias = self.get_tx_bias()
rx_power = self.get_rx_power()
tx_power = self.get_tx_power()
read_failed = rx_los is None or \
tx_fault is None or \
tx_disable is None or \
tx_disabled_channel is None or \
temp is None or \
read_failed = temp is None or \
voltage is None or \
tx_bias is None or \
rx_power is None or \
Expand All @@ -91,10 +106,6 @@ def get_transceiver_bulk_status(self):
return None

bulk_status = {
"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,
"voltage": voltage
}
Expand Down
31 changes: 21 additions & 10 deletions sonic_platform_base/sonic_xcvr/api/public/sff8472.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,21 +60,36 @@ def get_transceiver_info(self):

return xcvr_info

def get_transceiver_bulk_status(self):
def get_transceiver_status(self):
rx_los = self.get_rx_los()
tx_fault = self.get_tx_fault()
tx_disable = self.get_tx_disable()
tx_disabled_channel = self.get_tx_disable_channel()
read_failed = rx_los is None or \
tx_fault is None or \
tx_disable is None or \
tx_disabled_channel is None
if read_failed:
return None

trans_status = dict()
for lane in range(1, len(rx_los) + 1):
trans_status['rxlos%d' % lane] = rx_los[lane - 1]
for lane in range(1, len(tx_fault) + 1):
trans_status['txfault%d' % lane] = tx_fault[lane - 1]
for lane in range(1, len(tx_disable) + 1):
trans_status['tx%ddisable' % lane] = tx_disable[lane - 1]
trans_status['tx_disabled_channel'] = tx_disabled_channel

return trans_status

def get_transceiver_bulk_status(self):
temp = self.get_module_temperature()
voltage = self.get_voltage()
tx_bias = self.get_tx_bias()
rx_power = self.get_rx_power()
tx_power = self.get_tx_power()
read_failed = rx_los is None or \
tx_fault is None or \
tx_disable is None or \
tx_disabled_channel is None or \
temp is None or \
read_failed = temp is None or \
voltage is None or \
tx_bias is None or \
rx_power is None or \
Expand All @@ -83,10 +98,6 @@ def get_transceiver_bulk_status(self):
return None

bulk_status = {
"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,
"voltage": voltage
}
Expand Down
31 changes: 21 additions & 10 deletions sonic_platform_base/sonic_xcvr/api/public/sff8636.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,21 +75,36 @@ def get_transceiver_info(self):

return xcvr_info

def get_transceiver_bulk_status(self):
def get_transceiver_status(self):
rx_los = self.get_rx_los()
tx_fault = self.get_tx_fault()
tx_disable = self.get_tx_disable()
tx_disabled_channel = self.get_tx_disable_channel()
read_failed = rx_los is None or \
tx_fault is None or \
tx_disable is None or \
tx_disabled_channel is None
if read_failed:
return None

trans_status = dict()
for lane in range(1, len(rx_los) + 1):
trans_status['rxlos%d' % lane] = rx_los[lane - 1]
for lane in range(1, len(tx_fault) + 1):
trans_status['txfault%d' % lane] = tx_fault[lane - 1]
for lane in range(1, len(tx_disable) + 1):
trans_status['tx%ddisable' % lane] = tx_disable[lane - 1]
trans_status['tx_disabled_channel'] = tx_disabled_channel

return trans_status

def get_transceiver_bulk_status(self):
temp = self.get_module_temperature()
voltage = self.get_voltage()
tx_bias = self.get_tx_bias()
rx_power = self.get_rx_power()
tx_power = self.get_tx_power()
read_failed = rx_los is None or \
tx_fault is None or \
tx_disable is None or \
tx_disabled_channel is None or \
temp is None or \
read_failed = temp is None or \
voltage is None or \
tx_bias is None or \
rx_power is None or \
Expand All @@ -98,10 +113,6 @@ def get_transceiver_bulk_status(self):
return None

bulk_status = {
"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,
"voltage": voltage
}
Expand Down
7 changes: 1 addition & 6 deletions sonic_platform_base/sonic_xcvr/api/xcvr_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,6 @@ def get_transceiver_bulk_status(self):
========================================================================
keys |Value Format |Information
---------------------------|---------------|----------------------------
rx_los |bool |RX loss-of-signal status, True if has RX los, False if not.
tx_fault |bool |TX fault status, True if has TX fault, False if not.
tx_disable |bool |TX disable status, True TX disabled, False if not.
tx_disabled_channel |int |disabled TX channels in hex, bits 0 to 3 represent channel 0
| |to channel 3 (for example).
temperature |float |module temperature in Celsius
voltage |float |supply voltage in mV
tx<n>bias |float |TX Bias Current in mA, n is the channel number,
Expand Down Expand Up @@ -145,7 +140,7 @@ def get_transceiver_threshold_info(self):

def get_transceiver_status(self):
"""
Retrieves transceiver status of this SFP (applicable for CMIS/C-CMIS)
Retrieves transceiver status of this SFP
Returns:
A dict which may contain following keys/values (there could be more for C-CMIS) :
Expand Down
Loading

0 comments on commit 285a4dd

Please sign in to comment.