diff --git a/qosmngr/files/common/etc/uci-defaults/60-qos_config_generate b/qosmngr/files/common/etc/uci-defaults/60-qos_config_generate index 5e7d60977..728e943a8 100644 --- a/qosmngr/files/common/etc/uci-defaults/60-qos_config_generate +++ b/qosmngr/files/common/etc/uci-defaults/60-qos_config_generate @@ -1,9 +1,10 @@ #!/bin/sh . /lib/qos/qos.sh +. /usr/share/libubox/jshn.sh -ethwan="$(db -q get hw.board.ethernetWanPort)" +cpu_model="$(cat /proc/socinfo | grep 'SoC Name' | cut -d':' -f2)" queue_num=8 populate_no_of_queue(){ @@ -17,28 +18,13 @@ populate_no_of_queue(){ } generate_queue(){ - section="$1" + local ifname="$1" + local no_of_q="$2" - 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 i=0 local total_q=$((${no_of_q##* } + 1)) for i in $no_of_q; do - order=$((total_q - i)) + local order=$((total_q - i)) uci add qos queue uci rename qos.@queue[-1]="q_${i}_${ifname}" uci set qos.@queue[-1].enable="1" @@ -53,8 +39,31 @@ generate_queue(){ uci commit qos } +generate_wan_queues() { + local ifname="$1" + local no_of_q="0 1 2 3 4 5 6 7" + + generate_queue "$ifname" "$no_of_q" +} + +generate_lan_queues() { + local ifname="$1" + local no_of_q="0 1 2 3 4 5 6 7" + + queue_num=$(qosmngr -q $ifname) + + populate_no_of_queue $queue_num + + if [ $queue_num -eq 4 ]; then + no_of_q="0 1 2 3" + fi + + generate_queue "$ifname" "$no_of_q" +} + 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 @@ -62,7 +71,16 @@ if [ -s "/etc/config/qos" ]; then fi touch /etc/config/qos -# generate qos queue config -config_load ports -config_foreach generate_queue ethport +lan_ports="" +wan_port="" +json_init +json_load_file /etc/board.json +json_select network +json_select lan +json_for_each_item "generate_lan_queues" "ports" + +json_select .. +json_select wan +json_get_var wan_port device +generate_wan_queues "$wan_port"