Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Thermal without manager #6

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions device/barefoot/x86_64-accton_wedge100bf_32x-r0/platform.json
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,33 @@
},
{
"name": "pch_haswell-virtual-0:temp1"
},
{
"name": "psu_driver-i2c-7-59:psu2-temp2"
},
{
"name": "psu_driver-i2c-7-5a:psu1-temp1"
},
{
"name": "psu_driver-i2c-7-5a:psu1-temp2"
},
{
"name": "tmp75-i2c-3-48:chip-temp"
},
{
"name": "tmp75-i2c-3-49:exhaust2-temp"
},
{
"name": "tmp75-i2c-3-4a:exhaust-temp"
},
{
"name": "tmp75-i2c-3-4b:intake-temp"
},
{
"name": "tmp75-i2c-3-4c:tofino-temp"
},
{
"name": "tmp75-i2c-3-4d:intake2-temp"
}
],
"sfps": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
from sonic_platform.fan_drawer import fan_drawer_list_get
from sonic_platform.thermal import thermal_list_get
from eeprom import Eeprom
from sonic_platform.thermal_manager import ThermalManager

from sonic_platform.platform_thrift_client import pltfm_mgr_ready
from sonic_platform.platform_thrift_client import thrift_try
Expand Down Expand Up @@ -41,8 +40,6 @@ def __init__(self):
self.__thermals = None
self.__psu_list = None
self.__sfp_list = None
self.__thermal_mngr = None
self.__polling_thermal_time = 30

self.ready = False
self.phy_port_cur_state = {}
Expand Down Expand Up @@ -114,16 +111,6 @@ def _sfp_list(self):
def _sfp_list(self, value):
pass

@property
def _thermal_mngr(self):
if self.__thermal_mngr is None:
self.__thermal_mngr = ThermalManager(self.__polling_thermal_time)
return self.__thermal_mngr

@_thermal_mngr.setter
def _thermal_mngr(self, value):
self.__thermal_mngr = ThermalManager(value)

def __update_port_info(self):
def qsfp_max_port_get(client):
return client.pltfm_mgr.pltfm_mgr_qsfp_get_max_port()
Expand Down Expand Up @@ -346,10 +333,4 @@ def get_status_led(self):
specified.
"""
return self.system_led

def get_thermal_manager(self):
return self._thermal_mngr

def __del__(self):
if self.__thermal_mngr is not None:
self.__thermal_mngr.stop()

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
try:
import subprocess

from collections import namedtuple
from bfn_extensions.platform_sensors import platform_sensors_get
from sonic_platform_base.thermal_base import ThermalBase
except ImportError as e:
Expand All @@ -18,6 +18,8 @@
temp2_input: 37.000
...
'''
Threshold = namedtuple('Threshold', ['crit', 'max', 'min', 'alarm'], defaults=[0.1]*4)

def _sensors_chip_parsed(data: str):
def kv(line):
k, v, *_ = [t.strip(': ') for t in line.split(':') if t] + ['']
Expand Down Expand Up @@ -68,6 +70,30 @@ def _value_get(d: dict, key_prefix, key_suffix=''):

# Thermal -> ThermalBase -> DeviceBase
class Thermal(ThermalBase):
_thresholds = {
"com_e_driver-i2c-4-33:memory-temp": Threshold(85.0, 80.75, 0.2, 0.1),
"com_e_driver-i2c-4-33:cpu-temp": Threshold(99.9, 99.75, 0.2, 0.1),
"psu_driver-i2c-7-5a:psu1-temp1": Threshold(50.0, 47.5, 0.2, 0.1),
"psu_driver-i2c-7-5a:psu1-temp2": Threshold(90.0, 85.5, 0.2, 0.1),
"psu_driver-i2c-7-5a:psu1-temp3": Threshold(50.0, 47.5, 0.2, 0.1),
"tmp75-i2c-3-48:chip-temp": Threshold(90.0, 85.5, 0.2, 0.1),
"tmp75-i2c-3-49:exhaust2-temp": Threshold(80.0, 76.0, 0.2, 0.1),
"tmp75-i2c-3-4a:exhaust-temp": Threshold(60.0, 57.0, 0.2, 0.1),
"tmp75-i2c-3-4b:intake-temp": Threshold(60.0, 57.0, 0.2, 0.1),
"tmp75-i2c-3-4c:tofino-temp": Threshold(99.9, 99.75, 0.2, 0.1),
"tmp75-i2c-3-4d:intake2-temp": Threshold(60.0, 57.0, 0.2, 0.1),
"coretemp-isa-0000:package-id-0": Threshold(80.0, 76.0, 0.2, 0.1),
"coretemp-isa-0000:core-0": Threshold(99.9, 82.0, 0.2, 0.1),
"coretemp-isa-0000:core-1": Threshold(99.9, 82.0, 0.2, 0.1),
"coretemp-isa-0000:core-2": Threshold(99.9, 82.0, 0.2, 0.1),
"coretemp-isa-0000:core-3": Threshold(99.9, 82.0, 0.2, 0.1),
# add from Montara"
"psu_driver-i2c-7-59:psu2-temp1": Threshold(50.0, 47.5, 0.2, 0.1),
"psu_driver-i2c-7-59:psu2-temp2": Threshold(90.0, 85.5, 0.2, 0.1),
"tmp75-i2c-8-48:outlet-right-temp": Threshold(60.0, 57.0, 0.2, 0.1),
"tmp75-i2c-8-49:outlet-left-temp": Threshold(60.0, 57.0, 0.2, 0.1)
}

def __init__(self, chip, label, index = 0):
self.__chip = chip
self.__label = label
Expand All @@ -78,13 +104,29 @@ def __init__(self, chip, label, index = 0):
def __get(self, attr_prefix, attr_suffix):
sensor_data = _sensors_get().get(self.__chip, {}).get(self.__label, {})
value = _value_get(sensor_data, attr_prefix, attr_suffix)
return value if value is not None else -999.9
if value is not None:
return value
elif attr_prefix == 'temp':
if attr_suffix == 'crit':
return self._thresholds[self.__name].crit
elif attr_suffix == 'max':
return self._thresholds[self.__name].max
elif attr_suffix == 'min':
return self._thresholds[self.__name].min
elif attr_suffix == 'alarm':
return self._thresholds[self.__name].alarm
else:
return 1.0
else:
return 0.1

# ThermalBase interface methods:
def get_temperature(self) -> float:
temp = self.__get('temp', 'input')
self.__collect_temp.append(float(temp))
self.__collect_temp.sort()
if len(self.__collect_temp) == 3:
del self.__collect_temp[1]
return float(temp)

def get_high_threshold(self) -> float:
Expand Down Expand Up @@ -119,13 +161,15 @@ def get_serial(self):
return 'N/A'

def get_minimum_recorded(self) -> float:
temp = self.__collect_temp[0] if len(self.__collect_temp) > 0 else 0.1
temp = self.__collect_temp[0] if len(self.__collect_temp) > 0 else 36.6
temp = temp if temp <= 100.0 else 100.0
temp = temp if temp > 0.0 else 0.1
return float(temp)

def get_maximum_recorded(self) -> float:
temp = self.__collect_temp[-1] if len(self.__collect_temp) > 0 else 100.0
temp = self.__collect_temp[-1] if len(self.__collect_temp) > 0 else 36.6
temp = temp if temp <= 100.0 else 100.0
temp = temp if temp > 0.0 else 0.1
return float(temp)

def get_position_in_parent(self):
Expand Down

This file was deleted.