qcacmn: Add new cdp API to get vdev in monitor mode

After gerrit#2436786, vdev in monitor mode is removed from vdev
list of pdev. So it is needed to add one more cdp API to get vdev
in monitor mode.

CRs-Fixed: 2343290
Change-Id: I9d74302a464280881ce0cf25dbc8c4f9d8b8d48d
diff --git a/dp/inc/cdp_txrx_cmn.h b/dp/inc/cdp_txrx_cmn.h
index 0ac21fe..31b814e 100644
--- a/dp/inc/cdp_txrx_cmn.h
+++ b/dp/inc/cdp_txrx_cmn.h
@@ -1126,6 +1126,24 @@
 			(pdev, vdev_id);
 }
 
+static inline struct cdp_vdev *
+cdp_get_mon_vdev_from_pdev(ol_txrx_soc_handle soc, struct cdp_pdev *pdev)
+{
+	if (!soc || !soc->ops) {
+		QDF_TRACE(QDF_MODULE_ID_CDP, QDF_TRACE_LEVEL_DEBUG,
+			  "%s: Invalid Instance:", __func__);
+		QDF_BUG(0);
+		return NULL;
+	}
+
+	if (!soc->ops->cmn_drv_ops ||
+	    !soc->ops->cmn_drv_ops->txrx_get_mon_vdev_from_pdev)
+		return NULL;
+
+	return soc->ops->cmn_drv_ops->txrx_get_mon_vdev_from_pdev
+			(pdev);
+}
+
 static inline void
 cdp_soc_detach(ol_txrx_soc_handle soc)
 {
diff --git a/dp/inc/cdp_txrx_ops.h b/dp/inc/cdp_txrx_ops.h
index 9a1a5fa..07852be 100644
--- a/dp/inc/cdp_txrx_ops.h
+++ b/dp/inc/cdp_txrx_ops.h
@@ -274,6 +274,15 @@
 	struct cdp_cfg *
 		(*txrx_get_ctrl_pdev_from_vdev)(struct cdp_vdev *vdev);
 
+	/**
+	 * txrx_get_mon_vdev_from_pdev() - Return monitor mode vdev
+	 * @pdev: pdev handle
+	 *
+	 * Return: Handle to vdev
+	 */
+	struct cdp_vdev *
+		(*txrx_get_mon_vdev_from_pdev)(struct cdp_pdev *pdev);
+
 	struct cdp_vdev *
 		(*txrx_get_vdev_from_vdev_id)(struct cdp_pdev *pdev,
 				uint8_t vdev_id);
diff --git a/dp/wifi3.0/dp_main.c b/dp/wifi3.0/dp_main.c
index 7708651..5b4b9e4 100644
--- a/dp/wifi3.0/dp_main.c
+++ b/dp/wifi3.0/dp_main.c
@@ -3799,8 +3799,10 @@
 
 	TAILQ_INIT(&vdev->peer_list);
 
-	if (wlan_op_mode_monitor == vdev->opmode)
+	if (wlan_op_mode_monitor == vdev->opmode) {
+		pdev->monitor_vdev = vdev;
 		return (struct cdp_vdev *)vdev;
+	}
 
 	vdev->tx_encap_type = wlan_cfg_pkt_type(soc->wlan_cfg_ctx);
 	vdev->rx_decap_type = wlan_cfg_pkt_type(soc->wlan_cfg_ctx);
@@ -4895,6 +4897,23 @@
 	return (struct cdp_vdev *)vdev;
 }
 
+/*
+ * dp_get_mon_vdev_from_pdev_wifi3() - Get vdev handle of monitor mode
+ * @dev: PDEV handle
+ *
+ * Return: VDEV handle of monitor mode
+ */
+
+static struct cdp_vdev *dp_get_mon_vdev_from_pdev_wifi3(struct cdp_pdev *dev)
+{
+	struct dp_pdev *pdev = (struct dp_pdev *)dev;
+
+	if (qdf_unlikely(!pdev))
+		return NULL;
+
+	return (struct cdp_vdev *)pdev->monitor_vdev;
+}
+
 static int dp_get_opmode(struct cdp_vdev *vdev_handle)
 {
 	struct dp_vdev *vdev = (struct dp_vdev *)vdev_handle;
@@ -8446,6 +8465,7 @@
 	.txrx_soc_detach = dp_soc_detach_wifi3,
 	.txrx_get_vdev_mac_addr = dp_get_vdev_mac_addr_wifi3,
 	.txrx_get_vdev_from_vdev_id = dp_get_vdev_from_vdev_id_wifi3,
+	.txrx_get_mon_vdev_from_pdev = dp_get_mon_vdev_from_pdev_wifi3,
 	.txrx_get_ctrl_pdev_from_vdev = dp_get_ctrl_pdev_from_vdev_wifi3,
 	.txrx_ath_getstats = dp_get_device_stats,
 	.addba_requestprocess = dp_addba_requestprocess_wifi3,