Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add transceiver info CLI support to show output from TRANSCEIVER_INFO for ZR #2630

Merged
merged 8 commits into from
Feb 9, 2023
44 changes: 43 additions & 1 deletion doc/Command-Reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -927,7 +927,7 @@ This command displays information for all the interfaces for the transceiver req

- Usage:
```
show interfaces transceiver (eeprom [-d|--dom] | lpmode | presence | error-status [-hw|--fetch-from-hardware] | pm) [<interface_name>]
show interfaces transceiver (eeprom [-d|--dom] | info | lpmode | presence | error-status [-hw|--fetch-from-hardware] | pm) [<interface_name>]
```

- Example (Decode and display information stored on the EEPROM of SFP transceiver connected to Ethernet0):
Expand Down Expand Up @@ -965,6 +965,48 @@ This command displays information for all the interfaces for the transceiver req
Vcc : 0.0000Volts
```

- Example (Decode and display information stored on the EEPROM of SFP transceiver connected to Ethernet16):
```
admin@sonic:~$ show interfaces transceiver info Ethernet16
Ethernet16: SFP EEPROM detected
Active Firmware: 61.20
Active application selected code assigned to host lane 1: 1
Active application selected code assigned to host lane 2: 1
Active application selected code assigned to host lane 3: 1
Active application selected code assigned to host lane 4: 1
Active application selected code assigned to host lane 5: 1
Active application selected code assigned to host lane 6: 1
Active application selected code assigned to host lane 7: 1
Active application selected code assigned to host lane 8: 1
Application Advertisement: 400GAUI-8 C2M (Annex 120E) - Host Assign (0x1) - 400ZR, DWDM, amplified - Media Assign (0x1)
400GAUI-8 C2M (Annex 120E) - Host Assign (0x1) - 400ZR, Single Wavelength, Unamplified - Media Assign (0x1)
100GAUI-2 C2M (Annex 135G) - Host Assign (0x55) - 400ZR, DWDM, amplified - Media Assign (0x1)
CMIS Rev: 4.1
Connector: LC
Encoding: N/A
Extended Identifier: Power Class 8 (20.0W Max)
Extended RateSelect Compliance: N/A
Host Lane Count: 8
Identifier: QSFP-DD Double Density 8X Pluggable Transceiver
Inactive Firmware: 61.20
Length Cable Assembly(m): 0.0
Media Interface Technology: 1550 nm DFB
Media Lane Count: 1
Module Hardware Rev: 49.49
Nominal Bit Rate(100Mbs): 0
Specification Compliance: sm_media_interface
Supported Max Laser Frequency: 196100
Supported Max TX Power: 4.0
Supported Min Laser Frequency: 191300
Supported Min TX Power: -22.9
Vendor Date Code(YYYY-MM-DD Lot): 2020-21-02 17
Vendor Name: Acacia Comm Inc.
Vendor OUI: 7c-b2-5c
Vendor PN: DP04QSDD-E20-00E
Vendor Rev: 01
Vendor SN: 210753986
```

- Example (Display status of low-power mode of SFP transceiver connected to Ethernet100):
```
admin@sonic:~$ show interfaces transceiver lpmode Ethernet100
Expand Down
29 changes: 24 additions & 5 deletions scripts/sfpshow
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ from natsort import natsorted
from sonic_py_common.interface import front_panel_prefix, backplane_prefix, inband_prefix, recirc_prefix
from sonic_py_common import multi_asic
from utilities_common.sfp_helper import covert_application_advertisement_to_output_string
from utilities_common.sfp_helper import QSFP_DATA_MAP
from utilities_common.sfp_helper import QSFP_DATA_MAP, CMIS_DATA_MAP
from tabulate import tabulate

# Mock the redis DB for unit test purposes
Expand Down Expand Up @@ -284,14 +284,16 @@ class SFPShow(object):
def convert_sfp_info_to_output_string(self, sfp_info_dict):
indent = ' ' * 8
output = ''
is_sfp_cmis = 'cmis_rev' in sfp_info_dict

sorted_qsfp_data_map_keys = sorted(QSFP_DATA_MAP, key=QSFP_DATA_MAP.get)
for key in sorted_qsfp_data_map_keys:
data_map = CMIS_DATA_MAP if is_sfp_cmis else QSFP_DATA_MAP
sorted_data_map_keys = sorted(data_map, key=data_map.get)
for key in sorted_data_map_keys:
if key == 'cable_type':
output += '{}{}: {}\n'.format(indent, sfp_info_dict['cable_type'], sfp_info_dict['cable_length'])
elif key == 'cable_length':
pass
elif key == 'specification_compliance':
elif key == 'specification_compliance' and not(is_sfp_cmis):
if sfp_info_dict['type'] == "QSFP-DD Double Density 8X Pluggable Transceiver":
output += '{}{}: {}\n'.format(indent, QSFP_DATA_MAP[key], sfp_info_dict[key])
else:
Expand All @@ -308,7 +310,7 @@ class SFPShow(object):
elif key == 'application_advertisement':
output += covert_application_advertisement_to_output_string(indent, sfp_info_dict)
else:
output += '{}{}: {}\n'.format(indent, QSFP_DATA_MAP[key], sfp_info_dict[key])
output += '{}{}: {}\n'.format(indent, data_map[key], sfp_info_dict[key])

return output

Expand Down Expand Up @@ -587,6 +589,23 @@ def eeprom(port, dump_dom, namespace):
sfp.get_eeprom()
sfp.display_eeprom()

# 'info' subcommand

@cli.command()
@click.option('-p', '--port', metavar='<port_name>', help="Display SFP EEPROM data for port <port_name> only")
@click.option('-n', '--namespace', default=None, help="Display interfaces for specific namespace")
def info(port, namespace):
if port and multi_asic.is_multi_asic() and namespace is None:
try:
namespace = multi_asic.get_namespace_for_port(port)
except Exception:
display_invalid_intf_eeprom(port)
sys.exit(1)

sfp = SFPShow(port, namespace)
sfp.get_eeprom()
sfp.display_eeprom()

# 'presence' subcommand


Expand Down
22 changes: 22 additions & 0 deletions show/interfaces/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -469,6 +469,28 @@ def pm(interfacename, namespace, verbose):

clicommon.run_command(cmd, display_cmd=verbose)

@transceiver.command()
@click.argument('interfacename', required=False)
@click.option('--namespace', '-n', 'namespace', default=None, show_default=True,
type=click.Choice(multi_asic_util.multi_asic_ns_choices()), help='Namespace name or all')
@click.option('--verbose', is_flag=True, help="Enable verbose output")
def info(interfacename, namespace, verbose):
"""Show interface transceiver information"""

ctx = click.get_current_context()

cmd = "sfpshow info"

if interfacename is not None:
interfacename = try_convert_interfacename_from_alias(ctx, interfacename)

cmd += " -p {}".format(interfacename)

if namespace is not None:
cmd += " -n {}".format(namespace)

clicommon.run_command(cmd, display_cmd=verbose)

@transceiver.command()
@click.argument('interfacename', required=False)
@click.option('--verbose', is_flag=True, help="Enable verbose output")
Expand Down
37 changes: 37 additions & 0 deletions tests/mock_tables/asic0/state_db.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,43 @@
"vcclowalarm": "2.9700",
"vcclowwarning": "3.1349"
},
"TRANSCEIVER_INFO|Ethernet48": {
"type" : "QSFP-DD Double Density 8X Pluggable Transceiver",
"hardware_rev" : "1.1",
"serial" : "214455197",
"manufacturer" : "Acacia Comm Inc.",
"model" : "DP04QSDD-E20-001",
"connector" : "LC",
"encoding" : "N/A",
"ext_identifier" : "Power Class 8 (20.0W Max)",
"ext_rateselect_compliance" : "N/A",
"cable_type" : "Length Cable Assembly(m)",
"cable_length" : "0.0",
"nominal_bit_rate" : "0",
"specification_compliance" : "sm_media_interface",
"vendor_date" : "2021-11-19",
"vendor_oui" : "7c-b2-5c",
"application_advertisement" : "{1: {'host_electrical_interface_id': '400GAUI-8 C2M (Annex 120E)', 'module_media_interface_id': '400ZR, DWDM, amplified', 'media_lane_count': 1, 'host_lane_count': 8, 'host_lane_assignment_options': 1, 'media_lane_assignment_options': 1}, 2: {'host_electrical_interface_id': '400GAUI-8 C2M (Annex 120E)', 'module_media_interface_id': '400ZR, Single Wavelength, Unamplified', 'media_lane_count': 1, 'host_lane_count': 8, 'host_lane_assignment_options': 1, 'media_lane_assignment_options': 1}, 3: {'host_electrical_interface_id': '100GAUI-2 C2M (Annex 135G)', 'module_media_interface_id': '400ZR, DWDM, amplified', 'media_lane_count': 1, 'host_lane_count': 2, 'host_lane_assignment_options': 85, 'media_lane_assignment_options': 1}}",
"host_lane_count" : "8",
"media_lane_count" : "1",
"active_apsel_hostlane1" : "1",
"active_apsel_hostlane2" : "1",
"active_apsel_hostlane3" : "1",
"active_apsel_hostlane4" : "1",
"active_apsel_hostlane5" : "1",
"active_apsel_hostlane6" : "1",
"active_apsel_hostlane7" : "1",
"active_apsel_hostlane8" : "1",
"media_interface_technology" : "1550 nm DFB",
"vendor_rev" : "A",
"cmis_rev" : "4.1",
"active_firmware" : "61.20",
"inactive_firmware" : "161.10",
"supported_max_tx_power" : "4.0",
"supported_min_tx_power" : "-22.9",
"supported_max_laser_freq" : "196100",
"supported_min_laser_freq" : "191300"
},
"CHASSIS_INFO|chassis 1": {
"psu_num": "2"
},
Expand Down
51 changes: 35 additions & 16 deletions tests/mock_tables/asic1/state_db.json
Original file line number Diff line number Diff line change
@@ -1,21 +1,40 @@
{
"TRANSCEIVER_INFO|Ethernet64": {
"type": "QSFP28 or later",
"vendor_rev": "AC",
"serial": "MT1706FT02064",
"manufacturer": "Mellanox",
"model": "MFA1A00-C003",
"vendor_oui": "00-02-c9",
"vendor_date": "2017-01-13 ",
"connector": "No separable connector",
"encoding": "64B66B",
"ext_identifier": "Power Class 3(2.5W max), CDR present in Rx Tx",
"ext_rateselect_compliance": "QSFP+ Rate Select Version 1",
"cable_type": "Length Cable Assembly(m)",
"cable_length": "3",
"specification_compliance": "{'10/40G Ethernet Compliance Code': '40G Active Cable (XLPPI)'}",
"nominal_bit_rate": "255",
"application_advertisement": "N/A"
"type" : "QSFP-DD Double Density 8X Pluggable Transceiver",
"hardware_rev" : "X.X",
"serial" : "0123456789",
"manufacturer" : "XXXX",
"model" : "XXX",
"connector" : "LC",
"encoding" : "N/A",
"ext_identifier" : "Power Class 8 (20.0W Max)",
"ext_rateselect_compliance" : "N/A",
"cable_type" : "Length Cable Assembly(m)",
"cable_length" : "0.0",
"nominal_bit_rate" : "0",
"specification_compliance" : "sm_media_interface",
"vendor_date" : "2021-11-19",
"vendor_oui" : "XX-XX-XX",
"application_advertisement" : "{1: {'host_electrical_interface_id': '400GAUI-8 C2M (Annex 120E)', 'module_media_interface_id': '400ZR, DWDM, amplified', 'media_lane_count': 1, 'host_lane_count': 8, 'host_lane_assignment_options': 1, 'media_lane_assignment_options': 1}, 2: {'host_electrical_interface_id': '400GAUI-8 C2M (Annex 120E)', 'module_media_interface_id': '400ZR, Single Wavelength, Unamplified', 'media_lane_count': 1, 'host_lane_count': 8, 'host_lane_assignment_options': 1, 'media_lane_assignment_options': 1}, 3: {'host_electrical_interface_id': '100GAUI-2 C2M (Annex 135G)', 'module_media_interface_id': '400ZR, DWDM, amplified', 'media_lane_count': 1, 'host_lane_count': 2, 'host_lane_assignment_options': 85, 'media_lane_assignment_options': 1}}",
"host_lane_count" : "8",
"media_lane_count" : "1",
"active_apsel_hostlane1" : "1",
"active_apsel_hostlane2" : "1",
"active_apsel_hostlane3" : "1",
"active_apsel_hostlane4" : "1",
"active_apsel_hostlane5" : "1",
"active_apsel_hostlane6" : "1",
"active_apsel_hostlane7" : "1",
"active_apsel_hostlane8" : "1",
"media_interface_technology" : "1550 nm DFB",
"vendor_rev" : "XX",
"cmis_rev" : "4.1",
"active_firmware" : "X.X",
"inactive_firmware" : "X.X",
"supported_max_tx_power" : "4.0",
"supported_min_tx_power" : "-22.9",
"supported_max_laser_freq" : "196100",
"supported_min_laser_freq" : "191300"
},
"TRANSCEIVER_DOM_SENSOR|Ethernet64": {
"temperature": "30.9258",
Expand Down
37 changes: 37 additions & 0 deletions tests/mock_tables/state_db.json
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,43 @@
"rx_sig_power_min": "-40",
"rx_sig_power_max": "40"
},
"TRANSCEIVER_INFO|Ethernet64": {
"type" : "QSFP-DD Double Density 8X Pluggable Transceiver",
"hardware_rev" : "X.X",
"serial" : "0123456789",
"manufacturer" : "XXXX",
"model" : "XXX",
"connector" : "LC",
"encoding" : "N/A",
"ext_identifier" : "Power Class 8 (20.0W Max)",
"ext_rateselect_compliance" : "N/A",
"cable_type" : "Length Cable Assembly(m)",
"cable_length" : "0.0",
"nominal_bit_rate" : "0",
"specification_compliance" : "sm_media_interface",
"vendor_date" : "2021-11-19",
"vendor_oui" : "XX-XX-XX",
"application_advertisement" : "{1: {'host_electrical_interface_id': '400GAUI-8 C2M (Annex 120E)', 'module_media_interface_id': '400ZR, DWDM, amplified', 'media_lane_count': 1, 'host_lane_count': 8, 'host_lane_assignment_options': 1, 'media_lane_assignment_options': 1}, 2: {'host_electrical_interface_id': '400GAUI-8 C2M (Annex 120E)', 'module_media_interface_id': '400ZR, Single Wavelength, Unamplified', 'media_lane_count': 1, 'host_lane_count': 8, 'host_lane_assignment_options': 1, 'media_lane_assignment_options': 1}, 3: {'host_electrical_interface_id': '100GAUI-2 C2M (Annex 135G)', 'module_media_interface_id': '400ZR, DWDM, amplified', 'media_lane_count': 1, 'host_lane_count': 2, 'host_lane_assignment_options': 85, 'media_lane_assignment_options': 1}}",
"host_lane_count" : "8",
"media_lane_count" : "1",
"active_apsel_hostlane1" : "1",
"active_apsel_hostlane2" : "1",
"active_apsel_hostlane3" : "1",
"active_apsel_hostlane4" : "1",
"active_apsel_hostlane5" : "1",
"active_apsel_hostlane6" : "1",
"active_apsel_hostlane7" : "1",
"active_apsel_hostlane8" : "1",
"media_interface_technology" : "1550 nm DFB",
"vendor_rev" : "XX",
"cmis_rev" : "4.1",
"active_firmware" : "X.X",
"inactive_firmware" : "X.X",
"supported_max_tx_power" : "4.0",
"supported_min_tx_power" : "-22.9",
"supported_max_laser_freq" : "196100",
"supported_min_laser_freq" : "191300"
},
"TRANSCEIVER_STATUS|Ethernet0": {
"status": "67",
"error": "Blocking Error|High temperature"
Expand Down
24 changes: 12 additions & 12 deletions tests/multi_asic_intfutil_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,18 @@
scripts_path = os.path.join(modules_path, "scripts")

intf_status_all = """\
Interface Lanes Speed MTU FEC Alias Vlan Oper Admin Type Asym PFC
--------------- ------------ ------- ----- ----- -------------- --------------- ------ ------- --------------- ----------
Ethernet0 33,34,35,36 40G 9100 N/A Ethernet1/1 PortChannel1002 up up QSFP28 or later off
Ethernet4 29,30,31,32 40G 9100 N/A Ethernet1/2 PortChannel1002 up up N/A off
Ethernet64 29,30,31,32 40G 9100 N/A Ethernet1/17 routed up up QSFP28 or later off
Ethernet-BP0 93,94,95,96 40G 9100 N/A Ethernet-BP0 PortChannel4001 up up N/A off
Ethernet-BP4 97,98,99,100 40G 9100 N/A Ethernet-BP4 PortChannel4001 up up N/A off
Ethernet-BP256 61,62,63,64 40G 9100 N/A Ethernet-BP256 PortChannel4009 up up N/A off
Ethernet-BP260 57,58,59,60 40G 9100 N/A Ethernet-BP260 PortChannel4009 up up N/A off
PortChannel1002 N/A 80G 9100 N/A N/A trunk up up N/A N/A
PortChannel4001 N/A 80G 9100 N/A N/A routed up up N/A N/A
PortChannel4009 N/A 80G 9100 N/A N/A routed up up N/A N/A
Interface Lanes Speed MTU FEC Alias Vlan Oper Admin Type Asym PFC
--------------- ------------ ------- ----- ----- -------------- --------------- ------ ------- ----------------------------------------------- ----------
Ethernet0 33,34,35,36 40G 9100 N/A Ethernet1/1 PortChannel1002 up up QSFP28 or later off
Ethernet4 29,30,31,32 40G 9100 N/A Ethernet1/2 PortChannel1002 up up N/A off
Ethernet64 29,30,31,32 40G 9100 N/A Ethernet1/17 routed up up QSFP-DD Double Density 8X Pluggable Transceiver off
Ethernet-BP0 93,94,95,96 40G 9100 N/A Ethernet-BP0 PortChannel4001 up up N/A off
Ethernet-BP4 97,98,99,100 40G 9100 N/A Ethernet-BP4 PortChannel4001 up up N/A off
Ethernet-BP256 61,62,63,64 40G 9100 N/A Ethernet-BP256 PortChannel4009 up up N/A off
Ethernet-BP260 57,58,59,60 40G 9100 N/A Ethernet-BP260 PortChannel4009 up up N/A off
PortChannel1002 N/A 80G 9100 N/A N/A trunk up up N/A N/A
PortChannel4001 N/A 80G 9100 N/A N/A routed up up N/A N/A
PortChannel4009 N/A 80G 9100 N/A N/A routed up up N/A N/A
"""
intf_status = """\
Interface Lanes Speed MTU FEC Alias Vlan Oper Admin Type Asym PFC
Expand Down
Loading