qcacld-3.0: Record ol rx indication events

Record ol rx indication events in a global ol rx indication record
buffer to have history of msdus received, no. of buffers replenished,
etc. in rx indication messages.

Change-Id: I96cf27a209c81208c6f6566b5e57116b2cf233e8
CRs-Fixed: 2012485
diff --git a/Kbuild b/Kbuild
index 50ad613..800b04b 100644
--- a/Kbuild
+++ b/Kbuild
@@ -2028,6 +2028,11 @@
 ifeq ($(CONFIG_64BIT_PADDR),y)
 CDEFINES += -DHTT_PADDR64
 endif
+
+ifeq ($(CONFIG_SLUB_DEBUG_ON),y)
+CDEFINES += -DOL_RX_INDICATION_RECORD
+endif
+
 endif
 endif
 
diff --git a/core/dp/txrx/ol_rx.c b/core/dp/txrx/ol_rx.c
index a4227e1..b0a30e6 100644
--- a/core/dp/txrx/ol_rx.c
+++ b/core/dp/txrx/ol_rx.c
@@ -63,6 +63,68 @@
 #include <cdp_txrx_handle.h>
 #include <pld_common.h>
 
+
+#define OL_RX_INDICATION_MAX_RECORDS 2048
+
+/**
+ * enum ol_rx_ind_record_type - OL rx indication events
+ * @OL_RX_INDICATION_POP_START: event recorded before netbuf pop
+ * @OL_RX_INDICATION_POP_END: event recorded after netbuf pop
+ * @OL_RX_INDICATION_BUF_REPLENISH: event recorded after buffer replenishment
+ */
+enum ol_rx_ind_record_type {
+	OL_RX_INDICATION_POP_START,
+	OL_RX_INDICATION_POP_END,
+	OL_RX_INDICATION_BUF_REPLENISH,
+};
+
+/**
+ * struct ol_rx_ind_record - structure for detailing ol txrx rx ind. event
+ * @value: info corresponding to rx indication event
+ * @type: what the event was
+ * @time: when it happened
+ */
+struct ol_rx_ind_record {
+	uint16_t value;
+	enum ol_rx_ind_record_type type;
+	uint64_t time;
+};
+
+#ifdef OL_RX_INDICATION_RECORD
+static uint32_t ol_rx_ind_record_index;
+static struct ol_rx_ind_record
+	      ol_rx_indication_record_history[OL_RX_INDICATION_MAX_RECORDS];
+
+/**
+ * ol_rx_ind_record_event() - record ol rx indication events
+ * @value: contains rx ind. event related info
+ * @type: ol rx indication message type
+ *
+ * This API record the ol rx indiation event in a rx indication
+ * record buffer.
+ *
+ * Return: None
+ */
+static void ol_rx_ind_record_event(uint32_t value,
+				    enum ol_rx_ind_record_type type)
+{
+	ol_rx_indication_record_history[ol_rx_ind_record_index].value = value;
+	ol_rx_indication_record_history[ol_rx_ind_record_index].type = type;
+	ol_rx_indication_record_history[ol_rx_ind_record_index].time =
+							qdf_get_log_timestamp();
+
+	ol_rx_ind_record_index++;
+	if (ol_rx_ind_record_index >= OL_RX_INDICATION_MAX_RECORDS)
+		ol_rx_ind_record_index = 0;
+}
+#else
+static inline
+void ol_rx_ind_record_event(uint32_t value, enum ol_rx_ind_record_type type)
+{
+}
+
+#endif /* OL_RX_INDICATION_RECORD */
+
 void ol_rx_data_process(struct ol_txrx_peer_t *peer,
 			qdf_nbuf_t rx_buf_list);
 
@@ -1349,6 +1411,7 @@
 #ifdef WDI_EVENT_ENABLE
 	uint8_t pktlog_bit;
 #endif
+	uint32_t filled = 0;
 
 	if (pdev) {
 		if (qdf_unlikely(QDF_GLOBAL_MONITOR_MODE == cds_get_conparam()))
@@ -1376,12 +1439,16 @@
 	/* Get the total number of MSDUs */
 	msdu_count = HTT_RX_IN_ORD_PADDR_IND_MSDU_CNT_GET(*(msg_word + 1));
 
+	ol_rx_ind_record_event(msdu_count, OL_RX_INDICATION_POP_START);
+
 	/*
 	 * Get a linked list of the MSDUs in the rx in order indication.
 	 * This also attaches each rx MSDU descriptor to the
 	 * corresponding rx MSDU network buffer.
 	 */
 	status = htt_rx_amsdu_pop(htt_pdev, rx_ind_msg, &head_msdu, &tail_msdu);
+	ol_rx_ind_record_event(status, OL_RX_INDICATION_POP_END);
+
 	if (qdf_unlikely(0 == status)) {
 		ol_txrx_warn("%s: Pop status is 0, returning here\n", __func__);
 		return;
@@ -1390,7 +1457,8 @@
 	/* Replenish the rx buffer ring first to provide buffers to the target
 	   rather than waiting for the indeterminate time taken by the OS
 	   to consume the rx frames */
-	htt_rx_msdu_buff_in_order_replenish(htt_pdev, msdu_count);
+	filled = htt_rx_msdu_buff_in_order_replenish(htt_pdev, msdu_count);
+	ol_rx_ind_record_event(filled, OL_RX_INDICATION_BUF_REPLENISH);
 
 	/* Send the chain of MSDUs to the OS */
 	/* rx_opt_proc takes a NULL-terminated list of msdu netbufs */