From 8ccb75592fdebd2da4c8c18ab996a213d6ab405e Mon Sep 17 00:00:00 2001 From: Aravind Mani Date: Thu, 7 Oct 2021 10:20:12 +0530 Subject: [PATCH] Address comments --- .../plugins/sfputil.py | 48 +++++++++++-------- .../z9332f/sonic_platform/sfp.py | 14 ++++-- 2 files changed, 36 insertions(+), 26 deletions(-) diff --git a/device/dell/x86_64-dellemc_z9332f_d1508-r0/plugins/sfputil.py b/device/dell/x86_64-dellemc_z9332f_d1508-r0/plugins/sfputil.py index 667053ef7785..360c2958bc11 100644 --- a/device/dell/x86_64-dellemc_z9332f_d1508-r0/plugins/sfputil.py +++ b/device/dell/x86_64-dellemc_z9332f_d1508-r0/plugins/sfputil.py @@ -294,32 +294,38 @@ def set_low_power_mode(self, port_num, lpmode): return False if port_num > self.PORTS_IN_BLOCK: return False - # Port offset starts with 0x4000 - port_offset = 16384 + ((port_num-1) * 16) - status = self.pci_get_value(self.BASE_RES_PATH, port_offset) - reg_value = int(status) - - # Absence of status throws error - if (reg_value == ""): - return False - # Mask off 4th bit for presence - mask = (1 << 6) + if self.get_media_type(port_num) == 'QSFP_DD': + if lpmode is True: + write_val = 0x10 + else: + write_val = 0x0 - # LPMode is active high; set or clear the bit accordingly - if lpmode is True: - reg_value = reg_value | mask - write_val = 0x10 + self._write_eeprom_bytes(self.port_to_eeprom_mapping[port_num], 26, 1, bytearray([write_val])) + return True else: - reg_value = reg_value & ~mask - write_val = 0x0 + # Port offset starts with 0x4000 + port_offset = 16384 + ((port_num-1) * 16) + status = self.pci_get_value(self.BASE_RES_PATH, port_offset) + reg_value = int(status) - # Convert our register value back to a hex string and write back - status = self.pci_set_value(self.BASE_RES_PATH, reg_value, port_offset) + # Absence of status throws error + if (reg_value == ""): + return False - if self.get_media_type(port_num) == 'QSFP_DD': - self._write_eeprom_bytes(self.port_to_eeprom_mapping[port_num], 26, 1, bytearray([write_val])) - return True + # Mask off 4th bit for presence + mask = (1 << 6) + + # LPMode is active high; set or clear the bit accordingly + if lpmode is True: + reg_value = reg_value | mask + else: + reg_value = reg_value & ~mask + + # Convert our register value back to a hex string and write back + status = self.pci_set_value(self.BASE_RES_PATH, reg_value, port_offset) + + return True def reset(self, port_num): diff --git a/platform/broadcom/sonic-platform-modules-dell/z9332f/sonic_platform/sfp.py b/platform/broadcom/sonic-platform-modules-dell/z9332f/sonic_platform/sfp.py index 1ebe9814e083..475a823f06eb 100644 --- a/platform/broadcom/sonic-platform-modules-dell/z9332f/sonic_platform/sfp.py +++ b/platform/broadcom/sonic-platform-modules-dell/z9332f/sonic_platform/sfp.py @@ -1243,7 +1243,15 @@ def set_lpmode(self, lpmode): Sets the lpmode(low power mode) of this SFP """ try: - if self.sfp_type.startswith('QSFP'): + if self.sfp_type == 'QSFP_DD': + if lpmode is True: + write_val = 0x10 + else: + write_val = 0x0 + + self._write_eeprom_bytes(26, 1, bytearray([write_val])) + return True + else: # Port offset starts with 0x4000 port_offset = 16384 + ((self.index-1) * 16) @@ -1256,15 +1264,11 @@ def set_lpmode(self, lpmode): # LPMode is active high; set or clear the bit accordingly if lpmode is True: reg_value = reg_value | mask - write_val = 0x10 else: reg_value = reg_value & ~mask - write_val = 0x0 # Convert our register value back to a hex string and write back self.pci_set_value(self.BASE_RES_PATH, reg_value, port_offset) - if self.sfp_type == 'QSFP_DD': - self._write_eeprom_bytes(26, 1, bytearray([write_val])) except ValueError: return False return True