iopsys-feed/qosmngr/files/etc/uci-defaults/60-qos_queue_generate

55 lines
1.1 KiB
Bash

#!/bin/sh
. /lib/functions.sh
ethwan="$(db -q get hw.board.ethernetWanPort)"
cpu_model="$(grep Hardware /proc/cpuinfo | awk '{print$NF}')"
generate_queue(){
section="$1"
config_get ifname "$section" "ifname"
local is_lan=0
if [ "$ifname" != "$ethwan" ]; then
is_lan=1
fi
local no_of_q="0 1 2 3 4 5 6 7"
if [ $is_lan -eq 1 ]; then
case $cpu_model in
BCM968*) no_of_q="0 1 2 3" ;;
esac
fi
i=0
local total_q=${no_of_q##* }
for i in $no_of_q; do
order=$((total_q - i))
uci add qos queue
uci rename qos.@queue[-1]="q_${i}_${ifname}"
uci set qos.@queue[-1].enable="1"
uci set qos.@queue[-1].ifname="$ifname"
uci set qos.@queue[-1].precedence="$order"
uci set qos.@queue[-1].scheduling="SP"
uci set qos.@queue[-1].rate="0"
uci set qos.@queue[-1].burst_size="0"
uci set qos.@queue[-1].weight="1"
done
uci commit qos
}
if [ -s "/etc/config/qos" ]; then
if uci -q get qos.@queue[0] >/dev/null; then
# return if there is any valid content
exit
else
rm -f /etc/config/qos
fi
fi
touch /etc/config/qos
config_load ports
config_foreach generate_queue ethport