#!/bin/sh
exec >/dev/null 2>&1

start() {
	echo -n "Starting netmap: "

	lsmod | grep netmap >/dev/null 2>&1
	if [ $? -ne 0 ]; then
		cd $BIN_DIR

		# netmap_generic_mit controls mitigation of RX notifications for
		# the generic netmap adapter. (default: 100*1000 nano sec)
		modprobe netmap buf_num=9216 generic_mit=5000000
	fi

	echo "OK"
}

stop() {
	echo -n "Stopping netmap: "

	lsmod | grep netmap >/dev/null 2>&1
	if [ $? -eq 0 ]; then
		modprobe -r netmap
	fi

	echo "OK"
}

case "$1" in
	start)
		start
		;;
	stop)
		stop
		;;
	restart|reload)
		stop
		start
		;;
	*)
		echo "Usage: $0 {start|stop|restart}"
		exit 1
esac
