blob: a083a7f48f3dd4847371ac3ff0488caaca62e798 [file] [log] [blame]
Varun Reddy Yeturu99ff7f02016-02-11 07:10:22 -08001/*
Jeff Johnson0301ecb2018-06-29 09:36:23 -07002 * Copyright (c) 2016-2018 The Linux Foundation. All rights reserved.
Varun Reddy Yeturu99ff7f02016-02-11 07:10:22 -08003 *
Varun Reddy Yeturu99ff7f02016-02-11 07:10:22 -08004 * Permission to use, copy, modify, and/or distribute this software for
5 * any purpose with or without fee is hereby granted, provided that the
6 * above copyright notice and this permission notice appear in all
7 * copies.
8 *
9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
10 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
11 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
12 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
13 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
14 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
15 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
16 * PERFORMANCE OF THIS SOFTWARE.
17 */
18
19/**
20 * DOC: lim_reassoc_utils.c
21 *
22 * Host based roaming re-association utilities
23 */
24
25#include "cds_api.h"
26#include "ani_global.h"
27#include "wni_api.h"
28#include "sir_common.h"
29
30#include "wni_cfg.h"
31#include "cfg_api.h"
32
33#include "sch_api.h"
34#include "utils_api.h"
35#include "lim_utils.h"
36#include "lim_assoc_utils.h"
37#include "lim_security_utils.h"
38#include "lim_ser_des_utils.h"
39#include "lim_sta_hash_api.h"
40#include "lim_admit_control.h"
41#include "lim_send_messages.h"
42#include "lim_ibss_peer_mgmt.h"
43#include "lim_ft_defs.h"
44#include "lim_session.h"
45
46#include "qdf_types.h"
47#include "wma_types.h"
48#include "lim_types.h"
49
50/**
51 * lim_update_re_assoc_globals() - Update reassoc global data
Jeff Johnson348973e2018-11-22 16:51:12 -080052 * @mac: Global MAC context
Varun Reddy Yeturu99ff7f02016-02-11 07:10:22 -080053 * @pAssocRsp: Reassociation response data
Jeff Johnsonb5c13332018-12-03 09:54:51 -080054 * @pe_session: PE Session
Varun Reddy Yeturu99ff7f02016-02-11 07:10:22 -080055 *
56 * This function is called to Update the Globals (LIM) during ReAssoc.
57 *
58 * Return: None
59 */
60
Jeff Johnson9320c1e2018-12-02 13:09:20 -080061void lim_update_re_assoc_globals(struct mac_context *mac, tpSirAssocRsp pAssocRsp,
Jeff Johnsonb5c13332018-12-03 09:54:51 -080062 struct pe_session *pe_session)
Varun Reddy Yeturu99ff7f02016-02-11 07:10:22 -080063{
64 /* Update the current Bss Information */
Jeff Johnsonb5c13332018-12-03 09:54:51 -080065 qdf_mem_copy(pe_session->bssId,
66 pe_session->limReAssocbssId, sizeof(tSirMacAddr));
67 pe_session->currentOperChannel = pe_session->limReassocChannelId;
68 pe_session->htSecondaryChannelOffset =
69 pe_session->reAssocHtSupportedChannelWidthSet;
70 pe_session->htRecommendedTxWidthSet =
71 pe_session->reAssocHtRecommendedTxWidthSet;
72 pe_session->htSecondaryChannelOffset =
73 pe_session->reAssocHtSecondaryChannelOffset;
74 pe_session->limCurrentBssCaps = pe_session->limReassocBssCaps;
75 pe_session->limCurrentBssQosCaps =
76 pe_session->limReassocBssQosCaps;
77 pe_session->limCurrentBssPropCap =
78 pe_session->limReassocBssPropCap;
Varun Reddy Yeturu99ff7f02016-02-11 07:10:22 -080079
Jeff Johnsonb5c13332018-12-03 09:54:51 -080080 qdf_mem_copy((uint8_t *) &pe_session->ssId,
81 (uint8_t *) &pe_session->limReassocSSID,
82 pe_session->limReassocSSID.length + 1);
Varun Reddy Yeturu99ff7f02016-02-11 07:10:22 -080083
84 /* Store assigned AID for TIM processing */
Jeff Johnsonb5c13332018-12-03 09:54:51 -080085 pe_session->limAID = pAssocRsp->aid & 0x3FFF;
Varun Reddy Yeturu99ff7f02016-02-11 07:10:22 -080086 /** Set the State Back to ReAssoc Rsp*/
Jeff Johnsonb5c13332018-12-03 09:54:51 -080087 pe_session->limMlmState = eLIM_MLM_WT_REASSOC_RSP_STATE;
Varun Reddy Yeturu99ff7f02016-02-11 07:10:22 -080088 MTRACE(mac_trace
Jeff Johnsonb5c13332018-12-03 09:54:51 -080089 (mac, TRACE_CODE_MLM_STATE, pe_session->peSessionId,
90 pe_session->limMlmState));
Varun Reddy Yeturu99ff7f02016-02-11 07:10:22 -080091
92}
93
94/**
95 * @lim_handle_del_bss_in_re_assoc_context() - DEL BSS during reassociation
Jeff Johnson348973e2018-11-22 16:51:12 -080096 * @mac: Global MAC Context
Varun Reddy Yeturu99ff7f02016-02-11 07:10:22 -080097 * @pStaDs: Station Hash entry
Jeff Johnsonb5c13332018-12-03 09:54:51 -080098 * @pe_session: PE Session
Varun Reddy Yeturu99ff7f02016-02-11 07:10:22 -080099 *
100 * While Processing the ReAssociation Response Frame in STA,
101 * a.immediately after receiving the Reassoc Response the RxCleanUp is
102 * being issued and the end of DelBSS the new BSS is being added.
103 *
104 * b. If an AP rejects the ReAssociation (Disassoc/Deauth) with some context
105 * change, We need to update CSR with ReAssocCNF Response with the
106 * ReAssoc Fail and the reason Code, that is also being handled in the
107 * DELBSS context only
108 *
109 * Return: None
110 */
Jeff Johnson9320c1e2018-12-02 13:09:20 -0800111void lim_handle_del_bss_in_re_assoc_context(struct mac_context *mac,
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800112 tpDphHashNode pStaDs, struct pe_session *pe_session)
Varun Reddy Yeturu99ff7f02016-02-11 07:10:22 -0800113{
114 tLimMlmReassocCnf mlmReassocCnf;
115 tpSirBssDescription bss_desc;
116 /*
117 * Skipped the DeleteDPH Hash Entry as we need it for the new BSS
118 * Set the MlmState to IDLE
119 */
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800120 pe_session->limMlmState = eLIM_MLM_IDLE_STATE;
Varun Reddy Yeturu99ff7f02016-02-11 07:10:22 -0800121 /* Update PE session Id */
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800122 mlmReassocCnf.sessionId = pe_session->peSessionId;
123 switch (pe_session->limSmeState) {
Varun Reddy Yeturu99ff7f02016-02-11 07:10:22 -0800124 case eLIM_SME_WT_REASSOC_STATE:
125 {
126 tpSirAssocRsp assocRsp;
127 tpDphHashNode pStaDs;
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700128 QDF_STATUS retStatus = QDF_STATUS_SUCCESS;
Varun Reddy Yeturu99ff7f02016-02-11 07:10:22 -0800129 tpSchBeaconStruct beacon_struct;
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -0700130
Varun Reddy Yeturu99ff7f02016-02-11 07:10:22 -0800131 beacon_struct = qdf_mem_malloc(sizeof(tSchBeaconStruct));
Arif Hussainf5b6c412018-10-10 19:41:09 -0700132 if (!beacon_struct) {
Varun Reddy Yeturu99ff7f02016-02-11 07:10:22 -0800133 mlmReassocCnf.resultCode =
134 eSIR_SME_RESOURCES_UNAVAILABLE;
135 mlmReassocCnf.protStatusCode =
136 eSIR_MAC_UNSPEC_FAILURE_STATUS;
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800137 lim_delete_dph_hash_entry(mac, pe_session->bssId,
138 DPH_STA_HASH_INDEX_PEER, pe_session);
Varun Reddy Yeturu99ff7f02016-02-11 07:10:22 -0800139 goto error;
140 }
141 /* Delete the older STA Table entry */
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800142 lim_delete_dph_hash_entry(mac, pe_session->bssId,
143 DPH_STA_HASH_INDEX_PEER, pe_session);
Varun Reddy Yeturu99ff7f02016-02-11 07:10:22 -0800144 /*
145 * Add an entry for AP to hash table
146 * maintained by DPH module
147 */
Jeff Johnson348973e2018-11-22 16:51:12 -0800148 pStaDs = dph_add_hash_entry(mac,
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800149 pe_session->limReAssocbssId,
Varun Reddy Yeturu99ff7f02016-02-11 07:10:22 -0800150 DPH_STA_HASH_INDEX_PEER,
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800151 &pe_session->dph.dphHashTable);
Varun Reddy Yeturu99ff7f02016-02-11 07:10:22 -0800152 if (pStaDs == NULL) {
153 /* Could not add hash table entry */
Srinivas Girigowdacc95af02017-03-26 11:31:49 -0700154 pe_err("could not add hash entry at DPH for");
Jeff Johnson348973e2018-11-22 16:51:12 -0800155 lim_print_mac_addr(mac,
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800156 pe_session->limReAssocbssId, LOGE);
Varun Reddy Yeturu99ff7f02016-02-11 07:10:22 -0800157 mlmReassocCnf.resultCode =
158 eSIR_SME_RESOURCES_UNAVAILABLE;
159 mlmReassocCnf.protStatusCode = eSIR_SME_SUCCESS;
160 qdf_mem_free(beacon_struct);
161 goto error;
162 }
163 /*
164 * While Processing the ReAssoc Response Frame the Rsp Frame
165 * is being stored to be used here for sending ADDBSS
166 */
167 assocRsp =
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800168 (tpSirAssocRsp) pe_session->limAssocResponseData;
Jeff Johnson348973e2018-11-22 16:51:12 -0800169 lim_update_assoc_sta_datas(mac, pStaDs, assocRsp,
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800170 pe_session);
171 lim_update_re_assoc_globals(mac, assocRsp, pe_session);
172 bss_desc = &pe_session->pLimReAssocReq->bssDescription;
Jeff Johnson348973e2018-11-22 16:51:12 -0800173 lim_extract_ap_capabilities(mac,
Varun Reddy Yeturu99ff7f02016-02-11 07:10:22 -0800174 (uint8_t *) bss_desc->ieFields,
175 lim_get_ielen_from_bss_description(bss_desc),
176 beacon_struct);
Jeff Johnson348973e2018-11-22 16:51:12 -0800177 if (mac->lim.gLimProtectionControl !=
Pragaspathi Thilagaraj1ee76002018-09-18 21:38:51 +0530178 MLME_FORCE_POLICY_PROTECTION_DISABLE)
Jeff Johnson348973e2018-11-22 16:51:12 -0800179 lim_decide_sta_protection_on_assoc(mac,
Varun Reddy Yeturu99ff7f02016-02-11 07:10:22 -0800180 beacon_struct,
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800181 pe_session);
Varun Reddy Yeturu99ff7f02016-02-11 07:10:22 -0800182 if (beacon_struct->erpPresent) {
183 if (beacon_struct->erpIEInfo.barkerPreambleMode)
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800184 pe_session->beaconParams.fShortPreamble = 0;
Varun Reddy Yeturu99ff7f02016-02-11 07:10:22 -0800185 else
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800186 pe_session->beaconParams.fShortPreamble = 1;
Varun Reddy Yeturu99ff7f02016-02-11 07:10:22 -0800187 }
188 /*
189 * updateBss flag is false, as in this case, PE is first
190 * deleting the existing BSS and then adding a new one
191 */
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700192 if (QDF_STATUS_SUCCESS !=
Jeff Johnson348973e2018-11-22 16:51:12 -0800193 lim_sta_send_add_bss(mac, assocRsp, beacon_struct,
Varun Reddy Yeturu99ff7f02016-02-11 07:10:22 -0800194 bss_desc,
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800195 false, pe_session)) {
Srinivas Girigowdacc95af02017-03-26 11:31:49 -0700196 pe_err("Posting ADDBSS in the ReAssocCtx Failed");
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700197 retStatus = QDF_STATUS_E_FAILURE;
Varun Reddy Yeturu99ff7f02016-02-11 07:10:22 -0800198 }
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700199 if (retStatus != QDF_STATUS_SUCCESS) {
Varun Reddy Yeturu99ff7f02016-02-11 07:10:22 -0800200 mlmReassocCnf.resultCode =
201 eSIR_SME_RESOURCES_UNAVAILABLE;
202 mlmReassocCnf.protStatusCode =
203 eSIR_MAC_UNSPEC_FAILURE_STATUS;
204 qdf_mem_free(assocRsp);
Jeff Johnson348973e2018-11-22 16:51:12 -0800205 mac->lim.gLimAssocResponseData = NULL;
Varun Reddy Yeturu99ff7f02016-02-11 07:10:22 -0800206 qdf_mem_free(beacon_struct);
207 goto error;
208 }
209 qdf_mem_free(assocRsp);
210 qdf_mem_free(beacon_struct);
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800211 pe_session->limAssocResponseData = NULL;
Varun Reddy Yeturu99ff7f02016-02-11 07:10:22 -0800212 }
213 break;
Varun Reddy Yeturu99ff7f02016-02-11 07:10:22 -0800214 default:
Srinivas Girigowdacc95af02017-03-26 11:31:49 -0700215 pe_err("DelBss in wrong system Role and SME State");
Varun Reddy Yeturu99ff7f02016-02-11 07:10:22 -0800216 mlmReassocCnf.resultCode = eSIR_SME_REFUSED;
217 mlmReassocCnf.protStatusCode =
218 eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
219 goto error;
220 }
221 return;
222error:
Jeff Johnson348973e2018-11-22 16:51:12 -0800223 lim_post_sme_message(mac, LIM_MLM_REASSOC_CNF,
Varun Reddy Yeturu99ff7f02016-02-11 07:10:22 -0800224 (uint32_t *) &mlmReassocCnf);
225}
226
227/**
228 * @lim_handle_add_bss_in_re_assoc_context() - ADD BSS during reassociation
Jeff Johnson348973e2018-11-22 16:51:12 -0800229 * @mac: Global MAC Context
Varun Reddy Yeturu99ff7f02016-02-11 07:10:22 -0800230 * @pStaDs: Station Hash entry
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800231 * @pe_session: PE Session
Varun Reddy Yeturu99ff7f02016-02-11 07:10:22 -0800232 *
233 * While Processing the ReAssociation Response Frame in STA,
234 * a. immediately after receiving the Reassoc Response the RxCleanUp is
235 * being issued and the end of DelBSS the new BSS is being added.
236 *
237 * b. If an AP rejects the ReAssociation (Disassoc/Deauth) with some context
238 * change, We need to update CSR with ReAssocCNF Response with the
239 * ReAssoc Fail and the reason Code, that is also being handled in the
240 * DELBSS context only
241 *
242 * Return: None
243 */
Jeff Johnson9320c1e2018-12-02 13:09:20 -0800244void lim_handle_add_bss_in_re_assoc_context(struct mac_context *mac,
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800245 tpDphHashNode pStaDs, struct pe_session *pe_session)
Varun Reddy Yeturu99ff7f02016-02-11 07:10:22 -0800246{
247 tLimMlmReassocCnf mlmReassocCnf;
248 /** Skipped the DeleteDPH Hash Entry as we need it for the new BSS*/
249 /** Set the MlmState to IDLE*/
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800250 pe_session->limMlmState = eLIM_MLM_IDLE_STATE;
Varun Reddy Yeturu99ff7f02016-02-11 07:10:22 -0800251 MTRACE(mac_trace
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800252 (mac, TRACE_CODE_MLM_STATE, pe_session->peSessionId,
253 pe_session->limMlmState));
254 switch (pe_session->limSmeState) {
Varun Reddy Yeturu99ff7f02016-02-11 07:10:22 -0800255 case eLIM_SME_WT_REASSOC_STATE: {
256 tpSirAssocRsp assocRsp;
257 tpDphHashNode pStaDs;
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700258 QDF_STATUS retStatus = QDF_STATUS_SUCCESS;
Varun Reddy Yeturu99ff7f02016-02-11 07:10:22 -0800259 tSchBeaconStruct *pBeaconStruct;
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -0700260
Varun Reddy Yeturu99ff7f02016-02-11 07:10:22 -0800261 pBeaconStruct =
262 qdf_mem_malloc(sizeof(tSchBeaconStruct));
Arif Hussainf5b6c412018-10-10 19:41:09 -0700263 if (!pBeaconStruct) {
Varun Reddy Yeturu99ff7f02016-02-11 07:10:22 -0800264 mlmReassocCnf.resultCode =
265 eSIR_SME_RESOURCES_UNAVAILABLE;
266 mlmReassocCnf.protStatusCode =
267 eSIR_SME_RESOURCES_UNAVAILABLE;
268 goto Error;
269 }
270 /* Get the AP entry from DPH hash table */
271 pStaDs =
Jeff Johnson348973e2018-11-22 16:51:12 -0800272 dph_get_hash_entry(mac, DPH_STA_HASH_INDEX_PEER,
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800273 &pe_session->dph.dphHashTable);
Varun Reddy Yeturu99ff7f02016-02-11 07:10:22 -0800274 if (pStaDs == NULL) {
Srinivas Girigowdacc95af02017-03-26 11:31:49 -0700275 pe_err("Fail to get STA PEER entry from hash");
Varun Reddy Yeturu99ff7f02016-02-11 07:10:22 -0800276 mlmReassocCnf.resultCode =
277 eSIR_SME_RESOURCES_UNAVAILABLE;
278 mlmReassocCnf.protStatusCode = eSIR_SME_SUCCESS;
279 qdf_mem_free(pBeaconStruct);
280 goto Error;
281 }
282 /*
283 * While Processing the ReAssoc Response Frame the Rsp Frame
284 * is being stored to be used here for sending ADDBSS
285 */
286 assocRsp =
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800287 (tpSirAssocRsp) pe_session->limAssocResponseData;
Jeff Johnson348973e2018-11-22 16:51:12 -0800288 lim_update_assoc_sta_datas(mac, pStaDs, assocRsp,
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800289 pe_session);
290 lim_update_re_assoc_globals(mac, assocRsp, pe_session);
Jeff Johnson348973e2018-11-22 16:51:12 -0800291 lim_extract_ap_capabilities(mac,
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800292 (uint8_t *) pe_session->
Varun Reddy Yeturu99ff7f02016-02-11 07:10:22 -0800293 pLimReAssocReq->bssDescription.
294 ieFields,
295 lim_get_ielen_from_bss_description
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800296 (&pe_session->
Varun Reddy Yeturu99ff7f02016-02-11 07:10:22 -0800297 pLimReAssocReq->
298 bssDescription),
299 pBeaconStruct);
Jeff Johnson348973e2018-11-22 16:51:12 -0800300 if (mac->lim.gLimProtectionControl !=
Pragaspathi Thilagaraj1ee76002018-09-18 21:38:51 +0530301 MLME_FORCE_POLICY_PROTECTION_DISABLE)
Jeff Johnson348973e2018-11-22 16:51:12 -0800302 lim_decide_sta_protection_on_assoc(mac,
Varun Reddy Yeturu99ff7f02016-02-11 07:10:22 -0800303 pBeaconStruct,
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800304 pe_session);
Varun Reddy Yeturu99ff7f02016-02-11 07:10:22 -0800305
306 if (pBeaconStruct->erpPresent) {
307 if (pBeaconStruct->erpIEInfo.barkerPreambleMode)
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800308 pe_session->beaconParams.
Varun Reddy Yeturu99ff7f02016-02-11 07:10:22 -0800309 fShortPreamble = 0;
310 else
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800311 pe_session->beaconParams.
Varun Reddy Yeturu99ff7f02016-02-11 07:10:22 -0800312 fShortPreamble = 1;
313 }
314
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800315 pe_session->isNonRoamReassoc = 1;
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700316 if (QDF_STATUS_SUCCESS !=
Jeff Johnson348973e2018-11-22 16:51:12 -0800317 lim_sta_send_add_bss(mac, assocRsp, pBeaconStruct,
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800318 &pe_session->pLimReAssocReq->
Varun Reddy Yeturu99ff7f02016-02-11 07:10:22 -0800319 bssDescription, true,
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800320 pe_session)) {
Srinivas Girigowdacc95af02017-03-26 11:31:49 -0700321 pe_err("Post ADDBSS in the ReAssocCtxt Failed");
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700322 retStatus = QDF_STATUS_E_FAILURE;
Varun Reddy Yeturu99ff7f02016-02-11 07:10:22 -0800323 }
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700324 if (retStatus != QDF_STATUS_SUCCESS) {
Varun Reddy Yeturu99ff7f02016-02-11 07:10:22 -0800325 mlmReassocCnf.resultCode =
326 eSIR_SME_RESOURCES_UNAVAILABLE;
327 mlmReassocCnf.protStatusCode =
328 eSIR_MAC_UNSPEC_FAILURE_STATUS;
329 qdf_mem_free(assocRsp);
Jeff Johnson348973e2018-11-22 16:51:12 -0800330 mac->lim.gLimAssocResponseData = NULL;
Varun Reddy Yeturu99ff7f02016-02-11 07:10:22 -0800331 qdf_mem_free(pBeaconStruct);
332 goto Error;
333 }
334 qdf_mem_free(assocRsp);
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800335 pe_session->limAssocResponseData = NULL;
Varun Reddy Yeturu99ff7f02016-02-11 07:10:22 -0800336 qdf_mem_free(pBeaconStruct);
337 }
338 break;
Varun Reddy Yeturu99ff7f02016-02-11 07:10:22 -0800339 default:
Srinivas Girigowdacc95af02017-03-26 11:31:49 -0700340 pe_err("DelBss in the wrong system Role and SME State");
Varun Reddy Yeturu99ff7f02016-02-11 07:10:22 -0800341 mlmReassocCnf.resultCode = eSIR_SME_REFUSED;
342 mlmReassocCnf.protStatusCode =
343 eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
344 goto Error;
345 }
346 return;
347Error:
Jeff Johnson348973e2018-11-22 16:51:12 -0800348 lim_post_sme_message(mac, LIM_MLM_REASSOC_CNF,
Varun Reddy Yeturu99ff7f02016-02-11 07:10:22 -0800349 (uint32_t *) &mlmReassocCnf);
350}
351
352/**
353 * lim_is_reassoc_in_progress() - Check if reassoiciation is in progress
Jeff Johnson348973e2018-11-22 16:51:12 -0800354 * @mac: Global MAC Context
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800355 * @pe_session: PE Session
Varun Reddy Yeturu99ff7f02016-02-11 07:10:22 -0800356 *
357 * Return: true When STA is waiting for Reassoc response from AP
358 * else false
359 */
Jeff Johnson9320c1e2018-12-02 13:09:20 -0800360bool lim_is_reassoc_in_progress(struct mac_context *mac, struct pe_session *pe_session)
Varun Reddy Yeturu99ff7f02016-02-11 07:10:22 -0800361{
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800362 if (pe_session == NULL)
Varun Reddy Yeturu99ff7f02016-02-11 07:10:22 -0800363 return false;
Naveen Rawatba662972017-07-05 16:07:08 -0700364
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800365 if (LIM_IS_STA_ROLE(pe_session) &&
366 (pe_session->limSmeState == eLIM_SME_WT_REASSOC_STATE))
Varun Reddy Yeturu99ff7f02016-02-11 07:10:22 -0800367 return true;
368
369 return false;
370}
371
372/**
373 * lim_add_ft_sta_self()- function to add STA once we have connected with a
374 * new AP
375 * @mac_ctx: pointer to global mac structure
376 * @assoc_id: association id for the station connection
377 * @session_entry: pe session entr
378 *
379 * This function is called to add a STA once we have connected with a new
380 * AP, that we have performed an FT to.
381 *
382 * The Add STA Response is created and now after the ADD Bss Is Successful
383 * we add the self sta. We update with the association id from the reassoc
384 * response from the AP.
385 *
Jeff Johnsond9e03512018-06-29 12:04:03 -0700386 * Return: QDF_STATUS_SUCCESS on success else QDF_STATUS failure codes
Varun Reddy Yeturu99ff7f02016-02-11 07:10:22 -0800387 */
Jeff Johnson9320c1e2018-12-02 13:09:20 -0800388QDF_STATUS lim_add_ft_sta_self(struct mac_context *mac_ctx, uint16_t assoc_id,
Jeff Johnsonf19e3f12018-11-19 06:45:35 -0800389 struct pe_session *session_entry)
Varun Reddy Yeturu99ff7f02016-02-11 07:10:22 -0800390{
391 tpAddStaParams add_sta_params = NULL;
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700392 QDF_STATUS ret_code = QDF_STATUS_SUCCESS;
Rajeev Kumar37d478b2017-04-17 16:59:28 -0700393 struct scheduler_msg msg_q = {0};
Varun Reddy Yeturu99ff7f02016-02-11 07:10:22 -0800394
395 add_sta_params = session_entry->ftPEContext.pAddStaReq;
396 add_sta_params->assocId = assoc_id;
397 add_sta_params->smesessionId = session_entry->smeSessionId;
398
399 msg_q.type = WMA_ADD_STA_REQ;
400 msg_q.reserved = 0;
401 msg_q.bodyptr = add_sta_params;
402 msg_q.bodyval = 0;
403
404 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_DEBUG,
405 "Sending WMA_ADD_STA_REQ (aid %d)",
406 add_sta_params->assocId);
407 MTRACE(mac_trace_msg_tx(mac_ctx, session_entry->peSessionId,
408 msg_q.type));
409
410 session_entry->limPrevMlmState = session_entry->limMlmState;
411 MTRACE(mac_trace(mac_ctx, TRACE_CODE_MLM_STATE,
412 session_entry->peSessionId, eLIM_MLM_WT_ADD_STA_RSP_STATE));
413 session_entry->limMlmState = eLIM_MLM_WT_ADD_STA_RSP_STATE;
414 ret_code = wma_post_ctrl_msg(mac_ctx, &msg_q);
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700415 if (QDF_STATUS_SUCCESS != ret_code) {
Srinivas Girigowdacc95af02017-03-26 11:31:49 -0700416 pe_err("Posting WMA_ADD_STA_REQ to HAL failed, reason=%X",
Varun Reddy Yeturu99ff7f02016-02-11 07:10:22 -0800417 ret_code);
418 qdf_mem_free(add_sta_params);
419 }
420
421 session_entry->ftPEContext.pAddStaReq = NULL;
422 return ret_code;
423}
424
425/**
426 * lim_restore_pre_reassoc_state() - Restore the pre-association context
Jeff Johnson348973e2018-11-22 16:51:12 -0800427 * @mac: Global MAC Context
Varun Reddy Yeturu99ff7f02016-02-11 07:10:22 -0800428 * @resultCode: Assoc response result
429 * @protStatusCode: Internal protocol status code
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800430 * @pe_session: PE Session
Varun Reddy Yeturu99ff7f02016-02-11 07:10:22 -0800431 *
432 * This function is called on STA role whenever Reasociation
433 * Response with a reject code is received from AP.
434 * Reassociation failure timer is stopped, Old (or current) AP's
435 * context is restored both at Polaris & software
436 *
437 * Return: None
438 */
439
440void
Jeff Johnson9320c1e2018-12-02 13:09:20 -0800441lim_restore_pre_reassoc_state(struct mac_context *mac,
Varun Reddy Yeturu99ff7f02016-02-11 07:10:22 -0800442 tSirResultCodes resultCode, uint16_t protStatusCode,
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800443 struct pe_session *pe_session)
Varun Reddy Yeturu99ff7f02016-02-11 07:10:22 -0800444{
445 tLimMlmReassocCnf mlmReassocCnf;
446
Srinivas Girigowdacc95af02017-03-26 11:31:49 -0700447 pe_debug("sessionid: %d protStatusCode: %d resultCode: %d",
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800448 pe_session->smeSessionId, protStatusCode, resultCode);
Varun Reddy Yeturu99ff7f02016-02-11 07:10:22 -0800449
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800450 pe_session->limMlmState = eLIM_MLM_LINK_ESTABLISHED_STATE;
Varun Reddy Yeturu99ff7f02016-02-11 07:10:22 -0800451 MTRACE(mac_trace
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800452 (mac, TRACE_CODE_MLM_STATE, pe_session->peSessionId,
Varun Reddy Yeturu99ff7f02016-02-11 07:10:22 -0800453 eLIM_MLM_LINK_ESTABLISHED_STATE));
454
455 /* 'Change' timer for future activations */
Jeff Johnson348973e2018-11-22 16:51:12 -0800456 lim_deactivate_and_change_timer(mac, eLIM_REASSOC_FAIL_TIMER);
Varun Reddy Yeturu99ff7f02016-02-11 07:10:22 -0800457
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800458 lim_set_channel(mac, pe_session->currentOperChannel,
459 pe_session->ch_center_freq_seg0,
460 pe_session->ch_center_freq_seg1,
461 pe_session->ch_width,
462 pe_session->maxTxPower,
463 pe_session->peSessionId,
Arif Hussain671a1902017-03-17 09:08:32 -0700464 0, 0);
Varun Reddy Yeturu99ff7f02016-02-11 07:10:22 -0800465
466 /* @ToDo:Need to Integrate the STOP the Dataxfer to AP from 11H code */
467
468 mlmReassocCnf.resultCode = resultCode;
469 mlmReassocCnf.protStatusCode = protStatusCode;
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800470 mlmReassocCnf.sessionId = pe_session->peSessionId;
Jeff Johnson348973e2018-11-22 16:51:12 -0800471 lim_post_sme_message(mac,
Varun Reddy Yeturu99ff7f02016-02-11 07:10:22 -0800472 LIM_MLM_REASSOC_CNF, (uint32_t *) &mlmReassocCnf);
473}
474
475/**
476 * lim_post_reassoc_failure() - Post failure message to SME
Jeff Johnson348973e2018-11-22 16:51:12 -0800477 * @mac: Global MAC Context
Varun Reddy Yeturu99ff7f02016-02-11 07:10:22 -0800478 * @resultCode: Result Code
479 * @protStatusCode: Protocol Status Code
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800480 * @pe_session: PE Session
Varun Reddy Yeturu99ff7f02016-02-11 07:10:22 -0800481 *
482 * Return: None
483 */
Jeff Johnson9320c1e2018-12-02 13:09:20 -0800484void lim_post_reassoc_failure(struct mac_context *mac,
Varun Reddy Yeturu99ff7f02016-02-11 07:10:22 -0800485 tSirResultCodes resultCode, uint16_t protStatusCode,
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800486 struct pe_session *pe_session)
Varun Reddy Yeturu99ff7f02016-02-11 07:10:22 -0800487{
488 tLimMlmReassocCnf mlmReassocCnf;
489
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800490 pe_session->limMlmState = eLIM_MLM_LINK_ESTABLISHED_STATE;
Varun Reddy Yeturu99ff7f02016-02-11 07:10:22 -0800491 MTRACE(mac_trace
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800492 (mac, TRACE_CODE_MLM_STATE, pe_session->peSessionId,
Varun Reddy Yeturu99ff7f02016-02-11 07:10:22 -0800493 eLIM_MLM_LINK_ESTABLISHED_STATE));
494
Jeff Johnson348973e2018-11-22 16:51:12 -0800495 lim_deactivate_and_change_timer(mac, eLIM_REASSOC_FAIL_TIMER);
Varun Reddy Yeturu99ff7f02016-02-11 07:10:22 -0800496
497 mlmReassocCnf.resultCode = resultCode;
498 mlmReassocCnf.protStatusCode = protStatusCode;
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800499 mlmReassocCnf.sessionId = pe_session->peSessionId;
Jeff Johnson348973e2018-11-22 16:51:12 -0800500 lim_post_sme_message(mac,
Varun Reddy Yeturu99ff7f02016-02-11 07:10:22 -0800501 LIM_MLM_REASSOC_CNF, (uint32_t *) &mlmReassocCnf);
502}
503