blob: fdfc8427c56687b23ce6ad90f62c666f70e45bb4 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
#!/bin/sh
. /lib/functions.sh
config_load mtkhnat
config_get enable global enable 0
[ "${enable}" -eq 1 ] || {
echo 0 ${sch_upstream} > /sys/kernel/debug/hnat/scheduler0
echo 0 ${sch_downstream} > /sys/kernel/debug/hnat/scheduler1
rmmod mtkhnat
exit 0
}
insmod mtkhnat
sleep 1
config_get sch_upstream global upstream 100000
config_get sch_downstream global downstream 100000
echo 1 ${sch_upstream} > /sys/kernel/debug/hnat/scheduler0
echo 1 ${sch_downstream} > /sys/kernel/debug/hnat/scheduler1
setup_queue() {
local queue_id queue_scheduler queue_minebl queue_maxebl queue_minrate queue_maxrate queue_resv minrate maxrate queue_weight
config_get queue_id $1 id 0
config_get queue_minrate $1 minrate 0
config_get queue_maxrate $1 maxrate 0
config_get queue_resv $1 resv 22
config_get queue_weight $1 weight 7
[ "${queue_id}" -gt 7 ] && return 0
queue_minebl=1
queue_maxebl=1
queue_scheduler=0
[ "${queue_minrate}" -eq 0 ] && queue_minebl=0
[ "${queue_maxrate}" -eq 0 ] && queue_maxebl=0
minrate=$((sch_upstream * $queue_minrate))
minrate=$((minrate / 100))
maxrate=$((sch_upstream * $queue_maxrate))
maxrate=$((maxrate / 100))
echo 0 ${queue_minebl} ${minrate} ${queue_maxebl} ${maxrate} ${queue_weight} ${queue_resv} > /sys/kernel/debug/hnat/queue${queue_id}
queue_id=$((queue_id + 8))
minrate=$((sch_downstream * $queue_minrate))
minrate=$((minrate / 100))
maxrate=$((sch_downstream * $queue_maxrate))
maxrate=$((maxrate / 100))
echo 1 ${queue_minebl} ${minrate} ${queue_maxebl} ${maxrate} ${queue_weight} ${queue_resv} > /sys/kernel/debug/hnat/queue${queue_id}
}
config_foreach setup_scheduler scheduler
config_foreach setup_queue queue
|