Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs
[linux/fpc-iii.git] / Documentation / mic / mpssd / mpss
blob3136c68dad0b7862ca0f994f0aee50cb70dcba21
1 #!/bin/bash
2 # Intel MIC Platform Software Stack (MPSS)
4 # Copyright(c) 2013 Intel Corporation.
6 # This program is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License, version 2, as
8 # published by the Free Software Foundation.
10 # This program is distributed in the hope that it will be useful, but
11 # WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 # General Public License for more details.
15 # The full GNU General Public License is included in this distribution in
16 # the file called "COPYING".
18 # Intel MIC User Space Tools.
20 # mpss Start mpssd.
22 # chkconfig: 2345 95 05
23 # description: start MPSS stack processing.
25 ### BEGIN INIT INFO
26 # Provides: mpss
27 # Required-Start:
28 # Required-Stop:
29 # Short-Description: MPSS stack control
30 # Description: MPSS stack control
31 ### END INIT INFO
33 # Source function library.
34 . /etc/init.d/functions
36 exec=/usr/sbin/mpssd
37 sysfs="/sys/class/mic"
39 start()
41 [ -x $exec ] || exit 5
43 if [ "`ps -e | awk '{print $4}' | grep mpssd | head -1`" = "mpssd" ]; then
44 echo -e $"MPSSD already running! "
45 success
46 echo
47 return 0
50 echo -e $"Starting MPSS Stack"
51 echo -e $"Loading MIC_HOST Module"
53 # Ensure the driver is loaded
54 if [ ! -d "$sysfs" ]; then
55 modprobe mic_host
56 RETVAL=$?
57 if [ $RETVAL -ne 0 ]; then
58 failure
59 echo
60 return $RETVAL
64 # Start the daemon
65 echo -n $"Starting MPSSD "
66 $exec
67 RETVAL=$?
68 if [ $RETVAL -ne 0 ]; then
69 failure
70 echo
71 return $RETVAL
73 success
74 echo
76 sleep 5
78 # Boot the cards
79 micctrl -b
81 # Wait till ping works
82 for f in $sysfs/*
84 count=100
85 ipaddr=`cat $f/cmdline`
86 ipaddr=${ipaddr#*address,}
87 ipaddr=`echo $ipaddr | cut -d, -f1 | cut -d\; -f1`
88 while [ $count -ge 0 ]
90 echo -e "Pinging "`basename $f`" "
91 ping -c 1 $ipaddr &> /dev/null
92 RETVAL=$?
93 if [ $RETVAL -eq 0 ]; then
94 success
95 break
97 sleep 1
98 count=`expr $count - 1`
99 done
100 [ $RETVAL -ne 0 ] && failure || success
101 echo
102 done
103 return $RETVAL
106 stop()
108 echo -e $"Shutting down MPSS Stack: "
110 # Bail out if module is unloaded
111 if [ ! -d "$sysfs" ]; then
112 echo -n $"Module unloaded "
113 success
114 echo
115 return 0
118 # Shut down the cards.
119 micctrl -S
121 # Wait for the cards to go offline
122 for f in $sysfs/*
124 while [ "`cat $f/state`" != "offline" ]
126 sleep 1
127 echo -e "Waiting for "`basename $f`" to go offline"
128 done
129 done
131 # Display the status of the cards
132 micctrl -s
134 # Kill MPSSD now
135 echo -n $"Killing MPSSD"
136 killall -9 mpssd 2>/dev/null
137 RETVAL=$?
138 [ $RETVAL -ne 0 ] && failure || success
139 echo
140 return $RETVAL
143 restart()
145 stop
146 sleep 5
147 start
150 status()
152 micctrl -s
153 if [ "`ps -e | awk '{print $4}' | grep mpssd | head -n 1`" = "mpssd" ]; then
154 echo "mpssd is running"
155 else
156 echo "mpssd is stopped"
158 return 0
161 unload()
163 if [ ! -d "$sysfs" ]; then
164 echo -n $"No MIC_HOST Module: "
165 success
166 echo
167 return
170 stop
172 sleep 5
173 echo -n $"Removing MIC_HOST Module: "
174 modprobe -r mic_host
175 RETVAL=$?
176 [ $RETVAL -ne 0 ] && failure || success
177 echo
178 return $RETVAL
181 case $1 in
182 start)
183 start
185 stop)
186 stop
188 restart)
189 restart
191 status)
192 status
194 unload)
195 unload
198 echo $"Usage: $0 {start|stop|restart|status|unload}"
199 exit 2
200 esac
202 exit $?