From ce217c09b0eee6e484360087347fc6746de57c68 Mon Sep 17 00:00:00 2001 From: qinchuanares <37220227+qinchuanares@users.noreply.github.com> Date: Mon, 25 Apr 2022 12:02:39 -0700 Subject: [PATCH] Include changes from xcvr_api in transceiver_info table (#253) * include changes from xcvr_api in transceiver_info table * include new items in test_xcvrd.py * resolving comments, add four items related to c-cmis, and support both non-cmis and cmis compliant modules Co-authored-by: Chuan Qin (QINCHUAN) --- sonic-xcvrd/tests/test_xcvrd.py | 25 ++++++- sonic-xcvrd/xcvrd/xcvrd.py | 115 ++++++++++++++++++++++++++------ 2 files changed, 117 insertions(+), 23 deletions(-) diff --git a/sonic-xcvrd/tests/test_xcvrd.py b/sonic-xcvrd/tests/test_xcvrd.py index 619ef59c4593..d65a3bb89907 100644 --- a/sonic-xcvrd/tests/test_xcvrd.py +++ b/sonic-xcvrd/tests/test_xcvrd.py @@ -136,7 +136,30 @@ def test_post_port_dom_threshold_info_to_db(self): 'nominal_bit_rate': '0.7', 'application_advertisement': '0.7', 'is_replaceable': '0.7', - 'dom_capability': '0.7', })) + 'dom_capability': '0.7', + 'active_firmware': '1.1', + 'inactive_firmware': '1.0', + 'hardware_rev': '1.0', + 'media_interface_code': '0.1', + 'host_electrical_interface': '0.1', + 'host_lane_count': 8, + 'media_lane_count': 1, + 'host_lane_assignment_option': 1, + 'media_lane_assignment_option': 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': '1', + 'cmis_rev': '5.0', + 'supported_max_tx_power': 1.0, + 'supported_min_tx_power': -15.0, + 'supported_max_laser_freq': 196100, + 'supported_min_laser_freq': 191300})) def test_post_port_sfp_info_to_db(self): logical_port_name = "Ethernet0" port_mapping = PortMapping() diff --git a/sonic-xcvrd/xcvrd/xcvrd.py b/sonic-xcvrd/xcvrd/xcvrd.py index 12ef0be3af03..e5bc59abf38f 100644 --- a/sonic-xcvrd/xcvrd/xcvrd.py +++ b/sonic-xcvrd/xcvrd/xcvrd.py @@ -301,28 +301,99 @@ def post_port_sfp_info_to_db(logical_port_name, port_mapping, table, transceiver if port_info_dict is not None: is_replaceable = _wrapper_is_replaceable(physical_port) transceiver_dict[physical_port] = port_info_dict - fvs = swsscommon.FieldValuePairs( - [('type', port_info_dict['type']), - ('vendor_rev', port_info_dict['vendor_rev']), - ('serial', port_info_dict['serial']), - ('manufacturer', port_info_dict['manufacturer']), - ('model', port_info_dict['model']), - ('vendor_oui', port_info_dict['vendor_oui']), - ('vendor_date', port_info_dict['vendor_date']), - ('connector', port_info_dict['connector']), - ('encoding', port_info_dict['encoding']), - ('ext_identifier', port_info_dict['ext_identifier']), - ('ext_rateselect_compliance', port_info_dict['ext_rateselect_compliance']), - ('cable_type', port_info_dict['cable_type']), - ('cable_length', str(port_info_dict['cable_length'])), - ('specification_compliance', port_info_dict['specification_compliance']), - ('nominal_bit_rate', str(port_info_dict['nominal_bit_rate'])), - ('application_advertisement', port_info_dict['application_advertisement'] - if 'application_advertisement' in port_info_dict else 'N/A'), - ('is_replaceable', str(is_replaceable)), - ('dom_capability', port_info_dict['dom_capability'] - if 'dom_capability' in port_info_dict else 'N/A'), - ]) + # if cmis is supported by the module + if 'cmis_rev' in port_info_dict: + fvs = swsscommon.FieldValuePairs( + [('type', port_info_dict['type']), + ('vendor_rev', port_info_dict['vendor_rev']), + ('serial', port_info_dict['serial']), + ('manufacturer', port_info_dict['manufacturer']), + ('model', port_info_dict['model']), + ('vendor_oui', port_info_dict['vendor_oui']), + ('vendor_date', port_info_dict['vendor_date']), + ('connector', port_info_dict['connector']), + ('encoding', port_info_dict['encoding']), + ('ext_identifier', port_info_dict['ext_identifier']), + ('ext_rateselect_compliance', port_info_dict['ext_rateselect_compliance']), + ('cable_type', port_info_dict['cable_type']), + ('cable_length', str(port_info_dict['cable_length'])), + ('specification_compliance', port_info_dict['specification_compliance']), + ('nominal_bit_rate', str(port_info_dict['nominal_bit_rate'])), + ('application_advertisement', port_info_dict['application_advertisement'] + if 'application_advertisement' in port_info_dict else 'N/A'), + ('is_replaceable', str(is_replaceable)), + ('dom_capability', port_info_dict['dom_capability'] + if 'dom_capability' in port_info_dict else 'N/A'), + ('cmis_rev', port_info_dict['cmis_rev'] if 'cmis_rev' in port_info_dict else 'N/A'), + ('active_firmware', port_info_dict['active_firmware'] + if 'active_firmware' in port_info_dict else 'N/A'), + ('inactive_firmware', port_info_dict['inactive_firmware'] + if 'inactive_firmware' in port_info_dict else 'N/A'), + ('hardware_rev', port_info_dict['hardware_rev'] + if 'hardware_rev' in port_info_dict else 'N/A'), + ('media_interface_code', port_info_dict['media_interface_code'] + if 'media_interface_code' in port_info_dict else 'N/A'), + ('host_electrical_interface', port_info_dict['host_electrical_interface'] + if 'host_electrical_interface' in port_info_dict else 'N/A'), + ('host_lane_count', str(port_info_dict['host_lane_count']) + if 'host_lane_count' in port_info_dict else 'N/A'), + ('media_lane_count', str(port_info_dict['media_lane_count']) + if 'media_lane_count' in port_info_dict else 'N/A'), + ('host_lane_assignment_option', str(port_info_dict['host_lane_assignment_option']) + if 'host_lane_assignment_option' in port_info_dict else 'N/A'), + ('media_lane_assignment_option', str(port_info_dict['media_lane_assignment_option']) + if 'media_lane_assignment_option' in port_info_dict else 'N/A'), + ('active_apsel_hostlane1', str(port_info_dict['active_apsel_hostlane1']) + if 'active_apsel_hostlane1' in port_info_dict else 'N/A'), + ('active_apsel_hostlane2', str(port_info_dict['active_apsel_hostlane2']) + if 'active_apsel_hostlane2' in port_info_dict else 'N/A'), + ('active_apsel_hostlane3', str(port_info_dict['active_apsel_hostlane3']) + if 'active_apsel_hostlane3' in port_info_dict else 'N/A'), + ('active_apsel_hostlane4', str(port_info_dict['active_apsel_hostlane4']) + if 'active_apsel_hostlane4' in port_info_dict else 'N/A'), + ('active_apsel_hostlane5', str(port_info_dict['active_apsel_hostlane5']) + if 'active_apsel_hostlane5' in port_info_dict else 'N/A'), + ('active_apsel_hostlane6', str(port_info_dict['active_apsel_hostlane6']) + if 'active_apsel_hostlane6' in port_info_dict else 'N/A'), + ('active_apsel_hostlane7', str(port_info_dict['active_apsel_hostlane7']) + if 'active_apsel_hostlane7' in port_info_dict else 'N/A'), + ('active_apsel_hostlane8', str(port_info_dict['active_apsel_hostlane8']) + if 'active_apsel_hostlane8' in port_info_dict else 'N/A'), + ('media_interface_technology', port_info_dict['media_interface_technology'] + if 'media_interface_technology' in port_info_dict else 'N/A'), + ('supported_max_tx_power', str(port_info_dict['supported_max_tx_power']) + if 'supported_max_tx_power' in port_info_dict else 'N/A'), + ('supported_min_tx_power', str(port_info_dict['supported_min_tx_power']) + if 'supported_min_tx_power' in port_info_dict else 'N/A'), + ('supported_max_laser_freq', str(port_info_dict['supported_max_laser_freq']) + if 'supported_max_laser_freq' in port_info_dict else 'N/A'), + ('supported_min_laser_freq', str(port_info_dict['supported_min_laser_freq']) + if 'supported_min_laser_freq' in port_info_dict else 'N/A') + ]) + # else cmis is not supported by the module + else: + fvs = swsscommon.FieldValuePairs([ + ('type', port_info_dict['type']), + ('vendor_rev', port_info_dict['vendor_rev']), + ('serial', port_info_dict['serial']), + ('manufacturer', port_info_dict['manufacturer']), + ('model', port_info_dict['model']), + ('vendor_oui', port_info_dict['vendor_oui']), + ('vendor_date', port_info_dict['vendor_date']), + ('connector', port_info_dict['connector']), + ('encoding', port_info_dict['encoding']), + ('ext_identifier', port_info_dict['ext_identifier']), + ('ext_rateselect_compliance', port_info_dict['ext_rateselect_compliance']), + ('cable_type', port_info_dict['cable_type']), + ('cable_length', str(port_info_dict['cable_length'])), + ('specification_compliance', port_info_dict['specification_compliance']), + ('nominal_bit_rate', str(port_info_dict['nominal_bit_rate'])), + ('application_advertisement', port_info_dict['application_advertisement'] + if 'application_advertisement' in port_info_dict else 'N/A'), + ('is_replaceable', str(is_replaceable)), + ('dom_capability', port_info_dict['dom_capability'] + if 'dom_capability' in port_info_dict else 'N/A') + ]) table.set(port_name, fvs) else: return SFP_EEPROM_NOT_READY