From c62a733443be49cbe4ba2d06047aac7516f0495e Mon Sep 17 00:00:00 2001 From: Kostiantyn Yarovyi Date: Fri, 10 Dec 2021 16:08:32 +0200 Subject: [PATCH] [BFN] Fans and Fantray platform APIs update (#7) --- .../x86_64-accton_as9516_32d-r0/platform.json | 269 ++++++++++- .../platform.json | 224 ++++++++- .../platform.json | 448 ++++++++++++++++++ .../sonic_platform/fan.py | 34 +- .../sonic_platform/fan_drawer.py | 36 +- 5 files changed, 949 insertions(+), 62 deletions(-) diff --git a/device/barefoot/x86_64-accton_as9516_32d-r0/platform.json b/device/barefoot/x86_64-accton_as9516_32d-r0/platform.json index 25237ab0522d..1b1430f3733c 100644 --- a/device/barefoot/x86_64-accton_as9516_32d-r0/platform.json +++ b/device/barefoot/x86_64-accton_as9516_32d-r0/platform.json @@ -3,49 +3,272 @@ "name": "Newport", "fans": [ { - "name": "counter-rotating-fan-1" - }, - { - "name": "counter-rotating-fan-2" - }, + "name": "FAN-1F", + "status_led": { + "controllable": false + }, + "speed": { + "controllable": false + } + }, + { + "name": "FAN-1R", + "status_led": { + "controllable": false + }, + "speed": { + "controllable": false + } + }, + { + "name": "FAN-2F", + "status_led": { + "controllable": false + }, + "speed": { + "controllable": false + } + }, + { + "name": "FAN-2R", + "status_led": { + "controllable": false + }, + "speed": { + "controllable": false + } + }, + { + "name": "FAN-3F", + "status_led": { + "controllable": false + }, + "speed": { + "controllable": false + } + }, + { + "name": "FAN-3R", + "status_led": { + "controllable": false + }, + "speed": { + "controllable": false + } + }, + { + "name": "FAN-4F", + "status_led": { + "controllable": false + }, + "speed": { + "controllable": false + } + }, + { + "name": "FAN-4R", + "status_led": { + "controllable": false + }, + "speed": { + "controllable": false + } + }, + { + "name": "FAN-5F", + "status_led": { + "controllable": false + }, + "speed": { + "controllable": false + } + }, + { + "name": "FAN-5R", + "status_led": { + "controllable": false + }, + "speed": { + "controllable": false + } + }, + { + "name": "FAN-6F", + "status_led": { + "controllable": false + }, + "speed": { + "controllable": false + } + }, + { + "name": "FAN-6R", + "status_led": { + "controllable": false + }, + "speed": { + "controllable": false + } + } + ], + "fan_drawers":[ { - "name": "counter-rotating-fan-3" + "name": "fantray-1", + "status_led": { + "controllable": false + }, + "fans": [ + { + "name": "FAN-1F", + "status_led": { + "controllable": false + }, + "speed": { + "controllable": false + } + }, + { + "name": "FAN-1R", + "status_led": { + "controllable": false + }, + "speed": { + "controllable": false + } + } + ] }, { - "name": "counter-rotating-fan-4" + "name": "fantray-2", + "status_led": { + "controllable": false + }, + "fans": [ + { + "name": "FAN-2F", + "status_led": { + "controllable": false + }, + "speed": { + "controllable": false + } + }, + { + "name": "FAN-2R", + "status_led": { + "controllable": false + }, + "speed": { + "controllable": false + } + } + ] }, { - "name": "counter-rotating-fan-5" + "name": "fantray-3", + "status_led": { + "controllable": false + }, + "fans": [ + { + "name": "FAN-3F", + "status_led": { + "controllable": false + }, + "speed": { + "controllable": false + } + }, + { + "name": "FAN-3R", + "status_led": { + "controllable": false + }, + "speed": { + "controllable": false + } + } + ] }, { - "name": "counter-rotating-fan-6" - } - ], - "fan_drawers":[ - { - "name": "fantray", - "num_fans" : 6, + "name": "fantray-4", + "status_led": { + "controllable": false + }, "fans": [ { - "name": "counter-rotating-fan-1" + "name": "FAN-4F", + "status_led": { + "controllable": false + }, + "speed": { + "controllable": false + } }, { - "name": "counter-rotating-fan-2" - }, + "name": "FAN-4R", + "status_led": { + "controllable": false + }, + "speed": { + "controllable": false + } + } + ] + }, + { + "name": "fantray-5", + "status_led": { + "controllable": false + }, + "fans": [ { - "name": "counter-rotating-fan-3" + "name": "FAN-5F", + "status_led": { + "controllable": false + }, + "speed": { + "controllable": false + } }, { - "name": "counter-rotating-fan-4" - }, + "name": "FAN-5R", + "status_led": { + "controllable": false + }, + "speed": { + "controllable": false + } + } + ] + }, + { + "name": "fantray-6", + "status_led": { + "controllable": false + }, + "fans": [ { - "name": "counter-rotating-fan-5" + "name": "FAN-6F", + "status_led": { + "controllable": false + }, + "speed": { + "controllable": false + } }, { - "name": "counter-rotating-fan-6" + "name": "FAN-6R", + "status_led": { + "controllable": false + }, + "speed": { + "controllable": false + } } ] } + ], "psus": [ { diff --git a/device/barefoot/x86_64-accton_wedge100bf_32x-r0/platform.json b/device/barefoot/x86_64-accton_wedge100bf_32x-r0/platform.json index b8bbfd703566..5f8d123dcf94 100644 --- a/device/barefoot/x86_64-accton_wedge100bf_32x-r0/platform.json +++ b/device/barefoot/x86_64-accton_wedge100bf_32x-r0/platform.json @@ -3,40 +3,224 @@ "name": "Wedge100BF-32X-O-AC-F-BF", "fans": [ { - "name": "counter-rotating-fan-1" - }, - { - "name": "counter-rotating-fan-2" - }, - { - "name": "counter-rotating-fan-3" - }, - { - "name": "counter-rotating-fan-4" - }, - { - "name": "counter-rotating-fan-5" + "name": "FAN-1F", + "status_led": { + "controllable": false + }, + "speed": { + "controllable": false + } + }, + { + "name": "FAN-1R", + "status_led": { + "controllable": false + }, + "speed": { + "controllable": false + } + }, + { + "name": "FAN-2F", + "status_led": { + "controllable": false + }, + "speed": { + "controllable": false + } + }, + { + "name": "FAN-2R", + "status_led": { + "controllable": false + }, + "speed": { + "controllable": false + } + }, + { + "name": "FAN-3F", + "status_led": { + "controllable": false + }, + "speed": { + "controllable": false + } + }, + { + "name": "FAN-3R", + "status_led": { + "controllable": false + }, + "speed": { + "controllable": false + } + }, + { + "name": "FAN-4F", + "status_led": { + "controllable": false + }, + "speed": { + "controllable": false + } + }, + { + "name": "FAN-4R", + "status_led": { + "controllable": false + }, + "speed": { + "controllable": false + } + }, + { + "name": "FAN-5F", + "status_led": { + "controllable": false + }, + "speed": { + "controllable": false + } + }, + { + "name": "FAN-5R", + "status_led": { + "controllable": false + }, + "speed": { + "controllable": false + } } ], "fan_drawers":[ { - "name": "fantray", - "num_fans" : 5, + "name": "fantray-1", + "status_led": { + "controllable": false + }, "fans": [ { - "name": "counter-rotating-fan-1" + "name": "FAN-1F", + "status_led": { + "controllable": false + }, + "speed": { + "controllable": false + } }, { - "name": "counter-rotating-fan-2" + "name": "FAN-1R", + "status_led": { + "controllable": false + }, + "speed": { + "controllable": false + } + } + ] + }, + { + "name": "fantray-2", + "status_led": { + "controllable": false + }, + "fans": [ + { + "name": "FAN-2F", + "status_led": { + "controllable": false + }, + "speed": { + "controllable": false + } + }, + { + "name": "FAN-2R", + "status_led": { + "controllable": false + }, + "speed": { + "controllable": false + } + } + ] + }, + { + "name": "fantray-3", + "status_led": { + "controllable": false + }, + "fans": [ + { + "name": "FAN-3F", + "status_led": { + "controllable": false + }, + "speed": { + "controllable": false + } }, { - "name": "counter-rotating-fan-3" + "name": "FAN-3R", + "status_led": { + "controllable": false + }, + "speed": { + "controllable": false + } + } + ] + }, + { + "name": "fantray-4", + "status_led": { + "controllable": false + }, + "fans": [ + { + "name": "FAN-4F", + "status_led": { + "controllable": false + }, + "speed": { + "controllable": false + } }, { - "name": "counter-rotating-fan-4" + "name": "FAN-4R", + "status_led": { + "controllable": false + }, + "speed": { + "controllable": false + } + } + ] + }, + { + "name": "fantray-5", + "status_led": { + "controllable": false + }, + "fans": [ + { + "name": "FAN-5F", + "status_led": { + "controllable": false + }, + "speed": { + "controllable": false + } }, { - "name": "counter-rotating-fan-5" + "name": "FAN-5R", + "status_led": { + "controllable": false + }, + "speed": { + "controllable": false + } } ] } diff --git a/device/barefoot/x86_64-accton_wedge100bf_65x-r0/platform.json b/device/barefoot/x86_64-accton_wedge100bf_65x-r0/platform.json index a2394135c0fc..58d22b36eca9 100644 --- a/device/barefoot/x86_64-accton_wedge100bf_65x-r0/platform.json +++ b/device/barefoot/x86_64-accton_wedge100bf_65x-r0/platform.json @@ -1,4 +1,452 @@ { + "chassis": { + "name": "Mavericks", + "fans": [ + { + "name": "FAN-1F", + "status_led": { + "controllable": false + }, + "speed": { + "controllable": false + } + }, + { + "name": "FAN-1R", + "status_led": { + "controllable": false + }, + "speed": { + "controllable": false + } + }, + { + "name": "FAN-2F", + "status_led": { + "controllable": false + }, + "speed": { + "controllable": false + } + }, + { + "name": "FAN-2R", + "status_led": { + "controllable": false + }, + "speed": { + "controllable": false + } + }, + { + "name": "FAN-3F", + "status_led": { + "controllable": false + }, + "speed": { + "controllable": false + } + }, + { + "name": "FAN-3R", + "status_led": { + "controllable": false + }, + "speed": { + "controllable": false + } + }, + { + "name": "FAN-4F", + "status_led": { + "controllable": false + }, + "speed": { + "controllable": false + } + }, + { + "name": "FAN-4R", + "status_led": { + "controllable": false + }, + "speed": { + "controllable": false + } + }, + { + "name": "FAN-5F", + "status_led": { + "controllable": false + }, + "speed": { + "controllable": false + } + }, + { + "name": "FAN-5R", + "status_led": { + "controllable": false + }, + "speed": { + "controllable": false + } + }, + { + "name": "FAN-6F", + "status_led": { + "controllable": false + }, + "speed": { + "controllable": false + } + }, + { + "name": "FAN-6R", + "status_led": { + "controllable": false + }, + "speed": { + "controllable": false + } + }, + { + "name": "FAN-7F", + "status_led": { + "controllable": false + }, + "speed": { + "controllable": false + } + }, + { + "name": "FAN-7R", + "status_led": { + "controllable": false + }, + "speed": { + "controllable": false + } + }, + { + "name": "FAN-8F", + "status_led": { + "controllable": false + }, + "speed": { + "controllable": false + } + }, + { + "name": "FAN-8R", + "status_led": { + "controllable": false + }, + "speed": { + "controllable": false + } + }, + { + "name": "FAN-9F", + "status_led": { + "controllable": false + }, + "speed": { + "controllable": false + } + }, + { + "name": "FAN-9R", + "status_led": { + "controllable": false + }, + "speed": { + "controllable": false + } + }, + { + "name": "FAN-10F", + "status_led": { + "controllable": false + }, + "speed": { + "controllable": false + } + }, + { + "name": "FAN-10R", + "status_led": { + "controllable": false + }, + "speed": { + "controllable": false + } + } + ], + "fan_drawers":[ + { + "name": "fantray-1", + "status_led": { + "controllable": false + }, + "fans": [ + { + "name": "FAN-1F", + "status_led": { + "controllable": false + }, + "speed": { + "controllable": false + } + }, + { + "name": "FAN-1R", + "status_led": { + "controllable": false + }, + "speed": { + "controllable": false + } + } + ] + }, + { + "name": "fantray-2", + "status_led": { + "controllable": false + }, + "fans": [ + { + "name": "FAN-2F", + "status_led": { + "controllable": false + }, + "speed": { + "controllable": false + } + }, + { + "name": "FAN-2R", + "status_led": { + "controllable": false + }, + "speed": { + "controllable": false + } + } + ] + }, + { + "name": "fantray-3", + "status_led": { + "controllable": false + }, + "fans": [ + { + "name": "FAN-3F", + "status_led": { + "controllable": false + }, + "speed": { + "controllable": false + } + }, + { + "name": "FAN-3R", + "status_led": { + "controllable": false + }, + "speed": { + "controllable": false + } + } + ] + }, + { + "name": "fantray-4", + "status_led": { + "controllable": false + }, + "fans": [ + { + "name": "FAN-4F", + "status_led": { + "controllable": false + }, + "speed": { + "controllable": false + } + }, + { + "name": "FAN-4R", + "status_led": { + "controllable": false + }, + "speed": { + "controllable": false + } + } + ] + }, + { + "name": "fantray-5", + "status_led": { + "controllable": false + }, + "fans": [ + { + "name": "FAN-5F", + "status_led": { + "controllable": false + }, + "speed": { + "controllable": false + } + }, + { + "name": "FAN-5R", + "status_led": { + "controllable": false + }, + "speed": { + "controllable": false + } + } + ] + }, + { + "name": "fantray-6", + "status_led": { + "controllable": false + }, + "fans": [ + { + "name": "FAN-6F", + "status_led": { + "controllable": false + }, + "speed": { + "controllable": false + } + }, + { + "name": "FAN-6R", + "status_led": { + "controllable": false + }, + "speed": { + "controllable": false + } + } + ] + }, + { + "name": "fantray-7", + "status_led": { + "controllable": false + }, + "fans": [ + { + "name": "FAN-7F", + "status_led": { + "controllable": false + }, + "speed": { + "controllable": false + } + }, + { + "name": "FAN-7R", + "status_led": { + "controllable": false + }, + "speed": { + "controllable": false + } + } + ] + }, + { + "name": "fantray-8", + "status_led": { + "controllable": false + }, + "fans": [ + { + "name": "FAN-8F", + "status_led": { + "controllable": false + }, + "speed": { + "controllable": false + } + }, + { + "name": "FAN-8R", + "status_led": { + "controllable": false + }, + "speed": { + "controllable": false + } + } + ] + }, + { + "name": "fantray-9", + "status_led": { + "controllable": false + }, + "fans": [ + { + "name": "FAN-9F", + "status_led": { + "controllable": false + }, + "speed": { + "controllable": false + } + }, + { + "name": "FAN-9R", + "status_led": { + "controllable": false + }, + "speed": { + "controllable": false + } + } + ] + }, + { + "name": "fantray-10", + "status_led": { + "controllable": false + }, + "fans": [ + { + "name": "FAN-10F", + "status_led": { + "controllable": false + }, + "speed": { + "controllable": false + } + }, + { + "name": "FAN-10R", + "status_led": { + "controllable": false + }, + "speed": { + "controllable": false + } + } + ] + } + + ] + }, "interfaces": { "Ethernet0": { "index": "1,1,1,1", diff --git a/platform/barefoot/sonic-platform-modules-bfn-montara/sonic_platform/fan.py b/platform/barefoot/sonic-platform-modules-bfn-montara/sonic_platform/fan.py index 2402988f55ad..6156ac819ae3 100644 --- a/platform/barefoot/sonic-platform-modules-bfn-montara/sonic_platform/fan.py +++ b/platform/barefoot/sonic-platform-modules-bfn-montara/sonic_platform/fan.py @@ -16,35 +16,43 @@ def get_data(client): # Fan -> FanBase -> DeviceBase class Fan(FanBase): - def __init__(self, num): - self.__num = num + def __init__(self, fan_index, fantrayindex, platform="Montara"): + self.fan_index = fan_index + self.fantrayindex = fantrayindex + self.platform = platform # FanBase interface methods: # returns speed in percents def get_speed(self): def cb(info): return info.percent - return _fan_info_get(self.__num, cb, 0) + return _fan_info_get(self.fan_index, cb, 0) def set_speed(self, percent): - def set_fan_speed(client): - return client.pltfm_mgr.pltfm_mgr_fan_speed_set(self.__num, percent) - return thrift_try(set_fan_speed) + + # Fan tray speed controlled by BMC + # Should return True to avoid thermalctld alarm + return False # DeviceBase interface methods: def get_name(self): - return f"counter-rotating-fan-{self.__num}" + print("self.fan_index ", self.fan_index) + if self.fan_index%2 == 0: + return "FAN-{}R".format(self.fantrayindex) + return "FAN-{}F".format(self.fantrayindex) def get_presence(self): - return _fan_info_get(self.__num, lambda _: True, False) + return _fan_info_get(self.fan_index, lambda _: True, False) def get_position_in_parent(self): - return self.__num + return self.fan_index def is_replaceable(self): - return True + return False def get_status(self): - return True + if (self.get_presence() and self.get_presence() > 0): + return True + return False def get_model(self): """ @@ -81,7 +89,9 @@ def get_speed_tolerance(self): An integer, the percentage of variance from target speed which is considered tolerable """ - return 0 + if self.platform == "Newport": + return 6 + return 3 def get_serial(self): """ diff --git a/platform/barefoot/sonic-platform-modules-bfn-montara/sonic_platform/fan_drawer.py b/platform/barefoot/sonic-platform-modules-bfn-montara/sonic_platform/fan_drawer.py index fef7bbd11033..2f4d26ebcb78 100644 --- a/platform/barefoot/sonic-platform-modules-bfn-montara/sonic_platform/fan_drawer.py +++ b/platform/barefoot/sonic-platform-modules-bfn-montara/sonic_platform/fan_drawer.py @@ -2,14 +2,23 @@ from sonic_platform.platform_thrift_client import thrift_try from sonic_platform_base.fan_drawer_base import FanDrawerBase from sonic_platform_base.fan_base import FanBase + from sonic_py_common import device_info from fan import Fan except ImportError as e: raise ImportError (str(e) + "- required module not found") -_MAX_FAN = 10 +_CONST_MAX_FAN = 2 +_MAX_FANTRAY = 5 + +_product_dict = { + "x86_64-accton_wedge100bf_32x-r0" : "Montara", + "x86_64-accton_as9516_32d-r0" : "Newport", + "Lx86_64-accton_as9516bf_32d-r0" : "Newport", + "x86_64-accton_wedge100bf_65x-r0" : "Mavericks" +} def _fan_info_get_all(): - for fan_num in range(1, _MAX_FAN + 1): + for fan_num in range(1, _CONST_MAX_FAN + 1): def get_data(client, fan_num=fan_num): return client.pltfm_mgr.pltfm_mgr_fan_info_get(fan_num) fan_info = thrift_try(get_data) @@ -18,14 +27,17 @@ def get_data(client, fan_num=fan_num): # FanDrawer -> FanDrawerBase -> DeviceBase class FanDrawer(FanDrawerBase): - def __init__(self, fantray_index): + def __init__(self, fantray_index, modelstr="Montara"): # For now we return only present fans - self._fan_list = [Fan(i.fan_num) for i in _fan_info_get_all()] + self.modelstr = modelstr self.fantrayindex = fantray_index + 1 + self._fan_list = [Fan(i.fan_num, self.fantrayindex, modelstr) for i in _fan_info_get_all()] + + # DeviceBase interface methods: def get_name(self): - return 'fantray' + return f"fantray-{self.fantrayindex}" def get_presence(self): return True @@ -48,7 +60,7 @@ def is_replaceable(self): Returns: bool: True if it is replaceable, False if not """ - return True + return False def get_model(self): """ @@ -96,5 +108,15 @@ def get_maximum_consumed_power(self): """ return 36.0 +def get_platform_name(): + return _product_dict.get(device_info.get_platform()) + def fan_drawer_list_get(): - return [FanDrawer(0)] + global _MAX_FANTRAY + platform = get_platform_name() + if platform == "Newport": + _MAX_FANTRAY = 6 + if platform == "Mavericks": + _MAX_FANTRAY = 10 + + return [FanDrawer(i, platform) for i in range(0, _MAX_FANTRAY)]