diff --git a/sonic_platform_base/sonic_xcvr/api/public/cmis.py b/sonic_platform_base/sonic_xcvr/api/public/cmis.py index ca319faae..1b4188d3e 100644 --- a/sonic_platform_base/sonic_xcvr/api/public/cmis.py +++ b/sonic_platform_base/sonic_xcvr/api/public/cmis.py @@ -130,7 +130,7 @@ def get_transceiver_info(self): "ext_identifier": "%s (%sW Max)" % (power_class, max_power), "ext_rateselect_compliance": "N/A", # Not supported "cable_type": "Length Cable Assembly(m)", - "cable_length": admin_info[consts.LENGTH_ASSEMBLY_FIELD], + "cable_length": float(admin_info[consts.LENGTH_ASSEMBLY_FIELD]), "nominal_bit_rate": 0, # Not supported "specification_compliance": admin_info[consts.MEDIA_TYPE_FIELD], "vendor_date": admin_info[consts.VENDOR_DATE_FIELD], @@ -610,8 +610,6 @@ def get_module_media_type(self): ''' This function returns module media type: MMF, SMF, Passive Copper Cable, Active Cable Assembly or Base-T. ''' - if self.is_flat_memory(): - return 'N/A' return self.xcvr_eeprom.read(consts.MEDIA_TYPE_FIELD) def get_host_electrical_interface(self): @@ -624,19 +622,16 @@ def get_module_media_interface(self): ''' This function returns module media electrical interface. Table 4-6 ~ 4-10 in SFF-8024 Rev4.6 ''' - if self.is_flat_memory(): - return 'N/A' - media_type = self.get_module_media_type() - if media_type == 'Multimode Fiber (MMF)': + if media_type == 'nm_850_media_interface': return self.xcvr_eeprom.read(consts.MODULE_MEDIA_INTERFACE_850NM) - elif media_type == 'Single Mode Fiber (SMF)': + elif media_type == 'sm_media_interface': return self.xcvr_eeprom.read(consts.MODULE_MEDIA_INTERFACE_SM) - elif media_type == 'Passive Copper Cable': + elif media_type == 'passive_copper_media_interface': return self.xcvr_eeprom.read(consts.MODULE_MEDIA_INTERFACE_PASSIVE_COPPER) - elif media_type == 'Active Cable Assembly': + elif media_type == 'active_cable_media_interface': return self.xcvr_eeprom.read(consts.MODULE_MEDIA_INTERFACE_ACTIVE_CABLE) - elif media_type == 'BASE-T': + elif media_type == 'base_t_media_interface': return self.xcvr_eeprom.read(consts.MODULE_MEDIA_INTERFACE_BASE_T) else: return 'Unknown media interface' diff --git a/sonic_platform_base/sonic_xcvr/codes/public/cmis.py b/sonic_platform_base/sonic_xcvr/codes/public/cmis.py index 9bbcb0be6..ec2029b5b 100644 --- a/sonic_platform_base/sonic_xcvr/codes/public/cmis.py +++ b/sonic_platform_base/sonic_xcvr/codes/public/cmis.py @@ -12,15 +12,6 @@ class CmisCodes(Sff8024): 7: "Power Class 8" } - MEDIA_TYPES = { - 0: "Undefined", - 1: "nm_850_media_interface", - 2: "sm_media_interface", - 3: "passive_copper_media_interface", - 4: "active_cable_media_interface", - 5: "base_t_media_interface", - } - MEDIA_INTERFACE_TECH = { 0: '850 nm VCSEL', 1: '1310 nm VCSEL', diff --git a/sonic_platform_base/sonic_xcvr/codes/public/sff8024.py b/sonic_platform_base/sonic_xcvr/codes/public/sff8024.py index d805da3d8..e850d90a5 100644 --- a/sonic_platform_base/sonic_xcvr/codes/public/sff8024.py +++ b/sonic_platform_base/sonic_xcvr/codes/public/sff8024.py @@ -174,14 +174,13 @@ class Sff8024(XcvrCodes): 129: 'Capable of 128GFC' } - MODULE_MEDIA_TYPE = { 0: 'Undefined', - 1: 'Multimode Fiber (MMF)', - 2: 'Single Mode Fiber (SMF)', - 3: 'Passive Copper Cable', - 4: 'Active Cable Assembly', - 5: 'BASE-T' + 1: 'nm_850_media_interface', + 2: 'sm_media_interface', + 3: 'passive_copper_media_interface', + 4: 'active_cable_media_interface', + 5: 'base_t_media_interface' } HOST_ELECTRICAL_INTERFACE = { diff --git a/tests/sonic_xcvr/test_cmis.py b/tests/sonic_xcvr/test_cmis.py index 8737ef315..9fbd7c283 100644 --- a/tests/sonic_xcvr/test_cmis.py +++ b/tests/sonic_xcvr/test_cmis.py @@ -498,7 +498,7 @@ def test_get_power_override_support(self, ): assert result == False @pytest.mark.parametrize("mock_response, expected", [ - ("Single Mode Fiber (SMF)", "Single Mode Fiber (SMF)") + ("sm_media_interface", "sm_media_interface") ]) def test_get_module_media_type(self, mock_response, expected): self.api.xcvr_eeprom.read = MagicMock() @@ -516,11 +516,11 @@ def test_get_host_electrical_interface(self, mock_response, expected): assert result == expected @pytest.mark.parametrize("mock_response1, mock_response2, expected", [ - ("Single Mode Fiber (SMF)", "400ZR", "400ZR"), - ("Multimode Fiber (MMF)", "100GE BiDi", "100GE BiDi"), - ("Passive Copper Cable", "Copper cable", "Copper cable"), - ("Active Cable Assembly", "Active Loopback module", "Active Loopback module"), - ("BASE-T", "1000BASE-T (Clause 40)", "1000BASE-T (Clause 40)"), + ("sm_media_interface", "400ZR", "400ZR"), + ("nm_850_media_interface", "100GE BiDi", "100GE BiDi"), + ("passive_copper_media_interface", "Copper cable", "Copper cable"), + ("active_cable_media_interface", "Active Loopback module", "Active Loopback module"), + ("base_t_media_interface", "1000BASE-T (Clause 40)", "1000BASE-T (Clause 40)"), ("ABCD", "ABCD", "Unknown media interface") ]) def test_get_module_media_interface(self, mock_response1, mock_response2, expected): @@ -951,7 +951,7 @@ def test_module_fw_upgrade(self, input_param, mock_response, expected): 'VendorPN': 'ABCD', 'Connector': 'LC', 'Length Cable Assembly': 0.0, - 'ModuleMediaType': 'Single Mode Fiber (SMF)', + 'ModuleMediaType': 'sm_media_interface', 'VendorDate': '21010100', 'VendorOUI': 'xx-xx-xx' }, @@ -965,7 +965,7 @@ def test_module_fw_upgrade(self, input_param, mock_response, expected): '5.0', '0.1', '0.0', - 'Single Mode Fiber (SMF)' + 'sm_media_interface' ], { 'type': 'QSFP-DD Double Density 8X Pluggable Transceiver', 'type_abbrv_name': 'QSFP-DD', @@ -976,7 +976,7 @@ def test_module_fw_upgrade(self, input_param, mock_response, expected): 'cable_type': 'Length Cable Assembly(m)', 'cable_length': 0.0, 'nominal_bit_rate': 0, - 'specification_compliance': 'Single Mode Fiber (SMF)', + 'specification_compliance': 'sm_media_interface', 'application_advertisement': 'N/A', 'active_firmware': '0.1', 'media_lane_count': 1,