qcacld-3.0: Use pdev_id instead of global dp handle

As a part of cdp convergence the pdev_id
is used to obtain the pdev handle on need
basis.

Instead of the pdev handle, use the pdev_id to
retrieve datapath pdev handle.

CRs-Fixed: 2539733
Change-Id: I887ea2f1a312207cbb642b33435f4e7111068c62
diff --git a/core/cds/src/cds_api.c b/core/cds/src/cds_api.c
index 72ddbc2e..e4f6231 100644
--- a/core/cds/src/cds_api.c
+++ b/core/cds/src/cds_api.c
@@ -810,7 +810,7 @@
 		false : gp_cds_context->cds_cfg->enable_dp_rx_threads;
 
 	qdf_status = dp_txrx_init(cds_get_context(QDF_MODULE_ID_SOC),
-				  cds_get_context(QDF_MODULE_ID_TXRX),
+				  WMI_PDEV_ID_SOC,
 				  &dp_config);
 
 	if (!QDF_IS_STATUS_SUCCESS(qdf_status))
diff --git a/core/dp/txrx/ol_rx.c b/core/dp/txrx/ol_rx.c
index bc8821d..2bc57cf 100644
--- a/core/dp/txrx/ol_rx.c
+++ b/core/dp/txrx/ol_rx.c
@@ -33,6 +33,7 @@
 #include <ol_rx_reorder_timeout.h>      /* OL_RX_REORDER_TIMEOUT_UPDATE */
 #include <ol_rx_defrag.h>       /* ol_rx_defrag_waitlist_flush */
 #include <ol_txrx_internal.h>
+#include <ol_txrx.h>
 #include <wdi_event.h>
 #ifdef QCA_SUPPORT_SW_TXRX_ENCAP
 #include <ol_txrx_encap.h>      /* ol_rx_decap_info_t, etc */
@@ -228,8 +229,15 @@
 void ol_rx_update_histogram_stats(uint32_t msdu_count, uint8_t frag_ind,
 		 uint8_t offload_ind)
 {
-	struct ol_txrx_pdev_t *pdev = cds_get_context(QDF_MODULE_ID_TXRX);
+	struct ol_txrx_soc_t *soc = cds_get_context(QDF_MODULE_ID_SOC);
+	ol_txrx_pdev_handle pdev;
 
+	if (qdf_unlikely(!soc)) {
+		ol_txrx_err("soc is NULL");
+		return;
+	}
+
+	pdev = ol_txrx_get_pdev_from_pdev_id(soc, OL_TXRX_PDEV_ID);
 	if (!pdev) {
 		ol_txrx_err("pdev is NULL");
 		return;
@@ -1672,12 +1680,18 @@
 	uint8_t peer_id,
 	uint8_t status)
 {
-	ol_txrx_pdev_handle pdev;
+	struct ol_txrx_soc_t *soc = cds_get_context(QDF_MODULE_ID_SOC);
+	ol_txrx_soc_handle soc_hdl = ol_txrx_soc_t_to_cdp_soc_t(soc);
 	struct ol_txrx_peer_t *peer = NULL;
 	ol_txrx_pktdump_cb packetdump_cb;
-	void *soc = cds_get_context(QDF_MODULE_ID_SOC);
+	ol_txrx_pdev_handle pdev;
 
-	pdev = cds_get_context(QDF_MODULE_ID_TXRX);
+	if (qdf_unlikely(!soc)) {
+		ol_txrx_err("soc is NULL");
+		return;
+	}
+
+	pdev = ol_txrx_get_pdev_from_pdev_id(soc, OL_TXRX_PDEV_ID);
 	if (!pdev) {
 		ol_txrx_err("pdev is NULL");
 		return;
@@ -1692,7 +1706,8 @@
 	packetdump_cb = pdev->ol_rx_packetdump_cb;
 	if (packetdump_cb &&
 	    wlan_op_mode_sta == peer->vdev->opmode)
-		packetdump_cb(soc, (struct cdp_vdev *)peer->vdev,
+		packetdump_cb(soc_hdl,
+			      (struct cdp_vdev *)peer->vdev,
 			      msdu, status, RX_DATA_PKT);
 }
 #endif
diff --git a/core/dp/txrx/ol_tx_send.c b/core/dp/txrx/ol_tx_send.c
index 70c3853..fbcae26 100644
--- a/core/dp/txrx/ol_tx_send.c
+++ b/core/dp/txrx/ol_tx_send.c
@@ -1617,8 +1617,15 @@
 #ifdef WLAN_FEATURE_TSF_PLUS
 void ol_register_timestamp_callback(tp_ol_timestamp_cb ol_tx_timestamp_cb)
 {
-	ol_txrx_pdev_handle pdev = cds_get_context(QDF_MODULE_ID_TXRX);
+	struct ol_txrx_soc_t *soc = cds_get_context(QDF_MODULE_ID_SOC);
+	ol_txrx_pdev_handle pdev;
 
+	if (qdf_unlikely(!soc)) {
+		ol_txrx_err("soc is NULL");
+		return;
+	}
+
+	pdev = ol_txrx_get_pdev_from_pdev_id(soc, OL_TXRX_PDEV_ID);
 	if (!pdev) {
 		ol_txrx_err("pdev is NULL");
 		return;
@@ -1628,8 +1635,10 @@
 
 void ol_deregister_timestamp_callback(void)
 {
-	ol_txrx_pdev_handle pdev = cds_get_context(QDF_MODULE_ID_TXRX);
+	struct ol_txrx_soc_t *soc = cds_get_context(QDF_MODULE_ID_SOC);
+	ol_txrx_pdev_handle pdev;
 
+	pdev = ol_txrx_get_pdev_from_pdev_id(soc, OL_TXRX_PDEV_ID);
 	if (!pdev) {
 		ol_txrx_err("pdev is NULL");
 		return;
diff --git a/core/dp/txrx/ol_txrx.c b/core/dp/txrx/ol_txrx.c
index d978b94..1e049c9 100644
--- a/core/dp/txrx/ol_txrx.c
+++ b/core/dp/txrx/ol_txrx.c
@@ -61,6 +61,7 @@
 #include <ol_txrx_types.h>
 #include <ol_cfg.h>
 #include <cdp_txrx_flow_ctrl_legacy.h>
+#include <cdp_txrx_cmn_reg.h>
 #include <cdp_txrx_bus.h>
 #include <cdp_txrx_ipa.h>
 #include <cdp_txrx_pmf.h>
@@ -147,12 +148,20 @@
  */
 void ol_tx_set_is_mgmt_over_wmi_enabled(uint8_t value)
 {
-	struct ol_txrx_pdev_t *pdev = cds_get_context(QDF_MODULE_ID_TXRX);
+	struct ol_txrx_soc_t *soc = cds_get_context(QDF_MODULE_ID_SOC);
+	ol_txrx_pdev_handle pdev;
 
-	if (!pdev) {
-		qdf_print("pdev is NULL");
+	if (qdf_unlikely(!soc)) {
+		ol_txrx_err("soc is NULL");
 		return;
 	}
+
+	pdev = ol_txrx_get_pdev_from_pdev_id(soc, OL_TXRX_PDEV_ID);
+	if (!pdev) {
+		ol_txrx_err("pdev is NULL");
+		return;
+	}
+
 	pdev->is_mgmt_over_wmi_enabled = value;
 }
 
@@ -163,12 +172,20 @@
  */
 uint8_t ol_tx_get_is_mgmt_over_wmi_enabled(void)
 {
-	struct ol_txrx_pdev_t *pdev = cds_get_context(QDF_MODULE_ID_TXRX);
+	struct ol_txrx_soc_t *soc = cds_get_context(QDF_MODULE_ID_SOC);
+	ol_txrx_pdev_handle pdev;
 
-	if (!pdev) {
-		qdf_print("pdev is NULL");
+	if (qdf_unlikely(!soc)) {
+		ol_txrx_err("soc is NULL");
 		return 0;
 	}
+
+	pdev = ol_txrx_get_pdev_from_pdev_id(soc, OL_TXRX_PDEV_ID);
+	if (!pdev) {
+		ol_txrx_err("pdev is NULL");
+		return 0;
+	}
+
 	return pdev->is_mgmt_over_wmi_enabled;
 }
 
@@ -1592,7 +1609,7 @@
 	struct ol_txrx_stats_req_internal *req, *temp_req;
 	int i = 0;
 
-	if (!soc)
+	if (!soc) {
 		ol_txrx_err("soc is NULL");
 		return;
 	}
@@ -2086,11 +2103,17 @@
 
 static void ol_txrx_flush_cache_rx_queue(void)
 {
+	struct ol_txrx_soc_t *soc = cds_get_context(QDF_MODULE_ID_SOC);
 	struct ol_txrx_peer_t *peer;
-	struct ol_txrx_pdev_t *pdev;
 	struct ol_txrx_vdev_t *vdev;
+	ol_txrx_pdev_handle pdev;
 
-	pdev = cds_get_context(QDF_MODULE_ID_TXRX);
+	if (qdf_unlikely(!soc)) {
+		ol_txrx_err("soc is NULL");
+		return;
+	}
+
+	pdev = ol_txrx_get_pdev_from_pdev_id(soc, OL_TXRX_PDEV_ID);
 	if (!pdev)
 		return;
 
@@ -3408,8 +3431,15 @@
  */
 static QDF_STATUS ol_txrx_wait_for_pending_tx(int timeout)
 {
-	struct ol_txrx_pdev_t *txrx_pdev = cds_get_context(QDF_MODULE_ID_TXRX);
+	struct ol_txrx_soc_t *soc = cds_get_context(QDF_MODULE_ID_SOC);
+	struct ol_txrx_pdev_t *txrx_pdev;
 
+	if (qdf_unlikely(!soc)) {
+		ol_txrx_err("soc is NULL");
+		return QDF_STATUS_E_FAULT;
+	}
+
+	txrx_pdev = ol_txrx_get_pdev_from_pdev_id(soc, OL_TXRX_PDEV_ID);
 	if (!txrx_pdev) {
 		ol_txrx_err("txrx context is null");
 		return QDF_STATUS_E_FAULT;
@@ -4547,9 +4577,21 @@
  */
 static inline int ol_txrx_drop_nbuf_list(qdf_nbuf_t buf_list)
 {
+	struct ol_txrx_soc_t *soc = cds_get_context(QDF_MODULE_ID_SOC);
+	ol_txrx_pdev_handle pdev;
 	int num_dropped = 0;
 	qdf_nbuf_t buf, next_buf;
-	ol_txrx_pdev_handle pdev = cds_get_context(QDF_MODULE_ID_TXRX);
+
+	if (qdf_unlikely(!soc)) {
+		ol_txrx_err("soc is NULL");
+		return 0;
+	}
+
+	pdev = ol_txrx_get_pdev_from_pdev_id(soc, OL_TXRX_PDEV_ID);
+	if (!pdev) {
+		ol_txrx_err("pdev is NULL");
+		return 0;
+	}
 
 	buf = buf_list;
 	while (buf) {
@@ -4737,14 +4779,21 @@
 void ol_rx_data_process(struct ol_txrx_peer_t *peer,
 			qdf_nbuf_t rx_buf_list)
 {
+	struct ol_txrx_soc_t *soc = cds_get_context(QDF_MODULE_ID_SOC);
+	ol_txrx_pdev_handle pdev;
 	/*
 	 * Firmware data path active response will use shim RX thread
 	 * T2H MSG running on SIRQ context,
 	 * IPA kernel module API should not be called on SIRQ CTXT
 	 */
 	ol_txrx_rx_fp data_rx = NULL;
-	ol_txrx_pdev_handle pdev = cds_get_context(QDF_MODULE_ID_TXRX);
 
+	if (qdf_unlikely(!soc)) {
+		ol_txrx_err("soc is NULL");
+		goto drop_rx_buf;
+	}
+
+	pdev = ol_txrx_get_pdev_from_pdev_id(soc, OL_TXRX_PDEV_ID);
 	if ((!peer) || (!pdev)) {
 		ol_txrx_err("peer/pdev is NULL");
 		goto drop_rx_buf;
@@ -4966,10 +5015,18 @@
 					qdf_nbuf_t rxpkt,
 					uint16_t staid)
 {
-	ol_txrx_pdev_handle pdev = cds_get_context(QDF_MODULE_ID_TXRX);
+	struct ol_txrx_soc_t *soc = cds_get_context(QDF_MODULE_ID_SOC);
+	ol_txrx_pdev_handle pdev;
 
+	if (qdf_unlikely(!soc)) {
+		ol_txrx_err("Invalid soc context");
+		qdf_assert(0);
+		return;
+	}
+
+	pdev = ol_txrx_get_pdev_from_pdev_id(soc, OL_TXRX_PDEV_ID);
 	if (qdf_unlikely(!pdev)) {
-		ol_txrx_err("Invalid context");
+		ol_txrx_err("Invalid pdev context");
 		qdf_assert(0);
 		return;
 	}
@@ -4993,11 +5050,18 @@
 {
 	p_cds_sched_context sched_ctx = get_cds_sched_ctxt();
 	struct cds_ol_rx_pkt *pkt;
-	ol_txrx_pdev_handle pdev = cds_get_context(QDF_MODULE_ID_TXRX);
+	struct ol_txrx_soc_t *soc = cds_get_context(QDF_MODULE_ID_SOC);
+	ol_txrx_pdev_handle pdev;
 
 	if (qdf_unlikely(!sched_ctx))
 		return;
 
+	if (qdf_unlikely(!soc)) {
+		ol_txrx_err("soc is NULL");
+		return;
+	}
+
+	pdev = ol_txrx_get_pdev_from_pdev_id(soc, OL_TXRX_PDEV_ID);
 	if (qdf_unlikely(!pdev)) {
 		ol_txrx_err("TXRX module context is NULL");
 		return;
@@ -5031,8 +5095,16 @@
 static void ol_register_offld_flush_cb(void (offld_flush_cb)(void *))
 {
 	struct hif_opaque_softc *hif_device;
-	struct ol_txrx_pdev_t *pdev = cds_get_context(QDF_MODULE_ID_TXRX);
+	struct ol_txrx_soc_t *soc = cds_get_context(QDF_MODULE_ID_SOC);
+	ol_txrx_pdev_handle pdev;
 
+	if (qdf_unlikely(!soc)) {
+		ol_txrx_err("soc NULL!");
+		TXRX_ASSERT2(0);
+		goto out;
+	}
+
+	pdev = ol_txrx_get_pdev_from_pdev_id(soc, OL_TXRX_PDEV_ID);
 	if (!pdev) {
 		ol_txrx_err("pdev NULL!");
 		TXRX_ASSERT2(0);
@@ -5074,8 +5146,15 @@
 static void ol_deregister_offld_flush_cb(void)
 {
 	struct hif_opaque_softc *hif_device;
-	struct ol_txrx_pdev_t *pdev = cds_get_context(QDF_MODULE_ID_TXRX);
+	struct ol_txrx_soc_t *soc = cds_get_context(QDF_MODULE_ID_SOC);
+	ol_txrx_pdev_handle pdev;
 
+	if (qdf_unlikely(!soc)) {
+		ol_txrx_err("soc is NULL");
+		return;
+	}
+
+	pdev = ol_txrx_get_pdev_from_pdev_id(soc, OL_TXRX_PDEV_ID);
 	if (!pdev) {
 		ol_txrx_err("pdev NULL!");
 		return;
@@ -5198,18 +5277,28 @@
 		       qdf_nbuf_data(nbuf), len, true);
 }
 
-/**
- * ol_txrx_get_vdev_from_vdev_id() - get vdev from vdev_id
- * @vdev_id: vdev_id
- *
- * Return: vdev handle
- *            NULL if not found.
- */
 struct cdp_vdev *ol_txrx_get_vdev_from_vdev_id(uint8_t vdev_id)
 {
-	ol_txrx_pdev_handle pdev = cds_get_context(QDF_MODULE_ID_TXRX);
+	struct ol_txrx_soc_t *soc = cds_get_context(QDF_MODULE_ID_SOC);
 	ol_txrx_vdev_handle vdev = NULL;
 
+	if (qdf_unlikely(!soc)) {
+		ol_txrx_err("soc is NULL");
+		return NULL;
+	}
+
+	vdev = ol_txrx_get_vdev_from_soc_vdev_id(soc, vdev_id);
+
+	return ol_txrx_vdev_t_to_cdp_vdev(vdev);
+}
+
+struct ol_txrx_vdev_t *ol_txrx_get_vdev_from_soc_vdev_id(
+				struct ol_txrx_soc_t *soc, uint8_t vdev_id)
+{
+	ol_txrx_pdev_handle pdev;
+	ol_txrx_vdev_handle vdev = NULL;
+
+	pdev = ol_txrx_get_pdev_from_pdev_id(soc, OL_TXRX_PDEV_ID);
 	if (qdf_unlikely(!pdev))
 		return NULL;
 
@@ -5218,7 +5307,7 @@
 			break;
 	}
 
-	return (struct cdp_vdev *)vdev;
+	return vdev;
 }
 
 /**
@@ -5934,8 +6023,10 @@
 
 void ol_txrx_set_new_htt_msg_format(uint8_t val)
 {
-	struct ol_txrx_pdev_t *pdev = cds_get_context(QDF_MODULE_ID_TXRX);
+	struct ol_txrx_soc_t *soc = cds_get_context(QDF_MODULE_ID_SOC);
+	ol_txrx_pdev_handle pdev;
 
+	pdev = ol_txrx_get_pdev_from_pdev_id(soc, OL_TXRX_PDEV_ID);
 	if (!pdev) {
 		qdf_print("%s: pdev is NULL\n", __func__);
 		return;
@@ -5945,8 +6036,15 @@
 
 bool ol_txrx_get_peer_unmap_conf_support(void)
 {
-	struct ol_txrx_pdev_t *pdev = cds_get_context(QDF_MODULE_ID_TXRX);
+	struct ol_txrx_soc_t *soc = cds_get_context(QDF_MODULE_ID_SOC);
+	ol_txrx_pdev_handle pdev;
 
+	if (qdf_unlikely(!soc)) {
+		ol_txrx_err("soc is NULL");
+		return false;
+	}
+
+	pdev = ol_txrx_get_pdev_from_pdev_id(soc, OL_TXRX_PDEV_ID);
 	if (!pdev) {
 		qdf_print("%s: pdev is NULL\n", __func__);
 		return false;
@@ -5956,8 +6054,15 @@
 
 void ol_txrx_set_peer_unmap_conf_support(bool val)
 {
-	struct ol_txrx_pdev_t *pdev = cds_get_context(QDF_MODULE_ID_TXRX);
+	struct ol_txrx_soc_t *soc = cds_get_context(QDF_MODULE_ID_SOC);
+	ol_txrx_pdev_handle pdev;
 
+	if (qdf_unlikely(!soc)) {
+		ol_txrx_err("soc is NULL");
+		return;
+	}
+
+	pdev = ol_txrx_get_pdev_from_pdev_id(soc, OL_TXRX_PDEV_ID);
 	if (!pdev) {
 		qdf_print("%s: pdev is NULL\n", __func__);
 		return;
@@ -5968,8 +6073,15 @@
 #ifdef WLAN_FEATURE_TSF_PLUS
 bool ol_txrx_get_tx_compl_tsf64(void)
 {
-	struct ol_txrx_pdev_t *pdev = cds_get_context(QDF_MODULE_ID_TXRX);
+	struct ol_txrx_soc_t *soc = cds_get_context(QDF_MODULE_ID_SOC);
+	ol_txrx_pdev_handle pdev;
 
+	if (qdf_unlikely(!soc)) {
+		ol_txrx_err("soc is NULL");
+		return false;
+	}
+
+	pdev = ol_txrx_get_pdev_from_pdev_id(soc, OL_TXRX_PDEV_ID);
 	if (!pdev) {
 		qdf_print("%s: pdev is NULL\n", __func__);
 		return false;
@@ -5979,12 +6091,20 @@
 
 void ol_txrx_set_tx_compl_tsf64(bool val)
 {
-	struct ol_txrx_pdev_t *pdev = cds_get_context(QDF_MODULE_ID_TXRX);
+	struct ol_txrx_soc_t *soc = cds_get_context(QDF_MODULE_ID_SOC);
+	ol_txrx_pdev_handle pdev;
 
-	if (!pdev) {
-		qdf_print("%s: pdev is NULL\n", __func__);
+	if (qdf_unlikely(!soc)) {
+		ol_txrx_err("soc is NULL");
 		return;
 	}
+
+	pdev = ol_txrx_get_pdev_from_pdev_id(soc, OL_TXRX_PDEV_ID);
+	if (!pdev) {
+		ol_txrx_err("pdev is NULL");
+		return;
+	}
+
 	pdev->enable_tx_compl_tsf64 = val;
 }
 #else
diff --git a/core/dp/txrx/ol_txrx.h b/core/dp/txrx/ol_txrx.h
index dfec188..a583fc0 100644
--- a/core/dp/txrx/ol_txrx.h
+++ b/core/dp/txrx/ol_txrx.h
@@ -27,6 +27,8 @@
 #include <ol_txrx_internal.h>
 #include <qdf_hrtimer.h>
 
+#define OL_TXRX_PDEV_ID 0
+
 /*
  * Pool of tx descriptors reserved for
  * high-priority traffic, such as ARP/EAPOL etc
@@ -150,6 +152,21 @@
 				 enum peer_debug_id_type dbg_id);
 #endif /* QCA_SUPPORT_TXRX_LOCAL_PEER_ID */
 
+/**
+ * ol_txrx_get_pdev_from_pdev_id() - Returns pdev object given the pdev id
+ * @soc: core DP soc context
+ * @pdev_id: pdev id from pdev object can be retrieved
+ *
+ * Return: Pointer to DP pdev object
+ */
+
+static inline struct ol_txrx_pdev_t *
+ol_txrx_get_pdev_from_pdev_id(struct ol_txrx_soc_t *soc,
+			      uint8_t pdev_id)
+{
+	return soc->pdev_list[pdev_id];
+}
+
 /*
  * @nbuf: buffer which contains data to be displayed
  * @nbuf_paddr: physical address of the buffer
@@ -160,9 +177,27 @@
 void
 ol_txrx_dump_pkt(qdf_nbuf_t nbuf, uint32_t nbuf_paddr, int len);
 
+/**
+ * ol_txrx_get_vdev_from_vdev_id() - get vdev from vdev_id
+ * @vdev_id: vdev_id
+ *
+ * Return: vdev handle
+ *            NULL if not found.
+ */
 struct cdp_vdev *ol_txrx_get_vdev_from_vdev_id(uint8_t vdev_id);
 
 /**
+ * ol_txrx_get_vdev_from_soc_vdev_id() - get vdev from soc and vdev_id
+ * @soc: datapath soc handle
+ * @vdev_id: vdev_id
+ *
+ * Return: vdev handle
+ *            NULL if not found.
+ */
+struct ol_txrx_vdev_t *ol_txrx_get_vdev_from_soc_vdev_id(
+				struct ol_txrx_soc_t *soc, uint8_t vdev_id);
+
+/**
  * ol_txrx_get_mon_vdev_from_pdev() - get monitor mode vdev from pdev
  * @ppdev: the physical device the virtual device belongs to
  *
@@ -342,6 +377,54 @@
 	return (struct cdp_soc_t *)soc;
 }
 
+/**
+ * cdp_pdev_to_ol_txrx_pdev_t() - typecast cdp_pdev to ol_txrx_pdev_t
+ * @pdev: OL pdev handle
+ *
+ * Return: struct ol_txrx_pdev_t pointer
+ */
+static inline
+struct ol_txrx_pdev_t *cdp_pdev_to_ol_txrx_pdev_t(struct cdp_pdev *pdev)
+{
+	return (struct ol_txrx_pdev_t *)pdev;
+}
+
+/**
+ * ol_txrx_pdev_t_to_cdp_pdev() - typecast ol_txrx_pdev_t to cdp_pdev
+ * @pdev: Opaque pdev handle
+ *
+ * Return: struct cdp_pdev pointer
+ */
+static inline
+struct cdp_pdev *ol_txrx_pdev_t_to_cdp_pdev(struct ol_txrx_pdev_t *pdev)
+{
+	return (struct cdp_pdev *)pdev;
+}
+
+/**
+ * cdp_vdev_to_ol_txrx_vdev_t() - typecast cdp_vdev to ol_txrx_vdev_t
+ * @vdev: OL vdev handle
+ *
+ * Return: struct ol_txrx_vdev_t pointer
+ */
+static inline
+struct ol_txrx_vdev_t *cdp_vdev_to_ol_txrx_vdev_t(struct cdp_vdev *vdev)
+{
+	return (struct ol_txrx_vdev_t *)vdev;
+}
+
+/**
+ * ol_txrx_vdev_t_to_cdp_vdev() - typecast ol_txrx_vdev_t to cdp_vdev
+ * @vdev: Opaque vdev handle
+ *
+ * Return: struct cdp_vdev pointer
+ */
+static inline
+struct cdp_vdev *ol_txrx_vdev_t_to_cdp_vdev(struct ol_txrx_vdev_t *vdev)
+{
+	return (struct cdp_vdev *)vdev;
+}
+
 #ifdef QCA_LL_TX_FLOW_CONTROL_V2
 void ol_tx_set_desc_global_pool_size(uint32_t num_msdu_desc);
 uint32_t ol_tx_get_total_free_desc(struct ol_txrx_pdev_t *pdev);
diff --git a/core/dp/txrx/ol_txrx_flow_control.c b/core/dp/txrx/ol_txrx_flow_control.c
index 74ba806..212cf5a 100644
--- a/core/dp/txrx/ol_txrx_flow_control.c
+++ b/core/dp/txrx/ol_txrx_flow_control.c
@@ -113,8 +113,15 @@
  */
 void ol_tx_set_desc_global_pool_size(uint32_t num_msdu_desc)
 {
-	struct ol_txrx_pdev_t *pdev = cds_get_context(QDF_MODULE_ID_TXRX);
+	struct ol_txrx_soc_t *soc = cds_get_context(QDF_MODULE_ID_SOC);
+	ol_txrx_pdev_handle pdev;
 
+	if (qdf_unlikely(!soc)) {
+		ol_txrx_err("soc is NULL");
+		return;
+	}
+
+	pdev = ol_txrx_get_pdev_from_pdev_id(soc, OL_TXRX_PDEV_ID);
 	if (!pdev) {
 		qdf_print("pdev is NULL");
 		return;
@@ -210,7 +217,8 @@
  */
 static int ol_tx_delete_flow_pool(struct ol_tx_flow_pool_t *pool, bool force)
 {
-	struct ol_txrx_pdev_t *pdev = cds_get_context(QDF_MODULE_ID_TXRX);
+	struct ol_txrx_soc_t *soc = cds_get_context(QDF_MODULE_ID_SOC);
+	ol_txrx_pdev_handle pdev;
 	uint16_t i, size;
 	union ol_tx_desc_list_elem_t *temp_list = NULL;
 	struct ol_tx_desc_t *tx_desc = NULL;
@@ -220,6 +228,14 @@
 		QDF_ASSERT(0);
 		return -ENOMEM;
 	}
+
+	if (qdf_unlikely(!soc)) {
+		ol_txrx_err("soc is NULL");
+		QDF_ASSERT(0);
+		return -ENOMEM;
+	}
+
+	pdev = ol_txrx_get_pdev_from_pdev_id(soc, OL_TXRX_PDEV_ID);
 	if (!pdev) {
 		ol_txrx_err("pdev is NULL");
 		QDF_ASSERT(0);
@@ -294,7 +310,8 @@
 
 QDF_STATUS ol_tx_dec_pool_ref(struct ol_tx_flow_pool_t *pool, bool force)
 {
-	struct ol_txrx_pdev_t *pdev = cds_get_context(QDF_MODULE_ID_TXRX);
+	struct ol_txrx_soc_t *soc = cds_get_context(QDF_MODULE_ID_SOC);
+	ol_txrx_pdev_handle pdev;
 
 	if (!pool) {
 		ol_txrx_err("flow pool is NULL");
@@ -302,6 +319,13 @@
 		return QDF_STATUS_E_INVAL;
 	}
 
+	if (qdf_unlikely(!soc)) {
+		ol_txrx_err("soc is NULL");
+		QDF_ASSERT(0);
+		return QDF_STATUS_E_INVAL;
+	}
+
+	pdev = ol_txrx_get_pdev_from_pdev_id(soc, OL_TXRX_PDEV_ID);
 	if (!pdev) {
 		ol_txrx_err("pdev is NULL");
 		QDF_ASSERT(0);
@@ -463,8 +487,15 @@
  */
 void ol_tx_clear_flow_pool_stats(void)
 {
-	struct ol_txrx_pdev_t *pdev = cds_get_context(QDF_MODULE_ID_TXRX);
+	struct ol_txrx_soc_t *soc = cds_get_context(QDF_MODULE_ID_SOC);
+	ol_txrx_pdev_handle pdev;
 
+	if (qdf_unlikely(!soc)) {
+		ol_txrx_err("soc is NULL");
+		return;
+	}
+
+	pdev = ol_txrx_get_pdev_from_pdev_id(soc, OL_TXRX_PDEV_ID);
 	if (!pdev) {
 		ol_txrx_err("pdev is null");
 		return;
@@ -537,11 +568,18 @@
 static int
 ol_tx_distribute_descs_to_deficient_pools(struct ol_tx_flow_pool_t *src_pool)
 {
-	struct ol_txrx_pdev_t *pdev = cds_get_context(QDF_MODULE_ID_TXRX);
+	struct ol_txrx_soc_t *soc = cds_get_context(QDF_MODULE_ID_SOC);
+	ol_txrx_pdev_handle pdev;
 	struct ol_tx_flow_pool_t *dst_pool = NULL;
 	uint16_t desc_count = src_pool->avail_desc;
 	uint16_t desc_move_count = 0;
 
+	if (qdf_unlikely(!soc)) {
+		ol_txrx_err("soc is NULL");
+		return -EINVAL;
+	}
+
+	pdev = ol_txrx_get_pdev_from_pdev_id(soc, OL_TXRX_PDEV_ID);
 	if (!pdev) {
 		ol_txrx_err("pdev is NULL");
 		return -EINVAL;
@@ -594,7 +632,8 @@
 struct ol_tx_flow_pool_t *ol_tx_create_flow_pool(uint8_t flow_pool_id,
 						 uint16_t flow_pool_size)
 {
-	struct ol_txrx_pdev_t *pdev = cds_get_context(QDF_MODULE_ID_TXRX);
+	struct ol_txrx_soc_t *soc = cds_get_context(QDF_MODULE_ID_SOC);
+	ol_txrx_pdev_handle pdev;
 	struct ol_tx_flow_pool_t *pool;
 	uint16_t size = 0, i;
 	struct ol_tx_desc_t *tx_desc;
@@ -602,6 +641,12 @@
 	uint32_t stop_threshold;
 	uint32_t start_threshold;
 
+	if (qdf_unlikely(!soc)) {
+		ol_txrx_err("soc is NULL");
+		return NULL;
+	}
+
+	pdev = ol_txrx_get_pdev_from_pdev_id(soc, OL_TXRX_PDEV_ID);
 	if (!pdev) {
 		ol_txrx_err("pdev is NULL");
 		return NULL;
@@ -670,8 +715,15 @@
  */
 int ol_tx_free_invalid_flow_pool(struct ol_tx_flow_pool_t *pool)
 {
-	struct ol_txrx_pdev_t *pdev = cds_get_context(QDF_MODULE_ID_TXRX);
+	struct ol_txrx_soc_t *soc = cds_get_context(QDF_MODULE_ID_SOC);
+	ol_txrx_pdev_handle pdev;
 
+	if (qdf_unlikely(!soc)) {
+		ol_txrx_err("soc is NULL");
+		return -EINVAL;
+	}
+
+	pdev = ol_txrx_get_pdev_from_pdev_id(soc, OL_TXRX_PDEV_ID);
 	if ((!pdev) || (!pool) || (pool->status != FLOW_POOL_INVALID)) {
 		ol_txrx_err("Invalid pool/pdev");
 		return -EINVAL;
@@ -699,10 +751,18 @@
  */
 static struct ol_tx_flow_pool_t *ol_tx_get_flow_pool(uint8_t flow_pool_id)
 {
-	struct ol_txrx_pdev_t *pdev = cds_get_context(QDF_MODULE_ID_TXRX);
+	struct ol_txrx_soc_t *soc = cds_get_context(QDF_MODULE_ID_SOC);
+	ol_txrx_pdev_handle pdev;
 	struct ol_tx_flow_pool_t *pool = NULL;
 	bool is_found = false;
 
+	if (qdf_unlikely(!soc)) {
+		ol_txrx_err("soc is NULL");
+		QDF_ASSERT(0);
+		return NULL;
+	}
+
+	pdev = ol_txrx_get_pdev_from_pdev_id(soc, OL_TXRX_PDEV_ID);
 	if (!pdev) {
 		ol_txrx_err("ERROR: pdev NULL");
 		QDF_ASSERT(0); /* traceback */
@@ -791,7 +851,8 @@
 void ol_tx_flow_pool_map_handler(uint8_t flow_id, uint8_t flow_type,
 				 uint8_t flow_pool_id, uint16_t flow_pool_size)
 {
-	struct ol_txrx_pdev_t *pdev = cds_get_context(QDF_MODULE_ID_TXRX);
+	struct ol_txrx_soc_t *soc = cds_get_context(QDF_MODULE_ID_SOC);
+	ol_txrx_pdev_handle pdev;
 	struct ol_tx_flow_pool_t *pool;
 	uint8_t pool_create = 0;
 	enum htt_flow_type type = flow_type;
@@ -799,6 +860,12 @@
 	ol_txrx_dbg("flow_id %d flow_type %d flow_pool_id %d flow_pool_size %d",
 		    flow_id, flow_type, flow_pool_id, flow_pool_size);
 
+	if (qdf_unlikely(!soc)) {
+		ol_txrx_err("soc is NULL");
+		return;
+	}
+
+	pdev = ol_txrx_get_pdev_from_pdev_id(soc, OL_TXRX_PDEV_ID);
 	if (qdf_unlikely(!pdev)) {
 		ol_txrx_err("pdev is NULL");
 		return;
@@ -849,13 +916,20 @@
 void ol_tx_flow_pool_unmap_handler(uint8_t flow_id, uint8_t flow_type,
 							  uint8_t flow_pool_id)
 {
-	struct ol_txrx_pdev_t *pdev = cds_get_context(QDF_MODULE_ID_TXRX);
+	struct ol_txrx_soc_t *soc = cds_get_context(QDF_MODULE_ID_SOC);
+	ol_txrx_pdev_handle pdev;
 	struct ol_tx_flow_pool_t *pool;
 	enum htt_flow_type type = flow_type;
 
 	ol_txrx_dbg("flow_id %d flow_type %d flow_pool_id %d",
 		    flow_id, flow_type, flow_pool_id);
 
+	if (qdf_unlikely(!soc)) {
+		ol_txrx_err("soc is NULL");
+		return;
+	}
+
+	pdev = ol_txrx_get_pdev_from_pdev_id(soc, OL_TXRX_PDEV_ID);
 	if (qdf_unlikely(!pdev)) {
 		ol_txrx_err("pdev is NULL");
 		return;
@@ -896,7 +970,8 @@
  */
 int ol_tx_distribute_descs_to_deficient_pools_from_global_pool(void)
 {
-	struct ol_txrx_pdev_t *pdev = cds_get_context(QDF_MODULE_ID_TXRX);
+	struct ol_txrx_soc_t *soc = cds_get_context(QDF_MODULE_ID_SOC);
+	ol_txrx_pdev_handle pdev;
 	struct ol_tx_flow_pool_t *dst_pool = NULL;
 	struct ol_tx_flow_pool_t *tmp_pool = NULL;
 	uint16_t total_desc_req = 0;
@@ -906,6 +981,12 @@
 	struct ol_tx_desc_t *tx_desc;
 	uint8_t free_invalid_pool = 0;
 
+	if (qdf_unlikely(!soc)) {
+		ol_txrx_err("soc is NULL");
+		return -EINVAL;
+	}
+
+	pdev = ol_txrx_get_pdev_from_pdev_id(soc, OL_TXRX_PDEV_ID);
 	if (!pdev) {
 		ol_txrx_err("pdev is NULL");
 		return -EINVAL;
@@ -1032,12 +1113,23 @@
 				   uint16_t deficient_count,
 				   uint16_t overflow_count)
 {
-	struct ol_txrx_pdev_t *pdev = cds_get_context(QDF_MODULE_ID_TXRX);
+	struct ol_txrx_soc_t *soc = cds_get_context(QDF_MODULE_ID_SOC);
+	ol_txrx_pdev_handle pdev;
 	uint32_t stop_threshold =
 			 ol_cfg_get_tx_flow_stop_queue_th(pdev->ctrl_pdev);
 	uint32_t start_threshold = stop_threshold +
 			ol_cfg_get_tx_flow_start_queue_offset(pdev->ctrl_pdev);
 
+	if (qdf_unlikely(!soc)) {
+		ol_txrx_err("soc is NULL");
+		return 0;
+	}
+
+	pdev = ol_txrx_get_pdev_from_pdev_id(soc, OL_TXRX_PDEV_ID);
+	if (!pdev) {
+		ol_txrx_err("pdev is NULL");
+		return 0;
+	}
 	pool->flow_pool_size = new_pool_size;
 	pool->start_th = (start_threshold * new_pool_size) / 100;
 	pool->stop_th = (stop_threshold * new_pool_size) / 100;
@@ -1066,7 +1158,8 @@
 static void ol_tx_flow_pool_resize(struct ol_tx_flow_pool_t *pool,
 				   uint16_t new_pool_size)
 {
-	struct ol_txrx_pdev_t *pdev = cds_get_context(QDF_MODULE_ID_TXRX);
+	struct ol_txrx_soc_t *soc = cds_get_context(QDF_MODULE_ID_SOC);
+	ol_txrx_pdev_handle pdev;
 	uint16_t diff = 0, overflow_count = 0, deficient_count = 0;
 	uint16_t move_desc_to_global = 0, move_desc_from_global = 0;
 	union ol_tx_desc_list_elem_t *temp_list = NULL;
@@ -1074,6 +1167,17 @@
 	struct ol_tx_desc_t *tx_desc = NULL;
 	uint16_t temp = 0;
 
+	if (qdf_unlikely(!soc)) {
+		ol_txrx_err("soc is NULL");
+		return 0;
+	}
+
+	pdev = ol_txrx_get_pdev_from_pdev_id(soc, OL_TXRX_PDEV_ID);
+	if (!pdev) {
+		ol_txrx_err("pdev is NULL");
+		return 0;
+	}
+
 	qdf_spin_lock_bh(&pool->flow_pool_lock);
 	if (pool->flow_pool_size == new_pool_size) {
 		qdf_spin_unlock_bh(&pool->flow_pool_lock);
@@ -1198,12 +1302,19 @@
 void ol_tx_flow_pool_resize_handler(uint8_t flow_pool_id,
 				    uint16_t flow_pool_size)
 {
-	struct ol_txrx_pdev_t *pdev = cds_get_context(QDF_MODULE_ID_TXRX);
+	struct ol_txrx_soc_t *soc = cds_get_context(QDF_MODULE_ID_SOC);
+	ol_txrx_pdev_handle pdev;
 	struct ol_tx_flow_pool_t *pool;
 
 	ol_txrx_dbg("flow_pool_id %d flow_pool_size %d",
 		    flow_pool_id, flow_pool_size);
 
+	if (qdf_unlikely(!soc)) {
+		ol_txrx_err("soc is NULL");
+		return;
+	}
+
+	pdev = ol_txrx_get_pdev_from_pdev_id(soc, OL_TXRX_PDEV_ID);
 	if (qdf_unlikely(!pdev)) {
 		ol_txrx_err("pdev is NULL");
 		return;
diff --git a/core/dp/txrx3.0/dp_txrx.c b/core/dp/txrx3.0/dp_txrx.c
index 7b7de29..7e126f3 100644
--- a/core/dp/txrx3.0/dp_txrx.c
+++ b/core/dp/txrx3.0/dp_txrx.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2017-2018 The Linux Foundation. All rights reserved.
+ * Copyright (c) 2017-2019 The Linux Foundation. All rights reserved.
  *
  * Permission to use, copy, modify, and/or distribute this software for
  * any purpose with or without fee is hereby granted, provided that the
@@ -18,15 +18,29 @@
 
 #include <wlan_objmgr_pdev_obj.h>
 #include <dp_txrx.h>
+#include <dp_internal.h>
 #include <cdp_txrx_cmn.h>
 #include <cdp_txrx_misc.h>
 
-QDF_STATUS dp_txrx_init(ol_txrx_soc_handle soc, struct cdp_pdev *pdev,
+QDF_STATUS dp_txrx_init(ol_txrx_soc_handle soc, uint8_t pdev_id,
 			struct dp_txrx_config *config)
 {
 	struct dp_txrx_handle *dp_ext_hdl;
 	QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
 	uint8_t num_dp_rx_threads;
+	struct dp_pdev *pdev;
+
+	if (qdf_unlikely(!soc)) {
+		dp_err("soc is NULL");
+		return 0;
+	}
+
+	pdev = dp_get_pdev_from_soc_pdev_id_wifi3(cdp_soc_t_to_dp_soc(soc),
+						  pdev_id);
+	if (!pdev) {
+		dp_err("pdev is NULL");
+		return 0;
+	}
 
 	dp_ext_hdl = qdf_mem_malloc(sizeof(*dp_ext_hdl));
 	if (!dp_ext_hdl) {
@@ -36,7 +50,7 @@
 
 	dp_info("dp_txrx_handle allocated");
 	dp_ext_hdl->soc = soc;
-	dp_ext_hdl->pdev = pdev;
+	dp_ext_hdl->pdev = dp_pdev_to_cdp_pdev(pdev);
 	cdp_soc_set_dp_txrx_handle(soc, dp_ext_hdl);
 	qdf_mem_copy(&dp_ext_hdl->config, config, sizeof(*config));
 	dp_ext_hdl->rx_tm_hdl.txrx_handle_cmn =
diff --git a/core/dp/txrx3.0/dp_txrx.h b/core/dp/txrx3.0/dp_txrx.h
index 38eaf1d..709e64b 100644
--- a/core/dp/txrx3.0/dp_txrx.h
+++ b/core/dp/txrx3.0/dp_txrx.h
@@ -94,11 +94,12 @@
 /**
  * dp_txrx_init() - initialize DP TXRX module
  * @soc: ol_txrx_soc_handle
+ * @pdev_id: id of dp pdev handle
  * @config: configuration for DP TXRX modules
  *
  * Return: QDF_STATUS_SUCCESS on success, error qdf status on failure
  */
-QDF_STATUS dp_txrx_init(ol_txrx_soc_handle soc, struct cdp_pdev *pdev,
+QDF_STATUS dp_txrx_init(ol_txrx_soc_handle soc, uint8_t pdev_id,
 			struct dp_txrx_config *config);
 
 /**
@@ -320,8 +321,8 @@
 #else
 
 static inline
-QDF_STATUS dp_txrx_init(ol_txrx_soc_handle soc, struct cdp_pdev *pdev,
-			    struct dp_txrx_config *config)
+QDF_STATUS dp_txrx_init(ol_txrx_soc_handle soc, uint8_t pdev_id,
+			struct dp_txrx_config *config)
 {
 	return QDF_STATUS_SUCCESS;
 }
diff --git a/core/hdd/src/wlan_hdd_wext.c b/core/hdd/src/wlan_hdd_wext.c
index 953d069..05cba8e 100644
--- a/core/hdd/src/wlan_hdd_wext.c
+++ b/core/hdd/src/wlan_hdd_wext.c
@@ -7769,8 +7769,7 @@
 	int *apps_args = (int *) extra;
 	struct hdd_context *hdd_ctx;
 	int ret, num_args;
-	void *soc = NULL;
-	struct cdp_pdev *pdev = NULL;
+	void *soc = cds_get_context(QDF_MODULE_ID_SOC);
 	struct cdp_vdev *vdev = NULL;
 	struct cdp_txrx_stats_req req = {0};
 
@@ -7989,20 +7988,17 @@
 	break;
 	case WE_SET_TXRX_STATS:
 	{
-		ret = cds_get_datapath_handles(&soc, &pdev, &vdev,
-					       adapter->vdev_id);
-
-		if (ret != 0) {
-			hdd_err("Invalid handles");
-			break;
-		}
-
 		req.stats = apps_args[0];
 		/* default value of secondary parameter is 0(mac_id) */
 		req.mac_id = apps_args[1];
 
 		hdd_debug("WE_SET_TXRX_STATS stats cmd: %d mac_id: %d",
-			  req.stats, req.mac_id);
+				req.stats, req.mac_id);
+		if (qdf_unlikely(!soc)) {
+			hdd_err("soc is NULL");
+			return -EINVAL;
+		}
+
 		if (apps_args[0] == CDP_TXRX_STATS_28) {
 			if (sta_ctx->conn_info.is_authenticated) {
 				hdd_debug("ap mac addr: %pM",