Browse Source

qcacmn: Update correct tx rate, rx rate and sojourn stats

Currently we are upadting sojourn stats for all tid.
but rate stats maintains stats for only data tids 0-7.
updating stats for tid value exceeding 7 is leading it to
assert.
Update correct tx rate, rx rate and sojourn stats.

Change-Id: Ib2f5791aa7b8e85aac6283c46f58ce7e821a559b
CRs-Fixed: 2428648 2429575 2429575
Amir Patel 6 years ago
parent
commit
ac7d9465f9

+ 2 - 3
dp/inc/cdp_txrx_stats_struct.h

@@ -114,10 +114,9 @@
 #define CDP_WDI_NUM_EVENTS 26
 #endif
 
-#define CDP_FC_RETRY_OFFSET 0x4
-#define CDP_FC_RETRY_MASK (CDP_FC_RETRY_OFFSET << 1)
+#define CDP_FCTL_RETRY 0x0800
 #define CDP_FC_IS_RETRY_SET(_fc) \
-	((_fc) && CDP_FC_RETRY_MASK)
+	((_fc) & qdf_cpu_to_le16(CDP_FCTL_RETRY))
 
 /* Different Packet Types */
 enum cdp_packet_type {

+ 2 - 1
dp/wifi3.0/dp_htt.c

@@ -149,6 +149,7 @@ dp_tx_rate_stats_update(struct dp_peer *peer,
 		return;
 
 	ppdu->rix = rix;
+	ppdu->tx_ratekbps = ratekbps;
 	peer->stats.tx.avg_tx_rate =
 		dp_ath_rate_lpf(peer->stats.tx.avg_tx_rate, ratekbps);
 	ppdu_tx_rate = dp_ath_rate_out(peer->stats.tx.avg_tx_rate);
@@ -2601,6 +2602,7 @@ void dp_ppdu_desc_deliver(struct dp_pdev *pdev,
 		if (!peer)
 			continue;
 
+		ppdu_desc->user[i].cookie = (void *)peer->wlanstats_ctx;
 		if (ppdu_desc->user[i].completion_status !=
 		    HTT_PPDU_STATS_USER_STATUS_OK)
 			tlv_bitmap_expected = tlv_bitmap_expected & 0xFF;
@@ -2616,7 +2618,6 @@ void dp_ppdu_desc_deliver(struct dp_pdev *pdev,
 					ppdu_desc->ack_rssi);
 		}
 
-		ppdu_desc->user[i].cookie = (void *)peer->wlanstats_ctx;
 		dp_tx_rate_stats_update(peer, &ppdu_desc->user[i]);
 		dp_peer_unref_del_find_by_id(peer);
 		tlv_bitmap_expected = tlv_bitmap_default;

+ 5 - 0
dp/wifi3.0/dp_main.c

@@ -3265,6 +3265,7 @@ static struct cdp_pdev *dp_pdev_attach_wifi3(struct cdp_soc_t *txrx_soc,
 	int entries;
 	struct wlan_cfg_dp_soc_ctxt *soc_cfg_ctx;
 	int nss_cfg;
+	void *sojourn_buf;
 
 	struct dp_soc *soc = (struct dp_soc *)txrx_soc;
 	struct dp_pdev *pdev = NULL;
@@ -3472,6 +3473,10 @@ static struct cdp_pdev *dp_pdev_attach_wifi3(struct cdp_soc_t *txrx_soc,
 			      sizeof(struct cdp_tx_sojourn_stats), 0, 4,
 			      TRUE);
 
+	if (pdev->sojourn_buf) {
+		sojourn_buf = qdf_nbuf_data(pdev->sojourn_buf);
+		qdf_mem_zero(sojourn_buf, sizeof(struct cdp_tx_sojourn_stats));
+	}
 	/* initlialize cal client timer */
 	dp_cal_client_attach(&pdev->cal_client_ctx, pdev, pdev->soc->osdev,
 			     &dp_iterate_update_peer_list);

+ 3 - 2
dp/wifi3.0/dp_rx_mon_status.c

@@ -106,8 +106,8 @@ dp_rx_populate_cdp_indication_ppdu(struct dp_pdev *pdev,
 			cdp_rx_ppdu->udp_msdu_count +
 			cdp_rx_ppdu->other_msdu_count);
 	cdp_rx_ppdu->num_bytes = ppdu_info->rx_status.ppdu_len;
-	if (CDP_FC_IS_RETRY_SET(cdp_rx_ppdu->frame_ctrl))
-		cdp_rx_ppdu->retries += ppdu_info->com_info.mpdu_cnt_fcs_ok;
+	cdp_rx_ppdu->retries = CDP_FC_IS_RETRY_SET(cdp_rx_ppdu->frame_ctrl) ?
+					ppdu_info->com_info.mpdu_cnt_fcs_ok : 0;
 
 	if (ppdu_info->com_info.mpdu_cnt_fcs_ok > 1)
 		cdp_rx_ppdu->is_ampdu = 1;
@@ -188,6 +188,7 @@ static inline void dp_rx_rate_stats_update(struct dp_peer *peer,
 	dp_ath_rate_lpf(peer->stats.rx.avg_rx_rate, ratekbps);
 	ppdu_rx_rate = dp_ath_rate_out(peer->stats.rx.avg_rx_rate);
 	DP_STATS_UPD(peer, rx.rnd_avg_rx_rate, ppdu_rx_rate);
+	ppdu->rx_ratekbps = ratekbps;
 
 	if (peer->vdev)
 		peer->vdev->stats.rx.last_rx_rate = ratekbps;

+ 20 - 31
dp/wifi3.0/dp_tx.c

@@ -2978,47 +2978,36 @@ static inline void dp_tx_sojourn_stats_process(struct dp_pdev *pdev,
 {
 	uint64_t delta_ms;
 	struct cdp_tx_sojourn_stats *sojourn_stats;
-	uint8_t tidno;
 
-	if (pdev->enhanced_stats_en == 0)
+	if (qdf_unlikely(pdev->enhanced_stats_en == 0))
 		return;
 
-	if (pdev->sojourn_stats.ppdu_seq_id == 0)
-		pdev->sojourn_stats.ppdu_seq_id = ppdu_id;
-
-	if (ppdu_id != pdev->sojourn_stats.ppdu_seq_id) {
-		if (!pdev->sojourn_buf)
-			return;
-
-		sojourn_stats = (struct cdp_tx_sojourn_stats *)
-					qdf_nbuf_data(pdev->sojourn_buf);
-
-		qdf_mem_copy(sojourn_stats, &pdev->sojourn_stats,
-			     sizeof(struct cdp_tx_sojourn_stats));
-
-		sojourn_stats->cookie = (void *)peer->wlanstats_ctx;
-
-		for (tidno = 0; tidno < CDP_DATA_TID_MAX; tidno++) {
-			pdev->sojourn_stats.sum_sojourn_msdu[tidno] = 0;
-			pdev->sojourn_stats.num_msdus[tidno] = 0;
-		}
+	if (qdf_unlikely(tid == HTT_INVALID_TID ||
+			 tid >= CDP_DATA_TID_MAX))
+		return;
 
-		dp_wdi_event_handler(WDI_EVENT_TX_SOJOURN_STAT, pdev->soc,
-				     pdev->sojourn_buf, HTT_INVALID_PEER,
-				     WDI_NO_VAL, pdev->pdev_id);
+	if (qdf_unlikely(!pdev->sojourn_buf))
+		return;
 
-		pdev->sojourn_stats.ppdu_seq_id = ppdu_id;
-	}
+	sojourn_stats = (struct cdp_tx_sojourn_stats *)
+		qdf_nbuf_data(pdev->sojourn_buf);
 
-	if (tid == HTT_INVALID_TID)
-		return;
+	sojourn_stats->cookie = (void *)peer->wlanstats_ctx;
 
 	delta_ms = qdf_ktime_to_ms(qdf_ktime_get()) -
 				txdesc_ts;
-	qdf_ewma_tx_lag_add(&pdev->sojourn_stats.avg_sojourn_msdu[tid],
+	qdf_ewma_tx_lag_add(&peer->avg_sojourn_msdu[tid],
 			    delta_ms);
-	pdev->sojourn_stats.sum_sojourn_msdu[tid] += delta_ms;
-	pdev->sojourn_stats.num_msdus[tid]++;
+	sojourn_stats->sum_sojourn_msdu[tid] = delta_ms;
+	sojourn_stats->num_msdus[tid] = 1;
+	sojourn_stats->avg_sojourn_msdu[tid].internal =
+		peer->avg_sojourn_msdu[tid].internal;
+	dp_wdi_event_handler(WDI_EVENT_TX_SOJOURN_STAT, pdev->soc,
+			     pdev->sojourn_buf, HTT_INVALID_PEER,
+			     WDI_NO_VAL, pdev->pdev_id);
+	sojourn_stats->sum_sojourn_msdu[tid] = 0;
+	sojourn_stats->num_msdus[tid] = 0;
+	sojourn_stats->avg_sojourn_msdu[tid].internal = 0;
 }
 #else
 static inline void dp_tx_sojourn_stats_process(struct dp_pdev *pdev,

+ 2 - 0
dp/wifi3.0/dp_types.h

@@ -1714,6 +1714,8 @@ struct dp_peer {
 
 	/* rdk statistics context */
 	struct cdp_peer_rate_stats_ctx *wlanstats_ctx;
+	/* average sojourn time */
+	qdf_ewma_tx_lag avg_sojourn_msdu[CDP_DATA_TID_MAX];
 };
 
 #ifdef CONFIG_WIN