qca-wifi: Fix tx capture tid init issues

For some peers, tx capture tid init is not invoked,
It is resulting in ppdu_desc leak.

Invoking tid init on tid peer update, if tid is not
initialized.

Change-Id: Ia49c7e6d093a42e57e8d9239a60ad0b8dabfcc5b
CRs-Fixed: 2718150
diff --git a/dp/wifi3.0/dp_tx_capture.c b/dp/wifi3.0/dp_tx_capture.c
index 768bb5b..574e280 100644
--- a/dp/wifi3.0/dp_tx_capture.c
+++ b/dp/wifi3.0/dp_tx_capture.c
@@ -501,9 +501,14 @@
 	int tid;
 	struct dp_tx_tid *tx_tid;
 
+	dp_peer_tid_queue_init(peer);
 	for (tid = 0; tid < DP_MAX_TIDS; tid++) {
 		tx_tid = &peer->tx_capture.tx_tid[tid];
 		tx_tid->peer_id = peer_id;
+		if (tx_tid->tid != tid) {
+			qdf_err("tx tid is corrupted for tid %d, peer_id %d", tid, peer_id);
+			tx_tid->tid = tid;
+		}
 	}
 }
 
@@ -519,6 +524,8 @@
 
 	for (tid = 0; tid < DP_MAX_TIDS; tid++) {
 		tx_tid = &peer->tx_capture.tx_tid[tid];
+		if (tx_tid->init_done)
+			continue;
 		tx_tid->tid = tid;
 		qdf_nbuf_queue_init(&tx_tid->defer_msdu_q);
 		qdf_nbuf_queue_init(&tx_tid->msdu_comp_q);
@@ -528,6 +535,7 @@
 		/* spinlock create */
 		qdf_spinlock_create(&tx_tid->tid_lock);
 		qdf_spinlock_create(&tx_tid->tasklet_tid_lock);
+		tx_tid->init_done = 1;
 	}
 }
 
@@ -2856,7 +2864,6 @@
 			      uint8_t usr_idx)
 {
 	struct cdp_tx_completion_ppdu *ppdu_desc = NULL;
-	struct cdp_tx_completion_ppdu_user *user = NULL;
 	qdf_nbuf_t tmp_nbuf;
 
 	if (!ptr_nbuf_list->nbuf_ppdu ||
@@ -2868,7 +2875,6 @@
 	if (tmp_nbuf) {
 		ppdu_desc = (struct cdp_tx_completion_ppdu *)
 				qdf_nbuf_data(tmp_nbuf);
-		user = &ppdu_desc->user[usr_idx];
 
 		dp_ppdu_queue_free(tmp_nbuf, usr_idx);
 		dp_tx_cap_nbuf_list_dec_ref(ptr_nbuf_list);
@@ -3173,6 +3179,7 @@
 			if ((user->skip == 1) || (peer_id != user->peer_id) ||
 			    (tx_tid->tid != user->tid))
 				continue;
+
 			if ((user->pending_retries == 0) &&
 			    qdf_nbuf_is_queue_empty(&tx_tid->pending_ppdu_q) &&
 			    qdf_nbuf_is_queue_empty(head_ppdu)) {
@@ -3239,6 +3246,7 @@
 
 			if (cur_user->skip == 1)
 				continue;
+
 			/* to handle last ppdu case we need to decrement */
 			ppdu_cnt--;
 			break;
@@ -4258,6 +4266,7 @@
 							 user->peer_id);
 			if (!peer) {
 				dp_ppdu_desc_free(ptr_nbuf_list, usr_idx);
+				user->skip = 1;
 				continue;
 			}
 
@@ -4424,7 +4433,8 @@
 				continue;
 
 			cur_user = &cur_ppdu_desc->user[usr_idx];
-			if (cur_user->delayed_ba == 1 || cur_user->skip == 1)
+			if ((cur_user->delayed_ba == 1) ||
+			    (cur_user->skip == 1))
 				continue;
 
 			peer_id = cur_ppdu_desc->user[usr_idx].peer_id;
@@ -4612,7 +4622,7 @@
 			 */
 			if (peer->bss_peer ||
 			    !dp_peer_or_pdev_tx_cap_enabled(pdev,
-				NULL, peer->mac_addr.raw)) {
+				NULL, peer->mac_addr.raw) || user->is_mcast) {
 				user->skip = 1;
 				goto free_nbuf_dec_ref;
 			}
@@ -4979,9 +4989,10 @@
 							ptr_nbuf_list)) {
 					QDF_TRACE(QDF_MODULE_ID_TX_CAPTURE,
 						  QDF_TRACE_LEVEL_FATAL,
-						  "%s: %d missing handling of ppdu_desc ref_cnt:%d ,i : %d!!!\n",
+						  "%s: %d missing handling of ppdu_desc ref_cnt:%d ,i : %d ptr %p, ppdu_desc_cnt %d!!!\n",
 						  __func__, __LINE__,
-						  ptr_nbuf_list->ref_cnt, i);
+						  ptr_nbuf_list->ref_cnt, i, ptr_nbuf_list, ppdu_desc_cnt);
+					QDF_BUG(0);
 				}
 			}
 		}
diff --git a/dp/wifi3.0/dp_tx_capture.h b/dp/wifi3.0/dp_tx_capture.h
index e8cdbc5..34eee18 100644
--- a/dp/wifi3.0/dp_tx_capture.h
+++ b/dp/wifi3.0/dp_tx_capture.h
@@ -131,6 +131,7 @@
 	uint16_t first_data_seq_ctrl;
 	uint32_t mpdu_cnt;
 	uint32_t mpdu_fcs_ok_bitmap[QDF_MON_STATUS_MPDU_FCS_BMAP_NWORDS];
+	uint8_t init_done;
 };
 
 struct dp_peer_tx_capture {