Skip to content

Commit

Permalink
Adding support for get/set low pwer mode for QSFPs in PDDF common APIs
Browse files Browse the repository at this point in the history
  • Loading branch information
FuzailBrcm committed Aug 19, 2022
1 parent 3ea5e83 commit 13baefe
Showing 1 changed file with 28 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
except ImportError as e:
raise ImportError(str(e) + "- required module not found")

QSFP_PWR_CTRL_ADDR = 93


class PddfSfp(SfpOptoeBase):
"""
Expand Down Expand Up @@ -194,8 +196,18 @@ def get_lpmode(self):
else:
lpmode = False
else:
# Use common SfpOptoeBase implementation for get_lpmode
lpmode = super().get_lpmode()
xcvr_id = self._xcvr_api_factory._get_id()
if xcvr_id is not None:
if xcvr_id == 0x18 or xcvr_id == 0x19 or xcvr_id == 0x1e:
# QSFP-DD or OSFP
# Use common SfpOptoeBase implementation for get_lpmode
lpmode = super().get_lpmode()
elif xcvr_id == 0x11 or xcvr_id == 0x0d or xcvr_id == 0x0c:
# QSFP28, QSFP+, QSFP
val = self.read_eeprom(QSFP_PWR_CTRL_ADDR, 1)
if val is not None:
if (ord(val) & 0x3) == 0x3:
lpmode = True

return lpmode

Expand Down Expand Up @@ -321,8 +333,20 @@ def set_lpmode(self, lpmode):
except IOError as e:
status = False
else:
# Use common SfpOptoeBase implementation for set_lpmode
status = super().set_lpmode(lpmode)
xcvr_id = self._xcvr_api_factory._get_id()
if xcvr_id is not None:
if xcvr_id == 0x18 or xcvr_id == 0x19 or xcvr_id == 0x1e:
# QSFP-DD or OSFP
# Use common SfpOptoeBase implementation for set_lpmode
status = super().set_lpmode(lpmode)
elif xcvr_id == 0x11 or xcvr_id == 0x0d or xcvr_id == 0x0c:
# QSFP28, QSFP+, QSFP
val = self.read_eeprom(QSFP_PWR_CTRL_ADDR, 1)
if val is not None:
val = ord(val) & 0xf0
val |= 0x3 if lpmode else 0xd
buf = bytearray([val])
status = self.write_eeprom(QSFP_PWR_CTRL_ADDR, 1, buf)

return status

Expand Down

0 comments on commit 13baefe

Please sign in to comment.