From ad81a5d8725b195128e3f91fe5e5a11f311d5915 Mon Sep 17 00:00:00 2001 From: roy_lee Date: Tue, 17 Apr 2018 16:46:43 +0800 Subject: [PATCH 1/3] [onlpdump] ledi.c: correct LOC led to be amber colored. support onlp_ledi_mode_set for turning on. Signed-off-by: roy_lee --- .../onlp/builds/src/module/src/ledi.c | 34 +++++++++++++++---- 1 file changed, 28 insertions(+), 6 deletions(-) diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7312-54x/onlp/builds/src/module/src/ledi.c b/packages/platforms/accton/x86-64/x86-64-accton-as7312-54x/onlp/builds/src/module/src/ledi.c index a4d1cbc2..9357e422 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as7312-54x/onlp/builds/src/module/src/ledi.c +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7312-54x/onlp/builds/src/module/src/ledi.c @@ -80,7 +80,7 @@ led_light_mode_map_t led_map[] = { {LED_DIAG, LED_MODE_AMBER, ONLP_LED_MODE_ORANGE}, {LED_DIAG, LED_MODE_RED, ONLP_LED_MODE_RED}, {LED_LOC, LED_MODE_OFF, ONLP_LED_MODE_OFF}, -{LED_LOC, LED_MODE_BLUE, ONLP_LED_MODE_BLUE}, +{LED_LOC, LED_MODE_AMBER, ONLP_LED_MODE_ORANGE}, {LED_FAN, LED_MODE_AUTO, ONLP_LED_MODE_AUTO}, {LED_PSU1, LED_MODE_AUTO, ONLP_LED_MODE_AUTO}, {LED_PSU2, LED_MODE_AUTO, ONLP_LED_MODE_AUTO} @@ -159,15 +159,27 @@ static int onlp_to_driver_led_mode(enum onlp_led_id id, onlp_led_mode_t onlp_led return 0; } +/* Get the highest bit position of input value.*/ +static int _log2(int val) { + int bits = sizeof(val)*8 - 1; + int i, t; + + for (i = bits; i>=0; i--) { + t = (val >> i); + if ( t & 1) + return i; + } + return i; +} + /* * This function will be called prior to any other onlp_ledi_* functions. */ int onlp_ledi_init(void) { - onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_DIAG), ONLP_LED_MODE_OFF); - onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_LOC), ONLP_LED_MODE_OFF); - + onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_DIAG), ONLP_LED_MODE_OFF); + onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_LOC), ONLP_LED_MODE_OFF); return ONLP_STATUS_OK; } @@ -220,9 +232,19 @@ onlp_ledi_set(onlp_oid_t id, int on_or_off) if (!on_or_off) { return onlp_ledi_mode_set(id, ONLP_LED_MODE_OFF); - } + } else { + int rv; - return ONLP_STATUS_E_UNSUPPORTED; + onlp_led_mode_t mode = ONLP_LED_MODE_OFF; + onlp_led_info_t led_info; + rv = onlp_ledi_info_get(id, &led_info); + if (rv < 0) + return rv; + + /*If multiple color is supported, take the mode at highest bit.*/ + mode = _log2(led_info.caps); + return onlp_ledi_mode_set(id, mode); + } } /* From 64d353a1ee1b3642fa9b8e072f567b7ae980ffe5 Mon Sep 17 00:00:00 2001 From: roy_lee Date: Tue, 17 Apr 2018 17:13:00 +0800 Subject: [PATCH 2/3] [platform] correct SYS_OBJECT_ID and replace local file write API to one in onlplib. Signed-off-by: roy_lee --- .../onlp/builds/src/module/src/platform_lib.c | 31 +------------------ .../x86_64_accton_as7326_56x_r0/__init__.py | 2 +- 2 files changed, 2 insertions(+), 31 deletions(-) diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/onlp/builds/src/module/src/platform_lib.c b/packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/onlp/builds/src/module/src/platform_lib.c index 2758d9b3..c3e61500 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/onlp/builds/src/module/src/platform_lib.c +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/onlp/builds/src/module/src/platform_lib.c @@ -5,41 +5,12 @@ #include "x86_64_accton_as7326_56x_log.h" -static int _onlp_file_write(char *filename, char *buffer, int buf_size, int data_len) -{ - int fd; - int len; - - if ((buffer == NULL) || (buf_size < 0)) { - return -1; - } - - if ((fd = open(filename, O_WRONLY, S_IWUSR)) == -1) { - return -1; - } - - if ((len = write(fd, buffer, buf_size)) < 0) { - close(fd); - return -1; - } - - if ((close(fd) == -1)) { - return -1; - } - - if ((len > buf_size) || (data_len != 0 && len != data_len)) { - return -1; - } - - return 0; -} - int onlp_file_write_integer(char *filename, int value) { char buf[8] = {0}; sprintf(buf, "%d", value); - return _onlp_file_write(filename, buf, (int)strlen(buf), 0); + return onlp_file_write((uint8_t*)buf, strlen(buf), filename); } int onlp_file_read_binary(char *filename, char *buffer, int buf_size, int data_len) diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/platform-config/r0/src/python/x86_64_accton_as7326_56x_r0/__init__.py b/packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/platform-config/r0/src/python/x86_64_accton_as7326_56x_r0/__init__.py index 24e9a914..3f34ef71 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/platform-config/r0/src/python/x86_64_accton_as7326_56x_r0/__init__.py +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/platform-config/r0/src/python/x86_64_accton_as7326_56x_r0/__init__.py @@ -6,7 +6,7 @@ class OnlPlatform_x86_64_accton_as7326_56x_r0(OnlPlatformAccton, PLATFORM='x86-64-accton-as7326-56x-r0' MODEL="AS7326-56X" - SYS_OBJECT_ID=".7326.54" + SYS_OBJECT_ID=".7326.56" def baseconfig(self): self.insmod('optoe') From 1d6448567122a53530f8cc588f34787db11c707e Mon Sep 17 00:00:00 2001 From: Zi Zhou Date: Tue, 17 Apr 2018 22:29:59 -0700 Subject: [PATCH 3/3] Retry fan speed read when we see zero RPM, to make sure it's not a glitch --- .../builds/x86-64-accton-as6812-32x-fan.c | 25 +++++++++++++------ 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as6812-32x/modules/builds/x86-64-accton-as6812-32x-fan.c b/packages/platforms/accton/x86-64/x86-64-accton-as6812-32x/modules/builds/x86-64-accton-as6812-32x-fan.c index f0555674..43d3fe32 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as6812-32x/modules/builds/x86-64-accton-as6812-32x-fan.c +++ b/packages/platforms/accton/x86-64/x86-64-accton-as6812-32x/modules/builds/x86-64-accton-as6812-32x-fan.c @@ -32,6 +32,7 @@ #include #include #include +#include #define FAN_MAX_NUMBER 5 #define FAN_SPEED_CPLD_TO_RPM_STEP 150 @@ -268,7 +269,7 @@ static int accton_as6812_32x_fan_write_value(u8 reg, u8 value) static void accton_as6812_32x_fan_update_device(struct device *dev) { int speed, r_speed, fault, r_fault, direction, ctrl_speed; - int i; + int i, retry_count; mutex_lock(&fan_data->update_lock); @@ -298,6 +299,7 @@ static void accton_as6812_32x_fan_update_device(struct device *dev) for (i = 0; i < FAN_MAX_NUMBER; i++) { + retry_count = 5; /* Update fan data */ @@ -314,12 +316,21 @@ static void accton_as6812_32x_fan_update_device(struct device *dev) /* fan speed */ - speed = accton_as6812_32x_fan_read_value(fan_speed_reg[i]); - r_speed = accton_as6812_32x_fan_read_value(fanr_speed_reg[i]); - if ( (speed < 0) || (r_speed < 0) ) - { - DEBUG_PRINT("[Error!!][%s][%d] \n", __FUNCTION__, __LINE__); - goto _exit; /* error */ + while (retry_count) { + retry_count--; + speed = accton_as6812_32x_fan_read_value(fan_speed_reg[i]); + r_speed = accton_as6812_32x_fan_read_value(fanr_speed_reg[i]); + if ( (speed < 0) || (r_speed < 0) ) + { + DEBUG_PRINT("[Error!!][%s][%d] \n", __FUNCTION__, __LINE__); + goto _exit; /* error */ + } + if ( (speed == 0) || (r_speed == 0) ) + { + msleep(200); + continue; + } + break; } DEBUG_PRINT("[fan%d:] speed:%d, r_speed=%d \n", i, speed, r_speed);