Skip to content

Commit 285a4dd

Browse files
Move tx_disable/tx_disabled_channel/rx_los/tx_fault to get_transceiver_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
1 parent 8c0398e commit 285a4dd

File tree

11 files changed

+236
-98
lines changed

11 files changed

+236
-98
lines changed

sonic_platform_base/sfp_base.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -161,9 +161,6 @@ def get_transceiver_bulk_status(self):
161161
tx_fault |BOOLEAN |TX fault status, True if has TX fault, False if not.
162162
reset_status |BOOLEAN |reset status, True if SFP in reset, False if not.
163163
lp_mode |BOOLEAN |low power mode status, True in lp mode, False if not.
164-
tx_disable |BOOLEAN |TX disable status, True TX disabled, False if not.
165-
tx_disabled_channel |HEX |disabled TX channels in hex, bits 0 to 3 represent channel 0
166-
| |to channel 3.
167164
temperature |INT |module temperature in Celsius
168165
voltage |INT |supply voltage in mV
169166
tx<n>bias |INT |TX Bias Current in mA, n is the channel number,

sonic_platform_base/sonic_xcvr/api/public/c_cmis.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -644,7 +644,7 @@ def get_transceiver_status(self):
644644
tuning_in_progress = BOOLEAN ; tuning in progress status
645645
wavelength_unlock_status = BOOLEAN ; laser unlocked status
646646
target_output_power_oor = BOOLEAN ; target output power out of range flag
647-
fine_tuning_oor = BOOLEAN ; fine tuning out of range flag
647+
fine_tuning_oor = BOOLEAN ; fine tuning out of range flag
648648
tuning_not_accepted = BOOLEAN ; tuning not accepted flag
649649
invalid_channel_num = BOOLEAN ; invalid channel number flag
650650
tuning_complete = BOOLEAN ; tuning complete flag

sonic_platform_base/sonic_xcvr/api/public/cmis.py

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -187,20 +187,12 @@ def get_transceiver_info_firmware_versions(self):
187187
return [ActiveFirmware, InactiveFirmware]
188188

189189
def get_transceiver_bulk_status(self):
190-
rx_los = self.get_rx_los()
191-
tx_fault = self.get_tx_fault()
192-
tx_disable = self.get_tx_disable()
193-
tx_disabled_channel = self.get_tx_disable_channel()
194190
temp = self.get_module_temperature()
195191
voltage = self.get_voltage()
196192
tx_bias = self.get_tx_bias()
197193
rx_power = self.get_rx_power()
198194
tx_power = self.get_tx_power()
199-
read_failed = rx_los is None or \
200-
tx_fault is None or \
201-
tx_disable is None or \
202-
tx_disabled_channel is None or \
203-
temp is None or \
195+
read_failed = temp is None or \
204196
voltage is None or \
205197
tx_bias is None or \
206198
rx_power is None or \
@@ -209,15 +201,11 @@ def get_transceiver_bulk_status(self):
209201
return None
210202

211203
bulk_status = {
212-
"rx_los": all(rx_los) if self.get_rx_los_support() else 'N/A',
213-
"tx_fault": all(tx_fault) if self.get_tx_fault_support() else 'N/A',
214-
"tx_disabled_channel": tx_disabled_channel,
215204
"temperature": temp,
216205
"voltage": voltage
217206
}
218207

219208
for i in range(1, self.NUM_CHANNELS + 1):
220-
bulk_status["tx%ddisable" % i] = tx_disable[i-1] if self.get_tx_disable_support() else 'N/A'
221209
bulk_status["tx%dbias" % i] = tx_bias[i - 1]
222210
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'
223211
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'
@@ -1659,6 +1647,8 @@ def get_transceiver_status(self):
16591647
rxoutput_status_hostlane6 = BOOLEAN ; rx output status on host lane 6
16601648
rxoutput_status_hostlane7 = BOOLEAN ; rx output status on host lane 7
16611649
rxoutput_status_hostlane8 = BOOLEAN ; rx output status on host lane 8
1650+
tx_disable = BOOLEAN ; tx disable status
1651+
tx_disabled_channel = INTEGER ; disabled TX channels
16621652
txfault = BOOLEAN ; tx fault flag on media lane
16631653
txlos_hostlane1 = BOOLEAN ; tx loss of signal flag on host lane 1
16641654
txlos_hostlane2 = BOOLEAN ; tx loss of signal flag on host lane 2
@@ -1777,6 +1767,13 @@ def get_transceiver_status(self):
17771767
if rx_output_status_dict:
17781768
for lane in range(1, self.NUM_CHANNELS+1):
17791769
trans_status['rxoutput_status_hostlane%d' % lane] = rx_output_status_dict.get('RxOutputStatus%d' % lane)
1770+
tx_disabled_channel = self.get_tx_disable_channel()
1771+
if tx_disabled_channel is not None:
1772+
trans_status['tx_disabled_channel'] = tx_disabled_channel
1773+
tx_disable = self.get_tx_disable()
1774+
if tx_disable is not None:
1775+
for lane in range(1, self.NUM_CHANNELS+1):
1776+
trans_status['tx%ddisable' % lane] = tx_disable[lane - 1]
17801777
tx_fault = self.get_tx_fault()
17811778
if tx_fault:
17821779
for lane in range(1, self.NUM_CHANNELS+1):

sonic_platform_base/sonic_xcvr/api/public/sff8436.py

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -68,21 +68,36 @@ def get_transceiver_info(self):
6868

6969
return xcvr_info
7070

71-
def get_transceiver_bulk_status(self):
71+
def get_transceiver_status(self):
7272
rx_los = self.get_rx_los()
7373
tx_fault = self.get_tx_fault()
7474
tx_disable = self.get_tx_disable()
7575
tx_disabled_channel = self.get_tx_disable_channel()
76+
read_failed = rx_los is None or \
77+
tx_fault is None or \
78+
tx_disable is None or \
79+
tx_disabled_channel is None
80+
if read_failed:
81+
return None
82+
83+
trans_status = dict()
84+
for lane in range(1, len(rx_los) + 1):
85+
trans_status['rxlos%d' % lane] = rx_los[lane - 1]
86+
for lane in range(1, len(tx_fault) + 1):
87+
trans_status['txfault%d' % lane] = tx_fault[lane - 1]
88+
for lane in range(1, len(tx_disable) + 1):
89+
trans_status['tx%ddisable' % lane] = tx_disable[lane - 1]
90+
trans_status['tx_disabled_channel'] = tx_disabled_channel
91+
92+
return trans_status
93+
94+
def get_transceiver_bulk_status(self):
7695
temp = self.get_module_temperature()
7796
voltage = self.get_voltage()
7897
tx_bias = self.get_tx_bias()
7998
rx_power = self.get_rx_power()
8099
tx_power = self.get_tx_power()
81-
read_failed = rx_los is None or \
82-
tx_fault is None or \
83-
tx_disable is None or \
84-
tx_disabled_channel is None or \
85-
temp is None or \
100+
read_failed = temp is None or \
86101
voltage is None or \
87102
tx_bias is None or \
88103
rx_power is None or \
@@ -91,10 +106,6 @@ def get_transceiver_bulk_status(self):
91106
return None
92107

93108
bulk_status = {
94-
"rx_los": all(rx_los) if self.get_rx_los_support() else 'N/A',
95-
"tx_fault": all(tx_fault) if self.get_tx_fault_support() else 'N/A',
96-
"tx_disable": all(tx_disable),
97-
"tx_disabled_channel": tx_disabled_channel,
98109
"temperature": temp,
99110
"voltage": voltage
100111
}

sonic_platform_base/sonic_xcvr/api/public/sff8472.py

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -60,21 +60,36 @@ def get_transceiver_info(self):
6060

6161
return xcvr_info
6262

63-
def get_transceiver_bulk_status(self):
63+
def get_transceiver_status(self):
6464
rx_los = self.get_rx_los()
6565
tx_fault = self.get_tx_fault()
6666
tx_disable = self.get_tx_disable()
6767
tx_disabled_channel = self.get_tx_disable_channel()
68+
read_failed = rx_los is None or \
69+
tx_fault is None or \
70+
tx_disable is None or \
71+
tx_disabled_channel is None
72+
if read_failed:
73+
return None
74+
75+
trans_status = dict()
76+
for lane in range(1, len(rx_los) + 1):
77+
trans_status['rxlos%d' % lane] = rx_los[lane - 1]
78+
for lane in range(1, len(tx_fault) + 1):
79+
trans_status['txfault%d' % lane] = tx_fault[lane - 1]
80+
for lane in range(1, len(tx_disable) + 1):
81+
trans_status['tx%ddisable' % lane] = tx_disable[lane - 1]
82+
trans_status['tx_disabled_channel'] = tx_disabled_channel
83+
84+
return trans_status
85+
86+
def get_transceiver_bulk_status(self):
6887
temp = self.get_module_temperature()
6988
voltage = self.get_voltage()
7089
tx_bias = self.get_tx_bias()
7190
rx_power = self.get_rx_power()
7291
tx_power = self.get_tx_power()
73-
read_failed = rx_los is None or \
74-
tx_fault is None or \
75-
tx_disable is None or \
76-
tx_disabled_channel is None or \
77-
temp is None or \
92+
read_failed = temp is None or \
7893
voltage is None or \
7994
tx_bias is None or \
8095
rx_power is None or \
@@ -83,10 +98,6 @@ def get_transceiver_bulk_status(self):
8398
return None
8499

85100
bulk_status = {
86-
"rx_los": all(rx_los) if self.get_rx_los_support() else 'N/A',
87-
"tx_fault": all(tx_fault) if self.get_tx_fault_support() else 'N/A',
88-
"tx_disable": all(tx_disable),
89-
"tx_disabled_channel": tx_disabled_channel,
90101
"temperature": temp,
91102
"voltage": voltage
92103
}

sonic_platform_base/sonic_xcvr/api/public/sff8636.py

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -75,21 +75,36 @@ def get_transceiver_info(self):
7575

7676
return xcvr_info
7777

78-
def get_transceiver_bulk_status(self):
78+
def get_transceiver_status(self):
7979
rx_los = self.get_rx_los()
8080
tx_fault = self.get_tx_fault()
8181
tx_disable = self.get_tx_disable()
8282
tx_disabled_channel = self.get_tx_disable_channel()
83+
read_failed = rx_los is None or \
84+
tx_fault is None or \
85+
tx_disable is None or \
86+
tx_disabled_channel is None
87+
if read_failed:
88+
return None
89+
90+
trans_status = dict()
91+
for lane in range(1, len(rx_los) + 1):
92+
trans_status['rxlos%d' % lane] = rx_los[lane - 1]
93+
for lane in range(1, len(tx_fault) + 1):
94+
trans_status['txfault%d' % lane] = tx_fault[lane - 1]
95+
for lane in range(1, len(tx_disable) + 1):
96+
trans_status['tx%ddisable' % lane] = tx_disable[lane - 1]
97+
trans_status['tx_disabled_channel'] = tx_disabled_channel
98+
99+
return trans_status
100+
101+
def get_transceiver_bulk_status(self):
83102
temp = self.get_module_temperature()
84103
voltage = self.get_voltage()
85104
tx_bias = self.get_tx_bias()
86105
rx_power = self.get_rx_power()
87106
tx_power = self.get_tx_power()
88-
read_failed = rx_los is None or \
89-
tx_fault is None or \
90-
tx_disable is None or \
91-
tx_disabled_channel is None or \
92-
temp is None or \
107+
read_failed = temp is None or \
93108
voltage is None or \
94109
tx_bias is None or \
95110
rx_power is None or \
@@ -98,10 +113,6 @@ def get_transceiver_bulk_status(self):
98113
return None
99114

100115
bulk_status = {
101-
"rx_los": all(rx_los) if self.get_rx_los_support() else 'N/A',
102-
"tx_fault": all(tx_fault) if self.get_tx_fault_support() else 'N/A',
103-
"tx_disable": all(tx_disable),
104-
"tx_disabled_channel": tx_disabled_channel,
105116
"temperature": temp,
106117
"voltage": voltage
107118
}

sonic_platform_base/sonic_xcvr/api/xcvr_api.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -89,11 +89,6 @@ def get_transceiver_bulk_status(self):
8989
========================================================================
9090
keys |Value Format |Information
9191
---------------------------|---------------|----------------------------
92-
rx_los |bool |RX loss-of-signal status, True if has RX los, False if not.
93-
tx_fault |bool |TX fault status, True if has TX fault, False if not.
94-
tx_disable |bool |TX disable status, True TX disabled, False if not.
95-
tx_disabled_channel |int |disabled TX channels in hex, bits 0 to 3 represent channel 0
96-
| |to channel 3 (for example).
9792
temperature |float |module temperature in Celsius
9893
voltage |float |supply voltage in mV
9994
tx<n>bias |float |TX Bias Current in mA, n is the channel number,
@@ -145,7 +140,7 @@ def get_transceiver_threshold_info(self):
145140

146141
def get_transceiver_status(self):
147142
"""
148-
Retrieves transceiver status of this SFP (applicable for CMIS/C-CMIS)
143+
Retrieves transceiver status of this SFP
149144
150145
Returns:
151146
A dict which may contain following keys/values (there could be more for C-CMIS) :

0 commit comments

Comments
 (0)