[][kernel][common][app][Add multiple QDMA TX queue scheduler support]
[Description]
Add multiple QDMA TX queue scheduler support.
If without this patch, mtkhant only configure two schedulers.
[Release-log]
N/A
Change-Id: Ib6173163a2a6e06305eb64b3948983995ebda0b8
Reviewed-on: https://gerrit.mediatek.inc/c/openwrt/feeds/mtk_openwrt_feeds/+/8203880
diff --git a/feed/mtkhnat_util/files/mtkhnat b/feed/mtkhnat_util/files/mtkhnat
index 53e444b..38d3fe2 100755
--- a/feed/mtkhnat_util/files/mtkhnat
+++ b/feed/mtkhnat_util/files/mtkhnat
@@ -6,9 +6,12 @@
config_get enable global enable 0
config_get hqos global hqos 0
config_get txq_num global txq_num 16
+config_get sch_num global sch_num 2
config_get scheduling global scheduling "wrr"
config_get sch0_bw global sch0_bw 100000
config_get sch1_bw global sch1_bw 100000
+config_get sch2_bw global sch2_bw 100000
+config_get sch3_bw global sch3_bw 100000
# disable bridge netfilter module to avoid high cpu usage
echo 0 > /proc/sys/net/bridge/bridge-nf-call-arptables
@@ -28,8 +31,12 @@
#if enable=0, disable qdma_sch & qdma_txq
[ "${enable}" -eq 1 ] || {
- echo 0 ${scheduling} ${sch0_bw} > /sys/kernel/debug/${module}/qdma_sch0
- echo 0 ${scheduling} ${sch1_bw} > /sys/kernel/debug/${module}/qdma_sch1
+ for i in $(seq 0 $((sch_num - 1)))
+ do
+ eval sch_bw='$sch'$i'_bw'
+ echo 0 ${scheduling} ${sch_bw} > /sys/kernel/debug/${module}/qdma_sch${i}
+ done
+
echo 0 0 0 0 0 0 4 > /sys/kernel/debug/${module}/qdma_txq0
for i in $(seq 1 $((txq_num - 1)))
do
@@ -44,35 +51,36 @@
#if hqos=0, disable qdma_sch & qdma_txq
[ "${hqos}" -eq 1 ] || {
- SOC=`cat /proc/device-tree/ethernet*/compatible | cut -c 10-15`
- DUAL_SCH=$(if [ $SOC = "mt7981" ]; then echo true; fi)
-
- echo 0 ${scheduling} ${sch0_bw} > /sys/kernel/debug/${module}/qdma_sch0
- echo 0 ${scheduling} ${sch1_bw} > /sys/kernel/debug/${module}/qdma_sch1
+ for i in $(seq 0 $((sch_num - 1)))
+ do
+ eval sch_bw='$sch'$i'_bw'
+ echo 0 ${scheduling} ${sch_bw} > /sys/kernel/debug/${module}/qdma_sch${i}
+ done
for i in $(seq 0 $((txq_num - 1)))
do
- if [ "${i}" -le $(((txq_num / 2) - 1)) ] || [ ! $DUAL_SCH ]; then
- echo 0 0 0 0 0 0 4 > /sys/kernel/debug/${module}/qdma_txq$i
- else
- echo 1 0 0 0 0 0 4 > /sys/kernel/debug/${module}/qdma_txq$i
- fi
+ current_sch=$((${i} / (txq_num / sch_num)))
+ echo ${current_sch} 0 0 0 0 0 4 > /sys/kernel/debug/${module}/qdma_txq$i
done
exit 0
}
-# enable qdma_sch0 and qdma_sch1
-echo 1 ${scheduling} ${sch0_bw} > /sys/kernel/debug/${module}/qdma_sch0
-echo 1 ${scheduling} ${sch1_bw} > /sys/kernel/debug/${module}/qdma_sch1
+# enable qdma_sch
+for i in $(seq 0 $((sch_num - 1)))
+do
+ eval sch_bw='$sch'$i'_bw'
+ echo 1 ${scheduling} ${sch_bw} > /sys/kernel/debug/${module}/qdma_sch${i}
+done
# enable bridge netfilter module to allow skb being marked
echo 1 > /proc/sys/net/bridge/bridge-nf-call-iptables
echo 1 > /proc/sys/net/bridge/bridge-nf-call-ip6tables
setup_queue() {
- local queue_id queue_scheduler queue_minebl queue_maxebl
+ local queue_id queue_minebl queue_maxebl
local queue_minrate queue_maxrate queue_resv minrate maxrate queue_weight
+ local current_sch
config_get queue_id $1 id 0
config_get queue_minrate $1 minrate 0
@@ -86,37 +94,24 @@
# start to set per queue config
queue_minebl=1
queue_maxebl=1
- queue_scheduler=0
# if min rate = 0, set min enable = 0
# if max rate = 0, set max enable = 0
[ "${queue_minrate}" -eq 0 ] && queue_minebl=0
[ "${queue_maxrate}" -eq 0 ] && queue_maxebl=0
- # calculate min rate according to sch0_bw
- minrate=$((sch0_bw * $queue_minrate))
- minrate=$((minrate / 100))
-
- # calculate max rate according to sch0_bw
- maxrate=$((sch0_bw * $queue_maxrate))
- maxrate=$((maxrate / 100))
-
- # set the queue of sch0 group(the lower half of total queues)
- [ "${queue_id}" -le $(((txq_num / 2) - 1)) ] && \
- echo 0 ${queue_minebl} ${minrate} ${queue_maxebl} ${maxrate} ${queue_weight} \
- ${queue_resv} > /sys/kernel/debug/${module}/qdma_txq${queue_id}
+ # get current scheduler id
+ current_sch=$((${queue_id} / (txq_num / sch_num)))
- # calculate min rate according to sch1_bw
- minrate=$((sch1_bw * $queue_minrate))
+ # calculate min rate according to schx_bw
+ minrate=$((sch${current_sch}_bw * $queue_minrate))
minrate=$((minrate / 100))
- # calculate max rate according to sch1_bw
- maxrate=$((sch1_bw * $queue_maxrate))
+ # calculate max rate according to schx_bw
+ maxrate=$((sch${current_sch}_bw * $queue_maxrate))
maxrate=$((maxrate / 100))
- # set the queue of sch1 group(the upper half of total queues)
- [ "${queue_id}" -gt $(((txq_num / 2) - 1)) ] && \
- echo 1 ${queue_minebl} ${minrate} ${queue_maxebl} ${maxrate} ${queue_weight} \
+ echo ${current_sch} ${queue_minebl} ${minrate} ${queue_maxebl} ${maxrate} ${queue_weight} \
${queue_resv} > /sys/kernel/debug/${module}/qdma_txq${queue_id}
}
diff --git a/feed/mtkhnat_util/files/mtkhnat.config b/feed/mtkhnat_util/files/mtkhnat.config
index f252a98..b5a29e4 100755
--- a/feed/mtkhnat_util/files/mtkhnat.config
+++ b/feed/mtkhnat_util/files/mtkhnat.config
@@ -1,23 +1,29 @@
####################################################################
# hqos: 1:ON, 0:OFF #
# txq_num: 16:default (only supports 64 queues for MT7622) #
+# sch_num: 2 or 4 (only supports 2 schedulers for MT7622) #
# scheduling: wrr: weighted round-robin, sp: strict priority #
# sch0_bw: sch0 bandwidth (unit:Kbps) #
# sch1_bw: sch1 bandwidth (unit:Kbps) #
+# sch2_bw: sch2 bandwidth (unit:Kbps) #
+# sch3_bw: sch3 bandwidth (unit:Kbps) #
####################################################################
config global global
option enable 1
option hqos 0
option txq_num 16
+ option sch_num 2
option scheduling 'wrr'
option sch0_bw 1000000
option sch1_bw 1000000
+ option sch2_bw 1000000
+ option sch3_bw 1000000
####################################################################
# id: queue id #
# minrate: percentage of min rate limit #
# maxrate: percentage of max rate limit #
-# weight: weight for queue schedule #
+# weight: weight for queue schedule (only for wrr) #
# resv: buffer reserved for HW/SW path #
####################################################################
config queue