Explorar el Código

qcacld-3.0: Don't open or close sap session internally

There are few instances in current driver code, where SAP's
session is getting opened or closed internally by SAP module
which is wrong. It should come from HDD module.

Resolve above mentioned issue by following:
1) allocating and opening sap session through wlansap_open and
   wlansap_start APIs respectively.
2) freeing and closing sap session through wlansap_close and
   wlansap_stop APIs respectively.

Remove all other instances of sap_open_session and
sap_close_session.

Change-Id: I9ac9f68c9cd1f8c856b6228d4e3b32d3310c936a
CRs-Fixed: 2036385
Krunal Soni hace 8 años
padre
commit
074dd2c690
Se han modificado 4 ficheros con 70 adiciones y 199 borrados
  1. 0 1
      core/sap/src/sap_api_link_cntl.c
  2. 32 104
      core/sap/src/sap_fsm.c
  3. 0 3
      core/sap/src/sap_internal.h
  4. 38 91
      core/sap/src/sap_module.c

+ 0 - 1
core/sap/src/sap_api_link_cntl.c

@@ -918,7 +918,6 @@ wlansap_roam_callback(void *ctx, tCsrRoamInfo *csr_roam_info, uint32_t roamId,
 		QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_INFO_HIGH,
 			  FL("Session %d opened successfully"),
 			  sap_ctx->sessionId);
-		sap_ctx->isSapSessionOpen = eSAP_TRUE;
 		qdf_event_set(&sap_ctx->sap_session_opened_evt);
 		break;
 	case eCSR_ROAM_INFRA_IND:

+ 32 - 104
core/sap/src/sap_fsm.c

@@ -2632,27 +2632,26 @@ static QDF_STATUS sap_clear_global_dfs_param(tHalHandle hal)
 {
 	tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
 
-	if (NULL == sap_find_valid_concurrent_session(hal)) {
-		/* If timer is running then stop the timer and destory it */
-		QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_INFO_MED,
-			  "sapdfs: no session are valid, so clearing dfs global structure");
-		/*
-		 * CAC timer will be initiated and started only when SAP starts
-		 * on DFS channel and it will be stopped and destroyed
-		 * immediately once the radar detected or timedout. So
-		 * as per design CAC timer should be destroyed after stop
-		 */
-		if (mac_ctx->sap.SapDfsInfo.is_dfs_cac_timer_running) {
-			qdf_mc_timer_stop(&mac_ctx->sap.SapDfsInfo.
-					  sap_dfs_cac_timer);
-			mac_ctx->sap.SapDfsInfo.is_dfs_cac_timer_running = 0;
-			qdf_mc_timer_destroy(
-				&mac_ctx->sap.SapDfsInfo.sap_dfs_cac_timer);
-		}
-		mac_ctx->sap.SapDfsInfo.cac_state = eSAP_DFS_DO_NOT_SKIP_CAC;
-		sap_cac_reset_notify(hal);
-		qdf_mem_zero(&mac_ctx->sap, sizeof(mac_ctx->sap));
+	if (NULL != sap_find_valid_concurrent_session(hal)) {
+		QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_DEBUG,
+			  "conc session exists, no need to clear dfs struct");
+		return QDF_STATUS_SUCCESS;
+	}
+	/*
+	 * CAC timer will be initiated and started only when SAP starts
+	 * on DFS channel and it will be stopped and destroyed
+	 * immediately once the radar detected or timedout. So
+	 * as per design CAC timer should be destroyed after stop
+	 */
+	if (mac_ctx->sap.SapDfsInfo.is_dfs_cac_timer_running) {
+		qdf_mc_timer_stop(&mac_ctx->sap.SapDfsInfo.sap_dfs_cac_timer);
+		mac_ctx->sap.SapDfsInfo.is_dfs_cac_timer_running = 0;
+		qdf_mc_timer_destroy(
+			&mac_ctx->sap.SapDfsInfo.sap_dfs_cac_timer);
 	}
+	mac_ctx->sap.SapDfsInfo.cac_state = eSAP_DFS_DO_NOT_SKIP_CAC;
+	sap_cac_reset_notify(hal);
+	qdf_mem_zero(&mac_ctx->sap, sizeof(mac_ctx->sap));
 
 	return QDF_STATUS_SUCCESS;
 }
@@ -2663,7 +2662,6 @@ QDF_STATUS sap_set_session_param(tHalHandle hal, ptSapContext sapctx,
 	tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
 
 	sapctx->sessionId = session_id;
-	sapctx->isSapSessionOpen = eSAP_TRUE;
 	sapctx->is_pre_cac_on = false;
 	sapctx->pre_cac_complete = false;
 	sapctx->chan_before_pre_cac = 0;
@@ -2672,6 +2670,9 @@ QDF_STATUS sap_set_session_param(tHalHandle hal, ptSapContext sapctx,
 	mac_ctx->sap.sapCtxList[sapctx->sessionId].pSapContext = sapctx;
 	mac_ctx->sap.sapCtxList[sapctx->sessionId].sapPersona =
 				sapctx->csr_roamProfile.csrPersona;
+	QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_DEBUG,
+		"%s: Initializing sapContext = %p with session = %d", __func__,
+		sapctx, session_id);
 
 	return QDF_STATUS_SUCCESS;
 }
@@ -2681,18 +2682,17 @@ QDF_STATUS sap_clear_session_param(tHalHandle hal, ptSapContext sapctx,
 {
 	tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
 
-	sapctx->isCacStartNotified = false;
-	sapctx->isCacEndNotified = false;
-	sapctx->isSapSessionOpen = false;
-	sapctx->pre_cac_complete = false;
-	sapctx->is_pre_cac_on = false;
-	sapctx->chan_before_pre_cac = 0;
 	mac_ctx->sap.sapCtxList[sapctx->sessionId].sessionID =
-						CSR_SESSION_ID_INVALID;
+		CSR_SESSION_ID_INVALID;
 	mac_ctx->sap.sapCtxList[sapctx->sessionId].pSapContext = NULL;
 	mac_ctx->sap.sapCtxList[sapctx->sessionId].sapPersona =
-							QDF_MAX_NO_OF_MODE;
+		QDF_MAX_NO_OF_MODE;
 	sap_clear_global_dfs_param(hal);
+	qdf_mem_zero(sapctx, sizeof(tSapContext));
+	sapctx->sessionId = CSR_SESSION_ID_INVALID;
+	QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_DEBUG,
+		"%s: Initializing State: %d, sapContext value = %p", __func__,
+		sapctx->sapsMachine, sapctx);
 
 	return QDF_STATUS_SUCCESS;
 }
@@ -2861,26 +2861,6 @@ static QDF_STATUS sap_goto_disconnecting(ptSapContext sapContext)
 	return QDF_STATUS_SUCCESS;
 }
 
-static QDF_STATUS sap_roam_session_close_callback(void *pContext)
-{
-	ptSapContext sapContext = (ptSapContext) pContext;
-	QDF_STATUS status;
-
-	status = wlansap_context_get(pContext);
-	if (status != QDF_STATUS_SUCCESS) {
-		QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_ERROR,
-			  "%s: sap context has already been freed", __func__);
-		return status;
-	}
-
-	status = sap_signal_hdd_event(sapContext, NULL,
-				 eSAP_STOP_BSS_EVENT,
-				 (void *) eSAP_STATUS_SUCCESS);
-
-	wlansap_context_put(pContext);
-	return status;
-}
-
 /*==========================================================================
    FUNCTION    sapGotoDisconnected
 
@@ -3658,39 +3638,6 @@ static QDF_STATUS sap_fsm_state_disconnected(ptSapContext sap_ctx,
 			  "eSAP_DISCONNECTED", "eSAP_CH_SELECT",
 			  sap_ctx->sessionId);
 
-		if (sap_ctx->isSapSessionOpen == eSAP_FALSE) {
-			uint32_t type, subtype;
-			if (sap_ctx->csr_roamProfile.csrPersona ==
-			    QDF_P2P_GO_MODE)
-				qdf_status = cds_get_vdev_types(QDF_P2P_GO_MODE,
-							&type, &subtype);
-			else
-				qdf_status = cds_get_vdev_types(QDF_SAP_MODE,
-								&type,
-								&subtype);
-
-			if (QDF_STATUS_SUCCESS != qdf_status) {
-				QDF_TRACE(QDF_MODULE_ID_SAP,
-						QDF_TRACE_LEVEL_FATAL,
-						"failed to get vdev type");
-				return QDF_STATUS_E_FAILURE;
-			}
-
-			/* recycle old session Id */
-			qdf_status = sme_open_session(hal,
-					&wlansap_roam_callback,
-					sap_ctx, sap_ctx->self_mac_addr,
-					sap_ctx->sessionId, type, subtype);
-			if (QDF_STATUS_SUCCESS != qdf_status) {
-				QDF_TRACE(QDF_MODULE_ID_SAP,
-					 QDF_TRACE_LEVEL_ERROR,
-					 FL("Error: calling sme_open_session"));
-				return QDF_STATUS_E_FAILURE;
-			}
-
-			sap_ctx->isSapSessionOpen = eSAP_TRUE;
-		}
-
 		/* init dfs channel nol */
 		sap_init_dfs_channel_nol_list(sap_ctx);
 
@@ -4090,15 +4037,6 @@ static QDF_STATUS sap_fsm_state_starting(ptSapContext sap_ctx,
 				(void *) eSAP_STATUS_FAILURE);
 		qdf_status = sap_goto_disconnected(sap_ctx);
 		/* Close the SME session */
-
-		if (eSAP_TRUE == sap_ctx->isSapSessionOpen) {
-			if (QDF_STATUS_SUCCESS == sap_close_session(hal,
-						sap_ctx, NULL, false)) {
-				sap_clear_session_param(hal, sap_ctx,
-						sap_ctx->sessionId);
-				sap_ctx->isSapSessionOpen = eSAP_FALSE;
-			}
-		}
 	} else if (msg == eSAP_OPERATING_CHANNEL_CHANGED) {
 		/* The operating channel has changed, update hostapd */
 		sap_ctx->channel =
@@ -4230,19 +4168,9 @@ static QDF_STATUS sap_fsm_state_disconnecting(ptSapContext sap_ctx,
 		sap_ctx->sapsMachine = eSAP_DISCONNECTED;
 
 		/* Close the SME session */
-		if (eSAP_TRUE == sap_ctx->isSapSessionOpen) {
-			sap_ctx->isSapSessionOpen = eSAP_FALSE;
-			qdf_status = sap_close_session(hal, sap_ctx,
-					sap_roam_session_close_callback, true);
-			if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
-				qdf_status = sap_signal_hdd_event(sap_ctx, NULL,
-						eSAP_STOP_BSS_EVENT,
-						(void *)eSAP_STATUS_SUCCESS);
-			} else {
-				sap_clear_session_param(hal, sap_ctx,
-						sap_ctx->sessionId);
-			}
-		}
+		qdf_status = sap_signal_hdd_event(sap_ctx, NULL,
+					eSAP_STOP_BSS_EVENT,
+					(void *)eSAP_STATUS_SUCCESS);
 	} else if (msg == eWNI_SME_CHANNEL_CHANGE_REQ) {
 		QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_INFO_MED,
 			  FL("sapdfs: Send channel change request on sapctx[%p]"),

+ 0 - 3
core/sap/src/sap_internal.h

@@ -166,9 +166,6 @@ typedef struct sSapContext {
 	tCsrRoamProfile csr_roamProfile;
 	uint32_t csr_roamId;
 
-	/* Sap session */
-	bool isSapSessionOpen;
-
 	/* SAP event Callback to hdd */
 	tpWLAN_SAPEventCB pfnSapEventCallback;
 

+ 38 - 91
core/sap/src/sap_module.c

@@ -273,9 +273,7 @@ void *wlansap_open(void *p_cds_gctx)
 	}
 
 	/* Clean up SAP control block, initialize all values */
-	QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_INFO_HIGH, "wlansap_open");
-
-	wlansap_clean_cb(pSapCtx, 0); /*do not empty */
+	QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_DEBUG, FL("Enter"));
 
 	/* Setup the "link back" to the CDS context */
 	pSapCtx->p_cds_gctx = p_cds_gctx;
@@ -288,6 +286,7 @@ void *wlansap_open(void *p_cds_gctx)
 		qdf_mem_free(pSapCtx);
 		return NULL;
 	}
+	QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_DEBUG, FL("Exit"));
 
 	return pSapCtx;
 } /* wlansap_open */
@@ -416,10 +415,11 @@ QDF_STATUS wlansap_start(void *pCtx, enum tQDF_ADAPTER_MODE mode,
 QDF_STATUS wlansap_stop(void *pCtx)
 {
 	ptSapContext pSapCtx = NULL;
+	tHalHandle hal;
 	tpAniSirGlobal pmac;
 
 	/* Sanity check - Extract SAP control block */
-	QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_INFO_HIGH,
+	QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_DEBUG,
 		  "wlansap_stop invoked successfully ");
 
 	pSapCtx = CDS_GET_SAP_CB(pCtx);
@@ -428,13 +428,20 @@ QDF_STATUS wlansap_stop(void *pCtx)
 			  "%s: Invalid SAP pointer from pCtx", __func__);
 		return QDF_STATUS_E_FAULT;
 	}
-	pmac = (tpAniSirGlobal) CDS_GET_HAL_CB(pSapCtx->p_cds_gctx);
+	hal = CDS_GET_HAL_CB(pSapCtx->p_cds_gctx);
+	pmac = (tpAniSirGlobal) hal;
 	if (NULL == pmac) {
-		QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_INFO_HIGH,
+		QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_ERROR,
 			  "%s: Invalid MAC context from p_cds_gctx",
 			  __func__);
 		return QDF_STATUS_E_FAULT;
 	}
+	if (QDF_STATUS_SUCCESS !=
+			sap_close_session(hal, pSapCtx, NULL, false)) {
+		QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_ERROR,
+			  FL("sap session can't be closed"));
+		return QDF_STATUS_E_FAULT;
+	}
 #ifdef NAPIER_SCAN
 	ucfg_scan_unregister_requester(pmac->psoc, pSapCtx->req_id);
 #endif
@@ -466,6 +473,7 @@ QDF_STATUS wlansap_stop(void *pCtx)
 QDF_STATUS wlansap_close(void *pCtx)
 {
 	ptSapContext pSapCtx = NULL;
+	tHalHandle hal;
 
 	/* Sanity check - Extract SAP control block */
 	QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_INFO_HIGH,
@@ -477,82 +485,28 @@ QDF_STATUS wlansap_close(void *pCtx)
 			  "%s: Invalid SAP pointer from pCtx", __func__);
 		return QDF_STATUS_E_FAULT;
 	}
-
+	hal = CDS_GET_HAL_CB(pSapCtx->p_cds_gctx);
+	if (!hal) {
+		QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_ERROR,
+			  FL("Invalid hal pointer"));
+		return QDF_STATUS_E_FAULT;
+	}
 	/* Cleanup SAP control block */
-	QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_INFO_HIGH,
-		  "wlansap_close");
-
+	QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_DEBUG, FL("Enter"));
 	sap_cleanup_channel_list(pCtx);
-
 	/* empty queues/lists/pkts if any */
-	wlansap_clean_cb(pSapCtx, true);
-
+	if (pSapCtx->sessionId != CSR_SESSION_ID_INVALID)
+		sap_clear_session_param(hal, pSapCtx, pSapCtx->sessionId);
+	/*
+	 * wlansap_context_put will release actual pSapCtx memory
+	 * allocated during wlansap_open
+	 */
 	wlansap_context_put(pSapCtx);
+	QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_DEBUG, FL("Exit"));
 
 	return QDF_STATUS_SUCCESS;
 } /* wlansap_close */
 
-/*----------------------------------------------------------------------------
- * Utility Function implementations
- * -------------------------------------------------------------------------*/
-
-/**
- * wlansap_clean_cb() - clean SAP callback function.
- * @pCtx: Pointer to the global cds context; a handle to SAP's control block
- *        can be extracted from its context. When MBSSID feature is enabled,
- *        SAP context is directly passed to SAP APIs.
- *
- * Clear out all fields in the SAP context.
- *
- * Return: The result code associated with performing the operation
- *         QDF_STATUS_E_FAULT: Pointer to SAP cb is NULL;
- *                             access would cause a page fault
- *         QDF_STATUS_SUCCESS: Success
- */
-QDF_STATUS wlansap_clean_cb(ptSapContext pSapCtx, uint32_t freeFlag      /* 0 / *do not empty* /); */
-			    ) {
-	tHalHandle hal;
-
-	/*------------------------------------------------------------------------
-	    Sanity check SAP control block
-	   ------------------------------------------------------------------------*/
-
-	if (NULL == pSapCtx) {
-		QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_ERROR,
-			  "%s: Invalid SAP pointer", __func__);
-		return QDF_STATUS_E_FAULT;
-	}
-
-	/*------------------------------------------------------------------------
-	    Clean up SAP control block, initialize all values
-	   ------------------------------------------------------------------------*/
-	QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_INFO_HIGH,
-		  "wlansap_clean_cb");
-
-	hal = (tHalHandle) CDS_GET_HAL_CB(pSapCtx->p_cds_gctx);
-	if (eSAP_TRUE == pSapCtx->isSapSessionOpen && hal) {
-		QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_DEBUG,
-				"close existing SAP session");
-		sap_close_session(hal, pSapCtx, NULL, false);
-		sap_clear_session_param(hal, pSapCtx,
-					pSapCtx->sessionId);
-	}
-
-	qdf_mem_zero(pSapCtx, sizeof(tSapContext));
-
-	pSapCtx->p_cds_gctx = NULL;
-
-	pSapCtx->sapsMachine = eSAP_DISCONNECTED;
-
-	QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_INFO_HIGH,
-		  "%s: Initializing State: %d, sapContext value = %p", __func__,
-		  pSapCtx->sapsMachine, pSapCtx);
-	pSapCtx->sessionId = 0;
-	pSapCtx->channel = 0;
-
-	return QDF_STATUS_SUCCESS;
-} /* wlansap_clean_cb */
-
 /*==========================================================================
    FUNCTION    wlansap_pmc_full_pwr_req_cb
 
@@ -2290,10 +2244,9 @@ QDF_STATUS wlansap_send_action(void *pCtx, const uint8_t *pBuf,
 		return QDF_STATUS_E_FAULT;
 	}
 	hHal = CDS_GET_HAL_CB(pSapCtx->p_cds_gctx);
-	if ((NULL == hHal) || (eSAP_TRUE != pSapCtx->isSapSessionOpen)) {
+	if (NULL == hHal) {
 		QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_ERROR,
-			  "%s: HAL pointer (%p) NULL OR SME session is not open (%d)",
-			  __func__, hHal, pSapCtx->isSapSessionOpen);
+			  FL("NULL hal pointer"));
 		return QDF_STATUS_E_FAULT;
 	}
 
@@ -2344,10 +2297,9 @@ QDF_STATUS wlansap_remain_on_channel(void *pCtx,
 		return QDF_STATUS_E_FAULT;
 	}
 	hHal = CDS_GET_HAL_CB(pSapCtx->p_cds_gctx);
-	if ((NULL == hHal) || (eSAP_TRUE != pSapCtx->isSapSessionOpen)) {
+	if (NULL == hHal) {
 		QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_ERROR,
-			  "%s: HAL pointer (%p) NULL OR SME session is not open (%d)",
-			  __func__, hHal, pSapCtx->isSapSessionOpen);
+			  FL("NULL hal pointer"));
 		return QDF_STATUS_E_FAULT;
 	}
 
@@ -2391,11 +2343,9 @@ QDF_STATUS wlansap_cancel_remain_on_channel(void *pCtx,
 		return QDF_STATUS_E_FAULT;
 	}
 	hHal = CDS_GET_HAL_CB(pSapCtx->p_cds_gctx);
-	if ((NULL == hHal) ||
-		(eSAP_TRUE != pSapCtx->isSapSessionOpen)) {
+	if (NULL == hHal) {
 		QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_ERROR,
-			  "%s: HAL pointer (%p) NULL OR SME session is not open (%d)",
-			  __func__, hHal, pSapCtx->isSapSessionOpen);
+			  FL("HAL pointer is null"));
 		return QDF_STATUS_E_FAULT;
 	}
 
@@ -2608,10 +2558,9 @@ QDF_STATUS wlansap_register_mgmt_frame
 		return QDF_STATUS_E_FAULT;
 	}
 	hHal = CDS_GET_HAL_CB(pSapCtx->p_cds_gctx);
-	if ((NULL == hHal) || (eSAP_TRUE != pSapCtx->isSapSessionOpen)) {
+	if (NULL == hHal) {
 		QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_ERROR,
-			  "%s: HAL pointer (%p) NULL OR SME session is not open (%d)",
-			  __func__, hHal, pSapCtx->isSapSessionOpen);
+			  FL("hal pointer null"));
 		return QDF_STATUS_E_FAULT;
 	}
 
@@ -2658,10 +2607,9 @@ QDF_STATUS wlansap_de_register_mgmt_frame
 		return QDF_STATUS_E_FAULT;
 	}
 	hHal = CDS_GET_HAL_CB(pSapCtx->p_cds_gctx);
-	if ((NULL == hHal) || (eSAP_TRUE != pSapCtx->isSapSessionOpen)) {
+	if (NULL == hHal) {
 		QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_ERROR,
-			  "%s: HAL pointer (%p) NULL OR SME session is not open (%d)",
-			  __func__, hHal, pSapCtx->isSapSessionOpen);
+			  FL("hal pointer null"));
 		return QDF_STATUS_E_FAULT;
 	}
 
@@ -3838,7 +3786,6 @@ wlansap_set_invalid_session(void *cds_ctx)
 	}
 
 	psapctx->sessionId = CSR_SESSION_ID_INVALID;
-	psapctx->isSapSessionOpen = eSAP_FALSE;
 
 	return QDF_STATUS_SUCCESS;
 }