From 991657fc99fd5ac3aa1d64f597e0a59e6e31336d Mon Sep 17 00:00:00 2001 From: Markus Gothe Date: Wed, 17 Sep 2025 19:33:30 +0200 Subject: [PATCH] dslmngr: airoha: Fix QoS uplink bandwidth monitor. --- dslmngr/files/airoha/sbin/xdsl_wan | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/dslmngr/files/airoha/sbin/xdsl_wan b/dslmngr/files/airoha/sbin/xdsl_wan index a45e8f10d..d89dd4f39 100755 --- a/dslmngr/files/airoha/sbin/xdsl_wan +++ b/dslmngr/files/airoha/sbin/xdsl_wan @@ -5,6 +5,8 @@ source "/lib/functions/network.sh" source "/lib/functions/system.sh" PREVLINK="" +LINK="" +LINKSPEED="" PREVWANMODE="" WANMODE="" CONFIGURED=0 @@ -150,6 +152,12 @@ while [ true ]; do if [ "$LINK" != "$PREVLINK" -a \( "$LINK" = "down" -o "$LINK" = "up" \) ]; then if [ "$LINK" = "down" ]; then + if [ ! -s /tmp/qos/wan_link_shape_rate ]; then + rm -rf /tmp/qos/wan_link_shape_rate + rm -rf /tmp/qos/wan_link_speed + /usr/sbin/qos-uplink-bandwidth + fi + [ "$CONFIGURED" -eq 0 ] && configure_lines # Needs to be done once the slave SoC is in down state and we've not been able to auto-sync. if [ -n "$WANMODE" ]; then if [ "$WANMODE" = "PTM" ]; then @@ -226,6 +234,26 @@ while [ true ]; do call_wan_hotplug "up" "$WANPORT" PREVWANMODE="$WANMODE" + + if [ ! -s /tmp/qos/wan_link_shape_rate ]; then + LINKSPEED="$(awk '/far-end interleaved channel bit rate/{print $6}' /proc/tc3162/adsl_stats)" + LINKSPEED=$((LINKSPEED)) + if [ "$LINKSPEED" -eq 0 ]; then + LINKSPEED="$(awk '/far-end fast channel bit rate/{print $6}' /proc/tc3162/adsl_stats)" + LINKSPEED=$((LINKSPEED)) + fi + + if [ "$LINKSPEED" -ne 0 ]; then + mkdir -p /tmp/qos + touch /tmp/qos/wan_link_shape_rate + + /userfs/bin/qosrule discpline Rate uplink-bandwidth ${LINKSPEED} + hw_nat -! > /dev/null 2>&1 + else + rm -rf /tmp/qos/wan_link_speed + /usr/sbin/qos-uplink-bandwidth + fi + fi fi # Toggle link state