From a56bc54bc416cb863453a84067be904c99d721b0 Mon Sep 17 00:00:00 2001 From: KroosMicas Date: Tue, 14 Jul 2026 00:26:52 +0800 Subject: [PATCH] add cpo els cli show Signed-off-by: duanchunming --- doc/Command-Reference.md | 403 +++++++++++++++++++++++++++++++++ scripts/sfpshow | 69 ++++++ sfputil/main.py | 82 ++++++- tests/sfp_test.py | 51 +++++ tests/sfputil_test.py | 46 ++++ utilities_common/sfp_helper.py | 32 ++- 6 files changed, 680 insertions(+), 3 deletions(-) diff --git a/doc/Command-Reference.md b/doc/Command-Reference.md index 29f34148457..354363b101d 100644 --- a/doc/Command-Reference.md +++ b/doc/Command-Reference.md @@ -1371,6 +1371,138 @@ Ethernet0: SFP EEPROM detected VccLowWarning : 3.15Volts ``` +- Example (Decode and display information stored on the EEPROM of CPO connected to Ethernet0): +``` +admin@sonic:~$ show interfaces transceiver eeprom -d Ethernet0 +Ethernet0: SFP EEPROM detected + Active Firmware: N/A + Active application selected code assigned to host lane 1: 6 + Active application selected code assigned to host lane 2: 6 + Active application selected code assigned to host lane 3: 6 + Active application selected code assigned to host lane 4: 6 + Active application selected code assigned to host lane 5: 6 + Active application selected code assigned to host lane 6: 6 + Active application selected code assigned to host lane 7: 6 + Active application selected code assigned to host lane 8: 6 + Application Advertisement: 400GAUI-4-L C2M (Annex 120G) - Host Assign (0x11) - 400G-FR4/400GBASE-FR4 (Cl 151) - Media Assign (0x11) + 200GAUI-4 C2M (Annex 120E) - Host Assign (0x11) - 200GBASE-FR4 (Cl 122) - Media Assign (0x11) + Bailly-Reserved-2 - Host Assign (0x11) - Bailly-Reserved-LC-2 - Media Assign (0x11) + CAUI-4 C2M (Annex 83E) with RS(528,514) FEC - Host Assign (0x11) - 100G CWDM4 MSA Spec - Media Assign (0x11) + Bailly-Reserved-1 - Host Assign (0x1) - Bailly-Reserved-LC-1 - Media Assign (0x1) + 800GAUI-8 L C2M (Annex 120G) - Host Assign (0x1) - Bailly-800G-2xFR4 - Media Assign (0x1) + CMIS Rev: 5.2 + Connector: LC + ELS Identifier: QSFP-DD Double Density 8X Pluggable Transceiver + ELS Laser Count: 8 + ELS Maximum Power Consumption: 12.0 + ELS Revision: 0.1 + ELS Vendor Date Code(YYYY-MM-DD Lot): 2024-06-28 + ELS Vendor Name: BROADCOM + ELS Vendor OUI: ec-01-e2 + ELS Vendor PN: ARLM-96F8DMZ + ELS Vendor Rev: A0 + ELS Vendor SN: FD2424VG006 + Encoding: N/A + Extended Identifier: Power Class 8 (20.0W Max) + Extended RateSelect Compliance: N/A + Host Lane Count: 8 + Identifier: CPO Bailly + Inactive Firmware: N/A + Length Cable Assembly(m): 0.0 + Media Interface Technology: Others + Media Lane Count: 8 + Module Hardware Rev: 0.0 + Nominal Bit Rate(100Mbs): N/A + RLM Laser Lpower Mode Control: 0 + RLM Laser Wavelength Grid: CWDM4 + Specification compliance: sm_media_interface + Vendor Date Code(YYYY-MM-DD Lot): 2024-09-14 + Vendor Name: BROADCOM + Vendor OUI: 38-ba-b0 + Vendor PN: BCM789096FBB0KLG + Vendor Rev: A0 + Vendor SN: SB243500200 + is_replaceable: False + type_abbrv_name: QSFP-DD + vdm_supported: False + ChannelMonitorValues: + RX1Power: 1.757dBm + RX2Power: 1.898dBm + RX3Power: 2.279dBm + RX4Power: 2.458dBm + RX5Power: 0.9dBm + RX6Power: 1.475dBm + RX7Power: 1.678dBm + RX8Power: 1.159dBm + TX1Bias: 79.6mA + TX1Power: 1.952dBm + TX2Bias: 57.22mA + TX2Power: 1.994dBm + TX3Bias: 68.8mA + TX3Power: 1.879dBm + TX4Bias: 63.024mA + TX4Power: 2.101dBm + TX5Bias: 79.6mA + TX5Power: 1.939dBm + TX6Bias: 57.22mA + TX6Power: 1.927dBm + TX7Bias: 68.8mA + TX7Power: 1.874dBm + TX8Bias: 63.024mA + TX8Power: 2.037dBm + ChannelThresholdValues: + RxPowerHighAlarm : 6.0dBm + RxPowerHighWarning: 4.003dBm + RxPowerLowAlarm : -11.203dBm + RxPowerLowWarning : -8.202dBm + TxBiasHighAlarm : 137.5mA + TxBiasHighWarning : 132.5mA + TxBiasLowAlarm : 5.0mA + TxBiasLowWarning : 7.5mA + TxPowerHighAlarm : 6.0dBm + TxPowerHighWarning: 4.0dBm + TxPowerLowAlarm : -7.201dBm + TxPowerLowWarning : -4.201dBm + ModuleMonitorValues: + Temperature: 81.363C + Vcc: 3.311Volts + ModuleThresholdValues: + TempHighAlarm : 90.0C + TempHighWarning: 85.0C + TempLowAlarm : 15.0C + TempLowWarning : 20.0C + VccHighAlarm : 3.465Volts + VccHighWarning : 3.399Volts + VccLowAlarm : 3.135Volts + VccLowWarning : 3.201Volts + ELSMonitorValues: + RLM0_Laser4_current: 252.38 mA + RLM0_Laser4_power: 72.290 mW 18.591 dBm + RLM0_Laser5_current: 275.49 mA + RLM0_Laser5_power: 76.700 mW 18.848 dBm + RLM0_Laser6_current: 228.96 mA + RLM0_Laser6_power: 66.600 mW 18.235 dBm + RLM0_Laser7_current: 318.41 mA + RLM0_Laser7_power: 88.060 mW 19.448 dBm + ELS Temperature: 25.027C + ELS Vcc: 3.365Volts + ELSThresholdValues: + ELS TempHighAlarm: 0.0C + ELS TempHighWarning: 0.0C + ELS TempLowAlarm: 0.0C + ELS TempLowWarning: 0.0C + ELS TxBiasHighAlarm: 0.0mA + ELS TxBiasHighWarning: 0.0mA + ELS TxPowerHighAlarm: 0.0mW + ELS TxPowerHighWarning: 0.0mW + ELS TxPowerLowAlarm: 0.0mW + ELS TxPowerLowWarning: 0.0mW + ELS VccHighAlarm: 0.0Volts + ELS VccHighWarning: 0.0Volts + ELS VccLowAlarm: 0.0Volts + ELS VccLowWarning: 0.0Volts +``` + - Example (Decode and display information stored on the EEPROM of SFP transceiver connected to Ethernet16): ``` admin@sonic:~$ show interfaces transceiver info Ethernet16 @@ -1413,6 +1545,62 @@ Ethernet0: SFP EEPROM detected Vendor SN: 210753986 ``` +- Example (Decode and display information stored on the EEPROM of CPO connected to Ethernet0): + ``` +admin@sonic:~$ show interfaces transceiver info Ethernet0 +Ethernet0: SFP EEPROM detected + Active Firmware: N/A + Active application selected code assigned to host lane 1: 6 + Active application selected code assigned to host lane 2: 6 + Active application selected code assigned to host lane 3: 6 + Active application selected code assigned to host lane 4: 6 + Active application selected code assigned to host lane 5: 6 + Active application selected code assigned to host lane 6: 6 + Active application selected code assigned to host lane 7: 6 + Active application selected code assigned to host lane 8: 6 + Application Advertisement: 400GAUI-4-L C2M (Annex 120G) - Host Assign (0x11) - 400G-FR4/400GBASE-FR4 (Cl 151) - Media Assign (0x11) + 200GAUI-4 C2M (Annex 120E) - Host Assign (0x11) - 200GBASE-FR4 (Cl 122) - Media Assign (0x11) + Bailly-Reserved-2 - Host Assign (0x11) - Bailly-Reserved-LC-2 - Media Assign (0x11) + CAUI-4 C2M (Annex 83E) with RS(528,514) FEC - Host Assign (0x11) - 100G CWDM4 MSA Spec - Media Assign (0x11) + Bailly-Reserved-1 - Host Assign (0x1) - Bailly-Reserved-LC-1 - Media Assign (0x1) + 800GAUI-8 L C2M (Annex 120G) - Host Assign (0x1) - Bailly-800G-2xFR4 - Media Assign (0x1) + CMIS Rev: 5.2 + Connector: LC + ELS Identifier: QSFP-DD Double Density 8X Pluggable Transceiver + ELS Laser Count: 8 + ELS Maximum Power Consumption: 12.0 + ELS Revision: 0.1 + ELS Vendor Date Code(YYYY-MM-DD Lot): 2024-06-28 + ELS Vendor Name: BROADCOM + ELS Vendor OUI: ec-01-e2 + ELS Vendor PN: ARLM-96F8DMZ + ELS Vendor Rev: A0 + ELS Vendor SN: FD2424VG006 + Encoding: N/A + Extended Identifier: Power Class 8 (20.0W Max) + Extended RateSelect Compliance: N/A + Host Lane Count: 8 + Identifier: CPO Bailly + Inactive Firmware: N/A + Length Cable Assembly(m): 0.0 + Media Interface Technology: Others + Media Lane Count: 8 + Module Hardware Rev: 0.0 + Nominal Bit Rate(100Mbs): N/A + RLM Laser Lpower Mode Control: 0 + RLM Laser Wavelength Grid: CWDM4 + Specification compliance: sm_media_interface + Vendor Date Code(YYYY-MM-DD Lot): 2024-09-14 + Vendor Name: BROADCOM + Vendor OUI: 38-ba-b0 + Vendor PN: BCM789096FBB0KLG + Vendor Rev: A0 + Vendor SN: SB243500200 + is_replaceable: False + type_abbrv_name: QSFP-DD + vdm_supported: False + ``` + - Example (Display status of low-power mode of SFP transceiver connected to Ethernet100): ``` admin@sonic:~$ show interfaces transceiver lpmode Ethernet100 @@ -1745,6 +1933,221 @@ Ethernet0: SFP EEPROM detected Rxtotpower low alarm flag: False ``` +- Example (Display status info of CPO connected to Ethernet0): + ``` +admin@sonic:~$ show interfaces transceiver status Ethernet0 +Ethernet0: + CMIS State (SW): READY + Tx fault flag on media lane 1: False + Tx fault flag on media lane 2: False + Tx fault flag on media lane 3: False + Tx fault flag on media lane 4: False + Tx fault flag on media lane 5: False + Tx fault flag on media lane 6: False + Tx fault flag on media lane 7: False + Tx fault flag on media lane 8: False + Rx loss of signal flag on media lane 1: False + Rx loss of signal flag on media lane 2: False + Rx loss of signal flag on media lane 3: False + Rx loss of signal flag on media lane 4: False + Rx loss of signal flag on media lane 5: False + Rx loss of signal flag on media lane 6: False + Rx loss of signal flag on media lane 7: False + Rx loss of signal flag on media lane 8: False + TX disable status on lane 1: False + TX disable status on lane 2: False + TX disable status on lane 3: False + TX disable status on lane 4: False + TX disable status on lane 5: False + TX disable status on lane 6: False + TX disable status on lane 7: False + TX disable status on lane 8: False + Disabled TX channels: 0 + Current module state: ModuleReady + Reason of entering the module fault state: No Fault detected + Datapath firmware fault: False + Module firmware fault: False + Module state changed: False + Data path state indicator on host lane 1: DataPathActivated + Data path state indicator on host lane 2: DataPathActivated + Data path state indicator on host lane 3: DataPathActivated + Data path state indicator on host lane 4: DataPathActivated + Data path state indicator on host lane 5: DataPathActivated + Data path state indicator on host lane 6: DataPathActivated + Data path state indicator on host lane 7: DataPathActivated + Data path state indicator on host lane 8: DataPathActivated + Tx output status on media lane 1: True + Tx output status on media lane 2: True + Tx output status on media lane 3: True + Tx output status on media lane 4: True + Tx output status on media lane 5: True + Tx output status on media lane 6: True + Tx output status on media lane 7: True + Tx output status on media lane 8: True + Rx output status on host lane 1: True + Rx output status on host lane 2: True + Rx output status on host lane 3: True + Rx output status on host lane 4: True + Rx output status on host lane 5: True + Rx output status on host lane 6: True + Rx output status on host lane 7: True + Rx output status on host lane 8: True + Tx loss of signal flag on host lane 1: False + Tx loss of signal flag on host lane 2: False + Tx loss of signal flag on host lane 3: False + Tx loss of signal flag on host lane 4: False + Tx loss of signal flag on host lane 5: False + Tx loss of signal flag on host lane 6: False + Tx loss of signal flag on host lane 7: False + Tx loss of signal flag on host lane 8: False + Tx clock and data recovery loss of lock on host lane 1: N/A + Tx clock and data recovery loss of lock on host lane 2: N/A + Tx clock and data recovery loss of lock on host lane 3: N/A + Tx clock and data recovery loss of lock on host lane 4: N/A + Tx clock and data recovery loss of lock on host lane 5: N/A + Tx clock and data recovery loss of lock on host lane 6: N/A + Tx clock and data recovery loss of lock on host lane 7: N/A + Tx clock and data recovery loss of lock on host lane 8: N/A + Rx clock and data recovery loss of lock on media lane 1: N/A + Rx clock and data recovery loss of lock on media lane 2: N/A + Rx clock and data recovery loss of lock on media lane 3: N/A + Rx clock and data recovery loss of lock on media lane 4: N/A + Rx clock and data recovery loss of lock on media lane 5: N/A + Rx clock and data recovery loss of lock on media lane 6: N/A + Rx clock and data recovery loss of lock on media lane 7: N/A + Rx clock and data recovery loss of lock on media lane 8: N/A + Configuration status for the data path of host line 1: ConfigSuccess + Configuration status for the data path of host line 2: ConfigSuccess + Configuration status for the data path of host line 3: ConfigSuccess + Configuration status for the data path of host line 4: ConfigSuccess + Configuration status for the data path of host line 5: ConfigSuccess + Configuration status for the data path of host line 6: ConfigSuccess + Configuration status for the data path of host line 7: ConfigSuccess + Configuration status for the data path of host line 8: ConfigSuccess + Data path configuration updated on host lane 1: True + Data path configuration updated on host lane 2: True + Data path configuration updated on host lane 3: True + Data path configuration updated on host lane 4: True + Data path configuration updated on host lane 5: True + Data path configuration updated on host lane 6: True + Data path configuration updated on host lane 7: True + Data path configuration updated on host lane 8: True + Temperature high alarm flag: False + Temperature high warning flag: False + Temperature low warning flag: False + Temperature low alarm flag: False + Vcc high alarm flag: False + Vcc high warning flag: False + Vcc low warning flag: False + Vcc low alarm flag: False + Tx power high alarm flag on lane 1: False + Tx power high alarm flag on lane 2: False + Tx power high alarm flag on lane 3: False + Tx power high alarm flag on lane 4: False + Tx power high alarm flag on lane 5: False + Tx power high alarm flag on lane 6: False + Tx power high alarm flag on lane 7: False + Tx power high alarm flag on lane 8: False + Tx power high warning flag on lane 1: False + Tx power high warning flag on lane 2: False + Tx power high warning flag on lane 3: False + Tx power high warning flag on lane 4: False + Tx power high warning flag on lane 5: False + Tx power high warning flag on lane 6: False + Tx power high warning flag on lane 7: False + Tx power high warning flag on lane 8: False + Tx power low warning flag on lane 1: False + Tx power low warning flag on lane 2: False + Tx power low warning flag on lane 3: False + Tx power low warning flag on lane 4: False + Tx power low warning flag on lane 5: False + Tx power low warning flag on lane 6: False + Tx power low warning flag on lane 7: False + Tx power low warning flag on lane 8: False + Tx power low alarm flag on lane 1: False + Tx power low alarm flag on lane 2: False + Tx power low alarm flag on lane 3: False + Tx power low alarm flag on lane 4: False + Tx power low alarm flag on lane 5: False + Tx power low alarm flag on lane 6: False + Tx power low alarm flag on lane 7: False + Tx power low alarm flag on lane 8: False + Rx power high alarm flag on lane 1: False + Rx power high alarm flag on lane 2: False + Rx power high alarm flag on lane 3: False + Rx power high alarm flag on lane 4: False + Rx power high alarm flag on lane 5: False + Rx power high alarm flag on lane 6: False + Rx power high alarm flag on lane 7: False + Rx power high alarm flag on lane 8: False + Rx power high warning flag on lane 1: False + Rx power high warning flag on lane 2: False + Rx power high warning flag on lane 3: False + Rx power high warning flag on lane 4: False + Rx power high warning flag on lane 5: False + Rx power high warning flag on lane 6: False + Rx power high warning flag on lane 7: False + Rx power high warning flag on lane 8: False + Rx power low warning flag on lane 1: False + Rx power low warning flag on lane 2: False + Rx power low warning flag on lane 3: False + Rx power low warning flag on lane 4: False + Rx power low warning flag on lane 5: False + Rx power low warning flag on lane 6: False + Rx power low warning flag on lane 7: False + Rx power low warning flag on lane 8: False + Rx power low alarm flag on lane 1: False + Rx power low alarm flag on lane 2: False + Rx power low alarm flag on lane 3: False + Rx power low alarm flag on lane 4: False + Rx power low alarm flag on lane 5: False + Rx power low alarm flag on lane 6: False + Rx power low alarm flag on lane 7: False + Rx power low alarm flag on lane 8: False + Tx bias high alarm flag on lane 1: False + Tx bias high alarm flag on lane 2: False + Tx bias high alarm flag on lane 3: False + Tx bias high alarm flag on lane 4: False + Tx bias high alarm flag on lane 5: False + Tx bias high alarm flag on lane 6: False + Tx bias high alarm flag on lane 7: False + Tx bias high alarm flag on lane 8: False + Tx bias high warning flag on lane 1: False + Tx bias high warning flag on lane 2: False + Tx bias high warning flag on lane 3: False + Tx bias high warning flag on lane 4: False + Tx bias high warning flag on lane 5: False + Tx bias high warning flag on lane 6: False + Tx bias high warning flag on lane 7: False + Tx bias high warning flag on lane 8: False + Tx bias low warning flag on lane 1: False + Tx bias low warning flag on lane 2: False + Tx bias low warning flag on lane 3: False + Tx bias low warning flag on lane 4: False + Tx bias low warning flag on lane 5: False + Tx bias low warning flag on lane 6: False + Tx bias low warning flag on lane 7: False + Tx bias low warning flag on lane 8: False + Tx bias low alarm flag on lane 1: False + Tx bias low alarm flag on lane 2: False + Tx bias low alarm flag on lane 3: False + Tx bias low alarm flag on lane 4: False + Tx bias low alarm flag on lane 5: False + Tx bias low alarm flag on lane 6: False + Tx bias low alarm flag on lane 7: False + Tx bias low alarm flag on lane 8: False + ELS temperature high alarm flag: False + ELS temperature low alarm flag: False + ELS temperature high warning flag: False + ELS temperature low warning flag: False + ELS Vcc high alarm flag: False + ELS Vcc low alarm flag: False + ELS Vcc high warning flag: False + ELS Vcc low warning flag: False + ELS module state: High power mode + ELS interrupt status: Interrupt event cleared + ``` + Go Back To [Beginning of the document](#) or [Beginning of this section](#basic-show-commands) ## AAA & TACACS+ diff --git a/scripts/sfpshow b/scripts/sfpshow index 05754e44deb..9bdc447bf5d 100755 --- a/scripts/sfpshow +++ b/scripts/sfpshow @@ -147,6 +147,28 @@ DOM_MODULE_MONITOR_MAP = { 'tx_config_power': 'Requested Tx Power' } +ELS_DOM_MONITOR_MAP = { + 'els_temperature': 'ELS Temperature', + 'els_voltage': 'ELS Vcc', +} + +ELS_THRESHOLD_MAP = { + 'els_temphighalarm': 'ELS TempHighAlarm', + 'els_templowalarm': 'ELS TempLowAlarm', + 'els_temphighwarning': 'ELS TempHighWarning', + 'els_templowwarning': 'ELS TempLowWarning', + 'els_vcchighalarm': 'ELS VccHighAlarm', + 'els_vcclowalarm': 'ELS VccLowAlarm', + 'els_vcchighwarning': 'ELS VccHighWarning', + 'els_vcclowwarning': 'ELS VccLowWarning', + 'els_txpowerhighalarm': 'ELS TxPowerHighAlarm', + 'els_txpowerlowalarm': 'ELS TxPowerLowAlarm', + 'els_txpowerhighwarning': 'ELS TxPowerHighWarning', + 'els_txpowerlowwarning': 'ELS TxPowerLowWarning', + 'els_txbiashighalarm': 'ELS TxBiasHighAlarm', + 'els_txbiashighwarning': 'ELS TxBiasHighWarning' +} + DOM_CHANNEL_THRESHOLD_UNIT_MAP = { 'txpowerhighalarm': 'dBm', 'txpowerlowalarm': 'dBm', @@ -173,6 +195,28 @@ DOM_MODULE_THRESHOLD_UNIT_MAP = { 'vcclowwarning': 'Volts' } +ELS_DOM_MONITOR_UNIT_MAP = { + 'els_temperature': 'C', + 'els_voltage': 'Volts', +} + +ELS_THRESHOLD_UNIT_MAP = { + 'els_temphighalarm': 'C', + 'els_templowalarm': 'C', + 'els_temphighwarning': 'C', + 'els_templowwarning': 'C', + 'els_vcchighalarm': 'Volts', + 'els_vcclowalarm': 'Volts', + 'els_vcchighwarning': 'Volts', + 'els_vcclowwarning': 'Volts', + 'els_txpowerhighalarm': 'mW', + 'els_txpowerlowalarm': 'mW', + 'els_txpowerhighwarning': 'mW', + 'els_txpowerlowwarning': 'mW', + 'els_txbiashighalarm': 'mA', + 'els_txbiashighwarning': 'mA' +} + DOM_VALUE_UNIT_MAP = { 'rx1power': 'dBm', 'rx2power': 'dBm', @@ -431,6 +475,31 @@ class SFPShow(object): module_threshold_align) output_dom += output_module_threshold + # This is specific for CPO DOM value parsing. + is_cpo = sfp_type.startswith('CPO') + if is_cpo: + laser_keys = [key for key in dom_info_dict if key.startswith('RLM') and 'Laser' in key] + dom_monitor_map = ELS_DOM_MONITOR_MAP.copy() + dom_monitor_map.update({key: key for key in laser_keys}) + dom_monitor_unit_map = ELS_DOM_MONITOR_UNIT_MAP.copy() + dom_monitor_unit_map.update({key: '' for key in laser_keys}) # laser monitor values include units + output_dom += (indent + 'ELSMonitorValues:\n') + sorted_key_table = natsorted(dom_monitor_map) + output_monitor = self.format_dict_value_to_string( + sorted_key_table, dom_info_dict, + dom_monitor_map, + dom_monitor_unit_map) + output_dom += output_monitor + + # Threshold + output_dom += (indent + 'ELSThresholdValues:\n') + sorted_key_table = natsorted(ELS_THRESHOLD_MAP) + output_threshold = self.format_dict_value_to_string( + sorted_key_table, dom_info_dict, + ELS_THRESHOLD_MAP, + ELS_THRESHOLD_UNIT_MAP) + output_dom += output_threshold + else: output_dom += (indent + 'MonitorData:\n') sorted_key_table = natsorted(SFP_DOM_CHANNEL_MONITOR_MAP) diff --git a/sfputil/main.py b/sfputil/main.py index 4a6687aeef9..f3041872b1e 100644 --- a/sfputil/main.py +++ b/sfputil/main.py @@ -111,7 +111,19 @@ 'supported_max_tx_power': 'Supported Max TX Power', 'supported_min_tx_power': 'Supported Min TX Power', 'supported_max_laser_freq': 'Supported Max Laser Frequency', - 'supported_min_laser_freq': 'Supported Min Laser Frequency' + 'supported_min_laser_freq': 'Supported Min Laser Frequency', + 'els_identifier': 'ELS Identifier', + 'els_revision': 'ELS Revision', + 'els_laser_count': 'ELS Laser Count', + 'els_vendor_name': 'ELS Vendor Name', + 'els_vendor_oui': 'ELS Vendor OUI', + 'els_vendor_pn': 'ELS Vendor PN', + 'els_vendor_rev': 'ELS Vendor Rev', + 'els_vendor_sn': 'ELS Vendor SN', + 'els_date_code': 'ELS Vendor Date Code(YYYY-MM-DD Lot)', + 'els_max_power': 'ELS Maximum Power Consumption', + 'rlm_laser_lpmode_control': 'RLM Laser Lpower Mode Control', + 'rlm_laser_wavelength_grid': 'RLM Laser Wavelength Grid', } SFP_DOM_CHANNEL_MONITOR_MAP = { @@ -204,6 +216,28 @@ 'voltage': 'Vcc' } +ELS_DOM_MONITOR_MAP = { + 'els_temperature': 'ELS Temperature', + 'els_voltage': 'ELS Vcc', +} + +ELS_THRESHOLD_MAP = { + 'els_temphighalarm': 'ELS TempHighAlarm', + 'els_templowalarm': 'ELS TempLowAlarm', + 'els_temphighwarning': 'ELS TempHighWarning', + 'els_templowwarning': 'ELS TempLowWarning', + 'els_vcchighalarm': 'ELS VccHighAlarm', + 'els_vcclowalarm': 'ELS VccLowAlarm', + 'els_vcchighwarning': 'ELS VccHighWarning', + 'els_vcclowwarning': 'ELS VccLowWarning', + 'els_txpowerhighalarm': 'ELS TxPowerHighAlarm', + 'els_txpowerlowalarm': 'ELS TxPowerLowAlarm', + 'els_txpowerhighwarning': 'ELS TxPowerHighWarning', + 'els_txpowerlowwarning': 'ELS TxPowerLowWarning', + 'els_txbiashighalarm': 'ELS TxBiasHighAlarm', + 'els_txbiashighwarning': 'ELS TxBiasHighWarning' +} + DOM_CHANNEL_THRESHOLD_UNIT_MAP = { 'txpowerhighalarm': 'dBm', 'txpowerlowalarm': 'dBm', @@ -230,6 +264,28 @@ 'vcclowwarning': 'Volts' } +ELS_DOM_MONITOR_UNIT_MAP = { + 'els_temperature': 'C', + 'els_voltage': 'Volts', +} + +ELS_THRESHOLD_UNIT_MAP = { + 'els_temphighalarm': 'C', + 'els_templowalarm': 'C', + 'els_temphighwarning': 'C', + 'els_templowwarning': 'C', + 'els_vcchighalarm': 'Volts', + 'els_vcclowalarm': 'Volts', + 'els_vcchighwarning': 'Volts', + 'els_vcclowwarning': 'Volts', + 'els_txpowerhighalarm': 'mW', + 'els_txpowerlowalarm': 'mW', + 'els_txpowerhighwarning': 'mW', + 'els_txpowerlowwarning': 'mW', + 'els_txbiashighalarm': 'mA', + 'els_txbiashighwarning': 'mA' +} + DOM_VALUE_UNIT_MAP = { 'rx1power': 'dBm', 'rx2power': 'dBm', @@ -453,6 +509,30 @@ def convert_dom_to_output_string(sfp_type, is_sfp_cmis, dom_info_dict): module_threshold_align) output_dom += output_module_threshold + # This is specific for CPO DOM value parsing. + is_cpo = sfp_type.startswith('CPO') + if is_cpo: + laser_keys = [key for key in dom_info_dict if key.startswith('RLM') and 'Laser' in key] + dom_monitor_map = ELS_DOM_MONITOR_MAP.copy() + dom_monitor_map.update({key: key for key in laser_keys}) + dom_monitor_unit_map = ELS_DOM_MONITOR_UNIT_MAP.copy() + dom_monitor_unit_map.update({key: '' for key in laser_keys}) # laser monitor values include units + output_dom += (indent + 'ELSMonitorValues:\n') + sorted_key_table = natsorted(dom_monitor_map) + output_els_monitor = format_dict_value_to_string( + sorted_key_table, dom_info_dict, + dom_monitor_map, + dom_monitor_unit_map) + output_dom += output_els_monitor + + # Threshold + output_dom += (indent + 'ELSThresholdValues:\n') + sorted_key_table = natsorted(ELS_THRESHOLD_MAP) + output_els_threshold = format_dict_value_to_string( + sorted_key_table, dom_info_dict, + ELS_THRESHOLD_MAP, + ELS_THRESHOLD_UNIT_MAP) + output_dom += output_els_threshold else: output_dom += (indent + 'MonitorData:\n') sorted_key_table = natsorted(SFP_DOM_CHANNEL_MONITOR_MAP) diff --git a/tests/sfp_test.py b/tests/sfp_test.py index 296ec831551..1117404f394 100644 --- a/tests/sfp_test.py +++ b/tests/sfp_test.py @@ -9,6 +9,7 @@ logical_port_name_to_physical_port_list, is_sfp_present, get_first_subport, get_subport, get_sfp_object, get_value_from_db_by_field ) +from .utils import load_source test_path = os.path.dirname(os.path.abspath(__file__)) modules_path = os.path.dirname(test_path) @@ -17,6 +18,7 @@ import show.main as show import show as show_module +sfpshow = load_source("sfpshow", os.path.join(scripts_path, "sfpshow")) ERROR_INVALID_PORT = 1 EXIT_FAIL = -1 @@ -898,6 +900,50 @@ Ethernet64: Transceiver status info not applicable """ +test_els_dom_info_dict = { + 'els_temperature': '16.16', + 'els_voltage': '3.396', + 'els_temphighalarm': '80.0', + 'els_templowalarm': '-5.0', + 'els_temphighwarning': '70.0', + 'els_templowwarning': '0.0', + 'els_vcchighalarm': '3.63', + 'els_vcclowalarm': '2.97', + 'els_vcchighwarning': '3.465', + 'els_vcclowwarning': '3.135', + 'els_txpowerhighalarm': '7.0', + 'els_txpowerlowalarm': '-6.9', + 'els_txpowerhighwarning': '4.0', + 'els_txpowerlowwarning': '-2.9', + 'els_txbiashighalarm': '162.5', + 'els_txbiashighwarning': '156.248', +} + +test_els_dom_output = """\ + ChannelMonitorValues: + ChannelThresholdValues: + ModuleMonitorValues: + ModuleThresholdValues: + ELSMonitorValues: + ELS Temperature: 16.16C + ELS Vcc: 3.396Volts + ELSThresholdValues: + ELS TempHighAlarm: 80.0C + ELS TempHighWarning: 70.0C + ELS TempLowAlarm: -5.0C + ELS TempLowWarning: 0.0C + ELS TxBiasHighAlarm: 162.5mA + ELS TxBiasHighWarning: 156.248mA + ELS TxPowerHighAlarm: 7.0mW + ELS TxPowerHighWarning: 4.0mW + ELS TxPowerLowAlarm: -6.9mW + ELS TxPowerLowWarning: -2.9mW + ELS VccHighAlarm: 3.63Volts + ELS VccHighWarning: 3.465Volts + ELS VccLowAlarm: 2.97Volts + ELS VccLowWarning: 3.135Volts +""" + class TestSFP(object): @classmethod def setup_class(cls): @@ -975,6 +1021,11 @@ def test_sfp_dpc_ports(self): assert result.exit_code == 0 assert "Ethernet24" not in result.output + def test_sfpshow_convert_dom_to_output_string_with_els(self): + sfp_show = sfpshow.SFPShow(None, None, dump_dom=True) + output = sfp_show.convert_dom_to_output_string("CPO", True, test_els_dom_info_dict) + assert output == test_els_dom_output + def test_sfp_eeprom_with_dom(self): runner = CliRunner() result = runner.invoke(show.cli.commands["interfaces"].commands["transceiver"].commands["eeprom"], ["Ethernet0", "-d"]) diff --git a/tests/sfputil_test.py b/tests/sfputil_test.py index 65e40767248..beaf0f03a27 100644 --- a/tests/sfputil_test.py +++ b/tests/sfputil_test.py @@ -411,6 +411,52 @@ def test_convert_sfp_info_to_output_string(self, sfp_info_dict, expected_output) Temperature: 41.7539C Vcc: 3.2577Volts ModuleThresholdValues: +''' + ), + ( + 'CPO', + True, + { + 'els_temperature': '16.16', + 'els_voltage': '3.396', + 'els_temphighalarm': '80.0', + 'els_templowalarm': '-5.0', + 'els_temphighwarning': '70.0', + 'els_templowwarning': '0.0', + 'els_vcchighalarm': '3.63', + 'els_vcclowalarm': '2.97', + 'els_vcchighwarning': '3.465', + 'els_vcclowwarning': '3.135', + 'els_txpowerhighalarm': '7.0', + 'els_txpowerlowalarm': '-6.9', + 'els_txpowerhighwarning': '4.0', + 'els_txpowerlowwarning': '-2.9', + 'els_txbiashighalarm': '162.5', + 'els_txbiashighwarning': '156.248', + }, + '''\ + ChannelMonitorValues: + ChannelThresholdValues: + ModuleMonitorValues: + ModuleThresholdValues: + ELSMonitorValues: + ELS Temperature: 16.16C + ELS Vcc: 3.396Volts + ELSThresholdValues: + ELS TempHighAlarm: 80.0C + ELS TempHighWarning: 70.0C + ELS TempLowAlarm: -5.0C + ELS TempLowWarning: 0.0C + ELS TxBiasHighAlarm: 162.5mA + ELS TxBiasHighWarning: 156.248mA + ELS TxPowerHighAlarm: 7.0mW + ELS TxPowerHighWarning: 4.0mW + ELS TxPowerLowAlarm: -6.9mW + ELS TxPowerLowWarning: -2.9mW + ELS VccHighAlarm: 3.63Volts + ELS VccHighWarning: 3.465Volts + ELS VccLowAlarm: 2.97Volts + ELS VccLowWarning: 3.135Volts ''' )]) def test_convert_dom_to_output_string(self, sfp_type, is_sfp_cmis, dom_info_dict, expected_output): diff --git a/utilities_common/sfp_helper.py b/utilities_common/sfp_helper.py index 3caeb605fab..401b6af6502 100644 --- a/utilities_common/sfp_helper.py +++ b/utilities_common/sfp_helper.py @@ -43,6 +43,24 @@ 'e2_server_firmware': 'E2 Server Firmware' } +ELSFP_DATA_MAP = { + 'els_identifier': 'ELS Identifier', + 'els_revision': 'ELS Revision', + 'els_laser_count': 'ELS Laser Count', + 'els_vendor_name': 'ELS Vendor Name', + 'els_vendor_oui': 'ELS Vendor OUI', + 'els_vendor_pn': 'ELS Vendor PN', + 'els_vendor_rev': 'ELS Vendor Rev', + 'els_vendor_sn': 'ELS Vendor SN', + 'els_date_code': 'ELS Vendor Date Code(YYYY-MM-DD Lot)', + 'els_max_power': 'ELS Maximum Power Consumption', +} + +BAILLY_RLM_DATA_MAP = { + 'rlm_laser_wavelength_grid': 'RLM Laser Wavelength Grid', + 'rlm_laser_lpmode_control': 'RLM Laser Lpower Mode Control' +} + C_CMIS_DELTA_DATA_MAP = { 'supported_max_tx_power': 'Supported Max TX Power', 'supported_min_tx_power': 'Supported Min TX Power', @@ -50,7 +68,7 @@ 'supported_min_laser_freq': 'Supported Min Laser Frequency', } -CMIS_DATA_MAP = {**QSFP_DATA_MAP, **QSFP_CMIS_DELTA_DATA_MAP} +CMIS_DATA_MAP = {**QSFP_DATA_MAP, **QSFP_CMIS_DELTA_DATA_MAP, **BAILLY_RLM_DATA_MAP, **ELSFP_DATA_MAP} C_CMIS_DATA_MAP = {**CMIS_DATA_MAP, **C_CMIS_DELTA_DATA_MAP} # Common fields for all types: @@ -271,7 +289,17 @@ 'postfecberhighalarm_flag': 'Postfec ber high alarm flag', 'postfecberhighwarning_flag': 'Postfec ber high warning flag', 'postfecberlowwarning_flag': 'Postfec ber low warning flag', - 'postfecberlowalarm_flag': 'Postfec ber low alarm flag' + 'postfecberlowalarm_flag': 'Postfec ber low alarm flag', + 'els_tempHAlarm': 'ELS temperature high alarm flag', + 'els_tempLAlarm': 'ELS temperature low alarm flag', + 'els_tempHWarn': 'ELS temperature high warning flag', + 'els_tempLWarn': 'ELS temperature low warning flag', + 'els_vccHAlarm': 'ELS Vcc high alarm flag', + 'els_vccLAlarm': 'ELS Vcc low alarm flag', + 'els_vccHWarn': 'ELS Vcc high warning flag', + 'els_vccLWarn': 'ELS Vcc low warning flag', + 'els_module_low_power_state': 'ELS module state', + 'els_interrupt_status': 'ELS interrupt status' } CMIS_VDM_TO_LEGACY_STATUS_MAP = {