Browse Source

qcacld-3.0: Refactor mlme code to integrate SAP start vdev SM

Divide and refactor mlme functions to integrate vdev state
machine for SAP start.

Change-Id: Id4419261cb1ba88754eded9fd780cca60f1f5db7
CRs-Fixed: 2309240
Abhishek Singh 6 years ago
parent
commit
dfa69c397a

+ 1 - 1
core/mac/src/pe/include/lim_session.h

@@ -479,7 +479,7 @@ typedef struct sPESession       /* Added to Support BT-AMP */
 	qdf_mc_timer_t protection_fields_reset_timer;
 	/* timer to decrement CSA/ECSA count */
 	qdf_mc_timer_t ap_ecsa_timer;
-	void *mac_ctx;
+	tpAniSirGlobal mac_ctx;
 	/*
 	 * variable to store state of various protection struct like
 	 * gLimOlbcParams, gLimOverlap11gParams, gLimOverlapHt20Params etc

+ 4 - 24
core/mac/src/pe/lim/lim_process_mlm_req_messages.c

@@ -40,7 +40,6 @@
 #include "wlan_reg_services_api.h"
 #include "lim_process_fils.h"
 
-static void lim_process_mlm_start_req(tpAniSirGlobal, uint32_t *);
 static void lim_process_mlm_join_req(tpAniSirGlobal, uint32_t *);
 static void lim_process_mlm_auth_req(tpAniSirGlobal, uint32_t *);
 static void lim_process_mlm_assoc_req(tpAniSirGlobal, uint32_t *);
@@ -117,9 +116,6 @@ void lim_process_mlm_req_messages(tpAniSirGlobal mac_ctx,
 				  struct scheduler_msg *msg)
 {
 	switch (msg->type) {
-	case LIM_MLM_START_REQ:
-		lim_process_mlm_start_req(mac_ctx, msg->bodyptr);
-		break;
 	case LIM_MLM_JOIN_REQ:
 		lim_process_mlm_join_req(mac_ctx, msg->bodyptr);
 		break;
@@ -648,33 +644,17 @@ lim_mlm_add_bss(tpAniSirGlobal mac_ctx,
 	return eSIR_SME_SUCCESS;
 }
 
-/**
- * lim_process_mlm_start_req() - process MLM_START_REQ message
- *
- * @mac_ctx: global MAC context
- * @msg_buf: Pointer to MLM message buffer
- *
- * This function is called to process MLM_START_REQ message
- * from SME
- * 1) MLME receives LIM_MLM_START_REQ from LIM
- * 2) MLME sends WMA_ADD_BSS_REQ to HAL
- * 3) MLME changes state to eLIM_MLM_WT_ADD_BSS_RSP_STATE
- * MLME now waits for HAL to send WMA_ADD_BSS_RSP
- *
- * Return: None
- */
-static void lim_process_mlm_start_req(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
+void lim_process_mlm_start_req(tpAniSirGlobal mac_ctx,
+			       tLimMlmStartReq *mlm_start_req)
 {
-	tLimMlmStartReq *mlm_start_req;
 	tLimMlmStartCnf mlm_start_cnf;
 	tpPESession session = NULL;
 
-	if (msg_buf == NULL) {
+	if (!mlm_start_req) {
 		pe_err("Buffer is Pointing to NULL");
 		return;
 	}
 
-	mlm_start_req = (tLimMlmStartReq *) msg_buf;
 	session = pe_find_session_by_session_id(mac_ctx,
 				mlm_start_req->sessionId);
 	if (NULL == session) {
@@ -704,7 +684,7 @@ end:
 	mlm_start_cnf.sessionId = mlm_start_req->sessionId;
 
 	/* Free up buffer allocated for LimMlmScanReq */
-	qdf_mem_free(msg_buf);
+	qdf_mem_free(mlm_start_req);
 
 	/*
 	 * Respond immediately to LIM, only if MLME has not been

+ 21 - 5
core/mac/src/pe/lim/lim_process_sme_req_messages.c

@@ -531,6 +531,21 @@ lim_configure_ap_start_bss_session(tpAniSirGlobal mac_ctx, tpPESession session,
 
 }
 
+/**
+ * lim_send_start_vdev_req() - send vdev start request
+ *@session: pe session
+ *@mlm_start_req: vdev start req
+ *
+ * Return: QDF_STATUS
+ */
+static QDF_STATUS
+lim_send_start_vdev_req(tpPESession session, tLimMlmStartReq *mlm_start_req)
+{
+	lim_process_mlm_start_req(session->mac_ctx, mlm_start_req);
+
+	return QDF_STATUS_SUCCESS;
+}
+
 /**
  * __lim_handle_sme_start_bss_request() - process SME_START_BSS_REQ message
  *@mac_ctx: Pointer to Global MAC structure
@@ -559,7 +574,7 @@ __lim_handle_sme_start_bss_request(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
 	uint16_t sme_transaction_id = 0xFF;
 	uint32_t chanwidth;
 	struct vdev_type_nss *vdev_type_nss;
-	QDF_STATUS cfg_get_wmi_dfs_master_param = QDF_STATUS_SUCCESS;
+	QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
 	struct policy_mgr_hw_mode_params hw_mode;
 
 /* FEATURE_WLAN_DIAG_SUPPORT */
@@ -1009,13 +1024,13 @@ __lim_handle_sme_start_bss_request(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
 			if (session->lim11hEnable &&
 				(eSIR_INFRA_AP_MODE ==
 					mlm_start_req->bssType)) {
-				cfg_get_wmi_dfs_master_param =
+				qdf_status =
 					wlan_cfg_get_int(mac_ctx,
 						WNI_CFG_DFS_MASTER_ENABLED,
 						&val);
 				session->lim11hEnable = val;
 			}
-			if (cfg_get_wmi_dfs_master_param != QDF_STATUS_SUCCESS)
+			if (QDF_IS_STATUS_ERROR(qdf_status))
 				/* Failed get CFG WNI_CFG_DFS_MASTER_ENABLED */
 				pe_err("Get Fail, CFG DFS ENABLE");
 		}
@@ -1040,8 +1055,9 @@ __lim_handle_sme_start_bss_request(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
 			session->peSessionId,
 			session->limSmeState));
 
-		lim_post_mlm_message(mac_ctx, LIM_MLM_START_REQ,
-			(uint32_t *) mlm_start_req);
+		qdf_status = lim_send_start_vdev_req(session, mlm_start_req);
+		if (QDF_IS_STATUS_ERROR(qdf_status))
+			goto free;
 		return;
 	} else {
 

+ 4 - 2
core/mac/src/pe/lim/lim_session.c

@@ -136,7 +136,7 @@ static void pe_init_beacon_params(tpAniSirGlobal pMac,
 static void pe_reset_protection_callback(void *ptr)
 {
 	tpPESession pe_session_entry = (tpPESession)ptr;
-	tpAniSirGlobal mac_ctx = (tpAniSirGlobal)pe_session_entry->mac_ctx;
+	tpAniSirGlobal mac_ctx = pe_session_entry->mac_ctx;
 	int8_t i = 0;
 	tUpdateBeaconParams beacon_params;
 	uint16_t current_protection_state = 0;
@@ -678,6 +678,7 @@ tpPESession pe_create_session(tpAniSirGlobal pMac,
 	}
 	session_ptr->vdev = vdev;
 	session_ptr->smeSessionId = sme_session_id;
+	session_ptr->mac_ctx = pMac;
 
 	if (eSIR_INFRASTRUCTURE_MODE == bssType)
 		lim_ft_open(pMac, &pMac->lim.gpSession[i]);
@@ -689,7 +690,6 @@ tpPESession pe_create_session(tpAniSirGlobal pMac,
 		session_ptr->old_protection_state = 0;
 		session_ptr->is_session_obss_offload_enabled = false;
 		session_ptr->is_obss_reset_timer_initialized = false;
-		session_ptr->mac_ctx = (void *)pMac;
 
 		status = qdf_mc_timer_init(&session_ptr->
 					   protection_fields_reset_timer,
@@ -735,6 +735,7 @@ free_dp_hash_table:
 
 	session_ptr->dph.dphHashTable.pHashTable = NULL;
 	session_ptr->dph.dphHashTable.pDphNodeArray = NULL;
+	session_ptr->valid = false;
 
 	return NULL;
 }
@@ -1036,6 +1037,7 @@ void pe_delete_session(tpAniSirGlobal mac_ctx, tpPESession session)
 	pe_delete_fils_info(session);
 	session->valid = false;
 
+	session->mac_ctx = NULL;
 	if (session->access_policy_vendor_ie)
 		qdf_mem_free(session->access_policy_vendor_ie);
 

+ 13 - 1
core/mac/src/pe/lim/lim_types.h

@@ -54,7 +54,6 @@
 #define LIM_MLM_MSG_START           1000
 #define LIM_MLM_SCAN_REQ            LIM_MLM_MSG_START
 #define LIM_MLM_SCAN_CNF            (LIM_MLM_MSG_START + 1)
-#define LIM_MLM_START_REQ           (LIM_MLM_MSG_START + 2)
 #define LIM_MLM_START_CNF           (LIM_MLM_MSG_START + 3)
 #define LIM_MLM_JOIN_REQ            (LIM_MLM_MSG_START + 4)
 #define LIM_MLM_JOIN_CNF            (LIM_MLM_MSG_START + 5)
@@ -1077,5 +1076,18 @@ void lim_process_assoc_failure_timeout(tpAniSirGlobal mac_ctx,
  */
 void lim_send_mgmt_frame_tx(tpAniSirGlobal mac_ctx,
 		struct scheduler_msg *msg);
+/**
+ * lim_process_mlm_start_req() - process MLM_START_REQ message
+ *
+ * @mac_ctx: global MAC context
+ * @mlm_start_req: Pointer to start req
+ *
+ * This function is called to process MLM_START_REQ message
+ * from SME. MLME now waits for HAL to send WMA_ADD_BSS_RSP.
+ *
+ * Return: None
+ */
+void lim_process_mlm_start_req(tpAniSirGlobal mac_ctx,
+					  tLimMlmStartReq *mlm_start_req);
 
 #endif /* __LIM_TYPES_H */

+ 2 - 1
core/mac/src/pe/lim/lim_utils.c

@@ -8351,7 +8351,7 @@ void lim_process_ap_ecsa_timeout(void *data)
 		return;
 	}
 
-	mac_ctx = (tpAniSirGlobal)session->mac_ctx;
+	mac_ctx = session->mac_ctx;
 
 	if (!session->dfsIncludeChanSwIe) {
 		pe_debug("session->dfsIncludeChanSwIe not set");
@@ -8423,3 +8423,4 @@ void lim_process_ap_ecsa_timeout(void *data)
 		}
 	}
 }
+

+ 0 - 1
core/mac/src/sys/legacy/src/utils/src/mac_trace.c

@@ -707,7 +707,6 @@ uint8_t *mac_trace_get_lim_msg_string(uint16_t lim_msg)
 		CASE_RETURN_STRING(SIR_LIM_MSG_TYPES_END);
 		CASE_RETURN_STRING(LIM_MLM_SCAN_REQ);
 		CASE_RETURN_STRING(LIM_MLM_SCAN_CNF);
-		CASE_RETURN_STRING(LIM_MLM_START_REQ);
 		CASE_RETURN_STRING(LIM_MLM_START_CNF);
 		CASE_RETURN_STRING(LIM_MLM_JOIN_REQ);
 		CASE_RETURN_STRING(LIM_MLM_JOIN_CNF);

+ 11 - 15
core/sap/src/sap_fsm.c

@@ -2022,14 +2022,6 @@ static QDF_STATUS sap_cac_end_notify(tHalHandle hHal,
 					  __func__, intf);
 				return qdf_status;
 			}
-
-			/* Transition from SAP_STARTING to SAP_STARTED
-			 * (both without substates)
-			 */
-			QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_INFO_HIGH,
-				  "In %s, from state %s => %s",
-				  __func__, "SAP_DFS_CAC_WAIT",
-				  "SAP_STARTED");
 		}
 	}
 	/*
@@ -3554,16 +3546,20 @@ static int sap_start_dfs_cac_timer(struct sap_context *sap_ctx)
 	/* Start the CAC timer */
 	status = qdf_mc_timer_start(&mac->sap.SapDfsInfo.sap_dfs_cac_timer,
 			cac_dur);
-	if (status == QDF_STATUS_SUCCESS) {
-		mac->sap.SapDfsInfo.is_dfs_cac_timer_running = true;
-		return 1;
-	} else {
-		mac->sap.SapDfsInfo.is_dfs_cac_timer_running = false;
-		qdf_mc_timer_destroy(&mac->sap.SapDfsInfo.sap_dfs_cac_timer);
+	if (QDF_IS_STATUS_ERROR(status)) {
 		QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_ERROR,
 			  "%s: failed to start cac timer", __func__);
-		return 0;
+		goto destroy_timer;
 	}
+
+	mac->sap.SapDfsInfo.is_dfs_cac_timer_running = true;
+	return 0;
+
+destroy_timer:
+	mac->sap.SapDfsInfo.is_dfs_cac_timer_running = false;
+	qdf_mc_timer_destroy(&mac->sap.SapDfsInfo.sap_dfs_cac_timer);
+
+	return 1;
 }
 
 /*

+ 9 - 0
core/wma/inc/wma_internal.h

@@ -640,6 +640,15 @@ int wma_tbttoffset_update_event_handler(void *handle, uint8_t *event,
 void wma_send_probe_rsp_tmpl(tp_wma_handle wma,
 				    tpSendProbeRespParams probe_rsp_info);
 
+/**
+ * wma_set_ap_vdev_up() - send vdev up req
+ * @wma: wma handle
+ * @vdev_id: vdev id
+ *
+ * Return: none
+ */
+void wma_set_ap_vdev_up(tp_wma_handle wma, uint8_t vdev_id);
+
 void wma_send_beacon(tp_wma_handle wma, tpSendbeaconParams bcn_info);
 
 void wma_set_keepalive_req(tp_wma_handle wma,

+ 25 - 9
core/wma/src/wma_dev_if.c

@@ -867,6 +867,30 @@ send_rsp:
 	return status;
 }
 
+/**
+ * wma_send_start_resp() - send vdev start response to upper layer
+ * @wma: wma handle
+ * @add_bss: add bss params
+ * @resp_event: response params
+ *
+ * Return: none
+ */
+static void wma_send_start_resp(tp_wma_handle wma,
+			       tpAddBssParams add_bss,
+			       wmi_vdev_start_response_event_fixed_param *
+			       resp_event)
+{
+	/* Send vdev stop if vdev start was success */
+	if (QDF_IS_STATUS_ERROR(add_bss->status) &&
+	   !resp_event->status)
+		if (wma_send_vdev_stop_to_fw(wma, resp_event->vdev_id))
+			WMA_LOGE(FL("Failed to send vdev stop"));
+
+	WMA_LOGD(FL("Sending add bss rsp to umac(vdev %d status %d)"),
+		 resp_event->vdev_id, add_bss->status);
+	wma_send_msg_high_priority(wma, WMA_ADD_BSS_RSP, (void *)add_bss, 0);
+}
+
 /**
  * wma_vdev_start_rsp() - send vdev start response to upper layer
  * @wma: wma handle
@@ -960,15 +984,7 @@ send_fail_resp:
 				resp_event->vdev_id, peer, false);
 	}
 
-	/* Send vdev stop if vdev start was success */
-	if ((add_bss->status != QDF_STATUS_SUCCESS) &&
-	   !resp_event->status)
-		if (wma_send_vdev_stop_to_fw(wma, resp_event->vdev_id))
-			WMA_LOGE("%s: %d Failed to send vdev stop", __func__, __LINE__);
-
-	WMA_LOGD("%s: Sending add bss rsp to umac(vdev %d status %d)",
-		 __func__, resp_event->vdev_id, add_bss->status);
-	wma_send_msg_high_priority(wma, WMA_ADD_BSS_RSP, (void *)add_bss, 0);
+	wma_send_start_resp(wma, add_bss, resp_event);
 }
 
 #ifdef FEATURE_AP_MCC_CH_AVOIDANCE

+ 28 - 21
core/wma/src/wma_mgmt.c

@@ -2888,6 +2888,33 @@ void wma_send_probe_rsp_tmpl(tp_wma_handle wma,
 	}
 }
 
+void wma_set_ap_vdev_up(tp_wma_handle wma, uint8_t vdev_id)
+{
+	struct vdev_up_params param = {0};
+	QDF_STATUS status;
+
+	if (!((qdf_atomic_read(
+		&wma->interfaces[vdev_id].vdev_restart_params.
+		hidden_ssid_restart_in_progress)) ||
+		(wma->interfaces[vdev_id].is_channel_switch))) {
+		if (!wma_is_vdev_up(vdev_id)) {
+			param.vdev_id = vdev_id;
+			param.assoc_id = 0;
+			status = wma_send_vdev_up_to_fw(wma, &param,
+						wma->interfaces[vdev_id].bssid);
+			if (QDF_IS_STATUS_ERROR(status)) {
+				WMA_LOGE(FL("failed to send vdev up"));
+				policy_mgr_set_do_hw_mode_change_flag(
+					wma->psoc, false);
+				return;
+			}
+			wma_vdev_set_mlme_state(wma, vdev_id, WLAN_VDEV_S_RUN);
+			wma_set_sap_keepalive(wma, vdev_id);
+			wma_set_vdev_mgmt_rate(wma, vdev_id);
+		}
+	}
+}
+
 /**
  * wma_send_beacon() - send beacon template
  * @wma: wma handle
@@ -2905,7 +2932,6 @@ void wma_send_beacon(tp_wma_handle wma, tpSendbeaconParams bcn_info)
 	QDF_STATUS status;
 	uint8_t *p2p_ie;
 	struct sAniBeaconStruct *beacon;
-	struct vdev_up_params param = {0};
 
 	beacon = (struct sAniBeaconStruct *) (bcn_info->beacon);
 	vdev = wma_find_vdev_by_addr(wma, beacon->macHdr.sa, &vdev_id);
@@ -2941,26 +2967,7 @@ void wma_send_beacon(tp_wma_handle wma, tpSendbeaconParams bcn_info)
 		WMA_LOGE("%s : wma_store_bcn_tmpl Failed", __func__);
 		return;
 	}
-	if (!((qdf_atomic_read(
-		&wma->interfaces[vdev_id].vdev_restart_params.
-		hidden_ssid_restart_in_progress)) ||
-		(wma->interfaces[vdev_id].is_channel_switch))) {
-		if (!wma_is_vdev_up(vdev_id)) {
-			param.vdev_id = vdev_id;
-			param.assoc_id = 0;
-			status = wma_send_vdev_up_to_fw(wma, &param,
-							bcn_info->bssId);
-			if (QDF_IS_STATUS_ERROR(status)) {
-				WMA_LOGE(FL("failed to send vdev up"));
-				policy_mgr_set_do_hw_mode_change_flag(
-					wma->psoc, false);
-				return;
-			}
-			wma_vdev_set_mlme_state(wma, vdev_id, WLAN_VDEV_S_RUN);
-			wma_set_sap_keepalive(wma, vdev_id);
-			wma_set_vdev_mgmt_rate(wma, vdev_id);
-		}
-	}
+	wma_set_ap_vdev_up(wma, vdev_id);
 }
 
 /**