qcacld-3.0: Process assoc indication in sme callback

In a noisy enviornment assoc indication in SME queueu
is not getting processed due to multiple beacons/probes
getting processed in PE queue which is high priority
than SME queue.

Instead of posting a message to SME queue, assoc indication
will run to completion using sme callback mechanism.

Change-Id: I4dc7e3ef0c91964ebc842afa38b7815464e0e406
CRs-Fixed: 2114425
diff --git a/core/mac/inc/ani_global.h b/core/mac/inc/ani_global.h
index 757daa3..f6499a0 100644
--- a/core/mac/inc/ani_global.h
+++ b/core/mac/inc/ani_global.h
@@ -837,6 +837,8 @@
 	QDF_STATUS(*add_bssdescr_callback)
 		(tpAniSirGlobal pMac, tpSirBssDescription buf,
 		uint32_t scan_id, uint32_t flags);
+	QDF_STATUS(*sme_msg_callback)
+		(tHalHandle hal, struct scheduler_msg *msg);
 	uint8_t retry_packet_cnt;
 	uint8_t scan_disabled;
 	uint8_t beacon_probe_rsp_cnt_per_scan;
diff --git a/core/mac/inc/sir_api.h b/core/mac/inc/sir_api.h
index f371179..411f7e5 100644
--- a/core/mac/inc/sir_api.h
+++ b/core/mac/inc/sir_api.h
@@ -470,6 +470,7 @@
 	void *add_bssdescr_cb;
 	void *csr_roam_synch_cb;
 	void *pe_roam_synch_cb;
+	void *sme_msg_cb;
 } tSirSmeReadyReq, *tpSirSmeReadyReq;
 
 /**
diff --git a/core/mac/src/pe/lim/lim_process_mlm_rsp_messages.c b/core/mac/src/pe/lim/lim_process_mlm_rsp_messages.c
index a9490c5..de3d40e 100644
--- a/core/mac/src/pe/lim/lim_process_mlm_rsp_messages.c
+++ b/core/mac/src/pe/lim/lim_process_mlm_rsp_messages.c
@@ -790,7 +790,7 @@
 void lim_process_mlm_assoc_ind(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
 {
 	uint32_t len;
-	struct scheduler_msg msgQ = {0};
+	struct scheduler_msg msg = {0};
 	tSirSmeAssocInd *pSirSmeAssocInd;
 	tpDphHashNode pStaDs = 0;
 	tpPESession psessionEntry;
@@ -814,11 +814,12 @@
 	}
 
 	pSirSmeAssocInd->messageType = eWNI_SME_ASSOC_IND;
-	lim_fill_assoc_ind_params(pMac, (tpLimMlmAssocInd) pMsgBuf, pSirSmeAssocInd,
+	lim_fill_assoc_ind_params(pMac, (tpLimMlmAssocInd) pMsgBuf,
+				  pSirSmeAssocInd,
 				  psessionEntry);
-	msgQ.type = eWNI_SME_ASSOC_IND;
-	msgQ.bodyptr = pSirSmeAssocInd;
-	msgQ.bodyval = 0;
+	msg.type = eWNI_SME_ASSOC_IND;
+	msg.bodyptr = pSirSmeAssocInd;
+	msg.bodyval = 0;
 	pStaDs = dph_get_hash_entry(pMac,
 				    ((tpLimMlmAssocInd) pMsgBuf)->aid,
 				    &psessionEntry->dph.dphHashTable);
@@ -833,13 +834,11 @@
 	pSirSmeAssocInd->reassocReq = pStaDs->mlmStaContext.subType;
 	pSirSmeAssocInd->timingMeasCap = pStaDs->timingMeasCap;
 	MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG,
-			 psessionEntry->peSessionId, msgQ.type));
+			 psessionEntry->peSessionId, msg.type));
 #ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM    /* FEATURE_WLAN_DIAG_SUPPORT */
 	lim_diag_event_report(pMac, WLAN_PE_DIAG_ASSOC_IND_EVENT, psessionEntry, 0,
 			      0);
 #endif /* FEATURE_WLAN_DIAG_SUPPORT */
-	lim_sys_process_mmh_msg_api(pMac, &msgQ, ePROT);
-
 	pe_debug("Create CNF_WAIT_TIMER after received LIM_MLM_ASSOC_IND");
 	/*
 	** turn on a timer to detect the loss of ASSOC CNF
@@ -848,6 +847,7 @@
 			       (uint16_t) ((tpLimMlmAssocInd) pMsgBuf)->aid,
 			       psessionEntry);
 
+	pMac->lim.sme_msg_callback(pMac, &msg);
 } /*** end lim_process_mlm_assoc_ind() ***/
 
 /**
diff --git a/core/mac/src/pe/lim/lim_process_sme_req_messages.c b/core/mac/src/pe/lim/lim_process_sme_req_messages.c
index 8eb9e39..46095b7 100644
--- a/core/mac/src/pe/lim/lim_process_sme_req_messages.c
+++ b/core/mac/src/pe/lim/lim_process_sme_req_messages.c
@@ -554,6 +554,7 @@
 		pe_register_mgmt_rx_frm_callback(pMac);
 		pe_register_callbacks_with_wma(pMac, ready_req);
 		pMac->lim.add_bssdescr_callback = ready_req->add_bssdescr_cb;
+		pMac->lim.sme_msg_callback = ready_req->sme_msg_cb;
 	}
 
 	pe_debug("sending WMA_SYS_READY_IND msg to HAL");
diff --git a/core/sme/inc/sme_api.h b/core/sme/inc/sme_api.h
index 109a1a4..7ac4c00 100644
--- a/core/sme/inc/sme_api.h
+++ b/core/sme/inc/sme_api.h
@@ -1682,7 +1682,6 @@
  */
 void sme_set_5g_band_pref(tHalHandle hal_handle,
 			  struct sme_5g_band_pref_params *pref_params);
-
 /**
  * sme_get_chain_rssi() - Get chain rssi
  * @hal: Global HAL handle
@@ -1731,4 +1730,16 @@
  * Return: None
  */
 void sme_display_disconnect_stats(tHalHandle hal, uint8_t session_id);
+
+/**
+ * sme_process_msg_callback() - process callback message from LIM
+ * @hal: global hal handle
+ * @msg: scheduler message
+ *
+ * This function process the callback messages from LIM.
+ *
+ * Return: QDF_STATUS enumeration.
+ */
+QDF_STATUS sme_process_msg_callback(tHalHandle hal,
+				struct scheduler_msg *msg);
 #endif /* #if !defined( __SME_API_H ) */
diff --git a/core/sme/src/common/sme_api.c b/core/sme/src/common/sme_api.c
index 05ab1f8..47c5890 100644
--- a/core/sme/src/common/sme_api.c
+++ b/core/sme/src/common/sme_api.c
@@ -1261,6 +1261,7 @@
 		msg->length = sizeof(*msg);
 		msg->add_bssdescr_cb = csr_scan_process_single_bssdescr;
 		msg->csr_roam_synch_cb = csr_roam_synch_callback;
+		msg->sme_msg_cb = sme_process_msg_callback;
 
 		if (eSIR_FAILURE != u_mac_post_ctrl_msg(hHal, (tSirMbMsg *) msg)) {
 			status = QDF_STATUS_SUCCESS;
@@ -16631,6 +16632,19 @@
 	return status;
 }
 
+QDF_STATUS sme_process_msg_callback(tHalHandle hal,
+				struct scheduler_msg *msg)
+{
+	QDF_STATUS status = QDF_STATUS_E_FAILURE;
+
+	if (msg == NULL) {
+		sme_err("Empty message for SME Msg callback");
+		return status;
+	}
+	status = sme_process_msg(hal, msg);
+	return status;
+}
+
 void sme_display_disconnect_stats(tHalHandle hal, uint8_t session_id)
 {
 	struct csr_roam_session *session;
diff --git a/core/sme/src/csr/csr_api_roam.c b/core/sme/src/csr/csr_api_roam.c
index 59d4c70..4ecc241 100644
--- a/core/sme/src/csr/csr_api_roam.c
+++ b/core/sme/src/csr/csr_api_roam.c
@@ -15676,6 +15676,7 @@
 {
 	QDF_STATUS status = QDF_STATUS_SUCCESS;
 	tSirSmeAssocCnf *pMsg;
+	struct scheduler_msg msg = { 0 };
 
 	sme_debug("Posting eWNI_SME_ASSOC_CNF to LIM.HalStatus: %d", Halstatus);
 	do {
@@ -15701,8 +15702,13 @@
 			     QDF_MAC_ADDR_SIZE);
 		/* alternateChannelId */
 		pMsg->alternateChannelId = 11;
+
+		msg.type = pMsg->messageType;
+		msg.bodyval = 0;
+		msg.bodyptr = pMsg;
 		/* pMsg is freed by umac_send_mb_message_to_mac in anycase*/
-		status = umac_send_mb_message_to_mac(pMsg);
+		status = scheduler_post_msg_by_priority(QDF_MODULE_ID_PE, &msg,
+							true);
 	} while (0);
 	return status;
 }