blob: 58eed714a2d7496215b3fdaac109642140ed7fd3 [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Gopichand Nakkala92f07d82013-01-08 21:16:34 -08002 * Copyright (c) 2012-2013, 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/*
Jeff Johnson32d95a32012-09-10 13:15:23 -070022 * Copyright (c) 2012, The Linux Foundation. All rights reserved.
Jeff Johnson295189b2012-06-20 16:38:30 -070023 *
24 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
25 *
26 *
27 * Permission to use, copy, modify, and/or distribute this software for
28 * any purpose with or without fee is hereby granted, provided that the
29 * above copyright notice and this permission notice appear in all
30 * copies.
31 *
32 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
33 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
34 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
35 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
36 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
37 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
38 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
39 * PERFORMANCE OF THIS SOFTWARE.
40 */
41
42#ifdef WLAN_FEATURE_VOWIFI_11R
43/**=========================================================================
44
45 \brief implementation for PE 11r VoWiFi FT Protocol
46
47 Copyright 2008 (c) Qualcomm, Incorporated. All Rights Reserved.
48
49 Qualcomm Confidential and Proprietary.
50
51 ========================================================================*/
52
53/* $Header$ */
54
55
56/*--------------------------------------------------------------------------
57 Include Files
58 ------------------------------------------------------------------------*/
59#include <limSendMessages.h>
60#include <limTypes.h>
61#include <limFT.h>
62#include <limFTDefs.h>
63#include <limUtils.h>
64#include <limPropExtsUtils.h>
65#include <limAssocUtils.h>
66#include <limSession.h>
67#include <limAdmitControl.h>
68#include "wmmApsd.h"
69
70#define LIM_FT_RIC_BA_SSN 1
71#define LIM_FT_RIC_BA_DIALOG_TOKEN_TID_0 248
72#define LIM_FT_RIC_DESCRIPTOR_RESOURCE_TYPE_BA 1
73
74/*--------------------------------------------------------------------------
75 Initialize the FT variables.
76 ------------------------------------------------------------------------*/
77void limFTOpen(tpAniSirGlobal pMac)
78{
79 pMac->ft.ftPEContext.pFTPreAuthReq = NULL;
80 pMac->ft.ftPEContext.psavedsessionEntry = NULL;
81}
82
83/*--------------------------------------------------------------------------
84 Cleanup FT variables.
85 ------------------------------------------------------------------------*/
86void limFTCleanup(tpAniSirGlobal pMac)
87{
88 if (pMac->ft.ftPEContext.pFTPreAuthReq)
89 {
90#if defined WLAN_FEATURE_VOWIFI_11R_DEBUG
Kiran Kumar Lokere80007262013-03-18 19:45:50 -070091 PELOGE(limLog( pMac, LOGE, "%s: Freeing pFTPreAuthReq= %p",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070092 __func__, pMac->ft.ftPEContext.pFTPreAuthReq);)
Jeff Johnson295189b2012-06-20 16:38:30 -070093#endif
Dhanashri Atree3a2a592013-03-08 13:18:42 -080094 if (pMac->ft.ftPEContext.pFTPreAuthReq->pbssDescription)
95 {
96 vos_mem_free(pMac->ft.ftPEContext.pFTPreAuthReq->pbssDescription);
97 pMac->ft.ftPEContext.pFTPreAuthReq->pbssDescription = NULL;
98 }
Jeff Johnson295189b2012-06-20 16:38:30 -070099 vos_mem_free(pMac->ft.ftPEContext.pFTPreAuthReq);
100 pMac->ft.ftPEContext.pFTPreAuthReq = NULL;
101 }
102
103 // This is the old session, should be deleted else where.
104 // We should not be cleaning it here, just set it to NULL.
105 if (pMac->ft.ftPEContext.psavedsessionEntry)
106 {
107#if defined WLAN_FEATURE_VOWIFI_11R_DEBUG
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700108 PELOGE(limLog( pMac, LOGE, "%s: Setting psavedsessionEntry= %p to NULL",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700109 __func__, pMac->ft.ftPEContext.psavedsessionEntry);)
Jeff Johnson295189b2012-06-20 16:38:30 -0700110#endif
111 pMac->ft.ftPEContext.psavedsessionEntry = NULL;
112 }
113
114 // This is the extra session we added as part of Auth resp
115 // clean it up.
116 if (pMac->ft.ftPEContext.pftSessionEntry)
117 {
118 if ((((tpPESession)(pMac->ft.ftPEContext.pftSessionEntry))->valid) &&
119 (((tpPESession)(pMac->ft.ftPEContext.pftSessionEntry))->limSmeState == eLIM_SME_WT_REASSOC_STATE))
120 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700121 PELOGE(limLog( pMac, LOGE, "%s: Deleting Preauth Session %d", __func__, ((tpPESession)pMac->ft.ftPEContext.pftSessionEntry)->peSessionId);)
Jeff Johnson295189b2012-06-20 16:38:30 -0700122 peDeleteSession(pMac, pMac->ft.ftPEContext.pftSessionEntry);
123 }
124 pMac->ft.ftPEContext.pftSessionEntry = NULL;
125#if defined WLAN_FEATURE_VOWIFI_11R_DEBUG
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700126 PELOGE(limLog( pMac, LOGE, "%s: Setting psavedsessionEntry= %p to NULL",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700127 __func__, pMac->ft.ftPEContext.psavedsessionEntry);)
Jeff Johnson295189b2012-06-20 16:38:30 -0700128#endif
129 }
130
131 if (pMac->ft.ftPEContext.pAddBssReq)
132 {
133 vos_mem_free(pMac->ft.ftPEContext.pAddBssReq);
134 pMac->ft.ftPEContext.pAddBssReq = NULL;
135 }
136
137 if (pMac->ft.ftPEContext.pAddStaReq)
138 {
139 vos_mem_free(pMac->ft.ftPEContext.pAddStaReq);
140 pMac->ft.ftPEContext.pAddStaReq = NULL;
141 }
142
143 pMac->ft.ftPEContext.ftPreAuthStatus = eSIR_SUCCESS;
144
145}
146
147/*--------------------------------------------------------------------------
148 Init FT variables.
149 ------------------------------------------------------------------------*/
150void limFTInit(tpAniSirGlobal pMac)
151{
152 if (pMac->ft.ftPEContext.pFTPreAuthReq)
153 {
154#if defined WLAN_FEATURE_VOWIFI_11R_DEBUG
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700155 PELOGE(limLog( pMac, LOGE, "%s: Freeing pFTPreAuthReq= %p",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700156 __func__, pMac->ft.ftPEContext.pFTPreAuthReq);)
Jeff Johnson295189b2012-06-20 16:38:30 -0700157#endif
Dhanashri Atree3a2a592013-03-08 13:18:42 -0800158 if (pMac->ft.ftPEContext.pFTPreAuthReq->pbssDescription)
159 {
160 vos_mem_free(pMac->ft.ftPEContext.pFTPreAuthReq->pbssDescription);
161 pMac->ft.ftPEContext.pFTPreAuthReq->pbssDescription = NULL;
162 }
163
Jeff Johnson295189b2012-06-20 16:38:30 -0700164 vos_mem_free(pMac->ft.ftPEContext.pFTPreAuthReq);
165 pMac->ft.ftPEContext.pFTPreAuthReq = NULL;
166 }
167
168 // This is the old session, should be deleted else where.
169 // We should not be cleaning it here, just set it to NULL.
170 if (pMac->ft.ftPEContext.psavedsessionEntry)
171 {
172#if defined WLAN_FEATURE_VOWIFI_11R_DEBUG
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700173 PELOGE(limLog( pMac, LOGE, "%s: Setting psavedsessionEntry= %p to NULL",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700174 __func__, pMac->ft.ftPEContext.psavedsessionEntry);)
Jeff Johnson295189b2012-06-20 16:38:30 -0700175#endif
176 pMac->ft.ftPEContext.psavedsessionEntry = NULL;
177 }
178
179 // This is the extra session we added as part of Auth resp
180 // clean it up.
181 if (pMac->ft.ftPEContext.pftSessionEntry)
182 {
183 /* Cannot delete sessions across associations */
184#if defined WLAN_FEATURE_VOWIFI_11R_DEBUG
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700185 PELOGE(limLog( pMac, LOGE, "%s: Deleting session = %p ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700186 __func__, pMac->ft.ftPEContext.pftSessionEntry);)
Jeff Johnson295189b2012-06-20 16:38:30 -0700187#endif
188 pMac->ft.ftPEContext.pftSessionEntry = NULL;
189 }
190
191 if (pMac->ft.ftPEContext.pAddBssReq)
192 {
193#if defined WLAN_FEATURE_VOWIFI_11R_DEBUG
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700194 PELOGE(limLog( pMac, LOGE, "%s: Freeing AddBssReq = %p ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700195 __func__, pMac->ft.ftPEContext.pAddBssReq);)
Jeff Johnson295189b2012-06-20 16:38:30 -0700196#endif
197 vos_mem_free(pMac->ft.ftPEContext.pAddBssReq);
198 pMac->ft.ftPEContext.pAddBssReq = NULL;
199 }
200
201
202 if (pMac->ft.ftPEContext.pAddStaReq)
203 {
204#if defined WLAN_FEATURE_VOWIFI_11R_DEBUG
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700205 PELOGE(limLog( pMac, LOGE, "%s: Freeing AddStaReq = %p ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700206 __func__, pMac->ft.ftPEContext.pAddStaReq);)
Jeff Johnson295189b2012-06-20 16:38:30 -0700207#endif
208 vos_mem_free(pMac->ft.ftPEContext.pAddStaReq);
209 pMac->ft.ftPEContext.pAddStaReq = NULL;
210 }
211
212 pMac->ft.ftPEContext.ftPreAuthStatus = eSIR_SUCCESS;
213
214}
215
216/*------------------------------------------------------------------
217 *
218 * This is the handler after suspending the link.
219 * We suspend the link and then now proceed to switch channel.
220 *
221 *------------------------------------------------------------------*/
222void FTPreAuthSuspendLinkHandler(tpAniSirGlobal pMac, eHalStatus status, tANI_U32 *data)
223{
224 tpPESession psessionEntry;
225
226 // The link is suspended of not ?
227 if (status != eHAL_STATUS_SUCCESS)
228 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700229 PELOGE(limLog( pMac, LOGE, "%s: Returning ", __func__);)
Jeff Johnson295189b2012-06-20 16:38:30 -0700230 // Post the FT Pre Auth Response to SME
231 limPostFTPreAuthRsp(pMac, eSIR_FAILURE, NULL, 0, (tpPESession)data);
232
233 return;
234 }
235
236 psessionEntry = (tpPESession)data;
237 // Suspended, now move to a different channel.
238 // Perform some sanity check before proceeding.
239 if ((pMac->ft.ftPEContext.pFTPreAuthReq) && psessionEntry)
240 {
241 limChangeChannelWithCallback(pMac,
242 pMac->ft.ftPEContext.pFTPreAuthReq->preAuthchannelNum,
243 limPerformFTPreAuth, NULL, psessionEntry);
244 return;
245 }
246
247 // Else return error.
248 limPostFTPreAuthRsp(pMac, eSIR_FAILURE, NULL, 0, psessionEntry);
249}
250
251
252/*--------------------------------------------------------------------------
253 In this function, we process the FT Pre Auth Req.
254 We receive Pre-Auth
255 Suspend link
256 Register a call back
257 In the call back, we will need to accept frames from the new bssid
258 Send out the auth req to new AP.
259 Start timer and when the timer is done or if we receive the Auth response
260 We change channel
261 Resume link
262 ------------------------------------------------------------------------*/
263int limProcessFTPreAuthReq(tpAniSirGlobal pMac, tpSirMsgQ pMsg)
264{
265 int bufConsumed = FALSE;
266 tpPESession psessionEntry;
267 tANI_U8 sessionId;
268
269 // Now we are starting fresh make sure all's cleanup.
270 limFTInit(pMac);
271 pMac->ft.ftPEContext.ftPreAuthStatus = eSIR_FAILURE; // Can set it only after sending auth
272
273 // We need information from the Pre-Auth Req. Lets save that
274 pMac->ft.ftPEContext.pFTPreAuthReq = (tpSirFTPreAuthReq)pMsg->bodyptr;
275
276#if defined WLAN_FEATURE_VOWIFI_11R_DEBUG
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -0800277 PELOGE(limLog( pMac, LOG1, "%s: PE Auth ft_ies_length=%02x%02x%02x", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -0700278 pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies[0],
279 pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies[1],
280 pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies[2]);)
281#endif
282
283 // Get the current session entry
284 psessionEntry = peFindSessionByBssid(pMac,
285 pMac->ft.ftPEContext.pFTPreAuthReq->currbssId, &sessionId);
286 if (psessionEntry == NULL)
287 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700288 PELOGE(limLog( pMac, LOGE, "%s: Unable to find session for the following bssid",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700289 __func__);)
Jeff Johnson295189b2012-06-20 16:38:30 -0700290 limPrintMacAddr( pMac, pMac->ft.ftPEContext.pFTPreAuthReq->currbssId, LOGE );
291 // Post the FT Pre Auth Response to SME
Gopichand Nakkala2d335f32013-01-04 12:24:28 -0800292 limPostFTPreAuthRsp(pMac, eSIR_FAILURE, NULL, 0, NULL);
293 pMac->ft.ftPEContext.pFTPreAuthReq = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -0700294 return TRUE;
295 }
296
297 // Dont need to suspend if APs are in same channel
298 if (psessionEntry->currentOperChannel != pMac->ft.ftPEContext.pFTPreAuthReq->preAuthchannelNum)
299 {
300 // Need to suspend link only if the channels are different
Madan Mohan Koyyalamudi23001722012-10-31 16:48:56 -0700301 PELOG2(limLog(pMac,LOG2,"%s: Performing pre-auth on different"
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700302 " channel (session %p)", __func__, psessionEntry);)
Madan Mohan Koyyalamudi9b876782012-10-11 16:22:51 -0700303 limSuspendLink(pMac, eSIR_CHECK_ROAMING_SCAN, FTPreAuthSuspendLinkHandler,
Jeff Johnson295189b2012-06-20 16:38:30 -0700304 (tANI_U32 *)psessionEntry);
305 }
306 else
307 {
Madan Mohan Koyyalamudi23001722012-10-31 16:48:56 -0700308 PELOG2(limLog(pMac,LOG2,"%s: Performing pre-auth on same"
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700309 " channel (session %p)", __func__, psessionEntry);)
Jeff Johnson295189b2012-06-20 16:38:30 -0700310 // We are in the same channel. Perform pre-auth
311 limPerformFTPreAuth(pMac, eHAL_STATUS_SUCCESS, NULL, psessionEntry);
312 }
313
314 return bufConsumed;
315}
316
317/*------------------------------------------------------------------
318 * Send the Auth1
319 * Receive back Auth2
320 *------------------------------------------------------------------*/
321void limPerformFTPreAuth(tpAniSirGlobal pMac, eHalStatus status, tANI_U32 *data,
322 tpPESession psessionEntry)
323{
324 tSirMacAuthFrameBody authFrame;
325
326 if (psessionEntry->is11Rconnection)
327 {
328 // Only 11r assoc has FT IEs.
329 if (pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies == NULL)
330 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700331 PELOGE(limLog( pMac, LOGE, "%s: FTIEs for Auth Req Seq 1 is absent");)
Jeff Johnson295189b2012-06-20 16:38:30 -0700332 return;
333 }
334 }
335 if (status != eHAL_STATUS_SUCCESS)
336 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700337 PELOGE(limLog( pMac, LOGE, "%s: Change channel not successful for FT pre-auth");)
Jeff Johnson295189b2012-06-20 16:38:30 -0700338 return;
339 }
340 pMac->ft.ftPEContext.psavedsessionEntry = psessionEntry;
341
342#if defined WLAN_FEATURE_VOWIFI_11R_DEBUG
Madan Mohan Koyyalamudi23001722012-10-31 16:48:56 -0700343 PELOG2(limLog(pMac,LOG2,"Entered wait auth2 state for FT"
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700344 " (old session %p)",
Madan Mohan Koyyalamudi23001722012-10-31 16:48:56 -0700345 pMac->ft.ftPEContext.psavedsessionEntry);)
Jeff Johnson295189b2012-06-20 16:38:30 -0700346#endif
347
348
349 if (psessionEntry->is11Rconnection)
350 {
351 // Now we are on the right channel and need to send out Auth1 and
352 // receive Auth2.
353 authFrame.authAlgoNumber = eSIR_FT_AUTH; // Set the auth type to FT
354 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -0700355#if defined FEATURE_WLAN_CCX || defined FEATURE_WLAN_LFR
Jeff Johnson295189b2012-06-20 16:38:30 -0700356 else
357 {
358 // Will need to make isCCXconnection a enum may be for further
359 // improvements to this to match this algorithm number
360 authFrame.authAlgoNumber = eSIR_OPEN_SYSTEM; // For now if its CCX and 11r FT.
361 }
362#endif
363 authFrame.authTransactionSeqNumber = SIR_MAC_AUTH_FRAME_1;
364 authFrame.authStatusCode = 0;
365
366 // Start timer here to come back to operating channel.
367 pMac->lim.limTimers.gLimFTPreAuthRspTimer.sessionId = psessionEntry->peSessionId;
368 if(TX_SUCCESS != tx_timer_activate(&pMac->lim.limTimers.gLimFTPreAuthRspTimer))
369 {
370#if defined WLAN_FEATURE_VOWIFI_11R_DEBUG
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700371 PELOGE(limLog( pMac, LOGE, "%s: FT Auth Rsp Timer Start Failed", __func__);)
Jeff Johnson295189b2012-06-20 16:38:30 -0700372#endif
373 }
Varun Reddy Yeturue3bbf6e2013-02-08 18:50:55 -0800374MTRACE(macTrace(pMac, TRACE_CODE_TIMER_ACTIVATE, psessionEntry->peSessionId, eLIM_FT_PREAUTH_RSP_TIMER));
Jeff Johnson295189b2012-06-20 16:38:30 -0700375
376#if defined WLAN_FEATURE_VOWIFI_11R_DEBUG
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -0800377 PELOGE(limLog( pMac, LOG1, "%s: FT Auth Rsp Timer Started", __func__);)
Jeff Johnson295189b2012-06-20 16:38:30 -0700378#endif
379
380 limSendAuthMgmtFrame(pMac, &authFrame,
381 pMac->ft.ftPEContext.pFTPreAuthReq->preAuthbssId,
382 LIM_NO_WEP_IN_FC, psessionEntry);
383
384 return;
385}
386
387
388/*------------------------------------------------------------------
389 *
390 * Create the new Add Bss Req to the new AP.
391 * This will be used when we are ready to FT to the new AP.
392 * The newly created ft Session entry is passed to this function
393 *
394 *------------------------------------------------------------------*/
395tSirRetStatus limFTPrepareAddBssReq( tpAniSirGlobal pMac,
396 tANI_U8 updateEntry, tpPESession pftSessionEntry,
397 tpSirBssDescription bssDescription )
398{
399 tpAddBssParams pAddBssParams = NULL;
400 tANI_U8 i;
401 tANI_U8 chanWidthSupp = 0;
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700402 tSchBeaconStruct *pBeaconStruct;
Jeff Johnson295189b2012-06-20 16:38:30 -0700403
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700404 if(eHAL_STATUS_SUCCESS != palAllocateMemory(pMac->hHdd,
405 (void **)&pBeaconStruct, sizeof(tSchBeaconStruct)))
406 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700407 limLog(pMac, LOGE, FL("Unable to PAL allocate memory for creating ADD_BSS") );
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700408 return eSIR_MEM_ALLOC_FAILED;
409 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700410
411 // Package SIR_HAL_ADD_BSS_REQ message parameters
412 if( eHAL_STATUS_SUCCESS != palAllocateMemory( pMac->hHdd,
413 (void **) &pAddBssParams, sizeof( tAddBssParams )))
414 {
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700415 palFreeMemory(pMac->hHdd, pBeaconStruct);
Jeff Johnson295189b2012-06-20 16:38:30 -0700416 limLog( pMac, LOGP,
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700417 FL( "Unable to PAL allocate memory for creating ADD_BSS" ));
Jeff Johnson295189b2012-06-20 16:38:30 -0700418 return (eSIR_MEM_ALLOC_FAILED);
419 }
420
421 palZeroMemory( pMac->hHdd, (tANI_U8 *) pAddBssParams, sizeof( tAddBssParams ));
422
423
424 limExtractApCapabilities( pMac,
425 (tANI_U8 *) bssDescription->ieFields,
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700426 limGetIElenFromBssDescription( bssDescription ), pBeaconStruct );
Jeff Johnson295189b2012-06-20 16:38:30 -0700427
428 if (pMac->lim.gLimProtectionControl != WNI_CFG_FORCE_POLICY_PROTECTION_DISABLE)
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700429 limDecideStaProtectionOnAssoc(pMac, pBeaconStruct, pftSessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -0700430
431 palCopyMemory( pMac->hHdd, pAddBssParams->bssId, bssDescription->bssId,
432 sizeof( tSirMacAddr ));
433
434 // Fill in tAddBssParams selfMacAddr
435 palCopyMemory( pMac->hHdd, pAddBssParams->selfMacAddr, pftSessionEntry->selfMacAddr,
436 sizeof( tSirMacAddr ));
437
438 pAddBssParams->bssType = pftSessionEntry->bssType;//eSIR_INFRASTRUCTURE_MODE;
439 pAddBssParams->operMode = BSS_OPERATIONAL_MODE_STA;
440
441 pAddBssParams->beaconInterval = bssDescription->beaconInterval;
442
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700443 pAddBssParams->dtimPeriod = pBeaconStruct->tim.dtimPeriod;
Jeff Johnson295189b2012-06-20 16:38:30 -0700444 pAddBssParams->updateBss = updateEntry;
445
446
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700447 pAddBssParams->cfParamSet.cfpCount = pBeaconStruct->cfParamSet.cfpCount;
448 pAddBssParams->cfParamSet.cfpPeriod = pBeaconStruct->cfParamSet.cfpPeriod;
449 pAddBssParams->cfParamSet.cfpMaxDuration = pBeaconStruct->cfParamSet.cfpMaxDuration;
450 pAddBssParams->cfParamSet.cfpDurRemaining = pBeaconStruct->cfParamSet.cfpDurRemaining;
Jeff Johnson295189b2012-06-20 16:38:30 -0700451
452
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700453 pAddBssParams->rateSet.numRates = pBeaconStruct->supportedRates.numRates;
Jeff Johnson295189b2012-06-20 16:38:30 -0700454 palCopyMemory( pMac->hHdd, pAddBssParams->rateSet.rate,
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700455 pBeaconStruct->supportedRates.rate, pBeaconStruct->supportedRates.numRates );
Jeff Johnson295189b2012-06-20 16:38:30 -0700456
457 pAddBssParams->nwType = bssDescription->nwType;
458
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700459 pAddBssParams->shortSlotTimeSupported = (tANI_U8)pBeaconStruct->capabilityInfo.shortSlotTime;
Jeff Johnson295189b2012-06-20 16:38:30 -0700460 pAddBssParams->llaCoexist = (tANI_U8) pftSessionEntry->beaconParams.llaCoexist;
461 pAddBssParams->llbCoexist = (tANI_U8) pftSessionEntry->beaconParams.llbCoexist;
462 pAddBssParams->llgCoexist = (tANI_U8) pftSessionEntry->beaconParams.llgCoexist;
463 pAddBssParams->ht20Coexist = (tANI_U8) pftSessionEntry->beaconParams.ht20Coexist;
464
465 // Use the advertised capabilities from the received beacon/PR
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700466 if (IS_DOT11_MODE_HT(pftSessionEntry->dot11mode) && ( pBeaconStruct->HTCaps.present ))
Jeff Johnson295189b2012-06-20 16:38:30 -0700467 {
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700468 pAddBssParams->htCapable = pBeaconStruct->HTCaps.present;
Jeff Johnson295189b2012-06-20 16:38:30 -0700469
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700470 if ( pBeaconStruct->HTInfo.present )
Jeff Johnson295189b2012-06-20 16:38:30 -0700471 {
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700472 pAddBssParams->htOperMode = (tSirMacHTOperatingMode)pBeaconStruct->HTInfo.opMode;
473 pAddBssParams->dualCTSProtection = ( tANI_U8 ) pBeaconStruct->HTInfo.dualCTSProtection;
Jeff Johnson295189b2012-06-20 16:38:30 -0700474
Jeff Johnson295189b2012-06-20 16:38:30 -0700475 chanWidthSupp = limGetHTCapability( pMac, eHT_SUPPORTED_CHANNEL_WIDTH_SET, pftSessionEntry);
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700476 if( (pBeaconStruct->HTCaps.supportedChannelWidthSet) &&
Jeff Johnson295189b2012-06-20 16:38:30 -0700477 (chanWidthSupp) )
478 {
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700479 pAddBssParams->txChannelWidthSet = ( tANI_U8 ) pBeaconStruct->HTInfo.recommendedTxWidthSet;
480 pAddBssParams->currentExtChannel = pBeaconStruct->HTInfo.secondaryChannelOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -0700481 }
482 else
483 {
484 pAddBssParams->txChannelWidthSet = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
Jeff Johnsone7245742012-09-05 17:12:55 -0700485 pAddBssParams->currentExtChannel = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -0700486 }
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700487 pAddBssParams->llnNonGFCoexist = (tANI_U8)pBeaconStruct->HTInfo.nonGFDevicesPresent;
488 pAddBssParams->fLsigTXOPProtectionFullSupport = (tANI_U8)pBeaconStruct->HTInfo.lsigTXOPProtectionFullSupport;
489 pAddBssParams->fRIFSMode = pBeaconStruct->HTInfo.rifsMode;
Jeff Johnson295189b2012-06-20 16:38:30 -0700490 }
491 }
492
493 pAddBssParams->currentOperChannel = bssDescription->channelId;
494
495#if defined WLAN_FEATURE_VOWIFI_11R_DEBUG
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700496 limLog( pMac, LOGE, FL( "SIR_HAL_ADD_BSS_REQ with channel = %d..." ),
Jeff Johnson295189b2012-06-20 16:38:30 -0700497 pAddBssParams->currentOperChannel);
498#endif
499
500
501 // Populate the STA-related parameters here
502 // Note that the STA here refers to the AP
503 {
504 pAddBssParams->staContext.staType = STA_ENTRY_OTHER; // Identifying AP as an STA
505
506 palCopyMemory( pMac->hHdd, pAddBssParams->staContext.bssId,
507 bssDescription->bssId,
508 sizeof( tSirMacAddr ));
509 pAddBssParams->staContext.listenInterval = bssDescription->beaconInterval;
510
511 pAddBssParams->staContext.assocId = 0; // Is SMAC OK with this?
512 pAddBssParams->staContext.uAPSD = 0;
513 pAddBssParams->staContext.maxSPLen = 0;
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700514 pAddBssParams->staContext.shortPreambleSupported = (tANI_U8)pBeaconStruct->capabilityInfo.shortPreamble;
Jeff Johnson295189b2012-06-20 16:38:30 -0700515 pAddBssParams->staContext.updateSta = updateEntry;
516 pAddBssParams->staContext.encryptType = pftSessionEntry->encryptType;
517
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700518 if (IS_DOT11_MODE_HT(pftSessionEntry->dot11mode) && ( pBeaconStruct->HTCaps.present ))
Jeff Johnson295189b2012-06-20 16:38:30 -0700519 {
520 pAddBssParams->staContext.us32MaxAmpduDuration = 0;
521 pAddBssParams->staContext.htCapable = 1;
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700522 pAddBssParams->staContext.greenFieldCapable = ( tANI_U8 ) pBeaconStruct->HTCaps.greenField;
523 pAddBssParams->staContext.lsigTxopProtection = ( tANI_U8 ) pBeaconStruct->HTCaps.lsigTXOPProtection;
524 if( (pBeaconStruct->HTCaps.supportedChannelWidthSet) &&
Jeff Johnson295189b2012-06-20 16:38:30 -0700525 (chanWidthSupp) )
526 {
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700527 pAddBssParams->staContext.txChannelWidthSet = ( tANI_U8 )pBeaconStruct->HTInfo.recommendedTxWidthSet;
Jeff Johnson295189b2012-06-20 16:38:30 -0700528 }
529 else
530 {
531 pAddBssParams->staContext.txChannelWidthSet = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
532 }
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700533 pAddBssParams->staContext.mimoPS = (tSirMacHTMIMOPowerSaveState)pBeaconStruct->HTCaps.mimoPowerSave;
534 pAddBssParams->staContext.delBASupport = ( tANI_U8 ) pBeaconStruct->HTCaps.delayedBA;
535 pAddBssParams->staContext.maxAmsduSize = ( tANI_U8 ) pBeaconStruct->HTCaps.maximalAMSDUsize;
536 pAddBssParams->staContext.maxAmpduDensity = pBeaconStruct->HTCaps.mpduDensity;
537 pAddBssParams->staContext.fDsssCckMode40Mhz = (tANI_U8)pBeaconStruct->HTCaps.dsssCckMode40MHz;
538 pAddBssParams->staContext.fShortGI20Mhz = (tANI_U8)pBeaconStruct->HTCaps.shortGI20MHz;
539 pAddBssParams->staContext.fShortGI40Mhz = (tANI_U8)pBeaconStruct->HTCaps.shortGI40MHz;
540 pAddBssParams->staContext.maxAmpduSize= pBeaconStruct->HTCaps.maxRxAMPDUFactor;
Jeff Johnson295189b2012-06-20 16:38:30 -0700541
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700542 if( pBeaconStruct->HTInfo.present )
543 pAddBssParams->staContext.rifsMode = pBeaconStruct->HTInfo.rifsMode;
Jeff Johnson295189b2012-06-20 16:38:30 -0700544 }
545
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700546 if ((pftSessionEntry->limWmeEnabled && pBeaconStruct->wmeEdcaPresent) ||
547 (pftSessionEntry->limQosEnabled && pBeaconStruct->edcaPresent))
Jeff Johnson295189b2012-06-20 16:38:30 -0700548 pAddBssParams->staContext.wmmEnabled = 1;
549 else
550 pAddBssParams->staContext.wmmEnabled = 0;
551
552 //Update the rates
Jeff Johnsone7245742012-09-05 17:12:55 -0700553#ifdef WLAN_FEATURE_11AC
554 limPopulateOwnRateSet(pMac, &pAddBssParams->staContext.supportedRates,
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700555 pBeaconStruct->HTCaps.supportedMCSSet,
556 false,pftSessionEntry,&pBeaconStruct->VHTCaps);
Jeff Johnsone7245742012-09-05 17:12:55 -0700557#else
Jeff Johnson295189b2012-06-20 16:38:30 -0700558 limPopulateOwnRateSet(pMac, &pAddBssParams->staContext.supportedRates,
559 beaconStruct.HTCaps.supportedMCSSet, false,pftSessionEntry);
Jeff Johnsone7245742012-09-05 17:12:55 -0700560#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700561 limFillSupportedRatesInfo(pMac, NULL, &pAddBssParams->staContext.supportedRates,pftSessionEntry);
562
563 }
564
565
566 //Disable BA. It will be set as part of ADDBA negotiation.
567 for( i = 0; i < STACFG_MAX_TC; i++ )
568 {
569 pAddBssParams->staContext.staTCParams[i].txUseBA = eBA_DISABLE;
570 pAddBssParams->staContext.staTCParams[i].rxUseBA = eBA_DISABLE;
571 pAddBssParams->staContext.staTCParams[i].txBApolicy = eBA_POLICY_IMMEDIATE;
572 pAddBssParams->staContext.staTCParams[i].rxBApolicy = eBA_POLICY_IMMEDIATE;
573 }
574
575#if defined WLAN_FEATURE_VOWIFI
576 pAddBssParams->maxTxPower = pftSessionEntry->maxTxPower;
577#endif
578
579 pAddBssParams->status = eHAL_STATUS_SUCCESS;
580 pAddBssParams->respReqd = true;
581
582 pAddBssParams->staContext.sessionId = pftSessionEntry->peSessionId;
583 pAddBssParams->sessionId = pftSessionEntry->peSessionId;
584
585 // Set a new state for MLME
586
587 pftSessionEntry->limMlmState = eLIM_MLM_WT_ADD_BSS_RSP_FT_REASSOC_STATE;
Varun Reddy Yeturue3bbf6e2013-02-08 18:50:55 -0800588 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, pftSessionEntry->peSessionId, eLIM_MLM_WT_ADD_BSS_RSP_FT_REASSOC_STATE));
Jeff Johnson295189b2012-06-20 16:38:30 -0700589 pAddBssParams->halPersona=(tANI_U8)pftSessionEntry->pePersona; //pass on the session persona to hal
590
591 pMac->ft.ftPEContext.pAddBssReq = pAddBssParams;
592
593#if defined WLAN_FEATURE_VOWIFI_11R_DEBUG
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -0800594 limLog( pMac, LOG1, FL( "Saving SIR_HAL_ADD_BSS_REQ for pre-auth ap..." ));
Jeff Johnson295189b2012-06-20 16:38:30 -0700595#endif
596
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700597 palFreeMemory(pMac->hHdd, pBeaconStruct);
Jeff Johnson295189b2012-06-20 16:38:30 -0700598 return 0;
599}
600
601/*------------------------------------------------------------------
602 *
603 * Setup the new session for the pre-auth AP.
604 * Return the newly created session entry.
605 *
606 *------------------------------------------------------------------*/
607tpPESession limFillFTSession(tpAniSirGlobal pMac,
608 tpSirBssDescription pbssDescription, tpPESession psessionEntry)
609{
610 tpPESession pftSessionEntry;
611 tANI_U8 currentBssUapsd;
Jeff Johnson295189b2012-06-20 16:38:30 -0700612 tPowerdBm localPowerConstraint;
613 tPowerdBm regMax;
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700614 tSchBeaconStruct *pBeaconStruct;
615
616 if(eHAL_STATUS_SUCCESS != palAllocateMemory(pMac->hHdd,
617 (void **)&pBeaconStruct, sizeof(tSchBeaconStruct)))
618 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700619 limLog(pMac, LOGE, FL("Unable to PAL allocate memory for creating limFillFTSession") );
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700620 return NULL;
621 }
622
Jeff Johnson295189b2012-06-20 16:38:30 -0700623
Dhanashri Atreaf3e84d2013-01-18 18:03:06 -0800624
625 /* Retrieve the session that has already been created and update the entry */
626 pftSessionEntry = pMac->ft.ftPEContext.pftSessionEntry;
Jeff Johnson04dd8a82012-06-29 20:41:40 -0700627#if defined WLAN_FEATURE_VOWIFI_11R_DEBUG || defined FEATURE_WLAN_CCX || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -0700628 limPrintMacAddr(pMac, pbssDescription->bssId, LOGE);
629#endif
630
Jeff Johnson295189b2012-06-20 16:38:30 -0700631 pftSessionEntry->dot11mode = psessionEntry->dot11mode;
Jeff Johnsone7245742012-09-05 17:12:55 -0700632 pftSessionEntry->htCapability = psessionEntry->htCapability;
Jeff Johnson295189b2012-06-20 16:38:30 -0700633
634 pftSessionEntry->limWmeEnabled = psessionEntry->limWmeEnabled;
635 pftSessionEntry->limQosEnabled = psessionEntry->limQosEnabled;
636 pftSessionEntry->limWsmEnabled = psessionEntry->limWsmEnabled;
637 pftSessionEntry->lim11hEnable = psessionEntry->lim11hEnable;
638
639 // Fields to be filled later
640 pftSessionEntry->pLimJoinReq = NULL;
641 pftSessionEntry->smeSessionId = 0;
642 pftSessionEntry->transactionId = 0;
643
644 limExtractApCapabilities( pMac,
645 (tANI_U8 *) pbssDescription->ieFields,
646 limGetIElenFromBssDescription( pbssDescription ),
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700647 pBeaconStruct );
Jeff Johnson295189b2012-06-20 16:38:30 -0700648
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700649 pftSessionEntry->rateSet.numRates = pBeaconStruct->supportedRates.numRates;
Jeff Johnson295189b2012-06-20 16:38:30 -0700650 palCopyMemory( pMac->hHdd, pftSessionEntry->rateSet.rate,
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700651 pBeaconStruct->supportedRates.rate, pBeaconStruct->supportedRates.numRates );
Jeff Johnson295189b2012-06-20 16:38:30 -0700652
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700653 pftSessionEntry->extRateSet.numRates = pBeaconStruct->extendedRates.numRates;
Jeff Johnson295189b2012-06-20 16:38:30 -0700654 palCopyMemory(pMac->hHdd, pftSessionEntry->extRateSet.rate,
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700655 pBeaconStruct->extendedRates.rate, pftSessionEntry->extRateSet.numRates);
Jeff Johnson295189b2012-06-20 16:38:30 -0700656
657
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700658 pftSessionEntry->ssId.length = pBeaconStruct->ssId.length;
659 palCopyMemory( pMac->hHdd, pftSessionEntry->ssId.ssId, pBeaconStruct->ssId.ssId,
Jeff Johnson295189b2012-06-20 16:38:30 -0700660 pftSessionEntry->ssId.length);
661
662
663 // Self Mac
664 sirCopyMacAddr(pftSessionEntry->selfMacAddr, psessionEntry->selfMacAddr);
665 sirCopyMacAddr(pftSessionEntry->limReAssocbssId, pbssDescription->bssId);
Jeff Johnson04dd8a82012-06-29 20:41:40 -0700666#if defined WLAN_FEATURE_VOWIFI_11R_DEBUG || defined FEATURE_WLAN_CCX || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -0700667 limPrintMacAddr(pMac, pftSessionEntry->limReAssocbssId, LOGE);
668#endif
669
670 /* Store beaconInterval */
671 pftSessionEntry->beaconParams.beaconInterval = pbssDescription->beaconInterval;
672 pftSessionEntry->bssType = psessionEntry->bssType;
673
674 pftSessionEntry->statypeForBss = STA_ENTRY_PEER;
675 pftSessionEntry->nwType = pbssDescription->nwType;
676
677 /* Copy The channel Id to the session Table */
678 pftSessionEntry->limReassocChannelId = pbssDescription->channelId;
679 pftSessionEntry->currentOperChannel = pbssDescription->channelId;
680
681
682 if (pftSessionEntry->bssType == eSIR_INFRASTRUCTURE_MODE)
683 {
684 pftSessionEntry->limSystemRole = eLIM_STA_ROLE;
685 }
686 else if(pftSessionEntry->bssType == eSIR_BTAMP_AP_MODE)
687 {
688 pftSessionEntry->limSystemRole = eLIM_BT_AMP_STA_ROLE;
689 }
690 else
691 {
692 /* Throw an error and return and make sure to delete the session.*/
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700693 limLog(pMac, LOGE, FL("Invalid bss type"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700694 }
695
696 pftSessionEntry->limCurrentBssCaps = pbssDescription->capabilityInfo;
697 pftSessionEntry->limReassocBssCaps = pbssDescription->capabilityInfo;
Srinivas Girigowda3353f1e2013-02-04 16:22:51 -0800698 if( pMac->roam.configParam.shortSlotTime &&
699 SIR_MAC_GET_SHORT_SLOT_TIME(pftSessionEntry->limReassocBssCaps))
700 {
701 pftSessionEntry->shortSlotTimeSupported = TRUE;
702 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700703
704 regMax = cfgGetRegulatoryMaxTransmitPower( pMac, pftSessionEntry->currentOperChannel );
705 localPowerConstraint = regMax;
706 limExtractApCapability( pMac, (tANI_U8 *) pbssDescription->ieFields,
707 limGetIElenFromBssDescription(pbssDescription),
708 &pftSessionEntry->limCurrentBssQosCaps,
709 &pftSessionEntry->limCurrentBssPropCap,
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -0700710 &currentBssUapsd , &localPowerConstraint, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -0700711
712 pftSessionEntry->limReassocBssQosCaps =
713 pftSessionEntry->limCurrentBssQosCaps;
714 pftSessionEntry->limReassocBssPropCap =
715 pftSessionEntry->limCurrentBssPropCap;
716
717
Madan Mohan Koyyalamudi3282c572012-11-09 17:01:41 -0800718#ifdef FEATURE_WLAN_CCX
719 pftSessionEntry->maxTxPower = limGetMaxTxPower(regMax, localPowerConstraint, pMac->roam.configParam.nTxPowerCap);
720#else
Jeff Johnson295189b2012-06-20 16:38:30 -0700721 pftSessionEntry->maxTxPower = VOS_MIN( regMax , (localPowerConstraint) );
Madan Mohan Koyyalamudi3282c572012-11-09 17:01:41 -0800722#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700723
724#if defined WLAN_FEATURE_VOWIFI_11R_DEBUG
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -0800725 limLog( pMac, LOG1, "%s: Regulatory max = %d, local power constraint = %d, ini tx power = %d, max tx = %d",
Madan Mohan Koyyalamudi3282c572012-11-09 17:01:41 -0800726 __func__, regMax, localPowerConstraint, pMac->roam.configParam.nTxPowerCap, pftSessionEntry->maxTxPower );
Jeff Johnson295189b2012-06-20 16:38:30 -0700727#endif
728
729 pftSessionEntry->limRFBand = limGetRFBand(pftSessionEntry->currentOperChannel);
730
731 pftSessionEntry->limPrevSmeState = pftSessionEntry->limSmeState;
732 pftSessionEntry->limSmeState = eLIM_SME_WT_REASSOC_STATE;
Varun Reddy Yeturue3bbf6e2013-02-08 18:50:55 -0800733 MTRACE(macTrace(pMac, TRACE_CODE_SME_STATE, pftSessionEntry->peSessionId, pftSessionEntry->limSmeState));
Jeff Johnson295189b2012-06-20 16:38:30 -0700734
735 pftSessionEntry->encryptType = psessionEntry->encryptType;
736
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700737 palFreeMemory(pMac->hHdd, pBeaconStruct);
Jeff Johnson295189b2012-06-20 16:38:30 -0700738 return pftSessionEntry;
739}
740
741/*------------------------------------------------------------------
742 *
743 * Setup the session and the add bss req for the pre-auth AP.
744 *
745 *------------------------------------------------------------------*/
746void limFTSetupAuthSession(tpAniSirGlobal pMac, tpPESession psessionEntry)
747{
748 tpPESession pftSessionEntry;
749
750 // Prepare the session right now with as much as possible.
751 pftSessionEntry = limFillFTSession(pMac, pMac->ft.ftPEContext.pFTPreAuthReq->pbssDescription, psessionEntry);
752
753 if (pftSessionEntry)
754 {
755 pftSessionEntry->is11Rconnection = psessionEntry->is11Rconnection;
756#ifdef FEATURE_WLAN_CCX
757 pftSessionEntry->isCCXconnection = psessionEntry->isCCXconnection;
758#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -0700759#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_CCX || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -0700760 pftSessionEntry->isFastTransitionEnabled = psessionEntry->isFastTransitionEnabled;
761#endif
Jeff Johnson43971f52012-07-17 12:26:56 -0700762
763#ifdef FEATURE_WLAN_LFR
764 pftSessionEntry->isFastRoamIniFeatureEnabled = psessionEntry->isFastRoamIniFeatureEnabled;
765#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700766 limFTPrepareAddBssReq( pMac, FALSE, pftSessionEntry,
767 pMac->ft.ftPEContext.pFTPreAuthReq->pbssDescription );
768 pMac->ft.ftPEContext.pftSessionEntry = pftSessionEntry;
769 }
770}
771
772/*------------------------------------------------------------------
773 * Resume Link Call Back
774 *------------------------------------------------------------------*/
775void limFTProcessPreAuthResult(tpAniSirGlobal pMac, eHalStatus status, tANI_U32 *data)
776{
777 tpPESession psessionEntry;
778
779 psessionEntry = (tpPESession)data;
780
781 if (pMac->ft.ftPEContext.ftPreAuthStatus == eSIR_SUCCESS)
782 {
783 limFTSetupAuthSession(pMac, psessionEntry);
784 }
785
786 // Post the FT Pre Auth Response to SME
787 limPostFTPreAuthRsp(pMac, pMac->ft.ftPEContext.ftPreAuthStatus,
788 pMac->ft.ftPEContext.saved_auth_rsp,
789 pMac->ft.ftPEContext.saved_auth_rsp_length, psessionEntry);
790
791}
792
793/*------------------------------------------------------------------
794 * Resume Link Call Back
795 *------------------------------------------------------------------*/
796void limPerformPostFTPreAuthAndChannelChange(tpAniSirGlobal pMac, eHalStatus status, tANI_U32 *data,
797 tpPESession psessionEntry)
798{
799 //Set the resume channel to Any valid channel (invalid).
800 //This will instruct HAL to set it to any previous valid channel.
801 peSetResumeChannel(pMac, 0, 0);
802 limResumeLink(pMac, limFTProcessPreAuthResult, (tANI_U32 *)psessionEntry);
803}
804
805tSirRetStatus limCreateRICBlockAckIE(tpAniSirGlobal pMac, tANI_U8 tid, tCfgTrafficClass *pTrafficClass,
806 tANI_U8 *ric_ies, tANI_U32 *ieLength)
807{
808 tDot11fIERICDataDesc ricIe;
809 tDot11fFfBAStartingSequenceControl baSsnControl;
810 tDot11fFfAddBAParameterSet baParamSet;
811 tDot11fFfBATimeout baTimeout;
812
813 vos_mem_zero(&ricIe, sizeof(tDot11fIERICDataDesc));
814 vos_mem_zero(&baSsnControl, sizeof(tDot11fFfBAStartingSequenceControl));
815 vos_mem_zero(&baParamSet, sizeof(tDot11fFfAddBAParameterSet));
816 vos_mem_zero(&baTimeout, sizeof(tDot11fFfBATimeout));
817
818 ricIe.present = 1;
819 ricIe.RICData.present = 1;
820 ricIe.RICData.resourceDescCount = 1;
821 ricIe.RICData.Identifier = LIM_FT_RIC_BA_DIALOG_TOKEN_TID_0 + tid;
822 ricIe.RICDescriptor.present = 1;
823 ricIe.RICDescriptor.resourceType = LIM_FT_RIC_DESCRIPTOR_RESOURCE_TYPE_BA;
824 baParamSet.tid = tid;
825 baParamSet.policy = pTrafficClass->fTxBApolicy; // Immediate Block Ack
826 baParamSet.bufferSize = pTrafficClass->txBufSize;
827 vos_mem_copy((v_VOID_t *)&baTimeout, (v_VOID_t *)&pTrafficClass->tuTxBAWaitTimeout, sizeof(baTimeout));
828 baSsnControl.fragNumber = 0;
829 baSsnControl.ssn = LIM_FT_RIC_BA_SSN;
Kiran Kumar Lokerea4db3dc2013-03-25 18:05:24 -0700830 if ( ricIe.RICDescriptor.num_variableData < sizeof (ricIe.RICDescriptor.variableData)) {
831 dot11fPackFfAddBAParameterSet(pMac, &baParamSet, &ricIe.RICDescriptor.variableData[ricIe.RICDescriptor.num_variableData]);
832 //vos_mem_copy(&ricIe.RICDescriptor.variableData[ricIe.RICDescriptor.num_variableData], &baParamSet, sizeof(tDot11fFfAddBAParameterSet));
833 ricIe.RICDescriptor.num_variableData += sizeof(tDot11fFfAddBAParameterSet);
834 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700835
Kiran Kumar Lokerea4db3dc2013-03-25 18:05:24 -0700836 if ( ricIe.RICDescriptor.num_variableData < sizeof (ricIe.RICDescriptor.variableData)) {
837 dot11fPackFfBATimeout(pMac, &baTimeout, &ricIe.RICDescriptor.variableData[ricIe.RICDescriptor.num_variableData]);
838 //vos_mem_copy(&ricIe.RICDescriptor.variableData[ricIe.RICDescriptor.num_variableData], &baTimeout, sizeof(tDot11fFfBATimeout));
839 ricIe.RICDescriptor.num_variableData += sizeof(tDot11fFfBATimeout);
840 }
841 if ( ricIe.RICDescriptor.num_variableData < sizeof (ricIe.RICDescriptor.variableData)) {
842 dot11fPackFfBAStartingSequenceControl(pMac, &baSsnControl, &ricIe.RICDescriptor.variableData[ricIe.RICDescriptor.num_variableData]);
843 //vos_mem_copy(&ricIe.RICDescriptor.variableData[ricIe.RICDescriptor.num_variableData], &baSsnControl, sizeof(tDot11fFfBAStartingSequenceControl));
844 ricIe.RICDescriptor.num_variableData += sizeof(tDot11fFfBAStartingSequenceControl);
845 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700846 return (tSirRetStatus) dot11fPackIeRICDataDesc(pMac, &ricIe, ric_ies, sizeof(tDot11fIERICDataDesc), ieLength);
847}
848
849tSirRetStatus limFTFillRICBlockAckInfo(tpAniSirGlobal pMac, tANI_U8 *ric_ies, tANI_U32 *ric_ies_length)
850{
851 tANI_U8 tid = 0;
852 tpDphHashNode pSta;
853 tANI_U16 numBA = 0, aid = 0;
854 tpPESession psessionEntry = pMac->ft.ftPEContext.psavedsessionEntry;
855 tANI_U32 offset = 0, ieLength = 0;
856 tSirRetStatus status = eSIR_SUCCESS;
857
858 // First, extract the DPH entry
859 pSta = dphLookupHashEntry( pMac, pMac->ft.ftPEContext.pFTPreAuthReq->currbssId, &aid, &psessionEntry->dph.dphHashTable);
860 if( NULL == pSta )
861 {
862 PELOGE(limLog( pMac, LOGE,
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700863 FL( "STA context not found for saved session's BSSID %02x:%02x:%02x:%02x:%02x:%02x" ),
Jeff Johnson295189b2012-06-20 16:38:30 -0700864 pMac->ft.ftPEContext.pFTPreAuthReq->currbssId[0],
865 pMac->ft.ftPEContext.pFTPreAuthReq->currbssId[1],
866 pMac->ft.ftPEContext.pFTPreAuthReq->currbssId[2],
867 pMac->ft.ftPEContext.pFTPreAuthReq->currbssId[3],
868 pMac->ft.ftPEContext.pFTPreAuthReq->currbssId[4],
869 pMac->ft.ftPEContext.pFTPreAuthReq->currbssId[5] );)
870 return eSIR_FAILURE;
871 }
872
873 for (tid = 0; tid < STACFG_MAX_TC; tid++)
874 {
875 if (pSta->tcCfg[tid].fUseBATx)
876 {
877 status = limCreateRICBlockAckIE(pMac, tid, &pSta->tcCfg[tid], ric_ies + offset, &ieLength);
878 if (eSIR_SUCCESS == status)
879 {
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700880 // TODO RIC
881 if ( ieLength > MAX_FTIE_SIZE )
882 {
883 ieLength = 0;
884 return status;
885 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700886 offset += ieLength;
887 *ric_ies_length += ieLength;
888 numBA++;
889 }
890 else
891 {
892 PELOGE(limLog(pMac, LOGE, FL("BA RIC IE creation for TID %d failed with status %d"), tid, status);)
893 }
894 }
895 }
896
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700897 PELOGE(limLog(pMac, LOGE, FL("Number of BA RIC IEs created = %d: Total length = %d"), numBA, *ric_ies_length);)
Jeff Johnson295189b2012-06-20 16:38:30 -0700898 return status;
899}
900
901/*------------------------------------------------------------------
902 *
903 * Will post pre auth response to SME.
904 *
905 *------------------------------------------------------------------*/
Srikant Kuppaa3ed0a32013-02-20 07:24:43 -0800906void limPostFTPreAuthRsp(tpAniSirGlobal pMac, tSirRetStatus status,
Jeff Johnson295189b2012-06-20 16:38:30 -0700907 tANI_U8 *auth_rsp, tANI_U16 auth_rsp_length,
908 tpPESession psessionEntry)
909{
910 tpSirFTPreAuthRsp pFTPreAuthRsp;
911 tSirMsgQ mmhMsg;
912 tANI_U16 rspLen = sizeof(tSirFTPreAuthRsp);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700913 // TODO: RIC Support
914 //tSirRetStatus sirStatus = eSIR_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -0700915
916 pFTPreAuthRsp = (tpSirFTPreAuthRsp)vos_mem_malloc(rspLen);
917 if(NULL == pFTPreAuthRsp)
918 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700919 PELOGE(limLog( pMac, LOGE, "Failed to allocate memory");)
Jeff Johnson295189b2012-06-20 16:38:30 -0700920 VOS_ASSERT(pFTPreAuthRsp != NULL);
921 return;
922 }
923 vos_mem_zero( pFTPreAuthRsp, rspLen);
924#if defined WLAN_FEATURE_VOWIFI_11R_DEBUG
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -0800925 PELOGE(limLog( pMac, LOG1, "%s: Auth Rsp = %p", pFTPreAuthRsp);)
Jeff Johnson295189b2012-06-20 16:38:30 -0700926#endif
927
928 palZeroMemory(pMac, (tANI_U8*)pFTPreAuthRsp, rspLen);
929 pFTPreAuthRsp->messageType = eWNI_SME_FT_PRE_AUTH_RSP;
930 pFTPreAuthRsp->length = (tANI_U16) rspLen;
931 pFTPreAuthRsp->status = status;
932 if (psessionEntry)
933 pFTPreAuthRsp->smeSessionId = psessionEntry->smeSessionId;
934
935 // The bssid of the AP we are sending Auth1 to.
936 if (pMac->ft.ftPEContext.pFTPreAuthReq)
937 sirCopyMacAddr(pFTPreAuthRsp->preAuthbssId,
938 pMac->ft.ftPEContext.pFTPreAuthReq->preAuthbssId);
939
940 // Attach the auth response now back to SME
941 pFTPreAuthRsp->ft_ies_length = 0;
942 if ((auth_rsp != NULL) && (auth_rsp_length < MAX_FTIE_SIZE))
943 {
944 // Only 11r assoc has FT IEs.
945 vos_mem_copy(pFTPreAuthRsp->ft_ies, auth_rsp, auth_rsp_length);
946 pFTPreAuthRsp->ft_ies_length = auth_rsp_length;
947 }
948
949#ifdef WLAN_FEATURE_VOWIFI_11R
950 if ((psessionEntry) && (psessionEntry->is11Rconnection))
951 {
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700952 /* TODO: RIC SUPPORT Fill in the Block Ack RIC IEs in the preAuthRsp */
953 /*
Jeff Johnson295189b2012-06-20 16:38:30 -0700954 sirStatus = limFTFillRICBlockAckInfo(pMac, pFTPreAuthRsp->ric_ies,
955 (tANI_U32 *)&pFTPreAuthRsp->ric_ies_length);
956 if (eSIR_SUCCESS != sirStatus)
957 {
958 PELOGE(limLog(pMac, LOGE, FL("Fill RIC BA Info failed with status %d"), sirStatus);)
959 }
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700960 */
Jeff Johnson295189b2012-06-20 16:38:30 -0700961 }
962#endif
963
964 mmhMsg.type = pFTPreAuthRsp->messageType;
965 mmhMsg.bodyptr = pFTPreAuthRsp;
966 mmhMsg.bodyval = 0;
967
968#if defined WLAN_FEATURE_VOWIFI_11R_DEBUG
Srikant Kuppaa3ed0a32013-02-20 07:24:43 -0800969 PELOGE(limLog( pMac, LOGE, "Posted Auth Rsp to SME with status of 0x%x", status);)
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -0800970#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700971 limSysProcessMmhMsgApi(pMac, &mmhMsg, ePROT);
972}
973
974/*------------------------------------------------------------------
975 *
976 * Send the FT Pre Auth Response to SME when ever we have a status
977 * ready to be sent to SME
978 *
979 * SME will be the one to send it up to the supplicant to receive
980 * FTIEs which will be required for Reassoc Req.
981 *
982 *------------------------------------------------------------------*/
Srikant Kuppaa3ed0a32013-02-20 07:24:43 -0800983void limHandleFTPreAuthRsp(tpAniSirGlobal pMac, tSirRetStatus status,
Jeff Johnson295189b2012-06-20 16:38:30 -0700984 tANI_U8 *auth_rsp, tANI_U16 auth_rsp_length,
985 tpPESession psessionEntry)
986{
987
Dhanashri Atreaf3e84d2013-01-18 18:03:06 -0800988 tpPESession pftSessionEntry;
989 tANI_U8 sessionId;
990 tpSirBssDescription pbssDescription;
991
Jeff Johnson295189b2012-06-20 16:38:30 -0700992 // Save the status of pre-auth
993 pMac->ft.ftPEContext.ftPreAuthStatus = status;
994
995 // Save the auth rsp, so we can send it to
996 // SME once we resume link.
997 pMac->ft.ftPEContext.saved_auth_rsp_length = 0;
998 if ((auth_rsp != NULL) && (auth_rsp_length < MAX_FTIE_SIZE))
999 {
1000 vos_mem_copy(pMac->ft.ftPEContext.saved_auth_rsp,
1001 auth_rsp, auth_rsp_length);
1002 pMac->ft.ftPEContext.saved_auth_rsp_length = auth_rsp_length;
1003 }
1004
Dhanashri Atreaf3e84d2013-01-18 18:03:06 -08001005 /* Create FT session for the re-association at this point */
1006 if (pMac->ft.ftPEContext.ftPreAuthStatus == eSIR_SUCCESS)
1007 {
1008 pbssDescription = pMac->ft.ftPEContext.pFTPreAuthReq->pbssDescription;
1009 if((pftSessionEntry = peCreateSession(pMac, pbssDescription->bssId,
1010 &sessionId, pMac->lim.maxStation)) == NULL)
1011 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001012 limLog(pMac, LOGE, FL("Session Can not be created for pre-auth 11R AP"));
Dhanashri Atreaf3e84d2013-01-18 18:03:06 -08001013 return;
1014 }
1015 pftSessionEntry->peSessionId = sessionId;
1016 sirCopyMacAddr(pftSessionEntry->selfMacAddr, psessionEntry->selfMacAddr);
1017 sirCopyMacAddr(pftSessionEntry->limReAssocbssId, pbssDescription->bssId);
1018 pftSessionEntry->bssType = psessionEntry->bssType;
1019
1020 if (pftSessionEntry->bssType == eSIR_INFRASTRUCTURE_MODE)
1021 {
1022 pftSessionEntry->limSystemRole = eLIM_STA_ROLE;
1023 }
1024 else if(pftSessionEntry->bssType == eSIR_BTAMP_AP_MODE)
1025 {
1026 pftSessionEntry->limSystemRole = eLIM_BT_AMP_STA_ROLE;
1027 }
1028 else
1029 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001030 limLog(pMac, LOGE, FL("Invalid bss type"));
Dhanashri Atreaf3e84d2013-01-18 18:03:06 -08001031 }
1032 pftSessionEntry->limPrevSmeState = pftSessionEntry->limSmeState;
1033 pftSessionEntry->limSmeState = eLIM_SME_WT_REASSOC_STATE;
1034 pMac->ft.ftPEContext.pftSessionEntry = pftSessionEntry;
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001035 PELOGE(limLog(pMac,LOGE,"%s:created session (%p) with id = %d",
Dhanashri Atreaf3e84d2013-01-18 18:03:06 -08001036 __func__, pftSessionEntry, pftSessionEntry->peSessionId);)
1037
1038 /* Update the ReAssoc BSSID of the current session */
1039 sirCopyMacAddr(psessionEntry->limReAssocbssId, pbssDescription->bssId);
1040 limPrintMacAddr(pMac, psessionEntry->limReAssocbssId, LOGE);
1041 }
1042
Jeff Johnson295189b2012-06-20 16:38:30 -07001043 if (psessionEntry->currentOperChannel !=
1044 pMac->ft.ftPEContext.pFTPreAuthReq->preAuthchannelNum)
1045 {
1046 // Need to move to the original AP channel
1047 limChangeChannelWithCallback(pMac, psessionEntry->currentOperChannel,
1048 limPerformPostFTPreAuthAndChannelChange, NULL, psessionEntry);
1049 }
1050 else
1051 {
1052#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001053 PELOGE(limLog( pMac, LOGE, "Pre auth on same channel as connected AP channel %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07001054 pMac->ft.ftPEContext.pFTPreAuthReq->preAuthchannelNum);)
1055#endif
1056 limFTProcessPreAuthResult(pMac, status, (tANI_U32 *)psessionEntry);
1057 }
1058}
1059
1060/*------------------------------------------------------------------
1061 *
1062 * This function handles the 11R Reassoc Req from SME
1063 *
1064 *------------------------------------------------------------------*/
1065void limProcessMlmFTReassocReq(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf,
1066 tpPESession psessionEntry)
1067{
1068 tANI_U8 smeSessionId = 0;
1069 tANI_U16 transactionId = 0;
1070 tANI_U8 chanNum = 0;
1071 tLimMlmReassocReq *pMlmReassocReq;
1072 tANI_U16 caps;
1073 tANI_U32 val;
1074 tSirMsgQ msgQ;
1075 tSirRetStatus retCode;
1076 tANI_U32 teleBcnEn = 0;
1077
1078 chanNum = psessionEntry->currentOperChannel;
1079 limGetSessionInfo(pMac,(tANI_U8*)pMsgBuf, &smeSessionId, &transactionId);
1080 psessionEntry->smeSessionId = smeSessionId;
1081 psessionEntry->transactionId = transactionId;
1082
1083
1084
1085 if( eHAL_STATUS_SUCCESS != palAllocateMemory( pMac->hHdd, (void **)&pMlmReassocReq,
1086 sizeof(tLimMlmReassocReq)))
1087 {
1088 // Log error
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001089 limLog(pMac, LOGE, FL("call to palAllocateMemory failed for mlmReassocReq"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001090 return;
1091 }
1092
1093 palCopyMemory( pMac->hHdd, pMlmReassocReq->peerMacAddr,
1094 psessionEntry->bssId,
1095 sizeof(tSirMacAddr));
1096
1097 if (wlan_cfgGetInt(pMac, WNI_CFG_REASSOCIATION_FAILURE_TIMEOUT,
1098 (tANI_U32 *) &pMlmReassocReq->reassocFailureTimeout)
1099 != eSIR_SUCCESS)
1100 {
1101 /**
1102 * Could not get ReassocFailureTimeout value
1103 * from CFG. Log error.
1104 */
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001105 limLog(pMac, LOGE, FL("could not retrieve ReassocFailureTimeout value"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001106 return;
1107 }
1108
1109 if (cfgGetCapabilityInfo(pMac, &caps,psessionEntry) != eSIR_SUCCESS)
1110 {
1111 /**
1112 * Could not get Capabilities value
1113 * from CFG. Log error.
1114 */
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001115 limLog(pMac, LOGE, FL("could not retrieve Capabilities value"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001116 return;
1117 }
1118 pMlmReassocReq->capabilityInfo = caps;
1119
1120 /* Update PE sessionId*/
1121 pMlmReassocReq->sessionId = psessionEntry->peSessionId;
1122
1123 /* If telescopic beaconing is enabled, set listen interval to WNI_CFG_TELE_BCN_MAX_LI */
1124 if(wlan_cfgGetInt(pMac, WNI_CFG_TELE_BCN_WAKEUP_EN, &teleBcnEn) !=
1125 eSIR_SUCCESS)
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001126 limLog(pMac, LOGP, FL("Couldn't get WNI_CFG_TELE_BCN_WAKEUP_EN"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001127
1128 if(teleBcnEn)
1129 {
1130 if(wlan_cfgGetInt(pMac, WNI_CFG_TELE_BCN_MAX_LI, &val) != eSIR_SUCCESS)
Varun Reddy Yeturuea6bd082013-01-28 10:31:22 -08001131 {
Jeff Johnson295189b2012-06-20 16:38:30 -07001132 /**
1133 * Could not get ListenInterval value
1134 * from CFG. Log error.
1135 */
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001136 limLog(pMac, LOGE, FL("could not retrieve ListenInterval"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001137 return;
Varun Reddy Yeturuea6bd082013-01-28 10:31:22 -08001138 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001139 }
1140 else
1141 {
1142 if (wlan_cfgGetInt(pMac, WNI_CFG_LISTEN_INTERVAL, &val) != eSIR_SUCCESS)
1143 {
1144 /**
1145 * Could not get ListenInterval value
1146 * from CFG. Log error.
1147 */
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001148 limLog(pMac, LOGE, FL("could not retrieve ListenInterval"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001149 return;
1150 }
1151 }
1152 if (limSetLinkState(pMac, eSIR_LINK_PREASSOC_STATE, psessionEntry->bssId,
1153 psessionEntry->selfMacAddr, NULL, NULL) != eSIR_SUCCESS)
1154 {
1155 return;
1156 }
1157
1158 if (limSetLinkState(pMac, eSIR_LINK_PREASSOC_STATE, psessionEntry->bssId,
1159 psessionEntry->selfMacAddr, NULL, NULL) != eSIR_SUCCESS)
1160 {
1161 return;
1162 }
1163
Jeff Johnson295189b2012-06-20 16:38:30 -07001164 pMlmReassocReq->listenInterval = (tANI_U16) val;
1165
1166 psessionEntry->pLimMlmReassocReq = pMlmReassocReq;
1167
1168
1169 //we need to defer the message until we get the response back from HAL.
1170 SET_LIM_PROCESS_DEFD_MESGS(pMac, false);
1171
1172 msgQ.type = SIR_HAL_ADD_BSS_REQ;
1173 msgQ.reserved = 0;
1174 msgQ.bodyptr = pMac->ft.ftPEContext.pAddBssReq;
1175 msgQ.bodyval = 0;
1176
1177
1178#if defined WLAN_FEATURE_VOWIFI_11R_DEBUG
1179 limLog( pMac, LOGE, FL( "Sending SIR_HAL_ADD_BSS_REQ..." ));
1180#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07001181 MTRACE(macTraceMsgTx(pMac, psessionEntry->peSessionId, msgQ.type));
Jeff Johnson295189b2012-06-20 16:38:30 -07001182
1183 retCode = wdaPostCtrlMsg( pMac, &msgQ );
1184 if( eSIR_SUCCESS != retCode)
1185 {
1186 vos_mem_free(pMac->ft.ftPEContext.pAddBssReq);
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001187 limLog( pMac, LOGE, FL("Posting ADD_BSS_REQ to HAL failed, reason=%X"),
Jeff Johnson295189b2012-06-20 16:38:30 -07001188 retCode );
1189 }
1190 // Dont need this anymore
1191 pMac->ft.ftPEContext.pAddBssReq = NULL;
1192 return;
1193}
1194
1195/*------------------------------------------------------------------
1196 *
1197 * This function is called if preauth response is not received from the AP
1198 * within this timeout while FT in progress
1199 *
1200 *------------------------------------------------------------------*/
1201void limProcessFTPreauthRspTimeout(tpAniSirGlobal pMac)
1202{
1203 tpPESession psessionEntry;
1204
1205 // We have failed pre auth. We need to resume link and get back on
1206 // home channel.
1207
1208 if((psessionEntry = peFindSessionBySessionId(pMac, pMac->lim.limTimers.gLimFTPreAuthRspTimer.sessionId))== NULL)
1209 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001210 limLog(pMac, LOGE, FL("Session Does not exist for given sessionID"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001211 return;
1212 }
1213
1214 // Ok, so attempted at Pre-Auth and failed. If we are off channel. We need
1215 // to get back.
1216 limHandleFTPreAuthRsp(pMac, eSIR_FAILURE, NULL, 0, psessionEntry);
1217}
1218
1219
1220/*------------------------------------------------------------------
1221 *
1222 * This function is called to process the update key request from SME
1223 *
1224 *------------------------------------------------------------------*/
1225tANI_BOOLEAN limProcessFTUpdateKey(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf )
1226{
1227 tAddBssParams * pAddBssParams;
1228 tSirFTUpdateKeyInfo * pKeyInfo;
1229 tANI_U32 val = 0;
1230
1231 /* Sanity Check */
1232 if( pMac == NULL || pMsgBuf == NULL )
1233 {
1234 return TRUE;
1235 }
1236
1237 pAddBssParams = pMac->ft.ftPEContext.pAddBssReq;
1238 pKeyInfo = (tSirFTUpdateKeyInfo *)pMsgBuf;
1239
1240 /* Store the key information in the ADD BSS parameters */
1241 pAddBssParams->extSetStaKeyParamValid = 1;
1242 pAddBssParams->extSetStaKeyParam.encType = pKeyInfo->keyMaterial.edType;
1243 palCopyMemory( pMac->hHdd, (tANI_U8 *) &pAddBssParams->extSetStaKeyParam.key,
1244 (tANI_U8 *) &pKeyInfo->keyMaterial.key, sizeof( tSirKeys ));
1245 if(eSIR_SUCCESS != wlan_cfgGetInt(pMac, WNI_CFG_SINGLE_TID_RC, &val))
1246 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001247 limLog( pMac, LOGP, FL( "Unable to read WNI_CFG_SINGLE_TID_RC" ));
Jeff Johnson295189b2012-06-20 16:38:30 -07001248 }
1249
1250 pAddBssParams->extSetStaKeyParam.singleTidRc = val;
1251
1252 return TRUE;
1253}
1254
1255tSirRetStatus
1256limProcessFTAggrQosReq(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf )
1257{
1258 tSirMsgQ msg;
1259 tSirAggrQosReq * aggrQosReq = (tSirAggrQosReq *)pMsgBuf;
1260 tpAggrAddTsParams pAggrAddTsParam;
1261 tpPESession psessionEntry = NULL;
1262 tpLimTspecInfo tspecInfo;
1263 tANI_U8 ac;
1264 tpDphHashNode pSta;
1265 tANI_U16 aid;
1266 tANI_U8 sessionId;
1267 int i;
1268
1269 if( eHAL_STATUS_SUCCESS != palAllocateMemory( pMac->hHdd,
1270 (void **)&pAggrAddTsParam,
1271 sizeof(tAggrAddTsParams)))
1272 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001273 PELOGE(limLog(pMac, LOGE, FL("palAllocateMemory() failed"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001274 return eSIR_MEM_ALLOC_FAILED;
1275 }
1276
1277 psessionEntry = peFindSessionByBssid(pMac, aggrQosReq->bssId, &sessionId);
1278
1279 if (psessionEntry == NULL) {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001280 PELOGE(limLog(pMac, LOGE, FL("psession Entry Null for sessionId = %d"), aggrQosReq->sessionId);)
Gopichand Nakkala6a4f4902013-03-28 12:08:37 +05301281 palFreeMemory(pMac->hHdd, (tANI_U8*)pAggrAddTsParam);
Jeff Johnson295189b2012-06-20 16:38:30 -07001282 return eSIR_FAILURE;
1283 }
1284
1285 pSta = dphLookupHashEntry(pMac, aggrQosReq->bssId, &aid, &psessionEntry->dph.dphHashTable);
1286 if (pSta == NULL)
1287 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001288 PELOGE(limLog(pMac, LOGE, FL("Station context not found - ignoring AddTsRsp"));)
Gopichand Nakkala6a4f4902013-03-28 12:08:37 +05301289 palFreeMemory(pMac->hHdd, (tANI_U8*)pAggrAddTsParam);
Jeff Johnson295189b2012-06-20 16:38:30 -07001290 return eSIR_FAILURE;
1291 }
1292
1293 palZeroMemory( pMac->hHdd, (tANI_U8 *)pAggrAddTsParam,
1294 sizeof(tAggrAddTsParams));
1295 pAggrAddTsParam->staIdx = psessionEntry->staId;
1296 // Fill in the sessionId specific to PE
1297 pAggrAddTsParam->sessionId = sessionId;
1298 pAggrAddTsParam->tspecIdx = aggrQosReq->aggrInfo.tspecIdx;
1299
1300 for( i = 0; i < HAL_QOS_NUM_AC_MAX; i++ )
1301 {
1302 if (aggrQosReq->aggrInfo.tspecIdx & (1<<i))
1303 {
1304 tSirMacTspecIE *pTspec = &aggrQosReq->aggrInfo.aggrAddTsInfo[i].tspec;
1305 /* Since AddTS response was successful, check for the PSB flag
1306 * and directional flag inside the TS Info field.
1307 * An AC is trigger enabled AC if the PSB subfield is set to 1
1308 * in the uplink direction.
1309 * An AC is delivery enabled AC if the PSB subfield is set to 1
1310 * in the downlink direction.
1311 * An AC is trigger and delivery enabled AC if the PSB subfield
1312 * is set to 1 in the bi-direction field.
1313 */
1314 if (pTspec->tsinfo.traffic.psb == 1)
1315 {
1316 limSetTspecUapsdMask(pMac, &pTspec->tsinfo, SET_UAPSD_MASK);
1317 }
1318 else
1319 {
1320 limSetTspecUapsdMask(pMac, &pTspec->tsinfo, CLEAR_UAPSD_MASK);
1321 }
1322 /* ADDTS success, so AC is now admitted. We shall now use the default
1323 * EDCA parameters as advertised by AP and send the updated EDCA params
1324 * to HAL.
1325 */
1326 ac = upToAc(pTspec->tsinfo.traffic.userPrio);
1327 if(pTspec->tsinfo.traffic.direction == SIR_MAC_DIRECTION_UPLINK)
1328 {
1329 pMac->lim.gAcAdmitMask[SIR_MAC_DIRECTION_UPLINK] |= (1 << ac);
1330 }
1331 else if(pTspec->tsinfo.traffic.direction == SIR_MAC_DIRECTION_DNLINK)
1332 {
1333 pMac->lim.gAcAdmitMask[SIR_MAC_DIRECTION_DNLINK] |= (1 << ac);
1334 }
1335 else if(pTspec->tsinfo.traffic.direction == SIR_MAC_DIRECTION_BIDIR)
1336 {
1337 pMac->lim.gAcAdmitMask[SIR_MAC_DIRECTION_UPLINK] |= (1 << ac);
1338 pMac->lim.gAcAdmitMask[SIR_MAC_DIRECTION_DNLINK] |= (1 << ac);
1339 }
1340
1341 limSetActiveEdcaParams(pMac, psessionEntry->gLimEdcaParams, psessionEntry);
1342
1343 if (pSta->aniPeer == eANI_BOOLEAN_TRUE)
1344 {
1345 limSendEdcaParams(pMac, psessionEntry->gLimEdcaParamsActive, pSta->bssId, eANI_BOOLEAN_TRUE);
1346 }
1347 else
1348 {
1349 limSendEdcaParams(pMac, psessionEntry->gLimEdcaParamsActive, pSta->bssId, eANI_BOOLEAN_FALSE);
1350 }
1351
1352 if(eSIR_SUCCESS != limTspecAdd(pMac, pSta->staAddr, pSta->assocId, pTspec, 0, &tspecInfo))
1353 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001354 PELOGE(limLog(pMac, LOGE, FL("Adding entry in lim Tspec Table failed "));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001355 pMac->lim.gLimAddtsSent = false;
Gopichand Nakkala6a4f4902013-03-28 12:08:37 +05301356 palFreeMemory(pMac->hHdd, (tANI_U8*)pAggrAddTsParam);
Jeff Johnson295189b2012-06-20 16:38:30 -07001357 return eSIR_FAILURE; //Error handling. send the response with error status. need to send DelTS to tear down the TSPEC status.
1358 }
1359
1360 // Copy the TSPEC paramters
1361 pAggrAddTsParam->tspec[i] = aggrQosReq->aggrInfo.aggrAddTsInfo[i].tspec;
1362 }
1363 }
1364
1365 msg.type = WDA_AGGR_QOS_REQ;
1366 msg.bodyptr = pAggrAddTsParam;
1367 msg.bodyval = 0;
1368
1369 /* We need to defer any incoming messages until we get a
1370 * WDA_AGGR_QOS_RSP from HAL.
1371 */
1372 SET_LIM_PROCESS_DEFD_MESGS(pMac, false);
Jeff Johnsone7245742012-09-05 17:12:55 -07001373 MTRACE(macTraceMsgTx(pMac, psessionEntry->peSessionId, msg.type));
Jeff Johnson295189b2012-06-20 16:38:30 -07001374
1375 if(eSIR_SUCCESS != wdaPostCtrlMsg(pMac, &msg))
1376 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001377 PELOGW(limLog(pMac, LOGW, FL("wdaPostCtrlMsg() failed"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001378 SET_LIM_PROCESS_DEFD_MESGS(pMac, true);
1379 palFreeMemory(pMac->hHdd, (tANI_U8*)pAggrAddTsParam);
1380 return eSIR_FAILURE;
1381 }
1382
1383 return eSIR_SUCCESS;
1384}
1385
1386void
1387limFTSendAggrQosRsp(tpAniSirGlobal pMac, tANI_U8 rspReqd,
1388 tpAggrAddTsParams aggrQosRsp, tANI_U8 smesessionId)
1389{
1390 tpSirAggrQosRsp rsp;
1391 int i = 0;
1392
1393 if (! rspReqd)
1394 {
1395 return;
1396 }
1397
1398 if( eHAL_STATUS_SUCCESS != palAllocateMemory( pMac->hHdd, (void **)&rsp,
1399 sizeof(tSirAggrQosRsp)))
1400 {
1401 limLog(pMac, LOGP, FL("palAllocateMemory failed for tSirAggrQosRsp"));
1402 return;
1403 }
1404
1405 palZeroMemory( pMac->hHdd, (tANI_U8 *) rsp, sizeof(*rsp));
1406 rsp->messageType = eWNI_SME_FT_AGGR_QOS_RSP;
1407 rsp->sessionId = smesessionId;
1408 rsp->length = sizeof(*rsp);
1409 rsp->aggrInfo.tspecIdx = aggrQosRsp->tspecIdx;
1410
1411 for( i = 0; i < SIR_QOS_NUM_AC_MAX; i++ )
1412 {
1413 if( (1 << i) & aggrQosRsp->tspecIdx )
1414 {
1415 rsp->aggrInfo.aggrRsp[i].status = aggrQosRsp->status[i];
1416 rsp->aggrInfo.aggrRsp[i].tspec = aggrQosRsp->tspec[i];
1417 }
1418 }
1419
1420 limSendSmeAggrQosRsp(pMac, rsp, smesessionId);
1421 return;
1422}
1423
1424
1425void limProcessFTAggrQoSRsp(tpAniSirGlobal pMac, tpSirMsgQ limMsg)
1426{
1427 tpAggrAddTsParams pAggrQosRspMsg = NULL;
1428 //tpAggrQosParams pAggrQosRspMsg = NULL;
1429 tAddTsParams addTsParam = {0};
1430 tpDphHashNode pSta = NULL;
1431 tANI_U16 assocId =0;
1432 tSirMacAddr peerMacAddr;
1433 tANI_U8 rspReqd = 1;
1434 tpPESession psessionEntry = NULL;
1435 int i = 0;
1436
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001437 PELOG1(limLog(pMac, LOG1, FL(" Received AGGR_QOS_RSP from HAL"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001438
1439 /* Need to process all the deferred messages enqueued since sending the
1440 SIR_HAL_AGGR_ADD_TS_REQ */
1441 SET_LIM_PROCESS_DEFD_MESGS(pMac, true);
1442
1443 pAggrQosRspMsg = (tpAggrAddTsParams) (limMsg->bodyptr);
1444 if (NULL == pAggrQosRspMsg)
1445 {
1446 PELOGE(limLog(pMac, LOGE, FL("NULL pAggrQosRspMsg"));)
1447 return;
1448 }
1449
1450 psessionEntry = peFindSessionBySessionId(pMac, pAggrQosRspMsg->sessionId);
1451 if (NULL == psessionEntry)
1452 {
1453 // Cant find session entry
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001454 PELOGE(limLog(pMac, LOGE, FL("Cant find session entry for %s"), __func__);)
Jeff Johnson295189b2012-06-20 16:38:30 -07001455 if( pAggrQosRspMsg != NULL )
1456 {
1457 palFreeMemory( pMac->hHdd, (void *)pAggrQosRspMsg );
1458 }
1459 return;
1460 }
1461
1462 for( i = 0; i < HAL_QOS_NUM_AC_MAX; i++ )
1463 {
1464 if((((1 << i) & pAggrQosRspMsg->tspecIdx)) &&
1465 (pAggrQosRspMsg->status[i] != eHAL_STATUS_SUCCESS))
1466 {
1467 /* send DELTS to the station */
1468 sirCopyMacAddr(peerMacAddr,psessionEntry->bssId);
1469
1470 addTsParam.staIdx = pAggrQosRspMsg->staIdx;
1471 addTsParam.sessionId = pAggrQosRspMsg->sessionId;
1472 addTsParam.tspec = pAggrQosRspMsg->tspec[i];
1473 addTsParam.tspecIdx = pAggrQosRspMsg->tspecIdx;
1474
1475 limSendDeltsReqActionFrame(pMac, peerMacAddr, rspReqd,
1476 &addTsParam.tspec.tsinfo,
1477 &addTsParam.tspec, psessionEntry);
1478
1479 pSta = dphLookupAssocId(pMac, addTsParam.staIdx, &assocId,
1480 &psessionEntry->dph.dphHashTable);
1481 if (pSta != NULL)
1482 {
1483 limAdmitControlDeleteTS(pMac, assocId, &addTsParam.tspec.tsinfo,
1484 NULL, (tANI_U8 *)&addTsParam.tspecIdx);
1485 }
1486 }
1487 }
1488
1489 /* Send the Aggr QoS response to SME */
1490
1491 limFTSendAggrQosRsp(pMac, rspReqd, pAggrQosRspMsg,
1492 psessionEntry->smeSessionId);
1493 if( pAggrQosRspMsg != NULL )
1494 {
1495 palFreeMemory( pMac->hHdd, (void *)pAggrQosRspMsg );
1496 }
1497 return;
1498}
1499
1500
1501/*--------------------------------------------------------------------------
1502 Determines if a session with ccx or 11r assoc is present.
1503 If present it will return TRUE else FALSE
1504 ------------------------------------------------------------------------*/
1505int limisFastTransitionRequired(tpAniSirGlobal pMac, int sessionId)
1506{
1507 if(pMac->lim.gpSession[sessionId].valid == TRUE)
1508 {
1509 // If ccx or 11r connection is found we need to return TRUE
1510 if((pMac->lim.gpSession[sessionId].bssType == eSIR_INFRASTRUCTURE_MODE) &&
1511 (((pMac->lim.gpSession[sessionId].is11Rconnection)
1512#ifdef FEATURE_WLAN_CCX
1513 || (pMac->lim.gpSession[sessionId].isCCXconnection)
1514#endif
Jeff Johnson43971f52012-07-17 12:26:56 -07001515#ifdef FEATURE_WLAN_LFR
1516 || (pMac->lim.gpSession[sessionId].isFastRoamIniFeatureEnabled)
1517#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001518 )&&
1519 pMac->lim.gpSession[sessionId].isFastTransitionEnabled))
1520 {
1521 // Make sure we have 11r/CCX and FT enabled only then we need
1522 // the values to be altered from cfg for FW RSSI Period alteration.
1523 return TRUE;
1524 }
1525 }
1526
1527 return FALSE;
1528}
1529
1530#endif /* WLAN_FEATURE_VOWIFI_11R */