qosmngr: updates related to rate control

* separate scheduling logic from rate control logic
* add support for burst_size
This commit is contained in:
Mohd Husaam Mehdi 2024-12-04 16:36:01 +05:30 committed by Markus Gothe
parent 64d1873eba
commit d161ef2238
3 changed files with 49 additions and 16 deletions

View file

@ -2,8 +2,9 @@
# Implementation of QoS setup for Econet platform.
VALID_INTF=""
ETHWAN="$(jsonfilter -i /etc/board.json -e @.network.wan.device)"
OFFSET=32
readonly ETHWAN="$(jsonfilter -i /etc/board.json -e @.network.wan.device)"
readonly LANPORTS="$(jsonfilter -i /etc/board.json -e @.network.lan.ports[*] -e @.network.lan.device | xargs)"
readonly OFFSET=32
errmsg() {
echo "$@" >&2
@ -24,19 +25,25 @@ hw_queue_init_all() {
# populate interfaces available for rate limiting
init_valid_interface_list() {
local intf tmpintf
for intf in $(ifconfig -a | awk -F' ' '{if ($1 ~ "eth" ) print $1;}' | xargs); do
[ "$(ls -d /sys/class/net/${intf}/lower* 2> /dev/null)" != "" -o "$intf" = "eth0" ] && continue
[ -z "$VALID_INTF" ] && VALID_INTF="${intf}" || VALID_INTF="${VALID_INTF} ${intf}"
for tmpintf in $LANPORTS; do
if [ "$intf" = "$tmpintf" ]; then
[ -z "$VALID_INTF" ] && VALID_INTF="${intf}" || VALID_INTF="${VALID_INTF} ${intf}"
break
fi
done
done
for intf in $(ifconfig -a | awk -F' ' '{if ($1 ~ "rai" ) print $1;}' | xargs); do
[ "$(ls -d /sys/class/net/${intf}/lower* 2> /dev/null)" != "" ] && continue
[ -z "$VALID_INTF" ] && VALID_INTF="${intf}" || VALID_INTF="${VALID_INTF} ${intf}"
[ -z "$VALID_INTF" ] && VALID_INTF="${intf}" || VALID_INTF="${VALID_INTF} ${intf}"
done
for intf in $(ifconfig -a | awk -F' ' '!/rai/ {if ($1 ~ "ra") print $1;}' | xargs); do
[ "$(ls -d /sys/class/net/${intf}/lower* 2> /dev/null)" != "" ] && continue
[ -z "$VALID_INTF" ] && VALID_INTF="${intf}" || VALID_INTF="${VALID_INTF} ${intf}"
[ -z "$VALID_INTF" ] && VALID_INTF="${intf}" || VALID_INTF="${VALID_INTF} ${intf}"
done
}
@ -49,6 +56,8 @@ hw_intf_init() {
# Initialize the hardware setup library
hw_init_all() {
local tc=0
local tsid=0
local channel
export TMP_HW_QUEUE_LIST=""
echo clear > /proc/ifc_debug
@ -59,6 +68,15 @@ hw_init_all() {
rm -rf "/tmp/qos/dscp_values_${tc}_6"
done
/userfs/bin/qdmamgr_lan set general_rx_init enable trtcm 8 125
/userfs/bin/qdmamgr_wan set general_rx_init enable trtcm 8 125
for channel in $(seq 0 30); do
tsid=$((OFFSET+channel))
/userfs/bin/qdmamgr_lan set general_rx_trtcm config "$tsid" disable byte slow disable byte fast
/userfs/bin/qdmamgr_wan set general_rx_trtcm config "$tsid" disable byte slow disable byte fast
done
return 0
}
@ -143,10 +161,19 @@ get_tsid() {
echo "-1"
}
get_numeric_value() {
local val="$1"
case $val in
''|*[!0-9]*) echo 0 ;;
*) echo "${val}" ;;
esac
}
set_lan_rate() {
local ifname="$1"
local rate="$2"
local burst_size="$3"
local rate="$(get_numeric_value "${2}")"
local burst_size="$(get_numeric_value "${3}")"
local direction="$4"
local qdma_exe=""
@ -164,11 +191,14 @@ set_lan_rate() {
fi
if [ "$rate" -eq 0 ]; then
"${qdma_exe}" set general_rx_trtcm config "$tsid" disable byte slow disable byte fast
return
return
else
"${qdma_exe}" set general_rx_trtcm config "$tsid" enable byte slow enable byte fast
"${qdma_exe}" set general_rx_trtcm value "$tsid" "$rate" "$rate"
if [ "$burst_size" -gt 0 ]; then
"${qdma_exe}" set general_rx_trtcm bsize "$tsid" "$burst_size" "$burst_size"
fi
fi
}

View file

@ -49,8 +49,7 @@ handle_policer_rules() {
return
fi
config_ingress_rate_limit "$ifname" "$ingress_rate" "$in_burst_size"
config_ingress_rate_limit "$ifname" "$ingress_rate" "$in_burst_rate"
}
# Configure ingress rate limit
@ -65,9 +64,7 @@ config_ingress_rate_limit() {
ingress_rate=$((ingress_rate / 1000))
if [ "$in_burst_size" -eq 0 ]; then
in_burst_size="$ingress_rate"
else
if [ -n "$in_burst_size" ] && [ "$in_burst_size" -ge 1000 ]; then
in_burst_size="$((in_burst_size / 1000))"
fi
@ -100,7 +97,7 @@ handle_policer() {
# Configure policer based on UCI subtree 'qos.policer'
configure_policer() {
# initialize ratelimit params for lan
# initialize ratelimit params
/userfs/bin/femgr ratelimit set rx_mode 1 2
/userfs/bin/qdmamgr_wan set general_rx_init enable trtcm 8 125

View file

@ -29,6 +29,12 @@ handle_shaper() {
rate=$((rate / 1000))
config_get bs "$sid" "burst_size"
if [ "${bs}" -ge 1000 ] ; then
bs=$((bs / 1000))
else
bs=0
fi
hw_shaper_set "$ifname" add "$rate" "$bs"
}