# sfputil.py # # Platform-specific SFP transceiver interface for SONiC # try: import time from sonic_sfp.sfputilbase import SfpUtilBase except ImportError as e: raise ImportError("%s - required module not found" % str(e)) class SfpUtil(SfpUtilBase): """Platform-specific SfpUtil class""" PORT_START = 48 PORT_END = 49 PORTS_IN_BLOCK = 1 EEPROM_OFFSET = 44 _port_to_eeprom_mapping = {} @property def port_start(self): return self.PORT_START @property def port_end(self): return self.PORT_END @property def qsfp_ports(self): return range(0) @property def port_to_eeprom_mapping(self): return self._port_to_eeprom_mapping def __init__(self): eeprom_path = "/sys/class/i2c-adapter/i2c-{0}/{0}-0050/eeprom" for x in range(0, self.port_end + 1): if x >= self.port_start and x <= self.port_end: self._port_to_eeprom_mapping[x] = eeprom_path.format(x - self.EEPROM_OFFSET) else: self._port_to_eeprom_mapping[x] = eeprom_path.format(x - x) 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 presence_path = "/sys/devices/platform/delta-et6248brb-gpio.0/SFP/sfp_mod_p{}" try: reg_file = open(presence_path.format(port_num - 47)) except IOError as e: print "Error: unable to open file: %s" % str(e) return False if int(reg_file.readline()) == 0: return True return False def get_low_power_mode(self, port_num): # Check for invalid port_num if port_num < self.port_start or port_num > self.port_end: return False return False def set_low_power_mode(self, port_num, lpmode): # Check for invalid port_num if port_num < self.port_start or port_num > self.port_end: return False return False def reset(self, port_num): # Check for invalid port_num if port_num < self.port_start or port_num > self.port_end: return False return False def get_transceiver_change_event(self): """ TODO: This function need to be implemented when decide to support monitoring SFP(Xcvrd) on this platform. """ raise NotImplementedError