blob: ffab46808c22fe216ad7a9ca73043de87aaaa076 [file] [log] [blame]
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001/*
2 * Copyright (c) 2012-2015 The Linux Foundation. All rights reserved.
3 *
4 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
5 *
6 *
7 * Permission to use, copy, modify, and/or distribute this software for
8 * any purpose with or without fee is hereby granted, provided that the
9 * above copyright notice and this permission notice appear in all
10 * copies.
11 *
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
13 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
14 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
15 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
16 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
17 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
18 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19 * PERFORMANCE OF THIS SOFTWARE.
20 */
21
22/*
23 * This file was originally distributed by Qualcomm Atheros, Inc.
24 * under proprietary terms before Copyright ownership was assigned
25 * to the Linux Foundation.
26 */
27
28#ifdef WLAN_FEATURE_VOWIFI_11R
29/**=========================================================================
30
31 \brief implementation for PE 11r VoWiFi FT Protocol
32
33 ========================================================================*/
34
35/* $Header$ */
36
37/*--------------------------------------------------------------------------
38 Include Files
39 ------------------------------------------------------------------------*/
40#include <lim_send_messages.h>
41#include <lim_types.h>
42#include <lim_ft.h>
43#include <lim_ft_defs.h>
44#include <lim_utils.h>
45#include <lim_prop_exts_utils.h>
46#include <lim_assoc_utils.h>
47#include <lim_session.h>
48#include <lim_admit_control.h>
49#include "wmm_apsd.h"
50
51extern void lim_send_set_sta_key_req(tpAniSirGlobal pMac,
52 tLimMlmSetKeysReq *pMlmSetKeysReq,
53 uint16_t staIdx,
54 uint8_t defWEPIdx,
55 tpPESession sessionEntry, bool sendRsp);
56
57/*--------------------------------------------------------------------------
58 Initialize the FT variables.
59 ------------------------------------------------------------------------*/
60void lim_ft_open(tpAniSirGlobal pMac, tpPESession psessionEntry)
61{
62 if (psessionEntry)
63 cdf_mem_set(&psessionEntry->ftPEContext, sizeof(tftPEContext),
64 0);
65}
66
67/*--------------------------------------------------------------------------
68 Cleanup FT variables.
69 ------------------------------------------------------------------------*/
70void lim_ft_cleanup_pre_auth_info(tpAniSirGlobal pMac, tpPESession psessionEntry)
71{
72 tpPESession pReAssocSessionEntry = NULL;
73 uint8_t sessionId = 0;
74
75 if (!psessionEntry) {
76#if defined WLAN_FEATURE_VOWIFI_11R_DEBUG
77 PELOGE(lim_log
78 (pMac, LOGE, "%s: psessionEntry is NULL", __func__);
79 )
80#endif
81 return;
82 }
83
84 /* Nothing to be done if the session is not in STA mode */
85 if (!LIM_IS_STA_ROLE(psessionEntry)) {
86#if defined WLAN_FEATURE_VOWIFI_11R_DEBUG
87 PELOGE(lim_log
88 (pMac, LOGE, FL("psessionEntry is not in STA mode"));
89 )
90#endif
91 return;
92 }
93
94 if (psessionEntry->ftPEContext.pFTPreAuthReq) {
95 pReAssocSessionEntry =
96 pe_find_session_by_bssid(pMac,
97 psessionEntry->ftPEContext.
98 pFTPreAuthReq->preAuthbssId,
99 &sessionId);
100
101#if defined WLAN_FEATURE_VOWIFI_11R_DEBUG
102 PELOG1(lim_log(pMac, LOG1, FL("Freeing pFTPreAuthReq= %p"),
103 psessionEntry->ftPEContext.pFTPreAuthReq);
104 )
105#endif
106 if (psessionEntry->ftPEContext.pFTPreAuthReq->
107 pbssDescription) {
108 cdf_mem_free(psessionEntry->ftPEContext.pFTPreAuthReq->
109 pbssDescription);
110 psessionEntry->ftPEContext.pFTPreAuthReq->
111 pbssDescription = NULL;
112 }
113 cdf_mem_free(psessionEntry->ftPEContext.pFTPreAuthReq);
114 psessionEntry->ftPEContext.pFTPreAuthReq = NULL;
115 }
116
117 if (psessionEntry->ftPEContext.pAddBssReq) {
118 cdf_mem_free(psessionEntry->ftPEContext.pAddBssReq);
119 psessionEntry->ftPEContext.pAddBssReq = NULL;
120 }
121
122 if (psessionEntry->ftPEContext.pAddStaReq) {
123 cdf_mem_free(psessionEntry->ftPEContext.pAddStaReq);
124 psessionEntry->ftPEContext.pAddStaReq = NULL;
125 }
126
127 /* The session is being deleted, cleanup the contents */
128 cdf_mem_set(&psessionEntry->ftPEContext, sizeof(tftPEContext), 0);
129
130 /* Delete the session created while handling pre-auth response */
131 if (pReAssocSessionEntry) {
132 /* If we have successful pre-auth response, then we would have
133 * created a session on which reassoc request will be sent
134 */
135 if (pReAssocSessionEntry->valid &&
136 pReAssocSessionEntry->limSmeState ==
137 eLIM_SME_WT_REASSOC_STATE) {
138 CDF_TRACE(CDF_MODULE_ID_PE,
139 CDF_TRACE_LEVEL_DEBUG,
140 FL("Deleting Preauth session(%d)"),
141 pReAssocSessionEntry->peSessionId);
142 pe_delete_session(pMac, pReAssocSessionEntry);
143 }
144 }
145}
146
147void lim_ft_cleanup_all_ft_sessions(tpAniSirGlobal pMac)
148{
149 /* Wrapper function to cleanup all FT sessions */
150 int i;
151
152 for (i = 0; i < pMac->lim.maxBssId; i++) {
153 if (true == pMac->lim.gpSession[i].valid) {
154 /* The session is valid, may have FT data */
155 lim_ft_cleanup(pMac, &pMac->lim.gpSession[i]);
156 }
157 }
158}
159
160void lim_ft_cleanup(tpAniSirGlobal pMac, tpPESession psessionEntry)
161{
162 if (NULL == psessionEntry) {
163#if defined WLAN_FEATURE_VOWIFI_11R_DEBUG
164 PELOGE(lim_log(pMac, LOGE, FL("psessionEntry is NULL"));)
165#endif
166 return;
167 }
168
169 /* Nothing to be done if the session is not in STA mode */
170 if (!LIM_IS_STA_ROLE(psessionEntry)) {
171#if defined WLAN_FEATURE_VOWIFI_11R_DEBUG
172 PELOGE(lim_log
173 (pMac, LOGE, FL("psessionEntry is not in STA mode"));
174 )
175#endif
176 return;
177 }
178
179 if (NULL != psessionEntry->ftPEContext.pFTPreAuthReq) {
180#if defined WLAN_FEATURE_VOWIFI_11R_DEBUG
181 PELOG1(lim_log(pMac, LOG1, FL("Freeing pFTPreAuthReq= %p"),
182 psessionEntry->ftPEContext.pFTPreAuthReq);
183 )
184#endif
185 if (NULL !=
186 psessionEntry->ftPEContext.pFTPreAuthReq->
187 pbssDescription) {
188 cdf_mem_free(psessionEntry->ftPEContext.pFTPreAuthReq->
189 pbssDescription);
190 psessionEntry->ftPEContext.pFTPreAuthReq->
191 pbssDescription = NULL;
192 }
193 cdf_mem_free(psessionEntry->ftPEContext.pFTPreAuthReq);
194 psessionEntry->ftPEContext.pFTPreAuthReq = NULL;
195 }
196
197 if (psessionEntry->ftPEContext.pAddBssReq) {
198 cdf_mem_free(psessionEntry->ftPEContext.pAddBssReq);
199 psessionEntry->ftPEContext.pAddBssReq = NULL;
200 }
201
202 if (psessionEntry->ftPEContext.pAddStaReq) {
203 cdf_mem_free(psessionEntry->ftPEContext.pAddStaReq);
204 psessionEntry->ftPEContext.pAddStaReq = NULL;
205 }
206
207 /* The session is being deleted, cleanup the contents */
208 cdf_mem_set(&psessionEntry->ftPEContext, sizeof(tftPEContext), 0);
209}
210
211/*------------------------------------------------------------------
212 *
213 * This is the handler after suspending the link.
214 * We suspend the link and then now proceed to switch channel.
215 *
216 *------------------------------------------------------------------*/
217void static
218lim_ft_pre_auth_suspend_link_handler(tpAniSirGlobal pMac, CDF_STATUS status,
219 uint32_t *data)
220{
221 tpPESession psessionEntry = (tpPESession) data;
222
223 /* The link is suspended of not */
224 if (NULL == psessionEntry ||
225 NULL == psessionEntry->ftPEContext.pFTPreAuthReq ||
226 status != CDF_STATUS_SUCCESS) {
227 PELOGE(lim_log(pMac, LOGE,
228 FL("preAuth error, status = %d"), status);
229 )
230 lim_post_ft_pre_auth_rsp(pMac, eSIR_FAILURE, NULL, 0,
231 psessionEntry);
232 return;
233 }
234
235 /* Suspended, now move to a different channel.
236 * Perform some sanity check before proceeding
237 */
238 if (psessionEntry->ftPEContext.pFTPreAuthReq) {
239 lim_change_channel_with_callback(pMac,
240 psessionEntry->ftPEContext.
241 pFTPreAuthReq->preAuthchannelNum,
242 lim_perform_ft_pre_auth, NULL,
243 psessionEntry);
244 return;
245 }
246}
247
248/*
249 * lim_process_ft_pre_auth_req() - process ft pre auth req
250 *
251 * @mac_ctx: global mac ctx
252 * @msg: pointer to message
253 *
254 * In this function, we process the FT Pre Auth Req:
255 * We receive Pre-Auth, suspend link, register a call back. In the call back,
256 * we will need to accept frames from the new bssid. Send out the auth req to
257 * new AP. Start timer and when the timer is done or if we receive the Auth
258 * response. We change channel. Resume link
259 *
260 * Return: value to indicate if buffer was consumed
261 */
262int lim_process_ft_pre_auth_req(tpAniSirGlobal mac_ctx, tpSirMsgQ msg)
263{
264 int buf_consumed = false;
265 tpPESession session;
266 uint8_t session_id;
267 tpSirFTPreAuthReq ft_pre_auth_req = (tSirFTPreAuthReq *) msg->bodyptr;
268
269 if (NULL == ft_pre_auth_req) {
270#if defined WLAN_FEATURE_VOWIFI_11R_DEBUG
271 PELOGE(lim_log(mac_ctx, LOGE, FL("tSirFTPreAuthReq is NULL"));)
272#endif
273 return buf_consumed;
274 }
275
276 /* Get the current session entry */
277 session = pe_find_session_by_bssid(mac_ctx,
278 ft_pre_auth_req->currbssId,
279 &session_id);
280 if (session == NULL) {
281 lim_log(mac_ctx, LOGE,
282 FL("Unable to find session for the bssid"
283 MAC_ADDRESS_STR),
284 MAC_ADDR_ARRAY(ft_pre_auth_req->currbssId));
285 /* Post the FT Pre Auth Response to SME */
286 lim_post_ft_pre_auth_rsp(mac_ctx, eSIR_FAILURE, NULL, 0,
287 session);
288 /*
289 * return FALSE, since the Pre-Auth Req will be freed in
290 * limPostFTPreAuthRsp on failure
291 */
292 return buf_consumed;
293 }
294
295 /* Nothing to be done if the session is not in STA mode */
296 if (!LIM_IS_STA_ROLE(session)) {
297#if defined WLAN_FEATURE_VOWIFI_11R_DEBUG
298 lim_log(mac_ctx, LOGE, FL("session is not in STA mode"));
299#endif
300 buf_consumed = true;
301 return buf_consumed;
302 }
303
304 /* Can set it only after sending auth */
305 session->ftPEContext.ftPreAuthStatus = eSIR_FAILURE;
306 session->ftPEContext.ftPreAuthSession = true;
307
308 /* Indicate that this is the session on which preauth is being done */
309 if (session->ftPEContext.pFTPreAuthReq) {
310 if (session->ftPEContext.pFTPreAuthReq->pbssDescription) {
311 cdf_mem_free(
312 session->ftPEContext.pFTPreAuthReq->pbssDescription);
313 session->ftPEContext.pFTPreAuthReq->pbssDescription =
314 NULL;
315 }
316 cdf_mem_free(session->ftPEContext.pFTPreAuthReq);
317 session->ftPEContext.pFTPreAuthReq = NULL;
318 }
319
320 /* We need information from the Pre-Auth Req. Lets save that */
321 session->ftPEContext.pFTPreAuthReq = ft_pre_auth_req;
322
323#if defined WLAN_FEATURE_VOWIFI_11R_DEBUG
324 lim_log(mac_ctx, LOG1, FL("PRE Auth ft_ies_length=%02x%02x%02x"),
325 session->ftPEContext.pFTPreAuthReq->ft_ies[0],
326 session->ftPEContext.pFTPreAuthReq->ft_ies[1],
327 session->ftPEContext.pFTPreAuthReq->ft_ies[2]);
328#endif
329#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
330 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_PRE_AUTH_REQ_EVENT,
331 session, 0, 0);
332#endif
333
334 /* Dont need to suspend if APs are in same channel */
335 if (session->currentOperChannel !=
336 session->ftPEContext.pFTPreAuthReq->preAuthchannelNum) {
337 /* Need to suspend link only if the channels are different */
338 lim_log(mac_ctx, LOG2,
339 FL("Performing pre-auth on diff channel(session %p)"),
340 session);
341 lim_ft_pre_auth_suspend_link_handler(mac_ctx, CDF_STATUS_SUCCESS,
342 (uint32_t *)session);
343 } else {
344 lim_log(mac_ctx, LOG2,
345 FL("Performing pre-auth on same channel (session %p)"),
346 session);
347 /* We are in the same channel. Perform pre-auth */
348 lim_perform_ft_pre_auth(mac_ctx, CDF_STATUS_SUCCESS, NULL,
349 session);
350 }
351
352 return buf_consumed;
353}
354
355/*------------------------------------------------------------------
356 * Send the Auth1
357 * Receive back Auth2
358 *------------------------------------------------------------------*/
359void lim_perform_ft_pre_auth(tpAniSirGlobal pMac, CDF_STATUS status,
360 uint32_t *data, tpPESession psessionEntry)
361{
362 tSirMacAuthFrameBody authFrame;
363
364 if (NULL == psessionEntry) {
365 PELOGE(lim_log(pMac, LOGE, FL("psessionEntry is NULL"));)
366 return;
367 }
368
369 if (psessionEntry->is11Rconnection &&
370 psessionEntry->ftPEContext.pFTPreAuthReq) {
371 /* Only 11r assoc has FT IEs */
372 if (psessionEntry->ftPEContext.pFTPreAuthReq->ft_ies == NULL) {
Vidyullatha Kanchanapally3554e4e2015-08-12 12:43:18 -0700373 lim_log(pMac, LOGE,
374 FL("FTIEs for Auth Req Seq 1 is absent"));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800375 goto preauth_fail;
376 }
377 }
378
379 if (status != CDF_STATUS_SUCCESS) {
Vidyullatha Kanchanapally3554e4e2015-08-12 12:43:18 -0700380 lim_log(pMac, LOGE,
381 FL(" Change channel not successful for FT pre-auth"));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800382 goto preauth_fail;
383 }
384
385 /* Nothing to be done if the session is not in STA mode */
386 if (!LIM_IS_STA_ROLE(psessionEntry)) {
387#if defined WLAN_FEATURE_VOWIFI_11R_DEBUG
Vidyullatha Kanchanapally3554e4e2015-08-12 12:43:18 -0700388 lim_log(pMac, LOGE, FL("psessionEntry is not in STA mode"));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800389#endif
390 return;
391 }
392#if defined WLAN_FEATURE_VOWIFI_11R_DEBUG
Vidyullatha Kanchanapally3554e4e2015-08-12 12:43:18 -0700393 lim_log(pMac, LOG2, "Entered wait auth2 state for FT (old session %p)",
394 psessionEntry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800395#endif
396 if (psessionEntry->is11Rconnection) {
397 /* Now we are on the right channel and need to send out Auth1 and
398 * receive Auth2
399 */
400 authFrame.authAlgoNumber = eSIR_FT_AUTH;
401 }
402#if defined FEATURE_WLAN_ESE || defined FEATURE_WLAN_LFR
403 else {
404 /* Will need to make isESEconnection a enum may be for further
405 * improvements to this to match this algorithm number
406 */
407 authFrame.authAlgoNumber = eSIR_OPEN_SYSTEM;
408 }
409#endif
410 authFrame.authTransactionSeqNumber = SIR_MAC_AUTH_FRAME_1;
411 authFrame.authStatusCode = 0;
412
413 /* Start timer here to come back to operating channel */
414 pMac->lim.limTimers.gLimFTPreAuthRspTimer.sessionId =
415 psessionEntry->peSessionId;
416 if (TX_SUCCESS !=
417 tx_timer_activate(&pMac->lim.limTimers.gLimFTPreAuthRspTimer)) {
418#if defined WLAN_FEATURE_VOWIFI_11R_DEBUG
Vidyullatha Kanchanapally3554e4e2015-08-12 12:43:18 -0700419 lim_log(pMac, LOGE, FL("FT Auth Rsp Timer Start Failed"));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800420#endif
Vidyullatha Kanchanapally3554e4e2015-08-12 12:43:18 -0700421 goto preauth_fail;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800422 }
Vidyullatha Kanchanapally3554e4e2015-08-12 12:43:18 -0700423 MTRACE(mac_trace(pMac, TRACE_CODE_TIMER_ACTIVATE,
424 psessionEntry->peSessionId, eLIM_FT_PREAUTH_RSP_TIMER));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800425
426#if defined WLAN_FEATURE_VOWIFI_11R_DEBUG
Vidyullatha Kanchanapally3554e4e2015-08-12 12:43:18 -0700427 lim_log(pMac, LOG1, FL("FT Auth Rsp Timer Started"));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800428#endif
429#ifdef FEATURE_WLAN_DIAG_SUPPORT
430 lim_diag_event_report(pMac, WLAN_PE_DIAG_ROAM_AUTH_START_EVENT,
431 pMac->lim.pSessionEntry, eSIR_SUCCESS, eSIR_SUCCESS);
432#endif
433
434 lim_send_auth_mgmt_frame(pMac, &authFrame,
Vidyullatha Kanchanapally3554e4e2015-08-12 12:43:18 -0700435 psessionEntry->ftPEContext.pFTPreAuthReq->preAuthbssId,
436 LIM_NO_WEP_IN_FC, psessionEntry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800437
438 return;
439
440preauth_fail:
441 lim_handle_ft_pre_auth_rsp(pMac, eSIR_FAILURE, NULL, 0, psessionEntry);
442 return;
443}
444
445/*------------------------------------------------------------------
446 *
447 * Create the new Add Bss Req to the new AP.
448 * This will be used when we are ready to FT to the new AP.
449 * The newly created ft Session entry is passed to this function
450 *
451 *------------------------------------------------------------------*/
452tSirRetStatus lim_ft_prepare_add_bss_req(tpAniSirGlobal pMac,
453 uint8_t updateEntry,
454 tpPESession pftSessionEntry,
455 tpSirBssDescription bssDescription)
456{
457 tpAddBssParams pAddBssParams = NULL;
458 tAddStaParams *sta_ctx;
459 uint8_t chanWidthSupp = 0;
460 tSchBeaconStruct *pBeaconStruct;
461
462 /* Nothing to be done if the session is not in STA mode */
463 if (!LIM_IS_STA_ROLE(pftSessionEntry)) {
464#if defined WLAN_FEATURE_VOWIFI_11R_DEBUG
465 PELOGE(lim_log
466 (pMac, LOGE, FL("psessionEntry is not in STA mode"));
467 )
468#endif
469 return eSIR_FAILURE;
470 }
471
472 pBeaconStruct = cdf_mem_malloc(sizeof(tSchBeaconStruct));
473 if (NULL == pBeaconStruct) {
474 lim_log(pMac, LOGE,
475 FL("Unable to allocate memory for creating ADD_BSS"));
476 return eSIR_MEM_ALLOC_FAILED;
477 }
478 /* Package SIR_HAL_ADD_BSS_REQ message parameters */
479 pAddBssParams = cdf_mem_malloc(sizeof(tAddBssParams));
480 if (NULL == pAddBssParams) {
481 cdf_mem_free(pBeaconStruct);
482 lim_log(pMac, LOGP,
483 FL("Unable to allocate memory for creating ADD_BSS"));
484 return (eSIR_MEM_ALLOC_FAILED);
485 }
486
487 cdf_mem_set((uint8_t *) pAddBssParams, sizeof(tAddBssParams), 0);
488
489 lim_extract_ap_capabilities(pMac, (uint8_t *) bssDescription->ieFields,
490 lim_get_ielen_from_bss_description(bssDescription),
491 pBeaconStruct);
492
493 if (pMac->lim.gLimProtectionControl !=
494 WNI_CFG_FORCE_POLICY_PROTECTION_DISABLE)
495 lim_decide_sta_protection_on_assoc(pMac, pBeaconStruct,
496 pftSessionEntry);
497
498 cdf_mem_copy(pAddBssParams->bssId, bssDescription->bssId,
499 sizeof(tSirMacAddr));
500
501 /* Fill in tAddBssParams selfMacAddr */
502 cdf_mem_copy(pAddBssParams->selfMacAddr, pftSessionEntry->selfMacAddr,
503 sizeof(tSirMacAddr));
504
505 pAddBssParams->bssType = pftSessionEntry->bssType;
506 pAddBssParams->operMode = BSS_OPERATIONAL_MODE_STA;
507
508 pAddBssParams->beaconInterval = bssDescription->beaconInterval;
509
510 pAddBssParams->dtimPeriod = pBeaconStruct->tim.dtimPeriod;
511 pAddBssParams->updateBss = updateEntry;
512
513 pAddBssParams->reassocReq = true;
514
515 pAddBssParams->cfParamSet.cfpCount = pBeaconStruct->cfParamSet.cfpCount;
516 pAddBssParams->cfParamSet.cfpPeriod =
517 pBeaconStruct->cfParamSet.cfpPeriod;
518 pAddBssParams->cfParamSet.cfpMaxDuration =
519 pBeaconStruct->cfParamSet.cfpMaxDuration;
520 pAddBssParams->cfParamSet.cfpDurRemaining =
521 pBeaconStruct->cfParamSet.cfpDurRemaining;
522
523 pAddBssParams->rateSet.numRates =
524 pBeaconStruct->supportedRates.numRates;
525 cdf_mem_copy(pAddBssParams->rateSet.rate,
526 pBeaconStruct->supportedRates.rate,
527 pBeaconStruct->supportedRates.numRates);
528
529 pAddBssParams->nwType = bssDescription->nwType;
530
531 pAddBssParams->shortSlotTimeSupported =
532 (uint8_t) pBeaconStruct->capabilityInfo.shortSlotTime;
533 pAddBssParams->llaCoexist =
534 (uint8_t) pftSessionEntry->beaconParams.llaCoexist;
535 pAddBssParams->llbCoexist =
536 (uint8_t) pftSessionEntry->beaconParams.llbCoexist;
537 pAddBssParams->llgCoexist =
538 (uint8_t) pftSessionEntry->beaconParams.llgCoexist;
539 pAddBssParams->ht20Coexist =
540 (uint8_t) pftSessionEntry->beaconParams.ht20Coexist;
541#ifdef WLAN_FEATURE_11W
542 pAddBssParams->rmfEnabled = pftSessionEntry->limRmfEnabled;
543#endif
544
545 /* Use the advertised capabilities from the received beacon/PR */
546 if (IS_DOT11_MODE_HT(pftSessionEntry->dot11mode) &&
547 (pBeaconStruct->HTCaps.present)) {
548 pAddBssParams->htCapable = pBeaconStruct->HTCaps.present;
549 cdf_mem_copy(&pAddBssParams->staContext.capab_info,
550 &pBeaconStruct->capabilityInfo,
551 sizeof(pAddBssParams->staContext.capab_info));
552 cdf_mem_copy(&pAddBssParams->staContext.ht_caps,
553 (uint8_t *) &pBeaconStruct->HTCaps +
554 sizeof(uint8_t),
555 sizeof(pAddBssParams->staContext.ht_caps));
556
557 if (pBeaconStruct->HTInfo.present) {
558 pAddBssParams->htOperMode =
559 (tSirMacHTOperatingMode) pBeaconStruct->HTInfo.
560 opMode;
561 pAddBssParams->dualCTSProtection =
562 (uint8_t) pBeaconStruct->HTInfo.dualCTSProtection;
563
564 chanWidthSupp = lim_get_ht_capability(pMac,
565 eHT_SUPPORTED_CHANNEL_WIDTH_SET,
566 pftSessionEntry);
567 if ((pBeaconStruct->HTCaps.supportedChannelWidthSet) &&
568 (chanWidthSupp)) {
569 pAddBssParams->ch_width = (uint8_t)
570 pBeaconStruct->HTInfo.recommendedTxWidthSet;
571 if (pBeaconStruct->HTInfo.secondaryChannelOffset ==
572 PHY_DOUBLE_CHANNEL_LOW_PRIMARY)
573 pAddBssParams->ch_center_freq_seg0 =
574 bssDescription->channelId + 2;
575 else if (pBeaconStruct->HTInfo.secondaryChannelOffset ==
576 PHY_DOUBLE_CHANNEL_HIGH_PRIMARY)
577 pAddBssParams->ch_center_freq_seg0 =
578 bssDescription->channelId - 2;
579 } else {
580 pAddBssParams->ch_width = CH_WIDTH_20MHZ;
581 pAddBssParams->ch_center_freq_seg0 = 0;
582 }
583 pAddBssParams->llnNonGFCoexist =
584 (uint8_t) pBeaconStruct->HTInfo.nonGFDevicesPresent;
585 pAddBssParams->fLsigTXOPProtectionFullSupport =
586 (uint8_t) pBeaconStruct->HTInfo.
587 lsigTXOPProtectionFullSupport;
588 pAddBssParams->fRIFSMode =
589 pBeaconStruct->HTInfo.rifsMode;
590 }
591 }
592
593 pAddBssParams->currentOperChannel = bssDescription->channelId;
594 pftSessionEntry->htSecondaryChannelOffset =
595 pBeaconStruct->HTInfo.secondaryChannelOffset;
596 sta_ctx = &pAddBssParams->staContext;
597
598#ifdef WLAN_FEATURE_11AC
599 if (pftSessionEntry->vhtCapability &&
600 pftSessionEntry->vhtCapabilityPresentInBeacon) {
601 pAddBssParams->vhtCapable = pBeaconStruct->VHTCaps.present;
602 if (pBeaconStruct->VHTOperation.chanWidth && chanWidthSupp) {
603 pAddBssParams->ch_width =
604 pBeaconStruct->VHTOperation.chanWidth + 1;
605 pAddBssParams->ch_center_freq_seg0 =
606 pBeaconStruct->VHTOperation.chanCenterFreqSeg1;
607 pAddBssParams->ch_center_freq_seg1 =
608 pBeaconStruct->VHTOperation.chanCenterFreqSeg2;
609 }
610 pAddBssParams->staContext.vht_caps =
611 ((pBeaconStruct->VHTCaps.maxMPDULen <<
612 SIR_MAC_VHT_CAP_MAX_MPDU_LEN) |
613 (pBeaconStruct->VHTCaps.supportedChannelWidthSet <<
614 SIR_MAC_VHT_CAP_SUPP_CH_WIDTH_SET) |
615 (pBeaconStruct->VHTCaps.ldpcCodingCap <<
616 SIR_MAC_VHT_CAP_LDPC_CODING_CAP) |
617 (pBeaconStruct->VHTCaps.shortGI80MHz <<
618 SIR_MAC_VHT_CAP_SHORTGI_80MHZ) |
619 (pBeaconStruct->VHTCaps.shortGI160and80plus80MHz <<
620 SIR_MAC_VHT_CAP_SHORTGI_160_80_80MHZ) |
621 (pBeaconStruct->VHTCaps.txSTBC <<
622 SIR_MAC_VHT_CAP_TXSTBC) |
623 (pBeaconStruct->VHTCaps.rxSTBC <<
624 SIR_MAC_VHT_CAP_RXSTBC) |
625 (pBeaconStruct->VHTCaps.suBeamFormerCap <<
626 SIR_MAC_VHT_CAP_SU_BEAMFORMER_CAP) |
627 (pBeaconStruct->VHTCaps.suBeamformeeCap <<
628 SIR_MAC_VHT_CAP_SU_BEAMFORMEE_CAP) |
629 (pBeaconStruct->VHTCaps.csnofBeamformerAntSup <<
630 SIR_MAC_VHT_CAP_CSN_BEAMORMER_ANT_SUP) |
631 (pBeaconStruct->VHTCaps.numSoundingDim <<
632 SIR_MAC_VHT_CAP_NUM_SOUNDING_DIM) |
633 (pBeaconStruct->VHTCaps.muBeamformerCap <<
634 SIR_MAC_VHT_CAP_NUM_BEAM_FORMER_CAP) |
635 (pBeaconStruct->VHTCaps.muBeamformeeCap <<
636 SIR_MAC_VHT_CAP_NUM_BEAM_FORMEE_CAP) |
637 (pBeaconStruct->VHTCaps.vhtTXOPPS <<
638 SIR_MAC_VHT_CAP_TXOPPS) |
639 (pBeaconStruct->VHTCaps.htcVHTCap <<
640 SIR_MAC_VHT_CAP_HTC_CAP) |
641 (pBeaconStruct->VHTCaps.maxAMPDULenExp <<
642 SIR_MAC_VHT_CAP_MAX_AMDU_LEN_EXPO) |
643 (pBeaconStruct->VHTCaps.vhtLinkAdaptCap <<
644 SIR_MAC_VHT_CAP_LINK_ADAPT_CAP) |
645 (pBeaconStruct->VHTCaps.rxAntPattern <<
646 SIR_MAC_VHT_CAP_RX_ANTENNA_PATTERN) |
647 (pBeaconStruct->VHTCaps.txAntPattern <<
648 SIR_MAC_VHT_CAP_TX_ANTENNA_PATTERN) |
649 (pBeaconStruct->VHTCaps.reserved1 <<
650 SIR_MAC_VHT_CAP_RESERVED2));
651 } else {
652 pAddBssParams->vhtCapable = 0;
653 }
654#endif
655
656#if defined WLAN_FEATURE_VOWIFI_11R_DEBUG
657 lim_log(pMac, LOG1, FL("SIR_HAL_ADD_BSS_REQ with channel = %d..."),
658 pAddBssParams->currentOperChannel);
659#endif
660
661 /* Populate the STA-related parameters here */
662 /* Note that the STA here refers to the AP */
663 {
664 pAddBssParams->staContext.staType = STA_ENTRY_OTHER;
665
666 cdf_mem_copy(pAddBssParams->staContext.bssId,
667 bssDescription->bssId, sizeof(tSirMacAddr));
668 pAddBssParams->staContext.listenInterval =
669 bssDescription->beaconInterval;
670
671 pAddBssParams->staContext.assocId = 0;
672 pAddBssParams->staContext.uAPSD = 0;
673 pAddBssParams->staContext.maxSPLen = 0;
674 pAddBssParams->staContext.shortPreambleSupported =
675 (uint8_t) pBeaconStruct->capabilityInfo.shortPreamble;
676 pAddBssParams->staContext.updateSta = updateEntry;
677 pAddBssParams->staContext.encryptType =
678 pftSessionEntry->encryptType;
679#ifdef WLAN_FEATURE_11W
680 pAddBssParams->staContext.rmfEnabled =
681 pftSessionEntry->limRmfEnabled;
682#endif
683
684 if (IS_DOT11_MODE_HT(pftSessionEntry->dot11mode) &&
685 (pBeaconStruct->HTCaps.present)) {
686 pAddBssParams->staContext.us32MaxAmpduDuration = 0;
687 pAddBssParams->staContext.htCapable = 1;
688 pAddBssParams->staContext.greenFieldCapable =
689 (uint8_t) pBeaconStruct->HTCaps.greenField;
690 pAddBssParams->staContext.lsigTxopProtection =
691 (uint8_t) pBeaconStruct->HTCaps.lsigTXOPProtection;
692 if ((pBeaconStruct->HTCaps.supportedChannelWidthSet) &&
693 (chanWidthSupp)) {
694 pAddBssParams->staContext.ch_width = (uint8_t)
695 pBeaconStruct->HTInfo.recommendedTxWidthSet;
696 } else {
697 pAddBssParams->staContext.ch_width =
698 CH_WIDTH_20MHZ;
699 }
700 if (pftSessionEntry->vhtCapability &&
701 IS_BSS_VHT_CAPABLE(pBeaconStruct->VHTCaps)) {
702 pAddBssParams->staContext.vhtCapable = 1;
703 if ((pBeaconStruct->VHTCaps.suBeamFormerCap ||
704 pBeaconStruct->VHTCaps.muBeamformerCap) &&
705 pftSessionEntry->txBFIniFeatureEnabled)
706 sta_ctx->vhtTxBFCapable
707 = 1;
708 if (pBeaconStruct->VHTCaps.suBeamformeeCap &&
709 pftSessionEntry->enable_su_tx_bformer)
710 sta_ctx->enable_su_tx_bformer = 1;
711 }
712 if ((pBeaconStruct->HTCaps.supportedChannelWidthSet) &&
713 (chanWidthSupp)) {
714 sta_ctx->ch_width = (uint8_t)
715 pBeaconStruct->HTInfo.recommendedTxWidthSet;
716 if (pAddBssParams->staContext.vhtCapable &&
717 pBeaconStruct->VHTOperation.chanWidth)
718 sta_ctx->ch_width =
719 pBeaconStruct->VHTOperation.chanWidth
720 + 1;
721 } else {
722 pAddBssParams->staContext.ch_width =
723 CH_WIDTH_20MHZ;
724 }
725 pAddBssParams->staContext.mimoPS =
726 (tSirMacHTMIMOPowerSaveState) pBeaconStruct->HTCaps.
727 mimoPowerSave;
728 pAddBssParams->staContext.maxAmsduSize =
729 (uint8_t) pBeaconStruct->HTCaps.maximalAMSDUsize;
730 pAddBssParams->staContext.maxAmpduDensity =
731 pBeaconStruct->HTCaps.mpduDensity;
732 pAddBssParams->staContext.fDsssCckMode40Mhz =
733 (uint8_t) pBeaconStruct->HTCaps.dsssCckMode40MHz;
734 pAddBssParams->staContext.fShortGI20Mhz =
735 (uint8_t) pBeaconStruct->HTCaps.shortGI20MHz;
736 pAddBssParams->staContext.fShortGI40Mhz =
737 (uint8_t) pBeaconStruct->HTCaps.shortGI40MHz;
738 pAddBssParams->staContext.maxAmpduSize =
739 pBeaconStruct->HTCaps.maxRxAMPDUFactor;
740
741 if (pBeaconStruct->HTInfo.present)
742 pAddBssParams->staContext.rifsMode =
743 pBeaconStruct->HTInfo.rifsMode;
744 }
745
746 if ((pftSessionEntry->limWmeEnabled
747 && pBeaconStruct->wmeEdcaPresent)
748 || (pftSessionEntry->limQosEnabled
749 && pBeaconStruct->edcaPresent))
750 pAddBssParams->staContext.wmmEnabled = 1;
751 else
752 pAddBssParams->staContext.wmmEnabled = 0;
753
754 pAddBssParams->staContext.wpa_rsn = pBeaconStruct->rsnPresent;
755 /* For OSEN Connection AP does not advertise RSN or WPA IE
756 * so from the IEs we get from supplicant we get this info
757 * so for FW to transmit EAPOL message 4 we shall set
758 * wpa_rsn
759 */
760 pAddBssParams->staContext.wpa_rsn |=
761 (pBeaconStruct->wpaPresent << 1);
762 if ((!pAddBssParams->staContext.wpa_rsn)
763 && (pftSessionEntry->isOSENConnection))
764 pAddBssParams->staContext.wpa_rsn = 1;
765 /* Update the rates */
766#ifdef WLAN_FEATURE_11AC
767 lim_populate_peer_rate_set(pMac,
768 &pAddBssParams->staContext.
769 supportedRates,
770 pBeaconStruct->HTCaps.supportedMCSSet,
771 false, pftSessionEntry,
772 &pBeaconStruct->VHTCaps);
773#else
774 lim_populate_peer_rate_set(pMac,
775 &pAddBssParams->staContext.
776 supportedRates,
777 beaconStruct.HTCaps.supportedMCSSet,
778 false, pftSessionEntry);
779#endif
780 if (pftSessionEntry->htCapability) {
781 pAddBssParams->staContext.supportedRates.opRateMode =
782 eSTA_11n;
783 if (pftSessionEntry->vhtCapability)
784 pAddBssParams->staContext.supportedRates.
785 opRateMode = eSTA_11ac;
786 } else {
787 if (pftSessionEntry->limRFBand == SIR_BAND_5_GHZ) {
788 pAddBssParams->staContext.supportedRates.
789 opRateMode = eSTA_11a;
790 } else {
791 pAddBssParams->staContext.supportedRates.
792 opRateMode = eSTA_11bg;
793 }
794 }
795 }
796
797#if defined WLAN_FEATURE_VOWIFI
798 pAddBssParams->maxTxPower = pftSessionEntry->maxTxPower;
799#endif
800
801#ifdef WLAN_FEATURE_11W
802 if (pftSessionEntry->limRmfEnabled) {
803 pAddBssParams->rmfEnabled = 1;
804 pAddBssParams->staContext.rmfEnabled = 1;
805 }
806#endif
807
808 pAddBssParams->status = CDF_STATUS_SUCCESS;
809 pAddBssParams->respReqd = true;
810
811 pAddBssParams->staContext.sessionId = pftSessionEntry->peSessionId;
812 pAddBssParams->staContext.smesessionId = pftSessionEntry->smeSessionId;
813 pAddBssParams->sessionId = pftSessionEntry->peSessionId;
814
815 /* Set a new state for MLME */
816
817 pftSessionEntry->limMlmState = eLIM_MLM_WT_ADD_BSS_RSP_FT_REASSOC_STATE;
818 MTRACE(mac_trace
819 (pMac, TRACE_CODE_MLM_STATE, pftSessionEntry->peSessionId,
820 eLIM_MLM_WT_ADD_BSS_RSP_FT_REASSOC_STATE));
821 pAddBssParams->halPersona = (uint8_t) pftSessionEntry->pePersona;
822
823 pftSessionEntry->ftPEContext.pAddBssReq = pAddBssParams;
824
825#if defined WLAN_FEATURE_VOWIFI_11R_DEBUG
826 lim_log(pMac, LOG1, FL("Saving SIR_HAL_ADD_BSS_REQ for pre-auth ap..."));
827#endif
828
829 cdf_mem_free(pBeaconStruct);
830 return 0;
831}
832
833/*------------------------------------------------------------------
834 *
835 * Setup the new session for the pre-auth AP.
836 * Return the newly created session entry.
837 *
838 *------------------------------------------------------------------*/
839void lim_fill_ft_session(tpAniSirGlobal pMac,
840 tpSirBssDescription pbssDescription,
841 tpPESession pftSessionEntry, tpPESession psessionEntry)
842{
843 uint8_t currentBssUapsd;
844 tPowerdBm localPowerConstraint;
845 tPowerdBm regMax;
846 tSchBeaconStruct *pBeaconStruct;
847 uint32_t selfDot11Mode;
848 ePhyChanBondState cbEnabledMode;
849
850 pBeaconStruct = cdf_mem_malloc(sizeof(tSchBeaconStruct));
851 if (NULL == pBeaconStruct) {
852#if defined WLAN_FEATURE_VOWIFI_11R_DEBUG
853 lim_log(pMac, LOGE,
854 FL
855 ("Unable to allocate memory for creating lim_fill_ft_session"));
856#endif
857 return;
858 }
859
860 /* Retrieve the session that has already been created and update the entry */
861#if defined WLAN_FEATURE_VOWIFI_11R_DEBUG || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
862 lim_print_mac_addr(pMac, pbssDescription->bssId, LOG1);
863#endif
864 pftSessionEntry->limWmeEnabled = psessionEntry->limWmeEnabled;
865 pftSessionEntry->limQosEnabled = psessionEntry->limQosEnabled;
866 pftSessionEntry->limWsmEnabled = psessionEntry->limWsmEnabled;
867 pftSessionEntry->lim11hEnable = psessionEntry->lim11hEnable;
868 pftSessionEntry->isOSENConnection = psessionEntry->isOSENConnection;
869
870 /* Fields to be filled later */
871 pftSessionEntry->pLimJoinReq = NULL;
872 pftSessionEntry->smeSessionId = psessionEntry->smeSessionId;
873 pftSessionEntry->transactionId = 0;
874
875 lim_extract_ap_capabilities(pMac, (uint8_t *) pbssDescription->ieFields,
876 lim_get_ielen_from_bss_description(pbssDescription),
877 pBeaconStruct);
878
879 pftSessionEntry->rateSet.numRates =
880 pBeaconStruct->supportedRates.numRates;
881 cdf_mem_copy(pftSessionEntry->rateSet.rate,
882 pBeaconStruct->supportedRates.rate,
883 pBeaconStruct->supportedRates.numRates);
884
885 pftSessionEntry->extRateSet.numRates =
886 pBeaconStruct->extendedRates.numRates;
887 cdf_mem_copy(pftSessionEntry->extRateSet.rate,
888 pBeaconStruct->extendedRates.rate,
889 pftSessionEntry->extRateSet.numRates);
890
891 pftSessionEntry->ssId.length = pBeaconStruct->ssId.length;
892 cdf_mem_copy(pftSessionEntry->ssId.ssId, pBeaconStruct->ssId.ssId,
893 pftSessionEntry->ssId.length);
894
895 wlan_cfg_get_int(pMac, WNI_CFG_DOT11_MODE, &selfDot11Mode);
896 lim_log(pMac, LOG1, FL("selfDot11Mode %d"), selfDot11Mode);
897 pftSessionEntry->dot11mode = selfDot11Mode;
898 pftSessionEntry->vhtCapability =
899 (IS_DOT11_MODE_VHT(pftSessionEntry->dot11mode)
900 && IS_BSS_VHT_CAPABLE(pBeaconStruct->VHTCaps));
901 pftSessionEntry->htCapability =
902 (IS_DOT11_MODE_HT(pftSessionEntry->dot11mode)
903 && pBeaconStruct->HTCaps.present);
904
905 /* Copy The channel Id to the session Table */
906 pftSessionEntry->limReassocChannelId = pbssDescription->channelId;
907 pftSessionEntry->currentOperChannel = pbssDescription->channelId;
908
909 pftSessionEntry->limRFBand = lim_get_rf_band(
910 pftSessionEntry->currentOperChannel);
911
912 if (pftSessionEntry->limRFBand == SIR_BAND_2_4_GHZ) {
913 cbEnabledMode = pMac->roam.configParam.channelBondingMode24GHz;
914 } else {
915 cbEnabledMode = pMac->roam.configParam.channelBondingMode5GHz;
916 }
917 pftSessionEntry->htSupportedChannelWidthSet =
918 (pBeaconStruct->HTInfo.present) ?
919 (cbEnabledMode && pBeaconStruct->HTInfo.recommendedTxWidthSet) : 0;
920 pftSessionEntry->htRecommendedTxWidthSet =
921 pftSessionEntry->htSupportedChannelWidthSet;
922
923
924#ifdef WLAN_FEATURE_11AC
925 if (IS_BSS_VHT_CAPABLE(pBeaconStruct->VHTCaps) &&
926 pBeaconStruct->VHTOperation.present &&
927 pftSessionEntry->vhtCapability) {
928 pftSessionEntry->vhtCapabilityPresentInBeacon = 1;
929 } else {
930 pftSessionEntry->vhtCapabilityPresentInBeacon = 0;
931 }
932#endif
933 if (pftSessionEntry->htRecommendedTxWidthSet) {
934 pftSessionEntry->ch_width = CH_WIDTH_40MHZ;
935 if (pftSessionEntry->vhtCapabilityPresentInBeacon &&
936 pBeaconStruct->VHTOperation.chanWidth) {
937 pftSessionEntry->ch_width =
938 pBeaconStruct->VHTOperation.chanWidth + 1;
939 pftSessionEntry->ch_center_freq_seg0 =
940 pBeaconStruct->VHTOperation.chanCenterFreqSeg1;
941 pftSessionEntry->ch_center_freq_seg1 =
942 pBeaconStruct->VHTOperation.chanCenterFreqSeg2;
943 } else {
944 if (pBeaconStruct->HTInfo.secondaryChannelOffset ==
945 PHY_DOUBLE_CHANNEL_LOW_PRIMARY)
946 pftSessionEntry->ch_center_freq_seg0 =
947 pbssDescription->channelId + 2;
948 else if (pBeaconStruct->HTInfo.secondaryChannelOffset ==
949 PHY_DOUBLE_CHANNEL_HIGH_PRIMARY)
950 pftSessionEntry->ch_center_freq_seg0 =
951 pbssDescription->channelId - 2;
952 else
953 lim_log(pMac, LOGE, FL("Invalid sec ch offset"));
954 }
955 } else {
956 pftSessionEntry->ch_width = CH_WIDTH_20MHZ;
957 pftSessionEntry->ch_center_freq_seg0 = 0;
958 pftSessionEntry->ch_center_freq_seg1 = 0;
959 }
960
961 sir_copy_mac_addr(pftSessionEntry->selfMacAddr,
962 psessionEntry->selfMacAddr);
963 sir_copy_mac_addr(pftSessionEntry->limReAssocbssId,
964 pbssDescription->bssId);
965 sir_copy_mac_addr(pftSessionEntry->prev_ap_bssid, psessionEntry->bssId);
966#if defined WLAN_FEATURE_VOWIFI_11R_DEBUG || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
967 lim_print_mac_addr(pMac, pftSessionEntry->limReAssocbssId, LOG1);
968#endif
969
970 /* Store beaconInterval */
971 pftSessionEntry->beaconParams.beaconInterval =
972 pbssDescription->beaconInterval;
973 pftSessionEntry->bssType = psessionEntry->bssType;
974
975 pftSessionEntry->statypeForBss = STA_ENTRY_PEER;
976 pftSessionEntry->nwType = pbssDescription->nwType;
977
978
979 if (pftSessionEntry->bssType == eSIR_INFRASTRUCTURE_MODE) {
980 pftSessionEntry->limSystemRole = eLIM_STA_ROLE;
981 } else if (pftSessionEntry->bssType == eSIR_BTAMP_AP_MODE) {
982 pftSessionEntry->limSystemRole = eLIM_BT_AMP_STA_ROLE;
983 } else {
984 /* Throw an error and return and make sure to delete the session. */
985 lim_log(pMac, LOGE, FL("Invalid bss type"));
986 }
987
988 pftSessionEntry->limCurrentBssCaps = pbssDescription->capabilityInfo;
989 pftSessionEntry->limReassocBssCaps = pbssDescription->capabilityInfo;
990 if (pMac->roam.configParam.shortSlotTime &&
991 SIR_MAC_GET_SHORT_SLOT_TIME(pftSessionEntry->limReassocBssCaps)) {
992 pftSessionEntry->shortSlotTimeSupported = true;
993 }
994
995 regMax = cfg_get_regulatory_max_transmit_power(pMac,
996 pftSessionEntry->
997 currentOperChannel);
998 localPowerConstraint = regMax;
999 lim_extract_ap_capability(pMac, (uint8_t *) pbssDescription->ieFields,
1000 lim_get_ielen_from_bss_description(pbssDescription),
1001 &pftSessionEntry->limCurrentBssQosCaps,
1002 &pftSessionEntry->limCurrentBssPropCap, &currentBssUapsd,
1003 &localPowerConstraint, pftSessionEntry);
1004
1005 pftSessionEntry->limReassocBssQosCaps =
1006 pftSessionEntry->limCurrentBssQosCaps;
1007 pftSessionEntry->limReassocBssPropCap =
1008 pftSessionEntry->limCurrentBssPropCap;
1009
1010#ifdef WLAN_FEATURE_VOWIFI_11R
1011 pftSessionEntry->is11Rconnection = psessionEntry->is11Rconnection;
1012#endif
1013#ifdef FEATURE_WLAN_ESE
1014 pftSessionEntry->isESEconnection = psessionEntry->isESEconnection;
1015 pftSessionEntry->is_ese_version_ie_present =
1016 pBeaconStruct->is_ese_ver_ie_present;
1017#endif
1018#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
1019 pftSessionEntry->isFastTransitionEnabled =
1020 psessionEntry->isFastTransitionEnabled;
1021#endif
1022
1023#ifdef FEATURE_WLAN_LFR
1024 pftSessionEntry->isFastRoamIniFeatureEnabled =
1025 psessionEntry->isFastRoamIniFeatureEnabled;
1026#endif
1027
1028#ifdef FEATURE_WLAN_ESE
1029 pftSessionEntry->maxTxPower =
1030 lim_get_max_tx_power(regMax, localPowerConstraint,
1031 pMac->roam.configParam.nTxPowerCap);
1032#else
1033 pftSessionEntry->maxTxPower = CDF_MIN(regMax, (localPowerConstraint));
1034#endif
1035
1036#if defined WLAN_FEATURE_VOWIFI_11R_DEBUG
1037 lim_log(pMac, LOG1,
1038 FL
1039 ("Reg max = %d, local power = %d, ini tx power = %d, max tx = %d"),
1040 regMax, localPowerConstraint, pMac->roam.configParam.nTxPowerCap,
1041 pftSessionEntry->maxTxPower);
1042#endif
1043
1044 pftSessionEntry->limPrevSmeState = pftSessionEntry->limSmeState;
1045 pftSessionEntry->limSmeState = eLIM_SME_WT_REASSOC_STATE;
1046 MTRACE(mac_trace
1047 (pMac, TRACE_CODE_SME_STATE, pftSessionEntry->peSessionId,
1048 pftSessionEntry->limSmeState));
1049
1050 pftSessionEntry->encryptType = psessionEntry->encryptType;
1051#ifdef WLAN_FEATURE_11W
1052 pftSessionEntry->limRmfEnabled = psessionEntry->limRmfEnabled;
1053#endif
1054
1055 cdf_mem_free(pBeaconStruct);
1056}
1057
1058/*------------------------------------------------------------------
1059 *
1060 * Setup the session and the add bss req for the pre-auth AP.
1061 *
1062 *------------------------------------------------------------------*/
1063tSirRetStatus lim_ft_setup_auth_session(tpAniSirGlobal pMac,
1064 tpPESession psessionEntry)
1065{
1066 tpPESession pftSessionEntry = NULL;
1067 uint8_t sessionId = 0;
1068
1069 pftSessionEntry =
1070 pe_find_session_by_bssid(pMac, psessionEntry->limReAssocbssId,
1071 &sessionId);
1072 if (pftSessionEntry == NULL) {
1073 PELOGE(lim_log(pMac, LOGE,
1074 FL
1075 ("Unable to find session for the following bssid"));
1076 )
1077 lim_print_mac_addr(pMac, psessionEntry->limReAssocbssId, LOGE);
1078 return eSIR_FAILURE;
1079 }
1080
1081 /* Nothing to be done if the session is not in STA mode */
1082 if (!LIM_IS_STA_ROLE(psessionEntry)) {
1083#if defined WLAN_FEATURE_VOWIFI_11R_DEBUG
1084 PELOGE(lim_log
1085 (pMac, LOGE, FL("psessionEntry is not in STA mode"));
1086 )
1087#endif
1088 return eSIR_FAILURE;
1089 }
1090
1091 if (psessionEntry->ftPEContext.pFTPreAuthReq &&
1092 psessionEntry->ftPEContext.pFTPreAuthReq->pbssDescription) {
1093 lim_fill_ft_session(pMac,
1094 psessionEntry->ftPEContext.pFTPreAuthReq->
1095 pbssDescription, pftSessionEntry,
1096 psessionEntry);
1097
1098 lim_ft_prepare_add_bss_req(pMac, false, pftSessionEntry,
1099 psessionEntry->ftPEContext.pFTPreAuthReq->
1100 pbssDescription);
1101 }
1102
1103 return eSIR_SUCCESS;
1104}
1105
1106/*------------------------------------------------------------------
1107 * Resume Link Call Back
1108 *------------------------------------------------------------------*/
1109void lim_ft_process_pre_auth_result(tpAniSirGlobal pMac, CDF_STATUS status,
1110 uint32_t *data)
1111{
1112 tpPESession psessionEntry = (tpPESession) data;
1113
1114 if (NULL == psessionEntry ||
1115 NULL == psessionEntry->ftPEContext.pFTPreAuthReq)
1116 return;
1117
1118 /* Nothing to be done if the session is not in STA mode */
1119 if (!LIM_IS_STA_ROLE(psessionEntry)) {
1120#if defined WLAN_FEATURE_VOWIFI_11R_DEBUG
1121 PELOGE(lim_log
1122 (pMac, LOGE, FL("psessionEntry is not in STA mode"));
1123 )
1124#endif
1125 return;
1126 }
1127
1128 if (psessionEntry->ftPEContext.ftPreAuthStatus == eSIR_SUCCESS) {
1129 psessionEntry->ftPEContext.ftPreAuthStatus =
1130 lim_ft_setup_auth_session(pMac, psessionEntry);
1131 }
1132 /* Post the FT Pre Auth Response to SME */
1133 lim_post_ft_pre_auth_rsp(pMac, psessionEntry->ftPEContext.ftPreAuthStatus,
1134 psessionEntry->ftPEContext.saved_auth_rsp,
1135 psessionEntry->ftPEContext.saved_auth_rsp_length,
1136 psessionEntry);
1137}
1138
1139/*------------------------------------------------------------------
1140 * Resume Link Call Back
1141 *------------------------------------------------------------------*/
1142void lim_perform_post_ft_pre_auth_and_channel_change(tpAniSirGlobal pMac,
1143 CDF_STATUS status,
1144 uint32_t *data,
1145 tpPESession psessionEntry)
1146{
1147 /* Set the resume channel to Any valid channel (invalid)
1148 * This will instruct HAL to set it to any previous valid channel.
1149 */
1150 pe_set_resume_channel(pMac, 0, 0);
1151 lim_ft_process_pre_auth_result(pMac, CDF_STATUS_SUCCESS,
1152 (uint32_t *) psessionEntry);
1153}
1154
1155/*
1156 * lim_post_ft_pre_auth_rsp() - post ft pre auth response to SME.
1157 *
1158 * @mac_ctx: global mac ctx
1159 * @status: status code to post in auth rsp
1160 * @auth_rsp: pointer to auth rsp FT ie
1161 * @auth_rsp_length: len of the IE field
1162 * @session: pe session
1163 *
1164 * post pre auth response to SME.
1165 *
1166 * Return: void
1167 */
1168void lim_post_ft_pre_auth_rsp(tpAniSirGlobal mac_ctx,
1169 tSirRetStatus status,
1170 uint8_t *auth_rsp,
1171 uint16_t auth_rsp_length,
1172 tpPESession session)
1173{
1174 tpSirFTPreAuthRsp ft_pre_auth_rsp;
1175 tSirMsgQ mmh_msg;
1176 uint16_t rsp_len = sizeof(tSirFTPreAuthRsp);
1177
1178 ft_pre_auth_rsp = (tpSirFTPreAuthRsp) cdf_mem_malloc(rsp_len);
1179 if (NULL == ft_pre_auth_rsp) {
1180 lim_log(mac_ctx, LOGE, "Failed to allocate memory");
1181 CDF_ASSERT(ft_pre_auth_rsp != NULL);
1182 return;
1183 }
1184 cdf_mem_zero(ft_pre_auth_rsp, rsp_len);
1185
1186#if defined WLAN_FEATURE_VOWIFI_11R_DEBUG
1187 lim_log(mac_ctx, LOG1, FL("Auth Rsp = %p"), ft_pre_auth_rsp);
1188#endif
1189 if (session) {
1190 /* Nothing to be done if the session is not in STA mode */
1191 if (!LIM_IS_STA_ROLE(session)) {
1192#if defined WLAN_FEATURE_VOWIFI_11R_DEBUG
1193 lim_log(mac_ctx, LOGE,
1194 FL("session is not in STA mode"));
1195#endif
1196 cdf_mem_free(ft_pre_auth_rsp);
1197 return;
1198 }
1199 ft_pre_auth_rsp->smeSessionId = session->smeSessionId;
1200 /* The bssid of the AP we are sending Auth1 to. */
1201 if (session->ftPEContext.pFTPreAuthReq)
1202 sir_copy_mac_addr(ft_pre_auth_rsp->preAuthbssId,
1203 session->ftPEContext.pFTPreAuthReq->preAuthbssId);
1204 }
1205
1206 ft_pre_auth_rsp->messageType = eWNI_SME_FT_PRE_AUTH_RSP;
1207 ft_pre_auth_rsp->length = (uint16_t) rsp_len;
1208 ft_pre_auth_rsp->status = status;
1209
1210 /* Attach the auth response now back to SME */
1211 ft_pre_auth_rsp->ft_ies_length = 0;
1212 if ((auth_rsp != NULL) && (auth_rsp_length < MAX_FTIE_SIZE)) {
1213 /* Only 11r assoc has FT IEs */
1214 cdf_mem_copy(ft_pre_auth_rsp->ft_ies,
1215 auth_rsp, auth_rsp_length);
1216 ft_pre_auth_rsp->ft_ies_length = auth_rsp_length;
1217 }
1218
1219 if (status != eSIR_SUCCESS) {
1220 /*
1221 * Ensure that on Pre-Auth failure the cached Pre-Auth Req and
1222 * other allocated memory is freed up before returning.
1223 */
1224 lim_log(mac_ctx, LOG1, "Pre-Auth Failed, Cleanup!");
1225 lim_ft_cleanup(mac_ctx, session);
1226 }
1227
1228 mmh_msg.type = ft_pre_auth_rsp->messageType;
1229 mmh_msg.bodyptr = ft_pre_auth_rsp;
1230 mmh_msg.bodyval = 0;
1231
1232#if defined WLAN_FEATURE_VOWIFI_11R_DEBUG
1233 lim_log(mac_ctx, LOG1, FL("Posted Auth Rsp to SME with status of 0x%x"),
1234 status);
1235#endif
1236#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
1237 if (status == eSIR_SUCCESS)
1238 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_PREAUTH_DONE,
1239 session, status, 0);
1240#endif
1241 lim_sys_process_mmh_msg_api(mac_ctx, &mmh_msg, ePROT);
1242}
1243
1244/*------------------------------------------------------------------
1245 *
1246 * Send the FT Pre Auth Response to SME whenever we have a status
1247 * ready to be sent to SME
1248 *
1249 * SME will be the one to send it up to the supplicant to receive
1250 * FTIEs which will be required for Reassoc Req.
1251 *
1252 *------------------------------------------------------------------*/
1253void lim_handle_ft_pre_auth_rsp(tpAniSirGlobal pMac, tSirRetStatus status,
1254 uint8_t *auth_rsp, uint16_t auth_rsp_length,
1255 tpPESession psessionEntry)
1256{
1257 tpPESession pftSessionEntry = NULL;
1258 uint8_t sessionId = 0;
1259 tpSirBssDescription pbssDescription = NULL;
1260#ifdef FEATURE_WLAN_DIAG_SUPPORT
1261 lim_diag_event_report(pMac, WLAN_PE_DIAG_PRE_AUTH_RSP_EVENT,
1262 psessionEntry, (uint16_t) status, 0);
1263#endif
1264
1265 /* Nothing to be done if the session is not in STA mode */
1266 if (!LIM_IS_STA_ROLE(psessionEntry)) {
1267#if defined WLAN_FEATURE_VOWIFI_11R_DEBUG
1268 PELOGE(lim_log
1269 (pMac, LOGE, FL("psessionEntry is not in STA mode"));
1270 )
1271#endif
1272 return;
1273 }
1274
1275 /* Save the status of pre-auth */
1276 psessionEntry->ftPEContext.ftPreAuthStatus = status;
1277
1278 /* Save the auth rsp, so we can send it to
1279 * SME once we resume link
1280 */
1281 psessionEntry->ftPEContext.saved_auth_rsp_length = 0;
1282 if ((auth_rsp != NULL) && (auth_rsp_length < MAX_FTIE_SIZE)) {
1283 cdf_mem_copy(psessionEntry->ftPEContext.saved_auth_rsp,
1284 auth_rsp, auth_rsp_length);
1285 psessionEntry->ftPEContext.saved_auth_rsp_length =
1286 auth_rsp_length;
1287 }
1288
1289 if (!psessionEntry->ftPEContext.pFTPreAuthReq ||
1290 !psessionEntry->ftPEContext.pFTPreAuthReq->pbssDescription) {
1291 lim_log(pMac, LOGE,
1292 FL("pFTPreAuthReq or pbssDescription is NULL"));
1293 return;
1294 }
1295
1296 /* Create FT session for the re-association at this point */
1297 if (psessionEntry->ftPEContext.ftPreAuthStatus == eSIR_SUCCESS) {
1298 pbssDescription =
1299 psessionEntry->ftPEContext.pFTPreAuthReq->pbssDescription;
1300 lim_print_mac_addr(pMac, pbssDescription->bssId, LOG1);
1301 if ((pftSessionEntry =
1302 pe_create_session(pMac, pbssDescription->bssId,
1303 &sessionId, pMac->lim.maxStation,
1304 psessionEntry->bssType)) == NULL) {
1305 lim_log(pMac, LOGE, FL(
1306 "Session not created for pre-auth 11R AP"));
1307 status = eSIR_FAILURE;
1308 psessionEntry->ftPEContext.ftPreAuthStatus = status;
1309 goto send_rsp;
1310 }
1311 pftSessionEntry->peSessionId = sessionId;
1312 pftSessionEntry->smeSessionId = psessionEntry->smeSessionId;
1313 sir_copy_mac_addr(pftSessionEntry->selfMacAddr,
1314 psessionEntry->selfMacAddr);
1315 sir_copy_mac_addr(pftSessionEntry->limReAssocbssId,
1316 pbssDescription->bssId);
1317 pftSessionEntry->bssType = psessionEntry->bssType;
1318
1319 if (pftSessionEntry->bssType == eSIR_INFRASTRUCTURE_MODE) {
1320 pftSessionEntry->limSystemRole = eLIM_STA_ROLE;
1321 } else if (pftSessionEntry->bssType == eSIR_BTAMP_AP_MODE) {
1322 pftSessionEntry->limSystemRole = eLIM_BT_AMP_STA_ROLE;
1323 } else {
1324 lim_log(pMac, LOGE, FL("Invalid bss type"));
1325 }
1326 pftSessionEntry->limPrevSmeState = pftSessionEntry->limSmeState;
1327 cdf_mem_copy(&(pftSessionEntry->htConfig),
1328 &(psessionEntry->htConfig),
1329 sizeof(psessionEntry->htConfig));
1330 pftSessionEntry->limSmeState = eLIM_SME_WT_REASSOC_STATE;
1331
1332 PELOGE(lim_log
1333 (pMac, LOG1, "%s:created session (%p) with id = %d",
1334 __func__, pftSessionEntry,
1335 pftSessionEntry->peSessionId);
1336 )
1337
1338 /* Update the ReAssoc BSSID of the current session */
1339 sir_copy_mac_addr(psessionEntry->limReAssocbssId,
1340 pbssDescription->bssId);
1341 lim_print_mac_addr(pMac, psessionEntry->limReAssocbssId, LOG1);
1342 }
1343send_rsp:
1344 if (psessionEntry->currentOperChannel !=
1345 psessionEntry->ftPEContext.pFTPreAuthReq->preAuthchannelNum) {
1346 /* Need to move to the original AP channel */
1347 lim_change_channel_with_callback(pMac,
1348 psessionEntry->currentOperChannel,
1349 lim_perform_post_ft_pre_auth_and_channel_change,
1350 NULL, psessionEntry);
1351 } else {
1352#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
1353 PELOGE(lim_log(pMac, LOG1,
1354 "Pre auth on same channel as connected AP channel %d",
1355 psessionEntry->ftPEContext.pFTPreAuthReq->
1356 preAuthchannelNum);
1357 )
1358#endif
1359 lim_ft_process_pre_auth_result(pMac, status,
1360 (uint32_t *) psessionEntry);
1361 }
1362}
1363
1364/*------------------------------------------------------------------
1365 *
1366 * This function handles the 11R Reassoc Req from SME
1367 *
1368 *------------------------------------------------------------------*/
1369void lim_process_mlm_ft_reassoc_req(tpAniSirGlobal pMac, uint32_t *pMsgBuf,
1370 tpPESession psessionEntry)
1371{
1372 uint8_t smeSessionId = 0;
1373 uint16_t transactionId = 0;
1374 uint8_t chanNum = 0;
1375 tLimMlmReassocReq *pMlmReassocReq;
1376 uint16_t caps;
1377 uint32_t val;
1378 tSirMsgQ msgQ;
1379 tSirRetStatus retCode;
1380 uint32_t teleBcnEn = 0;
1381
1382 chanNum = psessionEntry->currentOperChannel;
1383 lim_get_session_info(pMac, (uint8_t *) pMsgBuf, &smeSessionId,
1384 &transactionId);
1385 psessionEntry->smeSessionId = smeSessionId;
1386 psessionEntry->transactionId = transactionId;
1387
1388#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
1389 lim_diag_event_report(pMac, WLAN_PE_DIAG_REASSOCIATING, psessionEntry, 0,
1390 0);
1391#endif
1392
1393 /* Nothing to be done if the session is not in STA mode */
1394 if (!LIM_IS_STA_ROLE(psessionEntry)) {
1395#if defined WLAN_FEATURE_VOWIFI_11R_DEBUG
1396 PELOGE(lim_log
1397 (pMac, LOGE, FL("psessionEntry is not in STA mode"));
1398 )
1399#endif
1400 return;
1401 }
1402
1403 if (NULL == psessionEntry->ftPEContext.pAddBssReq) {
1404 lim_log(pMac, LOGE, FL("pAddBssReq is NULL"));
1405 return;
1406 }
1407 pMlmReassocReq = cdf_mem_malloc(sizeof(tLimMlmReassocReq));
1408 if (NULL == pMlmReassocReq) {
1409 lim_log(pMac, LOGE,
1410 FL("call to AllocateMemory failed for mlmReassocReq"));
1411 return;
1412 }
1413
1414 cdf_mem_copy(pMlmReassocReq->peerMacAddr,
1415 psessionEntry->bssId, sizeof(tSirMacAddr));
1416
1417 if (wlan_cfg_get_int(pMac, WNI_CFG_REASSOCIATION_FAILURE_TIMEOUT,
1418 (uint32_t *) &pMlmReassocReq->reassocFailureTimeout)
1419 != eSIR_SUCCESS) {
1420 /**
1421 * Could not get ReassocFailureTimeout value
1422 * from CFG. Log error.
1423 */
1424 lim_log(pMac, LOGE,
1425 FL("could not retrieve ReassocFailureTimeout value"));
1426 cdf_mem_free(pMlmReassocReq);
1427 return;
1428 }
1429
1430 if (cfg_get_capability_info(pMac, &caps, psessionEntry) != eSIR_SUCCESS) {
1431 /**
1432 * Could not get Capabilities value
1433 * from CFG. Log error.
1434 */
1435 lim_log(pMac, LOGE, FL("could not retrieve Capabilities value"));
1436 cdf_mem_free(pMlmReassocReq);
1437 return;
1438 }
1439 pMlmReassocReq->capabilityInfo = caps;
1440
1441 /* Update PE sessionId */
1442 pMlmReassocReq->sessionId = psessionEntry->peSessionId;
1443
1444 /* If telescopic beaconing is enabled, set listen interval
1445 to WNI_CFG_TELE_BCN_MAX_LI
1446 */
1447 if (wlan_cfg_get_int(pMac, WNI_CFG_TELE_BCN_WAKEUP_EN, &teleBcnEn) !=
1448 eSIR_SUCCESS) {
1449 lim_log(pMac, LOGP,
1450 FL("Couldn't get WNI_CFG_TELE_BCN_WAKEUP_EN"));
1451 cdf_mem_free(pMlmReassocReq);
1452 return;
1453 }
1454
1455 if (teleBcnEn) {
1456 if (wlan_cfg_get_int(pMac, WNI_CFG_TELE_BCN_MAX_LI, &val) !=
1457 eSIR_SUCCESS) {
1458 /**
1459 * Could not get ListenInterval value
1460 * from CFG. Log error.
1461 */
1462 lim_log(pMac, LOGE,
1463 FL("could not retrieve ListenInterval"));
1464 cdf_mem_free(pMlmReassocReq);
1465 return;
1466 }
1467 } else {
1468 if (wlan_cfg_get_int(pMac, WNI_CFG_LISTEN_INTERVAL, &val) !=
1469 eSIR_SUCCESS) {
1470 /**
1471 * Could not get ListenInterval value
1472 * from CFG. Log error.
1473 */
1474 lim_log(pMac, LOGE,
1475 FL("could not retrieve ListenInterval"));
1476 cdf_mem_free(pMlmReassocReq);
1477 return;
1478 }
1479 }
1480 if (lim_set_link_state
1481 (pMac, eSIR_LINK_PREASSOC_STATE, psessionEntry->bssId,
1482 psessionEntry->selfMacAddr, NULL, NULL) != eSIR_SUCCESS) {
1483 cdf_mem_free(pMlmReassocReq);
1484 return;
1485 }
1486
1487 pMlmReassocReq->listenInterval = (uint16_t) val;
1488 psessionEntry->pLimMlmReassocReq = pMlmReassocReq;
1489
1490 /* we need to defer the message until we get the response back from HAL */
1491 SET_LIM_PROCESS_DEFD_MESGS(pMac, false);
1492
1493 msgQ.type = SIR_HAL_ADD_BSS_REQ;
1494 msgQ.reserved = 0;
1495 msgQ.bodyptr = psessionEntry->ftPEContext.pAddBssReq;
1496 msgQ.bodyval = 0;
1497
1498#if defined WLAN_FEATURE_VOWIFI_11R_DEBUG
1499 lim_log(pMac, LOG1, FL("Sending SIR_HAL_ADD_BSS_REQ..."));
1500#endif
1501 MTRACE(mac_trace_msg_tx(pMac, psessionEntry->peSessionId, msgQ.type));
1502 retCode = wma_post_ctrl_msg(pMac, &msgQ);
1503 if (eSIR_SUCCESS != retCode) {
1504 cdf_mem_free(psessionEntry->ftPEContext.pAddBssReq);
1505 lim_log(pMac, LOGE,
1506 FL("Posting ADD_BSS_REQ to HAL failed, reason=%X"),
1507 retCode);
1508 }
1509
1510 psessionEntry->ftPEContext.pAddBssReq = NULL;
1511 return;
1512}
1513
1514/*
1515 * lim_process_ft_preauth_rsp_timeout() - process ft preauth rsp timeout
1516 *
1517 * @mac_ctx: global mac ctx
1518 *
1519 * This function is called if preauth response is not received from the AP
1520 * within this timeout while FT in progress
1521 *
1522 * Return: void
1523 */
1524void lim_process_ft_preauth_rsp_timeout(tpAniSirGlobal mac_ctx)
1525{
1526 tpPESession session;
1527
1528 /*
1529 * We have failed pre auth. We need to resume link and get back on
1530 * home channel
1531 */
1532 lim_log(mac_ctx, LOGE, FL("FT Pre-Auth Time Out!!!!"));
1533 session = pe_find_session_by_session_id(mac_ctx,
1534 mac_ctx->lim.limTimers.gLimFTPreAuthRspTimer.sessionId);
1535 if (NULL == session) {
1536 lim_log(mac_ctx, LOGE,
1537 FL("Session Does not exist for given sessionID"));
1538 return;
1539 }
1540
1541 /* Nothing to be done if the session is not in STA mode */
1542 if (!LIM_IS_STA_ROLE(session)) {
1543#if defined WLAN_FEATURE_VOWIFI_11R_DEBUG
1544 lim_log(mac_ctx, LOGE, FL("session is not in STA mode"));
1545#endif
1546 return;
1547 }
1548
1549 /* Reset the flag to indicate preauth request session */
1550 session->ftPEContext.ftPreAuthSession = false;
1551
1552 if (NULL == session->ftPEContext.pFTPreAuthReq) {
1553 lim_log(mac_ctx, LOGE,
1554 FL("pFTPreAuthReq is NULL. Auth Rsp might already be posted to SME and ftcleanup done! sessionId:%d"),
1555 mac_ctx->lim.limTimers.gLimFTPreAuthRspTimer.sessionId);
1556 return;
1557 }
1558
1559 /*
1560 * To handle the race condition where we recieve preauth rsp after
1561 * timer has expired.
1562 */
1563 if (true ==
1564 session->ftPEContext.pFTPreAuthReq->bPreAuthRspProcessed) {
1565 lim_log(mac_ctx, LOGE,
1566 FL("Auth rsp already posted to SME (session %p)"),
1567 session);
1568 return;
1569 } else {
1570 /*
1571 * Here we are sending preauth rsp with failure state
1572 * and which is forwarded to SME. Now, if we receive an preauth
1573 * resp from AP with success it would create a FT pesession, but
1574 * will be dropped in SME leaving behind the pesession. Mark
1575 * Preauth rsp processed so that any rsp from AP is dropped in
1576 * lim_process_auth_frame_no_session.
1577 */
1578 lim_log(mac_ctx, LOG1,
1579 FL("Auth rsp not yet posted to SME (session %p)"),
1580 session);
1581 session->ftPEContext.pFTPreAuthReq->bPreAuthRspProcessed = true;
1582 }
1583
1584 /*
1585 * Attempted at Pre-Auth and failed. If we are off channel. We need
1586 * to get back to home channel
1587 */
1588 lim_handle_ft_pre_auth_rsp(mac_ctx, eSIR_FAILURE, NULL, 0, session);
1589}
1590
1591/*------------------------------------------------------------------
1592 *
1593 * This function is called to process the update key request from SME
1594 *
1595 *------------------------------------------------------------------*/
1596bool lim_process_ft_update_key(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
1597{
1598 tAddBssParams *pAddBssParams;
1599 tSirFTUpdateKeyInfo *pKeyInfo;
1600 uint32_t val = 0;
1601 tpPESession psessionEntry;
1602 uint8_t sessionId;
1603
1604 /* Sanity Check */
1605 if (pMac == NULL || pMsgBuf == NULL) {
1606 return false;
1607 }
1608
1609 pKeyInfo = (tSirFTUpdateKeyInfo *) pMsgBuf;
1610
Srinivas Girigowdaf9d9dd42015-12-04 13:53:58 -08001611 psessionEntry = pe_find_session_by_bssid(pMac, pKeyInfo->bssid.bytes,
1612 &sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001613 if (NULL == psessionEntry) {
1614 PELOGE(lim_log(pMac, LOGE,
1615 "%s: Unable to find session for the following bssid",
1616 __func__);
1617 )
Srinivas Girigowdaf9d9dd42015-12-04 13:53:58 -08001618 lim_print_mac_addr(pMac, pKeyInfo->bssid.bytes, LOGE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001619 return false;
1620 }
1621
1622 /* Nothing to be done if the session is not in STA mode */
1623 if (!LIM_IS_STA_ROLE(psessionEntry)) {
1624#if defined WLAN_FEATURE_VOWIFI_11R_DEBUG
1625 PELOGE(lim_log
1626 (pMac, LOGE, FL("psessionEntry is not in STA mode"));
1627 )
1628#endif
1629 return false;
1630 }
1631
1632 if (NULL == psessionEntry->ftPEContext.pAddBssReq) {
1633 /* AddBss Req is NULL, save the keys to configure them later. */
1634 tpLimMlmSetKeysReq pMlmSetKeysReq =
1635 &psessionEntry->ftPEContext.PreAuthKeyInfo.
1636 extSetStaKeyParam;
1637
1638 cdf_mem_zero(pMlmSetKeysReq, sizeof(tLimMlmSetKeysReq));
Srinivas Girigowdaf9d9dd42015-12-04 13:53:58 -08001639 cdf_copy_macaddr(&pMlmSetKeysReq->peer_macaddr,
1640 &pKeyInfo->bssid);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001641 pMlmSetKeysReq->sessionId = psessionEntry->peSessionId;
1642 pMlmSetKeysReq->smesessionId = psessionEntry->smeSessionId;
1643 pMlmSetKeysReq->edType = pKeyInfo->keyMaterial.edType;
1644 pMlmSetKeysReq->numKeys = pKeyInfo->keyMaterial.numKeys;
1645 cdf_mem_copy((uint8_t *) &pMlmSetKeysReq->key,
1646 (uint8_t *) &pKeyInfo->keyMaterial.key,
1647 sizeof(tSirKeys));
1648
1649 psessionEntry->ftPEContext.PreAuthKeyInfo.
1650 extSetStaKeyParamValid = true;
1651
1652 lim_log(pMac, LOGE, FL("pAddBssReq is NULL"));
1653
1654 if (psessionEntry->ftPEContext.pAddStaReq == NULL) {
1655 lim_log(pMac, LOGE, FL("pAddStaReq is NULL"));
1656 lim_send_set_sta_key_req(pMac, pMlmSetKeysReq, 0, 0,
1657 psessionEntry, false);
1658 psessionEntry->ftPEContext.PreAuthKeyInfo.
1659 extSetStaKeyParamValid = false;
1660 }
1661 } else {
1662 pAddBssParams = psessionEntry->ftPEContext.pAddBssReq;
1663
1664 /* Store the key information in the ADD BSS parameters */
1665 pAddBssParams->extSetStaKeyParamValid = 1;
1666 pAddBssParams->extSetStaKeyParam.encType =
1667 pKeyInfo->keyMaterial.edType;
1668 cdf_mem_copy((uint8_t *) &pAddBssParams->extSetStaKeyParam.key,
1669 (uint8_t *) &pKeyInfo->keyMaterial.key,
1670 sizeof(tSirKeys));
1671 if (eSIR_SUCCESS !=
1672 wlan_cfg_get_int(pMac, WNI_CFG_SINGLE_TID_RC, &val)) {
1673 lim_log(pMac, LOGP,
1674 FL("Unable to read WNI_CFG_SINGLE_TID_RC"));
1675 }
1676
1677 pAddBssParams->extSetStaKeyParam.singleTidRc = val;
1678 PELOG1(lim_log(pMac, LOG1, FL("Key valid %d"),
1679 pAddBssParams->extSetStaKeyParamValid,
1680 pAddBssParams->extSetStaKeyParam.key[0].
1681 keyLength);
1682 )
1683
1684 pAddBssParams->extSetStaKeyParam.staIdx = 0;
1685
1686 PELOG1(lim_log(pMac, LOG1,
1687 FL("BSSID = " MAC_ADDRESS_STR),
Srinivas Girigowdaf9d9dd42015-12-04 13:53:58 -08001688 MAC_ADDR_ARRAY(pKeyInfo->bssid.bytes));)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001689
Srinivas Girigowdaf9d9dd42015-12-04 13:53:58 -08001690 cdf_copy_macaddr(&pAddBssParams->extSetStaKeyParam.peer_macaddr,
1691 &pKeyInfo->bssid);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001692
1693 pAddBssParams->extSetStaKeyParam.sendRsp = false;
1694
1695 if (pAddBssParams->extSetStaKeyParam.key[0].keyLength == 16) {
1696 PELOG1(lim_log(pMac, LOG1,
1697 FL
1698 ("BSS key = %02X-%02X-%02X-%02X-%02X-%02X-%02X- "
1699 "%02X-%02X-%02X-%02X-%02X-%02X-%02X-%02X-%02X"),
1700 pAddBssParams->extSetStaKeyParam.key[0].
1701 key[0],
1702 pAddBssParams->extSetStaKeyParam.key[0].
1703 key[1],
1704 pAddBssParams->extSetStaKeyParam.key[0].
1705 key[2],
1706 pAddBssParams->extSetStaKeyParam.key[0].
1707 key[3],
1708 pAddBssParams->extSetStaKeyParam.key[0].
1709 key[4],
1710 pAddBssParams->extSetStaKeyParam.key[0].
1711 key[5],
1712 pAddBssParams->extSetStaKeyParam.key[0].
1713 key[6],
1714 pAddBssParams->extSetStaKeyParam.key[0].
1715 key[7],
1716 pAddBssParams->extSetStaKeyParam.key[0].
1717 key[8],
1718 pAddBssParams->extSetStaKeyParam.key[0].
1719 key[9],
1720 pAddBssParams->extSetStaKeyParam.key[0].
1721 key[10],
1722 pAddBssParams->extSetStaKeyParam.key[0].
1723 key[11],
1724 pAddBssParams->extSetStaKeyParam.key[0].
1725 key[12],
1726 pAddBssParams->extSetStaKeyParam.key[0].
1727 key[13],
1728 pAddBssParams->extSetStaKeyParam.key[0].
1729 key[14],
1730 pAddBssParams->extSetStaKeyParam.key[0].
1731 key[15]);
1732 )
1733 }
1734 }
1735 return true;
1736}
1737
1738void
1739lim_ft_send_aggr_qos_rsp(tpAniSirGlobal pMac, uint8_t rspReqd,
1740 tpAggrAddTsParams aggrQosRsp, uint8_t smesessionId)
1741{
1742 tpSirAggrQosRsp rsp;
1743 int i = 0;
1744 if (!rspReqd) {
1745 return;
1746 }
1747 rsp = cdf_mem_malloc(sizeof(tSirAggrQosRsp));
1748 if (NULL == rsp) {
1749 lim_log(pMac, LOGP,
1750 FL("AllocateMemory failed for tSirAggrQosRsp"));
1751 return;
1752 }
1753 cdf_mem_set((uint8_t *) rsp, sizeof(*rsp), 0);
1754 rsp->messageType = eWNI_SME_FT_AGGR_QOS_RSP;
1755 rsp->sessionId = smesessionId;
1756 rsp->length = sizeof(*rsp);
1757 rsp->aggrInfo.tspecIdx = aggrQosRsp->tspecIdx;
1758 for (i = 0; i < SIR_QOS_NUM_AC_MAX; i++) {
1759 if ((1 << i) & aggrQosRsp->tspecIdx) {
1760 rsp->aggrInfo.aggrRsp[i].status = aggrQosRsp->status[i];
1761 rsp->aggrInfo.aggrRsp[i].tspec = aggrQosRsp->tspec[i];
1762 }
1763 }
1764 lim_send_sme_aggr_qos_rsp(pMac, rsp, smesessionId);
1765 return;
1766}
1767void lim_process_ft_aggr_qo_s_rsp(tpAniSirGlobal pMac, tpSirMsgQ limMsg)
1768{
1769 tpAggrAddTsParams pAggrQosRspMsg = NULL;
1770 tAddTsParams addTsParam = { 0 };
1771 tpDphHashNode pSta = NULL;
1772 uint16_t assocId = 0;
1773 tSirMacAddr peerMacAddr;
1774 uint8_t rspReqd = 1;
1775 tpPESession psessionEntry = NULL;
1776 int i = 0;
1777 PELOG1(lim_log(pMac, LOG1, FL(" Received AGGR_QOS_RSP from HAL"));)
1778 SET_LIM_PROCESS_DEFD_MESGS(pMac, true);
1779 pAggrQosRspMsg = (tpAggrAddTsParams) (limMsg->bodyptr);
1780 if (NULL == pAggrQosRspMsg) {
1781 PELOGE(lim_log(pMac, LOGE, FL("NULL pAggrQosRspMsg"));)
1782 return;
1783 }
1784 psessionEntry =
1785 pe_find_session_by_session_id(pMac, pAggrQosRspMsg->sessionId);
1786 if (NULL == psessionEntry) {
1787 PELOGE(lim_log(pMac, LOGE,
1788 FL("Cant find session entry for %s"), __func__);
1789 )
1790 if (pAggrQosRspMsg != NULL) {
1791 cdf_mem_free(pAggrQosRspMsg);
1792 }
1793 return;
1794 }
1795 if (!LIM_IS_STA_ROLE(psessionEntry)) {
1796#if defined WLAN_FEATURE_VOWIFI_11R_DEBUG
1797 PELOGE(lim_log
1798 (pMac, LOGE, FL("psessionEntry is not in STA mode"));
1799 )
1800#endif
1801 return;
1802 }
1803 for (i = 0; i < HAL_QOS_NUM_AC_MAX; i++) {
1804 if ((((1 << i) & pAggrQosRspMsg->tspecIdx)) &&
1805 (pAggrQosRspMsg->status[i] != CDF_STATUS_SUCCESS)) {
1806 sir_copy_mac_addr(peerMacAddr, psessionEntry->bssId);
1807 addTsParam.staIdx = pAggrQosRspMsg->staIdx;
1808 addTsParam.sessionId = pAggrQosRspMsg->sessionId;
1809 addTsParam.tspec = pAggrQosRspMsg->tspec[i];
1810 addTsParam.tspecIdx = pAggrQosRspMsg->tspecIdx;
1811 lim_send_delts_req_action_frame(pMac, peerMacAddr, rspReqd,
1812 &addTsParam.tspec.tsinfo,
1813 &addTsParam.tspec,
1814 psessionEntry);
1815 pSta =
1816 dph_lookup_assoc_id(pMac, addTsParam.staIdx, &assocId,
1817 &psessionEntry->dph.dphHashTable);
1818 if (pSta != NULL) {
1819 lim_admit_control_delete_ts(pMac, assocId,
1820 &addTsParam.tspec.
1821 tsinfo, NULL,
1822 (uint8_t *) &
1823 addTsParam.tspecIdx);
1824 }
1825 }
1826 }
1827 lim_ft_send_aggr_qos_rsp(pMac, rspReqd, pAggrQosRspMsg,
1828 psessionEntry->smeSessionId);
1829 if (pAggrQosRspMsg != NULL) {
1830 cdf_mem_free(pAggrQosRspMsg);
1831 }
1832 return;
1833}
1834tSirRetStatus lim_process_ft_aggr_qos_req(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
1835{
1836 tSirMsgQ msg;
1837 tSirAggrQosReq *aggrQosReq = (tSirAggrQosReq *) pMsgBuf;
1838 tpAggrAddTsParams pAggrAddTsParam;
1839 tpPESession psessionEntry = NULL;
1840 tpLimTspecInfo tspecInfo;
1841 uint8_t ac;
1842 tpDphHashNode pSta;
1843 uint16_t aid;
1844 uint8_t sessionId;
1845 int i;
1846
1847 pAggrAddTsParam = cdf_mem_malloc(sizeof(tAggrAddTsParams));
1848 if (NULL == pAggrAddTsParam) {
1849 PELOGE(lim_log(pMac, LOGE, FL("AllocateMemory() failed"));)
1850 return eSIR_MEM_ALLOC_FAILED;
1851 }
1852
Srinivas Girigowda99faf482015-12-03 19:06:15 -08001853 psessionEntry = pe_find_session_by_bssid(pMac, aggrQosReq->bssid.bytes,
1854 &sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001855
1856 if (psessionEntry == NULL) {
1857 PELOGE(lim_log
1858 (pMac, LOGE,
1859 FL("psession Entry Null for sessionId = %d"),
1860 aggrQosReq->sessionId);
1861 )
1862 cdf_mem_free(pAggrAddTsParam);
1863 return eSIR_FAILURE;
1864 }
1865
1866 /* Nothing to be done if the session is not in STA mode */
1867 if (!LIM_IS_STA_ROLE(psessionEntry)) {
1868#if defined WLAN_FEATURE_VOWIFI_11R_DEBUG
1869 PELOGE(lim_log
1870 (pMac, LOGE, FL("psessionEntry is not in STA mode"));
1871 )
1872#endif
1873 cdf_mem_free(pAggrAddTsParam);
1874 return eSIR_FAILURE;
1875 }
1876
Srinivas Girigowda99faf482015-12-03 19:06:15 -08001877 pSta = dph_lookup_hash_entry(pMac, aggrQosReq->bssid.bytes, &aid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001878 &psessionEntry->dph.dphHashTable);
1879 if (pSta == NULL) {
1880 PELOGE(lim_log(pMac, LOGE,
1881 FL
1882 ("Station context not found - ignoring AddTsRsp"));
1883 )
1884 cdf_mem_free(pAggrAddTsParam);
1885 return eSIR_FAILURE;
1886 }
1887
1888 cdf_mem_set((uint8_t *) pAggrAddTsParam, sizeof(tAggrAddTsParams), 0);
1889 pAggrAddTsParam->staIdx = psessionEntry->staId;
1890 /* Fill in the sessionId specific to PE */
1891 pAggrAddTsParam->sessionId = sessionId;
1892 pAggrAddTsParam->tspecIdx = aggrQosReq->aggrInfo.tspecIdx;
1893
1894 for (i = 0; i < HAL_QOS_NUM_AC_MAX; i++) {
1895 if (aggrQosReq->aggrInfo.tspecIdx & (1 << i)) {
1896 tSirMacTspecIE *pTspec =
1897 &aggrQosReq->aggrInfo.aggrAddTsInfo[i].tspec;
1898 /* Since AddTS response was successful, check for the PSB flag
1899 * and directional flag inside the TS Info field.
1900 * An AC is trigger enabled AC if the PSB subfield is set to 1
1901 * in the uplink direction.
1902 * An AC is delivery enabled AC if the PSB subfield is set to 1
1903 * in the downlink direction.
1904 * An AC is trigger and delivery enabled AC if the PSB subfield
1905 * is set to 1 in the bi-direction field.
1906 */
1907 if (pTspec->tsinfo.traffic.psb == 1) {
1908 lim_set_tspec_uapsd_mask_per_session(pMac,
1909 psessionEntry,
1910 &pTspec->
1911 tsinfo,
1912 SET_UAPSD_MASK);
1913 } else {
1914 lim_set_tspec_uapsd_mask_per_session(pMac,
1915 psessionEntry,
1916 &pTspec->
1917 tsinfo,
1918 CLEAR_UAPSD_MASK);
1919 }
1920 /*
1921 * ADDTS success, so AC is now admitted.
1922 * We shall now use the default
1923 * EDCA parameters as advertised by AP and
1924 * send the updated EDCA params
1925 * to HAL.
1926 */
1927 ac = upToAc(pTspec->tsinfo.traffic.userPrio);
1928 if (pTspec->tsinfo.traffic.direction ==
1929 SIR_MAC_DIRECTION_UPLINK) {
1930 psessionEntry->
1931 gAcAdmitMask
1932 [SIR_MAC_DIRECTION_UPLINK] |=
1933 (1 << ac);
1934 } else if (pTspec->tsinfo.traffic.direction ==
1935 SIR_MAC_DIRECTION_DNLINK) {
1936 psessionEntry->
1937 gAcAdmitMask
1938 [SIR_MAC_DIRECTION_DNLINK] |=
1939 (1 << ac);
1940 } else if (pTspec->tsinfo.traffic.direction ==
1941 SIR_MAC_DIRECTION_BIDIR) {
1942 psessionEntry->
1943 gAcAdmitMask
1944 [SIR_MAC_DIRECTION_UPLINK] |=
1945 (1 << ac);
1946 psessionEntry->
1947 gAcAdmitMask
1948 [SIR_MAC_DIRECTION_DNLINK] |=
1949 (1 << ac);
1950 }
1951 lim_set_active_edca_params(pMac,
1952 psessionEntry->gLimEdcaParams,
1953 psessionEntry);
1954
1955 lim_send_edca_params(pMac,
1956 psessionEntry->gLimEdcaParamsActive,
1957 pSta->bssId);
1958
1959 if (eSIR_SUCCESS !=
1960 lim_tspec_add(pMac, pSta->staAddr, pSta->assocId,
1961 pTspec, 0, &tspecInfo)) {
1962 PELOGE(lim_log
1963 (pMac, LOGE,
1964 FL
1965 ("Adding entry in lim Tspec Table failed "));
1966 )
1967 pMac->lim.gLimAddtsSent = false;
1968 cdf_mem_free(pAggrAddTsParam);
1969 return eSIR_FAILURE;
1970 }
1971
1972 pAggrAddTsParam->tspec[i] =
1973 aggrQosReq->aggrInfo.aggrAddTsInfo[i].tspec;
1974 }
1975 }
1976
1977#ifdef WLAN_FEATURE_ROAM_OFFLOAD
1978 if (!pMac->roam.configParam.isRoamOffloadEnabled ||
1979 (pMac->roam.configParam.isRoamOffloadEnabled &&
1980 !psessionEntry->is11Rconnection))
1981#endif
1982 {
1983 msg.type = WMA_AGGR_QOS_REQ;
1984 msg.bodyptr = pAggrAddTsParam;
1985 msg.bodyval = 0;
1986
1987 /* We need to defer any incoming messages until we get a
1988 * WMA_AGGR_QOS_RSP from HAL.
1989 */
1990 SET_LIM_PROCESS_DEFD_MESGS(pMac, false);
1991 MTRACE(mac_trace_msg_tx(pMac, psessionEntry->peSessionId, msg.type));
1992
1993 if (eSIR_SUCCESS != wma_post_ctrl_msg(pMac, &msg)) {
1994 PELOGW(lim_log
1995 (pMac, LOGW, FL("wma_post_ctrl_msg() failed"));
1996 )
1997 SET_LIM_PROCESS_DEFD_MESGS(pMac, true);
1998 cdf_mem_free(pAggrAddTsParam);
1999 return eSIR_FAILURE;
2000 }
2001 }
2002#ifdef WLAN_FEATURE_ROAM_OFFLOAD
2003 else {
2004 /* Implies it is a LFR3.0 based 11r connection
2005 * so donot send add ts request to fimware since it
2006 * already has the RIC IEs */
2007
2008 /* Send the Aggr QoS response to SME */
2009 lim_ft_send_aggr_qos_rsp(pMac, true, pAggrAddTsParam,
2010 psessionEntry->smeSessionId);
2011 if (pAggrAddTsParam != NULL) {
2012 cdf_mem_free(pAggrAddTsParam);
2013 }
2014 }
2015#endif
2016
2017 return eSIR_SUCCESS;
2018}
2019
2020#endif /* WLAN_FEATURE_VOWIFI_11R */