[Mellanox] Remove EEPROM write limitation if it is software control (#17030) (#17694)

This commit is contained in:
mssonicbld 2024-01-07 13:16:25 +08:00 committed by GitHub
parent fb7bad2d11
commit 4060f5ce5b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 1 deletions

View File

@ -771,6 +771,13 @@ class SFP(NvidiaSFPCommon):
Returns:
bool: True if the limited bytes is hit
"""
try:
if self.is_sw_control():
return False
except Exception as e:
logger.log_notice(f'Module is under initialization, cannot write module EEPROM - {e}')
return True
eeprom_path = self._get_eeprom_path()
limited_data = limited_eeprom.get(self._get_sfp_type_str(eeprom_path))
if not limited_data:

View File

@ -162,8 +162,13 @@ class TestSfp:
@mock.patch('sonic_platform.sfp.SFP._get_eeprom_path', mock.MagicMock(return_value = None))
@mock.patch('sonic_platform.sfp.SFP._get_sfp_type_str')
def test_is_write_protected(self, mock_get_type_str):
@mock.patch('sonic_platform.sfp.SFP.is_sw_control')
def test_is_write_protected(self, mock_sw_control, mock_get_type_str):
sfp = SFP(0)
mock_sw_control.return_value = True
assert not sfp._is_write_protected(page=0, page_offset=26, num_bytes=1)
mock_sw_control.return_value = False
mock_get_type_str.return_value = 'cmis'
assert sfp._is_write_protected(page=0, page_offset=26, num_bytes=1)
assert not sfp._is_write_protected(page=0, page_offset=27, num_bytes=1)