Browse Source

qcacld-3.0: cdp: Converge cdp_ipa_ops

Currently cdp ops are given pdev/vdev/peer
handle as its arguments, which is directly
accessed in those APIs. This can cause a
race-condition in access of the respective
handles if it has been deleted in parallel.

Hence as a part of cdp convergence, pass only
the pdev_id or vdev_id or peer mac address,
which will be used to get the respective handles,
and hence avoiding the unwanted access of the
handles if it has been deleted.

- ipa_get_resource
- ipa_set_doorbell_paddr
- ipa_set_active
- ipa_register_op_cb
- ipa_get_stat
- ipa_tx_data_frame
- ipa_uc_get_share_stats
- ipa_uc_set_quota
- ipa_enable_autonomy
- ipa_disable_autonomy
- ipa_setup
- ipa_enable_pipes
- ipa_disable_pipes
- ipa_rx_intrabss_fwd

Change-Id: I678d7a7de7132417ff6051b0fd6da5d14426d21e
CRs-Fixed: 2540861
Vevek Venkatesan 5 years ago
parent
commit
29076ec1d8

+ 3 - 3
components/ipa/core/inc/wlan_ipa_main.h

@@ -164,13 +164,13 @@ QDF_STATUS ipa_send_uc_offload_enable_disable(struct wlan_objmgr_pdev *pdev,
 void ipa_set_dp_handle(struct wlan_objmgr_psoc *psoc, void *dp_soc);
 
 /**
- * ipa_set_txrx_handle() - set dp txrx handle
+ * ipa_set_pdev_id() - set dp pdev id
  * @psoc: psoc handle
- * @txrx_handle: dp txrx handle
+ * @pdev_id: dp txrx physical device id
  *
  * Return: None
  */
-void ipa_set_txrx_handle(struct wlan_objmgr_psoc *psoc, void *txrx_handle);
+void ipa_set_pdev_id(struct wlan_objmgr_psoc *psoc, uint8_t pdev_id);
 
 /**
  * ipa_rm_set_perf_level() - set ipa rm perf level

+ 1 - 2
components/ipa/core/inc/wlan_ipa_priv.h

@@ -310,7 +310,6 @@ struct wlan_ipa_priv;
 /**
  * struct wlan_ipa_iface_context - IPA interface context
  * @ipa_ctx: IPA private context
- * @tl_context: TL context
  * @cons_client: IPA consumer pipe
  * @prod_client: IPA producer pipe
  * @prod_client: IPA producer pipe
@@ -324,7 +323,6 @@ struct wlan_ipa_priv;
  */
 struct wlan_ipa_iface_context {
 	struct wlan_ipa_priv *ipa_ctx;
-	void *tl_context;
 
 	qdf_ipa_client_type_t cons_client;
 	qdf_ipa_client_type_t prod_client;
@@ -588,6 +586,7 @@ struct wlan_ipa_priv {
 	uint8_t num_iface;
 	void *dp_soc;
 	void *dp_pdev;
+	uint8_t dp_pdev_id;
 	struct wlan_ipa_config *config;
 	enum wlan_ipa_rm_state rm_state;
 	/*

+ 24 - 35
components/ipa/core/src/wlan_ipa_core.c

@@ -338,8 +338,8 @@ static void wlan_ipa_send_pkt_to_tl(
 	}
 
 	skb = cdp_ipa_tx_send_data_frame(cds_get_context(QDF_MODULE_ID_SOC),
-			(struct cdp_vdev *)iface_context->tl_context,
-			QDF_IPA_RX_DATA_SKB(ipa_tx_desc));
+					 iface_context->session_id,
+					 QDF_IPA_RX_DATA_SKB(ipa_tx_desc));
 	if (skb) {
 		qdf_nbuf_free(skb);
 		iface_context->stats.num_tx_err++;
@@ -499,7 +499,7 @@ static inline QDF_STATUS wlan_ipa_wdi_setup(struct wlan_ipa_priv *ipa_ctx,
 			     &ipa_ctx->sys_pipe[i].ipa_sys_params,
 			     sizeof(qdf_ipa_sys_connect_params_t));
 
-	return cdp_ipa_setup(ipa_ctx->dp_soc, ipa_ctx->dp_pdev,
+	return cdp_ipa_setup(ipa_ctx->dp_soc, ipa_ctx->dp_pdev_id,
 			     wlan_ipa_i2w_cb, wlan_ipa_w2i_cb,
 			     wlan_ipa_wdi_meter_notifier_cb,
 			     ipa_ctx->config->desc_size,
@@ -756,7 +756,7 @@ wlan_ipa_rx_intrabss_fwd(struct wlan_ipa_priv *ipa_ctx,
 		goto exit;
 	}
 
-	if (cdp_ipa_rx_intrabss_fwd(ipa_ctx->dp_soc, iface_ctx->tl_context,
+	if (cdp_ipa_rx_intrabss_fwd(ipa_ctx->dp_soc, iface_ctx->session_id,
 				    nbuf, &fwd_success)) {
 		ipa_ctx->ipa_rx_internal_drop_count++;
 		ipa_ctx->ipa_rx_discard++;
@@ -790,7 +790,7 @@ static inline int wlan_ipa_wdi_is_smmu_enabled(struct wlan_ipa_priv *ipa_ctx,
 static inline QDF_STATUS wlan_ipa_wdi_setup(struct wlan_ipa_priv *ipa_ctx,
 					    qdf_device_t osdev)
 {
-	return cdp_ipa_setup(ipa_ctx->dp_soc, ipa_ctx->dp_pdev,
+	return cdp_ipa_setup(ipa_ctx->dp_soc, ipa_ctx->dp_pdev_id,
 			     wlan_ipa_i2w_cb, wlan_ipa_w2i_cb,
 			     wlan_ipa_wdi_meter_notifier_cb,
 			     ipa_ctx->config->desc_size,
@@ -1000,9 +1000,9 @@ static void __wlan_ipa_w2i_cb(void *priv, qdf_ipa_dp_evt_type_t evt,
 		}
 
 		iface_context = &ipa_ctx->iface_context[iface_id];
-		if (!iface_context->tl_context) {
-			ipa_err_rl("TL context of iface_id %u is NULL",
-				   iface_id);
+		if (iface_context->session_id == WLAN_IPA_MAX_SESSION) {
+			ipa_err_rl("session_id of iface_id %u is invalid:%d",
+				   iface_id, iface_context->session_id);
 			ipa_ctx->ipa_rx_internal_drop_count++;
 			dev_kfree_skb_any(skb);
 			return;
@@ -1241,7 +1241,7 @@ QDF_STATUS wlan_ipa_uc_enable_pipes(struct wlan_ipa_priv *ipa_ctx)
 
 	if (qdf_atomic_read(&ipa_ctx->pipes_disabled)) {
 		result = cdp_ipa_enable_pipes(ipa_ctx->dp_soc,
-					      ipa_ctx->dp_pdev);
+					      ipa_ctx->dp_pdev_id);
 		if (result) {
 			ipa_err("Enable IPA WDI PIPE failed: ret=%d", result);
 			qdf_status = QDF_STATUS_E_FAILURE;
@@ -1254,7 +1254,7 @@ QDF_STATUS wlan_ipa_uc_enable_pipes(struct wlan_ipa_priv *ipa_ctx)
 
 	if (qdf_atomic_read(&ipa_ctx->autonomy_disabled)) {
 		cdp_ipa_enable_autonomy(ipa_ctx->dp_soc,
-					ipa_ctx->dp_pdev);
+					ipa_ctx->dp_pdev_id);
 		qdf_atomic_set(&ipa_ctx->autonomy_disabled, 0);
 	}
 end:
@@ -1292,7 +1292,7 @@ wlan_ipa_uc_disable_pipes(struct wlan_ipa_priv *ipa_ctx, bool force_disable)
 
 	if (!qdf_atomic_read(&ipa_ctx->autonomy_disabled)) {
 		cdp_ipa_disable_autonomy(ipa_ctx->dp_soc,
-					 ipa_ctx->dp_pdev);
+					 ipa_ctx->dp_pdev_id);
 		qdf_atomic_set(&ipa_ctx->autonomy_disabled, 1);
 	}
 
@@ -1301,7 +1301,7 @@ wlan_ipa_uc_disable_pipes(struct wlan_ipa_priv *ipa_ctx, bool force_disable)
 			wlan_ipa_set_pending_tx_timer(ipa_ctx);
 		} else {
 			qdf_status = cdp_ipa_disable_pipes(ipa_ctx->dp_soc,
-							   ipa_ctx->dp_pdev);
+							   ipa_ctx->dp_pdev_id);
 			if (QDF_IS_STATUS_ERROR(qdf_status)) {
 				ipa_err("Disable IPA WDI PIPE failed: ret=%u",
 					qdf_status);
@@ -1427,7 +1427,7 @@ static void wlan_ipa_cleanup_iface(struct wlan_ipa_iface_context *iface_context)
 
 	ipa_debug("enter");
 
-	if (!iface_context->tl_context)
+	if (iface_context->session_id == WLAN_IPA_MAX_SESSION)
 		return;
 
 	cdp_ipa_cleanup_iface(ipa_ctx->dp_soc,
@@ -1435,7 +1435,6 @@ static void wlan_ipa_cleanup_iface(struct wlan_ipa_iface_context *iface_context)
 			      wlan_ipa_is_ipv6_enabled(ipa_ctx->config));
 
 	qdf_spin_lock_bh(&iface_context->interface_lock);
-	iface_context->tl_context = NULL;
 	iface_context->dev = NULL;
 	iface_context->device_mode = QDF_MAX_NO_OF_MODE;
 	iface_context->session_id = WLAN_IPA_MAX_SESSION;
@@ -1527,7 +1526,6 @@ static QDF_STATUS wlan_ipa_setup_iface(struct wlan_ipa_priv *ipa_ctx,
 				       uint8_t session_id)
 {
 	struct wlan_ipa_iface_context *iface_context = NULL;
-	void *tl_context = NULL;
 	int i;
 	QDF_STATUS status;
 
@@ -1563,7 +1561,8 @@ static QDF_STATUS wlan_ipa_setup_iface(struct wlan_ipa_priv *ipa_ctx,
 	}
 
 	for (i = 0; i < WLAN_IPA_MAX_IFACE; i++) {
-		if (!ipa_ctx->iface_context[i].tl_context) {
+		if (ipa_ctx->iface_context[i].session_id ==
+						WLAN_IPA_MAX_SESSION) {
 			iface_context = &(ipa_ctx->iface_context[i]);
 			break;
 		}
@@ -1576,17 +1575,6 @@ static QDF_STATUS wlan_ipa_setup_iface(struct wlan_ipa_priv *ipa_ctx,
 		goto end;
 	}
 
-	tl_context = (void *)cdp_get_vdev_from_vdev_id(ipa_ctx->dp_soc,
-						       ipa_ctx->dp_pdev,
-						       session_id);
-	if (!tl_context) {
-		ipa_err("Not able to get TL context session_id: %d",
-			session_id);
-		status = QDF_STATUS_E_INVAL;
-		goto end;
-	}
-
-	iface_context->tl_context = tl_context;
 	iface_context->dev = net_dev;
 	iface_context->device_mode = device_mode;
 	iface_context->session_id = session_id;
@@ -1769,7 +1757,7 @@ void wlan_ipa_uc_handle_last_discon(struct wlan_ipa_priv *ipa_ctx,
 	ipa_ctx->resource_unloading = true;
 	qdf_event_reset(&ipa_ctx->ipa_resource_comp);
 	ipa_info("Disable FW RX PIPE");
-	cdp_ipa_set_active(ipa_ctx->dp_soc, ipa_ctx->dp_pdev, false, false);
+	cdp_ipa_set_active(ipa_ctx->dp_soc, ipa_ctx->dp_pdev_id, false, false);
 
 	ipa_debug("exit: IPA WDI Pipes deactivated");
 }
@@ -2995,7 +2983,7 @@ QDF_STATUS wlan_ipa_setup(struct wlan_ipa_priv *ipa_ctx,
 		iface_context->iface_id = i;
 		iface_context->dev = NULL;
 		iface_context->device_mode = QDF_MAX_NO_OF_MODE;
-		iface_context->tl_context = NULL;
+		iface_context->session_id = WLAN_IPA_MAX_SESSION;
 		qdf_spinlock_create(&iface_context->interface_lock);
 	}
 
@@ -3215,7 +3203,7 @@ static void wlan_ipa_uc_loaded_handler(struct wlan_ipa_priv *ipa_ctx)
 		return;
 	}
 
-	cdp_ipa_set_doorbell_paddr(ipa_ctx->dp_soc, ipa_ctx->dp_pdev);
+	cdp_ipa_set_doorbell_paddr(ipa_ctx->dp_soc, ipa_ctx->dp_pdev_id);
 
 	/*
 	 * Enable IPA/FW PIPEs if
@@ -3285,7 +3273,7 @@ static void wlan_ipa_uc_op_cb(struct op_msg_type *op_msg,
 		if (msg->op_code == WLAN_IPA_UC_OPCODE_RX_SUSPEND) {
 			wlan_ipa_uc_disable_pipes(ipa_ctx, true);
 			ipa_info("Disable FW TX PIPE");
-			cdp_ipa_set_active(ipa_ctx->dp_soc, ipa_ctx->dp_pdev,
+			cdp_ipa_set_active(ipa_ctx->dp_soc, ipa_ctx->dp_pdev_id,
 					   false, true);
 		}
 
@@ -3442,7 +3430,7 @@ QDF_STATUS wlan_ipa_uc_ol_init(struct wlan_ipa_priv *ipa_ctx,
 		ipa_ctx->vdev_offload_enabled[i] = false;
 	}
 
-	if (cdp_ipa_get_resource(ipa_ctx->dp_soc, ipa_ctx->dp_pdev)) {
+	if (cdp_ipa_get_resource(ipa_ctx->dp_soc, ipa_ctx->dp_pdev_id)) {
 		ipa_err("IPA UC resource alloc fail");
 		status = QDF_STATUS_E_FAILURE;
 		goto fail_return;
@@ -3457,14 +3445,15 @@ QDF_STATUS wlan_ipa_uc_ol_init(struct wlan_ipa_priv *ipa_ctx,
 			goto fail_return;
 		}
 
-		cdp_ipa_set_doorbell_paddr(ipa_ctx->dp_soc, ipa_ctx->dp_pdev);
+		cdp_ipa_set_doorbell_paddr(ipa_ctx->dp_soc,
+					   ipa_ctx->dp_pdev_id);
 		wlan_ipa_init_metering(ipa_ctx);
 
 		if (wlan_ipa_init_perf_level(ipa_ctx) != QDF_STATUS_SUCCESS)
 			ipa_err("Failed to init perf level");
 	}
 
-	cdp_ipa_register_op_cb(ipa_ctx->dp_soc, ipa_ctx->dp_pdev,
+	cdp_ipa_register_op_cb(ipa_ctx->dp_soc, ipa_ctx->dp_pdev_id,
 			       wlan_ipa_uc_op_event_handler, (void *)ipa_ctx);
 
 	for (i = 0; i < WLAN_IPA_UC_OPCODE_MAX; i++) {
@@ -3584,7 +3573,7 @@ void wlan_ipa_uc_cleanup_sta(struct wlan_ipa_priv *ipa_ctx,
 	for (i = 0; i < WLAN_IPA_MAX_IFACE; i++) {
 		iface_ctx = &ipa_ctx->iface_context[i];
 		if (iface_ctx && iface_ctx->device_mode == QDF_STA_MODE &&
-		    iface_ctx->dev == net_dev && iface_ctx->tl_context) {
+		    iface_ctx->dev && iface_ctx->dev == net_dev) {
 			wlan_ipa_uc_send_evt(net_dev, QDF_IPA_STA_DISCONNECT,
 					     net_dev->dev_addr);
 			wlan_ipa_cleanup_iface(iface_ctx);

+ 2 - 2
components/ipa/core/src/wlan_ipa_main.c

@@ -125,7 +125,7 @@ void ipa_set_dp_handle(struct wlan_objmgr_psoc *psoc, void *dp_soc)
 	wlan_objmgr_pdev_release_ref(pdev, WLAN_IPA_ID);
 }
 
-void ipa_set_txrx_handle(struct wlan_objmgr_psoc *psoc, void *txrx_handle)
+void ipa_set_pdev_id(struct wlan_objmgr_psoc *psoc, uint8_t pdev_id)
 {
 	struct wlan_objmgr_pdev *pdev;
 	struct wlan_ipa_priv *ipa_obj;
@@ -150,7 +150,7 @@ void ipa_set_txrx_handle(struct wlan_objmgr_psoc *psoc, void *txrx_handle)
 		return;
 	}
 
-	ipa_obj->dp_pdev = txrx_handle;
+	ipa_obj->dp_pdev_id = pdev_id;
 	wlan_objmgr_pdev_release_ref(pdev, WLAN_IPA_ID);
 }
 

+ 7 - 7
components/ipa/core/src/wlan_ipa_stats.c

@@ -423,7 +423,7 @@ static void wlan_ipa_dump_iface_context(struct wlan_ipa_priv *ipa_ctx)
 
 		ipa_info("\niface_context[%d]----\n"
 			"\tipa_ctx: %pK\n"
-			"\ttl_context: %pK\n"
+			"\tsession_id: %d\n"
 			"\tcons_client: %d\n"
 			"\tprod_client: %d\n"
 			"\tiface_id: %d\n"
@@ -431,7 +431,7 @@ static void wlan_ipa_dump_iface_context(struct wlan_ipa_priv *ipa_ctx)
 			"\tifa_address: 0x%x\n",
 			i,
 			iface_context->ipa_ctx,
-			iface_context->tl_context,
+			iface_context->session_id,
 			iface_context->cons_client,
 			iface_context->prod_client,
 			iface_context->iface_id,
@@ -468,7 +468,7 @@ void wlan_ipa_uc_stat_request(struct wlan_ipa_priv *ipa_ctx, uint8_t reason)
 	if (wlan_ipa_is_fw_wdi_activated(ipa_ctx) &&
 	    (false == ipa_ctx->resource_loading)) {
 		ipa_ctx->stat_req_reason = reason;
-		cdp_ipa_get_stat(ipa_ctx->dp_soc, ipa_ctx->dp_pdev);
+		cdp_ipa_get_stat(ipa_ctx->dp_soc, ipa_ctx->dp_pdev_id);
 		qdf_mutex_release(&ipa_ctx->ipa_lock);
 	} else {
 		qdf_mutex_release(&ipa_ctx->ipa_lock);
@@ -520,7 +520,7 @@ static void wlan_ipa_print_session_info(struct wlan_ipa_priv *ipa_ctx)
 	for (i = 0; i < WLAN_IPA_MAX_IFACE; i++) {
 		iface_context = &ipa_ctx->iface_context[i];
 
-		if (!iface_context->tl_context)
+		if (iface_context->session_id == WLAN_IPA_MAX_SESSION)
 			continue;
 
 		ipa_info("\nIFACE[%d]: mode:%d, offload:%d",
@@ -604,7 +604,7 @@ static void wlan_ipa_print_txrx_stats(struct wlan_ipa_priv *ipa_ctx)
 	for (i = 0; i < WLAN_IPA_MAX_IFACE; i++) {
 
 		iface_context = &ipa_ctx->iface_context[i];
-		if (!iface_context->tl_context)
+		if (iface_context->session_id == WLAN_IPA_MAX_SESSION)
 			continue;
 
 		ipa_info("IFACE[%d]: TX:%llu, TX DROP:%llu, TX ERR:%llu,"
@@ -828,7 +828,7 @@ static void wlan_ipa_uc_sharing_stats_request(struct wlan_ipa_priv *ipa_ctx,
 	qdf_mutex_acquire(&ipa_ctx->ipa_lock);
 	if (false == ipa_ctx->resource_loading) {
 		qdf_mutex_release(&ipa_ctx->ipa_lock);
-		cdp_ipa_uc_get_share_stats(ipa_ctx->dp_soc, ipa_ctx->dp_pdev,
+		cdp_ipa_uc_get_share_stats(ipa_ctx->dp_soc, ipa_ctx->dp_pdev_id,
 					   reset_stats);
 	} else {
 		qdf_mutex_release(&ipa_ctx->ipa_lock);
@@ -854,7 +854,7 @@ static void wlan_ipa_uc_set_quota(struct wlan_ipa_priv *ipa_ctx,
 	if (false == ipa_ctx->resource_loading) {
 		qdf_mutex_release(&ipa_ctx->ipa_lock);
 	} else {
-		cdp_ipa_uc_set_quota(ipa_ctx->dp_soc, ipa_ctx->dp_pdev,
+		cdp_ipa_uc_set_quota(ipa_ctx->dp_soc, ipa_ctx->dp_pdev_id,
 				     quota_bytes);
 		qdf_mutex_release(&ipa_ctx->ipa_lock);
 	}

+ 6 - 7
components/ipa/dispatcher/inc/wlan_ipa_ucfg_api.h

@@ -69,15 +69,14 @@ void ucfg_ipa_set_dp_handle(struct wlan_objmgr_psoc *psoc,
 			       void *dp_soc);
 
 /**
- * ucfg_ipa_set_txrx_handle() - register pdev txrx handler
+ * ucfg_ipa_set_pdev_id() - register pdev id
  * @psoc: psoc handle
- * @psoc: psoc obj
- * @txrx_handle: data path pdev txrx handle
+ * @pdev_id: data path txrx pdev id
  *
  * Return: None
  */
-void ucfg_ipa_set_txrx_handle(struct wlan_objmgr_psoc *psoc,
-			      void *txrx_handle);
+void ucfg_ipa_set_pdev_id(struct wlan_objmgr_psoc *psoc,
+			  uint8_t pdev_id);
 
 /**
  * ucfg_ipa_set_perf_level() - Set IPA perf level
@@ -403,8 +402,8 @@ QDF_STATUS ucfg_ipa_set_dp_handle(struct wlan_objmgr_psoc *psoc,
 }
 
 static inline
-QDF_STATUS ucfg_ipa_set_txrx_handle(struct wlan_objmgr_psoc *psoc,
-				    void *txrx_handle)
+QDF_STATUS ucfg_ipa_set_pdev_id(struct wlan_objmgr_psoc *psoc,
+				uint8_t pdev_id)
 {
 	return QDF_STATUS_SUCCESS;
 }

+ 3 - 3
components/ipa/dispatcher/src/wlan_ipa_ucfg_api.c

@@ -39,10 +39,10 @@ bool ucfg_ipa_uc_is_enabled(void)
 	return ipa_config_is_uc_enabled();
 }
 
-void ucfg_ipa_set_txrx_handle(struct wlan_objmgr_psoc *psoc,
-				    void *txrx_handle)
+void ucfg_ipa_set_pdev_id(struct wlan_objmgr_psoc *psoc,
+			  uint8_t pdev_id)
 {
-	return ipa_set_txrx_handle(psoc, txrx_handle);
+	return ipa_set_pdev_id(psoc, pdev_id);
 }
 
 void ucfg_ipa_set_dp_handle(struct wlan_objmgr_psoc *psoc,

+ 1 - 2
core/dp/htt/htt_t2h.c

@@ -177,8 +177,7 @@ static void htt_ipa_op_response(struct htt_pdev_t *pdev, uint32_t *msg_word)
 			sizeof(struct htt_wdi_ipa_op_response_t) +
 			len);
 	cdp_ipa_op_response(cds_get_context(QDF_MODULE_ID_SOC),
-			(struct cdp_pdev *)pdev->txrx_pdev,
-			op_msg_buffer);
+			    OL_TXRX_PDEV_ID, op_msg_buffer);
 }
 #else
 static void htt_ipa_op_response(struct htt_pdev_t *pdev, uint32_t *msg_word)

+ 12 - 5
core/dp/txrx/ol_tx.c

@@ -85,15 +85,22 @@ qdf_nbuf_t ol_tx_data(struct cdp_vdev *data_vdev, qdf_nbuf_t skb)
 }
 
 #ifdef IPA_OFFLOAD
-qdf_nbuf_t ol_tx_send_ipa_data_frame(struct cdp_vdev *vdev, qdf_nbuf_t skb)
+qdf_nbuf_t ol_tx_send_ipa_data_frame(struct cdp_soc_t *soc_hdl, uint8_t vdev_id,
+				     qdf_nbuf_t skb)
 {
-	struct ol_txrx_pdev_t *pdev = cds_get_context(QDF_MODULE_ID_TXRX);
+	struct ol_txrx_soc_t *soc = cdp_soc_t_to_ol_txrx_soc_t(soc_hdl);
+	struct ol_txrx_pdev_t *pdev = ol_txrx_get_pdev_from_pdev_id(
+							soc, OL_TXRX_PDEV_ID);
+	ol_txrx_vdev_handle vdev = ol_txrx_get_vdev_from_soc_vdev_id(soc,
+								     vdev_id);
 	qdf_nbuf_t ret;
 
 	if (qdf_unlikely(!pdev)) {
-		qdf_net_buf_debug_acquire_skb(skb, __FILE__, __LINE__);
-
-		ol_txrx_err("pdev is NULL");
+		ol_txrx_err("%s: invalid pdev", __func__);
+		return skb;
+	}
+	if (qdf_unlikely(!vdev)) {
+		ol_txrx_err("%s: invalid vdev, vdev_id:%d", __func__, vdev_id);
 		return skb;
 	}
 

+ 4 - 2
core/dp/txrx/ol_tx.h

@@ -35,12 +35,14 @@
 #ifdef IPA_OFFLOAD
 /**
  * ol_tx_send_ipa_data_frame() - send IPA data frame
- * @vdev: vdev
+ * @soc_hdl: datapath soc handle
+ * @vdev: virtual interface id
  * @skb: skb
  *
  * Return: skb/ NULL is for success
  */
-qdf_nbuf_t ol_tx_send_ipa_data_frame(struct cdp_vdev *vdev, qdf_nbuf_t skb);
+qdf_nbuf_t ol_tx_send_ipa_data_frame(struct cdp_soc_t *soc_hdl, uint8_t vdev_id,
+				     qdf_nbuf_t skb);
 #endif
 
 #ifdef CONFIG_LL_DP_SUPPORT

+ 146 - 166
core/dp/txrx/ol_txrx_ipa.c

@@ -106,28 +106,26 @@ struct ol_txrx_ipa_uc_tx_hdr ipa_uc_tx_hdr = {
 };
 #endif
 
-/**
- * ol_txrx_ipa_uc_get_resource() - Client request resource information
- * @pdev: handle to the HTT instance
- *
- *  OL client will request IPA UC related resource information
- *  Resource information will be distributted to IPA module
- *  All of the required resources should be pre-allocated
- *
- * Return: QDF_STATUS
- */
-QDF_STATUS ol_txrx_ipa_uc_get_resource(struct cdp_pdev *ppdev)
+QDF_STATUS ol_txrx_ipa_uc_get_resource(struct cdp_soc_t *soc_hdl,
+				       uint8_t pdev_id)
 {
-	ol_txrx_pdev_handle pdev = (ol_txrx_pdev_handle)ppdev;
-	struct ol_txrx_ipa_resources *ipa_res = &pdev->ipa_resource;
+	struct ol_txrx_soc_t *soc = cdp_soc_t_to_ol_txrx_soc_t(soc_hdl);
+	ol_txrx_pdev_handle pdev = ol_txrx_get_pdev_from_pdev_id(soc, pdev_id);
+	struct ol_txrx_ipa_resources *ipa_res;
 	qdf_device_t osdev = cds_get_context(QDF_MODULE_ID_QDF_DEVICE);
 
+	if (!pdev) {
+		ol_txrx_err("%s invalid instance", __func__);
+		return QDF_STATUS_E_FAILURE;
+	}
+
 	if (!osdev) {
 		QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR,
 			  "%s: qdf device is null!", __func__);
 		return QDF_STATUS_E_NOENT;
 	}
 
+	ipa_res = &pdev->ipa_resource;
 	htt_ipa_uc_get_resource(pdev->htt_pdev,
 				&ipa_res->ce_sr,
 				&ipa_res->tx_comp_ring,
@@ -155,21 +153,20 @@ QDF_STATUS ol_txrx_ipa_uc_get_resource(struct cdp_pdev *ppdev)
 	return QDF_STATUS_SUCCESS;
 }
 
-/**
- * ol_txrx_ipa_uc_set_doorbell_paddr() - Client set IPA UC doorbell register
- * @pdev: handle to the HTT instance
- *
- *  IPA UC let know doorbell register physical address
- *  WLAN firmware will use this physical address to notify IPA UC
- *
- * Return: QDF_STATUS
- */
-QDF_STATUS ol_txrx_ipa_uc_set_doorbell_paddr(struct cdp_pdev *ppdev)
+QDF_STATUS ol_txrx_ipa_uc_set_doorbell_paddr(struct cdp_soc_t *soc_hdl,
+					     uint8_t pdev_id)
 {
-	ol_txrx_pdev_handle pdev = (ol_txrx_pdev_handle)ppdev;
-	struct ol_txrx_ipa_resources *ipa_res = &pdev->ipa_resource;
+	struct ol_txrx_soc_t *soc = cdp_soc_t_to_ol_txrx_soc_t(soc_hdl);
+	ol_txrx_pdev_handle pdev = ol_txrx_get_pdev_from_pdev_id(soc, pdev_id);
+	struct ol_txrx_ipa_resources *ipa_res;
 	int ret;
 
+	if (!pdev) {
+		ol_txrx_err("%s invalid instance", __func__);
+		return QDF_STATUS_E_FAILURE;
+	}
+
+	ipa_res = &pdev->ipa_resource;
 	ret = htt_ipa_uc_set_doorbell_paddr(pdev->htt_pdev,
 				      ipa_res->tx_comp_doorbell_dmaaddr,
 				      ipa_res->rx_ready_doorbell_dmaaddr);
@@ -183,23 +180,18 @@ QDF_STATUS ol_txrx_ipa_uc_set_doorbell_paddr(struct cdp_pdev *ppdev)
 	return QDF_STATUS_SUCCESS;
 }
 
-/**
- * ol_txrx_ipa_uc_set_active() - Client notify IPA UC data path active or not
- * @pdev: handle to the HTT instance
- * @uc_active: WDI UC path enable or not
- * @is_tx: TX path or RX path
- *
- *  IPA UC let know doorbell register physical address
- *  WLAN firmware will use this physical address to notify IPA UC
- *
- * Return: QDF_STATUS
- */
-QDF_STATUS ol_txrx_ipa_uc_set_active(struct cdp_pdev *ppdev, bool uc_active,
-			       bool is_tx)
+QDF_STATUS ol_txrx_ipa_uc_set_active(struct cdp_soc_t *soc_hdl, uint8_t pdev_id,
+				     bool uc_active, bool is_tx)
 {
-	ol_txrx_pdev_handle pdev = (ol_txrx_pdev_handle)ppdev;
+	struct ol_txrx_soc_t *soc = cdp_soc_t_to_ol_txrx_soc_t(soc_hdl);
+	ol_txrx_pdev_handle pdev = ol_txrx_get_pdev_from_pdev_id(soc, pdev_id);
 	int ret;
 
+	if (!pdev) {
+		ol_txrx_err("%s invalid instance", __func__);
+		return QDF_STATUS_E_FAILURE;
+	}
+
 	ret = htt_h2t_ipa_uc_set_active(pdev->htt_pdev, uc_active, is_tx);
 	if (ret) {
 		QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR,
@@ -210,16 +202,16 @@ QDF_STATUS ol_txrx_ipa_uc_set_active(struct cdp_pdev *ppdev, bool uc_active,
 	return QDF_STATUS_SUCCESS;
 }
 
-/**
- * ol_txrx_ipa_uc_op_response() - Handle OP command response from firmware
- * @pdev: handle to the device instance
- * @op_msg: op response message from firmware
- *
- * Return: none
- */
-QDF_STATUS ol_txrx_ipa_uc_op_response(struct cdp_pdev *ppdev, uint8_t *op_msg)
+QDF_STATUS ol_txrx_ipa_uc_op_response(struct cdp_soc_t *soc_hdl,
+				      uint8_t pdev_id, uint8_t *op_msg)
 {
-	ol_txrx_pdev_handle pdev = (ol_txrx_pdev_handle)ppdev;
+	struct ol_txrx_soc_t *soc = cdp_soc_t_to_ol_txrx_soc_t(soc_hdl);
+	ol_txrx_pdev_handle pdev = ol_txrx_get_pdev_from_pdev_id(soc, pdev_id);
+
+	if (!pdev) {
+		ol_txrx_err("%s invalid instance", __func__);
+		return QDF_STATUS_E_FAILURE;
+	}
 
 	if (pdev->ipa_uc_op_cb) {
 		pdev->ipa_uc_op_cb(op_msg, pdev->usr_ctxt);
@@ -233,17 +225,18 @@ QDF_STATUS ol_txrx_ipa_uc_op_response(struct cdp_pdev *ppdev, uint8_t *op_msg)
 	return QDF_STATUS_SUCCESS;
 }
 
-/**
- * ol_txrx_ipa_uc_register_op_cb() - Register OP handler function
- * @pdev: handle to the device instance
- * @op_cb: handler function pointer
- *
- * Return: none
- */
-QDF_STATUS ol_txrx_ipa_uc_register_op_cb(struct cdp_pdev *ppdev,
-				   ipa_uc_op_cb_type op_cb, void *usr_ctxt)
+QDF_STATUS ol_txrx_ipa_uc_register_op_cb(struct cdp_soc_t *soc_hdl,
+					 uint8_t pdev_id,
+					 ipa_uc_op_cb_type op_cb,
+					 void *usr_ctxt)
 {
-	ol_txrx_pdev_handle pdev = (ol_txrx_pdev_handle)ppdev;
+	struct ol_txrx_soc_t *soc = cdp_soc_t_to_ol_txrx_soc_t(soc_hdl);
+	ol_txrx_pdev_handle pdev = ol_txrx_get_pdev_from_pdev_id(soc, pdev_id);
+
+	if (!pdev) {
+		ol_txrx_err("%s invalid instance", __func__);
+		return QDF_STATUS_E_FAILURE;
+	}
 
 	pdev->ipa_uc_op_cb = op_cb;
 	pdev->usr_ctxt = usr_ctxt;
@@ -251,17 +244,17 @@ QDF_STATUS ol_txrx_ipa_uc_register_op_cb(struct cdp_pdev *ppdev,
 	return QDF_STATUS_SUCCESS;
 }
 
-/**
- * ol_txrx_ipa_uc_get_stat() - Get firmware wdi status
- * @pdev: handle to the HTT instance
- *
- * Return: none
- */
-QDF_STATUS ol_txrx_ipa_uc_get_stat(struct cdp_pdev *ppdev)
+QDF_STATUS ol_txrx_ipa_uc_get_stat(struct cdp_soc_t *soc_hdl, uint8_t pdev_id)
 {
-	ol_txrx_pdev_handle pdev = (ol_txrx_pdev_handle)ppdev;
+	struct ol_txrx_soc_t *soc = cdp_soc_t_to_ol_txrx_soc_t(soc_hdl);
+	ol_txrx_pdev_handle pdev = ol_txrx_get_pdev_from_pdev_id(soc, pdev_id);
 	int ret;
 
+	if (!pdev) {
+		ol_txrx_err("%s invalid instance", __func__);
+		return QDF_STATUS_E_FAILURE;
+	}
+
 	ret = htt_h2t_ipa_uc_get_stats(pdev->htt_pdev);
 
 	if (ret) {
@@ -273,27 +266,15 @@ QDF_STATUS ol_txrx_ipa_uc_get_stat(struct cdp_pdev *ppdev)
 	return QDF_STATUS_SUCCESS;
 }
 
-/**
- * ol_txrx_ipa_enable_autonomy() - Enable autonomy RX path
- * @pdev: handle to the device instance
- *
- * Set all RX packet route to IPA
- * Return: none
- */
-QDF_STATUS ol_txrx_ipa_enable_autonomy(struct cdp_pdev *ppdev)
+QDF_STATUS ol_txrx_ipa_enable_autonomy(struct cdp_soc_t *soc_hdl,
+				       uint8_t pdev_id)
 {
 	/* TBD */
 	return QDF_STATUS_SUCCESS;
 }
 
-/**
- * ol_txrx_ipa_disable_autonomy() - Disable autonomy RX path
- * @pdev: handle to the device instance
- *
- * Disable RX packet route to host
- * Return: none
- */
-QDF_STATUS ol_txrx_ipa_disable_autonomy(struct cdp_pdev *ppdev)
+QDF_STATUS ol_txrx_ipa_disable_autonomy(struct cdp_soc_t *soc_hdl,
+					uint8_t pdev_id)
 {
 	/* TBD */
 	return QDF_STATUS_SUCCESS;
@@ -507,33 +488,19 @@ static inline void ol_txrx_ipa_wdi_rx_params(
 }
 
 #endif
-/**
- * ol_txrx_ipa_setup() - Setup and connect IPA pipes
- * @pdev: handle to the device instance
- * @ipa_i2w_cb: IPA to WLAN callback
- * @ipa_w2i_cb: WLAN to IPA callback
- * @ipa_wdi_meter_notifier_cb: IPA WDI metering callback
- * @ipa_desc_size: IPA descriptor size
- * @ipa_priv: handle to the HTT instance
- * @is_rm_enabled: Is IPA RM enabled or not
- * @p_tx_pipe_handle: pointer to Tx pipe handle
- * @p_rx_pipe_handle: pointer to Rx pipe handle
- * @is_smmu_enabled: Is SMMU enabled or not
- * @sys_in: parameters to setup sys pipe in mcc mode
- * @over_gsi: is ipa ver gsi fw
- *
- * Return: QDF_STATUS
- */
-QDF_STATUS ol_txrx_ipa_setup(struct cdp_pdev *ppdev, void *ipa_i2w_cb,
-			     void *ipa_w2i_cb, void *ipa_wdi_meter_notifier_cb,
+
+QDF_STATUS ol_txrx_ipa_setup(struct cdp_soc_t *soc_hdl, uint8_t pdev_id,
+			     void *ipa_i2w_cb, void *ipa_w2i_cb,
+			     void *ipa_wdi_meter_notifier_cb,
 			     uint32_t ipa_desc_size, void *ipa_priv,
 			     bool is_rm_enabled, uint32_t *p_tx_pipe_handle,
 			     uint32_t *p_rx_pipe_handle, bool is_smmu_enabled,
 			     qdf_ipa_sys_connect_params_t *sys_in,
 			     bool over_gsi)
 {
-	ol_txrx_pdev_handle pdev = (ol_txrx_pdev_handle)ppdev;
-	struct ol_txrx_ipa_resources *ipa_res = &pdev->ipa_resource;
+	struct ol_txrx_soc_t *soc = cdp_soc_t_to_ol_txrx_soc_t(soc_hdl);
+	ol_txrx_pdev_handle pdev = ol_txrx_get_pdev_from_pdev_id(soc, pdev_id);
+	struct ol_txrx_ipa_resources *ipa_res;
 	qdf_ipa_ep_cfg_t *tx_cfg;
 	qdf_ipa_ep_cfg_t *rx_cfg;
 	qdf_ipa_wdi_pipe_setup_info_t *tx;
@@ -546,12 +513,18 @@ QDF_STATUS ol_txrx_ipa_setup(struct cdp_pdev *ppdev, void *ipa_i2w_cb,
 	uint32_t tx_comp_db_dmaaddr = 0, rx_rdy_db_dmaaddr = 0;
 	int ret;
 
+	if (!pdev) {
+		ol_txrx_err("%s invalid instance", __func__);
+		return QDF_STATUS_E_FAILURE;
+	}
+
 	if (!osdev) {
 		QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR,
 			  "%s: qdf device is null!", __func__);
 		return QDF_STATUS_E_NOENT;
 	}
 
+	ipa_res = &pdev->ipa_resource;
 	qdf_mem_zero(&pipe_in, sizeof(pipe_in));
 	qdf_mem_zero(&pipe_out, sizeof(pipe_out));
 
@@ -761,18 +734,18 @@ QDF_STATUS ol_txrx_ipa_cleanup_iface(char *ifname, bool is_ipv6_enabled)
 	return QDF_STATUS_SUCCESS;
 }
 
-/**
- * ol_txrx_ipa_uc_enable_pipes() - Enable and resume traffic on Tx/Rx pipes
- * @pdev: handle to the device instance
- *
- * Return: QDF_STATUS
- */
-QDF_STATUS ol_txrx_ipa_enable_pipes(struct cdp_pdev *ppdev)
+QDF_STATUS ol_txrx_ipa_enable_pipes(struct cdp_soc_t *soc_hdl, uint8_t pdev_id)
 {
-	ol_txrx_pdev_handle pdev = (ol_txrx_pdev_handle)ppdev;
+	struct ol_txrx_soc_t *soc = cdp_soc_t_to_ol_txrx_soc_t(soc_hdl);
+	ol_txrx_pdev_handle pdev = ol_txrx_get_pdev_from_pdev_id(soc, pdev_id);
 	QDF_STATUS status;
 	int ret;
 
+	if (!pdev) {
+		ol_txrx_err("%s invalid instance", __func__);
+		return QDF_STATUS_E_FAILURE;
+	}
+
 	status = htt_rx_update_smmu_map(pdev->htt_pdev, true);
 	if (status != QDF_STATUS_SUCCESS) {
 		QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR,
@@ -795,23 +768,23 @@ QDF_STATUS ol_txrx_ipa_enable_pipes(struct cdp_pdev *ppdev)
 		return QDF_STATUS_E_FAILURE;
 	}
 
-	ol_txrx_ipa_uc_set_active((struct cdp_pdev *)pdev, true, true);
-	ol_txrx_ipa_uc_set_active((struct cdp_pdev *)pdev, true, false);
+	ol_txrx_ipa_uc_set_active(soc_hdl, pdev_id, true, true);
+	ol_txrx_ipa_uc_set_active(soc_hdl, pdev_id, true, false);
 
 	return QDF_STATUS_SUCCESS;
 }
 
-/**
- * ol_txrx_ipa_uc_disable_pipes() – Suspend traffic and disable Tx/Rx pipes
- * @pdev: handle to the device instance
- *
- * Return: QDF_STATUS
- */
-QDF_STATUS ol_txrx_ipa_disable_pipes(struct cdp_pdev *ppdev)
+QDF_STATUS ol_txrx_ipa_disable_pipes(struct cdp_soc_t *soc_hdl, uint8_t pdev_id)
 {
-	ol_txrx_pdev_handle pdev = (ol_txrx_pdev_handle)ppdev;
+	struct ol_txrx_soc_t *soc = cdp_soc_t_to_ol_txrx_soc_t(soc_hdl);
+	ol_txrx_pdev_handle pdev = ol_txrx_get_pdev_from_pdev_id(soc, pdev_id);
 	int ret;
 
+	if (!pdev) {
+		ol_txrx_err("%s invalid instance", __func__);
+		return QDF_STATUS_E_FAILURE;
+	}
+
 	QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_DEBUG,
 		  "%s: Disable IPA pipes", __func__);
 	ret = qdf_ipa_wdi_disable_pipes();
@@ -1001,41 +974,34 @@ static inline void ol_txrx_ipa_rx_params(
 			     osdev);
 }
 
-/**
- * ol_txrx_ipa_setup() - Setup and connect IPA pipes
- * @pdev: handle to the device instance
- * @ipa_i2w_cb: IPA to WLAN callback
- * @ipa_w2i_cb: WLAN to IPA callback
- * @ipa_wdi_meter_notifier_cb: IPA WDI metering callback
- * @ipa_desc_size: IPA descriptor size
- * @ipa_priv: handle to the HTT instance
- * @is_rm_enabled: Is IPA RM enabled or not
- * @p_tx_pipe_handle: pointer to Tx pipe handle
- * @p_rx_pipe_handle: pointer to Rx pipe handle
- *
- * Return: QDF_STATUS
- */
-QDF_STATUS ol_txrx_ipa_setup(struct cdp_pdev *ppdev, void *ipa_i2w_cb,
-			     void *ipa_w2i_cb, void *ipa_wdi_meter_notifier_cb,
+QDF_STATUS ol_txrx_ipa_setup(struct cdp_soc_t *soc_hdl, uint8_t pdev_id,
+			     void *ipa_i2w_cb, void *ipa_w2i_cb,
+			     void *ipa_wdi_meter_notifier_cb,
 			     uint32_t ipa_desc_size, void *ipa_priv,
 			     bool is_rm_enabled, uint32_t *p_tx_pipe_handle,
 			     uint32_t *p_rx_pipe_handle)
 {
-	ol_txrx_pdev_handle pdev = (ol_txrx_pdev_handle)ppdev;
+	struct ol_txrx_soc_t *soc = cdp_soc_t_to_ol_txrx_soc_t(soc_hdl);
+	ol_txrx_pdev_handle pdev = ol_txrx_get_pdev_from_pdev_id(soc, pdev_id);
 	qdf_device_t osdev = cds_get_context(QDF_MODULE_ID_QDF_DEVICE);
-	struct ol_txrx_ipa_resources *ipa_res = &pdev->ipa_resource;
+	struct ol_txrx_ipa_resources *ipa_res;
 	qdf_ipa_wdi_in_params_t pipe_in;
 	qdf_ipa_wdi_out_params_t pipe_out;
 	uint32_t tx_comp_db_dmaaddr = 0, rx_rdy_db_dmaaddr = 0;
-
 	int ret;
 
+	if (!pdev) {
+		ol_txrx_err("%s invalid instance", __func__);
+		return QDF_STATUS_E_FAILURE;
+	}
+
 	if (!osdev) {
 		QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR,
 			  "%s: qdf device is null!", __func__);
 		return QDF_STATUS_E_NOENT;
 	}
 
+	ipa_res = &pdev->ipa_resource;
 	qdf_mem_zero(&pipe_in, sizeof(pipe_in));
 	qdf_mem_zero(&pipe_out, sizeof(pipe_out));
 
@@ -1495,19 +1461,20 @@ QDF_STATUS ol_txrx_ipa_cleanup_iface(char *ifname, bool is_ipv6_enabled)
 	return QDF_STATUS_SUCCESS;
 }
 
-/**
- * ol_txrx_ipa_uc_enable_pipes() - Enable and resume traffic on Tx/Rx pipes
- * @pdev: handle to the device instance
- *
- * Return: QDF_STATUS
- */
-QDF_STATUS ol_txrx_ipa_enable_pipes(struct cdp_pdev *ppdev)
+QDF_STATUS ol_txrx_ipa_enable_pipes(struct cdp_soc_t *soc_hdl, uint8_t pdev_id)
 {
-	ol_txrx_pdev_handle pdev = (ol_txrx_pdev_handle)ppdev;
-	struct ol_txrx_ipa_resources *ipa_res = &pdev->ipa_resource;
+	struct ol_txrx_soc_t *soc = cdp_soc_t_to_ol_txrx_soc_t(soc_hdl);
+	ol_txrx_pdev_handle pdev = ol_txrx_get_pdev_from_pdev_id(soc, pdev_id);
+	struct ol_txrx_ipa_resources *ipa_res;
 	int result;
 	QDF_STATUS status;
 
+	if (!pdev) {
+		ol_txrx_err("%s invalid instance", __func__);
+		return QDF_STATUS_E_FAILURE;
+	}
+
+	ipa_res = &pdev->ipa_resource;
 	status = htt_rx_update_smmu_map(pdev->htt_pdev, true);
 	if (status != QDF_STATUS_SUCCESS) {
 		QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR,
@@ -1533,7 +1500,7 @@ QDF_STATUS ol_txrx_ipa_enable_pipes(struct cdp_pdev *ppdev)
 				__func__, result);
 		goto smmu_unmap;
 	}
-	ol_txrx_ipa_uc_set_active((struct cdp_pdev *)pdev, true, true);
+	ol_txrx_ipa_uc_set_active(soc_hdl, pdev_id, true, true);
 
 	/* ACTIVATE RX PIPE */
 	QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_DEBUG,
@@ -1553,7 +1520,7 @@ QDF_STATUS ol_txrx_ipa_enable_pipes(struct cdp_pdev *ppdev)
 				__func__, result);
 		goto smmu_unmap;
 	}
-	ol_txrx_ipa_uc_set_active((struct cdp_pdev *)pdev, true, false);
+	ol_txrx_ipa_uc_set_active(soc_hdl, pdev_id, true, false);
 
 	return QDF_STATUS_SUCCESS;
 
@@ -1567,18 +1534,19 @@ smmu_unmap:
 	return QDF_STATUS_E_FAILURE;
 }
 
-/**
- * ol_txrx_ipa_uc_disable_pipes() – Suspend traffic and disable Tx/Rx pipes
- * @pdev: handle to the device instance
- *
- * Return: QDF_STATUS
- */
-QDF_STATUS ol_txrx_ipa_disable_pipes(struct cdp_pdev *ppdev)
+QDF_STATUS ol_txrx_ipa_disable_pipes(struct cdp_soc_t *soc_hdl, uint8_t pdev_id)
 {
-	ol_txrx_pdev_handle pdev = (ol_txrx_pdev_handle)ppdev;
-	struct ol_txrx_ipa_resources *ipa_res = &pdev->ipa_resource;
+	struct ol_txrx_soc_t *soc = cdp_soc_t_to_ol_txrx_soc_t(soc_hdl);
+	ol_txrx_pdev_handle pdev = ol_txrx_get_pdev_from_pdev_id(soc, pdev_id);
+	struct ol_txrx_ipa_resources *ipa_res;
 	int result;
 
+	if (!pdev) {
+		ol_txrx_err("%s invalid instance", __func__);
+		return QDF_STATUS_E_FAILURE;
+	}
+
+	ipa_res = &pdev->ipa_resource;
 	QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_DEBUG,
 			"%s: Disable RX PIPE", __func__);
 	result = qdf_ipa_suspend_wdi_pipe(ipa_res->rx_pipe_handle);
@@ -1665,12 +1633,18 @@ QDF_STATUS ol_txrx_ipa_set_perf_level(int client,
 #endif /* CONFIG_IPA_WDI_UNIFIED_API */
 
 #ifdef FEATURE_METERING
-QDF_STATUS ol_txrx_ipa_uc_get_share_stats(struct cdp_pdev *ppdev,
-					   uint8_t reset_stats)
+QDF_STATUS ol_txrx_ipa_uc_get_share_stats(struct cdp_soc_t *soc_hdl,
+					  uint8_t pdev_id, uint8_t reset_stats)
 {
-	struct ol_txrx_pdev_t *pdev = (struct ol_txrx_pdev_t *)ppdev;
+	struct ol_txrx_soc_t *soc = cdp_soc_t_to_ol_txrx_soc_t(soc_hdl);
+	ol_txrx_pdev_handle pdev = ol_txrx_get_pdev_from_pdev_id(soc, pdev_id);
 	int result;
 
+	if (!pdev) {
+		ol_txrx_err("%s invalid instance", __func__);
+		return QDF_STATUS_E_FAILURE;
+	}
+
 	result = htt_h2t_ipa_uc_get_share_stats(pdev->htt_pdev, reset_stats);
 
 	if (result) {
@@ -1682,12 +1656,18 @@ QDF_STATUS ol_txrx_ipa_uc_get_share_stats(struct cdp_pdev *ppdev,
 	return QDF_STATUS_SUCCESS;
 }
 
-QDF_STATUS ol_txrx_ipa_uc_set_quota(struct cdp_pdev *ppdev,
-				     uint64_t quota_bytes)
+QDF_STATUS ol_txrx_ipa_uc_set_quota(struct cdp_soc_t *soc_hdl, uint8_t pdev_id,
+				    uint64_t quota_bytes)
 {
-	struct ol_txrx_pdev_t *pdev = (struct ol_txrx_pdev_t *)ppdev;
+	struct ol_txrx_soc_t *soc = cdp_soc_t_to_ol_txrx_soc_t(soc_hdl);
+	ol_txrx_pdev_handle pdev = ol_txrx_get_pdev_from_pdev_id(soc, pdev_id);
 	int result;
 
+	if (!pdev) {
+		ol_txrx_err("%s invalid instance", __func__);
+		return QDF_STATUS_E_FAILURE;
+	}
+
 	result = htt_h2t_ipa_uc_set_quota(pdev->htt_pdev, quota_bytes);
 
 	if (result) {

+ 184 - 26
core/dp/txrx/ol_txrx_ipa.h

@@ -113,28 +113,153 @@ struct ol_txrx_ipa_uc_rx_hdr {
 #define OL_TXRX_IPA_WDI2_SET(pipe_in, ipa_res, osdev)
 #endif /* IPA3 */
 
-QDF_STATUS ol_txrx_ipa_uc_get_resource(struct cdp_pdev *pdev);
-QDF_STATUS ol_txrx_ipa_uc_set_doorbell_paddr(struct cdp_pdev *pdev);
-QDF_STATUS ol_txrx_ipa_uc_set_active(struct cdp_pdev *pdev, bool uc_active,
-		bool is_tx);
-QDF_STATUS ol_txrx_ipa_uc_op_response(struct cdp_pdev *pdev, uint8_t *op_msg);
-QDF_STATUS ol_txrx_ipa_uc_register_op_cb(struct cdp_pdev *pdev,
-		ipa_uc_op_cb_type op_cb, void *usr_ctxt);
-QDF_STATUS ol_txrx_ipa_uc_get_stat(struct cdp_pdev *pdev);
-QDF_STATUS ol_txrx_ipa_enable_autonomy(struct cdp_pdev *pdev);
-QDF_STATUS ol_txrx_ipa_disable_autonomy(struct cdp_pdev *pdev);
+/**
+ * ol_txrx_ipa_uc_get_resource() - Client request resource information
+ * @soc_hdl: data path soc handle
+ * @pdev_id: device instance id
+ *
+ *  OL client will request IPA UC related resource information
+ *  Resource information will be distributted to IPA module
+ *  All of the required resources should be pre-allocated
+ *
+ * Return: QDF_STATUS
+ */
+QDF_STATUS ol_txrx_ipa_uc_get_resource(struct cdp_soc_t *soc_hdl,
+				       uint8_t pdev_id);
+
+/**
+ * ol_txrx_ipa_uc_set_doorbell_paddr() - Client set IPA UC doorbell register
+ * @soc_hdl: data path soc handle
+ * @pdev_id: device instance id
+ *
+ *  IPA UC let know doorbell register physical address
+ *  WLAN firmware will use this physical address to notify IPA UC
+ *
+ * Return: QDF_STATUS
+ */
+QDF_STATUS ol_txrx_ipa_uc_set_doorbell_paddr(struct cdp_soc_t *soc_hdl,
+					     uint8_t pdev_id);
+
+/**
+ * ol_txrx_ipa_uc_set_active() - Client notify IPA UC data path active or not
+ * @soc_hdl: data path soc handle
+ * @pdev_id: device instance id
+ * @uc_active: WDI UC path enable or not
+ * @is_tx: TX path or RX path
+ *
+ *  IPA UC let know doorbell register physical address
+ *  WLAN firmware will use this physical address to notify IPA UC
+ *
+ * Return: QDF_STATUS
+ */
+QDF_STATUS ol_txrx_ipa_uc_set_active(struct cdp_soc_t *soc_hdl, uint8_t pdev_id,
+				     bool uc_active, bool is_tx);
+
+/**
+ * ol_txrx_ipa_uc_op_response() - Handle OP command response from firmware
+ * @soc_hdl: data path soc handle
+ * @pdev_id: device instance id
+ * @op_msg: op response message from firmware
+ *
+ * Return: none
+ */
+QDF_STATUS ol_txrx_ipa_uc_op_response(struct cdp_soc_t *soc_hdl,
+				      uint8_t pdev_id, uint8_t *op_msg);
+
+/**
+ * ol_txrx_ipa_uc_register_op_cb() - Register OP handler function
+ * @soc_hdl: data path soc handle
+ * @pdev_id: device instance id
+ * @op_cb: handler function pointer
+ *
+ * Return: none
+ */
+QDF_STATUS ol_txrx_ipa_uc_register_op_cb(struct cdp_soc_t *soc_hdl,
+					 uint8_t pdev_id,
+					 ipa_uc_op_cb_type op_cb,
+					 void *usr_ctxt);
+
+/**
+ * ol_txrx_ipa_uc_get_stat() - Get firmware wdi status
+ * @soc_hdl: data path soc handle
+ * @pdev_id: device instance id
+ *
+ * Return: none
+ */
+QDF_STATUS ol_txrx_ipa_uc_get_stat(struct cdp_soc_t *soc_hdl, uint8_t pdev_id);
+
+/**
+ * ol_txrx_ipa_enable_autonomy() - Enable autonomy RX path
+ * @soc_hdl: data path soc handle
+ * @pdev_id: device instance id
+ *
+ * Set all RX packet route to IPA
+ * Return: none
+ */
+QDF_STATUS ol_txrx_ipa_enable_autonomy(struct cdp_soc_t *soc_hdl,
+				       uint8_t pdev_id);
+
+/**
+ * ol_txrx_ipa_disable_autonomy() - Disable autonomy RX path
+ * @soc_hdl: data path soc handle
+ * @pdev_id: device instance id
+ *
+ * Disable RX packet route to host
+ * Return: none
+ */
+QDF_STATUS ol_txrx_ipa_disable_autonomy(struct cdp_soc_t *soc_hdl,
+					uint8_t pdev_id);
+
 #ifdef CONFIG_IPA_WDI_UNIFIED_API
-QDF_STATUS ol_txrx_ipa_setup(struct cdp_pdev *pdev, void *ipa_i2w_cb,
-		void *ipa_w2i_cb, void *ipa_wdi_meter_notifier_cb,
-		uint32_t ipa_desc_size, void *ipa_priv, bool is_rm_enabled,
-		uint32_t *tx_pipe_handle, uint32_t *rx_pipe_handle,
-		bool is_smmu_enabled, qdf_ipa_sys_connect_params_t *sys_in,
-		bool over_gsi);
+/**
+ * ol_txrx_ipa_setup() - Setup and connect IPA pipes
+ * @soc_hdl: data path soc handle
+ * @pdev_id: device instance id
+ * @ipa_i2w_cb: IPA to WLAN callback
+ * @ipa_w2i_cb: WLAN to IPA callback
+ * @ipa_wdi_meter_notifier_cb: IPA WDI metering callback
+ * @ipa_desc_size: IPA descriptor size
+ * @ipa_priv: handle to the HTT instance
+ * @is_rm_enabled: Is IPA RM enabled or not
+ * @p_tx_pipe_handle: pointer to Tx pipe handle
+ * @p_rx_pipe_handle: pointer to Rx pipe handle
+ * @is_smmu_enabled: Is SMMU enabled or not
+ * @sys_in: parameters to setup sys pipe in mcc mode
+ * @over_gsi: is ipa ver gsi fw
+ *
+ * Return: QDF_STATUS
+ */
+QDF_STATUS ol_txrx_ipa_setup(struct cdp_soc_t *soc_hdl, uint8_t pdev_id,
+			     void *ipa_i2w_cb, void *ipa_w2i_cb,
+			     void *ipa_wdi_meter_notifier_cb,
+			     uint32_t ipa_desc_size,
+			     void *ipa_priv, bool is_rm_enabled,
+			     uint32_t *tx_pipe_handle, uint32_t *rx_pipe_handle,
+			     bool is_smmu_enabled,
+			     qdf_ipa_sys_connect_params_t *sys_in,
+			     bool over_gsi);
 #else /* CONFIG_IPA_WDI_UNIFIED_API */
-QDF_STATUS ol_txrx_ipa_setup(struct cdp_pdev *pdev, void *ipa_i2w_cb,
-		void *ipa_w2i_cb, void *ipa_wdi_meter_notifier_cb,
-		uint32_t ipa_desc_size, void *ipa_priv, bool is_rm_enabled,
-		uint32_t *tx_pipe_handle, uint32_t *rx_pipe_handle);
+/**
+ * ol_txrx_ipa_setup() - Setup and connect IPA pipes
+ * @soc_hdl: data path soc handle
+ * @pdev_id: device instance id
+ * @ipa_i2w_cb: IPA to WLAN callback
+ * @ipa_w2i_cb: WLAN to IPA callback
+ * @ipa_wdi_meter_notifier_cb: IPA WDI metering callback
+ * @ipa_desc_size: IPA descriptor size
+ * @ipa_priv: handle to the HTT instance
+ * @is_rm_enabled: Is IPA RM enabled or not
+ * @p_tx_pipe_handle: pointer to Tx pipe handle
+ * @p_rx_pipe_handle: pointer to Rx pipe handle
+ *
+ * Return: QDF_STATUS
+ */
+QDF_STATUS ol_txrx_ipa_setup(struct cdp_soc_t *soc_hdl, uint8_t pdev_id,
+			     void *ipa_i2w_cb, void *ipa_w2i_cb,
+			     void *ipa_wdi_meter_notifier_cb,
+			     uint32_t ipa_desc_size, void *ipa_priv,
+			     bool is_rm_enabled, uint32_t *tx_pipe_handle,
+			     uint32_t *rx_pipe_handle);
 #endif /* CONFIG_IPA_WDI_UNIFIED_API */
 QDF_STATUS ol_txrx_ipa_cleanup(uint32_t tx_pipe_handle,
 		uint32_t rx_pipe_handle);
@@ -143,15 +268,48 @@ QDF_STATUS ol_txrx_ipa_setup_iface(char *ifname, uint8_t *mac_addr,
 		qdf_ipa_client_type_t cons_client,
 		uint8_t session_id, bool is_ipv6_enabled);
 QDF_STATUS ol_txrx_ipa_cleanup_iface(char *ifname, bool is_ipv6_enabled);
-QDF_STATUS ol_txrx_ipa_enable_pipes(struct cdp_pdev *pdev);
-QDF_STATUS ol_txrx_ipa_disable_pipes(struct cdp_pdev *pdev);
+
+/**
+ * ol_txrx_ipa_enable_pipes() - Enable and resume traffic on Tx/Rx pipes
+ * @soc_hdl: data path soc handle
+ * @pdev_id: device instance id
+ *
+ * Return: QDF_STATUS
+ */
+QDF_STATUS ol_txrx_ipa_enable_pipes(struct cdp_soc_t *soc_hdl, uint8_t pdev_id);
+
+/**
+ * ol_txrx_ipa_disable_pipes() – Suspend traffic and disable Tx/Rx pipes
+ * @soc_hdl: data path soc handle
+ * @pdev_id: device instance id
+ *
+ * Return: QDF_STATUS
+ */
+QDF_STATUS ol_txrx_ipa_disable_pipes(struct cdp_soc_t *soc_hdl,
+				     uint8_t pdev_id);
 QDF_STATUS ol_txrx_ipa_set_perf_level(int client,
 		uint32_t max_supported_bw_mbps);
 #ifdef FEATURE_METERING
-QDF_STATUS ol_txrx_ipa_uc_get_share_stats(struct cdp_pdev *pdev,
-		uint8_t reset_stats);
-QDF_STATUS ol_txrx_ipa_uc_set_quota(struct cdp_pdev *pdev,
-		uint64_t quota_bytes);
+/**
+ * ol_txrx_ipa_uc_get_share_stats() - get Tx/Rx byte stats from FW
+ * @soc_hdl: data path soc handle
+ * @pdev_id: physical device instance id
+ * @value: reset stats
+ *
+ * Return: QDF_STATUS
+ */
+QDF_STATUS ol_txrx_ipa_uc_get_share_stats(struct cdp_soc_t *soc_hdl,
+					  uint8_t pdev_id, uint8_t reset_stats);
+/**
+ * ol_txrx_ipa_uc_set_quota() - set quota limit to FW
+ * @soc_hdl: data path soc handle
+ * @pdev_id: physical device instance number
+ * @value: quota limit bytes
+ *
+ * Return: QDF_STATUS
+ */
+QDF_STATUS ol_txrx_ipa_uc_set_quota(struct cdp_soc_t *soc_hdl, uint8_t pdev_id,
+				    uint64_t quota_bytes);
 #endif
 #endif
 #endif /* _OL_TXRX_IPA_H_*/

+ 1 - 2
core/hdd/src/wlan_hdd_main.c

@@ -2041,8 +2041,7 @@ int hdd_update_tgt_cfg(hdd_handle_t hdd_handle, struct wma_tgt_cfg *cfg)
 
 	ucfg_ipa_set_dp_handle(hdd_ctx->psoc,
 			       cds_get_context(QDF_MODULE_ID_SOC));
-	ucfg_ipa_set_txrx_handle(hdd_ctx->psoc,
-				 cds_get_context(QDF_MODULE_ID_TXRX));
+	ucfg_ipa_set_pdev_id(hdd_ctx->psoc, OL_TXRX_PDEV_ID);
 	ucfg_ipa_reg_sap_xmit_cb(hdd_ctx->pdev,
 				 hdd_softap_ipa_start_xmit);
 	ucfg_ipa_reg_send_to_nw_cb(hdd_ctx->pdev,

+ 0 - 112
core/wma/src/wma_main.c

@@ -654,99 +654,6 @@ static void wma_process_send_addba_req(tp_wma_handle wma_handle,
 	qdf_mem_free(send_addba);
 }
 
-/**
- * wma_ipa_get_stat() - get IPA data path stats from FW
- *
- * Return: 0 on success, errno on failure
- */
-#ifdef IPA_OFFLOAD
-static int wma_ipa_get_stat(void)
-{
-	struct cdp_pdev *pdev;
-
-	pdev = cds_get_context(QDF_MODULE_ID_TXRX);
-	if (!pdev) {
-		WMA_LOGE("pdev NULL for uc stat");
-		return -EINVAL;
-	}
-	cdp_ipa_get_stat(cds_get_context(QDF_MODULE_ID_SOC), pdev);
-
-	return 0;
-}
-#else
-static int wma_ipa_get_stat(void)
-{
-	return 0;
-}
-#endif
-
-/**
- * wma_ipa_uc_get_share_stats() - get Tx/Rx byte stats from FW
- * @privcmd: private command
- *
- * Return: 0 on success, errno on failure
- */
-#if defined(IPA_OFFLOAD) && defined(FEATURE_METERING)
-static int wma_ipa_uc_get_share_stats(wma_cli_set_cmd_t *privcmd)
-{
-	void *soc = cds_get_context(QDF_MODULE_ID_SOC);
-	struct cdp_pdev *pdev;
-	uint8_t reset_stats = privcmd->param_value;
-
-	WMA_LOGD("%s: reset_stats=%d",
-			"WMA_VDEV_TXRX_GET_IPA_UC_SHARING_STATS_CMDID",
-			reset_stats);
-	pdev = cds_get_context(QDF_MODULE_ID_TXRX);
-	if (!pdev) {
-		WMA_LOGE("pdev NULL for uc get share stats");
-		return -EINVAL;
-	}
-	cdp_ipa_uc_get_share_stats(soc, pdev, reset_stats);
-
-	return 0;
-}
-#else
-static int wma_ipa_uc_get_share_stats(wma_cli_set_cmd_t *privcmd)
-{
-	return 0;
-}
-#endif
-
-/**
- * wma_ipa_uc_set_quota() - set quota limit to FW
- * @privcmd: private command
- *
- * Return: 0 on success, errno on failure
- */
-#if defined(IPA_OFFLOAD) && defined(FEATURE_METERING)
-static int wma_ipa_uc_set_quota(wma_cli_set_cmd_t *privcmd)
-{
-	void *soc = cds_get_context(QDF_MODULE_ID_SOC);
-	struct cdp_pdev *pdev;
-	uint64_t quota_bytes = privcmd->param_sec_value;
-
-	quota_bytes <<= 32;
-	quota_bytes |= privcmd->param_value;
-
-	WMA_LOGD("%s: quota_bytes=%llu",
-			"WMA_VDEV_TXRX_SET_IPA_UC_QUOTA_CMDID",
-			quota_bytes);
-	pdev = cds_get_context(QDF_MODULE_ID_TXRX);
-	if (!pdev) {
-		WMA_LOGE("pdev NULL for uc set quota");
-		return -EINVAL;
-	}
-	cdp_ipa_uc_set_quota(soc, pdev, quota_bytes);
-
-	return 0;
-}
-#else
-static int wma_ipa_uc_set_quota(wma_cli_set_cmd_t *privcmd)
-{
-	return 0;
-}
-#endif
-
 /**
  * wma_set_priv_cfg() - set private config parameters
  * @wma_handle: wma handle
@@ -891,25 +798,6 @@ static int32_t wma_set_priv_cfg(tp_wma_handle wma_handle,
 	}
 		break;
 
-	case WMA_VDEV_TXRX_GET_IPA_UC_FW_STATS_CMDID:
-	{
-		wma_ipa_get_stat();
-	}
-		break;
-
-	case WMA_VDEV_TXRX_GET_IPA_UC_SHARING_STATS_CMDID:
-	{
-		wma_ipa_uc_get_share_stats(privcmd);
-	}
-		break;
-
-	case WMA_VDEV_TXRX_SET_IPA_UC_QUOTA_CMDID:
-	{
-		wma_ipa_uc_set_quota(privcmd);
-
-	}
-		break;
-
 	default:
 		WMA_LOGE("Invalid wma config command id:%d", privcmd->param_id);
 		ret = -EINVAL;