aboutsummaryrefslogtreecommitdiffstats
path: root/target/linux/mediatek/base-files
diff options
context:
space:
mode:
Diffstat (limited to 'target/linux/mediatek/base-files')
-rwxr-xr-xtarget/linux/mediatek/base-files/etc/board.d/02_network1
-rw-r--r--target/linux/mediatek/base-files/etc/config/mtkhnat60
-rwxr-xr-xtarget/linux/mediatek/base-files/etc/init.d/mtkhnat13
-rwxr-xr-xtarget/linux/mediatek/base-files/etc/uci-defaults/99-firewall9
-rwxr-xr-xtarget/linux/mediatek/base-files/etc/uci-defaults/99-net-ps16
-rw-r--r--target/linux/mediatek/base-files/lib/preinit/06_set_rps_sock_flow8
-rwxr-xr-xtarget/linux/mediatek/base-files/lib/upgrade/platform.sh1
-rwxr-xr-xtarget/linux/mediatek/base-files/sbin/mtkhnat64
8 files changed, 172 insertions, 0 deletions
diff --git a/target/linux/mediatek/base-files/etc/board.d/02_network b/target/linux/mediatek/base-files/etc/board.d/02_network
index 361771199f..e071ab27a0 100755
--- a/target/linux/mediatek/base-files/etc/board.d/02_network
+++ b/target/linux/mediatek/base-files/etc/board.d/02_network
@@ -9,6 +9,7 @@ mediatek_setup_interfaces()
local board="$1"
case $board in
+ 'bananapi,bpi-r2' | \
'mediatek,mt7623-rfb-emmc' | \
'mediatek,mt7623-rfb-nand-ephy')
ucidef_set_interface_lan "lan0 lan1 lan2 lan3"
diff --git a/target/linux/mediatek/base-files/etc/config/mtkhnat b/target/linux/mediatek/base-files/etc/config/mtkhnat
new file mode 100644
index 0000000000..a23bd1c22b
--- /dev/null
+++ b/target/linux/mediatek/base-files/etc/config/mtkhnat
@@ -0,0 +1,60 @@
+config global global
+ option enable 0
+ option upstream 1000000
+ option downstream 1000000
+
+config queue
+ option id 0
+ option minrate 10
+ option maxrate 50
+ option weight 7
+ option resv 32
+
+config queue
+ option id 1
+ option minrate 30
+ option maxrate 100
+ option weight 7
+ option resv 32
+
+config queue
+ option id 2
+ option minrate 30
+ option maxrate 100
+ option weight 7
+ option resv 32
+
+config queue
+ option id 3
+ option minrate 30
+ option maxrate 100
+ option weight 7
+ option resv 32
+
+config queue
+ option id 4
+ option minrate 25
+ option maxrate 100
+ option weight 7
+ option resv 32
+
+config queue
+ option id 5
+ option minrate 25
+ option maxrate 100
+ option weight 7
+ option resv 32
+
+config queue
+ option id 6
+ option minrate 25
+ option maxrate 100
+ option weight 7
+ option resv 32
+
+config queue
+ option id 7
+ option minrate 25
+ option maxrate 100
+ option weight 7
+ option resv 32
diff --git a/target/linux/mediatek/base-files/etc/init.d/mtkhnat b/target/linux/mediatek/base-files/etc/init.d/mtkhnat
new file mode 100755
index 0000000000..32011e73aa
--- /dev/null
+++ b/target/linux/mediatek/base-files/etc/init.d/mtkhnat
@@ -0,0 +1,13 @@
+#!/bin/sh /etc/rc.common
+
+START=90
+
+USE_PROCD=1
+NAME=mtkhnat
+PROG=/sbin/mtkhnat
+
+start_service() {
+ procd_open_instance
+ procd_set_param command "${PROG}"
+ procd_close_instance
+}
diff --git a/target/linux/mediatek/base-files/etc/uci-defaults/99-firewall b/target/linux/mediatek/base-files/etc/uci-defaults/99-firewall
new file mode 100755
index 0000000000..9a0dd9b5f0
--- /dev/null
+++ b/target/linux/mediatek/base-files/etc/uci-defaults/99-firewall
@@ -0,0 +1,9 @@
+echo "iptables -t mangle -A FORWARD -i br-lan -o eth1 -p tcp -m mark --mark 0/0x7 -j MARK --set-mark 4/0x7" >> /etc/firewall.user
+echo "iptables -t mangle -A FORWARD -i br-lan -o eth1 -p udp -m mark --mark 0/0x7 -j MARK --set-mark 5/0x7" >> /etc/firewall.user
+echo "iptables -t mangle -A FORWARD -i eth1 -o br-lan -p tcp -m mark --mark 0/0x7 -j MARK --set-mark 4/0x7" >> /etc/firewall.user
+echo "iptables -t mangle -A FORWARD -i eth1 -o br-lan -p udp -m mark --mark 0/0x7 -j MARK --set-mark 5/0x7" >> /etc/firewall.user
+
+echo "iptables -t mangle -A FORWARD -p udp -m mark --mark 0/0xf8 -j MARK --or-mark 0x60" >> /etc/firewall.user
+echo "iptables -t mangle -A FORWARD -p tcp -m mark --mark 0/0xf8 -j MARK --or-mark 0xc0" >> /etc/firewall.user
+
+exit 0
diff --git a/target/linux/mediatek/base-files/etc/uci-defaults/99-net-ps b/target/linux/mediatek/base-files/etc/uci-defaults/99-net-ps
new file mode 100755
index 0000000000..9267340317
--- /dev/null
+++ b/target/linux/mediatek/base-files/etc/uci-defaults/99-net-ps
@@ -0,0 +1,16 @@
+uci set network.globals.default_rps_val=14
+uci set network.globals.default_rps_flow_cnt=256
+uci set network.globals.default_xps_val=14
+uci set network.globals.default_ps=1
+uci set network.eth0=device
+uci set network.eth0.name=eth0
+uci set network.lan0=device
+uci set network.lan0.name=lan0
+uci set network.lan1=device
+uci set network.lan1.name=lan1
+uci set network.lan2=device
+uci set network.lan2.name=lan2
+uci set network.lan3=device
+uci set network.lan3.name=lan3
+uci commit
+exit 0
diff --git a/target/linux/mediatek/base-files/lib/preinit/06_set_rps_sock_flow b/target/linux/mediatek/base-files/lib/preinit/06_set_rps_sock_flow
new file mode 100644
index 0000000000..9a84ff4bf5
--- /dev/null
+++ b/target/linux/mediatek/base-files/lib/preinit/06_set_rps_sock_flow
@@ -0,0 +1,8 @@
+#!/bin/sh
+
+set_rps_sock_flow() {
+ echo 1024 > /proc/sys/net/core/rps_sock_flow_entries
+}
+
+boot_hook_add preinit_main set_rps_sock_flow
+
diff --git a/target/linux/mediatek/base-files/lib/upgrade/platform.sh b/target/linux/mediatek/base-files/lib/upgrade/platform.sh
index 7e936c4dad..7161a4b84e 100755
--- a/target/linux/mediatek/base-files/lib/upgrade/platform.sh
+++ b/target/linux/mediatek/base-files/lib/upgrade/platform.sh
@@ -25,6 +25,7 @@ platform_check_image() {
nand_do_platform_check $board $1
return $?
;;
+ bananapi,bpi-r2 |\
mediatek,mt7623-rfb-emmc)
local kernel_length=`(tar xf $tar_file sysupgrade-$board/kernel -O | wc -c) 2> /dev/null`
local rootfs_length=`(tar xf $tar_file sysupgrade-$board/root -O | wc -c) 2> /dev/null`
diff --git a/target/linux/mediatek/base-files/sbin/mtkhnat b/target/linux/mediatek/base-files/sbin/mtkhnat
new file mode 100755
index 0000000000..fdfc8427c5
--- /dev/null
+++ b/target/linux/mediatek/base-files/sbin/mtkhnat
@@ -0,0 +1,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