qcacmn: Add API to get mon mode mask in interrupt mode

Currently, monitor mode mask is being set while in interrupt mode. If
monitor mode rings are being processed in timer context(polled), both
timer and RX softirq end up processing monitor mode rings leading to
race condition. Monitor mode ring processing code is written to be
executed by a single context - either timer or softirq, not both.

Add an API to return zero monitor mode mask while in interrupt mode in
case timers are being used to process monitor mode rings.
So, in case packet log is enabled(based on a timer), regular interrupt
processing will not process monitor mode rings. It would be
done in a separate timer context.

Change-Id: I5cf5c881c2e2e07bac1b46646ee2a3b7cf42ef13
CRs-Fixed: 2266353
diff --git a/dp/wifi3.0/dp_main.c b/dp/wifi3.0/dp_main.c
index 8eb29e9..327a9ef 100644
--- a/dp/wifi3.0/dp_main.c
+++ b/dp/wifi3.0/dp_main.c
@@ -54,11 +54,9 @@
 #include "dp_ipa.h"
 
 #ifdef CONFIG_MCL
-static void dp_service_mon_rings(void *arg);
 #ifndef REMOVE_PKT_LOG
 #include <pktlog_ac_api.h>
 #include <pktlog_ac.h>
-static void dp_pkt_log_con_service(struct cdp_pdev *ppdev, void *scn);
 #endif
 #endif
 static void dp_pktlogmod_exit(struct dp_pdev *handle);
@@ -298,6 +296,144 @@
 	{TXRX_FW_STATS_INVALID, TXRX_RX_MON_STATS},
 };
 
+/* MCL specific functions */
+#ifdef CONFIG_MCL
+/**
+ * dp_soc_get_mon_mask_for_interrupt_mode() - get mon mode mask for intr mode
+ * @soc: pointer to dp_soc handle
+ * @intr_ctx_num: interrupt context number for which mon mask is needed
+ *
+ * For MCL, monitor mode rings are being processed in timer contexts (polled).
+ * This function is returning 0, since in interrupt mode(softirq based RX),
+ * we donot want to process monitor mode rings in a softirq.
+ *
+ * So, in case packet log is enabled for SAP/STA/P2P modes,
+ * regular interrupt processing will not process monitor mode rings. It would be
+ * done in a separate timer context.
+ *
+ * Return: 0
+ */
+static inline
+uint32_t dp_soc_get_mon_mask_for_interrupt_mode(struct dp_soc *soc, int intr_ctx_num)
+{
+	return 0;
+}
+
+/*
+ * dp_service_mon_rings()- timer to reap monitor rings
+ * reqd as we are not getting ppdu end interrupts
+ * @arg: SoC Handle
+ *
+ * Return:
+ *
+ */
+static void dp_service_mon_rings(void *arg)
+{
+	struct dp_soc *soc = (struct dp_soc *)arg;
+	int ring = 0, work_done, mac_id;
+	struct dp_pdev *pdev = NULL;
+
+	for  (ring = 0 ; ring < MAX_PDEV_CNT; ring++) {
+		pdev = soc->pdev_list[ring];
+		if (!pdev)
+			continue;
+		for (mac_id = 0; mac_id < NUM_RXDMA_RINGS_PER_PDEV; mac_id++) {
+			int mac_for_pdev = dp_get_mac_id_for_pdev(mac_id,
+								pdev->pdev_id);
+			work_done = dp_mon_process(soc, mac_for_pdev,
+						   QCA_NAPI_BUDGET);
+
+			QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
+				  FL("Reaped %d descs from Monitor rings"),
+				  work_done);
+		}
+	}
+
+	qdf_timer_mod(&soc->mon_reap_timer, DP_INTR_POLL_TIMER_MS);
+}
+
+#ifndef REMOVE_PKT_LOG
+/**
+ * dp_pkt_log_init() - API to initialize packet log
+ * @ppdev: physical device handle
+ * @scn: HIF context
+ *
+ * Return: none
+ */
+void dp_pkt_log_init(struct cdp_pdev *ppdev, void *scn)
+{
+	struct dp_pdev *handle = (struct dp_pdev *)ppdev;
+
+	if (handle->pkt_log_init) {
+		QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
+			  "%s: Packet log not initialized", __func__);
+		return;
+	}
+
+	pktlog_sethandle(&handle->pl_dev, scn);
+	pktlog_set_callback_regtype(PKTLOG_LITE_CALLBACK_REGISTRATION);
+
+	if (pktlogmod_init(scn)) {
+		QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
+			  "%s: pktlogmod_init failed", __func__);
+		handle->pkt_log_init = false;
+	} else {
+		handle->pkt_log_init = true;
+	}
+}
+
+/**
+ * dp_pkt_log_con_service() - connect packet log service
+ * @ppdev: physical device handle
+ * @scn: device context
+ *
+ * Return: none
+ */
+static void dp_pkt_log_con_service(struct cdp_pdev *ppdev, void *scn)
+{
+	struct dp_pdev *pdev = (struct dp_pdev *)ppdev;
+
+	dp_pkt_log_init((struct cdp_pdev *)pdev, scn);
+	pktlog_htc_attach();
+}
+
+/**
+ * dp_pktlogmod_exit() - API to cleanup pktlog info
+ * @handle: Pdev handle
+ *
+ * Return: none
+ */
+static void dp_pktlogmod_exit(struct dp_pdev *handle)
+{
+	void *scn = (void *)handle->soc->hif_handle;
+
+	if (!scn) {
+		QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
+			  "%s: Invalid hif(scn) handle", __func__);
+		return;
+	}
+
+	pktlogmod_exit(scn);
+	handle->pkt_log_init = false;
+}
+#endif
+#else
+static void dp_pktlogmod_exit(struct dp_pdev *handle) { }
+
+/**
+ * dp_soc_get_mon_mask_for_interrupt_mode() - get mon mode mask for intr mode
+ * @soc: pointer to dp_soc handle
+ * @intr_ctx_num: interrupt context number for which mon mask is needed
+ *
+ * Return: mon mask value
+ */
+static inline
+uint32_t dp_soc_get_mon_mask_for_interrupt_mode(struct dp_soc *soc, int intr_ctx_num)
+{
+	return wlan_cfg_get_rx_mon_ring_mask(soc->wlan_cfg_ctx, intr_ctx_num);
+}
+#endif
+
 static int dp_peer_add_ast_wifi3(struct cdp_soc_t *soc_hdl,
 					struct cdp_peer *peer_hdl,
 					uint8_t *mac_addr,
@@ -1275,7 +1411,7 @@
 		int rx_mask =
 			wlan_cfg_get_rx_ring_mask(soc->wlan_cfg_ctx, i);
 		int rx_mon_mask =
-			wlan_cfg_get_rx_mon_ring_mask(soc->wlan_cfg_ctx, i);
+			dp_soc_get_mon_mask_for_interrupt_mode(soc, i);
 		int rx_err_ring_mask =
 			wlan_cfg_get_rx_err_ring_mask(soc->wlan_cfg_ctx, i);
 		int rx_wbm_rel_ring_mask =
@@ -7848,107 +7984,3 @@
 	return 0;
 }
 #endif
-
-#ifdef CONFIG_MCL
-/*
- * dp_service_mon_rings()- timer to reap monitor rings
- * reqd as we are not getting ppdu end interrupts
- * @arg: SoC Handle
- *
- * Return:
- *
- */
-static void dp_service_mon_rings(void *arg)
-{
-	struct dp_soc *soc = (struct dp_soc *) arg;
-	int ring = 0, work_done, mac_id;
-	struct dp_pdev *pdev = NULL;
-
-	for  (ring = 0 ; ring < MAX_PDEV_CNT; ring++) {
-		pdev = soc->pdev_list[ring];
-		if (pdev == NULL)
-			continue;
-		for (mac_id = 0; mac_id < NUM_RXDMA_RINGS_PER_PDEV; mac_id++) {
-			int mac_for_pdev = dp_get_mac_id_for_pdev(mac_id,
-								pdev->pdev_id);
-			work_done = dp_mon_process(soc, mac_for_pdev,
-							QCA_NAPI_BUDGET);
-
-			QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
-				FL("Reaped %d descs from Monitor rings"),
-				work_done);
-		}
-	}
-
-	qdf_timer_mod(&soc->mon_reap_timer, DP_INTR_POLL_TIMER_MS);
-}
-
-#ifndef REMOVE_PKT_LOG
-/**
- * dp_pkt_log_init() - API to initialize packet log
- * @ppdev: physical device handle
- * @scn: HIF context
- *
- * Return: none
- */
-void dp_pkt_log_init(struct cdp_pdev *ppdev, void *scn)
-{
-	struct dp_pdev *handle = (struct dp_pdev *)ppdev;
-
-	if (handle->pkt_log_init) {
-		QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
-			 "%s: Packet log not initialized", __func__);
-		return;
-	}
-
-	pktlog_sethandle(&handle->pl_dev, scn);
-	pktlog_set_callback_regtype(PKTLOG_LITE_CALLBACK_REGISTRATION);
-
-	if (pktlogmod_init(scn)) {
-		QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
-			 "%s: pktlogmod_init failed", __func__);
-		handle->pkt_log_init = false;
-	} else {
-		handle->pkt_log_init = true;
-	}
-}
-
-/**
- * dp_pkt_log_con_service() - connect packet log service
- * @ppdev: physical device handle
- * @scn: device context
- *
- * Return: none
- */
-static void dp_pkt_log_con_service(struct cdp_pdev *ppdev, void *scn)
-{
-	struct dp_pdev *pdev = (struct dp_pdev *)ppdev;
-
-	dp_pkt_log_init((struct cdp_pdev *)pdev, scn);
-	pktlog_htc_attach();
-}
-
-/**
- * dp_pktlogmod_exit() - API to cleanup pktlog info
- * @handle: Pdev handle
- *
- * Return: none
- */
-static void dp_pktlogmod_exit(struct dp_pdev *handle)
-{
-	void *scn = (void *)handle->soc->hif_handle;
-
-	if (!scn) {
-		QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
-			 "%s: Invalid hif(scn) handle", __func__);
-		return;
-	}
-
-	pktlogmod_exit(scn);
-	handle->pkt_log_init = false;
-}
-#endif
-#else
-static void dp_pktlogmod_exit(struct dp_pdev *handle) { }
-#endif
-