Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restore optoe page to default 0 for active cables #548

Merged
merged 5 commits into from
Mar 3, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions sonic_platform_base/sonic_xcvr/sfp_optoe_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

from ..sfp_base import SfpBase

SFP_OPTOE_PAGE_OFFSET = 127

class SfpOptoeBase(SfpBase):
def __init__(self):
SfpBase.__init__(self)
Expand Down Expand Up @@ -261,6 +263,12 @@ def set_optoe_write_max(self, write_max):
except (OSError, IOError):
pass

def get_optoe_current_page(self):
return self.read_eeprom(SFP_OPTOE_PAGE_OFFSET, 1)

def set_page0(self):
self.write_eeprom(SFP_OPTOE_PAGE_OFFSET, 1, bytearray([0x00]))

def set_optoe_write_timeout(self, write_timeout):
sys_path = self.get_eeprom_path()
sys_path = sys_path.replace("eeprom", "write_timeout")
Expand All @@ -273,6 +281,10 @@ def set_optoe_write_timeout(self, write_timeout):
def read_eeprom(self, offset, num_bytes):
try:
with open(self.get_eeprom_path(), mode='rb', buffering=0) as f:
if offset > 127 and offset < 256 and self.get_optoe_current_page() != 0:
# Restoring the page to 0 helps in cases where the optoe driver failed to restore
# the page when say the module was busy with CDB command processing
self.set_page0()
f.seek(offset)
return bytearray(f.read(num_bytes))
except (OSError, IOError):
Expand Down
Loading