diff --git a/sonic_platform_base/sonic_xcvr/api/public/cdb_fw.py b/sonic_platform_base/sonic_xcvr/api/public/cdb_fw.py index 5ee00deee..915f57a02 100644 --- a/sonic_platform_base/sonic_xcvr/api/public/cdb_fw.py +++ b/sonic_platform_base/sonic_xcvr/api/public/cdb_fw.py @@ -72,13 +72,14 @@ def get_module_fw_mgmt_feature(self, verbose = False): log.log_error(txt) return {'status': False, 'info': txt, 'feature': None} - startLPLsize, maxblocksize, lplonly_flag = fw_features + startLPLsize, maxblocksize, lplonly_flag, abort_supported = fw_features txt += 'Start payload size %d\n' % startLPLsize txt += 'Max block size %d\n' % maxblocksize if lplonly_flag: txt += 'Write to LPL supported\n' else: txt += 'Write to LPL/EPL supported\n' + txt += 'Abort CMD102h supported %s\n' % abort_supported elapsedtime = time.time()-starttime log.log_info('Get module FW upgrade features time: {:.2f} s\n'.format(elapsedtime)) diff --git a/sonic_platform_base/sonic_xcvr/cdb/cdb_fw.py b/sonic_platform_base/sonic_xcvr/cdb/cdb_fw.py index 54521db3e..57e5b4449 100644 --- a/sonic_platform_base/sonic_xcvr/cdb/cdb_fw.py +++ b/sonic_platform_base/sonic_xcvr/cdb/cdb_fw.py @@ -19,6 +19,7 @@ def __init__(self, reader, writer, mem_map): self.start_payload_size = 0 self.is_lpl_only = False self.rw_length_ext = 0 + self.is_abort_supported = False self.timeout_start = None self.timeout_abort = None self.timeout_write = None @@ -40,16 +41,18 @@ def initFwHandler(self): log.log_notice("Failed to read firmware management features") return False + mgmt_features_adv = reply.get(cdb_consts.CDB_FIRMWARE_MGMT_ADV, {}) self.start_payload_size = reply[cdb_consts.CDB_START_CMD_PAYLOAD_SIZE] self.is_lpl_only = reply[cdb_consts.CDB_WRITE_MECHANISM] == "LPL" self.rw_length_ext = reply[cdb_consts.CDB_READ_WRITE_LENGTH_EXT] + 8 + self.is_abort_supported = bool(mgmt_features_adv.get(cdb_consts.CDB_ABORT_CMD_SUPPORTED, 0)) if self.is_lpl_only: self.rw_length_ext = min(cdb_consts.LPL_MAX_PAYLOAD_SIZE, self.rw_length_ext) else: self.rw_length_ext = min(cdb_consts.EPL_MAX_PAYLOAD_SIZE, self.rw_length_ext) - multiplier = 10 if reply.get(cdb_consts.CDB_MAX_DURATION_ENCODING, 0) else 1 + multiplier = 10 if mgmt_features_adv.get(cdb_consts.CDB_MAX_DURATION_ENCODING, 0) else 1 duration_start = reply.get(cdb_consts.CDB_MAX_DURATION_START, 0) duration_abort = reply.get(cdb_consts.CDB_MAX_DURATION_ABORT, 0) duration_write = reply.get(cdb_consts.CDB_MAX_DURATION_WRITE, 0) @@ -68,7 +71,7 @@ def get_fw_mgmt_features(self): """ if self.start_payload_size == 0 and self.rw_length_ext == 0: return None - return (self.start_payload_size, self.rw_length_ext, self.is_lpl_only) + return (self.start_payload_size, self.rw_length_ext, self.is_lpl_only, self.is_abort_supported) def get_firmware_info(self): """ diff --git a/sonic_platform_base/sonic_xcvr/mem_maps/public/cmis/pages/page9f_cdb.py b/sonic_platform_base/sonic_xcvr/mem_maps/public/cmis/pages/page9f_cdb.py index f5a402fc2..cd370cd53 100644 --- a/sonic_platform_base/sonic_xcvr/mem_maps/public/cmis/pages/page9f_cdb.py +++ b/sonic_platform_base/sonic_xcvr/mem_maps/public/cmis/pages/page9f_cdb.py @@ -58,6 +58,7 @@ def __init__(self, codes): cdb_consts.CDB_FIRMWARE_MGMT_ADV, self.getaddr(137), RegBitField(cdb_consts.CDB_MAX_DURATION_ENCODING, 3), RegBitField(cdb_consts.CDB_ABORT_CMD_SUPPORTED, 0), + bitdecode=True, ), NumberRegField(cdb_consts.CDB_START_CMD_PAYLOAD_SIZE, self.getaddr(138)), NumberRegField(cdb_consts.CDB_READ_WRITE_LENGTH_EXT, self.getaddr(140), scale=0.125), diff --git a/tests/sonic_xcvr/test_cdb_fw.py b/tests/sonic_xcvr/test_cdb_fw.py index 7ec389310..b25380d73 100644 --- a/tests/sonic_xcvr/test_cdb_fw.py +++ b/tests/sonic_xcvr/test_cdb_fw.py @@ -127,8 +127,9 @@ def test_get_fw_mgmt_features_valid(self): self.handler.start_payload_size = 112 self.handler.rw_length_ext = 2048 self.handler.is_lpl_only = True + self.handler.is_abort_supported = True result = self.handler.get_fw_mgmt_features() - assert result == (112, 2048, True) + assert result == (112, 2048, True, True) def test_get_firmware_info_success(self): """Test successful get_firmware_info""" diff --git a/tests/sonic_xcvr/test_cmis.py b/tests/sonic_xcvr/test_cmis.py index 4bc225a0c..508102423 100755 --- a/tests/sonic_xcvr/test_cmis.py +++ b/tests/sonic_xcvr/test_cmis.py @@ -1943,8 +1943,8 @@ def test_get_module_fw_info(self, mock_response, expected): @pytest.mark.parametrize("mock_fw_features, mock_eeprom_reads, expected", [ (None, [True, 1], {'status': False, 'feature': None}), - ((0, 8, False), [True, 1], {'status': True, 'feature': (0, 8, False, True, 16)}), - ((112, 2048, True), [False, 1], {'status': True, 'feature': (112, 2048, True, False, 16)}), + ((0, 8, False, True), [True, 1], {'status': True, 'feature': (0, 8, False, True, 16)}), + ((112, 2048, True, False), [False, 1], {'status': True, 'feature': (112, 2048, True, False, 16)}), ]) def test_get_module_fw_mgmt_feature(self, mock_fw_features, mock_eeprom_reads, expected): mock_fw_hdlr = MagicMock()