blob: a4f67b38ce0463413da87775515887bd0724fc03 [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/*
43 * Airgo Networks, Inc proprietary. All rights reserved.
44 * This file limProcessSmeReqMessages.cc contains the code
45 * for processing SME request messages.
46 * Author: Chandra Modumudi
47 * Date: 02/11/02
48 * History:-
49 * Date Modified by Modification Information
50 * --------------------------------------------------------------------
51 *
52 */
53
54#include "palTypes.h"
55#include "wniApi.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070056#include "wniCfgSta.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070057#include "cfgApi.h"
58#include "sirApi.h"
59#include "schApi.h"
60#include "utilsApi.h"
61#include "limTypes.h"
62#include "limUtils.h"
63#include "limAssocUtils.h"
64#include "limSecurityUtils.h"
65#include "limSerDesUtils.h"
66#include "limSmeReqUtils.h"
67#include "limIbssPeerMgmt.h"
68#include "limAdmitControl.h"
69#include "dphHashTable.h"
70#include "limSendMessages.h"
71#include "limApi.h"
72#include "wmmApsd.h"
73
Jeff Johnson295189b2012-06-20 16:38:30 -070074#include "sapApi.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070075
76#if defined WLAN_FEATURE_VOWIFI
77#include "rrmApi.h"
78#endif
79#if defined FEATURE_WLAN_CCX
80#include "ccxApi.h"
81#endif
82
83#if defined WLAN_FEATURE_VOWIFI_11R
84#include <limFT.h>
85#endif
86
87#ifdef FEATURE_WLAN_CCX
88/* These are the min/max tx power (non virtual rates) range
89 supported by prima hardware */
90#define MIN_TX_PWR_CAP 12
91#define MAX_TX_PWR_CAP 19
92
93#endif
94
Viral Modid86bde22012-12-10 13:09:21 -080095/* This overhead is time for sending NOA start to host in case of GO/sending NULL data & receiving ACK
96 * in case of P2P Client and starting actual scanning with init scan req/rsp plus in case of concurrency,
Sunil Ravi24fd3aa2013-01-21 22:12:06 -080097 * taking care of sending null data and receiving ACK to/from AP/Also SetChannel with calibration is taking
98 * around 7ms .
Viral Modid86bde22012-12-10 13:09:21 -080099 */
Viral Modid440e682013-03-06 02:25:31 -0800100#define SCAN_MESSAGING_OVERHEAD 20 // in msecs
101#define JOIN_NOA_DURATION 2000 // in msecs
102#define OEM_DATA_NOA_DURATION 60 // in msecs
103#define DEFAULT_PASSIVE_MAX_CHANNEL_TIME 110 // in msecs
Jeff Johnson295189b2012-06-20 16:38:30 -0700104
Gopichand Nakkala096a1052012-12-21 07:05:34 -0800105#define CONV_MS_TO_US 1024 //conversion factor from ms to us
106
Jeff Johnson295189b2012-06-20 16:38:30 -0700107// SME REQ processing function templates
108static void __limProcessSmeStartReq(tpAniSirGlobal, tANI_U32 *);
109static tANI_BOOLEAN __limProcessSmeSysReadyInd(tpAniSirGlobal, tANI_U32 *);
110static tANI_BOOLEAN __limProcessSmeStartBssReq(tpAniSirGlobal, tpSirMsgQ pMsg);
Viral Modid440e682013-03-06 02:25:31 -0800111static void __limProcessSmeScanReq(tpAniSirGlobal, tANI_U32 *);
Jeff Johnson295189b2012-06-20 16:38:30 -0700112static void __limProcessSmeJoinReq(tpAniSirGlobal, tANI_U32 *);
113static void __limProcessSmeReassocReq(tpAniSirGlobal, tANI_U32 *);
114static void __limProcessSmeDisassocReq(tpAniSirGlobal, tANI_U32 *);
115static void __limProcessSmeDisassocCnf(tpAniSirGlobal, tANI_U32 *);
116static void __limProcessSmeDeauthReq(tpAniSirGlobal, tANI_U32 *);
117static void __limProcessSmeSetContextReq(tpAniSirGlobal, tANI_U32 *);
118static tANI_BOOLEAN __limProcessSmeStopBssReq(tpAniSirGlobal, tpSirMsgQ pMsg);
119
Jeff Johnson295189b2012-06-20 16:38:30 -0700120void __limProcessSmeAssocCnfNew(tpAniSirGlobal, tANI_U32, tANI_U32 *);
121
Jeff Johnson295189b2012-06-20 16:38:30 -0700122extern void peRegisterTLHandle(tpAniSirGlobal pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -0700123
Jeff Johnson295189b2012-06-20 16:38:30 -0700124
Jeff Johnson295189b2012-06-20 16:38:30 -0700125#ifdef BACKGROUND_SCAN_ENABLED
126
127// start the background scan timers if it hasn't already started
128static void
129__limBackgroundScanInitiate(tpAniSirGlobal pMac)
130{
131 if (pMac->lim.gLimBackgroundScanStarted)
132 return;
133
134 //make sure timer is created first
135 if (TX_TIMER_VALID(pMac->lim.limTimers.gLimBackgroundScanTimer))
136 {
137 limDeactivateAndChangeTimer(pMac, eLIM_BACKGROUND_SCAN_TIMER);
Jeff Johnsone7245742012-09-05 17:12:55 -0700138 MTRACE(macTrace(pMac, TRACE_CODE_TIMER_ACTIVATE, NO_SESSION, eLIM_BACKGROUND_SCAN_TIMER));
Jeff Johnson295189b2012-06-20 16:38:30 -0700139 if (tx_timer_activate(&pMac->lim.limTimers.gLimBackgroundScanTimer) != TX_SUCCESS)
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700140 limLog(pMac, LOGP, FL("could not activate background scan timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700141 pMac->lim.gLimBackgroundScanStarted = true;
142 pMac->lim.gLimBackgroundScanChannelId = 0;
143 }
144}
145
146#endif // BACKGROUND_SCAN_ENABLED
Jeff Johnson295189b2012-06-20 16:38:30 -0700147
148// determine if a fresh scan request must be issued or not
149/*
150* PE will do fresh scan, if all of the active sessions are in good state (Link Est or BSS Started)
151* If one of the sessions is not in one of the above states, then PE does not do fresh scan
152* If no session exists (scanning very first time), then PE will always do fresh scan if SME
153* asks it to do that.
154*/
155static tANI_U8
156__limFreshScanReqd(tpAniSirGlobal pMac, tANI_U8 returnFreshResults)
157{
158
159 tANI_U8 validState = TRUE;
160 int i;
161
162 if(pMac->lim.gLimSmeState != eLIM_SME_IDLE_STATE)
163 {
164 return FALSE;
165 }
166 for(i =0; i < pMac->lim.maxBssId; i++)
167 {
168
169 if(pMac->lim.gpSession[i].valid == TRUE)
170 {
171 if(!( ( ( (pMac->lim.gpSession[i].bssType == eSIR_INFRASTRUCTURE_MODE) ||
172 (pMac->lim.gpSession[i].limSystemRole == eLIM_BT_AMP_STA_ROLE))&&
173 (pMac->lim.gpSession[i].limSmeState == eLIM_SME_LINK_EST_STATE) )||
174
175 ( ( (pMac->lim.gpSession[i].bssType == eSIR_IBSS_MODE)||
176 (pMac->lim.gpSession[i].limSystemRole == eLIM_BT_AMP_AP_ROLE)||
177 (pMac->lim.gpSession[i].limSystemRole == eLIM_BT_AMP_STA_ROLE) )&&
178 (pMac->lim.gpSession[i].limSmeState == eLIM_SME_NORMAL_STATE) )
Jeff Johnson295189b2012-06-20 16:38:30 -0700179 || ( ( ( (pMac->lim.gpSession[i].bssType == eSIR_INFRA_AP_MODE)
180 && ( pMac->lim.gpSession[i].pePersona == VOS_P2P_GO_MODE) )
181 || (pMac->lim.gpSession[i].limSystemRole == eLIM_AP_ROLE) )
182 && (pMac->lim.gpSession[i].limSmeState == eLIM_SME_NORMAL_STATE) )
Jeff Johnson295189b2012-06-20 16:38:30 -0700183 ))
184 {
185 validState = FALSE;
186 break;
187 }
188
189 }
190 }
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700191 PELOG1(limLog(pMac, LOG1, FL("FreshScanReqd: %d "), validState);)
Jeff Johnson295189b2012-06-20 16:38:30 -0700192
193 if( (validState) && (returnFreshResults & SIR_BG_SCAN_RETURN_FRESH_RESULTS))
194 return TRUE;
195
196 return FALSE;
197}
198
Jeff Johnson295189b2012-06-20 16:38:30 -0700199
200
201/**
202 * __limIsSmeAssocCnfValid()
203 *
204 *FUNCTION:
205 * This function is called by limProcessLmmMessages() upon
206 * receiving SME_ASSOC_CNF.
207 *
208 *LOGIC:
209 * Message validity checks are performed in this function
210 *
211 *ASSUMPTIONS:
212 *
213 *NOTE:
214 *
215 * @param pMeasReq Pointer to Received ASSOC_CNF message
216 * @return true When received SME_ASSOC_CNF is formatted
217 * correctly
218 * false otherwise
219 */
220
221inline static tANI_U8
222__limIsSmeAssocCnfValid(tpSirSmeAssocCnf pAssocCnf)
223{
224 if (limIsGroupAddr(pAssocCnf->peerMacAddr))
225 return false;
226 else
227 return true;
228} /*** end __limIsSmeAssocCnfValid() ***/
229
230
231/**
232 * __limGetSmeJoinReqSizeForAlloc()
233 *
234 *FUNCTION:
235 * This function is called in various places to get IE length
236 * from tSirBssDescription structure
237 * number being scanned.
238 *
239 *PARAMS:
240 *
241 *LOGIC:
242 *
243 *ASSUMPTIONS:
244 * NA
245 *
246 *NOTE:
247 * NA
248 *
249 * @param pBssDescr
250 * @return Total IE length
251 */
252
253static tANI_U16
254__limGetSmeJoinReqSizeForAlloc(tANI_U8 *pBuf)
255{
256 tANI_U16 len = 0;
257
258 if (!pBuf)
259 return len;
260
261 pBuf += sizeof(tANI_U16);
262 len = limGetU16( pBuf );
263 return (len + sizeof( tANI_U16 ));
264} /*** end __limGetSmeJoinReqSizeForAlloc() ***/
265
266
267/**----------------------------------------------------------------
268\fn __limIsDeferedMsgForLearn
269
270\brief Has role only if 11h is enabled. Not used on STA side.
271 Defers the message if SME is in learn state and brings
272 the LIM back to normal mode.
273
274\param pMac
275\param pMsg - Pointer to message posted from SME to LIM.
276\return TRUE - If defered
277 FALSE - Otherwise
278------------------------------------------------------------------*/
279static tANI_BOOLEAN
280__limIsDeferedMsgForLearn(tpAniSirGlobal pMac, tpSirMsgQ pMsg)
281{
282 if (limIsSystemInScanState(pMac))
283 {
284 if (limDeferMsg(pMac, pMsg) != TX_SUCCESS)
285 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700286 PELOGE(limLog(pMac, LOGE, FL("Could not defer Msg = %d"), pMsg->type);)
Jeff Johnson295189b2012-06-20 16:38:30 -0700287 return eANI_BOOLEAN_FALSE;
288 }
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700289 PELOG1(limLog(pMac, LOG1, FL("Defer the message, in learn mode type = %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -0700290 pMsg->type);)
291
292 /** Send finish scan req to HAL only if LIM is not waiting for any response
293 * from HAL like init scan rsp, start scan rsp etc.
294 */
295 if (GET_LIM_PROCESS_DEFD_MESGS(pMac))
296 {
297 //Set the resume channel to Any valid channel (invalid).
298 //This will instruct HAL to set it to any previous valid channel.
299 peSetResumeChannel(pMac, 0, 0);
300 limSendHalFinishScanReq(pMac, eLIM_HAL_FINISH_LEARN_WAIT_STATE);
301 }
302
303 return eANI_BOOLEAN_TRUE;
304 }
305 return eANI_BOOLEAN_FALSE;
306}
307
308/**----------------------------------------------------------------
309\fn __limIsDeferedMsgForRadar
310
311\brief Has role only if 11h is enabled. Not used on STA side.
312 Defers the message if radar is detected.
313
314\param pMac
315\param pMsg - Pointer to message posted from SME to LIM.
316\return TRUE - If defered
317 FALSE - Otherwise
318------------------------------------------------------------------*/
319static tANI_BOOLEAN
320__limIsDeferedMsgForRadar(tpAniSirGlobal pMac, tpSirMsgQ pMsg)
321{
322 /** fRadarDetCurOperChan will be set only if we detect radar in current
323 * operating channel and System Role == AP ROLE */
Jeff Johnsone7245742012-09-05 17:12:55 -0700324 //TODO: Need to take care radar detection.
325 //if (LIM_IS_RADAR_DETECTED(pMac))
326 if( 0 )
Jeff Johnson295189b2012-06-20 16:38:30 -0700327 {
328 if (limDeferMsg(pMac, pMsg) != TX_SUCCESS)
329 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700330 PELOGE(limLog(pMac, LOGE, FL("Could not defer Msg = %d"), pMsg->type);)
Jeff Johnson295189b2012-06-20 16:38:30 -0700331 return eANI_BOOLEAN_FALSE;
332 }
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700333 PELOG1(limLog(pMac, LOG1, FL("Defer the message, in learn mode type = %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -0700334 pMsg->type);)
335 return eANI_BOOLEAN_TRUE;
336 }
337 return eANI_BOOLEAN_FALSE;
338}
339
340
341/**
342 * __limProcessSmeStartReq()
343 *
344 *FUNCTION:
345 * This function is called to process SME_START_REQ message
346 * from HDD or upper layer application.
347 *
348 *LOGIC:
349 *
350 *ASSUMPTIONS:
351 *
352 *NOTE:
353 *
354 * @param pMac Pointer to Global MAC structure
355 * @param *pMsgBuf A pointer to the SME message buffer
356 * @return None
357 */
358
359static void
360__limProcessSmeStartReq(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
361{
362 tSirResultCodes retCode = eSIR_SME_SUCCESS;
363 tANI_U8 smesessionId;
364 tANI_U16 smetransactionId;
365
366
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700367 PELOG1(limLog(pMac, LOG1, FL("Received START_REQ"));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700368
369 limGetSessionInfo(pMac,(tANI_U8 *)pMsgBuf,&smesessionId,&smetransactionId);
370
371 if (pMac->lim.gLimSmeState == eLIM_SME_OFFLINE_STATE)
372 {
373 pMac->lim.gLimSmeState = eLIM_SME_IDLE_STATE;
374
Jeff Johnsone7245742012-09-05 17:12:55 -0700375 MTRACE(macTrace(pMac, TRACE_CODE_SME_STATE, NO_SESSION, pMac->lim.gLimSmeState));
Jeff Johnson295189b2012-06-20 16:38:30 -0700376
377 /// By default do not return after first scan match
378 pMac->lim.gLimReturnAfterFirstMatch = 0;
379
380 /// Initialize MLM state machine
381 limInitMlm(pMac);
382
383 /// By default return unique scan results
384 pMac->lim.gLimReturnUniqueResults = true;
385 pMac->lim.gLimSmeScanResultLength = 0;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -0700386#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
387 pMac->lim.gLimSmeLfrScanResultLength = 0;
388#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700389
Jeff Johnson295189b2012-06-20 16:38:30 -0700390 if (((tSirSmeStartReq *) pMsgBuf)->sendNewBssInd)
391 {
392 /*
393 * Need to indicate new BSSs found during background scanning to
394 * host. Update this parameter at CFG
395 */
396 if (cfgSetInt(pMac, WNI_CFG_NEW_BSS_FOUND_IND, ((tSirSmeStartReq *) pMsgBuf)->sendNewBssInd)
397 != eSIR_SUCCESS)
398 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700399 limLog(pMac, LOGP, FL("could not set NEIGHBOR_BSS_IND at CFG"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700400 retCode = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
401 }
402 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700403 }
404 else
405 {
406 /**
407 * Should not have received eWNI_SME_START_REQ in states
408 * other than OFFLINE. Return response to host and
409 * log error
410 */
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700411 limLog(pMac, LOGE, FL("Invalid SME_START_REQ received in SME state %X"),pMac->lim.gLimSmeState );
Jeff Johnson295189b2012-06-20 16:38:30 -0700412 limPrintSmeState(pMac, LOGE, pMac->lim.gLimSmeState);
413 retCode = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
414 }
415 limSendSmeRsp(pMac, eWNI_SME_START_RSP, retCode,smesessionId,smetransactionId);
416} /*** end __limProcessSmeStartReq() ***/
417
418
419/** -------------------------------------------------------------
420\fn __limProcessSmeSysReadyInd
421\brief handles the notification from HDD. PE just forwards this message to HAL.
422\param tpAniSirGlobal pMac
423\param tANI_U32* pMsgBuf
424\return TRUE-Posting to HAL failed, so PE will consume the buffer.
425\ FALSE-Posting to HAL successful, so HAL will consume the buffer.
426 -------------------------------------------------------------*/
427static tANI_BOOLEAN
428__limProcessSmeSysReadyInd(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
429{
430 tSirMsgQ msg;
431
432 msg.type = WDA_SYS_READY_IND;
433 msg.reserved = 0;
434 msg.bodyptr = pMsgBuf;
435 msg.bodyval = 0;
436
Jeff Johnson92751692013-03-06 16:00:33 -0800437 if (pMac->gDriverType != eDRIVER_TYPE_MFG)
Jeff Johnson295189b2012-06-20 16:38:30 -0700438 {
Jeff Johnson92751692013-03-06 16:00:33 -0800439 peRegisterTLHandle(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -0700440 }
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700441 PELOGW(limLog(pMac, LOGW, FL("sending WDA_SYS_READY_IND msg to HAL"));)
Jeff Johnsone7245742012-09-05 17:12:55 -0700442 MTRACE(macTraceMsgTx(pMac, NO_SESSION, msg.type));
Jeff Johnson295189b2012-06-20 16:38:30 -0700443
Jeff Johnson92751692013-03-06 16:00:33 -0800444 if (eSIR_SUCCESS != wdaPostCtrlMsg(pMac, &msg))
Jeff Johnson295189b2012-06-20 16:38:30 -0700445 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700446 limLog(pMac, LOGP, FL("wdaPostCtrlMsg failed"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700447 return eANI_BOOLEAN_TRUE;
448 }
449 return eANI_BOOLEAN_FALSE;
450}
451
Jeff Johnsone7245742012-09-05 17:12:55 -0700452#ifdef WLAN_FEATURE_11AC
Jeff Johnson295189b2012-06-20 16:38:30 -0700453
Jeff Johnsone7245742012-09-05 17:12:55 -0700454tANI_U32 limGetCenterChannel(tpAniSirGlobal pMac,tANI_U8 primarychanNum,ePhyChanBondState secondaryChanOffset, tANI_U8 chanWidth)
455{
456 if (chanWidth == WNI_CFG_VHT_CHANNEL_WIDTH_80MHZ)
457 {
458 switch(secondaryChanOffset)
459 {
460 case PHY_QUADRUPLE_CHANNEL_20MHZ_CENTERED_40MHZ_CENTERED:
461 return primarychanNum;
462 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_CENTERED:
463 return primarychanNum + 2;
464 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_CENTERED:
465 return primarychanNum - 2;
466 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_LOW:
467 return primarychanNum + 6;
468 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_LOW:
469 return primarychanNum + 2;
470 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_HIGH:
471 return primarychanNum - 2;
472 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_HIGH:
473 return primarychanNum - 6;
474 default :
475 return eSIR_CFG_INVALID_ID;
476 }
477 }
478 else if (chanWidth == WNI_CFG_VHT_CHANNEL_WIDTH_20_40MHZ)
479 {
480 switch(secondaryChanOffset)
481 {
482 case PHY_DOUBLE_CHANNEL_LOW_PRIMARY:
483 return primarychanNum + 2;
484 case PHY_DOUBLE_CHANNEL_HIGH_PRIMARY:
485 return primarychanNum - 2;
486 case PHY_QUADRUPLE_CHANNEL_20MHZ_CENTERED_40MHZ_CENTERED:
487 return primarychanNum;
488 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_CENTERED:
489 return primarychanNum + 2;
490 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_CENTERED:
491 return primarychanNum - 2;
492 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_LOW:
493 return primarychanNum + 2;
494 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_LOW:
495 return primarychanNum - 2;
496 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_HIGH:
497 return primarychanNum + 2;
498 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_HIGH:
499 return primarychanNum - 2;
500 default :
501 return eSIR_CFG_INVALID_ID;
502 }
503 }
504 return primarychanNum;
505}
506
507#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700508/**
509 * __limHandleSmeStartBssRequest()
510 *
511 *FUNCTION:
512 * This function is called to process SME_START_BSS_REQ message
513 * from HDD or upper layer application.
514 *
515 *LOGIC:
516 *
517 *ASSUMPTIONS:
518 *
519 *NOTE:
520 *
521 * @param pMac Pointer to Global MAC structure
522 * @param *pMsgBuf A pointer to the SME message buffer
523 * @return None
524 */
525
526static void
527__limHandleSmeStartBssRequest(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
528{
529 tANI_U16 size;
530 tANI_U32 val = 0;
531 tSirRetStatus retStatus;
532 tSirMacChanNum channelNumber;
Jeff Johnsonace91102013-04-05 08:03:18 -0700533 tLimMlmStartReq *pMlmStartReq = NULL;
534 tpSirSmeStartBssReq pSmeStartBssReq = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -0700535 tSirResultCodes retCode = eSIR_SME_SUCCESS;
536 tANI_U32 autoGenBssId = FALSE; //Flag Used in case of IBSS to Auto generate BSSID.
Jeff Johnson295189b2012-06-20 16:38:30 -0700537 tANI_U8 sessionId;
538 tpPESession psessionEntry = NULL;
539 tANI_U8 smesessionId;
540 tANI_U16 smetransactionId;
541
542#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM //FEATURE_WLAN_DIAG_SUPPORT
543 //Since the session is not created yet, sending NULL. The response should have the correct state.
544 limDiagEventReport(pMac, WLAN_PE_DIAG_START_BSS_REQ_EVENT, NULL, 0, 0);
545#endif //FEATURE_WLAN_DIAG_SUPPORT
546
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700547 PELOG1(limLog(pMac, LOG1, FL("Received START_BSS_REQ"));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700548
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +0530549 /* Global Sme state and mlm states are not defined yet, for BT-AMP Suppoprt . TO BE DONE */
Jeff Johnson295189b2012-06-20 16:38:30 -0700550 if ( (pMac->lim.gLimSmeState == eLIM_SME_OFFLINE_STATE) ||
551 (pMac->lim.gLimSmeState == eLIM_SME_IDLE_STATE))
552 {
553 size = sizeof(tSirSmeStartBssReq) + SIR_MAC_MAX_IE_LENGTH;
554
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +0530555 pSmeStartBssReq = vos_mem_malloc(size);
556 if ( NULL == pSmeStartBssReq )
Jeff Johnson295189b2012-06-20 16:38:30 -0700557 {
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +0530558 PELOGE(limLog(pMac, LOGE, FL("AllocateMemory failed for pMac->lim.gpLimStartBssReq"));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700559 /// Send failure response to host
560 retCode = eSIR_SME_RESOURCES_UNAVAILABLE;
561 goto end;
562 }
563
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +0530564 vos_mem_set((void *)pSmeStartBssReq, size, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700565
566 if ((limStartBssReqSerDes(pMac, pSmeStartBssReq, (tANI_U8 *) pMsgBuf) == eSIR_FAILURE) ||
567 (!limIsSmeStartBssReqValid(pMac, pSmeStartBssReq)))
568 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700569 PELOGW(limLog(pMac, LOGW, FL("Received invalid eWNI_SME_START_BSS_REQ"));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700570 retCode = eSIR_SME_INVALID_PARAMETERS;
571 goto free;
572 }
573#if 0
574 PELOG3(limLog(pMac, LOG3,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700575 FL("Parsed START_BSS_REQ fields are bssType=%d, channelId=%d"),
Jeff Johnson295189b2012-06-20 16:38:30 -0700576 pMac->lim.gpLimStartBssReq->bssType, pMac->lim.gpLimStartBssReq->channelId);)
577#endif
578
579 /* This is the place where PE is going to create a session.
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +0530580 * If session is not existed, then create a new session */
Jeff Johnson295189b2012-06-20 16:38:30 -0700581 if((psessionEntry = peFindSessionByBssid(pMac,pSmeStartBssReq->bssId,&sessionId)) != NULL)
582 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700583 limLog(pMac, LOGW, FL("Session Already exists for given BSSID"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700584 retCode = eSIR_SME_BSS_ALREADY_STARTED_OR_JOINED;
585 psessionEntry = NULL;
586 goto free;
587 }
588 else
589 {
590 if((psessionEntry = peCreateSession(pMac,pSmeStartBssReq->bssId,&sessionId, pMac->lim.maxStation)) == NULL)
591 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700592 limLog(pMac, LOGW, FL("Session Can not be created "));
Jeff Johnson295189b2012-06-20 16:38:30 -0700593 retCode = eSIR_SME_RESOURCES_UNAVAILABLE;
594 goto free;
595 }
596
597 }
598
599 /* Store the session related parameters in newly created session */
600 psessionEntry->pLimStartBssReq = pSmeStartBssReq;
601
602 /* Store PE sessionId in session Table */
603 psessionEntry->peSessionId = sessionId;
604
605 /* Store SME session Id in sessionTable */
606 psessionEntry->smeSessionId = pSmeStartBssReq->sessionId;
607
608 psessionEntry->transactionId = pSmeStartBssReq->transactionId;
609
610 sirCopyMacAddr(psessionEntry->selfMacAddr,pSmeStartBssReq->selfMacAddr);
611
612 /* Copy SSID to session table */
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +0530613 vos_mem_copy( (tANI_U8 *)&psessionEntry->ssId,
Jeff Johnson295189b2012-06-20 16:38:30 -0700614 (tANI_U8 *)&pSmeStartBssReq->ssId,
615 (pSmeStartBssReq->ssId.length + 1));
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +0530616
Jeff Johnson295189b2012-06-20 16:38:30 -0700617 psessionEntry->bssType = pSmeStartBssReq->bssType;
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +0530618
Jeff Johnson295189b2012-06-20 16:38:30 -0700619 psessionEntry->nwType = pSmeStartBssReq->nwType;
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +0530620
Jeff Johnson295189b2012-06-20 16:38:30 -0700621 psessionEntry->beaconParams.beaconInterval = pSmeStartBssReq->beaconInterval;
622
623 /* Store the channel number in session Table */
624 psessionEntry->currentOperChannel = pSmeStartBssReq->channelId;
625
626 /*Store Persona */
627 psessionEntry->pePersona = pSmeStartBssReq->bssPersona;
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -0700628 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,FL("PE PERSONA=%d"),
Jeff Johnson295189b2012-06-20 16:38:30 -0700629 psessionEntry->pePersona);
630
631 /*Update the phymode*/
632 psessionEntry->gLimPhyMode = pSmeStartBssReq->nwType;
633
634 psessionEntry->maxTxPower = cfgGetRegulatoryMaxTransmitPower( pMac,
635 psessionEntry->currentOperChannel );
636 /* Store the dot 11 mode in to the session Table*/
637
638 psessionEntry->dot11mode = pSmeStartBssReq->dot11mode;
Jeff Johnsone7245742012-09-05 17:12:55 -0700639 psessionEntry->htCapability = IS_DOT11_MODE_HT(psessionEntry->dot11mode);
640#ifdef WLAN_FEATURE_11AC
641 psessionEntry->vhtCapability = IS_DOT11_MODE_VHT(psessionEntry->dot11mode);
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -0700642 VOS_TRACE(VOS_MODULE_ID_PE,VOS_TRACE_LEVEL_INFO,
643 FL("*****psessionEntry->vhtCapability = %d"),psessionEntry->vhtCapability);
Jeff Johnsone7245742012-09-05 17:12:55 -0700644#endif
Gopichand Nakkalab2d2c312013-01-04 11:41:02 -0800645
646 psessionEntry->txLdpcIniFeatureEnabled =
647 pSmeStartBssReq->txLdpcIniFeatureEnabled;
648
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +0530649 vos_mem_copy((void*)&psessionEntry->rateSet,
Jeff Johnson295189b2012-06-20 16:38:30 -0700650 (void*)&pSmeStartBssReq->operationalRateSet,
651 sizeof(tSirMacRateSet));
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +0530652 vos_mem_copy((void*)&psessionEntry->extRateSet,
Jeff Johnson295189b2012-06-20 16:38:30 -0700653 (void*)&pSmeStartBssReq->extendedRateSet,
654 sizeof(tSirMacRateSet));
655
656 switch(pSmeStartBssReq->bssType)
657 {
Jeff Johnson295189b2012-06-20 16:38:30 -0700658 case eSIR_INFRA_AP_MODE:
659 psessionEntry->limSystemRole = eLIM_AP_ROLE;
660 psessionEntry->privacy = pSmeStartBssReq->privacy;
661 psessionEntry->fwdWPSPBCProbeReq = pSmeStartBssReq->fwdWPSPBCProbeReq;
662 psessionEntry->authType = pSmeStartBssReq->authType;
663 /* Store the DTIM period */
664 psessionEntry->dtimPeriod = (tANI_U8)pSmeStartBssReq->dtimPeriod;
665 /*Enable/disable UAPSD*/
666 psessionEntry->apUapsdEnable = pSmeStartBssReq->apUapsdEnable;
667 if (psessionEntry->pePersona == VOS_P2P_GO_MODE)
668 {
669 psessionEntry->proxyProbeRspEn = 0;
670 }
671 else
672 {
673 /* To detect PBC overlap in SAP WPS mode, Host handles
674 * Probe Requests.
675 */
676 if(SAP_WPS_DISABLED == pSmeStartBssReq->wps_state)
677 {
678 psessionEntry->proxyProbeRspEn = 1;
679 }
680 else
681 {
682 psessionEntry->proxyProbeRspEn = 0;
683 }
684 }
685 psessionEntry->ssidHidden = pSmeStartBssReq->ssidHidden;
686 psessionEntry->wps_state = pSmeStartBssReq->wps_state;
Madan Mohan Koyyalamudi6db7ad12012-10-29 16:14:41 -0700687 psessionEntry->shortSlotTimeSupported = limGetShortSlotFromPhyMode(pMac, psessionEntry, psessionEntry->gLimPhyMode);
Jeff Johnson295189b2012-06-20 16:38:30 -0700688 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700689 case eSIR_IBSS_MODE:
690 psessionEntry->limSystemRole = eLIM_STA_IN_IBSS_ROLE;
691 break;
692
693 case eSIR_BTAMP_AP_MODE:
694 psessionEntry->limSystemRole = eLIM_BT_AMP_AP_ROLE;
695 break;
696
697 case eSIR_BTAMP_STA_MODE:
698 psessionEntry->limSystemRole = eLIM_BT_AMP_STA_ROLE;
699 break;
700
701 /* There is one more mode called auto mode. which is used no where */
702
703 //FORBUILD -TEMPFIX.. HOW TO use AUTO MODE?????
704
705
706 default:
707 //not used anywhere...used in scan function
708 break;
709 }
710
711 // BT-AMP: Allocate memory for the array of parsed (Re)Assoc request structure
712 if ( (pSmeStartBssReq->bssType == eSIR_BTAMP_AP_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -0700713 || (pSmeStartBssReq->bssType == eSIR_INFRA_AP_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -0700714 )
715 {
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +0530716 psessionEntry->parsedAssocReq = vos_mem_malloc(
717 psessionEntry->dph.dphHashTable.size * sizeof(tpSirAssocReq));
718 if ( NULL == psessionEntry->parsedAssocReq )
Jeff Johnson295189b2012-06-20 16:38:30 -0700719 {
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +0530720 limLog(pMac, LOGW, FL("AllocateMemory() failed"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700721 retCode = eSIR_SME_RESOURCES_UNAVAILABLE;
722 goto free;
723 }
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +0530724 vos_mem_set(psessionEntry->parsedAssocReq,
725 (psessionEntry->dph.dphHashTable.size * sizeof(tpSirAssocReq)),
726 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -0700727 }
728
729 /* Channel Bonding is not addressd yet for BT-AMP Support.. sunit will address channel bonding */
730 if (pSmeStartBssReq->channelId)
731 {
732 channelNumber = pSmeStartBssReq->channelId;
Jeff Johnsone7245742012-09-05 17:12:55 -0700733 psessionEntry->htSupportedChannelWidthSet = (pSmeStartBssReq->cbMode)?1:0; // This is already merged value of peer and self - done by csr in csrGetCBModeFromIes
734 psessionEntry->htRecommendedTxWidthSet = psessionEntry->htSupportedChannelWidthSet;
735 psessionEntry->htSecondaryChannelOffset = pSmeStartBssReq->cbMode;
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -0700736 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
Jeff Johnsone7245742012-09-05 17:12:55 -0700737 FL("cbMode %u"), pSmeStartBssReq->cbMode);
738#ifdef WLAN_FEATURE_11AC
739 if(psessionEntry->vhtCapability)
740 {
741 tANI_U32 centerChan;
742 tANI_U32 chanWidth;
Jeff Johnson295189b2012-06-20 16:38:30 -0700743
Jeff Johnsone7245742012-09-05 17:12:55 -0700744 if (wlan_cfgGetInt(pMac, WNI_CFG_VHT_CHANNEL_WIDTH,
745 &chanWidth) != eSIR_SUCCESS)
Jeff Johnson295189b2012-06-20 16:38:30 -0700746 {
Jeff Johnsone7245742012-09-05 17:12:55 -0700747 limLog(pMac, LOGP,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700748 FL("Unable to retrieve Channel Width from CFG"));
Jeff Johnsone7245742012-09-05 17:12:55 -0700749 }
750
751 if(chanWidth == eHT_CHANNEL_WIDTH_20MHZ || chanWidth == eHT_CHANNEL_WIDTH_40MHZ)
752 {
753 if (cfgSetInt(pMac, WNI_CFG_VHT_CHANNEL_WIDTH, WNI_CFG_VHT_CHANNEL_WIDTH_20_40MHZ)
754 != eSIR_SUCCESS)
Jeff Johnson295189b2012-06-20 16:38:30 -0700755 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700756 limLog(pMac, LOGP, FL("could not set WNI_CFG_CHANNEL_BONDING_MODE at CFG"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700757 retCode = eSIR_LOGP_EXCEPTION;
Jeff Johnsone7245742012-09-05 17:12:55 -0700758 goto free;
Jeff Johnson295189b2012-06-20 16:38:30 -0700759 }
760 }
Jeff Johnsone7245742012-09-05 17:12:55 -0700761 if (chanWidth == eHT_CHANNEL_WIDTH_80MHZ)
762 {
763 if (cfgSetInt(pMac, WNI_CFG_VHT_CHANNEL_WIDTH, WNI_CFG_VHT_CHANNEL_WIDTH_80MHZ)
764 != eSIR_SUCCESS)
765 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700766 limLog(pMac, LOGP, FL("could not set WNI_CFG_CHANNEL_BONDING_MODE at CFG"));
Jeff Johnsone7245742012-09-05 17:12:55 -0700767 retCode = eSIR_LOGP_EXCEPTION;
768 goto free;
769 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700770
Jeff Johnsone7245742012-09-05 17:12:55 -0700771 centerChan = limGetCenterChannel(pMac,channelNumber,pSmeStartBssReq->cbMode,WNI_CFG_VHT_CHANNEL_WIDTH_80MHZ);
772 if(centerChan != eSIR_CFG_INVALID_ID)
773 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700774 limLog(pMac, LOGW, FL("***Center Channel for 80MHZ channel width = %ld"),centerChan);
Madan Mohan Koyyalamudi8b152b82012-10-18 20:56:27 -0700775 psessionEntry->apCenterChan = centerChan;
Jeff Johnsone7245742012-09-05 17:12:55 -0700776 if (cfgSetInt(pMac, WNI_CFG_VHT_CHANNEL_CENTER_FREQ_SEGMENT1, centerChan)
777 != eSIR_SUCCESS)
778 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700779 limLog(pMac, LOGP, FL("could not set WNI_CFG_CHANNEL_BONDING_MODE at CFG"));
Jeff Johnsone7245742012-09-05 17:12:55 -0700780 retCode = eSIR_LOGP_EXCEPTION;
781 goto free;
782 }
783 }
784 }
785
786 /* All the translation is done by now for gVhtChannelWidth from .ini file to
787 * the actual values as defined in spec. So, grabing the spec value which is
788 * updated in .dat file by the above logic */
789 if (wlan_cfgGetInt(pMac, WNI_CFG_VHT_CHANNEL_WIDTH,
790 &chanWidth) != eSIR_SUCCESS)
791 {
792 limLog(pMac, LOGP,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700793 FL("Unable to retrieve Channel Width from CFG"));
Jeff Johnsone7245742012-09-05 17:12:55 -0700794 }
Madan Mohan Koyyalamudi8b152b82012-10-18 20:56:27 -0700795 /*For Sta+p2p-Go concurrency
796 vhtTxChannelWidthSet is used for storing p2p-GO channel width
797 apChanWidth is used for storing the AP channel width that the Sta is going to associate.
798 Initialize the apChanWidth same as p2p-GO channel width this gets over written once the station joins the AP
799 */
Jeff Johnsone7245742012-09-05 17:12:55 -0700800 psessionEntry->vhtTxChannelWidthSet = chanWidth;
Madan Mohan Koyyalamudi8b152b82012-10-18 20:56:27 -0700801 psessionEntry->apChanWidth = chanWidth;
Jeff Johnsone7245742012-09-05 17:12:55 -0700802 }
803 psessionEntry->htSecondaryChannelOffset = limGetHTCBState(pSmeStartBssReq->cbMode);
804#endif
805 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700806 else
807 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700808 PELOGW(limLog(pMac, LOGW, FL("Received invalid eWNI_SME_START_BSS_REQ"));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700809 retCode = eSIR_SME_INVALID_PARAMETERS;
810 goto free;
811 }
812
813 // Delete pre-auth list if any
814 limDeletePreAuthList(pMac);
815
816 // Delete IBSS peer BSSdescription list if any
817 //limIbssDelete(pMac); sep 26 review
818
819
820
821#ifdef FIXME_GEN6 //following code may not be required. limInitMlm is now being invoked during peStart
822 /// Initialize MLM state machine
Jeff Johnson295189b2012-06-20 16:38:30 -0700823 limInitMlm(pMac);
824#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700825
Jeff Johnsone7245742012-09-05 17:12:55 -0700826 psessionEntry->htCapability = IS_DOT11_MODE_HT(pSmeStartBssReq->dot11mode);
Jeff Johnson295189b2012-06-20 16:38:30 -0700827
Jeff Johnson295189b2012-06-20 16:38:30 -0700828 /* keep the RSN/WPA IE information in PE Session Entry
829 * later will be using this to check when received (Re)Assoc req
830 * */
831 limSetRSNieWPAiefromSmeStartBSSReqMessage(pMac,&pSmeStartBssReq->rsnIE,psessionEntry);
832
Jeff Johnson295189b2012-06-20 16:38:30 -0700833
Jeff Johnson295189b2012-06-20 16:38:30 -0700834 //Taken care for only softAP case rest need to be done
835 if (psessionEntry->limSystemRole == eLIM_AP_ROLE){
836 psessionEntry->gLimProtectionControl = pSmeStartBssReq->protEnabled;
837 /*each byte will have the following info
838 *bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0
839 *reserved reserved RIFS Lsig n-GF ht20 11g 11b*/
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +0530840 vos_mem_copy( (void *) &psessionEntry->cfgProtection,
Jeff Johnson295189b2012-06-20 16:38:30 -0700841 (void *) &pSmeStartBssReq->ht_capab,
Kiran Kumar Lokerea4db3dc2013-03-25 18:05:24 -0700842 sizeof( tANI_U16 ));
Jeff Johnson295189b2012-06-20 16:38:30 -0700843 psessionEntry->pAPWPSPBCSession = NULL; // Initialize WPS PBC session link list
844 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700845
846 // Prepare and Issue LIM_MLM_START_REQ to MLM
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +0530847 pMlmStartReq = vos_mem_malloc(sizeof(tLimMlmStartReq));
848 if ( NULL == pMlmStartReq )
Jeff Johnson295189b2012-06-20 16:38:30 -0700849 {
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +0530850 limLog(pMac, LOGP, FL("call to AllocateMemory failed for mlmStartReq"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700851 retCode = eSIR_SME_RESOURCES_UNAVAILABLE;
852 goto free;
853 }
854
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +0530855 vos_mem_set((void *) pMlmStartReq, sizeof(tLimMlmStartReq), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700856
857 /* Copy SSID to the MLM start structure */
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +0530858 vos_mem_copy( (tANI_U8 *) &pMlmStartReq->ssId,
Jeff Johnson295189b2012-06-20 16:38:30 -0700859 (tANI_U8 *) &pSmeStartBssReq->ssId,
860 pSmeStartBssReq->ssId.length + 1);
Jeff Johnson295189b2012-06-20 16:38:30 -0700861 pMlmStartReq->ssidHidden = pSmeStartBssReq->ssidHidden;
862 pMlmStartReq->obssProtEnabled = pSmeStartBssReq->obssProtEnabled;
Jeff Johnson295189b2012-06-20 16:38:30 -0700863
864
865 pMlmStartReq->bssType = psessionEntry->bssType;
866
867 /* Fill PE session Id from the session Table */
868 pMlmStartReq->sessionId = psessionEntry->peSessionId;
869
870 if( (pMlmStartReq->bssType == eSIR_BTAMP_STA_MODE) || (pMlmStartReq->bssType == eSIR_BTAMP_AP_MODE )
Jeff Johnson295189b2012-06-20 16:38:30 -0700871 || (pMlmStartReq->bssType == eSIR_INFRA_AP_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -0700872 )
873 {
874 //len = sizeof(tSirMacAddr);
875 //retStatus = wlan_cfgGetStr(pMac, WNI_CFG_STA_ID, (tANI_U8 *) pMlmStartReq->bssId, &len);
876 //if (retStatus != eSIR_SUCCESS)
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700877 //limLog(pMac, LOGP, FL("could not retrive BSSID, retStatus=%d"), retStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -0700878
879 /* Copy the BSSId from sessionTable to mlmStartReq struct */
880 sirCopyMacAddr(pMlmStartReq->bssId,psessionEntry->bssId);
881 }
882
883 else // ibss mode
884 {
885 pMac->lim.gLimIbssCoalescingHappened = false;
886
887 if((retStatus = wlan_cfgGetInt(pMac, WNI_CFG_IBSS_AUTO_BSSID, &autoGenBssId)) != eSIR_SUCCESS)
888 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700889 limLog(pMac, LOGP, FL("Could not retrieve Auto Gen BSSID, retStatus=%d"), retStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -0700890 retCode = eSIR_LOGP_EXCEPTION;
891 goto free;
892 }
893
894 if(!autoGenBssId)
895 {
896 // We're not auto generating BSSID. Instead, get it from session entry
897 sirCopyMacAddr(pMlmStartReq->bssId,psessionEntry->bssId);
898
899 if(pMlmStartReq->bssId[0] & 0x01)
900 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700901 PELOGE(limLog(pMac, LOGE, FL("Request to start IBSS with group BSSID\n Autogenerating the BSSID"));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700902 autoGenBssId = TRUE;
903 }
904 }
905
906 if( autoGenBssId )
907 { //if BSSID is not any uc id. then use locally generated BSSID.
908 //Autogenerate the BSSID
909 limGetRandomBssid( pMac, pMlmStartReq->bssId);
910 pMlmStartReq->bssId[0]= 0x02;
911
912 /* Copy randomly generated BSSID to the session Table */
913 sirCopyMacAddr(psessionEntry->bssId,pMlmStartReq->bssId);
914 }
915 }
916 /* store the channel num in mlmstart req structure */
917 pMlmStartReq->channelNumber = psessionEntry->currentOperChannel;
918 pMlmStartReq->cbMode = pSmeStartBssReq->cbMode;
919 pMlmStartReq->beaconPeriod = psessionEntry->beaconParams.beaconInterval;
920
Jeff Johnson295189b2012-06-20 16:38:30 -0700921 if(psessionEntry->limSystemRole == eLIM_AP_ROLE ){
922 pMlmStartReq->dtimPeriod = psessionEntry->dtimPeriod;
923 pMlmStartReq->wps_state = psessionEntry->wps_state;
924
925 }else
Jeff Johnson295189b2012-06-20 16:38:30 -0700926 {
927 if (wlan_cfgGetInt(pMac, WNI_CFG_DTIM_PERIOD, &val) != eSIR_SUCCESS)
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700928 limLog(pMac, LOGP, FL("could not retrieve DTIM Period"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700929 pMlmStartReq->dtimPeriod = (tANI_U8)val;
930 }
931
932 if (wlan_cfgGetInt(pMac, WNI_CFG_CFP_PERIOD, &val) != eSIR_SUCCESS)
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700933 limLog(pMac, LOGP, FL("could not retrieve Beacon interval"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700934 pMlmStartReq->cfParamSet.cfpPeriod = (tANI_U8)val;
935
936 if (wlan_cfgGetInt(pMac, WNI_CFG_CFP_MAX_DURATION, &val) != eSIR_SUCCESS)
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700937 limLog(pMac, LOGP, FL("could not retrieve CFPMaxDuration"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700938 pMlmStartReq->cfParamSet.cfpMaxDuration = (tANI_U16) val;
939
940 //this may not be needed anymore now, as rateSet is now included in the session entry and MLM has session context.
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +0530941 vos_mem_copy((void*)&pMlmStartReq->rateSet, (void*)&psessionEntry->rateSet,
Jeff Johnson295189b2012-06-20 16:38:30 -0700942 sizeof(tSirMacRateSet));
943
Jeff Johnson295189b2012-06-20 16:38:30 -0700944 // Now populate the 11n related parameters
945 pMlmStartReq->nwType = psessionEntry->nwType;
Jeff Johnsone7245742012-09-05 17:12:55 -0700946 pMlmStartReq->htCapable = psessionEntry->htCapability;
Jeff Johnson295189b2012-06-20 16:38:30 -0700947 //
948 // FIXME_GEN4 - Determine the appropriate defaults...
949 //
950 pMlmStartReq->htOperMode = pMac->lim.gHTOperMode;
951 pMlmStartReq->dualCTSProtection = pMac->lim.gHTDualCTSProtection; // Unused
Jeff Johnsone7245742012-09-05 17:12:55 -0700952 pMlmStartReq->txChannelWidthSet = psessionEntry->htRecommendedTxWidthSet;
Jeff Johnson295189b2012-06-20 16:38:30 -0700953
954 /* sep26 review */
955 psessionEntry->limRFBand = limGetRFBand(channelNumber);
956
957 // Initialize 11h Enable Flag
958 psessionEntry->lim11hEnable = 0;
959 if((pMlmStartReq->bssType != eSIR_IBSS_MODE) &&
960 (SIR_BAND_5_GHZ == psessionEntry->limRFBand) )
961 {
962 if (wlan_cfgGetInt(pMac, WNI_CFG_11H_ENABLED, &val) != eSIR_SUCCESS)
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700963 limLog(pMac, LOGP, FL("Fail to get WNI_CFG_11H_ENABLED "));
Jeff Johnson295189b2012-06-20 16:38:30 -0700964 psessionEntry->lim11hEnable = val;
965 }
966
967 if (!psessionEntry->lim11hEnable)
968 {
969 if (cfgSetInt(pMac, WNI_CFG_LOCAL_POWER_CONSTRAINT, 0) != eSIR_SUCCESS)
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700970 limLog(pMac, LOGP, FL("Fail to get WNI_CFG_11H_ENABLED "));
Jeff Johnson295189b2012-06-20 16:38:30 -0700971 }
972
Jeff Johnson295189b2012-06-20 16:38:30 -0700973 psessionEntry ->limPrevSmeState = psessionEntry->limSmeState;
974 psessionEntry ->limSmeState = eLIM_SME_WT_START_BSS_STATE;
Jeff Johnsone7245742012-09-05 17:12:55 -0700975 MTRACE(macTrace(pMac, TRACE_CODE_SME_STATE, psessionEntry->peSessionId, psessionEntry ->limSmeState));
Jeff Johnson295189b2012-06-20 16:38:30 -0700976
977 limPostMlmMessage(pMac, LIM_MLM_START_REQ, (tANI_U32 *) pMlmStartReq);
978 return;
979 }
980 else
981 {
982
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700983 limLog(pMac, LOGE, FL("Received unexpected START_BSS_REQ, in state %X"),pMac->lim.gLimSmeState);
Jeff Johnson295189b2012-06-20 16:38:30 -0700984 retCode = eSIR_SME_BSS_ALREADY_STARTED_OR_JOINED;
985 goto end;
986 } // if (pMac->lim.gLimSmeState == eLIM_SME_OFFLINE_STATE)
987
988free:
Jeff Johnsonace91102013-04-05 08:03:18 -0700989 if ((psessionEntry != NULL) &&
990 (psessionEntry->pLimStartBssReq == pSmeStartBssReq))
991 {
992 psessionEntry->pLimStartBssReq = NULL;
993 }
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +0530994 vos_mem_free( pSmeStartBssReq);
995 vos_mem_free( pMlmStartReq);
Jeff Johnson295189b2012-06-20 16:38:30 -0700996
997end:
998
999 /* This routine should return the sme sessionId and SME transaction Id */
1000 limGetSessionInfo(pMac,(tANI_U8*)pMsgBuf,&smesessionId,&smetransactionId);
1001
1002 if(NULL != psessionEntry)
1003 {
1004 peDeleteSession(pMac,psessionEntry);
1005 psessionEntry = NULL;
1006 }
1007 limSendSmeStartBssRsp(pMac, eWNI_SME_START_BSS_RSP, retCode,psessionEntry,smesessionId,smetransactionId);
1008} /*** end __limHandleSmeStartBssRequest() ***/
1009
1010
1011/**--------------------------------------------------------------
1012\fn __limProcessSmeStartBssReq
1013
1014\brief Wrapper for the function __limHandleSmeStartBssRequest
1015 This message will be defered until softmac come out of
1016 scan mode or if we have detected radar on the current
1017 operating channel.
1018\param pMac
1019\param pMsg
1020
1021\return TRUE - If we consumed the buffer
1022 FALSE - If have defered the message.
1023 ---------------------------------------------------------------*/
1024static tANI_BOOLEAN
1025__limProcessSmeStartBssReq(tpAniSirGlobal pMac, tpSirMsgQ pMsg)
1026{
1027 if (__limIsDeferedMsgForLearn(pMac, pMsg) ||
1028 __limIsDeferedMsgForRadar(pMac, pMsg))
1029 {
1030 /**
1031 * If message defered, buffer is not consumed yet.
1032 * So return false
1033 */
1034 return eANI_BOOLEAN_FALSE;
1035 }
1036
1037 __limHandleSmeStartBssRequest(pMac, (tANI_U32 *) pMsg->bodyptr);
1038 return eANI_BOOLEAN_TRUE;
1039}
1040
1041
1042/**
1043 * limGetRandomBssid()
1044 *
1045 * FUNCTION:This function is called to process generate the random number for bssid
1046 * This function is called to process SME_SCAN_REQ message
1047 * from HDD or upper layer application.
1048 *
1049 * LOGIC:
1050 *
1051 * ASSUMPTIONS:
1052 *
1053 * NOTE:
1054 * 1. geneartes the unique random number for bssid in ibss
1055 *
1056 * @param pMac Pointer to Global MAC structure
1057 * @param *data Pointer to bssid buffer
1058 * @return None
1059 */
1060void limGetRandomBssid(tpAniSirGlobal pMac, tANI_U8 *data)
1061{
1062 tANI_U32 random[2] ;
1063 random[0] = tx_time_get();
1064 random[0] |= (random[0] << 15) ;
1065 random[1] = random[0] >> 1;
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301066 vos_mem_copy( data, (tANI_U8*)random, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07001067}
1068
Ganesh Kondabattinif0fa07c2013-06-11 17:47:49 +05301069static eHalStatus limSendHalStartScanOffloadReq(tpAniSirGlobal pMac,
1070 tpSirSmeScanReq pScanReq)
1071{
1072 tSirScanOffloadReq *pScanOffloadReq;
1073 tANI_U8 *p;
1074 tSirMsgQ msg;
Ganesh Kondabattinif0fa07c2013-06-11 17:47:49 +05301075 tANI_U16 i, len;
1076 tSirRetStatus rc = eSIR_SUCCESS;
1077
1078 /* The tSirScanOffloadReq will reserve the space for first channel,
1079 so allocate the memory for (numChannels - 1) and uIEFieldLen */
1080 len = sizeof(tSirScanOffloadReq) + (pScanReq->channelList.numChannels - 1) +
1081 pScanReq->uIEFieldLen;
1082
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301083 pScanOffloadReq = vos_mem_malloc(len);
1084 if ( NULL == pScanOffloadReq )
Ganesh Kondabattinif0fa07c2013-06-11 17:47:49 +05301085 {
1086 limLog(pMac, LOGE,
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301087 FL("AllocateMemory failed for pScanOffloadReq"));
Ganesh Kondabattinif0fa07c2013-06-11 17:47:49 +05301088 return eHAL_STATUS_FAILURE;
1089 }
1090
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301091 vos_mem_set( (tANI_U8 *) pScanOffloadReq, len, 0);
Ganesh Kondabattinif0fa07c2013-06-11 17:47:49 +05301092
1093 msg.type = WDA_START_SCAN_OFFLOAD_REQ;
1094 msg.bodyptr = pScanOffloadReq;
1095 msg.bodyval = 0;
1096
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301097 vos_mem_copy((tANI_U8 *) pScanOffloadReq->bssId,
Ganesh Kondabattinif0fa07c2013-06-11 17:47:49 +05301098 (tANI_U8*) pScanReq->bssId,
1099 sizeof(tSirMacAddr));
1100
1101 if (pScanReq->numSsid > SIR_SCAN_MAX_NUM_SSID)
1102 {
1103 limLog(pMac, LOGE,
1104 FL("Invalid value (%d) for numSsid"), SIR_SCAN_MAX_NUM_SSID);
Kiran Kumar Lokerefdf42412013-07-17 17:40:58 -07001105 palFreeMemory(pMac->hHdd, (void *)pScanOffloadReq);
Ganesh Kondabattinif0fa07c2013-06-11 17:47:49 +05301106 return eHAL_STATUS_FAILURE;
1107 }
1108
1109 pScanOffloadReq->numSsid = pScanReq->numSsid;
1110 for (i = 0; i < pScanOffloadReq->numSsid; i++)
1111 {
1112 pScanOffloadReq->ssId[i].length = pScanReq->ssId[i].length;
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301113 vos_mem_copy((tANI_U8 *) pScanOffloadReq->ssId[i].ssId,
Ganesh Kondabattinif0fa07c2013-06-11 17:47:49 +05301114 (tANI_U8 *) pScanReq->ssId[i].ssId,
1115 pScanOffloadReq->ssId[i].length);
1116 }
1117
1118 pScanOffloadReq->hiddenSsid = pScanReq->hiddenSsid;
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301119 vos_mem_copy((tANI_U8 *) pScanOffloadReq->selfMacAddr,
Ganesh Kondabattinif0fa07c2013-06-11 17:47:49 +05301120 (tANI_U8 *) pScanReq->selfMacAddr,
1121 sizeof(tSirMacAddr));
1122 pScanOffloadReq->bssType = pScanReq->bssType;
1123 pScanOffloadReq->dot11mode = pScanReq->dot11mode;
1124 pScanOffloadReq->scanType = pScanReq->scanType;
1125 pScanOffloadReq->minChannelTime = pScanReq->minChannelTime;
1126 pScanOffloadReq->maxChannelTime = pScanReq->maxChannelTime;
1127 pScanOffloadReq->p2pSearch = pScanReq->p2pSearch;
1128 pScanOffloadReq->sessionId = pScanReq->sessionId;
1129 pScanOffloadReq->channelList.numChannels =
1130 pScanReq->channelList.numChannels;
1131 p = &(pScanOffloadReq->channelList.channelNumber[0]);
1132 for (i = 0; i < pScanOffloadReq->channelList.numChannels; i++)
1133 p[i] = pScanReq->channelList.channelNumber[i];
1134
1135 pScanOffloadReq->uIEFieldLen = pScanReq->uIEFieldLen;
1136 pScanOffloadReq->uIEFieldOffset = len - pScanOffloadReq->uIEFieldLen;
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301137 vos_mem_copy((tANI_U8 *) p + i,
Ganesh Kondabattinif0fa07c2013-06-11 17:47:49 +05301138 (tANI_U8 *) pScanReq + pScanReq->uIEFieldOffset,
1139 pScanOffloadReq->uIEFieldLen);
1140
1141 rc = wdaPostCtrlMsg(pMac, &msg);
1142 if (rc != eSIR_SUCCESS)
1143 {
1144 limLog(pMac, LOGE, FL("wdaPostCtrlMsg() return failure"),
1145 pMac);
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301146 vos_mem_free(pScanOffloadReq);
Ganesh Kondabattinif0fa07c2013-06-11 17:47:49 +05301147 return eHAL_STATUS_FAILURE;
1148 }
1149
1150 return eHAL_STATUS_SUCCESS;
1151}
Jeff Johnson295189b2012-06-20 16:38:30 -07001152
1153/**
1154 * __limProcessSmeScanReq()
1155 *
1156 *FUNCTION:
1157 * This function is called to process SME_SCAN_REQ message
1158 * from HDD or upper layer application.
1159 *
1160 *LOGIC:
1161 *
1162 *ASSUMPTIONS:
1163 *
1164 *NOTE:
1165 * 1. Periodic scanning should be requesting to return unique
1166 * scan results.
1167 *
1168 * @param pMac Pointer to Global MAC structure
1169 * @param *pMsgBuf A pointer to the SME message buffer
1170 * @return None
1171 */
1172
Viral Modid440e682013-03-06 02:25:31 -08001173static void
Jeff Johnson295189b2012-06-20 16:38:30 -07001174__limProcessSmeScanReq(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
1175{
1176 tANI_U32 len;
1177 tLimMlmScanReq *pMlmScanReq;
1178 tpSirSmeScanReq pScanReq;
1179 tANI_U8 i = 0;
1180
1181#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM //FEATURE_WLAN_DIAG_SUPPORT
1182 limDiagEventReport(pMac, WLAN_PE_DIAG_SCAN_REQ_EVENT, NULL, 0, 0);
1183#endif //FEATURE_WLAN_DIAG_SUPPORT
1184
1185 pScanReq = (tpSirSmeScanReq) pMsgBuf;
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001186 PELOG1(limLog(pMac, LOG1, FL("SME SCAN REQ numChan %d min %d max %d IELen %d first %d fresh %d unique %d type %d mode %d rsp %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07001187 pScanReq->channelList.numChannels,
1188 pScanReq->minChannelTime,
1189 pScanReq->maxChannelTime,
1190 pScanReq->uIEFieldLen,
1191 pScanReq->returnAfterFirstMatch,
1192 pScanReq->returnFreshResults,
1193 pScanReq->returnUniqueResults,
Madan Mohan Koyyalamudi70bb4cb2012-10-18 19:31:25 -07001194 pScanReq->scanType,
1195 pScanReq->backgroundScanMode,
1196 pMac->lim.gLimRspReqd ? 1 : 0);)
Viral Modid86bde22012-12-10 13:09:21 -08001197
1198 /* Since scan req always requires a response, we will overwrite response required here.
1199 * This is added esp to take care of the condition where in p2p go case, we hold the scan req and
1200 * insert single NOA. We send the held scan request to FW later on getting start NOA ind from FW so
1201 * we lose state of the gLimRspReqd flag for the scan req if any other request comes by then.
1202 * e.g. While unit testing, we found when insert single NOA is done, we see a get stats request which turns the flag
1203 * gLimRspReqd to FALSE; now when we actually start the saved scan req for init scan after getting
1204 * NOA started, the gLimRspReqd being a global flag is showing FALSE instead of TRUE value for
1205 * this saved scan req. Since all scan reqs coming to lim require a response, there is no harm in setting
1206 * the global flag gLimRspReqd to TRUE here.
1207 */
1208 pMac->lim.gLimRspReqd = TRUE;
1209
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301210 /*copy the Self MAC address from SmeReq to the globalplace, used for sending probe req*/
Jeff Johnson295189b2012-06-20 16:38:30 -07001211 sirCopyMacAddr(pMac->lim.gSelfMacAddr, pScanReq->selfMacAddr);
1212
1213 /* This routine should return the sme sessionId and SME transaction Id */
1214
1215 if (!limIsSmeScanReqValid(pMac, pScanReq))
1216 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001217 PELOGW(limLog(pMac, LOGW, FL("Received SME_SCAN_REQ with invalid parameters"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001218
1219 if (pMac->lim.gLimRspReqd)
1220 {
1221 pMac->lim.gLimRspReqd = false;
1222
1223 limSendSmeScanRsp(pMac, sizeof(tSirSmeScanRsp), eSIR_SME_INVALID_PARAMETERS, pScanReq->sessionId, pScanReq->transactionId);
1224
1225 } // if (pMac->lim.gLimRspReqd)
1226
1227 return;
1228 }
1229
1230 //if scan is disabled then return as invalid scan request.
1231 //if scan in power save is disabled, and system is in power save mode, then ignore scan request.
1232 if( (pMac->lim.fScanDisabled) || (!pMac->lim.gScanInPowersave && !limIsSystemInActiveState(pMac)) )
1233 {
Leela V Kiran Kumar Reddy Chirala6a458752013-02-16 15:41:27 -08001234 limSendSmeScanRsp(pMac, offsetof(tSirSmeScanRsp,bssDescription[0]), eSIR_SME_INVALID_PARAMETERS, pScanReq->sessionId, pScanReq->transactionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07001235 return;
1236 }
1237
1238
1239 /**
1240 * If scan request is received in idle, joinFailed
1241 * states or in link established state (in STA role)
1242 * or in normal state (in STA-in-IBSS/AP role) with
1243 * 'return fresh scan results' request from HDD or
1244 * it is periodic background scanning request,
1245 * trigger fresh scan request to MLM
1246 */
1247 if (__limFreshScanReqd(pMac, pScanReq->returnFreshResults))
1248 {
Ganesh Kondabattinif0fa07c2013-06-11 17:47:49 +05301249 if (pScanReq->returnFreshResults & SIR_BG_SCAN_PURGE_RESUTLS)
1250 {
1251 // Discard previously cached scan results
1252 limReInitScanResults(pMac);
1253 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001254
Ganesh Kondabattinif0fa07c2013-06-11 17:47:49 +05301255 pMac->lim.gLim24Band11dScanDone = 0;
1256 pMac->lim.gLim50Band11dScanDone = 0;
1257 pMac->lim.gLimReturnAfterFirstMatch =
1258 pScanReq->returnAfterFirstMatch;
1259 pMac->lim.gLimBackgroundScanMode =
1260 pScanReq->backgroundScanMode;
Jeff Johnson295189b2012-06-20 16:38:30 -07001261
Ganesh Kondabattinif0fa07c2013-06-11 17:47:49 +05301262 pMac->lim.gLimReturnUniqueResults =
1263 ((pScanReq->returnUniqueResults) > 0 ? true : false);
1264 /* De-activate Heartbeat timers for connected sessions while
1265 * scan is in progress if the system is in Active mode *
1266 * AND it is not a ROAMING ("background") scan */
1267 if(((ePMM_STATE_BMPS_WAKEUP == pMac->pmm.gPmmState) ||
1268 (ePMM_STATE_READY == pMac->pmm.gPmmState)) &&
1269 (pScanReq->backgroundScanMode != eSIR_ROAMING_SCAN ) &&
1270 (!IS_ACTIVEMODE_OFFLOAD_FEATURE_ENABLE))
1271 {
Jeff Johnson295189b2012-06-20 16:38:30 -07001272 for(i=0;i<pMac->lim.maxBssId;i++)
1273 {
Ganesh Kondabattinif0fa07c2013-06-11 17:47:49 +05301274 if((peFindSessionBySessionId(pMac,i) != NULL) &&
1275 (pMac->lim.gpSession[i].valid == TRUE) &&
1276 (eLIM_MLM_LINK_ESTABLISHED_STATE == pMac->lim.gpSession[i].limMlmState))
1277 {
1278 limHeartBeatDeactivateAndChangeTimer(pMac, peFindSessionBySessionId(pMac,i));
1279 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001280 }
Ganesh Kondabattinif0fa07c2013-06-11 17:47:49 +05301281 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001282
Ganesh Kondabattinif0fa07c2013-06-11 17:47:49 +05301283 if (pMac->fScanOffload)
1284 {
1285 if (eHAL_STATUS_SUCCESS !=
1286 limSendHalStartScanOffloadReq(pMac, pScanReq))
1287 {
1288 limSendSmeScanRsp(pMac,
1289 offsetof(tSirSmeScanRsp, bssDescription[0]),
1290 eSIR_SME_INVALID_PARAMETERS,
1291 pScanReq->sessionId,
1292 pScanReq->transactionId);
1293 return;
1294 }
1295 }
1296 else
1297 {
1298
1299 /*Change Global SME state */
1300 /* Store the previous SME state */
1301 pMac->lim.gLimPrevSmeState = pMac->lim.gLimSmeState;
1302 pMac->lim.gLimSmeState = eLIM_SME_WT_SCAN_STATE;
1303 MTRACE(macTrace(pMac, TRACE_CODE_SME_STATE, pScanReq->sessionId, pMac->lim.gLimSmeState));
1304
1305 if (pScanReq->channelList.numChannels == 0)
1306 {
1307 tANI_U32 cfg_len;
1308 // Scan all channels
1309 len = sizeof(tLimMlmScanReq) +
Jeff Johnson295189b2012-06-20 16:38:30 -07001310 (sizeof( pScanReq->channelList.channelNumber ) * (WNI_CFG_VALID_CHANNEL_LIST_LEN - 1)) +
1311 pScanReq->uIEFieldLen;
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301312 pMlmScanReq = vos_mem_malloc(len);
1313 if ( NULL == pMlmScanReq )
Ganesh Kondabattinif0fa07c2013-06-11 17:47:49 +05301314 {
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301315 // Log error
1316 limLog(pMac, LOGP,
1317 FL("call to AllocateMemory failed for mlmScanReq (%d)"), len);
Jeff Johnson295189b2012-06-20 16:38:30 -07001318
Ganesh Kondabattinif0fa07c2013-06-11 17:47:49 +05301319 return;
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301320 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001321
Ganesh Kondabattinif0fa07c2013-06-11 17:47:49 +05301322 // Initialize this buffer
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301323 vos_mem_set( (tANI_U8 *) pMlmScanReq, len, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07001324
Ganesh Kondabattinif0fa07c2013-06-11 17:47:49 +05301325 cfg_len = WNI_CFG_VALID_CHANNEL_LIST_LEN;
1326 if (wlan_cfgGetStr(pMac, WNI_CFG_VALID_CHANNEL_LIST,
Jeff Johnson295189b2012-06-20 16:38:30 -07001327 pMlmScanReq->channelList.channelNumber,
1328 &cfg_len) != eSIR_SUCCESS)
Ganesh Kondabattinif0fa07c2013-06-11 17:47:49 +05301329 {
1330 /**
1331 * Could not get Valid channel list from CFG.
1332 * Log error.
1333 */
1334 limLog(pMac, LOGP,
1335 FL("could not retrieve Valid channel list"));
1336 }
1337 pMlmScanReq->channelList.numChannels = (tANI_U8) cfg_len;
1338 }
1339 else
1340 {
1341 len = sizeof( tLimMlmScanReq ) - sizeof( pScanReq->channelList.channelNumber ) +
1342 (sizeof( pScanReq->channelList.channelNumber ) * pScanReq->channelList.numChannels ) +
1343 pScanReq->uIEFieldLen;
Jeff Johnson295189b2012-06-20 16:38:30 -07001344
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301345 pMlmScanReq = vos_mem_malloc(len);
1346 if ( NULL == pMlmScanReq )
Ganesh Kondabattinif0fa07c2013-06-11 17:47:49 +05301347 {
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301348 // Log error
1349 limLog(pMac, LOGP,
1350 FL("call to AllocateMemory failed for mlmScanReq(%d)"), len);
Jeff Johnson295189b2012-06-20 16:38:30 -07001351
Ganesh Kondabattinif0fa07c2013-06-11 17:47:49 +05301352 return;
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301353 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001354
Ganesh Kondabattinif0fa07c2013-06-11 17:47:49 +05301355 // Initialize this buffer
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301356 vos_mem_set( (tANI_U8 *) pMlmScanReq, len, 0);
Ganesh Kondabattinif0fa07c2013-06-11 17:47:49 +05301357 pMlmScanReq->channelList.numChannels =
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301358 pScanReq->channelList.numChannels;
Jeff Johnson295189b2012-06-20 16:38:30 -07001359
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301360 vos_mem_copy( pMlmScanReq->channelList.channelNumber,
1361 pScanReq->channelList.channelNumber,
1362 pScanReq->channelList.numChannels);
1363 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001364
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301365 pMlmScanReq->uIEFieldLen = pScanReq->uIEFieldLen;
1366 pMlmScanReq->uIEFieldOffset = len - pScanReq->uIEFieldLen;
1367 if(pScanReq->uIEFieldLen)
1368 {
1369 vos_mem_copy( (tANI_U8 *)pMlmScanReq+ pMlmScanReq->uIEFieldOffset,
1370 (tANI_U8 *)pScanReq+(pScanReq->uIEFieldOffset),
1371 pScanReq->uIEFieldLen);
1372 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001373
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301374 pMlmScanReq->bssType = pScanReq->bssType;
1375 vos_mem_copy( pMlmScanReq->bssId,
1376 pScanReq->bssId,
1377 sizeof(tSirMacAddr));
1378 pMlmScanReq->numSsid = pScanReq->numSsid;
Jeff Johnson295189b2012-06-20 16:38:30 -07001379
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301380 i = 0;
1381 while (i < pMlmScanReq->numSsid)
1382 {
1383 vos_mem_copy( (tANI_U8 *) &pMlmScanReq->ssId[i],
Jeff Johnson295189b2012-06-20 16:38:30 -07001384 (tANI_U8 *) &pScanReq->ssId[i],
1385 pScanReq->ssId[i].length + 1);
1386
Ganesh Kondabattinif0fa07c2013-06-11 17:47:49 +05301387 i++;
1388 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001389
Jeff Johnson295189b2012-06-20 16:38:30 -07001390
Ganesh Kondabattinif0fa07c2013-06-11 17:47:49 +05301391 pMlmScanReq->scanType = pScanReq->scanType;
1392 pMlmScanReq->backgroundScanMode = pScanReq->backgroundScanMode;
1393 pMlmScanReq->minChannelTime = pScanReq->minChannelTime;
1394 pMlmScanReq->maxChannelTime = pScanReq->maxChannelTime;
1395 pMlmScanReq->minChannelTimeBtc = pScanReq->minChannelTimeBtc;
1396 pMlmScanReq->maxChannelTimeBtc = pScanReq->maxChannelTimeBtc;
1397 pMlmScanReq->dot11mode = pScanReq->dot11mode;
1398 pMlmScanReq->p2pSearch = pScanReq->p2pSearch;
Jeff Johnson295189b2012-06-20 16:38:30 -07001399
Ganesh Kondabattinif0fa07c2013-06-11 17:47:49 +05301400 //Store the smeSessionID and transaction ID for later use.
1401 pMac->lim.gSmeSessionId = pScanReq->sessionId;
1402 pMac->lim.gTransactionId = pScanReq->transactionId;
Jeff Johnson295189b2012-06-20 16:38:30 -07001403
Ganesh Kondabattinif0fa07c2013-06-11 17:47:49 +05301404 // Issue LIM_MLM_SCAN_REQ to MLM
1405 limPostMlmMessage(pMac, LIM_MLM_SCAN_REQ, (tANI_U32 *) pMlmScanReq);
1406 }
1407 } // if ((pMac->lim.gLimSmeState == eLIM_SME_IDLE_STATE) || ...
Jeff Johnson295189b2012-06-20 16:38:30 -07001408
1409 else
1410 {
1411 /// In all other cases return 'cached' scan results
1412 if ((pMac->lim.gLimRspReqd) || pMac->lim.gLimReportBackgroundScanResults)
1413 {
1414 tANI_U16 scanRspLen = sizeof(tSirSmeScanRsp);
1415
1416 pMac->lim.gLimRspReqd = false;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07001417#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
1418 if (pScanReq->returnFreshResults & SIR_BG_SCAN_RETURN_LFR_CACHED_RESULTS)
Jeff Johnson295189b2012-06-20 16:38:30 -07001419 {
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07001420 pMac->lim.gLimSmeLfrScanResultLength = pMac->lim.gLimMlmLfrScanResultLength;
1421 if (pMac->lim.gLimSmeLfrScanResultLength == 0)
1422 {
1423 limSendSmeLfrScanRsp(pMac, scanRspLen,
1424 eSIR_SME_SUCCESS,
1425 pScanReq->sessionId,
1426 pScanReq->transactionId);
1427 }
1428 else
1429 {
1430 scanRspLen = sizeof(tSirSmeScanRsp) +
1431 pMac->lim.gLimSmeLfrScanResultLength -
1432 sizeof(tSirBssDescription);
1433 limSendSmeLfrScanRsp(pMac, scanRspLen, eSIR_SME_SUCCESS,
1434 pScanReq->sessionId, pScanReq->transactionId);
1435 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001436 }
1437 else
1438 {
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07001439#endif
1440 if (pMac->lim.gLimSmeScanResultLength == 0)
1441 {
1442 limSendSmeScanRsp(pMac, scanRspLen, eSIR_SME_SUCCESS,
1443 pScanReq->sessionId, pScanReq->transactionId);
1444 }
1445 else
1446 {
1447 scanRspLen = sizeof(tSirSmeScanRsp) +
1448 pMac->lim.gLimSmeScanResultLength -
1449 sizeof(tSirBssDescription);
1450 limSendSmeScanRsp(pMac, scanRspLen, eSIR_SME_SUCCESS,
1451 pScanReq->sessionId, pScanReq->transactionId);
1452 }
1453#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
Jeff Johnson295189b2012-06-20 16:38:30 -07001454 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07001455#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001456
1457 if (pScanReq->returnFreshResults & SIR_BG_SCAN_PURGE_RESUTLS)
1458 {
1459 // Discard previously cached scan results
1460 limReInitScanResults(pMac);
1461 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07001462#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
1463 if (pScanReq->returnFreshResults & SIR_BG_SCAN_PURGE_LFR_RESULTS)
1464 {
1465 // Discard previously cached scan results
1466 limReInitLfrScanResults(pMac);
1467 }
1468#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001469
1470 } // if (pMac->lim.gLimRspReqd)
1471 } // else ((pMac->lim.gLimSmeState == eLIM_SME_IDLE_STATE) || ...
1472
Jeff Johnson295189b2012-06-20 16:38:30 -07001473#ifdef BACKGROUND_SCAN_ENABLED
1474 // start background scans if needed
1475 // There is a bug opened against softmac. Need to enable when the bug is fixed.
1476 __limBackgroundScanInitiate(pMac);
1477#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001478
1479} /*** end __limProcessSmeScanReq() ***/
1480
Jeff Johnsone7245742012-09-05 17:12:55 -07001481#ifdef FEATURE_OEM_DATA_SUPPORT
Jeff Johnson295189b2012-06-20 16:38:30 -07001482
Jeff Johnsone7245742012-09-05 17:12:55 -07001483static void __limProcessSmeOemDataReq(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
1484{
1485 tpSirOemDataReq pOemDataReq;
1486 tLimMlmOemDataReq* pMlmOemDataReq;
1487
1488 pOemDataReq = (tpSirOemDataReq) pMsgBuf;
1489
1490 //post the lim mlm message now
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301491 pMlmOemDataReq = vos_mem_malloc(sizeof(tLimMlmOemDataReq));
1492 if ( NULL == pMlmOemDataReq )
Jeff Johnsone7245742012-09-05 17:12:55 -07001493 {
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301494 limLog(pMac, LOGP, FL("AllocateMemory failed for mlmOemDataReq"));
Jeff Johnsone7245742012-09-05 17:12:55 -07001495 return;
1496 }
1497
1498 //Initialize this buffer
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301499 vos_mem_set( pMlmOemDataReq, (sizeof(tLimMlmOemDataReq)), 0);
Jeff Johnsone7245742012-09-05 17:12:55 -07001500
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301501 vos_mem_copy( pMlmOemDataReq->selfMacAddr, pOemDataReq->selfMacAddr,
1502 sizeof(tSirMacAddr));
1503 vos_mem_copy( pMlmOemDataReq->oemDataReq, pOemDataReq->oemDataReq,
1504 OEM_DATA_REQ_SIZE);
Jeff Johnsone7245742012-09-05 17:12:55 -07001505
1506 //Issue LIM_MLM_OEM_DATA_REQ to MLM
1507 limPostMlmMessage(pMac, LIM_MLM_OEM_DATA_REQ, (tANI_U32*)pMlmOemDataReq);
1508
1509 return;
1510
1511} /*** end __limProcessSmeOemDataReq() ***/
1512
1513#endif //FEATURE_OEM_DATA_SUPPORT
Jeff Johnson295189b2012-06-20 16:38:30 -07001514
Gopichand Nakkalac178ac82013-05-30 19:53:39 +05301515/**
1516 * __limProcessClearDfsChannelList()
1517 *
1518 *FUNCTION:
1519 *Clear DFS channel list when country is changed/aquired.
1520.*This message is sent from SME.
1521 *
1522 *LOGIC:
1523 *
1524 *ASSUMPTIONS:
1525 *
1526 *NOTE:
1527 *
1528 * @param pMac Pointer to Global MAC structure
1529 * @param *pMsgBuf A pointer to the SME message buffer
1530 * @return None
1531 */
1532static void __limProcessClearDfsChannelList(tpAniSirGlobal pMac,
1533 tpSirMsgQ pMsg)
1534{
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301535 vos_mem_set( &pMac->lim.dfschannelList,
1536 sizeof(tSirDFSChannelList), 0);
Gopichand Nakkalac178ac82013-05-30 19:53:39 +05301537}
Jeff Johnson295189b2012-06-20 16:38:30 -07001538
1539/**
1540 * __limProcessSmeJoinReq()
1541 *
1542 *FUNCTION:
1543 * This function is called to process SME_JOIN_REQ message
1544 * from HDD or upper layer application.
1545 *
1546 *LOGIC:
1547 *
1548 *ASSUMPTIONS:
1549 *
1550 *NOTE:
1551 *
1552 * @param pMac Pointer to Global MAC structure
1553 * @param *pMsgBuf A pointer to the SME message buffer
1554 * @return None
1555 */
Jeff Johnson295189b2012-06-20 16:38:30 -07001556static void
1557__limProcessSmeJoinReq(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
1558{
1559 // tANI_U8 *pBuf;
1560 //tANI_U32 len;
1561// tSirMacAddr currentBssId;
1562 tpSirSmeJoinReq pSmeJoinReq = NULL;
1563 tLimMlmJoinReq *pMlmJoinReq;
1564 tSirResultCodes retCode = eSIR_SME_SUCCESS;
1565 tANI_U32 val = 0;
1566 tANI_U16 nSize;
1567 tANI_U8 sessionId;
1568 tpPESession psessionEntry = NULL;
1569 tANI_U8 smesessionId;
1570 tANI_U16 smetransactionId;
1571 tPowerdBm localPowerConstraint = 0, regMax = 0;
1572
1573#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM //FEATURE_WLAN_DIAG_SUPPORT
1574 //Not sending any session, since it is not created yet. The response whould have correct state.
1575 limDiagEventReport(pMac, WLAN_PE_DIAG_JOIN_REQ_EVENT, NULL, 0, 0);
1576#endif //FEATURE_WLAN_DIAG_SUPPORT
1577
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001578 PELOG1(limLog(pMac, LOG1, FL("Received SME_JOIN_REQ"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001579
1580#ifdef WLAN_FEATURE_VOWIFI
1581 /* Need to read the CFG here itself as this is used in limExtractAPCapability() below.
1582 * This CFG is actually read in rrmUpdateConfig() which is called later. Because this is not
1583 * read, RRM related path before calling rrmUpdateConfig() is not getting executed causing issues
1584 * like not honoring power constraint on 1st association after driver loading. */
1585 if (wlan_cfgGetInt(pMac, WNI_CFG_RRM_ENABLED, &val) != eSIR_SUCCESS)
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001586 limLog(pMac, LOGP, FL("cfg get rrm enabled failed"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001587 pMac->rrm.rrmPEContext.rrmEnable = (val) ? 1 : 0;
1588 val = 0;
1589#endif /* WLAN_FEATURE_VOWIFI */
1590
1591 /**
1592 * Expect Join request in idle state.
1593 * Reassociate request is expected in link established state.
1594 */
1595
1596 /* Global SME and LIM states are not defined yet for BT-AMP Support */
1597 if(pMac->lim.gLimSmeState == eLIM_SME_IDLE_STATE)
1598 {
1599 nSize = __limGetSmeJoinReqSizeForAlloc((tANI_U8*) pMsgBuf);
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301600
1601 pSmeJoinReq = vos_mem_malloc(nSize);
1602 if ( NULL == pSmeJoinReq )
Jeff Johnson295189b2012-06-20 16:38:30 -07001603 {
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301604 limLog(pMac, LOGP, FL("call to AllocateMemory failed for pSmeJoinReq"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001605 retCode = eSIR_SME_RESOURCES_UNAVAILABLE;
1606 goto end;
1607 }
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301608 (void) vos_mem_set((void *) pSmeJoinReq, nSize, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07001609
Jeff Johnson295189b2012-06-20 16:38:30 -07001610 if ((limJoinReqSerDes(pMac, pSmeJoinReq, (tANI_U8 *)pMsgBuf) == eSIR_FAILURE) ||
1611 (!limIsSmeJoinReqValid(pMac, pSmeJoinReq)))
1612 {
1613 /// Received invalid eWNI_SME_JOIN_REQ
1614 // Log the event
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001615 limLog(pMac, LOGW, FL("received SME_JOIN_REQ with invalid data"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001616 retCode = eSIR_SME_INVALID_PARAMETERS;
1617 goto end;
1618 }
1619
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301620 //pMac->lim.gpLimJoinReq = pSmeJoinReq; TO SUPPORT BT-AMP, review os sep 23
Jeff Johnson295189b2012-06-20 16:38:30 -07001621
1622 /* check for the existence of start BSS session */
1623#ifdef FIXME_GEN6
1624 if(pSmeJoinReq->bsstype == eSIR_BTAMP_AP_MODE)
1625 {
1626 if(peValidateBtJoinRequest(pMac)!= TRUE)
1627 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001628 limLog(pMac, LOGW, FL("Start Bss session not present::SME_JOIN_REQ in unexpected state"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001629 retCode = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
1630 psessionEntry = NULL;
1631 goto end;
1632 }
1633 }
1634
1635#endif
1636
1637
1638 if((psessionEntry = peFindSessionByBssid(pMac,pSmeJoinReq->bssDescription.bssId,&sessionId)) != NULL)
1639 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001640 limLog(pMac, LOGE, FL("Session Already exists for given BSSID"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001641
1642 if(psessionEntry->limSmeState == eLIM_SME_LINK_EST_STATE)
1643 {
1644 // Received eWNI_SME_JOIN_REQ for same
1645 // BSS as currently associated.
1646 // Log the event and send success
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001647 PELOGW(limLog(pMac, LOGW, FL("Received SME_JOIN_REQ for currently joined BSS"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001648 /// Send Join success response to host
1649 retCode = eSIR_SME_SUCCESS;
1650 goto end;
1651 }
1652 else
1653 {
1654 retCode = eSIR_SME_REFUSED;
1655 psessionEntry = NULL;
1656 goto end;
1657 }
1658 }
1659 else /* Session Entry does not exist for given BSSId */
1660 {
1661 /* Try to Create a new session */
1662 if((psessionEntry = peCreateSession(pMac,pSmeJoinReq->bssDescription.bssId,&sessionId, pMac->lim.maxStation)) == NULL)
1663 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001664 limLog(pMac, LOGE, FL("Session Can not be created "));
Jeff Johnson295189b2012-06-20 16:38:30 -07001665 retCode = eSIR_SME_RESOURCES_UNAVAILABLE;
1666 goto end;
1667 }
1668 }
Jeff Johnsone7245742012-09-05 17:12:55 -07001669 handleHTCapabilityandHTInfo(pMac, psessionEntry);
krunal soni5afa96c2013-09-06 22:19:02 -07001670 psessionEntry->isAmsduSupportInAMPDU = pSmeJoinReq->isAmsduSupportInAMPDU;
Jeff Johnsone7245742012-09-05 17:12:55 -07001671
Jeff Johnson295189b2012-06-20 16:38:30 -07001672 /* Store Session related parameters */
1673 /* Store PE session Id in session Table */
1674 psessionEntry->peSessionId = sessionId;
1675
1676 /* store the smejoin req handle in session table */
1677 psessionEntry->pLimJoinReq = pSmeJoinReq;
1678
1679 /* Store SME session Id in sessionTable */
1680 psessionEntry->smeSessionId = pSmeJoinReq->sessionId;
1681
1682 /* Store SME transaction Id in session Table */
1683 psessionEntry->transactionId = pSmeJoinReq->transactionId;
1684
1685 /* Store beaconInterval */
1686 psessionEntry->beaconParams.beaconInterval = pSmeJoinReq->bssDescription.beaconInterval;
1687
1688 /* Copying of bssId is already done, while creating session */
1689 //sirCopyMacAddr(psessionEntry->bssId,pSmeJoinReq->bssId);
1690 sirCopyMacAddr(psessionEntry->selfMacAddr,pSmeJoinReq->selfMacAddr);
1691 psessionEntry->bssType = pSmeJoinReq->bsstype;
1692
1693 psessionEntry->statypeForBss = STA_ENTRY_PEER;
1694
1695 /* Copy the dot 11 mode in to the session table */
1696
1697 psessionEntry->dot11mode = pSmeJoinReq->dot11mode;
1698 psessionEntry->nwType = pSmeJoinReq->bssDescription.nwType;
Jeff Johnsone7245742012-09-05 17:12:55 -07001699#ifdef WLAN_FEATURE_11AC
1700 psessionEntry->vhtCapability = IS_DOT11_MODE_VHT(psessionEntry->dot11mode);
Jeff Johnson32d95a32012-09-10 13:15:23 -07001701 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO_MED,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001702 "***__limProcessSmeJoinReq: vhtCapability=%d****",psessionEntry->vhtCapability);
Shailender Karmuchi08f87c22013-01-17 12:51:24 -08001703 if (psessionEntry->vhtCapability )
1704 {
1705 psessionEntry->txBFIniFeatureEnabled = pSmeJoinReq->txBFIniFeatureEnabled;
1706
1707 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO_MED,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001708 "***__limProcessSmeJoinReq: txBFIniFeatureEnabled=%d****",
Shailender Karmuchi08f87c22013-01-17 12:51:24 -08001709 psessionEntry->txBFIniFeatureEnabled);
1710
1711 if( psessionEntry->txBFIniFeatureEnabled )
1712 {
1713 if (cfgSetInt(pMac, WNI_CFG_VHT_SU_BEAMFORMEE_CAP, psessionEntry->txBFIniFeatureEnabled)
1714 != eSIR_SUCCESS)
1715 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001716 limLog(pMac, LOGP, FL("could not set WNI_CFG_VHT_SU_BEAMFORMEE_CAP at CFG"));
Shailender Karmuchi08f87c22013-01-17 12:51:24 -08001717 retCode = eSIR_LOGP_EXCEPTION;
1718 goto end;
1719 }
Shailender Karmuchicc3fe442013-02-16 18:18:33 -08001720 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO_MED,
Leela V Kiran Kumar Reddy Chirala6a458752013-02-16 15:41:27 -08001721 "***__limProcessSmeJoinReq: txBFCsnValue=%d****", pSmeJoinReq->txBFCsnValue);
Shailender Karmuchicc3fe442013-02-16 18:18:33 -08001722
1723 if (cfgSetInt(pMac, WNI_CFG_VHT_CSN_BEAMFORMEE_ANT_SUPPORTED, pSmeJoinReq->txBFCsnValue)
Shailender Karmuchi08f87c22013-01-17 12:51:24 -08001724 != eSIR_SUCCESS)
1725 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001726 limLog(pMac, LOGP, FL("could not set WNI_CFG_VHT_CSN_BEAMFORMEE_ANT_SUPPORTED at CFG"));
Shailender Karmuchi08f87c22013-01-17 12:51:24 -08001727 retCode = eSIR_LOGP_EXCEPTION;
1728 goto end;
1729 }
1730 }
1731 }
1732
Jeff Johnsone7245742012-09-05 17:12:55 -07001733#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001734
1735 /*Phy mode*/
1736 psessionEntry->gLimPhyMode = pSmeJoinReq->bssDescription.nwType;
1737
1738 /* Copy The channel Id to the session Table */
1739 psessionEntry->currentOperChannel = pSmeJoinReq->bssDescription.channelId;
Jeff Johnsone7245742012-09-05 17:12:55 -07001740 psessionEntry->htSupportedChannelWidthSet = (pSmeJoinReq->cbMode)?1:0; // This is already merged value of peer and self - done by csr in csrGetCBModeFromIes
1741 psessionEntry->htRecommendedTxWidthSet = psessionEntry->htSupportedChannelWidthSet;
1742 psessionEntry->htSecondaryChannelOffset = pSmeJoinReq->cbMode;
Jeff Johnson295189b2012-06-20 16:38:30 -07001743
Chet Lanctot186b5732013-03-18 10:26:30 -07001744 /* Record if management frames need to be protected */
1745#ifdef WLAN_FEATURE_11W
1746 if(eSIR_ED_AES_128_CMAC == pSmeJoinReq->MgmtEncryptionType)
1747 {
1748 psessionEntry->limRmfEnabled = 1;
1749 }
1750 else
1751 {
1752 psessionEntry->limRmfEnabled = 0;
1753 }
1754#endif
1755
krunal soni8d13b092013-07-19 13:23:29 -07001756#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM
1757 psessionEntry->rssi = pSmeJoinReq->bssDescription.rssi;
1758#endif
1759
Jeff Johnson295189b2012-06-20 16:38:30 -07001760 /*Store Persona */
1761 psessionEntry->pePersona = pSmeJoinReq->staPersona;
1762 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
Jeff Johnsone7245742012-09-05 17:12:55 -07001763 FL("PE PERSONA=%d cbMode %u"), psessionEntry->pePersona, pSmeJoinReq->cbMode);
Jeff Johnson295189b2012-06-20 16:38:30 -07001764
1765 /* Copy the SSID from smejoinreq to session entry */
1766 psessionEntry->ssId.length = pSmeJoinReq->ssId.length;
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301767 vos_mem_copy( psessionEntry->ssId.ssId,
1768 pSmeJoinReq->ssId.ssId, psessionEntry->ssId.length);
1769
1770 // Determin 11r or CCX connection based on input from SME
1771 // which inturn is dependent on the profile the user wants to connect
1772 // to, So input is coming from supplicant
Jeff Johnson295189b2012-06-20 16:38:30 -07001773#ifdef WLAN_FEATURE_VOWIFI_11R
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301774 psessionEntry->is11Rconnection = pSmeJoinReq->is11Rconnection;
Jeff Johnson295189b2012-06-20 16:38:30 -07001775#endif
1776#ifdef FEATURE_WLAN_CCX
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301777 psessionEntry->isCCXconnection = pSmeJoinReq->isCCXconnection;
Jeff Johnson295189b2012-06-20 16:38:30 -07001778#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001779#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_CCX || defined(FEATURE_WLAN_LFR)
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301780 psessionEntry->isFastTransitionEnabled = pSmeJoinReq->isFastTransitionEnabled;
Jeff Johnson295189b2012-06-20 16:38:30 -07001781#endif
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301782
Jeff Johnson43971f52012-07-17 12:26:56 -07001783#ifdef FEATURE_WLAN_LFR
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301784 psessionEntry->isFastRoamIniFeatureEnabled = pSmeJoinReq->isFastRoamIniFeatureEnabled;
Jeff Johnson43971f52012-07-17 12:26:56 -07001785#endif
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301786 psessionEntry->txLdpcIniFeatureEnabled = pSmeJoinReq->txLdpcIniFeatureEnabled;
Gopichand Nakkalab2d2c312013-01-04 11:41:02 -08001787
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301788 if (psessionEntry->bssType == eSIR_INFRASTRUCTURE_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07001789 {
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301790 psessionEntry->limSystemRole = eLIM_STA_ROLE;
1791 }
1792 else if (psessionEntry->bssType == eSIR_BTAMP_AP_MODE)
1793 {
1794 psessionEntry->limSystemRole = eLIM_BT_AMP_STA_ROLE;
1795 }
1796 else
1797 {
1798 /* Throw an error and return and make sure to delete the session.*/
1799 limLog(pMac, LOGW, FL("received SME_JOIN_REQ with invalid bss type"));
1800 retCode = eSIR_SME_INVALID_PARAMETERS;
1801 goto end;
1802 }
1803
1804 if (pSmeJoinReq->addIEScan.length)
1805 {
1806 vos_mem_copy( &psessionEntry->pLimJoinReq->addIEScan,
Jeff Johnson295189b2012-06-20 16:38:30 -07001807 &pSmeJoinReq->addIEScan, sizeof(tSirAddie));
1808 }
1809
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301810 if (pSmeJoinReq->addIEAssoc.length)
Jeff Johnson295189b2012-06-20 16:38:30 -07001811 {
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301812 vos_mem_copy( &psessionEntry->pLimJoinReq->addIEAssoc,
Jeff Johnson295189b2012-06-20 16:38:30 -07001813 &pSmeJoinReq->addIEAssoc, sizeof(tSirAddie));
1814 }
1815
Jeff Johnson295189b2012-06-20 16:38:30 -07001816 val = sizeof(tLimMlmJoinReq) + psessionEntry->pLimJoinReq->bssDescription.length + 2;
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301817 pMlmJoinReq = vos_mem_malloc(val);
1818 if ( NULL == pMlmJoinReq )
Jeff Johnson295189b2012-06-20 16:38:30 -07001819 {
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301820 limLog(pMac, LOGP, FL("call to AllocateMemory failed for mlmJoinReq"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001821 return;
1822 }
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301823 (void) vos_mem_set((void *) pMlmJoinReq, val, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07001824
1825 /* PE SessionId is stored as a part of JoinReq*/
1826 pMlmJoinReq->sessionId = psessionEntry->peSessionId;
1827
1828 if (wlan_cfgGetInt(pMac, WNI_CFG_JOIN_FAILURE_TIMEOUT, (tANI_U32 *) &pMlmJoinReq->joinFailureTimeout)
1829 != eSIR_SUCCESS)
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001830 limLog(pMac, LOGP, FL("could not retrieve JoinFailureTimer value"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001831
1832 /* copy operational rate from psessionEntry*/
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301833 vos_mem_copy((void*)&psessionEntry->rateSet, (void*)&pSmeJoinReq->operationalRateSet,
Jeff Johnson295189b2012-06-20 16:38:30 -07001834 sizeof(tSirMacRateSet));
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301835 vos_mem_copy((void*)&psessionEntry->extRateSet, (void*)&pSmeJoinReq->extendedRateSet,
Jeff Johnson295189b2012-06-20 16:38:30 -07001836 sizeof(tSirMacRateSet));
1837 //this may not be needed anymore now, as rateSet is now included in the session entry and MLM has session context.
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301838 vos_mem_copy((void*)&pMlmJoinReq->operationalRateSet, (void*)&psessionEntry->rateSet,
Jeff Johnson295189b2012-06-20 16:38:30 -07001839 sizeof(tSirMacRateSet));
1840
1841 psessionEntry->encryptType = pSmeJoinReq->UCEncryptionType;
1842
Jeff Johnson295189b2012-06-20 16:38:30 -07001843 pMlmJoinReq->bssDescription.length = psessionEntry->pLimJoinReq->bssDescription.length;
1844
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301845 vos_mem_copy((tANI_U8 *) &pMlmJoinReq->bssDescription.bssId,
Jeff Johnson295189b2012-06-20 16:38:30 -07001846 (tANI_U8 *) &psessionEntry->pLimJoinReq->bssDescription.bssId,
1847 psessionEntry->pLimJoinReq->bssDescription.length + 2);
1848
Jeff Johnson295189b2012-06-20 16:38:30 -07001849 psessionEntry->limCurrentBssCaps =
Jeff Johnsone7245742012-09-05 17:12:55 -07001850 psessionEntry->pLimJoinReq->bssDescription.capabilityInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07001851
Jeff Johnsone7245742012-09-05 17:12:55 -07001852 regMax = cfgGetRegulatoryMaxTransmitPower( pMac, psessionEntry->currentOperChannel );
1853 localPowerConstraint = regMax;
1854 limExtractApCapability( pMac,
1855 (tANI_U8 *) psessionEntry->pLimJoinReq->bssDescription.ieFields,
1856 limGetIElenFromBssDescription(&psessionEntry->pLimJoinReq->bssDescription),
1857 &psessionEntry->limCurrentBssQosCaps,
1858 &psessionEntry->limCurrentBssPropCap,
1859 &pMac->lim.gLimCurrentBssUapsd //TBD-RAJESH make gLimCurrentBssUapsd this session specific
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07001860 , &localPowerConstraint,
1861 psessionEntry
Jeff Johnsone7245742012-09-05 17:12:55 -07001862 );
Jeff Johnson295189b2012-06-20 16:38:30 -07001863#ifdef FEATURE_WLAN_CCX
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001864 psessionEntry->maxTxPower = limGetMaxTxPower(regMax, localPowerConstraint, pMac->roam.configParam.nTxPowerCap);
Jeff Johnson295189b2012-06-20 16:38:30 -07001865#else
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301866 psessionEntry->maxTxPower = VOS_MIN( regMax, (localPowerConstraint) );
Jeff Johnson295189b2012-06-20 16:38:30 -07001867#endif
1868#if defined WLAN_VOWIFI_DEBUG
1869 limLog( pMac, LOGE, "Regulatory max = %d, local power constraint = %d, max tx = %d", regMax, localPowerConstraint, psessionEntry->maxTxPower );
1870#endif
1871
1872 if (pMac->lim.gLimCurrentBssUapsd)
1873 {
1874 pMac->lim.gUapsdPerAcBitmask = psessionEntry->pLimJoinReq->uapsdPerAcBitmask;
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001875 limLog( pMac, LOG1, FL("UAPSD flag for all AC - 0x%2x"), pMac->lim.gUapsdPerAcBitmask);
Jeff Johnson295189b2012-06-20 16:38:30 -07001876
1877 // resetting the dynamic uapsd mask
1878 pMac->lim.gUapsdPerAcDeliveryEnableMask = 0;
1879 pMac->lim.gUapsdPerAcTriggerEnableMask = 0;
1880 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001881
1882 psessionEntry->limRFBand = limGetRFBand(psessionEntry->currentOperChannel);
1883
1884 // Initialize 11h Enable Flag
1885 if(SIR_BAND_5_GHZ == psessionEntry->limRFBand)
1886 {
1887 if (wlan_cfgGetInt(pMac, WNI_CFG_11H_ENABLED, &val) != eSIR_SUCCESS)
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001888 limLog(pMac, LOGP, FL("Fail to get WNI_CFG_11H_ENABLED "));
Jeff Johnson295189b2012-06-20 16:38:30 -07001889 psessionEntry->lim11hEnable = val;
1890 }
1891 else
1892 psessionEntry->lim11hEnable = 0;
1893
1894 //To care of the scenario when STA transitions from IBSS to Infrastructure mode.
1895 pMac->lim.gLimIbssCoalescingHappened = false;
1896
Jeff Johnsone7245742012-09-05 17:12:55 -07001897 psessionEntry->limPrevSmeState = psessionEntry->limSmeState;
1898 psessionEntry->limSmeState = eLIM_SME_WT_JOIN_STATE;
1899 MTRACE(macTrace(pMac, TRACE_CODE_SME_STATE, psessionEntry->peSessionId, psessionEntry->limSmeState));
Jeff Johnson295189b2012-06-20 16:38:30 -07001900
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001901 PELOG1(limLog(pMac, LOG1, FL("SME JoinReq: SSID %d.%c%c%c%c%c%c"),
Jeff Johnson295189b2012-06-20 16:38:30 -07001902 psessionEntry->ssId.length,
1903 psessionEntry->ssId.ssId[0],
1904 psessionEntry->ssId.ssId[1],
1905 psessionEntry->ssId.ssId[2],
1906 psessionEntry->ssId.ssId[3],
1907 psessionEntry->ssId.ssId[4],
1908 psessionEntry->ssId.ssId[5]);
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001909 limLog(pMac, LOG1, FL("Channel %d, BSSID %x:%x:%x:%x:%x:%x"),
Jeff Johnson295189b2012-06-20 16:38:30 -07001910 psessionEntry->currentOperChannel,
1911 psessionEntry->bssId[0],
1912 psessionEntry->bssId[1],
1913 psessionEntry->bssId[2],
1914 psessionEntry->bssId[3],
1915 psessionEntry->bssId[4],
1916 psessionEntry->bssId[5]);)
1917
1918 /* Indicate whether spectrum management is enabled*/
1919 psessionEntry->spectrumMgtEnabled =
1920 pSmeJoinReq->spectrumMgtIndicator;
1921 /* Issue LIM_MLM_JOIN_REQ to MLM */
1922 limPostMlmMessage(pMac, LIM_MLM_JOIN_REQ, (tANI_U32 *) pMlmJoinReq);
1923 return;
1924
1925 }
1926 else
1927 {
1928 /* Received eWNI_SME_JOIN_REQ un expected state */
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001929 limLog(pMac, LOGE, FL("received unexpected SME_JOIN_REQ in state %X"), pMac->lim.gLimSmeState);
Jeff Johnson295189b2012-06-20 16:38:30 -07001930 limPrintSmeState(pMac, LOGE, pMac->lim.gLimSmeState);
1931 retCode = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
1932 psessionEntry = NULL;
1933 goto end;
1934
1935 }
1936
1937end:
1938 limGetSessionInfo(pMac,(tANI_U8*)pMsgBuf,&smesessionId,&smetransactionId);
1939
1940 if(pSmeJoinReq)
1941 {
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301942 vos_mem_free(pSmeJoinReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07001943 pSmeJoinReq = NULL;
1944 if (NULL != psessionEntry)
1945 {
1946 psessionEntry->pLimJoinReq = NULL;
1947 }
1948 }
1949
1950 if(retCode != eSIR_SME_SUCCESS)
1951 {
1952 if(NULL != psessionEntry)
1953 {
1954 peDeleteSession(pMac,psessionEntry);
1955 psessionEntry = NULL;
1956 }
1957 }
1958
1959 limSendSmeJoinReassocRsp(pMac, eWNI_SME_JOIN_RSP, retCode, eSIR_MAC_UNSPEC_FAILURE_STATUS,psessionEntry,smesessionId,smetransactionId);
1960} /*** end __limProcessSmeJoinReq() ***/
1961
1962
1963#ifdef FEATURE_WLAN_CCX
Madan Mohan Koyyalamudi3282c572012-11-09 17:01:41 -08001964tANI_U8 limGetMaxTxPower(tPowerdBm regMax, tPowerdBm apTxPower, tANI_U8 iniTxPower)
Jeff Johnson295189b2012-06-20 16:38:30 -07001965{
1966 tANI_U8 maxTxPower = 0;
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301967 tANI_U8 txPower = VOS_MIN( regMax, (apTxPower) );
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001968 txPower = VOS_MIN(txPower, iniTxPower);
Jeff Johnson295189b2012-06-20 16:38:30 -07001969 if((txPower >= MIN_TX_PWR_CAP) && (txPower <= MAX_TX_PWR_CAP))
1970 maxTxPower = txPower;
1971 else if (txPower < MIN_TX_PWR_CAP)
1972 maxTxPower = MIN_TX_PWR_CAP;
1973 else
1974 maxTxPower = MAX_TX_PWR_CAP;
1975
1976 return (maxTxPower);
1977}
1978#endif
1979
Jeff Johnson295189b2012-06-20 16:38:30 -07001980/**
1981 * __limProcessSmeReassocReq()
1982 *
1983 *FUNCTION:
1984 * This function is called to process SME_REASSOC_REQ message
1985 * from HDD or upper layer application.
1986 *
1987 *LOGIC:
1988 *
1989 *ASSUMPTIONS:
1990 *
1991 *NOTE:
1992 *
1993 * @param pMac Pointer to Global MAC structure
1994 * @param *pMsgBuf A pointer to the SME message buffer
1995 * @return None
1996 */
1997
1998static void
1999__limProcessSmeReassocReq(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
2000{
2001 tANI_U16 caps;
2002 tANI_U32 val;
Srinivas Girigowdac16730e2013-01-16 13:39:39 -08002003 tpSirSmeJoinReq pReassocReq = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002004 tLimMlmReassocReq *pMlmReassocReq;
2005 tSirResultCodes retCode = eSIR_SME_SUCCESS;
2006 tpPESession psessionEntry = NULL;
2007 tANI_U8 sessionId;
2008 tANI_U8 smeSessionId;
2009 tANI_U16 transactionId;
2010 tPowerdBm localPowerConstraint = 0, regMax = 0;
2011 tANI_U32 teleBcnEn = 0;
Madan Mohan Koyyalamudi7df624d2012-10-31 16:32:50 -07002012 tANI_U16 nSize;
Jeff Johnson295189b2012-06-20 16:38:30 -07002013
2014
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002015 PELOG3(limLog(pMac, LOG3, FL("Received REASSOC_REQ"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07002016
Madan Mohan Koyyalamudi7df624d2012-10-31 16:32:50 -07002017 nSize = __limGetSmeJoinReqSizeForAlloc((tANI_U8 *) pMsgBuf);
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302018 pReassocReq = vos_mem_malloc(nSize);
2019 if ( NULL == pReassocReq )
Jeff Johnson295189b2012-06-20 16:38:30 -07002020 {
2021 // Log error
2022 limLog(pMac, LOGP,
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302023 FL("call to AllocateMemory failed for pReassocReq"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002024
2025 retCode = eSIR_SME_RESOURCES_UNAVAILABLE;
2026 goto end;
2027 }
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302028 (void) vos_mem_set((void *) pReassocReq, nSize, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07002029 if ((limJoinReqSerDes(pMac, (tpSirSmeJoinReq) pReassocReq,
2030 (tANI_U8 *) pMsgBuf) == eSIR_FAILURE) ||
2031 (!limIsSmeJoinReqValid(pMac,
2032 (tpSirSmeJoinReq) pReassocReq)))
2033 {
2034 /// Received invalid eWNI_SME_REASSOC_REQ
2035 // Log the event
2036 limLog(pMac, LOGW,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002037 FL("received SME_REASSOC_REQ with invalid data"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002038
2039 retCode = eSIR_SME_INVALID_PARAMETERS;
2040 goto end;
2041 }
2042
2043 if((psessionEntry = peFindSessionByBssid(pMac,pReassocReq->bssDescription.bssId,&sessionId))==NULL)
2044 {
2045 limPrintMacAddr(pMac, pReassocReq->bssDescription.bssId, LOGE);
Srinivas Girigowda2a69dcf2013-09-13 14:48:34 -07002046 limLog(pMac, LOGE, FL("Session does not exist for given bssId"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002047 retCode = eSIR_SME_INVALID_PARAMETERS;
2048 goto end;
2049 }
2050
2051#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM //FEATURE_WLAN_DIAG_SUPPORT
2052 limDiagEventReport(pMac, WLAN_PE_DIAG_REASSOC_REQ_EVENT, psessionEntry, 0, 0);
2053#endif //FEATURE_WLAN_DIAG_SUPPORT
2054 //pMac->lim.gpLimReassocReq = pReassocReq;//TO SUPPORT BT-AMP
2055
2056 /* Store the reassoc handle in the session Table.. 23rd sep review */
2057 psessionEntry->pLimReAssocReq = pReassocReq;
2058
2059 /**
2060 * Reassociate request is expected
2061 * in link established state only.
2062 */
2063
2064 if (psessionEntry->limSmeState != eLIM_SME_LINK_EST_STATE)
2065 {
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002066#if defined(WLAN_FEATURE_VOWIFI_11R) || defined(FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07002067 if (psessionEntry->limSmeState == eLIM_SME_WT_REASSOC_STATE)
2068 {
2069 // May be from 11r FT pre-auth. So lets check it before we bail out
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08002070 limLog(pMac, LOG1, FL("Session in reassoc state is %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002071 psessionEntry->peSessionId);
2072
2073 // Make sure its our preauth bssid
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302074 if (!vos_mem_compare( pReassocReq->bssDescription.bssId,
Jeff Johnson295189b2012-06-20 16:38:30 -07002075 pMac->ft.ftPEContext.pFTPreAuthReq->preAuthbssId, 6))
2076 {
2077 limPrintMacAddr(pMac, pReassocReq->bssDescription.bssId, LOGE);
2078 limPrintMacAddr(pMac, pMac->ft.ftPEContext.pFTPreAuthReq->preAuthbssId, LOGE);
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002079 limLog(pMac, LOGP, FL("Unknown bssId in reassoc state"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002080 retCode = eSIR_SME_INVALID_PARAMETERS;
2081 goto end;
2082 }
2083
2084 limProcessMlmFTReassocReq(pMac, pMsgBuf, psessionEntry);
2085 return;
2086 }
2087#endif
2088 /// Should not have received eWNI_SME_REASSOC_REQ
2089 // Log the event
2090 limLog(pMac, LOGE,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002091 FL("received unexpected SME_REASSOC_REQ in state %X"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002092 psessionEntry->limSmeState);
2093 limPrintSmeState(pMac, LOGE, psessionEntry->limSmeState);
2094
2095 retCode = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
2096 goto end;
2097 }
2098
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302099 vos_mem_copy( psessionEntry->limReAssocbssId,
Jeff Johnson295189b2012-06-20 16:38:30 -07002100 psessionEntry->pLimReAssocReq->bssDescription.bssId,
2101 sizeof(tSirMacAddr));
2102
2103 psessionEntry->limReassocChannelId =
2104 psessionEntry->pLimReAssocReq->bssDescription.channelId;
2105
Jeff Johnsone7245742012-09-05 17:12:55 -07002106 psessionEntry->reAssocHtSupportedChannelWidthSet =
2107 (psessionEntry->pLimReAssocReq->cbMode)?1:0;
2108 psessionEntry->reAssocHtRecommendedTxWidthSet =
2109 psessionEntry->reAssocHtSupportedChannelWidthSet;
2110 psessionEntry->reAssocHtSecondaryChannelOffset =
2111 psessionEntry->pLimReAssocReq->cbMode;
2112
Jeff Johnson295189b2012-06-20 16:38:30 -07002113 psessionEntry->limReassocBssCaps =
2114 psessionEntry->pLimReAssocReq->bssDescription.capabilityInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07002115 regMax = cfgGetRegulatoryMaxTransmitPower( pMac, psessionEntry->currentOperChannel );
2116 localPowerConstraint = regMax;
2117 limExtractApCapability( pMac,
2118 (tANI_U8 *) psessionEntry->pLimReAssocReq->bssDescription.ieFields,
2119 limGetIElenFromBssDescription(
2120 &psessionEntry->pLimReAssocReq->bssDescription),
2121 &psessionEntry->limReassocBssQosCaps,
2122 &psessionEntry->limReassocBssPropCap,
2123 &pMac->lim.gLimCurrentBssUapsd //TBD-RAJESH make gLimReassocBssUapsd session specific
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07002124 , &localPowerConstraint,
2125 psessionEntry
Jeff Johnson295189b2012-06-20 16:38:30 -07002126 );
2127
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302128 psessionEntry->maxTxPower = VOS_MIN( regMax, (localPowerConstraint) );
Jeff Johnson295189b2012-06-20 16:38:30 -07002129#if defined WLAN_VOWIFI_DEBUG
2130 limLog( pMac, LOGE, "Regulatory max = %d, local power constraint = %d, max tx = %d", regMax, localPowerConstraint, psessionEntry->maxTxPower );
2131#endif
2132 {
2133 #if 0
2134 if (wlan_cfgGetStr(pMac, WNI_CFG_SSID, pMac->lim.gLimReassocSSID.ssId,
2135 &cfgLen) != eSIR_SUCCESS)
2136 {
2137 /// Could not get SSID from CFG. Log error.
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002138 limLog(pMac, LOGP, FL("could not retrive SSID"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002139 }
2140 #endif//TO SUPPORT BT-AMP
2141
2142 /* Copy the SSID from sessio entry to local variable */
2143 #if 0
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302144 vos_mem_copy( pMac->lim.gLimReassocSSID.ssId,
Jeff Johnson295189b2012-06-20 16:38:30 -07002145 psessionEntry->ssId.ssId,
2146 psessionEntry->ssId.length);
2147 #endif
2148 psessionEntry->limReassocSSID.length = pReassocReq->ssId.length;
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302149 vos_mem_copy( psessionEntry->limReassocSSID.ssId,
Jeff Johnson295189b2012-06-20 16:38:30 -07002150 pReassocReq->ssId.ssId, psessionEntry->limReassocSSID.length);
2151
2152 }
2153
2154 if (pMac->lim.gLimCurrentBssUapsd)
2155 {
2156 pMac->lim.gUapsdPerAcBitmask = psessionEntry->pLimReAssocReq->uapsdPerAcBitmask;
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002157 limLog( pMac, LOG1, FL("UAPSD flag for all AC - 0x%2x"), pMac->lim.gUapsdPerAcBitmask);
Jeff Johnson295189b2012-06-20 16:38:30 -07002158 }
2159
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302160 pMlmReassocReq = vos_mem_malloc(sizeof(tLimMlmReassocReq));
2161 if ( NULL == pMlmReassocReq )
Jeff Johnson295189b2012-06-20 16:38:30 -07002162 {
2163 // Log error
2164 limLog(pMac, LOGP,
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302165 FL("call to AllocateMemory failed for mlmReassocReq"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002166
2167 retCode = eSIR_SME_RESOURCES_UNAVAILABLE;
2168 goto end;
2169 }
2170
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302171 vos_mem_copy( pMlmReassocReq->peerMacAddr,
Jeff Johnson295189b2012-06-20 16:38:30 -07002172 psessionEntry->limReAssocbssId,
2173 sizeof(tSirMacAddr));
2174
2175 if (wlan_cfgGetInt(pMac, WNI_CFG_REASSOCIATION_FAILURE_TIMEOUT,
2176 (tANI_U32 *) &pMlmReassocReq->reassocFailureTimeout)
2177 != eSIR_SUCCESS)
2178 {
2179 /**
2180 * Could not get ReassocFailureTimeout value
2181 * from CFG. Log error.
2182 */
2183 limLog(pMac, LOGP,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002184 FL("could not retrieve ReassocFailureTimeout value"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002185 }
2186
2187 if (cfgGetCapabilityInfo(pMac, &caps,psessionEntry) != eSIR_SUCCESS)
2188 {
2189 /**
2190 * Could not get Capabilities value
2191 * from CFG. Log error.
2192 */
2193 limLog(pMac, LOGP,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002194 FL("could not retrieve Capabilities value"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002195 }
2196 pMlmReassocReq->capabilityInfo = caps;
2197
2198 /* Update PE sessionId*/
2199 pMlmReassocReq->sessionId = sessionId;
2200
2201 /* If telescopic beaconing is enabled, set listen interval to
2202 WNI_CFG_TELE_BCN_MAX_LI */
2203 if(wlan_cfgGetInt(pMac, WNI_CFG_TELE_BCN_WAKEUP_EN, &teleBcnEn) !=
2204 eSIR_SUCCESS)
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002205 limLog(pMac, LOGP, FL("Couldn't get WNI_CFG_TELE_BCN_WAKEUP_EN"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002206
2207 val = WNI_CFG_LISTEN_INTERVAL_STADEF;
2208
2209 if(teleBcnEn)
2210 {
2211 if(wlan_cfgGetInt(pMac, WNI_CFG_TELE_BCN_MAX_LI, &val) !=
2212 eSIR_SUCCESS)
2213 {
2214 /**
2215 * Could not get ListenInterval value
2216 * from CFG. Log error.
2217 */
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002218 limLog(pMac, LOGP, FL("could not retrieve ListenInterval"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002219 }
2220 }
2221 else
2222 {
2223 if (wlan_cfgGetInt(pMac, WNI_CFG_LISTEN_INTERVAL, &val) != eSIR_SUCCESS)
2224 {
2225 /**
2226 * Could not get ListenInterval value
2227 * from CFG. Log error.
2228 */
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002229 limLog(pMac, LOGP, FL("could not retrieve ListenInterval"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002230 }
2231 }
2232
2233 /* Delete all BA sessions before Re-Assoc.
2234 * BA frames are class 3 frames and the session
2235 * is lost upon disassociation and reassociation.
2236 */
2237
Kiran Kumar Lokere458d7322013-05-29 14:29:43 -07002238 limDeleteBASessions(pMac, psessionEntry, BA_BOTH_DIRECTIONS);
Jeff Johnson295189b2012-06-20 16:38:30 -07002239
2240 pMlmReassocReq->listenInterval = (tANI_U16) val;
2241
2242 /* Indicate whether spectrum management is enabled*/
2243 psessionEntry->spectrumMgtEnabled = pReassocReq->spectrumMgtIndicator;
2244
2245 psessionEntry->limPrevSmeState = psessionEntry->limSmeState;
2246 psessionEntry->limSmeState = eLIM_SME_WT_REASSOC_STATE;
2247
Jeff Johnsone7245742012-09-05 17:12:55 -07002248 MTRACE(macTrace(pMac, TRACE_CODE_SME_STATE, psessionEntry->peSessionId, psessionEntry->limSmeState));
Jeff Johnson295189b2012-06-20 16:38:30 -07002249
2250 limPostMlmMessage(pMac,
2251 LIM_MLM_REASSOC_REQ,
2252 (tANI_U32 *) pMlmReassocReq);
2253 return;
2254
2255end:
2256 if (pReassocReq)
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302257 vos_mem_free( pReassocReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07002258
2259 if (psessionEntry)
2260 {
2261 // error occurred after we determined the session so extract
2262 // session and transaction info from there
2263 smeSessionId = psessionEntry->smeSessionId;
2264 transactionId = psessionEntry->transactionId;
2265 }
2266 else
2267 {
2268 // error occurred before or during the time we determined the session
2269 // so extract the session and transaction info from the message
2270 limGetSessionInfo(pMac,(tANI_U8*)pMsgBuf, &smeSessionId, &transactionId);
2271 }
2272
2273 /// Send Reassoc failure response to host
2274 /// (note psessionEntry may be NULL, but that's OK)
2275 limSendSmeJoinReassocRsp(pMac, eWNI_SME_REASSOC_RSP,
2276 retCode, eSIR_MAC_UNSPEC_FAILURE_STATUS,
2277 psessionEntry, smeSessionId, transactionId);
2278
2279} /*** end __limProcessSmeReassocReq() ***/
2280
2281
2282tANI_BOOLEAN sendDisassocFrame = 1;
2283/**
2284 * __limProcessSmeDisassocReq()
2285 *
2286 *FUNCTION:
2287 * This function is called to process SME_DISASSOC_REQ message
2288 * from HDD or upper layer application.
2289 *
2290 *LOGIC:
2291 *
2292 *ASSUMPTIONS:
2293 *
2294 *NOTE:
2295 *
2296 * @param pMac Pointer to Global MAC structure
2297 * @param *pMsgBuf A pointer to the SME message buffer
2298 * @return None
2299 */
2300
2301static void
2302__limProcessSmeDisassocReq(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
2303{
2304 tANI_U16 disassocTrigger, reasonCode;
2305 tLimMlmDisassocReq *pMlmDisassocReq;
2306 tSirResultCodes retCode = eSIR_SME_SUCCESS;
Jeff Johnson43971f52012-07-17 12:26:56 -07002307 tSirRetStatus status;
Jeff Johnson295189b2012-06-20 16:38:30 -07002308 tSirSmeDisassocReq smeDisassocReq;
2309 tpPESession psessionEntry = NULL;
2310 tANI_U8 sessionId;
2311 tANI_U8 smesessionId;
2312 tANI_U16 smetransactionId;
2313
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002314 PELOG1(limLog(pMac, LOG1,FL("received DISASSOC_REQ message"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07002315
Jeff Johnson43971f52012-07-17 12:26:56 -07002316 if (pMsgBuf == NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -07002317 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002318 limLog(pMac, LOGE, FL("Buffer is Pointing to NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002319 return;
2320 }
2321
Jeff Johnson43971f52012-07-17 12:26:56 -07002322 limGetSessionInfo(pMac, (tANI_U8 *)pMsgBuf,&smesessionId, &smetransactionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07002323
Jeff Johnson43971f52012-07-17 12:26:56 -07002324 status = limDisassocReqSerDes(pMac, &smeDisassocReq, (tANI_U8 *) pMsgBuf);
Jeff Johnson295189b2012-06-20 16:38:30 -07002325
Jeff Johnson43971f52012-07-17 12:26:56 -07002326 if ( (eSIR_FAILURE == status) ||
2327 (!limIsSmeDisassocReqValid(pMac, &smeDisassocReq, psessionEntry)) )
Jeff Johnson295189b2012-06-20 16:38:30 -07002328 {
2329 PELOGE(limLog(pMac, LOGE,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002330 FL("received invalid SME_DISASSOC_REQ message"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07002331
2332 if (pMac->lim.gLimRspReqd)
2333 {
2334 pMac->lim.gLimRspReqd = false;
2335
2336 retCode = eSIR_SME_INVALID_PARAMETERS;
2337 disassocTrigger = eLIM_HOST_DISASSOC;
2338 goto sendDisassoc;
2339 }
2340
2341 return;
2342 }
2343
2344
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002345 PELOG1(limLog(pMac, LOG1, FL("received DISASSOC_REQ message. Reason: %d global SmeState: %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002346 smeDisassocReq.reasonCode, pMac->lim.gLimSmeState);)
2347
2348
2349 if((psessionEntry = peFindSessionByBssid(pMac,smeDisassocReq.bssId,&sessionId))== NULL)
2350 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002351 limLog(pMac, LOGE,FL("session does not exist for given bssId"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002352 retCode = eSIR_SME_INVALID_PARAMETERS;
2353 disassocTrigger = eLIM_HOST_DISASSOC;
2354 goto sendDisassoc;
2355
2356 }
2357
2358#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM //FEATURE_WLAN_DIAG_SUPPORT
2359 limDiagEventReport(pMac, WLAN_PE_DIAG_DISASSOC_REQ_EVENT, psessionEntry, 0, smeDisassocReq.reasonCode);
2360#endif //FEATURE_WLAN_DIAG_SUPPORT
2361
2362 /* Update SME session Id and SME transaction ID*/
2363
2364 psessionEntry->smeSessionId = smesessionId;
2365 psessionEntry->transactionId = smetransactionId;
2366
2367 switch (psessionEntry->limSystemRole)
2368 {
2369 case eLIM_STA_ROLE:
2370 case eLIM_BT_AMP_STA_ROLE:
2371 switch (psessionEntry->limSmeState)
2372 {
2373 case eLIM_SME_ASSOCIATED_STATE:
2374 case eLIM_SME_LINK_EST_STATE:
2375 psessionEntry->limPrevSmeState = psessionEntry->limSmeState;
2376 psessionEntry->limSmeState= eLIM_SME_WT_DISASSOC_STATE;
Hoonki Lee8c9e99f2013-04-18 22:59:11 -07002377#ifdef FEATURE_WLAN_TDLS
2378 /* Delete all TDLS peers connected before leaving BSS*/
2379 limDeleteTDLSPeers(pMac, psessionEntry);
2380#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07002381 MTRACE(macTrace(pMac, TRACE_CODE_SME_STATE, psessionEntry->peSessionId, psessionEntry->limSmeState));
Jeff Johnson295189b2012-06-20 16:38:30 -07002382 break;
2383
2384 case eLIM_SME_WT_DEAUTH_STATE:
2385 /* PE shall still process the DISASSOC_REQ and proceed with
2386 * link tear down even if it had already sent a DEAUTH_IND to
2387 * to SME. pMac->lim.gLimPrevSmeState shall remain the same as
2388 * its been set when PE entered WT_DEAUTH_STATE.
2389 */
2390 psessionEntry->limSmeState= eLIM_SME_WT_DISASSOC_STATE;
Jeff Johnsone7245742012-09-05 17:12:55 -07002391 MTRACE(macTrace(pMac, TRACE_CODE_SME_STATE, psessionEntry->peSessionId, psessionEntry->limSmeState));
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002392 limLog(pMac, LOG1, FL("Rcvd SME_DISASSOC_REQ while in SME_WT_DEAUTH_STATE. "));
Jeff Johnson295189b2012-06-20 16:38:30 -07002393 break;
2394
2395 case eLIM_SME_WT_DISASSOC_STATE:
2396 /* PE Recieved a Disassoc frame. Normally it gets DISASSOC_CNF but it
2397 * received DISASSOC_REQ. Which means host is also trying to disconnect.
2398 * PE can continue processing DISASSOC_REQ and send the response instead
2399 * of failing the request. SME will anyway ignore DEAUTH_IND that was sent
2400 * for disassoc frame.
2401 *
2402 * It will send a disassoc, which is ok. However, we can use the global flag
2403 * sendDisassoc to not send disassoc frame.
2404 */
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002405 limLog(pMac, LOG1, FL("Rcvd SME_DISASSOC_REQ while in SME_WT_DISASSOC_STATE. "));
Jeff Johnson295189b2012-06-20 16:38:30 -07002406 break;
2407
2408 case eLIM_SME_JOIN_FAILURE_STATE: {
2409 /** Return Success as we are already in Disconnected State*/
2410 if (pMac->lim.gLimRspReqd) {
2411 retCode = eSIR_SME_SUCCESS;
2412 disassocTrigger = eLIM_HOST_DISASSOC;
2413 goto sendDisassoc;
2414 }
2415 }break;
2416 default:
2417 /**
2418 * STA is not currently associated.
2419 * Log error and send response to host
2420 */
2421 limLog(pMac, LOGE,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002422 FL("received unexpected SME_DISASSOC_REQ in state %X"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002423 psessionEntry->limSmeState);
2424 limPrintSmeState(pMac, LOGE, psessionEntry->limSmeState);
2425
2426 if (pMac->lim.gLimRspReqd)
2427 {
2428 if (psessionEntry->limSmeState !=
2429 eLIM_SME_WT_ASSOC_STATE)
2430 pMac->lim.gLimRspReqd = false;
2431
2432 retCode = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
2433 disassocTrigger = eLIM_HOST_DISASSOC;
2434 goto sendDisassoc;
2435 }
2436
2437 return;
2438 }
2439
2440 break;
2441
2442 case eLIM_AP_ROLE:
2443 case eLIM_BT_AMP_AP_ROLE:
2444 // Fall through
2445 break;
2446
2447 case eLIM_STA_IN_IBSS_ROLE:
2448 default: // eLIM_UNKNOWN_ROLE
2449 limLog(pMac, LOGE,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002450 FL("received unexpected SME_DISASSOC_REQ for role %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002451 psessionEntry->limSystemRole);
2452
2453 retCode = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
2454 disassocTrigger = eLIM_HOST_DISASSOC;
2455 goto sendDisassoc;
2456 } // end switch (pMac->lim.gLimSystemRole)
2457
2458 if (smeDisassocReq.reasonCode == eLIM_LINK_MONITORING_DISASSOC)
2459 {
2460 /// Disassociation is triggered by Link Monitoring
2461 disassocTrigger = eLIM_LINK_MONITORING_DISASSOC;
2462 reasonCode = eSIR_MAC_DISASSOC_DUE_TO_INACTIVITY_REASON;
2463 }
2464 else
2465 {
2466 disassocTrigger = eLIM_HOST_DISASSOC;
2467 reasonCode = smeDisassocReq.reasonCode;
2468 }
2469
2470 if (smeDisassocReq.doNotSendOverTheAir)
2471 {
2472 sendDisassocFrame = 0;
2473 }
2474 // Trigger Disassociation frame to peer MAC entity
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302475
2476 pMlmDisassocReq = vos_mem_malloc(sizeof(tLimMlmDisassocReq));
2477 if ( NULL == pMlmDisassocReq )
Jeff Johnson295189b2012-06-20 16:38:30 -07002478 {
2479 // Log error
2480 limLog(pMac, LOGP,
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302481 FL("call to AllocateMemory failed for mlmDisassocReq"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002482
2483 return;
2484 }
2485
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302486 vos_mem_copy( (tANI_U8 *) &pMlmDisassocReq->peerMacAddr,
Jeff Johnson295189b2012-06-20 16:38:30 -07002487 (tANI_U8 *) &smeDisassocReq.peerMacAddr,
2488 sizeof(tSirMacAddr));
2489
2490 pMlmDisassocReq->reasonCode = reasonCode;
2491 pMlmDisassocReq->disassocTrigger = disassocTrigger;
2492
2493 /* Update PE session ID*/
2494 pMlmDisassocReq->sessionId = sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -07002495
2496 limPostMlmMessage(pMac,
2497 LIM_MLM_DISASSOC_REQ,
2498 (tANI_U32 *) pMlmDisassocReq);
2499 return;
2500
2501sendDisassoc:
2502 if (psessionEntry)
2503 limSendSmeDisassocNtf(pMac, smeDisassocReq.peerMacAddr,
2504 retCode,
2505 disassocTrigger,
Jeff Johnson295189b2012-06-20 16:38:30 -07002506 1,smesessionId,smetransactionId,psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07002507 else
2508 limSendSmeDisassocNtf(pMac, smeDisassocReq.peerMacAddr,
2509 retCode,
2510 disassocTrigger,
Sudhir Sattayappa Kohalli5a8ac222013-03-06 12:41:42 -08002511 1, smesessionId, smetransactionId, NULL);
Jeff Johnson295189b2012-06-20 16:38:30 -07002512
2513
2514} /*** end __limProcessSmeDisassocReq() ***/
2515
2516
2517/** -----------------------------------------------------------------
2518 \brief __limProcessSmeDisassocCnf() - Process SME_DISASSOC_CNF
2519
2520 This function is called to process SME_DISASSOC_CNF message
2521 from HDD or upper layer application.
2522
2523 \param pMac - global mac structure
2524 \param pStaDs - station dph hash node
2525 \return none
2526 \sa
2527 ----------------------------------------------------------------- */
2528static void
2529__limProcessSmeDisassocCnf(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
2530{
2531 tSirSmeDisassocCnf smeDisassocCnf;
2532 tANI_U16 aid;
2533 tpDphHashNode pStaDs;
2534 tSirRetStatus status = eSIR_SUCCESS;
2535 tpPESession psessionEntry;
2536 tANI_U8 sessionId;
2537
2538
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002539 PELOG1(limLog(pMac, LOG1, FL("received DISASSOC_CNF message"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07002540
2541 status = limDisassocCnfSerDes(pMac, &smeDisassocCnf,(tANI_U8 *) pMsgBuf);
2542
2543 if (status == eSIR_FAILURE)
2544 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002545 PELOGE(limLog(pMac, LOGE, FL("invalid SME_DISASSOC_CNF message"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07002546 return;
2547 }
2548
2549 if((psessionEntry = peFindSessionByBssid(pMac, smeDisassocCnf.bssId, &sessionId))== NULL)
2550 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002551 limLog(pMac, LOGE,FL("session does not exist for given bssId"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002552 return;
2553 }
2554
2555 if (!limIsSmeDisassocCnfValid(pMac, &smeDisassocCnf, psessionEntry))
2556 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002557 limLog(pMac, LOGW, FL("received invalid SME_DISASSOC_CNF message"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002558 return;
2559 }
2560
2561#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM //FEATURE_WLAN_DIAG_SUPPORT
2562 if (smeDisassocCnf.messageType == eWNI_SME_DISASSOC_CNF)
2563 limDiagEventReport(pMac, WLAN_PE_DIAG_DISASSOC_CNF_EVENT, psessionEntry, (tANI_U16)smeDisassocCnf.statusCode, 0);
2564 else if (smeDisassocCnf.messageType == eWNI_SME_DEAUTH_CNF)
2565 limDiagEventReport(pMac, WLAN_PE_DIAG_DEAUTH_CNF_EVENT, psessionEntry, (tANI_U16)smeDisassocCnf.statusCode, 0);
2566#endif //FEATURE_WLAN_DIAG_SUPPORT
2567
2568 switch (psessionEntry->limSystemRole)
2569 {
2570 case eLIM_STA_ROLE:
2571 case eLIM_BT_AMP_STA_ROLE: //To test reconn
2572 if ((psessionEntry->limSmeState != eLIM_SME_IDLE_STATE) &&
2573 (psessionEntry->limSmeState != eLIM_SME_WT_DISASSOC_STATE) &&
2574 (psessionEntry->limSmeState != eLIM_SME_WT_DEAUTH_STATE))
2575 {
2576 limLog(pMac, LOGE,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002577 FL("received unexp SME_DISASSOC_CNF in state %X"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002578 psessionEntry->limSmeState);
2579 limPrintSmeState(pMac, LOGE, psessionEntry->limSmeState);
2580 return;
2581 }
2582 break;
2583
2584 case eLIM_AP_ROLE:
2585 // Fall through
Jeff Johnson295189b2012-06-20 16:38:30 -07002586 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07002587
2588 case eLIM_STA_IN_IBSS_ROLE:
2589 default: // eLIM_UNKNOWN_ROLE
2590 limLog(pMac, LOGE,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002591 FL("received unexpected SME_DISASSOC_CNF role %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002592 psessionEntry->limSystemRole);
2593
2594 return;
2595 }
2596
2597
2598 if ( (psessionEntry->limSmeState == eLIM_SME_WT_DISASSOC_STATE) ||
2599 (psessionEntry->limSmeState == eLIM_SME_WT_DEAUTH_STATE)
Jeff Johnson295189b2012-06-20 16:38:30 -07002600 || (psessionEntry->limSystemRole == eLIM_AP_ROLE )
Jeff Johnson295189b2012-06-20 16:38:30 -07002601 )
2602 {
2603 pStaDs = dphLookupHashEntry(pMac, smeDisassocCnf.peerMacAddr, &aid, &psessionEntry->dph.dphHashTable);
2604 if (pStaDs == NULL)
2605 {
2606 PELOGW(limLog(pMac, LOGW, FL("received DISASSOC_CNF for a STA that does not have context, addr= "));
2607 limPrintMacAddr(pMac, smeDisassocCnf.peerMacAddr, LOGW);)
2608 return;
2609 }
Madan Mohan Koyyalamudi23001722012-10-31 16:48:56 -07002610 /* Delete FT session if there exists one */
2611 limFTCleanup(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -07002612 limCleanupRxPath(pMac, pStaDs, psessionEntry);
Madan Mohan Koyyalamudia67d4332012-11-29 11:35:23 -08002613
2614 limCleanUpDisassocDeauthReq(pMac, (char*)&smeDisassocCnf.peerMacAddr, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07002615 }
2616
2617 return;
2618}
2619
2620
2621/**
2622 * __limProcessSmeDeauthReq()
2623 *
2624 *FUNCTION:
2625 * This function is called to process SME_DEAUTH_REQ message
2626 * from HDD or upper layer application.
2627 *
2628 *LOGIC:
2629 *
2630 *ASSUMPTIONS:
2631 *
2632 *NOTE:
2633 *
2634 * @param pMac Pointer to Global MAC structure
2635 * @param *pMsgBuf A pointer to the SME message buffer
2636 * @return None
2637 */
2638
2639static void
2640__limProcessSmeDeauthReq(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
2641{
2642 tANI_U16 deauthTrigger, reasonCode;
2643 tLimMlmDeauthReq *pMlmDeauthReq;
2644 tSirSmeDeauthReq smeDeauthReq;
2645 tSirResultCodes retCode = eSIR_SME_SUCCESS;
2646 tSirRetStatus status = eSIR_SUCCESS;
2647 tpPESession psessionEntry;
2648 tANI_U8 sessionId; //PE sessionId
2649 tANI_U8 smesessionId;
2650 tANI_U16 smetransactionId;
2651
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002652 PELOG1(limLog(pMac, LOG1,FL("received DEAUTH_REQ message"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07002653
2654 status = limDeauthReqSerDes(pMac, &smeDeauthReq,(tANI_U8 *) pMsgBuf);
2655
2656 limGetSessionInfo(pMac,(tANI_U8 *)pMsgBuf,&smesessionId,&smetransactionId);
2657
2658 //We need to get a session first but we don't even know if the message is correct.
2659 if((psessionEntry = peFindSessionByBssid(pMac, smeDeauthReq.bssId, &sessionId)) == NULL)
2660 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002661 limLog(pMac, LOGE,FL("session does not exist for given bssId"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002662 retCode = eSIR_SME_INVALID_PARAMETERS;
2663 deauthTrigger = eLIM_HOST_DEAUTH;
2664 goto sendDeauth;
2665
2666 }
2667
2668 if ((status == eSIR_FAILURE) || (!limIsSmeDeauthReqValid(pMac, &smeDeauthReq, psessionEntry)))
2669 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002670 PELOGE(limLog(pMac, LOGW,FL("received invalid SME_DEAUTH_REQ message"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07002671 if (pMac->lim.gLimRspReqd)
2672 {
2673 pMac->lim.gLimRspReqd = false;
2674
2675 retCode = eSIR_SME_INVALID_PARAMETERS;
2676 deauthTrigger = eLIM_HOST_DEAUTH;
2677 goto sendDeauth;
2678 }
2679
2680 return;
2681 }
2682
2683#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM //FEATURE_WLAN_DIAG_SUPPORT
2684 limDiagEventReport(pMac, WLAN_PE_DIAG_DEAUTH_REQ_EVENT, psessionEntry, 0, smeDeauthReq.reasonCode);
2685#endif //FEATURE_WLAN_DIAG_SUPPORT
2686
2687 /* Update SME session ID and Transaction ID */
2688 psessionEntry->smeSessionId = smesessionId;
2689 psessionEntry->transactionId = smetransactionId;
2690
2691
2692 switch (psessionEntry->limSystemRole)
2693 {
2694 case eLIM_STA_ROLE:
2695 case eLIM_BT_AMP_STA_ROLE:
2696
2697 switch (psessionEntry->limSmeState)
2698 {
2699 case eLIM_SME_ASSOCIATED_STATE:
2700 case eLIM_SME_LINK_EST_STATE:
2701 case eLIM_SME_WT_ASSOC_STATE:
2702 case eLIM_SME_JOIN_FAILURE_STATE:
2703 case eLIM_SME_IDLE_STATE:
2704 psessionEntry->limPrevSmeState = psessionEntry->limSmeState;
2705 psessionEntry->limSmeState = eLIM_SME_WT_DEAUTH_STATE;
Varun Reddy Yeturue3bbf6e2013-02-08 18:50:55 -08002706 MTRACE(macTrace(pMac, TRACE_CODE_SME_STATE, psessionEntry->peSessionId, psessionEntry->limSmeState));
Jeff Johnson295189b2012-06-20 16:38:30 -07002707
2708 // Send Deauthentication request to MLM below
2709
2710 break;
2711
2712 default:
2713 /**
2714 * STA is not in a state to deauthenticate with
2715 * peer. Log error and send response to host.
2716 */
2717 limLog(pMac, LOGE,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002718 FL("received unexp SME_DEAUTH_REQ in state %X"),psessionEntry->limSmeState);
Jeff Johnson295189b2012-06-20 16:38:30 -07002719 limPrintSmeState(pMac, LOGE, psessionEntry->limSmeState);
2720
2721 if (pMac->lim.gLimRspReqd)
2722 {
2723 pMac->lim.gLimRspReqd = false;
2724
2725 retCode = eSIR_SME_STA_NOT_AUTHENTICATED;
2726 deauthTrigger = eLIM_HOST_DEAUTH;
2727 goto sendDeauth;
2728 }
2729
2730 return;
2731 }
2732
2733 break;
2734
2735 case eLIM_STA_IN_IBSS_ROLE:
2736
2737 return;
2738
2739 case eLIM_AP_ROLE:
2740 // Fall through
2741
2742 break;
2743
2744 default:
2745 limLog(pMac, LOGE,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002746 FL("received unexpected SME_DEAUTH_REQ for role %X"),psessionEntry->limSystemRole);
Jeff Johnson295189b2012-06-20 16:38:30 -07002747
2748 return;
2749 } // end switch (pMac->lim.gLimSystemRole)
2750
2751 if (smeDeauthReq.reasonCode == eLIM_LINK_MONITORING_DEAUTH)
2752 {
2753 /// Deauthentication is triggered by Link Monitoring
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002754 PELOG1(limLog(pMac, LOG1, FL("**** Lost link with AP ****"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07002755 deauthTrigger = eLIM_LINK_MONITORING_DEAUTH;
2756 reasonCode = eSIR_MAC_UNSPEC_FAILURE_REASON;
2757 }
2758 else
2759 {
2760 deauthTrigger = eLIM_HOST_DEAUTH;
2761 reasonCode = smeDeauthReq.reasonCode;
2762 }
2763
2764 // Trigger Deauthentication frame to peer MAC entity
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302765 pMlmDeauthReq = vos_mem_malloc(sizeof(tLimMlmDeauthReq));
2766 if ( NULL == pMlmDeauthReq )
Jeff Johnson295189b2012-06-20 16:38:30 -07002767 {
2768 // Log error
2769 limLog(pMac, LOGP,
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302770 FL("call to AllocateMemory failed for mlmDeauthReq"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002771
2772 return;
2773 }
2774
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302775 vos_mem_copy( (tANI_U8 *) &pMlmDeauthReq->peerMacAddr,
Jeff Johnson295189b2012-06-20 16:38:30 -07002776 (tANI_U8 *) &smeDeauthReq.peerMacAddr,
2777 sizeof(tSirMacAddr));
2778
2779 pMlmDeauthReq->reasonCode = reasonCode;
2780 pMlmDeauthReq->deauthTrigger = deauthTrigger;
Jeff Johnson295189b2012-06-20 16:38:30 -07002781
2782 /* Update PE session Id*/
2783 pMlmDeauthReq->sessionId = sessionId;
2784
2785 limPostMlmMessage(pMac,
2786 LIM_MLM_DEAUTH_REQ,
2787 (tANI_U32 *) pMlmDeauthReq);
2788 return;
2789
2790sendDeauth:
2791 limSendSmeDeauthNtf(pMac, smeDeauthReq.peerMacAddr,
2792 retCode,
2793 deauthTrigger,
Jeff Johnson295189b2012-06-20 16:38:30 -07002794 1,
Jeff Johnson295189b2012-06-20 16:38:30 -07002795 smesessionId, smetransactionId);
2796} /*** end __limProcessSmeDeauthReq() ***/
2797
2798
2799
2800/**
2801 * __limProcessSmeSetContextReq()
2802 *
2803 *FUNCTION:
2804 * This function is called to process SME_SETCONTEXT_REQ message
2805 * from HDD or upper layer application.
2806 *
2807 *LOGIC:
2808 *
2809 *ASSUMPTIONS:
2810 *
2811 *NOTE:
2812 *
2813 * @param pMac Pointer to Global MAC structure
2814 * @param *pMsgBuf A pointer to the SME message buffer
2815 * @return None
2816 */
2817
2818static void
2819__limProcessSmeSetContextReq(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
2820{
2821 tpSirSmeSetContextReq pSetContextReq;
2822 tLimMlmSetKeysReq *pMlmSetKeysReq;
2823 tpPESession psessionEntry;
2824 tANI_U8 sessionId; //PE sessionID
2825 tANI_U8 smesessionId;
2826 tANI_U16 smetransactionId;
2827
2828
2829 PELOG1(limLog(pMac, LOG1,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002830 FL("received SETCONTEXT_REQ message")););
Jeff Johnson295189b2012-06-20 16:38:30 -07002831
2832
2833 if(pMsgBuf == NULL)
2834 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002835 limLog(pMac, LOGE,FL("Buffer is Pointing to NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002836 return;
2837 }
2838
2839 limGetSessionInfo(pMac,(tANI_U8 *)pMsgBuf,&smesessionId,&smetransactionId);
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302840
2841 pSetContextReq = vos_mem_malloc(sizeof(tSirKeys) * SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS);
2842 if ( NULL == pSetContextReq )
Jeff Johnson295189b2012-06-20 16:38:30 -07002843 {
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302844 limLog(pMac, LOGP, FL("call to AllocateMemory failed for pSetContextReq"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002845 return;
2846 }
2847
2848 if ((limSetContextReqSerDes(pMac, pSetContextReq, (tANI_U8 *) pMsgBuf) == eSIR_FAILURE) ||
2849 (!limIsSmeSetContextReqValid(pMac, pSetContextReq)))
2850 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002851 limLog(pMac, LOGW, FL("received invalid SME_SETCONTEXT_REQ message"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002852 goto end;
2853 }
2854
2855 if(pSetContextReq->keyMaterial.numKeys > SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS)
2856 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002857 PELOGE(limLog(pMac, LOGE, FL("numKeys:%d is more than SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS"), pSetContextReq->keyMaterial.numKeys);)
Jeff Johnson295189b2012-06-20 16:38:30 -07002858 limSendSmeSetContextRsp(pMac,
2859 pSetContextReq->peerMacAddr,
Jeff Johnson295189b2012-06-20 16:38:30 -07002860 1,
Jeff Johnson295189b2012-06-20 16:38:30 -07002861 eSIR_SME_INVALID_PARAMETERS,NULL,
2862 smesessionId,smetransactionId);
2863
2864 goto end;
2865 }
2866
2867
2868 if((psessionEntry = peFindSessionByBssid(pMac, pSetContextReq->bssId, &sessionId)) == NULL)
2869 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002870 limLog(pMac, LOGW, FL("Session does not exist for given BSSID"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002871 limSendSmeSetContextRsp(pMac,
2872 pSetContextReq->peerMacAddr,
Jeff Johnson295189b2012-06-20 16:38:30 -07002873 1,
Jeff Johnson295189b2012-06-20 16:38:30 -07002874 eSIR_SME_INVALID_PARAMETERS,NULL,
2875 smesessionId,smetransactionId);
2876
2877 goto end;
2878 }
2879
2880#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM //FEATURE_WLAN_DIAG_SUPPORT
2881 limDiagEventReport(pMac, WLAN_PE_DIAG_SETCONTEXT_REQ_EVENT, psessionEntry, 0, 0);
2882#endif //FEATURE_WLAN_DIAG_SUPPORT
2883
2884
2885 if ((((psessionEntry->limSystemRole == eLIM_STA_ROLE) || (psessionEntry->limSystemRole == eLIM_BT_AMP_STA_ROLE)) &&
2886 (psessionEntry->limSmeState == eLIM_SME_LINK_EST_STATE)) ||
2887 (((psessionEntry->limSystemRole == eLIM_STA_IN_IBSS_ROLE) ||
2888 (psessionEntry->limSystemRole == eLIM_AP_ROLE)|| (psessionEntry->limSystemRole == eLIM_BT_AMP_AP_ROLE)) &&
2889 (psessionEntry->limSmeState == eLIM_SME_NORMAL_STATE)))
2890 {
2891 // Trigger MLM_SETKEYS_REQ
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302892 pMlmSetKeysReq = vos_mem_malloc(sizeof(tLimMlmSetKeysReq));
2893 if ( NULL == pMlmSetKeysReq )
Jeff Johnson295189b2012-06-20 16:38:30 -07002894 {
2895 // Log error
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302896 limLog(pMac, LOGP, FL("call to AllocateMemory failed for mlmSetKeysReq"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002897 goto end;
2898 }
2899
2900 pMlmSetKeysReq->edType = pSetContextReq->keyMaterial.edType;
2901 pMlmSetKeysReq->numKeys = pSetContextReq->keyMaterial.numKeys;
2902 if(pMlmSetKeysReq->numKeys > SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS)
2903 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002904 limLog(pMac, LOGP, FL("Num of keys exceeded max num of default keys limit"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002905 goto end;
2906 }
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302907 vos_mem_copy( (tANI_U8 *) &pMlmSetKeysReq->peerMacAddr,
Jeff Johnson295189b2012-06-20 16:38:30 -07002908 (tANI_U8 *) &pSetContextReq->peerMacAddr,
2909 sizeof(tSirMacAddr));
2910
Jeff Johnson295189b2012-06-20 16:38:30 -07002911
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302912 vos_mem_copy( (tANI_U8 *) &pMlmSetKeysReq->key,
Jeff Johnson295189b2012-06-20 16:38:30 -07002913 (tANI_U8 *) &pSetContextReq->keyMaterial.key,
2914 sizeof(tSirKeys) * (pMlmSetKeysReq->numKeys ? pMlmSetKeysReq->numKeys : 1));
2915
2916 pMlmSetKeysReq->sessionId = sessionId;
2917#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
2918 PELOG1(limLog(pMac, LOG1,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002919 FL("received SETCONTEXT_REQ message sessionId=%d"), pMlmSetKeysReq->sessionId););
Jeff Johnson295189b2012-06-20 16:38:30 -07002920#endif
2921
Jeff Johnson295189b2012-06-20 16:38:30 -07002922 if(((pSetContextReq->keyMaterial.edType == eSIR_ED_WEP40) || (pSetContextReq->keyMaterial.edType == eSIR_ED_WEP104))
2923 && (psessionEntry->limSystemRole == eLIM_AP_ROLE))
2924 {
2925 if(pSetContextReq->keyMaterial.key[0].keyLength)
2926 {
2927 tANI_U8 keyId;
2928 keyId = pSetContextReq->keyMaterial.key[0].keyId;
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302929 vos_mem_copy( (tANI_U8 *)&psessionEntry->WEPKeyMaterial[keyId],
Jeff Johnson295189b2012-06-20 16:38:30 -07002930 (tANI_U8 *) &pSetContextReq->keyMaterial, sizeof(tSirKeyMaterial));
2931 }
2932 else {
2933 tANI_U32 i;
2934 for( i = 0; i < SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS; i++)
2935 {
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302936 vos_mem_copy( (tANI_U8 *) &pMlmSetKeysReq->key[i],
Jeff Johnson295189b2012-06-20 16:38:30 -07002937 (tANI_U8 *)psessionEntry->WEPKeyMaterial[i].key, sizeof(tSirKeys));
2938 }
2939 }
2940 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002941
2942 limPostMlmMessage(pMac, LIM_MLM_SETKEYS_REQ, (tANI_U32 *) pMlmSetKeysReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07002943 }
2944 else
2945 {
2946 limLog(pMac, LOGE,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002947 FL("received unexpected SME_SETCONTEXT_REQ for role %d, state=%X"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002948 psessionEntry->limSystemRole,
2949 psessionEntry->limSmeState);
2950 limPrintSmeState(pMac, LOGE, psessionEntry->limSmeState);
2951
2952 limSendSmeSetContextRsp(pMac, pSetContextReq->peerMacAddr,
Jeff Johnson295189b2012-06-20 16:38:30 -07002953 1,
Jeff Johnson295189b2012-06-20 16:38:30 -07002954 eSIR_SME_UNEXPECTED_REQ_RESULT_CODE,psessionEntry,
2955 smesessionId,
2956 smetransactionId);
2957 }
2958
2959end:
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302960 vos_mem_free( pSetContextReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07002961 return;
2962} /*** end __limProcessSmeSetContextReq() ***/
2963
2964/**
2965 * __limProcessSmeRemoveKeyReq()
2966 *
2967 *FUNCTION:
2968 * This function is called to process SME_REMOVEKEY_REQ message
2969 * from HDD or upper layer application.
2970 *
2971 *LOGIC:
2972 *
2973 *ASSUMPTIONS:
2974 *
2975 *NOTE:
2976 *
2977 * @param pMac Pointer to Global MAC structure
2978 * @param *pMsgBuf A pointer to the SME message buffer
2979 * @return None
2980 */
2981
2982static void
2983__limProcessSmeRemoveKeyReq(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
2984{
2985 tpSirSmeRemoveKeyReq pRemoveKeyReq;
2986 tLimMlmRemoveKeyReq *pMlmRemoveKeyReq;
2987 tpPESession psessionEntry;
2988 tANI_U8 sessionId; //PE sessionID
2989 tANI_U8 smesessionId;
2990 tANI_U16 smetransactionId;
2991
2992 PELOG1(limLog(pMac, LOG1,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002993 FL("received REMOVEKEY_REQ message"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07002994
2995 if(pMsgBuf == NULL)
2996 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002997 limLog(pMac, LOGE,FL("Buffer is Pointing to NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002998 return;
2999 }
3000
3001
3002 limGetSessionInfo(pMac,(tANI_U8 *)pMsgBuf,&smesessionId,&smetransactionId);
3003
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303004 pRemoveKeyReq = vos_mem_malloc(sizeof(*pRemoveKeyReq));
3005 if ( NULL == pRemoveKeyReq )
Jeff Johnson295189b2012-06-20 16:38:30 -07003006 {
3007 //Log error
3008 limLog(pMac, LOGP,
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303009 FL("call to AllocateMemory failed for pRemoveKeyReq"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003010
3011 return;
3012 }
3013
3014 if ((limRemoveKeyReqSerDes(pMac,
3015 pRemoveKeyReq,
3016 (tANI_U8 *) pMsgBuf) == eSIR_FAILURE))
3017 {
3018 limLog(pMac, LOGW,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003019 FL("received invalid SME_REMOVECONTEXT_REQ message"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003020
3021 /* extra look up is needed since, session entry to be passed il limsendremovekey response */
3022
3023 if((psessionEntry = peFindSessionByBssid(pMac,pRemoveKeyReq->bssId,&sessionId))== NULL)
3024 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003025 limLog(pMac, LOGE,FL("session does not exist for given bssId"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003026 //goto end;
3027 }
3028
3029 limSendSmeRemoveKeyRsp(pMac,
3030 pRemoveKeyReq->peerMacAddr,
3031 eSIR_SME_INVALID_PARAMETERS,psessionEntry,
3032 smesessionId,smetransactionId);
3033
3034 goto end;
3035 }
3036
3037 if((psessionEntry = peFindSessionByBssid(pMac,pRemoveKeyReq->bssId, &sessionId))== NULL)
3038 {
3039 limLog(pMac, LOGE,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003040 FL("session does not exist for given bssId"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003041 limSendSmeRemoveKeyRsp(pMac,
3042 pRemoveKeyReq->peerMacAddr,
3043 eSIR_SME_UNEXPECTED_REQ_RESULT_CODE, NULL,
3044 smesessionId, smetransactionId);
3045 goto end;
3046 }
3047
3048
3049 if ((((psessionEntry->limSystemRole == eLIM_STA_ROLE)|| (psessionEntry->limSystemRole == eLIM_BT_AMP_STA_ROLE))&&
3050 (psessionEntry->limSmeState == eLIM_SME_LINK_EST_STATE)) ||
3051 (((psessionEntry->limSystemRole == eLIM_STA_IN_IBSS_ROLE) ||
3052 (psessionEntry->limSystemRole == eLIM_AP_ROLE)|| (psessionEntry->limSystemRole == eLIM_BT_AMP_AP_ROLE)) &&
3053 (psessionEntry->limSmeState == eLIM_SME_NORMAL_STATE)))
3054 {
3055 // Trigger MLM_REMOVEKEYS_REQ
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303056 pMlmRemoveKeyReq = vos_mem_malloc(sizeof(tLimMlmRemoveKeyReq));
3057 if ( NULL == pMlmRemoveKeyReq )
Jeff Johnson295189b2012-06-20 16:38:30 -07003058 {
3059 // Log error
3060 limLog(pMac, LOGP,
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303061 FL("call to AllocateMemory failed for mlmRemoveKeysReq"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003062
3063 goto end;
3064 }
3065
3066 pMlmRemoveKeyReq->edType = (tAniEdType)pRemoveKeyReq->edType;
3067 pMlmRemoveKeyReq->keyId = pRemoveKeyReq->keyId;
3068 pMlmRemoveKeyReq->wepType = pRemoveKeyReq->wepType;
3069 pMlmRemoveKeyReq->unicast = pRemoveKeyReq->unicast;
3070
3071 /* Update PE session Id */
3072 pMlmRemoveKeyReq->sessionId = sessionId;
3073
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303074 vos_mem_copy( (tANI_U8 *) &pMlmRemoveKeyReq->peerMacAddr,
Jeff Johnson295189b2012-06-20 16:38:30 -07003075 (tANI_U8 *) &pRemoveKeyReq->peerMacAddr,
3076 sizeof(tSirMacAddr));
3077
3078
3079 limPostMlmMessage(pMac,
3080 LIM_MLM_REMOVEKEY_REQ,
3081 (tANI_U32 *) pMlmRemoveKeyReq);
3082 }
3083 else
3084 {
3085 limLog(pMac, LOGE,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003086 FL("received unexpected SME_REMOVEKEY_REQ for role %d, state=%X"),
Jeff Johnson295189b2012-06-20 16:38:30 -07003087 psessionEntry->limSystemRole,
3088 psessionEntry->limSmeState);
3089 limPrintSmeState(pMac, LOGE, psessionEntry->limSmeState);
3090
3091 limSendSmeRemoveKeyRsp(pMac,
3092 pRemoveKeyReq->peerMacAddr,
3093 eSIR_SME_UNEXPECTED_REQ_RESULT_CODE,psessionEntry,
3094 smesessionId,smetransactionId);
3095 }
3096
3097end:
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303098 vos_mem_free( pRemoveKeyReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07003099} /*** end __limProcessSmeRemoveKeyReq() ***/
3100
Jeff Johnson295189b2012-06-20 16:38:30 -07003101void limProcessSmeGetScanChannelInfo(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
3102{
3103 tSirMsgQ mmhMsg;
3104 tpSmeGetScanChnRsp pSirSmeRsp;
3105 tANI_U16 len = 0;
Madan Mohan Koyyalamudide1b5bc2013-07-12 00:56:04 +05303106 tANI_U8 sessionId;
3107 tANI_U16 transactionId;
Jeff Johnson295189b2012-06-20 16:38:30 -07003108
3109 if(pMac->lim.scanChnInfo.numChnInfo > SIR_MAX_SUPPORTED_CHANNEL_LIST)
3110 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003111 limLog(pMac, LOGW, FL("numChn is out of bounds %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07003112 pMac->lim.scanChnInfo.numChnInfo);
3113 pMac->lim.scanChnInfo.numChnInfo = SIR_MAX_SUPPORTED_CHANNEL_LIST;
3114 }
3115
3116 PELOG2(limLog(pMac, LOG2,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003117 FL("Sending message %s with number of channels %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07003118 limMsgStr(eWNI_SME_GET_SCANNED_CHANNEL_RSP), pMac->lim.scanChnInfo.numChnInfo);)
3119
3120 len = sizeof(tSmeGetScanChnRsp) + (pMac->lim.scanChnInfo.numChnInfo - 1) * sizeof(tLimScanChn);
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303121 pSirSmeRsp = vos_mem_malloc(len);
3122 if ( NULL == pSirSmeRsp )
Jeff Johnson295189b2012-06-20 16:38:30 -07003123 {
3124 /// Buffer not available. Log error
3125 limLog(pMac, LOGP,
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303126 FL("call to AllocateMemory failed for JOIN/REASSOC_RSP"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003127
3128 return;
3129 }
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303130 vos_mem_set(pSirSmeRsp, len, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07003131
Jeff Johnson295189b2012-06-20 16:38:30 -07003132 pSirSmeRsp->mesgType = eWNI_SME_GET_SCANNED_CHANNEL_RSP;
3133 pSirSmeRsp->mesgLen = len;
Madan Mohan Koyyalamudide1b5bc2013-07-12 00:56:04 +05303134
3135 if (pMac->fScanOffload)
3136 {
3137 limGetSessionInfo(pMac,(tANI_U8 *)pMsgBuf,&sessionId,&transactionId);
3138 pSirSmeRsp->sessionId = sessionId;
3139 }
3140 else
3141 pSirSmeRsp->sessionId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003142
3143 if(pMac->lim.scanChnInfo.numChnInfo)
3144 {
3145 pSirSmeRsp->numChn = pMac->lim.scanChnInfo.numChnInfo;
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303146 vos_mem_copy( pSirSmeRsp->scanChn, pMac->lim.scanChnInfo.scanChn,
3147 sizeof(tLimScanChn) * pSirSmeRsp->numChn);
Jeff Johnson295189b2012-06-20 16:38:30 -07003148 }
3149 //Clear the list
3150 limRessetScanChannelInfo(pMac);
3151
3152 mmhMsg.type = eWNI_SME_GET_SCANNED_CHANNEL_RSP;
3153 mmhMsg.bodyptr = pSirSmeRsp;
3154 mmhMsg.bodyval = 0;
3155
3156 pMac->lim.gLimRspReqd = false;
Jeff Johnsone7245742012-09-05 17:12:55 -07003157 MTRACE(macTraceMsgTx(pMac, NO_SESSION, mmhMsg.type));
Jeff Johnson295189b2012-06-20 16:38:30 -07003158 limSysProcessMmhMsgApi(pMac, &mmhMsg, ePROT);
3159}
3160
3161
Jeff Johnson295189b2012-06-20 16:38:30 -07003162void limProcessSmeGetAssocSTAsInfo(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
3163{
3164 tSirSmeGetAssocSTAsReq getAssocSTAsReq;
3165 tpDphHashNode pStaDs = NULL;
3166 tpPESession psessionEntry = NULL;
3167 tSap_Event sapEvent;
3168 tpWLAN_SAPEventCB pSapEventCallback = NULL;
3169 tpSap_AssocMacAddr pAssocStasTemp = NULL;// #include "sapApi.h"
3170 tANI_U8 sessionId = CSR_SESSION_ID_INVALID;
3171 tANI_U8 assocId = 0;
3172 tANI_U8 staCount = 0;
3173
3174 if (!limIsSmeGetAssocSTAsReqValid(pMac, &getAssocSTAsReq, (tANI_U8 *) pMsgBuf))
3175 {
3176 limLog(pMac, LOGE,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003177 FL("received invalid eWNI_SME_GET_ASSOC_STAS_REQ message"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003178 goto limAssocStaEnd;
3179 }
3180
3181 switch (getAssocSTAsReq.modId)
3182 {
3183/**
3184 case VOS_MODULE_ID_HAL:
3185 wdaPostCtrlMsg( pMac, &msgQ );
3186 return;
3187
3188 case VOS_MODULE_ID_TL:
3189 Post msg TL
3190 return;
3191*/
3192 case VOS_MODULE_ID_PE:
3193 default:
3194 break;
3195 }
3196
Jeff Johnson1250df42012-12-10 14:31:52 -08003197 // Get Associated stations from PE
Jeff Johnson295189b2012-06-20 16:38:30 -07003198 // Find PE session Entry
3199 if ((psessionEntry = peFindSessionByBssid(pMac, getAssocSTAsReq.bssId, &sessionId)) == NULL)
3200 {
3201 limLog(pMac, LOGE,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003202 FL("session does not exist for given bssId"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003203 goto limAssocStaEnd;
3204 }
3205
3206 if (psessionEntry->limSystemRole != eLIM_AP_ROLE)
3207 {
3208 limLog(pMac, LOGE,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003209 FL("Received unexpected message in state %X, in role %X"),
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303210 psessionEntry->limSmeState, psessionEntry->limSystemRole);
Jeff Johnson295189b2012-06-20 16:38:30 -07003211 goto limAssocStaEnd;
3212 }
3213
3214 // Retrieve values obtained in the request message
3215 pSapEventCallback = (tpWLAN_SAPEventCB)getAssocSTAsReq.pSapEventCallback;
3216 pAssocStasTemp = (tpSap_AssocMacAddr)getAssocSTAsReq.pAssocStasArray;
3217
3218 for (assocId = 0; assocId < psessionEntry->dph.dphHashTable.size; assocId++)// Softap dphHashTable.size = 8
3219 {
3220 pStaDs = dphGetHashEntry(pMac, assocId, &psessionEntry->dph.dphHashTable);
3221
3222 if (NULL == pStaDs)
3223 continue;
3224
3225 if (pStaDs->valid)
3226 {
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303227 vos_mem_copy((tANI_U8 *)&pAssocStasTemp->staMac,
3228 (tANI_U8 *)&pStaDs->staAddr,
3229 sizeof(v_MACADDR_t)); // Mac address
Jeff Johnson295189b2012-06-20 16:38:30 -07003230 pAssocStasTemp->assocId = (v_U8_t)pStaDs->assocId; // Association Id
3231 pAssocStasTemp->staId = (v_U8_t)pStaDs->staIndex; // Station Id
3232
Leo Chang614d2072013-08-22 14:59:44 -07003233 palCopyMemory(pMac->hHdd, (tANI_U8 *)&pAssocStasTemp->supportedRates,
3234 (tANI_U8 *)&pStaDs->supportedRates,
3235 sizeof(tSirSupportedRates));
3236 pAssocStasTemp->ShortGI40Mhz = pStaDs->htShortGI40Mhz;
3237 pAssocStasTemp->ShortGI20Mhz = pStaDs->htShortGI20Mhz;
3238 pAssocStasTemp->Support40Mhz = pStaDs->htDsssCckRate40MHzSupport;
3239
Jeff Johnson295189b2012-06-20 16:38:30 -07003240 limLog(pMac, LOG1, FL("dph Station Number = %d"), staCount+1);
3241 limLog(pMac, LOG1, FL("MAC = %02x:%02x:%02x:%02x:%02x:%02x"),
3242 pStaDs->staAddr[0],
3243 pStaDs->staAddr[1],
3244 pStaDs->staAddr[2],
3245 pStaDs->staAddr[3],
3246 pStaDs->staAddr[4],
3247 pStaDs->staAddr[5]);
3248 limLog(pMac, LOG1, FL("Association Id = %d"),pStaDs->assocId);
3249 limLog(pMac, LOG1, FL("Station Index = %d"),pStaDs->staIndex);
3250
3251 pAssocStasTemp++;
3252 staCount++;
3253 }
3254 }
3255
3256limAssocStaEnd:
3257 // Call hdd callback with sap event to send the list of associated stations from PE
3258 if (pSapEventCallback != NULL)
3259 {
3260 sapEvent.sapHddEventCode = eSAP_ASSOC_STA_CALLBACK_EVENT;
3261 sapEvent.sapevt.sapAssocStaListEvent.module = VOS_MODULE_ID_PE;
3262 sapEvent.sapevt.sapAssocStaListEvent.noOfAssocSta = staCount;
3263 sapEvent.sapevt.sapAssocStaListEvent.pAssocStas = (tpSap_AssocMacAddr)getAssocSTAsReq.pAssocStasArray;
3264 pSapEventCallback(&sapEvent, getAssocSTAsReq.pUsrContext);
3265 }
3266}
3267
3268
3269/**
3270 * limProcessSmeGetWPSPBCSessions
3271 *
3272 *FUNCTION:
3273 * This function is called when query the WPS PBC overlap message is received
3274 *
3275 *LOGIC:
3276 * This function parses get WPS PBC overlap information message and call callback to pass
3277 * WPS PBC overlap information back to hdd.
3278 *ASSUMPTIONS:
3279 *
3280 *
3281 *NOTE:
3282 *
3283 * @param pMac Pointer to Global MAC structure
3284 * @param pMsgBuf A pointer to WPS PBC overlap query message
3285*
3286 * @return None
3287 */
3288void limProcessSmeGetWPSPBCSessions(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
3289{
3290 tSirSmeGetWPSPBCSessionsReq GetWPSPBCSessionsReq;
3291 tpPESession psessionEntry = NULL;
3292 tSap_Event sapEvent;
3293 tpWLAN_SAPEventCB pSapEventCallback = NULL;
3294 tANI_U8 sessionId = CSR_SESSION_ID_INVALID;
3295 tSirMacAddr zeroMac = {0,0,0,0,0,0};
3296
3297 sapEvent.sapevt.sapGetWPSPBCSessionEvent.status = VOS_STATUS_E_FAULT;
3298
3299 if (limIsSmeGetWPSPBCSessionsReqValid(pMac, &GetWPSPBCSessionsReq, (tANI_U8 *) pMsgBuf) != eSIR_SUCCESS)
3300 {
3301 limLog(pMac, LOGE,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003302 FL("received invalid eWNI_SME_GET_ASSOC_STAS_REQ message"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003303 goto limGetWPSPBCSessionsEnd;
3304 }
3305
Jeff Johnson1250df42012-12-10 14:31:52 -08003306 // Get Associated stations from PE
Jeff Johnson295189b2012-06-20 16:38:30 -07003307 // Find PE session Entry
3308 if ((psessionEntry = peFindSessionByBssid(pMac, GetWPSPBCSessionsReq.bssId, &sessionId)) == NULL)
3309 {
3310 limLog(pMac, LOGE,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003311 FL("session does not exist for given bssId"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003312 goto limGetWPSPBCSessionsEnd;
3313 }
3314
3315 if (psessionEntry->limSystemRole != eLIM_AP_ROLE)
3316 {
3317 limLog(pMac, LOGE,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003318 FL("Received unexpected message in role %X"),
Jeff Johnson295189b2012-06-20 16:38:30 -07003319 psessionEntry->limSystemRole);
3320 goto limGetWPSPBCSessionsEnd;
3321 }
3322
Jeff Johnson1250df42012-12-10 14:31:52 -08003323 // Call hdd callback with sap event to send the WPS PBC overlap information
Jeff Johnson295189b2012-06-20 16:38:30 -07003324 sapEvent.sapHddEventCode = eSAP_GET_WPSPBC_SESSION_EVENT;
3325 sapEvent.sapevt.sapGetWPSPBCSessionEvent.module = VOS_MODULE_ID_PE;
3326
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303327 if (vos_mem_compare( zeroMac, GetWPSPBCSessionsReq.pRemoveMac, sizeof(tSirMacAddr)))
Jeff Johnson295189b2012-06-20 16:38:30 -07003328 { //This is GetWpsSession call
3329
3330 limGetWPSPBCSessions(pMac,
3331 sapEvent.sapevt.sapGetWPSPBCSessionEvent.addr.bytes, sapEvent.sapevt.sapGetWPSPBCSessionEvent.UUID_E,
3332 &sapEvent.sapevt.sapGetWPSPBCSessionEvent.wpsPBCOverlap, psessionEntry);
3333 }
3334 else
3335 {
3336 limRemovePBCSessions(pMac, GetWPSPBCSessionsReq.pRemoveMac,psessionEntry);
3337 /* don't have to inform the HDD/Host */
3338 return;
3339 }
3340
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003341 PELOG4(limLog(pMac, LOGE, FL("wpsPBCOverlap %d"), sapEvent.sapevt.sapGetWPSPBCSessionEvent.wpsPBCOverlap);)
Jeff Johnson295189b2012-06-20 16:38:30 -07003342 PELOG4(limPrintMacAddr(pMac, sapEvent.sapevt.sapGetWPSPBCSessionEvent.addr.bytes, LOG4);)
3343
3344 sapEvent.sapevt.sapGetWPSPBCSessionEvent.status = VOS_STATUS_SUCCESS;
3345
3346limGetWPSPBCSessionsEnd:
3347 pSapEventCallback = (tpWLAN_SAPEventCB)GetWPSPBCSessionsReq.pSapEventCallback;
3348 pSapEventCallback(&sapEvent, GetWPSPBCSessionsReq.pUsrContext);
3349}
3350
Jeff Johnson295189b2012-06-20 16:38:30 -07003351
3352
3353/**
3354 * __limCounterMeasures()
3355 *
3356 * FUNCTION:
3357 * This function is called to "implement" MIC counter measure
3358 * and is *temporary* only
3359 *
3360 * LOGIC: on AP, disassoc all STA associated thru TKIP,
3361 * we don't do the proper STA disassoc sequence since the
3362 * BSS will be stoped anyway
3363 *
3364 *ASSUMPTIONS:
3365 *
3366 *NOTE:
3367 *
3368 * @param pMac Pointer to Global MAC structure
3369 * @return None
3370 */
3371
3372static void
3373__limCounterMeasures(tpAniSirGlobal pMac, tpPESession psessionEntry)
3374{
3375 tSirMacAddr mac = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
3376 if ( (psessionEntry->limSystemRole == eLIM_AP_ROLE) || (psessionEntry->limSystemRole == eLIM_BT_AMP_AP_ROLE)
3377 || (psessionEntry->limSystemRole == eLIM_BT_AMP_STA_ROLE) )
3378
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003379 limSendDisassocMgmtFrame(pMac, eSIR_MAC_MIC_FAILURE_REASON, mac, psessionEntry, FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003380
Jeff Johnson295189b2012-06-20 16:38:30 -07003381};
3382
3383
Jeff Johnson295189b2012-06-20 16:38:30 -07003384void
3385limProcessTkipCounterMeasures(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
3386{
3387 tSirSmeTkipCntrMeasReq tkipCntrMeasReq;
3388 tpPESession psessionEntry;
3389 tANI_U8 sessionId; //PE sessionId
3390
3391 if ( limTkipCntrMeasReqSerDes( pMac, &tkipCntrMeasReq, (tANI_U8 *) pMsgBuf ) != eSIR_SUCCESS )
3392 {
3393 limLog(pMac, LOGE,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003394 FL("received invalid eWNI_SME_TKIP_CNTR_MEAS_REQ message"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003395 return;
3396 }
3397
3398 if ( NULL == (psessionEntry = peFindSessionByBssid( pMac, tkipCntrMeasReq.bssId, &sessionId )) )
3399 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003400 limLog(pMac, LOGE, FL("session does not exist for given BSSID "));
Jeff Johnson295189b2012-06-20 16:38:30 -07003401 return;
3402 }
3403
3404 if ( tkipCntrMeasReq.bEnable )
3405 {
3406 __limCounterMeasures( pMac, psessionEntry );
3407 }
3408
3409 psessionEntry->bTkipCntrMeasActive = tkipCntrMeasReq.bEnable;
3410}
Jeff Johnson295189b2012-06-20 16:38:30 -07003411
3412
3413static void
3414__limHandleSmeStopBssRequest(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
3415{
3416 tSirSmeStopBssReq stopBssReq;
3417 tSirRetStatus status;
3418 tLimSmeStates prevState;
3419 tANI_U8 sessionId; //PE sessionId
3420 tpPESession psessionEntry;
3421 tANI_U8 smesessionId;
3422 tANI_U16 smetransactionId;
3423
3424 limGetSessionInfo(pMac,(tANI_U8 *)pMsgBuf,&smesessionId,&smetransactionId);
3425
3426
3427
3428 if ((limStopBssReqSerDes(pMac, &stopBssReq, (tANI_U8 *) pMsgBuf) != eSIR_SUCCESS) ||
3429 !limIsSmeStopBssReqValid(pMsgBuf))
3430 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003431 PELOGW(limLog(pMac, LOGW, FL("received invalid SME_STOP_BSS_REQ message"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07003432 /// Send Stop BSS response to host
3433 limSendSmeRsp(pMac, eWNI_SME_STOP_BSS_RSP, eSIR_SME_INVALID_PARAMETERS,smesessionId,smetransactionId);
3434 return;
3435 }
3436
3437
3438 if((psessionEntry = peFindSessionByBssid(pMac,stopBssReq.bssId,&sessionId)) == NULL)
3439 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003440 limLog(pMac, LOGW, FL("session does not exist for given BSSID "));
Jeff Johnson295189b2012-06-20 16:38:30 -07003441 limSendSmeRsp(pMac, eWNI_SME_STOP_BSS_RSP, eSIR_SME_INVALID_PARAMETERS,smesessionId,smetransactionId);
3442 return;
3443 }
3444
3445#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM //FEATURE_WLAN_DIAG_SUPPORT
3446 limDiagEventReport(pMac, WLAN_PE_DIAG_STOP_BSS_REQ_EVENT, psessionEntry, 0, 0);
3447#endif //FEATURE_WLAN_DIAG_SUPPORT
3448
3449
3450 if ((psessionEntry->limSmeState != eLIM_SME_NORMAL_STATE) || /* Added For BT -AMP Support */
3451 (psessionEntry->limSystemRole == eLIM_STA_ROLE ))
3452 {
3453 /**
3454 * Should not have received STOP_BSS_REQ in states
3455 * other than 'normal' state or on STA in Infrastructure
3456 * mode. Log error and return response to host.
3457 */
3458 limLog(pMac, LOGE,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003459 FL("received unexpected SME_STOP_BSS_REQ in state %X, for role %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07003460 psessionEntry->limSmeState, psessionEntry->limSystemRole);
3461 limPrintSmeState(pMac, LOGE, psessionEntry->limSmeState);
3462 /// Send Stop BSS response to host
3463 limSendSmeRsp(pMac, eWNI_SME_STOP_BSS_RSP, eSIR_SME_UNEXPECTED_REQ_RESULT_CODE,smesessionId,smetransactionId);
3464 return;
3465 }
3466
Jeff Johnson295189b2012-06-20 16:38:30 -07003467 if (psessionEntry->limSystemRole == eLIM_AP_ROLE )
3468 {
3469 limWPSPBCClose(pMac, psessionEntry);
3470 }
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003471 PELOGW(limLog(pMac, LOGW, FL("RECEIVED STOP_BSS_REQ with reason code=%d"), stopBssReq.reasonCode);)
Jeff Johnson295189b2012-06-20 16:38:30 -07003472
3473 prevState = psessionEntry->limSmeState;
3474
3475 psessionEntry->limSmeState = eLIM_SME_IDLE_STATE;
Jeff Johnsone7245742012-09-05 17:12:55 -07003476 MTRACE(macTrace(pMac, TRACE_CODE_SME_STATE, psessionEntry->peSessionId, psessionEntry->limSmeState));
Jeff Johnson295189b2012-06-20 16:38:30 -07003477
3478 /* Update SME session Id and Transaction Id */
3479 psessionEntry->smeSessionId = smesessionId;
3480 psessionEntry->transactionId = smetransactionId;
3481
3482 /* BTAMP_STA and STA_IN_IBSS should NOT send Disassoc frame */
3483 if ( (eLIM_STA_IN_IBSS_ROLE != psessionEntry->limSystemRole) && (eLIM_BT_AMP_STA_ROLE != psessionEntry->limSystemRole) )
3484 {
3485 tSirMacAddr bcAddr = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
3486 if ((stopBssReq.reasonCode == eSIR_SME_MIC_COUNTER_MEASURES))
3487 // Send disassoc all stations associated thru TKIP
3488 __limCounterMeasures(pMac,psessionEntry);
3489 else
Madan Mohan Koyyalamudi299b4862013-01-30 19:59:23 +05303490 limSendDisassocMgmtFrame(pMac, eSIR_MAC_DEAUTH_LEAVING_BSS_REASON, bcAddr, psessionEntry, FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003491 }
3492
3493 //limDelBss is also called as part of coalescing, when we send DEL BSS followed by Add Bss msg.
3494 pMac->lim.gLimIbssCoalescingHappened = false;
3495
3496 /* send a delBss to HAL and wait for a response */
3497 status = limDelBss(pMac, NULL,psessionEntry->bssIdx,psessionEntry);
3498
3499 if (status != eSIR_SUCCESS)
3500 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003501 PELOGE(limLog(pMac, LOGE, FL("delBss failed for bss %d"), psessionEntry->bssIdx);)
Jeff Johnson295189b2012-06-20 16:38:30 -07003502 psessionEntry->limSmeState= prevState;
3503
Jeff Johnsone7245742012-09-05 17:12:55 -07003504 MTRACE(macTrace(pMac, TRACE_CODE_SME_STATE, psessionEntry->peSessionId, psessionEntry->limSmeState));
Jeff Johnson295189b2012-06-20 16:38:30 -07003505
3506 limSendSmeRsp(pMac, eWNI_SME_STOP_BSS_RSP, eSIR_SME_STOP_BSS_FAILURE,smesessionId,smetransactionId);
3507 }
3508}
3509
3510
3511/**--------------------------------------------------------------
3512\fn __limProcessSmeStopBssReq
3513
3514\brief Wrapper for the function __limHandleSmeStopBssRequest
3515 This message will be defered until softmac come out of
3516 scan mode. Message should be handled even if we have
3517 detected radar in the current operating channel.
3518\param pMac
3519\param pMsg
3520
3521\return TRUE - If we consumed the buffer
3522 FALSE - If have defered the message.
3523 ---------------------------------------------------------------*/
3524static tANI_BOOLEAN
3525__limProcessSmeStopBssReq(tpAniSirGlobal pMac, tpSirMsgQ pMsg)
3526{
3527 if (__limIsDeferedMsgForLearn(pMac, pMsg))
3528 {
3529 /**
3530 * If message defered, buffer is not consumed yet.
3531 * So return false
3532 */
3533 return eANI_BOOLEAN_FALSE;
3534 }
3535 __limHandleSmeStopBssRequest(pMac, (tANI_U32 *) pMsg->bodyptr);
3536 return eANI_BOOLEAN_TRUE;
3537} /*** end __limProcessSmeStopBssReq() ***/
3538
3539
3540void limProcessSmeDelBssRsp(
3541 tpAniSirGlobal pMac,
3542 tANI_U32 body,tpPESession psessionEntry)
3543{
3544
3545 (void) body;
3546 SET_LIM_PROCESS_DEFD_MESGS(pMac, true);
3547 //TBD: get the sessionEntry
3548 dphHashTableClassInit(pMac, &psessionEntry->dph.dphHashTable);
3549 limDeletePreAuthList(pMac);
3550 limIbssDelete(pMac,psessionEntry);
3551 limSendSmeRsp(pMac, eWNI_SME_STOP_BSS_RSP, eSIR_SME_SUCCESS,psessionEntry->smeSessionId,psessionEntry->transactionId);
3552 return;
3553}
3554
3555
Jeff Johnson295189b2012-06-20 16:38:30 -07003556/**---------------------------------------------------------------
3557\fn __limProcessSmeAssocCnfNew
3558\brief This function handles SME_ASSOC_CNF/SME_REASSOC_CNF
3559\ in BTAMP AP.
3560\
3561\param pMac
3562\param msgType - message type
3563\param pMsgBuf - a pointer to the SME message buffer
3564\return None
3565------------------------------------------------------------------*/
3566
3567 void
3568__limProcessSmeAssocCnfNew(tpAniSirGlobal pMac, tANI_U32 msgType, tANI_U32 *pMsgBuf)
3569{
3570 tSirSmeAssocCnf assocCnf;
3571 tpDphHashNode pStaDs = NULL;
3572 tpPESession psessionEntry= NULL;
3573 tANI_U8 sessionId;
3574
3575
3576 if(pMsgBuf == NULL)
3577 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003578 limLog(pMac, LOGE, FL("pMsgBuf is NULL "));
Jeff Johnson295189b2012-06-20 16:38:30 -07003579 goto end;
3580 }
3581
3582 if ((limAssocCnfSerDes(pMac, &assocCnf, (tANI_U8 *) pMsgBuf) == eSIR_FAILURE) ||
3583 !__limIsSmeAssocCnfValid(&assocCnf))
3584 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003585 limLog(pMac, LOGE, FL("Received invalid SME_RE(ASSOC)_CNF message "));
Jeff Johnson295189b2012-06-20 16:38:30 -07003586 goto end;
3587 }
3588
3589 if((psessionEntry = peFindSessionByBssid(pMac, assocCnf.bssId, &sessionId))== NULL)
3590 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003591 limLog(pMac, LOGE, FL("session does not exist for given bssId"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003592 goto end;
3593 }
3594
3595 if ( ((psessionEntry->limSystemRole != eLIM_AP_ROLE) && (psessionEntry->limSystemRole != eLIM_BT_AMP_AP_ROLE)) ||
3596 ((psessionEntry->limSmeState != eLIM_SME_NORMAL_STATE) && (psessionEntry->limSmeState != eLIM_SME_NORMAL_CHANNEL_SCAN_STATE)))
3597 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003598 limLog(pMac, LOGE, FL("Received unexpected message %X in state %X, in role %X"),
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303599 msgType, psessionEntry->limSmeState, psessionEntry->limSystemRole);
Jeff Johnson295189b2012-06-20 16:38:30 -07003600 goto end;
3601 }
3602
3603 pStaDs = dphGetHashEntry(pMac, assocCnf.aid, &psessionEntry->dph.dphHashTable);
3604
3605 if (pStaDs == NULL)
3606 {
3607 limLog(pMac, LOG1,
3608 FL("Received invalid message %X due to no STA context, for aid %d, peer "),
3609 msgType, assocCnf.aid);
3610 limPrintMacAddr(pMac, assocCnf.peerMacAddr, LOG1);
3611
3612 /*
3613 ** send a DISASSOC_IND message to WSM to make sure
3614 ** the state in WSM and LIM is the same
3615 **/
3616 limSendSmeDisassocNtf( pMac, assocCnf.peerMacAddr, eSIR_SME_STA_NOT_ASSOCIATED,
3617 eLIM_PEER_ENTITY_DISASSOC, assocCnf.aid,psessionEntry->smeSessionId,psessionEntry->transactionId,psessionEntry);
3618 goto end;
3619 }
3620 if ((pStaDs &&
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303621 (( !vos_mem_compare( (tANI_U8 *) pStaDs->staAddr,
Jeff Johnson295189b2012-06-20 16:38:30 -07003622 (tANI_U8 *) assocCnf.peerMacAddr,
3623 sizeof(tSirMacAddr)) ) ||
3624 (pStaDs->mlmStaContext.mlmState != eLIM_MLM_WT_ASSOC_CNF_STATE) ||
3625 ((pStaDs->mlmStaContext.subType == LIM_ASSOC) &&
3626 (msgType != eWNI_SME_ASSOC_CNF)) ||
3627 ((pStaDs->mlmStaContext.subType == LIM_REASSOC) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07003628 (msgType != eWNI_SME_ASSOC_CNF))))) // since softap is passing this as ASSOC_CNF and subtype differs
Jeff Johnson295189b2012-06-20 16:38:30 -07003629 {
3630 limLog(pMac, LOG1,
3631 FL("Received invalid message %X due to peerMacAddr mismatched or not in eLIM_MLM_WT_ASSOC_CNF_STATE state, for aid %d, peer "),
3632 msgType, assocCnf.aid);
3633 limPrintMacAddr(pMac, assocCnf.peerMacAddr, LOG1);
3634 goto end;
3635 }
3636
3637 /*
3638 ** Deactivate/delet CNF_WAIT timer since ASSOC_CNF
3639 ** has been received
3640 **/
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003641 limLog(pMac, LOG1, FL("Received SME_ASSOC_CNF. Delete Timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003642 limDeactivateAndChangePerStaIdTimer(pMac, eLIM_CNF_WAIT_TIMER, pStaDs->assocId);
3643
3644 if (assocCnf.statusCode == eSIR_SME_SUCCESS)
3645 {
3646 /* In BTAMP-AP, PE already finished the WDA_ADD_STA sequence
3647 * when it had received Assoc Request frame. Now, PE just needs to send
3648 * Association Response frame to the requesting BTAMP-STA.
3649 */
3650 pStaDs->mlmStaContext.mlmState = eLIM_MLM_LINK_ESTABLISHED_STATE;
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003651 limLog(pMac, LOG1, FL("sending Assoc Rsp frame to STA (assoc id=%d) "), pStaDs->assocId);
Jeff Johnson295189b2012-06-20 16:38:30 -07003652 limSendAssocRspMgmtFrame( pMac, eSIR_SUCCESS, pStaDs->assocId, pStaDs->staAddr,
3653 pStaDs->mlmStaContext.subType, pStaDs, psessionEntry);
3654 goto end;
3655 } // (assocCnf.statusCode == eSIR_SME_SUCCESS)
3656 else
3657 {
3658 // SME_ASSOC_CNF status is non-success, so STA is not allowed to be associated
3659 /*Since the HAL sta entry is created for denied STA we need to remove this HAL entry.So to do that set updateContext to 1*/
3660 if(!pStaDs->mlmStaContext.updateContext)
3661 pStaDs->mlmStaContext.updateContext = 1;
3662 limRejectAssociation(pMac, pStaDs->staAddr,
3663 pStaDs->mlmStaContext.subType,
3664 true, pStaDs->mlmStaContext.authType,
3665 pStaDs->assocId, true,
3666 eSIR_MAC_UNSPEC_FAILURE_STATUS, psessionEntry);
3667 return;
3668 }
3669
3670end:
3671 if((psessionEntry != NULL) && (pStaDs != NULL))
3672 {
3673 if ( psessionEntry->parsedAssocReq[pStaDs->assocId] != NULL )
3674 {
3675 if ( ((tpSirAssocReq)(psessionEntry->parsedAssocReq[pStaDs->assocId]))->assocReqFrame)
3676 {
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303677 vos_mem_free(((tpSirAssocReq)
3678 (psessionEntry->parsedAssocReq[pStaDs->assocId]))->assocReqFrame);
Jeff Johnson295189b2012-06-20 16:38:30 -07003679 ((tpSirAssocReq)(psessionEntry->parsedAssocReq[pStaDs->assocId]))->assocReqFrame = NULL;
3680 }
3681
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303682 vos_mem_free(psessionEntry->parsedAssocReq[pStaDs->assocId]);
Jeff Johnson295189b2012-06-20 16:38:30 -07003683 psessionEntry->parsedAssocReq[pStaDs->assocId] = NULL;
3684 }
3685 }
3686
3687} /*** end __limProcessSmeAssocCnfNew() ***/
3688
3689
Jeff Johnson295189b2012-06-20 16:38:30 -07003690
3691
3692static void
3693__limProcessSmeAddtsReq(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
3694{
3695 tpDphHashNode pStaDs;
3696 tSirMacAddr peerMac;
3697 tpSirAddtsReq pSirAddts;
3698 tANI_U32 timeout;
3699 tpPESession psessionEntry;
3700 tANI_U8 sessionId; //PE sessionId
3701 tANI_U8 smesessionId;
3702 tANI_U16 smetransactionId;
3703
3704
3705 if(pMsgBuf == NULL)
3706 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003707 limLog(pMac, LOGE,FL("Buffer is Pointing to NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003708 return;
3709 }
3710
3711 limGetSessionInfo(pMac,(tANI_U8 *)pMsgBuf,&smesessionId,&smetransactionId);
3712
3713 pSirAddts = (tpSirAddtsReq) pMsgBuf;
3714
3715 if((psessionEntry = peFindSessionByBssid(pMac, pSirAddts->bssId,&sessionId))== NULL)
3716 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003717 limLog(pMac, LOGE, "Session Does not exist for given bssId");
Jeff Johnson295189b2012-06-20 16:38:30 -07003718 return;
3719 }
3720#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM //FEATURE_WLAN_DIAG_SUPPORT
3721 limDiagEventReport(pMac, WLAN_PE_DIAG_ADDTS_REQ_EVENT, psessionEntry, 0, 0);
3722#endif //FEATURE_WLAN_DIAG_SUPPORT
3723
3724
3725
3726 /* if sta
3727 * - verify assoc state
3728 * - send addts request to ap
3729 * - wait for addts response from ap
3730 * if ap, just ignore with error log
3731 */
3732 PELOG1(limLog(pMac, LOG1,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003733 FL("Received SME_ADDTS_REQ (TSid %d, UP %d)"),
Jeff Johnson295189b2012-06-20 16:38:30 -07003734 pSirAddts->req.tspec.tsinfo.traffic.tsid,
3735 pSirAddts->req.tspec.tsinfo.traffic.userPrio);)
3736
3737 if ((psessionEntry->limSystemRole != eLIM_STA_ROLE)&&(psessionEntry->limSystemRole != eLIM_BT_AMP_STA_ROLE))
3738 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003739 PELOGE(limLog(pMac, LOGE, "AddTs received on AP - ignoring");)
Jeff Johnson295189b2012-06-20 16:38:30 -07003740 limSendSmeAddtsRsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE, psessionEntry, pSirAddts->req.tspec,
3741 smesessionId,smetransactionId);
3742 return;
3743 }
3744
3745 //Ignore the request if STA is in 11B mode.
3746 if(psessionEntry->dot11mode == WNI_CFG_DOT11_MODE_11B)
3747 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003748 PELOGE(limLog(pMac, LOGE, "AddTS received while Dot11Mode is 11B - ignoring");)
Jeff Johnson295189b2012-06-20 16:38:30 -07003749 limSendSmeAddtsRsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE, psessionEntry, pSirAddts->req.tspec,
3750 smesessionId,smetransactionId);
3751 return;
3752 }
3753
3754
3755 pStaDs = dphGetHashEntry(pMac, DPH_STA_HASH_INDEX_PEER, &psessionEntry->dph.dphHashTable);
3756
3757 if(pStaDs == NULL)
3758 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003759 PELOGE(limLog(pMac, LOGE, "Cannot find AP context for addts req");)
Jeff Johnson295189b2012-06-20 16:38:30 -07003760 limSendSmeAddtsRsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE, psessionEntry, pSirAddts->req.tspec,
3761 smesessionId,smetransactionId);
3762 return;
3763 }
3764
3765 if ((! pStaDs->valid) ||
3766 (pStaDs->mlmStaContext.mlmState != eLIM_MLM_LINK_ESTABLISHED_STATE))
3767 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003768 PELOGE(limLog(pMac, LOGE, "AddTs received in invalid MLM state");)
Jeff Johnson295189b2012-06-20 16:38:30 -07003769 limSendSmeAddtsRsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE, psessionEntry, pSirAddts->req.tspec,
3770 smesessionId,smetransactionId);
3771 return;
3772 }
3773
3774 pSirAddts->req.wsmTspecPresent = 0;
3775 pSirAddts->req.wmeTspecPresent = 0;
3776 pSirAddts->req.lleTspecPresent = 0;
3777
3778 if ((pStaDs->wsmEnabled) &&
3779 (pSirAddts->req.tspec.tsinfo.traffic.accessPolicy != SIR_MAC_ACCESSPOLICY_EDCA))
3780 pSirAddts->req.wsmTspecPresent = 1;
3781 else if (pStaDs->wmeEnabled)
3782 pSirAddts->req.wmeTspecPresent = 1;
3783 else if (pStaDs->lleEnabled)
3784 pSirAddts->req.lleTspecPresent = 1;
3785 else
3786 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003787 PELOGW(limLog(pMac, LOGW, FL("ADDTS_REQ ignore - qos is disabled"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07003788 limSendSmeAddtsRsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE, psessionEntry, pSirAddts->req.tspec,
3789 smesessionId,smetransactionId);
3790 return;
3791 }
3792
3793 if ((psessionEntry->limSmeState != eLIM_SME_ASSOCIATED_STATE) &&
3794 (psessionEntry->limSmeState != eLIM_SME_LINK_EST_STATE))
3795 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003796 limLog(pMac, LOGE, "AddTs received in invalid LIMsme state (%d)",
Jeff Johnson295189b2012-06-20 16:38:30 -07003797 psessionEntry->limSmeState);
3798 limSendSmeAddtsRsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE, psessionEntry, pSirAddts->req.tspec,
3799 smesessionId,smetransactionId);
3800 return;
3801 }
3802
3803 if (pMac->lim.gLimAddtsSent)
3804 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003805 limLog(pMac, LOGE, "Addts (token %d, tsid %d, up %d) is still pending",
Jeff Johnson295189b2012-06-20 16:38:30 -07003806 pMac->lim.gLimAddtsReq.req.dialogToken,
3807 pMac->lim.gLimAddtsReq.req.tspec.tsinfo.traffic.tsid,
3808 pMac->lim.gLimAddtsReq.req.tspec.tsinfo.traffic.userPrio);
3809 limSendSmeAddtsRsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE, psessionEntry, pSirAddts->req.tspec,
3810 smesessionId,smetransactionId);
3811 return;
3812 }
3813
3814 #if 0
3815 val = sizeof(tSirMacAddr);
3816 if (wlan_cfgGetStr(pMac, WNI_CFG_BSSID, peerMac, &val) != eSIR_SUCCESS)
3817 {
3818 /// Could not get BSSID from CFG. Log error.
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003819 limLog(pMac, LOGP, FL("could not retrieve BSSID"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003820 return;
3821 }
3822 #endif
3823 sirCopyMacAddr(peerMac,psessionEntry->bssId);
3824
3825 // save the addts request
3826 pMac->lim.gLimAddtsSent = true;
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303827 vos_mem_copy( (tANI_U8 *) &pMac->lim.gLimAddtsReq, (tANI_U8 *) pSirAddts, sizeof(tSirAddtsReq));
Jeff Johnson295189b2012-06-20 16:38:30 -07003828
3829 // ship out the message now
3830 limSendAddtsReqActionFrame(pMac, peerMac, &pSirAddts->req,
3831 psessionEntry);
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003832 PELOG1(limLog(pMac, LOG1, "Sent ADDTS request");)
Jeff Johnson295189b2012-06-20 16:38:30 -07003833
3834 // start a timer to wait for the response
3835 if (pSirAddts->timeout)
3836 timeout = pSirAddts->timeout;
3837 else if (wlan_cfgGetInt(pMac, WNI_CFG_ADDTS_RSP_TIMEOUT, &timeout) != eSIR_SUCCESS)
3838 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003839 limLog(pMac, LOGP, FL("Unable to get Cfg param %d (Addts Rsp Timeout)"),
Jeff Johnson295189b2012-06-20 16:38:30 -07003840 WNI_CFG_ADDTS_RSP_TIMEOUT);
3841 return;
3842 }
3843
3844 timeout = SYS_MS_TO_TICKS(timeout);
3845 if (tx_timer_change(&pMac->lim.limTimers.gLimAddtsRspTimer, timeout, 0) != TX_SUCCESS)
3846 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003847 limLog(pMac, LOGP, FL("AddtsRsp timer change failed!"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003848 return;
3849 }
3850 pMac->lim.gLimAddtsRspTimerCount++;
3851 if (tx_timer_change_context(&pMac->lim.limTimers.gLimAddtsRspTimer,
3852 pMac->lim.gLimAddtsRspTimerCount) != TX_SUCCESS)
3853 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003854 limLog(pMac, LOGP, FL("AddtsRsp timer change failed!"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003855 return;
3856 }
Jeff Johnsone7245742012-09-05 17:12:55 -07003857 MTRACE(macTrace(pMac, TRACE_CODE_TIMER_ACTIVATE, psessionEntry->peSessionId, eLIM_ADDTS_RSP_TIMER));
Jeff Johnson295189b2012-06-20 16:38:30 -07003858
3859 //add the sessionId to the timer object
3860 pMac->lim.limTimers.gLimAddtsRspTimer.sessionId = sessionId;
3861 if (tx_timer_activate(&pMac->lim.limTimers.gLimAddtsRspTimer) != TX_SUCCESS)
3862 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003863 limLog(pMac, LOGP, FL("AddtsRsp timer activation failed!"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003864 return;
3865 }
3866 return;
3867}
3868
3869
3870static void
3871__limProcessSmeDeltsReq(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
3872{
3873 tSirMacAddr peerMacAddr;
3874 tANI_U8 ac;
3875 tSirMacTSInfo *pTsinfo;
3876 tpSirDeltsReq pDeltsReq = (tpSirDeltsReq) pMsgBuf;
3877 tpDphHashNode pStaDs = NULL;
3878 tpPESession psessionEntry;
3879 tANI_U8 sessionId;
3880 tANI_U32 status = eSIR_SUCCESS;
3881 tANI_U8 smesessionId;
3882 tANI_U16 smetransactionId;
3883
3884 limGetSessionInfo(pMac,(tANI_U8 *)pMsgBuf,&smesessionId,&smetransactionId);
3885
3886 if((psessionEntry = peFindSessionByBssid(pMac, pDeltsReq->bssId, &sessionId))== NULL)
3887 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003888 limLog(pMac, LOGE, "Session Does not exist for given bssId");
Jeff Johnson295189b2012-06-20 16:38:30 -07003889 status = eSIR_FAILURE;
3890 goto end;
3891 }
3892#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM //FEATURE_WLAN_DIAG_SUPPORT
3893 limDiagEventReport(pMac, WLAN_PE_DIAG_DELTS_REQ_EVENT, psessionEntry, 0, 0);
3894#endif //FEATURE_WLAN_DIAG_SUPPORT
3895
3896
3897 if (eSIR_SUCCESS != limValidateDeltsReq(pMac, pDeltsReq, peerMacAddr,psessionEntry))
3898 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003899 PELOGE(limLog(pMac, LOGE, FL("limValidateDeltsReq failed"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07003900 status = eSIR_FAILURE;
3901 limSendSmeDeltsRsp(pMac, pDeltsReq, eSIR_FAILURE,psessionEntry,smesessionId,smetransactionId);
3902 return;
3903 }
3904
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003905 PELOG1(limLog(pMac, LOG1, FL("Sent DELTS request to station with assocId = %d MacAddr = %x:%x:%x:%x:%x:%x"),
Jeff Johnson295189b2012-06-20 16:38:30 -07003906 pDeltsReq->aid, peerMacAddr[0], peerMacAddr[1], peerMacAddr[2],
3907 peerMacAddr[3], peerMacAddr[4], peerMacAddr[5]);)
3908
3909 limSendDeltsReqActionFrame(pMac, peerMacAddr, pDeltsReq->req.wmeTspecPresent, &pDeltsReq->req.tsinfo, &pDeltsReq->req.tspec,
3910 psessionEntry);
3911
3912 pTsinfo = pDeltsReq->req.wmeTspecPresent ? &pDeltsReq->req.tspec.tsinfo : &pDeltsReq->req.tsinfo;
3913
3914 /* We've successfully send DELTS frame to AP. Update the
3915 * dynamic UAPSD mask. The AC for this TSPEC to be deleted
3916 * is no longer trigger enabled or delivery enabled
3917 */
3918 limSetTspecUapsdMask(pMac, pTsinfo, CLEAR_UAPSD_MASK);
3919
3920 /* We're deleting the TSPEC, so this particular AC is no longer
3921 * admitted. PE needs to downgrade the EDCA
3922 * parameters(for the AC for which TS is being deleted) to the
3923 * next best AC for which ACM is not enabled, and send the
3924 * updated values to HAL.
3925 */
3926 ac = upToAc(pTsinfo->traffic.userPrio);
3927
3928 if(pTsinfo->traffic.direction == SIR_MAC_DIRECTION_UPLINK)
3929 {
3930 pMac->lim.gAcAdmitMask[SIR_MAC_DIRECTION_UPLINK] &= ~(1 << ac);
3931 }
3932 else if(pTsinfo->traffic.direction == SIR_MAC_DIRECTION_DNLINK)
3933 {
3934 pMac->lim.gAcAdmitMask[SIR_MAC_DIRECTION_DNLINK] &= ~(1 << ac);
3935 }
3936 else if(pTsinfo->traffic.direction == SIR_MAC_DIRECTION_BIDIR)
3937 {
3938 pMac->lim.gAcAdmitMask[SIR_MAC_DIRECTION_UPLINK] &= ~(1 << ac);
3939 pMac->lim.gAcAdmitMask[SIR_MAC_DIRECTION_DNLINK] &= ~(1 << ac);
3940 }
3941
3942 limSetActiveEdcaParams(pMac, psessionEntry->gLimEdcaParams, psessionEntry);
3943
3944 pStaDs = dphGetHashEntry(pMac, DPH_STA_HASH_INDEX_PEER, &psessionEntry->dph.dphHashTable);
3945 if (pStaDs != NULL)
3946 {
3947 if (pStaDs->aniPeer == eANI_BOOLEAN_TRUE)
3948 limSendEdcaParams(pMac, psessionEntry->gLimEdcaParamsActive, pStaDs->bssId, eANI_BOOLEAN_TRUE);
3949 else
3950 limSendEdcaParams(pMac, psessionEntry->gLimEdcaParamsActive, pStaDs->bssId, eANI_BOOLEAN_FALSE);
3951 status = eSIR_SUCCESS;
3952 }
3953 else
3954 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003955 limLog(pMac, LOGE, FL("Self entry missing in Hash Table "));
Jeff Johnson295189b2012-06-20 16:38:30 -07003956 status = eSIR_FAILURE;
3957 }
3958#ifdef FEATURE_WLAN_CCX
3959 limDeactivateAndChangeTimer(pMac,eLIM_TSM_TIMER);
3960#endif
3961
3962 // send an sme response back
3963 end:
3964 limSendSmeDeltsRsp(pMac, pDeltsReq, eSIR_SUCCESS,psessionEntry,smesessionId,smetransactionId);
3965}
3966
3967
3968void
3969limProcessSmeAddtsRspTimeout(tpAniSirGlobal pMac, tANI_U32 param)
3970{
3971 //fetch the sessionEntry based on the sessionId
3972 tpPESession psessionEntry;
3973 if((psessionEntry = peFindSessionBySessionId(pMac, pMac->lim.limTimers.gLimAddtsRspTimer.sessionId))== NULL)
3974 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003975 limLog(pMac, LOGP,FL("Session Does not exist for given sessionID"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003976 return;
3977 }
3978
3979 if ( (psessionEntry->limSystemRole != eLIM_STA_ROLE) && (psessionEntry->limSystemRole != eLIM_BT_AMP_STA_ROLE) )
3980 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003981 limLog(pMac, LOGW, "AddtsRspTimeout in non-Sta role (%d)", psessionEntry->limSystemRole);
Jeff Johnson295189b2012-06-20 16:38:30 -07003982 pMac->lim.gLimAddtsSent = false;
3983 return;
3984 }
3985
3986 if (! pMac->lim.gLimAddtsSent)
3987 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003988 PELOGW(limLog(pMac, LOGW, "AddtsRspTimeout but no AddtsSent");)
Jeff Johnson295189b2012-06-20 16:38:30 -07003989 return;
3990 }
3991
3992 if (param != pMac->lim.gLimAddtsRspTimerCount)
3993 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003994 limLog(pMac, LOGE, FL("Invalid AddtsRsp Timer count %d (exp %d)"),
Jeff Johnson295189b2012-06-20 16:38:30 -07003995 param, pMac->lim.gLimAddtsRspTimerCount);
3996 return;
3997 }
3998
3999 // this a real response timeout
4000 pMac->lim.gLimAddtsSent = false;
4001 pMac->lim.gLimAddtsRspTimerCount++;
4002
4003 limSendSmeAddtsRsp(pMac, true, eSIR_SME_ADDTS_RSP_TIMEOUT, psessionEntry, pMac->lim.gLimAddtsReq.req.tspec,
4004 psessionEntry->smeSessionId, psessionEntry->transactionId);
4005}
4006
4007
4008/**
4009 * __limProcessSmeStatsRequest()
4010 *
4011 *FUNCTION:
4012 *
4013 *
4014 *NOTE:
4015 *
4016 * @param pMac Pointer to Global MAC structure
4017 * @param *pMsgBuf A pointer to the SME message buffer
4018 * @return None
4019 */
4020static void
4021__limProcessSmeStatsRequest(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
4022{
4023 tpAniGetStatsReq pStatsReq;
4024 tSirMsgQ msgQ;
4025 tpPESession psessionEntry;
4026 tANI_U8 sessionId;
4027
4028
4029 if(pMsgBuf == NULL)
4030 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004031 limLog(pMac, LOGE,FL("Buffer is Pointing to NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004032 return;
4033 }
4034
4035 pStatsReq = (tpAniGetStatsReq) pMsgBuf;
4036
4037 if((psessionEntry = peFindSessionByBssid(pMac,pStatsReq->bssId,&sessionId))== NULL)
4038 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004039 limLog(pMac, LOGE, FL("session does not exist for given bssId"));
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304040 vos_mem_free( pMsgBuf );
Jeff Johnson295189b2012-06-20 16:38:30 -07004041 return;
4042 }
4043
4044
4045
4046 switch(pStatsReq->msgType)
4047 {
4048 //Add Lim stats here. and send reqsponse.
4049
4050 //HAL maintained Stats.
4051 case eWNI_SME_STA_STAT_REQ:
4052 msgQ.type = WDA_STA_STAT_REQ;
4053 break;
4054 case eWNI_SME_AGGR_STAT_REQ:
4055 msgQ.type = WDA_AGGR_STAT_REQ;
4056 break;
4057 case eWNI_SME_GLOBAL_STAT_REQ:
4058 msgQ.type = WDA_GLOBAL_STAT_REQ;
4059 break;
4060 case eWNI_SME_STAT_SUMM_REQ:
4061 msgQ.type = WDA_STAT_SUMM_REQ;
4062 break;
4063 default: //Unknown request.
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004064 PELOGE(limLog(pMac, LOGE, "Unknown Statistics request");)
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304065 vos_mem_free( pMsgBuf );
Jeff Johnson295189b2012-06-20 16:38:30 -07004066 return;
4067 }
4068
Jeff Johnson295189b2012-06-20 16:38:30 -07004069 msgQ.reserved = 0;
4070 msgQ.bodyptr = pMsgBuf;
4071 msgQ.bodyval = 0;
Leela Venkata Kiran Kumar Reddy Chirala68a6abe2013-02-28 07:43:16 -08004072 if(NULL == psessionEntry)
4073 {
4074 MTRACE(macTraceMsgTx(pMac, NO_SESSION, msgQ.type));
4075 }
4076 else
4077 {
4078 MTRACE(macTraceMsgTx(pMac, psessionEntry->peSessionId, msgQ.type));
4079 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004080 if( eSIR_SUCCESS != (wdaPostCtrlMsg( pMac, &msgQ ))){
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004081 limLog(pMac, LOGP, "Unable to forward request");
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304082 vos_mem_free( pMsgBuf );
Jeff Johnson295189b2012-06-20 16:38:30 -07004083 return;
4084 }
4085
4086 return;
4087}
4088
4089
4090/**
4091 * __limProcessSmeGetStatisticsRequest()
4092 *
4093 *FUNCTION:
4094 *
4095 *
4096 *NOTE:
4097 *
4098 * @param pMac Pointer to Global MAC structure
4099 * @param *pMsgBuf A pointer to the SME message buffer
4100 * @return None
4101 */
4102static void
4103__limProcessSmeGetStatisticsRequest(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
4104{
4105 tpAniGetPEStatsReq pPEStatsReq;
4106 tSirMsgQ msgQ;
4107
4108 pPEStatsReq = (tpAniGetPEStatsReq) pMsgBuf;
4109
4110 //pPEStatsReq->msgType should be eWNI_SME_GET_STATISTICS_REQ
4111
4112 msgQ.type = WDA_GET_STATISTICS_REQ;
4113
Jeff Johnson295189b2012-06-20 16:38:30 -07004114 msgQ.reserved = 0;
4115 msgQ.bodyptr = pMsgBuf;
4116 msgQ.bodyval = 0;
Jeff Johnsone7245742012-09-05 17:12:55 -07004117 MTRACE(macTraceMsgTx(pMac, NO_SESSION, msgQ.type));
Jeff Johnson295189b2012-06-20 16:38:30 -07004118
4119 if( eSIR_SUCCESS != (wdaPostCtrlMsg( pMac, &msgQ ))){
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304120 vos_mem_free( pMsgBuf );
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004121 limLog(pMac, LOGP, "Unable to forward request");
Jeff Johnson295189b2012-06-20 16:38:30 -07004122 return;
4123 }
4124
4125 return;
4126}
4127
4128
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08004129#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_CCX || defined(FEATURE_WLAN_LFR)
4130/**
4131 * __limProcessSmeGetRoamRssiRequest()
4132 *
4133 *FUNCTION:
4134 *
4135 *
4136 *NOTE:
4137 *
4138 * @param pMac Pointer to Global MAC structure
4139 * @param *pMsgBuf A pointer to the SME message buffer
4140 * @return None
4141 */
4142static void
4143__limProcessSmeGetRoamRssiRequest(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
4144{
4145 tpAniGetRssiReq pPEGetRoamRssiReq = NULL;
4146 tSirMsgQ msgQ;
4147
4148 pPEGetRoamRssiReq = (tpAniGetRssiReq) pMsgBuf;
4149 msgQ.type = WDA_GET_ROAM_RSSI_REQ;
4150
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08004151 msgQ.reserved = 0;
4152 msgQ.bodyptr = pMsgBuf;
4153 msgQ.bodyval = 0;
4154 MTRACE(macTraceMsgTx(pMac, NO_SESSION, msgQ.type));
4155
4156 if( eSIR_SUCCESS != (wdaPostCtrlMsg( pMac, &msgQ ))){
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304157 vos_mem_free( pMsgBuf );
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004158 limLog(pMac, LOGP, "Unable to forward request");
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08004159 return;
4160 }
4161
4162 return;
4163}
4164#endif
4165
4166
Jeff Johnson295189b2012-06-20 16:38:30 -07004167static void
4168__limProcessSmeUpdateAPWPSIEs(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
4169{
4170 tpSirUpdateAPWPSIEsReq pUpdateAPWPSIEsReq;
4171 tpPESession psessionEntry;
4172 tANI_U8 sessionId; //PE sessionID
4173
4174 PELOG1(limLog(pMac, LOG1,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004175 FL("received UPDATE_APWPSIEs_REQ message")););
Jeff Johnson295189b2012-06-20 16:38:30 -07004176
4177 if(pMsgBuf == NULL)
4178 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004179 limLog(pMac, LOGE,FL("Buffer is Pointing to NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004180 return;
4181 }
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08004182
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304183 pUpdateAPWPSIEsReq = vos_mem_malloc(sizeof(tSirUpdateAPWPSIEsReq));
4184 if ( NULL == pUpdateAPWPSIEsReq )
Jeff Johnson295189b2012-06-20 16:38:30 -07004185 {
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304186 limLog(pMac, LOGP, FL("call to AllocateMemory failed for pUpdateAPWPSIEsReq"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004187 return;
4188 }
4189
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08004190 if ((limUpdateAPWPSIEsReqSerDes(pMac, pUpdateAPWPSIEsReq, (tANI_U8 *) pMsgBuf) == eSIR_FAILURE))
Jeff Johnson295189b2012-06-20 16:38:30 -07004191 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004192 limLog(pMac, LOGW, FL("received invalid SME_SETCONTEXT_REQ message"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004193 goto end;
4194 }
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08004195
Jeff Johnson295189b2012-06-20 16:38:30 -07004196 if((psessionEntry = peFindSessionByBssid(pMac, pUpdateAPWPSIEsReq->bssId, &sessionId)) == NULL)
4197 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004198 limLog(pMac, LOGW, FL("Session does not exist for given BSSID"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004199 goto end;
4200 }
4201
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304202 vos_mem_copy( &psessionEntry->APWPSIEs, &pUpdateAPWPSIEsReq->APWPSIEs, sizeof(tSirAPWPSIEs));
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08004203
Jeff Johnson295189b2012-06-20 16:38:30 -07004204 schSetFixedBeaconFields(pMac, psessionEntry);
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08004205 limSendBeaconInd(pMac, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07004206
4207end:
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304208 vos_mem_free( pUpdateAPWPSIEsReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07004209 return;
4210} /*** end __limProcessSmeUpdateAPWPSIEs(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf) ***/
4211
4212static void
4213__limProcessSmeHideSSID(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
4214{
4215 tpSirUpdateParams pUpdateParams;
4216 tpPESession psessionEntry;
4217
4218 PELOG1(limLog(pMac, LOG1,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004219 FL("received HIDE_SSID message")););
Jeff Johnson295189b2012-06-20 16:38:30 -07004220
4221 if(pMsgBuf == NULL)
4222 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004223 limLog(pMac, LOGE,FL("Buffer is Pointing to NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004224 return;
4225 }
4226
4227 pUpdateParams = (tpSirUpdateParams)pMsgBuf;
4228
4229 if((psessionEntry = peFindSessionBySessionId(pMac, pUpdateParams->sessionId)) == NULL)
4230 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004231 limLog(pMac, LOGW, "Session does not exist for given sessionId %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07004232 pUpdateParams->sessionId);
4233 return;
4234 }
4235
4236 /* Update the session entry */
4237 psessionEntry->ssidHidden = pUpdateParams->ssidHidden;
4238
4239 /* Update beacon */
4240 schSetFixedBeaconFields(pMac, psessionEntry);
4241 limSendBeaconInd(pMac, psessionEntry);
4242
4243 return;
4244} /*** end __limProcessSmeHideSSID(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf) ***/
4245
4246static void
4247__limProcessSmeSetWPARSNIEs(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
4248{
4249 tpSirUpdateAPWPARSNIEsReq pUpdateAPWPARSNIEsReq;
4250 tpPESession psessionEntry;
4251 tANI_U8 sessionId; //PE sessionID
4252
4253 if(pMsgBuf == NULL)
4254 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004255 limLog(pMac, LOGE,FL("Buffer is Pointing to NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004256 return;
4257 }
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304258
4259 pUpdateAPWPARSNIEsReq = vos_mem_malloc(sizeof(tSirUpdateAPWPSIEsReq));
4260 if ( NULL == pUpdateAPWPARSNIEsReq )
Jeff Johnson295189b2012-06-20 16:38:30 -07004261 {
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304262 limLog(pMac, LOGP, FL("call to AllocateMemory failed for pUpdateAPWPARSNIEsReq"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004263 return;
4264 }
4265
4266 if ((limUpdateAPWPARSNIEsReqSerDes(pMac, pUpdateAPWPARSNIEsReq, (tANI_U8 *) pMsgBuf) == eSIR_FAILURE))
4267 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004268 limLog(pMac, LOGW, FL("received invalid SME_SETCONTEXT_REQ message"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004269 goto end;
4270 }
4271
4272 if((psessionEntry = peFindSessionByBssid(pMac, pUpdateAPWPARSNIEsReq->bssId, &sessionId)) == NULL)
4273 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004274 limLog(pMac, LOGW, FL("Session does not exist for given BSSID"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004275 goto end;
4276 }
4277
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304278 vos_mem_copy(&psessionEntry->pLimStartBssReq->rsnIE,
4279 &pUpdateAPWPARSNIEsReq->APWPARSNIEs, sizeof(tSirRSNie));
Jeff Johnson295189b2012-06-20 16:38:30 -07004280
4281 limSetRSNieWPAiefromSmeStartBSSReqMessage(pMac, &psessionEntry->pLimStartBssReq->rsnIE, psessionEntry);
4282
4283 psessionEntry->pLimStartBssReq->privacy = 1;
4284 psessionEntry->privacy = 1;
4285
4286 schSetFixedBeaconFields(pMac, psessionEntry);
4287 limSendBeaconInd(pMac, psessionEntry);
4288
4289end:
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304290 vos_mem_free(pUpdateAPWPARSNIEsReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07004291 return;
4292} /*** end __limProcessSmeSetWPARSNIEs(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf) ***/
4293
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08004294/*
4295Update the beacon Interval dynamically if beaconInterval is different in MCC
4296*/
4297static void
4298__limProcessSmeChangeBI(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
4299{
4300 tpSirChangeBIParams pChangeBIParams;
4301 tpPESession psessionEntry;
4302 tANI_U8 sessionId = 0;
4303 tUpdateBeaconParams beaconParams;
4304
4305 PELOG1(limLog(pMac, LOG1,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004306 FL("received Update Beacon Interval message")););
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08004307
4308 if(pMsgBuf == NULL)
4309 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004310 limLog(pMac, LOGE,FL("Buffer is Pointing to NULL"));
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08004311 return;
4312 }
4313
4314 pChangeBIParams = (tpSirChangeBIParams)pMsgBuf;
4315
4316 if((psessionEntry = peFindSessionByBssid(pMac, pChangeBIParams->bssId, &sessionId)) == NULL)
4317 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004318 limLog(pMac, LOGE, FL("Session does not exist for given BSSID"));
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08004319 return;
4320 }
4321
4322 /*Update sessionEntry Beacon Interval*/
4323 if(psessionEntry->beaconParams.beaconInterval !=
4324 pChangeBIParams->beaconInterval )
4325 {
4326 psessionEntry->beaconParams.beaconInterval = pChangeBIParams->beaconInterval;
4327 }
4328
4329 /*Update sch beaconInterval*/
4330 if(pMac->sch.schObject.gSchBeaconInterval !=
4331 pChangeBIParams->beaconInterval )
4332 {
4333 pMac->sch.schObject.gSchBeaconInterval = pChangeBIParams->beaconInterval;
4334
4335 PELOG1(limLog(pMac, LOG1,
4336 FL("LIM send update BeaconInterval Indication : %d"),pChangeBIParams->beaconInterval););
4337
4338 /* Update beacon */
4339 schSetFixedBeaconFields(pMac, psessionEntry);
4340
Sunil Ravib96f7b52013-05-22 21:40:05 -07004341 beaconParams.bssIdx = psessionEntry->bssIdx;
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08004342 //Set change in beacon Interval
4343 beaconParams.beaconInterval = pChangeBIParams->beaconInterval;
Jeff Johnson312557b2013-04-03 16:27:48 -07004344 beaconParams.paramChangeBitmap = PARAM_BCN_INTERVAL_CHANGED;
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08004345 limSendBeaconParams(pMac, &beaconParams, psessionEntry);
4346 }
4347
4348 return;
4349} /*** end __limProcessSmeChangeBI(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf) ***/
4350
Jeff Johnson295189b2012-06-20 16:38:30 -07004351
4352
4353/** -------------------------------------------------------------
4354\fn limProcessSmeDelBaPeerInd
4355\brief handles indication message from HDD to send delete BA request
4356\param tpAniSirGlobal pMac
4357\param tANI_U32 pMsgBuf
4358\return None
4359-------------------------------------------------------------*/
4360void
4361limProcessSmeDelBaPeerInd(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
4362{
4363 tANI_U16 assocId =0;
4364 tpSmeDelBAPeerInd pSmeDelBAPeerInd = (tpSmeDelBAPeerInd)pMsgBuf;
4365 tpDphHashNode pSta;
4366 tpPESession psessionEntry;
4367 tANI_U8 sessionId;
4368
4369
4370
4371 if(NULL == pSmeDelBAPeerInd)
4372 return;
4373
4374 if ((psessionEntry = peFindSessionByBssid(pMac,pSmeDelBAPeerInd->bssId,&sessionId))==NULL)
4375 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004376 limLog(pMac, LOGE,FL("session does not exist for given bssId"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004377 return;
4378 }
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004379 limLog(pMac, LOGW, FL("called with staId = %d, tid = %d, baDirection = %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07004380 pSmeDelBAPeerInd->staIdx, pSmeDelBAPeerInd->baTID, pSmeDelBAPeerInd->baDirection);
4381
4382 pSta = dphLookupAssocId(pMac, pSmeDelBAPeerInd->staIdx, &assocId, &psessionEntry->dph.dphHashTable);
4383 if( eSIR_SUCCESS != limPostMlmDelBAReq( pMac,
4384 pSta,
4385 pSmeDelBAPeerInd->baDirection,
4386 pSmeDelBAPeerInd->baTID,
4387 eSIR_MAC_UNSPEC_FAILURE_REASON,psessionEntry))
4388 {
4389 limLog( pMac, LOGW,
4390 FL( "Failed to post LIM_MLM_DELBA_REQ to " ));
4391 if (pSta)
4392 limPrintMacAddr(pMac, pSta->staAddr, LOGW);
4393 }
4394}
4395
4396// --------------------------------------------------------------------
4397/**
4398 * __limProcessReportMessage
4399 *
4400 * FUNCTION: Processes the next received Radio Resource Management message
4401 *
4402 * LOGIC:
4403 *
4404 * ASSUMPTIONS:
4405 *
4406 * NOTE:
4407 *
4408 * @param None
4409 * @return None
4410 */
4411
4412void __limProcessReportMessage(tpAniSirGlobal pMac, tpSirMsgQ pMsg)
4413{
4414#ifdef WLAN_FEATURE_VOWIFI
4415 switch (pMsg->type)
4416 {
4417 case eWNI_SME_NEIGHBOR_REPORT_REQ_IND:
4418 rrmProcessNeighborReportReq( pMac, pMsg->bodyptr );
4419 break;
4420 case eWNI_SME_BEACON_REPORT_RESP_XMIT_IND:
4421 {
4422#if defined FEATURE_WLAN_CCX
4423 tpSirBeaconReportXmitInd pBcnReport=NULL;
4424 tpPESession psessionEntry=NULL;
4425 tANI_U8 sessionId;
4426
4427 if(pMsg->bodyptr == NULL)
4428 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004429 limLog(pMac, LOGE,FL("Buffer is Pointing to NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004430 return;
4431 }
4432 pBcnReport = (tpSirBeaconReportXmitInd )pMsg->bodyptr;
4433 if((psessionEntry = peFindSessionByBssid(pMac, pBcnReport->bssId,&sessionId))== NULL)
4434 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004435 limLog(pMac, LOGE, "Session Does not exist for given bssId");
Jeff Johnson295189b2012-06-20 16:38:30 -07004436 return;
4437 }
4438 if (psessionEntry->isCCXconnection)
4439 ccxProcessBeaconReportXmit( pMac, pMsg->bodyptr);
4440 else
4441#endif
4442 rrmProcessBeaconReportXmit( pMac, pMsg->bodyptr );
4443 }
4444 break;
4445 }
4446#endif
4447}
4448
4449#if defined(FEATURE_WLAN_CCX) || defined(WLAN_FEATURE_VOWIFI)
4450// --------------------------------------------------------------------
4451/**
4452 * limSendSetMaxTxPowerReq
4453 *
4454 * FUNCTION: Send SIR_HAL_SET_MAX_TX_POWER_REQ message to change the max tx power.
4455 *
4456 * LOGIC:
4457 *
4458 * ASSUMPTIONS:
4459 *
4460 * NOTE:
4461 *
4462 * @param txPower txPower to be set.
4463 * @param pSessionEntry session entry.
4464 * @return None
4465 */
4466tSirRetStatus
4467limSendSetMaxTxPowerReq ( tpAniSirGlobal pMac, tPowerdBm txPower, tpPESession pSessionEntry )
4468{
4469 tpMaxTxPowerParams pMaxTxParams = NULL;
4470 tSirRetStatus retCode = eSIR_SUCCESS;
4471 tSirMsgQ msgQ;
4472
4473 if( pSessionEntry == NULL )
4474 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004475 PELOGE(limLog(pMac, LOGE, "%s:%d: Inavalid parameters", __func__, __LINE__ );)
Jeff Johnson295189b2012-06-20 16:38:30 -07004476 return eSIR_FAILURE;
4477 }
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304478
4479 pMaxTxParams = vos_mem_malloc(sizeof(tMaxTxPowerParams));
4480 if ( NULL == pMaxTxParams )
Jeff Johnson295189b2012-06-20 16:38:30 -07004481 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004482 limLog( pMac, LOGP, "%s:%d:Unable to allocate memory for pMaxTxParams ", __func__, __LINE__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004483 return eSIR_MEM_ALLOC_FAILED;
4484
4485 }
4486#if defined(WLAN_VOWIFI_DEBUG) || defined(FEATURE_WLAN_CCX)
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004487 PELOG1(limLog( pMac, LOG1, "%s:%d: Allocated memory for pMaxTxParams...will be freed in other module", __func__, __LINE__ );)
Jeff Johnson295189b2012-06-20 16:38:30 -07004488#endif
Kiran Kumar Lokerea4db3dc2013-03-25 18:05:24 -07004489 if( pMaxTxParams == NULL )
4490 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004491 limLog( pMac, LOGE, "%s:%d: pMaxTxParams is NULL", __func__, __LINE__);
Kiran Kumar Lokerea4db3dc2013-03-25 18:05:24 -07004492 return eSIR_FAILURE;
4493 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004494 pMaxTxParams->power = txPower;
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304495 vos_mem_copy( pMaxTxParams->bssId, pSessionEntry->bssId, sizeof(tSirMacAddr) );
4496 vos_mem_copy( pMaxTxParams->selfStaMacAddr, pSessionEntry->selfMacAddr, sizeof(tSirMacAddr) );
Jeff Johnson295189b2012-06-20 16:38:30 -07004497
Jeff Johnson68ce9c42013-04-08 10:33:28 -07004498 msgQ.type = WDA_SET_MAX_TX_POWER_REQ;
4499 msgQ.bodyptr = pMaxTxParams;
4500 msgQ.bodyval = 0;
4501 PELOG1(limLog(pMac, LOG1, FL("Posting WDA_SET_MAX_TX_POWER_REQ to WDA"));)
4502 MTRACE(macTraceMsgTx(pMac, pSessionEntry->peSessionId, msgQ.type));
4503 retCode = wdaPostCtrlMsg(pMac, &msgQ);
4504 if (eSIR_SUCCESS != retCode)
4505 {
4506 PELOGE(limLog(pMac, LOGE, FL("wdaPostCtrlMsg() failed"));)
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304507 vos_mem_free(pMaxTxParams);
Jeff Johnson68ce9c42013-04-08 10:33:28 -07004508 }
4509 return retCode;
Jeff Johnson295189b2012-06-20 16:38:30 -07004510}
4511#endif
4512
4513/**
4514 * __limProcessSmeAddStaSelfReq()
4515 *
4516 *FUNCTION:
4517 * This function is called to process SME_ADD_STA_SELF_REQ message
4518 * from SME. It sends a SIR_HAL_ADD_STA_SELF_REQ message to HAL.
4519 *
4520 *LOGIC:
4521 *
4522 *ASSUMPTIONS:
4523 *
4524 *NOTE:
4525 *
4526 * @param pMac Pointer to Global MAC structure
4527 * @param *pMsgBuf A pointer to the SME message buffer
4528 * @return None
4529 */
4530
4531static void
4532__limProcessSmeAddStaSelfReq(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
4533{
4534 tSirMsgQ msg;
4535 tpAddStaSelfParams pAddStaSelfParams;
4536 tpSirSmeAddStaSelfReq pSmeReq = (tpSirSmeAddStaSelfReq) pMsgBuf;
4537
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304538 pAddStaSelfParams = vos_mem_malloc(sizeof(tAddStaSelfParams));
4539 if ( NULL == pAddStaSelfParams )
Jeff Johnson295189b2012-06-20 16:38:30 -07004540 {
4541 limLog( pMac, LOGP, FL("Unable to allocate memory for tAddSelfStaParams") );
4542 return;
4543 }
4544
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304545 vos_mem_copy( pAddStaSelfParams->selfMacAddr, pSmeReq->selfMacAddr, sizeof(tSirMacAddr) );
4546
Jeff Johnson295189b2012-06-20 16:38:30 -07004547 msg.type = SIR_HAL_ADD_STA_SELF_REQ;
4548 msg.reserved = 0;
4549 msg.bodyptr = pAddStaSelfParams;
4550 msg.bodyval = 0;
4551
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004552 PELOGW(limLog(pMac, LOG1, FL("sending SIR_HAL_ADD_STA_SELF_REQ msg to HAL"));)
Jeff Johnsone7245742012-09-05 17:12:55 -07004553 MTRACE(macTraceMsgTx(pMac, NO_SESSION, msg.type));
Jeff Johnson295189b2012-06-20 16:38:30 -07004554
4555 if(eSIR_SUCCESS != wdaPostCtrlMsg(pMac, &msg))
4556 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004557 limLog(pMac, LOGP, FL("wdaPostCtrlMsg failed"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004558 }
4559 return;
4560} /*** end __limProcessAddStaSelfReq() ***/
4561
4562
4563/**
4564 * __limProcessSmeDelStaSelfReq()
4565 *
4566 *FUNCTION:
4567 * This function is called to process SME_DEL_STA_SELF_REQ message
4568 * from SME. It sends a SIR_HAL_DEL_STA_SELF_REQ message to HAL.
4569 *
4570 *LOGIC:
4571 *
4572 *ASSUMPTIONS:
4573 *
4574 *NOTE:
4575 *
4576 * @param pMac Pointer to Global MAC structure
4577 * @param *pMsgBuf A pointer to the SME message buffer
4578 * @return None
4579 */
4580
4581static void
4582__limProcessSmeDelStaSelfReq(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
4583{
4584 tSirMsgQ msg;
4585 tpDelStaSelfParams pDelStaSelfParams;
4586 tpSirSmeDelStaSelfReq pSmeReq = (tpSirSmeDelStaSelfReq) pMsgBuf;
4587
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304588 pDelStaSelfParams = vos_mem_malloc(sizeof( tDelStaSelfParams));
4589 if ( NULL == pDelStaSelfParams )
Jeff Johnson295189b2012-06-20 16:38:30 -07004590 {
4591 limLog( pMac, LOGP, FL("Unable to allocate memory for tDelStaSelfParams") );
4592 return;
4593 }
4594
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304595 vos_mem_copy( pDelStaSelfParams->selfMacAddr, pSmeReq->selfMacAddr, sizeof(tSirMacAddr) );
Jeff Johnson295189b2012-06-20 16:38:30 -07004596
4597 msg.type = SIR_HAL_DEL_STA_SELF_REQ;
4598 msg.reserved = 0;
4599 msg.bodyptr = pDelStaSelfParams;
4600 msg.bodyval = 0;
4601
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004602 PELOGW(limLog(pMac, LOG1, FL("sending SIR_HAL_ADD_STA_SELF_REQ msg to HAL"));)
Jeff Johnsone7245742012-09-05 17:12:55 -07004603 MTRACE(macTraceMsgTx(pMac, NO_SESSION, msg.type));
Jeff Johnson295189b2012-06-20 16:38:30 -07004604
4605 if(eSIR_SUCCESS != wdaPostCtrlMsg(pMac, &msg))
4606 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004607 limLog(pMac, LOGP, FL("wdaPostCtrlMsg failed"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004608 }
4609 return;
4610} /*** end __limProcessSmeDelStaSelfReq() ***/
4611
4612
Jeff Johnson295189b2012-06-20 16:38:30 -07004613/**
4614 * __limProcessSmeRegisterMgmtFrameReq()
4615 *
4616 *FUNCTION:
4617 * This function is called to process eWNI_SME_REGISTER_MGMT_FRAME_REQ message
4618 * from SME. It Register this information within PE.
4619 *
4620 *LOGIC:
4621 *
4622 *ASSUMPTIONS:
4623 *
4624 *NOTE:
4625 *
4626 * @param pMac Pointer to Global MAC structure
4627 * @param *pMsgBuf A pointer to the SME message buffer
4628 * @return None
4629 */
4630static void
4631__limProcessSmeRegisterMgmtFrameReq(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
4632{
4633 VOS_STATUS vosStatus;
4634 tpSirRegisterMgmtFrame pSmeReq = (tpSirRegisterMgmtFrame)pMsgBuf;
4635 tpLimMgmtFrameRegistration pLimMgmtRegistration = NULL, pNext = NULL;
Jeff Johnsond13512a2012-07-17 11:42:19 -07004636 tANI_BOOLEAN match = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07004637 PELOG1(limLog(pMac, LOG1,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004638 FL("registerFrame %d, frameType %d, matchLen %d"),
Jeff Johnsone7245742012-09-05 17:12:55 -07004639 pSmeReq->registerFrame, pSmeReq->frameType, pSmeReq->matchLen);)
Jeff Johnson295189b2012-06-20 16:38:30 -07004640
Jeff Johnsond13512a2012-07-17 11:42:19 -07004641 /* First check whether entry exists already*/
4642
4643 vos_list_peek_front(&pMac->lim.gLimMgmtFrameRegistratinQueue,
4644 (vos_list_node_t**)&pLimMgmtRegistration);
4645
4646 while(pLimMgmtRegistration != NULL)
4647 {
4648 if (pLimMgmtRegistration->frameType == pSmeReq->frameType)
4649 {
4650 if(pSmeReq->matchLen)
4651 {
4652 if (pLimMgmtRegistration->matchLen == pSmeReq->matchLen)
4653 {
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304654 if (vos_mem_compare( pLimMgmtRegistration->matchData,
Jeff Johnsond13512a2012-07-17 11:42:19 -07004655 pSmeReq->matchData, pLimMgmtRegistration->matchLen))
4656 {
Madan Mohan Koyyalamudic537df22012-10-22 15:07:08 -07004657 /* found match! */
4658 match = VOS_TRUE;
4659 break;
Jeff Johnsond13512a2012-07-17 11:42:19 -07004660 }
4661 }
4662 }
4663 else
4664 {
Madan Mohan Koyyalamudic537df22012-10-22 15:07:08 -07004665 /* found match! */
Jeff Johnsond13512a2012-07-17 11:42:19 -07004666 match = VOS_TRUE;
4667 break;
4668 }
4669 }
4670 vosStatus = vos_list_peek_next (
4671 &pMac->lim.gLimMgmtFrameRegistratinQueue,
4672 (vos_list_node_t*) pLimMgmtRegistration,
4673 (vos_list_node_t**) &pNext );
4674
4675 pLimMgmtRegistration = pNext;
4676 pNext = NULL;
4677
4678 }
4679
4680 if (match)
4681 {
4682 vos_list_remove_node(&pMac->lim.gLimMgmtFrameRegistratinQueue,
4683 (vos_list_node_t*)pLimMgmtRegistration);
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304684 vos_mem_free(pLimMgmtRegistration);
Jeff Johnsond13512a2012-07-17 11:42:19 -07004685 }
4686
Jeff Johnson295189b2012-06-20 16:38:30 -07004687 if(pSmeReq->registerFrame)
4688 {
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304689 pLimMgmtRegistration = vos_mem_malloc(sizeof(tLimMgmtFrameRegistration) + pSmeReq->matchLen);
4690 if ( pLimMgmtRegistration != NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -07004691 {
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304692 vos_mem_set((void*)pLimMgmtRegistration,
4693 sizeof(tLimMgmtFrameRegistration) + pSmeReq->matchLen, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004694 pLimMgmtRegistration->frameType = pSmeReq->frameType;
4695 pLimMgmtRegistration->matchLen = pSmeReq->matchLen;
4696 pLimMgmtRegistration->sessionId = pSmeReq->sessionId;
4697 if(pSmeReq->matchLen)
4698 {
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304699 vos_mem_copy(pLimMgmtRegistration->matchData,
4700 pSmeReq->matchData, pSmeReq->matchLen);
Jeff Johnson295189b2012-06-20 16:38:30 -07004701 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004702 vos_list_insert_front(&pMac->lim.gLimMgmtFrameRegistratinQueue,
4703 &pLimMgmtRegistration->node);
4704 }
4705 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004706
4707 return;
4708} /*** end __limProcessSmeRegisterMgmtFrameReq() ***/
Viral Modid86bde22012-12-10 13:09:21 -08004709
4710static tANI_BOOLEAN
Viral Modid440e682013-03-06 02:25:31 -08004711__limInsertSingleShotNOAForScan(tpAniSirGlobal pMac, tANI_U32 noaDuration)
Viral Modid86bde22012-12-10 13:09:21 -08004712{
4713 tpP2pPsParams pMsgNoA;
4714 tSirMsgQ msg;
Vinay Malekal62757362012-12-17 12:15:51 -08004715
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304716 pMsgNoA = vos_mem_malloc(sizeof( tP2pPsConfig ));
4717 if ( NULL == pMsgNoA )
Viral Modid86bde22012-12-10 13:09:21 -08004718 {
4719 limLog( pMac, LOGP,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004720 FL( "Unable to allocate memory during NoA Update" ));
Viral Modid440e682013-03-06 02:25:31 -08004721 goto error;
Viral Modid86bde22012-12-10 13:09:21 -08004722 }
4723
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304724 vos_mem_set((tANI_U8 *)pMsgNoA, sizeof(tP2pPsConfig), 0);
Viral Modid86bde22012-12-10 13:09:21 -08004725 /* Below params used for opp PS/periodic NOA and are don't care in this case - so initialized to 0 */
4726 pMsgNoA->opp_ps = 0;
4727 pMsgNoA->ctWindow = 0;
4728 pMsgNoA->duration = 0;
4729 pMsgNoA->interval = 0;
4730 pMsgNoA->count = 0;
Vinay Malekal62757362012-12-17 12:15:51 -08004731
Vinay Malekal62757362012-12-17 12:15:51 -08004732 /* Below params used for Single Shot NOA - so assign proper values */
4733 pMsgNoA->psSelection = P2P_SINGLE_NOA;
Viral Modid440e682013-03-06 02:25:31 -08004734 pMsgNoA->single_noa_duration = noaDuration;
Gopichand Nakkala096a1052012-12-21 07:05:34 -08004735
Viral Modid86bde22012-12-10 13:09:21 -08004736 /* Start Insert NOA timer
4737 * If insert NOA req fails or NOA rsp fails or start NOA indication doesn't come from FW due to GO session deletion
Viral Modid440e682013-03-06 02:25:31 -08004738 * or any other failure or reason, we still need to process the deferred SME req. The insert NOA
4739 * timer of 500 ms will ensure the stored SME req always gets processed
Viral Modid86bde22012-12-10 13:09:21 -08004740 */
4741 if (tx_timer_activate(&pMac->lim.limTimers.gLimP2pSingleShotNoaInsertTimer)
4742 == TX_TIMER_ERROR)
4743 {
4744 /// Could not activate Insert NOA timer.
4745 // Log error
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004746 limLog(pMac, LOGP, FL("could not activate Insert Single Shot NOA during scan timer"));
Viral Modid86bde22012-12-10 13:09:21 -08004747
4748 // send the scan response back with status failure and do not even call insert NOA
4749 limSendSmeScanRsp(pMac, sizeof(tSirSmeScanRsp), eSIR_SME_SCAN_FAILED, pMac->lim.gSmeSessionId, pMac->lim.gTransactionId);
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304750 vos_mem_free(pMsgNoA);
Viral Modid440e682013-03-06 02:25:31 -08004751 goto error;
Viral Modid86bde22012-12-10 13:09:21 -08004752 }
4753
Viral Modid440e682013-03-06 02:25:31 -08004754 MTRACE(macTrace(pMac, TRACE_CODE_TIMER_ACTIVATE, NO_SESSION, eLIM_INSERT_SINGLESHOT_NOA_TIMER));
4755
Viral Modid86bde22012-12-10 13:09:21 -08004756 msg.type = WDA_SET_P2P_GO_NOA_REQ;
4757 msg.reserved = 0;
4758 msg.bodyptr = pMsgNoA;
4759 msg.bodyval = 0;
4760
4761 if(eSIR_SUCCESS != wdaPostCtrlMsg(pMac, &msg))
4762 {
4763 /* In this failure case, timer is already started, so its expiration will take care of sending scan response */
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004764 limLog(pMac, LOGP, FL("wdaPost Msg failed"));
Viral Modid440e682013-03-06 02:25:31 -08004765 /* Deactivate the NOA timer in failure case */
4766 limDeactivateAndChangeTimer(pMac, eLIM_INSERT_SINGLESHOT_NOA_TIMER);
4767 goto error;
Viral Modid86bde22012-12-10 13:09:21 -08004768 }
Viral Modid440e682013-03-06 02:25:31 -08004769 return FALSE;
Viral Modid86bde22012-12-10 13:09:21 -08004770
Viral Modid440e682013-03-06 02:25:31 -08004771error:
4772 /* In any of the failure cases, just go ahead with the processing of registered deferred SME request without
4773 * worrying about the NOA
4774 */
4775 limProcessRegdDefdSmeReqAfterNOAStart(pMac);
4776 // msg buffer is consumed and freed in above function so return FALSE
Viral Modid86bde22012-12-10 13:09:21 -08004777 return FALSE;
4778
4779}
4780
Viral Modid440e682013-03-06 02:25:31 -08004781static void __limRegisterDeferredSmeReqForNOAStart(tpAniSirGlobal pMac, tANI_U16 msgType, tANI_U32 *pMsgBuf)
4782{
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004783 limLog(pMac, LOG1, FL("Reg msgType %d"), msgType) ;
Viral Modid440e682013-03-06 02:25:31 -08004784 pMac->lim.gDeferMsgTypeForNOA = msgType;
4785 pMac->lim.gpDefdSmeMsgForNOA = pMsgBuf;
4786}
4787
4788static void __limDeregisterDeferredSmeReqAfterNOAStart(tpAniSirGlobal pMac)
4789{
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004790 limLog(pMac, LOG1, FL("Dereg msgType %d"), pMac->lim.gDeferMsgTypeForNOA) ;
Viral Modid440e682013-03-06 02:25:31 -08004791 pMac->lim.gDeferMsgTypeForNOA = 0;
4792 if (pMac->lim.gpDefdSmeMsgForNOA != NULL)
4793 {
4794 /* __limProcessSmeScanReq consumed the buffer. We can free it. */
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304795 vos_mem_free(pMac->lim.gpDefdSmeMsgForNOA);
Viral Modid440e682013-03-06 02:25:31 -08004796 pMac->lim.gpDefdSmeMsgForNOA = NULL;
4797 }
4798}
4799
4800static
4801tANI_U32 limCalculateNOADuration(tpAniSirGlobal pMac, tANI_U16 msgType, tANI_U32 *pMsgBuf)
4802{
4803 tANI_U32 noaDuration = 0;
4804
4805 switch (msgType)
4806 {
4807 case eWNI_SME_SCAN_REQ:
4808 {
4809 tANI_U32 val;
4810 tANI_U8 i;
4811 tpSirSmeScanReq pScanReq = (tpSirSmeScanReq) pMsgBuf;
4812 if (wlan_cfgGetInt(pMac, WNI_CFG_PASSIVE_MAXIMUM_CHANNEL_TIME, &val) != eSIR_SUCCESS)
4813 {
4814 /*
4815 * Could not get max channel value
4816 * from CFG. Log error.
4817 */
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004818 limLog(pMac, LOGP, FL("could not retrieve passive max channel value"));
Viral Modid440e682013-03-06 02:25:31 -08004819
4820 /* use a default value of 110ms */
4821 val = DEFAULT_PASSIVE_MAX_CHANNEL_TIME;
4822 }
4823
4824 for (i = 0; i < pScanReq->channelList.numChannels; i++) {
4825 tANI_U8 channelNum = pScanReq->channelList.channelNumber[i];
4826
4827 if (limActiveScanAllowed(pMac, channelNum)) {
4828 /* Use min + max channel time to calculate the total duration of scan */
4829 noaDuration += pScanReq->minChannelTime + pScanReq->maxChannelTime;
4830 } else {
4831 /* using the value from WNI_CFG_PASSIVE_MINIMUM_CHANNEL_TIME as is done in
4832 * void limContinuePostChannelScan(tpAniSirGlobal pMac)
4833 */
4834 noaDuration += val;
4835 }
4836 }
4837
4838 /* Adding an overhead of 20ms to account for the scan messaging delays */
4839 noaDuration += SCAN_MESSAGING_OVERHEAD;
4840 noaDuration *= CONV_MS_TO_US;
4841
4842 break;
4843 }
4844
4845 case eWNI_SME_OEM_DATA_REQ:
4846 noaDuration = OEM_DATA_NOA_DURATION*CONV_MS_TO_US; // use 60 msec as default
4847 break;
4848
4849 case eWNI_SME_REMAIN_ON_CHANNEL_REQ:
4850 {
4851 tSirRemainOnChnReq *pRemainOnChnReq = (tSirRemainOnChnReq *) pMsgBuf;
4852 noaDuration = (pRemainOnChnReq->duration)*CONV_MS_TO_US;
4853 break;
4854 }
4855
4856 case eWNI_SME_JOIN_REQ:
4857 noaDuration = JOIN_NOA_DURATION*CONV_MS_TO_US;
4858 break;
4859
4860 default:
4861 noaDuration = 0;
4862 break;
4863
4864 }
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004865 limLog(pMac, LOGW, FL("msgType %d noa %d"), msgType, noaDuration);
Viral Modid440e682013-03-06 02:25:31 -08004866 return noaDuration;
4867}
4868
4869void limProcessRegdDefdSmeReqAfterNOAStart(tpAniSirGlobal pMac)
4870{
Gopichand Nakkala7c4c3b92013-03-25 18:08:31 +05304871 tANI_BOOLEAN bufConsumed = TRUE;
Viral Modid440e682013-03-06 02:25:31 -08004872
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004873 limLog(pMac, LOG1, FL("Process defd sme req %d"), pMac->lim.gDeferMsgTypeForNOA);
Viral Modid440e682013-03-06 02:25:31 -08004874 if ( (pMac->lim.gDeferMsgTypeForNOA != 0) &&
4875 (pMac->lim.gpDefdSmeMsgForNOA != NULL) )
4876 {
4877 switch (pMac->lim.gDeferMsgTypeForNOA)
4878 {
4879 case eWNI_SME_SCAN_REQ:
4880 __limProcessSmeScanReq(pMac, pMac->lim.gpDefdSmeMsgForNOA);
4881 break;
4882 case eWNI_SME_OEM_DATA_REQ:
4883 __limProcessSmeOemDataReq(pMac, pMac->lim.gpDefdSmeMsgForNOA);
4884 break;
4885 case eWNI_SME_REMAIN_ON_CHANNEL_REQ:
Gopichand Nakkala7c4c3b92013-03-25 18:08:31 +05304886 bufConsumed = limProcessRemainOnChnlReq(pMac, pMac->lim.gpDefdSmeMsgForNOA);
4887 /* limProcessRemainOnChnlReq doesnt want us to free the buffer since
4888 * it is freed in limRemainOnChnRsp. this change is to avoid "double free"
4889 */
4890 if (FALSE == bufConsumed)
4891 {
4892 pMac->lim.gpDefdSmeMsgForNOA = NULL;
4893 }
Viral Modid440e682013-03-06 02:25:31 -08004894 break;
4895 case eWNI_SME_JOIN_REQ:
4896 __limProcessSmeJoinReq(pMac, pMac->lim.gpDefdSmeMsgForNOA);
4897 break;
4898 default:
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004899 limLog(pMac, LOGE, FL("Unknown deferred msg type %d"), pMac->lim.gDeferMsgTypeForNOA);
Viral Modid440e682013-03-06 02:25:31 -08004900 break;
4901 }
4902 __limDeregisterDeferredSmeReqAfterNOAStart(pMac);
4903 }
4904 else
4905 {
4906 limLog( pMac, LOGW, FL("start received from FW when no sme deferred msg pending. Do nothing."
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004907 "It might happen sometime when NOA start ind and timeout happen at the same time"));
Viral Modid440e682013-03-06 02:25:31 -08004908 }
4909}
Jeff Johnson295189b2012-06-20 16:38:30 -07004910
Mohit Khanna698ba2a2012-12-04 15:08:18 -08004911#ifdef FEATURE_WLAN_TDLS_INTERNAL
4912/*
4913 * Process Discovery request recieved from SME and transmit to AP.
4914 */
4915static tSirRetStatus limProcessSmeDisStartReq(tpAniSirGlobal pMac,
4916 tANI_U32 *pMsgBuf)
4917{
4918 /* get all discovery request parameters */
4919 tSirTdlsDisReq *disReq = (tSirTdlsDisReq *) pMsgBuf ;
4920 tpPESession psessionEntry;
4921 tANI_U8 sessionId;
4922
4923 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004924 ("Discovery Req Recieved")) ;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08004925
4926 if((psessionEntry = peFindSessionByBssid(pMac, disReq->bssid, &sessionId))
4927 == NULL)
4928 {
4929 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004930 "PE Session does not exist for given sme sessionId %d",
Mohit Khanna698ba2a2012-12-04 15:08:18 -08004931 disReq->sessionId);
4932 goto lim_tdls_dis_start_error;
4933 }
4934
4935 /* check if we are in proper state to work as TDLS client */
4936 if (psessionEntry->limSystemRole != eLIM_STA_ROLE)
4937 {
4938 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004939 "dis req received in wrong system Role %d",
Mohit Khanna698ba2a2012-12-04 15:08:18 -08004940 psessionEntry->limSystemRole);
4941 goto lim_tdls_dis_start_error;
4942 }
4943
4944 /*
4945 * if we are still good, go ahead and check if we are in proper state to
4946 * do TDLS discovery procedure.
4947 */
4948 if ((psessionEntry->limSmeState != eLIM_SME_ASSOCIATED_STATE) &&
4949 (psessionEntry->limSmeState != eLIM_SME_LINK_EST_STATE))
4950 {
4951
4952 limLog(pMac, LOGE, "dis req received in invalid LIMsme \
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004953 state (%d)", psessionEntry->limSmeState);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08004954 goto lim_tdls_dis_start_error;
4955 }
4956
4957 /*
4958 * if we are still good, go ahead and transmit TDLS discovery request,
4959 * and save Dis Req info for future reference.
4960 */
4961
4962#if 0 // TDLS_hklee: D13 no need to open Addr2 unknown data packet
4963 /*
4964 * send message to HAL to set RXP filters to receieve frame on
4965 * direct link..
4966 */
4967 //limSetLinkState(pMac, eSIR_LINK_TDLS_DISCOVERY_STATE,
4968 // psessionEntry->bssId) ;
4969#endif
4970
4971 /* save dis request message for matching dialog token */
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304972 vos_mem_copy((tANI_U8 *) &pMac->lim.gLimTdlsDisReq,
4973 (tANI_U8 *) disReq, sizeof(tSirTdlsDisReq));
Mohit Khanna698ba2a2012-12-04 15:08:18 -08004974
4975 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004976 "Transmit Discovery Request Frame") ;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08004977 /* format TDLS discovery request frame and transmit it */
4978 limSendTdlsDisReqFrame(pMac, disReq->peerMac, disReq->dialog,
4979 psessionEntry) ;
4980
4981 /* prepare for response */
4982 pMac->lim.gLimTdlsDisStaCount = 0 ;
4983 pMac->lim.gLimTdlsDisResultList = NULL ;
4984
4985 /*
4986 * start TDLS discovery request timer to wait for discovery responses
4987 * from all TDLS enabled clients in BSS.
4988 */
4989
4990 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004991 ("Start Discovery request Timeout Timer")) ;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08004992 MTRACE(macTrace(pMac, TRACE_CODE_TIMER_ACTIVATE, 0,
4993 eLIM_TDLS_DISCOVERY_RSP_WAIT));
4994
4995 /* assign appropriate sessionId to the timer object */
4996 pMac->lim.limTimers.gLimTdlsDisRspWaitTimer.sessionId =
4997 psessionEntry->peSessionId;
4998
4999 if (tx_timer_activate(&pMac->lim.limTimers.gLimTdlsDisRspWaitTimer)
5000 != TX_SUCCESS)
5001 {
5002 limLog(pMac, LOGP, FL("TDLS discovery response timer \
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005003 activation failed!"));
Mohit Khanna698ba2a2012-12-04 15:08:18 -08005004 goto lim_tdls_dis_start_error;
5005 }
5006 /*
5007 * when timer expired, eWNI_SME_TDLS_DISCOVERY_START_RSP is sent
5008 * back to SME
5009 */
5010 return (eSIR_SUCCESS) ;
5011lim_tdls_dis_start_error:
5012 /* in error case, PE has to sent the response SME immediately with error code */
5013 limSendSmeTdlsDisRsp(pMac, eSIR_FAILURE,
5014 eWNI_SME_TDLS_DISCOVERY_START_RSP);
5015 return eSIR_FAILURE;
5016}
5017/*
5018 * Process link start request recieved from SME and transmit to AP.
5019 */
5020eHalStatus limProcessSmeLinkStartReq(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
5021{
5022 /* get all discovery request parameters */
5023 tSirTdlsSetupReq *setupReq = (tSirTdlsSetupReq *) pMsgBuf ;
5024 tLimTdlsLinkSetupInfo *linkSetupInfo;
5025 //tLimTdlsLinkSetupPeer *setupPeer;
5026 tpPESession psessionEntry;
5027 tANI_U8 sessionId;
5028 eHalStatus status;
5029
5030 if((psessionEntry = peFindSessionByBssid(pMac,
5031 setupReq->bssid, &sessionId)) == NULL)
5032 {
5033 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005034 "PE Session does not exist for given sme sessionId %d",
Mohit Khanna698ba2a2012-12-04 15:08:18 -08005035 setupReq->sessionId);
5036 goto lim_tdls_link_start_error;
5037 }
5038
5039 /* check if we are in proper state to work as TDLS client */
5040 if (psessionEntry->limSystemRole != eLIM_STA_ROLE)
5041 {
5042 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005043 "TDLS link setup req received in wrong system Role %d",
Mohit Khanna698ba2a2012-12-04 15:08:18 -08005044 psessionEntry->limSystemRole);
5045 goto lim_tdls_link_start_error;
5046 }
5047
5048 /*
5049 * if we are still good, go ahead and check if we are in proper state to
5050 * do TDLS setup procedure.
5051 */
5052 if ((psessionEntry->limSmeState != eLIM_SME_ASSOCIATED_STATE) &&
5053 (psessionEntry->limSmeState != eLIM_SME_LINK_EST_STATE))
5054 {
5055 limLog(pMac, LOGE, "Setup request in invalid LIMsme \
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005056 state (%d)", pMac->lim.gLimSmeState);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08005057 goto lim_tdls_link_start_error;
5058 }
5059
5060 /*
5061 * Now, go ahead and transmit TDLS discovery request, and save setup Req
5062 * info for future reference.
5063 */
5064 /* create node for Link setup */
5065 linkSetupInfo = &pMac->lim.gLimTdlsLinkSetupInfo ;
5066 //setupPeer = NULL ;
5067
5068 status = limTdlsPrepareSetupReqFrame(pMac, linkSetupInfo, setupReq->dialog,
5069 setupReq->peerMac, psessionEntry) ;
5070 if(eHAL_STATUS_SUCCESS == status)
5071 /* in case of success, eWNI_SME_TDLS_LINK_START_RSP is sent back to SME later when
5072 TDLS setup cnf TX complete is successful. */
5073 return eSIR_SUCCESS;
5074#if 0
5075
5076 /*
5077 * we allocate the TDLS setup Peer Memory here, we will free'd this
Jeff Johnsonfeddb2d2012-12-10 14:41:22 -08005078 * memory after teardown, if the link is successfully setup or
Mohit Khanna698ba2a2012-12-04 15:08:18 -08005079 * free this memory if any timeout is happen in link setup procedure
5080 */
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05305081 setupPeer = vos_mem_malloc(sizeof( tLimTdlsLinkSetupPeer ));
5082 if ( NULL == setupPeer )
Mohit Khanna698ba2a2012-12-04 15:08:18 -08005083 {
5084 limLog( pMac, LOGP,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005085 FL( "Unable to allocate memory during ADD_STA" ));
Mohit Khanna698ba2a2012-12-04 15:08:18 -08005086 VOS_ASSERT(0) ;
5087 return eSIR_MEM_ALLOC_FAILED;
5088 }
5089 setupPeer->dialog = setupReq->dialog ;
5090 setupPeer->tdls_prev_link_state = setupPeer->tdls_link_state ;
5091 setupPeer->tdls_link_state = TDLS_LINK_SETUP_START_STATE ;
5092 /* TDLS_sessionize: remember sessionId for future */
5093 setupPeer->tdls_sessionId = psessionEntry->peSessionId;
5094 setupPeer->tdls_bIsResponder = 1;
5095
5096 /*
5097 * we only populate peer MAC, so it can assit us to find the
5098 * TDLS peer after response/or after response timeout
5099 */
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05305100 vos_mem_copy(setupPeer->peerMac, setupReq->peerMac,
Mohit Khanna698ba2a2012-12-04 15:08:18 -08005101 sizeof(tSirMacAddr)) ;
5102 /* format TDLS discovery request frame and transmit it */
5103 limSendTdlsLinkSetupReqFrame(pMac, setupReq->peerMac,
5104 setupReq->dialog, psessionEntry, NULL, 0) ;
5105
5106 limStartTdlsTimer(pMac, psessionEntry->peSessionId,
5107 &setupPeer->gLimTdlsLinkSetupRspTimeoutTimer,
5108 (tANI_U32)setupPeer->peerMac, WNI_CFG_TDLS_LINK_SETUP_RSP_TIMEOUT,
5109 SIR_LIM_TDLS_LINK_SETUP_RSP_TIMEOUT) ;
5110 /* update setup peer list */
5111 setupPeer->next = linkSetupInfo->tdlsLinkSetupList ;
5112 linkSetupInfo->tdlsLinkSetupList = setupPeer ;
5113 /* in case of success, eWNI_SME_TDLS_LINK_START_RSP is sent back to SME later when
5114 TDLS setup cnf TX complete is successful. --> see limTdlsSetupCnfTxComplete() */
5115 return eSIR_SUCCESS ;
5116#endif
5117lim_tdls_link_start_error:
5118 /* in case of error, return immediately to SME */
5119 limSendSmeTdlsLinkStartRsp(pMac, eSIR_FAILURE, setupReq->peerMac,
5120 eWNI_SME_TDLS_LINK_START_RSP);
5121 return eSIR_FAILURE ;
5122}
5123
5124/*
5125 * Process link teardown request recieved from SME and transmit to AP.
5126 */
5127eHalStatus limProcessSmeTeardownReq(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
5128{
5129 /* get all discovery request parameters */
5130 tSirTdlsTeardownReq *teardownReq = (tSirTdlsTeardownReq *) pMsgBuf ;
5131 tLimTdlsLinkSetupPeer *setupPeer;
5132 tpPESession psessionEntry;
5133 tANI_U8 sessionId;
5134
5135 if((psessionEntry = peFindSessionByBssid(pMac, teardownReq->bssid, &sessionId)) == NULL)
5136 {
5137 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005138 "PE Session does not exist for given sme sessionId %d", teardownReq->sessionId);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08005139 goto lim_tdls_teardown_req_error;
5140 }
5141
5142 /* check if we are in proper state to work as TDLS client */
5143 if (psessionEntry->limSystemRole != eLIM_STA_ROLE)
5144 {
5145 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005146 "TDLS teardown req received in wrong system Role %d", psessionEntry->limSystemRole);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08005147 goto lim_tdls_teardown_req_error;
5148 }
5149
5150 /*
5151 * if we are still good, go ahead and check if we are in proper state to
5152 * do TDLS setup procedure.
5153 */
5154 if ((psessionEntry->limSmeState != eLIM_SME_ASSOCIATED_STATE) &&
5155 (psessionEntry->limSmeState != eLIM_SME_LINK_EST_STATE))
5156 {
5157 limLog(pMac, LOGE, "TDLS teardwon req received in invalid LIMsme \
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005158 state (%d)", psessionEntry->limSmeState);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08005159 goto lim_tdls_teardown_req_error;
5160 }
5161
5162 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005163 "Teardown for peer = %02x,%02x,%02x,%02x,%02x,%02x",
Mohit Khanna698ba2a2012-12-04 15:08:18 -08005164 teardownReq->peerMac[0],
5165 teardownReq->peerMac[1],
5166 teardownReq->peerMac[2],
5167 teardownReq->peerMac[3],
5168 teardownReq->peerMac[4],
5169 teardownReq->peerMac[5]) ;
5170 /*
5171 * Now, go ahead and transmit TDLS teardown request, and save teardown info
5172 * info for future reference.
5173 */
5174 /* Verify if this link is setup */
5175 setupPeer = NULL ;
5176 limTdlsFindLinkPeer(pMac, teardownReq->peerMac, &setupPeer);
5177 if(NULL == setupPeer)
5178 {
5179 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005180 ("invalid Peer on teardown ")) ;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08005181 goto lim_tdls_teardown_req_error;
5182 }
5183
5184
5185 (setupPeer)->tdls_prev_link_state = (setupPeer)->tdls_link_state ;
5186 (setupPeer)->tdls_link_state = TDLS_LINK_TEARDOWN_START_STATE ;
5187 /* TDLS_sessionize: check sessionId in case */
5188 if((setupPeer)->tdls_sessionId != psessionEntry->peSessionId)
5189 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005190 limLog(pMac, LOGE, "TDLS teardown req; stored sessionId (%d) not matched from peSessionId (%d)", \
Mohit Khanna698ba2a2012-12-04 15:08:18 -08005191 (setupPeer)->tdls_sessionId, psessionEntry->limSmeState);
5192 (setupPeer)->tdls_sessionId = psessionEntry->peSessionId;
5193 }
5194
5195 /* format TDLS teardown request frame and transmit it */
5196 if(eSIR_SUCCESS != limSendTdlsTeardownFrame(pMac, teardownReq->peerMac,
5197 eSIR_MAC_TDLS_TEARDOWN_UNSPEC_REASON, psessionEntry, NULL, 0 ))
5198 {
5199 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005200 ("couldn't send teardown frame ")) ;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08005201 goto lim_tdls_teardown_req_error;
5202 }
5203 /* in case of success, eWNI_SME_TDLS_TEARDOWN_RSP is sent back to SME later when
5204 TDLS teardown TX complete is successful. --> see limTdlsTeardownTxComplete() */
5205 return eSIR_SUCCESS;
5206lim_tdls_teardown_req_error:
5207 /* in case of error, return immediately to SME */
5208 limSendSmeTdlsTeardownRsp(pMac, eSIR_FAILURE, teardownReq->peerMac,
5209 eWNI_SME_TDLS_TEARDOWN_RSP);
5210 return eSIR_FAILURE;
5211}
5212
5213
5214#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005215
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05305216static void
5217__limProcessSmeResetApCapsChange(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
5218{
5219 tpSirResetAPCapsChange pResetCapsChange;
5220 tpPESession psessionEntry;
5221 tANI_U8 sessionId = 0;
5222 if (pMsgBuf == NULL)
5223 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005224 limLog(pMac, LOGE,FL("Buffer is Pointing to NULL"));
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05305225 return;
5226 }
5227
5228 pResetCapsChange = (tpSirResetAPCapsChange)pMsgBuf;
5229 psessionEntry = peFindSessionByBssid(pMac, pResetCapsChange->bssId, &sessionId);
5230 if (psessionEntry == NULL)
5231 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005232 limLog(pMac, LOGE, FL("Session does not exist for given BSSID"));
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05305233 return;
5234 }
5235
5236 psessionEntry->limSentCapsChangeNtf = false;
5237 return;
5238}
5239
Jeff Johnson295189b2012-06-20 16:38:30 -07005240/**
5241 * limProcessSmeReqMessages()
5242 *
5243 *FUNCTION:
5244 * This function is called by limProcessMessageQueue(). This
5245 * function processes SME request messages from HDD or upper layer
5246 * application.
5247 *
5248 *LOGIC:
5249 *
5250 *ASSUMPTIONS:
5251 *
5252 *NOTE:
5253 *
5254 * @param pMac Pointer to Global MAC structure
5255 * @param msgType Indicates the SME message type
5256 * @param *pMsgBuf A pointer to the SME message buffer
5257 * @return Boolean - TRUE - if pMsgBuf is consumed and can be freed.
5258 * FALSE - if pMsgBuf is not to be freed.
5259 */
5260
5261tANI_BOOLEAN
5262limProcessSmeReqMessages(tpAniSirGlobal pMac, tpSirMsgQ pMsg)
5263{
5264 tANI_BOOLEAN bufConsumed = TRUE; //Set this flag to false within case block of any following message, that doesnt want pMsgBuf to be freed.
5265 tANI_U32 *pMsgBuf = pMsg->bodyptr;
Sudhir Sattayappa Kohalliabf751c2013-06-30 15:37:18 -07005266 tpSirSmeScanReq pScanReq;
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005267 PELOG1(limLog(pMac, LOG1, FL("LIM Received SME Message %s(%d) Global LimSmeState:%s(%d) Global LimMlmState: %s(%d)"),
Jeff Johnson295189b2012-06-20 16:38:30 -07005268 limMsgStr(pMsg->type), pMsg->type,
5269 limSmeStateStr(pMac->lim.gLimSmeState), pMac->lim.gLimSmeState,
5270 limMlmStateStr(pMac->lim.gLimMlmState), pMac->lim.gLimMlmState );)
5271
Sudhir Sattayappa Kohalliabf751c2013-06-30 15:37:18 -07005272 pScanReq = (tpSirSmeScanReq) pMsgBuf;
Viral Modid440e682013-03-06 02:25:31 -08005273 /* Special handling of some SME Req msgs where we have an existing GO session and
5274 * want to insert NOA before processing those msgs. These msgs will be processed later when
5275 * start event happens
5276 */
5277 switch (pMsg->type)
5278 {
5279 case eWNI_SME_SCAN_REQ:
Viral Modid440e682013-03-06 02:25:31 -08005280 case eWNI_SME_REMAIN_ON_CHANNEL_REQ:
Sudhir Sattayappa Kohalliabf751c2013-06-30 15:37:18 -07005281
5282 /* If scan is disabled return from here
5283 */
5284 if (pMac->lim.fScanDisabled)
5285 {
5286 PELOGE(limLog(pMac, LOGE, FL("Error: Scan Disabled"));)
5287 if (pMsg->type == eWNI_SME_SCAN_REQ)
5288 {
5289 limSendSmeScanRsp(pMac,
5290 offsetof(tSirSmeScanRsp,bssDescription[0]),
5291 eSIR_SME_INVALID_PARAMETERS,
5292 pScanReq->sessionId,
5293 pScanReq->transactionId);
5294
5295 bufConsumed = TRUE;
5296 }
5297 else if (pMsg->type == eWNI_SME_REMAIN_ON_CHANNEL_REQ)
5298 {
5299 pMac->lim.gpDefdSmeMsgForNOA = NULL;
5300 pMac->lim.gpLimRemainOnChanReq = (tpSirRemainOnChnReq )pMsgBuf;
5301 limRemainOnChnRsp(pMac,eHAL_STATUS_FAILURE, NULL);
5302
5303 /*
5304 * limRemainOnChnRsp will free the buffer this change is to
5305 * avoid "double free"
5306 */
5307 bufConsumed = FALSE;
5308 }
5309
5310 return bufConsumed;
5311 }
5312 /*
5313 * Do not add BREAK here
5314 */
5315 case eWNI_SME_OEM_DATA_REQ:
Viral Modid440e682013-03-06 02:25:31 -08005316 case eWNI_SME_JOIN_REQ:
5317 /* If we have an existing P2P GO session we need to insert NOA before actually process this SME Req */
5318 if ((limIsNOAInsertReqd(pMac) == TRUE) && IS_FEATURE_SUPPORTED_BY_FW(P2P_GO_NOA_DECOUPLE_INIT_SCAN))
5319 {
5320 tANI_U32 noaDuration;
5321 __limRegisterDeferredSmeReqForNOAStart(pMac, pMsg->type, pMsgBuf);
5322 noaDuration = limCalculateNOADuration(pMac, pMsg->type, pMsgBuf);
5323 bufConsumed = __limInsertSingleShotNOAForScan(pMac, noaDuration);
5324 return bufConsumed;
5325 }
5326 }
5327 /* If no insert NOA required then execute the code below */
5328
Jeff Johnson295189b2012-06-20 16:38:30 -07005329 switch (pMsg->type)
5330 {
5331 case eWNI_SME_START_REQ:
5332 __limProcessSmeStartReq(pMac, pMsgBuf);
5333 break;
5334
5335 case eWNI_SME_SYS_READY_IND:
5336 bufConsumed = __limProcessSmeSysReadyInd(pMac, pMsgBuf);
5337 break;
5338
Jeff Johnson295189b2012-06-20 16:38:30 -07005339 case eWNI_SME_START_BSS_REQ:
5340 bufConsumed = __limProcessSmeStartBssReq(pMac, pMsg);
5341 break;
5342
5343 case eWNI_SME_SCAN_REQ:
Viral Modid440e682013-03-06 02:25:31 -08005344 __limProcessSmeScanReq(pMac, pMsgBuf);
Jeff Johnson295189b2012-06-20 16:38:30 -07005345 break;
5346
Jeff Johnsone7245742012-09-05 17:12:55 -07005347#ifdef FEATURE_OEM_DATA_SUPPORT
5348 case eWNI_SME_OEM_DATA_REQ:
5349 __limProcessSmeOemDataReq(pMac, pMsgBuf);
Jeff Johnsone7245742012-09-05 17:12:55 -07005350 break;
5351#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005352 case eWNI_SME_REMAIN_ON_CHANNEL_REQ:
5353 bufConsumed = limProcessRemainOnChnlReq(pMac, pMsgBuf);
5354 break;
5355
5356 case eWNI_SME_UPDATE_NOA:
5357 __limProcessSmeNoAUpdate(pMac, pMsgBuf);
5358 break;
Gopichand Nakkalac178ac82013-05-30 19:53:39 +05305359 case eWNI_SME_CLEAR_DFS_CHANNEL_LIST:
5360 __limProcessClearDfsChannelList(pMac, pMsg);
5361 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005362 case eWNI_SME_JOIN_REQ:
5363 __limProcessSmeJoinReq(pMac, pMsgBuf);
Jeff Johnson295189b2012-06-20 16:38:30 -07005364 break;
5365
5366 case eWNI_SME_AUTH_REQ:
5367 // __limProcessSmeAuthReq(pMac, pMsgBuf);
5368
5369 break;
5370
5371 case eWNI_SME_REASSOC_REQ:
5372 __limProcessSmeReassocReq(pMac, pMsgBuf);
5373
5374 break;
5375
5376 case eWNI_SME_PROMISCUOUS_MODE_REQ:
5377 //__limProcessSmePromiscuousReq(pMac, pMsgBuf);
5378
5379 break;
5380
5381 case eWNI_SME_DISASSOC_REQ:
5382 __limProcessSmeDisassocReq(pMac, pMsgBuf);
5383
5384 break;
5385
5386 case eWNI_SME_DISASSOC_CNF:
5387 case eWNI_SME_DEAUTH_CNF:
5388 __limProcessSmeDisassocCnf(pMac, pMsgBuf);
5389
5390 break;
5391
5392 case eWNI_SME_DEAUTH_REQ:
5393 __limProcessSmeDeauthReq(pMac, pMsgBuf);
5394
5395 break;
5396
Jeff Johnson295189b2012-06-20 16:38:30 -07005397
5398
5399 case eWNI_SME_SETCONTEXT_REQ:
5400 __limProcessSmeSetContextReq(pMac, pMsgBuf);
5401
5402 break;
5403
5404 case eWNI_SME_REMOVEKEY_REQ:
5405 __limProcessSmeRemoveKeyReq(pMac, pMsgBuf);
5406
5407 break;
5408
5409 case eWNI_SME_STOP_BSS_REQ:
5410 bufConsumed = __limProcessSmeStopBssReq(pMac, pMsg);
5411 break;
5412
5413 case eWNI_SME_ASSOC_CNF:
5414 case eWNI_SME_REASSOC_CNF:
5415 if (pMsg->type == eWNI_SME_ASSOC_CNF)
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005416 PELOG1(limLog(pMac, LOG1, FL("Received ASSOC_CNF message"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07005417 else
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005418 PELOG1(limLog(pMac, LOG1, FL("Received REASSOC_CNF message"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07005419 __limProcessSmeAssocCnfNew(pMac, pMsg->type, pMsgBuf);
5420 break;
5421
5422 case eWNI_SME_ADDTS_REQ:
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005423 PELOG1(limLog(pMac, LOG1, FL("Received ADDTS_REQ message"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07005424 __limProcessSmeAddtsReq(pMac, pMsgBuf);
5425 break;
5426
5427 case eWNI_SME_DELTS_REQ:
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005428 PELOG1(limLog(pMac, LOG1, FL("Received DELTS_REQ message"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07005429 __limProcessSmeDeltsReq(pMac, pMsgBuf);
5430 break;
5431
5432 case SIR_LIM_ADDTS_RSP_TIMEOUT:
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005433 PELOG1(limLog(pMac, LOG1, FL("Received SIR_LIM_ADDTS_RSP_TIMEOUT message "));)
Jeff Johnson295189b2012-06-20 16:38:30 -07005434 limProcessSmeAddtsRspTimeout(pMac, pMsg->bodyval);
5435 break;
5436
5437 case eWNI_SME_STA_STAT_REQ:
5438 case eWNI_SME_AGGR_STAT_REQ:
5439 case eWNI_SME_GLOBAL_STAT_REQ:
5440 case eWNI_SME_STAT_SUMM_REQ:
5441 __limProcessSmeStatsRequest( pMac, pMsgBuf);
5442 //HAL consumes pMsgBuf. It will be freed there. Set bufConsumed to false.
5443 bufConsumed = FALSE;
5444 break;
5445 case eWNI_SME_GET_STATISTICS_REQ:
5446 __limProcessSmeGetStatisticsRequest( pMac, pMsgBuf);
5447 //HAL consumes pMsgBuf. It will be freed there. Set bufConsumed to false.
5448 bufConsumed = FALSE;
5449 break;
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08005450#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_CCX || defined(FEATURE_WLAN_LFR)
5451 case eWNI_SME_GET_ROAM_RSSI_REQ:
5452 __limProcessSmeGetRoamRssiRequest( pMac, pMsgBuf);
5453 //HAL consumes pMsgBuf. It will be freed there. Set bufConsumed to false.
5454 bufConsumed = FALSE;
5455 break;
5456#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005457 case eWNI_SME_DEL_BA_PEER_IND:
5458 limProcessSmeDelBaPeerInd(pMac, pMsgBuf);
5459 break;
5460 case eWNI_SME_GET_SCANNED_CHANNEL_REQ:
5461 limProcessSmeGetScanChannelInfo(pMac, pMsgBuf);
5462 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005463 case eWNI_SME_GET_ASSOC_STAS_REQ:
5464 limProcessSmeGetAssocSTAsInfo(pMac, pMsgBuf);
5465 break;
5466 case eWNI_SME_TKIP_CNTR_MEAS_REQ:
5467 limProcessTkipCounterMeasures(pMac, pMsgBuf);
5468 break;
5469
5470 case eWNI_SME_HIDE_SSID_REQ:
5471 __limProcessSmeHideSSID(pMac, pMsgBuf);
5472 break;
5473 case eWNI_SME_UPDATE_APWPSIE_REQ:
5474 __limProcessSmeUpdateAPWPSIEs(pMac, pMsgBuf);
5475 break;
5476 case eWNI_SME_GET_WPSPBC_SESSION_REQ:
5477 limProcessSmeGetWPSPBCSessions(pMac, pMsgBuf);
5478 break;
5479
5480 case eWNI_SME_SET_APWPARSNIEs_REQ:
5481 __limProcessSmeSetWPARSNIEs(pMac, pMsgBuf);
5482 break;
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08005483
5484 case eWNI_SME_CHNG_MCC_BEACON_INTERVAL:
5485 //Update the beaconInterval
5486 __limProcessSmeChangeBI(pMac, pMsgBuf );
5487 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005488
5489#if defined WLAN_FEATURE_VOWIFI
5490 case eWNI_SME_NEIGHBOR_REPORT_REQ_IND:
5491 case eWNI_SME_BEACON_REPORT_RESP_XMIT_IND:
5492 __limProcessReportMessage(pMac, pMsg);
5493 break;
5494#endif
5495
5496#if defined WLAN_FEATURE_VOWIFI_11R
5497 case eWNI_SME_FT_PRE_AUTH_REQ:
5498 bufConsumed = (tANI_BOOLEAN)limProcessFTPreAuthReq(pMac, pMsg);
5499 break;
5500 case eWNI_SME_FT_UPDATE_KEY:
5501 limProcessFTUpdateKey(pMac, pMsgBuf);
5502 break;
5503
5504 case eWNI_SME_FT_AGGR_QOS_REQ:
5505 limProcessFTAggrQosReq(pMac, pMsgBuf);
5506 break;
5507#endif
5508
5509#if defined FEATURE_WLAN_CCX
5510 case eWNI_SME_CCX_ADJACENT_AP_REPORT:
5511 limProcessAdjacentAPRepMsg ( pMac, pMsgBuf );
5512 break;
5513#endif
5514 case eWNI_SME_ADD_STA_SELF_REQ:
5515 __limProcessSmeAddStaSelfReq( pMac, pMsgBuf );
5516 break;
5517 case eWNI_SME_DEL_STA_SELF_REQ:
5518 __limProcessSmeDelStaSelfReq( pMac, pMsgBuf );
5519 break;
5520
Jeff Johnson295189b2012-06-20 16:38:30 -07005521 case eWNI_SME_REGISTER_MGMT_FRAME_REQ:
5522 __limProcessSmeRegisterMgmtFrameReq( pMac, pMsgBuf );
5523 break;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08005524#ifdef FEATURE_WLAN_TDLS
5525 case eWNI_SME_TDLS_SEND_MGMT_REQ:
5526 limProcessSmeTdlsMgmtSendReq(pMac, pMsgBuf);
5527 break;
5528 case eWNI_SME_TDLS_ADD_STA_REQ:
5529 limProcessSmeTdlsAddStaReq(pMac, pMsgBuf);
5530 break;
5531 case eWNI_SME_TDLS_DEL_STA_REQ:
5532 limProcessSmeTdlsDelStaReq(pMac, pMsgBuf);
5533 break;
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05305534 case eWNI_SME_TDLS_LINK_ESTABLISH_REQ:
5535 limProcesSmeTdlsLinkEstablishReq(pMac, pMsgBuf);
5536 break;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08005537#endif
5538#ifdef FEATURE_WLAN_TDLS_INTERNAL
5539 case eWNI_SME_TDLS_DISCOVERY_START_REQ:
5540 limProcessSmeDisStartReq(pMac, pMsgBuf);
5541 break ;
5542 case eWNI_SME_TDLS_LINK_START_REQ:
5543 limProcessSmeLinkStartReq(pMac, pMsgBuf);
5544 break ;
5545 case eWNI_SME_TDLS_TEARDOWN_REQ:
5546 limProcessSmeTeardownReq(pMac, pMsgBuf);
5547 break ;
5548#endif
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05305549 case eWNI_SME_RESET_AP_CAPS_CHANGED:
5550 __limProcessSmeResetApCapsChange(pMac, pMsgBuf);
5551 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005552
schang86c22c42013-03-13 18:41:24 -07005553 case eWNI_SME_SET_TX_POWER_REQ:
5554 limSendSetTxPowerReq(pMac, pMsgBuf);
5555 break ;
5556
Jeff Johnson295189b2012-06-20 16:38:30 -07005557 default:
5558 vos_mem_free((v_VOID_t*)pMsg->bodyptr);
5559 pMsg->bodyptr = NULL;
5560 break;
5561 } // switch (msgType)
5562
5563 return bufConsumed;
5564} /*** end limProcessSmeReqMessages() ***/