[DellEMC]: FanDrawer and get_high_critical_threshold Platform API implementation for S6000, S6100, Z9100 and Z9264F (#5673)

- Implement FanDrawer and get_high_critical_threshold Platform API for S6000, S6100, Z9100 and Z9264F.
- Fix incorrect fan direction values in S6100, Z9100
This commit is contained in:
Arun Saravanan Balachandran 2020-10-30 01:05:16 +00:00 committed by GitHub
parent e111204206
commit 6145e4f6f1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
16 changed files with 240 additions and 38 deletions

View File

@ -718,18 +718,13 @@ static ssize_t show_fan_airflow(struct device *dev,
{ {
int index = to_sensor_dev_attr(devattr)->index; int index = to_sensor_dev_attr(devattr)->index;
struct smf_data *data = dev_get_drvdata(dev); struct smf_data *data = dev_get_drvdata(dev);
int ret=1, fan_airflow; int ret, fan_airflow;
if (data->kind == s6100smf && index == FAN_TRAY_5) if (data->kind == s6100smf && index == FAN_TRAY_5)
return 0; return 0;
fan_airflow = smf_read_reg(data, FAN_TRAY_AIRFLOW); fan_airflow = smf_read_reg(data, FAN_TRAY_AIRFLOW);
ret = (fan_airflow >> index) & 1;
if (fan_airflow & (1 << (index)))
ret=1;
if (ret < 0)
return ret;
return sprintf(buf, "%d\n", ret); return sprintf(buf, "%d\n", ret);
} }

View File

@ -1,2 +1,2 @@
__all__ = ["platform", "chassis", "sfp", "psu", "thermal"] __all__ = ["platform", "chassis", "fan", "fan_drawer", "sfp", "psu", "thermal"]
from sonic_platform import * from sonic_platform import *

View File

@ -14,7 +14,7 @@ try:
from sonic_platform_base.chassis_base import ChassisBase from sonic_platform_base.chassis_base import ChassisBase
from sonic_platform.sfp import Sfp from sonic_platform.sfp import Sfp
from sonic_platform.eeprom import Eeprom, EepromS6000 from sonic_platform.eeprom import Eeprom, EepromS6000
from sonic_platform.fan import Fan from sonic_platform.fan_drawer import FanDrawer
from sonic_platform.psu import Psu from sonic_platform.psu import Psu
from sonic_platform.thermal import Thermal from sonic_platform.thermal import Thermal
from sonic_platform.component import Component from sonic_platform.component import Component
@ -22,7 +22,7 @@ except ImportError as e:
raise ImportError(str(e) + "- required module not found") raise ImportError(str(e) + "- required module not found")
MAX_S6000_FAN = 3 MAX_S6000_FANTRAY = 3
MAX_S6000_PSU = 2 MAX_S6000_PSU = 2
MAX_S6000_THERMAL = 10 MAX_S6000_THERMAL = 10
MAX_S6000_COMPONENT = 4 MAX_S6000_COMPONENT = 4
@ -74,9 +74,10 @@ class Chassis(ChassisBase):
else: else:
self._eeprom = EepromS6000() self._eeprom = EepromS6000()
for i in range(MAX_S6000_FAN): for i in range(MAX_S6000_FANTRAY):
fan = Fan(i) fandrawer = FanDrawer(i)
self._fan_list.append(fan) self._fan_drawer_list.append(fandrawer)
self._fan_list.extend(fandrawer._fan_list)
for i in range(MAX_S6000_PSU): for i in range(MAX_S6000_PSU):
psu = Psu(i) psu = Psu(i)

View File

@ -0,0 +1,34 @@
#!/usr/bin/env python
########################################################################
# DellEMC S6000
#
# Module contains an implementation of SONiC Platform Base API and
# provides the Fan-Drawers' information available in the platform.
#
########################################################################
try:
from sonic_platform_base.fan_drawer_base import FanDrawerBase
from sonic_platform.fan import Fan
except ImportError as e:
raise ImportError(str(e) + "- required module not found")
class FanDrawer(FanDrawerBase):
"""DellEMC Platform-specific Fan class"""
def __init__(self, fantray_index):
FanDrawerBase.__init__(self)
# FanTray is 1-based in DellEMC platforms
self.fantrayindex = fantray_index + 1
self._fan_list.append(Fan(fantray_index))
def get_name(self):
"""
Retrieves the fan drawer name
Returns:
string: The name of the device
"""
return "FanTray{}".format(self.fantrayindex)

View File

@ -1,3 +1,3 @@
__all__ = ["platform", "chassis", "module", "fan", "psu", "sfp", "thermal"] __all__ = ["platform", "chassis", "module", "fan", "fan_drawer", "psu", "sfp", "thermal"]
from sonic_platform import * from sonic_platform import *

View File

@ -13,7 +13,7 @@ try:
from sonic_platform_base.chassis_base import ChassisBase from sonic_platform_base.chassis_base import ChassisBase
from sonic_platform.sfp import Sfp from sonic_platform.sfp import Sfp
from sonic_platform.psu import Psu from sonic_platform.psu import Psu
from sonic_platform.fan import Fan from sonic_platform.fan_drawer import FanDrawer
from sonic_platform.module import Module from sonic_platform.module import Module
from sonic_platform.thermal import Thermal from sonic_platform.thermal import Thermal
from sonic_platform.component import Component from sonic_platform.component import Component
@ -24,7 +24,7 @@ except ImportError as e:
raise ImportError(str(e) + "- required module not found") raise ImportError(str(e) + "- required module not found")
MAX_S6100_MODULE = 4 MAX_S6100_MODULE = 4
MAX_S6100_FAN = 4 MAX_S6100_FANTRAY = 4
MAX_S6100_PSU = 2 MAX_S6100_PSU = 2
MAX_S6100_THERMAL = 10 MAX_S6100_THERMAL = 10
MAX_S6100_COMPONENT = 3 MAX_S6100_COMPONENT = 3
@ -64,9 +64,10 @@ class Chassis(ChassisBase):
self._module_list.append(module) self._module_list.append(module)
self._sfp_list.extend(module._sfp_list) self._sfp_list.extend(module._sfp_list)
for i in range(MAX_S6100_FAN): for i in range(MAX_S6100_FANTRAY):
fan = Fan(i) fandrawer = FanDrawer(i)
self._fan_list.append(fan) self._fan_drawer_list.append(fandrawer)
self._fan_list.extend(fandrawer._fan_list)
for i in range(MAX_S6100_PSU): for i in range(MAX_S6100_PSU):
psu = Psu(i) psu = Psu(i)

View File

@ -0,0 +1,34 @@
#!/usr/bin/env python
########################################################################
# DellEMC S6100
#
# Module contains an implementation of SONiC Platform Base API and
# provides the Fan-Drawers' information available in the platform.
#
########################################################################
try:
from sonic_platform_base.fan_drawer_base import FanDrawerBase
from sonic_platform.fan import Fan
except ImportError as e:
raise ImportError(str(e) + "- required module not found")
class FanDrawer(FanDrawerBase):
"""DellEMC Platform-specific Fan class"""
def __init__(self, fantray_index):
FanDrawerBase.__init__(self)
# FanTray is 1-based in DellEMC platforms
self.fantrayindex = fantray_index + 1
self._fan_list.append(Fan(fantray_index))
def get_name(self):
"""
Retrieves the fan drawer name
Returns:
string: The name of the device
"""
return "FanTray{}".format(self.fantrayindex)

View File

@ -49,10 +49,14 @@ class Thermal(ThermalBase):
self.thermal_temperature_file = self.HWMON_DIR \ self.thermal_temperature_file = self.HWMON_DIR \
+ "temp{}_input".format(hwmon_temp_index) + "temp{}_input".format(hwmon_temp_index)
self.thermal_high_threshold_file = self.HWMON_DIR \ self.thermal_high_threshold_file = self.HWMON_DIR \
+ "temp{}_crit".format(hwmon_temp_index) + "temp{}_max".format(hwmon_temp_index)
self.thermal_low_threshold_file = self.HWMON_DIR \ self.thermal_low_threshold_file = self.HWMON_DIR \
+ "temp{}_min".format(hwmon_temp_index) + "temp{}_min".format(hwmon_temp_index)
if not self.is_cpu_thermal:
self.thermal_high_crit_threshold_file = self.HWMON_DIR \
+ "temp{}_crit".format(hwmon_temp_index)
def _read_sysfs_file(self, sysfs_file): def _read_sysfs_file(self, sysfs_file):
# On successful read, returns the value read from given # On successful read, returns the value read from given
# sysfs_file and on failure returns 'ERR' # sysfs_file and on failure returns 'ERR'
@ -180,6 +184,27 @@ class Thermal(ThermalBase):
return thermal_low_threshold / 1000.0 return thermal_low_threshold / 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.is_cpu_thermal:
return super(Thermal, self).get_high_critical_threshold()
thermal_high_crit_threshold = self._read_sysfs_file(
self.thermal_high_crit_threshold_file)
if (thermal_high_crit_threshold != 'ERR'):
thermal_high_crit_threshold = float(thermal_high_crit_threshold)
else:
thermal_high_crit_threshold = 0
return thermal_high_crit_threshold / 1000.0
def set_high_threshold(self, temperature): def set_high_threshold(self, temperature):
""" """
Sets the high threshold temperature of thermal Sets the high threshold temperature of thermal

View File

@ -1,3 +1,3 @@
__all__ = ["platform", "chassis", "fan", "psu", "sfp", "thermal"] __all__ = ["platform", "chassis", "fan", "fan_drawer", "psu", "sfp", "thermal"]
from sonic_platform import * from sonic_platform import *

View File

@ -14,7 +14,7 @@ try:
import sys import sys
from sonic_platform_base.chassis_base import ChassisBase from sonic_platform_base.chassis_base import ChassisBase
from sonic_platform.sfp import Sfp from sonic_platform.sfp import Sfp
from sonic_platform.fan import Fan from sonic_platform.fan_drawer import FanDrawer
from sonic_platform.psu import Psu from sonic_platform.psu import Psu
from sonic_platform.thermal import Thermal from sonic_platform.thermal import Thermal
from sonic_platform.component import Component from sonic_platform.component import Component
@ -24,7 +24,6 @@ except ImportError as e:
MAX_Z9100_FANTRAY = 5 MAX_Z9100_FANTRAY = 5
MAX_Z9100_FAN = 2
MAX_Z9100_PSU = 2 MAX_Z9100_PSU = 2
MAX_Z9100_THERMAL = 8 MAX_Z9100_THERMAL = 8
MAX_Z9100_COMPONENT = 6 MAX_Z9100_COMPONENT = 6
@ -100,9 +99,9 @@ class Chassis(ChassisBase):
# Initialize EEPROM # Initialize EEPROM
self._eeprom = Eeprom() self._eeprom = Eeprom()
for i in range(MAX_Z9100_FANTRAY): for i in range(MAX_Z9100_FANTRAY):
for j in range(MAX_Z9100_FAN): fandrawer = FanDrawer(i)
fan = Fan(i, j) self._fan_drawer_list.append(fandrawer)
self._fan_list.append(fan) self._fan_list.extend(fandrawer._fan_list)
for i in range(MAX_Z9100_PSU): for i in range(MAX_Z9100_PSU):
psu = Psu(i) psu = Psu(i)

View File

@ -0,0 +1,37 @@
#!/usr/bin/env python
########################################################################
# DellEMC Z9100
#
# Module contains an implementation of SONiC Platform Base API and
# provides the Fan-Drawers' information available in the platform.
#
########################################################################
try:
from sonic_platform_base.fan_drawer_base import FanDrawerBase
from sonic_platform.fan import Fan
except ImportError as e:
raise ImportError(str(e) + "- required module not found")
Z9100_FANS_PER_FANTRAY = 2
class FanDrawer(FanDrawerBase):
"""DellEMC Platform-specific Fan class"""
def __init__(self, fantray_index):
FanDrawerBase.__init__(self)
# FanTray is 1-based in DellEMC platforms
self.fantrayindex = fantray_index + 1
for i in range(Z9100_FANS_PER_FANTRAY):
self._fan_list.append(Fan(fantray_index, i))
def get_name(self):
"""
Retrieves the fan drawer name
Returns:
string: The name of the device
"""
return "FanTray{}".format(self.fantrayindex)

View File

@ -45,10 +45,14 @@ class Thermal(ThermalBase):
self.thermal_temperature_file = self.HWMON_DIR \ self.thermal_temperature_file = self.HWMON_DIR \
+ "temp{}_input".format(hwmon_temp_index) + "temp{}_input".format(hwmon_temp_index)
self.thermal_high_threshold_file = self.HWMON_DIR \ self.thermal_high_threshold_file = self.HWMON_DIR \
+ "temp{}_crit".format(hwmon_temp_index) + "temp{}_max".format(hwmon_temp_index)
self.thermal_low_threshold_file = self.HWMON_DIR \ self.thermal_low_threshold_file = self.HWMON_DIR \
+ "temp{}_min".format(hwmon_temp_index) + "temp{}_min".format(hwmon_temp_index)
if not self.is_cpu_thermal:
self.thermal_high_crit_threshold_file = self.HWMON_DIR \
+ "temp{}_crit".format(hwmon_temp_index)
def _read_sysfs_file(self, sysfs_file): def _read_sysfs_file(self, sysfs_file):
# On successful read, returns the value read from given # On successful read, returns the value read from given
# sysfs_file and on failure returns 'ERR' # sysfs_file and on failure returns 'ERR'
@ -176,6 +180,27 @@ class Thermal(ThermalBase):
return thermal_low_threshold / 1000.0 return thermal_low_threshold / 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.is_cpu_thermal:
return super(Thermal, self).get_high_critical_threshold()
thermal_high_crit_threshold = self._read_sysfs_file(
self.thermal_high_crit_threshold_file)
if (thermal_high_crit_threshold != 'ERR'):
thermal_high_crit_threshold = float(thermal_high_crit_threshold)
else:
thermal_high_crit_threshold = 0
return thermal_high_crit_threshold / 1000.0
def set_high_threshold(self, temperature): def set_high_threshold(self, temperature):
""" """
Sets the high threshold temperature of thermal Sets the high threshold temperature of thermal

View File

@ -1,2 +1,2 @@
__all__ = ["platform", "chassis", "sfp", "eeprom", "component", "psu", "thermal", "fan"] __all__ = ["platform", "chassis", "sfp", "eeprom", "component", "psu", "thermal", "fan", "fan_drawer"]
from sonic_platform import * from sonic_platform import *

View File

@ -18,13 +18,12 @@ try:
from sonic_platform.component import Component from sonic_platform.component import Component
from sonic_platform.psu import Psu from sonic_platform.psu import Psu
from sonic_platform.watchdog import Watchdog from sonic_platform.watchdog import Watchdog
from sonic_platform.fan import Fan from sonic_platform.fan_drawer import FanDrawer
from sonic_platform.thermal import Thermal from sonic_platform.thermal import Thermal
except ImportError as e: except ImportError as e:
raise ImportError(str(e) + "- required module not found") raise ImportError(str(e) + "- required module not found")
MAX_Z9264F_FANTRAY =4 MAX_Z9264F_FANTRAY =4
MAX_Z9264F_FAN = 2
MAX_Z9264F_COMPONENT = 8 # BIOS,BMC,FPGA,SYSTEM CPLD,4 SLAVE CPLDs MAX_Z9264F_COMPONENT = 8 # BIOS,BMC,FPGA,SYSTEM CPLD,4 SLAVE CPLDs
MAX_Z9264F_PSU = 2 MAX_Z9264F_PSU = 2
MAX_Z9264F_THERMAL = 8 MAX_Z9264F_THERMAL = 8
@ -65,24 +64,24 @@ class Chassis(ChassisBase):
self._eeprom = Eeprom() self._eeprom = Eeprom()
self._watchdog = Watchdog() self._watchdog = Watchdog()
for i in range(MAX_Z9264F_COMPONENT): for i in range(MAX_Z9264F_COMPONENT):
component = Component(i) component = Component(i)
self._component_list.append(component) self._component_list.append(component)
for i in range(MAX_Z9264F_PSU): for i in range(MAX_Z9264F_PSU):
psu = Psu(i) psu = Psu(i)
self._psu_list.append(psu) self._psu_list.append(psu)
for i in range(MAX_Z9264F_FANTRAY): for i in range(MAX_Z9264F_FANTRAY):
for j in range(MAX_Z9264F_FAN): fandrawer = FanDrawer(i)
fan = Fan(i,j) self._fan_drawer_list.append(fandrawer)
self._fan_list.append(fan) self._fan_list.extend(fandrawer._fan_list)
for i in range(MAX_Z9264F_THERMAL): for i in range(MAX_Z9264F_THERMAL):
thermal = Thermal(i) thermal = Thermal(i)
self._thermal_list.append(thermal) self._thermal_list.append(thermal)
for port_num in range(self.PORT_START, (self.PORT_END + 1)): for port_num in range(self.PORT_START, (self.PORT_END + 1)):
presence = self.get_sfp(port_num).get_presence() presence = self.get_sfp(port_num).get_presence()
if presence: if presence:

View File

@ -0,0 +1,37 @@
#!/usr/bin/env python
########################################################################
# DellEMC Z9264F
#
# Module contains an implementation of SONiC Platform Base API and
# provides the Fan-Drawers' information available in the platform.
#
########################################################################
try:
from sonic_platform_base.fan_drawer_base import FanDrawerBase
from sonic_platform.fan import Fan
except ImportError as e:
raise ImportError(str(e) + "- required module not found")
Z9264F_FANS_PER_FANTRAY = 2
class FanDrawer(FanDrawerBase):
"""DellEMC Platform-specific Fan class"""
def __init__(self, fantray_index):
FanDrawerBase.__init__(self)
# FanTray is 1-based in DellEMC platforms
self.fantrayindex = fantray_index + 1
for i in range(Z9264F_FANS_PER_FANTRAY):
self._fan_list.append(Fan(fantray_index, i))
def get_name(self):
"""
Retrieves the fan drawer name
Returns:
string: The name of the device
"""
return "FanTray{}".format(self.fantrayindex)

View File

@ -105,7 +105,7 @@ class Thermal(ThermalBase):
Celsius up to nearest thousandth of one degree Celsius, Celsius up to nearest thousandth of one degree Celsius,
e.g. 30.125 e.g. 30.125
""" """
is_valid, high_threshold = self.sensor.get_threshold("UpperNonRecoverable") is_valid, high_threshold = self.sensor.get_threshold("UpperCritical")
if not is_valid: if not is_valid:
high_threshold = 0 high_threshold = 0
@ -126,6 +126,21 @@ class Thermal(ThermalBase):
return float(low_threshold) return float(low_threshold)
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
"""
is_valid, high_crit_threshold = self.sensor.get_threshold("UpperNonRecoverable")
if not is_valid:
high_crit_threshold = 0
return float(high_crit_threshold)
def set_high_threshold(self, temperature): def set_high_threshold(self, temperature):
""" """
Sets the high threshold temperature of thermal Sets the high threshold temperature of thermal