From d577d0949719edb989e5462667e663b4ce89c832 Mon Sep 17 00:00:00 2001 From: Amir Patel Date: Tue, 27 Nov 2018 20:11:58 +0530 Subject: [PATCH] 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 --- dp/cmn_dp_api/dp_cal_client_api.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/dp/cmn_dp_api/dp_cal_client_api.c b/dp/cmn_dp_api/dp_cal_client_api.c index 8e2bcd9d33..37217434ac 100644 --- a/dp/cmn_dp_api/dp_cal_client_api.c +++ b/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);