def get_tx_disable(self): """ Retrieves the tx_disable status of this SFP Returns: A Boolean, True if tx_disable is enabled, False if disabled """ tx_disable = False tx_disable_list = [] sfpd_obj = sff8436Dom() if sfpd_obj is None: return tx_disable dom_control_raw = self.__read_eeprom_specific_bytes( QSFP_CONTROL_OFFSET, QSFP_CONTROL_WIDTH) if dom_control_raw is not None: dom_control_data = sfpd_obj.parse_control_bytes(dom_control_raw, 0) tx_disable_list.append( 'On' == dom_control_data['data']['TX1Disable']['value']) tx_disable_list.append( 'On' == dom_control_data['data']['TX2Disable']['value']) tx_disable_list.append( 'On' == dom_control_data['data']['TX3Disable']['value']) tx_disable_list.append( 'On' == dom_control_data['data']['TX4Disable']['value']) tx_disable = tx_disable_list[0] and tx_disable_list[ 1] and tx_disable_list[2] and tx_disable_list[3] return tx_disable
def get_tx_disable_channel(self): """ Retrieves the TX disabled channels in this SFP Returns: A hex of 4 bits (bit 0 to bit 3 as channel 0 to channel 3) to represent TX channels which have been disabled in this SFP. As an example, a returned value of 0x5 indicates that channel 0 and channel 2 have been disabled. """ tx_disable_channel = 0 tx_disable_list = [] sfpd_obj = sff8436Dom() if sfpd_obj is None: return tx_disable_channel dom_control_raw = self.__read_eeprom_specific_bytes(QSFP_CONTROL_OFFSET, QSFP_CONTROL_WIDTH) if dom_control_raw is not None: dom_control_data = sfpd_obj.parse_control_bytes(dom_control_raw, 0) tx_disable_list.append('On' == dom_control_data['data']['TX1Disable']['value']) tx_disable_list.append('On' == dom_control_data['data']['TX2Disable']['value']) tx_disable_list.append('On' == dom_control_data['data']['TX3Disable']['value']) tx_disable_list.append('On' == dom_control_data['data']['TX4Disable']['value']) for i in range(len(tx_disable_list)): if tx_disable_list[i]: tx_disable_channel |= 1 << i return tx_disable_channel
def get_low_power_mode(self, port_num): """ Not support LPMode pin to control lpmde. This function is affected by the Power_over-ride and Power_set software control bits (byte 93 bits 0,1) """ if port_num < self.port_start or port_num > self.port_end: return False if port_num in self.qsfp_ports: offset = 0 sfpd_obj = sff8436Dom() if sfpd_obj is None: return False sysfs_sfp_i2c_client_eeprom_path = self._get_port_eeprom_path( port_num, self.IDENTITY_EEPROM_ADDR) with open(sysfs_sfp_i2c_client_eeprom_path, "rb", buffering=0) as sysfsfile: dom_control_raw = self._read_eeprom_specific_bytes( sysfsfile, offset + self.QSFP_CONTROL_OFFSET, self.QSFP_CONTROL_WIDTH ) if self.get_presence(port_num) else None if dom_control_raw is not None: dom_control_data = sfpd_obj.parse_control_bytes( dom_control_raw, 0) lpmode = ( 'On' == dom_control_data['data']['PowerSet']['value']) power_override = ( 'On' == dom_control_data['data']['PowerOverride']['value']) if lpmode == power_override == True: return True else: # SFP doesn't support this feature return False return False
def __init__(self, index, sfp_type, eeprom_path): SfpBase.__init__(self) self.sfp_type = sfp_type self.index = index self.eeprom_path = eeprom_path self.qsfpInfo = sff8436InterfaceId() self.qsfpDomInfo = sff8436Dom() self.sfpInfo = sff8472InterfaceId() self.sfpDomInfo = sff8472Dom(None, 1)
def __init__(self, index, sfp_type, eeprom_path, sfp_control, sfp_ctrl_idx): SfpBase.__init__(self) self.sfp_type = sfp_type self.index = index self.eeprom_path = eeprom_path self.sfp_control = sfp_control self.sfp_ctrl_idx = sfp_ctrl_idx self.sfpInfo = sff8436InterfaceId() self.sfpDomInfo = sff8436Dom()
def __init__(self, index, sfp_type, eeprom_path): SfpBase.__init__(self) self.index = index self.eeprom_path = eeprom_path #sfp_type is the native port type and media_type is the transceiver type #media_type will be detected in get_transceiver_info self.sfp_type = sfp_type self.media_type = self.sfp_type self.qsfpInfo = sff8436InterfaceId() self.qsfpDomInfo = sff8436Dom() self.sfpInfo = sff8472InterfaceId() self.sfpDomInfo = sff8472Dom(None, 1)
def get_rx_power(self): """ Retrieves the received optical power for this SFP Returns: A list of four integer numbers, representing received optical power in mW for channel 0 to channel 4. Ex. ['1.77', '1.71', '1.68', '1.70'] """ rx_power_list = [] sfpd_obj = sff8436Dom() sfpi_obj = sff8436InterfaceId() offset = DOM_OFFSET offset_xcvr = INFO_OFFSET if not self.get_presence() or not sfpd_obj: return [] qsfp_dom_capability_raw = self.__read_eeprom_specific_bytes((offset_xcvr + XCVR_DOM_CAPABILITY_OFFSET), XCVR_DOM_CAPABILITY_WIDTH) if qsfp_dom_capability_raw is not None: qspf_dom_capability_data = sfpi_obj.parse_dom_capability(qsfp_dom_capability_raw, 0) else: return None qsfp_dom_rev_raw = self.__read_eeprom_specific_bytes((offset + QSFP_DOM_REV_OFFSET), QSFP_DOM_REV_WIDTH) if qsfp_dom_rev_raw is not None: qsfp_dom_rev_data = sfpd_obj.parse_sfp_dom_rev(qsfp_dom_rev_raw, 0) qsfp_dom_rev = qsfp_dom_rev_data['data']['dom_rev']['value'] dom_channel_monitor_data = {} dom_channel_monitor_raw = None qsfp_tx_power_support = qspf_dom_capability_data['data']['Tx_power_support']['value'] if (qsfp_dom_rev[0:8] != 'SFF-8636' or (qsfp_dom_rev[0:8] == 'SFF-8636' and qsfp_tx_power_support != 'on')): dom_channel_monitor_raw = self.__read_eeprom_specific_bytes((offset + QSFP_CHANNL_MON_OFFSET), QSFP_CHANNL_MON_WIDTH) if dom_channel_monitor_raw is not None: dom_channel_monitor_data = sfpd_obj.parse_channel_monitor_params(dom_channel_monitor_raw, 0) else: dom_channel_monitor_raw = self.__read_eeprom_specific_bytes((offset + QSFP_CHANNL_MON_OFFSET), QSFP_CHANNL_MON_WITH_TX_POWER_WIDTH) if dom_channel_monitor_raw is not None: dom_channel_monitor_data = sfpd_obj.parse_channel_monitor_params_with_tx_power(dom_channel_monitor_raw, 0) if dom_channel_monitor_raw is not None: rx_power_list.append(self.__convert_string_to_num(dom_channel_monitor_data['data']['RX1Power']['value'])) rx_power_list.append(self.__convert_string_to_num(dom_channel_monitor_data['data']['RX2Power']['value'])) rx_power_list.append(self.__convert_string_to_num(dom_channel_monitor_data['data']['RX3Power']['value'])) rx_power_list.append(self.__convert_string_to_num(dom_channel_monitor_data['data']['RX4Power']['value'])) return rx_power_list
def get_tx_bias(self): """ Retrieves the TX bias current of this SFP Returns: A list of four integer numbers, representing TX bias in mA for channel 0 to channel 4. Ex. ['110.09', '111.12', '108.21', '112.09'] """ tx_bias_list = [] sfpd_obj = sff8436Dom() sfpi_obj = sff8436InterfaceId() offset = DOM_OFFSET offset_xcvr = INFO_OFFSET if not self.get_presence() or not sfpd_obj: return [] qsfp_dom_capability_raw = self.__read_eeprom_specific_bytes((offset_xcvr + XCVR_DOM_CAPABILITY_OFFSET), XCVR_DOM_CAPABILITY_WIDTH) if qsfp_dom_capability_raw is not None: qspf_dom_capability_data = sfpi_obj.parse_dom_capability(qsfp_dom_capability_raw, 0) else: return None qsfp_dom_rev_raw = self.__read_eeprom_specific_bytes((offset + QSFP_DOM_REV_OFFSET), QSFP_DOM_REV_WIDTH) if qsfp_dom_rev_raw is not None: qsfp_dom_rev_data = sfpd_obj.parse_sfp_dom_rev(qsfp_dom_rev_raw, 0) qsfp_dom_rev = qsfp_dom_rev_data['data']['dom_rev']['value'] dom_channel_monitor_data = {} dom_channel_monitor_raw = None qsfp_tx_power_support = qspf_dom_capability_data['data']['Tx_power_support']['value'] if (qsfp_dom_rev[0:8] != 'SFF-8636' or (qsfp_dom_rev[0:8] == 'SFF-8636' and qsfp_tx_power_support != 'on')): dom_channel_monitor_raw = self.__read_eeprom_specific_bytes((offset + QSFP_CHANNL_MON_OFFSET), QSFP_CHANNL_MON_WIDTH) if dom_channel_monitor_raw is not None: dom_channel_monitor_data = sfpd_obj.parse_channel_monitor_params(dom_channel_monitor_raw, 0) else: dom_channel_monitor_raw = self.__read_eeprom_specific_bytes((offset + QSFP_CHANNL_MON_OFFSET), QSFP_CHANNL_MON_WITH_TX_POWER_WIDTH) if dom_channel_monitor_raw is not None: dom_channel_monitor_data = sfpd_obj.parse_channel_monitor_params_with_tx_power(dom_channel_monitor_raw, 0) if dom_channel_monitor_raw is not None: tx_bias_list.append(self.__convert_string_to_num(dom_channel_monitor_data['data']['TX1Bias']['value'])) tx_bias_list.append(self.__convert_string_to_num(dom_channel_monitor_data['data']['TX2Bias']['value'])) tx_bias_list.append(self.__convert_string_to_num(dom_channel_monitor_data['data']['TX3Bias']['value'])) tx_bias_list.append(self.__convert_string_to_num(dom_channel_monitor_data['data']['TX4Bias']['value'])) return tx_bias_list
def get_power_override(self): """ Retrieves the power-override status of this SFP Returns: A Boolean, True if power-override is enabled, False if disabled """ power_override = False sfpd_obj = sff8436Dom() if sfpd_obj is None: return power_override dom_control_raw = self.__read_eeprom_specific_bytes(QSFP_CONTROL_OFFSET, QSFP_CONTROL_WIDTH) if dom_control_raw is not None: dom_control_data = sfpd_obj.parse_control_bytes(dom_control_raw, 0) power_override = ('On' == dom_control_data['data']['PowerOverride']['value']) return power_override
def get_temperature(self): """ Retrieves the temperature of this SFP Returns: An integer number of current temperature in Celsius """ temp = "N/A" sfpd_obj = sff8436Dom() offset = DOM_OFFSET if not self.get_presence() or not sfpd_obj: return temp dom_temperature_raw = self.__read_eeprom_specific_bytes((offset + QSFP_TEMPE_OFFSET), QSFP_TEMPE_WIDTH) if dom_temperature_raw is not None: dom_temperature_data = sfpd_obj.parse_temperature(dom_temperature_raw, 0) temp = self.__convert_string_to_num(dom_temperature_data['data']['Temperature']['value']) return temp
def get_voltage(self): """ Retrieves the supply voltage of this SFP Returns: An integer number of supply voltage in mV """ voltage = "N/A" sfpd_obj = sff8436Dom() offset = DOM_OFFSET if not self.get_presence() or not sfpd_obj: return voltage dom_voltage_raw = self.__read_eeprom_specific_bytes((offset + QSFP_VOLT_OFFSET), QSFP_VOLT_WIDTH) if dom_voltage_raw is not None: dom_voltage_data = sfpd_obj.parse_voltage(dom_voltage_raw, 0) voltage = self.__convert_string_to_num(dom_voltage_data['data']['Vcc']['value']) return voltage
def get_transceiver_threshold_info(self): """ Retrieves transceiver threshold info of this SFP Returns: A dict which contains following keys/values : ======================================================================== keys |Value Format |Information ---------------------------|---------------|---------------------------- temphighalarm |FLOAT |High Alarm Threshold value of temperature in Celsius. templowalarm |FLOAT |Low Alarm Threshold value of temperature in Celsius. temphighwarning |FLOAT |High Warning Threshold value of temperature in Celsius. templowwarning |FLOAT |Low Warning Threshold value of temperature in Celsius. vcchighalarm |FLOAT |High Alarm Threshold value of supply voltage in mV. vcclowalarm |FLOAT |Low Alarm Threshold value of supply voltage in mV. vcchighwarning |FLOAT |High Warning Threshold value of supply voltage in mV. vcclowwarning |FLOAT |Low Warning Threshold value of supply voltage in mV. rxpowerhighalarm |FLOAT |High Alarm Threshold value of received power in dBm. rxpowerlowalarm |FLOAT |Low Alarm Threshold value of received power in dBm. rxpowerhighwarning |FLOAT |High Warning Threshold value of received power in dBm. rxpowerlowwarning |FLOAT |Low Warning Threshold value of received power in dBm. txpowerhighalarm |FLOAT |High Alarm Threshold value of transmit power in dBm. txpowerlowalarm |FLOAT |Low Alarm Threshold value of transmit power in dBm. txpowerhighwarning |FLOAT |High Warning Threshold value of transmit power in dBm. txpowerlowwarning |FLOAT |Low Warning Threshold value of transmit power in dBm. txbiashighalarm |FLOAT |High Alarm Threshold value of tx Bias Current in mA. txbiaslowalarm |FLOAT |Low Alarm Threshold value of tx Bias Current in mA. txbiashighwarning |FLOAT |High Warning Threshold value of tx Bias Current in mA. txbiaslowwarning |FLOAT |Low Warning Threshold value of tx Bias Current in mA. ======================================================================== """ # check present status if not self.get_presence(): return None xcvr_dom_threshold_info_dict = dict.fromkeys(self.threshold_dict_keys, 'N/A') if self.is_osfp_port: # Below part is added to avoid fail xcvrd, shall be implemented later pass elif self.is_qsfp_port: # QSFPs sfpd_obj = sff8436Dom() if sfpd_obj is None: return None dom_thres_raw = self.__read_eeprom_specific_bytes( QSFP_MODULE_THRESHOLD_OFFSET, QSFP_MODULE_THRESHOLD_WIDTH) if dom_thres_raw: module_threshold_values = sfpd_obj.parse_module_threshold_values( dom_thres_raw, 0) module_threshold_data = module_threshold_values.get('data') if module_threshold_data: xcvr_dom_threshold_info_dict[ 'temphighalarm'] = module_threshold_data[ 'TempHighAlarm']['value'] xcvr_dom_threshold_info_dict[ 'templowalarm'] = module_threshold_data[ 'TempLowAlarm']['value'] xcvr_dom_threshold_info_dict[ 'temphighwarning'] = module_threshold_data[ 'TempHighWarning']['value'] xcvr_dom_threshold_info_dict[ 'templowwarning'] = module_threshold_data[ 'TempLowWarning']['value'] xcvr_dom_threshold_info_dict[ 'vcchighalarm'] = module_threshold_data[ 'VccHighAlarm']['value'] xcvr_dom_threshold_info_dict[ 'vcclowalarm'] = module_threshold_data['VccLowAlarm'][ 'value'] xcvr_dom_threshold_info_dict[ 'vcchighwarning'] = module_threshold_data[ 'VccHighWarning']['value'] xcvr_dom_threshold_info_dict[ 'vcclowwarning'] = module_threshold_data[ 'VccLowWarning']['value'] dom_thres_raw = self.__read_eeprom_specific_bytes( QSFP_CHANNEL_THRESHOLD_OFFSET, QSFP_CHANNEL_THRESHOLD_WIDTH) if dom_thres_raw: channel_threshold_values = sfpd_obj.parse_channel_threshold_values( dom_thres_raw, 0) channel_threshold_data = channel_threshold_values.get('data') if channel_threshold_data: xcvr_dom_threshold_info_dict[ 'rxpowerhighalarm'] = channel_threshold_data[ 'RxPowerHighAlarm']['value'] xcvr_dom_threshold_info_dict[ 'rxpowerlowalarm'] = channel_threshold_data[ 'RxPowerLowAlarm']['value'] xcvr_dom_threshold_info_dict[ 'rxpowerhighwarning'] = channel_threshold_data[ 'RxPowerHighWarning']['value'] xcvr_dom_threshold_info_dict[ 'rxpowerlowwarning'] = channel_threshold_data[ 'RxPowerLowWarning']['value'] xcvr_dom_threshold_info_dict['txpowerhighalarm'] = "0.0dBm" xcvr_dom_threshold_info_dict['txpowerlowalarm'] = "0.0dBm" xcvr_dom_threshold_info_dict[ 'txpowerhighwarning'] = "0.0dBm" xcvr_dom_threshold_info_dict[ 'txpowerlowwarning'] = "0.0dBm" xcvr_dom_threshold_info_dict[ 'txbiashighalarm'] = channel_threshold_data[ 'TxBiasHighAlarm']['value'] xcvr_dom_threshold_info_dict[ 'txbiaslowalarm'] = channel_threshold_data[ 'TxBiasLowAlarm']['value'] xcvr_dom_threshold_info_dict[ 'txbiashighwarning'] = channel_threshold_data[ 'TxBiasHighWarning']['value'] xcvr_dom_threshold_info_dict[ 'txbiaslowwarning'] = channel_threshold_data[ 'TxBiasLowWarning']['value'] else: # SFPs sfpd_obj = sff8472Dom() offset = 256 eeprom_ifraw = self.__read_eeprom_specific_bytes(0, offset) sfpi_obj = sff8472InterfaceId(eeprom_ifraw) cal_type = sfpi_obj.get_calibration_type() sfpd_obj._calibration_type = cal_type dom_module_threshold_raw = self.__read_eeprom_specific_bytes( (offset + SFP_MODULE_THRESHOLD_OFFSET), SFP_MODULE_THRESHOLD_WIDTH) if dom_module_threshold_raw is not None: dom_module_threshold_data = sfpd_obj.parse_alarm_warning_threshold( dom_module_threshold_raw, 0) xcvr_dom_threshold_info_dict[ 'temphighalarm'] = dom_module_threshold_data['data'][ 'TempHighAlarm']['value'] xcvr_dom_threshold_info_dict[ 'templowalarm'] = dom_module_threshold_data['data'][ 'TempLowAlarm']['value'] xcvr_dom_threshold_info_dict[ 'temphighwarning'] = dom_module_threshold_data['data'][ 'TempHighWarning']['value'] xcvr_dom_threshold_info_dict[ 'templowwarning'] = dom_module_threshold_data['data'][ 'TempLowWarning']['value'] xcvr_dom_threshold_info_dict[ 'vcchighalarm'] = dom_module_threshold_data['data'][ 'VoltageHighAlarm']['value'] xcvr_dom_threshold_info_dict[ 'vcclowalarm'] = dom_module_threshold_data['data'][ 'VoltageLowAlarm']['value'] xcvr_dom_threshold_info_dict[ 'vcchighwarning'] = dom_module_threshold_data['data'][ 'VoltageHighWarning']['value'] xcvr_dom_threshold_info_dict[ 'vcclowwarning'] = dom_module_threshold_data['data'][ 'VoltageLowWarning']['value'] xcvr_dom_threshold_info_dict[ 'txbiashighalarm'] = dom_module_threshold_data['data'][ 'BiasHighAlarm']['value'] xcvr_dom_threshold_info_dict[ 'txbiaslowalarm'] = dom_module_threshold_data['data'][ 'BiasLowAlarm']['value'] xcvr_dom_threshold_info_dict[ 'txbiashighwarning'] = dom_module_threshold_data['data'][ 'BiasHighWarning']['value'] xcvr_dom_threshold_info_dict[ 'txbiaslowwarning'] = dom_module_threshold_data['data'][ 'BiasLowWarning']['value'] xcvr_dom_threshold_info_dict[ 'txpowerhighalarm'] = dom_module_threshold_data['data'][ 'TXPowerHighAlarm']['value'] xcvr_dom_threshold_info_dict[ 'txpowerlowalarm'] = dom_module_threshold_data['data'][ 'TXPowerLowAlarm']['value'] xcvr_dom_threshold_info_dict[ 'txpowerhighwarning'] = dom_module_threshold_data['data'][ 'TXPowerHighWarning']['value'] xcvr_dom_threshold_info_dict[ 'txpowerlowwarning'] = dom_module_threshold_data['data'][ 'TXPowerLowWarning']['value'] xcvr_dom_threshold_info_dict[ 'rxpowerhighalarm'] = dom_module_threshold_data['data'][ 'RXPowerHighAlarm']['value'] xcvr_dom_threshold_info_dict[ 'rxpowerlowalarm'] = dom_module_threshold_data['data'][ 'RXPowerLowAlarm']['value'] xcvr_dom_threshold_info_dict[ 'rxpowerhighwarning'] = dom_module_threshold_data['data'][ 'RXPowerHighWarning']['value'] xcvr_dom_threshold_info_dict[ 'rxpowerlowwarning'] = dom_module_threshold_data['data'][ 'RXPowerLowWarning']['value'] return xcvr_dom_threshold_info_dict
def __dom_capability_detect(self): self.dom_supported = False self.dom_temp_supported = False self.dom_volt_supported = False self.dom_rx_power_supported = False self.dom_tx_power_supported = False self.qsfp_page3_available = False self.calibration = 0 if not self.get_presence(): return if self.is_osfp_port: # Not implement return elif self.is_qsfp_port: self.calibration = 1 sfpi_obj = sff8436InterfaceId() if sfpi_obj is None: self.dom_supported = False offset = 128 # QSFP capability byte parse, through this byte can know whether it support tx_power or not. # TODO: in the future when decided to migrate to support SFF-8636 instead of SFF-8436, # need to add more code for determining the capability and version compliance # in SFF-8636 dom capability definitions evolving with the versions. qsfp_dom_capability_raw = self.__read_eeprom_specific_bytes( (offset + XCVR_DOM_CAPABILITY_OFFSET), XCVR_DOM_CAPABILITY_WIDTH) if qsfp_dom_capability_raw is not None: qsfp_version_compliance_raw = self.__read_eeprom_specific_bytes( QSFP_VERSION_COMPLIANCE_OFFSET, QSFP_VERSION_COMPLIANCE_WIDTH) qsfp_version_compliance = int(qsfp_version_compliance_raw[0], 16) dom_capability = sfpi_obj.parse_dom_capability( qsfp_dom_capability_raw, 0) if qsfp_version_compliance >= 0x08: self.dom_temp_supported = dom_capability['data'][ 'Temp_support']['value'] == 'On' self.dom_volt_supported = dom_capability['data'][ 'Voltage_support']['value'] == 'On' self.dom_rx_power_supported = dom_capability['data'][ 'Rx_power_support']['value'] == 'On' self.dom_tx_power_supported = dom_capability['data'][ 'Tx_power_support']['value'] == 'On' else: self.dom_temp_supported = True self.dom_volt_supported = True self.dom_rx_power_supported = dom_capability['data'][ 'Rx_power_support']['value'] == 'On' self.dom_tx_power_supported = True self.dom_supported = True self.calibration = 1 sfpd_obj = sff8436Dom() if sfpd_obj is None: return None qsfp_option_value_raw = self.__read_eeprom_specific_bytes( QSFP_OPTION_VALUE_OFFSET, QSFP_OPTION_VALUE_WIDTH) if qsfp_option_value_raw is not None: optional_capability = sfpd_obj.parse_option_params( qsfp_option_value_raw, 0) self.dom_tx_disable_supported = optional_capability[ 'data']['TxDisable']['value'] == 'On' dom_status_indicator = sfpd_obj.parse_dom_status_indicator( qsfp_version_compliance_raw, 1) self.qsfp_page3_available = dom_status_indicator['data'][ 'FlatMem']['value'] == 'Off' else: self.dom_supported = False self.dom_temp_supported = False self.dom_volt_supported = False self.dom_rx_power_supported = False self.dom_tx_power_supported = False self.calibration = 0 self.qsfp_page3_available = False else: sfpi_obj = sff8472InterfaceId() if sfpi_obj is None: return None sfp_dom_capability_raw = self.__read_eeprom_specific_bytes( XCVR_DOM_CAPABILITY_OFFSET, XCVR_DOM_CAPABILITY_WIDTH) if sfp_dom_capability_raw is not None: sfp_dom_capability = int(sfp_dom_capability_raw[0], 16) self.dom_supported = (sfp_dom_capability & 0x40 != 0) if self.dom_supported: self.dom_temp_supported = True self.dom_volt_supported = True self.dom_rx_power_supported = True self.dom_tx_power_supported = True if sfp_dom_capability & 0x20 != 0: self.calibration = 1 elif sfp_dom_capability & 0x10 != 0: self.calibration = 2 else: self.calibration = 0 else: self.dom_temp_supported = False self.dom_volt_supported = False self.dom_rx_power_supported = False self.dom_tx_power_supported = False self.calibration = 0 self.dom_tx_disable_supported = ( int(sfp_dom_capability_raw[1], 16) & 0x40 != 0)
def get_transceiver_threshold_info(self): """ Retrieves transceiver threshold info of this SFP Returns: A dict which contains following keys/values : ======================================================================== keys |Value Format |Information ---------------------------|---------------|---------------------------- temphighalarm |FLOAT |High Alarm Threshold value of temperature in Celsius. templowalarm |FLOAT |Low Alarm Threshold value of temperature in Celsius. temphighwarning |FLOAT |High Warning Threshold value of temperature in Celsius. templowwarning |FLOAT |Low Warning Threshold value of temperature in Celsius. vcchighalarm |FLOAT |High Alarm Threshold value of supply voltage in mV. vcclowalarm |FLOAT |Low Alarm Threshold value of supply voltage in mV. vcchighwarning |FLOAT |High Warning Threshold value of supply voltage in mV. vcclowwarning |FLOAT |Low Warning Threshold value of supply voltage in mV. rxpowerhighalarm |FLOAT |High Alarm Threshold value of received power in dBm. rxpowerlowalarm |FLOAT |Low Alarm Threshold value of received power in dBm. rxpowerhighwarning |FLOAT |High Warning Threshold value of received power in dBm. rxpowerlowwarning |FLOAT |Low Warning Threshold value of received power in dBm. txpowerhighalarm |FLOAT |High Alarm Threshold value of transmit power in dBm. txpowerlowalarm |FLOAT |Low Alarm Threshold value of transmit power in dBm. txpowerhighwarning |FLOAT |High Warning Threshold value of transmit power in dBm. txpowerlowwarning |FLOAT |Low Warning Threshold value of transmit power in dBm. txbiashighalarm |FLOAT |High Alarm Threshold value of tx Bias Current in mA. txbiaslowalarm |FLOAT |Low Alarm Threshold value of tx Bias Current in mA. txbiashighwarning |FLOAT |High Warning Threshold value of tx Bias Current in mA. txbiaslowwarning |FLOAT |Low Warning Threshold value of tx Bias Current in mA. ======================================================================== """ transceiver_dom_threshold_info_dict_keys = ['temphighalarm', 'temphighwarning', 'templowalarm', 'templowwarning', 'vcchighalarm', 'vcchighwarning', 'vcclowalarm', 'vcclowwarning', 'rxpowerhighalarm', 'rxpowerhighwarning', 'rxpowerlowalarm', 'rxpowerlowwarning', 'txpowerhighalarm', 'txpowerhighwarning', 'txpowerlowalarm', 'txpowerlowwarning', 'txbiashighalarm', 'txbiashighwarning', 'txbiaslowalarm', 'txbiaslowwarning'] sfpd_obj = sff8436Dom() if not self.get_presence() or not sfpd_obj: return {} transceiver_dom_threshold_dict = dict.fromkeys(transceiver_dom_threshold_info_dict_keys, 'N/A') offset = DOM_OFFSET dom_module_threshold_raw = self.__read_eeprom_specific_bytes((offset + QSFP_MODULE_THRESHOLD_OFFSET), QSFP_MODULE_THRESHOLD_WIDTH) if dom_module_threshold_raw: module_threshold_values = sfpd_obj.parse_module_threshold_values(dom_module_threshold_raw, 0) module_threshold_data = module_threshold_values.get('data') if module_threshold_data: transceiver_dom_threshold_dict['temphighalarm'] = module_threshold_data['TempHighAlarm']['value'] transceiver_dom_threshold_dict['templowalarm'] = module_threshold_data['TempLowAlarm']['value'] transceiver_dom_threshold_dict['temphighwarning'] = module_threshold_data['TempHighWarning']['value'] transceiver_dom_threshold_dict['templowwarning'] = module_threshold_data['TempLowWarning']['value'] transceiver_dom_threshold_dict['vcchighalarm'] = module_threshold_data['VccHighAlarm']['value'] transceiver_dom_threshold_dict['vcclowalarm'] = module_threshold_data['VccLowAlarm']['value'] transceiver_dom_threshold_dict['vcchighwarning'] = module_threshold_data['VccHighWarning']['value'] transceiver_dom_threshold_dict['vcclowwarning'] = module_threshold_data['VccLowWarning']['value'] dom_channel_thres_raw = self.__read_eeprom_specific_bytes((offset + QSFP_CHANNEL_THRESHOLD_OFFSET), QSFP_CHANNEL_THRESHOLD_WIDTH) channel_threshold_values = sfpd_obj.parse_channel_threshold_values(dom_channel_thres_raw, 0) channel_threshold_data = channel_threshold_values.get('data') if channel_threshold_data: transceiver_dom_threshold_dict['rxpowerhighalarm'] = channel_threshold_data['RxPowerHighAlarm']['value'] transceiver_dom_threshold_dict['rxpowerlowalarm'] = channel_threshold_data['RxPowerLowAlarm']['value'] transceiver_dom_threshold_dict['rxpowerhighwarning'] = channel_threshold_data['RxPowerHighWarning']['value'] transceiver_dom_threshold_dict['rxpowerlowwarning'] = channel_threshold_data['RxPowerLowWarning']['value'] transceiver_dom_threshold_dict['txpowerhighalarm'] = "0.0dBm" transceiver_dom_threshold_dict['txpowerlowalarm'] = "0.0dBm" transceiver_dom_threshold_dict['txpowerhighwarning'] = "0.0dBm" transceiver_dom_threshold_dict['txpowerlowwarning'] = "0.0dBm" transceiver_dom_threshold_dict['txbiashighalarm'] = channel_threshold_data['TxBiasHighAlarm']['value'] transceiver_dom_threshold_dict['txbiaslowalarm'] = channel_threshold_data['TxBiasLowAlarm']['value'] transceiver_dom_threshold_dict['txbiashighwarning'] = channel_threshold_data['TxBiasHighWarning']['value'] transceiver_dom_threshold_dict['txbiaslowwarning'] = channel_threshold_data['TxBiasLowWarning']['value'] for key in transceiver_dom_threshold_dict: transceiver_dom_threshold_dict[key] = self.__convert_string_to_num(transceiver_dom_threshold_dict[key]) return transceiver_dom_threshold_dict
def get_transceiver_bulk_status(self): """ Retrieves transceiver bulk status of this SFP Returns: A dict which contains following keys/values : ======================================================================== keys |Value Format |Information ---------------------------|---------------|---------------------------- rx_los |BOOLEAN |RX loss-of-signal status, True if has RX los, False if not. tx_fault |BOOLEAN |TX fault status, True if has TX fault, False if not. reset_status |BOOLEAN |reset status, True if SFP in reset, False if not. lp_mode |BOOLEAN |low power mode status, True in lp mode, False if not. tx_disable |BOOLEAN |TX disable status, True TX disabled, False if not. tx_disabled_channel |HEX |disabled TX channels in hex, bits 0 to 3 represent channel 0 | |to channel 3. temperature |INT |module temperature in Celsius voltage |INT |supply voltage in mV tx<n>bias |INT |TX Bias Current in mA, n is the channel number, | |for example, tx2bias stands for tx bias of channel 2. rx<n>power |INT |received optical power in mW, n is the channel number, | |for example, rx2power stands for rx power of channel 2. tx<n>power |INT |TX output power in mW, n is the channel number, | |for example, tx2power stands for tx power of channel 2. ======================================================================== """ transceiver_dom_info_dict_keys = ['rx_los', 'tx_fault', 'reset_status', 'power_lpmode', 'tx_disable', 'tx_disable_channel', 'temperature', 'voltage', 'rx1power', 'rx2power', 'rx3power', 'rx4power', 'tx1bias', 'tx2bias', 'tx3bias', 'tx4bias', 'tx1power', 'tx2power', 'tx3power', 'tx4power'] sfpd_obj = sff8436Dom() sfpi_obj = sff8436InterfaceId() if not self.get_presence() or not sfpi_obj or not sfpd_obj: return {} transceiver_dom_info_dict = dict.fromkeys(transceiver_dom_info_dict_keys, 'N/A') offset = DOM_OFFSET offset_xcvr = INFO_OFFSET # QSFP capability byte parse, through this byte can know whether it support tx_power or not. # TODO: in the future when decided to migrate to support SFF-8636 instead of SFF-8436, # need to add more code for determining the capability and version compliance # in SFF-8636 dom capability definitions evolving with the versions. qsfp_dom_capability_raw = self.__read_eeprom_specific_bytes((offset_xcvr + XCVR_DOM_CAPABILITY_OFFSET), XCVR_DOM_CAPABILITY_WIDTH) if qsfp_dom_capability_raw is not None: qspf_dom_capability_data = sfpi_obj.parse_qsfp_dom_capability(qsfp_dom_capability_raw, 0) else: return None dom_temperature_raw = self.__read_eeprom_specific_bytes((offset + QSFP_TEMPE_OFFSET), QSFP_TEMPE_WIDTH) if dom_temperature_raw is not None: dom_temperature_data = sfpd_obj.parse_temperature(dom_temperature_raw, 0) transceiver_dom_info_dict['temperature'] = dom_temperature_data['data']['Temperature']['value'] dom_voltage_raw = self.__read_eeprom_specific_bytes((offset + QSFP_VOLT_OFFSET), QSFP_VOLT_WIDTH) if dom_voltage_raw is not None: dom_voltage_data = sfpd_obj.parse_voltage(dom_voltage_raw, 0) transceiver_dom_info_dict['voltage'] = dom_voltage_data['data']['Vcc']['value'] qsfp_dom_rev_raw = self.__read_eeprom_specific_bytes((offset + QSFP_DOM_REV_OFFSET), QSFP_DOM_REV_WIDTH) if qsfp_dom_rev_raw is not None: qsfp_dom_rev_data = sfpd_obj.parse_sfp_dom_rev(qsfp_dom_rev_raw, 0) qsfp_dom_rev = qsfp_dom_rev_data['data']['dom_rev']['value'] # The tx_power monitoring is only available on QSFP which compliant with SFF-8636 # and claimed that it support tx_power with one indicator bit. dom_channel_monitor_data = {} dom_channel_monitor_raw = None qsfp_tx_power_support = qspf_dom_capability_data['data']['Tx_power_support']['value'] if (qsfp_dom_rev[0:8] != 'SFF-8636' or (qsfp_dom_rev[0:8] == 'SFF-8636' and qsfp_tx_power_support != 'on')): dom_channel_monitor_raw = self.__read_eeprom_specific_bytes((offset + QSFP_CHANNL_MON_OFFSET), QSFP_CHANNL_MON_WIDTH) if dom_channel_monitor_raw is not None: dom_channel_monitor_data = sfpd_obj.parse_channel_monitor_params(dom_channel_monitor_raw, 0) else: dom_channel_monitor_raw = self.__read_eeprom_specific_bytes((offset + QSFP_CHANNL_MON_OFFSET), QSFP_CHANNL_MON_WITH_TX_POWER_WIDTH) if dom_channel_monitor_raw is not None: dom_channel_monitor_data = sfpd_obj.parse_channel_monitor_params_with_tx_power(dom_channel_monitor_raw, 0) transceiver_dom_info_dict['tx1power'] = dom_channel_monitor_data['data']['TX1Power']['value'] transceiver_dom_info_dict['tx2power'] = dom_channel_monitor_data['data']['TX2Power']['value'] transceiver_dom_info_dict['tx3power'] = dom_channel_monitor_data['data']['TX3Power']['value'] transceiver_dom_info_dict['tx4power'] = dom_channel_monitor_data['data']['TX4Power']['value'] if dom_channel_monitor_raw: transceiver_dom_info_dict['rx1power'] = dom_channel_monitor_data['data']['RX1Power']['value'] transceiver_dom_info_dict['rx2power'] = dom_channel_monitor_data['data']['RX2Power']['value'] transceiver_dom_info_dict['rx3power'] = dom_channel_monitor_data['data']['RX3Power']['value'] transceiver_dom_info_dict['rx4power'] = dom_channel_monitor_data['data']['RX4Power']['value'] transceiver_dom_info_dict['tx1bias'] = dom_channel_monitor_data['data']['TX1Bias']['value'] transceiver_dom_info_dict['tx2bias'] = dom_channel_monitor_data['data']['TX2Bias']['value'] transceiver_dom_info_dict['tx3bias'] = dom_channel_monitor_data['data']['TX3Bias']['value'] transceiver_dom_info_dict['tx4bias'] = dom_channel_monitor_data['data']['TX4Bias']['value'] for key in transceiver_dom_info_dict: transceiver_dom_info_dict[key] = self.__convert_string_to_num(transceiver_dom_info_dict[key]) transceiver_dom_info_dict['rx_los'] = self.get_rx_los() transceiver_dom_info_dict['tx_fault'] = self.get_tx_fault() transceiver_dom_info_dict['reset_status'] = self.get_reset_status() transceiver_dom_info_dict['tx_disable'] = self.get_tx_disable() transceiver_dom_info_dict['tx_disable_channel'] = self.get_tx_disable_channel() transceiver_dom_info_dict['lp_mode'] = self.get_lpmode() return transceiver_dom_info_dict
def get_transceiver_dom_info_dict(self, port_num): transceiver_dom_info_dict = {} logger.log_debug("QFX5200: get_transceiver_dom_info_dict Start") if port_num in self.osfp_ports: # Below part is added to avoid fail xcvrd, shall be implemented later transceiver_dom_info_dict['temperature'] = 'N/A' transceiver_dom_info_dict['voltage'] = 'N/A' transceiver_dom_info_dict['rx1power'] = 'N/A' transceiver_dom_info_dict['rx2power'] = 'N/A' transceiver_dom_info_dict['rx3power'] = 'N/A' transceiver_dom_info_dict['rx4power'] = 'N/A' transceiver_dom_info_dict['tx1bias'] = 'N/A' transceiver_dom_info_dict['tx2bias'] = 'N/A' transceiver_dom_info_dict['tx3bias'] = 'N/A' transceiver_dom_info_dict['tx4bias'] = 'N/A' transceiver_dom_info_dict['tx1power'] = 'N/A' transceiver_dom_info_dict['tx2power'] = 'N/A' transceiver_dom_info_dict['tx3power'] = 'N/A' transceiver_dom_info_dict['tx4power'] = 'N/A' elif port_num in self.qsfp_ports: offset = 0 offset_xcvr = 128 file_path = self._get_port_eeprom_path(port_num, self.IDENTITY_EEPROM_ADDR) if not self._sfp_eeprom_present(file_path, 0): return None try: sysfsfile_eeprom = open(file_path, mode="rb", buffering=0) except IOError: print("Error: reading sysfs file %s" % file_path) return None sfpd_obj = sff8436Dom() if sfpd_obj is None: return None sfpi_obj = sff8436InterfaceId() if sfpi_obj is None: return None # QSFP capability byte parse, through this byte can know whether it support tx_power or not. # TODO: in the future when decided to migrate to support SFF-8636 instead of SFF-8436, # need to add more code for determining the capability and version compliance # in SFF-8636 dom capability definitions evolving with the versions. qsfp_dom_capability_raw = self._read_eeprom_specific_bytes( sysfsfile_eeprom, (offset_xcvr + XCVR_DOM_CAPABILITY_OFFSET), XCVR_DOM_CAPABILITY_WIDTH) if qsfp_dom_capability_raw is not None: qspf_dom_capability_data = sfpi_obj.parse_qsfp_dom_capability(qsfp_dom_capability_raw, 0) else: return None dom_temperature_raw = self._read_eeprom_specific_bytes( sysfsfile_eeprom, (offset + QSFP_TEMPE_OFFSET), QSFP_TEMPE_WIDTH) if dom_temperature_raw is not None: dom_temperature_data = sfpd_obj.parse_temperature(dom_temperature_raw, 0) else: return None dom_voltage_raw = self._read_eeprom_specific_bytes( sysfsfile_eeprom, (offset + QSFP_VOLT_OFFSET), QSFP_VOLT_WIDTH) if dom_voltage_raw is not None: dom_voltage_data = sfpd_obj.parse_voltage(dom_voltage_raw, 0) else: return None qsfp_dom_rev_raw = self._read_eeprom_specific_bytes( sysfsfile_eeprom, (offset + QSFP_DOM_REV_OFFSET), QSFP_DOM_REV_WIDTH) if qsfp_dom_rev_raw is not None: qsfp_dom_rev_data = sfpd_obj.parse_sfp_dom_rev(qsfp_dom_rev_raw, 0) else: return None transceiver_dom_info_dict['temperature'] = dom_temperature_data['data']['Temperature']['value'] transceiver_dom_info_dict['voltage'] = dom_voltage_data['data']['Vcc']['value'] # The tx_power monitoring is only available on QSFP which compliant with SFF-8636 # and claimed that it support tx_power with one indicator bit. dom_channel_monitor_data = {} qsfp_dom_rev = qsfp_dom_rev_data['data']['dom_rev']['value'] qsfp_tx_power_support = qspf_dom_capability_data['data']['Tx_power_support']['value'] if (qsfp_dom_rev[0:8] != 'SFF-8636' or (qsfp_dom_rev[0:8] == 'SFF-8636' and qsfp_tx_power_support != 'on')): dom_channel_monitor_raw = self._read_eeprom_specific_bytes( sysfsfile_eeprom, (offset + QSFP_CHANNL_MON_OFFSET), QSFP_CHANNL_MON_WIDTH) if dom_channel_monitor_raw is not None: dom_channel_monitor_data = sfpd_obj.parse_channel_monitor_params(dom_channel_monitor_raw, 0) else: return None transceiver_dom_info_dict['tx1power'] = 'N/A' transceiver_dom_info_dict['tx2power'] = 'N/A' transceiver_dom_info_dict['tx3power'] = 'N/A' transceiver_dom_info_dict['tx4power'] = 'N/A' else: dom_channel_monitor_raw = self._read_eeprom_specific_bytes( sysfsfile_eeprom, (offset + QSFP_CHANNL_MON_OFFSET), QSFP_CHANNL_MON_WITH_TX_POWER_WIDTH) if dom_channel_monitor_raw is not None: dom_channel_monitor_data = sfpd_obj.parse_channel_monitor_params_with_tx_power( dom_channel_monitor_raw, 0) else: return None transceiver_dom_info_dict['tx1power'] = dom_channel_monitor_data['data']['TX1Power']['value'] transceiver_dom_info_dict['tx2power'] = dom_channel_monitor_data['data']['TX2Power']['value'] transceiver_dom_info_dict['tx3power'] = dom_channel_monitor_data['data']['TX3Power']['value'] transceiver_dom_info_dict['tx4power'] = dom_channel_monitor_data['data']['TX4Power']['value'] try: sysfsfile_eeprom.close() except IOError: print("Error: closing sysfs file %s" % file_path) return None transceiver_dom_info_dict['temperature'] = dom_temperature_data['data']['Temperature']['value'] transceiver_dom_info_dict['voltage'] = dom_voltage_data['data']['Vcc']['value'] transceiver_dom_info_dict['rx1power'] = dom_channel_monitor_data['data']['RX1Power']['value'] transceiver_dom_info_dict['rx2power'] = dom_channel_monitor_data['data']['RX2Power']['value'] transceiver_dom_info_dict['rx3power'] = dom_channel_monitor_data['data']['RX3Power']['value'] transceiver_dom_info_dict['rx4power'] = dom_channel_monitor_data['data']['RX4Power']['value'] transceiver_dom_info_dict['tx1bias'] = dom_channel_monitor_data['data']['TX1Bias']['value'] transceiver_dom_info_dict['tx2bias'] = dom_channel_monitor_data['data']['TX2Bias']['value'] transceiver_dom_info_dict['tx3bias'] = dom_channel_monitor_data['data']['TX3Bias']['value'] transceiver_dom_info_dict['tx4bias'] = dom_channel_monitor_data['data']['TX4Bias']['value'] else: offset = 256 file_path = self._get_port_eeprom_path(port_num, self.DOM_EEPROM_ADDR) if not self._sfp_eeprom_present(file_path, 0): return None try: sysfsfile_eeprom = open(file_path, mode="rb", buffering=0) except IOError: print("Error: reading sysfs file %s" % file_path) return None sfpd_obj = sff8472Dom() if sfpd_obj is None: return None dom_temperature_raw = self._read_eeprom_specific_bytes( sysfsfile_eeprom, (offset + SFP_TEMPE_OFFSET), SFP_TEMPE_WIDTH) if dom_temperature_raw is not None: dom_temperature_data = sfpd_obj.parse_temperature(dom_temperature_raw, 0) else: return None dom_voltage_raw = self._read_eeprom_specific_bytes( sysfsfile_eeprom, (offset + SFP_VOLT_OFFSET), SFP_VOLT_WIDTH) if dom_voltage_raw is not None: dom_voltage_data = sfpd_obj.parse_voltage(dom_voltage_raw, 0) else: return None dom_channel_monitor_raw = self._read_eeprom_specific_bytes( sysfsfile_eeprom, (offset + SFP_CHANNL_MON_OFFSET), SFP_CHANNL_MON_WIDTH) if dom_channel_monitor_raw is not None: dom_channel_monitor_data = sfpd_obj.parse_channel_monitor_params(dom_channel_monitor_raw, 0) else: return None try: sysfsfile_eeprom.close() except IOError: print("Error: closing sysfs file %s" % file_path) return None transceiver_dom_info_dict['temperature'] = dom_temperature_data['data']['Temperature']['value'] transceiver_dom_info_dict['voltage'] = dom_voltage_data['data']['Vcc']['value'] transceiver_dom_info_dict['rx1power'] = dom_channel_monitor_data['data']['RXPower']['value'] transceiver_dom_info_dict['rx2power'] = 'N/A' transceiver_dom_info_dict['rx3power'] = 'N/A' transceiver_dom_info_dict['rx4power'] = 'N/A' transceiver_dom_info_dict['tx1bias'] = dom_channel_monitor_data['data']['TXBias']['value'] transceiver_dom_info_dict['tx2bias'] = 'N/A' transceiver_dom_info_dict['tx3bias'] = 'N/A' transceiver_dom_info_dict['tx4bias'] = 'N/A' transceiver_dom_info_dict['tx1power'] = dom_channel_monitor_data['data']['TXPower']['value'] transceiver_dom_info_dict['tx2power'] = 'N/A' transceiver_dom_info_dict['tx3power'] = 'N/A' transceiver_dom_info_dict['tx4power'] = 'N/A' logger.log_debug("QFX5200: get_transceiver_dom_info_dict End") return transceiver_dom_info_dict
def get_transceiver_dom_threshold_info_dict(self, port_num): transceiver_dom_threshold_info_dict = {} dom_info_dict_keys = ['temphighalarm', 'temphighwarning', 'templowalarm', 'templowwarning', 'vcchighalarm', 'vcchighwarning', 'vcclowalarm', 'vcclowwarning', 'rxpowerhighalarm', 'rxpowerhighwarning', 'rxpowerlowalarm', 'rxpowerlowwarning', 'txpowerhighalarm', 'txpowerhighwarning', 'txpowerlowalarm', 'txpowerlowwarning', 'txbiashighalarm', 'txbiashighwarning', 'txbiaslowalarm', 'txbiaslowwarning' ] transceiver_dom_threshold_info_dict = dict.fromkeys(dom_info_dict_keys, 'N/A') logger.log_debug("QFX5200: get_transceiver_dom_threshold_info_dict Start") if port_num in self.qsfp_ports: file_path = self._get_port_eeprom_path(port_num, self.IDENTITY_EEPROM_ADDR) if not self._sfp_eeprom_present(file_path, 0): return None try: sysfsfile_eeprom = io.open(file_path, mode="rb", buffering=0) except IOError: print("Error: reading sysfs file %s" % file_path) return None sfpd_obj = sff8436Dom() if sfpd_obj is None: return transceiver_dom_threshold_info_dict # Dom Threshold data starts from offset 384 # Revert offset back to 0 once data is retrieved offset = 384 dom_module_threshold_raw = self._read_eeprom_specific_bytes( sysfsfile_eeprom, (offset + QSFP_MODULE_THRESHOLD_OFFSET), QSFP_MODULE_THRESHOLD_WIDTH) if dom_module_threshold_raw is not None: dom_module_threshold_data = sfpd_obj.parse_module_threshold_values(dom_module_threshold_raw, 0) else: return transceiver_dom_threshold_info_dict dom_channel_threshold_raw = self._read_eeprom_specific_bytes( sysfsfile_eeprom, (offset + QSFP_CHANNL_THRESHOLD_OFFSET), QSFP_CHANNL_THRESHOLD_WIDTH) if dom_channel_threshold_raw is not None: dom_channel_threshold_data = sfpd_obj.parse_channel_threshold_values(dom_channel_threshold_raw, 0) else: return transceiver_dom_threshold_info_dict try: sysfsfile_eeprom.close() except IOError: print("Error: closing sysfs file %s" % file_path) return None # Threshold Data transceiver_dom_threshold_info_dict['temphighalarm'] = dom_module_threshold_data['data']['TempHighAlarm']['value'] transceiver_dom_threshold_info_dict['temphighwarning'] = dom_module_threshold_data['data']['TempHighWarning']['value'] transceiver_dom_threshold_info_dict['templowalarm'] = dom_module_threshold_data['data']['TempLowAlarm']['value'] transceiver_dom_threshold_info_dict['templowwarning'] = dom_module_threshold_data['data']['TempLowWarning']['value'] transceiver_dom_threshold_info_dict['vcchighalarm'] = dom_module_threshold_data['data']['VccHighAlarm']['value'] transceiver_dom_threshold_info_dict['vcchighwarning'] = dom_module_threshold_data['data']['VccHighWarning']['value'] transceiver_dom_threshold_info_dict['vcclowalarm'] = dom_module_threshold_data['data']['VccLowAlarm']['value'] transceiver_dom_threshold_info_dict['vcclowwarning'] = dom_module_threshold_data['data']['VccLowWarning']['value'] transceiver_dom_threshold_info_dict['rxpowerhighalarm'] = dom_channel_threshold_data['data']['RxPowerHighAlarm']['value'] transceiver_dom_threshold_info_dict['rxpowerhighwarning'] = dom_channel_threshold_data['data']['RxPowerHighWarning']['value'] transceiver_dom_threshold_info_dict['rxpowerlowalarm'] = dom_channel_threshold_data['data']['RxPowerLowAlarm']['value'] transceiver_dom_threshold_info_dict['rxpowerlowwarning'] = dom_channel_threshold_data['data']['RxPowerLowWarning']['value'] transceiver_dom_threshold_info_dict['txbiashighalarm'] = dom_channel_threshold_data['data']['TxBiasHighAlarm']['value'] transceiver_dom_threshold_info_dict['txbiashighwarning'] = dom_channel_threshold_data['data']['TxBiasHighWarning']['value'] transceiver_dom_threshold_info_dict['txbiaslowalarm'] = dom_channel_threshold_data['data']['TxBiasLowAlarm']['value'] transceiver_dom_threshold_info_dict['txbiaslowwarning'] = dom_channel_threshold_data['data']['TxBiasLowWarning']['value'] else: offset = 256 file_path = self._get_port_eeprom_path(port_num, self.DOM_EEPROM_ADDR) if not self._sfp_eeprom_present(file_path, 0): return None try: sysfsfile_eeprom = io.open(file_path, "rb", 0) except IOError: print("Error: reading sysfs file %s" % file_path) return None sfpd_obj = sff8472Dom(None, 1) if sfpd_obj is None: return transceiver_dom_threshold_info_dict dom_module_threshold_raw = self._read_eeprom_specific_bytes(sysfsfile_eeprom, (offset + SFP_MODULE_THRESHOLD_OFFSET), SFP_MODULE_THRESHOLD_WIDTH) if dom_module_threshold_raw is not None: dom_module_threshold_data = sfpd_obj.parse_alarm_warning_threshold(dom_module_threshold_raw, 0) else: return transceiver_dom_threshold_info_dict try: sysfsfile_eeprom.close() except IOError: print("Error: closing sysfs file %s" % file_path) return None # Threshold Data transceiver_dom_threshold_info_dict['temphighalarm'] = dom_module_threshold_data['data']['TempHighAlarm']['value'] transceiver_dom_threshold_info_dict['templowalarm'] = dom_module_threshold_data['data']['TempLowAlarm']['value'] transceiver_dom_threshold_info_dict['temphighwarning'] = dom_module_threshold_data['data']['TempHighWarning']['value'] transceiver_dom_threshold_info_dict['templowwarning'] = dom_module_threshold_data['data']['TempLowWarning']['value'] transceiver_dom_threshold_info_dict['vcchighalarm'] = dom_module_threshold_data['data']['VoltageHighAlarm']['value'] transceiver_dom_threshold_info_dict['vcclowalarm'] = dom_module_threshold_data['data']['VoltageLowAlarm']['value'] transceiver_dom_threshold_info_dict['vcchighwarning'] = dom_module_threshold_data['data']['VoltageHighWarning']['value'] transceiver_dom_threshold_info_dict['vcclowwarning'] = dom_module_threshold_data['data']['VoltageLowWarning']['value'] transceiver_dom_threshold_info_dict['txbiashighalarm'] = dom_module_threshold_data['data']['BiasHighAlarm']['value'] transceiver_dom_threshold_info_dict['txbiaslowalarm'] = dom_module_threshold_data['data']['BiasLowAlarm']['value'] transceiver_dom_threshold_info_dict['txbiashighwarning'] = dom_module_threshold_data['data']['BiasHighWarning']['value'] transceiver_dom_threshold_info_dict['txbiaslowwarning'] = dom_module_threshold_data['data']['BiasLowWarning']['value'] transceiver_dom_threshold_info_dict['txpowerhighalarm'] = dom_module_threshold_data['data']['TXPowerHighAlarm']['value'] transceiver_dom_threshold_info_dict['txpowerlowalarm'] = dom_module_threshold_data['data']['TXPowerLowAlarm']['value'] transceiver_dom_threshold_info_dict['txpowerhighwarning'] = dom_module_threshold_data['data']['TXPowerHighWarning']['value'] transceiver_dom_threshold_info_dict['txpowerlowwarning'] = dom_module_threshold_data['data']['TXPowerLowWarning']['value'] transceiver_dom_threshold_info_dict['rxpowerhighalarm'] = dom_module_threshold_data['data']['RXPowerHighAlarm']['value'] transceiver_dom_threshold_info_dict['rxpowerlowalarm'] = dom_module_threshold_data['data']['RXPowerLowAlarm']['value'] transceiver_dom_threshold_info_dict['rxpowerhighwarning'] = dom_module_threshold_data['data']['RXPowerHighWarning']['value'] transceiver_dom_threshold_info_dict['rxpowerlowwarning'] = dom_module_threshold_data['data']['RXPowerLowWarning']['value'] logger.log_debug("QFX5200: get_transceiver_dom_threshold_info_dict End") return transceiver_dom_threshold_info_dict
def get_transceiver_bulk_status(self): # check present status if not self.get_presence(): return None self.__dom_capability_detect() xcvr_dom_info_dict = dict.fromkeys(self.dom_dict_keys, 'N/A') if self.is_osfp_port: # Below part is added to avoid fail xcvrd, shall be implemented later pass elif self.is_qsfp_port: # QSFPs xcvr_dom_info_dict = super(Sfp, self).get_transceiver_bulk_status() # pddf_sfp "qsfp_tx_power_support != 'on'" is wrong offset = 0 sfpd_obj = sff8436Dom() if sfpd_obj is None: return None qsfp_dom_rev_raw = self.__read_eeprom_specific_bytes( (offset + QSFP_DOM_REV_OFFSET), QSFP_DOM_REV_WIDTH) if qsfp_dom_rev_raw is not None: qsfp_dom_rev_data = sfpd_obj.parse_sfp_dom_rev( qsfp_dom_rev_raw, 0) else: return None dom_channel_monitor_data = {} qsfp_dom_rev = qsfp_dom_rev_data['data']['dom_rev']['value'] if (qsfp_dom_rev[0:8] == 'SFF-8636' and self.dom_tx_power_supported is True): dom_channel_monitor_raw = self.__read_eeprom_specific_bytes( (offset + QSFP_CHANNL_MON_OFFSET), QSFP_CHANNL_MON_WITH_TX_POWER_WIDTH) if dom_channel_monitor_raw is not None: dom_channel_monitor_data = sfpd_obj.parse_channel_monitor_params_with_tx_power( dom_channel_monitor_raw, 0) else: return None xcvr_dom_info_dict['tx1power'] = dom_channel_monitor_data[ 'data']['TX1Power']['value'] xcvr_dom_info_dict['tx2power'] = dom_channel_monitor_data[ 'data']['TX2Power']['value'] xcvr_dom_info_dict['tx3power'] = dom_channel_monitor_data[ 'data']['TX3Power']['value'] xcvr_dom_info_dict['tx4power'] = dom_channel_monitor_data[ 'data']['TX4Power']['value'] else: # SFPs offset = 256 if not self.dom_supported: return xcvr_dom_info_dict sfpd_obj = sff8472Dom() if sfpd_obj is None: return None sfpd_obj._calibration_type = self.calibration dom_temperature_raw = self.__read_eeprom_specific_bytes( (offset + SFP_TEMPE_OFFSET), SFP_TEMPE_WIDTH) if dom_temperature_raw is not None: dom_temperature_data = sfpd_obj.parse_temperature( dom_temperature_raw, 0) else: return None dom_voltage_raw = self.__read_eeprom_specific_bytes( (offset + SFP_VOLT_OFFSET), SFP_VOLT_WIDTH) if dom_voltage_raw is not None: dom_voltage_data = sfpd_obj.parse_voltage(dom_voltage_raw, 0) else: return None dom_channel_monitor_raw = self.__read_eeprom_specific_bytes( (offset + SFP_CHANNL_MON_OFFSET), SFP_CHANNL_MON_WIDTH) if dom_channel_monitor_raw is not None: dom_channel_monitor_data = sfpd_obj.parse_channel_monitor_params( dom_channel_monitor_raw, 0) else: return None xcvr_dom_info_dict['temperature'] = dom_temperature_data['data'][ 'Temperature']['value'] xcvr_dom_info_dict['voltage'] = dom_voltage_data['data']['Vcc'][ 'value'] xcvr_dom_info_dict['rx1power'] = dom_channel_monitor_data['data'][ 'RXPower']['value'] xcvr_dom_info_dict['rx2power'] = 'N/A' xcvr_dom_info_dict['rx3power'] = 'N/A' xcvr_dom_info_dict['rx4power'] = 'N/A' xcvr_dom_info_dict['tx1bias'] = dom_channel_monitor_data['data'][ 'TXBias']['value'] xcvr_dom_info_dict['tx2bias'] = 'N/A' xcvr_dom_info_dict['tx3bias'] = 'N/A' xcvr_dom_info_dict['tx4bias'] = 'N/A' xcvr_dom_info_dict['tx1power'] = dom_channel_monitor_data['data'][ 'TXPower']['value'] xcvr_dom_info_dict['tx2power'] = 'N/A' xcvr_dom_info_dict['tx3power'] = 'N/A' xcvr_dom_info_dict['tx4power'] = 'N/A' xcvr_dom_info_dict['rx_los'] = self.get_rx_los() xcvr_dom_info_dict['tx_fault'] = self.get_tx_fault() xcvr_dom_info_dict['reset_status'] = self.get_reset_status() xcvr_dom_info_dict['lp_mode'] = self.get_lpmode() return xcvr_dom_info_dict
def get_transceiver_bulk_status(self): """ Retrieves transceiver bulk status of this SFP Returns: A dict which contains following keys/values : ======================================================================== keys |Value Format |Information ---------------------------|---------------|---------------------------- RX LOS |BOOLEAN |RX lost-of-signal status, | |True if has RX los, False if not. TX FAULT |BOOLEAN |TX fault status, | |True if has TX fault, False if not. Reset status |BOOLEAN |reset status, | |True if SFP in reset, False if not. LP mode |BOOLEAN |low power mode status, | |True in lp mode, False if not. TX disable |BOOLEAN |TX disable status, | |True TX disabled, False if not. TX disabled channel |HEX |disabled TX channles in hex, | |bits 0 to 3 represent channel 0 | |to channel 3. Temperature |INT |module temperature in Celsius Voltage |INT |supply voltage in mV TX bias |INT |TX Bias Current in mA RX power |INT |received optical power in mW TX power |INT |TX output power in mW ======================================================================== """ # check present status if not self.get_presence(): return None xcvr_dom_info_dict = dict.fromkeys(self.dom_dict_keys, 'N/A') if self.is_osfp_port: # Below part is added to avoid fail xcvrd, shall be implemented later pass elif self.is_qsfp_port: # QSFPs offset = 0 offset_xcvr = 128 sfpd_obj = sff8436Dom() if sfpd_obj is None: return None sfpi_obj = sff8436InterfaceId() if sfpi_obj is None: return None qsfp_dom_capability_raw = self.__read_eeprom_specific_bytes( (offset_xcvr + XCVR_DOM_CAPABILITY_OFFSET), XCVR_DOM_CAPABILITY_WIDTH) if qsfp_dom_capability_raw is not None: qspf_dom_capability_data = sfpi_obj.parse_qsfp_dom_capability( qsfp_dom_capability_raw, 0) else: return None dom_temperature_raw = self.__read_eeprom_specific_bytes( (offset + QSFP_TEMPE_OFFSET), QSFP_TEMPE_WIDTH) if dom_temperature_raw is not None: dom_temperature_data = sfpd_obj.parse_temperature( dom_temperature_raw, 0) else: return None dom_voltage_raw = self.__read_eeprom_specific_bytes( (offset + QSFP_VOLT_OFFSET), QSFP_VOLT_WIDTH) if dom_voltage_raw is not None: dom_voltage_data = sfpd_obj.parse_voltage(dom_voltage_raw, 0) else: return None qsfp_dom_rev_raw = self.__read_eeprom_specific_bytes( (offset + QSFP_DOM_REV_OFFSET), QSFP_DOM_REV_WIDTH) if qsfp_dom_rev_raw is not None: qsfp_dom_rev_data = sfpd_obj.parse_sfp_dom_rev( qsfp_dom_rev_raw, 0) else: return None xcvr_dom_info_dict['temperature'] = dom_temperature_data['data'][ 'Temperature']['value'] xcvr_dom_info_dict['voltage'] = dom_voltage_data['data']['Vcc'][ 'value'] # The tx_power monitoring is only available on QSFP which compliant with SFF-8636 # and claimed that it support tx_power with one indicator bit. dom_channel_monitor_data = {} qsfp_dom_rev = qsfp_dom_rev_data['data']['dom_rev']['value'] qsfp_tx_power_support = qspf_dom_capability_data['data'][ 'Tx_power_support']['value'] if (qsfp_dom_rev[0:8] != 'SFF-8636' or (qsfp_dom_rev[0:8] == 'SFF-8636' and qsfp_tx_power_support != 'on')): dom_channel_monitor_raw = self.__read_eeprom_specific_bytes( (offset + QSFP_CHANNL_MON_OFFSET), QSFP_CHANNL_MON_WIDTH) if dom_channel_monitor_raw is not None: dom_channel_monitor_data = sfpd_obj.parse_channel_monitor_params( dom_channel_monitor_raw, 0) else: return None xcvr_dom_info_dict['tx1power'] = 'N/A' xcvr_dom_info_dict['tx2power'] = 'N/A' xcvr_dom_info_dict['tx3power'] = 'N/A' xcvr_dom_info_dict['tx4power'] = 'N/A' else: dom_channel_monitor_raw = self.__read_eeprom_specific_bytes( (offset + QSFP_CHANNL_MON_OFFSET), QSFP_CHANNL_MON_WITH_TX_POWER_WIDTH) if dom_channel_monitor_raw is not None: dom_channel_monitor_data = sfpd_obj.parse_channel_monitor_params_with_tx_power( dom_channel_monitor_raw, 0) else: return None xcvr_dom_info_dict['tx1power'] = dom_channel_monitor_data[ 'data']['TX1Power']['value'] xcvr_dom_info_dict['tx2power'] = dom_channel_monitor_data[ 'data']['TX2Power']['value'] xcvr_dom_info_dict['tx3power'] = dom_channel_monitor_data[ 'data']['TX3Power']['value'] xcvr_dom_info_dict['tx4power'] = dom_channel_monitor_data[ 'data']['TX4Power']['value'] if dom_channel_monitor_raw: xcvr_dom_info_dict['temperature'] = dom_temperature_data[ 'data']['Temperature']['value'] xcvr_dom_info_dict['voltage'] = dom_voltage_data['data'][ 'Vcc']['value'] xcvr_dom_info_dict['rx1power'] = dom_channel_monitor_data[ 'data']['RX1Power']['value'] xcvr_dom_info_dict['rx2power'] = dom_channel_monitor_data[ 'data']['RX2Power']['value'] xcvr_dom_info_dict['rx3power'] = dom_channel_monitor_data[ 'data']['RX3Power']['value'] xcvr_dom_info_dict['rx4power'] = dom_channel_monitor_data[ 'data']['RX4Power']['value'] xcvr_dom_info_dict['tx1bias'] = dom_channel_monitor_data[ 'data']['TX1Bias']['value'] xcvr_dom_info_dict['tx2bias'] = dom_channel_monitor_data[ 'data']['TX2Bias']['value'] xcvr_dom_info_dict['tx3bias'] = dom_channel_monitor_data[ 'data']['TX3Bias']['value'] xcvr_dom_info_dict['tx4bias'] = dom_channel_monitor_data[ 'data']['TX4Bias']['value'] else: # SFPs offset = 256 sfpd_obj = sff8472Dom() if sfpd_obj is None: return None dom_temperature_raw = self.__read_eeprom_specific_bytes( (offset + SFP_TEMPE_OFFSET), SFP_TEMPE_WIDTH) if dom_temperature_raw is not None: dom_temperature_data = sfpd_obj.parse_temperature( dom_temperature_raw, 0) else: return None dom_voltage_raw = self.__read_eeprom_specific_bytes( (offset + SFP_VOLT_OFFSET), SFP_VOLT_WIDTH) if dom_voltage_raw is not None: dom_voltage_data = sfpd_obj.parse_voltage(dom_voltage_raw, 0) else: return None dom_channel_monitor_raw = self.__read_eeprom_specific_bytes( (offset + SFP_CHANNL_MON_OFFSET), SFP_CHANNL_MON_WIDTH) if dom_channel_monitor_raw is not None: dom_channel_monitor_data = sfpd_obj.parse_channel_monitor_params( dom_channel_monitor_raw, 0) else: return None xcvr_dom_info_dict['temperature'] = dom_temperature_data['data'][ 'Temperature']['value'] xcvr_dom_info_dict['voltage'] = dom_voltage_data['data']['Vcc'][ 'value'] xcvr_dom_info_dict['rx1power'] = dom_channel_monitor_data['data'][ 'RXPower']['value'] xcvr_dom_info_dict['rx2power'] = 'N/A' xcvr_dom_info_dict['rx3power'] = 'N/A' xcvr_dom_info_dict['rx4power'] = 'N/A' xcvr_dom_info_dict['tx1bias'] = dom_channel_monitor_data['data'][ 'TXBias']['value'] xcvr_dom_info_dict['tx2bias'] = 'N/A' xcvr_dom_info_dict['tx3bias'] = 'N/A' xcvr_dom_info_dict['tx4bias'] = 'N/A' xcvr_dom_info_dict['tx1power'] = dom_channel_monitor_data['data'][ 'TXPower']['value'] xcvr_dom_info_dict['tx2power'] = 'N/A' xcvr_dom_info_dict['tx3power'] = 'N/A' xcvr_dom_info_dict['tx4power'] = 'N/A' xcvr_dom_info_dict['rx_los'] = self.get_rx_los() xcvr_dom_info_dict['tx_fault'] = self.get_tx_fault() xcvr_dom_info_dict['reset_status'] = self.get_reset_status() xcvr_dom_info_dict['lp_mode'] = self.get_lpmode() return xcvr_dom_info_dict