Merge "qca-wifi: fix TSF wrap around case in tx capture"
diff --git a/dp/wifi3.0/dp_tx_capture.c b/dp/wifi3.0/dp_tx_capture.c
index 99e7f41..f7567c7 100644
--- a/dp/wifi3.0/dp_tx_capture.c
+++ b/dp/wifi3.0/dp_tx_capture.c
@@ -813,7 +813,7 @@
 		if (ts->tsf > ptr_msdu_info->tsf)
 			tsf_delta = ts->tsf - ptr_msdu_info->tsf;
 		else
-			tsf_delta = ptr_msdu_info->tsf - ts->tsf;
+			tsf_delta = LOWER_32_MASK - ptr_msdu_info->tsf + ts->tsf;
 
 		if (tsf_delta < MAX_MSDU_THRESHOLD_TSF)
 			break;
@@ -1900,7 +1900,7 @@
 	frame_ctrl_le =
 		qdf_cpu_to_le16(mpdu_info->frame_ctrl);
 	duration_le =
-		qdf_cpu_to_le16(ppdu_desc->bar_tx_duration);
+		qdf_cpu_to_le16(mpdu_info->tx_duration);
 	wh_min->i_fc[1] = (frame_ctrl_le & 0xFF00) >> 8;
 	wh_min->i_fc[0] = (frame_ctrl_le & 0xFF);
 	wh_min->i_aidordur[1] = (duration_le & 0xFF00) >> 8;
@@ -1991,6 +1991,7 @@
 				cur_ppdu_desc->ppdu_start_timestamp;
 		ppdu_desc->ppdu_end_timestamp =
 				cur_ppdu_desc->ppdu_end_timestamp;
+		ppdu_desc->tx_duration = cur_ppdu_desc->tx_duration;
 		ppdu_desc->user[0].peer_id = cur_ppdu_desc->user[0].peer_id;
 		ppdu_desc->frame_ctrl = (IEEE80211_FC0_SUBTYPE_RTS |
 					 IEEE80211_FC0_TYPE_CTL);
@@ -2015,6 +2016,8 @@
 				cur_ppdu_desc->ppdu_start_timestamp;
 		ppdu_desc->ppdu_end_timestamp =
 				cur_ppdu_desc->ppdu_end_timestamp;
+		ppdu_desc->tx_duration = cur_ppdu_desc->tx_duration -
+					 (RTS_INTERVAL + SIFS_INTERVAL);
 		ppdu_desc->user[0].peer_id = peer_id;
 		peer = dp_tx_cap_peer_find_by_id(pdev->soc, peer_id);
 		if (peer) {
@@ -2753,7 +2756,7 @@
 				if (start_tsf > ptr_comp_info->tx_tsf)
 					tsf_delta = start_tsf - ptr_comp_info->tx_tsf;
 				else
-					tsf_delta = ptr_comp_info->tx_tsf - start_tsf;
+					tsf_delta = LOWER_32_MASK - ptr_comp_info->tx_tsf + start_tsf;
 
 				if (tsf_delta > MAX_MGMT_ENQ_DELAY) {
 					/*
diff --git a/dp/wifi3.0/dp_tx_capture.h b/dp/wifi3.0/dp_tx_capture.h
index 0511bd0..3988a21 100644
--- a/dp/wifi3.0/dp_tx_capture.h
+++ b/dp/wifi3.0/dp_tx_capture.h
@@ -37,6 +37,8 @@
 
 #define SIFS_INTERVAL 16
 
+#define RTS_INTERVAL 40
+
 #define MAX_MGMT_PEER_FILTER 16
 struct dp_peer_mgmt_list {
 	uint8_t mac_addr[QDF_MAC_ADDR_SIZE];