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

Fix celestica's seastone sfputil for lpmode and transceiver presence #1358

Merged
merged 20 commits into from
Feb 1, 2018
Merged
Changes from all commits
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
48 changes: 46 additions & 2 deletions device/celestica/x86_64-cel_seastone-r0/plugins/sfputil.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,54 @@ def __init__(self):
SfpUtilBase.__init__(self)

def get_presence(self, port_num):
raise NotImplementedError
# Check for invalid port_num
if port_num < self.port_start or port_num > self.port_end:
return False

try:
reg_file = open("/sys/devices/platform/dx010_cpld/qsfp_modprs", "r")
except IOError as e:
print "Error: unable to open file: %s" % str(e)
return False

content = reg_file.readline().rstrip()

# content is a string containing the hex representation of the register
reg_value = int(content, 16)

# Mask off the bit corresponding to our port
mask = (1 << port_num)

# ModPrsL is active low
if reg_value & mask == 0:
return True

return False

def get_low_power_mode(self, port_num):
raise NotImplementedError
# Check for invalid port_num
if port_num < self.port_start or port_num > self.port_end:
return False

try:
reg_file = open("/sys/devices/platform/dx010_cpld/qsfp_lpmode", "r")
except IOError as e:
print "Error: unable to open file: %s" % str(e)
return False

content = reg_file.readline().rstrip()

# content is a string containing the hex representation of the register
reg_value = int(content, 16)

# Mask off the bit corresponding to our port
mask = (1 << port_num)

# LPMode is active high
if reg_value & mask == 0:
return False

return True

def set_low_power_mode(self, port_num, lpmode):
raise NotImplementedError
Expand Down