From be03bbe5908fe700a207819863d7e4caaa259682 Mon Sep 17 00:00:00 2001 From: Arun Saravanan Balachandran Date: Tue, 20 Oct 2020 14:29:01 +0530 Subject: [PATCH] [DellEMC]: FanDrawer and get_high_critical_threshold Platform API implementation for S6000, S6100, Z9100 and Z9264F --- .../common/dell_pmc.c | 9 +---- .../s6000/sonic_platform/__init__.py | 2 +- .../s6000/sonic_platform/chassis.py | 11 +++--- .../s6000/sonic_platform/fan_drawer.py | 34 +++++++++++++++++ .../s6100/sonic_platform/__init__.py | 2 +- .../s6100/sonic_platform/chassis.py | 11 +++--- .../s6100/sonic_platform/fan_drawer.py | 34 +++++++++++++++++ .../s6100/sonic_platform/thermal.py | 27 +++++++++++++- .../z9100/sonic_platform/__init__.py | 2 +- .../z9100/sonic_platform/chassis.py | 9 ++--- .../z9100/sonic_platform/fan_drawer.py | 37 +++++++++++++++++++ .../z9100/sonic_platform/thermal.py | 27 +++++++++++++- .../z9264f/sonic_platform/__init__.py | 4 +- .../z9264f/sonic_platform/chassis.py | 15 ++++---- .../z9264f/sonic_platform/fan_drawer.py | 37 +++++++++++++++++++ .../z9264f/sonic_platform/thermal.py | 17 ++++++++- 16 files changed, 240 insertions(+), 38 deletions(-) create mode 100644 platform/broadcom/sonic-platform-modules-dell/s6000/sonic_platform/fan_drawer.py create mode 100644 platform/broadcom/sonic-platform-modules-dell/s6100/sonic_platform/fan_drawer.py create mode 100644 platform/broadcom/sonic-platform-modules-dell/z9100/sonic_platform/fan_drawer.py create mode 100644 platform/broadcom/sonic-platform-modules-dell/z9264f/sonic_platform/fan_drawer.py diff --git a/platform/broadcom/sonic-platform-modules-dell/common/dell_pmc.c b/platform/broadcom/sonic-platform-modules-dell/common/dell_pmc.c index 8206f20a1867..3193e8b4642f 100644 --- a/platform/broadcom/sonic-platform-modules-dell/common/dell_pmc.c +++ b/platform/broadcom/sonic-platform-modules-dell/common/dell_pmc.c @@ -718,18 +718,13 @@ static ssize_t show_fan_airflow(struct device *dev, { int index = to_sensor_dev_attr(devattr)->index; 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) return 0; fan_airflow = smf_read_reg(data, FAN_TRAY_AIRFLOW); - - if (fan_airflow & (1 << (index))) - ret=1; - - if (ret < 0) - return ret; + ret = (fan_airflow >> index) & 1; return sprintf(buf, "%d\n", ret); } diff --git a/platform/broadcom/sonic-platform-modules-dell/s6000/sonic_platform/__init__.py b/platform/broadcom/sonic-platform-modules-dell/s6000/sonic_platform/__init__.py index 48057d290357..db8b45acb1b5 100755 --- a/platform/broadcom/sonic-platform-modules-dell/s6000/sonic_platform/__init__.py +++ b/platform/broadcom/sonic-platform-modules-dell/s6000/sonic_platform/__init__.py @@ -1,2 +1,2 @@ -__all__ = ["platform", "chassis", "sfp", "psu", "thermal"] +__all__ = ["platform", "chassis", "fan", "fan_drawer", "sfp", "psu", "thermal"] from sonic_platform import * diff --git a/platform/broadcom/sonic-platform-modules-dell/s6000/sonic_platform/chassis.py b/platform/broadcom/sonic-platform-modules-dell/s6000/sonic_platform/chassis.py index 06fb6c2ff0e9..60b75ab80963 100755 --- a/platform/broadcom/sonic-platform-modules-dell/s6000/sonic_platform/chassis.py +++ b/platform/broadcom/sonic-platform-modules-dell/s6000/sonic_platform/chassis.py @@ -16,7 +16,7 @@ from sonic_platform_base.chassis_base import ChassisBase from sonic_platform.sfp import Sfp 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.thermal import Thermal from sonic_platform.component import Component @@ -24,7 +24,7 @@ raise ImportError(str(e) + "- required module not found") -MAX_S6000_FAN = 3 +MAX_S6000_FANTRAY = 3 MAX_S6000_PSU = 2 MAX_S6000_THERMAL = 10 MAX_S6000_COMPONENT = 4 @@ -76,9 +76,10 @@ def __init__(self): else: self._eeprom = EepromS6000() - for i in range(MAX_S6000_FAN): - fan = Fan(i) - self._fan_list.append(fan) + for i in range(MAX_S6000_FANTRAY): + fandrawer = FanDrawer(i) + self._fan_drawer_list.append(fandrawer) + self._fan_list.extend(fandrawer._fan_list) for i in range(MAX_S6000_PSU): psu = Psu(i) diff --git a/platform/broadcom/sonic-platform-modules-dell/s6000/sonic_platform/fan_drawer.py b/platform/broadcom/sonic-platform-modules-dell/s6000/sonic_platform/fan_drawer.py new file mode 100644 index 000000000000..c8ea283e5ba4 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-dell/s6000/sonic_platform/fan_drawer.py @@ -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) diff --git a/platform/broadcom/sonic-platform-modules-dell/s6100/sonic_platform/__init__.py b/platform/broadcom/sonic-platform-modules-dell/s6100/sonic_platform/__init__.py index 96de5a93c4c2..2764c0c33007 100755 --- a/platform/broadcom/sonic-platform-modules-dell/s6100/sonic_platform/__init__.py +++ b/platform/broadcom/sonic-platform-modules-dell/s6100/sonic_platform/__init__.py @@ -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 * diff --git a/platform/broadcom/sonic-platform-modules-dell/s6100/sonic_platform/chassis.py b/platform/broadcom/sonic-platform-modules-dell/s6100/sonic_platform/chassis.py index 3284e671bfe0..275b69e72b1d 100755 --- a/platform/broadcom/sonic-platform-modules-dell/s6100/sonic_platform/chassis.py +++ b/platform/broadcom/sonic-platform-modules-dell/s6100/sonic_platform/chassis.py @@ -14,7 +14,7 @@ from sonic_platform_base.chassis_base import ChassisBase from sonic_platform.sfp import Sfp 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.thermal import Thermal from sonic_platform.component import Component @@ -25,7 +25,7 @@ raise ImportError(str(e) + "- required module not found") MAX_S6100_MODULE = 4 -MAX_S6100_FAN = 4 +MAX_S6100_FANTRAY = 4 MAX_S6100_PSU = 2 MAX_S6100_THERMAL = 10 MAX_S6100_COMPONENT = 3 @@ -65,9 +65,10 @@ def __init__(self): self._module_list.append(module) self._sfp_list.extend(module._sfp_list) - for i in range(MAX_S6100_FAN): - fan = Fan(i) - self._fan_list.append(fan) + for i in range(MAX_S6100_FANTRAY): + fandrawer = FanDrawer(i) + self._fan_drawer_list.append(fandrawer) + self._fan_list.extend(fandrawer._fan_list) for i in range(MAX_S6100_PSU): psu = Psu(i) diff --git a/platform/broadcom/sonic-platform-modules-dell/s6100/sonic_platform/fan_drawer.py b/platform/broadcom/sonic-platform-modules-dell/s6100/sonic_platform/fan_drawer.py new file mode 100644 index 000000000000..ada5e93393c9 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-dell/s6100/sonic_platform/fan_drawer.py @@ -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) diff --git a/platform/broadcom/sonic-platform-modules-dell/s6100/sonic_platform/thermal.py b/platform/broadcom/sonic-platform-modules-dell/s6100/sonic_platform/thermal.py index c6f6314dcb6d..f7037b000c5b 100644 --- a/platform/broadcom/sonic-platform-modules-dell/s6100/sonic_platform/thermal.py +++ b/platform/broadcom/sonic-platform-modules-dell/s6100/sonic_platform/thermal.py @@ -49,10 +49,14 @@ def __init__(self, thermal_index): self.thermal_temperature_file = self.HWMON_DIR \ + "temp{}_input".format(hwmon_temp_index) 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 \ + "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): # On successful read, returns the value read from given # sysfs_file and on failure returns 'ERR' @@ -180,6 +184,27 @@ def get_low_threshold(self): 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): """ Sets the high threshold temperature of thermal diff --git a/platform/broadcom/sonic-platform-modules-dell/z9100/sonic_platform/__init__.py b/platform/broadcom/sonic-platform-modules-dell/z9100/sonic_platform/__init__.py index 56f88c6e0fe2..8b4def6e7884 100755 --- a/platform/broadcom/sonic-platform-modules-dell/z9100/sonic_platform/__init__.py +++ b/platform/broadcom/sonic-platform-modules-dell/z9100/sonic_platform/__init__.py @@ -1,3 +1,3 @@ -__all__ = ["platform", "chassis", "fan", "psu", "sfp", "thermal"] +__all__ = ["platform", "chassis", "fan", "fan_drawer", "psu", "sfp", "thermal"] from sonic_platform import * diff --git a/platform/broadcom/sonic-platform-modules-dell/z9100/sonic_platform/chassis.py b/platform/broadcom/sonic-platform-modules-dell/z9100/sonic_platform/chassis.py index 3f03f9671f91..af2881bc392f 100755 --- a/platform/broadcom/sonic-platform-modules-dell/z9100/sonic_platform/chassis.py +++ b/platform/broadcom/sonic-platform-modules-dell/z9100/sonic_platform/chassis.py @@ -14,7 +14,7 @@ import sys from sonic_platform_base.chassis_base import ChassisBase 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.thermal import Thermal from sonic_platform.component import Component @@ -24,7 +24,6 @@ MAX_Z9100_FANTRAY = 5 -MAX_Z9100_FAN = 2 MAX_Z9100_PSU = 2 MAX_Z9100_THERMAL = 8 MAX_Z9100_COMPONENT = 6 @@ -100,9 +99,9 @@ def __init__(self): # Initialize EEPROM self._eeprom = Eeprom() for i in range(MAX_Z9100_FANTRAY): - for j in range(MAX_Z9100_FAN): - fan = Fan(i, j) - self._fan_list.append(fan) + fandrawer = FanDrawer(i) + self._fan_drawer_list.append(fandrawer) + self._fan_list.extend(fandrawer._fan_list) for i in range(MAX_Z9100_PSU): psu = Psu(i) diff --git a/platform/broadcom/sonic-platform-modules-dell/z9100/sonic_platform/fan_drawer.py b/platform/broadcom/sonic-platform-modules-dell/z9100/sonic_platform/fan_drawer.py new file mode 100644 index 000000000000..b74931dd92d3 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-dell/z9100/sonic_platform/fan_drawer.py @@ -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) diff --git a/platform/broadcom/sonic-platform-modules-dell/z9100/sonic_platform/thermal.py b/platform/broadcom/sonic-platform-modules-dell/z9100/sonic_platform/thermal.py index e781a545e8ea..942934ed7638 100644 --- a/platform/broadcom/sonic-platform-modules-dell/z9100/sonic_platform/thermal.py +++ b/platform/broadcom/sonic-platform-modules-dell/z9100/sonic_platform/thermal.py @@ -45,10 +45,14 @@ def __init__(self, thermal_index): self.thermal_temperature_file = self.HWMON_DIR \ + "temp{}_input".format(hwmon_temp_index) 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 \ + "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): # On successful read, returns the value read from given # sysfs_file and on failure returns 'ERR' @@ -176,6 +180,27 @@ def get_low_threshold(self): 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): """ Sets the high threshold temperature of thermal diff --git a/platform/broadcom/sonic-platform-modules-dell/z9264f/sonic_platform/__init__.py b/platform/broadcom/sonic-platform-modules-dell/z9264f/sonic_platform/__init__.py index 656052a68223..4f5d4f6e473d 100644 --- a/platform/broadcom/sonic-platform-modules-dell/z9264f/sonic_platform/__init__.py +++ b/platform/broadcom/sonic-platform-modules-dell/z9264f/sonic_platform/__init__.py @@ -1,2 +1,2 @@ -__all__ = ["platform", "chassis", "sfp", "eeprom", "component", "psu", "thermal", "fan"] -from sonic_platform import * \ No newline at end of file +__all__ = ["platform", "chassis", "sfp", "eeprom", "component", "psu", "thermal", "fan", "fan_drawer"] +from sonic_platform import * diff --git a/platform/broadcom/sonic-platform-modules-dell/z9264f/sonic_platform/chassis.py b/platform/broadcom/sonic-platform-modules-dell/z9264f/sonic_platform/chassis.py index 0eec21c09c28..0bd52ed4b95f 100644 --- a/platform/broadcom/sonic-platform-modules-dell/z9264f/sonic_platform/chassis.py +++ b/platform/broadcom/sonic-platform-modules-dell/z9264f/sonic_platform/chassis.py @@ -17,13 +17,12 @@ from sonic_platform.component import Component from sonic_platform.psu import Psu 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 except ImportError as e: raise ImportError(str(e) + "- required module not found") MAX_Z9264F_FANTRAY =4 -MAX_Z9264F_FAN = 2 MAX_Z9264F_COMPONENT = 8 # BIOS,BMC,FPGA,SYSTEM CPLD,4 SLAVE CPLDs MAX_Z9264F_PSU = 2 MAX_Z9264F_THERMAL = 8 @@ -64,24 +63,24 @@ def __init__(self): self._eeprom = Eeprom() self._watchdog = Watchdog() - + for i in range(MAX_Z9264F_COMPONENT): component = Component(i) self._component_list.append(component) - + for i in range(MAX_Z9264F_PSU): psu = Psu(i) self._psu_list.append(psu) for i in range(MAX_Z9264F_FANTRAY): - for j in range(MAX_Z9264F_FAN): - fan = Fan(i,j) - self._fan_list.append(fan) + fandrawer = FanDrawer(i) + self._fan_drawer_list.append(fandrawer) + self._fan_list.extend(fandrawer._fan_list) for i in range(MAX_Z9264F_THERMAL): thermal = Thermal(i) self._thermal_list.append(thermal) - + for port_num in range(self.PORT_START, (self.PORT_END + 1)): presence = self.get_sfp(port_num).get_presence() if presence: diff --git a/platform/broadcom/sonic-platform-modules-dell/z9264f/sonic_platform/fan_drawer.py b/platform/broadcom/sonic-platform-modules-dell/z9264f/sonic_platform/fan_drawer.py new file mode 100644 index 000000000000..6e8acfa720a4 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-dell/z9264f/sonic_platform/fan_drawer.py @@ -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) diff --git a/platform/broadcom/sonic-platform-modules-dell/z9264f/sonic_platform/thermal.py b/platform/broadcom/sonic-platform-modules-dell/z9264f/sonic_platform/thermal.py index ab66c59b8600..1f3caaa02dd3 100644 --- a/platform/broadcom/sonic-platform-modules-dell/z9264f/sonic_platform/thermal.py +++ b/platform/broadcom/sonic-platform-modules-dell/z9264f/sonic_platform/thermal.py @@ -105,7 +105,7 @@ def get_high_threshold(self): Celsius up to nearest thousandth of one degree Celsius, 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: high_threshold = 0 @@ -126,6 +126,21 @@ def get_low_threshold(self): 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): """ Sets the high threshold temperature of thermal