From e880c78f2a5058a2330e4104f24f8c4166fe43d4 Mon Sep 17 00:00:00 2001 From: StanleyCi <34563271+StanleyCi@users.noreply.github.com> Date: Tue, 6 Feb 2018 21:23:20 +0800 Subject: [PATCH] [Delta]: Updated port_config.ini & fix the bug of fancontrol.service for ag9032v1. (#1371) * [Delta]: Updated port_config.ini & fix the bug of fancontrol.service for ag9032v1. Signed-off-by: Stanley Chi * [Delta]: Updated port_config.ini & fix the bug of fancontrol.service for ag9032v1. Signed-off-by: Stanley Chi --- .../Delta-ag9032v1/port_config.ini | 48 ++++---- .../fancontrol.service | 109 +++++++++++++----- 2 files changed, 101 insertions(+), 56 deletions(-) diff --git a/device/delta/x86_64-delta_ag9032v1-r0/Delta-ag9032v1/port_config.ini b/device/delta/x86_64-delta_ag9032v1-r0/Delta-ag9032v1/port_config.ini index e000f29bef38..4fb783847b0a 100644 --- a/device/delta/x86_64-delta_ag9032v1-r0/Delta-ag9032v1/port_config.ini +++ b/device/delta/x86_64-delta_ag9032v1-r0/Delta-ag9032v1/port_config.ini @@ -1,16 +1,16 @@ # name lanes alias -Ethernet0 49,50,51,52 hundredGigE1/1 -Ethernet4 53,54,55,56 hundredGigE1/2 -Ethernet8 57,58,59,60 hundredGigE1/3 -Ethernet12 61,62,63,64 hundredGigE1/4 -Ethernet16 65,66,67,68 hundredGigE1/5 -Ethernet20 69,70,71,72 hundredGigE1/6 -Ethernet24 73,74,75,76 hundredGigE1/7 -Ethernet28 77,78,79,80 hundredGigE1/8 -Ethernet32 37,38,39,40 hundredGigE1/9 -Ethernet36 33,34,35,36 hundredGigE1/10 -Ethernet40 45,46,47,48 hundredGigE1/11 -Ethernet44 41,42,43,44 hundredGigE1/12 +Ethernet0 41,42,43,44 hundredGigE1/1 +Ethernet4 45,46,47,48 hundredGigE1/2 +Ethernet8 49,50,51,52 hundredGigE1/3 +Ethernet12 37,38,39,40 hundredGigE1/4 +Ethernet16 33,34,35,36 hundredGigE1/5 +Ethernet20 53,54,55,56 hundredGigE1/6 +Ethernet24 57,58,59,60 hundredGigE1/7 +Ethernet28 61,62,63,64 hundredGigE1/8 +Ethernet32 65,66,67,68 hundredGigE1/9 +Ethernet36 69,70,71,72 hundredGigE1/10 +Ethernet40 73,74,75,76 hundredGigE1/11 +Ethernet44 77,78,79,80 hundredGigE1/12 Ethernet48 81,82,83,84 hundredGigE1/13 Ethernet52 85,86,87,88 hundredGigE1/14 Ethernet56 89,90,91,92 hundredGigE1/15 @@ -19,15 +19,15 @@ Ethernet64 97,98,99,100 hundredGigE1/17 Ethernet68 101,102,103,104 hundredGigE1/18 Ethernet72 105,106,107,108 hundredGigE1/19 Ethernet76 109,110,111,112 hundredGigE1/20 -Ethernet80 21,22,23,24 hundredGigE1/21 -Ethernet84 17,18,19,20 hundredGigE1/22 -Ethernet88 29,30,31,32 hundredGigE1/23 -Ethernet92 25,26,27,28 hundredGigE1/24 -Ethernet96 117,118,119,120 hundredGigE1/25 -Ethernet100 113,114,115,116 hundredGigE1/26 -Ethernet104 125,126,127,128 hundredGigE1/27 -Ethernet108 121,122,123,124 hundredGigE1/28 -Ethernet112 5,6,7,8 hundredGigE1/29 -Ethernet116 1,2,3,4 hundredGigE1/30 -Ethernet120 13,14,15,16 hundredGigE1/31 -Ethernet124 9,10,11,12 hundredGigE1/32 +Ethernet80 121,122,123,124 hundredGigE1/21 +Ethernet84 113,114,115,116 hundredGigE1/22 +Ethernet88 1,2,3,4 hundredGigE1/23 +Ethernet92 117,118,119,120 hundredGigE1/24 +Ethernet96 5,6,7,8 hundredGigE1/25 +Ethernet100 125,126,127,128 hundredGigE1/26 +Ethernet104 29,30,31,32 hundredGigE1/27 +Ethernet108 9,10,11,12 hundredGigE1/28 +Ethernet112 13,14,15,16 hundredGigE1/29 +Ethernet116 25,26,27,28 hundredGigE1/30 +Ethernet120 17,18,19,20 hundredGigE1/31 +Ethernet124 21,22,23,24 hundredGigE1/32 diff --git a/device/delta/x86_64-delta_ag9032v1-r0/fancontrol.service b/device/delta/x86_64-delta_ag9032v1-r0/fancontrol.service index 17f647effb5b..83f14245d1bd 100755 --- a/device/delta/x86_64-delta_ag9032v1-r0/fancontrol.service +++ b/device/delta/x86_64-delta_ag9032v1-r0/fancontrol.service @@ -69,6 +69,17 @@ function LoadConfig FCMAXTEMP=$MAXTEMP FCMINSTART=$MINSTART FCMINSTOP=$MINSTOP + AFCTEMP_1_LOWER=(00 39 36 41 46 55) + AFCTEMP_1_UPPER=(39 39 44 49 54 150) + AFCTEMP_2_LOWER=(00 61 65 69 73 82) + AFCTEMP_2_UPPER=(63 67 71 75 79 150) + AFCTEMP_3_LOWER=(00 51 55 59 63 71) + AFCTEMP_3_UPPER=(53 57 61 65 69 150) + AFCTEMP_4_LOWER=(00 46 50 54 58 65) + AFCTEMP_4_UPPER=(45 52 56 60 64 150) + AFCTEMP_5_LOWER=(00 46 50 54 58 65) + AFCTEMP_5_UPPER=(45 52 56 60 64 150) + FCFANS=`egrep '^FCFANS=.*$' $1 | sed -e 's/FCFANS=//g'` @@ -98,7 +109,6 @@ function LoadConfig AFCTEMP[$fcvcount]=$( echo "$temp_string" | cut -d" " -f $fcvcount ) AFCTEMP[$fcvcount]=$( echo "${AFCTEMP[$fcvcount]}" | sed 's/hwmon1/\/sys\/bus\/i2c\/devices/g' ) AFCTEMP_PATH[$fcvcount]=$( echo "${AFCTEMP[$fcvcount]}" | sed 's/hwmon1/\/sys\/bus\/i2c\/devices/g' ) - AFCTEMP[$fcvcount]=$( cat ${AFCTEMP[$fcvcount]} ) AFCTEMP[$fcvcount]=$(( AFCTEMP[$fcvcount]/1000 )) done @@ -165,39 +175,79 @@ then fi echo $$ > "$PIDFILE" - # main function function UpdateThermalSensors { - echo "" - TEMP_HIGHEST=0 - FAN_PERCENTAGE=0 - - for i in ${AFCTEMP_PATH[@]}; do - if (( $(cat $i) > $TEMP_HIGHEST )); then - TEMP_HIGHEST=$(cat $i); - fi; + fcvcount=0 + for fcv in $FCTEMPS + do + fcvcount=$((fcvcount+1)) + AFCTEMP[$fcvcount]=$( cat ${AFCTEMP_PATH[$fcvcount]} ) + AFCTEMP[$fcvcount]=$(( AFCTEMP[$fcvcount]/1000 )) done - TEMP_HIGHEST=$((TEMP_HIGHEST/1000)) - echo "The highest temperature of thermal sensors: $TEMP_HIGHEST °C" +} + +function UpdateThermalLevel +{ + AFCTEMP_NUM=$((6-${AFCTEMP_LEVEL[$i]})) + AFCTEMP_UPPER_BUF=AFCTEMP_"$i"_UPPER["$AFCTEMP_NUM"] + AFCTEMP_LOWER_BUF=AFCTEMP_"$i"_LOWER["$AFCTEMP_NUM"] + + AFCTEMP_UPPER=${!AFCTEMP_UPPER_BUF} + AFCTEMP_LOWER=${!AFCTEMP_LOWER_BUF} + + + if (( ("${AFCTEMP[$i]}" <= "$AFCTEMP_UPPER") && ("${AFCTEMP[$i]}" >= "$AFCTEMP_LOWER") )) ; then + FLAG=2 + elif (( "${AFCTEMP[$i]}" > "$AFCTEMP_UPPER" )); then + AFCTEMP_LEVEL[$i]=$((${AFCTEMP_LEVEL[$i]} - 1)) + FLAG=1 + elif (( "${AFCTEMP[$i]}" < "$AFCTEMP_LOWER" )); then + AFCTEMP_LEVEL[$i]=$((${AFCTEMP_LEVEL[$i]} + 1)) + FLAG=1 + else + AFCTEMP_LEVEL[$i]=1 + FLAG=2 + fi } function UpdateFanSpeeds { - if [ $TEMP_HIGHEST -lt 51 ]; then #TEMP<=50 - FAN_PERCENTAGE=40 - elif [ $TEMP_HIGHEST -lt 56 -a $TEMP_HIGHEST -gt 50 ]; then #50 '/sys/bus/i2c/devices/4-0058/psu_select_member' echo "$FAN_ON_PSU_PERCENTAGE" > '/sys/bus/i2c/devices/40-0058/fan1_set_percentage' echo "PSU fan1 =$( cat '/sys/bus/i2c/devices/40-0058/fan1_input' ) (rpm)" #Set speed to PSU_FAN2 - #echo "0x20" > '/sys/bus/i2c/devices/4-0058/psu_select_member' echo "$FAN_ON_PSU_PERCENTAGE" > '/sys/bus/i2c/devices/41-0058/fan1_set_percentage' echo "PSU fan2 =$( cat '/sys/bus/i2c/devices/41-0058/fan1_input' ) (rpm)" rm -f "$PIDFILE" } + # main loop calling the main function at specified intervals +AFCTEMP_LEVEL=(9 4 4 4 4 4) #inttial level while true do UpdateThermalSensors UpdateFanSpeeds echo "Sleep $INTERVAL seconds ..." + echo # Sleep while still handling signals sleep $INTERVAL & wait $!