Skip to content
Merged
Show file tree
Hide file tree
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
35 changes: 26 additions & 9 deletions device/alibaba/x86_64-alibaba_as13-32h-cl-r0/plugins/sfputil.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,17 +168,34 @@ def tx_disable(self, port_num, disable):
False -- enable port tx signal
@return True when operation success, False on failure.
"""
TX_DISABLE_BYTE_OFFSET = 86
if port_num not in range(self.port_start, self.port_end + 1) or type(disable) != bool:
return False

try:
disable = hex(1) if disable else hex(0)
port_name = self.get_port_name(port_num)
reg_file = open(
"/".join([self.PORT_INFO_PATH, port_name, "sfp_txdisable"]), "w")
reg_file.write(disable)
except IOError as e:
print "Error: unable to open file: %s" % str(e)
return False
# QSFP, set eeprom to disable tx
if port_num in self.qsfp_ports:
disable = b'\x0f' if disable else b'\x00'
# open eeprom
try:
with open(self.port_to_eeprom_mapping[port_num], mode="wb", buffering=0) as sysfsfile:
sysfsfile.seek(TX_DISABLE_BYTE_OFFSET)
sysfsfile.write(bytearray(disable))
except IOError:
return False
except:
return False

# SFP, set tx_disable pin
else:
try:
disable = hex(1) if disable else hex(0)
port_name = self.get_port_name(port_num)
reg_file = open(
"/".join([self.PORT_INFO_PATH, port_name, "sfp_txdisable"]), "w")
reg_file.write(disable)
reg_file.close()
except IOError as e:
print "Error: unable to open file: %s" % str(e)
return False

return True
35 changes: 26 additions & 9 deletions device/alibaba/x86_64-alibaba_as13-48f8h-cl-r0/plugins/sfputil.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,17 +168,34 @@ def tx_disable(self, port_num, disable):
False -- enable port tx signal
@return True when operation success, False on failure.
"""
TX_DISABLE_BYTE_OFFSET = 86
if port_num not in range(self.port_start, self.port_end + 1) or type(disable) != bool:
return False

try:
disable = hex(1) if disable else hex(0)
port_name = self.get_port_name(port_num)
reg_file = open(
"/".join([self.PORT_INFO_PATH, port_name, "sfp_txdisable"]), "w")
reg_file.write(disable)
except IOError as e:
print "Error: unable to open file: %s" % str(e)
return False
# QSFP, set eeprom to disable tx
if port_num in self.qsfp_ports:
disable = b'\x0f' if disable else b'\x00'
# open eeprom
try:
with open(self.port_to_eeprom_mapping[port_num], mode="wb", buffering=0) as sysfsfile:
sysfsfile.seek(TX_DISABLE_BYTE_OFFSET)
sysfsfile.write(bytearray(disable))
except IOError:
return False
except:
return False

# SFP, set tx_disable pin
else:
try:
disable = hex(1) if disable else hex(0)
port_name = self.get_port_name(port_num)
reg_file = open(
"/".join([self.PORT_INFO_PATH, port_name, "sfp_txdisable"]), "w")
reg_file.write(disable)
reg_file.close()
except IOError as e:
print "Error: unable to open file: %s" % str(e)
return False

return True
35 changes: 26 additions & 9 deletions device/alibaba/x86_64-alibaba_as23-128h-cl-r0/plugins/sfputil.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,17 +168,34 @@ def tx_disable(self, port_num, disable):
False -- enable port tx signal
@return True when operation success, False on failure.
"""
TX_DISABLE_BYTE_OFFSET = 86
if port_num not in range(self.port_start, self.port_end + 1) or type(disable) != bool:
return False

try:
disable = hex(1) if disable else hex(0)
port_name = self.get_port_name(port_num)
reg_file = open(
"/".join([self.PORT_INFO_PATH, port_name, "sfp_txdisable"]), "w")
reg_file.write(disable)
except IOError as e:
print "Error: unable to open file: %s" % str(e)
return False
# QSFP, set eeprom to disable tx
if port_num in self.qsfp_ports:
disable = b'\x0f' if disable else b'\x00'
# open eeprom
try:
with open(self.port_to_eeprom_mapping[port_num], mode="wb", buffering=0) as sysfsfile:
sysfsfile.seek(TX_DISABLE_BYTE_OFFSET)
sysfsfile.write(bytearray(disable))
except IOError:
return False
except:
return False

# SFP, set tx_disable pin
else:
try:
disable = hex(1) if disable else hex(0)
port_name = self.get_port_name(port_num)
reg_file = open(
"/".join([self.PORT_INFO_PATH, port_name, "sfp_txdisable"]), "w")
reg_file.write(disable)
reg_file.close()
except IOError as e:
print "Error: unable to open file: %s" % str(e)
return False

return True