Skip to content

Commit

Permalink
[Mellanox]: Add get_presence implementation for SFP on Mellanox platf…
Browse files Browse the repository at this point in the history
…orms (#1056)

Signed-off-by: Andriy Moroz <c_andriym@mellanox.com>
  • Loading branch information
andriymoroz-mlnx authored and Shuotian Cheng committed Oct 20, 2017
1 parent a9566bd commit 587b14a
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 3 deletions.
17 changes: 16 additions & 1 deletion device/mellanox/x86_64-mlnx_msn2410-r0/plugins/sfputil.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,23 @@ def __init__(self):
SfpUtilBase.__init__(self)

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

raise NotImplementedError
try:
reg_file = open("/bsp/qsfp/qsfp%d_status" % (port_num+1))
except IOError as e:
print "Error: unable to open file: %s" % str(e)
return False

content = reg_file.readline().rstrip()

# content is a string with the qsfp status
if content == "good":
return True

return False

def get_low_power_mode(self, port_num):

Expand Down
17 changes: 16 additions & 1 deletion device/mellanox/x86_64-mlnx_msn2700-r0/plugins/sfputil.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,23 @@ def __init__(self):
SfpUtilBase.__init__(self)

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

raise NotImplementedError
try:
reg_file = open("/bsp/qsfp/qsfp%d_status" % (port_num+1))
except IOError as e:
print "Error: unable to open file: %s" % str(e)
return False

content = reg_file.readline().rstrip()

# content is a string with the qsfp status
if content == "good":
return True

return False

def get_low_power_mode(self, port_num):

Expand Down
17 changes: 16 additions & 1 deletion device/mellanox/x86_64-mlnx_msn2740-r0/plugins/sfputil.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,23 @@ def __init__(self):
SfpUtilBase.__init__(self)

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

raise NotImplementedError
try:
reg_file = open("/bsp/qsfp/qsfp%d_status" % (port_num+1))
except IOError as e:
print "Error: unable to open file: %s" % str(e)
return False

content = reg_file.readline().rstrip()

# content is a string with the qsfp status
if content == "good":
return True

return False

def get_low_power_mode(self, port_num):

Expand Down

0 comments on commit 587b14a

Please sign in to comment.