From 453e36975086577309df8e10a8600de59305d65d Mon Sep 17 00:00:00 2001 From: Prince George Date: Fri, 9 Jul 2021 06:18:15 +0000 Subject: [PATCH 1/3] Fix for Xcvrd crash Signed-off-by: Prince George --- sonic_platform_base/sonic_sfp/qsfp_dd.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/sonic_platform_base/sonic_sfp/qsfp_dd.py b/sonic_platform_base/sonic_sfp/qsfp_dd.py index 02281d997..ffcd50c5e 100644 --- a/sonic_platform_base/sonic_sfp/qsfp_dd.py +++ b/sonic_platform_base/sonic_sfp/qsfp_dd.py @@ -46,7 +46,10 @@ def decode_module_state(self, eeprom_data, offset, size): def decode_connector(self, eeprom_data, offset, size): connector_id = eeprom_data[offset] - return connector_dict[connector_id] + if connector_id in connector_dict.keys(): + return connector_dict[connector_id] + else: + return 'N/A' def decode_ext_id(self, eeprom_data, offset, size): # bits 5-7 represent Module Card Power Class @@ -213,7 +216,7 @@ def parse_vendor_sn(self, sn_raw_data, start_pos): def parse_vendor_date(self, date_raw_data, start_pos): return sffbase.parse(self, self.vendor_date, date_raw_data, start_pos) - + def parse_vendor_oui(self, vendor_oui_data, start_pos): return sffbase.parse(self, self.vendor_oui, vendor_oui_data, start_pos) @@ -700,7 +703,7 @@ def parse_voltage(self, eeprom_raw_data, start_pos): def parse_channel_monitor_params(self, eeprom_raw_data, start_pos): return sffbase.parse(self, self.dom_channel_monitor_params, eeprom_raw_data, start_pos) - + def parse_dom_tx_bias(self, eeprom_raw_data, start_pos): return sffbase.parse(self, self.dom_tx_bias, eeprom_raw_data, start_pos) From 1b65326fd26e0b0f69fa6b281d7142cdefd9fd44 Mon Sep 17 00:00:00 2001 From: Prince George Date: Fri, 9 Jul 2021 13:08:33 +0000 Subject: [PATCH 2/3] Addressed review comment Signed-off-by: Prince George --- sonic_platform_base/sonic_sfp/qsfp_dd.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/sonic_platform_base/sonic_sfp/qsfp_dd.py b/sonic_platform_base/sonic_sfp/qsfp_dd.py index ffcd50c5e..0c5d39379 100644 --- a/sonic_platform_base/sonic_sfp/qsfp_dd.py +++ b/sonic_platform_base/sonic_sfp/qsfp_dd.py @@ -79,7 +79,12 @@ def decode_cable_len(self, eeprom_data, offset, size): def decode_media_type(self, eeprom_data, offset, size): media_type_code = eeprom_data[0] + + if media_type_code not in type_of_media_interface.keys(): + return None + dict_name = type_of_media_interface[media_type_code] + if dict_name == "nm_850_media_interface": return nm_850_media_interface elif dict_name == "sm_media_interface": From 2696783844a6d7f90f89919096c8f1586e0f7dd0 Mon Sep 17 00:00:00 2001 From: Prince George Date: Tue, 13 Jul 2021 02:49:17 +0000 Subject: [PATCH 3/3] fix invalid key access in parse_application() Signed-off-by: Prince George --- sonic_platform_base/sonic_sfp/qsfp_dd.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/sonic_platform_base/sonic_sfp/qsfp_dd.py b/sonic_platform_base/sonic_sfp/qsfp_dd.py index 0c5d39379..37575dee7 100644 --- a/sonic_platform_base/sonic_sfp/qsfp_dd.py +++ b/sonic_platform_base/sonic_sfp/qsfp_dd.py @@ -99,11 +99,14 @@ def decode_media_type(self, eeprom_data, offset, size): return None def parse_application(self, sfp_media_type_dict, host_interface, media_interface): - host_result = host_electrical_interface[host_interface] + media_result = 'Unknown' + host_result = 'Unknown' + + if host_interface in host_electrical_interface: + host_result = host_electrical_interface[host_interface] + if media_interface in sfp_media_type_dict.keys(): media_result = sfp_media_type_dict[media_interface] - else: - media_result = 'Unknown' return host_result, media_result version = '1.0'