Skip to content

Commit e880c78

Browse files
StanleyCilguohan
authored andcommitted
[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 <[email protected]> * [Delta]: Updated port_config.ini & fix the bug of fancontrol.service for ag9032v1. Signed-off-by: Stanley Chi <[email protected]>
1 parent 6045235 commit e880c78

File tree

2 files changed

+101
-56
lines changed

2 files changed

+101
-56
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
# name lanes alias
2-
Ethernet0 49,50,51,52 hundredGigE1/1
3-
Ethernet4 53,54,55,56 hundredGigE1/2
4-
Ethernet8 57,58,59,60 hundredGigE1/3
5-
Ethernet12 61,62,63,64 hundredGigE1/4
6-
Ethernet16 65,66,67,68 hundredGigE1/5
7-
Ethernet20 69,70,71,72 hundredGigE1/6
8-
Ethernet24 73,74,75,76 hundredGigE1/7
9-
Ethernet28 77,78,79,80 hundredGigE1/8
10-
Ethernet32 37,38,39,40 hundredGigE1/9
11-
Ethernet36 33,34,35,36 hundredGigE1/10
12-
Ethernet40 45,46,47,48 hundredGigE1/11
13-
Ethernet44 41,42,43,44 hundredGigE1/12
2+
Ethernet0 41,42,43,44 hundredGigE1/1
3+
Ethernet4 45,46,47,48 hundredGigE1/2
4+
Ethernet8 49,50,51,52 hundredGigE1/3
5+
Ethernet12 37,38,39,40 hundredGigE1/4
6+
Ethernet16 33,34,35,36 hundredGigE1/5
7+
Ethernet20 53,54,55,56 hundredGigE1/6
8+
Ethernet24 57,58,59,60 hundredGigE1/7
9+
Ethernet28 61,62,63,64 hundredGigE1/8
10+
Ethernet32 65,66,67,68 hundredGigE1/9
11+
Ethernet36 69,70,71,72 hundredGigE1/10
12+
Ethernet40 73,74,75,76 hundredGigE1/11
13+
Ethernet44 77,78,79,80 hundredGigE1/12
1414
Ethernet48 81,82,83,84 hundredGigE1/13
1515
Ethernet52 85,86,87,88 hundredGigE1/14
1616
Ethernet56 89,90,91,92 hundredGigE1/15
@@ -19,15 +19,15 @@ Ethernet64 97,98,99,100 hundredGigE1/17
1919
Ethernet68 101,102,103,104 hundredGigE1/18
2020
Ethernet72 105,106,107,108 hundredGigE1/19
2121
Ethernet76 109,110,111,112 hundredGigE1/20
22-
Ethernet80 21,22,23,24 hundredGigE1/21
23-
Ethernet84 17,18,19,20 hundredGigE1/22
24-
Ethernet88 29,30,31,32 hundredGigE1/23
25-
Ethernet92 25,26,27,28 hundredGigE1/24
26-
Ethernet96 117,118,119,120 hundredGigE1/25
27-
Ethernet100 113,114,115,116 hundredGigE1/26
28-
Ethernet104 125,126,127,128 hundredGigE1/27
29-
Ethernet108 121,122,123,124 hundredGigE1/28
30-
Ethernet112 5,6,7,8 hundredGigE1/29
31-
Ethernet116 1,2,3,4 hundredGigE1/30
32-
Ethernet120 13,14,15,16 hundredGigE1/31
33-
Ethernet124 9,10,11,12 hundredGigE1/32
22+
Ethernet80 121,122,123,124 hundredGigE1/21
23+
Ethernet84 113,114,115,116 hundredGigE1/22
24+
Ethernet88 1,2,3,4 hundredGigE1/23
25+
Ethernet92 117,118,119,120 hundredGigE1/24
26+
Ethernet96 5,6,7,8 hundredGigE1/25
27+
Ethernet100 125,126,127,128 hundredGigE1/26
28+
Ethernet104 29,30,31,32 hundredGigE1/27
29+
Ethernet108 9,10,11,12 hundredGigE1/28
30+
Ethernet112 13,14,15,16 hundredGigE1/29
31+
Ethernet116 25,26,27,28 hundredGigE1/30
32+
Ethernet120 17,18,19,20 hundredGigE1/31
33+
Ethernet124 21,22,23,24 hundredGigE1/32

device/delta/x86_64-delta_ag9032v1-r0/fancontrol.service

+77-32
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,17 @@ function LoadConfig
6969
FCMAXTEMP=$MAXTEMP
7070
FCMINSTART=$MINSTART
7171
FCMINSTOP=$MINSTOP
72+
AFCTEMP_1_LOWER=(00 39 36 41 46 55)
73+
AFCTEMP_1_UPPER=(39 39 44 49 54 150)
74+
AFCTEMP_2_LOWER=(00 61 65 69 73 82)
75+
AFCTEMP_2_UPPER=(63 67 71 75 79 150)
76+
AFCTEMP_3_LOWER=(00 51 55 59 63 71)
77+
AFCTEMP_3_UPPER=(53 57 61 65 69 150)
78+
AFCTEMP_4_LOWER=(00 46 50 54 58 65)
79+
AFCTEMP_4_UPPER=(45 52 56 60 64 150)
80+
AFCTEMP_5_LOWER=(00 46 50 54 58 65)
81+
AFCTEMP_5_UPPER=(45 52 56 60 64 150)
82+
7283

7384
FCFANS=`egrep '^FCFANS=.*$' $1 | sed -e 's/FCFANS=//g'`
7485

@@ -98,7 +109,6 @@ function LoadConfig
98109
AFCTEMP[$fcvcount]=$( echo "$temp_string" | cut -d" " -f $fcvcount )
99110
AFCTEMP[$fcvcount]=$( echo "${AFCTEMP[$fcvcount]}" | sed 's/hwmon1/\/sys\/bus\/i2c\/devices/g' )
100111
AFCTEMP_PATH[$fcvcount]=$( echo "${AFCTEMP[$fcvcount]}" | sed 's/hwmon1/\/sys\/bus\/i2c\/devices/g' )
101-
102112
AFCTEMP[$fcvcount]=$( cat ${AFCTEMP[$fcvcount]} )
103113
AFCTEMP[$fcvcount]=$(( AFCTEMP[$fcvcount]/1000 ))
104114
done
@@ -165,39 +175,79 @@ then
165175
fi
166176
echo $$ > "$PIDFILE"
167177

168-
169178
# main function
170179
function UpdateThermalSensors
171180
{
172-
echo ""
173-
TEMP_HIGHEST=0
174-
FAN_PERCENTAGE=0
175-
176-
for i in ${AFCTEMP_PATH[@]}; do
177-
if (( $(cat $i) > $TEMP_HIGHEST )); then
178-
TEMP_HIGHEST=$(cat $i);
179-
fi;
181+
fcvcount=0
182+
for fcv in $FCTEMPS
183+
do
184+
fcvcount=$((fcvcount+1))
185+
AFCTEMP[$fcvcount]=$( cat ${AFCTEMP_PATH[$fcvcount]} )
186+
AFCTEMP[$fcvcount]=$(( AFCTEMP[$fcvcount]/1000 ))
180187
done
181-
TEMP_HIGHEST=$((TEMP_HIGHEST/1000))
182-
echo "The highest temperature of thermal sensors: $TEMP_HIGHEST °C"
188+
}
189+
190+
function UpdateThermalLevel
191+
{
192+
AFCTEMP_NUM=$((6-${AFCTEMP_LEVEL[$i]}))
193+
AFCTEMP_UPPER_BUF=AFCTEMP_"$i"_UPPER["$AFCTEMP_NUM"]
194+
AFCTEMP_LOWER_BUF=AFCTEMP_"$i"_LOWER["$AFCTEMP_NUM"]
195+
196+
AFCTEMP_UPPER=${!AFCTEMP_UPPER_BUF}
197+
AFCTEMP_LOWER=${!AFCTEMP_LOWER_BUF}
198+
199+
200+
if (( ("${AFCTEMP[$i]}" <= "$AFCTEMP_UPPER") && ("${AFCTEMP[$i]}" >= "$AFCTEMP_LOWER") )) ; then
201+
FLAG=2
202+
elif (( "${AFCTEMP[$i]}" > "$AFCTEMP_UPPER" )); then
203+
AFCTEMP_LEVEL[$i]=$((${AFCTEMP_LEVEL[$i]} - 1))
204+
FLAG=1
205+
elif (( "${AFCTEMP[$i]}" < "$AFCTEMP_LOWER" )); then
206+
AFCTEMP_LEVEL[$i]=$((${AFCTEMP_LEVEL[$i]} + 1))
207+
FLAG=1
208+
else
209+
AFCTEMP_LEVEL[$i]=1
210+
FLAG=2
211+
fi
183212
}
184213

185214
function UpdateFanSpeeds
186215
{
187-
if [ $TEMP_HIGHEST -lt 51 ]; then #TEMP<=50
188-
FAN_PERCENTAGE=40
189-
elif [ $TEMP_HIGHEST -lt 56 -a $TEMP_HIGHEST -gt 50 ]; then #50<TEMP<=55
190-
FAN_PERCENTAGE=60
191-
elif [ $TEMP_HIGHEST -lt 61 -a $TEMP_HIGHEST -gt 55 ]; then #55<TEMP<=60
216+
#echo "num tmp lev F L H"
217+
#Update level
218+
for i in 1 2 3 4 5
219+
do
220+
#echo "----------------------"
221+
FLAG=0
222+
#FLAG=0 : initial flag
223+
#FLAG=1 : update level
224+
#FLAG=2 : final level
225+
while [ $FLAG -ne 2 ]
226+
do
227+
UpdateThermalLevel
228+
#echo " $i ${AFCTEMP[$i]} ${AFCTEMP_LEVEL[$i]} $FLAG $AFCTEMP_LOWER $AFCTEMP_UPPER "
229+
done
230+
done
231+
232+
min=${AFCTEMP_LEVEL[0]}
233+
for j in "${AFCTEMP_LEVEL[@]}"; do
234+
(( j < min )) && min=$j
235+
done
236+
237+
if (($min == 1 || $min == 2)); then
238+
FAN_PERCENTAGE=100
239+
elif (($min == 3)); then
192240
FAN_PERCENTAGE=80
193-
elif [ $TEMP_HIGHEST -lt 66 -a $TEMP_HIGHEST -gt 60 ]; then #60<TEMP<=65
194-
FAN_PERCENTAGE=90
195-
elif [ $TEMP_HIGHEST -gt 65 ]; then # 65<TEMP
196-
FAN_PERCENTAGE=100
241+
elif (($min == 4)); then
242+
FAN_PERCENTAGE=60
243+
elif (($min == 5)); then
244+
FAN_PERCENTAGE=40
245+
elif (($min == 6)); then
246+
FAN_PERCENTAGE=30
197247
else
198248
FAN_PERCENTAGE=100
199249
fi
200-
250+
echo "The lowest level of thermal sensors: $min "
201251
echo "Trying to set fan speed to $FAN_PERCENTAGE %"
202252
#Set speed to fan1~fan10
203253
let fcvcount=0
@@ -211,33 +261,28 @@ function UpdateFanSpeeds
211261
then
212262
AFCFAN[$fcvcount]=$zero
213263
fi
264+
echo "FAN fan$fcvcount = ${AFCFAN[$fcvcount]} (rpm)"
214265
done
215266

216-
if [ $TEMP_HIGHEST -lt 51 ]; then #TEMP<=50
217-
FAN_ON_PSU_PERCENTAGE=50
218-
elif [ $TEMP_HIGHEST -lt 100 -a $TEMP_HIGHEST -gt 50 ]; then #50<TEMP<100
219-
FAN_ON_PSU_PERCENTAGE=100
220-
else
221-
echo "Unable to get thermal temperature"
222-
FAN_ON_PSU_PERCENTAGE=100
223-
fi
267+
FAN_ON_PSU_PERCENTAGE=$FAN_PERCENTAGE
224268
#Set speed to PSU_FAN1
225-
#echo "0x00" > '/sys/bus/i2c/devices/4-0058/psu_select_member'
226269
echo "$FAN_ON_PSU_PERCENTAGE" > '/sys/bus/i2c/devices/40-0058/fan1_set_percentage'
227270
echo "PSU fan1 =$( cat '/sys/bus/i2c/devices/40-0058/fan1_input' ) (rpm)"
228271
#Set speed to PSU_FAN2
229-
#echo "0x20" > '/sys/bus/i2c/devices/4-0058/psu_select_member'
230272
echo "$FAN_ON_PSU_PERCENTAGE" > '/sys/bus/i2c/devices/41-0058/fan1_set_percentage'
231273
echo "PSU fan2 =$( cat '/sys/bus/i2c/devices/41-0058/fan1_input' ) (rpm)"
232274

233275
rm -f "$PIDFILE"
234276
}
277+
235278
# main loop calling the main function at specified intervals
279+
AFCTEMP_LEVEL=(9 4 4 4 4 4) #inttial level
236280
while true
237281
do
238282
UpdateThermalSensors
239283
UpdateFanSpeeds
240284
echo "Sleep $INTERVAL seconds ..."
285+
echo
241286
# Sleep while still handling signals
242287
sleep $INTERVAL &
243288
wait $!

0 commit comments

Comments
 (0)