From 9e5becac6874853de6c97446cc120607f993cd85 Mon Sep 17 00:00:00 2001 From: Mykola Kostenok Date: Mon, 17 Dec 2018 16:36:34 +0200 Subject: [PATCH] fix sensors names and path. Signed-off-by: Mykola Kostenok Conflicts: packages/platforms/mellanox/x86-64/x86-64-mlnx-mqm8700/onlp/builds/src/module/src/thermali.c --- .../module/inc/mlnx_common/mlnx_common.h | 9 +- .../mlnx_common/module/src/mlnx_common_fani.c | 21 ++-- .../mlnx_common/module/src/mlnx_common_int.h | 2 +- .../mlnx_common/module/src/mlnx_common_ledi.c | 2 +- .../mlnx_common/module/src/mlnx_common_sfpi.c | 6 +- .../module/src/mlnx_common_thermali.c | 2 +- .../onlp/builds/src/module/src/thermali.c | 109 ++++++++++++++++++ .../onlp/builds/src/module/src/thermali.c | 2 +- .../onlp/builds/src/module/src/thermali.c | 2 +- .../onlp/builds/src/module/src/thermali.c | 2 +- .../onlp/builds/src/module/src/thermali.c | 6 +- .../onlp/builds/src/module/src/thermali.c | 2 +- .../onlp/builds/src/module/src/thermali.c | 2 +- 13 files changed, 138 insertions(+), 29 deletions(-) create mode 100644 packages/platforms/mellanox/x86-64/x86-64-mlnx-mqm8700/onlp/builds/src/module/src/thermali.c diff --git a/packages/platforms/mellanox/any/src/mlnx_common/module/inc/mlnx_common/mlnx_common.h b/packages/platforms/mellanox/any/src/mlnx_common/module/inc/mlnx_common/mlnx_common.h index 11913e85..6b36fd95 100644 --- a/packages/platforms/mellanox/any/src/mlnx_common/module/inc/mlnx_common/mlnx_common.h +++ b/packages/platforms/mellanox/any/src/mlnx_common/module/inc/mlnx_common/mlnx_common.h @@ -138,9 +138,12 @@ typedef struct mlnx_platform_info_s { #define PSU1_ID 1 #define PSU2_ID 2 -#define PSU_MODULE_PREFIX "/bsp/module/psu%d_%s" -#define PSU_POWER_PREFIX "/bsp/power/psu%d_%s" -#define IDPROM_PATH "/bsp/eeprom/%s%d_info" +#define HW_MANAGEMENT_PATH "/var/run/hw-management" +#define QSFP_PATH HW_MANAGEMENT_PATH"/qsfp" +#define THERMAL_PATH "/var/run/hw-management/thermal" +#define PSU_MODULE_PREFIX THERMAL_PATH"/psu%d_%s" +#define PSU_POWER_PREFIX HW_MANAGEMENT_PATH"/power/psu%d_%s" +#define IDPROM_PATH HW_MANAGEMENT_PATH"/eeprom/%s%d_info" typedef enum psu_type { PSU_TYPE_UNKNOWN, diff --git a/packages/platforms/mellanox/any/src/mlnx_common/module/src/mlnx_common_fani.c b/packages/platforms/mellanox/any/src/mlnx_common/module/src/mlnx_common_fani.c index 8eeea7c4..463d1771 100644 --- a/packages/platforms/mellanox/any/src/mlnx_common/module/src/mlnx_common_fani.c +++ b/packages/platforms/mellanox/any/src/mlnx_common/module/src/mlnx_common_fani.c @@ -31,9 +31,6 @@ #include "mlnx_common/mlnx_common.h" #include "mlnx_common_log.h" -#define PREFIX_PATH "/bsp/fan/" -#define PREFIX_MODULE_PATH "/bsp/module/" - #define FAN_STATUS_OK 1 #define VALIDATE(_id) \ @@ -144,7 +141,7 @@ _onlp_fani_info_get_fan(int local_id, onlp_fan_info_t* info) /* get fan status */ fru_index = (local_id + mlnx_platform_info->fan_per_module -1) / mlnx_platform_info->fan_per_module; - ret = onlp_file_read_int(&r_val, "%s%s", PREFIX_MODULE_PATH, mlnx_platform_info->fan_fnames[fru_index].status); + ret = onlp_file_read_int(&r_val, "%s/%s", THERMAL_PATH, mlnx_platform_info->fan_fnames[fru_index].status); if (ret < 0) { return ONLP_STATUS_E_INTERNAL; } @@ -158,7 +155,7 @@ _onlp_fani_info_get_fan(int local_id, onlp_fan_info_t* info) info->status |= ONLP_FAN_STATUS_PRESENT; /* get fan speed */ - ret = onlp_file_read_int(&r_val, "%s%s", PREFIX_PATH, mlnx_platform_info->fan_fnames[local_id].r_speed_get); + ret = onlp_file_read_int(&r_val, "%s/%s", THERMAL_PATH, mlnx_platform_info->fan_fnames[local_id].r_speed_get); if (ret < 0) { return ONLP_STATUS_E_INTERNAL; } @@ -172,14 +169,14 @@ _onlp_fani_info_get_fan(int local_id, onlp_fan_info_t* info) if (ONLP_FAN_CAPS_GET_PERCENTAGE & info->caps) { /* get fan min speed */ - ret = onlp_file_read_int(&r_val, "%s%s", PREFIX_PATH, mlnx_platform_info->fan_fnames[local_id].min); + ret = onlp_file_read_int(&r_val, "%s/%s", THERMAL_PATH, mlnx_platform_info->fan_fnames[local_id].min); if (ret < 0) { return ONLP_STATUS_E_INTERNAL; } mlnx_platform_info->min_fan_speed[local_id] = r_val; /* get fan max speed */ - ret = onlp_file_read_int(&r_val, "%s%s", PREFIX_PATH, mlnx_platform_info->fan_fnames[local_id].max); + ret = onlp_file_read_int(&r_val, "%s/%s", THERMAL_PATH, mlnx_platform_info->fan_fnames[local_id].max); if (ret < 0) { return ONLP_STATUS_E_INTERNAL; } @@ -214,7 +211,7 @@ _onlp_fani_info_get_fan_on_psu(int local_id, int psu_id, onlp_fan_info_t* info) mlnx_platform_info_t* mlnx_platform_info = get_platform_info(); /* get fan status */ - ret = onlp_file_read_int(&r_val, "%s%s", PREFIX_MODULE_PATH, mlnx_platform_info->fan_fnames[local_id].status); + ret = onlp_file_read_int(&r_val, "%s/%s", THERMAL_PATH, mlnx_platform_info->fan_fnames[local_id].status); if (ret < 0) { return ONLP_STATUS_E_INTERNAL; } @@ -228,7 +225,7 @@ _onlp_fani_info_get_fan_on_psu(int local_id, int psu_id, onlp_fan_info_t* info) /* get fan speed */ - ret = onlp_file_read_int(&r_val, "%s%s", PREFIX_PATH, mlnx_platform_info->fan_fnames[local_id].r_speed_get); + ret = onlp_file_read_int(&r_val, "%s/%s", THERMAL_PATH, mlnx_platform_info->fan_fnames[local_id].r_speed_get); if (ret < 0) { return ONLP_STATUS_E_INTERNAL; } @@ -325,7 +322,7 @@ onlp_fani_rpm_set(onlp_oid_t id, int rpm) snprintf(r_data, sizeof(r_data), "%d", (int)temp); nbytes = strnlen(r_data, sizeof(r_data)); - rv = onlp_file_write((uint8_t*)r_data, nbytes, "%s%s", PREFIX_PATH, + rv = onlp_file_write((uint8_t*)r_data, nbytes, "%s/%s", THERMAL_PATH, mlnx_platform_info->fan_fnames[local_id].r_speed_set); if (rv < 0) { return ONLP_STATUS_E_INTERNAL; @@ -378,7 +375,7 @@ onlp_fani_percentage_set(onlp_oid_t id, int p) snprintf(r_data, sizeof(r_data), "%d", (int)temp); nbytes = strnlen(r_data, sizeof(r_data)); - rv = onlp_file_write((uint8_t*)r_data, nbytes, "%s%s", PREFIX_PATH, + rv = onlp_file_write((uint8_t*)r_data, nbytes, "%s/%s", THERMAL_PATH, mlnx_platform_info->fan_fnames[local_id].r_speed_set); if (rv < 0) { return ONLP_STATUS_E_INTERNAL; @@ -394,7 +391,7 @@ onlp_fani_get_min_rpm(int id) mlnx_platform_info_t* mlnx_platform_info = get_platform_info(); - if (onlp_file_read_int(&r_val, "%s%s", PREFIX_PATH, mlnx_platform_info->fan_fnames[id].min) < 0) + if (onlp_file_read_int(&r_val, "%s/%s", THERMAL_PATH, mlnx_platform_info->fan_fnames[id].min) < 0) return ONLP_STATUS_E_INTERNAL; return r_val; diff --git a/packages/platforms/mellanox/any/src/mlnx_common/module/src/mlnx_common_int.h b/packages/platforms/mellanox/any/src/mlnx_common/module/src/mlnx_common_int.h index d75227d9..50ca7729 100644 --- a/packages/platforms/mellanox/any/src/mlnx_common/module/src/mlnx_common_int.h +++ b/packages/platforms/mellanox/any/src/mlnx_common/module/src/mlnx_common_int.h @@ -10,7 +10,7 @@ #include #define MAX_NUM_OF_CPLD 3 -#define PREFIX_PATH_ON_CPLD_DEV "/bsp/cpld" +#define PREFIX_PATH_ON_CPLD_DEV HW_MANAGEMENT_PATH"/system" mlnx_platform_info_t* get_platform_info(void); diff --git a/packages/platforms/mellanox/any/src/mlnx_common/module/src/mlnx_common_ledi.c b/packages/platforms/mellanox/any/src/mlnx_common/module/src/mlnx_common_ledi.c index 23feeff1..c8febd53 100644 --- a/packages/platforms/mellanox/any/src/mlnx_common/module/src/mlnx_common_ledi.c +++ b/packages/platforms/mellanox/any/src/mlnx_common/module/src/mlnx_common_ledi.c @@ -31,7 +31,7 @@ #include #include -#define prefix_path "/bsp/led/led_" +#define prefix_path HW_MANAGEMENT_PATH"/led/led_" #define driver_value_len 50 #define LED_MODE_OFF "none" diff --git a/packages/platforms/mellanox/any/src/mlnx_common/module/src/mlnx_common_sfpi.c b/packages/platforms/mellanox/any/src/mlnx_common/module/src/mlnx_common_sfpi.c index 1a11a2f3..8430cf30 100644 --- a/packages/platforms/mellanox/any/src/mlnx_common/module/src/mlnx_common_sfpi.c +++ b/packages/platforms/mellanox/any/src/mlnx_common/module/src/mlnx_common_sfpi.c @@ -74,16 +74,16 @@ static char* mc_sfp_get_port_path(int port, char *node_name) { if (node_name) - sprintf(sfp_node_path, "/bsp/qsfp/qsfp%d%s", port, node_name); + sprintf(sfp_node_path, "%s/qsfp%d%s", QSFP_PATH, port, node_name); else - sprintf(sfp_node_path, "/bsp/qsfp/qsfp%d", port); + sprintf(sfp_node_path, "%s/qsfp%d", QSFP_PATH, port); return sfp_node_path; } static char* mc_sfp_convert_i2c_path(int port, int devaddr) { - sprintf(sfp_node_path, "/bsp/qsfp/qsfp%d", port); + sprintf(sfp_node_path, "%s/qsfp%d", QSFP_PATH, port); return sfp_node_path; } diff --git a/packages/platforms/mellanox/any/src/mlnx_common/module/src/mlnx_common_thermali.c b/packages/platforms/mellanox/any/src/mlnx_common/module/src/mlnx_common_thermali.c index 4727d3a5..18898340 100644 --- a/packages/platforms/mellanox/any/src/mlnx_common/module/src/mlnx_common_thermali.c +++ b/packages/platforms/mellanox/any/src/mlnx_common/module/src/mlnx_common_thermali.c @@ -30,7 +30,7 @@ #include #include "mlnx_common/mlnx_common.h" -#define prefix_path "/bsp/thermal" +#define prefix_path HW_MANAGEMENT_PATH"/thermal" #define VALIDATE(_id) \ do { \ diff --git a/packages/platforms/mellanox/x86-64/x86-64-mlnx-mqm8700/onlp/builds/src/module/src/thermali.c b/packages/platforms/mellanox/x86-64/x86-64-mlnx-mqm8700/onlp/builds/src/module/src/thermali.c new file mode 100644 index 00000000..d7f442ad --- /dev/null +++ b/packages/platforms/mellanox/x86-64/x86-64-mlnx-mqm8700/onlp/builds/src/module/src/thermali.c @@ -0,0 +1,109 @@ +/************************************************************ + * + * + * Copyright 2014 Big Switch Networks, Inc. + * + * Licensed under the Eclipse Public License, Version 1.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.eclipse.org/legal/epl-v10.html + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the + * License. + * + * + ************************************************************ + * + * Thermal Sensor Platform Implementation. + * + ***********************************************************/ +#include +#include +#include +#include +#include +#include +#include "platform_lib.h" +#include "mlnx_common/mlnx_common.h" + +enum onlp_thermal_id +{ + THERMAL_RESERVED = 0, + THERMAL_CPU_CORE_0, + THERMAL_CPU_CORE_1, + THERMAL_CPU_PACK, + THERMAL_ASIC, + THERMAL_BOARD_AMB, + THERMAL_PORT, + THERMAL_ON_PSU1, + THERMAL_ON_PSU2, +}; + +static char* thermal_fnames[] = /* must map with onlp_thermal_id */ +{ + "reserved", + "cpu_core0", + "cpu_core1", + "cpu_pack", + "asic", + "fan_amb", + "port_amb", + "psu1", + "psu2" +}; + +/* Static values */ +static onlp_thermal_info_t tinfo[] = { + { }, /* Not used */ + { { ONLP_THERMAL_ID_CREATE(THERMAL_CPU_CORE_0), "CPU Core 0", 0}, + ONLP_THERMAL_STATUS_PRESENT, + ONLP_THERMAL_CAPS_ALL, 0, CPU_THERMAL_THRESHOLD_INIT_DEFAULTS + }, + { { ONLP_THERMAL_ID_CREATE(THERMAL_CPU_CORE_1), "CPU Core 1", 0}, + ONLP_THERMAL_STATUS_PRESENT, + ONLP_THERMAL_CAPS_ALL, 0, CPU_THERMAL_THRESHOLD_INIT_DEFAULTS + }, + + { { ONLP_THERMAL_ID_CREATE(THERMAL_CPU_PACK), "CPU pack", 0}, + ONLP_THERMAL_STATUS_PRESENT, + ONLP_THERMAL_CAPS_ALL, 0, CPU_THERMAL_THRESHOLD_INIT_DEFAULTS + }, + + { { ONLP_THERMAL_ID_CREATE(THERMAL_ASIC), "Asic Thermal Sensor", 0}, + ONLP_THERMAL_STATUS_PRESENT, + ONLP_THERMAL_CAPS_ALL, 0, ASIC_THERMAL_THRESHOLD_INIT_DEFAULTS + }, + { { ONLP_THERMAL_ID_CREATE(THERMAL_BOARD_AMB), "Board AMB Thermal Sensor", 0}, + ONLP_THERMAL_STATUS_PRESENT, + ONLP_THERMAL_CAPS_GET_TEMPERATURE, 0, {0,0,0} + }, + { { ONLP_THERMAL_ID_CREATE(THERMAL_PORT), "Port AMB Thermal Sensor", 0}, + ONLP_THERMAL_STATUS_PRESENT, + ONLP_THERMAL_CAPS_GET_TEMPERATURE, 0, {0,0,0} + }, + { { ONLP_THERMAL_ID_CREATE(THERMAL_ON_PSU1), "PSU-1 Thermal Sensor 1", ONLP_PSU_ID_CREATE(PSU1_ID)}, + ONLP_THERMAL_STATUS_PRESENT, + ONLP_THERMAL_CAPS_GET_TEMPERATURE, 0, {0,0,0} + }, + { { ONLP_THERMAL_ID_CREATE(THERMAL_ON_PSU2), "PSU-2 Thermal Sensor 1", ONLP_PSU_ID_CREATE(PSU2_ID)}, + ONLP_THERMAL_STATUS_PRESENT, + ONLP_THERMAL_CAPS_GET_TEMPERATURE, 0, {0,0,0} + } +}; + +/* + * This will be called to intiialize the thermali subsystem. + */ +int +onlp_thermali_init(void) +{ + mlnx_platform_info_t* mlnx_platform_info = get_platform_info(); + mlnx_platform_info->tinfo=tinfo; + mlnx_platform_info->thermal_fnames=thermal_fnames; + return ONLP_STATUS_OK; +} diff --git a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2010/onlp/builds/src/module/src/thermali.c b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2010/onlp/builds/src/module/src/thermali.c index db4d6393..4b44a007 100644 --- a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2010/onlp/builds/src/module/src/thermali.c +++ b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2010/onlp/builds/src/module/src/thermali.c @@ -51,7 +51,7 @@ static char* thermal_fnames[] = /* must map with onlp_thermal_id */ "cpu_core2", "cpu_core3", "asic", - "board_amb", + "fan_amb", "port_amb" }; diff --git a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2100/onlp/builds/src/module/src/thermali.c b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2100/onlp/builds/src/module/src/thermali.c index eb3126dc..ab932546 100644 --- a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2100/onlp/builds/src/module/src/thermali.c +++ b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2100/onlp/builds/src/module/src/thermali.c @@ -52,7 +52,7 @@ static char* thermal_fnames[] = /* must map with onlp_thermal_id */ "cpu_core2", "cpu_core3", "asic", - "board_amb", + "fan_amb", "port_amb" }; diff --git a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2410/onlp/builds/src/module/src/thermali.c b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2410/onlp/builds/src/module/src/thermali.c index 82b44635..4434c022 100644 --- a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2410/onlp/builds/src/module/src/thermali.c +++ b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2410/onlp/builds/src/module/src/thermali.c @@ -51,7 +51,7 @@ static char* thermal_fnames[] = /* must map with onlp_thermal_id */ "cpu_core1", "cpu_pack", "asic", - "board_amb", + "fan_amb", "port_amb", "psu1", "psu2" diff --git a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2700/onlp/builds/src/module/src/thermali.c b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2700/onlp/builds/src/module/src/thermali.c index 82b44635..137bb0bb 100644 --- a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2700/onlp/builds/src/module/src/thermali.c +++ b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2700/onlp/builds/src/module/src/thermali.c @@ -38,7 +38,7 @@ enum onlp_thermal_id THERMAL_CPU_CORE_1, THERMAL_CPU_PACK, THERMAL_ASIC, - THERMAL_BOAR_AMB, + THERMAL_BOARD_AMB, THERMAL_PORT, THERMAL_ON_PSU1, THERMAL_ON_PSU2, @@ -51,7 +51,7 @@ static char* thermal_fnames[] = /* must map with onlp_thermal_id */ "cpu_core1", "cpu_pack", "asic", - "board_amb", + "fan_amb", "port_amb", "psu1", "psu2" @@ -76,7 +76,7 @@ static onlp_thermal_info_t tinfo[] = { ONLP_THERMAL_STATUS_PRESENT, ONLP_THERMAL_CAPS_ALL, 0, ASIC_THERMAL_THRESHOLD_INIT_DEFAULTS }, - { { ONLP_THERMAL_ID_CREATE(THERMAL_BOAR_AMB), "Board AMB Thermal Sensor", 0}, + { { ONLP_THERMAL_ID_CREATE(THERMAL_BOARD_AMB), "Board AMB Thermal Sensor", 0}, ONLP_THERMAL_STATUS_PRESENT, ONLP_THERMAL_CAPS_GET_TEMPERATURE, 0, {0,0,0} }, diff --git a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2740/onlp/builds/src/module/src/thermali.c b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2740/onlp/builds/src/module/src/thermali.c index 7011410d..951707bc 100755 --- a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2740/onlp/builds/src/module/src/thermali.c +++ b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn2740/onlp/builds/src/module/src/thermali.c @@ -53,7 +53,7 @@ static char* thermal_fnames[] = /* must map with onlp_thermal_id */ "cpu_core2", "cpu_core3", "asic", - "board_amb", + "fan_amb", "port_amb", "psu1", "psu2" diff --git a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn3700/onlp/builds/src/module/src/thermali.c b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn3700/onlp/builds/src/module/src/thermali.c index a41b9bd7..40d4c9bd 100644 --- a/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn3700/onlp/builds/src/module/src/thermali.c +++ b/packages/platforms/mellanox/x86-64/x86-64-mlnx-msn3700/onlp/builds/src/module/src/thermali.c @@ -55,7 +55,7 @@ static char* thermal_fnames[] = /* must map with onlp_thermal_id */ "cpu_core3", "cpu_pack", "asic", - "board_amb", + "fan_amb", "port_amb", "psu1", "psu2"