qos: qos reload handling updated

This commit is contained in:
Amit Kumar 2022-11-18 09:08:36 +05:30
parent 5dd35e99e2
commit 0385a0b715
3 changed files with 80 additions and 58 deletions

View file

@ -49,3 +49,7 @@ reload_qos() {
esac
hw_commit_all
}
reload_qos_service() {
reload_qos
}

View file

@ -15,10 +15,6 @@ temp_order=1
cfg_name=""
cfg_type=""
q_cfg_restart="false"
policer_cfg_modf="false"
classify_cfg_modf="false"
shaper_cfg_modf="false"
# Function to handle a queue order and
# update total number of queues
@ -1220,7 +1216,7 @@ configure_qos() {
configure_classify
}
reload_qos_service() {
reload_qos() {
local service_name="$1"
local cpu_model="$(cat /proc/socinfo | grep 'SoC Name' | cut -d':' -f2)"
@ -1242,13 +1238,16 @@ reload_qos_service() {
fi
}
is_queue_cfg_added_deleted()
get_cfg_added_deleted()
{
# return true if there is difference in number of queue configuration
# in /etc/config/qos and /tmp/qos/qos, false is returned if both file
# has same count of queue configuration.
q_cfg_count=0
local new_q_cfg_count=0
local queue=0
local classify=0
local shaper=0
local policer=0
local old_cfg="false"
config_cb() {
# invoked on the just previous config_load, get the count of
@ -1258,42 +1257,63 @@ is_queue_cfg_added_deleted()
if [ -z $cfg_name ] || [ -z $cfg_type ]; then
return
fi
if [ "$cfg_type" == "queue" ]; then
q_cfg_count=$(($q_cfg_count + 1))
option_cb() {
local option="$1"
local value="$2"
if [ -z $option ] || [ -z $value ]; then
return
fi
q_cfg_count=$(($q_cfg_count + 1))
}
if [ "$old_cfg" == "false" ]; then
eval $cfg_type=$(($cfg_type + 1))
else
option_cb() {
return
}
eval $cfg_type=$(($cfg_type - 1))
fi
option_cb() {
local option="$1"
local value="$2"
if [ -z "$option" ] || [ -z "$value" ]; then
return
fi
if [ "$old_cfg" == "false" ]; then
eval $cfg_type=$(($cfg_type + 1))
else
eval $cfg_type=$(($cfg_type - 1))
fi
}
}
# config_load will trigger call for config_cb that is getting count
# of qos configuration, q_cfg_count will have the count.
# of qos configuration, respective config counts will come.
config_load qos
new_q_cfg_count=$q_cfg_count
q_cfg_count=0
# config_load will trigger call for config_cb that is getting count
# config_load will trigger call for config_cb that is decreasing count
# of qos configuration.
config_load "/tmp/qos/qos"
old_cfg="true"
UCI_CONFIG_DIR="/tmp/qos"
config_load qos
UCI_CONFIG_DIR="/etc/config"
reset_cb
if [ $new_q_cfg_count -eq $q_cfg_count ]; then
echo "false"
if [ $classify -ne 0 ]; then
modified_config="classify"
fi
if [ $shaper -ne 0 ]; then
modified_config="$modified_config shaper"
fi
if [ $policer -ne 0 ]; then
modified_config="$modified_config policer"
fi
if [ $queue -eq 0 ]; then
echo "$modified_config"
return
else
echo "true"
echo "queue"
return
fi
}
# reload_qos is invoked on qos service reload.
reload_qos() {
# reload_qos_service is invoked on qos service reload.
reload_qos_service() {
q_cfg_restart="false"
policer="false"
classify="false"
shaper="false"
setup_qos
if ! [[ -f "/etc/config/qos" && -f "/tmp/qos/qos" ]]; then
configure_qos
cp /etc/config/qos /tmp/qos/qos
@ -1311,36 +1331,30 @@ reload_qos() {
# comparsion is done between /etc/config/qos and /tmp/qos/qos
local option="$1"
local value="$2"
if [ -z $option ] || [ -z $value ]; then
local old_value=""
if [ -z "$option" ] || [ -z "$value" ]; then
return
fi
old_value=$(uci -q -c "/tmp/qos" get qos.$cfg_name.$option)
if ! [ $old_value = $value ]; then
if ! [ "$old_value" == "$value" ]; then
if [ "$cfg_type" == "queue" ]; then
q_cfg_restart="true"
elif [ "$cfg_type" == "shaper" ]; then
shaper_cfg_modf="true"
elif [ "$cfg_type" == "classify" ]; then
classify_cfg_modf="true"
elif [ "$cfg_type" == "policer" ]; then
policer_cfg_modf="true"
else
eval $cfg_type="true"
fi
fi
}
}
# if there is new addition/deletion of queue configuration or modification
# of value of queue configuration parameters then return false to
# trigger restart of qos. Otehrwise shaper, policer and classification
# related operation config is invoked that does not change queue statistics
q_cfg_added_deleted=$(is_queue_cfg_added_deleted)
if [ "$q_cfg_added_deleted" == "true" ]; then
# if there is new addition/deletion of queue configuration
# then return is queue to trigger restart of qos.
# Otehrwise shaper policer classify
# respective operation config is invoked that does not change queue statistics
cfg_added_deleted=$(get_cfg_added_deleted)
if [ "$cfg_added_deleted" == "queue" ]; then
configure_qos
else
q_cfg_restart="false"
policer_cfg_modf="false"
classify_cfg_modf="false"
shaper_cfg_modf="false"
# config_load will trigger call for config_cb that is checking
# config_load will trigger call for config_cb that is checking
# for modification in config value of queue config.
# if change of value of queue config is there then q_cfg_restart
# is set as true, else other qos config flag is set as true.
@ -1349,17 +1363,21 @@ reload_qos() {
if [ "$q_cfg_restart" == "true" ]; then
configure_qos
else
if [ "$shaper_cfg_modf" == "true" ]; then
reload_qos_service "shaper"
for config in $cfg_added_deleted
do
eval $config="true"
done
if [ "$shaper" == "true" ]; then
reload_qos "shaper"
fi
if [ "$policer_cfg_modf" == "true" ]; then
reload_qos_service "policer"
if [ "$policer" == "true" ]; then
reload_qos "policer"
# change in policer config may need reconfiguration
# of classifier
reload_qos_service "classify"
reload_qos "classify"
fi
if [ "$classify_cfg_modf" == "true" ]; then
reload_qos_service "classify"
if [ "$classify" == "true" ]; then
reload_qos "classify"
fi
fi
fi

View file

@ -16,7 +16,7 @@ PROG=/usr/sbin/qosmngr
start_service() {
if [ -f "/etc/config/qos" ]; then
reload_qos_service
reload_qos
procd_open_instance qosmngr
procd_set_param command ${PROG}
procd_set_param respawn
@ -41,5 +41,5 @@ restart() {
reload_service()
{
reload_qos
reload_qos_service
}