From 5543be5e81b792619a93b4fea3b95f73b0bb8160 Mon Sep 17 00:00:00 2001 From: chiourung_huang Date: Tue, 8 Aug 2023 06:26:23 +0000 Subject: [PATCH] EEPROM "application advertisement" cannot display customized information. Can't show all application advertisement for CISCO ZR. For CISCO ZR, it use Vendor specific ID for module_media_interface_id Solution: 1. Add mapping for Host Electrical and Media Interface IDs 2. return code information when can't get the definition Signed-off-by: chiourung_huang Signed-off-by: Wataru Ishida --- .../sonic_xcvr/api/public/cmis.py | 4 ++-- .../sonic_xcvr/codes/public/sff8024.py | 22 ++++++++++++++++++- .../sonic_xcvr/fields/xcvr_field.py | 2 +- 3 files changed, 24 insertions(+), 4 deletions(-) diff --git a/sonic_platform_base/sonic_xcvr/api/public/cmis.py b/sonic_platform_base/sonic_xcvr/api/public/cmis.py index cc6cd5920..271101aee 100644 --- a/sonic_platform_base/sonic_xcvr/api/public/cmis.py +++ b/sonic_platform_base/sonic_xcvr/api/public/cmis.py @@ -2033,7 +2033,7 @@ def get_application_advertisement(self): key = "{}_{}".format(consts.HOST_ELECTRICAL_INTERFACE, app) val = dic.get(key) - if val in [None, 'Unknown', 'Undefined']: + if val in [None, 'End', 'Undefined']: continue buf['host_electrical_interface_id'] = val @@ -2042,7 +2042,7 @@ def get_application_advertisement(self): continue key = "{}_{}".format(prefix, app) val = dic.get(key) - if val in [None, 'Unknown']: + if val in [None]: continue buf['module_media_interface_id'] = val diff --git a/sonic_platform_base/sonic_xcvr/codes/public/sff8024.py b/sonic_platform_base/sonic_xcvr/codes/public/sff8024.py index c6a7e6e1e..2cf185c22 100644 --- a/sonic_platform_base/sonic_xcvr/codes/public/sff8024.py +++ b/sonic_platform_base/sonic_xcvr/codes/public/sff8024.py @@ -267,9 +267,13 @@ class Sff8024(XcvrCodes): 80: '400GAUI-4-L C2M (Annex 120G)', 81: '800G S C2M (placeholder)', 82: '800G L C2M (placeholder)', - 83: 'OTL4.2' + 83: 'OTL4.2', + 255: 'End' } + for i in range(192,255): + HOST_ELECTRICAL_INTERFACE[i] = 'Vendor specific: {}'.format(i) + # MMF media interface IDs NM_850_MEDIA_INTERFACE = { 0: 'Undefined', @@ -307,6 +311,9 @@ class Sff8024(XcvrCodes): 32: '800G-VR8 (Placeholder)' } + for i in range(192,256): + NM_850_MEDIA_INTERFACE[i] = 'Vendor specific: {}'.format(i) + # SMF media interface IDs SM_MEDIA_INTERFACE = { 0: 'Undefined', @@ -390,13 +397,20 @@ class Sff8024(XcvrCodes): 87: '800GBASE-DR8-2 (placeholder)' } + for i in range(192,256): + SM_MEDIA_INTERFACE[i] = 'Vendor specific: {}'.format(i) + # Passive and Linear Active Copper Cable and Passive Loopback media interface codes PASSIVE_COPPER_MEDIA_INTERFACE = { 0: 'Undefined', 1: 'Copper cable', + 2: 'Passive Loopback module', 191: 'Passive Loopback module' } + for i in range(192,256): + PASSIVE_COPPER_MEDIA_INTERFACE[i] = 'Vendor specific: {}'.format(i) + # Limiting and Retimed Active Cable assembly and Active Loopback media interface codes ACTIVE_CABLE_MEDIA_INTERFACE = { 0: 'Undefined', @@ -407,6 +421,9 @@ class Sff8024(XcvrCodes): 191: 'Active Loopback module' } + for i in range(192,256): + ACTIVE_CABLE_MEDIA_INTERFACE[i] = 'Vendor specific: {}'.format(i) + # BASE-T media interface codes BASE_T_MEDIA_INTERFACE = { 0: 'Undefined', @@ -419,4 +436,7 @@ class Sff8024(XcvrCodes): 7: '50GBASE-T (Placeholder)' } + for i in range(192,256): + BASE_T_MEDIA_INTERFACE[i] = 'Vendor specific: {}'.format(i) + # TODO: Add other codes diff --git a/sonic_platform_base/sonic_xcvr/fields/xcvr_field.py b/sonic_platform_base/sonic_xcvr/fields/xcvr_field.py index 1b7d3c856..1eb90833e 100644 --- a/sonic_platform_base/sonic_xcvr/fields/xcvr_field.py +++ b/sonic_platform_base/sonic_xcvr/fields/xcvr_field.py @@ -238,7 +238,7 @@ def decode(self, raw_data, **decoded_deps): if mask is not None: code &= mask code >>= self.start_bitpos - return self.code_dict.get(code, "Unknown") + return self.code_dict.get(code, "Unknown: {}".format(code)) class HexRegField(RegField): """