diff --git a/device/nokia/armhf-nokia_ixs7215_52x-r0/plugins/pcie.yaml b/device/nokia/armhf-nokia_ixs7215_52x-r0/pcie.yaml similarity index 100% rename from device/nokia/armhf-nokia_ixs7215_52x-r0/plugins/pcie.yaml rename to device/nokia/armhf-nokia_ixs7215_52x-r0/pcie.yaml diff --git a/device/nokia/armhf-nokia_ixs7215_52x-r0/platform_reboot b/device/nokia/armhf-nokia_ixs7215_52x-r0/platform_reboot new file mode 100644 index 000000000000..83fc5d8028f2 --- /dev/null +++ b/device/nokia/armhf-nokia_ixs7215_52x-r0/platform_reboot @@ -0,0 +1,11 @@ +#!/bin/bash + +function SafePwrCycle() { + sync ; sync + umount -fa > /dev/null 2&>1 + + # Write CPLD register to initiate cold reboot + sudo i2cset -f -y 0 0x41 0x10 0x00 +} + +SafePwrCycle diff --git a/platform/marvell-armhf/sonic-platform-nokia/7215/scripts/nokia-7215init.sh b/platform/marvell-armhf/sonic-platform-nokia/7215/scripts/nokia-7215init.sh index 4cad43348e06..3f23afe1fce2 100755 --- a/platform/marvell-armhf/sonic-platform-nokia/7215/scripts/nokia-7215init.sh +++ b/platform/marvell-armhf/sonic-platform-nokia/7215/scripts/nokia-7215init.sh @@ -51,7 +51,7 @@ chmod 644 /sys/class/i2c-adapter/i2c-0/0-0053/eeprom echo eeprom 0x55 > /sys/class/i2c-adapter/i2c-0/new_device echo eeprom 0x56 > /sys/class/i2c-adapter/i2c-0/new_device -# Enumerate psu eeprom devices +# Enumerate PSU eeprom devices echo eeprom 0x51 > /sys/class/i2c-adapter/i2c-1/new_device echo eeprom 0x52 > /sys/class/i2c-adapter/i2c-1/new_device diff --git a/platform/marvell-armhf/sonic-platform-nokia/7215/sonic_platform/__init__.py b/platform/marvell-armhf/sonic-platform-nokia/7215/sonic_platform/__init__.py index 139597f9cb07..39c712316dc6 100755 --- a/platform/marvell-armhf/sonic-platform-nokia/7215/sonic_platform/__init__.py +++ b/platform/marvell-armhf/sonic-platform-nokia/7215/sonic_platform/__init__.py @@ -1,2 +1,4 @@ +__all__ = ["platform", "chassis"] +from sonic_platform import * diff --git a/platform/marvell-armhf/sonic-platform-nokia/7215/sonic_platform/chassis.py b/platform/marvell-armhf/sonic-platform-nokia/7215/sonic_platform/chassis.py index b3ada4c71f9c..a01aca24b684 100755 --- a/platform/marvell-armhf/sonic-platform-nokia/7215/sonic_platform/chassis.py +++ b/platform/marvell-armhf/sonic-platform-nokia/7215/sonic_platform/chassis.py @@ -159,6 +159,14 @@ def get_model(self): """ return self._eeprom.part_number_str() + def get_service_tag(self): + """ + Retrieves the Service Tag of the chassis + Returns: + string: Service Tag of chassis + """ + return self._eeprom.service_tag_str() + def get_status(self): """ Retrieves the operational status of the chassis @@ -367,7 +375,7 @@ def get_watchdog(self): sonic_logger.log_warning(" Fail to load watchdog {}".format(repr(e))) return self._watchdog - + def get_position_in_parent(self): """ Retrieves 1-based relative physical position in parent device. If the agent cannot determine the parent-relative position diff --git a/platform/marvell-armhf/sonic-platform-nokia/7215/sonic_platform/component.py b/platform/marvell-armhf/sonic-platform-nokia/7215/sonic_platform/component.py index 6a5410458df7..1c219d7920a5 100644 --- a/platform/marvell-armhf/sonic-platform-nokia/7215/sonic_platform/component.py +++ b/platform/marvell-armhf/sonic-platform-nokia/7215/sonic_platform/component.py @@ -16,6 +16,7 @@ except ImportError as e: raise ImportError(str(e) + "- required module not found") +smbus_present = 1 try: import smbus except ImportError as e: @@ -34,6 +35,7 @@ class Component(ComponentBase): ["System-CPLD", "Used for managing SFPs, LEDs, PSUs and FANs "], ["U-Boot", "Performs initialization during booting"], ] + CPLD_UPDATE_COMMAND = 'cp /usr/sbin/vme /tmp; cp {} /tmp; cd /tmp; ./vme {};' def __init__(self, component_index): self.index = component_index @@ -55,12 +57,12 @@ def _get_command_result(self, cmdline): def _get_cpld_version(self, cpld_number): if smbus_present == 0: - cmdstatus, cpld_version = cmd.getstatusoutput('i2cget -y 0 0x41 0x2') + cmdstatus, cpld_version = cmd.getstatusoutput('sudo i2cget -y 0 0x41 0x2') else: bus = smbus.SMBus(0) DEVICE_ADDRESS = 0x41 DEVICE_REG = 0x2 - cpld_version = bus.read_byte_data(DEVICE_ADDRESS, DEVICE_REG) + cpld_version = str(bus.read_byte_data(DEVICE_ADDRESS, DEVICE_REG)) return str(int(cpld_version, 16)) @@ -93,7 +95,7 @@ def get_firmware_version(self): return self._get_cpld_version(self.index) if self.index == 1: - cmdstatus, uboot_version = cmd.getstatusoutput('grep --null-data U-Boot /dev/mtd0ro|head -1 | cut -c 1-30') + cmdstatus, uboot_version = cmd.getstatusoutput('grep --null-data U-Boot /dev/mtd0ro|head -1 | cut -d" " -f2-4') return uboot_version def install_firmware(self, image_path): @@ -114,6 +116,18 @@ def install_firmware(self, image_path): print("ERROR: the cpld image {} doesn't exist ".format(image_path)) return False + cmdline = self.CPLD_UPDATE_COMMAND.format(image_path, image_name) + success_flag = False + try: + subprocess.check_call(cmdline, stderr=subprocess.STDOUT, shell=True) + success_flag = True + except subprocess.CalledProcessError as e: + print("ERROR: Failed to upgrade CPLD: rc={}".format(e.returncode)) + + if success_flag: + print("INFO: Refresh or power cycle is required to finish CPLD installation") + return success_flag + diff --git a/platform/marvell-armhf/sonic-platform-nokia/7215/sonic_platform/eeprom.py b/platform/marvell-armhf/sonic-platform-nokia/7215/sonic_platform/eeprom.py index cefcedaedf12..d0e3e00fffc2 100644 --- a/platform/marvell-armhf/sonic-platform-nokia/7215/sonic_platform/eeprom.py +++ b/platform/marvell-armhf/sonic-platform-nokia/7215/sonic_platform/eeprom.py @@ -1,5 +1,5 @@ ######################################################################## -# Nokia IXR7220_D1 +# Nokia IXS7215 # # Module contains platform specific implementation of SONiC Platform # Base API and provides the EEPROMs' information. @@ -7,10 +7,9 @@ # The different EEPROMs available are as follows: # - System EEPROM : Contains Serial number, Service tag, Base MA # address, etc. in ONIE TlvInfo EEPROM format. -# - PSU EEPROM : Contains Serial number, Part number, Service Tag, -# PSU type, Revision. -# - Fan EEPROM : Contains Serial number, Part number, Service Tag, -# Fan type, Number of Fans in Fantray, Revision. +# - PSU EEPROM : Contains Model name and Part number. +# - Fan EEPROM : Contains Part number, Serial number, Manufacture Date, +# and Service Tag. ######################################################################## @@ -23,15 +22,9 @@ # PSU eeprom fields in format required by EepromDecoder psu_eeprom_format = [ - ('PPID', 's', 20), ('DPN Rev', 's', 3), ('Service Tag', 's', 7), - ('Part Number', 's', 10), ('Part Num Revision', 's', 3), - ('Mfg Test', 's', 2), ('Redundant copy', 's', 83), ('PSU Type', 's', 1), - ('Fab Rev', 's', 2) - ] - -# Fan eeprom fields in format required by EepromDecoder -fan_eeprom_format = [ - ('Model', 's', 12), ('Serial Number', 's', 13) + ('Model', 's', 15), ('burn', 'x', 1), + ('Part Number', 's', 14), ('burn', 'x', 40), + ('Serial Number', 's', 11) ] @@ -48,6 +41,7 @@ def __init__(self, is_psu=False, psu_index=0, is_fan=False, fan_index=0): if self.is_sys_eeprom: self.start_offset = 0 self.eeprom_path = self.I2C_DIR + "i2c-0/0-0053/eeprom" + # System EEPROM is in ONIE TlvInfo EEPROM format super(Eeprom, self).__init__(self.eeprom_path, self.start_offset, '', True) @@ -55,18 +49,24 @@ def __init__(self, is_psu=False, psu_index=0, is_fan=False, fan_index=0): else: if self.is_psu_eeprom: self.index = psu_index - self.start_offset = 6 + self.start_offset = 18 self.eeprom_path = self.I2C_DIR \ - + "i2c-1/1-005{}/eeprom".format(2 - self.index) + + "i2c-1/1-005{}/eeprom".format(self.index) self.format = psu_eeprom_format + + # Decode device eeprom as per specified format + EepromDecoder.__init__(self, self.eeprom_path, self.format, + self.start_offset, '', True) else: self.index = fan_index - self.start_offset = 13 + self.start_offset = 0 self.eeprom_path = self.I2C_DIR \ - + "i2c-4{0}/4{0}-0050/eeprom".format(self.index - 1) - self.format = fan_eeprom_format - EepromDecoder.__init__(self, self.eeprom_path, self.format, - self.start_offset, '', True) + + "i2c-0/0-005{}/eeprom".format(self.index + 4) + + # Fan EEPROM is in ONIE TlvInfo EEPROM format + super(Eeprom, self).__init__(self.eeprom_path, + self.start_offset, '', True) + self._load_device_eeprom() def _load_system_eeprom(self): @@ -83,24 +83,24 @@ def _load_system_eeprom(self): self.serial_number = 'NA' self.part_number = 'NA' self.model_str = 'NA' - self.serial = 'NA' + self.service_tag = 'NA' self.eeprom_tlv_dict = dict() else: eeprom = self.eeprom_data - self.eeprom_tlv_dict = dict() - if not self.is_valid_tlvinfo_header(eeprom): self.base_mac = 'NA' self.serial_number = 'NA' self.part_number = 'NA' self.model_str = 'NA' - self.serial = 'NA' + self.service_tag = 'NA' return total_length = (eeprom[9] << 8) | eeprom[10] tlv_index = self._TLV_INFO_HDR_LEN tlv_end = self._TLV_INFO_HDR_LEN + total_length + # Construct dictionary of eeprom TLV entries + self.eeprom_tlv_dict = dict() while (tlv_index + 2) < len(eeprom) and tlv_index < tlv_end: if not self.is_valid_tlv(eeprom[tlv_index:]): break @@ -108,7 +108,7 @@ def _load_system_eeprom(self): tlv = eeprom[tlv_index:tlv_index + 2 + eeprom[tlv_index + 1]] code = "0x%02X" % (tlv[0]) - + name, value = self.decoder(None, tlv) self.eeprom_tlv_dict[code] = value @@ -118,56 +118,98 @@ def _load_system_eeprom(self): tlv_index += eeprom[tlv_index+1] + 2 self.base_mac = self.eeprom_tlv_dict.get( - "0x%X" % (self._TLV_CODE_MAC_BASE), 'NA') + "0x%X" % (self._TLV_CODE_MAC_BASE), 'NA') self.serial_number = self.eeprom_tlv_dict.get( - "0x%X" % (self._TLV_CODE_SERIAL_NUMBER), 'NA') + "0x%X" % (self._TLV_CODE_SERIAL_NUMBER), 'NA') self.part_number = self.eeprom_tlv_dict.get( - "0x%X" % (self._TLV_CODE_PART_NUMBER), 'NA') + "0x%X" % (self._TLV_CODE_PART_NUMBER), 'NA') self.model_str = self.eeprom_tlv_dict.get( - "0x%X" % (self._TLV_CODE_PRODUCT_NAME), 'NA') - self.serial = self.eeprom_tlv_dict.get( - "0x%X" % (self._TLV_CODE_SERVICE_TAG), 'NA') + "0x%X" % (self._TLV_CODE_PRODUCT_NAME), 'NA') + self.service_tag = self.eeprom_tlv_dict.get( + "0x%X" % (self._TLV_CODE_SERVICE_TAG), 'NA') def _load_device_eeprom(self): """ - Reads the Fan/PSU EEPROM and retrieves the serial number and - model number of the device. + Reads the Fan/PSU EEPROM and interprets as per the specified format """ - try: - # Read Fan/PSU EEPROM as per the specified format. - self.eeprom_data = EepromDecoder.read_eeprom(self) - except Exception as e: - self.serial_number = 'NA' - self.part_number = 'NA' - self.model_str = 'NA' - self.serial = 'NA' - else: + self.serial_number = 'NA' + self.part_number = 'NA' + self.model_str = 'NA' + self.service_tag = 'NA' + self.mfg_date = 'NA' + + # PSU device eeproms use proprietary format + if self.is_psu_eeprom: + try: + # Read Fan/PSU EEPROM as per the specified format. + self.eeprom_data = EepromDecoder.read_eeprom(self) + except Exception as e: + return + + # Bail out if PSU eeprom unavailable + if self.eeprom_data[0] == 255: + return + (valid, data) = self._get_eeprom_field("Model") if valid: - self.model_str = data - else: - self.model_str = 'NA' + self.model_str = data.decode() - (valid, data) = self._get_eeprom_field("Serial Number") + (valid, data) = self._get_eeprom_field("Part Number") if valid: - self.serial_number = data - else: - self.serial_number = 'NA' + self.part_number = data.decode() - if self.is_psu_eeprom: - (valid, data) = self._get_eeprom_field("PSU Type") + # Early PSU device eeproms were not programmed with serial # + try: + (valid, data) = self._get_eeprom_field("Serial Number") if valid: - self.psu_type = data - else: - self.psu_type = 'NA' - else: - (valid, data) = self._get_eeprom_field("Fan Type") - if valid: - self.fan_type = data - else: - self.fan_type = 'NA' + self.serial_number = data.decode() + except Exception as e: + return + + # Fan device eeproms use ONIE TLV format + else: + try: + # Read Fan EEPROM as per ONIE TlvInfo EEPROM format. + self.eeprom_data = self.read_eeprom() + except Exception as e: + return + + eeprom = self.eeprom_data + if not self.is_valid_tlvinfo_header(eeprom): + return + + total_length = (eeprom[9] << 8) | eeprom[10] + tlv_index = self._TLV_INFO_HDR_LEN + tlv_end = self._TLV_INFO_HDR_LEN + total_length + + # Construct dictionary of eeprom TLV entries + self.eeprom_tlv_dict = dict() + while (tlv_index + 2) < len(eeprom) and tlv_index < tlv_end: + if not self.is_valid_tlv(eeprom[tlv_index:]): + break + + tlv = eeprom[tlv_index:tlv_index + 2 + + eeprom[tlv_index + 1]] + code = "0x%02X" % (tlv[0]) + + name, value = self.decoder(None, tlv) + + self.eeprom_tlv_dict[code] = value + if eeprom[tlv_index] == self._TLV_CODE_CRC_32: + break + + tlv_index += eeprom[tlv_index+1] + 2 + + self.serial_number = self.eeprom_tlv_dict.get( + "0x%X" % (self._TLV_CODE_SERIAL_NUMBER), 'NA') + self.part_number = self.eeprom_tlv_dict.get( + "0x%X" % (self._TLV_CODE_PART_NUMBER), 'NA') + self.model_str = self.eeprom_tlv_dict.get( + "0x%X" % (self._TLV_CODE_PRODUCT_NAME), 'NA') + self.service_tag = self.eeprom_tlv_dict.get( + "0x%X" % (self._TLV_CODE_SERVICE_TAG), 'NA') - def _get_eeprom_field(self, field_name): + def _get_eeprom_field(self, field_name, decode=False): """ For a field name specified in the EEPROM format, returns the presence of the field and the value for the same. @@ -205,24 +247,23 @@ def airflow_fan_type(self): else: return int(self.fan_type.encode('hex'), 16) - # System EEPROM specific methods - def base_mac_addr(self): - """ - Returns the base MAC address found in the system EEPROM. - """ - return self.base_mac - def modelstr(self): """ Returns the Model name. """ return self.model_str - def serial_str(self): + def base_mac_addr(self): + """ + Returns the base MAC address found in the system EEPROM. + """ + return self.base_mac + + def service_tag_str(self): """ Returns the servicetag number. """ - return self.serial + return self.service_tag def system_eeprom_info(self): """ diff --git a/platform/marvell-armhf/sonic-platform-nokia/7215/sonic_platform/fan.py b/platform/marvell-armhf/sonic-platform-nokia/7215/sonic_platform/fan.py index 67610a125fad..14c00c763dde 100644 --- a/platform/marvell-armhf/sonic-platform-nokia/7215/sonic_platform/fan.py +++ b/platform/marvell-armhf/sonic-platform-nokia/7215/sonic_platform/fan.py @@ -1,5 +1,5 @@ ######################################################################## -# Nokia 7215 +# Nokia IXS7215 # # Module contains an implementation of SONiC Platform Base API and # provides the Fans' information which are available in the platform @@ -9,7 +9,9 @@ try: import os + import time from sonic_platform_base.fan_base import FanBase + from sonic_platform.eeprom import Eeprom from sonic_py_common import logger except ImportError as e: raise ImportError(str(e) + "- required module not found") @@ -41,6 +43,9 @@ def __init__(self, fan_index, fan_drawer, psu_fan=False, dependency=None): self.get_fan_speed_reg = ADT7473_DIR+"fan{}_input".format(self.index) self.max_fan_speed = MAX_IXS7215_FAN_SPEED self.supported_led_color = ['off', 'green', 'red'] + + # Fan eeprom + self.eeprom = Eeprom(is_fan=True, fan_index=self.index) else: # this is a PSU Fan self.index = fan_index @@ -78,6 +83,12 @@ def _set_i2c_register(self, reg_file, value): except Exception as e: rv = 'ERR' + # Ensure that the write operation has succeeded + if (int(self._get_i2c_register(reg_file)) != value ): + time.sleep(3) + if (int(self._get_i2c_register(reg_file)) != value ): + rv = 'ERR' + return rv def get_name(self): @@ -123,10 +134,9 @@ def get_model(self): Retrieves the model number of the Fan Returns: - string: Part number of Fan + string: Model number of Fan. Use part number for this. """ - - return 'NA' + return self.eeprom.part_number_str() def get_serial(self): """ @@ -135,8 +145,25 @@ def get_serial(self): Returns: string: Serial number of Fan """ + return self.eeprom.serial_number_str() + + def get_part_number(self): + """ + Retrieves the part number of the Fan + + Returns: + string: Part number of Fan + """ + return self.eeprom.part_number_str() - return 'NA' + def get_service_tag(self): + """ + Retrieves the service tag of the Fan + + Returns: + string: Service Tag of Fan + """ + return self.eeprom.service_tag_str() def get_status(self): """ diff --git a/platform/marvell-armhf/sonic-platform-nokia/7215/sonic_platform/fan_drawer.py b/platform/marvell-armhf/sonic-platform-nokia/7215/sonic_platform/fan_drawer.py index cabb15d455d6..35b663cbb786 100644 --- a/platform/marvell-armhf/sonic-platform-nokia/7215/sonic_platform/fan_drawer.py +++ b/platform/marvell-armhf/sonic-platform-nokia/7215/sonic_platform/fan_drawer.py @@ -30,7 +30,7 @@ def get_model(self): """ Retrieves the model number of the Fan Drawer Returns: - string: Part number of Fan Drawer + string: Part number of Fan Drawer """ return self._fan_list[0].get_model() @@ -49,7 +49,7 @@ def get_status(self): bool: True if Fan is operating properly, False if not """ return self._fan_list[0].get_status() - + def get_direction(self): return 'intake' @@ -74,8 +74,8 @@ def get_position_in_parent(self): integer: The 1-based relative physical position in parent device """ return self._index - - + + # For Nokia platforms with fan drawer(s) class RealDrawer(NokiaFanDrawer): def __init__(self, index): @@ -84,8 +84,3 @@ def __init__(self, index): def get_name(self): return self._name - - - - - diff --git a/platform/marvell-armhf/sonic-platform-nokia/7215/sonic_platform/psu.py b/platform/marvell-armhf/sonic-platform-nokia/7215/sonic_platform/psu.py index ab53abebf934..9de9ebec3699 100644 --- a/platform/marvell-armhf/sonic-platform-nokia/7215/sonic_platform/psu.py +++ b/platform/marvell-armhf/sonic-platform-nokia/7215/sonic_platform/psu.py @@ -1,5 +1,5 @@ ######################################################################## -# Nokia 7215 +# Nokia IXS7215 # # Module contains an implementation of SONiC Platform Base API and # provides the PSUs' information which are available in the platform @@ -10,6 +10,7 @@ import sys from sonic_platform_base.psu_base import PsuBase from sonic_py_common import logger + from sonic_platform.eeprom import Eeprom except ImportError as e: raise ImportError(str(e) + "- required module not found") @@ -34,6 +35,9 @@ def __init__(self, psu_index): self.index = psu_index + 1 self._fan_list = [] + # PSU eeprom + self.eeprom = Eeprom(is_psu=True, psu_index=self.index) + def get_name(self): """ Retrieves the name of the device @@ -52,7 +56,7 @@ def get_presence(self): """ if smbus_present == 0: # if called from psuutil outside of pmon - cmdstatus, psustatus = cmd.getstatusoutput('i2cget -y 0 0x41 0xa') + cmdstatus, psustatus = cmd.getstatusoutput('sudo i2cget -y 0 0x41 0xa') psustatus = int(psustatus, 16) else: bus = smbus.SMBus(0) @@ -78,8 +82,7 @@ def get_model(self): Returns: string: Part number of PSU """ - return "N/A" -# return self.eeprom.serial_number_str() + return self.eeprom.modelstr() def get_serial(self): @@ -89,9 +92,17 @@ def get_serial(self): Returns: string: Serial number of PSU """ - return "N/A" -# return self.eeprom.serial_number_str() + return self.eeprom.serial_number_str() + + + def get_part_number(self): + """ + Retrieves the part number of the PSU + Returns: + string: Part number of PSU + """ + return self.eeprom.part_number_str() def get_status(self): """ @@ -102,7 +113,7 @@ def get_status(self): """ if smbus_present == 0: - cmdstatus, psustatus = cmd.getstatusoutput('i2cget -y 0 0x41 0xa') + cmdstatus, psustatus = cmd.getstatusoutput('sudo i2cget -y 0 0x41 0xa') psustatus = int(psustatus, 16) sonic_logger.log_warning("PMON psu-smbus - presence = 0 ") else: @@ -131,7 +142,7 @@ def get_voltage(self): e.g. 12.1 """ if smbus_present == 0: - cmdstatus, psustatus = cmd.getstatusoutput('i2cget -y 0 0x41 0xa') + cmdstatus, psustatus = cmd.getstatusoutput('sudo i2cget -y 0 0x41 0xa') psustatus = int(psustatus, 16) else: bus = smbus.SMBus(0) @@ -153,30 +164,6 @@ def get_voltage(self): psu_voltage = 0.0 return psu_voltage -# def get_current(self): -# """ -# Retrieves present electric current supplied by PSU -# -# Returns: -# A float number, electric current in amperes, -# e.g. 15.4 -# """ -# psu_current = 0.0 -# -# return psu_current -# -# def get_power(self): -# """ -# Retrieves current energy supplied by PSU -# -# Returns: -# A float number, the power in watts, -# e.g. 302.6 -# """ -# psu_power = 0.0 -# -# return psu_power - def get_position_in_parent(self): """ Retrieves 1-based relative physical position in parent device @@ -191,7 +178,7 @@ def is_replaceable(self): Returns: bool: True if it is replaceable. """ - return True + return True def get_powergood_status(self): """ @@ -202,7 +189,7 @@ def get_powergood_status(self): """ if smbus_present == 0: - cmdstatus, psustatus = cmd.getstatusoutput('i2cget -y 0 0x41 0xa') + cmdstatus, psustatus = cmd.getstatusoutput('sudo i2cget -y 0 0x41 0xa') psustatus = int(psustatus, 16) else: bus = smbus.SMBus(0) @@ -243,6 +230,6 @@ def set_status_led(self, color): bool: True if status LED state is set successfully, False if not """ - # In ISX7215 , the firmware running in the PSU controls the LED + # The firmware running in the PSU controls the LED # and the PSU LED state cannot be changed from CPU. return False diff --git a/platform/marvell-armhf/sonic-platform-nokia/7215/sonic_platform/sfp.py b/platform/marvell-armhf/sonic-platform-nokia/7215/sonic_platform/sfp.py index cb9c1b910561..57fcde16149d 100644 --- a/platform/marvell-armhf/sonic-platform-nokia/7215/sonic_platform/sfp.py +++ b/platform/marvell-armhf/sonic-platform-nokia/7215/sonic_platform/sfp.py @@ -366,7 +366,7 @@ def get_transceiver_info(self): transceiver_info_dict['nominal_bit_rate'] = str( sfp_interface_bulk_data['data']['NominalSignallingRate(UnitsOf100Mbd)']['value']) transceiver_info_dict['application_advertisement'] = 'N/A' - + return transceiver_info_dict def get_transceiver_bulk_status(self): @@ -571,7 +571,7 @@ def get_rx_los(self): rx_los_list.append(rx_los_data & 0x02 != 0) else: return None - + return rx_los_list def get_tx_fault(self): @@ -617,7 +617,7 @@ def get_tx_disable(self): tx_disable_list.append(tx_disable_data & 0xC0 != 0) else: return None - + return tx_disable_list def get_tx_disable_channel(self): @@ -668,7 +668,7 @@ def get_temperature(self): """ if self.sfp_type == COPPER_TYPE: return None - + transceiver_bulk_status = self.get_transceiver_bulk_status() return transceiver_bulk_status.get("temperature", "N/A") @@ -680,7 +680,7 @@ def get_voltage(self): """ if self.sfp_type == COPPER_TYPE: return None - + transceiver_bulk_status = self.get_transceiver_bulk_status() return transceiver_bulk_status.get("voltage", "N/A") @@ -688,11 +688,11 @@ def get_tx_bias(self): """ Retrieves the TX bias current of this SFP Returns: - + """ if self.sfp_type == COPPER_TYPE: return None - + tx_bias_list = [] transceiver_bulk_status = self.get_transceiver_bulk_status() tx_bias_list.append(transceiver_bulk_status.get("tx1bias", "N/A")) @@ -884,7 +884,7 @@ def get_presence(self): return False if smbus_present == 0: # if called from sfputil outside of pmon - cmdstatus, sfpstatus = cmd.getstatusoutput('i2cget -y 0 0x41 0x3') + cmdstatus, sfpstatus = cmd.getstatusoutput('sudo i2cget -y 0 0x41 0x3') sfpstatus = int(sfpstatus, 16) else: bus = smbus.SMBus(0) @@ -938,7 +938,7 @@ def is_replaceable(self): return True else: return False - + def get_position_in_parent(self): """ Retrieves 1-based relative physical position in parent device diff --git a/platform/marvell-armhf/sonic-platform-nokia/7215/sonic_platform/sfp_event.py b/platform/marvell-armhf/sonic-platform-nokia/7215/sonic_platform/sfp_event.py index ed2143886760..fd494ca674f5 100644 --- a/platform/marvell-armhf/sonic-platform-nokia/7215/sonic_platform/sfp_event.py +++ b/platform/marvell-armhf/sonic-platform-nokia/7215/sonic_platform/sfp_event.py @@ -51,7 +51,7 @@ def deinitialize(self): def _get_transceiver_status(self): if smbus_present == 0: sonic_logger.log_info(" PMON - smbus ERROR - DEBUG sfp_event ") - cmdstatus, sfpstatus = cmd.getstatusoutput('i2cget -y 0 0x41 0x3') + cmdstatus, sfpstatus = cmd.getstatusoutput('sudo i2cget -y 0 0x41 0x3') sfpstatus = int(sfpstatus, 16) else: bus = smbus.SMBus(0) diff --git a/platform/marvell-armhf/sonic-platform-nokia/7215/sonic_platform/test/test-chassis.py b/platform/marvell-armhf/sonic-platform-nokia/7215/sonic_platform/test/test-chassis.py index 775596159269..53c047ca2329 100755 --- a/platform/marvell-armhf/sonic-platform-nokia/7215/sonic_platform/test/test-chassis.py +++ b/platform/marvell-armhf/sonic-platform-nokia/7215/sonic_platform/test/test-chassis.py @@ -41,6 +41,10 @@ def main(): print(" Chassis all_fans: {}\n".format(chassis.get_all_fans())) + print(" Chassis num_psus: {}".format(chassis.get_num_psus())) + + print(" Chassis all_psus: {}\n".format(chassis.get_all_psus())) + print(" Chassis num_thermals: {}".format(chassis.get_num_thermals())) print(" Chassis all_thermals: {}\n".format(chassis.get_all_thermals())) diff --git a/platform/marvell-armhf/sonic-platform-nokia/7215/sonic_platform/test/test-component.py b/platform/marvell-armhf/sonic-platform-nokia/7215/sonic_platform/test/test-component.py index edc9e03b3f66..1116cc7b5857 100755 --- a/platform/marvell-armhf/sonic-platform-nokia/7215/sonic_platform/test/test-component.py +++ b/platform/marvell-armhf/sonic-platform-nokia/7215/sonic_platform/test/test-component.py @@ -10,6 +10,11 @@ def main(): chassis = Chassis() + for component in chassis.get_all_components(): + print(" Name: {}".format(component.get_name())) + print(" Description: {}".format(component.get_description())) + print(" FW version: {}\n".format(component.get_firmware_version())) + return diff --git a/platform/marvell-armhf/sonic-platform-nokia/7215/sonic_platform/test/test-eeprom.py b/platform/marvell-armhf/sonic-platform-nokia/7215/sonic_platform/test/test-eeprom.py index 76f3d8995e4a..40836611692b 100755 --- a/platform/marvell-armhf/sonic-platform-nokia/7215/sonic_platform/test/test-eeprom.py +++ b/platform/marvell-armhf/sonic-platform-nokia/7215/sonic_platform/test/test-eeprom.py @@ -12,11 +12,11 @@ def main(): eeprom = chassis.get_eeprom() - print " Model: {}, Serial: {}".format(eeprom.modelstr(), - eeprom.serial_str()) - print " Part#: {}, Serial#: {}".format(eeprom.part_number_str(), - eeprom.serial_number_str()) - print " Base MAC: {}".format(eeprom.base_mac_addr()) + print(" Model: {}, Service Tag: {}".format(eeprom.modelstr(), + eeprom.service_tag_str())) + print(" Part#: {}, Serial#: {}".format(eeprom.part_number_str(), + eeprom.serial_number_str())) + print(" Base MAC: {}".format(eeprom.base_mac_addr())) return diff --git a/platform/marvell-armhf/sonic-platform-nokia/7215/sonic_platform/test/test-fan.py b/platform/marvell-armhf/sonic-platform-nokia/7215/sonic_platform/test/test-fan.py index 6f1ebd42adbe..9bbf4d864acb 100755 --- a/platform/marvell-armhf/sonic-platform-nokia/7215/sonic_platform/test/test-fan.py +++ b/platform/marvell-armhf/sonic-platform-nokia/7215/sonic_platform/test/test-fan.py @@ -11,15 +11,20 @@ def main(): chassis = Chassis() for fan in chassis.get_all_fans(): - print(" Name:", fan.get_name()) - print(" Presence: {}, Status: {}, LED: {}".format(fan.get_presence(), - fan.get_status(), - fan.get_status_led())) - print(" Model: {}, Serial: {}".format(fan.get_model(), - fan.get_serial())) - print(" Direction: {}, Speed: {}RPM, Target Speed: {}%\n".format(fan.get_direction(), - str(fan.get_speed()), - str(fan.get_target_speed()))) + if not fan.get_presence(): + print(" Name: {} not present".format(fan.get_name())) + else: + print(" Name:", fan.get_name()) + print(" Presence: {}, Status: {}, LED: {}".format(fan.get_presence(), + fan.get_status(), + fan.get_status_led())) + print(" Model: {}, Serial#: {}".format(fan.get_model(), + fan.get_serial())) + print(" Part#: {}, Service Tag: {}".format(fan.get_part_number(), + fan.get_service_tag())) + print(" Direction: {}, Speed: {}RPM, Target Speed: {}%\n".format(fan.get_direction(), + str(fan.get_speed()), + str(fan.get_target_speed()))) return diff --git a/platform/marvell-armhf/sonic-platform-nokia/7215/sonic_platform/test/test-psu.py b/platform/marvell-armhf/sonic-platform-nokia/7215/sonic_platform/test/test-psu.py index 692430ff2991..e3979b8c4175 100755 --- a/platform/marvell-armhf/sonic-platform-nokia/7215/sonic_platform/test/test-psu.py +++ b/platform/marvell-armhf/sonic-platform-nokia/7215/sonic_platform/test/test-psu.py @@ -11,13 +11,28 @@ def main(): chassis = Chassis() for psu in chassis.get_all_psus(): - print(" Name:", psu.get_name()) - print(" Presence: {}, Status: {}, LED: {}".format(psu.get_presence(), - psu.get_status(), - psu.get_status_led())) - print(" Model: {}, Serial: {}".format(psu.get_model(), - psu.get_serial())) - print(" Voltage: {}, Current: NO, Power: NO \n".format(psu.get_voltage())) + if not psu.get_presence(): + print(" Name: {} not present".format(psu.get_name())) + else: + print(" Name:", psu.get_name()) + print(" Presence: {}, Status: {}, LED: {}".format(psu.get_presence(), + psu.get_status(), + psu.get_status_led())) + print(" Model: {}, Serial#: {}, Part#: {}".format(psu.get_model(), + psu.get_serial(), + psu.get_part_number())) + try: + current = psu.get_current() + except NotImplementedError: + current = "NA" + try: + power = psu.get_power() + except NotImplementedError: + power = "NA" + + print(" Voltage: {}, Current: {}, Power: {}\n".format(psu.get_voltage(), + current, + power)) return diff --git a/platform/marvell-armhf/sonic-platform-nokia/7215/sonic_platform/test/test-sfp.py b/platform/marvell-armhf/sonic-platform-nokia/7215/sonic_platform/test/test-sfp.py index f5437b18f82e..4d283fa2eb03 100755 --- a/platform/marvell-armhf/sonic-platform-nokia/7215/sonic_platform/test/test-sfp.py +++ b/platform/marvell-armhf/sonic-platform-nokia/7215/sonic_platform/test/test-sfp.py @@ -7,15 +7,16 @@ def main(): + print("---------------------") + print("Chassis SFP Unit Test") + print("---------------------") + + chassis = Chassis() PORT_START = 1 PORT_END = 52 - chassis = Chassis() - for physical_port in range(PORT_START, PORT_END+1): - - print(" ") print(" SFP transceiver tests PORT = ", physical_port) name = chassis.get_sfp(physical_port).get_name() diff --git a/platform/marvell-armhf/sonic-platform-nokia/7215/sonic_platform/test/test-thermal.py b/platform/marvell-armhf/sonic-platform-nokia/7215/sonic_platform/test/test-thermal.py index 9e99b0da3f41..91ef75d8f9a7 100755 --- a/platform/marvell-armhf/sonic-platform-nokia/7215/sonic_platform/test/test-thermal.py +++ b/platform/marvell-armhf/sonic-platform-nokia/7215/sonic_platform/test/test-thermal.py @@ -2,7 +2,6 @@ from sonic_platform.chassis import Chassis - def main(): print("-------------------------") print("Chassis Thermal Unit Test") @@ -11,13 +10,39 @@ def main(): chassis = Chassis() for thermal in chassis.get_all_thermals(): - print(" Name:", thermal.get_name()) - print(" Presence: {}, Status: {}".format(thermal.get_presence(), - thermal.get_status())) - print(" Model: {}, Serial: {}".format(thermal.get_model(), - thermal.get_serial())) - print(" Temperature: {}C, High Threshold: {}C\n".format(thermal.get_temperature(), - thermal.get_high_threshold())) + if not thermal.get_presence(): + print(" Name: {} not present".format(thermal.get_name())) + else: + print(" Name:", thermal.get_name()) + print(" Presence: {}, Status: {}".format(thermal.get_presence(), + thermal.get_status())) + print(" Model: {}, Serial#: {}".format(thermal.get_model(), + thermal.get_serial())) + print(" Temperature(C): {}".format(thermal.get_temperature())) + + try: + low_thresh = thermal.get_low_threshold() + except NotImplementedError: + low_thresh = "NA" + try: + high_thresh = thermal.get_high_threshold() + except NotImplementedError: + high_thresh = "NA" + + print(" Low Threshold(C): {}, High Threshold(C): {}".format(low_thresh, + high_thresh)) + + try: + crit_low_thresh = thermal.get_low_critical_threshold() + except NotImplementedError: + crit_low_thresh = "NA" + try: + crit_high_thresh = thermal.get_high_critical_threshold() + except NotImplementedError: + crit_high_thresh = "NA" + + print(" Crit Low Threshold(C): {}, Crit High Threshold(C): {}\n".format(crit_low_thresh, + crit_high_thresh)) return