diff --git a/device/celestica/x86_64-cel_e1031-r0/Celestica-E1031-T48S4/hwsku.json b/device/celestica/x86_64-cel_e1031-r0/Celestica-E1031-T48S4/hwsku.json new file mode 100644 index 0000000000..e4afe9bc5d --- /dev/null +++ b/device/celestica/x86_64-cel_e1031-r0/Celestica-E1031-T48S4/hwsku.json @@ -0,0 +1,224 @@ +{ + "interfaces": { + "Ethernet0": { + "default_brkout_mode": "1x1G", + "port_type": "RJ45" + }, + "Ethernet1": { + "default_brkout_mode": "1x1G", + "port_type": "RJ45" + }, + "Ethernet2": { + "default_brkout_mode": "1x1G", + "port_type": "RJ45" + }, + "Ethernet3": { + "default_brkout_mode": "1x1G", + "port_type": "RJ45" + }, + "Ethernet4": { + "default_brkout_mode": "1x1G", + "port_type": "RJ45" + }, + "Ethernet5": { + "default_brkout_mode": "1x1G", + "port_type": "RJ45" + }, + "Ethernet6": { + "default_brkout_mode": "1x1G", + "port_type": "RJ45" + }, + "Ethernet7": { + "default_brkout_mode": "1x1G", + "port_type": "RJ45" + }, + "Ethernet8": { + "default_brkout_mode": "1x1G", + "port_type": "RJ45" + }, + "Ethernet9": { + "default_brkout_mode": "1x1G", + "port_type": "RJ45" + }, + "Ethernet10": { + "default_brkout_mode": "1x1G", + "port_type": "RJ45" + }, + "Ethernet11": { + "default_brkout_mode": "1x1G", + "port_type": "RJ45" + }, + "Ethernet12": { + "default_brkout_mode": "1x1G", + "port_type": "RJ45" + }, + "Ethernet13": { + "default_brkout_mode": "1x1G", + "port_type": "RJ45" + }, + "Ethernet14": { + "default_brkout_mode": "1x1G", + "port_type": "RJ45" + }, + "Ethernet15": { + "default_brkout_mode": "1x1G", + "port_type": "RJ45" + }, + "Ethernet16": { + "default_brkout_mode": "1x1G", + "port_type": "RJ45" + }, + "Ethernet17": { + "default_brkout_mode": "1x1G", + "port_type": "RJ45" + }, + "Ethernet18": { + "default_brkout_mode": "1x1G", + "port_type": "RJ45" + }, + "Ethernet19": { + "default_brkout_mode": "1x1G", + "port_type": "RJ45" + }, + "Ethernet20": { + "default_brkout_mode": "1x1G", + "port_type": "RJ45" + }, + "Ethernet21": { + "default_brkout_mode": "1x1G", + "port_type": "RJ45" + }, + "Ethernet22": { + "default_brkout_mode": "1x1G", + "port_type": "RJ45" + }, + "Ethernet23": { + "default_brkout_mode": "1x1G", + "port_type": "RJ45" + }, + "Ethernet24": { + "default_brkout_mode": "1x1G", + "port_type": "RJ45" + }, + "Ethernet25": { + "default_brkout_mode": "1x1G", + "port_type": "RJ45" + }, + "Ethernet26": { + "default_brkout_mode": "1x1G", + "port_type": "RJ45" + }, + "Ethernet27": { + "default_brkout_mode": "1x1G", + "port_type": "RJ45" + }, + "Ethernet28": { + "default_brkout_mode": "1x1G", + "port_type": "RJ45" + }, + "Ethernet29": { + "default_brkout_mode": "1x1G", + "port_type": "RJ45" + }, + "Ethernet30": { + "default_brkout_mode": "1x1G", + "port_type": "RJ45" + }, + "Ethernet31": { + "default_brkout_mode": "1x1G", + "port_type": "RJ45" + }, + "Ethernet32": { + "default_brkout_mode": "1x1G", + "port_type": "RJ45" + }, + "Ethernet33": { + "default_brkout_mode": "1x1G", + "port_type": "RJ45" + }, + "Ethernet34": { + "default_brkout_mode": "1x1G", + "port_type": "RJ45" + }, + "Ethernet35": { + "default_brkout_mode": "1x1G", + "port_type": "RJ45" + }, + "Ethernet36": { + "default_brkout_mode": "1x1G", + "port_type": "RJ45" + }, + "Ethernet37": { + "default_brkout_mode": "1x1G", + "port_type": "RJ45" + }, + "Ethernet38": { + "default_brkout_mode": "1x1G", + "port_type": "RJ45" + }, + "Ethernet39": { + "default_brkout_mode": "1x1G", + "port_type": "RJ45" + }, + "Ethernet40": { + "default_brkout_mode": "1x1G", + "port_type": "RJ45" + }, + "Ethernet41": { + "default_brkout_mode": "1x1G", + "port_type": "RJ45" + }, + "Ethernet42": { + "default_brkout_mode": "1x1G", + "port_type": "RJ45" + }, + "Ethernet43": { + "default_brkout_mode": "1x1G", + "port_type": "RJ45" + }, + "Ethernet44": { + "default_brkout_mode": "1x1G", + "port_type": "RJ45" + }, + "Ethernet45": { + "default_brkout_mode": "1x1G", + "port_type": "RJ45" + }, + "Ethernet46": { + "default_brkout_mode": "1x1G", + "port_type": "RJ45" + }, + "Ethernet47": { + "default_brkout_mode": "1x1G", + "port_type": "RJ45" + }, + "Ethernet48": { + "default_brkout_mode": "1x10G", + "port_type": "SFP+" + }, + "Ethernet49": { + "default_brkout_mode": "1x10G", + "port_type": "SFP+" + }, + "Ethernet50": { + "default_brkout_mode": "1x10G", + "port_type": "SFP+" + }, + "Ethernet51": { + "default_brkout_mode": "1x10G", + "port_type": "SFP+" + }, + "Ethernet52": { + "default_brkout_mode": "1x1G", + "port_type": "RJ45" + }, + "Ethernet53": { + "default_brkout_mode": "1x21G", + "port_type": "RJ45" + }, + "Ethernet54": { + "default_brkout_mode": "1x21G", + "port_type": "RJ45" + } + } +} diff --git a/device/celestica/x86_64-cel_e1031-r0/platform.json b/device/celestica/x86_64-cel_e1031-r0/platform.json index 26acaf4aee..0e4656feae 100644 --- a/device/celestica/x86_64-cel_e1031-r0/platform.json +++ b/device/celestica/x86_64-cel_e1031-r0/platform.json @@ -91,9 +91,6 @@ } ], "sfps": [ - { - "name": "Ethernet54" - }, { "name": "Ethernet0" }, @@ -255,504 +252,11 @@ }, { "name": "Ethernet53" + }, + { + "name": "Ethernet54" } ] }, - "interfaces": { - "Ethernet0": { - "index": "1", - "lanes": "2", - "breakout_modes": { - "1x1G": [ - "etp1" - ] - } - }, - "Ethernet1": { - "index": "2", - "lanes": "1", - "breakout_modes": { - "1x1G": [ - "etp2" - ] - } - }, - "Ethernet2": { - "index": "3", - "lanes": "4", - "breakout_modes": { - "1x1G": [ - "etp3" - ] - } - }, - "Ethernet3": { - "index": "4", - "lanes": "3", - "breakout_modes": { - "1x1G": [ - "etp4" - ] - } - }, - "Ethernet4": { - "index": "5", - "lanes": "6", - "breakout_modes": { - "1x1G": [ - "etp5" - ] - } - }, - "Ethernet5": { - "index": "6", - "lanes": "5", - "breakout_modes": { - "1x1G": [ - "etp6" - ] - } - }, - "Ethernet6": { - "index": "7", - "lanes": "8", - "breakout_modes": { - "1x1G": [ - "etp7" - ] - } - }, - "Ethernet7": { - "index": "8", - "lanes": "7", - "breakout_modes": { - "1x1G": [ - "etp8" - ] - } - }, - "Ethernet8": { - "index": "9", - "lanes": "10", - "breakout_modes": { - "1x1G": [ - "etp9" - ] - } - }, - "Ethernet9": { - "index": "10", - "lanes": "9", - "breakout_modes": { - "1x1G": [ - "etp10" - ] - } - }, - "Ethernet10": { - "index": "11", - "lanes": "12", - "breakout_modes": { - "1x1G": [ - "etp11" - ] - } - }, - "Ethernet11": { - "index": "12", - "lanes": "11", - "breakout_modes": { - "1x1G": [ - "etp12" - ] - } - }, - "Ethernet12": { - "index": "13", - "lanes": "14", - "breakout_modes": { - "1x1G": [ - "etp13" - ] - } - }, - "Ethernet13": { - "index": "14", - "lanes": "13", - "breakout_modes": { - "1x1G": [ - "etp14" - ] - } - }, - "Ethernet14": { - "index": "15", - "lanes": "16", - "breakout_modes": { - "1x1G": [ - "etp15" - ] - } - }, - "Ethernet15": { - "index": "16", - "lanes": "15", - "breakout_modes": { - "1x1G": [ - "etp16" - ] - } - }, - "Ethernet16": { - "index": "17", - "lanes": "18", - "breakout_modes": { - "1x1G": [ - "etp17" - ] - } - }, - "Ethernet17": { - "index": "18", - "lanes": "17", - "breakout_modes": { - "1x1G": [ - "etp18" - ] - } - }, - "Ethernet18": { - "index": "19", - "lanes": "20", - "breakout_modes": { - "1x1G": [ - "etp19" - ] - } - }, - "Ethernet19": { - "index": "20", - "lanes": "19", - "breakout_modes": { - "1x1G": [ - "etp20" - ] - } - }, - "Ethernet20": { - "index": "21", - "lanes": "22", - "breakout_modes": { - "1x1G": [ - "etp21" - ] - } - }, - "Ethernet21": { - "index": "22", - "lanes": "21", - "breakout_modes": { - "1x1G": [ - "etp22" - ] - } - }, - "Ethernet22": { - "index": "23", - "lanes": "24", - "breakout_modes": { - "1x1G": [ - "etp23" - ] - } - }, - "Ethernet23": { - "index": "24", - "lanes": "23", - "breakout_modes": { - "1x1G": [ - "etp24" - ] - } - }, - "Ethernet24": { - "index": "25", - "lanes": "26", - "breakout_modes": { - "1x1G": [ - "etp25" - ] - } - }, - "Ethernet25": { - "index": "26", - "lanes": "25", - "breakout_modes": { - "1x1G": [ - "etp26" - ] - } - }, - "Ethernet26": { - "index": "27", - "lanes": "28", - "breakout_modes": { - "1x1G": [ - "etp27" - ] - } - }, - "Ethernet27": { - "index": "28", - "lanes": "27", - "breakout_modes": { - "1x1G": [ - "etp28" - ] - } - }, - "Ethernet28": { - "index": "29", - "lanes": "30", - "breakout_modes": { - "1x1G": [ - "etp29" - ] - } - }, - "Ethernet29": { - "index": "30", - "lanes": "29", - "breakout_modes": { - "1x1G": [ - "etp30" - ] - } - }, - "Ethernet30": { - "index": "31", - "lanes": "32", - "breakout_modes": { - "1x1G": [ - "etp31" - ] - } - }, - "Ethernet31": { - "index": "32", - "lanes": "31", - "breakout_modes": { - "1x1G": [ - "etp32" - ] - } - }, - "Ethernet32": { - "index": "33", - "lanes": "34", - "breakout_modes": { - "1x1G": [ - "etp33" - ] - } - }, - "Ethernet33": { - "index": "34", - "lanes": "33", - "breakout_modes": { - "1x1G": [ - "etp34" - ] - } - }, - "Ethernet34": { - "index": "35", - "lanes": "36", - "breakout_modes": { - "1x1G": [ - "etp35" - ] - } - }, - "Ethernet35": { - "index": "36", - "lanes": "35", - "breakout_modes": { - "1x1G": [ - "etp36" - ] - } - }, - "Ethernet36": { - "index": "37", - "lanes": "38", - "breakout_modes": { - "1x1G": [ - "etp37" - ] - } - }, - "Ethernet37": { - "index": "38", - "lanes": "37", - "breakout_modes": { - "1x1G": [ - "etp38" - ] - } - }, - "Ethernet38": { - "index": "39", - "lanes": "40", - "breakout_modes": { - "1x1G": [ - "etp39" - ] - } - }, - "Ethernet39": { - "index": "40", - "lanes": "39", - "breakout_modes": { - "1x1G": [ - "etp40" - ] - } - }, - "Ethernet40": { - "index": "41", - "lanes": "42", - "breakout_modes": { - "1x1G": [ - "etp41" - ] - } - }, - "Ethernet41": { - "index": "42", - "lanes": "41", - "breakout_modes": { - "1x1G": [ - "etp42" - ] - } - }, - "Ethernet42": { - "index": "43", - "lanes": "44", - "breakout_modes": { - "1x1G": [ - "etp43" - ] - } - }, - "Ethernet43": { - "index": "44", - "lanes": "43", - "breakout_modes": { - "1x1G": [ - "etp44" - ] - } - }, - "Ethernet44": { - "index": "45", - "lanes": "46", - "breakout_modes": { - "1x1G": [ - "etp45" - ] - } - }, - "Ethernet45": { - "index": "46", - "lanes": "45", - "breakout_modes": { - "1x1G": [ - "etp46" - ] - } - }, - "Ethernet46": { - "index": "47", - "lanes": "48", - "breakout_modes": { - "1x1G": [ - "etp47" - ] - } - }, - "Ethernet47": { - "index": "48", - "lanes": "47", - "breakout_modes": { - "1x1G": [ - "etp48" - ] - } - }, - "Ethernet48": { - "index": "49", - "lanes": "48", - "breakout_modes": { - "1x10G": [ - "etp49" - ] - } - }, - "Ethernet49": { - "index": "50", - "lanes": "53", - "breakout_modes": { - "1x10G": [ - "etp50" - ] - } - }, - "Ethernet50": { - "index": "51", - "lanes": "56", - "breakout_modes": { - "1x10G": [ - "etp51" - ] - } - }, - "Ethernet51": { - "index": "52", - "lanes": "55", - "breakout_modes": { - "1x10G": [ - "etp52" - ] - } - }, - "Ethernet52": { - "index": "53", - "lanes": "49", - "breakout_modes": { - "1x10G": [ - "etp53" - ] - } - }, - "Ethernet53": { - "index": "54,54,54,54", - "lanes": "57,58,59,60 ", - "breakout_modes": { - "1x10G": [ - "etp54" - ] - } - }, - "Ethernet54": { - "index": "55,55,55,55", - "lanes": "61,62,63,64", - "breakout_modes": { - "1x10G": [ - "etp55" - ] - } - } - } + "interfaces": {} } \ No newline at end of file diff --git a/device/celestica/x86_64-cel_e1031-r0/sonic_platform/chassis.py b/device/celestica/x86_64-cel_e1031-r0/sonic_platform/chassis.py index cb442518f1..4b081f4e3c 100644 --- a/device/celestica/x86_64-cel_e1031-r0/sonic_platform/chassis.py +++ b/device/celestica/x86_64-cel_e1031-r0/sonic_platform/chassis.py @@ -236,17 +236,10 @@ class Chassis(ChassisBase): Returns: An object dervied from SfpBase representing the specified sfp """ - sfp = None if not self.sfp_module_initialized: self.__initialize_sfp() - try: - # The index will start from 1 - sfp = self._sfp_list[index-1] - except IndexError: - print("SFP index {} out of range (1-{})\n".format( - index, len(self._sfp_list))) - return sfp + return super(Chassis, self).get_sfp(index - 1) ############################################################## ################## ThermalManager methods #################### diff --git a/device/celestica/x86_64-cel_e1031-r0/sonic_platform/fan.py b/device/celestica/x86_64-cel_e1031-r0/sonic_platform/fan.py index 90029ffce4..a652fa546e 100644 --- a/device/celestica/x86_64-cel_e1031-r0/sonic_platform/fan.py +++ b/device/celestica/x86_64-cel_e1031-r0/sonic_platform/fan.py @@ -145,7 +145,7 @@ class Fan(FanBase): 0 : when PWM mode is use pwm : when pwm mode is not use """ - target = NULL_VAL + target = 0 if not self.is_psu_fan: chip = self.emc2305_chip_mapping[self.fan_index] device = chip['device'] diff --git a/device/celestica/x86_64-cel_e1031-r0/sonic_platform/fan_drawer.py b/device/celestica/x86_64-cel_e1031-r0/sonic_platform/fan_drawer.py index fe12b0ab10..9b912a52c4 100644 --- a/device/celestica/x86_64-cel_e1031-r0/sonic_platform/fan_drawer.py +++ b/device/celestica/x86_64-cel_e1031-r0/sonic_platform/fan_drawer.py @@ -14,6 +14,7 @@ except ImportError as e: raise ImportError(str(e) + "- required module not found") NUM_FAN = 1 +MAX_FAN_WATT = 10.0 class FanDrawer(FanDrawerBase): @@ -47,6 +48,15 @@ class FanDrawer(FanDrawerBase): """ return self._fan_list[0].get_status_led() + def get_maximum_consumed_power(self): + """ + Retrives the maximum power drawn by Fan Drawer + Returns: + A float, with value of the maximum consumable power of the + component. + """ + return MAX_FAN_WATT + ############################################################## ###################### Device methods ######################## ############################################################## diff --git a/device/celestica/x86_64-cel_e1031-r0/sonic_platform/sfp.py b/device/celestica/x86_64-cel_e1031-r0/sonic_platform/sfp.py index 157b06de1c..c0187819ec 100644 --- a/device/celestica/x86_64-cel_e1031-r0/sonic_platform/sfp.py +++ b/device/celestica/x86_64-cel_e1031-r0/sonic_platform/sfp.py @@ -12,7 +12,6 @@ try: from sonic_platform_base.sfp_base import SfpBase from sonic_platform_base.sonic_sfp.sff8472 import sff8472InterfaceId from sonic_platform_base.sonic_sfp.sff8472 import sff8472Dom - from sonic_platform_base.sonic_sfp.sff8472 import sffbase from sonic_platform_base.sonic_sfp.sff8436 import sff8436InterfaceId from sonic_platform_base.sonic_sfp.sff8436 import sff8436Dom from sonic_platform_base.sonic_sfp.inf8628 import inf8628InterfaceId @@ -210,9 +209,9 @@ class Sfp(SfpBase): def __get_sfp_type(self): return SFP_TYPE if self.port_num in self._sfp_port else ETP_TYPE - def __convert_string_to_num(self, value_str): + def _convert_string_to_num(self, value_str): if "-inf" in value_str: - return 'N/A' + return float("-inf") elif "Unknown" in value_str: return 'N/A' elif 'dBm' in value_str: @@ -230,7 +229,7 @@ class Sfp(SfpBase): else: return 'N/A' - def __read_eeprom_specific_bytes(self, offset, num_bytes): + def _read_eeprom_specific_bytes(self, offset, num_bytes): sysfsfile_eeprom = None eeprom_raw = [] for i in range(0, num_bytes): @@ -277,10 +276,10 @@ class Sfp(SfpBase): # 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( + 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_raw = self._read_eeprom_specific_bytes( QSFP_VERSION_COMPLIANCE_OFFSET, QSFP_VERSION_COMPLIANCE_WIDTH) qsfp_version_compliance = int( qsfp_version_compliance_raw[0], 16) @@ -302,7 +301,7 @@ class Sfp(SfpBase): sfpd_obj = sff8436Dom() if sfpd_obj is None: return None - qsfp_option_value_raw = self.__read_eeprom_specific_bytes( + 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( @@ -325,7 +324,7 @@ class Sfp(SfpBase): sfpi_obj = sff8472InterfaceId() if sfpi_obj is None: return None - sfp_dom_capability_raw = self.__read_eeprom_specific_bytes( + 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) @@ -382,6 +381,7 @@ class Sfp(SfpBase): """ compliance_code_dict = {} transceiver_info_dict = dict.fromkeys(self.info_dict_keys, 'N/A') + transceiver_info_dict['specification_compliance'] = '{}' if not self.get_presence(): return transceiver_info_dict @@ -396,14 +396,14 @@ class Sfp(SfpBase): if sfpi_obj is None: return None - sfp_type_raw = self.__read_eeprom_specific_bytes( + sfp_type_raw = self._read_eeprom_specific_bytes( (offset + OSFP_TYPE_OFFSET), XCVR_TYPE_WIDTH) if sfp_type_raw is not None: sfp_type_data = sfpi_obj.parse_sfp_type(sfp_type_raw, 0) else: return None - sfp_vendor_name_raw = self.__read_eeprom_specific_bytes( + sfp_vendor_name_raw = self._read_eeprom_specific_bytes( (offset + OSFP_VENDOR_NAME_OFFSET), XCVR_VENDOR_NAME_WIDTH) if sfp_vendor_name_raw is not None: sfp_vendor_name_data = sfpi_obj.parse_vendor_name( @@ -411,7 +411,7 @@ class Sfp(SfpBase): else: return None - sfp_vendor_pn_raw = self.__read_eeprom_specific_bytes( + sfp_vendor_pn_raw = self._read_eeprom_specific_bytes( (offset + OSFP_VENDOR_PN_OFFSET), XCVR_VENDOR_PN_WIDTH) if sfp_vendor_pn_raw is not None: sfp_vendor_pn_data = sfpi_obj.parse_vendor_pn( @@ -419,7 +419,7 @@ class Sfp(SfpBase): else: return None - sfp_vendor_rev_raw = self.__read_eeprom_specific_bytes( + sfp_vendor_rev_raw = self._read_eeprom_specific_bytes( (offset + OSFP_HW_REV_OFFSET), vendor_rev_width) if sfp_vendor_rev_raw is not None: sfp_vendor_rev_data = sfpi_obj.parse_vendor_rev( @@ -427,7 +427,7 @@ class Sfp(SfpBase): else: return None - sfp_vendor_sn_raw = self.__read_eeprom_specific_bytes( + sfp_vendor_sn_raw = self._read_eeprom_specific_bytes( (offset + OSFP_VENDOR_SN_OFFSET), XCVR_VENDOR_SN_WIDTH) if sfp_vendor_sn_raw is not None: sfp_vendor_sn_data = sfpi_obj.parse_vendor_sn( @@ -473,7 +473,7 @@ class Sfp(SfpBase): if sfpi_obj is None: print("Error: sfp_object open failed") return None - sfp_interface_bulk_raw = self.__read_eeprom_specific_bytes( + sfp_interface_bulk_raw = self._read_eeprom_specific_bytes( offset + XCVR_INTERFACE_DATA_START, XCVR_INTERFACE_DATA_SIZE) if sfp_interface_bulk_raw is None: return None @@ -598,7 +598,7 @@ class Sfp(SfpBase): if sfpd_obj is None: return transceiver_dom_info_dict - dom_data_raw = self.__read_eeprom_specific_bytes( + dom_data_raw = self._read_eeprom_specific_bytes( (offset + QSFP_DOM_BULK_DATA_START), QSFP_DOM_BULK_DATA_SIZE) if dom_data_raw is None: return transceiver_dom_info_dict @@ -608,7 +608,7 @@ class Sfp(SfpBase): end = start + QSFP_TEMPE_WIDTH dom_temperature_data = sfpd_obj.parse_temperature( dom_data_raw[start: end], 0) - temp = self.__convert_string_to_num( + temp = self._convert_string_to_num( dom_temperature_data['data']['Temperature']['value']) if temp is not None: transceiver_dom_info_dict['temperature'] = temp @@ -618,7 +618,7 @@ class Sfp(SfpBase): end = start + QSFP_VOLT_WIDTH dom_voltage_data = sfpd_obj.parse_voltage( dom_data_raw[start: end], 0) - volt = self.__convert_string_to_num( + volt = self._convert_string_to_num( dom_voltage_data['data']['Vcc']['value']) if volt is not None: transceiver_dom_info_dict['voltage'] = volt @@ -629,32 +629,32 @@ class Sfp(SfpBase): dom_data_raw[start: end], 0) if self.dom_tx_power_supported: - transceiver_dom_info_dict['tx1power'] = self.__convert_string_to_num( + transceiver_dom_info_dict['tx1power'] = self._convert_string_to_num( dom_channel_monitor_data['data']['TX1Power']['value']) - transceiver_dom_info_dict['tx2power'] = self.__convert_string_to_num( + transceiver_dom_info_dict['tx2power'] = self._convert_string_to_num( dom_channel_monitor_data['data']['TX2Power']['value']) - transceiver_dom_info_dict['tx3power'] = self.__convert_string_to_num( + transceiver_dom_info_dict['tx3power'] = self._convert_string_to_num( dom_channel_monitor_data['data']['TX3Power']['value']) - transceiver_dom_info_dict['tx4power'] = self.__convert_string_to_num( + transceiver_dom_info_dict['tx4power'] = self._convert_string_to_num( dom_channel_monitor_data['data']['TX4Power']['value']) if self.dom_rx_power_supported: - transceiver_dom_info_dict['rx1power'] = self.__convert_string_to_num( + transceiver_dom_info_dict['rx1power'] = self._convert_string_to_num( dom_channel_monitor_data['data']['RX1Power']['value']) - transceiver_dom_info_dict['rx2power'] = self.__convert_string_to_num( + transceiver_dom_info_dict['rx2power'] = self._convert_string_to_num( dom_channel_monitor_data['data']['RX2Power']['value']) - transceiver_dom_info_dict['rx3power'] = self.__convert_string_to_num( + transceiver_dom_info_dict['rx3power'] = self._convert_string_to_num( dom_channel_monitor_data['data']['RX3Power']['value']) - transceiver_dom_info_dict['rx4power'] = self.__convert_string_to_num( + transceiver_dom_info_dict['rx4power'] = self._convert_string_to_num( dom_channel_monitor_data['data']['RX4Power']['value']) - transceiver_dom_info_dict['tx1bias'] = self.__convert_string_to_num( + transceiver_dom_info_dict['tx1bias'] = self._convert_string_to_num( dom_channel_monitor_data['data']['TX1Bias']['value']) - transceiver_dom_info_dict['tx2bias'] = self.__convert_string_to_num( + transceiver_dom_info_dict['tx2bias'] = self._convert_string_to_num( dom_channel_monitor_data['data']['TX2Bias']['value']) - transceiver_dom_info_dict['tx3bias'] = self.__convert_string_to_num( + transceiver_dom_info_dict['tx3bias'] = self._convert_string_to_num( dom_channel_monitor_data['data']['TX3Bias']['value']) - transceiver_dom_info_dict['tx4bias'] = self.__convert_string_to_num( + transceiver_dom_info_dict['tx4bias'] = self._convert_string_to_num( dom_channel_monitor_data['data']['TX4Bias']['value']) else: @@ -667,7 +667,7 @@ class Sfp(SfpBase): return transceiver_dom_info_dict sfpd_obj._calibration_type = self.calibration - dom_data_raw = self.__read_eeprom_specific_bytes( + dom_data_raw = self._read_eeprom_specific_bytes( (offset + SFP_DOM_BULK_DATA_START), SFP_DOM_BULK_DATA_SIZE) start = SFP_TEMPE_OFFSET - SFP_DOM_BULK_DATA_START @@ -685,15 +685,15 @@ class Sfp(SfpBase): dom_channel_monitor_data = sfpd_obj.parse_channel_monitor_params( dom_data_raw[start: end], 0) - transceiver_dom_info_dict['temperature'] = self.__convert_string_to_num( + transceiver_dom_info_dict['temperature'] = self._convert_string_to_num( dom_temperature_data['data']['Temperature']['value']) - transceiver_dom_info_dict['voltage'] = self.__convert_string_to_num( + transceiver_dom_info_dict['voltage'] = self._convert_string_to_num( dom_voltage_data['data']['Vcc']['value']) - transceiver_dom_info_dict['rx1power'] = self.__convert_string_to_num( + transceiver_dom_info_dict['rx1power'] = self._convert_string_to_num( dom_channel_monitor_data['data']['RXPower']['value']) - transceiver_dom_info_dict['tx1bias'] = self.__convert_string_to_num( + transceiver_dom_info_dict['tx1bias'] = self._convert_string_to_num( dom_channel_monitor_data['data']['TXBias']['value']) - transceiver_dom_info_dict['tx1power'] = self.__convert_string_to_num( + transceiver_dom_info_dict['tx1power'] = self._convert_string_to_num( dom_channel_monitor_data['data']['TXPower']['value']) transceiver_dom_info_dict['rx_los'] = self.get_rx_los() @@ -750,7 +750,7 @@ class Sfp(SfpBase): if sfpd_obj is None: return transceiver_dom_threshold_info_dict - dom_module_threshold_raw = self.__read_eeprom_specific_bytes( + dom_module_threshold_raw = self._read_eeprom_specific_bytes( (offset + QSFP_MODULE_THRESHOLD_OFFSET), QSFP_MODULE_THRESHOLD_WIDTH) if dom_module_threshold_raw is None: return transceiver_dom_threshold_info_dict @@ -758,8 +758,8 @@ class Sfp(SfpBase): dom_module_threshold_data = sfpd_obj.parse_module_threshold_values( dom_module_threshold_raw, 0) - dom_channel_threshold_raw = self.__read_eeprom_specific_bytes((offset + QSFP_CHANNL_THRESHOLD_OFFSET), - QSFP_CHANNL_THRESHOLD_WIDTH) + dom_channel_threshold_raw = self._read_eeprom_specific_bytes((offset + QSFP_CHANNL_THRESHOLD_OFFSET), + QSFP_CHANNL_THRESHOLD_WIDTH) if dom_channel_threshold_raw is None: return transceiver_dom_threshold_info_dict dom_channel_threshold_data = sfpd_obj.parse_channel_threshold_values( @@ -797,8 +797,8 @@ class Sfp(SfpBase): if sfpd_obj is None: return transceiver_dom_threshold_info_dict - dom_module_threshold_raw = self.__read_eeprom_specific_bytes((offset + SFP_MODULE_THRESHOLD_OFFSET), - SFP_MODULE_THRESHOLD_WIDTH) + 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) @@ -829,7 +829,7 @@ class Sfp(SfpBase): transceiver_dom_threshold_info_dict['rxpowerlowwarning'] = dom_module_threshold_data['data']['RXPowerLowWarning']['value'] for key in transceiver_dom_threshold_info_dict: - transceiver_dom_threshold_info_dict[key] = self.__convert_string_to_num( + transceiver_dom_threshold_info_dict[key] = self._convert_string_to_num( transceiver_dom_threshold_info_dict[key]) return transceiver_dom_threshold_info_dict @@ -845,35 +845,36 @@ class Sfp(SfpBase): def get_rx_los(self): """ - Retrieves the RX LOS (lost-of-signal) status of SFP + Retrieves the RX LOS (loss-of-signal) status of SFP Returns: - A Boolean, True if SFP has RX LOS, False if not. + A list of boolean values, representing the RX LOS status + of each available channel, value is True if SFP channel + has RX LOS, False if not. + E.g., for a tranceiver with four channels: [False, False, True, False] Note : RX LOS status is latched until a call to get_rx_los or a reset. """ - rx_los = False - if self.sfp_type == OSFP_TYPE: - return False + rx_los_list = [] - elif self.sfp_type == QSFP_TYPE: + if self.sfp_type == QSFP_TYPE: offset = 0 - dom_channel_monitor_raw = self.__read_eeprom_specific_bytes( + dom_channel_monitor_raw = self._read_eeprom_specific_bytes( (offset + QSFP_CHANNL_RX_LOS_STATUS_OFFSET), QSFP_CHANNL_RX_LOS_STATUS_WIDTH) if dom_channel_monitor_raw is not None: rx_los_data = int(dom_channel_monitor_raw[0], 16) - rx1_los = (rx_los_data & 0x01 != 0) - rx2_los = (rx_los_data & 0x02 != 0) - rx3_los = (rx_los_data & 0x04 != 0) - rx4_los = (rx_los_data & 0x08 != 0) - rx_los = (rx1_los and rx2_los and rx3_los and rx4_los) - else: + rx_los_list.append(rx_los_data & 0x01 != 0) + rx_los_list.append(rx_los_data & 0x02 != 0) + rx_los_list.append(rx_los_data & 0x04 != 0) + rx_los_list.append(rx_los_data & 0x08 != 0) + + elif self.sfp_type == SFP_TYPE: offset = 256 - dom_channel_monitor_raw = self.__read_eeprom_specific_bytes( + dom_channel_monitor_raw = self._read_eeprom_specific_bytes( (offset + SFP_CHANNL_STATUS_OFFSET), SFP_CHANNL_STATUS_WIDTH) if dom_channel_monitor_raw is not None: rx_los_data = int(dom_channel_monitor_raw[0], 16) - rx_los = (rx_los_data & 0x02 != 0) + rx_los_list.append(rx_los_data & 0x02 != 0) - return rx_los + return rx_los_list def get_tx_fault(self): """ @@ -882,51 +883,66 @@ class Sfp(SfpBase): A Boolean, True if SFP has TX fault, False if not Note : TX fault status is lached until a call to get_tx_fault or a reset. """ - tx4_fault = False + tx_fault_list = [] + if not self.dom_supported: + return tx_fault_list - if self.sfp_type == OSFP_TYPE or not self.dom_supported: - return False - - elif self.sfp_type == QSFP_TYPE: + if self.sfp_type == QSFP_TYPE: offset = 0 - dom_channel_monitor_raw = self.__read_eeprom_specific_bytes( + dom_channel_monitor_raw = self._read_eeprom_specific_bytes( (offset + QSFP_CHANNL_TX_FAULT_STATUS_OFFSET), QSFP_CHANNL_TX_FAULT_STATUS_WIDTH) if dom_channel_monitor_raw is not None: tx_fault_data = int(dom_channel_monitor_raw[0], 16) - tx1_fault = (tx_fault_data & 0x01 != 0) - tx2_fault = (tx_fault_data & 0x02 != 0) - tx3_fault = (tx_fault_data & 0x04 != 0) - tx4_fault = (tx_fault_data & 0x08 != 0) - tx4_fault = ( - tx1_fault and tx2_fault and tx3_fault and tx4_fault) - else: + tx_fault_list.append(tx_fault_data & 0x01 != 0) + tx_fault_list.append(tx_fault_data & 0x02 != 0) + tx_fault_list.append(tx_fault_data & 0x04 != 0) + tx_fault_list.append(tx_fault_data & 0x08 != 0) + + elif self.sfp_type == SFP_TYPE: offset = 256 - dom_channel_monitor_raw = self.__read_eeprom_specific_bytes( + dom_channel_monitor_raw = self._read_eeprom_specific_bytes( (offset + SFP_CHANNL_STATUS_OFFSET), SFP_CHANNL_STATUS_WIDTH) if dom_channel_monitor_raw is not None: tx_fault_data = int(dom_channel_monitor_raw[0], 16) - tx4_fault = (tx_fault_data & 0x04 != 0) + tx_fault_list.append(tx_fault_data & 0x04 != 0) - return tx4_fault + return tx_fault_list 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 + A list of boolean values, representing the TX disable status + of each available channel, value is True if SFP channel + is TX disabled, False if not. + E.g., for a tranceiver with four channels: [False, False, True, False] """ - tx_disable = False - status_control_raw = self.__read_eeprom_specific_bytes( - SFP_CHANNL_STATUS_OFFSET, SFP_CHANNL_STATUS_WIDTH) - if status_control_raw: - data = int(status_control_raw[0], 16) - tx_disable_hard = (sffbase().test_bit( - data, SFP_TX_DISABLE_HARD_BIT) != 0) - tx_disable_soft = (sffbase().test_bit( - data, SFP_TX_DISABLE_SOFT_BIT) != 0) - tx_disable = tx_disable_hard | tx_disable_soft - return tx_disable + tx_disable_list = [] + if not self.dom_supported: + return tx_disable_list + + if self.sfp_type == QSFP_TYPE: + offset = 0 + dom_channel_monitor_raw = self._read_eeprom_specific_bytes( + (offset + QSFP_CHANNL_DISABLE_STATUS_OFFSET), QSFP_CHANNL_DISABLE_STATUS_WIDTH) + if dom_channel_monitor_raw is not None: + tx_disable_data = int(dom_channel_monitor_raw[0], 16) + tx_disable_list.append(tx_disable_data & 0x01 != 0) + tx_disable_list.append(tx_disable_data & 0x02 != 0) + tx_disable_list.append(tx_disable_data & 0x04 != 0) + tx_disable_list.append(tx_disable_data & 0x08 != 0) + + elif self.sfp_type == SFP_TYPE: + offset = 256 + dom_channel_monitor_raw = self._read_eeprom_specific_bytes( + (offset + SFP_CHANNL_STATUS_OFFSET), SFP_CHANNL_STATUS_WIDTH) + if dom_channel_monitor_raw is not None: + tx_disable_data = int(dom_channel_monitor_raw[0], 16) + tx_disable_list.append(tx_disable_data & 0xC0 != 0) + else: + return None + return tx_disable_list def get_tx_disable_channel(self): """ @@ -937,8 +953,14 @@ class Sfp(SfpBase): As an example, a returned value of 0x5 indicates that channel 0 and channel 2 have been disabled. """ - # SFP doesn't support this feature - return 0 + tx_disable_list = self.get_tx_disable() + if tx_disable_list is None: + return 0 + tx_disabled = 0 + for i in range(len(tx_disable_list)): + if tx_disable_list[i]: + tx_disabled |= 1 << i + return tx_disabled def get_lpmode(self): """ @@ -965,7 +987,7 @@ class Sfp(SfpBase): An integer number of current temperature in Celsius """ transceiver_bulk_status = self.get_transceiver_bulk_status() - return transceiver_bulk_status.get("temperature", "N/A") + return transceiver_bulk_status.get("temperature", 0.0) def get_voltage(self): """ @@ -974,7 +996,7 @@ class Sfp(SfpBase): An integer number of supply voltage in mV """ transceiver_bulk_status = self.get_transceiver_bulk_status() - return transceiver_bulk_status.get("voltage", "N/A") + return transceiver_bulk_status.get("voltage", 0.0) def get_tx_bias(self): """ @@ -984,9 +1006,49 @@ class Sfp(SfpBase): for channel 0 to channel 4. Ex. ['110.09', '111.12', '108.21', '112.09'] """ - transceiver_dom_info_dict = self.get_transceiver_bulk_status() - tx1_bs = transceiver_dom_info_dict.get("tx1bias", "N/A") - return [tx1_bs, "N/A", "N/A", "N/A"] if transceiver_dom_info_dict else [] + tx_bias_list = [] + if not self.dom_supported: + return tx_bias_list + + if self.sfp_type == QSFP_TYPE: + offset = 0 + + sfpd_obj = sff8436Dom() + if sfpd_obj is None: + return tx_bias_list + + 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) + 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'])) + + elif self.sfp_type == SFP_TYPE: + offset = 256 + + sfpd_obj = sff8472Dom() + if sfpd_obj is None: + return tx_bias_list + sfpd_obj._calibration_type = self.calibration + + if self.dom_supported: + 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) + tx_bias_list.append(self._convert_string_to_num( + dom_channel_monitor_data['data']['TXBias']['value'])) + + return tx_bias_list def get_rx_power(self): """ @@ -996,9 +1058,48 @@ class Sfp(SfpBase): power in mW for channel 0 to channel 4. Ex. ['1.77', '1.71', '1.68', '1.70'] """ - transceiver_dom_info_dict = self.get_transceiver_bulk_status() - rx1_pw = transceiver_dom_info_dict.get("rx1power", "N/A") - return [rx1_pw, "N/A", "N/A", "N/A"] if transceiver_dom_info_dict else [] + rx_power_list = [] + if self.sfp_type == QSFP_TYPE: + offset = 0 + + sfpd_obj = sff8436Dom() + if sfpd_obj is None: + return rx_power_list + + if self.dom_rx_power_supported: + 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) + 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'])) + + elif self.sfp_type == SFP_TYPE: + offset = 256 + + sfpd_obj = sff8472Dom() + if sfpd_obj is None: + return None + + if self.dom_supported: + sfpd_obj._calibration_type = self.calibration + + 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) + rx_power_list.append(self._convert_string_to_num( + dom_channel_monitor_data['data']['RXPower']['value'])) + + return rx_power_list def get_tx_power(self): """ @@ -1008,9 +1109,48 @@ class Sfp(SfpBase): for channel 0 to channel 4. Ex. ['1.86', '1.86', '1.86', '1.86'] """ - transceiver_dom_info_dict = self.get_transceiver_bulk_status() - tx1_pw = transceiver_dom_info_dict.get("tx1power", "N/A") - return [tx1_pw, "N/A", "N/A", "N/A"] if transceiver_dom_info_dict else [] + tx_power_list = [] + if self.sfp_type == QSFP_TYPE: + offset = 0 + + sfpd_obj = sff8436Dom() + if sfpd_obj is None: + return tx_power_list + + if self.dom_tx_power_supported: + 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) + tx_power_list.append(self._convert_string_to_num( + dom_channel_monitor_data['data']['TX1Power']['value'])) + tx_power_list.append(self._convert_string_to_num( + dom_channel_monitor_data['data']['TX2Power']['value'])) + tx_power_list.append(self._convert_string_to_num( + dom_channel_monitor_data['data']['TX3Power']['value'])) + tx_power_list.append(self._convert_string_to_num( + dom_channel_monitor_data['data']['TX4Power']['value'])) + + elif self.sfp_type == SFP_TYPE: + + offset = 256 + sfpd_obj = sff8472Dom() + if sfpd_obj is None: + return None + + if self.dom_supported: + sfpd_obj._calibration_type = self.calibration + + 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) + tx_power_list.append(self._convert_string_to_num( + dom_channel_monitor_data['data']['TXPower']['value'])) + + return tx_power_list def reset(self): """ @@ -1031,7 +1171,7 @@ class Sfp(SfpBase): A boolean, True if tx_disable is set successfully, False if not """ sysfs_sfp_i2c_client_eeprom_path = self.port_to_eeprom_mapping[self.port_num] - status_control_raw = self.__read_eeprom_specific_bytes( + status_control_raw = self._read_eeprom_specific_bytes( SFP_CHANNL_STATUS_OFFSET, SFP_CHANNL_STATUS_WIDTH) if status_control_raw is not None: # Set bit 6 for Soft TX Disable Select