[Mellanox] Remove EEPROM write limitation if it is software control (#17030)
- Why I did it When module is under software control (CMIS host management enabled), EEPROM should be controlled by software and there should be no limitation for any write operation. - How I did it Remove EEPROM write limitation if a module is under software control - How to verify it Manual test UT
This commit is contained in:
parent
dd39dd0e03
commit
0d62cf0e92
@ -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:
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user