Skip to content

Commit

Permalink
Address comments
Browse files Browse the repository at this point in the history
  • Loading branch information
aravindmani-1 committed Oct 7, 2021
1 parent 23691a6 commit 8ccb755
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 26 deletions.
48 changes: 27 additions & 21 deletions device/dell/x86_64-dellemc_z9332f_d1508-r0/plugins/sfputil.py
Original file line number Diff line number Diff line change
Expand Up @@ -294,32 +294,38 @@ def set_low_power_mode(self, port_num, lpmode):
return False
if port_num > self.PORTS_IN_BLOCK:
return False
# Port offset starts with 0x4000
port_offset = 16384 + ((port_num-1) * 16)
status = self.pci_get_value(self.BASE_RES_PATH, port_offset)
reg_value = int(status)

# Absence of status throws error
if (reg_value == ""):
return False

# Mask off 4th bit for presence
mask = (1 << 6)
if self.get_media_type(port_num) == 'QSFP_DD':
if lpmode is True:
write_val = 0x10
else:
write_val = 0x0

# LPMode is active high; set or clear the bit accordingly
if lpmode is True:
reg_value = reg_value | mask
write_val = 0x10
self._write_eeprom_bytes(self.port_to_eeprom_mapping[port_num], 26, 1, bytearray([write_val]))
return True
else:
reg_value = reg_value & ~mask
write_val = 0x0
# Port offset starts with 0x4000
port_offset = 16384 + ((port_num-1) * 16)
status = self.pci_get_value(self.BASE_RES_PATH, port_offset)
reg_value = int(status)

# Convert our register value back to a hex string and write back
status = self.pci_set_value(self.BASE_RES_PATH, reg_value, port_offset)
# Absence of status throws error
if (reg_value == ""):
return False

if self.get_media_type(port_num) == 'QSFP_DD':
self._write_eeprom_bytes(self.port_to_eeprom_mapping[port_num], 26, 1, bytearray([write_val]))
return True
# Mask off 4th bit for presence
mask = (1 << 6)

# LPMode is active high; set or clear the bit accordingly
if lpmode is True:
reg_value = reg_value | mask
else:
reg_value = reg_value & ~mask

# Convert our register value back to a hex string and write back
status = self.pci_set_value(self.BASE_RES_PATH, reg_value, port_offset)

return True

def reset(self, port_num):

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1243,7 +1243,15 @@ def set_lpmode(self, lpmode):
Sets the lpmode(low power mode) of this SFP
"""
try:
if self.sfp_type.startswith('QSFP'):
if self.sfp_type == 'QSFP_DD':
if lpmode is True:
write_val = 0x10
else:
write_val = 0x0

self._write_eeprom_bytes(26, 1, bytearray([write_val]))
return True
else:
# Port offset starts with 0x4000
port_offset = 16384 + ((self.index-1) * 16)

Expand All @@ -1256,15 +1264,11 @@ def set_lpmode(self, lpmode):
# LPMode is active high; set or clear the bit accordingly
if lpmode is True:
reg_value = reg_value | mask
write_val = 0x10
else:
reg_value = reg_value & ~mask
write_val = 0x0

# Convert our register value back to a hex string and write back
self.pci_set_value(self.BASE_RES_PATH, reg_value, port_offset)
if self.sfp_type == 'QSFP_DD':
self._write_eeprom_bytes(26, 1, bytearray([write_val]))
except ValueError:
return False
return True
Expand Down

0 comments on commit 8ccb755

Please sign in to comment.