blob: 3a96871790b1347ba4b9cda66fb64342d8ff3389 [file] [log] [blame]
Padma, Santhosh Kumar67f479b2016-12-28 15:43:42 +05301/*
gaurank kathpalia392e4452018-02-26 15:40:30 +05302 * Copyright (c) 2017-2018, The Linux Foundation. All rights reserved.
Padma, Santhosh Kumar67f479b2016-12-28 15:43:42 +05303 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above
10 * copyright notice, this list of conditions and the following
11 * disclaimer in the documentation and/or other materials provided
12 * with the distribution.
13 * * Neither the name of The Linux Foundation nor the names of its
14 * contributors may be used to endorse or promote products derived
15 * from this software without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
18 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
19 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
20 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
21 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
24 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
25 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
26 * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
27 * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 */
29
30#include "aniGlobal.h"
31#include "limTypes.h"
32#include "limUtils.h"
33#include "limFT.h"
34#include "limSendMessages.h"
Padma, Santhosh Kumarf4966dc2017-01-03 18:56:00 +053035#include "limAssocUtils.h"
36#include "limSerDesUtils.h"
37#include "limSmeReqUtils.h"
Padma, Santhosh Kumar9f729552017-01-09 14:06:30 +053038#include "limAdmitControl.h"
39#include "sirApi.h"
Padma, Santhosh Kumar7cdb5242017-01-11 19:19:08 +053040#include "rrmApi.h"
41#include "wlan_qct_tl.h"
Padma, Santhosh Kumarf4966dc2017-01-03 18:56:00 +053042
43#define PREAUTH_REASSOC_TIMEOUT 500
44
Padma, Santhosh Kumar7cdb5242017-01-11 19:19:08 +053045void lim_cleanup_connected_ap(tpAniSirGlobal mac, tpDphHashNode sta_ds,
46 tpPESession session_entry);
47
Padma, Santhosh Kumar67f479b2016-12-28 15:43:42 +053048/**
49 * lim_post_pre_auth_reassoc_rsp() -Posts preauth_reassoc response to SME
50 * @mac: MAC context
51 * @status: status
52 * @session_entry: session entry
Padma, Santhosh Kumar9f729552017-01-09 14:06:30 +053053 * @reason: indicates which type of clean up needs to be performed
Padma, Santhosh Kumar67f479b2016-12-28 15:43:42 +053054 *
Padma, Santhosh Kumar7cdb5242017-01-11 19:19:08 +053055 * This function process preauth_reassoc response to SME
Padma, Santhosh Kumar67f479b2016-12-28 15:43:42 +053056 */
57void lim_post_pre_auth_reassoc_rsp(tpAniSirGlobal mac,
Padma, Santhosh Kumar9f729552017-01-09 14:06:30 +053058 tSirRetStatus status, tpPESession session_entry,
59 enum sir_roam_cleanup_type reason)
Padma, Santhosh Kumar67f479b2016-12-28 15:43:42 +053060{
61 tpSirFTPreAuthRsp pre_auth_rsp;
62 tSirMsgQ mmh_msg;
63 tANI_U16 rsp_len = sizeof(tSirFTPreAuthRsp);
Padma, Santhosh Kumar9f729552017-01-09 14:06:30 +053064 tpPESession session_entry_con_ap;
Padma, Santhosh Kumar7cdb5242017-01-11 19:19:08 +053065 tpDphHashNode sta_ds = NULL;
Abhinav Kumarb4626d02018-02-26 18:16:30 +053066 if (session_entry == NULL) {
67 limLog(mac, LOGE, FL("Invalid Session Entry"));
68 return;
69 }
Padma, Santhosh Kumar67f479b2016-12-28 15:43:42 +053070
71 pre_auth_rsp = (tpSirFTPreAuthRsp)vos_mem_malloc(rsp_len);
72 if (NULL == pre_auth_rsp) {
73 limLog(mac, LOGE, FL("Failed to allocate memory"));
74 return;
75 }
76
Padma, Santhosh Kumar7cdb5242017-01-11 19:19:08 +053077 limLog(mac, LOG1, FL("reason %d"), reason);
78
Padma, Santhosh Kumar67f479b2016-12-28 15:43:42 +053079 vos_mem_zero(pre_auth_rsp, rsp_len);
80 pre_auth_rsp->messageType = eWNI_SME_MBB_PRE_AUTH_REASSOC_RSP;
81 pre_auth_rsp->length = (tANI_U16)rsp_len;
82 pre_auth_rsp->status = status;
Padma, Santhosh Kumar9f729552017-01-09 14:06:30 +053083 pre_auth_rsp->reason = reason;
Abhinav Kumarb4626d02018-02-26 18:16:30 +053084 pre_auth_rsp->smeSessionId = session_entry->smeSessionId;
Padma, Santhosh Kumar67f479b2016-12-28 15:43:42 +053085
86 /* The bssid of the AP we are sending Auth1 to. */
87 if (mac->ft.ftPEContext.pFTPreAuthReq)
88 sirCopyMacAddr(pre_auth_rsp->preAuthbssId,
89 mac->ft.ftPEContext.pFTPreAuthReq->preAuthbssId);
90
91 if (status != eSIR_SUCCESS) {
Padma, Santhosh Kumar7cdb5242017-01-11 19:19:08 +053092 limLog(mac, LOG1, FL("Pre-Auth Failed, Cleanup!"));
Padma, Santhosh Kumar0b04ed12017-01-23 15:39:03 +053093 limLog(mac, LOG1, FL("flushing cached packets"));
94 WLANTL_PreAssocForward(false);
Padma, Santhosh Kumar9f729552017-01-09 14:06:30 +053095
96 /*
97 * If reason is full clean up, add sme session id that
98 * will be useful in CSR during cleanup.
99 */
100 if (reason == SIR_MBB_DISCONNECTED) {
101 session_entry_con_ap =
102 (tpPESession)mac->ft.ftPEContext.psavedsessionEntry;
103 pre_auth_rsp->smeSessionId =
104 session_entry_con_ap->smeSessionId;
105 }
Padma, Santhosh Kumar67f479b2016-12-28 15:43:42 +0530106 limFTCleanup(mac);
107 }
108
Padma, Santhosh Kumar7cdb5242017-01-11 19:19:08 +0530109 if (status == eSIR_SUCCESS) {
110 limLog(mac, LOG1, FL("Success"));
111
112 rsp_len = session_entry->assocReqLen + session_entry->assocRspLen +
113 session_entry->bcnLen;
114
115 pre_auth_rsp->roam_info = vos_mem_malloc(sizeof(tCsrRoamInfo));
116 if (pre_auth_rsp->roam_info == NULL) {
117 limLog(mac, LOGE,
118 FL("Failed to allocate memory for roam info"));
119 return;
120 }
121 vos_mem_set(pre_auth_rsp->roam_info, sizeof(tCsrRoamInfo), 0);
122
123 pre_auth_rsp->roam_info->pbFrames = vos_mem_malloc(rsp_len);
124 if (pre_auth_rsp->roam_info->pbFrames == NULL) {
125 limLog(mac, LOGE,
126 FL("Failed to allocate memory for roam info frames"));
127 return;
128 }
129 vos_mem_set(pre_auth_rsp->roam_info->pbFrames, rsp_len, 0);
130
131
132 pre_auth_rsp->length += rsp_len + sizeof(tCsrRoamInfo);
133
134 session_entry_con_ap =
135 (tpPESession)mac->ft.ftPEContext.psavedsessionEntry;
136 pre_auth_rsp->smeSessionId = session_entry_con_ap->smeSessionId;
137
138 if(session_entry->beacon != NULL) {
139 pre_auth_rsp->roam_info->nBeaconLength = session_entry->bcnLen;
140 vos_mem_copy(pre_auth_rsp->roam_info->pbFrames,
141 session_entry->beacon,
142 session_entry->bcnLen);
143 limLog(mac, LOG1, FL("Beacon len %d"), session_entry->bcnLen);
144
145 vos_mem_free(session_entry->beacon);
146 session_entry->beacon = NULL;
147 }
148
149 if(session_entry->assocReq != NULL) {
150 pre_auth_rsp->roam_info->nAssocReqLength =
151 session_entry->assocReqLen;
152 vos_mem_copy(pre_auth_rsp->roam_info->pbFrames +
153 session_entry->bcnLen,
154 session_entry->assocReq,
155 session_entry->assocReqLen);
156
157 vos_mem_free(session_entry->assocReq);
158 session_entry->assocReq = NULL;
159
160 limLog(mac, LOG1, FL("AssocReq len %d"), session_entry->assocReqLen);
161 }
162
163 if(session_entry->assocRsp != NULL) {
164 pre_auth_rsp->roam_info->nAssocRspLength =
165 session_entry->assocRspLen;
166 vos_mem_copy(pre_auth_rsp->roam_info->pbFrames +
167 session_entry->bcnLen + session_entry->assocReqLen,
168 session_entry->assocRsp,
169 session_entry->assocRspLen);
170
171 vos_mem_free(session_entry->assocRsp);
172 session_entry->assocRsp = NULL;
173
174 limLog(mac, LOG1, FL("AssocRsp len %d"), session_entry->assocRspLen);
175 }
176
177 sta_ds = dphGetHashEntry(mac, DPH_STA_HASH_INDEX_PEER,
178 &session_entry->dph.dphHashTable);
179 if(NULL == sta_ds) {
180 limLog(mac, LOGE,
181 FL("Unable to get the DPH Hash Entry for AID - %d"),
182 DPH_STA_HASH_INDEX_PEER);
183 return;
184 }
185
186 pre_auth_rsp->roam_info->staId = sta_ds->staIndex;
187 pre_auth_rsp->roam_info->ucastSig = sta_ds->ucUcastSig;
188 pre_auth_rsp->roam_info->bcastSig = sta_ds->ucBcastSig;
189 pre_auth_rsp->roam_info->maxRateFlags =
190 limGetMaxRateFlags(sta_ds, session_entry);
191 }
192
Padma, Santhosh Kumar67f479b2016-12-28 15:43:42 +0530193 mmh_msg.type = pre_auth_rsp->messageType;
194 mmh_msg.bodyptr = pre_auth_rsp;
195 mmh_msg.bodyval = 0;
196
197 limLog(mac, LOG1,
198 FL("Posted Auth Rsp to SME with status of 0x%x"), status);
199
200 limSysProcessMmhMsgApi(mac, &mmh_msg, ePROT);
201}
202
203/*
Padma, Santhosh Kumarf4966dc2017-01-03 18:56:00 +0530204 * lim_reassoc_fail_cleanup() -handles cleanup during reassoc failure
205 * @mac: MAC context
206 * @status: status
207 * @data: pointer to data
208 *
209 * This function handles cleanup during reassoc failure
210 */
211void lim_reassoc_fail_cleanup(tpAniSirGlobal mac,
212 eHalStatus status, tANI_U32 *data)
213{
214 tpPESession session_entry;
215
216 session_entry = (tpPESession)data;
217
218 if (!mac->ft.ftPEContext.pFTPreAuthReq) {
219 limLog(mac, LOGE, FL("pFTPreAuthReq is NULL"));
220 return;
221 }
222
223 if (dphDeleteHashEntry(mac,
224 mac->ft.ftPEContext.pFTPreAuthReq->preAuthbssId,
225 DPH_STA_HASH_INDEX_PEER,
226 &session_entry->dph.dphHashTable) != eSIR_SUCCESS) {
227 limLog(mac, LOGE, FL("error deleting hash entry"));
228 }
229
230 /* Delete session as session was created during preauth success */
231 peDeleteSession(mac, session_entry);
232
233 /* Add bss parameter cleanup happens as part of this processing*/
Padma, Santhosh Kumar9f729552017-01-09 14:06:30 +0530234 if ((status == eHAL_STATUS_MBB_DEL_BSS_FAIL) ||
Padma, Santhosh Kumar7cdb5242017-01-11 19:19:08 +0530235 (status == eHAL_STATUS_INVALID_PARAMETER) ||
236 (status == eHAL_STATUS_MBB_ADD_BSS_FAIL))
Padma, Santhosh Kumar9f729552017-01-09 14:06:30 +0530237 lim_post_pre_auth_reassoc_rsp(mac, eSIR_FAILURE, NULL,
238 SIR_MBB_DISCONNECTED);
239 else
240 lim_post_pre_auth_reassoc_rsp(mac, eSIR_FAILURE, NULL,
241 SIR_MBB_CONNECTED);
Padma, Santhosh Kumarf4966dc2017-01-03 18:56:00 +0530242}
243
244/*
245 * lim_perform_post_reassoc_mbb_channel_change() -invokes resume callback
246 * @mac: MAC context
247 * @status: status
248 * @data: pointer to data
249 * @session_entry: session entry
250 *
251 * This function invokes resume callback
252 */
253void lim_perform_post_reassoc_mbb_channel_change(tpAniSirGlobal mac,
254 eHalStatus status, tANI_U32 *data, tpPESession session_entry)
255{
Padma, Santhosh Kumar7cdb5242017-01-11 19:19:08 +0530256 tpPESession session_entry_con_ap;
257 tANI_U8 session_id;
258
259 session_entry_con_ap = peFindSessionByBssid(mac,
260 mac->ft.ftPEContext.pFTPreAuthReq->currbssId,
261 &session_id);
262 if (session_entry_con_ap == NULL) {
263 limLog(mac, LOGE,
264 FL("session does not exist for given BSSID" MAC_ADDRESS_STR),
265 MAC_ADDR_ARRAY(mac->ft.ftPEContext.pFTPreAuthReq->currbssId));
266
267 lim_post_pre_auth_reassoc_rsp(mac, eSIR_FAILURE, NULL,
268 SIR_MBB_CONNECTED);
269 return;
270 }
271
272 peSetResumeChannel(mac, session_entry_con_ap->currentOperChannel, 0);
Padma, Santhosh Kumarf4966dc2017-01-03 18:56:00 +0530273 limResumeLink(mac, lim_reassoc_fail_cleanup,
274 (tANI_U32 *)session_entry);
275}
276
277/*
278 * lim_handle_reassoc_mbb_fail() -handles reassoc failure
279 * @mac: MAC context
280 * @session_entry: session entry
281 *
282 * This function handles reassoc failure
283 */
284void lim_handle_reassoc_mbb_fail(tpAniSirGlobal mac,
285 tpPESession session_entry)
286{
Padma, Santhosh Kumar7cdb5242017-01-11 19:19:08 +0530287 tpPESession session_entry_con_ap;
288 tANI_U8 session_id;
289
290 session_entry_con_ap = peFindSessionByBssid(mac,
291 mac->ft.ftPEContext.pFTPreAuthReq->currbssId,
292 &session_id);
293 if (session_entry_con_ap == NULL) {
294 limLog(mac, LOGE,
295 FL("session does not exist for given BSSID" MAC_ADDRESS_STR),
296 MAC_ADDR_ARRAY(mac->ft.ftPEContext.pFTPreAuthReq->currbssId));
297
298 lim_post_pre_auth_reassoc_rsp(mac, eSIR_FAILURE, NULL,
299 SIR_MBB_CONNECTED);
300 return;
301 }
302
303 limLog(mac, LOG1, FL("currentOperChannel %d preAuthchannelNum %d"),
304 session_entry_con_ap->currentOperChannel,
305 mac->ft.ftPEContext.pFTPreAuthReq->preAuthchannelNum);
306
307 /* Restore set link to post assoc for currently connected AP */
308 if (limSetLinkState(mac, eSIR_LINK_POSTASSOC_STATE,
309 session_entry_con_ap->bssId,
310 session_entry_con_ap->selfMacAddr,
311 NULL, NULL) != eSIR_SUCCESS) {
312 limLog(mac, LOGE, FL("Set link state to POSTASSOC failed"));
313
314 lim_post_pre_auth_reassoc_rsp(mac, eSIR_FAILURE, NULL,
315 SIR_MBB_CONNECTED);
316 return;
317 }
318
Padma, Santhosh Kumarf4966dc2017-01-03 18:56:00 +0530319 /* Change channel if required as channel might be changed during preauth */
Padma, Santhosh Kumar7cdb5242017-01-11 19:19:08 +0530320 if (session_entry_con_ap->currentOperChannel !=
Padma, Santhosh Kumarf4966dc2017-01-03 18:56:00 +0530321 mac->ft.ftPEContext.pFTPreAuthReq->preAuthchannelNum) {
Padma, Santhosh Kumar7cdb5242017-01-11 19:19:08 +0530322 limChangeChannelWithCallback(mac,
323 session_entry_con_ap->currentOperChannel,
Padma, Santhosh Kumarf4966dc2017-01-03 18:56:00 +0530324 lim_perform_post_reassoc_mbb_channel_change, NULL, session_entry);
325 } else {
326 /*
327 * Link needs to be resumed as link was suspended
328 * for same channel during preauth.
329 */
Padma, Santhosh Kumar7cdb5242017-01-11 19:19:08 +0530330 peSetResumeChannel(mac, session_entry_con_ap->currentOperChannel, 0);
Padma, Santhosh Kumarf4966dc2017-01-03 18:56:00 +0530331 limResumeLink(mac, lim_reassoc_fail_cleanup,
332 (tANI_U32 *)session_entry);
333 }
334}
335
336/*
Padma, Santhosh Kumar7cdb5242017-01-11 19:19:08 +0530337 * lim_preauth_fail_cleanup() -handles cleanup during preauth failure
338 * @mac: MAC context
339 * @status: status
340 * @data: pointer to data
341 *
342 * This function handles cleanup during reassoc failure
343 */
344void lim_preauth_fail_cleanup(tpAniSirGlobal mac,
345 eHalStatus status, tANI_U32 *data)
346{
347 tpPESession session_entry;
348
349 session_entry = (tpPESession)data;
350
351 lim_post_pre_auth_reassoc_rsp(mac, eSIR_FAILURE, NULL,
352 SIR_MBB_CONNECTED);
353}
354
355/*
356 * lim_perform_preauth_mbb_fail_channel_change() -invokes resume callback
357 * @mac: MAC context
358 * @status: status
359 * @data: pointer to data
360 * @session_entry: session entry
361 *
362 * This function invokes resume callback
363 */
364void lim_perform_preauth_mbb_fail_channel_change(tpAniSirGlobal mac,
365 eHalStatus status, tANI_U32 *data, tpPESession session_entry)
366{
367 peSetResumeChannel(mac, session_entry->currentOperChannel, 0);
368 limResumeLink(mac, lim_preauth_fail_cleanup,
369 (tANI_U32 *)session_entry);
370}
371
372/*
373 * lim_handle_preauth_mbb_fail() -handles preauth failure
374 * @mac: MAC context
375 * @session_entry: session entry
376 *
377 * This function handles reassoc failure
378 */
379void lim_handle_preauth_mbb_fail(tpAniSirGlobal mac,
380 tpPESession session_entry)
381{
382 limLog(mac, LOG1, FL("currentOperChannel %d preAuthchannelNum %d"),
383 session_entry->currentOperChannel,
384 mac->ft.ftPEContext.pFTPreAuthReq->preAuthchannelNum);
385
386 /* Restore set link to post assoc for currently connected AP */
387 if (limSetLinkState(mac, eSIR_LINK_POSTASSOC_STATE,
388 session_entry->bssId,
389 session_entry->selfMacAddr,
390 NULL, NULL) != eSIR_SUCCESS) {
391 limLog(mac, LOGE, FL("Set link state to POSTASSOC failed"));
392
393 lim_post_pre_auth_reassoc_rsp(mac, eSIR_FAILURE, NULL,
394 SIR_MBB_CONNECTED);
395 return;
396 }
397
398 /* Change channel if required as channel might be changed during preauth */
399 if (session_entry->currentOperChannel !=
400 mac->ft.ftPEContext.pFTPreAuthReq->preAuthchannelNum) {
401 limChangeChannelWithCallback(mac,
402 session_entry->currentOperChannel,
403 lim_perform_preauth_mbb_fail_channel_change, NULL, session_entry);
404 } else {
405 /*
406 * Link needs to be resumed as link was suspended
407 * for same channel during preauth.
408 */
409 peSetResumeChannel(mac, session_entry->currentOperChannel, 0);
410 limResumeLink(mac, lim_preauth_fail_cleanup,
411 (tANI_U32 *)session_entry);
412 }
413}
414
415
416/*
Padma, Santhosh Kumar9f729552017-01-09 14:06:30 +0530417 * lim_del_sta_mbb() -performs del sta
418 * @mac: MAC context
419 * @sta_ds_connected_ap: station entry of connected AP
420 * @resp_reqd: indicates whether response is required or not
421 * @session_entry_connected_ap: session entry of connected AP
422 *
423 * This function performs del sta
424 */
425tSirRetStatus lim_del_sta_mbb(tpAniSirGlobal mac,
426 tpDphHashNode sta_ds_connected_ap,
427 tANI_BOOLEAN resp_reqd,
428 tpPESession session_entry_connected_ap)
429{
430 tpDeleteStaParams del_sta_params;
431 tSirMsgQ msg;
432 tSirRetStatus ret_code;
433
434 del_sta_params = vos_mem_malloc(sizeof(*del_sta_params));
435 if (NULL == del_sta_params) {
436 limLog(mac, LOGE, FL("Unable to allocate memory during DEL_STA" ));
437 return eSIR_MEM_ALLOC_FAILED;
438 }
439 vos_mem_zero(del_sta_params, sizeof(*del_sta_params));
440
441 del_sta_params->sessionId = session_entry_connected_ap->peSessionId;
442 del_sta_params->status = eHAL_STATUS_SUCCESS;
443
444#ifdef FEATURE_WLAN_TDLS
445 if(((eLIM_STA_ROLE == GET_LIM_SYSTEM_ROLE(session_entry_connected_ap)) &&
446 (sta_ds_connected_ap->staType != STA_ENTRY_TDLS_PEER)) ||
447 (eLIM_BT_AMP_STA_ROLE ==
448 GET_LIM_SYSTEM_ROLE(session_entry_connected_ap)))
449#else
450 if((eLIM_STA_ROLE == GET_LIM_SYSTEM_ROLE(session_entry_connected_ap)) ||
451 (eLIM_BT_AMP_STA_ROLE ==
452 GET_LIM_SYSTEM_ROLE(session_entry_connected_ap)))
453#endif
454 del_sta_params->staIdx = session_entry_connected_ap->staId;
455 else
456 del_sta_params->staIdx = sta_ds_connected_ap->staIndex;
457
458 del_sta_params->assocId = sta_ds_connected_ap->assocId;
459 del_sta_params->respReqd = resp_reqd;
460
461 /* Change Mlm state of connected AP to Del sta rsp state */
462 session_entry_connected_ap->limMlmState = eLIM_MLM_WT_DEL_STA_RSP_STATE;
Padma, Santhosh Kumarce74fd82017-02-10 19:57:08 +0530463 MTRACE(macTrace(mac, TRACE_CODE_MLM_STATE,
464 session_entry_connected_ap->peSessionId, eLIM_MLM_WT_DEL_STA_RSP_STATE));
Padma, Santhosh Kumar9f729552017-01-09 14:06:30 +0530465
466 msg.type = WDA_DELETE_STA_REQ;
467 msg.reserved = 0;
468 msg.bodyptr = del_sta_params;
469 msg.bodyval = 0;
470
471 limLog(mac, LOG1,
472 FL("sessionId %d staIdx: %d assocId: %d for "MAC_ADDRESS_STR),
473 del_sta_params->sessionId, del_sta_params->staIdx,
474 del_sta_params->assocId,
475 MAC_ADDR_ARRAY(sta_ds_connected_ap->staAddr));
476
Padma, Santhosh Kumarce74fd82017-02-10 19:57:08 +0530477 MTRACE(macTraceMsgTx(mac, session_entry_connected_ap->peSessionId,
478 msg.type));
479
Padma, Santhosh Kumar9f729552017-01-09 14:06:30 +0530480 ret_code = wdaPostCtrlMsg(mac, &msg);
481 if( eSIR_SUCCESS != ret_code) {
482 if(resp_reqd)
483 SET_LIM_PROCESS_DEFD_MESGS(mac, true);
484 limLog(mac, LOGE,
485 FL("Posting DELETE_STA_REQ failed, reason=%X"), ret_code);
486 vos_mem_free(del_sta_params);
487 }
488
489 return ret_code;
490}
491
492/*
493 * lim_del_bss_mbb() -performs del bss of connected AP
494 * @mac: MAC context
495 * @sta_ds: station entry
496 * @bss_idx:BSS index
497 * @session_entry: session entry
498 *
499 * This function performs del bss of connected AP
500 */
501tSirRetStatus lim_del_bss_mbb(tpAniSirGlobal mac, tpDphHashNode sta_ds,
502 tANI_U16 bss_idx,tpPESession session_entry)
503{
504 tpDeleteBssParams delbss_params = NULL;
505 tSirMsgQ msg;
506 tSirRetStatus ret_code = eSIR_SUCCESS;
507
508 delbss_params = vos_mem_malloc(sizeof(tDeleteBssParams));
509 if (NULL == delbss_params) {
510 limLog(mac, LOGE,
511 FL("Unable to allocate memory during del bss" ));
512 return eSIR_MEM_ALLOC_FAILED;
513 }
514 vos_mem_set((tANI_U8 *) delbss_params, sizeof(tDeleteBssParams), 0);
515
516 delbss_params->sessionId = session_entry->peSessionId;
517
518 if (sta_ds != NULL) {
519 delbss_params->bssIdx = sta_ds->bssId;
520 sta_ds->valid = 0;
521 sta_ds->mlmStaContext.mlmState = eLIM_MLM_WT_DEL_BSS_RSP_STATE;
522 }
523 else
524 delbss_params->bssIdx = bss_idx;
525
526 session_entry->limMlmState = eLIM_MLM_WT_DEL_BSS_RSP_STATE;
Padma, Santhosh Kumarce74fd82017-02-10 19:57:08 +0530527 MTRACE(macTrace(mac, TRACE_CODE_MLM_STATE,
528 session_entry->peSessionId, eLIM_MLM_WT_DEL_BSS_RSP_STATE));
Padma, Santhosh Kumar9f729552017-01-09 14:06:30 +0530529
530 delbss_params->status= eHAL_STATUS_SUCCESS;
531 delbss_params->respReqd = 1;
532
533 limLog(mac, LOG1, FL("Sessionid %d bss idx: %x BSSID:" MAC_ADDRESS_STR),
534 delbss_params->sessionId, delbss_params->bssIdx,
535 MAC_ADDR_ARRAY(session_entry->bssId));
536
537 /* we need to defer the message until we get the response back from HAL. */
538 SET_LIM_PROCESS_DEFD_MESGS(mac, false);
539
540 msg.type = WDA_DELETE_BSS_REQ;
541 msg.reserved = 0;
542 msg.bodyptr = delbss_params;
543 msg.bodyval = 0;
544
Padma, Santhosh Kumarce74fd82017-02-10 19:57:08 +0530545 MTRACE(macTraceMsgTx(mac, session_entry->peSessionId, msg.type));
546
Padma, Santhosh Kumar9f729552017-01-09 14:06:30 +0530547 if(eSIR_SUCCESS != (ret_code = wdaPostCtrlMsg(mac, &msg)))
548 {
549 SET_LIM_PROCESS_DEFD_MESGS(mac, true);
550 limLog(mac, LOGE,
551 FL("Posting DELETE_BSS_REQ to HAL failed, reason=%X"), ret_code);
552 vos_mem_free(delbss_params);
553 }
554
555 return ret_code;
556}
557
558/*
Padma, Santhosh Kumar7cdb5242017-01-11 19:19:08 +0530559 * lim_add_bss_mbb() -performs add bss of new roamable AP
560 * @mac: MAC context
561 * @sta_ds: station entry
562 * @bss_idx:BSS index
563 * @session_entry: session entry
564 *
565 * This function performs add bss of new roamable AP
566 */
567void lim_add_bss_mbb(tpAniSirGlobal mac, tpDphHashNode sta_ds,
568 tpPESession session_entry)
569{
570 tSirMsgQ msg;
571 tSirRetStatus ret_code;
572
573 /* we need to defer the message until we get the response back from HAL. */
574 SET_LIM_PROCESS_DEFD_MESGS(mac, false);
575
576 msg.type = SIR_HAL_ADD_BSS_REQ;
577 msg.reserved = 0;
578 msg.bodyptr = mac->ft.ftPEContext.pAddBssReq;
579 msg.bodyval = 0;
580
581 limLog(mac, LOG1, FL("Sending SIR_HAL_ADD_BSS_REQ"));
582
583 session_entry->limMlmState = eLIM_MLM_WT_ADD_BSS_RSP_REASSOC_STATE;
584
Padma, Santhosh Kumarce74fd82017-02-10 19:57:08 +0530585 MTRACE(macTrace(mac, TRACE_CODE_MLM_STATE,
586 session_entry->peSessionId, eLIM_MLM_WT_ADD_BSS_RSP_REASSOC_STATE));
587
588 MTRACE(macTraceMsgTx(mac, session_entry->peSessionId, msg.type));
589
Padma, Santhosh Kumar7cdb5242017-01-11 19:19:08 +0530590 ret_code = wdaPostCtrlMsg(mac, &msg);
591 if( eSIR_SUCCESS != ret_code) {
592 vos_mem_free(mac->ft.ftPEContext.pAddBssReq);
593 limLog(mac, LOGE,
594 FL("Posting ADD_BSS_REQ to HAL failed, reason=%X"), ret_code);
595 }
596 /* Dont need this anymore */
597 mac->ft.ftPEContext.pAddBssReq = NULL;
598}
599
600tSirRetStatus lim_add_sta_mbb(tpAniSirGlobal mac, tANI_U16 assoc_id,
601 tpPESession session_entry)
602{
603 tpAddStaParams add_sta_params = NULL;
604 tSirMsgQ msg;
605 tSirRetStatus retCode = eSIR_SUCCESS;
606
607 add_sta_params = mac->ft.ftPEContext.pAddStaReq;
608 add_sta_params->assocId = assoc_id;
609
610 msg.type = SIR_HAL_ADD_STA_REQ;
611 msg.reserved = 0;
612 msg.bodyptr = add_sta_params;
613 msg.bodyval = 0;
614
615 limLog(mac, LOG1,
616 FL("Sending SIR_HAL_ADD_STA_REQ. aid %d)"),
617 add_sta_params->assocId);
618
619 session_entry->limPrevMlmState = session_entry->limMlmState;
620 session_entry->limMlmState = eLIM_MLM_WT_ADD_STA_RSP_STATE;
621
Padma, Santhosh Kumarce74fd82017-02-10 19:57:08 +0530622 MTRACE(macTrace(mac, TRACE_CODE_MLM_STATE,
623 session_entry->peSessionId, eLIM_MLM_WT_ADD_STA_RSP_STATE));
624
625 MTRACE(macTraceMsgTx(mac, session_entry->peSessionId, msg.type));
626
Padma, Santhosh Kumar7cdb5242017-01-11 19:19:08 +0530627 if(eSIR_SUCCESS != (retCode = wdaPostCtrlMsg( mac, &msg))) {
628 limLog(mac, LOGE,
629 FL("Posting ADD_STA_REQ to HAL failed, reason=%X"), retCode);
630 vos_mem_free(add_sta_params);
631 }
632
633 mac->ft.ftPEContext.pAddStaReq = NULL;
634 return retCode;
635}
636
637/*
Padma, Santhosh Kumarf4966dc2017-01-03 18:56:00 +0530638 * lim_handle_reassoc_mbb_success() -handles reassoc success
639 * @mac: MAC context
640 * @session_entry: session entry
641 * @assoc_rsp: pointer to assoc response
642 * @sta_ds : station entry
643 *
644 * This function handles reassoc success
645 */
646void lim_handle_reassoc_mbb_success(tpAniSirGlobal mac,
647 tpPESession session_entry, tpSirAssocRsp assoc_rsp, tpDphHashNode sta_ds)
648{
Padma, Santhosh Kumar9f729552017-01-09 14:06:30 +0530649 tpPESession session_entry_con_ap;
650 tANI_U8 session_id_connected_ap;
651 tpDphHashNode sta_ds_connected_ap;
652 tANI_U16 aid;
653 tSirRetStatus ret_code;
Padma, Santhosh Kumarf4966dc2017-01-03 18:56:00 +0530654
655 limUpdateAssocStaDatas(mac, sta_ds, assoc_rsp, session_entry);
656
657 /* Store assigned AID for TIM processing */
658 session_entry->limAID = assoc_rsp->aid & 0x3FFF;
659
Padma, Santhosh Kumar9f729552017-01-09 14:06:30 +0530660 /* De register STA for currently connected AP */
661 mac->sme.roaming_mbb_callback(mac, mac->ft.ftSmeContext.smeSessionId,
662 NULL, NULL, SIR_ROAMING_DEREGISTER_STA);
663
664 mac->sme.roaming_mbb_callback(mac, mac->ft.ftSmeContext.smeSessionId,
665 NULL, NULL, SIR_STOP_ROAM_OFFLOAD_SCAN);
666
Padma, Santhosh Kumar9f729552017-01-09 14:06:30 +0530667 if((session_entry_con_ap = peFindSessionByBssid(mac,
668 mac->ft.ftPEContext.pFTPreAuthReq->currbssId,
669 &session_id_connected_ap))== NULL) {
670 limLog(mac, LOGE,
671 FL("session does not exist for given BSSID" MAC_ADDRESS_STR),
672 MAC_ADDR_ARRAY(mac->ft.ftPEContext.pFTPreAuthReq->currbssId));
Abhinav Kumarb4626d02018-02-26 18:16:30 +0530673 goto cleanup;
Padma, Santhosh Kumar9f729552017-01-09 14:06:30 +0530674 }
675
Padma, Santhosh Kumar7cdb5242017-01-11 19:19:08 +0530676 session_entry->smeSessionId = session_entry_con_ap->smeSessionId;
677
Padma, Santhosh Kumar9f729552017-01-09 14:06:30 +0530678 sta_ds_connected_ap = dphLookupHashEntry(mac,
679 mac->ft.ftPEContext.pFTPreAuthReq->currbssId,
680 &aid,
681 &session_entry_con_ap->dph.dphHashTable);
682 if (sta_ds_connected_ap == NULL) {
683 limLog(mac, LOGE,
684 FL("sta_ds NULL for given BSSID" MAC_ADDRESS_STR),
685 MAC_ADDR_ARRAY(mac->ft.ftPEContext.pFTPreAuthReq->currbssId));
Abhinav Kumarb4626d02018-02-26 18:16:30 +0530686 goto cleanup;
Padma, Santhosh Kumar9f729552017-01-09 14:06:30 +0530687 }
688
Padma, Santhosh Kumar1f9d9342017-02-09 20:55:54 +0530689 /*
690 * Change Mlm state of new AP to Del sta rsp state so that
691 * duplicate reassoc response will be dropped.
692 */
693 session_entry->limMlmState = eLIM_MLM_WT_DEL_STA_RSP_STATE;
Padma, Santhosh Kumarce74fd82017-02-10 19:57:08 +0530694 MTRACE(macTrace(mac, TRACE_CODE_MLM_STATE,
695 session_entry->peSessionId, eLIM_MLM_WT_DEL_STA_RSP_STATE));
Padma, Santhosh Kumar1f9d9342017-02-09 20:55:54 +0530696
Padma, Santhosh Kumar9f729552017-01-09 14:06:30 +0530697 /* Delete sta for currently connected AP */
698 ret_code = lim_del_sta_mbb(mac, sta_ds_connected_ap,
699 false, session_entry_con_ap);
700 if (ret_code == eSIR_SUCCESS)
701 return;
702
Padma, Santhosh Kumar7cdb5242017-01-11 19:19:08 +0530703 /* Connected AP lim cleanup.*/
704 lim_cleanup_connected_ap(mac, sta_ds_connected_ap, session_entry_con_ap);
Abhinav Kumarb4626d02018-02-26 18:16:30 +0530705cleanup:
Padma, Santhosh Kumar9f729552017-01-09 14:06:30 +0530706 /*
707 * eHAL_STATUS_INVALID_PARAMETER is used
708 * so that full cleanup is triggered.
709 */
710 lim_reassoc_fail_cleanup(mac, eHAL_STATUS_INVALID_PARAMETER,
711 (tANI_U32 *)session_entry);
Padma, Santhosh Kumarf4966dc2017-01-03 18:56:00 +0530712}
713
714
715/*
Padma, Santhosh Kumar67f479b2016-12-28 15:43:42 +0530716 * lim_process_preauth_mbb_result() -process pre auth result
717 * @mac: MAC context
718 * @status: status
719 * @data: pointer to data
720 *
721 * This function invokes resume callback
722 */
723static inline void lim_process_preauth_mbb_result(tpAniSirGlobal mac,
724 eHalStatus status, tANI_U32 *data)
725{
Abhinav Kumarb4626d02018-02-26 18:16:30 +0530726 tpPESession session_entry, ft_session_entry = NULL;
Padma, Santhosh Kumarf4966dc2017-01-03 18:56:00 +0530727 tpDphHashNode sta_ds;
728 tAddBssParams *add_bss_params;
729 tSirSmeJoinReq *reassoc_req;
730 tLimMlmReassocReq *mlm_reassoc_req;
731 tANI_U16 caps;
732 tANI_U16 nSize;
733 tpSirSmeJoinReq pReassocReq = NULL;
Padma, Santhosh Kumar67f479b2016-12-28 15:43:42 +0530734
735 if (!mac->ft.ftPEContext.pFTPreAuthReq) {
736 limLog(mac, LOG1, "Pre-Auth request is NULL!");
Padma, Santhosh Kumarf4966dc2017-01-03 18:56:00 +0530737 goto end;
Padma, Santhosh Kumar67f479b2016-12-28 15:43:42 +0530738 }
739
740 session_entry = (tpPESession)data;
741
742 /* Post the FT Pre Auth Response to SME in case of failure*/
Padma, Santhosh Kumarf4966dc2017-01-03 18:56:00 +0530743 if (mac->ft.ftPEContext.ftPreAuthStatus == eSIR_FAILURE)
744 goto end;
Padma, Santhosh Kumar67f479b2016-12-28 15:43:42 +0530745
746 /* Flow for preauth success */
747 limFTSetupAuthSession(mac, session_entry);
Padma, Santhosh Kumarf4966dc2017-01-03 18:56:00 +0530748
749 /*
750 * Prepare reassoc request. Memory allocated for tSirSmeJoinReq
751 *reassoc_req in csr_fill_reassoc_req. Free that memory here.
752 */
753 mac->sme.roaming_mbb_callback(mac, mac->ft.ftSmeContext.smeSessionId,
754 mac->ft.ftPEContext.pFTPreAuthReq->pbssDescription,
755 &reassoc_req, SIR_PREPARE_REASSOC_REQ);
756 if (reassoc_req == NULL) {
757 limLog(mac, LOGE,
758 FL("reassoc req is NULL"));
759 goto end;
760 }
761
762 nSize = __limGetSmeJoinReqSizeForAlloc((tANI_U8 *) reassoc_req);
763 pReassocReq = vos_mem_malloc(nSize);
764 if ( NULL == pReassocReq )
765 {
766 limLog(mac, LOGE,
767 FL("call to AllocateMemory failed for pReassocReq"));
gaurank kathpalia392e4452018-02-26 15:40:30 +0530768 vos_mem_free(reassoc_req);
Padma, Santhosh Kumarf4966dc2017-01-03 18:56:00 +0530769 goto end;
770 }
771 vos_mem_set((void *) pReassocReq, nSize, 0);
772 if ((limJoinReqSerDes(mac, (tpSirSmeJoinReq) pReassocReq,
773 (tANI_U8 *) reassoc_req) == eSIR_FAILURE) ||
774 (!limIsSmeJoinReqValid(mac,
775 (tpSirSmeJoinReq) pReassocReq)))
776 {
777 limLog(mac, LOGE,
778 FL("received SME_REASSOC_REQ with invalid data"));
gaurank kathpalia392e4452018-02-26 15:40:30 +0530779 vos_mem_free(reassoc_req);
Padma, Santhosh Kumarf4966dc2017-01-03 18:56:00 +0530780 goto end;
781 }
782
783 ft_session_entry = mac->ft.ftPEContext.pftSessionEntry;
784
785 ft_session_entry->pLimReAssocReq = pReassocReq;
Padma, Santhosh Kumarf4966dc2017-01-03 18:56:00 +0530786
787 add_bss_params = mac->ft.ftPEContext.pAddBssReq;
788
789 mlm_reassoc_req = vos_mem_malloc(sizeof(tLimMlmReassocReq));
790 if (NULL == mlm_reassoc_req) {
791 limLog(mac, LOGE,
792 FL("call to AllocateMemory failed for mlmReassocReq"));
gaurank kathpalia392e4452018-02-26 15:40:30 +0530793 vos_mem_free(reassoc_req);
Padma, Santhosh Kumarf4966dc2017-01-03 18:56:00 +0530794 goto end;
795 }
796
797 vos_mem_copy(mlm_reassoc_req->peerMacAddr,
798 ft_session_entry->limReAssocbssId,
799 sizeof(tSirMacAddr));
800 mlm_reassoc_req->reassocFailureTimeout = PREAUTH_REASSOC_TIMEOUT;
801
802 if (cfgGetCapabilityInfo(mac, &caps, ft_session_entry) != eSIR_SUCCESS) {
803 limLog(mac, LOGE, FL("could not retrieve Capabilities value"));
804 vos_mem_free(mlm_reassoc_req);
gaurank kathpalia392e4452018-02-26 15:40:30 +0530805 vos_mem_free(reassoc_req);
Padma, Santhosh Kumarf4966dc2017-01-03 18:56:00 +0530806 goto end;
807 }
808
809 lim_update_caps_info_for_bss(mac, &caps,
810 reassoc_req->bssDescription.capabilityInfo);
gaurank kathpalia392e4452018-02-26 15:40:30 +0530811 vos_mem_free(reassoc_req);
Padma, Santhosh Kumarf4966dc2017-01-03 18:56:00 +0530812
813 limLog(mac, LOG1, FL("Capabilities info Reassoc: 0x%X"), caps);
814
815 mlm_reassoc_req->capabilityInfo = caps;
816 mlm_reassoc_req->sessionId = ft_session_entry->peSessionId;
817 mlm_reassoc_req->listenInterval = WNI_CFG_LISTEN_INTERVAL_STADEF;
818
819 if ((sta_ds = dphAddHashEntry(mac, add_bss_params->bssId,
820 DPH_STA_HASH_INDEX_PEER,
821 &ft_session_entry->dph.dphHashTable)) == NULL) {
822 limLog(mac, LOGE, FL("could not add hash entry at DPH"));
823 limPrintMacAddr(mac, add_bss_params->bssId, LOGE);
824 vos_mem_free(mlm_reassoc_req);
825 goto end;
826 }
827
828 /* Start timer here to handle reassoc timeout */
829 mac->lim.limTimers.glim_reassoc_mbb_rsp_timer.sessionId =
830 ft_session_entry->peSessionId;
831
Padma, Santhosh Kumarce74fd82017-02-10 19:57:08 +0530832 MTRACE(macTrace(mac, TRACE_CODE_TIMER_ACTIVATE,
833 session_entry->peSessionId, eLIM_REASSOC_MBB_RSP_TIMER));
834
Padma, Santhosh Kumarf4966dc2017-01-03 18:56:00 +0530835 if(TX_SUCCESS !=
836 tx_timer_activate(&mac->lim.limTimers.glim_reassoc_mbb_rsp_timer)) {
837 limLog(mac, LOGE, FL("Reassoc MBB Rsp Timer Start Failed"));
838
839 if (ft_session_entry->pLimReAssocReq) {
840 vos_mem_free(ft_session_entry->pLimReAssocReq);
841 ft_session_entry->pLimReAssocReq = NULL;
842 }
843
844 vos_mem_free(mlm_reassoc_req);
845 goto end;
846 }
847
Padma, Santhosh Kumar9ac54d02017-02-02 18:48:52 +0530848 limLog(mac, LOG1, FL("enabling caching"));
849 WLANTL_EnablePreAssocCaching();
850
Padma, Santhosh Kumarf4966dc2017-01-03 18:56:00 +0530851 /* To do: Add changes for reassoc fail timer */
852 limSendReassocReqWithFTIEsMgmtFrame(mac,
853 mlm_reassoc_req, ft_session_entry);
854
855 ft_session_entry->limMlmState = eLIM_MLM_WT_REASSOC_RSP_STATE;
856
857 limLog(mac, LOG1, FL("Set the mlm state to %d session=%d"),
858 ft_session_entry->limMlmState, ft_session_entry->peSessionId);
859 return;
860
861end:
Abhinav Kumarb4626d02018-02-26 18:16:30 +0530862 if (ft_session_entry)
863 lim_handle_reassoc_mbb_fail(mac, ft_session_entry);
Padma, Santhosh Kumar67f479b2016-12-28 15:43:42 +0530864}
865
866/*
867 * lim_perform_post_preauth_mbb_channel_change() -invokes resume callback
868 * @mac: MAC context
869 * @status: status
870 * @data: pointer to data
871 * @session_entry: session entry
872 *
873 * This function invokes resume callback after successful reception of
874 * pre auth
875 */
876static inline
877void lim_perform_post_preauth_mbb_channel_change(tpAniSirGlobal mac,
878 eHalStatus status, tANI_U32 *data, tpPESession session_entry)
879{
880 peSetResumeChannel(mac, 0, 0);
881 limResumeLink(mac, lim_process_preauth_mbb_result,
882 (tANI_U32 *)session_entry);
883}
884
885/*
886 * lim_handle_pre_auth_mbb_rsp() -handles preauth response
887 * @mac: MAC context
888 * @status: status of message
889 * @session_entry: session entry
890 *
891 * This function process preauth response
892 */
893void lim_handle_pre_auth_mbb_rsp(tpAniSirGlobal mac,
894 tSirRetStatus status, tpPESession session_entry)
895{
896 tpPESession ft_session_entry;
897 tANI_U8 session_id;
898 tpSirBssDescription bss_description;
899
900 mac->ft.ftPEContext.ftPreAuthStatus = status;
901
902 mac->ft.ftPEContext.saved_auth_rsp_length = 0;
903
904 limLog(mac, LOG1, FL("preauth status %d"),
905 mac->ft.ftPEContext.ftPreAuthStatus);
906
907 /* Create FT session for the re-association at this point */
908 if (mac->ft.ftPEContext.ftPreAuthStatus == eSIR_SUCCESS) {
909 bss_description = mac->ft.ftPEContext.pFTPreAuthReq->pbssDescription;
910 if((ft_session_entry = peCreateSession(mac, bss_description->bssId,
911 &session_id, mac->lim.maxStation)) == NULL) {
912 limLog(mac, LOGE,
913 FL("session can not be created for pre-auth AP"));
914 mac->ft.ftPEContext.ftPreAuthStatus = eSIR_FAILURE;
915 goto out;
916 }
917 ft_session_entry->peSessionId = session_id;
918 sirCopyMacAddr(ft_session_entry->selfMacAddr,
919 session_entry->selfMacAddr);
920 sirCopyMacAddr(ft_session_entry->limReAssocbssId,
921 bss_description->bssId);
922 ft_session_entry->bssType = session_entry->bssType;
923
924 if (ft_session_entry->bssType == eSIR_INFRASTRUCTURE_MODE)
925 ft_session_entry->limSystemRole = eLIM_STA_ROLE;
926
927 ft_session_entry->limSmeState = eLIM_SME_WT_REASSOC_STATE;
928 mac->ft.ftPEContext.pftSessionEntry = ft_session_entry;
Jeff Johnson0fe596e2017-09-19 08:36:48 -0700929 limLog(mac, LOG1,"%s:created session (%pK) with id = %d",
Padma, Santhosh Kumar67f479b2016-12-28 15:43:42 +0530930 __func__, ft_session_entry, ft_session_entry->peSessionId);
931
932 /* Update the ReAssoc BSSID of the current session */
933 sirCopyMacAddr(session_entry->limReAssocbssId, bss_description->bssId);
934 limPrintMacAddr(mac, session_entry->limReAssocbssId, LOG1);
Padma, Santhosh Kumarf4966dc2017-01-03 18:56:00 +0530935
936 /* Prepare session for roamable AP */
937 lim_process_preauth_mbb_result(mac,
938 mac->ft.ftPEContext.ftPreAuthStatus, (tANI_U32 *)session_entry);
939 return;
Padma, Santhosh Kumar7cdb5242017-01-11 19:19:08 +0530940 }else {
941 lim_handle_preauth_mbb_fail(mac, session_entry);
942 return;
Padma, Santhosh Kumar67f479b2016-12-28 15:43:42 +0530943 }
Padma, Santhosh Kumar7cdb5242017-01-11 19:19:08 +0530944
Padma, Santhosh Kumar67f479b2016-12-28 15:43:42 +0530945out:
Padma, Santhosh Kumarf4966dc2017-01-03 18:56:00 +0530946 /* This sequence needs to be executed in case of failure*/
Padma, Santhosh Kumar67f479b2016-12-28 15:43:42 +0530947 if (session_entry->currentOperChannel !=
948 mac->ft.ftPEContext.pFTPreAuthReq->preAuthchannelNum) {
949 limChangeChannelWithCallback(mac, session_entry->currentOperChannel,
950 lim_perform_post_preauth_mbb_channel_change, NULL, session_entry);
951 } else {
952 /* Link needs to be resumed as link was suspended for same channel */
953 peSetResumeChannel(mac, 0, 0);
954 limResumeLink(mac, lim_process_preauth_mbb_result,
955 (tANI_U32 *)session_entry);
956 }
957}
958
959/**
960 * lim_process_preauth_mbb_rsp_timeout() -Process preauth response timeout
961 * @mac: MAC context
962 *
963 * This function is called if preauth response is not received from the AP
964 * within timeout
965 */
966void lim_process_preauth_mbb_rsp_timeout(tpAniSirGlobal mac)
967{
968 tpPESession session_entry;
969
970 /*
971 * Pre auth is failed. Need to resume link and get back on
972 * to home channel.
973 */
974 limLog(mac, LOG1, FL("Pre-Auth MBB Time Out!!!!"));
975
976 if((session_entry = peFindSessionBySessionId(mac,
977 mac->lim.limTimers.glim_pre_auth_mbb_rsp_timer.sessionId))== NULL) {
978 limLog(mac, LOGE, FL("session does not exist for given session id"));
979 return;
980 }
981
982 /*
983 * To handle the race condition where we recieve preauth rsp after
984 * timer has expired.
985 */
986 if (mac->ft.ftPEContext.pFTPreAuthReq == NULL) {
987 limLog(mac, LOGE, FL("Auth Rsp might already be posted to SME"
988 "and cleanup done! sessionId:%d"),
989 mac->lim.limTimers.glim_pre_auth_mbb_rsp_timer.sessionId);
990 return;
991 }
992
993 if (eANI_BOOLEAN_TRUE ==
994 mac->ft.ftPEContext.pFTPreAuthReq->bPreAuthRspProcessed) {
995 limLog(mac, LOGE,
Jeff Johnson0fe596e2017-09-19 08:36:48 -0700996 FL("Auth rsp already posted to SME session %pK"), session_entry);
Padma, Santhosh Kumar67f479b2016-12-28 15:43:42 +0530997 return;
998 } else {
999 /*
1000 * Here we are sending preauth rsp with failure state
1001 * and which is forwarded to SME. Now, if we receive an preauth
1002 * resp from AP with success it would create a FT pesession, but
1003 * will be dropped in SME leaving behind the pesession.
1004 * Mark Preauth rsp processed so that any rsp from AP is dropped in
1005 * limProcessAuthFrameNoSession.
1006 */
1007 limLog(mac,LOG1,
Jeff Johnson0fe596e2017-09-19 08:36:48 -07001008 FL("Auth rsp not yet posted to SME session %pK)"), session_entry);
Padma, Santhosh Kumar67f479b2016-12-28 15:43:42 +05301009 mac->ft.ftPEContext.pFTPreAuthReq->bPreAuthRspProcessed =
1010 eANI_BOOLEAN_TRUE;
1011 }
1012 /*
1013 * Ok, so attempted a Pre-Auth and failed. If we are off channel. We need
1014 * to get back.
1015 */
1016 lim_handle_pre_auth_mbb_rsp(mac, eSIR_FAILURE, session_entry);
1017 }
1018
1019/**
Padma, Santhosh Kumarf4966dc2017-01-03 18:56:00 +05301020 * lim_process_reassoc_mbb_rsp_timeout() -Process reassoc response timeout
1021 * @mac: MAC context
1022 *
1023 * This function is called if preauth response is not received from the
1024 * AP within timeout
1025 */
1026void lim_process_reassoc_mbb_rsp_timeout(tpAniSirGlobal mac)
1027{
1028 tpPESession session_entry, ft_session_entry;
1029 tANI_U8 session_id;
1030
1031 if((ft_session_entry = peFindSessionBySessionId(mac,
1032 mac->lim.limTimers.glim_reassoc_mbb_rsp_timer.sessionId))== NULL) {
1033 limLog(mac, LOGE,
1034 FL("ft session does not exist for given session id %d"),
1035 mac->lim.limTimers.glim_reassoc_mbb_rsp_timer.sessionId);
1036 return;
1037 }
1038
1039 limLog(mac, LOG1, FL("Reassoc timeout happened in state %d"),
1040 ft_session_entry->limMlmState);
1041
1042 if((session_entry = peFindSessionByBssid(mac,
1043 mac->ft.ftPEContext.pFTPreAuthReq->currbssId, &session_id))== NULL) {
1044 limLog(mac, LOGE,
1045 FL("session does not exist for given BSSID" MAC_ADDRESS_STR),
1046 MAC_ADDR_ARRAY(mac->ft.ftPEContext.pFTPreAuthReq->currbssId));
1047 return;
1048 }
1049
1050 lim_handle_reassoc_mbb_fail(mac, ft_session_entry);
1051
1052}
1053
1054
1055/**
Padma, Santhosh Kumar67f479b2016-12-28 15:43:42 +05301056 * lim_perform_pre_auth_reassoc() -Sends preauth request
1057 * @mac: MAC context
1058 * @status: status of message
1059 * @data: gives information of session
1060 * @session_entry: session entry
1061 *
1062 * This function process preauth request received from CSR
1063 */
1064static inline
1065void lim_perform_pre_auth_reassoc(tpAniSirGlobal mac, eHalStatus status,
1066 tANI_U32 *data, tpPESession session_entry)
1067{
1068 tSirMacAuthFrameBody authFrame;
1069
1070 if (status != eHAL_STATUS_SUCCESS) {
1071 limLog(mac, LOGE,
1072 FL("Change channel not successful for pre-auth"));
1073 goto preauth_fail;
1074 }
1075
1076 limLog(mac, LOGE,
1077 FL("session id %d"), session_entry->peSessionId);
1078
1079 mac->ft.ftPEContext.psavedsessionEntry = session_entry;
1080
1081 authFrame.authAlgoNumber = eSIR_OPEN_SYSTEM;
1082 authFrame.authTransactionSeqNumber = SIR_MAC_AUTH_FRAME_1;
1083 authFrame.authStatusCode = 0;
1084
1085 /* Start timer here to come back to operating channel. */
1086 mac->lim.limTimers.glim_pre_auth_mbb_rsp_timer.sessionId =
1087 session_entry->peSessionId;
1088
1089 limSendAuthMgmtFrame(mac, &authFrame,
1090 mac->ft.ftPEContext.pFTPreAuthReq->preAuthbssId,
1091 LIM_NO_WEP_IN_FC, session_entry, eSIR_FALSE);
1092
Padma, Santhosh Kumarce74fd82017-02-10 19:57:08 +05301093 MTRACE(macTrace(mac, TRACE_CODE_TIMER_ACTIVATE,
1094 session_entry->peSessionId, eLIM_PREAUTH_MBB_RSP_TIMER));
1095
Padma, Santhosh Kumar67f479b2016-12-28 15:43:42 +05301096 if(TX_SUCCESS !=
1097 tx_timer_activate(&mac->lim.limTimers.glim_pre_auth_mbb_rsp_timer)) {
1098 limLog(mac, LOGE, FL("Pre Auth MBB Rsp Timer Start Failed"));
1099
1100 mac->ft.ftPEContext.psavedsessionEntry = NULL;
1101 goto preauth_fail;
1102 }
1103
1104 return;
1105
1106preauth_fail:
1107 lim_handle_pre_auth_mbb_rsp(mac, eSIR_FAILURE, session_entry);
1108 return;
1109}
1110
1111/**
1112 * pre_auth_mbb_suspend_link_handler() -Handler for suspend link
1113 * @mac: MAC context
1114 * @status: status of message
1115 * @data: gives information of session
1116 *
1117 * This function process preauth request received from CSR
1118 */
1119static inline
1120void pre_auth_mbb_suspend_link_handler(tpAniSirGlobal mac,
1121 eHalStatus status, tANI_U32 *data)
1122{
1123 tpPESession session_entry;
1124
1125 if (status != eHAL_STATUS_SUCCESS) {
1126 limLog(mac, LOGE, FL("Link suspend failed"));
Padma, Santhosh Kumar9f729552017-01-09 14:06:30 +05301127 lim_post_pre_auth_reassoc_rsp(mac, eSIR_FAILURE,
1128 (tpPESession)data, SIR_MBB_CONNECTED);
Padma, Santhosh Kumar67f479b2016-12-28 15:43:42 +05301129 return;
1130 }
1131
1132 session_entry = (tpPESession)data;
1133
1134 if (session_entry->currentOperChannel !=
1135 mac->ft.ftPEContext.pFTPreAuthReq->preAuthchannelNum) {
1136 limChangeChannelWithCallback(mac,
1137 mac->ft.ftPEContext.pFTPreAuthReq->preAuthchannelNum,
1138 lim_perform_pre_auth_reassoc, NULL, session_entry);
1139 return;
1140 } else {
1141 lim_perform_pre_auth_reassoc(mac, eHAL_STATUS_SUCCESS,
1142 NULL, session_entry);
1143 return;
1144 }
1145}
1146
1147/**
1148 * lim_process_pre_auth_reassoc_req() -Process preauth request
1149 * @hal: HAL context
1150 * @msg: message
1151 *
1152 * This function process preauth request received from CSR
1153 */
1154void lim_process_pre_auth_reassoc_req(tpAniSirGlobal mac, tpSirMsgQ msg)
1155{
1156 tpPESession session_entry;
1157 tANI_U8 session_id;
1158
1159 limFTInit(mac);
1160
1161 /* Can set it only after sending auth */
1162 mac->ft.ftPEContext.ftPreAuthStatus = eSIR_FAILURE;
1163
1164 /* We need information from the Pre-Auth Req. Lets save that */
1165 mac->ft.ftPEContext.pFTPreAuthReq = (tpSirFTPreAuthReq)msg->bodyptr;
1166 if (!mac->ft.ftPEContext.pFTPreAuthReq) {
1167 limLog(mac, LOGE,
1168 FL("pFTPreAuthReq is NULL"));
Padma, Santhosh Kumar9f729552017-01-09 14:06:30 +05301169 lim_post_pre_auth_reassoc_rsp(mac, eSIR_FAILURE, NULL,
1170 SIR_MBB_CONNECTED);
Padma, Santhosh Kumar67f479b2016-12-28 15:43:42 +05301171 return;
1172 }
1173
1174 /* Get the current session entry */
1175 session_entry = peFindSessionByBssid(mac,
1176 mac->ft.ftPEContext.pFTPreAuthReq->currbssId, &session_id);
1177 if (session_entry == NULL) {
1178 limLog(mac, LOGE,
1179 FL("Unable to find session for the following bssid"));
1180 limPrintMacAddr(mac,
1181 mac->ft.ftPEContext.pFTPreAuthReq->currbssId, LOGE);
1182
1183 /* Post the pre auth response to SME */
Padma, Santhosh Kumar9f729552017-01-09 14:06:30 +05301184 lim_post_pre_auth_reassoc_rsp(mac, eSIR_FAILURE, NULL,
1185 SIR_MBB_CONNECTED);
Padma, Santhosh Kumarc2346202017-02-02 19:48:39 +05301186 return;
Padma, Santhosh Kumar67f479b2016-12-28 15:43:42 +05301187 }
1188
1189 limLog(mac, LOG1,
1190 FL("set link with eSIR_LINK_PRE_AUTH_REASSOC_STATE"));
1191
1192 if (limSetLinkState(mac, eSIR_LINK_PRE_AUTH_REASSOC_STATE,
1193 session_entry->bssId, session_entry->selfMacAddr,
1194 NULL, NULL) != eSIR_SUCCESS) {
1195 limLog(mac, LOGE,
1196 FL("set link failed for eSIR_LINK_PRE_AUTH_REASSOC_STATE"));
Padma, Santhosh Kumar9f729552017-01-09 14:06:30 +05301197 lim_post_pre_auth_reassoc_rsp(mac, eSIR_FAILURE, NULL,
1198 SIR_MBB_CONNECTED);
Padma, Santhosh Kumar67f479b2016-12-28 15:43:42 +05301199 return;
1200 }
1201
1202 /*
1203 * Suspend link for same channel or different channel so that STA
1204 * can be in power save for connected AP.
1205 */
1206 limLog(mac, LOG1,
Jeff Johnson0fe596e2017-09-19 08:36:48 -07001207 FL("pre-auth on channel %d (session %pK) currentOperChannel %d"),
Padma, Santhosh Kumar67f479b2016-12-28 15:43:42 +05301208 mac->ft.ftPEContext.pFTPreAuthReq->preAuthchannelNum,
1209 session_entry, session_entry->currentOperChannel);
1210 limSuspendLink(mac, eSIR_CHECK_ROAMING_SCAN,
1211 pre_auth_mbb_suspend_link_handler,
1212 (tANI_U32 *)session_entry);
1213}
Padma, Santhosh Kumarf4966dc2017-01-03 18:56:00 +05301214
Padma, Santhosh Kumar9f729552017-01-09 14:06:30 +05301215
1216/**
1217 * lim_process_sta_mlm_del_sta_rsp_mbb() -Process del sta response
1218 * @mac: MAC context
1219 * @lim_msg: lim message
1220 * @session_entry: session entry
1221 *
1222 * This function process del sta response
1223 */
1224void lim_process_sta_mlm_del_sta_rsp_mbb(tpAniSirGlobal mac,
1225 tpSirMsgQ lim_msg, tpPESession session_entry)
1226{
1227 tpDeleteStaParams del_sta_params = (tpDeleteStaParams)lim_msg->bodyptr;
1228 tpDphHashNode sta_ds = NULL;
Padma, Santhosh Kumar7cdb5242017-01-11 19:19:08 +05301229 tANI_U8 session_id;
1230 tpPESession ft_session_entry;
Padma, Santhosh Kumar9f729552017-01-09 14:06:30 +05301231
1232 if(NULL == del_sta_params) {
1233 limLog(mac, LOGE, FL("Encountered NULL Pointer"));
1234 goto end;
1235 }
1236
1237 limLog(mac, LOG1, FL("Del STA RSP received. Status:%d AssocID:%d"),
1238 del_sta_params->status, del_sta_params->assocId);
1239
1240 if (eHAL_STATUS_SUCCESS != del_sta_params->status) {
1241 limLog(mac, LOGE, FL("Del STA failed! Status:%d, still proceeding"
1242 "with Del BSS"), del_sta_params->status);
1243 }
1244
1245 sta_ds = dphGetHashEntry(mac, DPH_STA_HASH_INDEX_PEER,
1246 &session_entry->dph.dphHashTable);
1247
1248 if (sta_ds == NULL) {
1249 limLog( mac, LOGE, FL("DPH Entry for STA %X missing"),
1250 del_sta_params->assocId);
1251 goto end;
1252 }
1253
1254 if (eLIM_MLM_WT_DEL_STA_RSP_STATE != session_entry->limMlmState) {
1255 limLog(mac, LOGE,
1256 FL( "Received unexpected WDA_DELETE_STA_RSP in state %s" ),
1257 limMlmStateStr(session_entry->limMlmState));
1258 goto end;
1259 }
1260
1261 limLog( mac, LOG1, FL("STA AssocID %d MAC "), sta_ds->assocId);
1262 limPrintMacAddr(mac, sta_ds->staAddr, LOG1);
1263
1264 /*
1265 * we must complete all cleanup related to del sta
1266 * before calling del bss.
1267 */
Padma, Santhosh Kumar7cdb5242017-01-11 19:19:08 +05301268 if (NULL != lim_msg->bodyptr) {
Padma, Santhosh Kumar9f729552017-01-09 14:06:30 +05301269 vos_mem_free(del_sta_params);
1270 lim_msg->bodyptr = NULL;
1271 }
1272
1273 /* Proceed to do del bss even if del sta resulted in failure */
1274 lim_del_bss_mbb(mac, sta_ds, 0, session_entry);
1275 return;
1276
1277end:
Padma, Santhosh Kumar7cdb5242017-01-11 19:19:08 +05301278 if(NULL != lim_msg->bodyptr) {
Padma, Santhosh Kumar9f729552017-01-09 14:06:30 +05301279 vos_mem_free(del_sta_params);
1280 lim_msg->bodyptr = NULL;
1281 }
Padma, Santhosh Kumar7cdb5242017-01-11 19:19:08 +05301282 /* Connected AP lim cleanup.*/
1283 lim_cleanup_connected_ap(mac, sta_ds, session_entry);
1284
1285 ft_session_entry = peFindSessionByBssid(mac,
1286 mac->ft.ftPEContext.pFTPreAuthReq->preAuthbssId,
1287 &session_id);
1288 if (ft_session_entry == NULL) {
1289 limLog(mac, LOGE,
1290 FL("Unable to find session for the following bssid"));
1291 limPrintMacAddr(mac,
1292 mac->ft.ftPEContext.pFTPreAuthReq->preAuthbssId, LOGE);
1293 return;
1294 }
1295
Padma, Santhosh Kumar9f729552017-01-09 14:06:30 +05301296 /*
1297 * eHAL_STATUS_INVALID_PARAMETER is used
1298 * so that full cleanup is triggered.
1299 */
1300 lim_reassoc_fail_cleanup(mac, eHAL_STATUS_INVALID_PARAMETER,
Padma, Santhosh Kumar7cdb5242017-01-11 19:19:08 +05301301 (tANI_U32 *)ft_session_entry);
Padma, Santhosh Kumar9f729552017-01-09 14:06:30 +05301302}
1303
1304/**
1305 * lim_cleanup_rx_path_mbb() -cleans up tspec related info
1306 * @mac: MAC context
1307 * @sta_ds: station entry
1308 * @session_entry: session entry of connected AP
1309 *
1310 * This function cleans up tspec related info
1311 */
1312void lim_cleanup_rx_path_mbb(tpAniSirGlobal mac,
1313 tpDphHashNode sta_ds,tpPESession session_entry)
1314{
1315 limLog(mac, LOG1, FL("AID %d limSmeState %d, mlmState %d"),
1316 sta_ds->assocId, session_entry->limSmeState,
1317 sta_ds->mlmStaContext.mlmState);
1318
1319 session_entry->isCiscoVendorAP = FALSE;
1320
1321 if (mac->lim.gLimAddtsSent)
1322 tx_timer_deactivate(&mac->lim.limTimers.gLimAddtsRspTimer);
1323
1324 /* delete all tspecs associated with this sta. */
1325 limAdmitControlDeleteSta(mac, sta_ds->assocId);
Padma, Santhosh Kumar9f729552017-01-09 14:06:30 +05301326}
1327
1328
1329/**
1330 * lim_cleanup_connected_ap() -cleans up connected AP lim info
1331 * @mac: MAC context
1332 * @sta_ds: station entry
1333 * @session_entry: session entry of connected AP
1334 *
1335 * This function cleans up connected AP lim info
1336 */
1337void lim_cleanup_connected_ap(tpAniSirGlobal mac, tpDphHashNode sta_ds,
1338 tpPESession session_entry)
1339{
gaurank kathpalia392e4452018-02-26 15:40:30 +05301340 if (!sta_ds || !session_entry)
1341 return;
Padma, Santhosh Kumar9f729552017-01-09 14:06:30 +05301342 lim_cleanup_rx_path_mbb(mac, sta_ds, session_entry);
1343 limDeleteDphHashEntry(mac, sta_ds->staAddr,
1344 sta_ds->assocId, session_entry);
Padma, Santhosh Kumar7cdb5242017-01-11 19:19:08 +05301345
1346 /**
1347 * Make STA hash entry invalid at eCPU so that DPH
1348 * does not process any more data packets and
1349 * releases those BDs
1350 */
1351 sta_ds->valid = 0;
1352
Padma, Santhosh Kumar9f729552017-01-09 14:06:30 +05301353 peDeleteSession(mac, session_entry);
1354}
1355
1356/**
1357 * lim_process_sta_mlm_del_bss_rsp_mbb() -Process del bss response of
1358 * connected AP
1359 * @mac: MAC context
1360 * @lim_msg: lim message
1361 * @session_entry: session entry of connected AP
1362 *
1363 * This function process del sta response
1364 */
1365void lim_process_sta_mlm_del_bss_rsp_mbb(tpAniSirGlobal mac,
1366 tpSirMsgQ lim_msg, tpPESession session_entry)
1367{
1368 tpDeleteBssParams delbss_params = (tpDeleteBssParams)lim_msg->bodyptr;
1369 tpDphHashNode sta_ds = dphGetHashEntry(mac, DPH_STA_HASH_INDEX_PEER,
1370 &session_entry->dph.dphHashTable);
1371 tpPESession ft_session_entry;
1372 tANI_U8 session_id;
1373
1374 if (NULL == delbss_params) {
1375 limLog(mac, LOGE, FL( "Invalid body pointer in message"));
1376 goto end;
1377 }
Padma, Santhosh Kumar7cdb5242017-01-11 19:19:08 +05301378
1379 ft_session_entry = peFindSessionByBssid(mac,
1380 mac->ft.ftPEContext.pFTPreAuthReq->preAuthbssId,
1381 &session_id);
1382 if (ft_session_entry == NULL) {
1383 limLog(mac, LOGE,
1384 FL("Unable to find session for the following bssid"));
1385 limPrintMacAddr(mac,
1386 mac->ft.ftPEContext.pFTPreAuthReq->preAuthbssId, LOGE);
1387 goto end;
1388 }
1389
Padma, Santhosh Kumar9f729552017-01-09 14:06:30 +05301390 if(eHAL_STATUS_SUCCESS == delbss_params->status) {
1391 limLog(mac, LOG1,
1392 FL( "STA received the DEL_BSS_RSP for BSSID: %X."),
1393 delbss_params->bssIdx);
1394
Padma, Santhosh Kumar9f729552017-01-09 14:06:30 +05301395 if(sta_ds == NULL) {
1396 limLog(mac, LOGE, FL("DPH Entry for STA missing"));
1397 goto end;
1398 }
1399 if(eLIM_MLM_WT_DEL_BSS_RSP_STATE != session_entry->limMlmState) {
1400 limLog(mac, LOGE,
1401 FL("Received unexpected WDA_DEL_BSS_RSP in state %d"),
1402 session_entry->limMlmState);
1403 goto end;
1404 }
1405 limLog(mac, LOG1, FL("STA AssocID %d MAC "), sta_ds->assocId );
1406 limPrintMacAddr(mac, sta_ds->staAddr, LOG1);
Padma, Santhosh Kumar7cdb5242017-01-11 19:19:08 +05301407
1408 lim_cleanup_connected_ap(mac, sta_ds, session_entry);
1409
1410 lim_add_bss_mbb(mac, sta_ds, ft_session_entry);
1411
1412 if(NULL != lim_msg->bodyptr) {
1413 vos_mem_free(delbss_params);
1414 lim_msg->bodyptr = NULL;
1415 }
1416 return;
Padma, Santhosh Kumar9f729552017-01-09 14:06:30 +05301417 } else {
1418 /*
Padma, Santhosh Kumar7cdb5242017-01-11 19:19:08 +05301419 * If del bss response is failure, cleanup sessions of both currently
1420 * connected AP and roamable AP as add bss can not be send
1421 * without successful delbss.
Padma, Santhosh Kumar9f729552017-01-09 14:06:30 +05301422 */
1423 limLog(mac, LOGE,
1424 FL("DEL BSS failed! Status:%d"), delbss_params->status);
1425
Padma, Santhosh Kumar7cdb5242017-01-11 19:19:08 +05301426 if(NULL != lim_msg->bodyptr) {
Padma, Santhosh Kumar9f729552017-01-09 14:06:30 +05301427 vos_mem_free(delbss_params);
1428 lim_msg->bodyptr = NULL;
1429 }
1430
1431 /* Connected AP lim cleanup.*/
1432 lim_cleanup_connected_ap(mac, sta_ds, session_entry);
1433
1434 /* Newly created session cleanup */
1435 lim_reassoc_fail_cleanup(mac, eHAL_STATUS_MBB_DEL_BSS_FAIL,
1436 (tANI_U32 *)ft_session_entry);
1437 return;
1438 }
1439
1440end:
Padma, Santhosh Kumar7cdb5242017-01-11 19:19:08 +05301441 if(NULL != lim_msg->bodyptr) {
Padma, Santhosh Kumar9f729552017-01-09 14:06:30 +05301442 vos_mem_free(delbss_params);
1443 lim_msg->bodyptr = NULL;
1444 }
Padma, Santhosh Kumar9f729552017-01-09 14:06:30 +05301445 lim_cleanup_connected_ap(mac, sta_ds, session_entry);
Padma, Santhosh Kumar7cdb5242017-01-11 19:19:08 +05301446
1447 ft_session_entry = peFindSessionByBssid(mac,
1448 mac->ft.ftPEContext.pFTPreAuthReq->preAuthbssId,
1449 &session_id);
1450 if (ft_session_entry == NULL) {
1451 limLog(mac, LOGE,
1452 FL("Unable to find session for the following bssid"));
1453 limPrintMacAddr(mac,
1454 mac->ft.ftPEContext.pFTPreAuthReq->preAuthbssId, LOGE);
1455 return;
1456 }
1457
1458 /*
1459 * eHAL_STATUS_INVALID_PARAMETER is used
1460 * so that full cleanup is triggered.
1461 */
1462 lim_reassoc_fail_cleanup(mac, eHAL_STATUS_INVALID_PARAMETER,
1463 (tANI_U32 *)ft_session_entry);
Padma, Santhosh Kumar9f729552017-01-09 14:06:30 +05301464}
1465
1466
Padma, Santhosh Kumar7cdb5242017-01-11 19:19:08 +05301467void lim_fill_add_sta_params_mbb(tpAniSirGlobal mac,
1468 tpPESession session_entry, tpAddStaParams add_sta_params)
1469{
1470 tANI_U32 listen_interval = WNI_CFG_LISTEN_INTERVAL_STADEF;
1471 tANI_U32 self_sta_dot11_mode = 0;
Padma, Santhosh Kumar9f729552017-01-09 14:06:30 +05301472
Padma, Santhosh Kumar7cdb5242017-01-11 19:19:08 +05301473 vos_mem_copy(add_sta_params->staMac, session_entry->selfMacAddr,
1474 sizeof(tSirMacAddr));
1475 vos_mem_copy(add_sta_params->bssId, session_entry->bssId,
1476 sizeof(tSirMacAddr));
1477
1478 add_sta_params->staType = STA_ENTRY_SELF;
1479 add_sta_params->status = eHAL_STATUS_SUCCESS;
1480 add_sta_params->respReqd = 1;
1481
1482 add_sta_params->sessionId = session_entry->peSessionId;
1483 add_sta_params->staIdx = HAL_STA_INVALID_IDX;
1484 add_sta_params->updateSta = FALSE;
1485
1486 add_sta_params->shortPreambleSupported =
1487 session_entry->beaconParams.fShortPreamble;
1488
1489#ifdef WLAN_FEATURE_11AC
1490 limPopulatePeerRateSet(mac, &add_sta_params->supportedRates, NULL,
1491 false,session_entry, NULL);
1492#else
1493 limPopulatePeerRateSet(mac, &add_sta_params->supportedRates, NULL,
1494 false,session_entry);
1495#endif
1496
1497 if(session_entry->htCapability) {
1498 add_sta_params->htCapable = session_entry->htCapability;
1499#ifdef WLAN_FEATURE_11AC
1500 add_sta_params->vhtCapable = session_entry->vhtCapability;
1501 add_sta_params->vhtTxChannelWidthSet = session_entry->vhtTxChannelWidthSet;
1502#endif
1503
1504#ifdef DISABLE_GF_FOR_INTEROP
1505 if((session_entry->pLimJoinReq != NULL) &&
1506 (!session_entry->pLimJoinReq->bssDescription.aniIndicator)) {
1507 limLog(mac, LOGE,
1508 FL("Turning off Greenfield, when adding self entry"));
1509 add_sta_params->greenFieldCapable =
1510 WNI_CFG_GREENFIELD_CAPABILITY_DISABLE;
1511 }
1512 else
1513#endif
1514 add_sta_params->greenFieldCapable =
1515 limGetHTCapability( mac, eHT_GREENFIELD, session_entry);
1516
1517 if (session_entry->limRFBand == SIR_BAND_2_4_GHZ)
1518 add_sta_params->txChannelWidthSet =
1519 mac->roam.configParam.channelBondingMode24GHz;
1520 else
1521 add_sta_params->txChannelWidthSet =
1522 mac->roam.configParam.channelBondingMode5GHz;
1523
1524 add_sta_params->mimoPS =
1525 limGetHTCapability(mac, eHT_MIMO_POWER_SAVE, session_entry);
1526 add_sta_params->rifsMode =
1527 limGetHTCapability(mac, eHT_RIFS_MODE, session_entry);
1528 add_sta_params->lsigTxopProtection =
1529 limGetHTCapability(mac, eHT_LSIG_TXOP_PROTECTION, session_entry);
1530 add_sta_params->delBASupport =
1531 limGetHTCapability(mac, eHT_DELAYED_BA, session_entry);
1532 add_sta_params->maxAmpduDensity =
1533 limGetHTCapability(mac, eHT_MPDU_DENSITY, session_entry);
1534 add_sta_params->maxAmpduSize =
1535 limGetHTCapability(mac, eHT_MAX_RX_AMPDU_FACTOR, session_entry);
1536 add_sta_params->maxAmsduSize =
1537 limGetHTCapability(mac, eHT_MAX_AMSDU_LENGTH, session_entry);
1538 add_sta_params->fDsssCckMode40Mhz =
1539 limGetHTCapability(mac, eHT_DSSS_CCK_MODE_40MHZ, session_entry);
1540 add_sta_params->fShortGI20Mhz =
1541 limGetHTCapability(mac, eHT_SHORT_GI_20MHZ, session_entry);
1542 add_sta_params->fShortGI40Mhz =
1543 limGetHTCapability(mac, eHT_SHORT_GI_40MHZ, session_entry);
1544 }
1545
1546 if (wlan_cfgGetInt(mac, WNI_CFG_LISTEN_INTERVAL,
1547 &listen_interval) != eSIR_SUCCESS)
1548 limLog(mac, LOGE, FL("Couldn't get LISTEN_INTERVAL"));
1549
1550 add_sta_params->listenInterval = (tANI_U16)listen_interval;
1551
1552 wlan_cfgGetInt(mac, WNI_CFG_DOT11_MODE, &self_sta_dot11_mode);
1553 add_sta_params->supportedRates.opRateMode =
1554 limGetStaRateMode((tANI_U8)self_sta_dot11_mode);
1555
1556 mac->ft.ftPEContext.pAddStaReq = add_sta_params;
1557
1558
1559}
1560
1561void lim_process_sta_mlm_add_bss_rsp_mbb(tpAniSirGlobal mac,
1562 tpSirMsgQ limMsgQ,tpPESession session_entry)
1563{
1564 tpAddBssParams add_bss_params = (tpAddBssParams)limMsgQ->bodyptr;
1565 tpAddStaParams add_sta_params = NULL;
1566 tpDphHashNode sta_ds = dphGetHashEntry(mac, DPH_STA_HASH_INDEX_PEER,
1567 &session_entry->dph.dphHashTable);
1568
1569 if(add_bss_params == 0)
1570 goto end;
gaurank kathpalia392e4452018-02-26 15:40:30 +05301571 if (!sta_ds) {
1572 limLog(mac, LOGE, FL("DPH Entry for STA missing"));
1573 goto end;
1574 }
Padma, Santhosh Kumar7cdb5242017-01-11 19:19:08 +05301575
1576 limLog(mac, LOG1, FL("Add BSS RSP received. Status:%d"),
1577 add_bss_params->status);
1578
1579 if(eHAL_STATUS_SUCCESS == add_bss_params->status) {
1580
1581 if(eLIM_MLM_WT_ADD_BSS_RSP_REASSOC_STATE != session_entry->limMlmState) {
1582 limLog(mac, LOGE,
1583 FL("Received unexpected ADD BSS in state %d"),
1584 session_entry->limMlmState);
1585 goto end;
1586 }
1587
1588 session_entry->bssIdx = add_bss_params->bssIdx;
1589
1590 sta_ds->bssId = add_bss_params->bssIdx;
1591 sta_ds->staIndex = add_bss_params->staContext.staIdx;
1592 sta_ds->ucUcastSig = add_bss_params->staContext.ucUcastSig;
1593 sta_ds->ucBcastSig = add_bss_params->staContext.ucBcastSig;
1594
1595 rrmCacheMgmtTxPower(mac, add_bss_params->txMgmtPower, session_entry);
1596
1597 /* Allocate memory for add sta params */
1598 add_sta_params = vos_mem_malloc(sizeof( tAddStaParams ));
1599 if (NULL == add_sta_params) {
1600 limLog(mac, LOGE,
1601 FL("Unable to allocate memory during ADD_STA"));
1602 goto end;
1603 }
1604 vos_mem_set(add_sta_params, sizeof(tAddStaParams), 0);
1605
1606 /* Prepare add sta params */
1607 lim_fill_add_sta_params_mbb(mac, session_entry, add_sta_params);
1608
1609 if(0 != limMsgQ->bodyptr) {
1610 vos_mem_free(add_bss_params);
1611 add_bss_params = NULL;
1612 limMsgQ->bodyptr = NULL;
1613 }
1614
1615 lim_add_sta_mbb(mac, session_entry->limAID, session_entry);
1616
1617 } else {
1618 /*
1619 * If add bss response is failure, cleanup session of roamable AP
1620 * as cleanup of connected bss happened during del bss
1621 */
1622 limLog(mac, LOGE,
1623 FL("ADD BSS failed! Status:%d"), add_bss_params->status);
1624
1625 /* Newly created session cleanup */
1626 lim_reassoc_fail_cleanup(mac, eHAL_STATUS_MBB_ADD_BSS_FAIL,
1627 (tANI_U32 *)session_entry);
1628 }
1629
1630end:
1631 if(0 != limMsgQ->bodyptr) {
1632 vos_mem_free(add_bss_params);
1633 add_bss_params = NULL;
1634 limMsgQ->bodyptr = NULL;
1635 }
1636}
1637
1638/*
1639 * lim_perform_post_add_sta_rsp() -invokes resume callback to handle add sta response
1640 * @mac: MAC context
1641 * @status: status
1642 * @data: pointer to data
1643 *
1644 * This function invokes resume callback
1645 */
1646void lim_perform_post_add_sta_rsp(tpAniSirGlobal mac,
1647 eHalStatus status, tANI_U32 *data)
1648{
1649 tpDphHashNode sta_ds;
1650 /* session entry for newly roamed ap */
1651 tpPESession session_entry;
1652
1653 session_entry = (tpPESession)data;
1654
Padma, Santhosh Kumar0b04ed12017-01-23 15:39:03 +05301655 limLog(mac, LOG1, FL("forwarding cached packets"));
1656 WLANTL_PreAssocForward(true);
1657
Padma, Santhosh Kumar7cdb5242017-01-11 19:19:08 +05301658 sta_ds = dphGetHashEntry(mac, DPH_STA_HASH_INDEX_PEER,
1659 &session_entry->dph.dphHashTable);
1660 if(NULL != sta_ds)
1661 sta_ds->mlmStaContext.mlmState = eLIM_MLM_LINK_ESTABLISHED_STATE;
1662 else {
1663 limLog(mac, LOGE,
1664 FL("Unable to get the DPH Hash Entry for AID - %d"),
1665 DPH_STA_HASH_INDEX_PEER);
1666 return;
1667 }
1668
1669 session_entry->limMlmState = eLIM_MLM_LINK_ESTABLISHED_STATE;
Padma, Santhosh Kumarce74fd82017-02-10 19:57:08 +05301670 MTRACE(macTrace(mac, TRACE_CODE_MLM_STATE,
1671 session_entry->peSessionId, eLIM_MLM_LINK_ESTABLISHED_STATE));
Padma, Santhosh Kumar7cdb5242017-01-11 19:19:08 +05301672
1673#ifdef FEATURE_WLAN_TDLS
1674 /* initialize TDLS peer related data */
1675 limInitTdlsData(mac, session_entry);
1676#endif
1677
1678 if (limSetLinkState(mac, eSIR_LINK_POSTASSOC_STATE, session_entry->bssId,
1679 session_entry->selfMacAddr, NULL, NULL) != eSIR_SUCCESS) {
1680 limLog(mac, LOGE, FL("Set link state to POSTASSOC failed"));
1681 return;
1682 }
1683
1684 session_entry->limSmeState = eLIM_SME_LINK_EST_STATE;
1685
1686 lim_post_pre_auth_reassoc_rsp(mac, eSIR_SUCCESS, session_entry,
1687 SIR_MBB_CONNECTED);
1688
1689 /* Freeup the cached preauth request */
1690 if (mac->ft.ftPEContext.pFTPreAuthReq) {
Jeff Johnson0fe596e2017-09-19 08:36:48 -07001691 limLog(mac, LOG1, FL("Freeing pFTPreAuthReq= %pK"),
Padma, Santhosh Kumar7cdb5242017-01-11 19:19:08 +05301692 mac->ft.ftPEContext.pFTPreAuthReq);
1693 if (mac->ft.ftPEContext.pFTPreAuthReq->pbssDescription) {
1694 vos_mem_free(mac->ft.ftPEContext.pFTPreAuthReq->pbssDescription);
1695 mac->ft.ftPEContext.pFTPreAuthReq->pbssDescription = NULL;
1696 }
1697 vos_mem_free(mac->ft.ftPEContext.pFTPreAuthReq);
1698 mac->ft.ftPEContext.pFTPreAuthReq = NULL;
1699 }
1700}
1701
1702void lim_process_sta_mlm_add_sta_rsp_mbb(tpAniSirGlobal mac,
1703 tpSirMsgQ limMsgQ,tpPESession session_entry)
1704{
1705 tpAddStaParams add_sta_params = (tpAddStaParams)limMsgQ->bodyptr;
1706
1707 if(NULL == add_sta_params) {
1708 limLog(mac, LOGE, FL("Encountered NULL Pointer"));
1709 return;
1710 }
1711
1712 limLog(mac, LOG1, FL("Add STA RSP received. Status:%d"),
1713 add_sta_params->status);
1714
1715 if (eHAL_STATUS_SUCCESS == add_sta_params->status) {
1716 if ( eLIM_MLM_WT_ADD_STA_RSP_STATE != session_entry->limMlmState) {
1717 limLog(mac, LOGE,
1718 FL("Received unexpected ADD_STA_RSP in state %d"),
1719 session_entry->limMlmState);
1720 goto end;
1721 }
1722
1723 /*
1724 * Storing the self StaIndex(Generated by HAL) in session context,
1725 * instead of storing it in DPH Hash entry for Self STA.
1726 * DPH entry for the self STA stores the sta index for the BSS entry
1727 * to which the STA is associated.
1728 */
1729 session_entry->staId = add_sta_params->staIdx;
1730
1731 limLog(mac, LOG1, FL("resuming to oper ch %d"),
1732 session_entry->currentOperChannel);
1733
1734 peSetResumeChannel(mac, session_entry->currentOperChannel, 0);
1735 limResumeLink(mac, lim_perform_post_add_sta_rsp, (tANI_U32 *)session_entry);
1736 } else {
1737 limLog(mac, LOGE, FL( "ADD_STA failed!"));
1738
1739 /* Newly created session cleanup */
1740 lim_reassoc_fail_cleanup(mac, eHAL_STATUS_MBB_ADD_BSS_FAIL,
1741 (tANI_U32 *)session_entry);
1742
1743 }
1744end:
1745 if( 0 != limMsgQ->bodyptr )
1746 {
1747 vos_mem_free(add_sta_params);
1748 limMsgQ->bodyptr = NULL;
1749 }
1750}
Padma, Santhosh Kumar071de2d2017-02-02 20:38:03 +05301751
1752eAniBoolean lim_is_mbb_reassoc_in_progress(tpAniSirGlobal mac,
1753 tpPESession session_entry)
1754{
1755 if (session_entry == NULL)
1756 return eANI_BOOLEAN_FALSE;
1757
1758 if ((eLIM_STA_ROLE == session_entry->limSystemRole) &&
1759 mac->ft.ftSmeContext.is_preauth_lfr_mbb) {
1760 limLog(mac, LOG1, FL("MBB Reassoc in progress"));
1761 return eANI_BOOLEAN_TRUE;
1762 }
1763
1764 return eANI_BOOLEAN_FALSE;
1765}