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