[Nokia ixs7215] sfputil support + component tests (#8445)
Deliver sfputil support for sfputil show eeprom and sfputil reset along with some component test case fixes Co-authored-by: Carl Keene <keene@nokia.com>
This commit is contained in:
parent
e71eeb7de9
commit
03ef275314
@ -1,4 +1,5 @@
|
||||
try:
|
||||
import glob
|
||||
import sonic_platform.platform
|
||||
import sonic_platform.chassis
|
||||
from sonic_sfp.sfputilbase import SfpUtilBase
|
||||
@ -14,6 +15,12 @@ class SfpUtil(SfpUtilBase):
|
||||
ports_in_block = 4
|
||||
|
||||
_port_to_eeprom_mapping = {}
|
||||
port_to_i2c_mapping = {
|
||||
49: 2,
|
||||
50: 3,
|
||||
51: 4,
|
||||
52: 5
|
||||
}
|
||||
_changed_ports = [0, 0, 0, 0]
|
||||
|
||||
@property
|
||||
@ -33,10 +40,21 @@ class SfpUtil(SfpUtilBase):
|
||||
return self._port_to_eeprom_mapping
|
||||
|
||||
def __init__(self):
|
||||
# print " SfpUtil(SfpUtilBase) re-directed to chassis PMON 2.0 "
|
||||
# Mux Ordering
|
||||
mux_dev = sorted(glob.glob("/sys/class/i2c-adapter/i2c-0/i2c-[0-9]"))
|
||||
eeprom_path = "/sys/class/i2c-adapter/i2c-{0}/{0}-0050/eeprom"
|
||||
y = 0
|
||||
for x in range(self.port_start, self.port_end + 1):
|
||||
mux_dev_num = mux_dev[y]
|
||||
self.port_to_i2c_mapping[x] = mux_dev_num[-1]
|
||||
y = y + 1
|
||||
port_eeprom_path = eeprom_path.format(self.port_to_i2c_mapping[x])
|
||||
self.port_to_eeprom_mapping[x] = port_eeprom_path
|
||||
self._port_to_eeprom_mapping[x] = port_eeprom_path
|
||||
SfpUtilBase.__init__(self)
|
||||
self.chassis = sonic_platform.platform.Platform().get_chassis()
|
||||
|
||||
self.chassis = sonic_platform.platform.Platform().get_chassis()
|
||||
|
||||
def reset(self, port_num):
|
||||
# print " SfpUtil(SfpUtilBase) re-directed to chassis PMON 2.0 "
|
||||
if self.chassis is not None:
|
||||
|
@ -75,6 +75,55 @@ class Component(ComponentBase):
|
||||
"""
|
||||
return self.name
|
||||
|
||||
def get_model(self):
|
||||
"""
|
||||
Retrieves the part number of the component
|
||||
Returns:
|
||||
string: Part number of component
|
||||
"""
|
||||
return 'NA'
|
||||
|
||||
def get_serial(self):
|
||||
"""
|
||||
Retrieves the serial number of the component
|
||||
Returns:
|
||||
string: Serial number of component
|
||||
"""
|
||||
return 'NA'
|
||||
|
||||
def get_presence(self):
|
||||
"""
|
||||
Retrieves the presence of the component
|
||||
Returns:
|
||||
bool: True if present, False if not
|
||||
"""
|
||||
return True
|
||||
|
||||
def get_status(self):
|
||||
"""
|
||||
Retrieves the operational status of the component
|
||||
Returns:
|
||||
bool: True if component is operating properly, False if not
|
||||
"""
|
||||
return True
|
||||
|
||||
def get_position_in_parent(self):
|
||||
"""
|
||||
Retrieves 1-based relative physical position in parent device.
|
||||
Returns:
|
||||
integer: The 1-based relative physical position in parent
|
||||
device or -1 if cannot determine the position
|
||||
"""
|
||||
return -1
|
||||
|
||||
def is_replaceable(self):
|
||||
"""
|
||||
Indicate whether component is replaceable.
|
||||
Returns:
|
||||
bool: True if it is replaceable.
|
||||
"""
|
||||
return False
|
||||
|
||||
def get_description(self):
|
||||
"""
|
||||
Retrieves the description of the component
|
||||
|
@ -777,42 +777,59 @@ class Sfp(SfpBase):
|
||||
|
||||
def reset(self):
|
||||
"""
|
||||
Reset SFP and return all user module settings to their default srate.
|
||||
Reset SFP.
|
||||
Returns:
|
||||
A boolean, True if successful, False if not
|
||||
"""
|
||||
"""
|
||||
if self.sfp_type == COPPER_TYPE:
|
||||
return False
|
||||
|
||||
path = "/sys/class/i2c-adapter/i2c-{0}/{0}-0050/sfp_port_reset"
|
||||
port_ps = path.format(self.port_to_i2c_mapping)
|
||||
|
||||
try:
|
||||
reg_file = open(port_ps, 'w')
|
||||
except IOError as e:
|
||||
# print "Error: unable to open file: %s" % str(e)
|
||||
return False
|
||||
|
||||
# toggle reset
|
||||
reg_file.seek(0)
|
||||
reg_file.write('1')
|
||||
self.tx_disable(True)
|
||||
time.sleep(1)
|
||||
reg_file.seek(0)
|
||||
reg_file.write('0')
|
||||
reg_file.close()
|
||||
self.tx_disable(False)
|
||||
|
||||
return True
|
||||
|
||||
def tx_disable(self, tx_disable):
|
||||
"""
|
||||
Disable SFP TX for all channels
|
||||
Disable SFP TX
|
||||
Args:
|
||||
tx_disable : A Boolean, True to enable tx_disable mode, False to disable
|
||||
tx_disable mode.
|
||||
Returns:
|
||||
Returns:
|
||||
A boolean, True if tx_disable is set successfully, False if not
|
||||
"""
|
||||
if smbus_present == 0: # if called from sfputil outside of pmon
|
||||
cmdstatus, register = cmd.getstatusoutput('sudo i2cget -y 0 0x41 0x5')
|
||||
if cmdstatus:
|
||||
sonic_logger.log_warning("sfp cmdstatus i2c get failed %s" % register )
|
||||
return False
|
||||
register = int(register, 16)
|
||||
else:
|
||||
bus = smbus.SMBus(0)
|
||||
DEVICE_ADDRESS = 0x41
|
||||
DEVICE_REG = 0x5
|
||||
register = bus.read_byte_data(DEVICE_ADDRESS, DEVICE_REG)
|
||||
|
||||
return NotImplementedError
|
||||
pos = [1, 2, 4, 8]
|
||||
mask = pos[self.index-SFP_PORT_START]
|
||||
if tx_disable == True:
|
||||
setbits = register | mask
|
||||
else:
|
||||
setbits = register & ~mask
|
||||
|
||||
if smbus_present == 0: # if called from sfputil outside of pmon
|
||||
cmdstatus, output = cmd.getstatusoutput('sudo i2cset -y -m 0x0f 0 0x41 0x5 %d' % setbits)
|
||||
if cmdstatus:
|
||||
sonic_logger.log_warning("sfp cmdstatus i2c write failed %s" % output )
|
||||
return False
|
||||
else:
|
||||
bus = smbus.SMBus(0)
|
||||
DEVICE_ADDRESS = 0x41
|
||||
DEVICE_REG = 0x5
|
||||
bus.write_byte_data(DEVICE_ADDRESS, DEVICE_REG, setbits)
|
||||
|
||||
return True
|
||||
|
||||
def tx_disable_channel(self, channel, disable):
|
||||
"""
|
||||
|
Loading…
Reference in New Issue
Block a user