qcacld-3.0: Add timestamp debug info in ol_tx_desc_t

Add descriptor timestamp debug info in ol_tx_desc_t and
add APIs to set these values.

Change-Id: I686fccff4268811474630dbea8369fabe82d1517
CRs-Fixed: 2333654
diff --git a/Kbuild b/Kbuild
index 3f56f2d..6f8a695 100644
--- a/Kbuild
+++ b/Kbuild
@@ -2026,6 +2026,8 @@
 cppflags-$(CONFIG_DESC_DUP_DETECT_DEBUG) += -DDESC_DUP_DETECT_DEBUG
 cppflags-$(CONFIG_DEBUG_RX_RING_BUFFER) += -DDEBUG_RX_RING_BUFFER
 
+cppflags-$(CONFIG_DESC_TIMESTAMP_DEBUG_INFO) += -DDESC_TIMESTAMP_DEBUG_INFO
+
 cppflags-$(PANIC_ON_BUG) += -DPANIC_ON_BUG
 
 cppflags-$(WLAN_WARN_ON_ASSERT) += -DWLAN_WARN_ON_ASSERT
diff --git a/configs/default_defconfig b/configs/default_defconfig
index 68ce747..eb182c6 100644
--- a/configs/default_defconfig
+++ b/configs/default_defconfig
@@ -649,6 +649,7 @@
 	CONFIG_MAX_LOGS_PER_SEC := 500
 	CONFIG_SCHED_HISTORY_SIZE := 256
 	CONFIG_UNIT_TEST := y
+	CONFIG_DESC_TIMESTAMP_DEBUG_INFO := y
 endif
 
 ifeq ($(CONFIG_UNIT_TEST), y)
diff --git a/core/dp/txrx/ol_tx_desc.c b/core/dp/txrx/ol_tx_desc.c
index 957260f..9322762 100644
--- a/core/dp/txrx/ol_tx_desc.c
+++ b/core/dp/txrx/ol_tx_desc.c
@@ -80,6 +80,19 @@
 }
 #endif
 
+#ifdef DESC_TIMESTAMP_DEBUG_INFO
+static inline void ol_tx_desc_update_tx_ts(struct ol_tx_desc_t *tx_desc)
+{
+	tx_desc->desc_debug_info.prev_tx_ts = tx_desc
+						->desc_debug_info.curr_tx_ts;
+	tx_desc->desc_debug_info.curr_tx_ts = qdf_get_log_timestamp();
+}
+#else
+static inline void ol_tx_desc_update_tx_ts(struct ol_tx_desc_t *tx_desc)
+{
+}
+#endif
+
 /**
  * ol_tx_desc_vdev_update() - vedv assign.
  * @tx_desc: tx descriptor pointer
@@ -144,6 +157,7 @@
 		ol_tx_desc_compute_delay(tx_desc);
 		ol_tx_desc_vdev_update(tx_desc, vdev);
 		ol_tx_desc_count_inc(vdev);
+		ol_tx_desc_update_tx_ts(tx_desc);
 		qdf_atomic_inc(&tx_desc->ref_cnt);
 	}
 	qdf_spin_unlock_bh(&pdev->tx_mutex);
@@ -214,6 +228,7 @@
 		}
 		ol_tx_desc_sanity_checks(pdev, tx_desc);
 		ol_tx_desc_compute_delay(tx_desc);
+		ol_tx_desc_update_tx_ts(tx_desc);
 		ol_tx_desc_vdev_update(tx_desc, vdev);
 		qdf_atomic_inc(&tx_desc->ref_cnt);
 	} else {
diff --git a/core/dp/txrx/ol_tx_send.c b/core/dp/txrx/ol_tx_send.c
index c83df05..a8893a7 100644
--- a/core/dp/txrx/ol_tx_send.c
+++ b/core/dp/txrx/ol_tx_send.c
@@ -105,6 +105,17 @@
 }
 #endif
 
+#ifdef DESC_TIMESTAMP_DEBUG_INFO
+static inline void ol_tx_desc_update_comp_ts(struct ol_tx_desc_t *tx_desc)
+{
+	tx_desc->desc_debug_info.last_comp_ts = qdf_get_log_timestamp();
+}
+#else
+static inline void ol_tx_desc_update_comp_ts(struct ol_tx_desc_t *tx_desc)
+{
+}
+#endif
+
 #if defined(CONFIG_HL_SUPPORT) && defined(QCA_HL_NETDEV_FLOW_CONTROL)
 void ol_tx_flow_ct_unpause_os_q(ol_txrx_pdev_handle pdev)
 {
@@ -773,6 +784,7 @@
 		}
 		tx_desc = ol_tx_desc_find(pdev, tx_desc_id);
 		qdf_assert(tx_desc);
+		ol_tx_desc_update_comp_ts(tx_desc);
 		tx_desc->status = status;
 		netbuf = tx_desc->netbuf;
 
@@ -1096,6 +1108,7 @@
 		}
 		tx_desc = ol_tx_desc_find(pdev, tx_desc_id);
 		qdf_assert(tx_desc);
+		ol_tx_desc_update_comp_ts(tx_desc);
 		netbuf = tx_desc->netbuf;
 
 		/* find the "vdev" this tx_desc belongs to */
@@ -1122,7 +1135,6 @@
 					    lcl_freelist, tx_desc_last,
 					    htt_tx_status_ok,
 					    is_tx_desc_freed);
-
 #ifdef QCA_SUPPORT_TXDESC_SANITY_CHECKS
 			if (!is_tx_desc_freed) {
 				tx_desc->pkt_type = ol_tx_frm_freed;
diff --git a/core/dp/txrx/ol_txrx_types.h b/core/dp/txrx/ol_txrx_types.h
index bf59093..7a36938 100644
--- a/core/dp/txrx/ol_txrx_types.h
+++ b/core/dp/txrx/ol_txrx_types.h
@@ -164,6 +164,15 @@
 #ifdef QCA_COMPUTE_TX_DELAY
 	uint32_t entry_timestamp_ticks;
 #endif
+
+#ifdef DESC_TIMESTAMP_DEBUG_INFO
+	struct {
+		uint64_t prev_tx_ts;
+		uint64_t curr_tx_ts;
+		uint64_t last_comp_ts;
+	} desc_debug_info;
+#endif
+
 	/*
 	 * Allow tx descriptors to be stored in (doubly-linked) lists.
 	 * This is mainly used for HL tx queuing and scheduling, but is