Browse Source

qcacmn: Fix last_per overflow issue

Check if ucast pkts count is more than success pkts count,
compute last packet error rate only if ucast is less than success
pkts.

Change-Id: I0aa4d41d09b1691e4d554beab2f2ed7a7f2ceb1e
CRs-Fixed: 2343479
Amir Patel 6 years ago
parent
commit
d577d09497
1 changed files with 11 additions and 4 deletions
  1. 11 4
      dp/cmn_dp_api/dp_cal_client_api.c

+ 11 - 4
dp/cmn_dp_api/dp_cal_client_api.c

@@ -153,10 +153,17 @@ void dp_cal_client_update_peer_stats(struct cdp_peer_stats *peer_stats)
 	peer_stats->tx.tx_data_success_last = temp_tx_data;
 	peer_stats->tx.tx_data_ucast_last = temp_tx_ucast_pkts;
 
-	if (peer_stats->tx.tx_data_ucast_rate)
-		peer_stats->tx.last_per = ((peer_stats->tx.tx_data_ucast_last -
-				peer_stats->tx.tx_data_success_last) * 100) /
-				peer_stats->tx.tx_data_ucast_last;
+	if (peer_stats->tx.tx_data_ucast_rate) {
+		if (peer_stats->tx.tx_data_ucast_rate >
+				peer_stats->tx.tx_data_rate)
+			peer_stats->tx.last_per =
+				((peer_stats->tx.tx_data_ucast_rate -
+					peer_stats->tx.tx_data_rate) * 100) /
+				peer_stats->tx.tx_data_ucast_rate;
+		else
+			peer_stats->tx.last_per = 0;
+	}
+
 }
 
 qdf_export_symbol(dp_cal_client_update_peer_stats);