qosmngr: cumulative counters on dg400prime and eg400

The runner hardware on both the chips are different due to which
the operation of counter read on dg400prime and eg400 units is
actually a read and reset. As a result cumulative counter values
are not available.

To uniformalise the behaviour of qosmngr across platforms, handling
is added to represent cumulative value of counters.

Test:
Scripts that were earlier failing on dg400prime and passing on panther
in the QoS L3 suite were executed and with this fix scripts pass on both
the platforms. This is a good enough indicator beside the manual tests,
that the issue now stands resolved.

Note: pending scripts can now be closed with this fix.
This commit is contained in:
Rahul 2020-08-24 16:32:40 +05:30
parent 6255b9b2df
commit a8960be7b5

View file

@ -3,6 +3,7 @@
IP_RULE=""
BR_RULE=""
is_bcm968=0
#function to handle a queue section
handle_queue() {
@ -45,6 +46,23 @@ handle_queue() {
# Call tmctl which is a broadcomm command to configure queues on a port.
tmctl setqcfg --devtype 0 --if $ifname --qid $order --priority $order --qsize $qsize --weight $wgt --schedmode $salg --shapingrate $rate --burstsize $bs
# In BCM968 chips, the counters for queues are read, on other model, its read and reset. So, to maintain counter
# value and uniform behaviour, we are storing counter value for each queue in files
local d_name="/tmp/qos/queue_stats/${ifname}_${order}"
mkdir $d_name
local f_name="$d_name/txPackets"
touch $f_name
echo 0 > $f_name
f_name="$d_name/txBytes"
touch $f_name
echo 0 > $f_name
f_name="$d_name/droppedPackets"
touch $f_name
echo 0 > $f_name
f_name="$d_name/droppedBytes"
touch $f_name
echo 0 > $f_name
}
#function to handle a shaper section
@ -450,6 +468,8 @@ configure_queue() {
done
done
rm -rf /tmp/qos/queue_stats
mkdir /tmp/qos/queue_stats
# Load UCI file
config_load qos
config_foreach handle_queue queue
@ -476,8 +496,11 @@ reload_qos() {
get_queue_stats() {
local ifname
local tmp_val
json_init
json_add_array "queues"
i=0
while :
do
@ -520,6 +543,14 @@ get_queue_stats() {
# remove trailing : from the name
pname="${pname::-1}"
local f_name="/tmp/qos/queue_stats/${ifname}_${order}/${pname}"
# In non BCM968* chips, read operation on queues is actually a read and reset,
# so values need to be maintained to present cumulative value
if [ $is_bcm968 -eq 0 ]; then
tmp_val=$(cat $f_name)
val=$((val + tmp_val))
fi
echo $val > $f_name
# convert to iopsyswrt names
case "$pname" in
@ -552,6 +583,7 @@ get_eth_q_stats() {
json_add_array "queues"
ifname="$1"
local tmp_val=0
# if ifname is empty that is good enough to break
if [ -z "$ifname" ];then
@ -586,6 +618,14 @@ get_eth_q_stats() {
# remove trailing : from the name
pname="${pname::-1}"
local f_name="/tmp/qos/queue_stats/${ifname}_${qid}/${pname}"
# In non BCM968* chips, read operation on queues is actually a read and reset,
# so values need to be maintained to present cumulative value
if [ $is_bcm968 -eq 0 ]; then
tmp_val=$(cat $f_name)
val=$((val + tmp_val))
fi
echo $val > $f_name
# convert to iopsyswrt names
case "$pname" in
@ -613,6 +653,10 @@ get_eth_q_stats() {
read_queue_stats() {
itf="$1"
q_idx="$2"
local cpu_model="$(grep Hardware /proc/cpuinfo | awk '{print$NF}')"
case $cpu_model in
BCM968*) is_bcm968=1 ;;
esac
if [ -n "$itf" -a -n "$q_idx" ]; then
get_eth_q_stats $itf $q_idx