Skip to content

Commit

Permalink
[E1031] Update sonic_platform.sfp.Sfp class to fix xcvrd crash issue (s…
Browse files Browse the repository at this point in the history
…onic-net#18495)

* [E1031] Update sonic_platform class Sfp

* Add implementation for get_eeprom_path
  • Loading branch information
lizhijianrd authored Apr 2, 2024
1 parent aea7d55 commit 7b04c69
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions device/celestica/x86_64-cel_e1031-r0/sonic_platform/sfp.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
try:
import time
from ctypes import c_char
from sonic_platform_base.sfp_base import SfpBase
from sonic_platform_base.sonic_xcvr.sfp_optoe_base import SfpOptoeBase
from sonic_platform_base.sonic_sfp.sff8472 import sff8472InterfaceId
from sonic_platform_base.sonic_sfp.sff8472 import sff8472Dom
from sonic_platform_base.sonic_sfp.sff8436 import sff8436InterfaceId
Expand Down Expand Up @@ -157,7 +157,7 @@
PORT_END = 55


class Sfp(SfpBase):
class Sfp(SfpOptoeBase):
"""Platform-specific Sfp class"""

# Port I2C number
Expand All @@ -172,7 +172,7 @@ class Sfp(SfpBase):
PRS_PATH = "/sys/devices/platform/e1031.smc/SFP/sfp_modabs"

def __init__(self, sfp_index, sfp_name):
SfpBase.__init__(self)
SfpOptoeBase.__init__(self)

# Init common function
self._api_common = Common()
Expand Down Expand Up @@ -235,7 +235,7 @@ def _read_eeprom_specific_bytes(self, offset, num_bytes):
for i in range(0, num_bytes):
eeprom_raw.append("0x00")

sysfs_sfp_i2c_client_eeprom_path = self.port_to_eeprom_mapping[self.port_num]
sysfs_sfp_i2c_client_eeprom_path = self.get_eeprom_path()
try:
sysfsfile_eeprom = open(
sysfs_sfp_i2c_client_eeprom_path, mode="rb", buffering=0)
Expand Down Expand Up @@ -355,6 +355,9 @@ def _dom_capability_detect(self):
self.dom_rx_power_supported = False
self.dom_tx_power_supported = False

def get_eeprom_path(self):
return self.port_to_eeprom_mapping[self.port_num]

def get_transceiver_info(self):
"""
Retrieves transceiver info of this SFP
Expand Down Expand Up @@ -1176,7 +1179,7 @@ def tx_disable(self, tx_disable):
if self.dom_tx_disable_supported:
# SFP status/control register at address A2h, byte 110
offset = 256
sysfs_sfp_i2c_client_eeprom_path = self.port_to_eeprom_mapping[self.port_num]
sysfs_sfp_i2c_client_eeprom_path = self.get_eeprom_path()
status_control_raw = self._read_eeprom_specific_bytes(
(offset + SFP_STATUS_CONTROL_OFFSET), SFP_STATUS_CONTROL_WIDTH)
if status_control_raw is not None:
Expand Down

0 comments on commit 7b04c69

Please sign in to comment.