From ff63eb262cb1d7b6fed5a0fbf37076ee0c8b1129 Mon Sep 17 00:00:00 2001 From: Markus Gothe Date: Fri, 13 Mar 2026 14:34:07 +0100 Subject: [PATCH] qosmngr: Airoha: Implement SP+WRR mixed mode. --- qosmngr/files/airoha/lib/qos/airoha.sh | 78 ++++++++++++++------------ 1 file changed, 42 insertions(+), 36 deletions(-) diff --git a/qosmngr/files/airoha/lib/qos/airoha.sh b/qosmngr/files/airoha/lib/qos/airoha.sh index 22ce85a30..919321690 100755 --- a/qosmngr/files/airoha/lib/qos/airoha.sh +++ b/qosmngr/files/airoha/lib/qos/airoha.sh @@ -322,28 +322,9 @@ hw_shaper_set() { return 0 } -# Convert shaper in UCI terms to Econet terms -hw_sc_alg2str() { - local sc_alg="$1" - - case "${sc_alg}" in - SP) - echo "PQ" - ;; - WRR) - echo "WRR" - ;; - *) - echo "" - return 1 - esac - - return 0 -} - # Commit all options preserved during hw_commit_all() { - local sorted_list="$(echo $TMP_HW_QUEUE_LIST | tr ' ' '\n' | sort | xargs)" + local sorted_list="$(echo $TMP_HW_QUEUE_LIST | tr ' ' '\n' | sort -u | xargs)" local weight_list="" local glob_alg="" local shape_rate="$TMP_HW_SHAPE_RATE" @@ -355,24 +336,36 @@ hw_commit_all() { # Reorder queues for q in ${sorted_list} ; do local sc_alg="$(get_var TMP_HW_QUEUE_${q}_sc_alg)" - local wgt="$(get_var TMP_HW_QUEUE_${q}_wgt)" if [ "$glob_alg" != "" ] && [ "$sc_alg" != "$glob_alg" ] ; then - errmsg "Not matching scheduling algorithm: $sc_alg vs $glob_alg" - return 1 + if [ "$glob_alg" = "SPWRR" -a "$sc_alg" = "WRR" ] || [ "$sc_alg" = "WRR" -a "$glob_alg" = "SP" ]; then + sc_alg="SPWRR" + else + errmsg "Not matching scheduling algorithm: $sc_alg vs $glob_alg" + return 1 + fi fi glob_alg="$sc_alg" + done - case "${sc_alg}" in - WRR) - if [ $(($q_count >= 8)) != 0 ] ; then - errmsg "Too many queues, next queues will be ignored" - else - weight_list="$weight_list $wgt" - fi - ;; - esac + for q in ${sorted_list} ; do + local sc_alg="$(get_var TMP_HW_QUEUE_${q}_sc_alg)" + local wgt="$(get_var TMP_HW_QUEUE_${q}_wgt)" + + if [ "${sc_alg}" = "SP" -o $((wgt)) -lt 0 ]; then + wgt=0 + fi + + if [ "${glob_alg}" = "SPWRR" -a "${sc_alg}" = "WRR" -a $((wgt)) -eq 0 ]; then # 0 is valid for WRR but not for SP+WRR. + wgt=1 + fi + + if [ $(($q_count >= 8)) != 0 ] ; then + errmsg "Too many queues, next queues will be ignored" + else + weight_list="$weight_list $wgt" + fi q_count=$((q_count + 1)) done @@ -388,12 +381,25 @@ hw_commit_all() { echo ${mac_qos_flag} > /proc/qdma_wan/mac_qos_flag echo "1 ${weight_list}" > /proc/qdma_wan/mac_qos ;; - SP) - mac_qos_flag="8QPQ" - q_count="8" + SPWRR) + mac_qos_flag="HW8QPQWRR" + while [ $((q_count < 8)) != 0 ] ; do + weight_list="$weight_list 1" + q_count=$((q_count + 1)) + done echo ${mac_qos_flag} > /proc/qdma_wan/mac_qos_flag - echo "0 0 0 0 0 0 0 0 0" > /proc/qdma_wan/mac_qos + echo "2 ${weight_list}" > /proc/qdma_wan/mac_qos + ;; + *) + mac_qos_flag="8QPQ" + while [ $((q_count < 8)) != 0 ] ; do + weight_list="$weight_list 0" + q_count=$((q_count + 1)) + done + + echo ${mac_qos_flag} > /proc/qdma_wan/mac_qos_flag + echo "0 ${weight_list}" > /proc/qdma_wan/mac_qos ;; esac