Skip to content

Commit

Permalink
Add cmis_xcvr_info_dict global dictionary with default N/A values for…
Browse files Browse the repository at this point in the history
… all fields
  • Loading branch information
vvolam committed Feb 24, 2025
1 parent 8dac755 commit 4fc7a86
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 47 deletions.
96 changes: 61 additions & 35 deletions sonic_platform_base/sonic_xcvr/api/public/cmis.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,49 @@ class CmisApi(XcvrApi):
LowPwrRequestSW = 4
LowPwrAllowRequestHW = 6

cmis_xcvr_info_dict = {
"type": "N/A",
"type_abbrv_name": "N/A",
"hardware_rev": "N/A",
"serial": "N/A",
"manufacturer": "N/A",
"model": "N/A",
"connector": "N/A",
"encoding": "N/A",
"ext_identifier": "N/A",
"ext_rateselect_compliance": "N/A",
"cable_length": 0.0,
"nominal_bit_rate": 0,
"vendor_date": "N/A",
"vendor_oui": "N/A",
"is_replaceable": "N/A",
"dom_capability": "N/A",
"active_apsel_hostlane1": "N/A",
"active_apsel_hostlane2": "N/A",
"active_apsel_hostlane3": "N/A",
"active_apsel_hostlane4": "N/A",
"active_apsel_hostlane5": "N/A",
"active_apsel_hostlane6": "N/A",
"active_apsel_hostlane7": "N/A",
"active_apsel_hostlane8": "N/A",
"supported_max_tx_power": "N/A",
"supported_min_tx_power": "N/A",
"supported_max_laser_freq": "N/A",
"supported_min_laser_freq": "N/A",
"application_advertisement": "N/A",
"host_electrical_interface": "N/A",
"media_interface_code": "N/A",
"host_lane_count": 0,
"media_lane_count": "N/A",
"host_lane_assignment_option": "N/A",
"media_lane_assignment_option": "N/A",
"cable_type": "N/A",
"media_interface_technology": "N/A",
"vendor_rev": 0.0,
"cmis_rev": 0.0,
"specification_compliance": "N/A"
}

def __init__(self, xcvr_eeprom):
super(CmisApi, self).__init__(xcvr_eeprom)
self.vdm = CmisVdmApi(xcvr_eeprom) if not self.is_flat_memory() else None
Expand Down Expand Up @@ -268,63 +311,46 @@ def get_transceiver_info(self):
power_class = ext_id[consts.POWER_CLASS_FIELD]
max_power = ext_id[consts.MAX_POWER_FIELD]

xcvr_info = {
self.cmis_xcvr_info_dict.update({
"type": admin_info[consts.ID_FIELD],
"type_abbrv_name": admin_info[consts.ID_ABBRV_FIELD],
"hardware_rev": self.get_module_hardware_revision(),
"serial": admin_info[consts.VENDOR_SERIAL_NO_FIELD],
"manufacturer": admin_info[consts.VENDOR_NAME_FIELD],
"model": admin_info[consts.VENDOR_PART_NO_FIELD],
"connector": admin_info[consts.CONNECTOR_FIELD],
"encoding": "N/A", # Not supported
"ext_identifier": "%s (%sW Max)" % (power_class, max_power),
"ext_rateselect_compliance": "N/A", # Not supported
"cable_length": float(admin_info[consts.LENGTH_ASSEMBLY_FIELD]),
"nominal_bit_rate": 0, # Not supported
"vendor_date": admin_info[consts.VENDOR_DATE_FIELD],
"vendor_oui": admin_info[consts.VENDOR_OUI_FIELD],
"is_replaceable": "N/A", # Not supported
"dom_capability": "N/A", # Not supported
"active_apsel_hostlane1": "N/A", # Not supported
"active_apsel_hostlane2": "N/A", # Not supported
"active_apsel_hostlane3": "N/A", # Not supported
"active_apsel_hostlane4": "N/A", # Not supported
"active_apsel_hostlane5": "N/A", # Not supported
"active_apsel_hostlane6": "N/A", # Not supported
"active_apsel_hostlane7": "N/A", # Not supported
"active_apsel_hostlane8": "N/A", # Not supported
"supported_max_tx_power": "N/A", # Not supported
"supported_min_tx_power": "N/A", # Not supported
"supported_max_laser_freq": "N/A", # Not supported
"supported_min_laser_freq": "N/A" # Not supported
}
"vendor_oui": admin_info[consts.VENDOR_OUI_FIELD]
})
appl_advt = self.get_application_advertisement()
xcvr_info['application_advertisement'] = str(appl_advt) if len(appl_advt) > 0 else 'N/A'
xcvr_info['host_electrical_interface'] = self.get_host_electrical_interface()
xcvr_info['media_interface_code'] = self.get_module_media_interface()
xcvr_info['host_lane_count'] = self.get_host_lane_count()
xcvr_info['media_lane_count'] = self.get_media_lane_count()
xcvr_info['host_lane_assignment_option'] = self.get_host_lane_assignment_option()
xcvr_info['media_lane_assignment_option'] = self.get_media_lane_assignment_option()
xcvr_info['cable_type'] = self.get_cable_length_type()
self.cmis_xcvr_info_dict['application_advertisement'] = str(appl_advt) if len(appl_advt) > 0 else 'N/A'
self.cmis_xcvr_info_dict['host_electrical_interface'] = self.get_host_electrical_interface()
self.cmis_xcvr_info_dict['media_interface_code'] = self.get_module_media_interface()
self.cmis_xcvr_info_dict['host_lane_count'] = self.get_host_lane_count()
self.cmis_xcvr_info_dict['media_lane_count'] = self.get_media_lane_count()
self.cmis_xcvr_info_dict['host_lane_assignment_option'] = self.get_host_lane_assignment_option()
self.cmis_xcvr_info_dict['media_lane_assignment_option'] = self.get_media_lane_assignment_option()
self.cmis_xcvr_info_dict['cable_type'] = self.get_cable_length_type()
apsel_dict = self.get_active_apsel_hostlane()
for lane in range(1, self.NUM_CHANNELS+1):
xcvr_info["%s%d" % ("active_apsel_hostlane", lane)] = \
self.cmis_xcvr_info_dict["%s%d" % ("active_apsel_hostlane", lane)] = \
apsel_dict["%s%d" % (consts.ACTIVE_APSEL_HOSTLANE, lane)]
xcvr_info['media_interface_technology'] = self.get_media_interface_technology()
xcvr_info['vendor_rev'] = self.get_vendor_rev()
xcvr_info['cmis_rev'] = self.get_cmis_rev()
xcvr_info['specification_compliance'] = self.get_module_media_type()
self.cmis_xcvr_info_dict['media_interface_technology'] = self.get_media_interface_technology()
self.cmis_xcvr_info_dict['vendor_rev'] = self.get_vendor_rev()
self.cmis_xcvr_info_dict['cmis_rev'] = self.get_cmis_rev()
self.cmis_xcvr_info_dict['specification_compliance'] = self.get_module_media_type()

# In normal case will get a valid value for each of the fields. If get a 'None' value
# means there was a failure while reading the EEPROM, either because the EEPROM was
# not ready yet or experincing some other issues. It shouldn't return a dict with a
# wrong field value, instead should return a 'None' to indicate to XCVRD that retry is
# needed.
if None in xcvr_info.values():
if None in self.cmis_xcvr_info_dict.values():
return None
else:
return xcvr_info
return self.cmis_xcvr_info_dict

def get_transceiver_info_firmware_versions(self):
return_dict = {"active_firmware" : "N/A", "inactive_firmware" : "N/A"}
Expand Down
8 changes: 4 additions & 4 deletions sonic_platform_base/sonic_xcvr/api/public/sff8436.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

from ...fields import consts
from ..xcvr_api import XcvrApi
from .cmis import CmisApi

class Sff8436Api(XcvrApi):
NUM_CHANNELS = 4
Expand Down Expand Up @@ -46,7 +47,7 @@ def get_transceiver_info(self):
cable_len = len
cable_type = type

xcvr_info = {
CmisApi.cmis_xcvr_info_dict = {
"type": serial_id[consts.ID_FIELD],
"type_abbrv_name": serial_id[consts.ID_ABBRV_FIELD],
"vendor_rev": serial_id[consts.VENDOR_REV_FIELD],
Expand All @@ -62,11 +63,10 @@ def get_transceiver_info(self):
"nominal_bit_rate": serial_id[consts.NOMINAL_BR_FIELD],
"specification_compliance": str(serial_id[consts.SPEC_COMPLIANCE_FIELD]),
"vendor_date": serial_id[consts.VENDOR_DATE_FIELD],
"vendor_oui": serial_id[consts.VENDOR_OUI_FIELD],
"application_advertisement": "N/A",
"vendor_oui": serial_id[consts.VENDOR_OUI_FIELD]
}

return xcvr_info
return CmisApi.cmis_xcvr_info_dict

def get_transceiver_status(self):
rx_los = self.get_rx_los()
Expand Down
8 changes: 4 additions & 4 deletions sonic_platform_base/sonic_xcvr/api/public/sff8472.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"""
from ...fields import consts
from ..xcvr_api import XcvrApi
from .cmis import CmisApi

class Sff8472Api(XcvrApi):
NUM_CHANNELS = 1
Expand Down Expand Up @@ -38,7 +39,7 @@ def get_transceiver_info(self):
cable_len = len
cable_type = type

xcvr_info = {
CmisApi.cmis_xcvr_info_dict = {
"type": serial_id[consts.ID_FIELD],
"type_abbrv_name": serial_id[consts.ID_ABBRV_FIELD],
"vendor_rev": serial_id[consts.VENDOR_REV_FIELD],
Expand All @@ -54,11 +55,10 @@ def get_transceiver_info(self):
"nominal_bit_rate": serial_id[consts.NOMINAL_BR_FIELD],
"specification_compliance": str(serial_id[consts.SPEC_COMPLIANCE_FIELD]),
"vendor_date": serial_id[consts.VENDOR_DATE_FIELD],
"vendor_oui": serial_id[consts.VENDOR_OUI_FIELD],
"application_advertisement": "N/A",
"vendor_oui": serial_id[consts.VENDOR_OUI_FIELD]
}

return xcvr_info
return CmisApi.cmis_xcvr_info_dict

def get_transceiver_status(self):
rx_los = self.get_rx_los()
Expand Down
8 changes: 4 additions & 4 deletions sonic_platform_base/sonic_xcvr/api/public/sff8636.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

from ...fields import consts
from ..xcvr_api import XcvrApi
from .cmis import CmisApi

from ...codes.public.sff8636 import Sff8636Codes

Expand Down Expand Up @@ -53,7 +54,7 @@ def get_transceiver_info(self):
cable_len = len
cable_type = type

xcvr_info = {
CmisApi.cmis_xcvr_info_dict = {
"type": serial_id[consts.ID_FIELD],
"type_abbrv_name": serial_id[consts.ID_ABBRV_FIELD],
"vendor_rev": serial_id[consts.VENDOR_REV_FIELD],
Expand All @@ -69,11 +70,10 @@ def get_transceiver_info(self):
"nominal_bit_rate": serial_id[consts.NOMINAL_BR_FIELD],
"specification_compliance": str(spec_compliance),
"vendor_date": serial_id[consts.VENDOR_DATE_FIELD],
"vendor_oui": serial_id[consts.VENDOR_OUI_FIELD],
"application_advertisement": "N/A",
"vendor_oui": serial_id[consts.VENDOR_OUI_FIELD]
}

return xcvr_info
return CmisApi.cmis_xcvr_info_dict

def get_transceiver_status(self):
rx_los = self.get_rx_los()
Expand Down

0 comments on commit 4fc7a86

Please sign in to comment.