From c2aac7530807dcc8ffce6bf1c534e3103ec55901 Mon Sep 17 00:00:00 2001 From: Aravind Mani <53524901+aravindmani-1@users.noreply.github.com> Date: Mon, 29 Nov 2021 20:29:56 +0530 Subject: [PATCH] [SFP-Refactor] Fix LP mode API issue (#247) * [SFP-Refactor] Fix LP mode API issue * update API --- sonic_platform_base/sonic_xcvr/api/public/cmis.py | 13 ++++++++++--- sonic_platform_base/sonic_xcvr/sfp_optoe_base.py | 2 +- 2 files changed, 11 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 78d70c009510..ca319faae90d 100644 --- a/sonic_platform_base/sonic_xcvr/api/public/cmis.py +++ b/sonic_platform_base/sonic_xcvr/api/public/cmis.py @@ -898,11 +898,18 @@ def set_lpmode(self, lpmode): if lpmode_val is not None: if lpmode is True: lpmode_val = lpmode_val | (1 << 4) + self.xcvr_eeprom.write(consts.MODULE_LEVEL_CONTROL, lpmode_val) + time.sleep(0.1) + return self.get_lpmode() else: lpmode_val = lpmode_val & ~(1 << 4) - self.xcvr_eeprom.write(consts.MODULE_LEVEL_CONTROL, lpmode_val) - time.sleep(0.1) - return self.get_lpmode() + self.xcvr_eeprom.write(consts.MODULE_LEVEL_CONTROL, lpmode_val) + time.sleep(1) + lpmode = self.xcvr_eeprom.read(consts.TRANS_MODULE_STATUS_FIELD) + if lpmode is not None: + if lpmode.get('ModuleState') == 'ModuleReady': + return True + return False return False def get_loopback_capability(self): diff --git a/sonic_platform_base/sonic_xcvr/sfp_optoe_base.py b/sonic_platform_base/sonic_xcvr/sfp_optoe_base.py index b1e657ef9fcb..41349c5db6f7 100644 --- a/sonic_platform_base/sonic_xcvr/sfp_optoe_base.py +++ b/sonic_platform_base/sonic_xcvr/sfp_optoe_base.py @@ -144,7 +144,7 @@ def set_lpmode(self, lpmode): vendors has to implement accordingly. """ api = self.get_xcvr_api() - return api.set_lp_mode(lpmode) if api is not None else None + return api.set_lpmode(lpmode) if api is not None else None def set_optoe_write_max(self, write_max): sys_path = self.get_eeprom_path()