mirror of
https://dev.iopsys.eu/feed/iopsys.git
synced 2025-12-10 07:44:50 +01:00
68 lines
1.4 KiB
Bash
68 lines
1.4 KiB
Bash
#!/bin/sh
|
|
|
|
. /lib/qos/qos.sh
|
|
|
|
ethwan="$(db -q get hw.board.ethernetWanPort)"
|
|
|
|
queue_num=8
|
|
|
|
populate_no_of_queue(){
|
|
# writing no. of queue per port into file and read on classify generate
|
|
if [ ! -d "/tmp/qos" ]; then
|
|
mkdir -p "/tmp/qos"
|
|
fi
|
|
no_queue_file="/tmp/qos/no_queue_per_port"
|
|
touch "$no_queue_file"
|
|
echo $1 >"$no_queue_file"
|
|
}
|
|
|
|
generate_queue(){
|
|
section="$1"
|
|
|
|
config_get ifname "$section" "ifname"
|
|
|
|
local is_lan=0
|
|
queue_num=$(qosmngr -q $ifname)
|
|
|
|
if [ "$ifname" != "$ethwan" ]; then
|
|
is_lan=1
|
|
populate_no_of_queue $queue_num
|
|
fi
|
|
|
|
local no_of_q="0 1 2 3 4 5 6 7"
|
|
|
|
if [ $is_lan -eq 1 ] && [ $queue_num -eq 4 ]; then
|
|
no_of_q="0 1 2 3"
|
|
fi
|
|
|
|
i=0
|
|
local total_q=$((${no_of_q##* } + 1))
|
|
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=$(get_rate_per_queue)
|
|
uci set qos.@queue[-1].burst_size=$(get_burst_size_per_queue)
|
|
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
|
|
exit
|
|
else
|
|
rm -f /etc/config/qos
|
|
fi
|
|
fi
|
|
touch /etc/config/qos
|
|
|
|
# generate qos queue config
|
|
config_load ports
|
|
config_foreach generate_queue ethport
|
|
|