Skip to content

Commit

Permalink
[201811][platform/cel]: Port fancontrol changes for dx010/e1031 to 20…
Browse files Browse the repository at this point in the history
…1811 branch (#4867)

Update fancontrol service for Seastone-DX010/E1031 device to support hysteresis temperature threshold and difference config for each unit fan direction type (B2F/F2B); follow master branch
  • Loading branch information
Wirut Getbamrung authored Jul 4, 2020
1 parent d04ad41 commit c9d86f0
Show file tree
Hide file tree
Showing 17 changed files with 906 additions and 25 deletions.
12 changes: 0 additions & 12 deletions device/celestica/x86_64-cel_e1031-r0/fancontrol

This file was deleted.

11 changes: 11 additions & 0 deletions device/celestica/x86_64-cel_e1031-r0/fancontrol-B2F
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Configuration file generated by pwmconfig, changes will be lost
INTERVAL=2
FCTEMPS=23-004d/pwm1=/sys/bus/i2c/devices/11-001a/hwmon/hwmon*/temp1_input 23-004d/pwm2=/sys/bus/i2c/devices/11-001a/hwmon/hwmon*/temp1_input 23-004d/pwm4=/sys/bus/i2c/devices/11-001a/hwmon/hwmon*/temp1_input
FCFANS=23-004d/pwm1=23-004d/fan1_input 23-004d/pwm2=23-004d/fan2_input 23-004d/pwm4=23-004d/fan4_input
MINTEMP=23-004d/pwm1=27 23-004d/pwm2=27 23-004d/pwm4=27
MAXTEMP=23-004d/pwm1=46 23-004d/pwm2=46 23-004d/pwm4=46
MINSTART=23-004d/pwm1=102 23-004d/pwm2=102 23-004d/pwm4=102
MINSTOP=23-004d/pwm1=102 23-004d/pwm2=102 23-004d/pwm4=102
MINPWM=23-004d/pwm1=102 23-004d/pwm2=102 23-004d/pwm4=102
MAXPWM=23-004d/pwm1=255 23-004d/pwm2=255 23-004d/pwm4=255
THYST=23-004d/pwm1=2 23-004d/pwm2=2 23-004d/pwm4=2
11 changes: 11 additions & 0 deletions device/celestica/x86_64-cel_e1031-r0/fancontrol-F2B
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Configuration file generated by pwmconfig, changes will be lost
INTERVAL=2
FCTEMPS=23-004d/pwm1=/sys/bus/i2c/devices/11-001a/hwmon/hwmon*/temp3_input 23-004d/pwm2=/sys/bus/i2c/devices/11-001a/hwmon/hwmon*/temp3_input 23-004d/pwm4=/sys/bus/i2c/devices/11-001a/hwmon/hwmon*/temp3_input
FCFANS=23-004d/pwm1=23-004d/fan1_input 23-004d/pwm2=23-004d/fan2_input 23-004d/pwm4=23-004d/fan4_input
MINTEMP=23-004d/pwm1=29 23-004d/pwm2=29 23-004d/pwm4=29
MAXTEMP=23-004d/pwm1=46 23-004d/pwm2=46 23-004d/pwm4=46
MINSTART=23-004d/pwm1=102 23-004d/pwm2=102 23-004d/pwm4=102
MINSTOP=23-004d/pwm1=102 23-004d/pwm2=102 23-004d/pwm4=102
MINPWM=23-004d/pwm1=102 23-004d/pwm2=102 23-004d/pwm4=102
MAXPWM=23-004d/pwm1=255 23-004d/pwm2=255 23-004d/pwm4=255
THYST=23-004d/pwm1=2 23-004d/pwm2=2 23-004d/pwm4=2
1 change: 1 addition & 0 deletions device/celestica/x86_64-cel_e1031-r0/installer.conf
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
CONSOLE_PORT=0x2f8
CONSOLE_DEV=1
CONSOLE_SPEED=9600
ONIE_PLATFORM_EXTRA_CMDLINE_LINUX="module_blacklist=gpio_ich"
12 changes: 0 additions & 12 deletions device/celestica/x86_64-cel_seastone-r0/fancontrol

This file was deleted.

13 changes: 13 additions & 0 deletions device/celestica/x86_64-cel_seastone-r0/fancontrol-B2F
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Configuration file generated by pwmconfig, changes will be lost
INTERVAL=2
FCTEMPS=13-002e/pwm1=/sys/bus/i2c/devices/15-004e/hwmon/hwmon*/temp1_input 13-002e/pwm2=/sys/bus/i2c/devices/15-004e/hwmon/hwmon*/temp1_input 13-002e/pwm3=/sys/bus/i2c/devices/15-004e/hwmon/hwmon*/temp1_input 13-002e/pwm4=/sys/bus/i2c/devices/15-004e/hwmon/hwmon*/temp1_input 13-002e/pwm5=/sys/bus/i2c/devices/15-004e/hwmon/hwmon*/temp1_input 13-004d/pwm1=/sys/bus/i2c/devices/15-004e/hwmon/hwmon*/temp1_input 13-004d/pwm2=/sys/bus/i2c/devices/15-004e/hwmon/hwmon*/temp1_input 13-004d/pwm3=/sys/bus/i2c/devices/15-004e/hwmon/hwmon*/temp1_input 13-004d/pwm4=/sys/bus/i2c/devices/15-004e/hwmon/hwmon*/temp1_input 13-004d/pwm5=/sys/bus/i2c/devices/15-004e/hwmon/hwmon*/temp1_input
FCFANS=13-004d/pwm5=13-004d/fan5_input 13-004d/pwm4=13-004d/fan4_input 13-004d/pwm3=13-004d/fan3_input 13-004d/pwm2=13-004d/fan2_input 13-004d/pwm1=13-004d/fan1_input 13-002e/pwm5=13-002e/fan5_input 13-002e/pwm4=13-002e/fan4_input 13-002e/pwm3=13-002e/fan3_input 13-002e/pwm2=13-002e/fan2_input 13-002e/pwm1=13-002e/fan1_input
MINTEMP=13-002e/pwm1=27 13-002e/pwm2=27 13-002e/pwm3=27 13-002e/pwm4=27 13-002e/pwm5=27 13-004d/pwm1=27 13-004d/pwm2=27 13-004d/pwm3=27 13-004d/pwm4=27 13-004d/pwm5=27
MAXTEMP=13-002e/pwm1=46 13-002e/pwm2=46 13-002e/pwm3=46 13-002e/pwm4=46 13-002e/pwm5=46 13-004d/pwm1=46 13-004d/pwm2=46 13-004d/pwm3=46 13-004d/pwm4=46 13-004d/pwm5=46
MINSTART=13-002e/pwm1=89 13-002e/pwm2=89 13-002e/pwm3=89 13-002e/pwm4=89 13-002e/pwm5=89 13-004d/pwm1=89 13-004d/pwm2=89 13-004d/pwm3=89 13-004d/pwm4=89 13-004d/pwm5=89
MINSTOP=13-002e/pwm1=89 13-002e/pwm2=89 13-002e/pwm3=89 13-002e/pwm4=89 13-002e/pwm5=89 13-004d/pwm1=89 13-004d/pwm2=89 13-004d/pwm3=89 13-004d/pwm4=89 13-004d/pwm5=89
MINPWM=13-002e/pwm1=89 13-002e/pwm2=89 13-002e/pwm3=89 13-002e/pwm4=89 13-002e/pwm5=89 13-004d/pwm1=89 13-004d/pwm2=89 13-004d/pwm3=89 13-004d/pwm4=89 13-004d/pwm5=89
MAXPWM=13-002e/pwm1=255 13-002e/pwm2=255 13-002e/pwm3=255 13-002e/pwm4=255 13-002e/pwm5=255 13-004d/pwm1=255 13-004d/pwm2=255 13-004d/pwm3=255 13-004d/pwm4=255 13-004d/pwm5=255
THYST=13-002e/pwm1=3 13-002e/pwm2=3 13-002e/pwm3=3 13-002e/pwm4=3 13-002e/pwm5=3 13-004d/pwm1=3 13-004d/pwm2=3 13-004d/pwm3=3 13-004d/pwm4=3 13-004d/pwm5=3
MAXTEMPCRIT=/sys/bus/i2c/devices/7-004a/hwmon/hwmon*/temp1_input=65 /sys/bus/i2c/devices/14-0048/hwmon/hwmon*/temp1_input=75
MAXTEMPTYPE=/sys/bus/i2c/devices/7-004a/hwmon/hwmon*/temp1_input=ASIC /sys/bus/i2c/devices/14-0048/hwmon/hwmon*/temp1_input=CPU
13 changes: 13 additions & 0 deletions device/celestica/x86_64-cel_seastone-r0/fancontrol-F2B
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Configuration file generated by pwmconfig, changes will be lost
INTERVAL=2
FCTEMPS=13-002e/pwm1=/sys/bus/i2c/devices/5-0048/hwmon/hwmon*/temp1_input 13-002e/pwm2=/sys/bus/i2c/devices/5-0048/hwmon/hwmon*/temp1_input 13-002e/pwm3=/sys/bus/i2c/devices/5-0048/hwmon/hwmon*/temp1_input 13-002e/pwm4=/sys/bus/i2c/devices/5-0048/hwmon/hwmon*/temp1_input 13-002e/pwm5=/sys/bus/i2c/devices/5-0048/hwmon/hwmon*/temp1_input 13-004d/pwm1=/sys/bus/i2c/devices/5-0048/hwmon/hwmon*/temp1_input 13-004d/pwm2=/sys/bus/i2c/devices/5-0048/hwmon/hwmon*/temp1_input 13-004d/pwm3=/sys/bus/i2c/devices/5-0048/hwmon/hwmon*/temp1_input 13-004d/pwm4=/sys/bus/i2c/devices/5-0048/hwmon/hwmon*/temp1_input 13-004d/pwm5=/sys/bus/i2c/devices/5-0048/hwmon/hwmon*/temp1_input
FCFANS=13-004d/pwm5=13-004d/fan5_input 13-004d/pwm4=13-004d/fan4_input 13-004d/pwm3=13-004d/fan3_input 13-004d/pwm2=13-004d/fan2_input 13-004d/pwm1=13-004d/fan1_input 13-002e/pwm5=13-002e/fan5_input 13-002e/pwm4=13-002e/fan4_input 13-002e/pwm3=13-002e/fan3_input 13-002e/pwm2=13-002e/fan2_input 13-002e/pwm1=13-002e/fan1_input
MINTEMP=13-002e/pwm1=26 13-002e/pwm2=26 13-002e/pwm3=26 13-002e/pwm4=26 13-002e/pwm5=26 13-004d/pwm1=26 13-004d/pwm2=26 13-004d/pwm3=26 13-004d/pwm4=26 13-004d/pwm5=26
MAXTEMP=13-002e/pwm1=45 13-002e/pwm2=45 13-002e/pwm3=45 13-002e/pwm4=45 13-002e/pwm5=45 13-004d/pwm1=45 13-004d/pwm2=45 13-004d/pwm3=45 13-004d/pwm4=45 13-004d/pwm5=45
MINSTART=13-002e/pwm1=89 13-002e/pwm2=89 13-002e/pwm3=89 13-002e/pwm4=89 13-002e/pwm5=89 13-004d/pwm1=89 13-004d/pwm2=89 13-004d/pwm3=89 13-004d/pwm4=89 13-004d/pwm5=89
MINSTOP=13-002e/pwm1=89 13-002e/pwm2=89 13-002e/pwm3=89 13-002e/pwm4=89 13-002e/pwm5=89 13-004d/pwm1=89 13-004d/pwm2=89 13-004d/pwm3=89 13-004d/pwm4=89 13-004d/pwm5=89
MINPWM=13-002e/pwm1=89 13-002e/pwm2=89 13-002e/pwm3=89 13-002e/pwm4=89 13-002e/pwm5=89 13-004d/pwm1=89 13-004d/pwm2=89 13-004d/pwm3=89 13-004d/pwm4=89 13-004d/pwm5=89
MAXPWM=13-002e/pwm1=255 13-002e/pwm2=255 13-002e/pwm3=255 13-002e/pwm4=255 13-002e/pwm5=255 13-004d/pwm1=255 13-004d/pwm2=255 13-004d/pwm3=255 13-004d/pwm4=255 13-004d/pwm5=255
THYST=13-002e/pwm1=3 13-002e/pwm2=3 13-002e/pwm3=3 13-002e/pwm4=3 13-002e/pwm5=3 13-004d/pwm1=3 13-004d/pwm2=3 13-004d/pwm3=3 13-004d/pwm4=3 13-004d/pwm5=3
MAXTEMPCRIT=/sys/bus/i2c/devices/7-004a/hwmon/hwmon*/temp1_input=75 /sys/bus/i2c/devices/14-0048/hwmon/hwmon*/temp1_input=75
MAXTEMPTYPE=/sys/bus/i2c/devices/7-004a/hwmon/hwmon*/temp1_input=ASIC /sys/bus/i2c/devices/14-0048/hwmon/hwmon*/temp1_input=CPU
1 change: 1 addition & 0 deletions device/celestica/x86_64-cel_seastone-r0/installer.conf
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
CONSOLE_PORT=0x3f8
CONSOLE_DEV=0
ONIE_PLATFORM_EXTRA_CMDLINE_LINUX="module_blacklist=gpio_ich"
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
dx010/scripts/dx010_check_qsfp.sh usr/local/bin
dx010/cfg/dx010-modules.conf etc/modules-load.d
dx010/systemd/platform-modules-dx010.service lib/systemd/system
dx010/scripts/fancontrol.sh etc/init.d
dx010/scripts/fancontrol.service lib/systemd/system
services/fancontrol/fancontrol usr/local/bin
dx010/modules/sonic_platform-1.0-py2-none-any.whl usr/share/sonic/device/x86_64-cel_seastone-r0
services/platform_api/platform_api_mgnt.sh usr/local/bin
services/platform_api/platform_api_mgnt.sh usr/local/bin
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,7 @@ depmod -a
systemctl enable platform-modules-dx010.service
systemctl start platform-modules-dx010.service

systemctl start platform-modules-dx010.service
systemctl start fancontrol.service

/usr/local/bin/platform_api_mgnt.sh install
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
haliburton/cfg/haliburton-modules.conf etc/modules-load.d
haliburton/systemd/platform-modules-haliburton.service lib/systemd/system
haliburton/scripts/fancontrol.sh etc/init.d
haliburton/scripts/fancontrol.service lib/systemd/system
services/fancontrol/fancontrol usr/local/bin
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
depmod -a
systemctl enable platform-modules-haliburton.service
systemctl enable fancontrol.service

systemctl start platform-modules-haliburton.service
systemctl start fancontrol.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[Unit]
Description=fan speed regulator
After=platform-modules-dx010.service
Before=pmon.service

[Service]
ExecStart=-/etc/init.d/fancontrol.sh start
ExecStop=-/etc/init.d/fancontrol.sh stop
RemainAfterExit=yes

[Install]
WantedBy=multi-user.target
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
#! /bin/sh

### BEGIN INIT INFO
# Provides: fancontrol
# Required-Start: $remote_fs
# Required-Stop: $remote_fs
# Default-Start: 2 3 4 5
# Default-Stop:
# Short-Description: fancontrol
# Description: fan speed regulator
### END INIT INFO

. /lib/lsb/init-functions

[ -f /etc/default/rcS ] && . /etc/default/rcS
PATH=/bin:/usr/bin:/sbin:/usr/sbin:/usr/local/bin
DAEMON=/usr/local/bin/fancontrol
DESC="fan speed regulator"
NAME="fancontrol"
PIDFILE=/var/run/fancontrol.pid
MAIN_CONF=/usr/share/sonic/device/x86_64-cel_seastone-r0/fancontrol
DEVPATH=/sys/devices/pci0000:00/0000:00:13.0/i2c-*/i2c-13/13-002e
GPIO_DIR=/sys/class/gpio
BASE_GPIO=$(find $GPIO_DIR | grep gpiochip | grep -o '[[:digit:]]*')
DIRGPIO_START=15

test -x $DAEMON || exit 0

for i in 1 2 3 4 5; do
FANFAULT=$(cat ${DEVPATH}/fan${i}_fault)
[ $FANFAULT = 1 ] && continue
FANDIR_GPIO_NUMBER=$((DIRGPIO_START + BASE_GPIO))
FANDIR_VALUE=$(cat ${GPIO_DIR}/gpio${FANDIR_GPIO_NUMBER}/value)
DIRGPIO_START=$((DIRGPIO_START + 1))
FANDIR=$([ $FANDIR_VALUE = 1 ] && echo "B2F" || echo "F2B")
done
CONF=${MAIN_CONF}-${FANDIR}

case "$1" in
start)
if [ -f $CONF ]; then
if $DAEMON --check $CONF 1>/dev/null 2>/dev/null; then
log_daemon_msg "Starting $DESC" "$NAME\n"
start-stop-daemon --start --quiet --pidfile $PIDFILE --startas $DAEMON $CONF
log_end_msg $?
else
log_failure_msg "Not starting fancontrol, broken configuration file; please re-run pwmconfig."
fi
else
if [ "$VERBOSE" != no ]; then
log_warning_msg "Not starting fancontrol; run pwmconfig first."
fi
fi
;;
stop)
log_daemon_msg "Stopping $DESC" "$NAME"
start-stop-daemon --stop --quiet --pidfile $PIDFILE --oknodo --startas $DAEMON $CONF
rm -f $PIDFILE
log_end_msg $?
;;
restart)
$0 stop
sleep 3
$0 start
;;
force-reload)
if start-stop-daemon --stop --test --quiet --pidfile $PIDFILE --startas $DAEMON $CONF; then
$0 restart
fi
;;
status)
status_of_proc $DAEMON $NAME $CONF && exit 0 || exit $?
;;
*)
log_success_msg "Usage: /etc/init.d/fancontrol {start|stop|restart|force-reload|status}"
exit 1
;;
esac

exit 0
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[Unit]
Description=fan speed regulator
After=platform-modules-haliburton.service
Before=pmon.service

[Service]
ExecStart=-/etc/init.d/fancontrol.sh start
ExecStop=-/etc/init.d/fancontrol.sh stop
RemainAfterExit=yes

[Install]
WantedBy=multi-user.target
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
#! /bin/sh

### BEGIN INIT INFO
# Provides: fancontrol
# Required-Start: $remote_fs
# Required-Stop: $remote_fs
# Default-Start: 2 3 4 5
# Default-Stop:
# Short-Description: fancontrol
# Description: fan speed regulator
### END INIT INFO

. /lib/lsb/init-functions

[ -f /etc/default/rcS ] && . /etc/default/rcS
PATH=/bin:/usr/bin:/sbin:/usr/sbin:/usr/local/bin
DAEMON=/usr/local/bin/fancontrol
DESC="fan speed regulator"
NAME="fancontrol"
PIDFILE=/var/run/fancontrol.pid
PLATFORMPATH=/sys/devices/platform/e1031.smc
MAIN_CONF=/usr/share/sonic/device/x86_64-cel_e1031-r0/fancontrol
DEVPATH=/sys/devices/pci0000:00/0000:00:13.0/i2c-0/i2c-8/i2c-23/23-004d

test -x $DAEMON || exit 0

for i in 1 2 3; do
j=$i
[ $i -eq 3 ] && j=4
FANFAULT=$(cat ${DEVPATH}/fan${j}_fault)
[ $FANFAULT = 1 ] && continue
FANDIR=$(cat ${PLATFORMPATH}/fan${i}_dir)
done
CONF=${MAIN_CONF}-${FANDIR}

case "$1" in
start)
if [ -f $CONF ]; then
if $DAEMON --check $CONF 1>/dev/null 2>/dev/null; then
log_daemon_msg "Starting $DESC" "$NAME\n"
start-stop-daemon --start --quiet --pidfile $PIDFILE --startas $DAEMON $CONF
log_end_msg $?
else
log_failure_msg "Not starting fancontrol, broken configuration file; please re-run pwmconfig."
fi
else
if [ "$VERBOSE" != no ]; then
log_warning_msg "Not starting fancontrol; run pwmconfig first."
fi
fi
;;
stop)
log_daemon_msg "Stopping $DESC" "$NAME"
start-stop-daemon --stop --quiet --pidfile $PIDFILE --oknodo --startas $DAEMON $CONF
rm -f $PIDFILE
log_end_msg $?
;;
restart)
$0 stop
sleep 3
$0 start
;;
force-reload)
if start-stop-daemon --stop --test --quiet --pidfile $PIDFILE --startas $DAEMON $CONF; then
$0 restart
fi
;;
status)
status_of_proc $DAEMON $NAME $CONF && exit 0 || exit $?
;;
*)
log_success_msg "Usage: /etc/init.d/fancontrol {start|stop|restart|force-reload|status}"
exit 1
;;
esac

exit 0
Loading

0 comments on commit c9d86f0

Please sign in to comment.