Skip to content

Commit f45cff7

Browse files
Junchao-Mellanoxpdhruv-marvell
authored andcommitted
Fix issue: show interfaces transceiver eeprom -d should display same entry for CMIS cable (sonic-net#2864)
* Fix issue: show interfaces transceiver eeprom -d should display same entry for CMIS cable * Fix unit test issue
1 parent 5812025 commit f45cff7

File tree

5 files changed

+318
-30
lines changed

5 files changed

+318
-30
lines changed

scripts/sfpshow

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -345,9 +345,9 @@ class SFPShow(object):
345345
channel_threshold_align = 18
346346
module_threshold_align = 15
347347

348-
if sfp_type.startswith('QSFP'):
348+
if sfp_type.startswith('QSFP') or sfp_type.startswith('OSFP'):
349349
# Channel Monitor
350-
if sfp_type.startswith('QSFP-DD'):
350+
if sfp_type.startswith('QSFP-DD') or sfp_type.startswith('OSFP'):
351351
output_dom += (indent + 'ChannelMonitorValues:\n')
352352
sorted_key_table = natsorted(QSFP_DD_DOM_CHANNEL_MONITOR_MAP)
353353
output_channel = self.format_dict_value_to_string(
@@ -365,7 +365,7 @@ class SFPShow(object):
365365
output_dom += output_channel
366366

367367
# Channel Threshold
368-
if sfp_type.startswith('QSFP-DD'):
368+
if sfp_type.startswith('QSFP-DD') or sfp_type.startswith('OSFP'):
369369
dom_map = SFP_DOM_CHANNEL_THRESHOLD_MAP
370370
else:
371371
dom_map = QSFP_DOM_CHANNEL_THRESHOLD_MAP

sfputil/main.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -372,9 +372,9 @@ def convert_dom_to_output_string(sfp_type, dom_info_dict):
372372
channel_threshold_align = 18
373373
module_threshold_align = 15
374374

375-
if sfp_type.startswith('QSFP'):
375+
if sfp_type.startswith('QSFP') or sfp_type.startswith('OSFP'):
376376
# Channel Monitor
377-
if sfp_type.startswith('QSFP-DD'):
377+
if sfp_type.startswith('QSFP-DD') or sfp_type.startswith('OSFP'):
378378
output_dom += (indent + 'ChannelMonitorValues:\n')
379379
sorted_key_table = natsorted(QSFP_DD_DOM_CHANNEL_MONITOR_MAP)
380380
output_channel = format_dict_value_to_string(
@@ -392,7 +392,7 @@ def convert_dom_to_output_string(sfp_type, dom_info_dict):
392392
output_dom += output_channel
393393

394394
# Channel Threshold
395-
if sfp_type.startswith('QSFP-DD'):
395+
if sfp_type.startswith('QSFP-DD') or sfp_type.startswith('OSFP'):
396396
dom_map = SFP_DOM_CHANNEL_THRESHOLD_MAP
397397
else:
398398
dom_map = QSFP_DOM_CHANNEL_THRESHOLD_MAP

tests/mock_tables/state_db.json

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -691,6 +691,111 @@
691691
"supported_max_laser_freq" : "196100",
692692
"supported_min_laser_freq" : "191300"
693693
},
694+
"TRANSCEIVER_INFO|Ethernet72": {
695+
"active_apsel_hostlane4": "N/A",
696+
"active_firmware": "0.0",
697+
"is_replaceable": "True",
698+
"application_advertisement": "{1: {'host_electrical_interface_id': 'IB NDR', 'module_media_interface_id': 'Copper cable', 'media_lane_count': 4, 'host_lane_count': 4, 'host_lane_assignment_options': 17}, 2: {'host_electrical_interface_id': 'IB SDR (Arch.Spec.Vol.2)', 'module_media_interface_id': 'Copper cable', 'media_lane_count': 4, 'host_lane_count': 4, 'host_lane_assignment_options': 17}}",
699+
"host_electrical_interface": "N/A",
700+
"active_apsel_hostlane2": "N/A",
701+
"supported_min_tx_power": "N/A",
702+
"supported_max_tx_power": "N/A",
703+
"host_lane_assignment_option": "17",
704+
"specification_compliance": "passive_copper_media_interface",
705+
"ext_identifier": "Power Class 1 (0.25W Max)",
706+
"active_apsel_hostlane8": "N/A",
707+
"manufacturer": "vendor1 ",
708+
"cmis_rev": "5.0",
709+
"cable_type": "Length Cable Assembly(m)",
710+
"supported_min_laser_freq": "N/A",
711+
"serial": "serial1 ",
712+
"active_apsel_hostlane7": "N/A",
713+
"inactive_firmware": "N/A",
714+
"active_apsel_hostlane1": "N/A",
715+
"type": "OSFP 8X Pluggable Transceiver",
716+
"cable_length": "1.0",
717+
"active_apsel_hostlane5": "N/A",
718+
"media_lane_assignment_option": "N/A",
719+
"vendor_rev": "A3",
720+
"active_apsel_hostlane6": "N/A",
721+
"encoding": "N/A",
722+
"dom_capability": "N/A",
723+
"media_interface_technology": "Copper cable unequalized",
724+
"nominal_bit_rate": "0",
725+
"hardware_rev": "0.0",
726+
"media_lane_count": "0",
727+
"host_lane_count": "4",
728+
"vendor_oui": "some-oui",
729+
"connector": "No separable connector",
730+
"supported_max_laser_freq": "N/A",
731+
"media_interface_code": "Copper cable",
732+
"active_apsel_hostlane3": "N/A",
733+
"ext_rateselect_compliance": "N/A",
734+
"model": "some-model ",
735+
"vendor_date": "2022-05-28 "
736+
},
737+
"TRANSCEIVER_DOM_SENSOR|Ethernet72": {
738+
"rx_los": "N/A",
739+
"tx_fault": "N/A",
740+
"tx_disabled_channel": "N/A",
741+
"temperature": "40.5",
742+
"voltage": "3.331",
743+
"tx1disable": "N/A",
744+
"tx1bias": "6.5",
745+
"rx1power": "0.5",
746+
"tx1power": "0.6",
747+
"tx2disable": "N/A",
748+
"tx2bias": "6.5",
749+
"rx2power": "0.3",
750+
"tx2power": "0.4",
751+
"tx3disable": "N/A",
752+
"tx3bias": "6.6",
753+
"rx3power": "0.1",
754+
"tx3power": "0.2",
755+
"tx4disable": "N/A",
756+
"tx4bias": "6.7",
757+
"rx4power": "0.7",
758+
"tx4power": "0.8",
759+
"tx5disable": "N/A",
760+
"tx5bias": "6.4",
761+
"rx5power": "0.8",
762+
"tx5power": "0.9",
763+
"tx6disable": "N/A",
764+
"tx6bias": "6.3",
765+
"rx6power": "0.2",
766+
"tx6power": "0.1",
767+
"tx7disable": "N/A",
768+
"tx7bias": "6.2",
769+
"rx7power": "0.2",
770+
"tx7power": "0.5",
771+
"tx8disable": "N/A",
772+
"tx8bias": "6.1",
773+
"rx8power": "0.3",
774+
"tx8power": "0.4",
775+
"laser_temperature": "N/A"
776+
},
777+
"TRANSCEIVER_DOM_THRESHOLD|Ethernet72": {
778+
"temphighalarm": "N/A",
779+
"temphighwarning": "N/A",
780+
"templowalarm": "N/A",
781+
"templowwarning": "N/A",
782+
"vcchighalarm": "N/A",
783+
"vcchighwarning": "N/A",
784+
"vcclowalarm": "N/A",
785+
"vcclowwarning": "N/A",
786+
"rxpowerhighalarm": "N/A",
787+
"rxpowerhighwarning": "N/A",
788+
"rxpowerlowalarm": "N/A",
789+
"rxpowerlowwarning": "N/A",
790+
"txpowerhighalarm": "N/A",
791+
"txpowerhighwarning": "N/A",
792+
"txpowerlowalarm": "N/A",
793+
"txpowerlowwarning": "N/A",
794+
"txbiashighalarm": "N/A",
795+
"txbiashighwarning": "N/A",
796+
"txbiaslowalarm": "N/A",
797+
"txbiaslowwarning": "N/A"
798+
},
694799
"TRANSCEIVER_STATUS|Ethernet0": {
695800
"status": "67",
696801
"error": "Blocking Error|High temperature"

tests/sfp_test.py

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,75 @@
133133
VccLowWarning : 3.1304Volts
134134
"""
135135

136+
test_osfp_eeprom_with_dom_output = """\
137+
Ethernet72: SFP EEPROM detected
138+
Active Firmware: 0.0
139+
Active application selected code assigned to host lane 1: N/A
140+
Active application selected code assigned to host lane 2: N/A
141+
Active application selected code assigned to host lane 3: N/A
142+
Active application selected code assigned to host lane 4: N/A
143+
Active application selected code assigned to host lane 5: N/A
144+
Active application selected code assigned to host lane 6: N/A
145+
Active application selected code assigned to host lane 7: N/A
146+
Active application selected code assigned to host lane 8: N/A
147+
Application Advertisement: IB NDR - Host Assign (0x11) - Copper cable - Media Assign (Unknown)
148+
IB SDR (Arch.Spec.Vol.2) - Host Assign (0x11) - Copper cable - Media Assign (Unknown)
149+
CMIS Rev: 5.0
150+
Connector: No separable connector
151+
Encoding: N/A
152+
Extended Identifier: Power Class 1 (0.25W Max)
153+
Extended RateSelect Compliance: N/A
154+
Host Lane Count: 4
155+
Identifier: OSFP 8X Pluggable Transceiver
156+
Inactive Firmware: N/A
157+
Length Cable Assembly(m): 1.0
158+
Media Interface Technology: Copper cable unequalized
159+
Media Lane Count: 0
160+
Module Hardware Rev: 0.0
161+
Nominal Bit Rate(100Mbs): 0
162+
Specification compliance: passive_copper_media_interface
163+
Supported Max Laser Frequency: N/A
164+
Supported Max TX Power: N/A
165+
Supported Min Laser Frequency: N/A
166+
Supported Min TX Power: N/A
167+
Vendor Date Code(YYYY-MM-DD Lot): 2022-05-28
168+
Vendor Name: vendor1
169+
Vendor OUI: some-oui
170+
Vendor PN: some-model
171+
Vendor Rev: A3
172+
Vendor SN: serial1
173+
ChannelMonitorValues:
174+
RX1Power: 0.5dBm
175+
RX2Power: 0.3dBm
176+
RX3Power: 0.1dBm
177+
RX4Power: 0.7dBm
178+
RX5Power: 0.8dBm
179+
RX6Power: 0.2dBm
180+
RX7Power: 0.2dBm
181+
RX8Power: 0.3dBm
182+
TX1Bias: 6.5mA
183+
TX1Power: 0.6dBm
184+
TX2Bias: 6.5mA
185+
TX2Power: 0.4dBm
186+
TX3Bias: 6.6mA
187+
TX3Power: 0.2dBm
188+
TX4Bias: 6.7mA
189+
TX4Power: 0.8dBm
190+
TX5Bias: 6.4mA
191+
TX5Power: 0.9dBm
192+
TX6Bias: 6.3mA
193+
TX6Power: 0.1dBm
194+
TX7Bias: 6.2mA
195+
TX7Power: 0.5dBm
196+
TX8Bias: 6.1mA
197+
TX8Power: 0.4dBm
198+
ChannelThresholdValues:
199+
ModuleMonitorValues:
200+
Temperature: 40.5C
201+
Vcc: 3.331Volts
202+
ModuleThresholdValues:
203+
"""
204+
136205
test_sfp_eeprom_output = """\
137206
Ethernet0: SFP EEPROM detected
138207
Application Advertisement: N/A
@@ -826,6 +895,12 @@ def test_qsfp_dd_eeprom_with_dom(self):
826895
result = runner.invoke(show.cli.commands["interfaces"].commands["transceiver"].commands["eeprom"], ["Ethernet8", "-d"])
827896
assert result.exit_code == 0
828897
assert result.output == test_qsfp_dd_eeprom_with_dom_output
898+
899+
def test_osfp_eeprom_with_dom(self):
900+
runner = CliRunner()
901+
result = runner.invoke(show.cli.commands["interfaces"].commands["transceiver"].commands["eeprom"], ["Ethernet72", "-d"])
902+
assert result.exit_code == 0
903+
assert result.output == test_osfp_eeprom_with_dom_output
829904

830905
def test_sfp_eeprom(self):
831906
runner = CliRunner()

0 commit comments

Comments
 (0)