[opennsl init] refactoring opennsl init script

- Move driver loading unloading code to functions.
- Change tabs to white spaces

Signed-off-by: Ying Xie <ying.xie@microsoft.com>
This commit is contained in:
Ying Xie 2018-08-31 15:54:27 +00:00
parent 5b3e8974cd
commit a11c28de46

View File

@ -12,47 +12,61 @@
# Short-Description: Load OpenNSL kernel modules # Short-Description: Load OpenNSL kernel modules
### END INIT INFO ### END INIT INFO
function create_devices()
{
rm -f /dev/linux-knet-cb
rm -f /dev/linux-bcm-knet
rm -f /dev/linux-bcm-bde
rm -f /dev/linux-kernel-bde
mknod /dev/linux-knet-cb c 121 0
mknod /dev/linux-bcm-knet c 122 0
mknod /dev/linux-bcm-bde c 126 0
mknod /dev/linux-kernel-bde c 127 0
}
function load_kernel_modules()
{
modprobe linux-kernel-bde dmasize=32M maxpayload=128
modprobe linux-user-bde
modprobe linux-bcm-knet use_rx_skb=1 rx_buffer_size=9238
modprobe linux-knet-cb
}
function remove_kernel_modules()
{
rmmod linux-knet-cb
rmmod linux-bcm-knet
rmmod linux-user-bde
rmmod linux-kernel-bde
}
case "$1" in case "$1" in
start) start)
echo -n "Load OpenNSL kernel modules... " echo -n "Load OpenNSL kernel modules... "
rm -f /dev/linux-knet-cb create_devices
rm -f /dev/linux-bcm-knet load_kernel_modules
rm -f /dev/linux-bcm-bde
rm -f /dev/linux-kernel-bde
mknod /dev/linux-knet-cb c 121 0 echo "done."
mknod /dev/linux-bcm-knet c 122 0 ;;
mknod /dev/linux-bcm-bde c 126 0
mknod /dev/linux-kernel-bde c 127 0
modprobe linux-kernel-bde dmasize=32M maxpayload=128
modprobe linux-user-bde
modprobe linux-bcm-knet use_rx_skb=1 rx_buffer_size=9238
modprobe linux-knet-cb
echo "done."
;;
stop) stop)
echo -n "Unload OpenNSL kernel modules... " echo -n "Unload OpenNSL kernel modules... "
rmmod linux-knet-cb remove_kernel_modules
rmmod linux-bcm-knet
rmmod linux-user-bde
rmmod linux-kernel-bde
echo "done." echo "done."
;; ;;
force-reload|restart) force-reload|restart)
echo "Not supported" echo "Not supported"
;; ;;
*) *)
echo "Usage: /etc/init.d/opennsl-modules-4.9.0-7-amd64.init {start|stop}" echo "Usage: /etc/init.d/opennsl-modules-4.9.0-7-amd64.init {start|stop}"
exit 1 exit 1
;; ;;
esac esac
exit 0 exit 0