Skip to content

Commit

Permalink
[Delta]: Updated port_config.ini & fix the bug of fancontrol.service …
Browse files Browse the repository at this point in the history
…for ag9032v1. (#1371)

* [Delta]: Updated port_config.ini & fix the bug of fancontrol.service for ag9032v1.

Signed-off-by: Stanley Chi <stanley.chi@deltaww.com>

* [Delta]: Updated port_config.ini & fix the bug of fancontrol.service for ag9032v1.

Signed-off-by: Stanley Chi <stanley.chi@deltaww.com>
  • Loading branch information
StanleyCi authored and lguohan committed Feb 6, 2018
1 parent 6045235 commit e880c78
Show file tree
Hide file tree
Showing 2 changed files with 101 additions and 56 deletions.
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
109 changes: 77 additions & 32 deletions device/delta/x86_64-delta_ag9032v1-r0/fancontrol.service
Original file line number Diff line number Diff line change
Expand Up @@ -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'`

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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<TEMP<=55
FAN_PERCENTAGE=60
elif [ $TEMP_HIGHEST -lt 61 -a $TEMP_HIGHEST -gt 55 ]; then #55<TEMP<=60
#echo "num tmp lev F L H"
#Update level
for i in 1 2 3 4 5
do
#echo "----------------------"
FLAG=0
#FLAG=0 : initial flag
#FLAG=1 : update level
#FLAG=2 : final level
while [ $FLAG -ne 2 ]
do
UpdateThermalLevel
#echo " $i ${AFCTEMP[$i]} ${AFCTEMP_LEVEL[$i]} $FLAG $AFCTEMP_LOWER $AFCTEMP_UPPER "
done
done

min=${AFCTEMP_LEVEL[0]}
for j in "${AFCTEMP_LEVEL[@]}"; do
(( j < min )) && min=$j
done

if (($min == 1 || $min == 2)); then
FAN_PERCENTAGE=100
elif (($min == 3)); then
FAN_PERCENTAGE=80
elif [ $TEMP_HIGHEST -lt 66 -a $TEMP_HIGHEST -gt 60 ]; then #60<TEMP<=65
FAN_PERCENTAGE=90
elif [ $TEMP_HIGHEST -gt 65 ]; then # 65<TEMP
FAN_PERCENTAGE=100
elif (($min == 4)); then
FAN_PERCENTAGE=60
elif (($min == 5)); then
FAN_PERCENTAGE=40
elif (($min == 6)); then
FAN_PERCENTAGE=30
else
FAN_PERCENTAGE=100
fi

echo "The lowest level of thermal sensors: $min "
echo "Trying to set fan speed to $FAN_PERCENTAGE %"
#Set speed to fan1~fan10
let fcvcount=0
Expand All @@ -211,33 +261,28 @@ function UpdateFanSpeeds
then
AFCFAN[$fcvcount]=$zero
fi
echo "FAN fan$fcvcount = ${AFCFAN[$fcvcount]} (rpm)"
done

if [ $TEMP_HIGHEST -lt 51 ]; then #TEMP<=50
FAN_ON_PSU_PERCENTAGE=50
elif [ $TEMP_HIGHEST -lt 100 -a $TEMP_HIGHEST -gt 50 ]; then #50<TEMP<100
FAN_ON_PSU_PERCENTAGE=100
else
echo "Unable to get thermal temperature"
FAN_ON_PSU_PERCENTAGE=100
fi
FAN_ON_PSU_PERCENTAGE=$FAN_PERCENTAGE
#Set speed to PSU_FAN1
#echo "0x00" > '/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 $!
Expand Down

0 comments on commit e880c78

Please sign in to comment.