Skip to content

Commit

Permalink
Make is_flat_memory more robust (#491)
Browse files Browse the repository at this point in the history
- Description
Currently, is_flat_memory could return 3 different values:

True when the module is flat memory
False when the module is not flat memory
None when the EEPROM read returns None or empty bytearray
When it returns None, we should not assume that the module is NOT a flat memory. Instead, it would be safer to treat it as a flat memory.

- Motivation and Context
This PR is to make is_flat_memory only returns two state, True or False. And if EEPROM reading returns None or empty bytearray, we should treat the module as a flat memory.

- How Has This Been Tested?
Manual test
  • Loading branch information
Junchao-Mellanox authored and mssonicbld committed Sep 11, 2024
1 parent 14b2a06 commit 82dfb06
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion sonic_platform_base/sonic_xcvr/api/public/cmis.py
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ def get_voltage(self):
return float("{:.3f}".format(voltage))

def is_flat_memory(self):
return self.xcvr_eeprom.read(consts.FLAT_MEM_FIELD)
return self.xcvr_eeprom.read(consts.FLAT_MEM_FIELD) is not False

def get_temperature_support(self):
return not self.is_flat_memory()
Expand Down
2 changes: 1 addition & 1 deletion sonic_platform_base/sonic_xcvr/api/public/sff8436.py
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ def set_power_override(self, power_override, power_set):
return ret

def is_flat_memory(self):
return self.xcvr_eeprom.read(consts.FLAT_MEM_FIELD)
return self.xcvr_eeprom.read(consts.FLAT_MEM_FIELD) is not False

def get_tx_power_support(self):
return False
Expand Down
2 changes: 1 addition & 1 deletion sonic_platform_base/sonic_xcvr/api/public/sff8472.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ def tx_disable_channel(self, channel, disable):
return self.tx_disable(disable) if channel != 0 else True

def is_flat_memory(self):
return not self.xcvr_eeprom.read(consts.PAGING_SUPPORT_FIELD)
return not self.xcvr_eeprom.read(consts.PAGING_SUPPORT_FIELD) is not False

def get_temperature_support(self):
return self.xcvr_eeprom.read(consts.DDM_SUPPORT_FIELD)
Expand Down
2 changes: 1 addition & 1 deletion sonic_platform_base/sonic_xcvr/api/public/sff8636.py
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ def set_power_override(self, power_override, power_set):
return ret

def is_flat_memory(self):
return self.xcvr_eeprom.read(consts.FLAT_MEM_FIELD)
return self.xcvr_eeprom.read(consts.FLAT_MEM_FIELD) is not False

def get_tx_power_support(self):
if self.is_copper():
Expand Down
2 changes: 1 addition & 1 deletion sonic_platform_base/sonic_xcvr/api/xcvr_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -493,7 +493,7 @@ def is_flat_memory(self):
Returns:
A Boolean, True if flat memory, False if paging is implemented
If there is an issue with reading the xcvr, None should be returned.
If there is an issue with reading the xcvr, True should be returned.
"""
raise NotImplementedError

Expand Down

0 comments on commit 82dfb06

Please sign in to comment.