From 3e6a8babc06ecc8a3e5b44596cd7869bfe7bbb13 Mon Sep 17 00:00:00 2001 From: mssonicbld <79238446+mssonicbld@users.noreply.github.com> Date: Sat, 9 Aug 2025 09:23:11 +0800 Subject: [PATCH 1/2] [CMIS] Remove application-dependent fields from get_transceiver_info (#593) #### Description This PR updates the `get_transceiver_info()` API in the CMIS module to remove fields from the returned `XCVR_INFO` dictionary that are dependent on the active application ID. These fields include: - host_electrical_interface - media_interface_code - host_lane_assignment_option - media_lane_assignment_option #### Motivation and Context These fields are only meaningful when the active application ID is explicitly shown. Including them without context can lead to confusion or misinterpretation of transceiver capabilities. This change ensures the API response reflects only valid and context-aware data. #### How Has This Been Tested? Please refer to the test section of https://github.com/sonic-net/sonic-utilities/pull/4020 #### Additional Information (Optional) MSFT ADO - 34325583 --- sonic_platform_base/sonic_xcvr/api/public/cmis.py | 8 -------- tests/sonic_xcvr/test_ccmis.py | 8 -------- 2 files changed, 16 deletions(-) diff --git a/sonic_platform_base/sonic_xcvr/api/public/cmis.py b/sonic_platform_base/sonic_xcvr/api/public/cmis.py index 2b96204..28e1382 100644 --- a/sonic_platform_base/sonic_xcvr/api/public/cmis.py +++ b/sonic_platform_base/sonic_xcvr/api/public/cmis.py @@ -96,12 +96,8 @@ class VdmSubtypeIndex(Enum): "vendor_oui": "N/A", **{f"active_apsel_hostlane{i}": "N/A" for i in range(1, 9)}, "application_advertisement": "N/A", - "host_electrical_interface": "N/A", - "media_interface_code": "N/A", "host_lane_count": "N/A", "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": "N/A", @@ -341,12 +337,8 @@ def get_transceiver_info(self): "vendor_date": self._strip_str(admin_info[consts.VENDOR_DATE_FIELD]), "vendor_oui": admin_info[consts.VENDOR_OUI_FIELD], "application_advertisement": str(self.get_application_advertisement()) if len(self.get_application_advertisement()) > 0 else 'N/A', - "host_electrical_interface": self.get_host_electrical_interface(), - "media_interface_code": self.get_module_media_interface(), "host_lane_count": self.get_host_lane_count(), "media_lane_count": self.get_media_lane_count(), - "host_lane_assignment_option": self.get_host_lane_assignment_option(), - "media_lane_assignment_option": self.get_media_lane_assignment_option(), "cable_type": self.get_cable_length_type(), "media_interface_technology": self.get_media_interface_technology(), "vendor_rev": self._strip_str(self.get_vendor_rev()), diff --git a/tests/sonic_xcvr/test_ccmis.py b/tests/sonic_xcvr/test_ccmis.py index abcc018..9ad0578 100644 --- a/tests/sonic_xcvr/test_ccmis.py +++ b/tests/sonic_xcvr/test_ccmis.py @@ -175,19 +175,15 @@ def test_get_pm_all(self, mock_response, expected): 'application_advertisement': 'N/A', 'media_lane_count': 1, 'vendor_rev': '0.0', - 'host_electrical_interface': '400GAUI-8 C2M (Annex 120E)', 'vendor_oui': 'xx-xx-xx', 'manufacturer': 'VENDOR_NAME', 'media_interface_technology': '1550 nm DFB', - 'media_interface_code': '400ZR, DWDM, amplified', 'serial': '00000000', 'host_lane_count': 8, **{f'active_apsel_hostlane{i}': 1 for i in range(1, 9)}, 'hardware_rev': '0.0', 'cmis_rev': '5.0', - 'media_lane_assignment_option': 1, 'connector': 'LC', - 'host_lane_assignment_option': 1, 'vendor_date': '21010100', 'vdm_supported': True, }, @@ -208,19 +204,15 @@ def test_get_pm_all(self, mock_response, expected): 'application_advertisement': 'N/A', 'media_lane_count': 1, 'vendor_rev': '0.0', - 'host_electrical_interface': '400GAUI-8 C2M (Annex 120E)', 'vendor_oui': 'xx-xx-xx', 'manufacturer': 'VENDOR_NAME', 'media_interface_technology': '1550 nm DFB', - 'media_interface_code': '400ZR, DWDM, amplified', 'serial': '00000000', 'host_lane_count': 8, **{f'active_apsel_hostlane{i}': 1 for i in range(1, 9)}, 'hardware_rev': '0.0', 'cmis_rev': '5.0', - 'media_lane_assignment_option': 1, 'connector': 'LC', - 'host_lane_assignment_option': 1, 'vendor_date': '21010100', 'vdm_supported': True, 'supported_min_laser_freq': 191300, From 381432bde0efe6d4c66fe2048f4659f8d2f5ae85 Mon Sep 17 00:00:00 2001 From: mssonicbld <79238446+mssonicbld@users.noreply.github.com> Date: Sat, 9 Aug 2025 09:23:15 +0800 Subject: [PATCH 2/2] [CMIS] Moving flat memory register handling from CmisMemMap to CmisFlatMemMap (#592) #### Description On the custom backplane cartridge cable, following error is periodically seen in syslog as part of DOM monitoring. ``` 2025 Aug 7 16:26:43.826059 dut WARNING pmon#DomInfoUpdateTask[34]: Got exception KeyError('ModuleFlagByte1') while processing dom flags for port Ethernet464, ignored ``` #### Motivation and Context The traceback is seen since some registers which are on page 0 are still defined in `CmisMemMap` instead of `CmisFlatMemMap`. This causes the KeyError to be seen since the backplane cartridge has a memory map as an instance of `CmisFlatMemMap`. (https://github.com/sonic-net/sonic-platform-common/blob/af47c73007206a9e3c7b37680ec69dfb59877d30/sonic_platform_base/sonic_xcvr/mem_maps/amphenol/backplane.py#L13) Hence, moving all registers which access page 0 to `CmisFlatMemMap` class. #### How Has This Been Tested? Verified that the error is not seen in syslog anymore. #### Additional Information (Optional) MSFT ADO - 34346395 --- .../sonic_xcvr/fields/consts.py | 1 + .../sonic_xcvr/mem_maps/public/cmis.py | 47 ++++++++++--------- 2 files changed, 26 insertions(+), 22 deletions(-) diff --git a/sonic_platform_base/sonic_xcvr/fields/consts.py b/sonic_platform_base/sonic_xcvr/fields/consts.py index ecef4da..f22a2af 100644 --- a/sonic_platform_base/sonic_xcvr/fields/consts.py +++ b/sonic_platform_base/sonic_xcvr/fields/consts.py @@ -20,6 +20,7 @@ LENGTH_OM2_FIELD = "Length OM2" LENGTH_OM1_FIELD = "Length OM1" +MODULE_MONITORS_PAGE0_FIELD = "Module Monitors Page 0" MODULE_MONITORS_FIELD = "Module Monitors" RX_LOS_FIELD = "RxLOS" diff --git a/sonic_platform_base/sonic_xcvr/mem_maps/public/cmis.py b/sonic_platform_base/sonic_xcvr/mem_maps/public/cmis.py index b86ff7a..a4428cb 100755 --- a/sonic_platform_base/sonic_xcvr/mem_maps/public/cmis.py +++ b/sonic_platform_base/sonic_xcvr/mem_maps/public/cmis.py @@ -112,6 +112,31 @@ def __init__(self, codes): NumberRegField(consts.ACTIVE_FW_MINOR_REV, self.getaddr(0x0, 40), format="B", size=1), ) + self.PAGE0_MODULE_LEVEL_MONITORS = RegGroupField(consts.MODULE_MONITORS_PAGE0_FIELD, + NumberRegField(consts.TEMPERATURE_FIELD, self.getaddr(0x0, 14), size=2, format=">h", scale=256.0), + NumberRegField(consts.VOLTAGE_FIELD, self.getaddr(0x0, 16), size=2, format=">H", scale=10000.0), + NumberRegField(consts.AUX1_MON, self.getaddr(0x0, 18), format=">h", size=2), + NumberRegField(consts.AUX2_MON, self.getaddr(0x0, 20), format=">h", size=2), + NumberRegField(consts.AUX3_MON, self.getaddr(0x0, 22), format=">h", size=2), + NumberRegField(consts.CUSTOM_MON, self.getaddr(0x0, 24), format=">H", size=2), + ) + + self.TRANS_MODULE_STATUS = RegGroupField(consts.TRANS_MODULE_STATUS_FIELD, + CodeRegField(consts.MODULE_STATE, self.getaddr(0x0, 3), self.codes.MODULE_STATE, + *(RegBitField("Bit%d" % (bit), bit) for bit in range (1, 4)) + ), + NumberRegField(consts.MODULE_FIRMWARE_FAULT_INFO, self.getaddr(0x0, 8), size=1), + NumberRegField(consts.MODULE_FLAG_BYTE1, self.getaddr(0x0, 9), size=1), + NumberRegField(consts.MODULE_FLAG_BYTE2, self.getaddr(0x0, 10), size=1), + NumberRegField(consts.MODULE_FLAG_BYTE3, self.getaddr(0x0, 11), size=1), + NumberRegField(consts.CDB1_STATUS, self.getaddr(0x0, 37), size=1), + CodeRegField(consts.MODULE_FAULT_CAUSE, self.getaddr(0x0, 41), self.codes.MODULE_FAULT_CAUSE), + ) + + self.TRANS_CONFIG = RegGroupField(consts.TRANS_CONFIG_FIELD, + NumberRegField(consts.MODULE_LEVEL_CONTROL, self.getaddr(0x0, 26), size=1, ro=False), + ) + def getaddr(self, page, offset, page_size=128): return page * page_size + offset @@ -187,8 +212,6 @@ def __init__(self, codes): ) self.MODULE_LEVEL_MONITORS = RegGroupField(consts.MODULE_MONITORS_FIELD, - NumberRegField(consts.TEMPERATURE_FIELD, self.getaddr(0x0, 14), size=2, format=">h", scale=256.0), - NumberRegField(consts.VOLTAGE_FIELD, self.getaddr(0x0, 16), size=2, format=">H", scale=10000.0), NumberRegField(consts.GRID_SPACING, self.getaddr(0x12, 128), *(RegBitField("Bit%d" % (bit), bit) for bit in range (4, 8)), ro = False ), @@ -196,10 +219,6 @@ def __init__(self, codes): NumberRegField(consts.LASER_CURRENT_FREQ, self.getaddr(0x12, 168), format=">L", size=4, scale = 1000.0), NumberRegField(consts.TX_CONFIG_POWER, self.getaddr(0x12, 200), format=">h", size=2, scale=100.0, ro=False), NumberRegField(consts.AUX_MON_TYPE, self.getaddr(0x1, 145), size=1), - NumberRegField(consts.AUX1_MON, self.getaddr(0x0, 18), format=">h", size=2), - NumberRegField(consts.AUX2_MON, self.getaddr(0x0, 20), format=">h", size=2), - NumberRegField(consts.AUX3_MON, self.getaddr(0x0, 22), format=">h", size=2), - NumberRegField(consts.CUSTOM_MON, self.getaddr(0x0, 24), format=">H", size=2), ) self.MODULE_CHAR_ADVT = RegGroupField(consts.MODULE_CHAR_ADVT_FIELD, @@ -529,18 +548,6 @@ def __init__(self, codes): NumberRegField(consts.HOST_INPUT_LOOPBACK, self.getaddr(0x13, 183), size=1, ro=False), ) - self.TRANS_MODULE_STATUS = RegGroupField(consts.TRANS_MODULE_STATUS_FIELD, - CodeRegField(consts.MODULE_STATE, self.getaddr(0x0, 3), self.codes.MODULE_STATE, - *(RegBitField("Bit%d" % (bit), bit) for bit in range (1, 4)) - ), - NumberRegField(consts.MODULE_FIRMWARE_FAULT_INFO, self.getaddr(0x0, 8), size=1), - NumberRegField(consts.MODULE_FLAG_BYTE1, self.getaddr(0x0, 9), size=1), - NumberRegField(consts.MODULE_FLAG_BYTE2, self.getaddr(0x0, 10), size=1), - NumberRegField(consts.MODULE_FLAG_BYTE3, self.getaddr(0x0, 11), size=1), - NumberRegField(consts.CDB1_STATUS, self.getaddr(0x0, 37), size=1), - CodeRegField(consts.MODULE_FAULT_CAUSE, self.getaddr(0x0, 41), self.codes.MODULE_FAULT_CAUSE), - ) - self.TRANS_PM = RegGroupField(consts.TRANS_PM_FIELD, NumberRegField(consts.VDM_SUPPORTED_PAGE, self.getaddr(0x2f, 128), *(RegBitField("Bit%d" % (bit), bit) for bit in range (0, 2)) @@ -552,10 +559,6 @@ def __init__(self, codes): ), ) - self.TRANS_CONFIG = RegGroupField(consts.TRANS_CONFIG_FIELD, - NumberRegField(consts.MODULE_LEVEL_CONTROL, self.getaddr(0x0, 26), size=1, ro=False), - ) - self.TRANS_CDB = RegGroupField(consts.TRANS_CDB_FIELD, NumberRegField(consts.CDB_SUPPORT, self.getaddr(0x1, 163), *(RegBitField("Bit%d" % (bit), bit) for bit in range (6, 8))