From 20e449e60dbb5c991e83c992dc359f1fd80f5bf1 Mon Sep 17 00:00:00 2001 From: byu343 Date: Mon, 11 Nov 2024 13:04:46 -0800 Subject: [PATCH] Implement get/set_lpmode API for SFF8472 (#512) * Add get/set_lpmode API for SFF8472 The lpmode is not supported by SFF8472 * Add unittest for get/set_lpmode for SFF8472 --------- Co-authored-by: Andy Wong --- .../sonic_xcvr/api/public/sff8472.py | 23 ++++++++++++++++++- tests/sonic_xcvr/test_sff8472.py | 6 +++++ 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/sonic_platform_base/sonic_xcvr/api/public/sff8472.py b/sonic_platform_base/sonic_xcvr/api/public/sff8472.py index 9fe40a16e..32646f2d2 100644 --- a/sonic_platform_base/sonic_xcvr/api/public/sff8472.py +++ b/sonic_platform_base/sonic_xcvr/api/public/sff8472.py @@ -37,7 +37,7 @@ def get_transceiver_info(self): if len > 0: cable_len = len cable_type = type - + xcvr_info = { "type": serial_id[consts.ID_FIELD], "type_abbrv_name": serial_id[consts.ID_ABBRV_FIELD], @@ -296,5 +296,26 @@ def get_lpmode_support(self): def get_power_override_support(self): return False + def get_lpmode(self): + ''' + Retrieves low power mode status + + Returns: + bool: True if module in low power else returns False. + ''' + return False + + def set_lpmode(self, lpmode): + ''' + This function sets LPMode for the module. + + Args: + lpmode (bool): False means LPMode Off, True means LPMode On + + Returns: + bool: True if the provision succeeds, False if it fails + ''' + return False + def is_copper(self): return self.xcvr_eeprom.read(consts.SFP_CABLE_TECH_FIELD) == 'Passive Cable' diff --git a/tests/sonic_xcvr/test_sff8472.py b/tests/sonic_xcvr/test_sff8472.py index c11db8fcd..923d10c53 100644 --- a/tests/sonic_xcvr/test_sff8472.py +++ b/tests/sonic_xcvr/test_sff8472.py @@ -290,3 +290,9 @@ def test_get_transceiver_bulk_status(self, mock_response, expected): result = self.api.get_transceiver_bulk_status() assert result == expected + def test_get_lpmode(self): + assert not self.api.get_lpmode() + + def test_set_lpmode(self): + assert not self.api.set_lpmode(True) + assert not self.api.set_lpmode(False)