From 460327011d932580f55c7b70acb1e652dd3c95a3 Mon Sep 17 00:00:00 2001 From: Amit Kumar <amit.kumar@iopsys.eu> Date: Thu, 29 Jul 2021 11:30:26 +0000 Subject: [PATCH] qosmngr: accumulation of stats done based on driver does read and reset of stats or read. --- src/qosmngr.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/src/qosmngr.c b/src/qosmngr.c index 86be094..45dfaa3 100644 --- a/src/qosmngr.c +++ b/src/qosmngr.c @@ -203,6 +203,7 @@ static int prepare_stats_blob(struct blob_buf *b, struct qos_stats *stats, void { int index; int ret = 0; + int is_read_and_reset; // Initialize global q_stat global struct if (init_flag) { @@ -214,7 +215,7 @@ static int prepare_stats_blob(struct blob_buf *b, struct qos_stats *stats, void init_flag = 0; } - ret = qos_get_stats(ifname, qid, stats); + ret = qos_get_stats(ifname, qid, stats, &is_read_and_reset); if (ret != 0) { syslog(LOG_ERR, "blob_get_status: ret %d\n", ret); return ret; @@ -222,10 +223,19 @@ static int prepare_stats_blob(struct blob_buf *b, struct qos_stats *stats, void index = get_interface_index(ifname); - q_stat[index][qid].tx_packets += stats->tx_packets; - q_stat[index][qid].tx_bytes += stats->tx_bytes; - q_stat[index][qid].tx_dropped_packets += stats->tx_dropped_packets; - q_stat[index][qid].tx_dropped_bytes += stats->tx_dropped_bytes; + /*BCM968 CHIP, stats read from driver is accunulated stats, while in other its read and reset */ + if (!is_read_and_reset) { + q_stat[index][qid].tx_packets = stats->tx_packets; + q_stat[index][qid].tx_bytes = stats->tx_bytes; + q_stat[index][qid].tx_dropped_packets = stats->tx_dropped_packets; + q_stat[index][qid].tx_dropped_bytes = stats->tx_dropped_bytes; + } + else { + q_stat[index][qid].tx_packets += stats->tx_packets; + q_stat[index][qid].tx_bytes += stats->tx_bytes; + q_stat[index][qid].tx_dropped_packets += stats->tx_dropped_packets; + q_stat[index][qid].tx_dropped_bytes += stats->tx_dropped_bytes; + } dd = blobmsg_open_table(b, ""); -- GitLab