[Mellanox] support new platform api, thermal and psu part (#3175)
* support new platform api, thermal and psu part
for psu, all APIs are supported.
for thermal, we support
get_temperature,
get_high_threshold
for the thermal sensors of cpu core, cpu pack, psu and sfp module
and get_temperature for the ambient thermal sensors around the asic, port, fan, comex and board.
* 1. address review comments
2. improve the handling of PSU inserting/removal
3. tolerance diverse psu thermal sensor file name conventions
* 1. adjust thermal code according to the latest version of hw-management
2. check power_good_status rather than whether file existing ahead of reading voltage, current and power of PSU
2019-07-22 09:59:49 -05:00
|
|
|
#!/usr/bin/env python
|
|
|
|
|
|
|
|
#############################################################################
|
|
|
|
# Mellanox
|
|
|
|
#
|
|
|
|
# Module contains an implementation of SONiC Platform Base API and
|
|
|
|
# provides the thermals data which are available in the platform
|
|
|
|
#
|
|
|
|
#############################################################################
|
|
|
|
|
|
|
|
try:
|
|
|
|
from sonic_platform_base.thermal_base import ThermalBase
|
2020-08-03 13:43:12 -05:00
|
|
|
from sonic_py_common.logger import Logger
|
[Mellanox] support new platform api, thermal and psu part (#3175)
* support new platform api, thermal and psu part
for psu, all APIs are supported.
for thermal, we support
get_temperature,
get_high_threshold
for the thermal sensors of cpu core, cpu pack, psu and sfp module
and get_temperature for the ambient thermal sensors around the asic, port, fan, comex and board.
* 1. address review comments
2. improve the handling of PSU inserting/removal
3. tolerance diverse psu thermal sensor file name conventions
* 1. adjust thermal code according to the latest version of hw-management
2. check power_good_status rather than whether file existing ahead of reading voltage, current and power of PSU
2019-07-22 09:59:49 -05:00
|
|
|
from os import listdir
|
|
|
|
from os.path import isfile, join
|
|
|
|
import io
|
|
|
|
import os.path
|
|
|
|
except ImportError as e:
|
|
|
|
raise ImportError (str(e) + "- required module not found")
|
|
|
|
|
|
|
|
# Global logger class instance
|
2019-10-15 13:29:45 -05:00
|
|
|
logger = Logger()
|
[Mellanox] support new platform api, thermal and psu part (#3175)
* support new platform api, thermal and psu part
for psu, all APIs are supported.
for thermal, we support
get_temperature,
get_high_threshold
for the thermal sensors of cpu core, cpu pack, psu and sfp module
and get_temperature for the ambient thermal sensors around the asic, port, fan, comex and board.
* 1. address review comments
2. improve the handling of PSU inserting/removal
3. tolerance diverse psu thermal sensor file name conventions
* 1. adjust thermal code according to the latest version of hw-management
2. check power_good_status rather than whether file existing ahead of reading voltage, current and power of PSU
2019-07-22 09:59:49 -05:00
|
|
|
|
|
|
|
THERMAL_DEV_CATEGORY_CPU_CORE = "cpu_core"
|
|
|
|
THERMAL_DEV_CATEGORY_CPU_PACK = "cpu_pack"
|
|
|
|
THERMAL_DEV_CATEGORY_MODULE = "module"
|
|
|
|
THERMAL_DEV_CATEGORY_PSU = "psu"
|
|
|
|
THERMAL_DEV_CATEGORY_GEARBOX = "gearbox"
|
|
|
|
THERMAL_DEV_CATEGORY_AMBIENT = "ambient"
|
|
|
|
|
|
|
|
THERMAL_DEV_ASIC_AMBIENT = "asic_amb"
|
|
|
|
THERMAL_DEV_FAN_AMBIENT = "fan_amb"
|
|
|
|
THERMAL_DEV_PORT_AMBIENT = "port_amb"
|
|
|
|
THERMAL_DEV_COMEX_AMBIENT = "comex_amb"
|
|
|
|
THERMAL_DEV_BOARD_AMBIENT = "board_amb"
|
|
|
|
|
|
|
|
THERMAL_API_GET_TEMPERATURE = "get_temperature"
|
|
|
|
THERMAL_API_GET_HIGH_THRESHOLD = "get_high_threshold"
|
2020-03-09 12:41:10 -05:00
|
|
|
THERMAL_API_GET_HIGH_CRITICAL_THRESHOLD = "get_high_critical_threshold"
|
|
|
|
|
|
|
|
THERMAL_API_INVALID_HIGH_THRESHOLD = 0.0
|
[Mellanox] support new platform api, thermal and psu part (#3175)
* support new platform api, thermal and psu part
for psu, all APIs are supported.
for thermal, we support
get_temperature,
get_high_threshold
for the thermal sensors of cpu core, cpu pack, psu and sfp module
and get_temperature for the ambient thermal sensors around the asic, port, fan, comex and board.
* 1. address review comments
2. improve the handling of PSU inserting/removal
3. tolerance diverse psu thermal sensor file name conventions
* 1. adjust thermal code according to the latest version of hw-management
2. check power_good_status rather than whether file existing ahead of reading voltage, current and power of PSU
2019-07-22 09:59:49 -05:00
|
|
|
|
|
|
|
HW_MGMT_THERMAL_ROOT = "/var/run/hw-management/thermal/"
|
|
|
|
|
2020-04-21 10:09:53 -05:00
|
|
|
THERMAL_ZONE_ASIC_PATH = "/var/run/hw-management/thermal/mlxsw/"
|
|
|
|
THERMAL_ZONE_MODULE_PATH = "/var/run/hw-management/thermal/mlxsw-module{}/"
|
|
|
|
THERMAL_ZONE_GEARBOX_PATH = "/var/run/hw-management/thermal/mlxsw-gearbox{}/"
|
|
|
|
THERMAL_ZONE_MODE = "thermal_zone_mode"
|
|
|
|
THERMAL_ZONE_POLICY = "thermal_zone_policy"
|
|
|
|
THERMAL_ZONE_TEMPERATURE = "thermal_zone_temp"
|
|
|
|
THERMAL_ZONE_NORMAL_TEMPERATURE = "temp_trip_norm"
|
|
|
|
|
|
|
|
MODULE_TEMPERATURE_FAULT_PATH = "/var/run/hw-management/thermal/module{}_temp_fault"
|
|
|
|
|
2020-06-28 19:54:28 -05:00
|
|
|
thermal_api_handler_asic = {
|
|
|
|
THERMAL_API_GET_TEMPERATURE: 'asic',
|
|
|
|
THERMAL_API_GET_HIGH_THRESHOLD: 'mlxsw/temp_trip_hot',
|
|
|
|
THERMAL_API_GET_HIGH_CRITICAL_THRESHOLD: 'mlxsw/temp_trip_crit'
|
|
|
|
}
|
|
|
|
|
[Mellanox] support new platform api, thermal and psu part (#3175)
* support new platform api, thermal and psu part
for psu, all APIs are supported.
for thermal, we support
get_temperature,
get_high_threshold
for the thermal sensors of cpu core, cpu pack, psu and sfp module
and get_temperature for the ambient thermal sensors around the asic, port, fan, comex and board.
* 1. address review comments
2. improve the handling of PSU inserting/removal
3. tolerance diverse psu thermal sensor file name conventions
* 1. adjust thermal code according to the latest version of hw-management
2. check power_good_status rather than whether file existing ahead of reading voltage, current and power of PSU
2019-07-22 09:59:49 -05:00
|
|
|
thermal_api_handler_cpu_core = {
|
|
|
|
THERMAL_API_GET_TEMPERATURE:"cpu_core{}",
|
2020-03-09 12:41:10 -05:00
|
|
|
THERMAL_API_GET_HIGH_THRESHOLD:"cpu_core{}_max",
|
|
|
|
THERMAL_API_GET_HIGH_CRITICAL_THRESHOLD:"cpu_core{}_crit"
|
[Mellanox] support new platform api, thermal and psu part (#3175)
* support new platform api, thermal and psu part
for psu, all APIs are supported.
for thermal, we support
get_temperature,
get_high_threshold
for the thermal sensors of cpu core, cpu pack, psu and sfp module
and get_temperature for the ambient thermal sensors around the asic, port, fan, comex and board.
* 1. address review comments
2. improve the handling of PSU inserting/removal
3. tolerance diverse psu thermal sensor file name conventions
* 1. adjust thermal code according to the latest version of hw-management
2. check power_good_status rather than whether file existing ahead of reading voltage, current and power of PSU
2019-07-22 09:59:49 -05:00
|
|
|
}
|
|
|
|
thermal_api_handler_cpu_pack = {
|
|
|
|
THERMAL_API_GET_TEMPERATURE:"cpu_pack",
|
2020-03-09 12:41:10 -05:00
|
|
|
THERMAL_API_GET_HIGH_THRESHOLD:"cpu_pack_max",
|
|
|
|
THERMAL_API_GET_HIGH_CRITICAL_THRESHOLD:"cpu_pack_crit"
|
[Mellanox] support new platform api, thermal and psu part (#3175)
* support new platform api, thermal and psu part
for psu, all APIs are supported.
for thermal, we support
get_temperature,
get_high_threshold
for the thermal sensors of cpu core, cpu pack, psu and sfp module
and get_temperature for the ambient thermal sensors around the asic, port, fan, comex and board.
* 1. address review comments
2. improve the handling of PSU inserting/removal
3. tolerance diverse psu thermal sensor file name conventions
* 1. adjust thermal code according to the latest version of hw-management
2. check power_good_status rather than whether file existing ahead of reading voltage, current and power of PSU
2019-07-22 09:59:49 -05:00
|
|
|
}
|
|
|
|
thermal_api_handler_module = {
|
2019-08-23 13:58:03 -05:00
|
|
|
THERMAL_API_GET_TEMPERATURE:"module{}_temp_input",
|
2020-03-09 12:41:10 -05:00
|
|
|
THERMAL_API_GET_HIGH_THRESHOLD:"module{}_temp_crit",
|
|
|
|
THERMAL_API_GET_HIGH_CRITICAL_THRESHOLD:"module{}_temp_emergency"
|
[Mellanox] support new platform api, thermal and psu part (#3175)
* support new platform api, thermal and psu part
for psu, all APIs are supported.
for thermal, we support
get_temperature,
get_high_threshold
for the thermal sensors of cpu core, cpu pack, psu and sfp module
and get_temperature for the ambient thermal sensors around the asic, port, fan, comex and board.
* 1. address review comments
2. improve the handling of PSU inserting/removal
3. tolerance diverse psu thermal sensor file name conventions
* 1. adjust thermal code according to the latest version of hw-management
2. check power_good_status rather than whether file existing ahead of reading voltage, current and power of PSU
2019-07-22 09:59:49 -05:00
|
|
|
}
|
|
|
|
thermal_api_handler_psu = {
|
|
|
|
THERMAL_API_GET_TEMPERATURE:"psu{}_temp",
|
2020-03-09 12:41:10 -05:00
|
|
|
THERMAL_API_GET_HIGH_THRESHOLD:"psu{}_temp_max",
|
|
|
|
THERMAL_API_GET_HIGH_CRITICAL_THRESHOLD:None
|
[Mellanox] support new platform api, thermal and psu part (#3175)
* support new platform api, thermal and psu part
for psu, all APIs are supported.
for thermal, we support
get_temperature,
get_high_threshold
for the thermal sensors of cpu core, cpu pack, psu and sfp module
and get_temperature for the ambient thermal sensors around the asic, port, fan, comex and board.
* 1. address review comments
2. improve the handling of PSU inserting/removal
3. tolerance diverse psu thermal sensor file name conventions
* 1. adjust thermal code according to the latest version of hw-management
2. check power_good_status rather than whether file existing ahead of reading voltage, current and power of PSU
2019-07-22 09:59:49 -05:00
|
|
|
}
|
|
|
|
thermal_api_handler_gearbox = {
|
2020-01-17 16:05:35 -06:00
|
|
|
THERMAL_API_GET_TEMPERATURE:"gearbox{}_temp_input",
|
2020-03-25 12:54:07 -05:00
|
|
|
THERMAL_API_GET_HIGH_THRESHOLD:None,
|
|
|
|
THERMAL_API_GET_HIGH_CRITICAL_THRESHOLD:None
|
[Mellanox] support new platform api, thermal and psu part (#3175)
* support new platform api, thermal and psu part
for psu, all APIs are supported.
for thermal, we support
get_temperature,
get_high_threshold
for the thermal sensors of cpu core, cpu pack, psu and sfp module
and get_temperature for the ambient thermal sensors around the asic, port, fan, comex and board.
* 1. address review comments
2. improve the handling of PSU inserting/removal
3. tolerance diverse psu thermal sensor file name conventions
* 1. adjust thermal code according to the latest version of hw-management
2. check power_good_status rather than whether file existing ahead of reading voltage, current and power of PSU
2019-07-22 09:59:49 -05:00
|
|
|
}
|
|
|
|
thermal_ambient_apis = {
|
2020-06-28 19:54:28 -05:00
|
|
|
THERMAL_DEV_ASIC_AMBIENT : thermal_api_handler_asic,
|
[Mellanox] support new platform api, thermal and psu part (#3175)
* support new platform api, thermal and psu part
for psu, all APIs are supported.
for thermal, we support
get_temperature,
get_high_threshold
for the thermal sensors of cpu core, cpu pack, psu and sfp module
and get_temperature for the ambient thermal sensors around the asic, port, fan, comex and board.
* 1. address review comments
2. improve the handling of PSU inserting/removal
3. tolerance diverse psu thermal sensor file name conventions
* 1. adjust thermal code according to the latest version of hw-management
2. check power_good_status rather than whether file existing ahead of reading voltage, current and power of PSU
2019-07-22 09:59:49 -05:00
|
|
|
THERMAL_DEV_PORT_AMBIENT : "port_amb",
|
|
|
|
THERMAL_DEV_FAN_AMBIENT : "fan_amb",
|
|
|
|
THERMAL_DEV_COMEX_AMBIENT : "comex_amb",
|
|
|
|
THERMAL_DEV_BOARD_AMBIENT : "board_amb"
|
|
|
|
}
|
|
|
|
thermal_ambient_name = {
|
2020-06-28 19:54:28 -05:00
|
|
|
THERMAL_DEV_ASIC_AMBIENT : 'ASIC',
|
[Mellanox] support new platform api, thermal and psu part (#3175)
* support new platform api, thermal and psu part
for psu, all APIs are supported.
for thermal, we support
get_temperature,
get_high_threshold
for the thermal sensors of cpu core, cpu pack, psu and sfp module
and get_temperature for the ambient thermal sensors around the asic, port, fan, comex and board.
* 1. address review comments
2. improve the handling of PSU inserting/removal
3. tolerance diverse psu thermal sensor file name conventions
* 1. adjust thermal code according to the latest version of hw-management
2. check power_good_status rather than whether file existing ahead of reading voltage, current and power of PSU
2019-07-22 09:59:49 -05:00
|
|
|
THERMAL_DEV_PORT_AMBIENT : "Ambient Port Side Temp",
|
|
|
|
THERMAL_DEV_FAN_AMBIENT : "Ambient Fan Side Temp",
|
|
|
|
THERMAL_DEV_COMEX_AMBIENT : "Ambient COMEX Temp",
|
|
|
|
THERMAL_DEV_BOARD_AMBIENT : "Ambient Board Temp"
|
|
|
|
}
|
|
|
|
thermal_api_handlers = {
|
|
|
|
THERMAL_DEV_CATEGORY_CPU_CORE : thermal_api_handler_cpu_core,
|
|
|
|
THERMAL_DEV_CATEGORY_CPU_PACK : thermal_api_handler_cpu_pack,
|
|
|
|
THERMAL_DEV_CATEGORY_MODULE : thermal_api_handler_module,
|
|
|
|
THERMAL_DEV_CATEGORY_PSU : thermal_api_handler_psu,
|
|
|
|
THERMAL_DEV_CATEGORY_GEARBOX : thermal_api_handler_gearbox
|
|
|
|
}
|
|
|
|
thermal_name = {
|
|
|
|
THERMAL_DEV_CATEGORY_CPU_CORE : "CPU Core {} Temp",
|
|
|
|
THERMAL_DEV_CATEGORY_CPU_PACK : "CPU Pack Temp",
|
|
|
|
THERMAL_DEV_CATEGORY_MODULE : "xSFP module {} Temp",
|
|
|
|
THERMAL_DEV_CATEGORY_PSU : "PSU-{} Temp",
|
|
|
|
THERMAL_DEV_CATEGORY_GEARBOX : "Gearbox {} Temp"
|
|
|
|
}
|
|
|
|
|
|
|
|
thermal_device_categories_all = [
|
|
|
|
THERMAL_DEV_CATEGORY_AMBIENT,
|
2020-11-16 20:56:03 -06:00
|
|
|
THERMAL_DEV_CATEGORY_CPU_PACK,
|
|
|
|
THERMAL_DEV_CATEGORY_CPU_CORE,
|
|
|
|
THERMAL_DEV_CATEGORY_GEARBOX,
|
[Mellanox] support new platform api, thermal and psu part (#3175)
* support new platform api, thermal and psu part
for psu, all APIs are supported.
for thermal, we support
get_temperature,
get_high_threshold
for the thermal sensors of cpu core, cpu pack, psu and sfp module
and get_temperature for the ambient thermal sensors around the asic, port, fan, comex and board.
* 1. address review comments
2. improve the handling of PSU inserting/removal
3. tolerance diverse psu thermal sensor file name conventions
* 1. adjust thermal code according to the latest version of hw-management
2. check power_good_status rather than whether file existing ahead of reading voltage, current and power of PSU
2019-07-22 09:59:49 -05:00
|
|
|
]
|
|
|
|
|
|
|
|
thermal_device_categories_singleton = [
|
|
|
|
THERMAL_DEV_CATEGORY_CPU_PACK,
|
|
|
|
THERMAL_DEV_CATEGORY_AMBIENT
|
|
|
|
]
|
|
|
|
thermal_api_names = [
|
|
|
|
THERMAL_API_GET_TEMPERATURE,
|
|
|
|
THERMAL_API_GET_HIGH_THRESHOLD
|
|
|
|
]
|
|
|
|
|
2020-11-24 12:43:48 -06:00
|
|
|
platform_dict_thermal = {'x86_64-mlnx_msn2700-r0': 0, 'x86_64-mlnx_lssn2700-r0':0, 'x86_64-mlnx_msn2740-r0': 3, 'x86_64-mlnx_msn2100-r0': 1, 'x86_64-mlnx_msn2410-r0': 2, 'x86_64-mlnx_msn2010-r0': 4, 'x86_64-mlnx_msn3420-r0':9, 'x86_64-mlnx_msn3700-r0': 5, 'x86_64-mlnx_msn3700c-r0': 6, 'x86_64-mlnx_msn3800-r0': 7, 'x86_64-mlnx_msn4600c-r0':9, 'x86_64-mlnx_msn4700-r0': 8, 'x86_64-mlnx_msn4410-r0': 8}
|
[Mellanox] support new platform api, thermal and psu part (#3175)
* support new platform api, thermal and psu part
for psu, all APIs are supported.
for thermal, we support
get_temperature,
get_high_threshold
for the thermal sensors of cpu core, cpu pack, psu and sfp module
and get_temperature for the ambient thermal sensors around the asic, port, fan, comex and board.
* 1. address review comments
2. improve the handling of PSU inserting/removal
3. tolerance diverse psu thermal sensor file name conventions
* 1. adjust thermal code according to the latest version of hw-management
2. check power_good_status rather than whether file existing ahead of reading voltage, current and power of PSU
2019-07-22 09:59:49 -05:00
|
|
|
thermal_profile_list = [
|
|
|
|
# 2700
|
|
|
|
{
|
|
|
|
THERMAL_DEV_CATEGORY_CPU_CORE:(0, 2),
|
|
|
|
THERMAL_DEV_CATEGORY_MODULE:(1, 32),
|
|
|
|
THERMAL_DEV_CATEGORY_PSU:(1, 2),
|
|
|
|
THERMAL_DEV_CATEGORY_CPU_PACK:(0,1),
|
|
|
|
THERMAL_DEV_CATEGORY_GEARBOX:(0,0),
|
|
|
|
THERMAL_DEV_CATEGORY_AMBIENT:(0,
|
|
|
|
[
|
|
|
|
THERMAL_DEV_ASIC_AMBIENT,
|
|
|
|
THERMAL_DEV_PORT_AMBIENT,
|
|
|
|
THERMAL_DEV_FAN_AMBIENT
|
|
|
|
]
|
|
|
|
)
|
|
|
|
},
|
|
|
|
# 2100
|
|
|
|
{
|
|
|
|
THERMAL_DEV_CATEGORY_CPU_CORE:(0, 4),
|
|
|
|
THERMAL_DEV_CATEGORY_MODULE:(1, 16),
|
|
|
|
THERMAL_DEV_CATEGORY_PSU:(0, 0),
|
|
|
|
THERMAL_DEV_CATEGORY_CPU_PACK:(0,0),
|
|
|
|
THERMAL_DEV_CATEGORY_GEARBOX:(0,0),
|
|
|
|
THERMAL_DEV_CATEGORY_AMBIENT:(0,
|
|
|
|
[
|
|
|
|
THERMAL_DEV_ASIC_AMBIENT,
|
|
|
|
THERMAL_DEV_PORT_AMBIENT,
|
|
|
|
THERMAL_DEV_FAN_AMBIENT,
|
|
|
|
]
|
|
|
|
)
|
|
|
|
},
|
|
|
|
# 2410
|
|
|
|
{
|
|
|
|
THERMAL_DEV_CATEGORY_CPU_CORE:(0, 2),
|
|
|
|
THERMAL_DEV_CATEGORY_MODULE:(1, 56),
|
|
|
|
THERMAL_DEV_CATEGORY_PSU:(1, 2),
|
|
|
|
THERMAL_DEV_CATEGORY_CPU_PACK:(0,1),
|
|
|
|
THERMAL_DEV_CATEGORY_GEARBOX:(0,0),
|
|
|
|
THERMAL_DEV_CATEGORY_AMBIENT:(0,
|
|
|
|
[
|
|
|
|
THERMAL_DEV_ASIC_AMBIENT,
|
|
|
|
THERMAL_DEV_PORT_AMBIENT,
|
|
|
|
THERMAL_DEV_FAN_AMBIENT,
|
|
|
|
]
|
|
|
|
)
|
|
|
|
},
|
|
|
|
# 2740
|
|
|
|
{
|
|
|
|
THERMAL_DEV_CATEGORY_CPU_CORE:(0, 4),
|
|
|
|
THERMAL_DEV_CATEGORY_MODULE:(1, 32),
|
|
|
|
THERMAL_DEV_CATEGORY_PSU:(1, 2),
|
|
|
|
THERMAL_DEV_CATEGORY_CPU_PACK:(0,0),
|
|
|
|
THERMAL_DEV_CATEGORY_GEARBOX:(0,0),
|
|
|
|
THERMAL_DEV_CATEGORY_AMBIENT:(0,
|
|
|
|
[
|
|
|
|
THERMAL_DEV_ASIC_AMBIENT,
|
|
|
|
THERMAL_DEV_PORT_AMBIENT,
|
|
|
|
THERMAL_DEV_FAN_AMBIENT,
|
|
|
|
]
|
|
|
|
)
|
|
|
|
},
|
|
|
|
# 2010
|
|
|
|
{
|
|
|
|
THERMAL_DEV_CATEGORY_CPU_CORE:(0, 4),
|
|
|
|
THERMAL_DEV_CATEGORY_MODULE:(1, 22),
|
|
|
|
THERMAL_DEV_CATEGORY_PSU:(0, 0),
|
|
|
|
THERMAL_DEV_CATEGORY_CPU_PACK:(0,0),
|
|
|
|
THERMAL_DEV_CATEGORY_GEARBOX:(0,0),
|
|
|
|
THERMAL_DEV_CATEGORY_AMBIENT:(0,
|
|
|
|
[
|
|
|
|
THERMAL_DEV_ASIC_AMBIENT,
|
|
|
|
THERMAL_DEV_PORT_AMBIENT,
|
|
|
|
THERMAL_DEV_FAN_AMBIENT,
|
|
|
|
]
|
|
|
|
)
|
|
|
|
},
|
|
|
|
# 3700
|
|
|
|
{
|
|
|
|
THERMAL_DEV_CATEGORY_CPU_CORE:(0, 4),
|
|
|
|
THERMAL_DEV_CATEGORY_MODULE:(1, 32),
|
|
|
|
THERMAL_DEV_CATEGORY_PSU:(1, 2),
|
|
|
|
THERMAL_DEV_CATEGORY_CPU_PACK:(0,1),
|
|
|
|
THERMAL_DEV_CATEGORY_GEARBOX:(0,0),
|
|
|
|
THERMAL_DEV_CATEGORY_AMBIENT:(0,
|
|
|
|
[
|
|
|
|
THERMAL_DEV_ASIC_AMBIENT,
|
|
|
|
THERMAL_DEV_COMEX_AMBIENT,
|
|
|
|
THERMAL_DEV_PORT_AMBIENT,
|
|
|
|
THERMAL_DEV_FAN_AMBIENT
|
|
|
|
]
|
|
|
|
)
|
|
|
|
},
|
|
|
|
# 3700c
|
|
|
|
{
|
|
|
|
THERMAL_DEV_CATEGORY_CPU_CORE:(0, 2),
|
|
|
|
THERMAL_DEV_CATEGORY_MODULE:(1, 32),
|
|
|
|
THERMAL_DEV_CATEGORY_PSU:(1, 2),
|
|
|
|
THERMAL_DEV_CATEGORY_CPU_PACK:(0,1),
|
|
|
|
THERMAL_DEV_CATEGORY_GEARBOX:(0,0),
|
|
|
|
THERMAL_DEV_CATEGORY_AMBIENT:(0,
|
|
|
|
[
|
|
|
|
THERMAL_DEV_ASIC_AMBIENT,
|
|
|
|
THERMAL_DEV_COMEX_AMBIENT,
|
|
|
|
THERMAL_DEV_PORT_AMBIENT,
|
|
|
|
THERMAL_DEV_FAN_AMBIENT
|
|
|
|
]
|
|
|
|
)
|
|
|
|
},
|
|
|
|
# 3800
|
|
|
|
{
|
|
|
|
THERMAL_DEV_CATEGORY_CPU_CORE:(0, 4),
|
|
|
|
THERMAL_DEV_CATEGORY_MODULE:(1, 64),
|
|
|
|
THERMAL_DEV_CATEGORY_PSU:(1, 2),
|
|
|
|
THERMAL_DEV_CATEGORY_CPU_PACK:(0,1),
|
|
|
|
THERMAL_DEV_CATEGORY_GEARBOX:(1,32),
|
|
|
|
THERMAL_DEV_CATEGORY_AMBIENT:(0,
|
|
|
|
[
|
|
|
|
THERMAL_DEV_ASIC_AMBIENT,
|
|
|
|
THERMAL_DEV_COMEX_AMBIENT,
|
|
|
|
THERMAL_DEV_PORT_AMBIENT,
|
|
|
|
THERMAL_DEV_FAN_AMBIENT
|
|
|
|
]
|
|
|
|
)
|
|
|
|
},
|
2020-03-24 07:32:52 -05:00
|
|
|
# 4700
|
|
|
|
{
|
|
|
|
THERMAL_DEV_CATEGORY_CPU_CORE:(0, 4),
|
|
|
|
THERMAL_DEV_CATEGORY_MODULE:(1, 32),
|
|
|
|
THERMAL_DEV_CATEGORY_PSU:(1, 2),
|
|
|
|
THERMAL_DEV_CATEGORY_CPU_PACK:(0,1),
|
|
|
|
THERMAL_DEV_CATEGORY_GEARBOX:(0,0),
|
|
|
|
THERMAL_DEV_CATEGORY_AMBIENT:(0,
|
|
|
|
[
|
|
|
|
THERMAL_DEV_ASIC_AMBIENT,
|
|
|
|
THERMAL_DEV_COMEX_AMBIENT,
|
|
|
|
THERMAL_DEV_PORT_AMBIENT,
|
2020-04-26 06:39:55 -05:00
|
|
|
THERMAL_DEV_FAN_AMBIENT
|
|
|
|
]
|
|
|
|
)
|
|
|
|
},
|
|
|
|
# 3420
|
|
|
|
{
|
2020-05-13 12:01:32 -05:00
|
|
|
THERMAL_DEV_CATEGORY_CPU_CORE:(0, 2),
|
2020-04-26 06:39:55 -05:00
|
|
|
THERMAL_DEV_CATEGORY_MODULE:(1, 60),
|
|
|
|
THERMAL_DEV_CATEGORY_PSU:(1, 2),
|
|
|
|
THERMAL_DEV_CATEGORY_CPU_PACK:(0,1),
|
|
|
|
THERMAL_DEV_CATEGORY_GEARBOX:(0,0),
|
2020-04-30 02:30:11 -05:00
|
|
|
THERMAL_DEV_CATEGORY_AMBIENT:(0,
|
|
|
|
[
|
|
|
|
THERMAL_DEV_ASIC_AMBIENT,
|
|
|
|
THERMAL_DEV_COMEX_AMBIENT,
|
|
|
|
THERMAL_DEV_PORT_AMBIENT,
|
|
|
|
THERMAL_DEV_FAN_AMBIENT
|
|
|
|
]
|
|
|
|
)
|
|
|
|
},
|
|
|
|
# 4600C
|
|
|
|
{
|
|
|
|
THERMAL_DEV_CATEGORY_CPU_CORE:(0, 4),
|
|
|
|
THERMAL_DEV_CATEGORY_MODULE:(1, 64),
|
|
|
|
THERMAL_DEV_CATEGORY_PSU:(1, 2),
|
|
|
|
THERMAL_DEV_CATEGORY_CPU_PACK:(0,1),
|
|
|
|
THERMAL_DEV_CATEGORY_GEARBOX:(0,0),
|
2020-04-26 06:39:55 -05:00
|
|
|
THERMAL_DEV_CATEGORY_AMBIENT:(0,
|
|
|
|
[
|
|
|
|
THERMAL_DEV_ASIC_AMBIENT,
|
|
|
|
THERMAL_DEV_COMEX_AMBIENT,
|
|
|
|
THERMAL_DEV_PORT_AMBIENT,
|
2020-03-24 07:32:52 -05:00
|
|
|
THERMAL_DEV_FAN_AMBIENT
|
2020-11-24 12:43:48 -06:00
|
|
|
]
|
|
|
|
)
|
|
|
|
},
|
|
|
|
# 4410
|
|
|
|
{
|
|
|
|
THERMAL_DEV_CATEGORY_CPU_CORE:(0, 4),
|
|
|
|
THERMAL_DEV_CATEGORY_MODULE:(1, 32),
|
|
|
|
THERMAL_DEV_CATEGORY_PSU:(1, 2),
|
|
|
|
THERMAL_DEV_CATEGORY_CPU_PACK:(0,1),
|
|
|
|
THERMAL_DEV_CATEGORY_GEARBOX:(0,0),
|
|
|
|
THERMAL_DEV_CATEGORY_AMBIENT:(0,
|
|
|
|
[
|
|
|
|
THERMAL_DEV_ASIC_AMBIENT,
|
|
|
|
THERMAL_DEV_COMEX_AMBIENT,
|
|
|
|
THERMAL_DEV_PORT_AMBIENT,
|
|
|
|
THERMAL_DEV_FAN_AMBIENT
|
2020-03-24 07:32:52 -05:00
|
|
|
]
|
|
|
|
)
|
|
|
|
}
|
[Mellanox] support new platform api, thermal and psu part (#3175)
* support new platform api, thermal and psu part
for psu, all APIs are supported.
for thermal, we support
get_temperature,
get_high_threshold
for the thermal sensors of cpu core, cpu pack, psu and sfp module
and get_temperature for the ambient thermal sensors around the asic, port, fan, comex and board.
* 1. address review comments
2. improve the handling of PSU inserting/removal
3. tolerance diverse psu thermal sensor file name conventions
* 1. adjust thermal code according to the latest version of hw-management
2. check power_good_status rather than whether file existing ahead of reading voltage, current and power of PSU
2019-07-22 09:59:49 -05:00
|
|
|
]
|
|
|
|
|
2020-11-16 20:56:03 -06:00
|
|
|
def initialize_psu_thermals(platform, thermal_list, psu_index, dependency):
|
|
|
|
tp_index = platform_dict_thermal[platform]
|
|
|
|
thermal_profile = thermal_profile_list[tp_index]
|
|
|
|
_, count = thermal_profile[THERMAL_DEV_CATEGORY_PSU]
|
|
|
|
if count == 0:
|
|
|
|
return
|
|
|
|
thermal = Thermal(THERMAL_DEV_CATEGORY_PSU, psu_index, True, 1, dependency)
|
|
|
|
thermal_list.append(thermal)
|
|
|
|
|
2020-03-09 12:41:10 -05:00
|
|
|
|
2020-11-16 20:56:03 -06:00
|
|
|
def initialize_sfp_thermals(platform, thermal_list, sfp_index):
|
|
|
|
thermal = Thermal(THERMAL_DEV_CATEGORY_MODULE, sfp_index, True, 1)
|
|
|
|
thermal_list.append(thermal)
|
|
|
|
|
|
|
|
|
|
|
|
def initialize_chassis_thermals(platform, thermal_list):
|
[Mellanox] support new platform api, thermal and psu part (#3175)
* support new platform api, thermal and psu part
for psu, all APIs are supported.
for thermal, we support
get_temperature,
get_high_threshold
for the thermal sensors of cpu core, cpu pack, psu and sfp module
and get_temperature for the ambient thermal sensors around the asic, port, fan, comex and board.
* 1. address review comments
2. improve the handling of PSU inserting/removal
3. tolerance diverse psu thermal sensor file name conventions
* 1. adjust thermal code according to the latest version of hw-management
2. check power_good_status rather than whether file existing ahead of reading voltage, current and power of PSU
2019-07-22 09:59:49 -05:00
|
|
|
# create thermal objects for all categories of sensors
|
2020-06-21 14:15:23 -05:00
|
|
|
tp_index = platform_dict_thermal[platform]
|
[Mellanox] support new platform api, thermal and psu part (#3175)
* support new platform api, thermal and psu part
for psu, all APIs are supported.
for thermal, we support
get_temperature,
get_high_threshold
for the thermal sensors of cpu core, cpu pack, psu and sfp module
and get_temperature for the ambient thermal sensors around the asic, port, fan, comex and board.
* 1. address review comments
2. improve the handling of PSU inserting/removal
3. tolerance diverse psu thermal sensor file name conventions
* 1. adjust thermal code according to the latest version of hw-management
2. check power_good_status rather than whether file existing ahead of reading voltage, current and power of PSU
2019-07-22 09:59:49 -05:00
|
|
|
thermal_profile = thermal_profile_list[tp_index]
|
2020-04-21 10:09:53 -05:00
|
|
|
Thermal.thermal_profile = thermal_profile
|
2020-11-16 20:56:03 -06:00
|
|
|
position = 1
|
[Mellanox] support new platform api, thermal and psu part (#3175)
* support new platform api, thermal and psu part
for psu, all APIs are supported.
for thermal, we support
get_temperature,
get_high_threshold
for the thermal sensors of cpu core, cpu pack, psu and sfp module
and get_temperature for the ambient thermal sensors around the asic, port, fan, comex and board.
* 1. address review comments
2. improve the handling of PSU inserting/removal
3. tolerance diverse psu thermal sensor file name conventions
* 1. adjust thermal code according to the latest version of hw-management
2. check power_good_status rather than whether file existing ahead of reading voltage, current and power of PSU
2019-07-22 09:59:49 -05:00
|
|
|
for category in thermal_device_categories_all:
|
|
|
|
if category == THERMAL_DEV_CATEGORY_AMBIENT:
|
|
|
|
count, ambient_list = thermal_profile[category]
|
|
|
|
for ambient in ambient_list:
|
2020-11-16 20:56:03 -06:00
|
|
|
thermal = Thermal(category, ambient, True, position)
|
|
|
|
thermal_list.append(thermal),
|
|
|
|
position += 1
|
[Mellanox] support new platform api, thermal and psu part (#3175)
* support new platform api, thermal and psu part
for psu, all APIs are supported.
for thermal, we support
get_temperature,
get_high_threshold
for the thermal sensors of cpu core, cpu pack, psu and sfp module
and get_temperature for the ambient thermal sensors around the asic, port, fan, comex and board.
* 1. address review comments
2. improve the handling of PSU inserting/removal
3. tolerance diverse psu thermal sensor file name conventions
* 1. adjust thermal code according to the latest version of hw-management
2. check power_good_status rather than whether file existing ahead of reading voltage, current and power of PSU
2019-07-22 09:59:49 -05:00
|
|
|
else:
|
|
|
|
start, count = 0, 0
|
|
|
|
if category in thermal_profile:
|
|
|
|
start, count = thermal_profile[category]
|
|
|
|
if count == 0:
|
|
|
|
continue
|
|
|
|
if count == 1:
|
2020-11-16 20:56:03 -06:00
|
|
|
thermal = Thermal(category, 0, False, position)
|
[Mellanox] support new platform api, thermal and psu part (#3175)
* support new platform api, thermal and psu part
for psu, all APIs are supported.
for thermal, we support
get_temperature,
get_high_threshold
for the thermal sensors of cpu core, cpu pack, psu and sfp module
and get_temperature for the ambient thermal sensors around the asic, port, fan, comex and board.
* 1. address review comments
2. improve the handling of PSU inserting/removal
3. tolerance diverse psu thermal sensor file name conventions
* 1. adjust thermal code according to the latest version of hw-management
2. check power_good_status rather than whether file existing ahead of reading voltage, current and power of PSU
2019-07-22 09:59:49 -05:00
|
|
|
thermal_list.append(thermal)
|
2020-11-16 20:56:03 -06:00
|
|
|
position += 1
|
[Mellanox] support new platform api, thermal and psu part (#3175)
* support new platform api, thermal and psu part
for psu, all APIs are supported.
for thermal, we support
get_temperature,
get_high_threshold
for the thermal sensors of cpu core, cpu pack, psu and sfp module
and get_temperature for the ambient thermal sensors around the asic, port, fan, comex and board.
* 1. address review comments
2. improve the handling of PSU inserting/removal
3. tolerance diverse psu thermal sensor file name conventions
* 1. adjust thermal code according to the latest version of hw-management
2. check power_good_status rather than whether file existing ahead of reading voltage, current and power of PSU
2019-07-22 09:59:49 -05:00
|
|
|
else:
|
2020-11-16 20:56:03 -06:00
|
|
|
for index in range(count):
|
|
|
|
thermal = Thermal(category, start + index, True, position)
|
|
|
|
thermal_list.append(thermal)
|
|
|
|
position += 1
|
[Mellanox] support new platform api, thermal and psu part (#3175)
* support new platform api, thermal and psu part
for psu, all APIs are supported.
for thermal, we support
get_temperature,
get_high_threshold
for the thermal sensors of cpu core, cpu pack, psu and sfp module
and get_temperature for the ambient thermal sensors around the asic, port, fan, comex and board.
* 1. address review comments
2. improve the handling of PSU inserting/removal
3. tolerance diverse psu thermal sensor file name conventions
* 1. adjust thermal code according to the latest version of hw-management
2. check power_good_status rather than whether file existing ahead of reading voltage, current and power of PSU
2019-07-22 09:59:49 -05:00
|
|
|
|
2020-03-09 12:41:10 -05:00
|
|
|
|
|
|
|
|
[Mellanox] support new platform api, thermal and psu part (#3175)
* support new platform api, thermal and psu part
for psu, all APIs are supported.
for thermal, we support
get_temperature,
get_high_threshold
for the thermal sensors of cpu core, cpu pack, psu and sfp module
and get_temperature for the ambient thermal sensors around the asic, port, fan, comex and board.
* 1. address review comments
2. improve the handling of PSU inserting/removal
3. tolerance diverse psu thermal sensor file name conventions
* 1. adjust thermal code according to the latest version of hw-management
2. check power_good_status rather than whether file existing ahead of reading voltage, current and power of PSU
2019-07-22 09:59:49 -05:00
|
|
|
class Thermal(ThermalBase):
|
2020-04-21 10:09:53 -05:00
|
|
|
thermal_profile = None
|
|
|
|
thermal_algorithm_status = False
|
|
|
|
|
2020-11-16 20:56:03 -06:00
|
|
|
def __init__(self, category, index, has_index, position, dependency = None):
|
[Mellanox] support new platform api, thermal and psu part (#3175)
* support new platform api, thermal and psu part
for psu, all APIs are supported.
for thermal, we support
get_temperature,
get_high_threshold
for the thermal sensors of cpu core, cpu pack, psu and sfp module
and get_temperature for the ambient thermal sensors around the asic, port, fan, comex and board.
* 1. address review comments
2. improve the handling of PSU inserting/removal
3. tolerance diverse psu thermal sensor file name conventions
* 1. adjust thermal code according to the latest version of hw-management
2. check power_good_status rather than whether file existing ahead of reading voltage, current and power of PSU
2019-07-22 09:59:49 -05:00
|
|
|
"""
|
|
|
|
index should be a string for category ambient and int for other categories
|
|
|
|
"""
|
|
|
|
if category == THERMAL_DEV_CATEGORY_AMBIENT:
|
|
|
|
self.name = thermal_ambient_name[index]
|
|
|
|
self.index = index
|
|
|
|
elif has_index:
|
|
|
|
self.name = thermal_name[category].format(index)
|
|
|
|
self.index = index
|
|
|
|
else:
|
|
|
|
self.name = thermal_name[category]
|
|
|
|
self.index = 0
|
|
|
|
|
|
|
|
self.category = category
|
2020-11-16 20:56:03 -06:00
|
|
|
self.position = position
|
[Mellanox] support new platform api, thermal and psu part (#3175)
* support new platform api, thermal and psu part
for psu, all APIs are supported.
for thermal, we support
get_temperature,
get_high_threshold
for the thermal sensors of cpu core, cpu pack, psu and sfp module
and get_temperature for the ambient thermal sensors around the asic, port, fan, comex and board.
* 1. address review comments
2. improve the handling of PSU inserting/removal
3. tolerance diverse psu thermal sensor file name conventions
* 1. adjust thermal code according to the latest version of hw-management
2. check power_good_status rather than whether file existing ahead of reading voltage, current and power of PSU
2019-07-22 09:59:49 -05:00
|
|
|
self.temperature = self._get_file_from_api(THERMAL_API_GET_TEMPERATURE)
|
|
|
|
self.high_threshold = self._get_file_from_api(THERMAL_API_GET_HIGH_THRESHOLD)
|
2020-03-09 12:41:10 -05:00
|
|
|
self.high_critical_threshold = self._get_file_from_api(THERMAL_API_GET_HIGH_CRITICAL_THRESHOLD)
|
[Mellanox] support new platform api, thermal and psu part (#3175)
* support new platform api, thermal and psu part
for psu, all APIs are supported.
for thermal, we support
get_temperature,
get_high_threshold
for the thermal sensors of cpu core, cpu pack, psu and sfp module
and get_temperature for the ambient thermal sensors around the asic, port, fan, comex and board.
* 1. address review comments
2. improve the handling of PSU inserting/removal
3. tolerance diverse psu thermal sensor file name conventions
* 1. adjust thermal code according to the latest version of hw-management
2. check power_good_status rather than whether file existing ahead of reading voltage, current and power of PSU
2019-07-22 09:59:49 -05:00
|
|
|
self.dependency = dependency
|
|
|
|
|
2020-03-09 12:41:10 -05:00
|
|
|
|
[Mellanox] support new platform api, thermal and psu part (#3175)
* support new platform api, thermal and psu part
for psu, all APIs are supported.
for thermal, we support
get_temperature,
get_high_threshold
for the thermal sensors of cpu core, cpu pack, psu and sfp module
and get_temperature for the ambient thermal sensors around the asic, port, fan, comex and board.
* 1. address review comments
2. improve the handling of PSU inserting/removal
3. tolerance diverse psu thermal sensor file name conventions
* 1. adjust thermal code according to the latest version of hw-management
2. check power_good_status rather than whether file existing ahead of reading voltage, current and power of PSU
2019-07-22 09:59:49 -05:00
|
|
|
def get_name(self):
|
|
|
|
"""
|
|
|
|
Retrieves the name of the device
|
|
|
|
|
|
|
|
Returns:
|
|
|
|
string: The name of the device
|
|
|
|
"""
|
|
|
|
return self.name
|
|
|
|
|
2020-03-09 12:41:10 -05:00
|
|
|
|
2020-04-21 10:09:53 -05:00
|
|
|
@classmethod
|
|
|
|
def _read_generic_file(cls, filename, len):
|
[Mellanox] support new platform api, thermal and psu part (#3175)
* support new platform api, thermal and psu part
for psu, all APIs are supported.
for thermal, we support
get_temperature,
get_high_threshold
for the thermal sensors of cpu core, cpu pack, psu and sfp module
and get_temperature for the ambient thermal sensors around the asic, port, fan, comex and board.
* 1. address review comments
2. improve the handling of PSU inserting/removal
3. tolerance diverse psu thermal sensor file name conventions
* 1. adjust thermal code according to the latest version of hw-management
2. check power_good_status rather than whether file existing ahead of reading voltage, current and power of PSU
2019-07-22 09:59:49 -05:00
|
|
|
"""
|
|
|
|
Read a generic file, returns the contents of the file
|
|
|
|
"""
|
|
|
|
result = None
|
|
|
|
try:
|
|
|
|
with open(filename, 'r') as fileobj:
|
2020-04-21 10:09:53 -05:00
|
|
|
result = fileobj.read().strip()
|
[Mellanox] support new platform api, thermal and psu part (#3175)
* support new platform api, thermal and psu part
for psu, all APIs are supported.
for thermal, we support
get_temperature,
get_high_threshold
for the thermal sensors of cpu core, cpu pack, psu and sfp module
and get_temperature for the ambient thermal sensors around the asic, port, fan, comex and board.
* 1. address review comments
2. improve the handling of PSU inserting/removal
3. tolerance diverse psu thermal sensor file name conventions
* 1. adjust thermal code according to the latest version of hw-management
2. check power_good_status rather than whether file existing ahead of reading voltage, current and power of PSU
2019-07-22 09:59:49 -05:00
|
|
|
except Exception as e:
|
|
|
|
logger.log_info("Fail to read file {} due to {}".format(filename, repr(e)))
|
|
|
|
return result
|
|
|
|
|
2020-03-09 12:41:10 -05:00
|
|
|
|
[Mellanox] support new platform api, thermal and psu part (#3175)
* support new platform api, thermal and psu part
for psu, all APIs are supported.
for thermal, we support
get_temperature,
get_high_threshold
for the thermal sensors of cpu core, cpu pack, psu and sfp module
and get_temperature for the ambient thermal sensors around the asic, port, fan, comex and board.
* 1. address review comments
2. improve the handling of PSU inserting/removal
3. tolerance diverse psu thermal sensor file name conventions
* 1. adjust thermal code according to the latest version of hw-management
2. check power_good_status rather than whether file existing ahead of reading voltage, current and power of PSU
2019-07-22 09:59:49 -05:00
|
|
|
def _get_file_from_api(self, api_name):
|
|
|
|
if self.category == THERMAL_DEV_CATEGORY_AMBIENT:
|
2020-06-28 19:54:28 -05:00
|
|
|
handler = thermal_ambient_apis[self.index]
|
|
|
|
if isinstance(handler, str):
|
|
|
|
if api_name == THERMAL_API_GET_TEMPERATURE:
|
|
|
|
filename = thermal_ambient_apis[self.index]
|
|
|
|
else:
|
|
|
|
return None
|
|
|
|
elif isinstance(handler, dict):
|
|
|
|
filename = handler[api_name]
|
[Mellanox] support new platform api, thermal and psu part (#3175)
* support new platform api, thermal and psu part
for psu, all APIs are supported.
for thermal, we support
get_temperature,
get_high_threshold
for the thermal sensors of cpu core, cpu pack, psu and sfp module
and get_temperature for the ambient thermal sensors around the asic, port, fan, comex and board.
* 1. address review comments
2. improve the handling of PSU inserting/removal
3. tolerance diverse psu thermal sensor file name conventions
* 1. adjust thermal code according to the latest version of hw-management
2. check power_good_status rather than whether file existing ahead of reading voltage, current and power of PSU
2019-07-22 09:59:49 -05:00
|
|
|
else:
|
|
|
|
return None
|
|
|
|
else:
|
|
|
|
handler = thermal_api_handlers[self.category][api_name]
|
|
|
|
if self.category in thermal_device_categories_singleton:
|
|
|
|
filename = handler
|
|
|
|
else:
|
2020-03-09 12:41:10 -05:00
|
|
|
if handler:
|
|
|
|
filename = handler.format(self.index)
|
|
|
|
else:
|
|
|
|
return None
|
[Mellanox] support new platform api, thermal and psu part (#3175)
* support new platform api, thermal and psu part
for psu, all APIs are supported.
for thermal, we support
get_temperature,
get_high_threshold
for the thermal sensors of cpu core, cpu pack, psu and sfp module
and get_temperature for the ambient thermal sensors around the asic, port, fan, comex and board.
* 1. address review comments
2. improve the handling of PSU inserting/removal
3. tolerance diverse psu thermal sensor file name conventions
* 1. adjust thermal code according to the latest version of hw-management
2. check power_good_status rather than whether file existing ahead of reading voltage, current and power of PSU
2019-07-22 09:59:49 -05:00
|
|
|
return join(HW_MGMT_THERMAL_ROOT, filename)
|
|
|
|
|
2020-03-09 12:41:10 -05:00
|
|
|
|
[Mellanox] support new platform api, thermal and psu part (#3175)
* support new platform api, thermal and psu part
for psu, all APIs are supported.
for thermal, we support
get_temperature,
get_high_threshold
for the thermal sensors of cpu core, cpu pack, psu and sfp module
and get_temperature for the ambient thermal sensors around the asic, port, fan, comex and board.
* 1. address review comments
2. improve the handling of PSU inserting/removal
3. tolerance diverse psu thermal sensor file name conventions
* 1. adjust thermal code according to the latest version of hw-management
2. check power_good_status rather than whether file existing ahead of reading voltage, current and power of PSU
2019-07-22 09:59:49 -05:00
|
|
|
def get_temperature(self):
|
|
|
|
"""
|
|
|
|
Retrieves current temperature reading from thermal
|
|
|
|
|
|
|
|
Returns:
|
|
|
|
A float number of current temperature in Celsius up to nearest thousandth
|
|
|
|
of one degree Celsius, e.g. 30.125
|
|
|
|
"""
|
2020-03-25 12:54:07 -05:00
|
|
|
if self.dependency:
|
|
|
|
status, hint = self.dependency()
|
|
|
|
if not status:
|
|
|
|
logger.log_debug("get_temperature for {} failed due to {}".format(self.name, hint))
|
|
|
|
return None
|
[Mellanox] support new platform api, thermal and psu part (#3175)
* support new platform api, thermal and psu part
for psu, all APIs are supported.
for thermal, we support
get_temperature,
get_high_threshold
for the thermal sensors of cpu core, cpu pack, psu and sfp module
and get_temperature for the ambient thermal sensors around the asic, port, fan, comex and board.
* 1. address review comments
2. improve the handling of PSU inserting/removal
3. tolerance diverse psu thermal sensor file name conventions
* 1. adjust thermal code according to the latest version of hw-management
2. check power_good_status rather than whether file existing ahead of reading voltage, current and power of PSU
2019-07-22 09:59:49 -05:00
|
|
|
value_str = self._read_generic_file(self.temperature, 0)
|
|
|
|
if value_str is None:
|
|
|
|
return None
|
|
|
|
value_float = float(value_str)
|
2020-03-09 12:41:10 -05:00
|
|
|
if self.category == THERMAL_DEV_CATEGORY_MODULE and value_float == THERMAL_API_INVALID_HIGH_THRESHOLD:
|
|
|
|
return None
|
[Mellanox] support new platform api, thermal and psu part (#3175)
* support new platform api, thermal and psu part
for psu, all APIs are supported.
for thermal, we support
get_temperature,
get_high_threshold
for the thermal sensors of cpu core, cpu pack, psu and sfp module
and get_temperature for the ambient thermal sensors around the asic, port, fan, comex and board.
* 1. address review comments
2. improve the handling of PSU inserting/removal
3. tolerance diverse psu thermal sensor file name conventions
* 1. adjust thermal code according to the latest version of hw-management
2. check power_good_status rather than whether file existing ahead of reading voltage, current and power of PSU
2019-07-22 09:59:49 -05:00
|
|
|
return value_float / 1000.0
|
|
|
|
|
2020-03-09 12:41:10 -05:00
|
|
|
|
[Mellanox] support new platform api, thermal and psu part (#3175)
* support new platform api, thermal and psu part
for psu, all APIs are supported.
for thermal, we support
get_temperature,
get_high_threshold
for the thermal sensors of cpu core, cpu pack, psu and sfp module
and get_temperature for the ambient thermal sensors around the asic, port, fan, comex and board.
* 1. address review comments
2. improve the handling of PSU inserting/removal
3. tolerance diverse psu thermal sensor file name conventions
* 1. adjust thermal code according to the latest version of hw-management
2. check power_good_status rather than whether file existing ahead of reading voltage, current and power of PSU
2019-07-22 09:59:49 -05:00
|
|
|
def get_high_threshold(self):
|
|
|
|
"""
|
|
|
|
Retrieves the high threshold temperature of thermal
|
|
|
|
|
|
|
|
Returns:
|
|
|
|
A float number, the high threshold temperature of thermal in Celsius
|
|
|
|
up to nearest thousandth of one degree Celsius, e.g. 30.125
|
|
|
|
"""
|
|
|
|
if self.high_threshold is None:
|
|
|
|
return None
|
2020-03-25 12:54:07 -05:00
|
|
|
if self.dependency:
|
|
|
|
status, hint = self.dependency()
|
|
|
|
if not status:
|
|
|
|
logger.log_debug("get_high_threshold for {} failed due to {}".format(self.name, hint))
|
|
|
|
return None
|
[Mellanox] support new platform api, thermal and psu part (#3175)
* support new platform api, thermal and psu part
for psu, all APIs are supported.
for thermal, we support
get_temperature,
get_high_threshold
for the thermal sensors of cpu core, cpu pack, psu and sfp module
and get_temperature for the ambient thermal sensors around the asic, port, fan, comex and board.
* 1. address review comments
2. improve the handling of PSU inserting/removal
3. tolerance diverse psu thermal sensor file name conventions
* 1. adjust thermal code according to the latest version of hw-management
2. check power_good_status rather than whether file existing ahead of reading voltage, current and power of PSU
2019-07-22 09:59:49 -05:00
|
|
|
value_str = self._read_generic_file(self.high_threshold, 0)
|
|
|
|
if value_str is None:
|
|
|
|
return None
|
|
|
|
value_float = float(value_str)
|
2020-03-09 12:41:10 -05:00
|
|
|
if self.category == THERMAL_DEV_CATEGORY_MODULE and value_float == THERMAL_API_INVALID_HIGH_THRESHOLD:
|
|
|
|
return None
|
|
|
|
return value_float / 1000.0
|
|
|
|
|
|
|
|
|
|
|
|
def get_high_critical_threshold(self):
|
|
|
|
"""
|
|
|
|
Retrieves the high critical threshold temperature of thermal
|
|
|
|
|
|
|
|
Returns:
|
|
|
|
A float number, the high critical threshold temperature of thermal in Celsius
|
|
|
|
up to nearest thousandth of one degree Celsius, e.g. 30.125
|
|
|
|
"""
|
|
|
|
if self.high_critical_threshold is None:
|
|
|
|
return None
|
2020-03-25 12:54:07 -05:00
|
|
|
if self.dependency:
|
|
|
|
status, hint = self.dependency()
|
|
|
|
if not status:
|
|
|
|
logger.log_debug("get_high_critical_threshold for {} failed due to {}".format(self.name, hint))
|
|
|
|
return None
|
2020-03-09 12:41:10 -05:00
|
|
|
value_str = self._read_generic_file(self.high_critical_threshold, 0)
|
|
|
|
if value_str is None:
|
|
|
|
return None
|
|
|
|
value_float = float(value_str)
|
|
|
|
if self.category == THERMAL_DEV_CATEGORY_MODULE and value_float == THERMAL_API_INVALID_HIGH_THRESHOLD:
|
|
|
|
return None
|
[Mellanox] support new platform api, thermal and psu part (#3175)
* support new platform api, thermal and psu part
for psu, all APIs are supported.
for thermal, we support
get_temperature,
get_high_threshold
for the thermal sensors of cpu core, cpu pack, psu and sfp module
and get_temperature for the ambient thermal sensors around the asic, port, fan, comex and board.
* 1. address review comments
2. improve the handling of PSU inserting/removal
3. tolerance diverse psu thermal sensor file name conventions
* 1. adjust thermal code according to the latest version of hw-management
2. check power_good_status rather than whether file existing ahead of reading voltage, current and power of PSU
2019-07-22 09:59:49 -05:00
|
|
|
return value_float / 1000.0
|
2020-04-21 10:09:53 -05:00
|
|
|
|
2020-11-16 20:56:03 -06:00
|
|
|
def get_position_in_parent(self):
|
|
|
|
"""
|
|
|
|
Retrieves 1-based relative physical position in parent device
|
|
|
|
Returns:
|
|
|
|
integer: The 1-based relative physical position in parent device
|
|
|
|
"""
|
|
|
|
return self.position
|
|
|
|
|
|
|
|
def is_replaceable(self):
|
|
|
|
"""
|
|
|
|
Indicate whether this device is replaceable.
|
|
|
|
Returns:
|
|
|
|
bool: True if it is replaceable.
|
|
|
|
"""
|
|
|
|
return False
|
2020-04-21 10:09:53 -05:00
|
|
|
|
|
|
|
@classmethod
|
|
|
|
def _write_generic_file(cls, filename, content):
|
|
|
|
"""
|
|
|
|
Generic functions to write content to a specified file path if
|
|
|
|
the content has changed.
|
|
|
|
"""
|
|
|
|
try:
|
|
|
|
with open(filename, 'w+') as file_obj:
|
|
|
|
origin_content = file_obj.read()
|
|
|
|
if origin_content != content:
|
|
|
|
file_obj.write(content)
|
|
|
|
except Exception as e:
|
|
|
|
logger.log_info("Fail to write file {} due to {}".format(filename, repr(e)))
|
|
|
|
|
|
|
|
@classmethod
|
|
|
|
def set_thermal_algorithm_status(cls, status, force=True):
|
|
|
|
"""
|
|
|
|
Enable/disable kernel thermal algorithm.
|
|
|
|
When enable kernel thermal algorithm, kernel will adjust fan speed
|
|
|
|
according to thermal zones temperature. Please note that kernel will
|
|
|
|
only adjust fan speed when temperature across some "edge", e.g temperature
|
|
|
|
changes to exceed high threshold.
|
|
|
|
When disable kernel thermal algorithm, kernel no longer adjust fan speed.
|
|
|
|
We usually disable the algorithm when we want to set a fix speed. E.g, when
|
|
|
|
a fan unit is removed from system, we will set fan speed to 100% and disable
|
|
|
|
the algorithm to avoid it adjust the speed.
|
2020-05-26 12:45:25 -05:00
|
|
|
|
|
|
|
Returns:
|
|
|
|
True if thermal algorithm status changed.
|
2020-04-21 10:09:53 -05:00
|
|
|
"""
|
|
|
|
if not cls.thermal_profile:
|
|
|
|
raise Exception("Fail to get thermal profile for this switch")
|
|
|
|
|
|
|
|
if not force and cls.thermal_algorithm_status == status:
|
2020-05-26 12:45:25 -05:00
|
|
|
return False
|
2020-04-21 10:09:53 -05:00
|
|
|
|
|
|
|
cls.thermal_algorithm_status = status
|
|
|
|
content = "enabled" if status else "disabled"
|
|
|
|
policy = "step_wise" if status else "user_space"
|
|
|
|
cls._write_generic_file(join(THERMAL_ZONE_ASIC_PATH, THERMAL_ZONE_MODE), content)
|
|
|
|
cls._write_generic_file(join(THERMAL_ZONE_ASIC_PATH, THERMAL_ZONE_POLICY), policy)
|
|
|
|
|
|
|
|
if THERMAL_DEV_CATEGORY_MODULE in cls.thermal_profile:
|
|
|
|
start, count = cls.thermal_profile[THERMAL_DEV_CATEGORY_MODULE]
|
|
|
|
if count != 0:
|
|
|
|
for index in range(count):
|
|
|
|
cls._write_generic_file(join(THERMAL_ZONE_MODULE_PATH.format(start + index), THERMAL_ZONE_MODE), content)
|
|
|
|
cls._write_generic_file(join(THERMAL_ZONE_MODULE_PATH.format(start + index), THERMAL_ZONE_POLICY), policy)
|
|
|
|
|
|
|
|
if THERMAL_DEV_CATEGORY_GEARBOX in cls.thermal_profile:
|
|
|
|
start, count = cls.thermal_profile[THERMAL_DEV_CATEGORY_GEARBOX]
|
|
|
|
if count != 0:
|
|
|
|
for index in range(count):
|
|
|
|
cls._write_generic_file(join(THERMAL_ZONE_GEARBOX_PATH.format(start + index), THERMAL_ZONE_MODE), content)
|
|
|
|
cls._write_generic_file(join(THERMAL_ZONE_GEARBOX_PATH.format(start + index), THERMAL_ZONE_POLICY), policy)
|
2020-05-26 12:45:25 -05:00
|
|
|
return True
|
2020-04-21 10:09:53 -05:00
|
|
|
|
|
|
|
@classmethod
|
|
|
|
def check_thermal_zone_temperature(cls):
|
|
|
|
"""
|
|
|
|
Check thermal zone current temperature with normal temperature
|
|
|
|
|
|
|
|
Returns:
|
|
|
|
True if all thermal zones current temperature less or equal than normal temperature
|
|
|
|
"""
|
|
|
|
if not cls.thermal_profile:
|
|
|
|
raise Exception("Fail to get thermal profile for this switch")
|
|
|
|
|
|
|
|
if not cls._check_thermal_zone_temperature(THERMAL_ZONE_ASIC_PATH):
|
|
|
|
return False
|
|
|
|
|
|
|
|
if THERMAL_DEV_CATEGORY_MODULE in cls.thermal_profile:
|
|
|
|
start, count = cls.thermal_profile[THERMAL_DEV_CATEGORY_MODULE]
|
|
|
|
if count != 0:
|
|
|
|
for index in range(count):
|
|
|
|
if not cls._check_thermal_zone_temperature(THERMAL_ZONE_MODULE_PATH.format(start + index)):
|
|
|
|
return False
|
|
|
|
|
|
|
|
if THERMAL_DEV_CATEGORY_GEARBOX in cls.thermal_profile:
|
|
|
|
start, count = cls.thermal_profile[THERMAL_DEV_CATEGORY_GEARBOX]
|
|
|
|
if count != 0:
|
|
|
|
for index in range(count):
|
|
|
|
if not cls._check_thermal_zone_temperature(THERMAL_ZONE_GEARBOX_PATH.format(start + index)):
|
|
|
|
return False
|
|
|
|
|
|
|
|
return True
|
|
|
|
|
|
|
|
@classmethod
|
|
|
|
def _check_thermal_zone_temperature(cls, thermal_zone_path):
|
|
|
|
normal_temp_path = join(thermal_zone_path, THERMAL_ZONE_NORMAL_TEMPERATURE)
|
|
|
|
current_temp_path = join(thermal_zone_path, THERMAL_ZONE_TEMPERATURE)
|
|
|
|
normal = None
|
|
|
|
current = None
|
|
|
|
try:
|
|
|
|
with open(normal_temp_path, 'r') as file_obj:
|
|
|
|
normal = float(file_obj.read())
|
|
|
|
|
|
|
|
with open(current_temp_path, 'r') as file_obj:
|
|
|
|
current = float(file_obj.read())
|
|
|
|
|
|
|
|
return current <= normal
|
|
|
|
except Exception as e:
|
|
|
|
logger.log_info("Fail to check thermal zone temperature for file {} due to {}".format(thermal_zone_path, repr(e)))
|
|
|
|
|
|
|
|
@classmethod
|
|
|
|
def check_module_temperature_trustable(cls):
|
|
|
|
if not cls.thermal_profile:
|
|
|
|
raise Exception("Fail to get thermal profile for this switch")
|
|
|
|
|
|
|
|
start, count = cls.thermal_profile[THERMAL_DEV_CATEGORY_MODULE]
|
|
|
|
for index in range(count):
|
|
|
|
fault_file_path = MODULE_TEMPERATURE_FAULT_PATH.format(index + start)
|
|
|
|
fault = cls._read_generic_file(fault_file_path, 0)
|
|
|
|
if fault.strip() != '0':
|
|
|
|
return 'untrust'
|
|
|
|
return 'trust'
|
|
|
|
|
|
|
|
@classmethod
|
2020-04-27 22:52:57 -05:00
|
|
|
def get_min_amb_temperature(cls):
|
2020-04-21 10:09:53 -05:00
|
|
|
fan_ambient_path = join(HW_MGMT_THERMAL_ROOT, THERMAL_DEV_FAN_AMBIENT)
|
|
|
|
port_ambient_path = join(HW_MGMT_THERMAL_ROOT, THERMAL_DEV_PORT_AMBIENT)
|
|
|
|
|
|
|
|
# if there is any exception, let it raise
|
|
|
|
fan_ambient_temp = int(cls._read_generic_file(fan_ambient_path, 0))
|
|
|
|
port_ambient_temp = int(cls._read_generic_file(port_ambient_path, 0))
|
2020-04-27 22:52:57 -05:00
|
|
|
return fan_ambient_temp if fan_ambient_temp < port_ambient_temp else port_ambient_temp
|