Explorar o código

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 %!s(int64=5) %!d(string=hai) anos
pai
achega
8390aa8117

+ 3 - 3
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
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
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
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
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
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
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,