blob: 31cc75b4e83d6147aa69dc71bd146178ca1fb01f [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Padma, Santhosh Kumar04822572017-05-12 19:15:22 +05302 * Copyright (c) 2012-2017 The Linux Foundation. All rights reserved.
Kiet Lam842dad02014-02-18 18:44:02 -08003 *
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.
Kiet Lamaa8e15a2014-02-11 23:30:06 -080020 */
Kiet Lam842dad02014-02-18 18:44:02 -080021
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
Jeff Johnson295189b2012-06-20 16:38:30 -070028#ifdef WLAN_FEATURE_VOWIFI_11R
29/**=========================================================================
30
Kiet Lam842dad02014-02-18 18:44:02 -080031 \brief implementation for PE 11r VoWiFi FT Protocol
Jeff Johnson295189b2012-06-20 16:38:30 -070032
33 ========================================================================*/
34
35/* $Header$ */
36
37
38/*--------------------------------------------------------------------------
39 Include Files
40 ------------------------------------------------------------------------*/
41#include <limSendMessages.h>
42#include <limTypes.h>
43#include <limFT.h>
44#include <limFTDefs.h>
45#include <limUtils.h>
46#include <limPropExtsUtils.h>
47#include <limAssocUtils.h>
48#include <limSession.h>
49#include <limAdmitControl.h>
50#include "wmmApsd.h"
Mukul Sharma38a6bbc2014-06-30 00:25:39 +053051#include "vos_utils.h"
Mukul Sharma38a6bbc2014-06-30 00:25:39 +053052
Jeff Johnson295189b2012-06-20 16:38:30 -070053#define LIM_FT_RIC_BA_SSN 1
54#define LIM_FT_RIC_BA_DIALOG_TOKEN_TID_0 248
55#define LIM_FT_RIC_DESCRIPTOR_RESOURCE_TYPE_BA 1
Gopichand Nakkala3d295922013-05-07 16:19:14 +053056#define LIM_FT_RIC_DESCRIPTOR_MAX_VAR_DATA_LEN 255
Jeff Johnson295189b2012-06-20 16:38:30 -070057
58/*--------------------------------------------------------------------------
59 Initialize the FT variables.
60 ------------------------------------------------------------------------*/
61void limFTOpen(tpAniSirGlobal pMac)
62{
63 pMac->ft.ftPEContext.pFTPreAuthReq = NULL;
64 pMac->ft.ftPEContext.psavedsessionEntry = NULL;
65}
66
67/*--------------------------------------------------------------------------
68 Cleanup FT variables.
69 ------------------------------------------------------------------------*/
70void limFTCleanup(tpAniSirGlobal pMac)
71{
72 if (pMac->ft.ftPEContext.pFTPreAuthReq)
73 {
74#if defined WLAN_FEATURE_VOWIFI_11R_DEBUG
Jeff Johnson0fe596e2017-09-19 08:36:48 -070075 PELOGE(limLog( pMac, LOGE, "%s: Freeing pFTPreAuthReq= %pK",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070076 __func__, pMac->ft.ftPEContext.pFTPreAuthReq);)
Jeff Johnson295189b2012-06-20 16:38:30 -070077#endif
Dhanashri Atree3a2a592013-03-08 13:18:42 -080078 if (pMac->ft.ftPEContext.pFTPreAuthReq->pbssDescription)
79 {
80 vos_mem_free(pMac->ft.ftPEContext.pFTPreAuthReq->pbssDescription);
81 pMac->ft.ftPEContext.pFTPreAuthReq->pbssDescription = NULL;
82 }
Jeff Johnson295189b2012-06-20 16:38:30 -070083 vos_mem_free(pMac->ft.ftPEContext.pFTPreAuthReq);
84 pMac->ft.ftPEContext.pFTPreAuthReq = NULL;
85 }
86
87 // This is the old session, should be deleted else where.
88 // We should not be cleaning it here, just set it to NULL.
89 if (pMac->ft.ftPEContext.psavedsessionEntry)
90 {
91#if defined WLAN_FEATURE_VOWIFI_11R_DEBUG
Jeff Johnson0fe596e2017-09-19 08:36:48 -070092 PELOGE(limLog( pMac, LOGE, "%s: Setting psavedsessionEntry= %pK to NULL",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070093 __func__, pMac->ft.ftPEContext.psavedsessionEntry);)
Jeff Johnson295189b2012-06-20 16:38:30 -070094#endif
95 pMac->ft.ftPEContext.psavedsessionEntry = NULL;
96 }
97
98 // This is the extra session we added as part of Auth resp
99 // clean it up.
100 if (pMac->ft.ftPEContext.pftSessionEntry)
101 {
102 if ((((tpPESession)(pMac->ft.ftPEContext.pftSessionEntry))->valid) &&
103 (((tpPESession)(pMac->ft.ftPEContext.pftSessionEntry))->limSmeState == eLIM_SME_WT_REASSOC_STATE))
104 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700105 PELOGE(limLog( pMac, LOGE, "%s: Deleting Preauth Session %d", __func__, ((tpPESession)pMac->ft.ftPEContext.pftSessionEntry)->peSessionId);)
Jeff Johnson295189b2012-06-20 16:38:30 -0700106 peDeleteSession(pMac, pMac->ft.ftPEContext.pftSessionEntry);
107 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700108#if defined WLAN_FEATURE_VOWIFI_11R_DEBUG
Jeff Johnson0fe596e2017-09-19 08:36:48 -0700109 PELOGE(limLog( pMac, LOGE, "%s: Setting pftSessionEntry= %pK to NULL",
Kanchanapally, Vidyullathaa7f6d212015-03-17 11:35:25 +0530110 __func__, pMac->ft.ftPEContext.pftSessionEntry);)
Jeff Johnson295189b2012-06-20 16:38:30 -0700111#endif
Kanchanapally, Vidyullathaa7f6d212015-03-17 11:35:25 +0530112 pMac->ft.ftPEContext.pftSessionEntry = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -0700113 }
114
115 if (pMac->ft.ftPEContext.pAddBssReq)
116 {
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +0530117 vos_mem_zero(pMac->ft.ftPEContext.pAddBssReq, sizeof(tAddBssParams));
Jeff Johnson295189b2012-06-20 16:38:30 -0700118 vos_mem_free(pMac->ft.ftPEContext.pAddBssReq);
119 pMac->ft.ftPEContext.pAddBssReq = NULL;
120 }
121
122 if (pMac->ft.ftPEContext.pAddStaReq)
123 {
124 vos_mem_free(pMac->ft.ftPEContext.pAddStaReq);
125 pMac->ft.ftPEContext.pAddStaReq = NULL;
126 }
127
Kanchanapally, Vidyullathaa7f6d212015-03-17 11:35:25 +0530128 vos_mem_zero(&pMac->ft.ftPEContext, sizeof(tftPEContext));
Jeff Johnson295189b2012-06-20 16:38:30 -0700129}
130
131/*--------------------------------------------------------------------------
132 Init FT variables.
133 ------------------------------------------------------------------------*/
134void limFTInit(tpAniSirGlobal pMac)
135{
136 if (pMac->ft.ftPEContext.pFTPreAuthReq)
137 {
138#if defined WLAN_FEATURE_VOWIFI_11R_DEBUG
Jeff Johnson0fe596e2017-09-19 08:36:48 -0700139 PELOGE(limLog( pMac, LOGE, "%s: Freeing pFTPreAuthReq= %pK",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700140 __func__, pMac->ft.ftPEContext.pFTPreAuthReq);)
Jeff Johnson295189b2012-06-20 16:38:30 -0700141#endif
Dhanashri Atree3a2a592013-03-08 13:18:42 -0800142 if (pMac->ft.ftPEContext.pFTPreAuthReq->pbssDescription)
143 {
144 vos_mem_free(pMac->ft.ftPEContext.pFTPreAuthReq->pbssDescription);
145 pMac->ft.ftPEContext.pFTPreAuthReq->pbssDescription = NULL;
146 }
147
Jeff Johnson295189b2012-06-20 16:38:30 -0700148 vos_mem_free(pMac->ft.ftPEContext.pFTPreAuthReq);
149 pMac->ft.ftPEContext.pFTPreAuthReq = NULL;
150 }
151
152 // This is the old session, should be deleted else where.
153 // We should not be cleaning it here, just set it to NULL.
154 if (pMac->ft.ftPEContext.psavedsessionEntry)
155 {
156#if defined WLAN_FEATURE_VOWIFI_11R_DEBUG
Jeff Johnson0fe596e2017-09-19 08:36:48 -0700157 PELOGE(limLog( pMac, LOGE, "%s: Setting psavedsessionEntry= %pK to NULL",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700158 __func__, pMac->ft.ftPEContext.psavedsessionEntry);)
Jeff Johnson295189b2012-06-20 16:38:30 -0700159#endif
160 pMac->ft.ftPEContext.psavedsessionEntry = NULL;
161 }
162
163 // This is the extra session we added as part of Auth resp
164 // clean it up.
165 if (pMac->ft.ftPEContext.pftSessionEntry)
166 {
Abhishek Singh8a226222014-03-13 14:49:16 +0530167
Jeff Johnson295189b2012-06-20 16:38:30 -0700168#if defined WLAN_FEATURE_VOWIFI_11R_DEBUG
Jeff Johnson0fe596e2017-09-19 08:36:48 -0700169 PELOGE(limLog( pMac, LOGE, "%s: Deleting session = %pK ",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700170 __func__, pMac->ft.ftPEContext.pftSessionEntry);)
Jeff Johnson295189b2012-06-20 16:38:30 -0700171#endif
Abhishek Singh8a226222014-03-13 14:49:16 +0530172 /* Delete the previous valid preauth pesession if it is still in
173 * mMlmState= eLIM_MLM_WT_ADD_BSS_RSP_FT_REASSOC_STATE
174 * and limSmeState = eLIM_SME_WT_REASSOC_STATE. This means last
175 * preauth didnt went through and its Session was not deleted.
176 */
177 if ((((tpPESession)(pMac->ft.ftPEContext.pftSessionEntry))->valid) &&
178 (((tpPESession)(pMac->ft.ftPEContext.pftSessionEntry))->limSmeState
179 == eLIM_SME_WT_REASSOC_STATE) &&
180 (((tpPESession)(pMac->ft.ftPEContext.pftSessionEntry))->limMlmState
181 == eLIM_MLM_WT_ADD_BSS_RSP_FT_REASSOC_STATE) )
182 {
183 limLog( pMac, LOGE, FL("Deleting Preauth Session %d"),
184 ((tpPESession)pMac->ft.ftPEContext.pftSessionEntry)->peSessionId);
185 peDeleteSession(pMac, pMac->ft.ftPEContext.pftSessionEntry);
186 }
187
Jeff Johnson295189b2012-06-20 16:38:30 -0700188 pMac->ft.ftPEContext.pftSessionEntry = NULL;
189 }
190
191 if (pMac->ft.ftPEContext.pAddBssReq)
192 {
193#if defined WLAN_FEATURE_VOWIFI_11R_DEBUG
Jeff Johnson0fe596e2017-09-19 08:36:48 -0700194 PELOGE(limLog( pMac, LOGE, "%s: Freeing AddBssReq = %pK ",
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
Jeff Johnson0fe596e2017-09-19 08:36:48 -0700205 PELOGE(limLog( pMac, LOGE, "%s: Freeing AddStaReq = %pK ",
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);
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +0530271 // Can set it only after sending auth
272 pMac->ft.ftPEContext.ftPreAuthStatus = eSIR_FAILURE;
273
Jeff Johnson295189b2012-06-20 16:38:30 -0700274 // We need information from the Pre-Auth Req. Lets save that
275 pMac->ft.ftPEContext.pFTPreAuthReq = (tpSirFTPreAuthReq)pMsg->bodyptr;
276
277#if defined WLAN_FEATURE_VOWIFI_11R_DEBUG
Kanchanapally, Vidyullatha31b8d142015-01-30 14:25:18 +0530278 PELOGE(limLog( pMac, LOG1, "%s: PRE Auth ft_ies_length=%02x%02x%02x", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -0700279 pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies[0],
280 pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies[1],
281 pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies[2]);)
282#endif
283
284 // Get the current session entry
285 psessionEntry = peFindSessionByBssid(pMac,
286 pMac->ft.ftPEContext.pFTPreAuthReq->currbssId, &sessionId);
287 if (psessionEntry == NULL)
288 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700289 PELOGE(limLog( pMac, LOGE, "%s: Unable to find session for the following bssid",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700290 __func__);)
Jeff Johnson295189b2012-06-20 16:38:30 -0700291 limPrintMacAddr( pMac, pMac->ft.ftPEContext.pFTPreAuthReq->currbssId, LOGE );
292 // Post the FT Pre Auth Response to SME
Gopichand Nakkala2d335f32013-01-04 12:24:28 -0800293 limPostFTPreAuthRsp(pMac, eSIR_FAILURE, NULL, 0, NULL);
Kanchanapally, Vidyullathaa7f6d212015-03-17 11:35:25 +0530294
295 /* return FALSE, since the Pre-Auth Req will be freed in
296 * limPostFTPreAuthRsp on failure
297 */
298 return bufConsumed;
Jeff Johnson295189b2012-06-20 16:38:30 -0700299 }
300
301 // Dont need to suspend if APs are in same channel
302 if (psessionEntry->currentOperChannel != pMac->ft.ftPEContext.pFTPreAuthReq->preAuthchannelNum)
303 {
304 // Need to suspend link only if the channels are different
Abhishek Singh525045c2014-12-15 17:18:45 +0530305 limLog(pMac, LOG1, FL(" Performing pre-auth on different"
Jeff Johnson0fe596e2017-09-19 08:36:48 -0700306 " channel (session %pK)"), psessionEntry);
Madan Mohan Koyyalamudi9b876782012-10-11 16:22:51 -0700307 limSuspendLink(pMac, eSIR_CHECK_ROAMING_SCAN, FTPreAuthSuspendLinkHandler,
Jeff Johnson295189b2012-06-20 16:38:30 -0700308 (tANI_U32 *)psessionEntry);
309 }
310 else
311 {
Abhishek Singh525045c2014-12-15 17:18:45 +0530312 limLog(pMac, LOG1, FL(" Performing pre-auth on same"
Jeff Johnson0fe596e2017-09-19 08:36:48 -0700313 " channel (session %pK)"), psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -0700314 // We are in the same channel. Perform pre-auth
315 limPerformFTPreAuth(pMac, eHAL_STATUS_SUCCESS, NULL, psessionEntry);
316 }
317
318 return bufConsumed;
319}
320
321/*------------------------------------------------------------------
322 * Send the Auth1
323 * Receive back Auth2
324 *------------------------------------------------------------------*/
325void limPerformFTPreAuth(tpAniSirGlobal pMac, eHalStatus status, tANI_U32 *data,
326 tpPESession psessionEntry)
327{
328 tSirMacAuthFrameBody authFrame;
329
330 if (psessionEntry->is11Rconnection)
331 {
332 // Only 11r assoc has FT IEs.
333 if (pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies == NULL)
334 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -0800335 PELOGE(limLog( pMac, LOGE,
336 "%s: FTIEs for Auth Req Seq 1 is absent",
337 __func__);)
Ganesh Kondabattini2bc754b2014-07-31 14:05:09 +0530338 goto preauth_fail;
Jeff Johnson295189b2012-06-20 16:38:30 -0700339 }
340 }
341 if (status != eHAL_STATUS_SUCCESS)
342 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -0800343 PELOGE(limLog( pMac, LOGE,
344 "%s: Change channel not successful for FT pre-auth",
345 __func__);)
Ganesh Kondabattini2bc754b2014-07-31 14:05:09 +0530346 goto preauth_fail;
Jeff Johnson295189b2012-06-20 16:38:30 -0700347 }
348 pMac->ft.ftPEContext.psavedsessionEntry = psessionEntry;
349
350#if defined WLAN_FEATURE_VOWIFI_11R_DEBUG
Abhishek Singh525045c2014-12-15 17:18:45 +0530351 limLog(pMac, LOG1, FL("Entered wait auth2 state for FT"
Jeff Johnson0fe596e2017-09-19 08:36:48 -0700352 " (old session %pK)"),
Abhishek Singh525045c2014-12-15 17:18:45 +0530353 pMac->ft.ftPEContext.psavedsessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -0700354#endif
355
356
357 if (psessionEntry->is11Rconnection)
358 {
359 // Now we are on the right channel and need to send out Auth1 and
360 // receive Auth2.
361 authFrame.authAlgoNumber = eSIR_FT_AUTH; // Set the auth type to FT
362 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800363#if defined FEATURE_WLAN_ESE || defined FEATURE_WLAN_LFR
Jeff Johnson295189b2012-06-20 16:38:30 -0700364 else
365 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800366 // Will need to make isESEconnection a enum may be for further
Jeff Johnson295189b2012-06-20 16:38:30 -0700367 // improvements to this to match this algorithm number
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800368 authFrame.authAlgoNumber = eSIR_OPEN_SYSTEM; // For now if its ESE and 11r FT.
Jeff Johnson295189b2012-06-20 16:38:30 -0700369 }
370#endif
371 authFrame.authTransactionSeqNumber = SIR_MAC_AUTH_FRAME_1;
372 authFrame.authStatusCode = 0;
373
374 // Start timer here to come back to operating channel.
375 pMac->lim.limTimers.gLimFTPreAuthRspTimer.sessionId = psessionEntry->peSessionId;
376 if(TX_SUCCESS != tx_timer_activate(&pMac->lim.limTimers.gLimFTPreAuthRspTimer))
377 {
378#if defined WLAN_FEATURE_VOWIFI_11R_DEBUG
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700379 PELOGE(limLog( pMac, LOGE, "%s: FT Auth Rsp Timer Start Failed", __func__);)
Jeff Johnson295189b2012-06-20 16:38:30 -0700380#endif
Kanchanapally, Vidyullathac796fc62015-03-17 10:45:28 +0530381 pMac->ft.ftPEContext.psavedsessionEntry = NULL;
382 goto preauth_fail;
Jeff Johnson295189b2012-06-20 16:38:30 -0700383 }
Varun Reddy Yeturue3bbf6e2013-02-08 18:50:55 -0800384MTRACE(macTrace(pMac, TRACE_CODE_TIMER_ACTIVATE, psessionEntry->peSessionId, eLIM_FT_PREAUTH_RSP_TIMER));
Jeff Johnson295189b2012-06-20 16:38:30 -0700385
386#if defined WLAN_FEATURE_VOWIFI_11R_DEBUG
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -0800387 PELOGE(limLog( pMac, LOG1, "%s: FT Auth Rsp Timer Started", __func__);)
Jeff Johnson295189b2012-06-20 16:38:30 -0700388#endif
Deepthi Gowri639d5042015-11-16 20:23:39 +0530389#ifdef FEATURE_WLAN_DIAG_SUPPORT
390 limDiagEventReport(pMac, WLAN_PE_DIAG_ROAM_AUTH_START_EVENT,
391 pMac->lim.pSessionEntry, eSIR_SUCCESS, eSIR_SUCCESS);
392#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700393
394 limSendAuthMgmtFrame(pMac, &authFrame,
395 pMac->ft.ftPEContext.pFTPreAuthReq->preAuthbssId,
Sushant Kaushik9e923872015-04-02 17:09:31 +0530396 LIM_NO_WEP_IN_FC, psessionEntry, eSIR_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -0700397
398 return;
Ganesh Kondabattini2bc754b2014-07-31 14:05:09 +0530399preauth_fail:
400 limHandleFTPreAuthRsp(pMac, eSIR_FAILURE, NULL, 0, psessionEntry);
401 return;
Jeff Johnson295189b2012-06-20 16:38:30 -0700402}
403
404
405/*------------------------------------------------------------------
406 *
407 * Create the new Add Bss Req to the new AP.
408 * This will be used when we are ready to FT to the new AP.
409 * The newly created ft Session entry is passed to this function
410 *
411 *------------------------------------------------------------------*/
412tSirRetStatus limFTPrepareAddBssReq( tpAniSirGlobal pMac,
413 tANI_U8 updateEntry, tpPESession pftSessionEntry,
414 tpSirBssDescription bssDescription )
415{
416 tpAddBssParams pAddBssParams = NULL;
417 tANI_U8 i;
418 tANI_U8 chanWidthSupp = 0;
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700419 tSchBeaconStruct *pBeaconStruct;
Jeff Johnson295189b2012-06-20 16:38:30 -0700420
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +0530421 pBeaconStruct = vos_mem_malloc(sizeof(tSchBeaconStruct));
422 if (NULL == pBeaconStruct)
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700423 {
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +0530424 limLog(pMac, LOGE, FL("Unable to allocate memory for creating ADD_BSS") );
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700425 return eSIR_MEM_ALLOC_FAILED;
426 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700427
428 // Package SIR_HAL_ADD_BSS_REQ message parameters
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +0530429 pAddBssParams = vos_mem_malloc(sizeof( tAddBssParams ));
430 if (NULL == pAddBssParams)
Jeff Johnson295189b2012-06-20 16:38:30 -0700431 {
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +0530432 vos_mem_free(pBeaconStruct);
Jeff Johnson295189b2012-06-20 16:38:30 -0700433 limLog( pMac, LOGP,
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +0530434 FL( "Unable to allocate memory for creating ADD_BSS" ));
Jeff Johnson295189b2012-06-20 16:38:30 -0700435 return (eSIR_MEM_ALLOC_FAILED);
436 }
437
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +0530438 vos_mem_set((tANI_U8 *) pAddBssParams, sizeof( tAddBssParams ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700439
440
441 limExtractApCapabilities( pMac,
442 (tANI_U8 *) bssDescription->ieFields,
Abhishek Singhbad2b322016-10-21 11:22:33 +0530443 GET_IE_LEN_IN_BSS(bssDescription->length), pBeaconStruct);
Jeff Johnson295189b2012-06-20 16:38:30 -0700444
445 if (pMac->lim.gLimProtectionControl != WNI_CFG_FORCE_POLICY_PROTECTION_DISABLE)
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700446 limDecideStaProtectionOnAssoc(pMac, pBeaconStruct, pftSessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -0700447
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +0530448 vos_mem_copy(pAddBssParams->bssId, bssDescription->bssId,
449 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -0700450
451 // Fill in tAddBssParams selfMacAddr
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +0530452 vos_mem_copy(pAddBssParams->selfMacAddr, pftSessionEntry->selfMacAddr,
453 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -0700454
455 pAddBssParams->bssType = pftSessionEntry->bssType;//eSIR_INFRASTRUCTURE_MODE;
456 pAddBssParams->operMode = BSS_OPERATIONAL_MODE_STA;
457
458 pAddBssParams->beaconInterval = bssDescription->beaconInterval;
459
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700460 pAddBssParams->dtimPeriod = pBeaconStruct->tim.dtimPeriod;
Jeff Johnson295189b2012-06-20 16:38:30 -0700461 pAddBssParams->updateBss = updateEntry;
462
463
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700464 pAddBssParams->cfParamSet.cfpCount = pBeaconStruct->cfParamSet.cfpCount;
465 pAddBssParams->cfParamSet.cfpPeriod = pBeaconStruct->cfParamSet.cfpPeriod;
466 pAddBssParams->cfParamSet.cfpMaxDuration = pBeaconStruct->cfParamSet.cfpMaxDuration;
467 pAddBssParams->cfParamSet.cfpDurRemaining = pBeaconStruct->cfParamSet.cfpDurRemaining;
Jeff Johnson295189b2012-06-20 16:38:30 -0700468
469
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700470 pAddBssParams->rateSet.numRates = pBeaconStruct->supportedRates.numRates;
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +0530471 vos_mem_copy(pAddBssParams->rateSet.rate,
472 pBeaconStruct->supportedRates.rate, pBeaconStruct->supportedRates.numRates);
Jeff Johnson295189b2012-06-20 16:38:30 -0700473
474 pAddBssParams->nwType = bssDescription->nwType;
475
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700476 pAddBssParams->shortSlotTimeSupported = (tANI_U8)pBeaconStruct->capabilityInfo.shortSlotTime;
Jeff Johnson295189b2012-06-20 16:38:30 -0700477 pAddBssParams->llaCoexist = (tANI_U8) pftSessionEntry->beaconParams.llaCoexist;
478 pAddBssParams->llbCoexist = (tANI_U8) pftSessionEntry->beaconParams.llbCoexist;
479 pAddBssParams->llgCoexist = (tANI_U8) pftSessionEntry->beaconParams.llgCoexist;
480 pAddBssParams->ht20Coexist = (tANI_U8) pftSessionEntry->beaconParams.ht20Coexist;
481
482 // Use the advertised capabilities from the received beacon/PR
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700483 if (IS_DOT11_MODE_HT(pftSessionEntry->dot11mode) && ( pBeaconStruct->HTCaps.present ))
Jeff Johnson295189b2012-06-20 16:38:30 -0700484 {
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700485 pAddBssParams->htCapable = pBeaconStruct->HTCaps.present;
Jeff Johnson295189b2012-06-20 16:38:30 -0700486
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700487 if ( pBeaconStruct->HTInfo.present )
Jeff Johnson295189b2012-06-20 16:38:30 -0700488 {
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700489 pAddBssParams->htOperMode = (tSirMacHTOperatingMode)pBeaconStruct->HTInfo.opMode;
490 pAddBssParams->dualCTSProtection = ( tANI_U8 ) pBeaconStruct->HTInfo.dualCTSProtection;
Jeff Johnson295189b2012-06-20 16:38:30 -0700491
Jeff Johnson295189b2012-06-20 16:38:30 -0700492 chanWidthSupp = limGetHTCapability( pMac, eHT_SUPPORTED_CHANNEL_WIDTH_SET, pftSessionEntry);
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700493 if( (pBeaconStruct->HTCaps.supportedChannelWidthSet) &&
Jeff Johnson295189b2012-06-20 16:38:30 -0700494 (chanWidthSupp) )
495 {
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700496 pAddBssParams->txChannelWidthSet = ( tANI_U8 ) pBeaconStruct->HTInfo.recommendedTxWidthSet;
497 pAddBssParams->currentExtChannel = pBeaconStruct->HTInfo.secondaryChannelOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -0700498 }
499 else
500 {
501 pAddBssParams->txChannelWidthSet = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
Jeff Johnsone7245742012-09-05 17:12:55 -0700502 pAddBssParams->currentExtChannel = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -0700503 }
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700504 pAddBssParams->llnNonGFCoexist = (tANI_U8)pBeaconStruct->HTInfo.nonGFDevicesPresent;
505 pAddBssParams->fLsigTXOPProtectionFullSupport = (tANI_U8)pBeaconStruct->HTInfo.lsigTXOPProtectionFullSupport;
506 pAddBssParams->fRIFSMode = pBeaconStruct->HTInfo.rifsMode;
Jeff Johnson295189b2012-06-20 16:38:30 -0700507 }
508 }
509
510 pAddBssParams->currentOperChannel = bssDescription->channelId;
Varun Reddy Yeturuee871e32014-02-20 14:20:51 -0800511 pftSessionEntry->htSecondaryChannelOffset = pAddBssParams->currentExtChannel;
512
513#ifdef WLAN_FEATURE_11AC
514 if (pftSessionEntry->vhtCapability && pftSessionEntry->vhtCapabilityPresentInBeacon)
515 {
516 pAddBssParams->vhtCapable = pBeaconStruct->VHTCaps.present;
517 pAddBssParams->vhtTxChannelWidthSet = pBeaconStruct->VHTOperation.chanWidth;
518 pAddBssParams->currentExtChannel = limGet11ACPhyCBState ( pMac,
519 pAddBssParams->currentOperChannel,
520 pAddBssParams->currentExtChannel,
521 pftSessionEntry->apCenterChan,
522 pftSessionEntry);
523 }
524 else
525 {
526 pAddBssParams->vhtCapable = 0;
527 }
528#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700529
530#if defined WLAN_FEATURE_VOWIFI_11R_DEBUG
Srinivas Girigowda5cecb202013-10-08 09:13:25 -0700531 limLog( pMac, LOG1, FL( "SIR_HAL_ADD_BSS_REQ with channel = %d..." ),
Jeff Johnson295189b2012-06-20 16:38:30 -0700532 pAddBssParams->currentOperChannel);
533#endif
534
535
536 // Populate the STA-related parameters here
537 // Note that the STA here refers to the AP
538 {
539 pAddBssParams->staContext.staType = STA_ENTRY_OTHER; // Identifying AP as an STA
540
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +0530541 vos_mem_copy(pAddBssParams->staContext.bssId,
542 bssDescription->bssId,
543 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -0700544 pAddBssParams->staContext.listenInterval = bssDescription->beaconInterval;
545
546 pAddBssParams->staContext.assocId = 0; // Is SMAC OK with this?
547 pAddBssParams->staContext.uAPSD = 0;
548 pAddBssParams->staContext.maxSPLen = 0;
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700549 pAddBssParams->staContext.shortPreambleSupported = (tANI_U8)pBeaconStruct->capabilityInfo.shortPreamble;
Jeff Johnson295189b2012-06-20 16:38:30 -0700550 pAddBssParams->staContext.updateSta = updateEntry;
551 pAddBssParams->staContext.encryptType = pftSessionEntry->encryptType;
552
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700553 if (IS_DOT11_MODE_HT(pftSessionEntry->dot11mode) && ( pBeaconStruct->HTCaps.present ))
Jeff Johnson295189b2012-06-20 16:38:30 -0700554 {
555 pAddBssParams->staContext.us32MaxAmpduDuration = 0;
556 pAddBssParams->staContext.htCapable = 1;
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700557 pAddBssParams->staContext.greenFieldCapable = ( tANI_U8 ) pBeaconStruct->HTCaps.greenField;
558 pAddBssParams->staContext.lsigTxopProtection = ( tANI_U8 ) pBeaconStruct->HTCaps.lsigTXOPProtection;
559 if( (pBeaconStruct->HTCaps.supportedChannelWidthSet) &&
Jeff Johnson295189b2012-06-20 16:38:30 -0700560 (chanWidthSupp) )
561 {
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700562 pAddBssParams->staContext.txChannelWidthSet = ( tANI_U8 )pBeaconStruct->HTInfo.recommendedTxWidthSet;
Jeff Johnson295189b2012-06-20 16:38:30 -0700563 }
564 else
565 {
566 pAddBssParams->staContext.txChannelWidthSet = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
567 }
Varun Reddy Yeturuee871e32014-02-20 14:20:51 -0800568#ifdef WLAN_FEATURE_11AC
Kanchanapally, Vidyullatha3f3b6542015-08-21 14:38:49 +0530569 if (pftSessionEntry->vhtCapability &&
570 IS_BSS_VHT_CAPABLE(pBeaconStruct->VHTCaps))
Varun Reddy Yeturuee871e32014-02-20 14:20:51 -0800571 {
572 pAddBssParams->staContext.vhtCapable = 1;
573 if ((pBeaconStruct->VHTCaps.suBeamFormerCap ||
574 pBeaconStruct->VHTCaps.muBeamformerCap) &&
575 pftSessionEntry->txBFIniFeatureEnabled)
576 {
577 pAddBssParams->staContext.vhtTxBFCapable = 1;
578 }
Abhishek Singhcfcc2b42015-08-08 09:22:58 +0530579 if (pBeaconStruct->VHTCaps.muBeamformerCap &&
580 pftSessionEntry->txMuBformee )
581 {
582 pAddBssParams->staContext.vhtTxMUBformeeCapable = 1;
583 limLog(pMac, LOG1, FL("Enabling MUBformee for peer"));
584 }
Varun Reddy Yeturuee871e32014-02-20 14:20:51 -0800585 }
586#endif
587 if( (pBeaconStruct->HTCaps.supportedChannelWidthSet) &&
588 (chanWidthSupp) )
589 {
590 pAddBssParams->staContext.txChannelWidthSet =
591 ( tANI_U8 )pBeaconStruct->HTInfo.recommendedTxWidthSet;
592#ifdef WLAN_FEATURE_11AC
593 if (pAddBssParams->staContext.vhtCapable)
594 {
595 pAddBssParams->staContext.vhtTxChannelWidthSet =
596 pBeaconStruct->VHTOperation.chanWidth;
597 }
598#endif
599 }
600 else
601 {
602 pAddBssParams->staContext.txChannelWidthSet = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
603 }
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700604 pAddBssParams->staContext.mimoPS = (tSirMacHTMIMOPowerSaveState)pBeaconStruct->HTCaps.mimoPowerSave;
605 pAddBssParams->staContext.delBASupport = ( tANI_U8 ) pBeaconStruct->HTCaps.delayedBA;
606 pAddBssParams->staContext.maxAmsduSize = ( tANI_U8 ) pBeaconStruct->HTCaps.maximalAMSDUsize;
607 pAddBssParams->staContext.maxAmpduDensity = pBeaconStruct->HTCaps.mpduDensity;
608 pAddBssParams->staContext.fDsssCckMode40Mhz = (tANI_U8)pBeaconStruct->HTCaps.dsssCckMode40MHz;
609 pAddBssParams->staContext.fShortGI20Mhz = (tANI_U8)pBeaconStruct->HTCaps.shortGI20MHz;
610 pAddBssParams->staContext.fShortGI40Mhz = (tANI_U8)pBeaconStruct->HTCaps.shortGI40MHz;
611 pAddBssParams->staContext.maxAmpduSize= pBeaconStruct->HTCaps.maxRxAMPDUFactor;
Jeff Johnson295189b2012-06-20 16:38:30 -0700612
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700613 if( pBeaconStruct->HTInfo.present )
614 pAddBssParams->staContext.rifsMode = pBeaconStruct->HTInfo.rifsMode;
Jeff Johnson295189b2012-06-20 16:38:30 -0700615 }
616
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700617 if ((pftSessionEntry->limWmeEnabled && pBeaconStruct->wmeEdcaPresent) ||
618 (pftSessionEntry->limQosEnabled && pBeaconStruct->edcaPresent))
Jeff Johnson295189b2012-06-20 16:38:30 -0700619 pAddBssParams->staContext.wmmEnabled = 1;
620 else
621 pAddBssParams->staContext.wmmEnabled = 0;
622
623 //Update the rates
Jeff Johnsone7245742012-09-05 17:12:55 -0700624#ifdef WLAN_FEATURE_11AC
Leela Venkata Kiran Kumar Reddy Chirala85c9fb12013-09-05 20:47:36 -0700625 limPopulatePeerRateSet(pMac, &pAddBssParams->staContext.supportedRates,
626 pBeaconStruct->HTCaps.supportedMCSSet,
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700627 false,pftSessionEntry,&pBeaconStruct->VHTCaps);
Jeff Johnsone7245742012-09-05 17:12:55 -0700628#else
Leela Venkata Kiran Kumar Reddy Chirala85c9fb12013-09-05 20:47:36 -0700629 limPopulatePeerRateSet(pMac, &pAddBssParams->staContext.supportedRates,
Jeff Johnson295189b2012-06-20 16:38:30 -0700630 beaconStruct.HTCaps.supportedMCSSet, false,pftSessionEntry);
Jeff Johnsone7245742012-09-05 17:12:55 -0700631#endif
Varun Reddy Yeturuee871e32014-02-20 14:20:51 -0800632 if (pftSessionEntry->htCapability)
633 {
634 pAddBssParams->staContext.supportedRates.opRateMode = eSTA_11n;
635 if (pftSessionEntry->vhtCapability)
636 pAddBssParams->staContext.supportedRates.opRateMode = eSTA_11ac;
637 }
638 else
639 {
640 if (pftSessionEntry->limRFBand == SIR_BAND_5_GHZ)
641 {
642 pAddBssParams->staContext.supportedRates.opRateMode = eSTA_11a;
643 }
644 else
645 {
646 pAddBssParams->staContext.supportedRates.opRateMode = eSTA_11bg;
647 }
648 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700649 }
650
Jeff Johnson295189b2012-06-20 16:38:30 -0700651 //Disable BA. It will be set as part of ADDBA negotiation.
652 for( i = 0; i < STACFG_MAX_TC; i++ )
653 {
654 pAddBssParams->staContext.staTCParams[i].txUseBA = eBA_DISABLE;
655 pAddBssParams->staContext.staTCParams[i].rxUseBA = eBA_DISABLE;
656 pAddBssParams->staContext.staTCParams[i].txBApolicy = eBA_POLICY_IMMEDIATE;
657 pAddBssParams->staContext.staTCParams[i].rxBApolicy = eBA_POLICY_IMMEDIATE;
658 }
659
660#if defined WLAN_FEATURE_VOWIFI
661 pAddBssParams->maxTxPower = pftSessionEntry->maxTxPower;
662#endif
663
Chet Lanctota4fd8e62013-12-10 16:02:32 -0800664#ifdef WLAN_FEATURE_11W
665 if (pftSessionEntry->limRmfEnabled)
666 {
667 pAddBssParams->rmfEnabled = 1;
668 pAddBssParams->staContext.rmfEnabled = 1;
669 }
670#endif
671
Jeff Johnson295189b2012-06-20 16:38:30 -0700672 pAddBssParams->status = eHAL_STATUS_SUCCESS;
673 pAddBssParams->respReqd = true;
674
675 pAddBssParams->staContext.sessionId = pftSessionEntry->peSessionId;
676 pAddBssParams->sessionId = pftSessionEntry->peSessionId;
677
678 // Set a new state for MLME
679
680 pftSessionEntry->limMlmState = eLIM_MLM_WT_ADD_BSS_RSP_FT_REASSOC_STATE;
Varun Reddy Yeturue3bbf6e2013-02-08 18:50:55 -0800681 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 -0700682 pAddBssParams->halPersona=(tANI_U8)pftSessionEntry->pePersona; //pass on the session persona to hal
683
684 pMac->ft.ftPEContext.pAddBssReq = pAddBssParams;
685
686#if defined WLAN_FEATURE_VOWIFI_11R_DEBUG
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -0800687 limLog( pMac, LOG1, FL( "Saving SIR_HAL_ADD_BSS_REQ for pre-auth ap..." ));
Jeff Johnson295189b2012-06-20 16:38:30 -0700688#endif
689
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +0530690 vos_mem_free(pBeaconStruct);
Jeff Johnson295189b2012-06-20 16:38:30 -0700691 return 0;
692}
693
694/*------------------------------------------------------------------
695 *
696 * Setup the new session for the pre-auth AP.
697 * Return the newly created session entry.
698 *
699 *------------------------------------------------------------------*/
700tpPESession limFillFTSession(tpAniSirGlobal pMac,
701 tpSirBssDescription pbssDescription, tpPESession psessionEntry)
702{
703 tpPESession pftSessionEntry;
704 tANI_U8 currentBssUapsd;
Jeff Johnson295189b2012-06-20 16:38:30 -0700705 tPowerdBm localPowerConstraint;
706 tPowerdBm regMax;
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700707 tSchBeaconStruct *pBeaconStruct;
Varun Reddy Yeturuee871e32014-02-20 14:20:51 -0800708 ePhyChanBondState cbMode;
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700709
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +0530710 pBeaconStruct = vos_mem_malloc(sizeof(tSchBeaconStruct));
711 if (NULL == pBeaconStruct)
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700712 {
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +0530713 limLog(pMac, LOGE, FL("Unable to allocate memory for creating limFillFTSession") );
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700714 return NULL;
715 }
716
Jeff Johnson295189b2012-06-20 16:38:30 -0700717
Dhanashri Atreaf3e84d2013-01-18 18:03:06 -0800718
719 /* Retrieve the session that has already been created and update the entry */
720 pftSessionEntry = pMac->ft.ftPEContext.pftSessionEntry;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800721#if defined WLAN_FEATURE_VOWIFI_11R_DEBUG || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -0700722 limPrintMacAddr(pMac, pbssDescription->bssId, LOG1);
Jeff Johnson295189b2012-06-20 16:38:30 -0700723#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700724 pftSessionEntry->limWmeEnabled = psessionEntry->limWmeEnabled;
725 pftSessionEntry->limQosEnabled = psessionEntry->limQosEnabled;
726 pftSessionEntry->limWsmEnabled = psessionEntry->limWsmEnabled;
727 pftSessionEntry->lim11hEnable = psessionEntry->lim11hEnable;
728
729 // Fields to be filled later
730 pftSessionEntry->pLimJoinReq = NULL;
731 pftSessionEntry->smeSessionId = 0;
732 pftSessionEntry->transactionId = 0;
733
734 limExtractApCapabilities( pMac,
735 (tANI_U8 *) pbssDescription->ieFields,
Abhishek Singhbad2b322016-10-21 11:22:33 +0530736 GET_IE_LEN_IN_BSS(pbssDescription->length),
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700737 pBeaconStruct );
Jeff Johnson295189b2012-06-20 16:38:30 -0700738
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700739 pftSessionEntry->rateSet.numRates = pBeaconStruct->supportedRates.numRates;
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +0530740 vos_mem_copy(pftSessionEntry->rateSet.rate,
741 pBeaconStruct->supportedRates.rate, pBeaconStruct->supportedRates.numRates);
Jeff Johnson295189b2012-06-20 16:38:30 -0700742
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700743 pftSessionEntry->extRateSet.numRates = pBeaconStruct->extendedRates.numRates;
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +0530744 vos_mem_copy(pftSessionEntry->extRateSet.rate,
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700745 pBeaconStruct->extendedRates.rate, pftSessionEntry->extRateSet.numRates);
Jeff Johnson295189b2012-06-20 16:38:30 -0700746
747
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700748 pftSessionEntry->ssId.length = pBeaconStruct->ssId.length;
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +0530749 vos_mem_copy(pftSessionEntry->ssId.ssId, pBeaconStruct->ssId.ssId,
Jeff Johnson295189b2012-06-20 16:38:30 -0700750 pftSessionEntry->ssId.length);
751
Padma, Santhosh Kumar04822572017-05-12 19:15:22 +0530752 pftSessionEntry->dot11mode = pMac->ft.ftPEContext.pFTPreAuthReq->dot11mode;
753 limLog(pMac, LOG1, FL("dot11mode %d"), pftSessionEntry->dot11mode);
Kanchanapally, Vidyullatha3f3b6542015-08-21 14:38:49 +0530754 pftSessionEntry->vhtCapability =
755 (IS_DOT11_MODE_VHT(pftSessionEntry->dot11mode)
756 && IS_BSS_VHT_CAPABLE(pBeaconStruct->VHTCaps));
Varun Reddy Yeturuee871e32014-02-20 14:20:51 -0800757 pftSessionEntry->htCapability = (IS_DOT11_MODE_HT(pftSessionEntry->dot11mode)
758 && pBeaconStruct->HTCaps.present);
759#ifdef WLAN_FEATURE_11AC
Kanchanapally, Vidyullatha3f3b6542015-08-21 14:38:49 +0530760 if (IS_BSS_VHT_CAPABLE(pBeaconStruct->VHTCaps)
761 && pBeaconStruct->VHTOperation.present)
Varun Reddy Yeturuee871e32014-02-20 14:20:51 -0800762 {
763 pftSessionEntry->vhtCapabilityPresentInBeacon = 1;
764 pftSessionEntry->apCenterChan = pBeaconStruct->VHTOperation.chanCenterFreqSeg1;
765 pftSessionEntry->apChanWidth = pBeaconStruct->VHTOperation.chanWidth;
Abhishek Singhcfcc2b42015-08-08 09:22:58 +0530766
767 pftSessionEntry->txBFIniFeatureEnabled =
768 pMac->roam.configParam.txBFEnable;
769
770 limLog(pMac, LOG1, FL("txBFIniFeatureEnabled=%d"),
771 pftSessionEntry->txBFIniFeatureEnabled);
772
773 if (pftSessionEntry->txBFIniFeatureEnabled)
774 {
775 if (cfgSetInt(pMac, WNI_CFG_VHT_SU_BEAMFORMEE_CAP,
776 pftSessionEntry->txBFIniFeatureEnabled)
777 != eSIR_SUCCESS)
778 {
779 limLog(pMac, LOGE, FL("could not set "
780 "WNI_CFG_VHT_SU_BEAMFORMEE_CAP at CFG"));
781 }
782 limLog(pMac, LOG1, FL("txBFCsnValue=%d"),
783 pMac->roam.configParam.txBFCsnValue);
784
785 if (cfgSetInt(pMac, WNI_CFG_VHT_CSN_BEAMFORMEE_ANT_SUPPORTED,
786 pMac->roam.configParam.txBFCsnValue)
787 != eSIR_SUCCESS)
788 {
789 limLog(pMac, LOGE, FL("could not set "
790 "WNI_CFG_VHT_CSN_BEAMFORMEE_ANT_SUPPORTED at CFG"));
791 }
792
793 if (IS_MUMIMO_BFORMEE_CAPABLE)
794 pftSessionEntry->txMuBformee =
795 pMac->roam.configParam.txMuBformee;
796 }
797
798 limLog(pMac, LOG1, FL("txMuBformee = %d"),
799 pftSessionEntry->txMuBformee);
800
801 if (cfgSetInt(pMac, WNI_CFG_VHT_MU_BEAMFORMEE_CAP,
802 pftSessionEntry->txMuBformee)
803 != eSIR_SUCCESS)
804 {
805 limLog(pMac, LOGE, FL("could not set "
806 "WNI_CFG_VHT_MU_BEAMFORMEE_CAP at CFG"));
807 }
Varun Reddy Yeturuee871e32014-02-20 14:20:51 -0800808 }
809 else
810 {
811 pftSessionEntry->vhtCapabilityPresentInBeacon = 0;
812 }
813#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700814 // Self Mac
815 sirCopyMacAddr(pftSessionEntry->selfMacAddr, psessionEntry->selfMacAddr);
816 sirCopyMacAddr(pftSessionEntry->limReAssocbssId, pbssDescription->bssId);
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800817#if defined WLAN_FEATURE_VOWIFI_11R_DEBUG || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -0700818 limPrintMacAddr(pMac, pftSessionEntry->limReAssocbssId, LOG1);
Jeff Johnson295189b2012-06-20 16:38:30 -0700819#endif
820
821 /* Store beaconInterval */
822 pftSessionEntry->beaconParams.beaconInterval = pbssDescription->beaconInterval;
823 pftSessionEntry->bssType = psessionEntry->bssType;
824
825 pftSessionEntry->statypeForBss = STA_ENTRY_PEER;
826 pftSessionEntry->nwType = pbssDescription->nwType;
827
828 /* Copy The channel Id to the session Table */
829 pftSessionEntry->limReassocChannelId = pbssDescription->channelId;
830 pftSessionEntry->currentOperChannel = pbssDescription->channelId;
831
832
833 if (pftSessionEntry->bssType == eSIR_INFRASTRUCTURE_MODE)
834 {
835 pftSessionEntry->limSystemRole = eLIM_STA_ROLE;
836 }
837 else if(pftSessionEntry->bssType == eSIR_BTAMP_AP_MODE)
838 {
839 pftSessionEntry->limSystemRole = eLIM_BT_AMP_STA_ROLE;
840 }
841 else
842 {
843 /* Throw an error and return and make sure to delete the session.*/
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700844 limLog(pMac, LOGE, FL("Invalid bss type"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700845 }
846
847 pftSessionEntry->limCurrentBssCaps = pbssDescription->capabilityInfo;
848 pftSessionEntry->limReassocBssCaps = pbssDescription->capabilityInfo;
Srinivas Girigowda3353f1e2013-02-04 16:22:51 -0800849 if( pMac->roam.configParam.shortSlotTime &&
850 SIR_MAC_GET_SHORT_SLOT_TIME(pftSessionEntry->limReassocBssCaps))
851 {
852 pftSessionEntry->shortSlotTimeSupported = TRUE;
853 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700854
855 regMax = cfgGetRegulatoryMaxTransmitPower( pMac, pftSessionEntry->currentOperChannel );
856 localPowerConstraint = regMax;
Abhishek Singhbad2b322016-10-21 11:22:33 +0530857 limExtractApCapability(pMac, (tANI_U8 *) pbssDescription->ieFields,
858 GET_IE_LEN_IN_BSS(pbssDescription->length),
Jeff Johnson295189b2012-06-20 16:38:30 -0700859 &pftSessionEntry->limCurrentBssQosCaps,
860 &pftSessionEntry->limCurrentBssPropCap,
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -0700861 &currentBssUapsd , &localPowerConstraint, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -0700862
863 pftSessionEntry->limReassocBssQosCaps =
864 pftSessionEntry->limCurrentBssQosCaps;
865 pftSessionEntry->limReassocBssPropCap =
866 pftSessionEntry->limCurrentBssPropCap;
867
868
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800869#ifdef FEATURE_WLAN_ESE
Madan Mohan Koyyalamudi3282c572012-11-09 17:01:41 -0800870 pftSessionEntry->maxTxPower = limGetMaxTxPower(regMax, localPowerConstraint, pMac->roam.configParam.nTxPowerCap);
871#else
Jeff Johnson295189b2012-06-20 16:38:30 -0700872 pftSessionEntry->maxTxPower = VOS_MIN( regMax , (localPowerConstraint) );
Madan Mohan Koyyalamudi3282c572012-11-09 17:01:41 -0800873#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700874
875#if defined WLAN_FEATURE_VOWIFI_11R_DEBUG
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -0800876 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 -0800877 __func__, regMax, localPowerConstraint, pMac->roam.configParam.nTxPowerCap, pftSessionEntry->maxTxPower );
Jeff Johnson295189b2012-06-20 16:38:30 -0700878#endif
879
880 pftSessionEntry->limRFBand = limGetRFBand(pftSessionEntry->currentOperChannel);
881
882 pftSessionEntry->limPrevSmeState = pftSessionEntry->limSmeState;
883 pftSessionEntry->limSmeState = eLIM_SME_WT_REASSOC_STATE;
Varun Reddy Yeturue3bbf6e2013-02-08 18:50:55 -0800884 MTRACE(macTrace(pMac, TRACE_CODE_SME_STATE, pftSessionEntry->peSessionId, pftSessionEntry->limSmeState));
Jeff Johnson295189b2012-06-20 16:38:30 -0700885
886 pftSessionEntry->encryptType = psessionEntry->encryptType;
887
Varun Reddy Yeturuee871e32014-02-20 14:20:51 -0800888 if (pftSessionEntry->limRFBand == SIR_BAND_2_4_GHZ)
889 {
890 cbMode = pMac->roam.configParam.channelBondingMode24GHz;
891 }
892 else
893 {
894 cbMode = pMac->roam.configParam.channelBondingMode5GHz;
895 }
896 pftSessionEntry->htSupportedChannelWidthSet =
897 cbMode && pBeaconStruct->HTCaps.supportedChannelWidthSet;
898 pftSessionEntry->htRecommendedTxWidthSet =
899 pftSessionEntry->htSupportedChannelWidthSet;
Sandeep Puligilla70b6b162014-04-19 02:06:04 +0530900 if ((pftSessionEntry->limRFBand == SIR_BAND_2_4_GHZ)&&
901 (pftSessionEntry->htSupportedChannelWidthSet == 1))
902 {
903 limInitOBSSScanParams(pMac, pftSessionEntry);
904 }
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +0530905 vos_mem_free(pBeaconStruct);
Jeff Johnson295189b2012-06-20 16:38:30 -0700906 return pftSessionEntry;
907}
908
909/*------------------------------------------------------------------
910 *
911 * Setup the session and the add bss req for the pre-auth AP.
912 *
913 *------------------------------------------------------------------*/
914void limFTSetupAuthSession(tpAniSirGlobal pMac, tpPESession psessionEntry)
915{
916 tpPESession pftSessionEntry;
917
918 // Prepare the session right now with as much as possible.
919 pftSessionEntry = limFillFTSession(pMac, pMac->ft.ftPEContext.pFTPreAuthReq->pbssDescription, psessionEntry);
920
921 if (pftSessionEntry)
922 {
923 pftSessionEntry->is11Rconnection = psessionEntry->is11Rconnection;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800924#ifdef FEATURE_WLAN_ESE
925 pftSessionEntry->isESEconnection = psessionEntry->isESEconnection;
Jeff Johnson295189b2012-06-20 16:38:30 -0700926#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800927#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -0700928 pftSessionEntry->isFastTransitionEnabled = psessionEntry->isFastTransitionEnabled;
929#endif
Jeff Johnson43971f52012-07-17 12:26:56 -0700930
931#ifdef FEATURE_WLAN_LFR
932 pftSessionEntry->isFastRoamIniFeatureEnabled = psessionEntry->isFastRoamIniFeatureEnabled;
933#endif
Chet Lanctota4fd8e62013-12-10 16:02:32 -0800934#ifdef WLAN_FEATURE_11W
935 pftSessionEntry->limRmfEnabled = psessionEntry->limRmfEnabled;
936#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700937 limFTPrepareAddBssReq( pMac, FALSE, pftSessionEntry,
938 pMac->ft.ftPEContext.pFTPreAuthReq->pbssDescription );
939 pMac->ft.ftPEContext.pftSessionEntry = pftSessionEntry;
940 }
941}
942
943/*------------------------------------------------------------------
944 * Resume Link Call Back
945 *------------------------------------------------------------------*/
946void limFTProcessPreAuthResult(tpAniSirGlobal pMac, eHalStatus status, tANI_U32 *data)
947{
948 tpPESession psessionEntry;
949
Srinivas Girigowda4585f0d2013-10-28 18:07:40 -0700950 if (!pMac->ft.ftPEContext.pFTPreAuthReq)
951 return;
952
Jeff Johnson295189b2012-06-20 16:38:30 -0700953 psessionEntry = (tpPESession)data;
954
955 if (pMac->ft.ftPEContext.ftPreAuthStatus == eSIR_SUCCESS)
956 {
957 limFTSetupAuthSession(pMac, psessionEntry);
958 }
959
960 // Post the FT Pre Auth Response to SME
961 limPostFTPreAuthRsp(pMac, pMac->ft.ftPEContext.ftPreAuthStatus,
962 pMac->ft.ftPEContext.saved_auth_rsp,
963 pMac->ft.ftPEContext.saved_auth_rsp_length, psessionEntry);
964
965}
966
967/*------------------------------------------------------------------
968 * Resume Link Call Back
969 *------------------------------------------------------------------*/
970void limPerformPostFTPreAuthAndChannelChange(tpAniSirGlobal pMac, eHalStatus status, tANI_U32 *data,
971 tpPESession psessionEntry)
972{
973 //Set the resume channel to Any valid channel (invalid).
974 //This will instruct HAL to set it to any previous valid channel.
975 peSetResumeChannel(pMac, 0, 0);
976 limResumeLink(pMac, limFTProcessPreAuthResult, (tANI_U32 *)psessionEntry);
977}
978
979tSirRetStatus limCreateRICBlockAckIE(tpAniSirGlobal pMac, tANI_U8 tid, tCfgTrafficClass *pTrafficClass,
980 tANI_U8 *ric_ies, tANI_U32 *ieLength)
981{
Gopichand Nakkala3d295922013-05-07 16:19:14 +0530982 /* BlockACK + RIC is not supported now, TODO later to support this */
983#if 0
Jeff Johnson295189b2012-06-20 16:38:30 -0700984 tDot11fIERICDataDesc ricIe;
985 tDot11fFfBAStartingSequenceControl baSsnControl;
986 tDot11fFfAddBAParameterSet baParamSet;
987 tDot11fFfBATimeout baTimeout;
988
989 vos_mem_zero(&ricIe, sizeof(tDot11fIERICDataDesc));
990 vos_mem_zero(&baSsnControl, sizeof(tDot11fFfBAStartingSequenceControl));
991 vos_mem_zero(&baParamSet, sizeof(tDot11fFfAddBAParameterSet));
992 vos_mem_zero(&baTimeout, sizeof(tDot11fFfBATimeout));
993
994 ricIe.present = 1;
995 ricIe.RICData.present = 1;
996 ricIe.RICData.resourceDescCount = 1;
997 ricIe.RICData.Identifier = LIM_FT_RIC_BA_DIALOG_TOKEN_TID_0 + tid;
998 ricIe.RICDescriptor.present = 1;
999 ricIe.RICDescriptor.resourceType = LIM_FT_RIC_DESCRIPTOR_RESOURCE_TYPE_BA;
1000 baParamSet.tid = tid;
1001 baParamSet.policy = pTrafficClass->fTxBApolicy; // Immediate Block Ack
1002 baParamSet.bufferSize = pTrafficClass->txBufSize;
1003 vos_mem_copy((v_VOID_t *)&baTimeout, (v_VOID_t *)&pTrafficClass->tuTxBAWaitTimeout, sizeof(baTimeout));
1004 baSsnControl.fragNumber = 0;
1005 baSsnControl.ssn = LIM_FT_RIC_BA_SSN;
Gopichand Nakkala3d295922013-05-07 16:19:14 +05301006 if (ricIe.RICDescriptor.num_variableData < sizeof (ricIe.RICDescriptor.variableData)) {
Kiran Kumar Lokerea4db3dc2013-03-25 18:05:24 -07001007 dot11fPackFfAddBAParameterSet(pMac, &baParamSet, &ricIe.RICDescriptor.variableData[ricIe.RICDescriptor.num_variableData]);
1008 //vos_mem_copy(&ricIe.RICDescriptor.variableData[ricIe.RICDescriptor.num_variableData], &baParamSet, sizeof(tDot11fFfAddBAParameterSet));
1009 ricIe.RICDescriptor.num_variableData += sizeof(tDot11fFfAddBAParameterSet);
1010 }
Gopichand Nakkala3d295922013-05-07 16:19:14 +05301011 if (ricIe.RICDescriptor.num_variableData < sizeof (ricIe.RICDescriptor.variableData)) {
Kiran Kumar Lokerea4db3dc2013-03-25 18:05:24 -07001012 dot11fPackFfBATimeout(pMac, &baTimeout, &ricIe.RICDescriptor.variableData[ricIe.RICDescriptor.num_variableData]);
1013 //vos_mem_copy(&ricIe.RICDescriptor.variableData[ricIe.RICDescriptor.num_variableData], &baTimeout, sizeof(tDot11fFfBATimeout));
1014 ricIe.RICDescriptor.num_variableData += sizeof(tDot11fFfBATimeout);
1015 }
Gopichand Nakkala3d295922013-05-07 16:19:14 +05301016 if (ricIe.RICDescriptor.num_variableData < sizeof (ricIe.RICDescriptor.variableData)) {
Kiran Kumar Lokerea4db3dc2013-03-25 18:05:24 -07001017 dot11fPackFfBAStartingSequenceControl(pMac, &baSsnControl, &ricIe.RICDescriptor.variableData[ricIe.RICDescriptor.num_variableData]);
1018 //vos_mem_copy(&ricIe.RICDescriptor.variableData[ricIe.RICDescriptor.num_variableData], &baSsnControl, sizeof(tDot11fFfBAStartingSequenceControl));
1019 ricIe.RICDescriptor.num_variableData += sizeof(tDot11fFfBAStartingSequenceControl);
1020 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001021 return (tSirRetStatus) dot11fPackIeRICDataDesc(pMac, &ricIe, ric_ies, sizeof(tDot11fIERICDataDesc), ieLength);
Gopichand Nakkala3d295922013-05-07 16:19:14 +05301022#endif
1023
1024 return eSIR_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001025}
1026
1027tSirRetStatus limFTFillRICBlockAckInfo(tpAniSirGlobal pMac, tANI_U8 *ric_ies, tANI_U32 *ric_ies_length)
1028{
1029 tANI_U8 tid = 0;
1030 tpDphHashNode pSta;
1031 tANI_U16 numBA = 0, aid = 0;
1032 tpPESession psessionEntry = pMac->ft.ftPEContext.psavedsessionEntry;
1033 tANI_U32 offset = 0, ieLength = 0;
1034 tSirRetStatus status = eSIR_SUCCESS;
1035
1036 // First, extract the DPH entry
1037 pSta = dphLookupHashEntry( pMac, pMac->ft.ftPEContext.pFTPreAuthReq->currbssId, &aid, &psessionEntry->dph.dphHashTable);
1038 if( NULL == pSta )
1039 {
1040 PELOGE(limLog( pMac, LOGE,
Arif Hussain24bafea2013-11-15 15:10:03 -08001041 FL( "STA context not found for saved session's BSSID " MAC_ADDRESS_STR ),
1042 MAC_ADDR_ARRAY(pMac->ft.ftPEContext.pFTPreAuthReq->currbssId));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001043 return eSIR_FAILURE;
1044 }
1045
1046 for (tid = 0; tid < STACFG_MAX_TC; tid++)
1047 {
1048 if (pSta->tcCfg[tid].fUseBATx)
1049 {
1050 status = limCreateRICBlockAckIE(pMac, tid, &pSta->tcCfg[tid], ric_ies + offset, &ieLength);
1051 if (eSIR_SUCCESS == status)
1052 {
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001053 // TODO RIC
1054 if ( ieLength > MAX_FTIE_SIZE )
1055 {
1056 ieLength = 0;
1057 return status;
1058 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001059 offset += ieLength;
1060 *ric_ies_length += ieLength;
1061 numBA++;
1062 }
1063 else
1064 {
1065 PELOGE(limLog(pMac, LOGE, FL("BA RIC IE creation for TID %d failed with status %d"), tid, status);)
1066 }
1067 }
1068 }
1069
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001070 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 -07001071 return status;
1072}
1073
1074/*------------------------------------------------------------------
1075 *
1076 * Will post pre auth response to SME.
1077 *
1078 *------------------------------------------------------------------*/
Srikant Kuppaa3ed0a32013-02-20 07:24:43 -08001079void limPostFTPreAuthRsp(tpAniSirGlobal pMac, tSirRetStatus status,
Jeff Johnson295189b2012-06-20 16:38:30 -07001080 tANI_U8 *auth_rsp, tANI_U16 auth_rsp_length,
1081 tpPESession psessionEntry)
1082{
1083 tpSirFTPreAuthRsp pFTPreAuthRsp;
1084 tSirMsgQ mmhMsg;
1085 tANI_U16 rspLen = sizeof(tSirFTPreAuthRsp);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001086 // TODO: RIC Support
1087 //tSirRetStatus sirStatus = eSIR_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001088
1089 pFTPreAuthRsp = (tpSirFTPreAuthRsp)vos_mem_malloc(rspLen);
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05301090 if (NULL == pFTPreAuthRsp)
Jeff Johnson295189b2012-06-20 16:38:30 -07001091 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001092 PELOGE(limLog( pMac, LOGE, "Failed to allocate memory");)
Jeff Johnson295189b2012-06-20 16:38:30 -07001093 VOS_ASSERT(pFTPreAuthRsp != NULL);
1094 return;
1095 }
Kanchanapally, Vidyullatha31b8d142015-01-30 14:25:18 +05301096
Jeff Johnson295189b2012-06-20 16:38:30 -07001097#if defined WLAN_FEATURE_VOWIFI_11R_DEBUG
Jeff Johnson0fe596e2017-09-19 08:36:48 -07001098 PELOGE(limLog( pMac, LOG1, FL("Auth Rsp = %pK"), pFTPreAuthRsp);)
Jeff Johnson295189b2012-06-20 16:38:30 -07001099#endif
Kanchanapally, Vidyullatha31b8d142015-01-30 14:25:18 +05301100
1101 vos_mem_zero(pFTPreAuthRsp, rspLen);
Jeff Johnson295189b2012-06-20 16:38:30 -07001102 pFTPreAuthRsp->messageType = eWNI_SME_FT_PRE_AUTH_RSP;
1103 pFTPreAuthRsp->length = (tANI_U16) rspLen;
1104 pFTPreAuthRsp->status = status;
1105 if (psessionEntry)
1106 pFTPreAuthRsp->smeSessionId = psessionEntry->smeSessionId;
1107
1108 // The bssid of the AP we are sending Auth1 to.
1109 if (pMac->ft.ftPEContext.pFTPreAuthReq)
1110 sirCopyMacAddr(pFTPreAuthRsp->preAuthbssId,
1111 pMac->ft.ftPEContext.pFTPreAuthReq->preAuthbssId);
1112
1113 // Attach the auth response now back to SME
1114 pFTPreAuthRsp->ft_ies_length = 0;
1115 if ((auth_rsp != NULL) && (auth_rsp_length < MAX_FTIE_SIZE))
1116 {
1117 // Only 11r assoc has FT IEs.
1118 vos_mem_copy(pFTPreAuthRsp->ft_ies, auth_rsp, auth_rsp_length);
1119 pFTPreAuthRsp->ft_ies_length = auth_rsp_length;
1120 }
1121
1122#ifdef WLAN_FEATURE_VOWIFI_11R
1123 if ((psessionEntry) && (psessionEntry->is11Rconnection))
1124 {
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001125 /* TODO: RIC SUPPORT Fill in the Block Ack RIC IEs in the preAuthRsp */
1126 /*
Jeff Johnson295189b2012-06-20 16:38:30 -07001127 sirStatus = limFTFillRICBlockAckInfo(pMac, pFTPreAuthRsp->ric_ies,
1128 (tANI_U32 *)&pFTPreAuthRsp->ric_ies_length);
1129 if (eSIR_SUCCESS != sirStatus)
1130 {
1131 PELOGE(limLog(pMac, LOGE, FL("Fill RIC BA Info failed with status %d"), sirStatus);)
1132 }
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001133 */
Jeff Johnson295189b2012-06-20 16:38:30 -07001134 }
1135#endif
Kanchanapally, Vidyullathaa7f6d212015-03-17 11:35:25 +05301136
1137 if (status != eSIR_SUCCESS)
1138 {
1139 /* Ensure that on Pre-Auth failure the cached Pre-Auth Req and
1140 * other allocated memory is freed up before returning.
1141 */
1142 limLog(pMac, LOG1, "Pre-Auth Failed, Cleanup!");
1143 limFTCleanup(pMac);
1144 }
1145
Jeff Johnson295189b2012-06-20 16:38:30 -07001146 mmhMsg.type = pFTPreAuthRsp->messageType;
1147 mmhMsg.bodyptr = pFTPreAuthRsp;
1148 mmhMsg.bodyval = 0;
1149
1150#if defined WLAN_FEATURE_VOWIFI_11R_DEBUG
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001151 PELOGE(limLog( pMac, LOG1, "Posted Auth Rsp to SME with status of 0x%x", status);)
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08001152#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001153 limSysProcessMmhMsgApi(pMac, &mmhMsg, ePROT);
1154}
1155
1156/*------------------------------------------------------------------
1157 *
1158 * Send the FT Pre Auth Response to SME when ever we have a status
1159 * ready to be sent to SME
1160 *
1161 * SME will be the one to send it up to the supplicant to receive
1162 * FTIEs which will be required for Reassoc Req.
1163 *
1164 *------------------------------------------------------------------*/
Srikant Kuppaa3ed0a32013-02-20 07:24:43 -08001165void limHandleFTPreAuthRsp(tpAniSirGlobal pMac, tSirRetStatus status,
Jeff Johnson295189b2012-06-20 16:38:30 -07001166 tANI_U8 *auth_rsp, tANI_U16 auth_rsp_length,
1167 tpPESession psessionEntry)
1168{
1169
Dhanashri Atreaf3e84d2013-01-18 18:03:06 -08001170 tpPESession pftSessionEntry;
1171 tANI_U8 sessionId;
1172 tpSirBssDescription pbssDescription;
Leela Venkata Kiran Kumar Reddy Chirala2365ee62013-05-09 17:30:12 -07001173#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM //FEATURE_WLAN_DIAG_SUPPORT
Deepthi Gowri639d5042015-11-16 20:23:39 +05301174 limDiagEventReport(pMac, WLAN_PE_DIAG_PRE_AUTH_RSP_EVENT,
Sushant Kaushikb97a0082015-08-31 12:36:45 +05301175 psessionEntry, status, eSIR_SUCCESS);
Leela Venkata Kiran Kumar Reddy Chirala2365ee62013-05-09 17:30:12 -07001176#endif
Dhanashri Atreaf3e84d2013-01-18 18:03:06 -08001177
Jeff Johnson295189b2012-06-20 16:38:30 -07001178 // Save the status of pre-auth
1179 pMac->ft.ftPEContext.ftPreAuthStatus = status;
1180
1181 // Save the auth rsp, so we can send it to
1182 // SME once we resume link.
1183 pMac->ft.ftPEContext.saved_auth_rsp_length = 0;
1184 if ((auth_rsp != NULL) && (auth_rsp_length < MAX_FTIE_SIZE))
1185 {
1186 vos_mem_copy(pMac->ft.ftPEContext.saved_auth_rsp,
1187 auth_rsp, auth_rsp_length);
1188 pMac->ft.ftPEContext.saved_auth_rsp_length = auth_rsp_length;
1189 }
1190
Dhanashri Atreaf3e84d2013-01-18 18:03:06 -08001191 /* Create FT session for the re-association at this point */
1192 if (pMac->ft.ftPEContext.ftPreAuthStatus == eSIR_SUCCESS)
1193 {
1194 pbssDescription = pMac->ft.ftPEContext.pFTPreAuthReq->pbssDescription;
1195 if((pftSessionEntry = peCreateSession(pMac, pbssDescription->bssId,
1196 &sessionId, pMac->lim.maxStation)) == NULL)
1197 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001198 limLog(pMac, LOGE, FL("Session Can not be created for pre-auth 11R AP"));
mukul sharmaa8f96f02014-12-03 22:41:07 +05301199 status = eSIR_FAILURE;
1200 pMac->ft.ftPEContext.ftPreAuthStatus = status;
1201 goto out;
Dhanashri Atreaf3e84d2013-01-18 18:03:06 -08001202 }
1203 pftSessionEntry->peSessionId = sessionId;
1204 sirCopyMacAddr(pftSessionEntry->selfMacAddr, psessionEntry->selfMacAddr);
1205 sirCopyMacAddr(pftSessionEntry->limReAssocbssId, pbssDescription->bssId);
1206 pftSessionEntry->bssType = psessionEntry->bssType;
1207
1208 if (pftSessionEntry->bssType == eSIR_INFRASTRUCTURE_MODE)
1209 {
1210 pftSessionEntry->limSystemRole = eLIM_STA_ROLE;
1211 }
1212 else if(pftSessionEntry->bssType == eSIR_BTAMP_AP_MODE)
1213 {
1214 pftSessionEntry->limSystemRole = eLIM_BT_AMP_STA_ROLE;
1215 }
1216 else
1217 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001218 limLog(pMac, LOGE, FL("Invalid bss type"));
Dhanashri Atreaf3e84d2013-01-18 18:03:06 -08001219 }
1220 pftSessionEntry->limPrevSmeState = pftSessionEntry->limSmeState;
1221 pftSessionEntry->limSmeState = eLIM_SME_WT_REASSOC_STATE;
1222 pMac->ft.ftPEContext.pftSessionEntry = pftSessionEntry;
Jeff Johnson0fe596e2017-09-19 08:36:48 -07001223 PELOGE(limLog(pMac, LOG1,"%s:created session (%pK) with id = %d",
Dhanashri Atreaf3e84d2013-01-18 18:03:06 -08001224 __func__, pftSessionEntry, pftSessionEntry->peSessionId);)
1225
1226 /* Update the ReAssoc BSSID of the current session */
1227 sirCopyMacAddr(psessionEntry->limReAssocbssId, pbssDescription->bssId);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001228 limPrintMacAddr(pMac, psessionEntry->limReAssocbssId, LOG1);
Dhanashri Atreaf3e84d2013-01-18 18:03:06 -08001229 }
mukul sharmaa8f96f02014-12-03 22:41:07 +05301230out:
Jeff Johnson295189b2012-06-20 16:38:30 -07001231 if (psessionEntry->currentOperChannel !=
1232 pMac->ft.ftPEContext.pFTPreAuthReq->preAuthchannelNum)
1233 {
1234 // Need to move to the original AP channel
1235 limChangeChannelWithCallback(pMac, psessionEntry->currentOperChannel,
1236 limPerformPostFTPreAuthAndChannelChange, NULL, psessionEntry);
1237 }
1238 else
1239 {
1240#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001241 PELOGE(limLog( pMac, LOG1, "Pre auth on same channel as connected AP channel %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07001242 pMac->ft.ftPEContext.pFTPreAuthReq->preAuthchannelNum);)
1243#endif
1244 limFTProcessPreAuthResult(pMac, status, (tANI_U32 *)psessionEntry);
1245 }
1246}
1247
1248/*------------------------------------------------------------------
1249 *
1250 * This function handles the 11R Reassoc Req from SME
1251 *
1252 *------------------------------------------------------------------*/
1253void limProcessMlmFTReassocReq(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf,
1254 tpPESession psessionEntry)
1255{
1256 tANI_U8 smeSessionId = 0;
1257 tANI_U16 transactionId = 0;
Jeff Johnson278b0492013-04-03 14:10:08 -07001258 tANI_U8 chanNum = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001259 tLimMlmReassocReq *pMlmReassocReq;
1260 tANI_U16 caps;
1261 tANI_U32 val;
1262 tSirMsgQ msgQ;
1263 tSirRetStatus retCode;
1264 tANI_U32 teleBcnEn = 0;
1265
Jeff Johnson278b0492013-04-03 14:10:08 -07001266 chanNum = psessionEntry->currentOperChannel;
Jeff Johnson295189b2012-06-20 16:38:30 -07001267 limGetSessionInfo(pMac,(tANI_U8*)pMsgBuf, &smeSessionId, &transactionId);
1268 psessionEntry->smeSessionId = smeSessionId;
1269 psessionEntry->transactionId = transactionId;
1270
Leela Venkata Kiran Kumar Reddy Chirala2365ee62013-05-09 17:30:12 -07001271#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM //FEATURE_WLAN_DIAG_SUPPORT
1272 limDiagEventReport(pMac, WLAN_PE_DIAG_REASSOCIATING, psessionEntry, 0, 0);
1273#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001274
Madan Mohan Koyyalamudi67b82f62013-06-21 18:35:53 +05301275 if (NULL == pMac->ft.ftPEContext.pAddBssReq)
1276 {
1277 limLog(pMac, LOGE, FL("pAddBssReq is NULL"));
1278 return;
1279 }
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05301280 pMlmReassocReq = vos_mem_malloc(sizeof(tLimMlmReassocReq));
1281 if (NULL == pMlmReassocReq)
Jeff Johnson295189b2012-06-20 16:38:30 -07001282 {
1283 // Log error
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05301284 limLog(pMac, LOGE, FL("call to AllocateMemory failed for mlmReassocReq"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001285 return;
1286 }
1287
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05301288 vos_mem_copy(pMlmReassocReq->peerMacAddr,
1289 psessionEntry->bssId,
1290 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07001291
1292 if (wlan_cfgGetInt(pMac, WNI_CFG_REASSOCIATION_FAILURE_TIMEOUT,
1293 (tANI_U32 *) &pMlmReassocReq->reassocFailureTimeout)
1294 != eSIR_SUCCESS)
1295 {
1296 /**
1297 * Could not get ReassocFailureTimeout value
1298 * from CFG. Log error.
1299 */
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001300 limLog(pMac, LOGE, FL("could not retrieve ReassocFailureTimeout value"));
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05301301 vos_mem_free(pMlmReassocReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07001302 return;
1303 }
1304
1305 if (cfgGetCapabilityInfo(pMac, &caps,psessionEntry) != eSIR_SUCCESS)
1306 {
1307 /**
1308 * Could not get Capabilities value
1309 * from CFG. Log error.
1310 */
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001311 limLog(pMac, LOGE, FL("could not retrieve Capabilities value"));
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05301312 vos_mem_free(pMlmReassocReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07001313 return;
1314 }
Selvaraj, Sridhar5f149192016-04-15 12:53:28 +05301315
1316 lim_update_caps_info_for_bss(pMac, &caps,
1317 psessionEntry->pLimReAssocReq->bssDescription.capabilityInfo);
1318
1319 limLog(pMac, LOG1, FL("Capabilities info FT Reassoc: 0x%X"), caps);
1320
Jeff Johnson295189b2012-06-20 16:38:30 -07001321 pMlmReassocReq->capabilityInfo = caps;
Jeff Johnson278b0492013-04-03 14:10:08 -07001322
Jeff Johnson295189b2012-06-20 16:38:30 -07001323 /* Update PE sessionId*/
1324 pMlmReassocReq->sessionId = psessionEntry->peSessionId;
1325
1326 /* If telescopic beaconing is enabled, set listen interval to WNI_CFG_TELE_BCN_MAX_LI */
Jeff Johnson278b0492013-04-03 14:10:08 -07001327 if (wlan_cfgGetInt(pMac, WNI_CFG_TELE_BCN_WAKEUP_EN, &teleBcnEn) !=
1328 eSIR_SUCCESS)
Jeff Johnson295189b2012-06-20 16:38:30 -07001329 {
Jeff Johnson278b0492013-04-03 14:10:08 -07001330 limLog(pMac, LOGP, FL("Couldn't get WNI_CFG_TELE_BCN_WAKEUP_EN"));
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05301331 vos_mem_free(pMlmReassocReq);
Jeff Johnson278b0492013-04-03 14:10:08 -07001332 return;
1333 }
1334
1335 if (teleBcnEn)
1336 {
1337 if (wlan_cfgGetInt(pMac, WNI_CFG_TELE_BCN_MAX_LI, &val) != eSIR_SUCCESS)
Varun Reddy Yeturuea6bd082013-01-28 10:31:22 -08001338 {
Jeff Johnson295189b2012-06-20 16:38:30 -07001339 /**
1340 * Could not get ListenInterval value
1341 * from CFG. Log error.
1342 */
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001343 limLog(pMac, LOGE, FL("could not retrieve ListenInterval"));
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05301344 vos_mem_free(pMlmReassocReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07001345 return;
Varun Reddy Yeturuea6bd082013-01-28 10:31:22 -08001346 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001347 }
1348 else
1349 {
Jeff Johnson278b0492013-04-03 14:10:08 -07001350 if (wlan_cfgGetInt(pMac, WNI_CFG_LISTEN_INTERVAL, &val) != eSIR_SUCCESS)
Jeff Johnson295189b2012-06-20 16:38:30 -07001351 {
1352 /**
1353 * Could not get ListenInterval value
1354 * from CFG. Log error.
1355 */
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001356 limLog(pMac, LOGE, FL("could not retrieve ListenInterval"));
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05301357 vos_mem_free(pMlmReassocReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07001358 return;
1359 }
1360 }
1361 if (limSetLinkState(pMac, eSIR_LINK_PREASSOC_STATE, psessionEntry->bssId,
Jeff Johnson278b0492013-04-03 14:10:08 -07001362 psessionEntry->selfMacAddr, NULL, NULL) != eSIR_SUCCESS)
Jeff Johnson295189b2012-06-20 16:38:30 -07001363 {
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05301364 vos_mem_free(pMlmReassocReq);
Jeff Johnson278b0492013-04-03 14:10:08 -07001365 return;
Jeff Johnson295189b2012-06-20 16:38:30 -07001366 }
1367
Jeff Johnson295189b2012-06-20 16:38:30 -07001368 pMlmReassocReq->listenInterval = (tANI_U16) val;
1369
1370 psessionEntry->pLimMlmReassocReq = pMlmReassocReq;
1371
1372
1373 //we need to defer the message until we get the response back from HAL.
1374 SET_LIM_PROCESS_DEFD_MESGS(pMac, false);
Jeff Johnson278b0492013-04-03 14:10:08 -07001375
Jeff Johnson295189b2012-06-20 16:38:30 -07001376 msgQ.type = SIR_HAL_ADD_BSS_REQ;
1377 msgQ.reserved = 0;
1378 msgQ.bodyptr = pMac->ft.ftPEContext.pAddBssReq;
1379 msgQ.bodyval = 0;
1380
1381
1382#if defined WLAN_FEATURE_VOWIFI_11R_DEBUG
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001383 limLog( pMac, LOG1, FL( "Sending SIR_HAL_ADD_BSS_REQ..." ));
Jeff Johnson295189b2012-06-20 16:38:30 -07001384#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07001385 MTRACE(macTraceMsgTx(pMac, psessionEntry->peSessionId, msgQ.type));
Jeff Johnson295189b2012-06-20 16:38:30 -07001386
1387 retCode = wdaPostCtrlMsg( pMac, &msgQ );
Jeff Johnson278b0492013-04-03 14:10:08 -07001388 if( eSIR_SUCCESS != retCode)
Jeff Johnson295189b2012-06-20 16:38:30 -07001389 {
1390 vos_mem_free(pMac->ft.ftPEContext.pAddBssReq);
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001391 limLog( pMac, LOGE, FL("Posting ADD_BSS_REQ to HAL failed, reason=%X"),
Jeff Johnson295189b2012-06-20 16:38:30 -07001392 retCode );
1393 }
1394 // Dont need this anymore
1395 pMac->ft.ftPEContext.pAddBssReq = NULL;
Girish Gowli1c2fc802015-01-19 16:18:07 +05301396 if (pMac->roam.configParam.roamDelayStatsEnabled)
1397 {
1398 vos_record_roam_event(e_LIM_ADD_BS_REQ, NULL, 0);
1399 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001400 return;
1401}
1402
1403/*------------------------------------------------------------------
1404 *
1405 * This function is called if preauth response is not received from the AP
1406 * within this timeout while FT in progress
1407 *
1408 *------------------------------------------------------------------*/
1409void limProcessFTPreauthRspTimeout(tpAniSirGlobal pMac)
1410{
1411 tpPESession psessionEntry;
1412
1413 // We have failed pre auth. We need to resume link and get back on
1414 // home channel.
Madan Mohan Koyyalamudi67b82f62013-06-21 18:35:53 +05301415 limLog(pMac, LOG1, FL("FT Pre-Auth Time Out!!!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001416
1417 if((psessionEntry = peFindSessionBySessionId(pMac, pMac->lim.limTimers.gLimFTPreAuthRspTimer.sessionId))== NULL)
1418 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001419 limLog(pMac, LOGE, FL("Session Does not exist for given sessionID"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001420 return;
1421 }
1422
Abhishek Singh8a226222014-03-13 14:49:16 +05301423 /* To handle the race condition where we recieve preauth rsp after
1424 * timer has expired.
1425 */
Kanchanapally, Vidyullathaa7f6d212015-03-17 11:35:25 +05301426
1427 if (pMac->ft.ftPEContext.pFTPreAuthReq == NULL)
1428 {
1429 limLog(pMac, LOGE, FL("Auth Rsp might already be posted to SME"
1430 " and ftcleanup done! sessionId:%d"),
1431 pMac->lim.limTimers.gLimFTPreAuthRspTimer.sessionId);
1432 return;
1433 }
1434
Abhishek Singh8a226222014-03-13 14:49:16 +05301435 if (eANI_BOOLEAN_TRUE ==
1436 pMac->ft.ftPEContext.pFTPreAuthReq->bPreAuthRspProcessed)
1437 {
1438 limLog(pMac,LOGE,FL("Auth rsp already posted to SME"
Jeff Johnson0fe596e2017-09-19 08:36:48 -07001439 " (session %pK)"), psessionEntry);
Abhishek Singh8a226222014-03-13 14:49:16 +05301440 return;
1441 }
1442 else
1443 {
1444 /* Here we are sending preauth rsp with failure state
1445 * and which is forwarded to SME. Now, if we receive an preauth
1446 * resp from AP with success it would create a FT pesession, but
1447 * will be dropped in SME leaving behind the pesession.
1448 * Mark Preauth rsp processed so that any rsp from AP is dropped in
1449 * limProcessAuthFrameNoSession.
1450 */
1451 limLog(pMac,LOG1,FL("Auth rsp not yet posted to SME"
Jeff Johnson0fe596e2017-09-19 08:36:48 -07001452 " (session %pK)"), psessionEntry);
Abhishek Singh8a226222014-03-13 14:49:16 +05301453 pMac->ft.ftPEContext.pFTPreAuthReq->bPreAuthRspProcessed =
1454 eANI_BOOLEAN_TRUE;
1455 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001456 // Ok, so attempted at Pre-Auth and failed. If we are off channel. We need
1457 // to get back.
1458 limHandleFTPreAuthRsp(pMac, eSIR_FAILURE, NULL, 0, psessionEntry);
1459}
1460
1461
1462/*------------------------------------------------------------------
1463 *
1464 * This function is called to process the update key request from SME
1465 *
1466 *------------------------------------------------------------------*/
1467tANI_BOOLEAN limProcessFTUpdateKey(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf )
1468{
Gopichand Nakkala3d295922013-05-07 16:19:14 +05301469 tAddBssParams * pAddBssParams;
1470 tSirFTUpdateKeyInfo * pKeyInfo;
1471 tANI_U32 val = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001472
Gopichand Nakkala3d295922013-05-07 16:19:14 +05301473 /* Sanity Check */
1474 if( pMac == NULL || pMsgBuf == NULL )
1475 {
1476 return TRUE;
1477 }
1478 if(pMac->ft.ftPEContext.pAddBssReq == NULL)
1479 {
1480 limLog( pMac, LOGE,
1481 FL( "pAddBssReq is NULL" ));
1482 return TRUE;
1483 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001484
Gopichand Nakkala3d295922013-05-07 16:19:14 +05301485 pAddBssParams = pMac->ft.ftPEContext.pAddBssReq;
1486 pKeyInfo = (tSirFTUpdateKeyInfo *)pMsgBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -07001487
Gopichand Nakkala3d295922013-05-07 16:19:14 +05301488 /* Store the key information in the ADD BSS parameters */
1489 pAddBssParams->extSetStaKeyParamValid = 1;
1490 pAddBssParams->extSetStaKeyParam.encType = pKeyInfo->keyMaterial.edType;
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05301491 vos_mem_copy((tANI_U8 *) &pAddBssParams->extSetStaKeyParam.key,
1492 (tANI_U8 *) &pKeyInfo->keyMaterial.key, sizeof(tSirKeys));
Gopichand Nakkala3d295922013-05-07 16:19:14 +05301493 if(eSIR_SUCCESS != wlan_cfgGetInt(pMac, WNI_CFG_SINGLE_TID_RC, &val))
1494 {
1495 limLog( pMac, LOGP, FL( "Unable to read WNI_CFG_SINGLE_TID_RC" ));
1496 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001497
Gopichand Nakkala3d295922013-05-07 16:19:14 +05301498 pAddBssParams->extSetStaKeyParam.singleTidRc = val;
Abhishek Singh3cbf6052014-12-15 16:46:42 +05301499 limLog(pMac, LOG1, FL("Key valid %d key len = %d"),
Gopichand Nakkala3d295922013-05-07 16:19:14 +05301500 pAddBssParams->extSetStaKeyParamValid,
Abhishek Singh3cbf6052014-12-15 16:46:42 +05301501 pAddBssParams->extSetStaKeyParam.key[0].keyLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07001502
Gopichand Nakkala3d295922013-05-07 16:19:14 +05301503 pAddBssParams->extSetStaKeyParam.staIdx = 0;
1504
Abhishek Singh3cbf6052014-12-15 16:46:42 +05301505 limLog(pMac, LOG1,
1506 FL("BSSID = "MAC_ADDRESS_STR), MAC_ADDR_ARRAY(pKeyInfo->bssId));
Gopichand Nakkala3d295922013-05-07 16:19:14 +05301507
Gopichand Nakkala3d295922013-05-07 16:19:14 +05301508 return TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001509}
1510
1511tSirRetStatus
1512limProcessFTAggrQosReq(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf )
1513{
1514 tSirMsgQ msg;
1515 tSirAggrQosReq * aggrQosReq = (tSirAggrQosReq *)pMsgBuf;
1516 tpAggrAddTsParams pAggrAddTsParam;
1517 tpPESession psessionEntry = NULL;
1518 tpLimTspecInfo tspecInfo;
1519 tANI_U8 ac;
1520 tpDphHashNode pSta;
1521 tANI_U16 aid;
1522 tANI_U8 sessionId;
1523 int i;
1524
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05301525 pAggrAddTsParam = vos_mem_malloc(sizeof(tAggrAddTsParams));
1526 if (NULL == pAggrAddTsParam)
Jeff Johnson295189b2012-06-20 16:38:30 -07001527 {
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05301528 PELOGE(limLog(pMac, LOGE, FL("AllocateMemory() failed"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001529 return eSIR_MEM_ALLOC_FAILED;
1530 }
1531
1532 psessionEntry = peFindSessionByBssid(pMac, aggrQosReq->bssId, &sessionId);
1533
1534 if (psessionEntry == NULL) {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001535 PELOGE(limLog(pMac, LOGE, FL("psession Entry Null for sessionId = %d"), aggrQosReq->sessionId);)
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05301536 vos_mem_free(pAggrAddTsParam);
Jeff Johnson295189b2012-06-20 16:38:30 -07001537 return eSIR_FAILURE;
1538 }
1539
1540 pSta = dphLookupHashEntry(pMac, aggrQosReq->bssId, &aid, &psessionEntry->dph.dphHashTable);
1541 if (pSta == NULL)
1542 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001543 PELOGE(limLog(pMac, LOGE, FL("Station context not found - ignoring AddTsRsp"));)
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05301544 vos_mem_free(pAggrAddTsParam);
Jeff Johnson295189b2012-06-20 16:38:30 -07001545 return eSIR_FAILURE;
1546 }
1547
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05301548 vos_mem_set((tANI_U8 *)pAggrAddTsParam,
1549 sizeof(tAggrAddTsParams), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07001550 pAggrAddTsParam->staIdx = psessionEntry->staId;
1551 // Fill in the sessionId specific to PE
1552 pAggrAddTsParam->sessionId = sessionId;
1553 pAggrAddTsParam->tspecIdx = aggrQosReq->aggrInfo.tspecIdx;
1554
1555 for( i = 0; i < HAL_QOS_NUM_AC_MAX; i++ )
1556 {
1557 if (aggrQosReq->aggrInfo.tspecIdx & (1<<i))
1558 {
1559 tSirMacTspecIE *pTspec = &aggrQosReq->aggrInfo.aggrAddTsInfo[i].tspec;
1560 /* Since AddTS response was successful, check for the PSB flag
1561 * and directional flag inside the TS Info field.
1562 * An AC is trigger enabled AC if the PSB subfield is set to 1
1563 * in the uplink direction.
1564 * An AC is delivery enabled AC if the PSB subfield is set to 1
1565 * in the downlink direction.
1566 * An AC is trigger and delivery enabled AC if the PSB subfield
1567 * is set to 1 in the bi-direction field.
1568 */
1569 if (pTspec->tsinfo.traffic.psb == 1)
1570 {
1571 limSetTspecUapsdMask(pMac, &pTspec->tsinfo, SET_UAPSD_MASK);
1572 }
1573 else
1574 {
1575 limSetTspecUapsdMask(pMac, &pTspec->tsinfo, CLEAR_UAPSD_MASK);
1576 }
1577 /* ADDTS success, so AC is now admitted. We shall now use the default
1578 * EDCA parameters as advertised by AP and send the updated EDCA params
1579 * to HAL.
1580 */
1581 ac = upToAc(pTspec->tsinfo.traffic.userPrio);
1582 if(pTspec->tsinfo.traffic.direction == SIR_MAC_DIRECTION_UPLINK)
1583 {
1584 pMac->lim.gAcAdmitMask[SIR_MAC_DIRECTION_UPLINK] |= (1 << ac);
1585 }
1586 else if(pTspec->tsinfo.traffic.direction == SIR_MAC_DIRECTION_DNLINK)
1587 {
1588 pMac->lim.gAcAdmitMask[SIR_MAC_DIRECTION_DNLINK] |= (1 << ac);
1589 }
1590 else if(pTspec->tsinfo.traffic.direction == SIR_MAC_DIRECTION_BIDIR)
1591 {
1592 pMac->lim.gAcAdmitMask[SIR_MAC_DIRECTION_UPLINK] |= (1 << ac);
1593 pMac->lim.gAcAdmitMask[SIR_MAC_DIRECTION_DNLINK] |= (1 << ac);
1594 }
1595
1596 limSetActiveEdcaParams(pMac, psessionEntry->gLimEdcaParams, psessionEntry);
1597
1598 if (pSta->aniPeer == eANI_BOOLEAN_TRUE)
1599 {
1600 limSendEdcaParams(pMac, psessionEntry->gLimEdcaParamsActive, pSta->bssId, eANI_BOOLEAN_TRUE);
1601 }
1602 else
1603 {
1604 limSendEdcaParams(pMac, psessionEntry->gLimEdcaParamsActive, pSta->bssId, eANI_BOOLEAN_FALSE);
1605 }
1606
1607 if(eSIR_SUCCESS != limTspecAdd(pMac, pSta->staAddr, pSta->assocId, pTspec, 0, &tspecInfo))
1608 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001609 PELOGE(limLog(pMac, LOGE, FL("Adding entry in lim Tspec Table failed "));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001610 pMac->lim.gLimAddtsSent = false;
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05301611 vos_mem_free(pAggrAddTsParam);
Jeff Johnson295189b2012-06-20 16:38:30 -07001612 return eSIR_FAILURE; //Error handling. send the response with error status. need to send DelTS to tear down the TSPEC status.
1613 }
1614
1615 // Copy the TSPEC paramters
1616 pAggrAddTsParam->tspec[i] = aggrQosReq->aggrInfo.aggrAddTsInfo[i].tspec;
1617 }
1618 }
1619
1620 msg.type = WDA_AGGR_QOS_REQ;
1621 msg.bodyptr = pAggrAddTsParam;
1622 msg.bodyval = 0;
1623
1624 /* We need to defer any incoming messages until we get a
1625 * WDA_AGGR_QOS_RSP from HAL.
1626 */
1627 SET_LIM_PROCESS_DEFD_MESGS(pMac, false);
Jeff Johnsone7245742012-09-05 17:12:55 -07001628 MTRACE(macTraceMsgTx(pMac, psessionEntry->peSessionId, msg.type));
Jeff Johnson295189b2012-06-20 16:38:30 -07001629
1630 if(eSIR_SUCCESS != wdaPostCtrlMsg(pMac, &msg))
1631 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001632 PELOGW(limLog(pMac, LOGW, FL("wdaPostCtrlMsg() failed"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001633 SET_LIM_PROCESS_DEFD_MESGS(pMac, true);
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05301634 vos_mem_free(pAggrAddTsParam);
Jeff Johnson295189b2012-06-20 16:38:30 -07001635 return eSIR_FAILURE;
1636 }
1637
1638 return eSIR_SUCCESS;
1639}
1640
1641void
1642limFTSendAggrQosRsp(tpAniSirGlobal pMac, tANI_U8 rspReqd,
1643 tpAggrAddTsParams aggrQosRsp, tANI_U8 smesessionId)
1644{
1645 tpSirAggrQosRsp rsp;
1646 int i = 0;
1647
1648 if (! rspReqd)
1649 {
1650 return;
1651 }
1652
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05301653 rsp = vos_mem_malloc(sizeof(tSirAggrQosRsp));
1654 if (NULL == rsp)
Jeff Johnson295189b2012-06-20 16:38:30 -07001655 {
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05301656 limLog(pMac, LOGP, FL("AllocateMemory failed for tSirAggrQosRsp"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001657 return;
1658 }
1659
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05301660 vos_mem_set((tANI_U8 *) rsp, sizeof(*rsp), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07001661 rsp->messageType = eWNI_SME_FT_AGGR_QOS_RSP;
1662 rsp->sessionId = smesessionId;
1663 rsp->length = sizeof(*rsp);
1664 rsp->aggrInfo.tspecIdx = aggrQosRsp->tspecIdx;
1665
1666 for( i = 0; i < SIR_QOS_NUM_AC_MAX; i++ )
1667 {
1668 if( (1 << i) & aggrQosRsp->tspecIdx )
1669 {
1670 rsp->aggrInfo.aggrRsp[i].status = aggrQosRsp->status[i];
1671 rsp->aggrInfo.aggrRsp[i].tspec = aggrQosRsp->tspec[i];
1672 }
1673 }
1674
1675 limSendSmeAggrQosRsp(pMac, rsp, smesessionId);
1676 return;
1677}
1678
1679
1680void limProcessFTAggrQoSRsp(tpAniSirGlobal pMac, tpSirMsgQ limMsg)
1681{
1682 tpAggrAddTsParams pAggrQosRspMsg = NULL;
1683 //tpAggrQosParams pAggrQosRspMsg = NULL;
1684 tAddTsParams addTsParam = {0};
1685 tpDphHashNode pSta = NULL;
1686 tANI_U16 assocId =0;
1687 tSirMacAddr peerMacAddr;
1688 tANI_U8 rspReqd = 1;
1689 tpPESession psessionEntry = NULL;
1690 int i = 0;
1691
Abhishek Singh3cbf6052014-12-15 16:46:42 +05301692 limLog(pMac, LOG1, FL(" Received AGGR_QOS_RSP from HAL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001693
1694 /* Need to process all the deferred messages enqueued since sending the
1695 SIR_HAL_AGGR_ADD_TS_REQ */
1696 SET_LIM_PROCESS_DEFD_MESGS(pMac, true);
1697
1698 pAggrQosRspMsg = (tpAggrAddTsParams) (limMsg->bodyptr);
1699 if (NULL == pAggrQosRspMsg)
1700 {
1701 PELOGE(limLog(pMac, LOGE, FL("NULL pAggrQosRspMsg"));)
1702 return;
1703 }
1704
1705 psessionEntry = peFindSessionBySessionId(pMac, pAggrQosRspMsg->sessionId);
1706 if (NULL == psessionEntry)
1707 {
1708 // Cant find session entry
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001709 PELOGE(limLog(pMac, LOGE, FL("Cant find session entry for %s"), __func__);)
Jeff Johnson295189b2012-06-20 16:38:30 -07001710 if( pAggrQosRspMsg != NULL )
1711 {
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05301712 vos_mem_free(pAggrQosRspMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -07001713 }
1714 return;
1715 }
1716
1717 for( i = 0; i < HAL_QOS_NUM_AC_MAX; i++ )
1718 {
1719 if((((1 << i) & pAggrQosRspMsg->tspecIdx)) &&
1720 (pAggrQosRspMsg->status[i] != eHAL_STATUS_SUCCESS))
1721 {
1722 /* send DELTS to the station */
1723 sirCopyMacAddr(peerMacAddr,psessionEntry->bssId);
1724
1725 addTsParam.staIdx = pAggrQosRspMsg->staIdx;
1726 addTsParam.sessionId = pAggrQosRspMsg->sessionId;
1727 addTsParam.tspec = pAggrQosRspMsg->tspec[i];
1728 addTsParam.tspecIdx = pAggrQosRspMsg->tspecIdx;
1729
1730 limSendDeltsReqActionFrame(pMac, peerMacAddr, rspReqd,
1731 &addTsParam.tspec.tsinfo,
1732 &addTsParam.tspec, psessionEntry);
1733
1734 pSta = dphLookupAssocId(pMac, addTsParam.staIdx, &assocId,
1735 &psessionEntry->dph.dphHashTable);
1736 if (pSta != NULL)
1737 {
1738 limAdmitControlDeleteTS(pMac, assocId, &addTsParam.tspec.tsinfo,
1739 NULL, (tANI_U8 *)&addTsParam.tspecIdx);
1740 }
1741 }
1742 }
1743
1744 /* Send the Aggr QoS response to SME */
1745
1746 limFTSendAggrQosRsp(pMac, rspReqd, pAggrQosRspMsg,
1747 psessionEntry->smeSessionId);
1748 if( pAggrQosRspMsg != NULL )
1749 {
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05301750 vos_mem_free(pAggrQosRspMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -07001751 }
1752 return;
1753}
1754
Jeff Johnson295189b2012-06-20 16:38:30 -07001755#endif /* WLAN_FEATURE_VOWIFI_11R */