mpss 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  1. #!/bin/bash
  2. # Intel MIC Platform Software Stack (MPSS)
  3. #
  4. # Copyright(c) 2013 Intel Corporation.
  5. #
  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.
  9. #
  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.
  14. #
  15. # The full GNU General Public License is included in this distribution in
  16. # the file called "COPYING".
  17. #
  18. # Intel MIC User Space Tools.
  19. #
  20. # mpss Start mpssd.
  21. #
  22. # chkconfig: 2345 95 05
  23. # description: start MPSS stack processing.
  24. #
  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
  32. # Source function library.
  33. . /etc/init.d/functions
  34. exec=/usr/sbin/mpssd
  35. sysfs="/sys/class/mic"
  36. mic_modules="mic_host mic_x100_dma scif vop"
  37. start()
  38. {
  39. [ -x $exec ] || exit 5
  40. if [ "`ps -e | awk '{print $4}' | grep mpssd | head -1`" = "mpssd" ]; then
  41. echo -e $"MPSSD already running! "
  42. success
  43. echo
  44. return 0
  45. fi
  46. echo -e $"Starting MPSS Stack"
  47. echo -e $"Loading MIC drivers:" $mic_modules
  48. modprobe -a $mic_modules
  49. RETVAL=$?
  50. if [ $RETVAL -ne 0 ]; then
  51. failure
  52. echo
  53. return $RETVAL
  54. fi
  55. # Start the daemon
  56. echo -n $"Starting MPSSD "
  57. $exec
  58. RETVAL=$?
  59. if [ $RETVAL -ne 0 ]; then
  60. failure
  61. echo
  62. return $RETVAL
  63. fi
  64. success
  65. echo
  66. sleep 5
  67. # Boot the cards
  68. micctrl -b
  69. # Wait till ping works
  70. for f in $sysfs/*
  71. do
  72. count=100
  73. ipaddr=`cat $f/cmdline`
  74. ipaddr=${ipaddr#*address,}
  75. ipaddr=`echo $ipaddr | cut -d, -f1 | cut -d\; -f1`
  76. while [ $count -ge 0 ]
  77. do
  78. echo -e "Pinging "`basename $f`" "
  79. ping -c 1 $ipaddr &> /dev/null
  80. RETVAL=$?
  81. if [ $RETVAL -eq 0 ]; then
  82. success
  83. break
  84. fi
  85. sleep 1
  86. count=`expr $count - 1`
  87. done
  88. [ $RETVAL -ne 0 ] && failure || success
  89. echo
  90. done
  91. return $RETVAL
  92. }
  93. stop()
  94. {
  95. echo -e $"Shutting down MPSS Stack: "
  96. # Bail out if module is unloaded
  97. if [ ! -d "$sysfs" ]; then
  98. echo -n $"Module unloaded "
  99. success
  100. echo
  101. return 0
  102. fi
  103. # Shut down the cards.
  104. micctrl -S
  105. # Wait for the cards to go offline
  106. for f in $sysfs/*
  107. do
  108. while [ "`cat $f/state`" != "ready" ]
  109. do
  110. sleep 1
  111. echo -e "Waiting for "`basename $f`" to become ready"
  112. done
  113. done
  114. # Display the status of the cards
  115. micctrl -s
  116. # Kill MPSSD now
  117. echo -n $"Killing MPSSD"
  118. killall -9 mpssd 2>/dev/null
  119. RETVAL=$?
  120. [ $RETVAL -ne 0 ] && failure || success
  121. echo
  122. return $RETVAL
  123. }
  124. restart()
  125. {
  126. stop
  127. sleep 5
  128. start
  129. }
  130. status()
  131. {
  132. micctrl -s
  133. if [ "`ps -e | awk '{print $4}' | grep mpssd | head -n 1`" = "mpssd" ]; then
  134. echo "mpssd is running"
  135. else
  136. echo "mpssd is stopped"
  137. fi
  138. return 0
  139. }
  140. unload()
  141. {
  142. if [ ! -d "$sysfs" ]; then
  143. echo -n $"No MIC_HOST Module: "
  144. success
  145. echo
  146. return
  147. fi
  148. stop
  149. sleep 5
  150. echo -n $"Removing MIC drivers:" $mic_modules
  151. modprobe -r $mic_modules
  152. RETVAL=$?
  153. [ $RETVAL -ne 0 ] && failure || success
  154. echo
  155. return $RETVAL
  156. }
  157. case $1 in
  158. start)
  159. start
  160. ;;
  161. stop)
  162. stop
  163. ;;
  164. restart)
  165. restart
  166. ;;
  167. status)
  168. status
  169. ;;
  170. unload)
  171. unload
  172. ;;
  173. *)
  174. echo $"Usage: $0 {start|stop|restart|status|unload}"
  175. exit 2
  176. esac
  177. exit $?