qcacld-3.0: Refactor channel switch resp in lim

Use vdev_start_response to replace tpSwitchChannelParams
parameter in channel switch response handler.

Lim channel switch resp handler will be called directly, don't
use post msg.

Use vdev id to replace tpHalHiddenSsidVdevRestart in hidden
ssid response handler.

Change-Id: Ida0bfed3fea1cc0ff28ed15832765d446296f3be
CRs-Fixed: 2516582
diff --git a/core/mac/src/pe/lim/lim_process_message_queue.c b/core/mac/src/pe/lim/lim_process_message_queue.c
index 3bea23f..18b05d3 100644
--- a/core/mac/src/pe/lim/lim_process_message_queue.c
+++ b/core/mac/src/pe/lim/lim_process_message_queue.c
@@ -1679,10 +1679,6 @@
 	case SIR_LIM_UPDATE_BEACON:
 		lim_update_beacon(mac_ctx);
 		break;
-	case WMA_SWITCH_CHANNEL_RSP:
-		lim_process_switch_channel_rsp(mac_ctx, msg->bodyptr);
-		msg->bodyptr = NULL;
-		break;
 #ifdef ANI_SIR_IBSS_PEER_CACHING
 	case WMA_IBSS_STA_ADD:
 		lim_ibss_sta_add(mac_ctx, msg->bodyptr);
@@ -1927,9 +1923,6 @@
 	case WMA_ADD_BSS_RSP:
 		lim_process_mlm_add_bss_rsp(mac_ctx, msg);
 		break;
-	case WMA_HIDDEN_SSID_RESTART_RSP:
-		lim_process_mlm_update_hidden_ssid_rsp(mac_ctx, msg);
-		break;
 	case WMA_ADD_STA_RSP:
 		lim_process_add_sta_rsp(mac_ctx, msg);
 		break;
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 3d53e2b..088b840 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
@@ -2510,46 +2510,31 @@
 }
 
 void lim_process_mlm_update_hidden_ssid_rsp(struct mac_context *mac_ctx,
-	struct scheduler_msg *msg)
+	uint8_t vdev_id)
 {
 	struct pe_session *session_entry;
-	tpHalHiddenSsidVdevRestart hidden_ssid_vdev_restart;
 	struct scheduler_msg message = {0};
 	QDF_STATUS status;
 
-	hidden_ssid_vdev_restart = (tpHalHiddenSsidVdevRestart)(msg->bodyptr);
-
-	if (!hidden_ssid_vdev_restart) {
-		pe_err("NULL msg pointer");
-		return;
-	}
-
-	session_entry = pe_find_session_by_session_id(mac_ctx,
-			hidden_ssid_vdev_restart->pe_session_id);
+	session_entry = pe_find_session_by_sme_session_id(mac_ctx, vdev_id);
 
 	if (!session_entry) {
-		pe_err("SessionId:%d Session Doesn't exist",
-			hidden_ssid_vdev_restart->pe_session_id);
-		goto free_req;
+		pe_err("vdev_id:%d Session Doesn't exist",
+		       vdev_id);
+		return;
 	}
 	/* Update beacon */
 	sch_set_fixed_beacon_fields(mac_ctx, session_entry);
 	lim_send_beacon(mac_ctx, session_entry);
 
 	message.type = eWNI_SME_HIDDEN_SSID_RESTART_RSP;
-	message.bodyval = hidden_ssid_vdev_restart->sessionId;
+	message.bodyval = vdev_id;
 	status = scheduler_post_message(QDF_MODULE_ID_PE,
 					QDF_MODULE_ID_SME,
 					QDF_MODULE_ID_SME, &message);
 
 	if (status != QDF_STATUS_SUCCESS)
 		pe_err("Failed to post message %u", status);
-
-free_req:
-	if (hidden_ssid_vdev_restart) {
-		qdf_mem_free(hidden_ssid_vdev_restart);
-		msg->bodyptr = NULL;
-	}
 }
 
 /**
@@ -3067,34 +3052,28 @@
  *
  * @return None
  */
-void lim_process_switch_channel_rsp(struct mac_context *mac, void *body)
+void lim_process_switch_channel_rsp(struct mac_context *mac,
+				    struct vdev_start_response *rsp)
 {
-	tpSwitchChannelParams pChnlParams = NULL;
 	QDF_STATUS status;
 	uint16_t channelChangeReasonCode;
-	uint8_t peSessionId;
 	struct pe_session *pe_session;
 	/* we need to process the deferred message since the initiating req. there might be nested request. */
 	/* in the case of nested request the new request initiated from the response will take care of resetting */
 	/* the deffered flag. */
 	SET_LIM_PROCESS_DEFD_MESGS(mac, true);
-	pChnlParams = (tpSwitchChannelParams) body;
-	status = pChnlParams->status;
-	peSessionId = pChnlParams->peSessionId;
+	status = rsp->status;
 
-	pe_session = pe_find_session_by_session_id(mac, peSessionId);
+	pe_session = pe_find_session_by_sme_session_id(mac, rsp->vdev_id);
 	if (!pe_session) {
 		pe_err("session does not exist for given sessionId");
-		goto free;
+		return;
 	}
 	pe_session->ch_switch_in_progress = false;
-	/* HAL fills in the tx power used for mgmt frames in this field. */
-	/* Store this value to use in TPC report IE. */
-	rrm_cache_mgmt_tx_power(mac, pChnlParams->txMgmtPower, pe_session);
 	channelChangeReasonCode = pe_session->channelChangeReasonCode;
 	/* initialize it back to invalid id */
-	pe_session->chainMask = pChnlParams->chainMask;
-	pe_session->smpsMode = pChnlParams->smpsMode;
+	pe_session->chainMask = rsp->chain_mask;
+	pe_session->smpsMode = rsp->smps_mode;
 	pe_session->channelChangeReasonCode = 0xBAD;
 	pe_debug("channelChangeReasonCode %d", channelChangeReasonCode);
 	switch (channelChangeReasonCode) {
@@ -3139,8 +3118,7 @@
 		 * require completely different information for P2P unlike
 		 * SAP.
 		 */
-		lim_send_sme_ap_channel_switch_resp(mac, pe_session,
-						pChnlParams);
+		lim_send_sme_ap_channel_switch_resp(mac, pe_session, rsp);
 		/* If MCC upgrade/DBS downgrade happended during channel switch,
 		 * the policy manager connection table needs to be updated.
 		 */
@@ -3160,8 +3138,6 @@
 	default:
 		break;
 	}
-free:
-	qdf_mem_free(body);
 }
 
 QDF_STATUS lim_send_beacon_ind(struct mac_context *mac,
diff --git a/core/mac/src/pe/lim/lim_send_messages.c b/core/mac/src/pe/lim/lim_send_messages.c
index 1da80fb..d0e00f2 100644
--- a/core/mac/src/pe/lim/lim_send_messages.c
+++ b/core/mac/src/pe/lim/lim_send_messages.c
@@ -138,8 +138,6 @@
 	qdf_mem_copy(pChnlParams->selfStaMacAddr, pe_session->self_mac_addr,
 		     sizeof(tSirMacAddr));
 	pChnlParams->maxTxPower = maxTxPower;
-	qdf_mem_copy(pChnlParams->bssId, pe_session->bssId,
-		     sizeof(tSirMacAddr));
 	pChnlParams->peSessionId = peSessionId;
 	pChnlParams->vhtCapable = pe_session->vhtCapability;
 	if (lim_is_session_he_capable(pe_session))
diff --git a/core/mac/src/pe/lim/lim_send_sme_rsp_messages.c b/core/mac/src/pe/lim/lim_send_sme_rsp_messages.c
index dc71711..bd1c082 100644
--- a/core/mac/src/pe/lim/lim_send_sme_rsp_messages.c
+++ b/core/mac/src/pe/lim/lim_send_sme_rsp_messages.c
@@ -1928,7 +1928,7 @@
 void
 lim_send_sme_ap_channel_switch_resp(struct mac_context *mac,
 				    struct pe_session *pe_session,
-				    tpSwitchChannelParams pChnlParams)
+				    struct vdev_start_response *rsp)
 {
 	struct scheduler_msg mmhMsg = {0};
 	tpSwitchChannelParams pSmeSwithChnlParams;
@@ -1944,10 +1944,10 @@
 	if (!pSmeSwithChnlParams)
 		return;
 
-	qdf_mem_copy(pSmeSwithChnlParams, pChnlParams,
-		     sizeof(tSwitchChannelParams));
 
-	channelId = pSmeSwithChnlParams->channelNumber;
+	channelId = wlan_reg_freq_to_chan(mac->pdev, pe_session->curr_op_freq);
+	pSmeSwithChnlParams->channelNumber = channelId;
+	pSmeSwithChnlParams->status = rsp->status;
 	ch_width = pSmeSwithChnlParams->ch_width;
 	ch_center_freq_seg1 = pSmeSwithChnlParams->ch_center_freq_seg1;
 
@@ -1955,14 +1955,14 @@
 	 * Pass the sme sessionID to SME instead
 	 * PE session ID.
 	 */
-	pSmeSwithChnlParams->peSessionId = pe_session->smeSessionId;
+	pSmeSwithChnlParams->peSessionId = rsp->vdev_id;
 
 	mmhMsg.type = eWNI_SME_CHANNEL_CHANGE_RSP;
 	mmhMsg.bodyptr = (void *)pSmeSwithChnlParams;
 	mmhMsg.bodyval = 0;
 	lim_sys_process_mmh_msg_api(mac, &mmhMsg);
 
-	if (QDF_IS_STATUS_ERROR(pChnlParams->status)) {
+	if (QDF_IS_STATUS_ERROR(rsp->status)) {
 		pe_err("failed to change sap channel to %u", channelId);
 		return;
 	}
@@ -1994,15 +1994,8 @@
 		lim_sap_move_to_cac_wait_state(pe_session);
 
 	} else {
-		if (channelId == wlan_reg_freq_to_chan(
-				mac->pdev, pe_session->curr_op_freq)) {
-			lim_apply_configuration(mac, pe_session);
-			lim_send_beacon(mac, pe_session);
-		} else {
-			pe_debug("Failed to Transmit Beacons on channel: %d after AP channel change response",
-				       pe_session->bcnLen);
-		}
-
+		lim_apply_configuration(mac, pe_session);
+		lim_send_beacon(mac, pe_session);
 		lim_obss_send_detection_cfg(mac, pe_session, true);
 	}
 	return;
diff --git a/core/mac/src/pe/lim/lim_send_sme_rsp_messages.h b/core/mac/src/pe/lim/lim_send_sme_rsp_messages.h
index fba236f..69b8c79 100644
--- a/core/mac/src/pe/lim/lim_send_sme_rsp_messages.h
+++ b/core/mac/src/pe/lim/lim_send_sme_rsp_messages.h
@@ -235,7 +235,7 @@
 
 void lim_send_sme_ap_channel_switch_resp(struct mac_context *mac,
 					 struct pe_session *pe_session,
-					 tpSwitchChannelParams pChnlParams);
+					 struct vdev_start_response *rsp);
 /*
  * lim_process_beacon_tx_success_ind() - handle successful beacon transmission
  * indication from the FW This is a generic event generated by the FW afer the
diff --git a/core/mac/src/pe/lim/lim_types.h b/core/mac/src/pe/lim/lim_types.h
index 9d89b5f..1897e31 100644
--- a/core/mac/src/pe/lim/lim_types.h
+++ b/core/mac/src/pe/lim/lim_types.h
@@ -573,8 +573,15 @@
 void lim_send_deauth_mgmt_frame(struct mac_context *, uint16_t, tSirMacAddr, struct pe_session *,
 				bool waitForAck);
 
+/**
+ * lim_process_mlm_update_hidden_ssid_rsp() - process hidden ssid response
+ * @mac_ctx: global mac context
+ * @vdev_id: vdev id
+ *
+ * Return: None
+ */
 void lim_process_mlm_update_hidden_ssid_rsp(struct mac_context *mac_ctx,
-					    struct scheduler_msg *msg);
+					    uint8_t vdev_id);
 
 tSirResultCodes lim_mlm_add_bss(struct mac_context *, tLimMlmStartReq *,
 				struct pe_session *pe_session);
@@ -793,7 +800,8 @@
 				     struct scheduler_msg *limMsgQ);
 
 /* Function to process WMA_SWITCH_CHANNEL_RSP message */
-void lim_process_switch_channel_rsp(struct mac_context *mac, void *);
+void lim_process_switch_channel_rsp(struct mac_context *mac,
+				    struct vdev_start_response *rsp);
 
 /**
  * lim_sta_handle_connect_fail() - handle connect failure of STA