From cc7d076dc8a780eded1972110db12eef9e568e08 Mon Sep 17 00:00:00 2001 From: subramanian c Date: Tue, 1 Nov 2022 09:41:03 +0000 Subject: [PATCH] qos: Apply qos classify config in the order of order param value --- qosmngr/files/lib/qos/broadcom.sh | 60 ++++++++++++++++++++++++++++--- 1 file changed, 56 insertions(+), 4 deletions(-) diff --git a/qosmngr/files/lib/qos/broadcom.sh b/qosmngr/files/lib/qos/broadcom.sh index 58a5ced16..f35c76f71 100755 --- a/qosmngr/files/lib/qos/broadcom.sh +++ b/qosmngr/files/lib/qos/broadcom.sh @@ -10,6 +10,9 @@ POLICER_COUNT=0 Q_COUNT=0 SP_Q_PRIO=7 +#counter variable to assign classify order value if not added in config +temp_order=1 + # Function to handle a queue order and # update total number of queues handle_q_order() { @@ -976,6 +979,43 @@ config_ingress_rate_limit() { ethswctl -c rxratectrl -n $unit -p $port -x $ingress_rate -y $in_burst_size } +# Function to handle a classify order +handle_classify_order() { + local cid="$1" #classify section ID + + config_get is_enable "$cid" "enable" 1 + + # No need to configure disabled classify + if [ $is_enable == '0' ]; then + return + fi + + # Create classify file containing classify order + local corder_file="/tmp/qos/classify.order" + + config_get c_order "$cid" "order" + + if [ -z "$c_order" ]; then + c_order=$temp_order; + temp_order=$((temp_order + 1)) + fi + + value=${c_order}_${cid} + echo $value >> $corder_file + +} + +# Sort classify, lower value in uci means higher precedence, so this +# function sorts the classify order in assending order +sort_classify_by_order() { + local corder_file="/tmp/qos/classify.order" + local tmp_corder_file="/tmp/qos/tmp_classify.order" + + sort -n -k1 $corder_file > $tmp_corder_file + cp $tmp_corder_file $corder_file + rm -f $tmp_corder_file +} + #function to handle a classify section handle_classify() { cid="$1" #classify section ID @@ -986,9 +1026,15 @@ handle_classify() { return fi - handle_ebtables_rules $cid - handle_iptables_rules $cid - handle_policer_rules $cid + local corder_file="/tmp/qos/classify.order" + + while read -r line; do + line_cid=${line: 2} + + handle_ebtables_rules $line_cid + handle_iptables_rules $line_cid + handle_policer_rules $line_cid + done < "$corder_file" } configure_shaper() { @@ -1008,19 +1054,25 @@ configure_classify() { rm -f /tmp/qos/classify.ebtables rm -f /tmp/qos/classify.iptables rm -f /tmp/qos/classify.ip6tables + rm -f /tmp/qos/classify.order + rm -f /tmp/qos/tmp_classify.order #create files that will contain the rules if not present already mkdir -p /tmp/qos/ touch /tmp/qos/classify.iptables touch /tmp/qos/classify.ip6tables touch /tmp/qos/classify.ebtables + touch /tmp/qos/classify.order + touch /tmp/qos/tmp_classify.order #add flush chain rules flush_chains # Load UCI file config_load qos - config_foreach handle_classify classify + config_foreach handle_classify_order classify + sort_classify_by_order + handle_classify classify sh /tmp/qos/classify.ebtables sh /tmp/qos/classify.iptables