From af58f6edee187d7eb7534124083ba916e7e84629 Mon Sep 17 00:00:00 2001 From: jumao Date: Thu, 9 Jul 2026 10:14:05 -0400 Subject: [PATCH] [H6-128]Update thermal algorithm, reset reason --- ixr7220h6-128/modules/h6_fan_cpld.c | 2 +- ixr7220h6-128/modules/mb_pld.c | 36 +++------- ixr7220h6-128/scripts/h6_128_platform_init.sh | 16 ++++- ixr7220h6-128/sonic_platform/chassis.py | 25 +++---- ixr7220h6-128/sonic_platform/fan.py | 47 ++++++++---- ixr7220h6-128/sonic_platform/psu.py | 15 ++-- ixr7220h6-128/sonic_platform/thermal.py | 32 +++++---- .../sonic_platform/thermal_actions.py | 35 +++++---- ixr7220h6-128/sonic_platform/thermal_infos.py | 72 +++++++++++++------ 9 files changed, 173 insertions(+), 107 deletions(-) diff --git a/ixr7220h6-128/modules/h6_fan_cpld.c b/ixr7220h6-128/modules/h6_fan_cpld.c index 8ccd64a..597421e 100644 --- a/ixr7220h6-128/modules/h6_fan_cpld.c +++ b/ixr7220h6-128/modules/h6_fan_cpld.c @@ -263,7 +263,7 @@ static u32 reg_val_to_speed_rpm(u8 reg_val) static u8 reg_val_to_is_present(u8 reg_val, enum fan_id id) { - return !((reg_val >> id) & 0x1); + return !((reg_val >> (id+4)) & 0x1); } static u8 reg_val_to_color(u8 reg_val, enum fan_id id) diff --git a/ixr7220h6-128/modules/mb_pld.c b/ixr7220h6-128/modules/mb_pld.c index e24e4ea..7c0edc8 100644 --- a/ixr7220h6-128/modules/mb_pld.c +++ b/ixr7220h6-128/modules/mb_pld.c @@ -31,7 +31,7 @@ // REGISTERS ADDRESS MAP #define VER_MAJOR_REG 0x00 #define VER_MINOR_REG 0x01 -#define SCRATCH_REG 0x04 +#define BMC_RESET_REG 0x04 #define OSFP_EFUSE_REG0 0x10 #define SYS_LED_REG0 0x80 #define SYS_LED_REG1 0x81 @@ -42,6 +42,7 @@ struct cpld_data { struct i2c_client *client; struct mutex update_lock; int osfp_efuse; + int bmc_reset; }; static int cpld_i2c_read(struct cpld_data *data, u8 reg) @@ -82,32 +83,10 @@ static ssize_t show_ver(struct device *dev, struct device_attribute *devattr, ch return sprintf(buf, "%02x.%02x\n", reg_major, reg_minor); } -static ssize_t show_scratch(struct device *dev, struct device_attribute *devattr, char *buf) +static ssize_t show_bmc_reset(struct device *dev, struct device_attribute *devattr, char *buf) { struct cpld_data *data = dev_get_drvdata(dev); - u8 val = 0; - - val = cpld_i2c_read(data, SCRATCH_REG); - - return sprintf(buf, "0x%02x\n", val); -} - -static ssize_t set_scratch(struct device *dev, struct device_attribute *devattr, const char *buf, size_t count) -{ - struct cpld_data *data = dev_get_drvdata(dev); - u8 usr_val = 0; - - int ret = kstrtou8(buf, 16, &usr_val); - if (ret != 0) { - return ret; - } - if (usr_val > 0xFF) { - return -EINVAL; - } - - cpld_i2c_write(data, SCRATCH_REG, usr_val); - - return count; + return sprintf(buf, "%02x\n", data->bmc_reset); } static ssize_t show_led0(struct device *dev, struct device_attribute *devattr, char *buf) @@ -220,7 +199,7 @@ static ssize_t set_osfp_efuse(struct device *dev, struct device_attribute *devat // sysfs attributes static SENSOR_DEVICE_ATTR(version, S_IRUGO, show_ver, NULL, 0); -static SENSOR_DEVICE_ATTR(scratch, S_IRUGO | S_IWUSR, show_scratch, set_scratch, 0); +static SENSOR_DEVICE_ATTR(bmc_reset, S_IRUGO, show_bmc_reset, NULL, 0); static SENSOR_DEVICE_ATTR(led_sys, S_IRUGO | S_IWUSR, show_led0, set_led0, 0); static SENSOR_DEVICE_ATTR(led_psu, S_IRUGO, show_led0, NULL, 4); @@ -231,7 +210,7 @@ static SENSOR_DEVICE_ATTR(osfp_efuse, S_IRUGO | S_IWUSR, show_osfp_efuse, set_os static struct attribute *mb_pld_attributes[] = { &sensor_dev_attr_version.dev_attr.attr, - &sensor_dev_attr_scratch.dev_attr.attr, + &sensor_dev_attr_bmc_reset.dev_attr.attr, &sensor_dev_attr_led_sys.dev_attr.attr, &sensor_dev_attr_led_psu.dev_attr.attr, @@ -281,6 +260,9 @@ static int mb_pld_probe(struct i2c_client *client) for (i=0;i<8;i++) cpld_i2c_write(data, OSFP_EFUSE_REG0+i, 0xFF); data->osfp_efuse = 1; + data->bmc_reset = cpld_i2c_read(data, BMC_RESET_REG); + cpld_i2c_write(data, BMC_RESET_REG, 0x0); + return 0; exit_sysfs_create_group: diff --git a/ixr7220h6-128/scripts/h6_128_platform_init.sh b/ixr7220h6-128/scripts/h6_128_platform_init.sh index ca5c755..7f38aa6 100644 --- a/ixr7220h6-128/scripts/h6_128_platform_init.sh +++ b/ixr7220h6-128/scripts/h6_128_platform_init.sh @@ -41,6 +41,8 @@ sleep 1 i2cset -y 1 0x77 0x0 0x03 sleep 2 i2cset -y 1 0x71 0xc 0xff +i2cset -y 1 0x71 0x82 0x1 +i2cset -y 1 0x71 0x80 0x7f sleep 1 echo cb_pld 0x60 > /sys/bus/i2c/devices/i2c-1/new_device @@ -50,7 +52,7 @@ sleep 1 echo mux_mb 0x72 > /sys/bus/i2c/devices/i2c-135/new_device echo mb_pld 0x71 > /sys/bus/i2c/devices/i2c-135/new_device - +i2cset -y 149 0x74 0x5 0x1f echo mux_fcm 0x75 > /sys/bus/i2c/devices/i2c-145/new_device echo mux_fcm 0x76 > /sys/bus/i2c/devices/i2c-146/new_device sleep 1 @@ -136,13 +138,23 @@ i2cset -y 132 0x61 0x11 0x80 i2cset -y 132 0x61 0x18 0x80 i2cset -y 132 0x61 0x23 0x00 i2cset -y 132 0x61 0x2d 0x00 -ip link set eth1 up for ch in {1..8}; do echo 60 > /sys/bus/i2c/devices/145-0032/hwmon/hwmon*/fan${ch}_pwm echo 60 > /sys/bus/i2c/devices/146-0033/hwmon/hwmon*/fan${ch}_pwm done +i2cset -y 147 0x20 0x0 0x0 +value=$(i2cget -y 147 0x20 0xba w) +if [ "$?" == "0" ]; then + if [ "$value" != "0x203c" ]; then + i2cset -y 147 0x20 0xba 0x203c w + sleep 1 + i2cset -y 147 0x20 0x17 + sleep 15 + fi +fi + SN=$(decode-syseeprom -s) logger -t h6_128_platform_init "Nokia-IXR7220-H6-128: SN = ${SN}" diff --git a/ixr7220h6-128/sonic_platform/chassis.py b/ixr7220h6-128/sonic_platform/chassis.py index b41981b..22f17df 100644 --- a/ixr7220h6-128/sonic_platform/chassis.py +++ b/ixr7220h6-128/sonic_platform/chassis.py @@ -31,7 +31,7 @@ FAN_DRAWERS = 8 FANS_PER_DRAWER = 2 PSU_NUM = 4 -THERMAL_NUM = 20 +THERMAL_NUM = 21 COMPONENT_NUM = 11 PLD_DIR = "/sys/bus/i2c/devices/135-0071/" @@ -86,7 +86,7 @@ def __init__(self): drawer = drawer_ctor(drawer_index) self._fan_drawer_list.append(drawer) for fan_index in range(fan_num_per_drawer): - fan = Fan(fan_index, drawer_index) + fan = Fan(fan_index, drawer_index, drawer=drawer) drawer._fan_list.append(fan) self._fan_list.append(fan) @@ -285,20 +285,21 @@ def get_reboot_cause(self): is "REBOOT_CAUSE_HARDWARE_OTHER", the second string can be used to pass a description of the reboot cause. """ - result = read_sysfs_file(SYSFPGA_DIR + "reset_cause") + result1 = read_sysfs_file(SYSFPGA_DIR + "reset_cause") + result2 = read_sysfs_file(PLD_DIR + "bmc_reset") + val1 = int(result1, 16) + val2 = int(result2, 16) - if (int(result, 16) & 0x10) >> 4 == 1: + if val1 & 0x10: return (self.REBOOT_CAUSE_WATCHDOG, "CPU_WD") - - if (int(result, 16) & 0x01) == 1: + if val1 & 0x01: return (self.REBOOT_CAUSE_WATCHDOG, "EC_WD") - - if (int(result, 16) & 0x02) >> 1 == 1: + if val1 & 0x02: return (self.REBOOT_CAUSE_HARDWARE_OTHER, "CPU Over Heat") - - if (int(result, 16) & 0x08) >> 3 == 1: - return (self.REBOOT_CAUSE_HARDWARE_OTHER, "Power Cycle") - + if val2 == 0x5A: + return (self.REBOOT_CAUSE_POWER_LOSS, "BMC Remote Power Cycle") + if val1 & 0x08: + return (self.REBOOT_CAUSE_POWER_LOSS, "Power Cycle") return (self.REBOOT_CAUSE_NON_HARDWARE, None) def get_watchdog(self): diff --git a/ixr7220h6-128/sonic_platform/fan.py b/ixr7220h6-128/sonic_platform/fan.py index ded310e..e248f3a 100644 --- a/ixr7220h6-128/sonic_platform/fan.py +++ b/ixr7220h6-128/sonic_platform/fan.py @@ -14,8 +14,11 @@ raise ImportError(str(e) + "- required module not found") FANS_PER_DRAWER = 2 -MAX_FAN_F_SPEED = 15400 -MAX_FAN_R_SPEED = 13600 +MAX_FAN15_F_SPEED = 15400 +MAX_FAN15_R_SPEED = 13600 +MAX_FAN20_F_SPEED = 20000 +MAX_FAN20_R_SPEED = 17500 +FAN15_PN = '3HE21988AA01' FAN_TOLERANCE = 50 WORKING_FAN_SPEED = 2000 @@ -36,8 +39,11 @@ class Fan(FanBase): """Nokia platform-specific Fan class""" - def __init__(self, fan_index, drawer_index, psu_fan=False, dependency=None): + def __init__(self, fan_index, drawer_index, psu_fan=False, dependency=None, drawer=None): + self._fan_index = fan_index self.is_psu_fan = psu_fan + self._drawer = drawer + self._max_speed_inited = False i2c_dev = I2C_DEV_LIST[drawer_index%2] hwmon_path = glob.glob(HWMON_DIR.format(i2c_dev)) self.fan_led_color = ['off', 'green', 'amber', 'green_blink'] @@ -51,10 +57,10 @@ def __init__(self, fan_index, drawer_index, psu_fan=False, dependency=None): self.get_fan_presence_reg = hwmon_path[0] + f"fan{(drawer_index//2)+1}_present" self.fan_led_reg = hwmon_path[0] + f"fan{(drawer_index//2)+1}_led" - if fan_index == 0: - self.max_fan_speed = MAX_FAN_F_SPEED + if self._fan_index == 0: + self.max_fan_speed = MAX_FAN20_F_SPEED else: - self.max_fan_speed = MAX_FAN_R_SPEED + self.max_fan_speed = MAX_FAN20_R_SPEED else: # this is a PSU Fan @@ -82,8 +88,11 @@ def get_presence(self): """ result = read_sysfs_file(self.get_fan_presence_reg) if result == '1': # present + if not self._max_speed_inited and not self.is_psu_fan: + self._get_max_fan_speed() return True + self._max_speed_inited = False return False def get_model(self): @@ -102,9 +111,6 @@ def get_serial(self): Returns: string: Serial number of Fan """ - #if self.get_presence(): - # result = read_sysfs_file(self.eeprom_dir + "serial_number") - # return result.strip() return 'N/A' def get_part_number(self): @@ -114,9 +120,6 @@ def get_part_number(self): Returns: string: Part number of Fan """ - #if self.get_presence(): - # result = read_sysfs_file(self.eeprom_dir + "part_number") - # return result.strip() return 'N/A' def get_service_tag(self): @@ -178,6 +181,10 @@ def get_speed(self): :return: integer, denoting front FAN speed """ speed = 0 + if not self.get_presence(): + return speed + elif not self._max_speed_inited: + return speed fan_speed = read_sysfs_file(self.get_fan_speed_reg) if (fan_speed != 'ERR'): @@ -260,3 +267,19 @@ def get_target_speed(self): if fan_duty != 'ERR': return int(fan_duty) return 0 + + def _get_max_fan_speed(self): + if self._drawer is None: + self._max_speed_inited = True + return + + part_number = self._drawer.get_part_number() + if part_number == 'N/A' or part_number is None: + return + + is_front = (self._fan_index == 0) + + if part_number.startswith(FAN15_PN): + self.max_fan_speed = MAX_FAN15_F_SPEED if is_front else MAX_FAN15_R_SPEED + + self._max_speed_inited = True diff --git a/ixr7220h6-128/sonic_platform/psu.py b/ixr7220h6-128/sonic_platform/psu.py index b5118d2..63ec9d7 100644 --- a/ixr7220h6-128/sonic_platform/psu.py +++ b/ixr7220h6-128/sonic_platform/psu.py @@ -91,7 +91,7 @@ def get_model(self): string: Part number of PSU """ if self.get_presence(): - return read_sysfs_file(self.eeprom_dir+"product_name") + return read_sysfs_file(self.eeprom_dir+"part_number") return 'N/A' @@ -103,7 +103,7 @@ def get_serial(self): string: Serial number of PSU """ if self.get_presence(): - return read_sysfs_file(self.eeprom_dir+"serial_number") + return read_sysfs_file(self.eeprom_dir+"customer_sn") return 'N/A' @@ -266,10 +266,13 @@ def get_status_master_led(self): A string, one of the predefined STATUS_LED_COLOR_* strings. """ result = read_sysfs_file(LED_REG_DIR+"led_psu") - if result == '1': - return 'green' - else: - return 'amber' + val = int(result, 16) + if val == 0x1: + return self.psu_led_color[1] + elif val == 0x2 or val == 0x0: + return self.psu_led_color[3] + + return 'N/A' def set_status_master_led(self, _color): """ diff --git a/ixr7220h6-128/sonic_platform/thermal.py b/ixr7220h6-128/sonic_platform/thermal.py index b3fe9bf..fe71c49 100644 --- a/ixr7220h6-128/sonic_platform/thermal.py +++ b/ixr7220h6-128/sonic_platform/thermal.py @@ -15,7 +15,7 @@ sonic_logger = logger.Logger('thermal') -THERMAL_NUM = 20 +THERMAL_NUM = 21 class Thermal(ThermalBase): """Nokia platform-specific Thermal class""" @@ -23,24 +23,24 @@ class Thermal(ThermalBase): HWMON_DIR = "/sys/bus/i2c/devices/{}/hwmon/hwmon*/" I2C_DEV_LIST = ["144-0048", "155-004b", "155-004c", "155-004d", "155-0049", "155-0048", "155-004a", "175-0048", "178-0048", - "181-0048", "184-0048", "168-004d","169-004e", "162-004d", - "163-004e", "0-0021", "0-0021"] + "181-0048", "184-0048", "162-004d","163-004e", "168-004d", + "169-004e", "0-0021", "0-0021", "0-0021"] THERMAL_NAME = ["Carrier Board", "MB Top U34", "MB Top U178", "MB Bottom U196", "MB Bottom U183", "MB Top U3", "MB Top U15", "LDB Left", "LDB Right", "UDB Left", "UDB Right", "Top FCM 1", "Top FCM 2", "Bottom FCM 1", - "Bottom FCM 2", "CPU", "DDR", "Max Port Temp.", "SSD", + "Bottom FCM 2", "CPU", "DDR1", "DDR2", "Max Port Temp.", "SSD", "ASIC TH6"] - THRESHOLD = [62.0, 75.0, 75.0, 75.0, - 75.0, 75.0, 75.0, 60.0, 60.0, - 60.0, 60.0, 60.0, 60.0, 62.0, - 62.0, 95.0, 70.0, 75.0, 70.0, - 95.0] - CRITICAL_THRESHOLD = [70.0, 85.0, 85.0, 85.0, - 85.0, 85.0, 85.0, 70.0, 70.0, - 70.0, 70.0, 70.0, 70.0, 72.0, - 72.0, 99.0, 80.0, 77.0, 80.0, - 100.0] + THRESHOLD = [55.0, 75.0, 60.0, 70.0, + 52.0, 60.0, 60.0, 55.0, 55.0, + 55.0, 55.0, 60.0, 60.0, 55.0, + 52.0, 80.0, 51.0, 51.0, 65.0, 50.0, + 111.0] + CRITICAL_THRESHOLD = [65.0, 85.0, 85.0, 80.0, + 65.0, 70.0, 70.0, 65.0, 65.0, + 65.0, 65.0, 70.0, 70.0, 65.0, + 65.0, 99.0, 70.0, 70.0, 77.0, 65.0, + 115.0] def __init__(self, thermal_index, sfps): ThermalBase.__init__(self) @@ -63,8 +63,10 @@ def __init__(self, thermal_index, sfps): elif self.index == THERMAL_NUM - 3: self.thermal_temperature_file = "/sys/bus/i2c/devices/" + self.I2C_DEV_LIST[self.index - 1] + "/mem1_temperature" elif self.index == THERMAL_NUM - 4: + self.thermal_temperature_file = "/sys/bus/i2c/devices/" + self.I2C_DEV_LIST[self.index - 1] + "/mem0_temperature" + elif self.index == THERMAL_NUM - 5: self.thermal_temperature_file = "/sys/bus/i2c/devices/" + self.I2C_DEV_LIST[self.index - 1] + "/cpu_temperature" - elif self.index < THERMAL_NUM - 4: + elif self.index < THERMAL_NUM - 5: self.device_path = glob.glob(self.HWMON_DIR.format(self.I2C_DEV_LIST[self.index - 1])) if len(self.device_path) > 0: self.thermal_temperature_file = self.device_path[0] + "temp1_input" diff --git a/ixr7220h6-128/sonic_platform/thermal_actions.py b/ixr7220h6-128/sonic_platform/thermal_actions.py index 6946b8b..782af53 100644 --- a/ixr7220h6-128/sonic_platform/thermal_actions.py +++ b/ixr7220h6-128/sonic_platform/thermal_actions.py @@ -25,7 +25,7 @@ def __init__(self): Constructor of SetFanSpeedAction """ self.default_speed = 46 - self.threshold1_speed = 60 + self.threshold1_speed = 66 self.threshold2_speed = 80 self.hightemp_speed = 100 self.speed = self.default_speed @@ -137,19 +137,30 @@ def execute(self, thermal_info_dict): :param thermal_info_dict: A dictionary stores all thermal information. :return: """ - from .thermal_infos import ThermalInfo + from .thermal_infos import ThermalInfo, FanInfo + fan_info_obj = thermal_info_dict.get(FanInfo.INFO_NAME) + if isinstance(fan_info_obj, FanInfo) and fan_info_obj.is_boost_fan_ctl(): + ThermalRecoverAction.set_all_fan_speed(thermal_info_dict, 60) + fan_info_obj.set_skip_fan_ctl(True) + sonic_logger.log_warning(f"Last fan drawer has been inserted, executing boost fan control.") + return + if ThermalInfo.INFO_NAME in thermal_info_dict and \ isinstance(thermal_info_dict[ThermalInfo.INFO_NAME], ThermalInfo): - - thermal_info_obj = thermal_info_dict[ThermalInfo.INFO_NAME] - if thermal_info_obj.is_set_fan_high_temp_speed(): - ThermalRecoverAction.set_all_fan_speed(thermal_info_dict, self.hightemp_speed) - elif thermal_info_obj.is_set_fan_threshold_two_speed(): - ThermalRecoverAction.set_all_fan_speed(thermal_info_dict, self.threshold2_speed) - elif thermal_info_obj.is_set_fan_threshold_one_speed(): - ThermalRecoverAction.set_all_fan_speed(thermal_info_dict, self.threshold1_speed) - elif thermal_info_obj.is_set_fan_default_speed(): - ThermalRecoverAction.set_all_fan_speed(thermal_info_dict, self.default_speed) + if isinstance(fan_info_obj, FanInfo) and not fan_info_obj.is_skip_fan_ctl(): + thermal_info_obj = thermal_info_dict[ThermalInfo.INFO_NAME] + if thermal_info_obj.is_set_fan_high_temp_speed(): + ThermalRecoverAction.set_all_fan_speed(thermal_info_dict, self.hightemp_speed) + elif thermal_info_obj.is_set_fan_threshold_two_speed(): + ThermalRecoverAction.set_all_fan_speed(thermal_info_dict, self.threshold2_speed) + elif thermal_info_obj.is_set_fan_threshold_one_speed(): + ThermalRecoverAction.set_all_fan_speed(thermal_info_dict, self.threshold1_speed) + elif thermal_info_obj.is_set_fan_default_speed(): + ThermalRecoverAction.set_all_fan_speed(thermal_info_dict, self.default_speed) + else: + fan_info_obj.set_skip_fan_ctl(False) + thermal_info_dict[ThermalInfo.INFO_NAME]._old_threshold_level = -1 + sonic_logger.log_warning(f"Skip fan speed control for boost fan control.") @thermal_json_object('switch.shutdown') class SwitchPolicyAction(ThermalPolicyActionBase): diff --git a/ixr7220h6-128/sonic_platform/thermal_infos.py b/ixr7220h6-128/sonic_platform/thermal_infos.py index 3c760c2..e8bca2d 100644 --- a/ixr7220h6-128/sonic_platform/thermal_infos.py +++ b/ixr7220h6-128/sonic_platform/thermal_infos.py @@ -1,11 +1,11 @@ try: from sonic_platform_base.sonic_thermal_control.thermal_info_base import ThermalPolicyInfoBase from sonic_platform_base.sonic_thermal_control.thermal_json_object import thermal_json_object - from sonic_py_common.logger import Logger + from sonic_py_common import logger except ImportError as e: raise ImportError(str(e) + ' - required module not found') from e -logger = Logger() +sonic_logger = logger.Logger('thermal_infos') @thermal_json_object('fan_info') class FanInfo(ThermalPolicyInfoBase): @@ -19,6 +19,9 @@ def __init__(self): self._absence_fans = set() self._presence_fans = set() self._status_changed = False + self._was_any_absent = False + self._boost_fan_ctl = False + self._skip_fan_ctl = False def collect(self, chassis): """ @@ -27,17 +30,27 @@ def collect(self, chassis): :return: """ self._status_changed = False - for fan in chassis.get_all_fans(): - if fan.get_presence() and fan not in self._presence_fans: - self._presence_fans.add(fan) - self._status_changed = True - if fan in self._absence_fans: - self._absence_fans.remove(fan) - elif not fan.get_presence() and fan not in self._absence_fans: - self._absence_fans.add(fan) - self._status_changed = True - if fan in self._presence_fans: - self._presence_fans.remove(fan) + for fandrawer in chassis.get_all_fan_drawers(): + drawer_present = fandrawer.get_presence() + for fan in fandrawer.get_all_fans(): + if drawer_present and fan not in self._presence_fans: + self._presence_fans.add(fan) + self._status_changed = True + if fan in self._absence_fans: + self._absence_fans.remove(fan) + elif not drawer_present and fan not in self._absence_fans: + self._absence_fans.add(fan) + self._status_changed = True + if fan in self._presence_fans: + self._presence_fans.remove(fan) + + currently_any_absent = bool(self._absence_fans) + if self._was_any_absent and not currently_any_absent: + self._boost_fan_ctl = True + sonic_logger.log_warning(f"!Warning: detected last fan drawer inserted.") + else: + self._boost_fan_ctl = False + self._was_any_absent = currently_any_absent def get_absence_fans(self): """ @@ -60,6 +73,15 @@ def is_status_changed(self): """ return self._status_changed + def is_boost_fan_ctl(self): + return self._boost_fan_ctl + + def set_skip_fan_ctl(self, skip_fan_ctl): + self._skip_fan_ctl = skip_fan_ctl + + def is_skip_fan_ctl(self): + return self._skip_fan_ctl + @thermal_json_object('thermal_info') class ThermalInfo(ThermalPolicyInfoBase): """ @@ -72,13 +94,13 @@ def __init__(self): self._old_threshold_level = -1 self._current_threshold_level = 0 self._num_fan_levels = 3 - self._level_up_threshold = [[44, 54, 51, 52, 45, 53, 50, 44, 43, 45, 44, 43, 43, 47, 47, 83, 56, 58, 47, 73], - [50, 60, 57, 58, 51, 59, 56, 51, 50, 52, 51, 50, 50, 53, 53, 88, 61, 68, 51, 86], - [55, 65, 62, 63, 56, 64, 61, 56, 55, 57, 56, 55, 55, 57, 57, 93, 66, 73, 55, 91]] + self._level_up_threshold = [[27, 55, 38, 50, 27, 36, 40, 29, 29, 28, 28, 35, 35, 24, 24, 57, 25, 26, 45, 24, 83], + [39, 63, 48, 58, 38, 45, 49, 40, 40, 40, 39, 45, 45, 37, 37, 65, 37, 37, 58, 36, 101], + [49, 71, 56, 65, 47, 54, 56, 49, 49, 49, 48, 54, 55, 48, 47, 71, 46, 46, 60, 45, 105]] - self._level_down_threshold = [[31, 44, 41, 42, 35, 43, 40, 34, 33, 35, 34, 32, 32, 35, 35, 70, 42, 50, 33, 70], - [39, 52, 49, 50, 43, 51, 48, 42, 41, 43, 42, 41, 41, 45, 45, 78, 48, 60, 40, 75], - [48, 58, 55, 56, 49, 57, 54, 49, 48, 50, 49, 48, 48, 51, 51, 83, 54, 69, 47, 80]] + self._level_down_threshold = [[19, 40, 26, 35, 18, 24, 27, 20, 20, 19, 19, 24, 25, 17, 17, 47, 17, 17, 39, 16, 69], + [33, 53, 40, 47, 32, 37, 40, 33, 33, 33, 33, 38, 39, 32, 32, 58, 30, 31, 50, 29, 83], + [38, 55, 43, 49, 35, 41, 43, 38, 38, 38, 37, 46, 46, 40, 40, 61, 35, 35, 54, 34, 86]] def collect(self, chassis): """ @@ -96,7 +118,17 @@ def collect(self, chassis): # Calculate average temp within the device num_of_thermals = chassis.get_num_thermals() for index in range(num_of_thermals): - self._temps.insert(index, chassis.get_thermal(index).get_temperature()) + temp_obj = chassis.get_thermal(index) + temp_current = temp_obj.get_temperature() + self._temps.insert(index, temp_current) + temp_threshold = temp_obj.get_high_threshold() + temp_crit_threshold = temp_obj.get_high_critical_threshold() + + if temp_crit_threshold != 'N/A' and temp_current >= temp_crit_threshold: + self._over_high_critical_threshold = True + sonic_logger.log_warning(f"!!!Alarm: {temp_obj.get_name()} temperature is {temp_current}C!!!") + elif temp_threshold != 'N/A' and temp_current >= temp_threshold: + sonic_logger.log_warning(f"!Warning: {temp_obj.get_name()} temperature is {temp_current}C!") # Find current required threshold level max_level =0