Linux 5.6.13
[linux/fpc-iii.git] / samples / mic / mpssd / mpss
blob248ac7313c714d7acb29ceaaadd8fc8ee484e85e
1 #!/bin/bash
2 # SPDX-License-Identifier: GPL-2.0-only
3 # Intel MIC Platform Software Stack (MPSS)
5 # Copyright(c) 2013 Intel Corporation.
7 # Intel MIC User Space Tools.
9 # mpss Start mpssd.
11 # chkconfig: 2345 95 05
12 # description: start MPSS stack processing.
14 ### BEGIN INIT INFO
15 # Provides: mpss
16 # Required-Start:
17 # Required-Stop:
18 # Short-Description: MPSS stack control
19 # Description: MPSS stack control
20 ### END INIT INFO
22 # Source function library.
23 . /etc/init.d/functions
25 exec=/usr/sbin/mpssd
26 sysfs="/sys/class/mic"
27 mic_modules="mic_host mic_x100_dma scif vop"
29 start()
31 [ -x $exec ] || exit 5
33 if [ "`ps -e | awk '{print $4}' | grep mpssd | head -1`" = "mpssd" ]; then
34 echo -e $"MPSSD already running! "
35 success
36 echo
37 return 0
40 echo -e $"Starting MPSS Stack"
41 echo -e $"Loading MIC drivers:" $mic_modules
43 modprobe -a $mic_modules
44 RETVAL=$?
45 if [ $RETVAL -ne 0 ]; then
46 failure
47 echo
48 return $RETVAL
51 # Start the daemon
52 echo -n $"Starting MPSSD "
53 $exec
54 RETVAL=$?
55 if [ $RETVAL -ne 0 ]; then
56 failure
57 echo
58 return $RETVAL
60 success
61 echo
63 sleep 5
65 # Boot the cards
66 micctrl -b
68 # Wait till ping works
69 for f in $sysfs/*
71 count=100
72 ipaddr=`cat $f/cmdline`
73 ipaddr=${ipaddr#*address,}
74 ipaddr=`echo $ipaddr | cut -d, -f1 | cut -d\; -f1`
75 while [ $count -ge 0 ]
77 echo -e "Pinging "`basename $f`" "
78 ping -c 1 $ipaddr &> /dev/null
79 RETVAL=$?
80 if [ $RETVAL -eq 0 ]; then
81 success
82 break
84 sleep 1
85 count=`expr $count - 1`
86 done
87 [ $RETVAL -ne 0 ] && failure || success
88 echo
89 done
90 return $RETVAL
93 stop()
95 echo -e $"Shutting down MPSS Stack: "
97 # Bail out if module is unloaded
98 if [ ! -d "$sysfs" ]; then
99 echo -n $"Module unloaded "
100 success
101 echo
102 return 0
105 # Shut down the cards.
106 micctrl -S
108 # Wait for the cards to go offline
109 for f in $sysfs/*
111 while [ "`cat $f/state`" != "ready" ]
113 sleep 1
114 echo -e "Waiting for "`basename $f`" to become ready"
115 done
116 done
118 # Display the status of the cards
119 micctrl -s
121 # Kill MPSSD now
122 echo -n $"Killing MPSSD"
123 killall -9 mpssd 2>/dev/null
124 RETVAL=$?
125 [ $RETVAL -ne 0 ] && failure || success
126 echo
127 return $RETVAL
130 restart()
132 stop
133 sleep 5
134 start
137 status()
139 micctrl -s
140 if [ "`ps -e | awk '{print $4}' | grep mpssd | head -n 1`" = "mpssd" ]; then
141 echo "mpssd is running"
142 else
143 echo "mpssd is stopped"
145 return 0
148 unload()
150 if [ ! -d "$sysfs" ]; then
151 echo -n $"No MIC_HOST Module: "
152 success
153 echo
154 return
157 stop
159 sleep 5
160 echo -n $"Removing MIC drivers:" $mic_modules
161 modprobe -r $mic_modules
162 RETVAL=$?
163 [ $RETVAL -ne 0 ] && failure || success
164 echo
165 return $RETVAL
168 case $1 in
169 start)
170 start
172 stop)
173 stop
175 restart)
176 restart
178 status)
179 status
181 unload)
182 unload
185 echo $"Usage: $0 {start|stop|restart|status|unload}"
186 exit 2
187 esac
189 exit $?