From 470765e7d81fc7274f83fd525ee343638ec638ca Mon Sep 17 00:00:00 2001 From: Jemston Fernando Date: Sun, 30 Jun 2024 10:48:28 +0000 Subject: [PATCH 1/2] Fix cable issues Add break to return the cable length immediately and avoid reading the junk values Ignore ASCII errors as some cables might have some junk values causing the daemon to exit --- sonic_platform_base/sonic_xcvr/api/public/sff8436.py | 1 + sonic_platform_base/sonic_xcvr/api/public/sff8636.py | 1 + sonic_platform_base/sonic_xcvr/xcvr_api_factory.py | 4 ++-- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/sonic_platform_base/sonic_xcvr/api/public/sff8436.py b/sonic_platform_base/sonic_xcvr/api/public/sff8436.py index 4336cf6f0..5c28db62f 100644 --- a/sonic_platform_base/sonic_xcvr/api/public/sff8436.py +++ b/sonic_platform_base/sonic_xcvr/api/public/sff8436.py @@ -45,6 +45,7 @@ def get_transceiver_info(self): if len > 0: cable_len = len cable_type = type + break xcvr_info = { "type": serial_id[consts.ID_FIELD], diff --git a/sonic_platform_base/sonic_xcvr/api/public/sff8636.py b/sonic_platform_base/sonic_xcvr/api/public/sff8636.py index f59163a6c..eb1b80ffb 100644 --- a/sonic_platform_base/sonic_xcvr/api/public/sff8636.py +++ b/sonic_platform_base/sonic_xcvr/api/public/sff8636.py @@ -52,6 +52,7 @@ def get_transceiver_info(self): if len > 0: cable_len = len cable_type = type + break xcvr_info = { "type": serial_id[consts.ID_FIELD], diff --git a/sonic_platform_base/sonic_xcvr/xcvr_api_factory.py b/sonic_platform_base/sonic_xcvr/xcvr_api_factory.py index ad35f7d9b..a957136c9 100644 --- a/sonic_platform_base/sonic_xcvr/xcvr_api_factory.py +++ b/sonic_platform_base/sonic_xcvr/xcvr_api_factory.py @@ -61,14 +61,14 @@ def _get_vendor_name(self): name_data = self.reader(VENDOR_NAME_OFFSET, VENDOR_NAME_LENGTH) if name_data is None: return None - vendor_name = name_data.decode() + vendor_name = name_data.decode("ascii", errors="ignore") return vendor_name.strip() def _get_vendor_part_num(self): part_num = self.reader(VENDOR_PART_NUM_OFFSET, VENDOR_PART_NUM_LENGTH) if part_num is None: return None - vendor_pn = part_num.decode() + vendor_pn = part_num.decode("ascii", errors="ignore") return vendor_pn.strip() def create_xcvr_api(self): From 88a33926cc1116930a712dc552918fa96356f959 Mon Sep 17 00:00:00 2001 From: Jemston Fernando Date: Sun, 30 Jun 2024 10:52:31 +0000 Subject: [PATCH 2/2] Generate media key in platform sepcific way Add API to support the generation of the preemphasis key in a platform vendor dictated way instead of generic one --- sonic_platform_base/sfp_base.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/sonic_platform_base/sfp_base.py b/sonic_platform_base/sfp_base.py index 804b51ab8..fc2e3661e 100644 --- a/sonic_platform_base/sfp_base.py +++ b/sonic_platform_base/sfp_base.py @@ -467,3 +467,22 @@ def get_xcvr_api(self): if self._xcvr_api is None: self.refresh_xcvr_api() return self._xcvr_api + + def get_platform_media_key(self, transceiver_dict, port_speed, lane_count): + """ + Retrieves the media key constructed in a platform specific way, + to be used for parsing the media settings + + Args: + transceiver_dict : + SFP transceived EEPROM dictionary + port_speed: + Configured port speed + lane_count: + Number of lanes assigned for that port + + Returns: + a dictionary with string values defined for keys, + {'vendor_key':'', 'media_key':'', 'lane_speed_key':'') + """ + raise NotImplementedError