def __init__(self, index, sfp_type, eeprom_path): SfpOptoeBase.__init__(self) self.sfp_type = sfp_type self.port_type = sfp_type self.index = index self.eeprom_path = eeprom_path self._initialize_media(delay=False)
def __init__(self, index, sfp_type, eeprom_path, sfp_control, sfp_ctrl_idx): SfpOptoeBase.__init__(self) self.sfp_type = sfp_type self.index = index + 1 self.eeprom_path = eeprom_path self.sfp_control = sfp_control self.sfp_ctrl_idx = sfp_ctrl_idx
def __init__(self, sfp_index=0): SfpOptoeBase.__init__(self) self._api_helper=APIHelper() # Init index self.index = sfp_index self.port_num = self.index + 1 # Init eeprom path eeprom_path = '/sys/bus/i2c/devices/{0}-0050/eeprom' self.port_to_eeprom_mapping = {} for x in range(self.PORT_START, self.PORT_END + 1): self.port_to_eeprom_mapping[x] = eeprom_path.format(self._port_to_i2c_mapping[x])
def __init__(self, index, sfp_type, eeprom_path): """ SFP Dunder init """ SfpOptoeBase.__init__(self) self.index = index self.eeprom_path = eeprom_path #port_type is the native port type and sfp_type is the transceiver type #sfp_type will be detected in get_transceiver_info self.port_type = sfp_type self.sfp_type = self.port_type self._initialize_media(delay=False)
def __init__(self, port_num): SfpOptoeBase.__init__(self) self.index = port_num self.port_num = port_num self.sfp_type = QSFP_TYPE if not os.path.exists(self.SFP_EEPROM_PATH): try: os.makedirs(self.SFP_EEPROM_PATH) except OSError as e: if e.errno != errno.EEXIST: raise self.eeprom_path = self.SFP_EEPROM_PATH + "sfp{}-eeprom-cache".format( self.index)
def set_lpmode(self, lpmode): """ Sets the lpmode(low power mode) of this SFP """ try: if self.sfp_type == 'QSFP_DD': return SfpOptoeBase.set_lpmode(self, lpmode) else: # Port offset starts with 0x4000 port_offset = 16384 + ((self.index - 1) * 16) status = self.pci_get_value(self.BASE_RES_PATH, port_offset) reg_value = int(status) # Mask off 6th bit for lowpower mode mask = (1 << 6) # LPMode is active high; set or clear the bit accordingly if lpmode is True: reg_value = reg_value | mask else: reg_value = reg_value & ~mask # Convert our register value back to a hex string and write back self.pci_set_value(self.BASE_RES_PATH, reg_value, port_offset) except ValueError: return False return True
def __init__(self, sfp_index=0): SfpOptoeBase.__init__(self) # Init index self.index = sfp_index self.port_num = self.index + 1 cpld_idx = 0 if self.port_num > 30 else 1 bus = CPLD_ADDR_MAPPING[cpld_idx]["bus"] addr = CPLD_ADDR_MAPPING[cpld_idx]["addr"] self.cpld_path = CPLD_I2C_PATH.format(bus, addr) # Init eeprom path eeprom_path = '/sys/bus/i2c/devices/{0}-0050/eeprom' self.port_to_eeprom_mapping = {} for x in range(self.PORT_START, self.PORT_END + 1): self.port_to_eeprom_mapping[x] = eeprom_path.format( self._port_to_i2c_mapping[x][0])
def __init__(self, index, pddf_data=None, pddf_plugin_data=None): if not pddf_data or not pddf_plugin_data: raise ValueError('PDDF JSON data error') self.pddf_obj = pddf_data self.plugin_data = pddf_plugin_data self.platform = self.pddf_obj.get_platform() # index is 0-based self._port_start = 0 self._port_end = int(self.platform['num_ports']) if index < self._port_start or index >= self._port_end: print("Invalid port index %d" % index) return self.port_index = index + 1 self.device = 'PORT{}'.format(self.port_index) self.sfp_type = self.pddf_obj.get_device_type(self.device) self.eeprom_path = self.pddf_obj.get_path(self.device, 'eeprom') SfpOptoeBase.__init__(self)
def get_lpmode(self): """ Retrieves the lpmode(low power mode) of this SFP """ lpmode_state = False try: if self.sfp_type == 'QSFP_DD': return SfpOptoeBase.get_lpmode(self) else: # Port offset starts with 0x4000 port_offset = 16384 + ((self.index - 1) * 16) status = self.pci_get_value(self.BASE_RES_PATH, port_offset) reg_value = int(status) # Mask off 6th bit for lpmode mask = (1 << 6) lpmode_state = (reg_value & mask) except ValueError: pass return bool(lpmode_state)
def __init__(self, index, sfp_type, eeprom_path): SfpOptoeBase.__init__(self) self.sfp_type = sfp_type self.index = index self.eeprom_path = eeprom_path