Skip to content

Commit

Permalink
Include changes from xcvr_api in transceiver_info table (sonic-net#253)
Browse files Browse the repository at this point in the history
* 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) <QINCHUAN@ame.gbl>
  • Loading branch information
qinchuanares and qinchuanares authored Apr 25, 2022
1 parent e0f8a35 commit ce217c0
Show file tree
Hide file tree
Showing 2 changed files with 117 additions and 23 deletions.
25 changes: 24 additions & 1 deletion sonic-xcvrd/tests/test_xcvrd.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
115 changes: 93 additions & 22 deletions sonic-xcvrd/xcvrd/xcvrd.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit ce217c0

Please sign in to comment.