diff --git a/README.md b/README.md index 563db0d8..16555d22 100644 --- a/README.md +++ b/README.md @@ -20,3 +20,5 @@ Documentation Instructions for building ONL from scratch. Please see the docs directory for additional information. + +![alt text] (https://scan.coverity.com/projects/8655/badge.svg "Coverity Scan Build Status") diff --git a/builds/any/installer/legacy/fit/builds/Makefile b/builds/any/installer/legacy/fit/builds/Makefile index a92befbb..38609d49 100644 --- a/builds/any/installer/legacy/fit/builds/Makefile +++ b/builds/any/installer/legacy/fit/builds/Makefile @@ -35,7 +35,7 @@ endif $(ONL_V_at)sed s/@@IARCH@@/$(ARCH)/g $(THISDIR)/fit-installer.sh > fit-installer.sh $(ONL_V_at)sed s/@@IARCH@@/$(ARCH)/g $(THISDIR)/fit-install-lib > fit-install-lib $(ONL_V_at)cp $(THISDIR)/boot-config . - $(MKSHAR) $(MKSHAR_OPTS) "$(INSTALLER_NAME)" $(ONL)/tools/scripts/sfx.sh.in fit-installer.sh fit-install-lib *.itb lib *.swi version-onl.sh boot-config + $(MKSHAR) $(MKSHAR_OPTS) "$(INSTALLER_NAME)" $(ONL)/tools/scripts/sfx.sh.in fit-installer.sh fit-install-lib *.itb lib *.swi version-onl.sh boot-config $(INSTALLER_EXTRA_FILES) $(ONL_V_at)rm -rf ./lib *.swi version-onl.sh autoperms.sh *.itb md5sum "$(INSTALLER_NAME)" | awk '{ print $$1 }' > "$(INSTALLER_NAME).md5sum" diff --git a/builds/any/installer/legacy/fit/builds/fit-install-lib b/builds/any/installer/legacy/fit/builds/fit-install-lib index 11c89540..172d2352 100644 --- a/builds/any/installer/legacy/fit/builds/fit-install-lib +++ b/builds/any/installer/legacy/fit/builds/fit-install-lib @@ -178,6 +178,13 @@ installer_blockdev_format() { local partition3size=$4 local partition4size=$5 + if [ -n "$ONL_BOOT_SIZE" ]; then + echo "Using ONL_BOOT_SIZE override ($ONL_BOOT_SIZE)" + partition1size=$ONL_BOOT_SIZE + fi + + + onl_config_partition=$(blkid | grep ONL-CONFIG | awk '{print $1}' | tr -d ':') # @@ -198,10 +205,21 @@ installer_blockdev_format() { installer_umount_blockdev ${blockdev} installer_say "Formatting ${blockdev} as ${partition1size}:${partition2size}:${partition3size}:${partition4size}." echo -e "o\nn\np\n1\n\n+${partition1size}\nn\np\n2\n\n+${partition2size}\nn\np\n3\n\n+${partition3size}\nn\np\n4\n\n${partition4size}\np\nw\n" | fdisk /dev/${blockdev} - installer_partition_format ${blockdev} 1 mkfs.ext2 "-L ONL-BOOT" - installer_partition_format ${blockdev} 2 mkfs.ext2 "-L ONL-CONFIG" - installer_partition_format ${blockdev} 3 mkfs.ext2 "-L ONL-IMAGES" - installer_partition_format ${blockdev} 4 mkfs.ext2 "-L ONL-DATA" + + + _mkfs="mkfs.ext2" + _archtools="${installer_dir}/`uname -m`" + if [ -f "${_archtools}/mkfs.ext2" ]; then + chmod a+x ${_archtools}/* + echo "Using installer archtools mkfs.ext2..." + _mkfs="${_archtools}/mkfs.ext2" + ls -l "${_archtools}" + fi + + installer_partition_format ${blockdev} 1 $_mkfs "-L ONL-BOOT" + installer_partition_format ${blockdev} 2 $_mkfs "-L ONL-CONFIG" + installer_partition_format ${blockdev} 3 $_mkfs "-L ONL-IMAGES" + installer_partition_format ${blockdev} 4 $_mkfs "-L ONL-DATA" if [ -f $ONL_CONFIG_TARBALL ]; then installer_say "Restoring the contents of the existing ONL-CONFIG partition..." diff --git a/builds/powerpc/installer/legacy/builds/Makefile b/builds/powerpc/installer/legacy/builds/Makefile index 2302ee8a..43f77a9d 100644 --- a/builds/powerpc/installer/legacy/builds/Makefile +++ b/builds/powerpc/installer/legacy/builds/Makefile @@ -1,2 +1,3 @@ +INSTALLER_EXTRA_FILES=ppc include $(ONL)/make/config.powerpc.mk include $(ONL)/builds/any/installer/legacy/fit/builds/Makefile diff --git a/builds/powerpc/installer/legacy/builds/ppc/libblkid.so.1 b/builds/powerpc/installer/legacy/builds/ppc/libblkid.so.1 new file mode 100644 index 00000000..0860ab90 Binary files /dev/null and b/builds/powerpc/installer/legacy/builds/ppc/libblkid.so.1 differ diff --git a/builds/powerpc/installer/legacy/builds/ppc/libcom_err.so.2 b/builds/powerpc/installer/legacy/builds/ppc/libcom_err.so.2 new file mode 100644 index 00000000..00ae647d Binary files /dev/null and b/builds/powerpc/installer/legacy/builds/ppc/libcom_err.so.2 differ diff --git a/builds/powerpc/installer/legacy/builds/ppc/libdl.so.0 b/builds/powerpc/installer/legacy/builds/ppc/libdl.so.0 new file mode 100644 index 00000000..1533f23c Binary files /dev/null and b/builds/powerpc/installer/legacy/builds/ppc/libdl.so.0 differ diff --git a/builds/powerpc/installer/legacy/builds/ppc/libe2p.so.2 b/builds/powerpc/installer/legacy/builds/ppc/libe2p.so.2 new file mode 100644 index 00000000..822c8d7f Binary files /dev/null and b/builds/powerpc/installer/legacy/builds/ppc/libe2p.so.2 differ diff --git a/builds/powerpc/installer/legacy/builds/ppc/libext2fs.so.2 b/builds/powerpc/installer/legacy/builds/ppc/libext2fs.so.2 new file mode 100644 index 00000000..0a5c721e Binary files /dev/null and b/builds/powerpc/installer/legacy/builds/ppc/libext2fs.so.2 differ diff --git a/builds/powerpc/installer/legacy/builds/ppc/libpthread.so.0 b/builds/powerpc/installer/legacy/builds/ppc/libpthread.so.0 new file mode 100644 index 00000000..b320f246 Binary files /dev/null and b/builds/powerpc/installer/legacy/builds/ppc/libpthread.so.0 differ diff --git a/builds/powerpc/installer/legacy/builds/ppc/libuuid.so.1 b/builds/powerpc/installer/legacy/builds/ppc/libuuid.so.1 new file mode 100644 index 00000000..1d4b0362 Binary files /dev/null and b/builds/powerpc/installer/legacy/builds/ppc/libuuid.so.1 differ diff --git a/builds/powerpc/installer/legacy/builds/ppc/mke2fs b/builds/powerpc/installer/legacy/builds/ppc/mke2fs new file mode 100755 index 00000000..b1369451 Binary files /dev/null and b/builds/powerpc/installer/legacy/builds/ppc/mke2fs differ diff --git a/builds/powerpc/installer/legacy/builds/ppc/mkfs.ext2 b/builds/powerpc/installer/legacy/builds/ppc/mkfs.ext2 new file mode 100755 index 00000000..2ac41d2d --- /dev/null +++ b/builds/powerpc/installer/legacy/builds/ppc/mkfs.ext2 @@ -0,0 +1,3 @@ +#!/bin/sh +export LD_LIBRARY_PATH=$( cd $( dirname -- "$0" ) > /dev/null ; pwd ) +$LD_LIBRARY_PATH/mke2fs $@ diff --git a/docs/SupportedHardware.md b/docs/SupportedHardware.md index f61b3ff8..b3b14899 100644 --- a/docs/SupportedHardware.md +++ b/docs/SupportedHardware.md @@ -13,8 +13,8 @@ Quanta QuantaMesh T1048-LB9 48x1G + 4x10G FreeScale P2020 Broadcom BCM56534 (Firebolt3) Yes Yes Yes No No No QuantaMesh T3048-LY2 48x10G + 4x40G FreeScale P2020 Broadcom BCM56846 (Trident+) Yes Yes Yes Yes No No - QuantaMesh T3048-LY8 48x10G + 6x40G Intel Rangely C2758 x86 Broadcom BCM56854 (Trident2) Yes* No No No No No - QuantaMesh T5032-LY6 32x40G Intel Rangely C2758 x86 Broadcom BCM56850 (Trident2) Yes* No No No No No + QuantaMesh T3048-LY8 48x10G + 6x40G Intel Rangeley C2758 x86 Broadcom BCM56854 (Trident2) Yes* No No No No No + QuantaMesh T5032-LY6 32x40G Intel Rangeley C2758 x86 Broadcom BCM56850 (Trident2) Yes* No No No No No @@ -26,17 +26,20 @@ Accton/Edge-Core Device Ports CPU Forwarding ONL Certified In Lab ORC OF-DPA OpenNSL SAI Accton AS4600-54T 48x1G + 4x10G FreeScale P2020 Broadcom BCM56540 (Apollo2) Yes Yes Yes Yes*** Yes*** No + Accton AS4610-54P 48x1G + 4x10G + 2x20G Dual-core ARM Cortex A9 1GHz Broadcom BCM56340 (Helix4) Yes Yes No No No No Accton AS5600-52X 48x10G + 4x40G FreeScale P2020 Broadcom BCM56846 (Trident+) Yes Yes Yes No No No Accton AS5610-52X 48x10G + 4x40G FreeScale P2020 Broadcom BCM56846 (Trident+) Yes Yes Yes No No No Accton AS5710-54X 48x10G + 6x40G FreeScale P2041 Broadcom BCM56854 (Trident2) Yes Yes Yes Yes*** Yes*** No Accton AS6700-32X 32x40G FreeScale P2041 Broadcom BCM56850 (Trident2) Yes Yes Yes No No No - Accton AS5712-54X 48x10G + 6x40G Intel Rangely C2538 x86 Broadcom BCM56854 (Trident2) Yes Yes Yes Yes*** Yes*** No - Accton AS6712-32X 32x40G Intel Rangely C2538 x86 Broadcom BCM56850 (Trident2) Yes Yes Yes Yes*** Yes*** No - Accton AS5812-54T 48x10G + 6x40G Intel Rangely C2538 x86 Broadcom BCM56864 (Trident2+) Yes Yes No No No No - Accton AS5812-54X 48x10G + 6x40G Intel Rangely C2538 x86 Broadcom BCM56864 (Trident2+) Yes Yes No No No No - Accton AS6812-32X 32x40G Intel Rangely C2538 x86 Broadcom BCM56864 (Trident2+) Yes Yes No No No No - Accton AS7712-32X 32x100G Intel Rangely C2538 x86 Broadcom BCM56960 (Tomahawk) Yes Yes Yes Yes*** Yes*** No - Accton Wedge-16X 16x40G Intel Rangely C2550 x86 Broadcom BCM56864 (Trident2+) Work In Progress** Yes No No Yes No + Accton AS5512-54X 48x10G + 6x40G Intel Rangeley C2538 x86 MediaTek MT3257 No No No No No No + Accton AS5712-54X 48x10G + 6x40G Intel Rangeley C2538 x86 Broadcom BCM56854 (Trident2) Yes Yes Yes Yes*** Yes*** No + Accton AS6712-32X 32x40G Intel Rangeley C2538 x86 Broadcom BCM56850 (Trident2) Yes Yes Yes Yes*** Yes*** No + Accton AS5812-54T 48x10G + 6x40G Intel Rangeley C2538 x86 Broadcom BCM56864 (Trident2+) Yes Yes No No No No + Accton AS5812-54X 48x10G + 6x40G Intel Rangeley C2538 x86 Broadcom BCM56864 (Trident2+) Yes Yes No Yes*** Yes*** No + Accton AS6812-32X 32x40G Intel Rangeley C2538 x86 Broadcom BCM56864 (Trident2+) Yes Yes No Yes*** Yes*** No + Accton AS7712-32X 32x100G Intel Rangeley C2538 x86 Broadcom BCM56960 (Tomahawk) Yes Yes Yes Yes*** Yes*** No + Accton AS7716-32X 32x100G Intel Xeon D-1518 x86 Broadcom BCM56960 (Tomahawk) Yes Yes No Yes*** Yes*** No + Accton Wedge-16X 16x40G Intel Rangeley C2550 x86 Broadcom BCM56864 (Trident2+) Work In Progress** Yes No No Yes No DNI/Agema diff --git a/packages/platforms/accton/powerpc/powerpc-accton-as4600-54t/onlp/builds/src/module/src/fani.c b/packages/platforms/accton/powerpc/powerpc-accton-as4600-54t/onlp/builds/src/module/src/fani.c index d7fb9c68..5544c9f8 100644 --- a/packages/platforms/accton/powerpc/powerpc-accton-as4600-54t/onlp/builds/src/module/src/fani.c +++ b/packages/platforms/accton/powerpc/powerpc-accton-as4600-54t/onlp/builds/src/module/src/fani.c @@ -25,6 +25,7 @@ ***********************************************************/ #include #include +#include //#include "onlpie_int.h" #include "platform_lib.h" @@ -64,6 +65,7 @@ #define FAN_DUTY_CYCLE_MAX 0xFF #define PSU_FAN_RPM_MAX 15000 +#define FAN_FAILED_RETRY_COUNT 100 typedef struct onlp_fan_cpld { @@ -145,6 +147,71 @@ onlp_fan_info_t finfo[] = { }, }; +int _onlp_fani_get_operational_status(int fan_id, onlp_fan_info_t* info) +{ + int rc = 0, i; + unsigned char tach_low, tach_high, pwm_offset; + unsigned char data[2] = {0}; + + if (fan_id < 1 || fan_id > 2) { + return ONLP_STATUS_E_PARAM; + } + + if (fan_id == 1) { + tach_low = I2C_FAN_1_STATUS_REG_TACH_1_LOW; + tach_high = I2C_FAN_1_STATUS_REG_TACH_1_HIGH; + } + else { + tach_low = I2C_FAN_2_STATUS_REG_TACH_3_LOW; + tach_high = I2C_FAN_2_STATUS_REG_TACH_3_HIGH; + } + + for (i = 0; i < FAN_FAILED_RETRY_COUNT; i++) { + /* Get the TACH status from ADT7473 + */ + rc = I2C_nRead(1, I2C_SLAVE_ADDR_ADT7473, tach_low, 1, &data[0]); + if (0 != rc) { + return ONLP_STATUS_E_INTERNAL; + } + + rc = I2C_nRead(1, I2C_SLAVE_ADDR_ADT7473, tach_high, 1, &data[1]); + if (0 != rc) { + return ONLP_STATUS_E_INTERNAL; + } + + if (data[0] == 0xFF && data[1] == 0xFF) { + /* Sleep 10 ms then retry if FAN fail + */ + info->status |= ONLP_FAN_STATUS_FAILED; + usleep(10000); + continue; + } + else { + info->status &= ~ONLP_FAN_STATUS_FAILED; + break; + } + } + + /* Set fan percentage and rpm by current PWM value + * Based on the fan module data sheet, the max RPM of fan module is 23540 + * Since the RPM monitored from ADT7473 is not accurate, the RPM would be + * reported in the formula: RPM = (Duty cycle) * 92314 / 1000. + * We assume the RPM would be 23540 when duty cycle is 255. + * So the multiplier is calculated from 23540/255 = 92.314 + */ + pwm_offset = (fan_id == 1) ? I2C_FAN_1_DUTY_CYCLE_REG_PWM_1 : + I2C_FAN_2_DUTY_CYCLE_REG_PWM_3 ; + rc = I2C_nRead(1, I2C_SLAVE_ADDR_ADT7473, pwm_offset, 1, &data[0]); + if (0 != rc) { + return ONLP_STATUS_E_INTERNAL; + } + + info->rpm = data[0] * 92314 / 1000; + info->percentage = (data[0] * 100) / 255; + + return ONLP_STATUS_OK; +} + int onlp_fani_info_get(onlp_oid_t id, onlp_fan_info_t* info) { @@ -160,11 +227,16 @@ onlp_fani_info_get(onlp_oid_t id, onlp_fan_info_t* info) switch (fid) { case 1: /* FAN 1 */ + case 2: /* FAN 2 */ + { + unsigned char dir_mask = (fid == 1) ? CPLD_FAN_1_DIRECTION_BIT_MASK : + CPLD_FAN_2_DIRECTION_BIT_MASK ; /* update the present status */ if ((val & fan_data[fid].cpld_mask) == fan_data[fid].cpld_mask) { info->status &= ~ONLP_FAN_STATUS_PRESENT; + return ONLP_STATUS_OK; } else { @@ -174,7 +246,7 @@ onlp_fani_info_get(onlp_oid_t id, onlp_fan_info_t* info) /* Update the Direction * 0: Back to front. 1: Front to back. */ - if((val & CPLD_FAN_1_DIRECTION_BIT_MASK) == CPLD_FAN_1_DIRECTION_BIT_MASK) + if((val & dir_mask) == dir_mask) { info->status |= ONLP_FAN_STATUS_F2B; info->status &= ~ONLP_FAN_STATUS_B2F; @@ -185,107 +257,8 @@ onlp_fani_info_get(onlp_oid_t id, onlp_fan_info_t* info) info->status &= ~ONLP_FAN_STATUS_F2B; } -#if 0 /* Hardware issue, the rpm value is unstable.*/ - /* Get the information from I2C - */ - i2c_addr = I2C_SLAVE_ADDR_ADT7473; - - /* Get the status - */ - rc = I2C_nRead(bus_id, i2c_addr, I2C_FAN_1_STATUS_REG_TACH_1_LOW, 1, &data[0]); - if(0 != rc) - { - return ONLP_STATUS_E_INTERNAL; - } - rc = I2C_nRead(bus_id, i2c_addr, I2C_FAN_1_STATUS_REG_TACH_1_HIGH, 1, &data[1]); - if(0 != rc) - { - return ONLP_STATUS_E_INTERNAL; - } - - if (data[0] == 0xFF && data[1] == 0xFF) - { - /* FAN fail - */ - info->status |= ONLP_FAN_STATUS_FAILED; - } - else - { - info->status &= ~ONLP_FAN_STATUS_FAILED; - } - - /* Update the rpm, Fan Speed (RPM) = (90,000 * 60)/Fan TACH Reading - */ - fan_tach = data[1]; - fan_tach = (fan_tach << 8) + data[0]; - - if (fan_tach != 0) - { - info->rpm = (90000 * 60) / fan_tach; - } -#endif - break; - - case 2: /* FAN 2 */ - if ((val & fan_data[fid].cpld_mask) == fan_data[fid].cpld_mask) - { - info->status &= ~ONLP_FAN_STATUS_PRESENT; - } - else - { - info->status |= ONLP_FAN_STATUS_PRESENT; - } - - if((val & CPLD_FAN_2_DIRECTION_BIT_MASK) == CPLD_FAN_2_DIRECTION_BIT_MASK) - { - info->status |= ONLP_FAN_STATUS_F2B; - info->status &= ~ONLP_FAN_STATUS_B2F; - } - else - { - info->status |= ONLP_FAN_STATUS_B2F; - info->status &= ~ONLP_FAN_STATUS_F2B; - } - -#if 0 /* Hardware issue, the rpm value is unstable.*/ - /* Get information from I2C - */ - i2c_addr = I2C_SLAVE_ADDR_ADT7473; - - /* Get the status - */ - rc = I2C_nRead(bus_id, i2c_addr, I2C_FAN_2_STATUS_REG_TACH_3_LOW, 1, &data[0]); - if(0 != rc) - { - return ONLP_STATUS_E_INTERNAL; - } - rc = I2C_nRead(bus_id, i2c_addr, I2C_FAN_2_STATUS_REG_TACH_3_HIGH, 1, &data[1]); - if(0 != rc) - { - return ONLP_STATUS_E_INTERNAL; - } - - if (data[0] == 0xFF && data[1] == 0xFF) - { - info->status |= ONLP_FAN_STATUS_FAILED; - } - else - { - info->status &= ~ONLP_FAN_STATUS_FAILED; - } - - /* Get the rpm, Fan Speed (RPM) = (90,000 * 60)/Fan TACH Reading - */ - fan_tach = data[1]; - fan_tach = (fan_tach << 8) + data[0]; - - if (fan_tach != 0) - { - info->rpm = (90000 * 60) / fan_tach; - } -#endif - break; - + return _onlp_fani_get_operational_status(fid, info); + } case 3: /* FAN in the PSU 1*/ case 4: /* FAN in the PSU 2*/ /* Get the PSU FAN status from CPLD @@ -524,5 +497,3 @@ onlp_fani_ioctl(onlp_oid_t id, va_list vargs) { return ONLP_STATUS_E_UNSUPPORTED; } - - diff --git a/packages/platforms/accton/powerpc/powerpc-accton-as5610-52x/onlp/builds/src/module/src/fani.c b/packages/platforms/accton/powerpc/powerpc-accton-as5610-52x/onlp/builds/src/module/src/fani.c index 54677722..ac2a0c2b 100644 --- a/packages/platforms/accton/powerpc/powerpc-accton-as5610-52x/onlp/builds/src/module/src/fani.c +++ b/packages/platforms/accton/powerpc/powerpc-accton-as5610-52x/onlp/builds/src/module/src/fani.c @@ -46,6 +46,9 @@ #define CPLD_FAN_FAILURE_MASK 0x08 #define CPLD_FAN_DIRECTION_MASK 0x10 #define CPLD_FAN_SPEED_CTL_REG 0x0D +#define CPLD_FAN_SPEED_VALUE_MAX 0x1F +#define CPLD_FAN_SPEED_VALUE_MID 0x15 +#define CPLD_FAN_SPEED_VALUE_MIN 0x0C #define I2C_PSU_BUS_ID 0 #define I2C_PSU1_SLAVE_ADDR_CFG 0x3E @@ -76,8 +79,16 @@ typedef enum onlp_fan_id static int chassis_fan_cpld_val_to_duty_cycle(unsigned char reg_val) { - if (reg_val >= 0x1F) { - return 100; + reg_val &= 0x1F; + + if (reg_val == CPLD_FAN_SPEED_VALUE_MAX) { + return FAN_PERCENTAGE_MAX; + } + else if (reg_val == CPLD_FAN_SPEED_VALUE_MID) { + return FAN_PERCENTAGE_MID; + } + else if (reg_val == CPLD_FAN_SPEED_VALUE_MIN) { + return FAN_PERCENTAGE_MIN; } return (reg_val * 3.25); @@ -86,8 +97,14 @@ chassis_fan_cpld_val_to_duty_cycle(unsigned char reg_val) static int chassis_fan_duty_cycle_to_cpld_val(int duty_cycle) { - if (duty_cycle >= 100) { - return 0x1F; + if (duty_cycle == FAN_PERCENTAGE_MAX) { + return CPLD_FAN_SPEED_VALUE_MAX; + } + else if (duty_cycle == FAN_PERCENTAGE_MID) { + return CPLD_FAN_SPEED_VALUE_MID; + } + else if (duty_cycle == FAN_PERCENTAGE_MIN) { + return CPLD_FAN_SPEED_VALUE_MIN; } return (duty_cycle / 3.25); @@ -110,6 +127,12 @@ onlp_fani_init(void) return ONLP_STATUS_E_INTERNAL; } + /* + * Bring both fans to max. + * These will be reduced after the first platform management sequence. + */ + onlp_fani_percentage_set(ONLP_FAN_ID_CREATE(1), FAN_PERCENTAGE_MAX); + return ONLP_STATUS_OK; } diff --git a/packages/platforms/accton/powerpc/powerpc-accton-as5610-52x/onlp/builds/src/module/src/platform_lib.h b/packages/platforms/accton/powerpc/powerpc-accton-as5610-52x/onlp/builds/src/module/src/platform_lib.h index 00222c62..990353cc 100644 --- a/packages/platforms/accton/powerpc/powerpc-accton-as5610-52x/onlp/builds/src/module/src/platform_lib.h +++ b/packages/platforms/accton/powerpc/powerpc-accton-as5610-52x/onlp/builds/src/module/src/platform_lib.h @@ -63,4 +63,32 @@ typedef enum as5610_52x_psu_type { as5610_52x_psu_type_t as5610_52x_get_psu_type(int id, char* modelname, int size); +enum onlp_thermal_id +{ + THERMAL_RESERVED = 0, + NE1617A_LOCAL_SENSOR, + NE1617A_REMOTE_SENSOR, + MAX6581_LOCAL_SENSOR, + MAX6581_REMOTE_SENSOR_1, + MAX6581_REMOTE_SENSOR_2, + MAX6581_REMOTE_SENSOR_3, + MAX6581_REMOTE_SENSOR_4, + MAX6581_REMOTE_SENSOR_5, + MAX6581_REMOTE_SENSOR_6, + MAX6581_REMOTE_SENSOR_7, + BCM56846_LOCAL_SENSOR, + PSU1_THERMAL_SENSOR_1, + PSU2_THERMAL_SENSOR_1, + NUM_OF_CHASSIS_THERMAL_SENSOR = BCM56846_LOCAL_SENSOR, +}; + +enum onlp_fan_duty_cycle_percentage +{ + FAN_PERCENTAGE_MIN = 40, + FAN_PERCENTAGE_MID = 70, + FAN_PERCENTAGE_MAX = 100 +}; + +#define TEMPERATURE_MULTIPLIER 1000 + #endif /* __PLATFORM_LIB_H__ */ diff --git a/packages/platforms/accton/powerpc/powerpc-accton-as5610-52x/onlp/builds/src/module/src/psui.c b/packages/platforms/accton/powerpc/powerpc-accton-as5610-52x/onlp/builds/src/module/src/psui.c index 09b26a5b..ecfcd32f 100644 --- a/packages/platforms/accton/powerpc/powerpc-accton-as5610-52x/onlp/builds/src/module/src/psui.c +++ b/packages/platforms/accton/powerpc/powerpc-accton-as5610-52x/onlp/builds/src/module/src/psui.c @@ -95,7 +95,7 @@ psu_cpr_4011_info_get(onlp_psu_info_t* info) /* Set the associated oid_table */ info->hdr.coids[0] = ONLP_FAN_ID_CREATE(index + 1); - info->hdr.coids[1] = ONLP_THERMAL_ID_CREATE(index + 8); + info->hdr.coids[1] = ONLP_THERMAL_ID_CREATE(index + NUM_OF_CHASSIS_THERMAL_SENSOR); /* Open channel for PSU */ diff --git a/packages/platforms/accton/powerpc/powerpc-accton-as5610-52x/onlp/builds/src/module/src/sysi.c b/packages/platforms/accton/powerpc/powerpc-accton-as5610-52x/onlp/builds/src/module/src/sysi.c index 566af639..aed3f4a4 100644 --- a/packages/platforms/accton/powerpc/powerpc-accton-as5610-52x/onlp/builds/src/module/src/sysi.c +++ b/packages/platforms/accton/powerpc/powerpc-accton-as5610-52x/onlp/builds/src/module/src/sysi.c @@ -25,6 +25,7 @@ ***********************************************************/ #include #include "powerpc_accton_as5610_52x_log.h" +#include "platform_lib.h" const char* onlp_sysi_platform_get(void) @@ -74,16 +75,18 @@ onlp_sysi_oids_get(onlp_oid_t* table, int max) /* 1 Fan */ *e++ = ONLP_FAN_ID_CREATE(1); - /* 9 Thermal sensors */ - *e++ = ONLP_THERMAL_ID_CREATE(1); - *e++ = ONLP_THERMAL_ID_CREATE(2); - *e++ = ONLP_THERMAL_ID_CREATE(3); - *e++ = ONLP_THERMAL_ID_CREATE(4); - *e++ = ONLP_THERMAL_ID_CREATE(5); - *e++ = ONLP_THERMAL_ID_CREATE(6); - *e++ = ONLP_THERMAL_ID_CREATE(7); - *e++ = ONLP_THERMAL_ID_CREATE(8); - *e++ = ONLP_THERMAL_ID_CREATE(11); + /* 11 Thermal sensors */ + *e++ = ONLP_THERMAL_ID_CREATE(NE1617A_LOCAL_SENSOR); + *e++ = ONLP_THERMAL_ID_CREATE(NE1617A_REMOTE_SENSOR); + *e++ = ONLP_THERMAL_ID_CREATE(MAX6581_LOCAL_SENSOR); + *e++ = ONLP_THERMAL_ID_CREATE(MAX6581_REMOTE_SENSOR_1); + *e++ = ONLP_THERMAL_ID_CREATE(MAX6581_REMOTE_SENSOR_2); + *e++ = ONLP_THERMAL_ID_CREATE(MAX6581_REMOTE_SENSOR_3); + *e++ = ONLP_THERMAL_ID_CREATE(MAX6581_REMOTE_SENSOR_4); + *e++ = ONLP_THERMAL_ID_CREATE(MAX6581_REMOTE_SENSOR_5); + *e++ = ONLP_THERMAL_ID_CREATE(MAX6581_REMOTE_SENSOR_6); + *e++ = ONLP_THERMAL_ID_CREATE(MAX6581_REMOTE_SENSOR_7); + *e++ = ONLP_THERMAL_ID_CREATE(BCM56846_LOCAL_SENSOR); /* 5 LEDs */ *e++ = ONLP_LED_ID_CREATE(1); @@ -95,13 +98,111 @@ onlp_sysi_oids_get(onlp_oid_t* table, int max) return 0; } +/* The tA/tB/tC/tD/tCritical is defined in the thermal policy spec + */ +typedef struct temp_sensor_threshold { + int tA; + int tB; + int tC; + int tD; + int tCitical; +} temp_sensor_threshold_t; + +/* The thermal plan table is for F2B(Front to back) airflow direction + */ +static const temp_sensor_threshold_t temp_sensor_threshold_f2b[NUM_OF_CHASSIS_THERMAL_SENSOR] = { +{53, 46, 62, 67, 75}, {71, 63, 82, 86, 95}, {46, 38, 53, 58, 66}, {49, 42, 57, 62, 69}, +{59, 52, 70, 73, 81}, {57, 50, 65, 70, 77}, {49, 42, 57, 62, 70}, {47, 39, 55, 60, 69}, +{53, 46, 59, 65, 73}, {56, 48, 65, 69, 78}, {75, 71, 89, 94, 111} +}; + +/* The thermal plan table is for B2F(Back to front) airflow direction + */ +static const temp_sensor_threshold_t temp_sensor_threshold_b2f[NUM_OF_CHASSIS_THERMAL_SENSOR] = { +{58, 52, 73, 73, 80}, {63, 51, 67, 70, 84}, {43, 33, 47, 51, 63}, {49, 38, 56, 59, 69}, +{53, 47, 65, 68, 75}, {63, 57, 80, 78, 84}, {46, 37, 52, 55, 67}, {44, 34, 48, 52, 65}, +{55, 47, 65, 67, 76}, {47, 38, 53, 56, 68}, {81, 78, 99, 98, 104} +}; + +#include +#include + int onlp_sysi_platform_manage_fans(void) { - return ONLP_STATUS_E_UNSUPPORTED; + int i = 0, rc; + onlp_fan_info_t fi; + const temp_sensor_threshold_t *pThreshold = NULL; + onlp_thermal_info_t ti[NUM_OF_CHASSIS_THERMAL_SENSOR]; + int aboveTa = 0, aboveTb = 0, aboveTc = 0, aboveTd = 0, newPercentage = 0; + + /* Get current fan status + */ + rc = onlp_fani_info_get(ONLP_FAN_ID_CREATE(1), &fi); + if (rc < 0) { + onlp_fani_percentage_set(ONLP_FAN_ID_CREATE(1), FAN_PERCENTAGE_MAX); + return ONLP_STATUS_E_INTERNAL; + } + + if (fi.status & ONLP_FAN_STATUS_FAILED) { + onlp_fani_percentage_set(ONLP_FAN_ID_CREATE(1), FAN_PERCENTAGE_MAX); + return ONLP_STATUS_OK; + } + + /* Bring fan speed to max if current speed is not expected + */ + if (fi.percentage != FAN_PERCENTAGE_MIN && + fi.percentage != FAN_PERCENTAGE_MID && + fi.percentage != FAN_PERCENTAGE_MAX ) { + onlp_fani_percentage_set(ONLP_FAN_ID_CREATE(1), FAN_PERCENTAGE_MAX); + return ONLP_STATUS_OK; + } + + /* Apply thermal plan by air flow direction + */ + pThreshold = (fi.status & ONLP_FAN_STATUS_F2B) ? temp_sensor_threshold_f2b : + temp_sensor_threshold_b2f ; + + /* Get temperature from each thermal sensor + */ + for (i = 0; i < NUM_OF_CHASSIS_THERMAL_SENSOR; i++) { + rc = onlp_thermali_info_get(ONLP_THERMAL_ID_CREATE(i+1), &ti[i]); + + if (rc != ONLP_STATUS_OK) { + onlp_fani_percentage_set(ONLP_FAN_ID_CREATE(1), FAN_PERCENTAGE_MAX); + return rc; + } + + aboveTa += (ti[i].mcelsius > pThreshold[i].tA* TEMPERATURE_MULTIPLIER) ? 1 : 0; + aboveTb += (ti[i].mcelsius > pThreshold[i].tB* TEMPERATURE_MULTIPLIER) ? 1 : 0; + aboveTc += (ti[i].mcelsius > pThreshold[i].tC* TEMPERATURE_MULTIPLIER) ? 1 : 0; + aboveTd += (ti[i].mcelsius > pThreshold[i].tD* TEMPERATURE_MULTIPLIER) ? 1 : 0; + } + + /* Adjust fan speed based on current temperature if fan speed changed + */ + if (fi.percentage == FAN_PERCENTAGE_MIN && aboveTc) { + newPercentage = FAN_PERCENTAGE_MID; + } + else if (fi.percentage == FAN_PERCENTAGE_MID) { + if (aboveTd) { + newPercentage = FAN_PERCENTAGE_MAX; + } + else if (!aboveTb) { + newPercentage = FAN_PERCENTAGE_MIN; + } + } + else if (fi.percentage == FAN_PERCENTAGE_MAX && !aboveTa) { + newPercentage = FAN_PERCENTAGE_MID; + } + + if (newPercentage != 0) { + onlp_fani_percentage_set(ONLP_FAN_ID_CREATE(1), newPercentage); + } + + return 0; } -#include #include #include @@ -156,6 +257,3 @@ onlp_sysi_platform_manage_leds(void) return 0; } - - - diff --git a/packages/platforms/accton/powerpc/powerpc-accton-as5610-52x/onlp/builds/src/module/src/thermali.c b/packages/platforms/accton/powerpc/powerpc-accton-as5610-52x/onlp/builds/src/module/src/thermali.c index 3b788fb4..8aa3e727 100644 --- a/packages/platforms/accton/powerpc/powerpc-accton-as5610-52x/onlp/builds/src/module/src/thermali.c +++ b/packages/platforms/accton/powerpc/powerpc-accton-as5610-52x/onlp/builds/src/module/src/thermali.c @@ -40,16 +40,9 @@ #define I2C_REG_MAX6581_CONFIG 0x41 #define I2C_MAX6581_REG_EXTENDED_RANGE_MASK 0x02 -#define I2C_THERMAL_1_REG_ADT7473_LOCAL 0x26 -#define I2C_THERMAL_2_REG_ADT7473_REMOTE_1 0x25 -#define I2C_THERMAL_3_REG_ADT7473_REMOTE_2 0x27 -#define I2C_THERMAL_REG_ADT7473_EXTENDED 0x77 - #define I2C_PSU1_SLAVE_ADDR_CFG 0x3E #define I2C_PSU2_SLAVE_ADDR_CFG 0x3D -#define TEMPERATURE_MULTIPLIER 1000 - #define VALIDATE(_id) \ do { \ if(!ONLP_OID_IS_THERMAL(_id)) { \ @@ -75,10 +68,10 @@ static int thermal_sensor_max6581_info_get(onlp_thermal_info_t* info) { unsigned char data = 0; - unsigned char temp_reg[7] = {0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x8}; - unsigned char temp_reg_dp[7] = {0x9, 0x52, 0x53, 0x54, 0x55, 0x56, 0x58}; /* Register to read decimal place */ + unsigned char temp_reg[8] = { 0x7, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x8}; + unsigned char temp_reg_dp[8] = {0x57, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x58}; /* Register to read decimal place */ int base_degree = thermal_sensor_max6581_base_degree(); - int index = ONLP_OID_ID_GET(info->hdr.id) - 1; + int index = ONLP_OID_ID_GET(info->hdr.id) - MAX6581_LOCAL_SENSOR; /* Set the thermal status from diode fault(0x46) register */ if (i2c_nRead(I2C_THERMAL_SENSOR_BUS_ID, I2C_SLAVE_ADDR_MAX6581, 0x46, sizeof(data), &data) != 0) { @@ -112,8 +105,10 @@ static int thermal_sensor_ne1617a_info_get(onlp_thermal_info_t* info) { unsigned char data = 0; + unsigned char temp_reg[2] = {0x0, 0x1}; + int index = ONLP_OID_ID_GET(info->hdr.id) - NE1617A_LOCAL_SENSOR; - if (i2c_nRead(I2C_THERMAL_SENSOR_BUS_ID, I2C_SLAVE_ADDR_NE1617A, 0x1, sizeof(data), &data) != 0) { + if (i2c_nRead(I2C_THERMAL_SENSOR_BUS_ID, I2C_SLAVE_ADDR_NE1617A, temp_reg[index], sizeof(data), &data) != 0) { return ONLP_STATUS_E_INTERNAL; } @@ -130,10 +125,10 @@ thermal_sensor_cpr_4011_info_get(onlp_thermal_info_t* info) unsigned char status = 0; unsigned char i2c_addr; - if (ONLP_OID_ID_GET(info->hdr.id) == 9) { + if (ONLP_OID_ID_GET(info->hdr.id) == PSU1_THERMAL_SENSOR_1) { i2c_addr = I2C_PSU1_SLAVE_ADDR_CFG; } - else { + else { /* PSU2_THERMAL_SENSOR_1 */ i2c_addr = I2C_PSU2_SLAVE_ADDR_CFG; } @@ -194,42 +189,48 @@ onlp_thermali_init(void) /* Static values */ static onlp_thermal_info_t tinfo[] = { { }, /* Not used */ -{ { ONLP_THERMAL_ID_CREATE(1), "Chassis Thermal Sensor 1 (near right-upper side of CPU)", 0}, 0x1, +{ { ONLP_THERMAL_ID_CREATE(NE1617A_LOCAL_SENSOR), "Chassis Thermal Sensor 1 (NE1617A local sensor)", 0}, 0x1, ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS }, -{ { ONLP_THERMAL_ID_CREATE(2), "Chassis Thermal Sensor 2 (near right side of MAX6581)", 0}, 0x1, +{ { ONLP_THERMAL_ID_CREATE(NE1617A_REMOTE_SENSOR), "Chassis Thermal Sensor 2 (the left middle side of the system)", 0}, 0x1, ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS }, -{ { ONLP_THERMAL_ID_CREATE(3), "Chassis Thermal Sensor 3 (near right side of MAC(Trident+)", 0}, 0x1, +{ { ONLP_THERMAL_ID_CREATE(MAX6581_LOCAL_SENSOR), "Chassis Thermal Sensor 3 (MAX6581 local sensor)", 0}, 0x1, ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS }, -{ { ONLP_THERMAL_ID_CREATE(4), "Chassis Thermal Sensor 4 (near left down side of Equalizer_U57)", 0}, 0x1, +{ { ONLP_THERMAL_ID_CREATE(MAX6581_REMOTE_SENSOR_1), "Chassis Thermal Sensor 4 (near right-upper side of CPU)", 0}, 0x1, ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS }, -{ { ONLP_THERMAL_ID_CREATE(5), "Chassis Thermal Sensor 5 (near right down side of MAC)", 0}, 0x1, +{ { ONLP_THERMAL_ID_CREATE(MAX6581_REMOTE_SENSOR_2), "Chassis Thermal Sensor 5 (near right side of MAX6581)", 0}, 0x1, ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS }, -{ { ONLP_THERMAL_ID_CREATE(6), "Chassis Thermal Sensor 6 (near upper side of Equalizer_U49)", 0}, 0x1, +{ { ONLP_THERMAL_ID_CREATE(MAX6581_REMOTE_SENSOR_3), "Chassis Thermal Sensor 6 (near right side of MAC(Trident+)", 0}, 0x1, ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS }, -{ { ONLP_THERMAL_ID_CREATE(7), "Chassis Thermal Sensor 7 (near left down side of PCB)", 0}, 0x1, +{ { ONLP_THERMAL_ID_CREATE(MAX6581_REMOTE_SENSOR_4), "Chassis Thermal Sensor 7 (near left down side of Equalizer_U57)", 0}, 0x1, ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS }, -{ { ONLP_THERMAL_ID_CREATE(8), "Chassis Thermal Sensor 8 (inside CPU)", 0}, 0x1, +{ { ONLP_THERMAL_ID_CREATE(MAX6581_REMOTE_SENSOR_5), "Chassis Thermal Sensor 8 (near right down side of MAC)", 0}, 0x1, ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS }, -{ { ONLP_THERMAL_ID_CREATE(9), "PSU-1 Thermal Sensor 1", ONLP_PSU_ID_CREATE(1)}, 0x1, +{ { ONLP_THERMAL_ID_CREATE(MAX6581_REMOTE_SENSOR_6), "Chassis Thermal Sensor 9 (near upper side of Equalizer_U49)", 0}, 0x1, ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS }, -{ { ONLP_THERMAL_ID_CREATE(10), "PSU-2 Thermal Sensor 1", ONLP_PSU_ID_CREATE(2)}, 0x1, +{ { ONLP_THERMAL_ID_CREATE(MAX6581_REMOTE_SENSOR_7), "Chassis Thermal Sensor 10 (near left down side of PCB)", 0}, 0x1, ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS }, -{ { ONLP_THERMAL_ID_CREATE(11), "Switch Thermal Sensor", 0}, 0x1, +{ { ONLP_THERMAL_ID_CREATE(BCM56846_LOCAL_SENSOR), "Chassis Thermal Sensor 11 (BCM56846 local sensor)", 0}, 0x1, ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS }, +{ { ONLP_THERMAL_ID_CREATE(PSU1_THERMAL_SENSOR_1), "PSU-1 Thermal Sensor 1", ONLP_PSU_ID_CREATE(1)}, 0x1, + ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS +}, +{ { ONLP_THERMAL_ID_CREATE(PSU2_THERMAL_SENSOR_1), "PSU-2 Thermal Sensor 1", ONLP_PSU_ID_CREATE(2)}, 0x1, + ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS +} }; -/* +/* * Retrieve the information structure for the given thermal OID. * * If the OID is invalid, return ONLP_E_STATUS_INVALID. @@ -246,8 +247,29 @@ onlp_thermali_info_get(onlp_oid_t id, onlp_thermal_info_t* info) VALIDATE(id); *info = tinfo[ONLP_OID_ID_GET(id)]; /* Set the ID/Description/Present state */ + if (ONLP_OID_ID_GET(id) == BCM56846_LOCAL_SENSOR) { + /* Switch Thermal Sensor */ + char* fname = "/var/run/broadcom/temp0"; + int rv = onlp_file_read_int(&info->mcelsius, fname); + if(rv >= 0) { + /** Present and running */ + info->status |= 1; + ret = ONLP_STATUS_OK; + } + else if(rv == ONLP_STATUS_E_MISSING) { + /** No switch management process running. */ + info->status = 0; + ret = ONLP_STATUS_OK; + } + else { + /** Other error. */ + ret = ONLP_STATUS_E_INTERNAL; + } + return ret; + } + /* Read the temperature and status */ - if (ONLP_OID_ID_GET(id) >= 1 && ONLP_OID_ID_GET(id) <= 7) { + if (ONLP_OID_ID_GET(id) >= MAX6581_LOCAL_SENSOR && ONLP_OID_ID_GET(id) <= MAX6581_REMOTE_SENSOR_7) { /* Set multiplexer to the channel of thermal sensor */ if (as5610_52x_i2c0_pca9548_channel_set(0x80) != 0) { return ONLP_STATUS_E_INTERNAL; @@ -256,7 +278,7 @@ onlp_thermali_info_get(onlp_oid_t id, onlp_thermal_info_t* info) ret = thermal_sensor_max6581_info_get(info); } - if (ONLP_OID_ID_GET(id) == 8) { + if (ONLP_OID_ID_GET(id) == NE1617A_LOCAL_SENSOR || ONLP_OID_ID_GET(id) == NE1617A_REMOTE_SENSOR) { /* Set multiplexer to the channel of thermal sensor */ if (as5610_52x_i2c0_pca9548_channel_set(0x80) != 0) { return ONLP_STATUS_E_INTERNAL; @@ -265,9 +287,10 @@ onlp_thermali_info_get(onlp_oid_t id, onlp_thermal_info_t* info) ret = thermal_sensor_ne1617a_info_get(info); } - if (ONLP_OID_ID_GET(id) == 9 || ONLP_OID_ID_GET(id) == 10) { + if (ONLP_OID_ID_GET(id) == PSU1_THERMAL_SENSOR_1 || ONLP_OID_ID_GET(id) == PSU2_THERMAL_SENSOR_1) { /* Check PSU type */ - as5610_52x_psu_type_t psu_type = as5610_52x_get_psu_type(ONLP_OID_ID_GET(id)-8, NULL, 0); + as5610_52x_psu_type_t psu_type; + psu_type = as5610_52x_get_psu_type(ONLP_OID_ID_GET(id)-NUM_OF_CHASSIS_THERMAL_SENSOR, NULL, 0); if (PSU_TYPE_AC_F2B == psu_type || PSU_TYPE_AC_B2F == psu_type) { /* Set multiplexer to the channel of thermal sensor */ @@ -279,26 +302,6 @@ onlp_thermali_info_get(onlp_oid_t id, onlp_thermal_info_t* info) } } - if (ONLP_OID_ID_GET(id) == 11) { - /* Switch Thermal Sensor */ - char* fname = "/var/run/broadcom/temp0"; - int rv = onlp_file_read_int(&info->mcelsius, fname); - if(rv >= 0) { - /** Present and running */ - info->status |= 1; - ret = 0; - } - else if(rv == ONLP_STATUS_E_MISSING) { - /** No switch management process running. */ - info->status = 0; - ret = 0; - } - else { - /** Other error. */ - ret = ONLP_STATUS_E_INTERNAL; - } - } - /* Close PSU channel */ as5610_52x_i2c0_pca9548_channel_set(0);