Эх сурвалжийг харах

qcacld-3.0: (Part-1) Refactor open & close session logic in SME module

Current open and close session APIs mainly defined in HDD, SME, and SAP
modules are not proper. They require some design changes to maintain the
consistency.

In order to achieve the goal of making symmetrical design for open and
close session logic, refactor existing API in SME module which could
serve as stepping stone for SAP module and HDD module changes.

CRs-Fixed: 2147968
Change-Id: If39d191084a9f3f58b88f36d71cf42878a43b484
Krunal Soni 7 жил өмнө
parent
commit
8d184fa082

+ 2 - 1
core/sme/inc/csr_api.h

@@ -1720,7 +1720,8 @@ typedef QDF_STATUS (*csr_roam_completeCallback)(void *pContext,
 						uint32_t roamId,
 						eRoamCmdStatus roamStatus,
 						eCsrRoamResult roamResult);
-typedef QDF_STATUS (*csr_roamSessionCloseCallback)(void *pContext);
+typedef QDF_STATUS (*csr_session_open_cb)(uint8_t session_id);
+typedef QDF_STATUS (*csr_session_close_cb)(uint8_t session_id);
 
 #define CSR_IS_START_IBSS(pProfile) (eCSR_BSS_TYPE_START_IBSS == \
 				     (pProfile)->BSSType)

+ 2 - 2
core/sme/inc/csr_internal.h

@@ -419,8 +419,6 @@ struct addstafor_sessioncmd {
 struct delstafor_sessionCmd {
 	/* Session self mac addr */
 	tSirMacAddr selfMacAddr;
-	csr_roamSessionCloseCallback callback;
-	void *pContext;
 };
 
 struct csr_11rconfig {
@@ -886,6 +884,8 @@ struct csr_roam_session {
 	/* For BT-AMP station, this serve as BSSID for self-BSS. */
 	struct qdf_mac_addr selfMacAddr;
 
+	csr_session_open_cb  session_open_cb;
+	csr_session_close_cb session_close_cb;
 	csr_roam_completeCallback callback;
 	void *pContext;
 	eCsrConnectState connectState;

+ 50 - 7
core/sme/inc/sme_api.h

@@ -238,6 +238,26 @@ struct sme_5g_band_pref_params {
 	uint8_t     max_rssi_penalize_5g;
 };
 
+/**
+ * struct sme_session_params: Session creation params passed by HDD layer
+ * @session_open_cb: callback to be registered with SME for opening the session
+ * @session_close_cb: callback to be registered with SME for closing the session
+ * @self_mac_addr: Self mac address
+ * @sme_session_id: SME session id
+ * @type_of_persona: person type
+ * @subtype_of_persona: sub type of persona
+ */
+struct sme_session_params {
+	csr_session_open_cb  session_open_cb;
+	csr_session_close_cb session_close_cb;
+	csr_roam_completeCallback callback;
+	void *callback_ctx;
+	uint8_t *self_mac_addr;
+	uint8_t sme_session_id;
+	uint32_t type_of_persona;
+	uint32_t subtype_of_persona;
+};
+
 /*-------------------------------------------------------------------------
   Function declarations and documenation
   ------------------------------------------------------------------------*/
@@ -247,15 +267,38 @@ QDF_STATUS sme_init_chan_list(tHalHandle hal, uint8_t *alpha2,
 QDF_STATUS sme_close(tHalHandle hHal);
 QDF_STATUS sme_start(tHalHandle hHal);
 QDF_STATUS sme_stop(tHalHandle hHal, tHalStopType stopType);
-QDF_STATUS sme_open_session(tHalHandle hHal, csr_roam_completeCallback callback,
-		void *pContext, uint8_t *pSelfMacAddr,
-		uint8_t session_id, uint32_t type,
-		uint32_t subType);
+/*
+ * sme_open_session() - Open a session for given persona
+ *
+ * This is a synchronous API. For any protocol stack related activity
+ * requires session to be opened. This API needs to be called to open
+ * the session in SME module.
+ *
+ * hal: The handle returned by mac_open.
+ * params: to initialize the session open params
+ *
+ * Return:
+ * QDF_STATUS_SUCCESS - session is opened.
+ * Other status means SME is failed to open the session.
+ */
+QDF_STATUS sme_open_session(tHalHandle hal, struct sme_session_params *params);
+
+/*
+ * sme_close_session() - Close a session for given persona
+ *
+ * This is a synchronous API. This API needs to be called to close the session
+ * in SME module before terminating the session completely.
+ *
+ * hal: The handle returned by mac_open.
+ * session_id: A previous opened session's ID.
+ *
+ * Return:
+ * QDF_STATUS_SUCCESS - session is closed.
+ * Other status means SME is failed to open the session.
+ */
+QDF_STATUS sme_close_session(tHalHandle hal, uint8_t sessionId);
 void sme_set_curr_device_mode(tHalHandle hHal,
 		enum QDF_OPMODE currDeviceMode);
-QDF_STATUS sme_close_session(tHalHandle hHal, uint8_t sessionId,
-		csr_roamSessionCloseCallback callback,
-		void *pContext);
 QDF_STATUS sme_update_roam_params(tHalHandle hHal, uint8_t session_id,
 		struct roam_ext_params *roam_params_src, int update_param);
 QDF_STATUS sme_update_config(tHalHandle hHal,

+ 15 - 48
core/sme/src/common/sme_api.c

@@ -5135,30 +5135,10 @@ QDF_STATUS sme_oem_data_req(tHalHandle hal, struct oem_data_req *hdd_oem_req)
 }
 #endif /*FEATURE_OEM_DATA_SUPPORT */
 
-/*
- * sme_open_session() - Open a session for scan/roam operation.
- *
- *  This is a synchronous API.
- *
- * hHal - The handle returned by mac_open.
- * callback - A pointer to the function caller specifies for
- *		     roam/connect status indication
- * pContext - The context passed with callback
- * pSelfMacAddr - Caller allocated memory filled with self MAC address
- *			 (6 bytes)
- * pbSessionId - pointer to a caller allocated buffer for returned session ID
- *
- * Return QDF_STATUS_SUCCESS - session is opened. sessionId returned.
- *
- *		Other status means SME is failed to open the session.
- *		QDF_STATUS_E_RESOURCES - no more session available.
- */
-QDF_STATUS sme_open_session(tHalHandle hHal, csr_roam_completeCallback callback,
-			    void *pContext, uint8_t *pSelfMacAddr,
-			    uint8_t session_id, uint32_t type, uint32_t subType)
+QDF_STATUS sme_open_session(tHalHandle hal, struct sme_session_params *params)
 {
 	QDF_STATUS status = QDF_STATUS_E_INVAL;
-	tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
+	tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
 	struct cdp_pdev *pdev;
 	ol_txrx_peer_handle peer;
 	uint8_t peer_id;
@@ -5166,7 +5146,9 @@ QDF_STATUS sme_open_session(tHalHandle hHal, csr_roam_completeCallback callback,
 
 	QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_DEBUG,
 		  "%s: type=%d, session_id %d subType=%d addr:%pM",
-		  __func__, type, session_id, subType, pSelfMacAddr);
+		  __func__, params->type_of_persona,
+		  params->sme_session_id, params->subtype_of_persona,
+		  params->self_mac_addr);
 
 	pdev = cds_get_context(QDF_MODULE_ID_TXRX);
 
@@ -5176,53 +5158,38 @@ QDF_STATUS sme_open_session(tHalHandle hHal, csr_roam_completeCallback callback,
 		return status;
 	}
 
-	status = sme_acquire_global_lock(&pMac->sme);
+	status = sme_acquire_global_lock(&mac_ctx->sme);
 	if (QDF_IS_STATUS_ERROR(status))
 		return status;
 
-	peer = cdp_peer_find_by_addr(soc, pdev, pSelfMacAddr, &peer_id);
+	peer = cdp_peer_find_by_addr(soc, pdev, params->self_mac_addr,
+				     &peer_id);
 	if (peer) {
 		QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_ERROR,
 			  "%s: Peer=%d exist with same MAC",
 			  __func__, peer_id);
 		status = QDF_STATUS_E_INVAL;
 	} else {
-		status = csr_roam_open_session(pMac, callback, pContext,
-				pSelfMacAddr, session_id, type, subType);
+		status = csr_roam_open_session(mac_ctx, params);
 	}
-	sme_release_global_lock(&pMac->sme);
+	sme_release_global_lock(&mac_ctx->sme);
 
 	MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_RX_HDD_OPEN_SESSION,
-			 session_id, 0));
+			 params->sme_session_id, 0));
 
 	return status;
 }
 
-/*
- * sme_close_session() - Open a session for scan/roam operation.
- *
- *  This is a synchronous API.
- *
- * hHal - The handle returned by mac_open.
- * sessionId - A previous opened session's ID.
- * Return QDF_STATUS_SUCCESS - session is closed.
- * Other status means SME is failed to open the session.
- *	QDF_STATUS_E_INVAL - session is not opened.
- */
-QDF_STATUS sme_close_session(tHalHandle hHal, uint8_t sessionId,
-			     csr_roamSessionCloseCallback callback,
-			     void *pContext)
+QDF_STATUS sme_close_session(tHalHandle hal, uint8_t session_id)
 {
 	QDF_STATUS status;
-	tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
+	tpAniSirGlobal pMac = PMAC_STRUCT(hal);
 
 	MTRACE(qdf_trace(QDF_MODULE_ID_SME,
-			 TRACE_CODE_SME_RX_HDD_CLOSE_SESSION, sessionId, 0));
+			 TRACE_CODE_SME_RX_HDD_CLOSE_SESSION, session_id, 0));
 	status = sme_acquire_global_lock(&pMac->sme);
 	if (QDF_IS_STATUS_SUCCESS(status)) {
-		status = csr_roam_close_session(pMac, sessionId, false,
-						callback, pContext);
-
+		status = csr_roam_close_session(pMac, session_id, false);
 		sme_release_global_lock(&pMac->sme);
 	}
 

+ 53 - 46
core/sme/src/csr/csr_api_roam.c

@@ -1016,7 +1016,7 @@ QDF_STATUS csr_stop(tpAniSirGlobal pMac, tHalStopType stopType)
 	uint32_t sessionId;
 
 	for (sessionId = 0; sessionId < CSR_ROAM_SESSION_MAX; sessionId++)
-		csr_roam_close_session(pMac, sessionId, true, NULL, NULL);
+		csr_roam_close_session(pMac, sessionId, true);
 
 	csr_scan_disable(pMac);
 	pMac->scan.fCancelIdleScan = false;
@@ -1174,7 +1174,7 @@ static QDF_STATUS csr_roam_close(tpAniSirGlobal pMac)
 	uint32_t sessionId;
 
 	for (sessionId = 0; sessionId < CSR_ROAM_SESSION_MAX; sessionId++)
-		csr_roam_close_session(pMac, sessionId, true, NULL, NULL);
+		csr_roam_close_session(pMac, sessionId, true);
 
 	qdf_mc_timer_stop(&pMac->roam.hTimerWaitForKey);
 	qdf_mc_timer_destroy(&pMac->roam.hTimerWaitForKey);
@@ -3840,9 +3840,16 @@ QDF_STATUS csr_roam_call_callback(tpAniSirGlobal pMac, uint32_t sessionId,
 		 */
 		pSession->bRefAssocStartCnt--;
 	} else if (u1 == eCSR_ROAM_SET_CHANNEL_RSP && u2 ==
-				eCSR_ROAM_RESULT_CHANNEL_CHANGE_SUCCESS)
+				eCSR_ROAM_RESULT_CHANNEL_CHANGE_SUCCESS) {
 		pSession->connectedProfile.operationChannel =
 			roam_info->channelChangeRespEvent->newChannelNumber;
+	} else if ((u1 == eCSR_ROAM_SESSION_OPENED) &&
+			(u2 == eCSR_ROAM_RESULT_NONE)) {
+		if (pSession->session_open_cb)
+			pSession->session_open_cb(sessionId);
+		else
+			sme_err("session_open_cb is not registered");
+	}
 
 	if (NULL != pSession->callback) {
 		if (roam_info) {
@@ -16300,11 +16307,7 @@ QDF_STATUS csr_issue_add_sta_for_session_req(tpAniSirGlobal pMac,
 }
 
 QDF_STATUS csr_roam_open_session(tpAniSirGlobal mac_ctx,
-				 csr_roam_completeCallback callback,
-				 void *pContext,
-				 uint8_t *pSelfMacAddr,
-				 uint8_t session_id,
-				 uint32_t type, uint32_t subType)
+				 struct sme_session_params *session_param)
 {
 	QDF_STATUS status;
 	uint32_t existing_session_id;
@@ -16317,39 +16320,42 @@ QDF_STATUS csr_roam_open_session(tpAniSirGlobal mac_ctx,
 
 	/* check to see if the mac address already belongs to a session */
 	status = csr_roam_get_session_id_from_bssid(mac_ctx,
-					(struct qdf_mac_addr *)pSelfMacAddr,
-					&existing_session_id);
+			(struct qdf_mac_addr *)session_param->self_mac_addr,
+			&existing_session_id);
 	if (QDF_IS_STATUS_SUCCESS(status)) {
-		sme_err("Session %d exists with mac address "
-			   MAC_ADDRESS_STR,
-			existing_session_id, MAC_ADDR_ARRAY(pSelfMacAddr));
+		sme_err("Session %d exists with mac address " MAC_ADDRESS_STR,
+			existing_session_id,
+			MAC_ADDR_ARRAY(session_param->self_mac_addr));
 		return QDF_STATUS_E_FAILURE;
 	}
 
 	/* attempt to retrieve session for Id */
-	session = CSR_GET_SESSION(mac_ctx, session_id);
+	session = CSR_GET_SESSION(mac_ctx, session_param->sme_session_id);
 	if (!session) {
 		sme_err("Session does not exist for interface %d",
-			session_id);
+			session_param->sme_session_id);
 		return QDF_STATUS_E_FAILURE;
 	}
 
 	/* check to see if the session is already active */
 	if (session->sessionActive) {
 		sme_err("Cannot re-open active session with Id %d",
-			session_id);
+			session_param->sme_session_id);
 		return QDF_STATUS_E_FAILURE;
 	}
 
 	session->sessionActive = true;
-	session->sessionId = session_id;
+	session->sessionId = session_param->sme_session_id;
 
 	/* Initialize FT related data structures only in STA mode */
 	sme_ft_open(mac_ctx, session->sessionId);
 
-	session->callback = callback;
-	session->pContext = pContext;
-	qdf_mem_copy(&session->selfMacAddr, pSelfMacAddr,
+	session->session_open_cb = session_param->session_open_cb;
+	session->session_close_cb = session_param->session_close_cb;
+	session->callback = session_param->callback;
+	session->pContext = session_param->callback_ctx;
+
+	qdf_mem_copy(&session->selfMacAddr, session_param->self_mac_addr,
 		     sizeof(struct qdf_mac_addr));
 	status = qdf_mc_timer_init(&session->hTimerRoaming,
 				   QDF_TIMER_TYPE_SW,
@@ -16471,8 +16477,11 @@ QDF_STATUS csr_roam_open_session(tpAniSirGlobal mac_ctx,
 
 	csr_update_session_he_cap(mac_ctx, session);
 
-	return csr_issue_add_sta_for_session_req(mac_ctx, session_id,
-						 pSelfMacAddr, type, subType);
+	return csr_issue_add_sta_for_session_req(mac_ctx,
+				session_param->sme_session_id,
+				session_param->self_mac_addr,
+				session_param->type_of_persona,
+				session_param->subtype_of_persona);
 }
 
 QDF_STATUS csr_process_del_sta_session_rsp(tpAniSirGlobal pMac, uint8_t *pMsg)
@@ -16495,7 +16504,7 @@ QDF_STATUS csr_process_del_sta_session_rsp(tpAniSirGlobal pMac, uint8_t *pMsg)
 		if (!QDF_IS_STATUS_SUCCESS(status))
 			sme_debug("Failed to Release Lock");
 		else {
-			rsp->sme_callback(rsp->sme_ctx);
+			rsp->sme_callback(rsp->session_id);
 			status = sme_acquire_global_lock(&pMac->sme);
 			if (!QDF_IS_STATUS_SUCCESS(status)) {
 				sme_debug("Failed to get Lock");
@@ -16511,7 +16520,7 @@ QDF_STATUS csr_process_del_sta_session_rsp(tpAniSirGlobal pMac, uint8_t *pMsg)
 static QDF_STATUS
 csr_issue_del_sta_for_session_req(tpAniSirGlobal pMac, uint32_t sessionId,
 				  tSirMacAddr sessionMacAddr,
-				  csr_roamSessionCloseCallback callback,
+				  csr_session_close_cb callback,
 				  void *pContext)
 {
 	struct del_sta_self_params *del_sta_self_req;
@@ -16569,38 +16578,36 @@ void csr_cleanup_session(tpAniSirGlobal pMac, uint32_t sessionId)
 	}
 }
 
-QDF_STATUS csr_roam_close_session(tpAniSirGlobal pMac,
-				uint32_t sessionId,
-				  bool fSync,
-				  csr_roamSessionCloseCallback callback,
-				  void *pContext)
+QDF_STATUS csr_roam_close_session(tpAniSirGlobal mac_ctx,
+				  uint32_t session_id, bool sync)
 {
 	QDF_STATUS status = QDF_STATUS_SUCCESS;
-	struct csr_roam_session *pSession;
+	struct csr_roam_session *session;
 
-	if (!CSR_IS_SESSION_VALID(pMac, sessionId)) {
-		sme_err("session %d not found", sessionId);
+	if (!CSR_IS_SESSION_VALID(mac_ctx, session_id)) {
+		sme_err("session %d not found", session_id);
 		return QDF_STATUS_E_INVAL;
 	}
 
-	pSession = CSR_GET_SESSION(pMac, sessionId);
+	session = CSR_GET_SESSION(mac_ctx, session_id);
 	/* Vdev going down stop roaming */
-	pSession->fCancelRoaming = true;
-	if (fSync) {
-		csr_cleanup_session(pMac, sessionId);
+	session->fCancelRoaming = true;
+	if (sync) {
+		csr_cleanup_session(mac_ctx, session_id);
 		return status;
 	}
 
-	purge_sme_session_pending_cmd_list(pMac, sessionId);
-	purge_sme_session_active_cmd_list(pMac, sessionId);
-	purge_sme_session_pending_scan_cmd_list(pMac,
-			sessionId);
-	purge_sme_session_active_scan_cmd_list(pMac,
-			sessionId);
-	status = csr_issue_del_sta_for_session_req(pMac,
-			sessionId,
-			pSession->selfMacAddr.bytes,
-			callback, pContext);
+	purge_sme_session_pending_cmd_list(mac_ctx, session_id);
+	purge_sme_session_active_cmd_list(mac_ctx, session_id);
+	purge_sme_session_pending_scan_cmd_list(mac_ctx, session_id);
+	purge_sme_session_active_scan_cmd_list(mac_ctx, session_id);
+	if (!session->session_close_cb) {
+		sme_err("no close session callback registered");
+		return QDF_STATUS_E_FAILURE;
+	}
+	status = csr_issue_del_sta_for_session_req(mac_ctx,
+			session_id, session->selfMacAddr.bytes,
+			session->session_close_cb, NULL);
 	return status;
 }
 

+ 3 - 9
core/sme/src/csr/csr_inside_api.h

@@ -510,15 +510,9 @@ bool csr_match_country_code(tpAniSirGlobal pMac, uint8_t *pCountry,
 QDF_STATUS csr_roam_set_key(tpAniSirGlobal pMac, uint32_t sessionId,
 			    tCsrRoamSetKey *pSetKey, uint32_t roamId);
 QDF_STATUS csr_roam_open_session(tpAniSirGlobal pMac,
-				 csr_roam_completeCallback callback,
-				 void *pContext, uint8_t *pSelfMacAddr,
-				 uint8_t session_id, uint32_t type,
-				 uint32_t subType);
-/* fSync: true means cleanupneeds to handle synchronously. */
-QDF_STATUS csr_roam_close_session(tpAniSirGlobal pMac, uint32_t sessionId,
-				  bool fSync,
-				  csr_roamSessionCloseCallback callback,
-				  void *pContext);
+				 struct sme_session_params *session_param);
+QDF_STATUS csr_roam_close_session(tpAniSirGlobal mac_ctx,
+				  uint32_t session_id, bool sync);
 void csr_cleanup_session(tpAniSirGlobal pMac, uint32_t sessionId);
 QDF_STATUS csr_roam_get_session_id_from_bssid(tpAniSirGlobal pMac,
 						struct qdf_mac_addr *bssid,

+ 1 - 1
core/wma/inc/wma_if.h

@@ -1323,7 +1323,7 @@ struct del_sta_self_params {
 	tSirMacAddr self_mac_addr;
 	uint8_t session_id;
 	uint32_t status;
-	QDF_STATUS (*sme_callback)(void *sme_ctx);
+	csr_session_close_cb sme_callback;
 	void *sme_ctx;
 };