blob: b9fdd0ae4594886f2863cc3f2d1fa4373673befa [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);
1670
Jeff Johnson295189b2012-06-20 16:38:30 -07001671 /* Store Session related parameters */
1672 /* Store PE session Id in session Table */
1673 psessionEntry->peSessionId = sessionId;
1674
1675 /* store the smejoin req handle in session table */
1676 psessionEntry->pLimJoinReq = pSmeJoinReq;
1677
1678 /* Store SME session Id in sessionTable */
1679 psessionEntry->smeSessionId = pSmeJoinReq->sessionId;
1680
1681 /* Store SME transaction Id in session Table */
1682 psessionEntry->transactionId = pSmeJoinReq->transactionId;
1683
1684 /* Store beaconInterval */
1685 psessionEntry->beaconParams.beaconInterval = pSmeJoinReq->bssDescription.beaconInterval;
1686
1687 /* Copying of bssId is already done, while creating session */
1688 //sirCopyMacAddr(psessionEntry->bssId,pSmeJoinReq->bssId);
1689 sirCopyMacAddr(psessionEntry->selfMacAddr,pSmeJoinReq->selfMacAddr);
1690 psessionEntry->bssType = pSmeJoinReq->bsstype;
1691
1692 psessionEntry->statypeForBss = STA_ENTRY_PEER;
1693
1694 /* Copy the dot 11 mode in to the session table */
1695
1696 psessionEntry->dot11mode = pSmeJoinReq->dot11mode;
1697 psessionEntry->nwType = pSmeJoinReq->bssDescription.nwType;
Jeff Johnsone7245742012-09-05 17:12:55 -07001698#ifdef WLAN_FEATURE_11AC
1699 psessionEntry->vhtCapability = IS_DOT11_MODE_VHT(psessionEntry->dot11mode);
Jeff Johnson32d95a32012-09-10 13:15:23 -07001700 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO_MED,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001701 "***__limProcessSmeJoinReq: vhtCapability=%d****",psessionEntry->vhtCapability);
Shailender Karmuchi08f87c22013-01-17 12:51:24 -08001702 if (psessionEntry->vhtCapability )
1703 {
1704 psessionEntry->txBFIniFeatureEnabled = pSmeJoinReq->txBFIniFeatureEnabled;
1705
1706 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO_MED,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001707 "***__limProcessSmeJoinReq: txBFIniFeatureEnabled=%d****",
Shailender Karmuchi08f87c22013-01-17 12:51:24 -08001708 psessionEntry->txBFIniFeatureEnabled);
1709
1710 if( psessionEntry->txBFIniFeatureEnabled )
1711 {
1712 if (cfgSetInt(pMac, WNI_CFG_VHT_SU_BEAMFORMEE_CAP, psessionEntry->txBFIniFeatureEnabled)
1713 != eSIR_SUCCESS)
1714 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001715 limLog(pMac, LOGP, FL("could not set WNI_CFG_VHT_SU_BEAMFORMEE_CAP at CFG"));
Shailender Karmuchi08f87c22013-01-17 12:51:24 -08001716 retCode = eSIR_LOGP_EXCEPTION;
1717 goto end;
1718 }
Shailender Karmuchicc3fe442013-02-16 18:18:33 -08001719 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO_MED,
Leela V Kiran Kumar Reddy Chirala6a458752013-02-16 15:41:27 -08001720 "***__limProcessSmeJoinReq: txBFCsnValue=%d****", pSmeJoinReq->txBFCsnValue);
Shailender Karmuchicc3fe442013-02-16 18:18:33 -08001721
1722 if (cfgSetInt(pMac, WNI_CFG_VHT_CSN_BEAMFORMEE_ANT_SUPPORTED, pSmeJoinReq->txBFCsnValue)
Shailender Karmuchi08f87c22013-01-17 12:51:24 -08001723 != eSIR_SUCCESS)
1724 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001725 limLog(pMac, LOGP, FL("could not set WNI_CFG_VHT_CSN_BEAMFORMEE_ANT_SUPPORTED at CFG"));
Shailender Karmuchi08f87c22013-01-17 12:51:24 -08001726 retCode = eSIR_LOGP_EXCEPTION;
1727 goto end;
1728 }
1729 }
1730 }
1731
Jeff Johnsone7245742012-09-05 17:12:55 -07001732#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001733
1734 /*Phy mode*/
1735 psessionEntry->gLimPhyMode = pSmeJoinReq->bssDescription.nwType;
1736
1737 /* Copy The channel Id to the session Table */
1738 psessionEntry->currentOperChannel = pSmeJoinReq->bssDescription.channelId;
Jeff Johnsone7245742012-09-05 17:12:55 -07001739 psessionEntry->htSupportedChannelWidthSet = (pSmeJoinReq->cbMode)?1:0; // This is already merged value of peer and self - done by csr in csrGetCBModeFromIes
1740 psessionEntry->htRecommendedTxWidthSet = psessionEntry->htSupportedChannelWidthSet;
1741 psessionEntry->htSecondaryChannelOffset = pSmeJoinReq->cbMode;
Jeff Johnson295189b2012-06-20 16:38:30 -07001742
Chet Lanctot186b5732013-03-18 10:26:30 -07001743 /* Record if management frames need to be protected */
1744#ifdef WLAN_FEATURE_11W
1745 if(eSIR_ED_AES_128_CMAC == pSmeJoinReq->MgmtEncryptionType)
1746 {
1747 psessionEntry->limRmfEnabled = 1;
1748 }
1749 else
1750 {
1751 psessionEntry->limRmfEnabled = 0;
1752 }
1753#endif
1754
krunal soni8d13b092013-07-19 13:23:29 -07001755#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM
1756 psessionEntry->rssi = pSmeJoinReq->bssDescription.rssi;
1757#endif
1758
Jeff Johnson295189b2012-06-20 16:38:30 -07001759 /*Store Persona */
1760 psessionEntry->pePersona = pSmeJoinReq->staPersona;
1761 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
Jeff Johnsone7245742012-09-05 17:12:55 -07001762 FL("PE PERSONA=%d cbMode %u"), psessionEntry->pePersona, pSmeJoinReq->cbMode);
Jeff Johnson295189b2012-06-20 16:38:30 -07001763
1764 /* Copy the SSID from smejoinreq to session entry */
1765 psessionEntry->ssId.length = pSmeJoinReq->ssId.length;
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301766 vos_mem_copy( psessionEntry->ssId.ssId,
1767 pSmeJoinReq->ssId.ssId, psessionEntry->ssId.length);
1768
1769 // Determin 11r or CCX connection based on input from SME
1770 // which inturn is dependent on the profile the user wants to connect
1771 // to, So input is coming from supplicant
Jeff Johnson295189b2012-06-20 16:38:30 -07001772#ifdef WLAN_FEATURE_VOWIFI_11R
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301773 psessionEntry->is11Rconnection = pSmeJoinReq->is11Rconnection;
Jeff Johnson295189b2012-06-20 16:38:30 -07001774#endif
1775#ifdef FEATURE_WLAN_CCX
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301776 psessionEntry->isCCXconnection = pSmeJoinReq->isCCXconnection;
Jeff Johnson295189b2012-06-20 16:38:30 -07001777#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001778#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_CCX || defined(FEATURE_WLAN_LFR)
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301779 psessionEntry->isFastTransitionEnabled = pSmeJoinReq->isFastTransitionEnabled;
Jeff Johnson295189b2012-06-20 16:38:30 -07001780#endif
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301781
Jeff Johnson43971f52012-07-17 12:26:56 -07001782#ifdef FEATURE_WLAN_LFR
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301783 psessionEntry->isFastRoamIniFeatureEnabled = pSmeJoinReq->isFastRoamIniFeatureEnabled;
Jeff Johnson43971f52012-07-17 12:26:56 -07001784#endif
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301785 psessionEntry->txLdpcIniFeatureEnabled = pSmeJoinReq->txLdpcIniFeatureEnabled;
Gopichand Nakkalab2d2c312013-01-04 11:41:02 -08001786
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301787 if (psessionEntry->bssType == eSIR_INFRASTRUCTURE_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07001788 {
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301789 psessionEntry->limSystemRole = eLIM_STA_ROLE;
1790 }
1791 else if (psessionEntry->bssType == eSIR_BTAMP_AP_MODE)
1792 {
1793 psessionEntry->limSystemRole = eLIM_BT_AMP_STA_ROLE;
1794 }
1795 else
1796 {
1797 /* Throw an error and return and make sure to delete the session.*/
1798 limLog(pMac, LOGW, FL("received SME_JOIN_REQ with invalid bss type"));
1799 retCode = eSIR_SME_INVALID_PARAMETERS;
1800 goto end;
1801 }
1802
1803 if (pSmeJoinReq->addIEScan.length)
1804 {
1805 vos_mem_copy( &psessionEntry->pLimJoinReq->addIEScan,
Jeff Johnson295189b2012-06-20 16:38:30 -07001806 &pSmeJoinReq->addIEScan, sizeof(tSirAddie));
1807 }
1808
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301809 if (pSmeJoinReq->addIEAssoc.length)
Jeff Johnson295189b2012-06-20 16:38:30 -07001810 {
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301811 vos_mem_copy( &psessionEntry->pLimJoinReq->addIEAssoc,
Jeff Johnson295189b2012-06-20 16:38:30 -07001812 &pSmeJoinReq->addIEAssoc, sizeof(tSirAddie));
1813 }
1814
Jeff Johnson295189b2012-06-20 16:38:30 -07001815 val = sizeof(tLimMlmJoinReq) + psessionEntry->pLimJoinReq->bssDescription.length + 2;
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301816 pMlmJoinReq = vos_mem_malloc(val);
1817 if ( NULL == pMlmJoinReq )
Jeff Johnson295189b2012-06-20 16:38:30 -07001818 {
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301819 limLog(pMac, LOGP, FL("call to AllocateMemory failed for mlmJoinReq"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001820 return;
1821 }
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301822 (void) vos_mem_set((void *) pMlmJoinReq, val, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07001823
1824 /* PE SessionId is stored as a part of JoinReq*/
1825 pMlmJoinReq->sessionId = psessionEntry->peSessionId;
1826
1827 if (wlan_cfgGetInt(pMac, WNI_CFG_JOIN_FAILURE_TIMEOUT, (tANI_U32 *) &pMlmJoinReq->joinFailureTimeout)
1828 != eSIR_SUCCESS)
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001829 limLog(pMac, LOGP, FL("could not retrieve JoinFailureTimer value"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001830
1831 /* copy operational rate from psessionEntry*/
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301832 vos_mem_copy((void*)&psessionEntry->rateSet, (void*)&pSmeJoinReq->operationalRateSet,
Jeff Johnson295189b2012-06-20 16:38:30 -07001833 sizeof(tSirMacRateSet));
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301834 vos_mem_copy((void*)&psessionEntry->extRateSet, (void*)&pSmeJoinReq->extendedRateSet,
Jeff Johnson295189b2012-06-20 16:38:30 -07001835 sizeof(tSirMacRateSet));
1836 //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 +05301837 vos_mem_copy((void*)&pMlmJoinReq->operationalRateSet, (void*)&psessionEntry->rateSet,
Jeff Johnson295189b2012-06-20 16:38:30 -07001838 sizeof(tSirMacRateSet));
1839
1840 psessionEntry->encryptType = pSmeJoinReq->UCEncryptionType;
1841
Jeff Johnson295189b2012-06-20 16:38:30 -07001842 pMlmJoinReq->bssDescription.length = psessionEntry->pLimJoinReq->bssDescription.length;
1843
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301844 vos_mem_copy((tANI_U8 *) &pMlmJoinReq->bssDescription.bssId,
Jeff Johnson295189b2012-06-20 16:38:30 -07001845 (tANI_U8 *) &psessionEntry->pLimJoinReq->bssDescription.bssId,
1846 psessionEntry->pLimJoinReq->bssDescription.length + 2);
1847
Jeff Johnson295189b2012-06-20 16:38:30 -07001848 psessionEntry->limCurrentBssCaps =
Jeff Johnsone7245742012-09-05 17:12:55 -07001849 psessionEntry->pLimJoinReq->bssDescription.capabilityInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07001850
Jeff Johnsone7245742012-09-05 17:12:55 -07001851 regMax = cfgGetRegulatoryMaxTransmitPower( pMac, psessionEntry->currentOperChannel );
1852 localPowerConstraint = regMax;
1853 limExtractApCapability( pMac,
1854 (tANI_U8 *) psessionEntry->pLimJoinReq->bssDescription.ieFields,
1855 limGetIElenFromBssDescription(&psessionEntry->pLimJoinReq->bssDescription),
1856 &psessionEntry->limCurrentBssQosCaps,
1857 &psessionEntry->limCurrentBssPropCap,
1858 &pMac->lim.gLimCurrentBssUapsd //TBD-RAJESH make gLimCurrentBssUapsd this session specific
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07001859 , &localPowerConstraint,
1860 psessionEntry
Jeff Johnsone7245742012-09-05 17:12:55 -07001861 );
Jeff Johnson295189b2012-06-20 16:38:30 -07001862#ifdef FEATURE_WLAN_CCX
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001863 psessionEntry->maxTxPower = limGetMaxTxPower(regMax, localPowerConstraint, pMac->roam.configParam.nTxPowerCap);
Jeff Johnson295189b2012-06-20 16:38:30 -07001864#else
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301865 psessionEntry->maxTxPower = VOS_MIN( regMax, (localPowerConstraint) );
Jeff Johnson295189b2012-06-20 16:38:30 -07001866#endif
1867#if defined WLAN_VOWIFI_DEBUG
1868 limLog( pMac, LOGE, "Regulatory max = %d, local power constraint = %d, max tx = %d", regMax, localPowerConstraint, psessionEntry->maxTxPower );
1869#endif
1870
1871 if (pMac->lim.gLimCurrentBssUapsd)
1872 {
1873 pMac->lim.gUapsdPerAcBitmask = psessionEntry->pLimJoinReq->uapsdPerAcBitmask;
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001874 limLog( pMac, LOG1, FL("UAPSD flag for all AC - 0x%2x"), pMac->lim.gUapsdPerAcBitmask);
Jeff Johnson295189b2012-06-20 16:38:30 -07001875
1876 // resetting the dynamic uapsd mask
1877 pMac->lim.gUapsdPerAcDeliveryEnableMask = 0;
1878 pMac->lim.gUapsdPerAcTriggerEnableMask = 0;
1879 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001880
1881 psessionEntry->limRFBand = limGetRFBand(psessionEntry->currentOperChannel);
1882
1883 // Initialize 11h Enable Flag
1884 if(SIR_BAND_5_GHZ == psessionEntry->limRFBand)
1885 {
1886 if (wlan_cfgGetInt(pMac, WNI_CFG_11H_ENABLED, &val) != eSIR_SUCCESS)
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001887 limLog(pMac, LOGP, FL("Fail to get WNI_CFG_11H_ENABLED "));
Jeff Johnson295189b2012-06-20 16:38:30 -07001888 psessionEntry->lim11hEnable = val;
1889 }
1890 else
1891 psessionEntry->lim11hEnable = 0;
1892
1893 //To care of the scenario when STA transitions from IBSS to Infrastructure mode.
1894 pMac->lim.gLimIbssCoalescingHappened = false;
1895
Jeff Johnsone7245742012-09-05 17:12:55 -07001896 psessionEntry->limPrevSmeState = psessionEntry->limSmeState;
1897 psessionEntry->limSmeState = eLIM_SME_WT_JOIN_STATE;
1898 MTRACE(macTrace(pMac, TRACE_CODE_SME_STATE, psessionEntry->peSessionId, psessionEntry->limSmeState));
Jeff Johnson295189b2012-06-20 16:38:30 -07001899
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001900 PELOG1(limLog(pMac, LOG1, FL("SME JoinReq: SSID %d.%c%c%c%c%c%c"),
Jeff Johnson295189b2012-06-20 16:38:30 -07001901 psessionEntry->ssId.length,
1902 psessionEntry->ssId.ssId[0],
1903 psessionEntry->ssId.ssId[1],
1904 psessionEntry->ssId.ssId[2],
1905 psessionEntry->ssId.ssId[3],
1906 psessionEntry->ssId.ssId[4],
1907 psessionEntry->ssId.ssId[5]);
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001908 limLog(pMac, LOG1, FL("Channel %d, BSSID %x:%x:%x:%x:%x:%x"),
Jeff Johnson295189b2012-06-20 16:38:30 -07001909 psessionEntry->currentOperChannel,
1910 psessionEntry->bssId[0],
1911 psessionEntry->bssId[1],
1912 psessionEntry->bssId[2],
1913 psessionEntry->bssId[3],
1914 psessionEntry->bssId[4],
1915 psessionEntry->bssId[5]);)
1916
1917 /* Indicate whether spectrum management is enabled*/
1918 psessionEntry->spectrumMgtEnabled =
1919 pSmeJoinReq->spectrumMgtIndicator;
1920 /* Issue LIM_MLM_JOIN_REQ to MLM */
1921 limPostMlmMessage(pMac, LIM_MLM_JOIN_REQ, (tANI_U32 *) pMlmJoinReq);
1922 return;
1923
1924 }
1925 else
1926 {
1927 /* Received eWNI_SME_JOIN_REQ un expected state */
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001928 limLog(pMac, LOGE, FL("received unexpected SME_JOIN_REQ in state %X"), pMac->lim.gLimSmeState);
Jeff Johnson295189b2012-06-20 16:38:30 -07001929 limPrintSmeState(pMac, LOGE, pMac->lim.gLimSmeState);
1930 retCode = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
1931 psessionEntry = NULL;
1932 goto end;
1933
1934 }
1935
1936end:
1937 limGetSessionInfo(pMac,(tANI_U8*)pMsgBuf,&smesessionId,&smetransactionId);
1938
1939 if(pSmeJoinReq)
1940 {
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301941 vos_mem_free(pSmeJoinReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07001942 pSmeJoinReq = NULL;
1943 if (NULL != psessionEntry)
1944 {
1945 psessionEntry->pLimJoinReq = NULL;
1946 }
1947 }
1948
1949 if(retCode != eSIR_SME_SUCCESS)
1950 {
1951 if(NULL != psessionEntry)
1952 {
1953 peDeleteSession(pMac,psessionEntry);
1954 psessionEntry = NULL;
1955 }
1956 }
1957
1958 limSendSmeJoinReassocRsp(pMac, eWNI_SME_JOIN_RSP, retCode, eSIR_MAC_UNSPEC_FAILURE_STATUS,psessionEntry,smesessionId,smetransactionId);
1959} /*** end __limProcessSmeJoinReq() ***/
1960
1961
1962#ifdef FEATURE_WLAN_CCX
Madan Mohan Koyyalamudi3282c572012-11-09 17:01:41 -08001963tANI_U8 limGetMaxTxPower(tPowerdBm regMax, tPowerdBm apTxPower, tANI_U8 iniTxPower)
Jeff Johnson295189b2012-06-20 16:38:30 -07001964{
1965 tANI_U8 maxTxPower = 0;
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301966 tANI_U8 txPower = VOS_MIN( regMax, (apTxPower) );
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001967 txPower = VOS_MIN(txPower, iniTxPower);
Jeff Johnson295189b2012-06-20 16:38:30 -07001968 if((txPower >= MIN_TX_PWR_CAP) && (txPower <= MAX_TX_PWR_CAP))
1969 maxTxPower = txPower;
1970 else if (txPower < MIN_TX_PWR_CAP)
1971 maxTxPower = MIN_TX_PWR_CAP;
1972 else
1973 maxTxPower = MAX_TX_PWR_CAP;
1974
1975 return (maxTxPower);
1976}
1977#endif
1978
Jeff Johnson295189b2012-06-20 16:38:30 -07001979/**
1980 * __limProcessSmeReassocReq()
1981 *
1982 *FUNCTION:
1983 * This function is called to process SME_REASSOC_REQ message
1984 * from HDD or upper layer application.
1985 *
1986 *LOGIC:
1987 *
1988 *ASSUMPTIONS:
1989 *
1990 *NOTE:
1991 *
1992 * @param pMac Pointer to Global MAC structure
1993 * @param *pMsgBuf A pointer to the SME message buffer
1994 * @return None
1995 */
1996
1997static void
1998__limProcessSmeReassocReq(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
1999{
2000 tANI_U16 caps;
2001 tANI_U32 val;
Srinivas Girigowdac16730e2013-01-16 13:39:39 -08002002 tpSirSmeJoinReq pReassocReq = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002003 tLimMlmReassocReq *pMlmReassocReq;
2004 tSirResultCodes retCode = eSIR_SME_SUCCESS;
2005 tpPESession psessionEntry = NULL;
2006 tANI_U8 sessionId;
2007 tANI_U8 smeSessionId;
2008 tANI_U16 transactionId;
2009 tPowerdBm localPowerConstraint = 0, regMax = 0;
2010 tANI_U32 teleBcnEn = 0;
Madan Mohan Koyyalamudi7df624d2012-10-31 16:32:50 -07002011 tANI_U16 nSize;
Jeff Johnson295189b2012-06-20 16:38:30 -07002012
2013
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002014 PELOG3(limLog(pMac, LOG3, FL("Received REASSOC_REQ"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07002015
Madan Mohan Koyyalamudi7df624d2012-10-31 16:32:50 -07002016 nSize = __limGetSmeJoinReqSizeForAlloc((tANI_U8 *) pMsgBuf);
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302017 pReassocReq = vos_mem_malloc(nSize);
2018 if ( NULL == pReassocReq )
Jeff Johnson295189b2012-06-20 16:38:30 -07002019 {
2020 // Log error
2021 limLog(pMac, LOGP,
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302022 FL("call to AllocateMemory failed for pReassocReq"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002023
2024 retCode = eSIR_SME_RESOURCES_UNAVAILABLE;
2025 goto end;
2026 }
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302027 (void) vos_mem_set((void *) pReassocReq, nSize, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07002028 if ((limJoinReqSerDes(pMac, (tpSirSmeJoinReq) pReassocReq,
2029 (tANI_U8 *) pMsgBuf) == eSIR_FAILURE) ||
2030 (!limIsSmeJoinReqValid(pMac,
2031 (tpSirSmeJoinReq) pReassocReq)))
2032 {
2033 /// Received invalid eWNI_SME_REASSOC_REQ
2034 // Log the event
2035 limLog(pMac, LOGW,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002036 FL("received SME_REASSOC_REQ with invalid data"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002037
2038 retCode = eSIR_SME_INVALID_PARAMETERS;
2039 goto end;
2040 }
2041
2042 if((psessionEntry = peFindSessionByBssid(pMac,pReassocReq->bssDescription.bssId,&sessionId))==NULL)
2043 {
2044 limPrintMacAddr(pMac, pReassocReq->bssDescription.bssId, LOGE);
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002045 limLog(pMac, LOGP, FL("Session does not exist for given bssId"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002046 retCode = eSIR_SME_INVALID_PARAMETERS;
2047 goto end;
2048 }
2049
2050#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM //FEATURE_WLAN_DIAG_SUPPORT
2051 limDiagEventReport(pMac, WLAN_PE_DIAG_REASSOC_REQ_EVENT, psessionEntry, 0, 0);
2052#endif //FEATURE_WLAN_DIAG_SUPPORT
2053 //pMac->lim.gpLimReassocReq = pReassocReq;//TO SUPPORT BT-AMP
2054
2055 /* Store the reassoc handle in the session Table.. 23rd sep review */
2056 psessionEntry->pLimReAssocReq = pReassocReq;
2057
2058 /**
2059 * Reassociate request is expected
2060 * in link established state only.
2061 */
2062
2063 if (psessionEntry->limSmeState != eLIM_SME_LINK_EST_STATE)
2064 {
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002065#if defined(WLAN_FEATURE_VOWIFI_11R) || defined(FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07002066 if (psessionEntry->limSmeState == eLIM_SME_WT_REASSOC_STATE)
2067 {
2068 // May be from 11r FT pre-auth. So lets check it before we bail out
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08002069 limLog(pMac, LOG1, FL("Session in reassoc state is %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002070 psessionEntry->peSessionId);
2071
2072 // Make sure its our preauth bssid
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302073 if (!vos_mem_compare( pReassocReq->bssDescription.bssId,
Jeff Johnson295189b2012-06-20 16:38:30 -07002074 pMac->ft.ftPEContext.pFTPreAuthReq->preAuthbssId, 6))
2075 {
2076 limPrintMacAddr(pMac, pReassocReq->bssDescription.bssId, LOGE);
2077 limPrintMacAddr(pMac, pMac->ft.ftPEContext.pFTPreAuthReq->preAuthbssId, LOGE);
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002078 limLog(pMac, LOGP, FL("Unknown bssId in reassoc state"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002079 retCode = eSIR_SME_INVALID_PARAMETERS;
2080 goto end;
2081 }
2082
2083 limProcessMlmFTReassocReq(pMac, pMsgBuf, psessionEntry);
2084 return;
2085 }
2086#endif
2087 /// Should not have received eWNI_SME_REASSOC_REQ
2088 // Log the event
2089 limLog(pMac, LOGE,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002090 FL("received unexpected SME_REASSOC_REQ in state %X"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002091 psessionEntry->limSmeState);
2092 limPrintSmeState(pMac, LOGE, psessionEntry->limSmeState);
2093
2094 retCode = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
2095 goto end;
2096 }
2097
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302098 vos_mem_copy( psessionEntry->limReAssocbssId,
Jeff Johnson295189b2012-06-20 16:38:30 -07002099 psessionEntry->pLimReAssocReq->bssDescription.bssId,
2100 sizeof(tSirMacAddr));
2101
2102 psessionEntry->limReassocChannelId =
2103 psessionEntry->pLimReAssocReq->bssDescription.channelId;
2104
Jeff Johnsone7245742012-09-05 17:12:55 -07002105 psessionEntry->reAssocHtSupportedChannelWidthSet =
2106 (psessionEntry->pLimReAssocReq->cbMode)?1:0;
2107 psessionEntry->reAssocHtRecommendedTxWidthSet =
2108 psessionEntry->reAssocHtSupportedChannelWidthSet;
2109 psessionEntry->reAssocHtSecondaryChannelOffset =
2110 psessionEntry->pLimReAssocReq->cbMode;
2111
Jeff Johnson295189b2012-06-20 16:38:30 -07002112 psessionEntry->limReassocBssCaps =
2113 psessionEntry->pLimReAssocReq->bssDescription.capabilityInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07002114 regMax = cfgGetRegulatoryMaxTransmitPower( pMac, psessionEntry->currentOperChannel );
2115 localPowerConstraint = regMax;
2116 limExtractApCapability( pMac,
2117 (tANI_U8 *) psessionEntry->pLimReAssocReq->bssDescription.ieFields,
2118 limGetIElenFromBssDescription(
2119 &psessionEntry->pLimReAssocReq->bssDescription),
2120 &psessionEntry->limReassocBssQosCaps,
2121 &psessionEntry->limReassocBssPropCap,
2122 &pMac->lim.gLimCurrentBssUapsd //TBD-RAJESH make gLimReassocBssUapsd session specific
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07002123 , &localPowerConstraint,
2124 psessionEntry
Jeff Johnson295189b2012-06-20 16:38:30 -07002125 );
2126
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302127 psessionEntry->maxTxPower = VOS_MIN( regMax, (localPowerConstraint) );
Jeff Johnson295189b2012-06-20 16:38:30 -07002128#if defined WLAN_VOWIFI_DEBUG
2129 limLog( pMac, LOGE, "Regulatory max = %d, local power constraint = %d, max tx = %d", regMax, localPowerConstraint, psessionEntry->maxTxPower );
2130#endif
2131 {
2132 #if 0
2133 if (wlan_cfgGetStr(pMac, WNI_CFG_SSID, pMac->lim.gLimReassocSSID.ssId,
2134 &cfgLen) != eSIR_SUCCESS)
2135 {
2136 /// Could not get SSID from CFG. Log error.
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002137 limLog(pMac, LOGP, FL("could not retrive SSID"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002138 }
2139 #endif//TO SUPPORT BT-AMP
2140
2141 /* Copy the SSID from sessio entry to local variable */
2142 #if 0
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302143 vos_mem_copy( pMac->lim.gLimReassocSSID.ssId,
Jeff Johnson295189b2012-06-20 16:38:30 -07002144 psessionEntry->ssId.ssId,
2145 psessionEntry->ssId.length);
2146 #endif
2147 psessionEntry->limReassocSSID.length = pReassocReq->ssId.length;
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302148 vos_mem_copy( psessionEntry->limReassocSSID.ssId,
Jeff Johnson295189b2012-06-20 16:38:30 -07002149 pReassocReq->ssId.ssId, psessionEntry->limReassocSSID.length);
2150
2151 }
2152
2153 if (pMac->lim.gLimCurrentBssUapsd)
2154 {
2155 pMac->lim.gUapsdPerAcBitmask = psessionEntry->pLimReAssocReq->uapsdPerAcBitmask;
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002156 limLog( pMac, LOG1, FL("UAPSD flag for all AC - 0x%2x"), pMac->lim.gUapsdPerAcBitmask);
Jeff Johnson295189b2012-06-20 16:38:30 -07002157 }
2158
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302159 pMlmReassocReq = vos_mem_malloc(sizeof(tLimMlmReassocReq));
2160 if ( NULL == pMlmReassocReq )
Jeff Johnson295189b2012-06-20 16:38:30 -07002161 {
2162 // Log error
2163 limLog(pMac, LOGP,
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302164 FL("call to AllocateMemory failed for mlmReassocReq"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002165
2166 retCode = eSIR_SME_RESOURCES_UNAVAILABLE;
2167 goto end;
2168 }
2169
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302170 vos_mem_copy( pMlmReassocReq->peerMacAddr,
Jeff Johnson295189b2012-06-20 16:38:30 -07002171 psessionEntry->limReAssocbssId,
2172 sizeof(tSirMacAddr));
2173
2174 if (wlan_cfgGetInt(pMac, WNI_CFG_REASSOCIATION_FAILURE_TIMEOUT,
2175 (tANI_U32 *) &pMlmReassocReq->reassocFailureTimeout)
2176 != eSIR_SUCCESS)
2177 {
2178 /**
2179 * Could not get ReassocFailureTimeout value
2180 * from CFG. Log error.
2181 */
2182 limLog(pMac, LOGP,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002183 FL("could not retrieve ReassocFailureTimeout value"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002184 }
2185
2186 if (cfgGetCapabilityInfo(pMac, &caps,psessionEntry) != eSIR_SUCCESS)
2187 {
2188 /**
2189 * Could not get Capabilities value
2190 * from CFG. Log error.
2191 */
2192 limLog(pMac, LOGP,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002193 FL("could not retrieve Capabilities value"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002194 }
2195 pMlmReassocReq->capabilityInfo = caps;
2196
2197 /* Update PE sessionId*/
2198 pMlmReassocReq->sessionId = sessionId;
2199
2200 /* If telescopic beaconing is enabled, set listen interval to
2201 WNI_CFG_TELE_BCN_MAX_LI */
2202 if(wlan_cfgGetInt(pMac, WNI_CFG_TELE_BCN_WAKEUP_EN, &teleBcnEn) !=
2203 eSIR_SUCCESS)
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002204 limLog(pMac, LOGP, FL("Couldn't get WNI_CFG_TELE_BCN_WAKEUP_EN"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002205
2206 val = WNI_CFG_LISTEN_INTERVAL_STADEF;
2207
2208 if(teleBcnEn)
2209 {
2210 if(wlan_cfgGetInt(pMac, WNI_CFG_TELE_BCN_MAX_LI, &val) !=
2211 eSIR_SUCCESS)
2212 {
2213 /**
2214 * Could not get ListenInterval value
2215 * from CFG. Log error.
2216 */
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002217 limLog(pMac, LOGP, FL("could not retrieve ListenInterval"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002218 }
2219 }
2220 else
2221 {
2222 if (wlan_cfgGetInt(pMac, WNI_CFG_LISTEN_INTERVAL, &val) != eSIR_SUCCESS)
2223 {
2224 /**
2225 * Could not get ListenInterval value
2226 * from CFG. Log error.
2227 */
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002228 limLog(pMac, LOGP, FL("could not retrieve ListenInterval"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002229 }
2230 }
2231
2232 /* Delete all BA sessions before Re-Assoc.
2233 * BA frames are class 3 frames and the session
2234 * is lost upon disassociation and reassociation.
2235 */
2236
Kiran Kumar Lokere458d7322013-05-29 14:29:43 -07002237 limDeleteBASessions(pMac, psessionEntry, BA_BOTH_DIRECTIONS);
Jeff Johnson295189b2012-06-20 16:38:30 -07002238
2239 pMlmReassocReq->listenInterval = (tANI_U16) val;
2240
2241 /* Indicate whether spectrum management is enabled*/
2242 psessionEntry->spectrumMgtEnabled = pReassocReq->spectrumMgtIndicator;
2243
2244 psessionEntry->limPrevSmeState = psessionEntry->limSmeState;
2245 psessionEntry->limSmeState = eLIM_SME_WT_REASSOC_STATE;
2246
Jeff Johnsone7245742012-09-05 17:12:55 -07002247 MTRACE(macTrace(pMac, TRACE_CODE_SME_STATE, psessionEntry->peSessionId, psessionEntry->limSmeState));
Jeff Johnson295189b2012-06-20 16:38:30 -07002248
2249 limPostMlmMessage(pMac,
2250 LIM_MLM_REASSOC_REQ,
2251 (tANI_U32 *) pMlmReassocReq);
2252 return;
2253
2254end:
2255 if (pReassocReq)
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302256 vos_mem_free( pReassocReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07002257
2258 if (psessionEntry)
2259 {
2260 // error occurred after we determined the session so extract
2261 // session and transaction info from there
2262 smeSessionId = psessionEntry->smeSessionId;
2263 transactionId = psessionEntry->transactionId;
2264 }
2265 else
2266 {
2267 // error occurred before or during the time we determined the session
2268 // so extract the session and transaction info from the message
2269 limGetSessionInfo(pMac,(tANI_U8*)pMsgBuf, &smeSessionId, &transactionId);
2270 }
2271
2272 /// Send Reassoc failure response to host
2273 /// (note psessionEntry may be NULL, but that's OK)
2274 limSendSmeJoinReassocRsp(pMac, eWNI_SME_REASSOC_RSP,
2275 retCode, eSIR_MAC_UNSPEC_FAILURE_STATUS,
2276 psessionEntry, smeSessionId, transactionId);
2277
2278} /*** end __limProcessSmeReassocReq() ***/
2279
2280
2281tANI_BOOLEAN sendDisassocFrame = 1;
2282/**
2283 * __limProcessSmeDisassocReq()
2284 *
2285 *FUNCTION:
2286 * This function is called to process SME_DISASSOC_REQ message
2287 * from HDD or upper layer application.
2288 *
2289 *LOGIC:
2290 *
2291 *ASSUMPTIONS:
2292 *
2293 *NOTE:
2294 *
2295 * @param pMac Pointer to Global MAC structure
2296 * @param *pMsgBuf A pointer to the SME message buffer
2297 * @return None
2298 */
2299
2300static void
2301__limProcessSmeDisassocReq(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
2302{
2303 tANI_U16 disassocTrigger, reasonCode;
2304 tLimMlmDisassocReq *pMlmDisassocReq;
2305 tSirResultCodes retCode = eSIR_SME_SUCCESS;
Jeff Johnson43971f52012-07-17 12:26:56 -07002306 tSirRetStatus status;
Jeff Johnson295189b2012-06-20 16:38:30 -07002307 tSirSmeDisassocReq smeDisassocReq;
2308 tpPESession psessionEntry = NULL;
2309 tANI_U8 sessionId;
2310 tANI_U8 smesessionId;
2311 tANI_U16 smetransactionId;
2312
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002313 PELOG1(limLog(pMac, LOG1,FL("received DISASSOC_REQ message"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07002314
Jeff Johnson43971f52012-07-17 12:26:56 -07002315 if (pMsgBuf == NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -07002316 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002317 limLog(pMac, LOGE, FL("Buffer is Pointing to NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002318 return;
2319 }
2320
Jeff Johnson43971f52012-07-17 12:26:56 -07002321 limGetSessionInfo(pMac, (tANI_U8 *)pMsgBuf,&smesessionId, &smetransactionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07002322
Jeff Johnson43971f52012-07-17 12:26:56 -07002323 status = limDisassocReqSerDes(pMac, &smeDisassocReq, (tANI_U8 *) pMsgBuf);
Jeff Johnson295189b2012-06-20 16:38:30 -07002324
Jeff Johnson43971f52012-07-17 12:26:56 -07002325 if ( (eSIR_FAILURE == status) ||
2326 (!limIsSmeDisassocReqValid(pMac, &smeDisassocReq, psessionEntry)) )
Jeff Johnson295189b2012-06-20 16:38:30 -07002327 {
2328 PELOGE(limLog(pMac, LOGE,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002329 FL("received invalid SME_DISASSOC_REQ message"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07002330
2331 if (pMac->lim.gLimRspReqd)
2332 {
2333 pMac->lim.gLimRspReqd = false;
2334
2335 retCode = eSIR_SME_INVALID_PARAMETERS;
2336 disassocTrigger = eLIM_HOST_DISASSOC;
2337 goto sendDisassoc;
2338 }
2339
2340 return;
2341 }
2342
2343
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002344 PELOG1(limLog(pMac, LOG1, FL("received DISASSOC_REQ message. Reason: %d global SmeState: %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002345 smeDisassocReq.reasonCode, pMac->lim.gLimSmeState);)
2346
2347
2348 if((psessionEntry = peFindSessionByBssid(pMac,smeDisassocReq.bssId,&sessionId))== NULL)
2349 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002350 limLog(pMac, LOGE,FL("session does not exist for given bssId"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002351 retCode = eSIR_SME_INVALID_PARAMETERS;
2352 disassocTrigger = eLIM_HOST_DISASSOC;
2353 goto sendDisassoc;
2354
2355 }
2356
2357#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM //FEATURE_WLAN_DIAG_SUPPORT
2358 limDiagEventReport(pMac, WLAN_PE_DIAG_DISASSOC_REQ_EVENT, psessionEntry, 0, smeDisassocReq.reasonCode);
2359#endif //FEATURE_WLAN_DIAG_SUPPORT
2360
2361 /* Update SME session Id and SME transaction ID*/
2362
2363 psessionEntry->smeSessionId = smesessionId;
2364 psessionEntry->transactionId = smetransactionId;
2365
2366 switch (psessionEntry->limSystemRole)
2367 {
2368 case eLIM_STA_ROLE:
2369 case eLIM_BT_AMP_STA_ROLE:
2370 switch (psessionEntry->limSmeState)
2371 {
2372 case eLIM_SME_ASSOCIATED_STATE:
2373 case eLIM_SME_LINK_EST_STATE:
2374 psessionEntry->limPrevSmeState = psessionEntry->limSmeState;
2375 psessionEntry->limSmeState= eLIM_SME_WT_DISASSOC_STATE;
Hoonki Lee8c9e99f2013-04-18 22:59:11 -07002376#ifdef FEATURE_WLAN_TDLS
2377 /* Delete all TDLS peers connected before leaving BSS*/
2378 limDeleteTDLSPeers(pMac, psessionEntry);
2379#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07002380 MTRACE(macTrace(pMac, TRACE_CODE_SME_STATE, psessionEntry->peSessionId, psessionEntry->limSmeState));
Jeff Johnson295189b2012-06-20 16:38:30 -07002381 break;
2382
2383 case eLIM_SME_WT_DEAUTH_STATE:
2384 /* PE shall still process the DISASSOC_REQ and proceed with
2385 * link tear down even if it had already sent a DEAUTH_IND to
2386 * to SME. pMac->lim.gLimPrevSmeState shall remain the same as
2387 * its been set when PE entered WT_DEAUTH_STATE.
2388 */
2389 psessionEntry->limSmeState= eLIM_SME_WT_DISASSOC_STATE;
Jeff Johnsone7245742012-09-05 17:12:55 -07002390 MTRACE(macTrace(pMac, TRACE_CODE_SME_STATE, psessionEntry->peSessionId, psessionEntry->limSmeState));
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002391 limLog(pMac, LOG1, FL("Rcvd SME_DISASSOC_REQ while in SME_WT_DEAUTH_STATE. "));
Jeff Johnson295189b2012-06-20 16:38:30 -07002392 break;
2393
2394 case eLIM_SME_WT_DISASSOC_STATE:
2395 /* PE Recieved a Disassoc frame. Normally it gets DISASSOC_CNF but it
2396 * received DISASSOC_REQ. Which means host is also trying to disconnect.
2397 * PE can continue processing DISASSOC_REQ and send the response instead
2398 * of failing the request. SME will anyway ignore DEAUTH_IND that was sent
2399 * for disassoc frame.
2400 *
2401 * It will send a disassoc, which is ok. However, we can use the global flag
2402 * sendDisassoc to not send disassoc frame.
2403 */
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002404 limLog(pMac, LOG1, FL("Rcvd SME_DISASSOC_REQ while in SME_WT_DISASSOC_STATE. "));
Jeff Johnson295189b2012-06-20 16:38:30 -07002405 break;
2406
2407 case eLIM_SME_JOIN_FAILURE_STATE: {
2408 /** Return Success as we are already in Disconnected State*/
2409 if (pMac->lim.gLimRspReqd) {
2410 retCode = eSIR_SME_SUCCESS;
2411 disassocTrigger = eLIM_HOST_DISASSOC;
2412 goto sendDisassoc;
2413 }
2414 }break;
2415 default:
2416 /**
2417 * STA is not currently associated.
2418 * Log error and send response to host
2419 */
2420 limLog(pMac, LOGE,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002421 FL("received unexpected SME_DISASSOC_REQ in state %X"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002422 psessionEntry->limSmeState);
2423 limPrintSmeState(pMac, LOGE, psessionEntry->limSmeState);
2424
2425 if (pMac->lim.gLimRspReqd)
2426 {
2427 if (psessionEntry->limSmeState !=
2428 eLIM_SME_WT_ASSOC_STATE)
2429 pMac->lim.gLimRspReqd = false;
2430
2431 retCode = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
2432 disassocTrigger = eLIM_HOST_DISASSOC;
2433 goto sendDisassoc;
2434 }
2435
2436 return;
2437 }
2438
2439 break;
2440
2441 case eLIM_AP_ROLE:
2442 case eLIM_BT_AMP_AP_ROLE:
2443 // Fall through
2444 break;
2445
2446 case eLIM_STA_IN_IBSS_ROLE:
2447 default: // eLIM_UNKNOWN_ROLE
2448 limLog(pMac, LOGE,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002449 FL("received unexpected SME_DISASSOC_REQ for role %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002450 psessionEntry->limSystemRole);
2451
2452 retCode = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
2453 disassocTrigger = eLIM_HOST_DISASSOC;
2454 goto sendDisassoc;
2455 } // end switch (pMac->lim.gLimSystemRole)
2456
2457 if (smeDisassocReq.reasonCode == eLIM_LINK_MONITORING_DISASSOC)
2458 {
2459 /// Disassociation is triggered by Link Monitoring
2460 disassocTrigger = eLIM_LINK_MONITORING_DISASSOC;
2461 reasonCode = eSIR_MAC_DISASSOC_DUE_TO_INACTIVITY_REASON;
2462 }
2463 else
2464 {
2465 disassocTrigger = eLIM_HOST_DISASSOC;
2466 reasonCode = smeDisassocReq.reasonCode;
2467 }
2468
2469 if (smeDisassocReq.doNotSendOverTheAir)
2470 {
2471 sendDisassocFrame = 0;
2472 }
2473 // Trigger Disassociation frame to peer MAC entity
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302474
2475 pMlmDisassocReq = vos_mem_malloc(sizeof(tLimMlmDisassocReq));
2476 if ( NULL == pMlmDisassocReq )
Jeff Johnson295189b2012-06-20 16:38:30 -07002477 {
2478 // Log error
2479 limLog(pMac, LOGP,
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302480 FL("call to AllocateMemory failed for mlmDisassocReq"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002481
2482 return;
2483 }
2484
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302485 vos_mem_copy( (tANI_U8 *) &pMlmDisassocReq->peerMacAddr,
Jeff Johnson295189b2012-06-20 16:38:30 -07002486 (tANI_U8 *) &smeDisassocReq.peerMacAddr,
2487 sizeof(tSirMacAddr));
2488
2489 pMlmDisassocReq->reasonCode = reasonCode;
2490 pMlmDisassocReq->disassocTrigger = disassocTrigger;
2491
2492 /* Update PE session ID*/
2493 pMlmDisassocReq->sessionId = sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -07002494
2495 limPostMlmMessage(pMac,
2496 LIM_MLM_DISASSOC_REQ,
2497 (tANI_U32 *) pMlmDisassocReq);
2498 return;
2499
2500sendDisassoc:
2501 if (psessionEntry)
2502 limSendSmeDisassocNtf(pMac, smeDisassocReq.peerMacAddr,
2503 retCode,
2504 disassocTrigger,
Jeff Johnson295189b2012-06-20 16:38:30 -07002505 1,smesessionId,smetransactionId,psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07002506 else
2507 limSendSmeDisassocNtf(pMac, smeDisassocReq.peerMacAddr,
2508 retCode,
2509 disassocTrigger,
Sudhir Sattayappa Kohalli5a8ac222013-03-06 12:41:42 -08002510 1, smesessionId, smetransactionId, NULL);
Jeff Johnson295189b2012-06-20 16:38:30 -07002511
2512
2513} /*** end __limProcessSmeDisassocReq() ***/
2514
2515
2516/** -----------------------------------------------------------------
2517 \brief __limProcessSmeDisassocCnf() - Process SME_DISASSOC_CNF
2518
2519 This function is called to process SME_DISASSOC_CNF message
2520 from HDD or upper layer application.
2521
2522 \param pMac - global mac structure
2523 \param pStaDs - station dph hash node
2524 \return none
2525 \sa
2526 ----------------------------------------------------------------- */
2527static void
2528__limProcessSmeDisassocCnf(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
2529{
2530 tSirSmeDisassocCnf smeDisassocCnf;
2531 tANI_U16 aid;
2532 tpDphHashNode pStaDs;
2533 tSirRetStatus status = eSIR_SUCCESS;
2534 tpPESession psessionEntry;
2535 tANI_U8 sessionId;
2536
2537
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002538 PELOG1(limLog(pMac, LOG1, FL("received DISASSOC_CNF message"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07002539
2540 status = limDisassocCnfSerDes(pMac, &smeDisassocCnf,(tANI_U8 *) pMsgBuf);
2541
2542 if (status == eSIR_FAILURE)
2543 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002544 PELOGE(limLog(pMac, LOGE, FL("invalid SME_DISASSOC_CNF message"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07002545 return;
2546 }
2547
2548 if((psessionEntry = peFindSessionByBssid(pMac, smeDisassocCnf.bssId, &sessionId))== NULL)
2549 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002550 limLog(pMac, LOGE,FL("session does not exist for given bssId"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002551 return;
2552 }
2553
2554 if (!limIsSmeDisassocCnfValid(pMac, &smeDisassocCnf, psessionEntry))
2555 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002556 limLog(pMac, LOGW, FL("received invalid SME_DISASSOC_CNF message"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002557 return;
2558 }
2559
2560#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM //FEATURE_WLAN_DIAG_SUPPORT
2561 if (smeDisassocCnf.messageType == eWNI_SME_DISASSOC_CNF)
2562 limDiagEventReport(pMac, WLAN_PE_DIAG_DISASSOC_CNF_EVENT, psessionEntry, (tANI_U16)smeDisassocCnf.statusCode, 0);
2563 else if (smeDisassocCnf.messageType == eWNI_SME_DEAUTH_CNF)
2564 limDiagEventReport(pMac, WLAN_PE_DIAG_DEAUTH_CNF_EVENT, psessionEntry, (tANI_U16)smeDisassocCnf.statusCode, 0);
2565#endif //FEATURE_WLAN_DIAG_SUPPORT
2566
2567 switch (psessionEntry->limSystemRole)
2568 {
2569 case eLIM_STA_ROLE:
2570 case eLIM_BT_AMP_STA_ROLE: //To test reconn
2571 if ((psessionEntry->limSmeState != eLIM_SME_IDLE_STATE) &&
2572 (psessionEntry->limSmeState != eLIM_SME_WT_DISASSOC_STATE) &&
2573 (psessionEntry->limSmeState != eLIM_SME_WT_DEAUTH_STATE))
2574 {
2575 limLog(pMac, LOGE,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002576 FL("received unexp SME_DISASSOC_CNF in state %X"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002577 psessionEntry->limSmeState);
2578 limPrintSmeState(pMac, LOGE, psessionEntry->limSmeState);
2579 return;
2580 }
2581 break;
2582
2583 case eLIM_AP_ROLE:
2584 // Fall through
Jeff Johnson295189b2012-06-20 16:38:30 -07002585 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07002586
2587 case eLIM_STA_IN_IBSS_ROLE:
2588 default: // eLIM_UNKNOWN_ROLE
2589 limLog(pMac, LOGE,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002590 FL("received unexpected SME_DISASSOC_CNF role %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002591 psessionEntry->limSystemRole);
2592
2593 return;
2594 }
2595
2596
2597 if ( (psessionEntry->limSmeState == eLIM_SME_WT_DISASSOC_STATE) ||
2598 (psessionEntry->limSmeState == eLIM_SME_WT_DEAUTH_STATE)
Jeff Johnson295189b2012-06-20 16:38:30 -07002599 || (psessionEntry->limSystemRole == eLIM_AP_ROLE )
Jeff Johnson295189b2012-06-20 16:38:30 -07002600 )
2601 {
2602 pStaDs = dphLookupHashEntry(pMac, smeDisassocCnf.peerMacAddr, &aid, &psessionEntry->dph.dphHashTable);
2603 if (pStaDs == NULL)
2604 {
2605 PELOGW(limLog(pMac, LOGW, FL("received DISASSOC_CNF for a STA that does not have context, addr= "));
2606 limPrintMacAddr(pMac, smeDisassocCnf.peerMacAddr, LOGW);)
2607 return;
2608 }
Madan Mohan Koyyalamudi23001722012-10-31 16:48:56 -07002609 /* Delete FT session if there exists one */
2610 limFTCleanup(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -07002611 limCleanupRxPath(pMac, pStaDs, psessionEntry);
Madan Mohan Koyyalamudia67d4332012-11-29 11:35:23 -08002612
2613 limCleanUpDisassocDeauthReq(pMac, (char*)&smeDisassocCnf.peerMacAddr, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07002614 }
2615
2616 return;
2617}
2618
2619
2620/**
2621 * __limProcessSmeDeauthReq()
2622 *
2623 *FUNCTION:
2624 * This function is called to process SME_DEAUTH_REQ message
2625 * from HDD or upper layer application.
2626 *
2627 *LOGIC:
2628 *
2629 *ASSUMPTIONS:
2630 *
2631 *NOTE:
2632 *
2633 * @param pMac Pointer to Global MAC structure
2634 * @param *pMsgBuf A pointer to the SME message buffer
2635 * @return None
2636 */
2637
2638static void
2639__limProcessSmeDeauthReq(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
2640{
2641 tANI_U16 deauthTrigger, reasonCode;
2642 tLimMlmDeauthReq *pMlmDeauthReq;
2643 tSirSmeDeauthReq smeDeauthReq;
2644 tSirResultCodes retCode = eSIR_SME_SUCCESS;
2645 tSirRetStatus status = eSIR_SUCCESS;
2646 tpPESession psessionEntry;
2647 tANI_U8 sessionId; //PE sessionId
2648 tANI_U8 smesessionId;
2649 tANI_U16 smetransactionId;
2650
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002651 PELOG1(limLog(pMac, LOG1,FL("received DEAUTH_REQ message"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07002652
2653 status = limDeauthReqSerDes(pMac, &smeDeauthReq,(tANI_U8 *) pMsgBuf);
2654
2655 limGetSessionInfo(pMac,(tANI_U8 *)pMsgBuf,&smesessionId,&smetransactionId);
2656
2657 //We need to get a session first but we don't even know if the message is correct.
2658 if((psessionEntry = peFindSessionByBssid(pMac, smeDeauthReq.bssId, &sessionId)) == NULL)
2659 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002660 limLog(pMac, LOGE,FL("session does not exist for given bssId"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002661 retCode = eSIR_SME_INVALID_PARAMETERS;
2662 deauthTrigger = eLIM_HOST_DEAUTH;
2663 goto sendDeauth;
2664
2665 }
2666
2667 if ((status == eSIR_FAILURE) || (!limIsSmeDeauthReqValid(pMac, &smeDeauthReq, psessionEntry)))
2668 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002669 PELOGE(limLog(pMac, LOGW,FL("received invalid SME_DEAUTH_REQ message"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07002670 if (pMac->lim.gLimRspReqd)
2671 {
2672 pMac->lim.gLimRspReqd = false;
2673
2674 retCode = eSIR_SME_INVALID_PARAMETERS;
2675 deauthTrigger = eLIM_HOST_DEAUTH;
2676 goto sendDeauth;
2677 }
2678
2679 return;
2680 }
2681
2682#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM //FEATURE_WLAN_DIAG_SUPPORT
2683 limDiagEventReport(pMac, WLAN_PE_DIAG_DEAUTH_REQ_EVENT, psessionEntry, 0, smeDeauthReq.reasonCode);
2684#endif //FEATURE_WLAN_DIAG_SUPPORT
2685
2686 /* Update SME session ID and Transaction ID */
2687 psessionEntry->smeSessionId = smesessionId;
2688 psessionEntry->transactionId = smetransactionId;
2689
2690
2691 switch (psessionEntry->limSystemRole)
2692 {
2693 case eLIM_STA_ROLE:
2694 case eLIM_BT_AMP_STA_ROLE:
2695
2696 switch (psessionEntry->limSmeState)
2697 {
2698 case eLIM_SME_ASSOCIATED_STATE:
2699 case eLIM_SME_LINK_EST_STATE:
2700 case eLIM_SME_WT_ASSOC_STATE:
2701 case eLIM_SME_JOIN_FAILURE_STATE:
2702 case eLIM_SME_IDLE_STATE:
2703 psessionEntry->limPrevSmeState = psessionEntry->limSmeState;
2704 psessionEntry->limSmeState = eLIM_SME_WT_DEAUTH_STATE;
Varun Reddy Yeturue3bbf6e2013-02-08 18:50:55 -08002705 MTRACE(macTrace(pMac, TRACE_CODE_SME_STATE, psessionEntry->peSessionId, psessionEntry->limSmeState));
Jeff Johnson295189b2012-06-20 16:38:30 -07002706
2707 // Send Deauthentication request to MLM below
2708
2709 break;
2710
2711 default:
2712 /**
2713 * STA is not in a state to deauthenticate with
2714 * peer. Log error and send response to host.
2715 */
2716 limLog(pMac, LOGE,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002717 FL("received unexp SME_DEAUTH_REQ in state %X"),psessionEntry->limSmeState);
Jeff Johnson295189b2012-06-20 16:38:30 -07002718 limPrintSmeState(pMac, LOGE, psessionEntry->limSmeState);
2719
2720 if (pMac->lim.gLimRspReqd)
2721 {
2722 pMac->lim.gLimRspReqd = false;
2723
2724 retCode = eSIR_SME_STA_NOT_AUTHENTICATED;
2725 deauthTrigger = eLIM_HOST_DEAUTH;
2726 goto sendDeauth;
2727 }
2728
2729 return;
2730 }
2731
2732 break;
2733
2734 case eLIM_STA_IN_IBSS_ROLE:
2735
2736 return;
2737
2738 case eLIM_AP_ROLE:
2739 // Fall through
2740
2741 break;
2742
2743 default:
2744 limLog(pMac, LOGE,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002745 FL("received unexpected SME_DEAUTH_REQ for role %X"),psessionEntry->limSystemRole);
Jeff Johnson295189b2012-06-20 16:38:30 -07002746
2747 return;
2748 } // end switch (pMac->lim.gLimSystemRole)
2749
2750 if (smeDeauthReq.reasonCode == eLIM_LINK_MONITORING_DEAUTH)
2751 {
2752 /// Deauthentication is triggered by Link Monitoring
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002753 PELOG1(limLog(pMac, LOG1, FL("**** Lost link with AP ****"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07002754 deauthTrigger = eLIM_LINK_MONITORING_DEAUTH;
2755 reasonCode = eSIR_MAC_UNSPEC_FAILURE_REASON;
2756 }
2757 else
2758 {
2759 deauthTrigger = eLIM_HOST_DEAUTH;
2760 reasonCode = smeDeauthReq.reasonCode;
2761 }
2762
2763 // Trigger Deauthentication frame to peer MAC entity
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302764 pMlmDeauthReq = vos_mem_malloc(sizeof(tLimMlmDeauthReq));
2765 if ( NULL == pMlmDeauthReq )
Jeff Johnson295189b2012-06-20 16:38:30 -07002766 {
2767 // Log error
2768 limLog(pMac, LOGP,
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302769 FL("call to AllocateMemory failed for mlmDeauthReq"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002770
2771 return;
2772 }
2773
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302774 vos_mem_copy( (tANI_U8 *) &pMlmDeauthReq->peerMacAddr,
Jeff Johnson295189b2012-06-20 16:38:30 -07002775 (tANI_U8 *) &smeDeauthReq.peerMacAddr,
2776 sizeof(tSirMacAddr));
2777
2778 pMlmDeauthReq->reasonCode = reasonCode;
2779 pMlmDeauthReq->deauthTrigger = deauthTrigger;
Jeff Johnson295189b2012-06-20 16:38:30 -07002780
2781 /* Update PE session Id*/
2782 pMlmDeauthReq->sessionId = sessionId;
2783
2784 limPostMlmMessage(pMac,
2785 LIM_MLM_DEAUTH_REQ,
2786 (tANI_U32 *) pMlmDeauthReq);
2787 return;
2788
2789sendDeauth:
2790 limSendSmeDeauthNtf(pMac, smeDeauthReq.peerMacAddr,
2791 retCode,
2792 deauthTrigger,
Jeff Johnson295189b2012-06-20 16:38:30 -07002793 1,
Jeff Johnson295189b2012-06-20 16:38:30 -07002794 smesessionId, smetransactionId);
2795} /*** end __limProcessSmeDeauthReq() ***/
2796
2797
2798
2799/**
2800 * __limProcessSmeSetContextReq()
2801 *
2802 *FUNCTION:
2803 * This function is called to process SME_SETCONTEXT_REQ message
2804 * from HDD or upper layer application.
2805 *
2806 *LOGIC:
2807 *
2808 *ASSUMPTIONS:
2809 *
2810 *NOTE:
2811 *
2812 * @param pMac Pointer to Global MAC structure
2813 * @param *pMsgBuf A pointer to the SME message buffer
2814 * @return None
2815 */
2816
2817static void
2818__limProcessSmeSetContextReq(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
2819{
2820 tpSirSmeSetContextReq pSetContextReq;
2821 tLimMlmSetKeysReq *pMlmSetKeysReq;
2822 tpPESession psessionEntry;
2823 tANI_U8 sessionId; //PE sessionID
2824 tANI_U8 smesessionId;
2825 tANI_U16 smetransactionId;
2826
2827
2828 PELOG1(limLog(pMac, LOG1,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002829 FL("received SETCONTEXT_REQ message")););
Jeff Johnson295189b2012-06-20 16:38:30 -07002830
2831
2832 if(pMsgBuf == NULL)
2833 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002834 limLog(pMac, LOGE,FL("Buffer is Pointing to NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002835 return;
2836 }
2837
2838 limGetSessionInfo(pMac,(tANI_U8 *)pMsgBuf,&smesessionId,&smetransactionId);
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302839
2840 pSetContextReq = vos_mem_malloc(sizeof(tSirKeys) * SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS);
2841 if ( NULL == pSetContextReq )
Jeff Johnson295189b2012-06-20 16:38:30 -07002842 {
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302843 limLog(pMac, LOGP, FL("call to AllocateMemory failed for pSetContextReq"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002844 return;
2845 }
2846
2847 if ((limSetContextReqSerDes(pMac, pSetContextReq, (tANI_U8 *) pMsgBuf) == eSIR_FAILURE) ||
2848 (!limIsSmeSetContextReqValid(pMac, pSetContextReq)))
2849 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002850 limLog(pMac, LOGW, FL("received invalid SME_SETCONTEXT_REQ message"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002851 goto end;
2852 }
2853
2854 if(pSetContextReq->keyMaterial.numKeys > SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS)
2855 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002856 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 -07002857 limSendSmeSetContextRsp(pMac,
2858 pSetContextReq->peerMacAddr,
Jeff Johnson295189b2012-06-20 16:38:30 -07002859 1,
Jeff Johnson295189b2012-06-20 16:38:30 -07002860 eSIR_SME_INVALID_PARAMETERS,NULL,
2861 smesessionId,smetransactionId);
2862
2863 goto end;
2864 }
2865
2866
2867 if((psessionEntry = peFindSessionByBssid(pMac, pSetContextReq->bssId, &sessionId)) == NULL)
2868 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002869 limLog(pMac, LOGW, FL("Session does not exist for given BSSID"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002870 limSendSmeSetContextRsp(pMac,
2871 pSetContextReq->peerMacAddr,
Jeff Johnson295189b2012-06-20 16:38:30 -07002872 1,
Jeff Johnson295189b2012-06-20 16:38:30 -07002873 eSIR_SME_INVALID_PARAMETERS,NULL,
2874 smesessionId,smetransactionId);
2875
2876 goto end;
2877 }
2878
2879#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM //FEATURE_WLAN_DIAG_SUPPORT
2880 limDiagEventReport(pMac, WLAN_PE_DIAG_SETCONTEXT_REQ_EVENT, psessionEntry, 0, 0);
2881#endif //FEATURE_WLAN_DIAG_SUPPORT
2882
2883
2884 if ((((psessionEntry->limSystemRole == eLIM_STA_ROLE) || (psessionEntry->limSystemRole == eLIM_BT_AMP_STA_ROLE)) &&
2885 (psessionEntry->limSmeState == eLIM_SME_LINK_EST_STATE)) ||
2886 (((psessionEntry->limSystemRole == eLIM_STA_IN_IBSS_ROLE) ||
2887 (psessionEntry->limSystemRole == eLIM_AP_ROLE)|| (psessionEntry->limSystemRole == eLIM_BT_AMP_AP_ROLE)) &&
2888 (psessionEntry->limSmeState == eLIM_SME_NORMAL_STATE)))
2889 {
2890 // Trigger MLM_SETKEYS_REQ
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302891 pMlmSetKeysReq = vos_mem_malloc(sizeof(tLimMlmSetKeysReq));
2892 if ( NULL == pMlmSetKeysReq )
Jeff Johnson295189b2012-06-20 16:38:30 -07002893 {
2894 // Log error
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302895 limLog(pMac, LOGP, FL("call to AllocateMemory failed for mlmSetKeysReq"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002896 goto end;
2897 }
2898
2899 pMlmSetKeysReq->edType = pSetContextReq->keyMaterial.edType;
2900 pMlmSetKeysReq->numKeys = pSetContextReq->keyMaterial.numKeys;
2901 if(pMlmSetKeysReq->numKeys > SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS)
2902 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002903 limLog(pMac, LOGP, FL("Num of keys exceeded max num of default keys limit"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002904 goto end;
2905 }
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302906 vos_mem_copy( (tANI_U8 *) &pMlmSetKeysReq->peerMacAddr,
Jeff Johnson295189b2012-06-20 16:38:30 -07002907 (tANI_U8 *) &pSetContextReq->peerMacAddr,
2908 sizeof(tSirMacAddr));
2909
Jeff Johnson295189b2012-06-20 16:38:30 -07002910
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302911 vos_mem_copy( (tANI_U8 *) &pMlmSetKeysReq->key,
Jeff Johnson295189b2012-06-20 16:38:30 -07002912 (tANI_U8 *) &pSetContextReq->keyMaterial.key,
2913 sizeof(tSirKeys) * (pMlmSetKeysReq->numKeys ? pMlmSetKeysReq->numKeys : 1));
2914
2915 pMlmSetKeysReq->sessionId = sessionId;
2916#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
2917 PELOG1(limLog(pMac, LOG1,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002918 FL("received SETCONTEXT_REQ message sessionId=%d"), pMlmSetKeysReq->sessionId););
Jeff Johnson295189b2012-06-20 16:38:30 -07002919#endif
2920
Jeff Johnson295189b2012-06-20 16:38:30 -07002921 if(((pSetContextReq->keyMaterial.edType == eSIR_ED_WEP40) || (pSetContextReq->keyMaterial.edType == eSIR_ED_WEP104))
2922 && (psessionEntry->limSystemRole == eLIM_AP_ROLE))
2923 {
2924 if(pSetContextReq->keyMaterial.key[0].keyLength)
2925 {
2926 tANI_U8 keyId;
2927 keyId = pSetContextReq->keyMaterial.key[0].keyId;
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302928 vos_mem_copy( (tANI_U8 *)&psessionEntry->WEPKeyMaterial[keyId],
Jeff Johnson295189b2012-06-20 16:38:30 -07002929 (tANI_U8 *) &pSetContextReq->keyMaterial, sizeof(tSirKeyMaterial));
2930 }
2931 else {
2932 tANI_U32 i;
2933 for( i = 0; i < SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS; i++)
2934 {
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302935 vos_mem_copy( (tANI_U8 *) &pMlmSetKeysReq->key[i],
Jeff Johnson295189b2012-06-20 16:38:30 -07002936 (tANI_U8 *)psessionEntry->WEPKeyMaterial[i].key, sizeof(tSirKeys));
2937 }
2938 }
2939 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002940
2941 limPostMlmMessage(pMac, LIM_MLM_SETKEYS_REQ, (tANI_U32 *) pMlmSetKeysReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07002942 }
2943 else
2944 {
2945 limLog(pMac, LOGE,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002946 FL("received unexpected SME_SETCONTEXT_REQ for role %d, state=%X"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002947 psessionEntry->limSystemRole,
2948 psessionEntry->limSmeState);
2949 limPrintSmeState(pMac, LOGE, psessionEntry->limSmeState);
2950
2951 limSendSmeSetContextRsp(pMac, pSetContextReq->peerMacAddr,
Jeff Johnson295189b2012-06-20 16:38:30 -07002952 1,
Jeff Johnson295189b2012-06-20 16:38:30 -07002953 eSIR_SME_UNEXPECTED_REQ_RESULT_CODE,psessionEntry,
2954 smesessionId,
2955 smetransactionId);
2956 }
2957
2958end:
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302959 vos_mem_free( pSetContextReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07002960 return;
2961} /*** end __limProcessSmeSetContextReq() ***/
2962
2963/**
2964 * __limProcessSmeRemoveKeyReq()
2965 *
2966 *FUNCTION:
2967 * This function is called to process SME_REMOVEKEY_REQ message
2968 * from HDD or upper layer application.
2969 *
2970 *LOGIC:
2971 *
2972 *ASSUMPTIONS:
2973 *
2974 *NOTE:
2975 *
2976 * @param pMac Pointer to Global MAC structure
2977 * @param *pMsgBuf A pointer to the SME message buffer
2978 * @return None
2979 */
2980
2981static void
2982__limProcessSmeRemoveKeyReq(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
2983{
2984 tpSirSmeRemoveKeyReq pRemoveKeyReq;
2985 tLimMlmRemoveKeyReq *pMlmRemoveKeyReq;
2986 tpPESession psessionEntry;
2987 tANI_U8 sessionId; //PE sessionID
2988 tANI_U8 smesessionId;
2989 tANI_U16 smetransactionId;
2990
2991 PELOG1(limLog(pMac, LOG1,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002992 FL("received REMOVEKEY_REQ message"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07002993
2994 if(pMsgBuf == NULL)
2995 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002996 limLog(pMac, LOGE,FL("Buffer is Pointing to NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002997 return;
2998 }
2999
3000
3001 limGetSessionInfo(pMac,(tANI_U8 *)pMsgBuf,&smesessionId,&smetransactionId);
3002
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303003 pRemoveKeyReq = vos_mem_malloc(sizeof(*pRemoveKeyReq));
3004 if ( NULL == pRemoveKeyReq )
Jeff Johnson295189b2012-06-20 16:38:30 -07003005 {
3006 //Log error
3007 limLog(pMac, LOGP,
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303008 FL("call to AllocateMemory failed for pRemoveKeyReq"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003009
3010 return;
3011 }
3012
3013 if ((limRemoveKeyReqSerDes(pMac,
3014 pRemoveKeyReq,
3015 (tANI_U8 *) pMsgBuf) == eSIR_FAILURE))
3016 {
3017 limLog(pMac, LOGW,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003018 FL("received invalid SME_REMOVECONTEXT_REQ message"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003019
3020 /* extra look up is needed since, session entry to be passed il limsendremovekey response */
3021
3022 if((psessionEntry = peFindSessionByBssid(pMac,pRemoveKeyReq->bssId,&sessionId))== NULL)
3023 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003024 limLog(pMac, LOGE,FL("session does not exist for given bssId"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003025 //goto end;
3026 }
3027
3028 limSendSmeRemoveKeyRsp(pMac,
3029 pRemoveKeyReq->peerMacAddr,
3030 eSIR_SME_INVALID_PARAMETERS,psessionEntry,
3031 smesessionId,smetransactionId);
3032
3033 goto end;
3034 }
3035
3036 if((psessionEntry = peFindSessionByBssid(pMac,pRemoveKeyReq->bssId, &sessionId))== NULL)
3037 {
3038 limLog(pMac, LOGE,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003039 FL("session does not exist for given bssId"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003040 limSendSmeRemoveKeyRsp(pMac,
3041 pRemoveKeyReq->peerMacAddr,
3042 eSIR_SME_UNEXPECTED_REQ_RESULT_CODE, NULL,
3043 smesessionId, smetransactionId);
3044 goto end;
3045 }
3046
3047
3048 if ((((psessionEntry->limSystemRole == eLIM_STA_ROLE)|| (psessionEntry->limSystemRole == eLIM_BT_AMP_STA_ROLE))&&
3049 (psessionEntry->limSmeState == eLIM_SME_LINK_EST_STATE)) ||
3050 (((psessionEntry->limSystemRole == eLIM_STA_IN_IBSS_ROLE) ||
3051 (psessionEntry->limSystemRole == eLIM_AP_ROLE)|| (psessionEntry->limSystemRole == eLIM_BT_AMP_AP_ROLE)) &&
3052 (psessionEntry->limSmeState == eLIM_SME_NORMAL_STATE)))
3053 {
3054 // Trigger MLM_REMOVEKEYS_REQ
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303055 pMlmRemoveKeyReq = vos_mem_malloc(sizeof(tLimMlmRemoveKeyReq));
3056 if ( NULL == pMlmRemoveKeyReq )
Jeff Johnson295189b2012-06-20 16:38:30 -07003057 {
3058 // Log error
3059 limLog(pMac, LOGP,
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303060 FL("call to AllocateMemory failed for mlmRemoveKeysReq"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003061
3062 goto end;
3063 }
3064
3065 pMlmRemoveKeyReq->edType = (tAniEdType)pRemoveKeyReq->edType;
3066 pMlmRemoveKeyReq->keyId = pRemoveKeyReq->keyId;
3067 pMlmRemoveKeyReq->wepType = pRemoveKeyReq->wepType;
3068 pMlmRemoveKeyReq->unicast = pRemoveKeyReq->unicast;
3069
3070 /* Update PE session Id */
3071 pMlmRemoveKeyReq->sessionId = sessionId;
3072
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303073 vos_mem_copy( (tANI_U8 *) &pMlmRemoveKeyReq->peerMacAddr,
Jeff Johnson295189b2012-06-20 16:38:30 -07003074 (tANI_U8 *) &pRemoveKeyReq->peerMacAddr,
3075 sizeof(tSirMacAddr));
3076
3077
3078 limPostMlmMessage(pMac,
3079 LIM_MLM_REMOVEKEY_REQ,
3080 (tANI_U32 *) pMlmRemoveKeyReq);
3081 }
3082 else
3083 {
3084 limLog(pMac, LOGE,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003085 FL("received unexpected SME_REMOVEKEY_REQ for role %d, state=%X"),
Jeff Johnson295189b2012-06-20 16:38:30 -07003086 psessionEntry->limSystemRole,
3087 psessionEntry->limSmeState);
3088 limPrintSmeState(pMac, LOGE, psessionEntry->limSmeState);
3089
3090 limSendSmeRemoveKeyRsp(pMac,
3091 pRemoveKeyReq->peerMacAddr,
3092 eSIR_SME_UNEXPECTED_REQ_RESULT_CODE,psessionEntry,
3093 smesessionId,smetransactionId);
3094 }
3095
3096end:
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303097 vos_mem_free( pRemoveKeyReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07003098} /*** end __limProcessSmeRemoveKeyReq() ***/
3099
Jeff Johnson295189b2012-06-20 16:38:30 -07003100void limProcessSmeGetScanChannelInfo(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
3101{
3102 tSirMsgQ mmhMsg;
3103 tpSmeGetScanChnRsp pSirSmeRsp;
3104 tANI_U16 len = 0;
Madan Mohan Koyyalamudide1b5bc2013-07-12 00:56:04 +05303105 tANI_U8 sessionId;
3106 tANI_U16 transactionId;
Jeff Johnson295189b2012-06-20 16:38:30 -07003107
3108 if(pMac->lim.scanChnInfo.numChnInfo > SIR_MAX_SUPPORTED_CHANNEL_LIST)
3109 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003110 limLog(pMac, LOGW, FL("numChn is out of bounds %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07003111 pMac->lim.scanChnInfo.numChnInfo);
3112 pMac->lim.scanChnInfo.numChnInfo = SIR_MAX_SUPPORTED_CHANNEL_LIST;
3113 }
3114
3115 PELOG2(limLog(pMac, LOG2,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003116 FL("Sending message %s with number of channels %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07003117 limMsgStr(eWNI_SME_GET_SCANNED_CHANNEL_RSP), pMac->lim.scanChnInfo.numChnInfo);)
3118
3119 len = sizeof(tSmeGetScanChnRsp) + (pMac->lim.scanChnInfo.numChnInfo - 1) * sizeof(tLimScanChn);
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303120 pSirSmeRsp = vos_mem_malloc(len);
3121 if ( NULL == pSirSmeRsp )
Jeff Johnson295189b2012-06-20 16:38:30 -07003122 {
3123 /// Buffer not available. Log error
3124 limLog(pMac, LOGP,
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303125 FL("call to AllocateMemory failed for JOIN/REASSOC_RSP"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003126
3127 return;
3128 }
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303129 vos_mem_set(pSirSmeRsp, len, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07003130
Jeff Johnson295189b2012-06-20 16:38:30 -07003131 pSirSmeRsp->mesgType = eWNI_SME_GET_SCANNED_CHANNEL_RSP;
3132 pSirSmeRsp->mesgLen = len;
Madan Mohan Koyyalamudide1b5bc2013-07-12 00:56:04 +05303133
3134 if (pMac->fScanOffload)
3135 {
3136 limGetSessionInfo(pMac,(tANI_U8 *)pMsgBuf,&sessionId,&transactionId);
3137 pSirSmeRsp->sessionId = sessionId;
3138 }
3139 else
3140 pSirSmeRsp->sessionId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003141
3142 if(pMac->lim.scanChnInfo.numChnInfo)
3143 {
3144 pSirSmeRsp->numChn = pMac->lim.scanChnInfo.numChnInfo;
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303145 vos_mem_copy( pSirSmeRsp->scanChn, pMac->lim.scanChnInfo.scanChn,
3146 sizeof(tLimScanChn) * pSirSmeRsp->numChn);
Jeff Johnson295189b2012-06-20 16:38:30 -07003147 }
3148 //Clear the list
3149 limRessetScanChannelInfo(pMac);
3150
3151 mmhMsg.type = eWNI_SME_GET_SCANNED_CHANNEL_RSP;
3152 mmhMsg.bodyptr = pSirSmeRsp;
3153 mmhMsg.bodyval = 0;
3154
3155 pMac->lim.gLimRspReqd = false;
Jeff Johnsone7245742012-09-05 17:12:55 -07003156 MTRACE(macTraceMsgTx(pMac, NO_SESSION, mmhMsg.type));
Jeff Johnson295189b2012-06-20 16:38:30 -07003157 limSysProcessMmhMsgApi(pMac, &mmhMsg, ePROT);
3158}
3159
3160
Jeff Johnson295189b2012-06-20 16:38:30 -07003161void limProcessSmeGetAssocSTAsInfo(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
3162{
3163 tSirSmeGetAssocSTAsReq getAssocSTAsReq;
3164 tpDphHashNode pStaDs = NULL;
3165 tpPESession psessionEntry = NULL;
3166 tSap_Event sapEvent;
3167 tpWLAN_SAPEventCB pSapEventCallback = NULL;
3168 tpSap_AssocMacAddr pAssocStasTemp = NULL;// #include "sapApi.h"
3169 tANI_U8 sessionId = CSR_SESSION_ID_INVALID;
3170 tANI_U8 assocId = 0;
3171 tANI_U8 staCount = 0;
3172
3173 if (!limIsSmeGetAssocSTAsReqValid(pMac, &getAssocSTAsReq, (tANI_U8 *) pMsgBuf))
3174 {
3175 limLog(pMac, LOGE,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003176 FL("received invalid eWNI_SME_GET_ASSOC_STAS_REQ message"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003177 goto limAssocStaEnd;
3178 }
3179
3180 switch (getAssocSTAsReq.modId)
3181 {
3182/**
3183 case VOS_MODULE_ID_HAL:
3184 wdaPostCtrlMsg( pMac, &msgQ );
3185 return;
3186
3187 case VOS_MODULE_ID_TL:
3188 Post msg TL
3189 return;
3190*/
3191 case VOS_MODULE_ID_PE:
3192 default:
3193 break;
3194 }
3195
Jeff Johnson1250df42012-12-10 14:31:52 -08003196 // Get Associated stations from PE
Jeff Johnson295189b2012-06-20 16:38:30 -07003197 // Find PE session Entry
3198 if ((psessionEntry = peFindSessionByBssid(pMac, getAssocSTAsReq.bssId, &sessionId)) == NULL)
3199 {
3200 limLog(pMac, LOGE,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003201 FL("session does not exist for given bssId"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003202 goto limAssocStaEnd;
3203 }
3204
3205 if (psessionEntry->limSystemRole != eLIM_AP_ROLE)
3206 {
3207 limLog(pMac, LOGE,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003208 FL("Received unexpected message in state %X, in role %X"),
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303209 psessionEntry->limSmeState, psessionEntry->limSystemRole);
Jeff Johnson295189b2012-06-20 16:38:30 -07003210 goto limAssocStaEnd;
3211 }
3212
3213 // Retrieve values obtained in the request message
3214 pSapEventCallback = (tpWLAN_SAPEventCB)getAssocSTAsReq.pSapEventCallback;
3215 pAssocStasTemp = (tpSap_AssocMacAddr)getAssocSTAsReq.pAssocStasArray;
3216
3217 for (assocId = 0; assocId < psessionEntry->dph.dphHashTable.size; assocId++)// Softap dphHashTable.size = 8
3218 {
3219 pStaDs = dphGetHashEntry(pMac, assocId, &psessionEntry->dph.dphHashTable);
3220
3221 if (NULL == pStaDs)
3222 continue;
3223
3224 if (pStaDs->valid)
3225 {
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303226 vos_mem_copy((tANI_U8 *)&pAssocStasTemp->staMac,
3227 (tANI_U8 *)&pStaDs->staAddr,
3228 sizeof(v_MACADDR_t)); // Mac address
Jeff Johnson295189b2012-06-20 16:38:30 -07003229 pAssocStasTemp->assocId = (v_U8_t)pStaDs->assocId; // Association Id
3230 pAssocStasTemp->staId = (v_U8_t)pStaDs->staIndex; // Station Id
3231
Leo Chang614d2072013-08-22 14:59:44 -07003232 palCopyMemory(pMac->hHdd, (tANI_U8 *)&pAssocStasTemp->supportedRates,
3233 (tANI_U8 *)&pStaDs->supportedRates,
3234 sizeof(tSirSupportedRates));
3235 pAssocStasTemp->ShortGI40Mhz = pStaDs->htShortGI40Mhz;
3236 pAssocStasTemp->ShortGI20Mhz = pStaDs->htShortGI20Mhz;
3237 pAssocStasTemp->Support40Mhz = pStaDs->htDsssCckRate40MHzSupport;
3238
Jeff Johnson295189b2012-06-20 16:38:30 -07003239 limLog(pMac, LOG1, FL("dph Station Number = %d"), staCount+1);
3240 limLog(pMac, LOG1, FL("MAC = %02x:%02x:%02x:%02x:%02x:%02x"),
3241 pStaDs->staAddr[0],
3242 pStaDs->staAddr[1],
3243 pStaDs->staAddr[2],
3244 pStaDs->staAddr[3],
3245 pStaDs->staAddr[4],
3246 pStaDs->staAddr[5]);
3247 limLog(pMac, LOG1, FL("Association Id = %d"),pStaDs->assocId);
3248 limLog(pMac, LOG1, FL("Station Index = %d"),pStaDs->staIndex);
3249
3250 pAssocStasTemp++;
3251 staCount++;
3252 }
3253 }
3254
3255limAssocStaEnd:
3256 // Call hdd callback with sap event to send the list of associated stations from PE
3257 if (pSapEventCallback != NULL)
3258 {
3259 sapEvent.sapHddEventCode = eSAP_ASSOC_STA_CALLBACK_EVENT;
3260 sapEvent.sapevt.sapAssocStaListEvent.module = VOS_MODULE_ID_PE;
3261 sapEvent.sapevt.sapAssocStaListEvent.noOfAssocSta = staCount;
3262 sapEvent.sapevt.sapAssocStaListEvent.pAssocStas = (tpSap_AssocMacAddr)getAssocSTAsReq.pAssocStasArray;
3263 pSapEventCallback(&sapEvent, getAssocSTAsReq.pUsrContext);
3264 }
3265}
3266
3267
3268/**
3269 * limProcessSmeGetWPSPBCSessions
3270 *
3271 *FUNCTION:
3272 * This function is called when query the WPS PBC overlap message is received
3273 *
3274 *LOGIC:
3275 * This function parses get WPS PBC overlap information message and call callback to pass
3276 * WPS PBC overlap information back to hdd.
3277 *ASSUMPTIONS:
3278 *
3279 *
3280 *NOTE:
3281 *
3282 * @param pMac Pointer to Global MAC structure
3283 * @param pMsgBuf A pointer to WPS PBC overlap query message
3284*
3285 * @return None
3286 */
3287void limProcessSmeGetWPSPBCSessions(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
3288{
3289 tSirSmeGetWPSPBCSessionsReq GetWPSPBCSessionsReq;
3290 tpPESession psessionEntry = NULL;
3291 tSap_Event sapEvent;
3292 tpWLAN_SAPEventCB pSapEventCallback = NULL;
3293 tANI_U8 sessionId = CSR_SESSION_ID_INVALID;
3294 tSirMacAddr zeroMac = {0,0,0,0,0,0};
3295
3296 sapEvent.sapevt.sapGetWPSPBCSessionEvent.status = VOS_STATUS_E_FAULT;
3297
3298 if (limIsSmeGetWPSPBCSessionsReqValid(pMac, &GetWPSPBCSessionsReq, (tANI_U8 *) pMsgBuf) != eSIR_SUCCESS)
3299 {
3300 limLog(pMac, LOGE,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003301 FL("received invalid eWNI_SME_GET_ASSOC_STAS_REQ message"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003302 goto limGetWPSPBCSessionsEnd;
3303 }
3304
Jeff Johnson1250df42012-12-10 14:31:52 -08003305 // Get Associated stations from PE
Jeff Johnson295189b2012-06-20 16:38:30 -07003306 // Find PE session Entry
3307 if ((psessionEntry = peFindSessionByBssid(pMac, GetWPSPBCSessionsReq.bssId, &sessionId)) == NULL)
3308 {
3309 limLog(pMac, LOGE,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003310 FL("session does not exist for given bssId"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003311 goto limGetWPSPBCSessionsEnd;
3312 }
3313
3314 if (psessionEntry->limSystemRole != eLIM_AP_ROLE)
3315 {
3316 limLog(pMac, LOGE,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003317 FL("Received unexpected message in role %X"),
Jeff Johnson295189b2012-06-20 16:38:30 -07003318 psessionEntry->limSystemRole);
3319 goto limGetWPSPBCSessionsEnd;
3320 }
3321
Jeff Johnson1250df42012-12-10 14:31:52 -08003322 // Call hdd callback with sap event to send the WPS PBC overlap information
Jeff Johnson295189b2012-06-20 16:38:30 -07003323 sapEvent.sapHddEventCode = eSAP_GET_WPSPBC_SESSION_EVENT;
3324 sapEvent.sapevt.sapGetWPSPBCSessionEvent.module = VOS_MODULE_ID_PE;
3325
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303326 if (vos_mem_compare( zeroMac, GetWPSPBCSessionsReq.pRemoveMac, sizeof(tSirMacAddr)))
Jeff Johnson295189b2012-06-20 16:38:30 -07003327 { //This is GetWpsSession call
3328
3329 limGetWPSPBCSessions(pMac,
3330 sapEvent.sapevt.sapGetWPSPBCSessionEvent.addr.bytes, sapEvent.sapevt.sapGetWPSPBCSessionEvent.UUID_E,
3331 &sapEvent.sapevt.sapGetWPSPBCSessionEvent.wpsPBCOverlap, psessionEntry);
3332 }
3333 else
3334 {
3335 limRemovePBCSessions(pMac, GetWPSPBCSessionsReq.pRemoveMac,psessionEntry);
3336 /* don't have to inform the HDD/Host */
3337 return;
3338 }
3339
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003340 PELOG4(limLog(pMac, LOGE, FL("wpsPBCOverlap %d"), sapEvent.sapevt.sapGetWPSPBCSessionEvent.wpsPBCOverlap);)
Jeff Johnson295189b2012-06-20 16:38:30 -07003341 PELOG4(limPrintMacAddr(pMac, sapEvent.sapevt.sapGetWPSPBCSessionEvent.addr.bytes, LOG4);)
3342
3343 sapEvent.sapevt.sapGetWPSPBCSessionEvent.status = VOS_STATUS_SUCCESS;
3344
3345limGetWPSPBCSessionsEnd:
3346 pSapEventCallback = (tpWLAN_SAPEventCB)GetWPSPBCSessionsReq.pSapEventCallback;
3347 pSapEventCallback(&sapEvent, GetWPSPBCSessionsReq.pUsrContext);
3348}
3349
Jeff Johnson295189b2012-06-20 16:38:30 -07003350
3351
3352/**
3353 * __limCounterMeasures()
3354 *
3355 * FUNCTION:
3356 * This function is called to "implement" MIC counter measure
3357 * and is *temporary* only
3358 *
3359 * LOGIC: on AP, disassoc all STA associated thru TKIP,
3360 * we don't do the proper STA disassoc sequence since the
3361 * BSS will be stoped anyway
3362 *
3363 *ASSUMPTIONS:
3364 *
3365 *NOTE:
3366 *
3367 * @param pMac Pointer to Global MAC structure
3368 * @return None
3369 */
3370
3371static void
3372__limCounterMeasures(tpAniSirGlobal pMac, tpPESession psessionEntry)
3373{
3374 tSirMacAddr mac = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
3375 if ( (psessionEntry->limSystemRole == eLIM_AP_ROLE) || (psessionEntry->limSystemRole == eLIM_BT_AMP_AP_ROLE)
3376 || (psessionEntry->limSystemRole == eLIM_BT_AMP_STA_ROLE) )
3377
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003378 limSendDisassocMgmtFrame(pMac, eSIR_MAC_MIC_FAILURE_REASON, mac, psessionEntry, FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003379
Jeff Johnson295189b2012-06-20 16:38:30 -07003380};
3381
3382
Jeff Johnson295189b2012-06-20 16:38:30 -07003383void
3384limProcessTkipCounterMeasures(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
3385{
3386 tSirSmeTkipCntrMeasReq tkipCntrMeasReq;
3387 tpPESession psessionEntry;
3388 tANI_U8 sessionId; //PE sessionId
3389
3390 if ( limTkipCntrMeasReqSerDes( pMac, &tkipCntrMeasReq, (tANI_U8 *) pMsgBuf ) != eSIR_SUCCESS )
3391 {
3392 limLog(pMac, LOGE,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003393 FL("received invalid eWNI_SME_TKIP_CNTR_MEAS_REQ message"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003394 return;
3395 }
3396
3397 if ( NULL == (psessionEntry = peFindSessionByBssid( pMac, tkipCntrMeasReq.bssId, &sessionId )) )
3398 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003399 limLog(pMac, LOGE, FL("session does not exist for given BSSID "));
Jeff Johnson295189b2012-06-20 16:38:30 -07003400 return;
3401 }
3402
3403 if ( tkipCntrMeasReq.bEnable )
3404 {
3405 __limCounterMeasures( pMac, psessionEntry );
3406 }
3407
3408 psessionEntry->bTkipCntrMeasActive = tkipCntrMeasReq.bEnable;
3409}
Jeff Johnson295189b2012-06-20 16:38:30 -07003410
3411
3412static void
3413__limHandleSmeStopBssRequest(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
3414{
3415 tSirSmeStopBssReq stopBssReq;
3416 tSirRetStatus status;
3417 tLimSmeStates prevState;
3418 tANI_U8 sessionId; //PE sessionId
3419 tpPESession psessionEntry;
3420 tANI_U8 smesessionId;
3421 tANI_U16 smetransactionId;
3422
3423 limGetSessionInfo(pMac,(tANI_U8 *)pMsgBuf,&smesessionId,&smetransactionId);
3424
3425
3426
3427 if ((limStopBssReqSerDes(pMac, &stopBssReq, (tANI_U8 *) pMsgBuf) != eSIR_SUCCESS) ||
3428 !limIsSmeStopBssReqValid(pMsgBuf))
3429 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003430 PELOGW(limLog(pMac, LOGW, FL("received invalid SME_STOP_BSS_REQ message"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07003431 /// Send Stop BSS response to host
3432 limSendSmeRsp(pMac, eWNI_SME_STOP_BSS_RSP, eSIR_SME_INVALID_PARAMETERS,smesessionId,smetransactionId);
3433 return;
3434 }
3435
3436
3437 if((psessionEntry = peFindSessionByBssid(pMac,stopBssReq.bssId,&sessionId)) == NULL)
3438 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003439 limLog(pMac, LOGW, FL("session does not exist for given BSSID "));
Jeff Johnson295189b2012-06-20 16:38:30 -07003440 limSendSmeRsp(pMac, eWNI_SME_STOP_BSS_RSP, eSIR_SME_INVALID_PARAMETERS,smesessionId,smetransactionId);
3441 return;
3442 }
3443
3444#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM //FEATURE_WLAN_DIAG_SUPPORT
3445 limDiagEventReport(pMac, WLAN_PE_DIAG_STOP_BSS_REQ_EVENT, psessionEntry, 0, 0);
3446#endif //FEATURE_WLAN_DIAG_SUPPORT
3447
3448
3449 if ((psessionEntry->limSmeState != eLIM_SME_NORMAL_STATE) || /* Added For BT -AMP Support */
3450 (psessionEntry->limSystemRole == eLIM_STA_ROLE ))
3451 {
3452 /**
3453 * Should not have received STOP_BSS_REQ in states
3454 * other than 'normal' state or on STA in Infrastructure
3455 * mode. Log error and return response to host.
3456 */
3457 limLog(pMac, LOGE,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003458 FL("received unexpected SME_STOP_BSS_REQ in state %X, for role %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07003459 psessionEntry->limSmeState, psessionEntry->limSystemRole);
3460 limPrintSmeState(pMac, LOGE, psessionEntry->limSmeState);
3461 /// Send Stop BSS response to host
3462 limSendSmeRsp(pMac, eWNI_SME_STOP_BSS_RSP, eSIR_SME_UNEXPECTED_REQ_RESULT_CODE,smesessionId,smetransactionId);
3463 return;
3464 }
3465
Jeff Johnson295189b2012-06-20 16:38:30 -07003466 if (psessionEntry->limSystemRole == eLIM_AP_ROLE )
3467 {
3468 limWPSPBCClose(pMac, psessionEntry);
3469 }
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003470 PELOGW(limLog(pMac, LOGW, FL("RECEIVED STOP_BSS_REQ with reason code=%d"), stopBssReq.reasonCode);)
Jeff Johnson295189b2012-06-20 16:38:30 -07003471
3472 prevState = psessionEntry->limSmeState;
3473
3474 psessionEntry->limSmeState = eLIM_SME_IDLE_STATE;
Jeff Johnsone7245742012-09-05 17:12:55 -07003475 MTRACE(macTrace(pMac, TRACE_CODE_SME_STATE, psessionEntry->peSessionId, psessionEntry->limSmeState));
Jeff Johnson295189b2012-06-20 16:38:30 -07003476
3477 /* Update SME session Id and Transaction Id */
3478 psessionEntry->smeSessionId = smesessionId;
3479 psessionEntry->transactionId = smetransactionId;
3480
3481 /* BTAMP_STA and STA_IN_IBSS should NOT send Disassoc frame */
3482 if ( (eLIM_STA_IN_IBSS_ROLE != psessionEntry->limSystemRole) && (eLIM_BT_AMP_STA_ROLE != psessionEntry->limSystemRole) )
3483 {
3484 tSirMacAddr bcAddr = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
3485 if ((stopBssReq.reasonCode == eSIR_SME_MIC_COUNTER_MEASURES))
3486 // Send disassoc all stations associated thru TKIP
3487 __limCounterMeasures(pMac,psessionEntry);
3488 else
Madan Mohan Koyyalamudi299b4862013-01-30 19:59:23 +05303489 limSendDisassocMgmtFrame(pMac, eSIR_MAC_DEAUTH_LEAVING_BSS_REASON, bcAddr, psessionEntry, FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003490 }
3491
3492 //limDelBss is also called as part of coalescing, when we send DEL BSS followed by Add Bss msg.
3493 pMac->lim.gLimIbssCoalescingHappened = false;
3494
3495 /* send a delBss to HAL and wait for a response */
3496 status = limDelBss(pMac, NULL,psessionEntry->bssIdx,psessionEntry);
3497
3498 if (status != eSIR_SUCCESS)
3499 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003500 PELOGE(limLog(pMac, LOGE, FL("delBss failed for bss %d"), psessionEntry->bssIdx);)
Jeff Johnson295189b2012-06-20 16:38:30 -07003501 psessionEntry->limSmeState= prevState;
3502
Jeff Johnsone7245742012-09-05 17:12:55 -07003503 MTRACE(macTrace(pMac, TRACE_CODE_SME_STATE, psessionEntry->peSessionId, psessionEntry->limSmeState));
Jeff Johnson295189b2012-06-20 16:38:30 -07003504
3505 limSendSmeRsp(pMac, eWNI_SME_STOP_BSS_RSP, eSIR_SME_STOP_BSS_FAILURE,smesessionId,smetransactionId);
3506 }
3507}
3508
3509
3510/**--------------------------------------------------------------
3511\fn __limProcessSmeStopBssReq
3512
3513\brief Wrapper for the function __limHandleSmeStopBssRequest
3514 This message will be defered until softmac come out of
3515 scan mode. Message should be handled even if we have
3516 detected radar in the current operating channel.
3517\param pMac
3518\param pMsg
3519
3520\return TRUE - If we consumed the buffer
3521 FALSE - If have defered the message.
3522 ---------------------------------------------------------------*/
3523static tANI_BOOLEAN
3524__limProcessSmeStopBssReq(tpAniSirGlobal pMac, tpSirMsgQ pMsg)
3525{
3526 if (__limIsDeferedMsgForLearn(pMac, pMsg))
3527 {
3528 /**
3529 * If message defered, buffer is not consumed yet.
3530 * So return false
3531 */
3532 return eANI_BOOLEAN_FALSE;
3533 }
3534 __limHandleSmeStopBssRequest(pMac, (tANI_U32 *) pMsg->bodyptr);
3535 return eANI_BOOLEAN_TRUE;
3536} /*** end __limProcessSmeStopBssReq() ***/
3537
3538
3539void limProcessSmeDelBssRsp(
3540 tpAniSirGlobal pMac,
3541 tANI_U32 body,tpPESession psessionEntry)
3542{
3543
3544 (void) body;
3545 SET_LIM_PROCESS_DEFD_MESGS(pMac, true);
3546 //TBD: get the sessionEntry
3547 dphHashTableClassInit(pMac, &psessionEntry->dph.dphHashTable);
3548 limDeletePreAuthList(pMac);
3549 limIbssDelete(pMac,psessionEntry);
3550 limSendSmeRsp(pMac, eWNI_SME_STOP_BSS_RSP, eSIR_SME_SUCCESS,psessionEntry->smeSessionId,psessionEntry->transactionId);
3551 return;
3552}
3553
3554
Jeff Johnson295189b2012-06-20 16:38:30 -07003555/**---------------------------------------------------------------
3556\fn __limProcessSmeAssocCnfNew
3557\brief This function handles SME_ASSOC_CNF/SME_REASSOC_CNF
3558\ in BTAMP AP.
3559\
3560\param pMac
3561\param msgType - message type
3562\param pMsgBuf - a pointer to the SME message buffer
3563\return None
3564------------------------------------------------------------------*/
3565
3566 void
3567__limProcessSmeAssocCnfNew(tpAniSirGlobal pMac, tANI_U32 msgType, tANI_U32 *pMsgBuf)
3568{
3569 tSirSmeAssocCnf assocCnf;
3570 tpDphHashNode pStaDs = NULL;
3571 tpPESession psessionEntry= NULL;
3572 tANI_U8 sessionId;
3573
3574
3575 if(pMsgBuf == NULL)
3576 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003577 limLog(pMac, LOGE, FL("pMsgBuf is NULL "));
Jeff Johnson295189b2012-06-20 16:38:30 -07003578 goto end;
3579 }
3580
3581 if ((limAssocCnfSerDes(pMac, &assocCnf, (tANI_U8 *) pMsgBuf) == eSIR_FAILURE) ||
3582 !__limIsSmeAssocCnfValid(&assocCnf))
3583 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003584 limLog(pMac, LOGE, FL("Received invalid SME_RE(ASSOC)_CNF message "));
Jeff Johnson295189b2012-06-20 16:38:30 -07003585 goto end;
3586 }
3587
3588 if((psessionEntry = peFindSessionByBssid(pMac, assocCnf.bssId, &sessionId))== NULL)
3589 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003590 limLog(pMac, LOGE, FL("session does not exist for given bssId"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003591 goto end;
3592 }
3593
3594 if ( ((psessionEntry->limSystemRole != eLIM_AP_ROLE) && (psessionEntry->limSystemRole != eLIM_BT_AMP_AP_ROLE)) ||
3595 ((psessionEntry->limSmeState != eLIM_SME_NORMAL_STATE) && (psessionEntry->limSmeState != eLIM_SME_NORMAL_CHANNEL_SCAN_STATE)))
3596 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003597 limLog(pMac, LOGE, FL("Received unexpected message %X in state %X, in role %X"),
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303598 msgType, psessionEntry->limSmeState, psessionEntry->limSystemRole);
Jeff Johnson295189b2012-06-20 16:38:30 -07003599 goto end;
3600 }
3601
3602 pStaDs = dphGetHashEntry(pMac, assocCnf.aid, &psessionEntry->dph.dphHashTable);
3603
3604 if (pStaDs == NULL)
3605 {
3606 limLog(pMac, LOG1,
3607 FL("Received invalid message %X due to no STA context, for aid %d, peer "),
3608 msgType, assocCnf.aid);
3609 limPrintMacAddr(pMac, assocCnf.peerMacAddr, LOG1);
3610
3611 /*
3612 ** send a DISASSOC_IND message to WSM to make sure
3613 ** the state in WSM and LIM is the same
3614 **/
3615 limSendSmeDisassocNtf( pMac, assocCnf.peerMacAddr, eSIR_SME_STA_NOT_ASSOCIATED,
3616 eLIM_PEER_ENTITY_DISASSOC, assocCnf.aid,psessionEntry->smeSessionId,psessionEntry->transactionId,psessionEntry);
3617 goto end;
3618 }
3619 if ((pStaDs &&
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303620 (( !vos_mem_compare( (tANI_U8 *) pStaDs->staAddr,
Jeff Johnson295189b2012-06-20 16:38:30 -07003621 (tANI_U8 *) assocCnf.peerMacAddr,
3622 sizeof(tSirMacAddr)) ) ||
3623 (pStaDs->mlmStaContext.mlmState != eLIM_MLM_WT_ASSOC_CNF_STATE) ||
3624 ((pStaDs->mlmStaContext.subType == LIM_ASSOC) &&
3625 (msgType != eWNI_SME_ASSOC_CNF)) ||
3626 ((pStaDs->mlmStaContext.subType == LIM_REASSOC) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07003627 (msgType != eWNI_SME_ASSOC_CNF))))) // since softap is passing this as ASSOC_CNF and subtype differs
Jeff Johnson295189b2012-06-20 16:38:30 -07003628 {
3629 limLog(pMac, LOG1,
3630 FL("Received invalid message %X due to peerMacAddr mismatched or not in eLIM_MLM_WT_ASSOC_CNF_STATE state, for aid %d, peer "),
3631 msgType, assocCnf.aid);
3632 limPrintMacAddr(pMac, assocCnf.peerMacAddr, LOG1);
3633 goto end;
3634 }
3635
3636 /*
3637 ** Deactivate/delet CNF_WAIT timer since ASSOC_CNF
3638 ** has been received
3639 **/
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003640 limLog(pMac, LOG1, FL("Received SME_ASSOC_CNF. Delete Timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003641 limDeactivateAndChangePerStaIdTimer(pMac, eLIM_CNF_WAIT_TIMER, pStaDs->assocId);
3642
3643 if (assocCnf.statusCode == eSIR_SME_SUCCESS)
3644 {
3645 /* In BTAMP-AP, PE already finished the WDA_ADD_STA sequence
3646 * when it had received Assoc Request frame. Now, PE just needs to send
3647 * Association Response frame to the requesting BTAMP-STA.
3648 */
3649 pStaDs->mlmStaContext.mlmState = eLIM_MLM_LINK_ESTABLISHED_STATE;
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003650 limLog(pMac, LOG1, FL("sending Assoc Rsp frame to STA (assoc id=%d) "), pStaDs->assocId);
Jeff Johnson295189b2012-06-20 16:38:30 -07003651 limSendAssocRspMgmtFrame( pMac, eSIR_SUCCESS, pStaDs->assocId, pStaDs->staAddr,
3652 pStaDs->mlmStaContext.subType, pStaDs, psessionEntry);
3653 goto end;
3654 } // (assocCnf.statusCode == eSIR_SME_SUCCESS)
3655 else
3656 {
3657 // SME_ASSOC_CNF status is non-success, so STA is not allowed to be associated
3658 /*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*/
3659 if(!pStaDs->mlmStaContext.updateContext)
3660 pStaDs->mlmStaContext.updateContext = 1;
3661 limRejectAssociation(pMac, pStaDs->staAddr,
3662 pStaDs->mlmStaContext.subType,
3663 true, pStaDs->mlmStaContext.authType,
3664 pStaDs->assocId, true,
3665 eSIR_MAC_UNSPEC_FAILURE_STATUS, psessionEntry);
3666 return;
3667 }
3668
3669end:
3670 if((psessionEntry != NULL) && (pStaDs != NULL))
3671 {
3672 if ( psessionEntry->parsedAssocReq[pStaDs->assocId] != NULL )
3673 {
3674 if ( ((tpSirAssocReq)(psessionEntry->parsedAssocReq[pStaDs->assocId]))->assocReqFrame)
3675 {
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303676 vos_mem_free(((tpSirAssocReq)
3677 (psessionEntry->parsedAssocReq[pStaDs->assocId]))->assocReqFrame);
Jeff Johnson295189b2012-06-20 16:38:30 -07003678 ((tpSirAssocReq)(psessionEntry->parsedAssocReq[pStaDs->assocId]))->assocReqFrame = NULL;
3679 }
3680
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303681 vos_mem_free(psessionEntry->parsedAssocReq[pStaDs->assocId]);
Jeff Johnson295189b2012-06-20 16:38:30 -07003682 psessionEntry->parsedAssocReq[pStaDs->assocId] = NULL;
3683 }
3684 }
3685
3686} /*** end __limProcessSmeAssocCnfNew() ***/
3687
3688
Jeff Johnson295189b2012-06-20 16:38:30 -07003689
3690
3691static void
3692__limProcessSmeAddtsReq(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
3693{
3694 tpDphHashNode pStaDs;
3695 tSirMacAddr peerMac;
3696 tpSirAddtsReq pSirAddts;
3697 tANI_U32 timeout;
3698 tpPESession psessionEntry;
3699 tANI_U8 sessionId; //PE sessionId
3700 tANI_U8 smesessionId;
3701 tANI_U16 smetransactionId;
3702
3703
3704 if(pMsgBuf == NULL)
3705 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003706 limLog(pMac, LOGE,FL("Buffer is Pointing to NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003707 return;
3708 }
3709
3710 limGetSessionInfo(pMac,(tANI_U8 *)pMsgBuf,&smesessionId,&smetransactionId);
3711
3712 pSirAddts = (tpSirAddtsReq) pMsgBuf;
3713
3714 if((psessionEntry = peFindSessionByBssid(pMac, pSirAddts->bssId,&sessionId))== NULL)
3715 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003716 limLog(pMac, LOGE, "Session Does not exist for given bssId");
Jeff Johnson295189b2012-06-20 16:38:30 -07003717 return;
3718 }
3719#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM //FEATURE_WLAN_DIAG_SUPPORT
3720 limDiagEventReport(pMac, WLAN_PE_DIAG_ADDTS_REQ_EVENT, psessionEntry, 0, 0);
3721#endif //FEATURE_WLAN_DIAG_SUPPORT
3722
3723
3724
3725 /* if sta
3726 * - verify assoc state
3727 * - send addts request to ap
3728 * - wait for addts response from ap
3729 * if ap, just ignore with error log
3730 */
3731 PELOG1(limLog(pMac, LOG1,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003732 FL("Received SME_ADDTS_REQ (TSid %d, UP %d)"),
Jeff Johnson295189b2012-06-20 16:38:30 -07003733 pSirAddts->req.tspec.tsinfo.traffic.tsid,
3734 pSirAddts->req.tspec.tsinfo.traffic.userPrio);)
3735
3736 if ((psessionEntry->limSystemRole != eLIM_STA_ROLE)&&(psessionEntry->limSystemRole != eLIM_BT_AMP_STA_ROLE))
3737 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003738 PELOGE(limLog(pMac, LOGE, "AddTs received on AP - ignoring");)
Jeff Johnson295189b2012-06-20 16:38:30 -07003739 limSendSmeAddtsRsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE, psessionEntry, pSirAddts->req.tspec,
3740 smesessionId,smetransactionId);
3741 return;
3742 }
3743
3744 //Ignore the request if STA is in 11B mode.
3745 if(psessionEntry->dot11mode == WNI_CFG_DOT11_MODE_11B)
3746 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003747 PELOGE(limLog(pMac, LOGE, "AddTS received while Dot11Mode is 11B - ignoring");)
Jeff Johnson295189b2012-06-20 16:38:30 -07003748 limSendSmeAddtsRsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE, psessionEntry, pSirAddts->req.tspec,
3749 smesessionId,smetransactionId);
3750 return;
3751 }
3752
3753
3754 pStaDs = dphGetHashEntry(pMac, DPH_STA_HASH_INDEX_PEER, &psessionEntry->dph.dphHashTable);
3755
3756 if(pStaDs == NULL)
3757 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003758 PELOGE(limLog(pMac, LOGE, "Cannot find AP context for addts req");)
Jeff Johnson295189b2012-06-20 16:38:30 -07003759 limSendSmeAddtsRsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE, psessionEntry, pSirAddts->req.tspec,
3760 smesessionId,smetransactionId);
3761 return;
3762 }
3763
3764 if ((! pStaDs->valid) ||
3765 (pStaDs->mlmStaContext.mlmState != eLIM_MLM_LINK_ESTABLISHED_STATE))
3766 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003767 PELOGE(limLog(pMac, LOGE, "AddTs received in invalid MLM state");)
Jeff Johnson295189b2012-06-20 16:38:30 -07003768 limSendSmeAddtsRsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE, psessionEntry, pSirAddts->req.tspec,
3769 smesessionId,smetransactionId);
3770 return;
3771 }
3772
3773 pSirAddts->req.wsmTspecPresent = 0;
3774 pSirAddts->req.wmeTspecPresent = 0;
3775 pSirAddts->req.lleTspecPresent = 0;
3776
3777 if ((pStaDs->wsmEnabled) &&
3778 (pSirAddts->req.tspec.tsinfo.traffic.accessPolicy != SIR_MAC_ACCESSPOLICY_EDCA))
3779 pSirAddts->req.wsmTspecPresent = 1;
3780 else if (pStaDs->wmeEnabled)
3781 pSirAddts->req.wmeTspecPresent = 1;
3782 else if (pStaDs->lleEnabled)
3783 pSirAddts->req.lleTspecPresent = 1;
3784 else
3785 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003786 PELOGW(limLog(pMac, LOGW, FL("ADDTS_REQ ignore - qos is disabled"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07003787 limSendSmeAddtsRsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE, psessionEntry, pSirAddts->req.tspec,
3788 smesessionId,smetransactionId);
3789 return;
3790 }
3791
3792 if ((psessionEntry->limSmeState != eLIM_SME_ASSOCIATED_STATE) &&
3793 (psessionEntry->limSmeState != eLIM_SME_LINK_EST_STATE))
3794 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003795 limLog(pMac, LOGE, "AddTs received in invalid LIMsme state (%d)",
Jeff Johnson295189b2012-06-20 16:38:30 -07003796 psessionEntry->limSmeState);
3797 limSendSmeAddtsRsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE, psessionEntry, pSirAddts->req.tspec,
3798 smesessionId,smetransactionId);
3799 return;
3800 }
3801
3802 if (pMac->lim.gLimAddtsSent)
3803 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003804 limLog(pMac, LOGE, "Addts (token %d, tsid %d, up %d) is still pending",
Jeff Johnson295189b2012-06-20 16:38:30 -07003805 pMac->lim.gLimAddtsReq.req.dialogToken,
3806 pMac->lim.gLimAddtsReq.req.tspec.tsinfo.traffic.tsid,
3807 pMac->lim.gLimAddtsReq.req.tspec.tsinfo.traffic.userPrio);
3808 limSendSmeAddtsRsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE, psessionEntry, pSirAddts->req.tspec,
3809 smesessionId,smetransactionId);
3810 return;
3811 }
3812
3813 #if 0
3814 val = sizeof(tSirMacAddr);
3815 if (wlan_cfgGetStr(pMac, WNI_CFG_BSSID, peerMac, &val) != eSIR_SUCCESS)
3816 {
3817 /// Could not get BSSID from CFG. Log error.
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003818 limLog(pMac, LOGP, FL("could not retrieve BSSID"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003819 return;
3820 }
3821 #endif
3822 sirCopyMacAddr(peerMac,psessionEntry->bssId);
3823
3824 // save the addts request
3825 pMac->lim.gLimAddtsSent = true;
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303826 vos_mem_copy( (tANI_U8 *) &pMac->lim.gLimAddtsReq, (tANI_U8 *) pSirAddts, sizeof(tSirAddtsReq));
Jeff Johnson295189b2012-06-20 16:38:30 -07003827
3828 // ship out the message now
3829 limSendAddtsReqActionFrame(pMac, peerMac, &pSirAddts->req,
3830 psessionEntry);
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003831 PELOG1(limLog(pMac, LOG1, "Sent ADDTS request");)
Jeff Johnson295189b2012-06-20 16:38:30 -07003832
3833 // start a timer to wait for the response
3834 if (pSirAddts->timeout)
3835 timeout = pSirAddts->timeout;
3836 else if (wlan_cfgGetInt(pMac, WNI_CFG_ADDTS_RSP_TIMEOUT, &timeout) != eSIR_SUCCESS)
3837 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003838 limLog(pMac, LOGP, FL("Unable to get Cfg param %d (Addts Rsp Timeout)"),
Jeff Johnson295189b2012-06-20 16:38:30 -07003839 WNI_CFG_ADDTS_RSP_TIMEOUT);
3840 return;
3841 }
3842
3843 timeout = SYS_MS_TO_TICKS(timeout);
3844 if (tx_timer_change(&pMac->lim.limTimers.gLimAddtsRspTimer, timeout, 0) != TX_SUCCESS)
3845 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003846 limLog(pMac, LOGP, FL("AddtsRsp timer change failed!"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003847 return;
3848 }
3849 pMac->lim.gLimAddtsRspTimerCount++;
3850 if (tx_timer_change_context(&pMac->lim.limTimers.gLimAddtsRspTimer,
3851 pMac->lim.gLimAddtsRspTimerCount) != TX_SUCCESS)
3852 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003853 limLog(pMac, LOGP, FL("AddtsRsp timer change failed!"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003854 return;
3855 }
Jeff Johnsone7245742012-09-05 17:12:55 -07003856 MTRACE(macTrace(pMac, TRACE_CODE_TIMER_ACTIVATE, psessionEntry->peSessionId, eLIM_ADDTS_RSP_TIMER));
Jeff Johnson295189b2012-06-20 16:38:30 -07003857
3858 //add the sessionId to the timer object
3859 pMac->lim.limTimers.gLimAddtsRspTimer.sessionId = sessionId;
3860 if (tx_timer_activate(&pMac->lim.limTimers.gLimAddtsRspTimer) != TX_SUCCESS)
3861 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003862 limLog(pMac, LOGP, FL("AddtsRsp timer activation failed!"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003863 return;
3864 }
3865 return;
3866}
3867
3868
3869static void
3870__limProcessSmeDeltsReq(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
3871{
3872 tSirMacAddr peerMacAddr;
3873 tANI_U8 ac;
3874 tSirMacTSInfo *pTsinfo;
3875 tpSirDeltsReq pDeltsReq = (tpSirDeltsReq) pMsgBuf;
3876 tpDphHashNode pStaDs = NULL;
3877 tpPESession psessionEntry;
3878 tANI_U8 sessionId;
3879 tANI_U32 status = eSIR_SUCCESS;
3880 tANI_U8 smesessionId;
3881 tANI_U16 smetransactionId;
3882
3883 limGetSessionInfo(pMac,(tANI_U8 *)pMsgBuf,&smesessionId,&smetransactionId);
3884
3885 if((psessionEntry = peFindSessionByBssid(pMac, pDeltsReq->bssId, &sessionId))== NULL)
3886 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003887 limLog(pMac, LOGE, "Session Does not exist for given bssId");
Jeff Johnson295189b2012-06-20 16:38:30 -07003888 status = eSIR_FAILURE;
3889 goto end;
3890 }
3891#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM //FEATURE_WLAN_DIAG_SUPPORT
3892 limDiagEventReport(pMac, WLAN_PE_DIAG_DELTS_REQ_EVENT, psessionEntry, 0, 0);
3893#endif //FEATURE_WLAN_DIAG_SUPPORT
3894
3895
3896 if (eSIR_SUCCESS != limValidateDeltsReq(pMac, pDeltsReq, peerMacAddr,psessionEntry))
3897 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003898 PELOGE(limLog(pMac, LOGE, FL("limValidateDeltsReq failed"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07003899 status = eSIR_FAILURE;
3900 limSendSmeDeltsRsp(pMac, pDeltsReq, eSIR_FAILURE,psessionEntry,smesessionId,smetransactionId);
3901 return;
3902 }
3903
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003904 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 -07003905 pDeltsReq->aid, peerMacAddr[0], peerMacAddr[1], peerMacAddr[2],
3906 peerMacAddr[3], peerMacAddr[4], peerMacAddr[5]);)
3907
3908 limSendDeltsReqActionFrame(pMac, peerMacAddr, pDeltsReq->req.wmeTspecPresent, &pDeltsReq->req.tsinfo, &pDeltsReq->req.tspec,
3909 psessionEntry);
3910
3911 pTsinfo = pDeltsReq->req.wmeTspecPresent ? &pDeltsReq->req.tspec.tsinfo : &pDeltsReq->req.tsinfo;
3912
3913 /* We've successfully send DELTS frame to AP. Update the
3914 * dynamic UAPSD mask. The AC for this TSPEC to be deleted
3915 * is no longer trigger enabled or delivery enabled
3916 */
3917 limSetTspecUapsdMask(pMac, pTsinfo, CLEAR_UAPSD_MASK);
3918
3919 /* We're deleting the TSPEC, so this particular AC is no longer
3920 * admitted. PE needs to downgrade the EDCA
3921 * parameters(for the AC for which TS is being deleted) to the
3922 * next best AC for which ACM is not enabled, and send the
3923 * updated values to HAL.
3924 */
3925 ac = upToAc(pTsinfo->traffic.userPrio);
3926
3927 if(pTsinfo->traffic.direction == SIR_MAC_DIRECTION_UPLINK)
3928 {
3929 pMac->lim.gAcAdmitMask[SIR_MAC_DIRECTION_UPLINK] &= ~(1 << ac);
3930 }
3931 else if(pTsinfo->traffic.direction == SIR_MAC_DIRECTION_DNLINK)
3932 {
3933 pMac->lim.gAcAdmitMask[SIR_MAC_DIRECTION_DNLINK] &= ~(1 << ac);
3934 }
3935 else if(pTsinfo->traffic.direction == SIR_MAC_DIRECTION_BIDIR)
3936 {
3937 pMac->lim.gAcAdmitMask[SIR_MAC_DIRECTION_UPLINK] &= ~(1 << ac);
3938 pMac->lim.gAcAdmitMask[SIR_MAC_DIRECTION_DNLINK] &= ~(1 << ac);
3939 }
3940
3941 limSetActiveEdcaParams(pMac, psessionEntry->gLimEdcaParams, psessionEntry);
3942
3943 pStaDs = dphGetHashEntry(pMac, DPH_STA_HASH_INDEX_PEER, &psessionEntry->dph.dphHashTable);
3944 if (pStaDs != NULL)
3945 {
3946 if (pStaDs->aniPeer == eANI_BOOLEAN_TRUE)
3947 limSendEdcaParams(pMac, psessionEntry->gLimEdcaParamsActive, pStaDs->bssId, eANI_BOOLEAN_TRUE);
3948 else
3949 limSendEdcaParams(pMac, psessionEntry->gLimEdcaParamsActive, pStaDs->bssId, eANI_BOOLEAN_FALSE);
3950 status = eSIR_SUCCESS;
3951 }
3952 else
3953 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003954 limLog(pMac, LOGE, FL("Self entry missing in Hash Table "));
Jeff Johnson295189b2012-06-20 16:38:30 -07003955 status = eSIR_FAILURE;
3956 }
3957#ifdef FEATURE_WLAN_CCX
3958 limDeactivateAndChangeTimer(pMac,eLIM_TSM_TIMER);
3959#endif
3960
3961 // send an sme response back
3962 end:
3963 limSendSmeDeltsRsp(pMac, pDeltsReq, eSIR_SUCCESS,psessionEntry,smesessionId,smetransactionId);
3964}
3965
3966
3967void
3968limProcessSmeAddtsRspTimeout(tpAniSirGlobal pMac, tANI_U32 param)
3969{
3970 //fetch the sessionEntry based on the sessionId
3971 tpPESession psessionEntry;
3972 if((psessionEntry = peFindSessionBySessionId(pMac, pMac->lim.limTimers.gLimAddtsRspTimer.sessionId))== NULL)
3973 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003974 limLog(pMac, LOGP,FL("Session Does not exist for given sessionID"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003975 return;
3976 }
3977
3978 if ( (psessionEntry->limSystemRole != eLIM_STA_ROLE) && (psessionEntry->limSystemRole != eLIM_BT_AMP_STA_ROLE) )
3979 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003980 limLog(pMac, LOGW, "AddtsRspTimeout in non-Sta role (%d)", psessionEntry->limSystemRole);
Jeff Johnson295189b2012-06-20 16:38:30 -07003981 pMac->lim.gLimAddtsSent = false;
3982 return;
3983 }
3984
3985 if (! pMac->lim.gLimAddtsSent)
3986 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003987 PELOGW(limLog(pMac, LOGW, "AddtsRspTimeout but no AddtsSent");)
Jeff Johnson295189b2012-06-20 16:38:30 -07003988 return;
3989 }
3990
3991 if (param != pMac->lim.gLimAddtsRspTimerCount)
3992 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003993 limLog(pMac, LOGE, FL("Invalid AddtsRsp Timer count %d (exp %d)"),
Jeff Johnson295189b2012-06-20 16:38:30 -07003994 param, pMac->lim.gLimAddtsRspTimerCount);
3995 return;
3996 }
3997
3998 // this a real response timeout
3999 pMac->lim.gLimAddtsSent = false;
4000 pMac->lim.gLimAddtsRspTimerCount++;
4001
4002 limSendSmeAddtsRsp(pMac, true, eSIR_SME_ADDTS_RSP_TIMEOUT, psessionEntry, pMac->lim.gLimAddtsReq.req.tspec,
4003 psessionEntry->smeSessionId, psessionEntry->transactionId);
4004}
4005
4006
4007/**
4008 * __limProcessSmeStatsRequest()
4009 *
4010 *FUNCTION:
4011 *
4012 *
4013 *NOTE:
4014 *
4015 * @param pMac Pointer to Global MAC structure
4016 * @param *pMsgBuf A pointer to the SME message buffer
4017 * @return None
4018 */
4019static void
4020__limProcessSmeStatsRequest(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
4021{
4022 tpAniGetStatsReq pStatsReq;
4023 tSirMsgQ msgQ;
4024 tpPESession psessionEntry;
4025 tANI_U8 sessionId;
4026
4027
4028 if(pMsgBuf == NULL)
4029 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004030 limLog(pMac, LOGE,FL("Buffer is Pointing to NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004031 return;
4032 }
4033
4034 pStatsReq = (tpAniGetStatsReq) pMsgBuf;
4035
4036 if((psessionEntry = peFindSessionByBssid(pMac,pStatsReq->bssId,&sessionId))== NULL)
4037 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004038 limLog(pMac, LOGE, FL("session does not exist for given bssId"));
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304039 vos_mem_free( pMsgBuf );
Jeff Johnson295189b2012-06-20 16:38:30 -07004040 return;
4041 }
4042
4043
4044
4045 switch(pStatsReq->msgType)
4046 {
4047 //Add Lim stats here. and send reqsponse.
4048
4049 //HAL maintained Stats.
4050 case eWNI_SME_STA_STAT_REQ:
4051 msgQ.type = WDA_STA_STAT_REQ;
4052 break;
4053 case eWNI_SME_AGGR_STAT_REQ:
4054 msgQ.type = WDA_AGGR_STAT_REQ;
4055 break;
4056 case eWNI_SME_GLOBAL_STAT_REQ:
4057 msgQ.type = WDA_GLOBAL_STAT_REQ;
4058 break;
4059 case eWNI_SME_STAT_SUMM_REQ:
4060 msgQ.type = WDA_STAT_SUMM_REQ;
4061 break;
4062 default: //Unknown request.
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004063 PELOGE(limLog(pMac, LOGE, "Unknown Statistics request");)
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304064 vos_mem_free( pMsgBuf );
Jeff Johnson295189b2012-06-20 16:38:30 -07004065 return;
4066 }
4067
Jeff Johnson295189b2012-06-20 16:38:30 -07004068 msgQ.reserved = 0;
4069 msgQ.bodyptr = pMsgBuf;
4070 msgQ.bodyval = 0;
Leela Venkata Kiran Kumar Reddy Chirala68a6abe2013-02-28 07:43:16 -08004071 if(NULL == psessionEntry)
4072 {
4073 MTRACE(macTraceMsgTx(pMac, NO_SESSION, msgQ.type));
4074 }
4075 else
4076 {
4077 MTRACE(macTraceMsgTx(pMac, psessionEntry->peSessionId, msgQ.type));
4078 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004079 if( eSIR_SUCCESS != (wdaPostCtrlMsg( pMac, &msgQ ))){
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004080 limLog(pMac, LOGP, "Unable to forward request");
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304081 vos_mem_free( pMsgBuf );
Jeff Johnson295189b2012-06-20 16:38:30 -07004082 return;
4083 }
4084
4085 return;
4086}
4087
4088
4089/**
4090 * __limProcessSmeGetStatisticsRequest()
4091 *
4092 *FUNCTION:
4093 *
4094 *
4095 *NOTE:
4096 *
4097 * @param pMac Pointer to Global MAC structure
4098 * @param *pMsgBuf A pointer to the SME message buffer
4099 * @return None
4100 */
4101static void
4102__limProcessSmeGetStatisticsRequest(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
4103{
4104 tpAniGetPEStatsReq pPEStatsReq;
4105 tSirMsgQ msgQ;
4106
4107 pPEStatsReq = (tpAniGetPEStatsReq) pMsgBuf;
4108
4109 //pPEStatsReq->msgType should be eWNI_SME_GET_STATISTICS_REQ
4110
4111 msgQ.type = WDA_GET_STATISTICS_REQ;
4112
Jeff Johnson295189b2012-06-20 16:38:30 -07004113 msgQ.reserved = 0;
4114 msgQ.bodyptr = pMsgBuf;
4115 msgQ.bodyval = 0;
Jeff Johnsone7245742012-09-05 17:12:55 -07004116 MTRACE(macTraceMsgTx(pMac, NO_SESSION, msgQ.type));
Jeff Johnson295189b2012-06-20 16:38:30 -07004117
4118 if( eSIR_SUCCESS != (wdaPostCtrlMsg( pMac, &msgQ ))){
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304119 vos_mem_free( pMsgBuf );
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004120 limLog(pMac, LOGP, "Unable to forward request");
Jeff Johnson295189b2012-06-20 16:38:30 -07004121 return;
4122 }
4123
4124 return;
4125}
4126
4127
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08004128#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_CCX || defined(FEATURE_WLAN_LFR)
4129/**
4130 * __limProcessSmeGetRoamRssiRequest()
4131 *
4132 *FUNCTION:
4133 *
4134 *
4135 *NOTE:
4136 *
4137 * @param pMac Pointer to Global MAC structure
4138 * @param *pMsgBuf A pointer to the SME message buffer
4139 * @return None
4140 */
4141static void
4142__limProcessSmeGetRoamRssiRequest(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
4143{
4144 tpAniGetRssiReq pPEGetRoamRssiReq = NULL;
4145 tSirMsgQ msgQ;
4146
4147 pPEGetRoamRssiReq = (tpAniGetRssiReq) pMsgBuf;
4148 msgQ.type = WDA_GET_ROAM_RSSI_REQ;
4149
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08004150 msgQ.reserved = 0;
4151 msgQ.bodyptr = pMsgBuf;
4152 msgQ.bodyval = 0;
4153 MTRACE(macTraceMsgTx(pMac, NO_SESSION, msgQ.type));
4154
4155 if( eSIR_SUCCESS != (wdaPostCtrlMsg( pMac, &msgQ ))){
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304156 vos_mem_free( pMsgBuf );
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004157 limLog(pMac, LOGP, "Unable to forward request");
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08004158 return;
4159 }
4160
4161 return;
4162}
4163#endif
4164
4165
Jeff Johnson295189b2012-06-20 16:38:30 -07004166static void
4167__limProcessSmeUpdateAPWPSIEs(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
4168{
4169 tpSirUpdateAPWPSIEsReq pUpdateAPWPSIEsReq;
4170 tpPESession psessionEntry;
4171 tANI_U8 sessionId; //PE sessionID
4172
4173 PELOG1(limLog(pMac, LOG1,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004174 FL("received UPDATE_APWPSIEs_REQ message")););
Jeff Johnson295189b2012-06-20 16:38:30 -07004175
4176 if(pMsgBuf == NULL)
4177 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004178 limLog(pMac, LOGE,FL("Buffer is Pointing to NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004179 return;
4180 }
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08004181
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304182 pUpdateAPWPSIEsReq = vos_mem_malloc(sizeof(tSirUpdateAPWPSIEsReq));
4183 if ( NULL == pUpdateAPWPSIEsReq )
Jeff Johnson295189b2012-06-20 16:38:30 -07004184 {
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304185 limLog(pMac, LOGP, FL("call to AllocateMemory failed for pUpdateAPWPSIEsReq"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004186 return;
4187 }
4188
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08004189 if ((limUpdateAPWPSIEsReqSerDes(pMac, pUpdateAPWPSIEsReq, (tANI_U8 *) pMsgBuf) == eSIR_FAILURE))
Jeff Johnson295189b2012-06-20 16:38:30 -07004190 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004191 limLog(pMac, LOGW, FL("received invalid SME_SETCONTEXT_REQ message"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004192 goto end;
4193 }
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08004194
Jeff Johnson295189b2012-06-20 16:38:30 -07004195 if((psessionEntry = peFindSessionByBssid(pMac, pUpdateAPWPSIEsReq->bssId, &sessionId)) == NULL)
4196 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004197 limLog(pMac, LOGW, FL("Session does not exist for given BSSID"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004198 goto end;
4199 }
4200
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304201 vos_mem_copy( &psessionEntry->APWPSIEs, &pUpdateAPWPSIEsReq->APWPSIEs, sizeof(tSirAPWPSIEs));
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08004202
Jeff Johnson295189b2012-06-20 16:38:30 -07004203 schSetFixedBeaconFields(pMac, psessionEntry);
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08004204 limSendBeaconInd(pMac, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07004205
4206end:
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304207 vos_mem_free( pUpdateAPWPSIEsReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07004208 return;
4209} /*** end __limProcessSmeUpdateAPWPSIEs(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf) ***/
4210
4211static void
4212__limProcessSmeHideSSID(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
4213{
4214 tpSirUpdateParams pUpdateParams;
4215 tpPESession psessionEntry;
4216
4217 PELOG1(limLog(pMac, LOG1,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004218 FL("received HIDE_SSID message")););
Jeff Johnson295189b2012-06-20 16:38:30 -07004219
4220 if(pMsgBuf == NULL)
4221 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004222 limLog(pMac, LOGE,FL("Buffer is Pointing to NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004223 return;
4224 }
4225
4226 pUpdateParams = (tpSirUpdateParams)pMsgBuf;
4227
4228 if((psessionEntry = peFindSessionBySessionId(pMac, pUpdateParams->sessionId)) == NULL)
4229 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004230 limLog(pMac, LOGW, "Session does not exist for given sessionId %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07004231 pUpdateParams->sessionId);
4232 return;
4233 }
4234
4235 /* Update the session entry */
4236 psessionEntry->ssidHidden = pUpdateParams->ssidHidden;
4237
4238 /* Update beacon */
4239 schSetFixedBeaconFields(pMac, psessionEntry);
4240 limSendBeaconInd(pMac, psessionEntry);
4241
4242 return;
4243} /*** end __limProcessSmeHideSSID(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf) ***/
4244
4245static void
4246__limProcessSmeSetWPARSNIEs(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
4247{
4248 tpSirUpdateAPWPARSNIEsReq pUpdateAPWPARSNIEsReq;
4249 tpPESession psessionEntry;
4250 tANI_U8 sessionId; //PE sessionID
4251
4252 if(pMsgBuf == NULL)
4253 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004254 limLog(pMac, LOGE,FL("Buffer is Pointing to NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004255 return;
4256 }
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304257
4258 pUpdateAPWPARSNIEsReq = vos_mem_malloc(sizeof(tSirUpdateAPWPSIEsReq));
4259 if ( NULL == pUpdateAPWPARSNIEsReq )
Jeff Johnson295189b2012-06-20 16:38:30 -07004260 {
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304261 limLog(pMac, LOGP, FL("call to AllocateMemory failed for pUpdateAPWPARSNIEsReq"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004262 return;
4263 }
4264
4265 if ((limUpdateAPWPARSNIEsReqSerDes(pMac, pUpdateAPWPARSNIEsReq, (tANI_U8 *) pMsgBuf) == eSIR_FAILURE))
4266 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004267 limLog(pMac, LOGW, FL("received invalid SME_SETCONTEXT_REQ message"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004268 goto end;
4269 }
4270
4271 if((psessionEntry = peFindSessionByBssid(pMac, pUpdateAPWPARSNIEsReq->bssId, &sessionId)) == NULL)
4272 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004273 limLog(pMac, LOGW, FL("Session does not exist for given BSSID"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004274 goto end;
4275 }
4276
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304277 vos_mem_copy(&psessionEntry->pLimStartBssReq->rsnIE,
4278 &pUpdateAPWPARSNIEsReq->APWPARSNIEs, sizeof(tSirRSNie));
Jeff Johnson295189b2012-06-20 16:38:30 -07004279
4280 limSetRSNieWPAiefromSmeStartBSSReqMessage(pMac, &psessionEntry->pLimStartBssReq->rsnIE, psessionEntry);
4281
4282 psessionEntry->pLimStartBssReq->privacy = 1;
4283 psessionEntry->privacy = 1;
4284
4285 schSetFixedBeaconFields(pMac, psessionEntry);
4286 limSendBeaconInd(pMac, psessionEntry);
4287
4288end:
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304289 vos_mem_free(pUpdateAPWPARSNIEsReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07004290 return;
4291} /*** end __limProcessSmeSetWPARSNIEs(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf) ***/
4292
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08004293/*
4294Update the beacon Interval dynamically if beaconInterval is different in MCC
4295*/
4296static void
4297__limProcessSmeChangeBI(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
4298{
4299 tpSirChangeBIParams pChangeBIParams;
4300 tpPESession psessionEntry;
4301 tANI_U8 sessionId = 0;
4302 tUpdateBeaconParams beaconParams;
4303
4304 PELOG1(limLog(pMac, LOG1,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004305 FL("received Update Beacon Interval message")););
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08004306
4307 if(pMsgBuf == NULL)
4308 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004309 limLog(pMac, LOGE,FL("Buffer is Pointing to NULL"));
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08004310 return;
4311 }
4312
4313 pChangeBIParams = (tpSirChangeBIParams)pMsgBuf;
4314
4315 if((psessionEntry = peFindSessionByBssid(pMac, pChangeBIParams->bssId, &sessionId)) == NULL)
4316 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004317 limLog(pMac, LOGE, FL("Session does not exist for given BSSID"));
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08004318 return;
4319 }
4320
4321 /*Update sessionEntry Beacon Interval*/
4322 if(psessionEntry->beaconParams.beaconInterval !=
4323 pChangeBIParams->beaconInterval )
4324 {
4325 psessionEntry->beaconParams.beaconInterval = pChangeBIParams->beaconInterval;
4326 }
4327
4328 /*Update sch beaconInterval*/
4329 if(pMac->sch.schObject.gSchBeaconInterval !=
4330 pChangeBIParams->beaconInterval )
4331 {
4332 pMac->sch.schObject.gSchBeaconInterval = pChangeBIParams->beaconInterval;
4333
4334 PELOG1(limLog(pMac, LOG1,
4335 FL("LIM send update BeaconInterval Indication : %d"),pChangeBIParams->beaconInterval););
4336
4337 /* Update beacon */
4338 schSetFixedBeaconFields(pMac, psessionEntry);
4339
Sunil Ravib96f7b52013-05-22 21:40:05 -07004340 beaconParams.bssIdx = psessionEntry->bssIdx;
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08004341 //Set change in beacon Interval
4342 beaconParams.beaconInterval = pChangeBIParams->beaconInterval;
Jeff Johnson312557b2013-04-03 16:27:48 -07004343 beaconParams.paramChangeBitmap = PARAM_BCN_INTERVAL_CHANGED;
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08004344 limSendBeaconParams(pMac, &beaconParams, psessionEntry);
4345 }
4346
4347 return;
4348} /*** end __limProcessSmeChangeBI(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf) ***/
4349
Jeff Johnson295189b2012-06-20 16:38:30 -07004350
4351
4352/** -------------------------------------------------------------
4353\fn limProcessSmeDelBaPeerInd
4354\brief handles indication message from HDD to send delete BA request
4355\param tpAniSirGlobal pMac
4356\param tANI_U32 pMsgBuf
4357\return None
4358-------------------------------------------------------------*/
4359void
4360limProcessSmeDelBaPeerInd(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
4361{
4362 tANI_U16 assocId =0;
4363 tpSmeDelBAPeerInd pSmeDelBAPeerInd = (tpSmeDelBAPeerInd)pMsgBuf;
4364 tpDphHashNode pSta;
4365 tpPESession psessionEntry;
4366 tANI_U8 sessionId;
4367
4368
4369
4370 if(NULL == pSmeDelBAPeerInd)
4371 return;
4372
4373 if ((psessionEntry = peFindSessionByBssid(pMac,pSmeDelBAPeerInd->bssId,&sessionId))==NULL)
4374 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004375 limLog(pMac, LOGE,FL("session does not exist for given bssId"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004376 return;
4377 }
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004378 limLog(pMac, LOGW, FL("called with staId = %d, tid = %d, baDirection = %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07004379 pSmeDelBAPeerInd->staIdx, pSmeDelBAPeerInd->baTID, pSmeDelBAPeerInd->baDirection);
4380
4381 pSta = dphLookupAssocId(pMac, pSmeDelBAPeerInd->staIdx, &assocId, &psessionEntry->dph.dphHashTable);
4382 if( eSIR_SUCCESS != limPostMlmDelBAReq( pMac,
4383 pSta,
4384 pSmeDelBAPeerInd->baDirection,
4385 pSmeDelBAPeerInd->baTID,
4386 eSIR_MAC_UNSPEC_FAILURE_REASON,psessionEntry))
4387 {
4388 limLog( pMac, LOGW,
4389 FL( "Failed to post LIM_MLM_DELBA_REQ to " ));
4390 if (pSta)
4391 limPrintMacAddr(pMac, pSta->staAddr, LOGW);
4392 }
4393}
4394
4395// --------------------------------------------------------------------
4396/**
4397 * __limProcessReportMessage
4398 *
4399 * FUNCTION: Processes the next received Radio Resource Management message
4400 *
4401 * LOGIC:
4402 *
4403 * ASSUMPTIONS:
4404 *
4405 * NOTE:
4406 *
4407 * @param None
4408 * @return None
4409 */
4410
4411void __limProcessReportMessage(tpAniSirGlobal pMac, tpSirMsgQ pMsg)
4412{
4413#ifdef WLAN_FEATURE_VOWIFI
4414 switch (pMsg->type)
4415 {
4416 case eWNI_SME_NEIGHBOR_REPORT_REQ_IND:
4417 rrmProcessNeighborReportReq( pMac, pMsg->bodyptr );
4418 break;
4419 case eWNI_SME_BEACON_REPORT_RESP_XMIT_IND:
4420 {
4421#if defined FEATURE_WLAN_CCX
4422 tpSirBeaconReportXmitInd pBcnReport=NULL;
4423 tpPESession psessionEntry=NULL;
4424 tANI_U8 sessionId;
4425
4426 if(pMsg->bodyptr == NULL)
4427 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004428 limLog(pMac, LOGE,FL("Buffer is Pointing to NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004429 return;
4430 }
4431 pBcnReport = (tpSirBeaconReportXmitInd )pMsg->bodyptr;
4432 if((psessionEntry = peFindSessionByBssid(pMac, pBcnReport->bssId,&sessionId))== NULL)
4433 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004434 limLog(pMac, LOGE, "Session Does not exist for given bssId");
Jeff Johnson295189b2012-06-20 16:38:30 -07004435 return;
4436 }
4437 if (psessionEntry->isCCXconnection)
4438 ccxProcessBeaconReportXmit( pMac, pMsg->bodyptr);
4439 else
4440#endif
4441 rrmProcessBeaconReportXmit( pMac, pMsg->bodyptr );
4442 }
4443 break;
4444 }
4445#endif
4446}
4447
4448#if defined(FEATURE_WLAN_CCX) || defined(WLAN_FEATURE_VOWIFI)
4449// --------------------------------------------------------------------
4450/**
4451 * limSendSetMaxTxPowerReq
4452 *
4453 * FUNCTION: Send SIR_HAL_SET_MAX_TX_POWER_REQ message to change the max tx power.
4454 *
4455 * LOGIC:
4456 *
4457 * ASSUMPTIONS:
4458 *
4459 * NOTE:
4460 *
4461 * @param txPower txPower to be set.
4462 * @param pSessionEntry session entry.
4463 * @return None
4464 */
4465tSirRetStatus
4466limSendSetMaxTxPowerReq ( tpAniSirGlobal pMac, tPowerdBm txPower, tpPESession pSessionEntry )
4467{
4468 tpMaxTxPowerParams pMaxTxParams = NULL;
4469 tSirRetStatus retCode = eSIR_SUCCESS;
4470 tSirMsgQ msgQ;
4471
4472 if( pSessionEntry == NULL )
4473 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004474 PELOGE(limLog(pMac, LOGE, "%s:%d: Inavalid parameters", __func__, __LINE__ );)
Jeff Johnson295189b2012-06-20 16:38:30 -07004475 return eSIR_FAILURE;
4476 }
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304477
4478 pMaxTxParams = vos_mem_malloc(sizeof(tMaxTxPowerParams));
4479 if ( NULL == pMaxTxParams )
Jeff Johnson295189b2012-06-20 16:38:30 -07004480 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004481 limLog( pMac, LOGP, "%s:%d:Unable to allocate memory for pMaxTxParams ", __func__, __LINE__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004482 return eSIR_MEM_ALLOC_FAILED;
4483
4484 }
4485#if defined(WLAN_VOWIFI_DEBUG) || defined(FEATURE_WLAN_CCX)
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004486 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 -07004487#endif
Kiran Kumar Lokerea4db3dc2013-03-25 18:05:24 -07004488 if( pMaxTxParams == NULL )
4489 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004490 limLog( pMac, LOGE, "%s:%d: pMaxTxParams is NULL", __func__, __LINE__);
Kiran Kumar Lokerea4db3dc2013-03-25 18:05:24 -07004491 return eSIR_FAILURE;
4492 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004493 pMaxTxParams->power = txPower;
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304494 vos_mem_copy( pMaxTxParams->bssId, pSessionEntry->bssId, sizeof(tSirMacAddr) );
4495 vos_mem_copy( pMaxTxParams->selfStaMacAddr, pSessionEntry->selfMacAddr, sizeof(tSirMacAddr) );
Jeff Johnson295189b2012-06-20 16:38:30 -07004496
Jeff Johnson68ce9c42013-04-08 10:33:28 -07004497 msgQ.type = WDA_SET_MAX_TX_POWER_REQ;
4498 msgQ.bodyptr = pMaxTxParams;
4499 msgQ.bodyval = 0;
4500 PELOG1(limLog(pMac, LOG1, FL("Posting WDA_SET_MAX_TX_POWER_REQ to WDA"));)
4501 MTRACE(macTraceMsgTx(pMac, pSessionEntry->peSessionId, msgQ.type));
4502 retCode = wdaPostCtrlMsg(pMac, &msgQ);
4503 if (eSIR_SUCCESS != retCode)
4504 {
4505 PELOGE(limLog(pMac, LOGE, FL("wdaPostCtrlMsg() failed"));)
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304506 vos_mem_free(pMaxTxParams);
Jeff Johnson68ce9c42013-04-08 10:33:28 -07004507 }
4508 return retCode;
Jeff Johnson295189b2012-06-20 16:38:30 -07004509}
4510#endif
4511
4512/**
4513 * __limProcessSmeAddStaSelfReq()
4514 *
4515 *FUNCTION:
4516 * This function is called to process SME_ADD_STA_SELF_REQ message
4517 * from SME. It sends a SIR_HAL_ADD_STA_SELF_REQ message to HAL.
4518 *
4519 *LOGIC:
4520 *
4521 *ASSUMPTIONS:
4522 *
4523 *NOTE:
4524 *
4525 * @param pMac Pointer to Global MAC structure
4526 * @param *pMsgBuf A pointer to the SME message buffer
4527 * @return None
4528 */
4529
4530static void
4531__limProcessSmeAddStaSelfReq(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
4532{
4533 tSirMsgQ msg;
4534 tpAddStaSelfParams pAddStaSelfParams;
4535 tpSirSmeAddStaSelfReq pSmeReq = (tpSirSmeAddStaSelfReq) pMsgBuf;
4536
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304537 pAddStaSelfParams = vos_mem_malloc(sizeof(tAddStaSelfParams));
4538 if ( NULL == pAddStaSelfParams )
Jeff Johnson295189b2012-06-20 16:38:30 -07004539 {
4540 limLog( pMac, LOGP, FL("Unable to allocate memory for tAddSelfStaParams") );
4541 return;
4542 }
4543
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304544 vos_mem_copy( pAddStaSelfParams->selfMacAddr, pSmeReq->selfMacAddr, sizeof(tSirMacAddr) );
4545
Jeff Johnson295189b2012-06-20 16:38:30 -07004546 msg.type = SIR_HAL_ADD_STA_SELF_REQ;
4547 msg.reserved = 0;
4548 msg.bodyptr = pAddStaSelfParams;
4549 msg.bodyval = 0;
4550
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004551 PELOGW(limLog(pMac, LOG1, FL("sending SIR_HAL_ADD_STA_SELF_REQ msg to HAL"));)
Jeff Johnsone7245742012-09-05 17:12:55 -07004552 MTRACE(macTraceMsgTx(pMac, NO_SESSION, msg.type));
Jeff Johnson295189b2012-06-20 16:38:30 -07004553
4554 if(eSIR_SUCCESS != wdaPostCtrlMsg(pMac, &msg))
4555 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004556 limLog(pMac, LOGP, FL("wdaPostCtrlMsg failed"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004557 }
4558 return;
4559} /*** end __limProcessAddStaSelfReq() ***/
4560
4561
4562/**
4563 * __limProcessSmeDelStaSelfReq()
4564 *
4565 *FUNCTION:
4566 * This function is called to process SME_DEL_STA_SELF_REQ message
4567 * from SME. It sends a SIR_HAL_DEL_STA_SELF_REQ message to HAL.
4568 *
4569 *LOGIC:
4570 *
4571 *ASSUMPTIONS:
4572 *
4573 *NOTE:
4574 *
4575 * @param pMac Pointer to Global MAC structure
4576 * @param *pMsgBuf A pointer to the SME message buffer
4577 * @return None
4578 */
4579
4580static void
4581__limProcessSmeDelStaSelfReq(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
4582{
4583 tSirMsgQ msg;
4584 tpDelStaSelfParams pDelStaSelfParams;
4585 tpSirSmeDelStaSelfReq pSmeReq = (tpSirSmeDelStaSelfReq) pMsgBuf;
4586
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304587 pDelStaSelfParams = vos_mem_malloc(sizeof( tDelStaSelfParams));
4588 if ( NULL == pDelStaSelfParams )
Jeff Johnson295189b2012-06-20 16:38:30 -07004589 {
4590 limLog( pMac, LOGP, FL("Unable to allocate memory for tDelStaSelfParams") );
4591 return;
4592 }
4593
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304594 vos_mem_copy( pDelStaSelfParams->selfMacAddr, pSmeReq->selfMacAddr, sizeof(tSirMacAddr) );
Jeff Johnson295189b2012-06-20 16:38:30 -07004595
4596 msg.type = SIR_HAL_DEL_STA_SELF_REQ;
4597 msg.reserved = 0;
4598 msg.bodyptr = pDelStaSelfParams;
4599 msg.bodyval = 0;
4600
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004601 PELOGW(limLog(pMac, LOG1, FL("sending SIR_HAL_ADD_STA_SELF_REQ msg to HAL"));)
Jeff Johnsone7245742012-09-05 17:12:55 -07004602 MTRACE(macTraceMsgTx(pMac, NO_SESSION, msg.type));
Jeff Johnson295189b2012-06-20 16:38:30 -07004603
4604 if(eSIR_SUCCESS != wdaPostCtrlMsg(pMac, &msg))
4605 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004606 limLog(pMac, LOGP, FL("wdaPostCtrlMsg failed"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004607 }
4608 return;
4609} /*** end __limProcessSmeDelStaSelfReq() ***/
4610
4611
Jeff Johnson295189b2012-06-20 16:38:30 -07004612/**
4613 * __limProcessSmeRegisterMgmtFrameReq()
4614 *
4615 *FUNCTION:
4616 * This function is called to process eWNI_SME_REGISTER_MGMT_FRAME_REQ message
4617 * from SME. It Register this information within PE.
4618 *
4619 *LOGIC:
4620 *
4621 *ASSUMPTIONS:
4622 *
4623 *NOTE:
4624 *
4625 * @param pMac Pointer to Global MAC structure
4626 * @param *pMsgBuf A pointer to the SME message buffer
4627 * @return None
4628 */
4629static void
4630__limProcessSmeRegisterMgmtFrameReq(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
4631{
4632 VOS_STATUS vosStatus;
4633 tpSirRegisterMgmtFrame pSmeReq = (tpSirRegisterMgmtFrame)pMsgBuf;
4634 tpLimMgmtFrameRegistration pLimMgmtRegistration = NULL, pNext = NULL;
Jeff Johnsond13512a2012-07-17 11:42:19 -07004635 tANI_BOOLEAN match = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07004636 PELOG1(limLog(pMac, LOG1,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004637 FL("registerFrame %d, frameType %d, matchLen %d"),
Jeff Johnsone7245742012-09-05 17:12:55 -07004638 pSmeReq->registerFrame, pSmeReq->frameType, pSmeReq->matchLen);)
Jeff Johnson295189b2012-06-20 16:38:30 -07004639
Jeff Johnsond13512a2012-07-17 11:42:19 -07004640 /* First check whether entry exists already*/
4641
4642 vos_list_peek_front(&pMac->lim.gLimMgmtFrameRegistratinQueue,
4643 (vos_list_node_t**)&pLimMgmtRegistration);
4644
4645 while(pLimMgmtRegistration != NULL)
4646 {
4647 if (pLimMgmtRegistration->frameType == pSmeReq->frameType)
4648 {
4649 if(pSmeReq->matchLen)
4650 {
4651 if (pLimMgmtRegistration->matchLen == pSmeReq->matchLen)
4652 {
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304653 if (vos_mem_compare( pLimMgmtRegistration->matchData,
Jeff Johnsond13512a2012-07-17 11:42:19 -07004654 pSmeReq->matchData, pLimMgmtRegistration->matchLen))
4655 {
Madan Mohan Koyyalamudic537df22012-10-22 15:07:08 -07004656 /* found match! */
4657 match = VOS_TRUE;
4658 break;
Jeff Johnsond13512a2012-07-17 11:42:19 -07004659 }
4660 }
4661 }
4662 else
4663 {
Madan Mohan Koyyalamudic537df22012-10-22 15:07:08 -07004664 /* found match! */
Jeff Johnsond13512a2012-07-17 11:42:19 -07004665 match = VOS_TRUE;
4666 break;
4667 }
4668 }
4669 vosStatus = vos_list_peek_next (
4670 &pMac->lim.gLimMgmtFrameRegistratinQueue,
4671 (vos_list_node_t*) pLimMgmtRegistration,
4672 (vos_list_node_t**) &pNext );
4673
4674 pLimMgmtRegistration = pNext;
4675 pNext = NULL;
4676
4677 }
4678
4679 if (match)
4680 {
4681 vos_list_remove_node(&pMac->lim.gLimMgmtFrameRegistratinQueue,
4682 (vos_list_node_t*)pLimMgmtRegistration);
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304683 vos_mem_free(pLimMgmtRegistration);
Jeff Johnsond13512a2012-07-17 11:42:19 -07004684 }
4685
Jeff Johnson295189b2012-06-20 16:38:30 -07004686 if(pSmeReq->registerFrame)
4687 {
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304688 pLimMgmtRegistration = vos_mem_malloc(sizeof(tLimMgmtFrameRegistration) + pSmeReq->matchLen);
4689 if ( pLimMgmtRegistration != NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -07004690 {
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304691 vos_mem_set((void*)pLimMgmtRegistration,
4692 sizeof(tLimMgmtFrameRegistration) + pSmeReq->matchLen, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004693 pLimMgmtRegistration->frameType = pSmeReq->frameType;
4694 pLimMgmtRegistration->matchLen = pSmeReq->matchLen;
4695 pLimMgmtRegistration->sessionId = pSmeReq->sessionId;
4696 if(pSmeReq->matchLen)
4697 {
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304698 vos_mem_copy(pLimMgmtRegistration->matchData,
4699 pSmeReq->matchData, pSmeReq->matchLen);
Jeff Johnson295189b2012-06-20 16:38:30 -07004700 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004701 vos_list_insert_front(&pMac->lim.gLimMgmtFrameRegistratinQueue,
4702 &pLimMgmtRegistration->node);
4703 }
4704 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004705
4706 return;
4707} /*** end __limProcessSmeRegisterMgmtFrameReq() ***/
Viral Modid86bde22012-12-10 13:09:21 -08004708
4709static tANI_BOOLEAN
Viral Modid440e682013-03-06 02:25:31 -08004710__limInsertSingleShotNOAForScan(tpAniSirGlobal pMac, tANI_U32 noaDuration)
Viral Modid86bde22012-12-10 13:09:21 -08004711{
4712 tpP2pPsParams pMsgNoA;
4713 tSirMsgQ msg;
Vinay Malekal62757362012-12-17 12:15:51 -08004714
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304715 pMsgNoA = vos_mem_malloc(sizeof( tP2pPsConfig ));
4716 if ( NULL == pMsgNoA )
Viral Modid86bde22012-12-10 13:09:21 -08004717 {
4718 limLog( pMac, LOGP,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004719 FL( "Unable to allocate memory during NoA Update" ));
Viral Modid440e682013-03-06 02:25:31 -08004720 goto error;
Viral Modid86bde22012-12-10 13:09:21 -08004721 }
4722
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304723 vos_mem_set((tANI_U8 *)pMsgNoA, sizeof(tP2pPsConfig), 0);
Viral Modid86bde22012-12-10 13:09:21 -08004724 /* Below params used for opp PS/periodic NOA and are don't care in this case - so initialized to 0 */
4725 pMsgNoA->opp_ps = 0;
4726 pMsgNoA->ctWindow = 0;
4727 pMsgNoA->duration = 0;
4728 pMsgNoA->interval = 0;
4729 pMsgNoA->count = 0;
Vinay Malekal62757362012-12-17 12:15:51 -08004730
Vinay Malekal62757362012-12-17 12:15:51 -08004731 /* Below params used for Single Shot NOA - so assign proper values */
4732 pMsgNoA->psSelection = P2P_SINGLE_NOA;
Viral Modid440e682013-03-06 02:25:31 -08004733 pMsgNoA->single_noa_duration = noaDuration;
Gopichand Nakkala096a1052012-12-21 07:05:34 -08004734
Viral Modid86bde22012-12-10 13:09:21 -08004735 /* Start Insert NOA timer
4736 * 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 -08004737 * or any other failure or reason, we still need to process the deferred SME req. The insert NOA
4738 * timer of 500 ms will ensure the stored SME req always gets processed
Viral Modid86bde22012-12-10 13:09:21 -08004739 */
4740 if (tx_timer_activate(&pMac->lim.limTimers.gLimP2pSingleShotNoaInsertTimer)
4741 == TX_TIMER_ERROR)
4742 {
4743 /// Could not activate Insert NOA timer.
4744 // Log error
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004745 limLog(pMac, LOGP, FL("could not activate Insert Single Shot NOA during scan timer"));
Viral Modid86bde22012-12-10 13:09:21 -08004746
4747 // send the scan response back with status failure and do not even call insert NOA
4748 limSendSmeScanRsp(pMac, sizeof(tSirSmeScanRsp), eSIR_SME_SCAN_FAILED, pMac->lim.gSmeSessionId, pMac->lim.gTransactionId);
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304749 vos_mem_free(pMsgNoA);
Viral Modid440e682013-03-06 02:25:31 -08004750 goto error;
Viral Modid86bde22012-12-10 13:09:21 -08004751 }
4752
Viral Modid440e682013-03-06 02:25:31 -08004753 MTRACE(macTrace(pMac, TRACE_CODE_TIMER_ACTIVATE, NO_SESSION, eLIM_INSERT_SINGLESHOT_NOA_TIMER));
4754
Viral Modid86bde22012-12-10 13:09:21 -08004755 msg.type = WDA_SET_P2P_GO_NOA_REQ;
4756 msg.reserved = 0;
4757 msg.bodyptr = pMsgNoA;
4758 msg.bodyval = 0;
4759
4760 if(eSIR_SUCCESS != wdaPostCtrlMsg(pMac, &msg))
4761 {
4762 /* 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 -07004763 limLog(pMac, LOGP, FL("wdaPost Msg failed"));
Viral Modid440e682013-03-06 02:25:31 -08004764 /* Deactivate the NOA timer in failure case */
4765 limDeactivateAndChangeTimer(pMac, eLIM_INSERT_SINGLESHOT_NOA_TIMER);
4766 goto error;
Viral Modid86bde22012-12-10 13:09:21 -08004767 }
Viral Modid440e682013-03-06 02:25:31 -08004768 return FALSE;
Viral Modid86bde22012-12-10 13:09:21 -08004769
Viral Modid440e682013-03-06 02:25:31 -08004770error:
4771 /* In any of the failure cases, just go ahead with the processing of registered deferred SME request without
4772 * worrying about the NOA
4773 */
4774 limProcessRegdDefdSmeReqAfterNOAStart(pMac);
4775 // msg buffer is consumed and freed in above function so return FALSE
Viral Modid86bde22012-12-10 13:09:21 -08004776 return FALSE;
4777
4778}
4779
Viral Modid440e682013-03-06 02:25:31 -08004780static void __limRegisterDeferredSmeReqForNOAStart(tpAniSirGlobal pMac, tANI_U16 msgType, tANI_U32 *pMsgBuf)
4781{
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004782 limLog(pMac, LOG1, FL("Reg msgType %d"), msgType) ;
Viral Modid440e682013-03-06 02:25:31 -08004783 pMac->lim.gDeferMsgTypeForNOA = msgType;
4784 pMac->lim.gpDefdSmeMsgForNOA = pMsgBuf;
4785}
4786
4787static void __limDeregisterDeferredSmeReqAfterNOAStart(tpAniSirGlobal pMac)
4788{
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004789 limLog(pMac, LOG1, FL("Dereg msgType %d"), pMac->lim.gDeferMsgTypeForNOA) ;
Viral Modid440e682013-03-06 02:25:31 -08004790 pMac->lim.gDeferMsgTypeForNOA = 0;
4791 if (pMac->lim.gpDefdSmeMsgForNOA != NULL)
4792 {
4793 /* __limProcessSmeScanReq consumed the buffer. We can free it. */
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304794 vos_mem_free(pMac->lim.gpDefdSmeMsgForNOA);
Viral Modid440e682013-03-06 02:25:31 -08004795 pMac->lim.gpDefdSmeMsgForNOA = NULL;
4796 }
4797}
4798
4799static
4800tANI_U32 limCalculateNOADuration(tpAniSirGlobal pMac, tANI_U16 msgType, tANI_U32 *pMsgBuf)
4801{
4802 tANI_U32 noaDuration = 0;
4803
4804 switch (msgType)
4805 {
4806 case eWNI_SME_SCAN_REQ:
4807 {
4808 tANI_U32 val;
4809 tANI_U8 i;
4810 tpSirSmeScanReq pScanReq = (tpSirSmeScanReq) pMsgBuf;
4811 if (wlan_cfgGetInt(pMac, WNI_CFG_PASSIVE_MAXIMUM_CHANNEL_TIME, &val) != eSIR_SUCCESS)
4812 {
4813 /*
4814 * Could not get max channel value
4815 * from CFG. Log error.
4816 */
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004817 limLog(pMac, LOGP, FL("could not retrieve passive max channel value"));
Viral Modid440e682013-03-06 02:25:31 -08004818
4819 /* use a default value of 110ms */
4820 val = DEFAULT_PASSIVE_MAX_CHANNEL_TIME;
4821 }
4822
4823 for (i = 0; i < pScanReq->channelList.numChannels; i++) {
4824 tANI_U8 channelNum = pScanReq->channelList.channelNumber[i];
4825
4826 if (limActiveScanAllowed(pMac, channelNum)) {
4827 /* Use min + max channel time to calculate the total duration of scan */
4828 noaDuration += pScanReq->minChannelTime + pScanReq->maxChannelTime;
4829 } else {
4830 /* using the value from WNI_CFG_PASSIVE_MINIMUM_CHANNEL_TIME as is done in
4831 * void limContinuePostChannelScan(tpAniSirGlobal pMac)
4832 */
4833 noaDuration += val;
4834 }
4835 }
4836
4837 /* Adding an overhead of 20ms to account for the scan messaging delays */
4838 noaDuration += SCAN_MESSAGING_OVERHEAD;
4839 noaDuration *= CONV_MS_TO_US;
4840
4841 break;
4842 }
4843
4844 case eWNI_SME_OEM_DATA_REQ:
4845 noaDuration = OEM_DATA_NOA_DURATION*CONV_MS_TO_US; // use 60 msec as default
4846 break;
4847
4848 case eWNI_SME_REMAIN_ON_CHANNEL_REQ:
4849 {
4850 tSirRemainOnChnReq *pRemainOnChnReq = (tSirRemainOnChnReq *) pMsgBuf;
4851 noaDuration = (pRemainOnChnReq->duration)*CONV_MS_TO_US;
4852 break;
4853 }
4854
4855 case eWNI_SME_JOIN_REQ:
4856 noaDuration = JOIN_NOA_DURATION*CONV_MS_TO_US;
4857 break;
4858
4859 default:
4860 noaDuration = 0;
4861 break;
4862
4863 }
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004864 limLog(pMac, LOGW, FL("msgType %d noa %d"), msgType, noaDuration);
Viral Modid440e682013-03-06 02:25:31 -08004865 return noaDuration;
4866}
4867
4868void limProcessRegdDefdSmeReqAfterNOAStart(tpAniSirGlobal pMac)
4869{
Gopichand Nakkala7c4c3b92013-03-25 18:08:31 +05304870 tANI_BOOLEAN bufConsumed = TRUE;
Viral Modid440e682013-03-06 02:25:31 -08004871
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004872 limLog(pMac, LOG1, FL("Process defd sme req %d"), pMac->lim.gDeferMsgTypeForNOA);
Viral Modid440e682013-03-06 02:25:31 -08004873 if ( (pMac->lim.gDeferMsgTypeForNOA != 0) &&
4874 (pMac->lim.gpDefdSmeMsgForNOA != NULL) )
4875 {
4876 switch (pMac->lim.gDeferMsgTypeForNOA)
4877 {
4878 case eWNI_SME_SCAN_REQ:
4879 __limProcessSmeScanReq(pMac, pMac->lim.gpDefdSmeMsgForNOA);
4880 break;
4881 case eWNI_SME_OEM_DATA_REQ:
4882 __limProcessSmeOemDataReq(pMac, pMac->lim.gpDefdSmeMsgForNOA);
4883 break;
4884 case eWNI_SME_REMAIN_ON_CHANNEL_REQ:
Gopichand Nakkala7c4c3b92013-03-25 18:08:31 +05304885 bufConsumed = limProcessRemainOnChnlReq(pMac, pMac->lim.gpDefdSmeMsgForNOA);
4886 /* limProcessRemainOnChnlReq doesnt want us to free the buffer since
4887 * it is freed in limRemainOnChnRsp. this change is to avoid "double free"
4888 */
4889 if (FALSE == bufConsumed)
4890 {
4891 pMac->lim.gpDefdSmeMsgForNOA = NULL;
4892 }
Viral Modid440e682013-03-06 02:25:31 -08004893 break;
4894 case eWNI_SME_JOIN_REQ:
4895 __limProcessSmeJoinReq(pMac, pMac->lim.gpDefdSmeMsgForNOA);
4896 break;
4897 default:
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004898 limLog(pMac, LOGE, FL("Unknown deferred msg type %d"), pMac->lim.gDeferMsgTypeForNOA);
Viral Modid440e682013-03-06 02:25:31 -08004899 break;
4900 }
4901 __limDeregisterDeferredSmeReqAfterNOAStart(pMac);
4902 }
4903 else
4904 {
4905 limLog( pMac, LOGW, FL("start received from FW when no sme deferred msg pending. Do nothing."
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004906 "It might happen sometime when NOA start ind and timeout happen at the same time"));
Viral Modid440e682013-03-06 02:25:31 -08004907 }
4908}
Jeff Johnson295189b2012-06-20 16:38:30 -07004909
Mohit Khanna698ba2a2012-12-04 15:08:18 -08004910#ifdef FEATURE_WLAN_TDLS_INTERNAL
4911/*
4912 * Process Discovery request recieved from SME and transmit to AP.
4913 */
4914static tSirRetStatus limProcessSmeDisStartReq(tpAniSirGlobal pMac,
4915 tANI_U32 *pMsgBuf)
4916{
4917 /* get all discovery request parameters */
4918 tSirTdlsDisReq *disReq = (tSirTdlsDisReq *) pMsgBuf ;
4919 tpPESession psessionEntry;
4920 tANI_U8 sessionId;
4921
4922 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004923 ("Discovery Req Recieved")) ;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08004924
4925 if((psessionEntry = peFindSessionByBssid(pMac, disReq->bssid, &sessionId))
4926 == NULL)
4927 {
4928 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004929 "PE Session does not exist for given sme sessionId %d",
Mohit Khanna698ba2a2012-12-04 15:08:18 -08004930 disReq->sessionId);
4931 goto lim_tdls_dis_start_error;
4932 }
4933
4934 /* check if we are in proper state to work as TDLS client */
4935 if (psessionEntry->limSystemRole != eLIM_STA_ROLE)
4936 {
4937 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004938 "dis req received in wrong system Role %d",
Mohit Khanna698ba2a2012-12-04 15:08:18 -08004939 psessionEntry->limSystemRole);
4940 goto lim_tdls_dis_start_error;
4941 }
4942
4943 /*
4944 * if we are still good, go ahead and check if we are in proper state to
4945 * do TDLS discovery procedure.
4946 */
4947 if ((psessionEntry->limSmeState != eLIM_SME_ASSOCIATED_STATE) &&
4948 (psessionEntry->limSmeState != eLIM_SME_LINK_EST_STATE))
4949 {
4950
4951 limLog(pMac, LOGE, "dis req received in invalid LIMsme \
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004952 state (%d)", psessionEntry->limSmeState);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08004953 goto lim_tdls_dis_start_error;
4954 }
4955
4956 /*
4957 * if we are still good, go ahead and transmit TDLS discovery request,
4958 * and save Dis Req info for future reference.
4959 */
4960
4961#if 0 // TDLS_hklee: D13 no need to open Addr2 unknown data packet
4962 /*
4963 * send message to HAL to set RXP filters to receieve frame on
4964 * direct link..
4965 */
4966 //limSetLinkState(pMac, eSIR_LINK_TDLS_DISCOVERY_STATE,
4967 // psessionEntry->bssId) ;
4968#endif
4969
4970 /* save dis request message for matching dialog token */
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304971 vos_mem_copy((tANI_U8 *) &pMac->lim.gLimTdlsDisReq,
4972 (tANI_U8 *) disReq, sizeof(tSirTdlsDisReq));
Mohit Khanna698ba2a2012-12-04 15:08:18 -08004973
4974 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004975 "Transmit Discovery Request Frame") ;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08004976 /* format TDLS discovery request frame and transmit it */
4977 limSendTdlsDisReqFrame(pMac, disReq->peerMac, disReq->dialog,
4978 psessionEntry) ;
4979
4980 /* prepare for response */
4981 pMac->lim.gLimTdlsDisStaCount = 0 ;
4982 pMac->lim.gLimTdlsDisResultList = NULL ;
4983
4984 /*
4985 * start TDLS discovery request timer to wait for discovery responses
4986 * from all TDLS enabled clients in BSS.
4987 */
4988
4989 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004990 ("Start Discovery request Timeout Timer")) ;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08004991 MTRACE(macTrace(pMac, TRACE_CODE_TIMER_ACTIVATE, 0,
4992 eLIM_TDLS_DISCOVERY_RSP_WAIT));
4993
4994 /* assign appropriate sessionId to the timer object */
4995 pMac->lim.limTimers.gLimTdlsDisRspWaitTimer.sessionId =
4996 psessionEntry->peSessionId;
4997
4998 if (tx_timer_activate(&pMac->lim.limTimers.gLimTdlsDisRspWaitTimer)
4999 != TX_SUCCESS)
5000 {
5001 limLog(pMac, LOGP, FL("TDLS discovery response timer \
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005002 activation failed!"));
Mohit Khanna698ba2a2012-12-04 15:08:18 -08005003 goto lim_tdls_dis_start_error;
5004 }
5005 /*
5006 * when timer expired, eWNI_SME_TDLS_DISCOVERY_START_RSP is sent
5007 * back to SME
5008 */
5009 return (eSIR_SUCCESS) ;
5010lim_tdls_dis_start_error:
5011 /* in error case, PE has to sent the response SME immediately with error code */
5012 limSendSmeTdlsDisRsp(pMac, eSIR_FAILURE,
5013 eWNI_SME_TDLS_DISCOVERY_START_RSP);
5014 return eSIR_FAILURE;
5015}
5016/*
5017 * Process link start request recieved from SME and transmit to AP.
5018 */
5019eHalStatus limProcessSmeLinkStartReq(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
5020{
5021 /* get all discovery request parameters */
5022 tSirTdlsSetupReq *setupReq = (tSirTdlsSetupReq *) pMsgBuf ;
5023 tLimTdlsLinkSetupInfo *linkSetupInfo;
5024 //tLimTdlsLinkSetupPeer *setupPeer;
5025 tpPESession psessionEntry;
5026 tANI_U8 sessionId;
5027 eHalStatus status;
5028
5029 if((psessionEntry = peFindSessionByBssid(pMac,
5030 setupReq->bssid, &sessionId)) == NULL)
5031 {
5032 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005033 "PE Session does not exist for given sme sessionId %d",
Mohit Khanna698ba2a2012-12-04 15:08:18 -08005034 setupReq->sessionId);
5035 goto lim_tdls_link_start_error;
5036 }
5037
5038 /* check if we are in proper state to work as TDLS client */
5039 if (psessionEntry->limSystemRole != eLIM_STA_ROLE)
5040 {
5041 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005042 "TDLS link setup req received in wrong system Role %d",
Mohit Khanna698ba2a2012-12-04 15:08:18 -08005043 psessionEntry->limSystemRole);
5044 goto lim_tdls_link_start_error;
5045 }
5046
5047 /*
5048 * if we are still good, go ahead and check if we are in proper state to
5049 * do TDLS setup procedure.
5050 */
5051 if ((psessionEntry->limSmeState != eLIM_SME_ASSOCIATED_STATE) &&
5052 (psessionEntry->limSmeState != eLIM_SME_LINK_EST_STATE))
5053 {
5054 limLog(pMac, LOGE, "Setup request in invalid LIMsme \
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005055 state (%d)", pMac->lim.gLimSmeState);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08005056 goto lim_tdls_link_start_error;
5057 }
5058
5059 /*
5060 * Now, go ahead and transmit TDLS discovery request, and save setup Req
5061 * info for future reference.
5062 */
5063 /* create node for Link setup */
5064 linkSetupInfo = &pMac->lim.gLimTdlsLinkSetupInfo ;
5065 //setupPeer = NULL ;
5066
5067 status = limTdlsPrepareSetupReqFrame(pMac, linkSetupInfo, setupReq->dialog,
5068 setupReq->peerMac, psessionEntry) ;
5069 if(eHAL_STATUS_SUCCESS == status)
5070 /* in case of success, eWNI_SME_TDLS_LINK_START_RSP is sent back to SME later when
5071 TDLS setup cnf TX complete is successful. */
5072 return eSIR_SUCCESS;
5073#if 0
5074
5075 /*
5076 * we allocate the TDLS setup Peer Memory here, we will free'd this
Jeff Johnsonfeddb2d2012-12-10 14:41:22 -08005077 * memory after teardown, if the link is successfully setup or
Mohit Khanna698ba2a2012-12-04 15:08:18 -08005078 * free this memory if any timeout is happen in link setup procedure
5079 */
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05305080 setupPeer = vos_mem_malloc(sizeof( tLimTdlsLinkSetupPeer ));
5081 if ( NULL == setupPeer )
Mohit Khanna698ba2a2012-12-04 15:08:18 -08005082 {
5083 limLog( pMac, LOGP,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005084 FL( "Unable to allocate memory during ADD_STA" ));
Mohit Khanna698ba2a2012-12-04 15:08:18 -08005085 VOS_ASSERT(0) ;
5086 return eSIR_MEM_ALLOC_FAILED;
5087 }
5088 setupPeer->dialog = setupReq->dialog ;
5089 setupPeer->tdls_prev_link_state = setupPeer->tdls_link_state ;
5090 setupPeer->tdls_link_state = TDLS_LINK_SETUP_START_STATE ;
5091 /* TDLS_sessionize: remember sessionId for future */
5092 setupPeer->tdls_sessionId = psessionEntry->peSessionId;
5093 setupPeer->tdls_bIsResponder = 1;
5094
5095 /*
5096 * we only populate peer MAC, so it can assit us to find the
5097 * TDLS peer after response/or after response timeout
5098 */
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05305099 vos_mem_copy(setupPeer->peerMac, setupReq->peerMac,
Mohit Khanna698ba2a2012-12-04 15:08:18 -08005100 sizeof(tSirMacAddr)) ;
5101 /* format TDLS discovery request frame and transmit it */
5102 limSendTdlsLinkSetupReqFrame(pMac, setupReq->peerMac,
5103 setupReq->dialog, psessionEntry, NULL, 0) ;
5104
5105 limStartTdlsTimer(pMac, psessionEntry->peSessionId,
5106 &setupPeer->gLimTdlsLinkSetupRspTimeoutTimer,
5107 (tANI_U32)setupPeer->peerMac, WNI_CFG_TDLS_LINK_SETUP_RSP_TIMEOUT,
5108 SIR_LIM_TDLS_LINK_SETUP_RSP_TIMEOUT) ;
5109 /* update setup peer list */
5110 setupPeer->next = linkSetupInfo->tdlsLinkSetupList ;
5111 linkSetupInfo->tdlsLinkSetupList = setupPeer ;
5112 /* in case of success, eWNI_SME_TDLS_LINK_START_RSP is sent back to SME later when
5113 TDLS setup cnf TX complete is successful. --> see limTdlsSetupCnfTxComplete() */
5114 return eSIR_SUCCESS ;
5115#endif
5116lim_tdls_link_start_error:
5117 /* in case of error, return immediately to SME */
5118 limSendSmeTdlsLinkStartRsp(pMac, eSIR_FAILURE, setupReq->peerMac,
5119 eWNI_SME_TDLS_LINK_START_RSP);
5120 return eSIR_FAILURE ;
5121}
5122
5123/*
5124 * Process link teardown request recieved from SME and transmit to AP.
5125 */
5126eHalStatus limProcessSmeTeardownReq(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
5127{
5128 /* get all discovery request parameters */
5129 tSirTdlsTeardownReq *teardownReq = (tSirTdlsTeardownReq *) pMsgBuf ;
5130 tLimTdlsLinkSetupPeer *setupPeer;
5131 tpPESession psessionEntry;
5132 tANI_U8 sessionId;
5133
5134 if((psessionEntry = peFindSessionByBssid(pMac, teardownReq->bssid, &sessionId)) == NULL)
5135 {
5136 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005137 "PE Session does not exist for given sme sessionId %d", teardownReq->sessionId);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08005138 goto lim_tdls_teardown_req_error;
5139 }
5140
5141 /* check if we are in proper state to work as TDLS client */
5142 if (psessionEntry->limSystemRole != eLIM_STA_ROLE)
5143 {
5144 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005145 "TDLS teardown req received in wrong system Role %d", psessionEntry->limSystemRole);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08005146 goto lim_tdls_teardown_req_error;
5147 }
5148
5149 /*
5150 * if we are still good, go ahead and check if we are in proper state to
5151 * do TDLS setup procedure.
5152 */
5153 if ((psessionEntry->limSmeState != eLIM_SME_ASSOCIATED_STATE) &&
5154 (psessionEntry->limSmeState != eLIM_SME_LINK_EST_STATE))
5155 {
5156 limLog(pMac, LOGE, "TDLS teardwon req received in invalid LIMsme \
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005157 state (%d)", psessionEntry->limSmeState);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08005158 goto lim_tdls_teardown_req_error;
5159 }
5160
5161 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005162 "Teardown for peer = %02x,%02x,%02x,%02x,%02x,%02x",
Mohit Khanna698ba2a2012-12-04 15:08:18 -08005163 teardownReq->peerMac[0],
5164 teardownReq->peerMac[1],
5165 teardownReq->peerMac[2],
5166 teardownReq->peerMac[3],
5167 teardownReq->peerMac[4],
5168 teardownReq->peerMac[5]) ;
5169 /*
5170 * Now, go ahead and transmit TDLS teardown request, and save teardown info
5171 * info for future reference.
5172 */
5173 /* Verify if this link is setup */
5174 setupPeer = NULL ;
5175 limTdlsFindLinkPeer(pMac, teardownReq->peerMac, &setupPeer);
5176 if(NULL == setupPeer)
5177 {
5178 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005179 ("invalid Peer on teardown ")) ;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08005180 goto lim_tdls_teardown_req_error;
5181 }
5182
5183
5184 (setupPeer)->tdls_prev_link_state = (setupPeer)->tdls_link_state ;
5185 (setupPeer)->tdls_link_state = TDLS_LINK_TEARDOWN_START_STATE ;
5186 /* TDLS_sessionize: check sessionId in case */
5187 if((setupPeer)->tdls_sessionId != psessionEntry->peSessionId)
5188 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005189 limLog(pMac, LOGE, "TDLS teardown req; stored sessionId (%d) not matched from peSessionId (%d)", \
Mohit Khanna698ba2a2012-12-04 15:08:18 -08005190 (setupPeer)->tdls_sessionId, psessionEntry->limSmeState);
5191 (setupPeer)->tdls_sessionId = psessionEntry->peSessionId;
5192 }
5193
5194 /* format TDLS teardown request frame and transmit it */
5195 if(eSIR_SUCCESS != limSendTdlsTeardownFrame(pMac, teardownReq->peerMac,
5196 eSIR_MAC_TDLS_TEARDOWN_UNSPEC_REASON, psessionEntry, NULL, 0 ))
5197 {
5198 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005199 ("couldn't send teardown frame ")) ;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08005200 goto lim_tdls_teardown_req_error;
5201 }
5202 /* in case of success, eWNI_SME_TDLS_TEARDOWN_RSP is sent back to SME later when
5203 TDLS teardown TX complete is successful. --> see limTdlsTeardownTxComplete() */
5204 return eSIR_SUCCESS;
5205lim_tdls_teardown_req_error:
5206 /* in case of error, return immediately to SME */
5207 limSendSmeTdlsTeardownRsp(pMac, eSIR_FAILURE, teardownReq->peerMac,
5208 eWNI_SME_TDLS_TEARDOWN_RSP);
5209 return eSIR_FAILURE;
5210}
5211
5212
5213#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005214
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05305215static void
5216__limProcessSmeResetApCapsChange(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
5217{
5218 tpSirResetAPCapsChange pResetCapsChange;
5219 tpPESession psessionEntry;
5220 tANI_U8 sessionId = 0;
5221 if (pMsgBuf == NULL)
5222 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005223 limLog(pMac, LOGE,FL("Buffer is Pointing to NULL"));
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05305224 return;
5225 }
5226
5227 pResetCapsChange = (tpSirResetAPCapsChange)pMsgBuf;
5228 psessionEntry = peFindSessionByBssid(pMac, pResetCapsChange->bssId, &sessionId);
5229 if (psessionEntry == NULL)
5230 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005231 limLog(pMac, LOGE, FL("Session does not exist for given BSSID"));
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05305232 return;
5233 }
5234
5235 psessionEntry->limSentCapsChangeNtf = false;
5236 return;
5237}
5238
Jeff Johnson295189b2012-06-20 16:38:30 -07005239/**
5240 * limProcessSmeReqMessages()
5241 *
5242 *FUNCTION:
5243 * This function is called by limProcessMessageQueue(). This
5244 * function processes SME request messages from HDD or upper layer
5245 * application.
5246 *
5247 *LOGIC:
5248 *
5249 *ASSUMPTIONS:
5250 *
5251 *NOTE:
5252 *
5253 * @param pMac Pointer to Global MAC structure
5254 * @param msgType Indicates the SME message type
5255 * @param *pMsgBuf A pointer to the SME message buffer
5256 * @return Boolean - TRUE - if pMsgBuf is consumed and can be freed.
5257 * FALSE - if pMsgBuf is not to be freed.
5258 */
5259
5260tANI_BOOLEAN
5261limProcessSmeReqMessages(tpAniSirGlobal pMac, tpSirMsgQ pMsg)
5262{
5263 tANI_BOOLEAN bufConsumed = TRUE; //Set this flag to false within case block of any following message, that doesnt want pMsgBuf to be freed.
5264 tANI_U32 *pMsgBuf = pMsg->bodyptr;
Sudhir Sattayappa Kohalliabf751c2013-06-30 15:37:18 -07005265 tpSirSmeScanReq pScanReq;
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005266 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 -07005267 limMsgStr(pMsg->type), pMsg->type,
5268 limSmeStateStr(pMac->lim.gLimSmeState), pMac->lim.gLimSmeState,
5269 limMlmStateStr(pMac->lim.gLimMlmState), pMac->lim.gLimMlmState );)
5270
Sudhir Sattayappa Kohalliabf751c2013-06-30 15:37:18 -07005271 pScanReq = (tpSirSmeScanReq) pMsgBuf;
Viral Modid440e682013-03-06 02:25:31 -08005272 /* Special handling of some SME Req msgs where we have an existing GO session and
5273 * want to insert NOA before processing those msgs. These msgs will be processed later when
5274 * start event happens
5275 */
5276 switch (pMsg->type)
5277 {
5278 case eWNI_SME_SCAN_REQ:
Viral Modid440e682013-03-06 02:25:31 -08005279 case eWNI_SME_REMAIN_ON_CHANNEL_REQ:
Sudhir Sattayappa Kohalliabf751c2013-06-30 15:37:18 -07005280
5281 /* If scan is disabled return from here
5282 */
5283 if (pMac->lim.fScanDisabled)
5284 {
5285 PELOGE(limLog(pMac, LOGE, FL("Error: Scan Disabled"));)
5286 if (pMsg->type == eWNI_SME_SCAN_REQ)
5287 {
5288 limSendSmeScanRsp(pMac,
5289 offsetof(tSirSmeScanRsp,bssDescription[0]),
5290 eSIR_SME_INVALID_PARAMETERS,
5291 pScanReq->sessionId,
5292 pScanReq->transactionId);
5293
5294 bufConsumed = TRUE;
5295 }
5296 else if (pMsg->type == eWNI_SME_REMAIN_ON_CHANNEL_REQ)
5297 {
5298 pMac->lim.gpDefdSmeMsgForNOA = NULL;
5299 pMac->lim.gpLimRemainOnChanReq = (tpSirRemainOnChnReq )pMsgBuf;
5300 limRemainOnChnRsp(pMac,eHAL_STATUS_FAILURE, NULL);
5301
5302 /*
5303 * limRemainOnChnRsp will free the buffer this change is to
5304 * avoid "double free"
5305 */
5306 bufConsumed = FALSE;
5307 }
5308
5309 return bufConsumed;
5310 }
5311 /*
5312 * Do not add BREAK here
5313 */
5314 case eWNI_SME_OEM_DATA_REQ:
Viral Modid440e682013-03-06 02:25:31 -08005315 case eWNI_SME_JOIN_REQ:
5316 /* If we have an existing P2P GO session we need to insert NOA before actually process this SME Req */
5317 if ((limIsNOAInsertReqd(pMac) == TRUE) && IS_FEATURE_SUPPORTED_BY_FW(P2P_GO_NOA_DECOUPLE_INIT_SCAN))
5318 {
5319 tANI_U32 noaDuration;
5320 __limRegisterDeferredSmeReqForNOAStart(pMac, pMsg->type, pMsgBuf);
5321 noaDuration = limCalculateNOADuration(pMac, pMsg->type, pMsgBuf);
5322 bufConsumed = __limInsertSingleShotNOAForScan(pMac, noaDuration);
5323 return bufConsumed;
5324 }
5325 }
5326 /* If no insert NOA required then execute the code below */
5327
Jeff Johnson295189b2012-06-20 16:38:30 -07005328 switch (pMsg->type)
5329 {
5330 case eWNI_SME_START_REQ:
5331 __limProcessSmeStartReq(pMac, pMsgBuf);
5332 break;
5333
5334 case eWNI_SME_SYS_READY_IND:
5335 bufConsumed = __limProcessSmeSysReadyInd(pMac, pMsgBuf);
5336 break;
5337
Jeff Johnson295189b2012-06-20 16:38:30 -07005338 case eWNI_SME_START_BSS_REQ:
5339 bufConsumed = __limProcessSmeStartBssReq(pMac, pMsg);
5340 break;
5341
5342 case eWNI_SME_SCAN_REQ:
Viral Modid440e682013-03-06 02:25:31 -08005343 __limProcessSmeScanReq(pMac, pMsgBuf);
Jeff Johnson295189b2012-06-20 16:38:30 -07005344 break;
5345
Jeff Johnsone7245742012-09-05 17:12:55 -07005346#ifdef FEATURE_OEM_DATA_SUPPORT
5347 case eWNI_SME_OEM_DATA_REQ:
5348 __limProcessSmeOemDataReq(pMac, pMsgBuf);
Jeff Johnsone7245742012-09-05 17:12:55 -07005349 break;
5350#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005351 case eWNI_SME_REMAIN_ON_CHANNEL_REQ:
5352 bufConsumed = limProcessRemainOnChnlReq(pMac, pMsgBuf);
5353 break;
5354
5355 case eWNI_SME_UPDATE_NOA:
5356 __limProcessSmeNoAUpdate(pMac, pMsgBuf);
5357 break;
Gopichand Nakkalac178ac82013-05-30 19:53:39 +05305358 case eWNI_SME_CLEAR_DFS_CHANNEL_LIST:
5359 __limProcessClearDfsChannelList(pMac, pMsg);
5360 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005361 case eWNI_SME_JOIN_REQ:
5362 __limProcessSmeJoinReq(pMac, pMsgBuf);
Jeff Johnson295189b2012-06-20 16:38:30 -07005363 break;
5364
5365 case eWNI_SME_AUTH_REQ:
5366 // __limProcessSmeAuthReq(pMac, pMsgBuf);
5367
5368 break;
5369
5370 case eWNI_SME_REASSOC_REQ:
5371 __limProcessSmeReassocReq(pMac, pMsgBuf);
5372
5373 break;
5374
5375 case eWNI_SME_PROMISCUOUS_MODE_REQ:
5376 //__limProcessSmePromiscuousReq(pMac, pMsgBuf);
5377
5378 break;
5379
5380 case eWNI_SME_DISASSOC_REQ:
5381 __limProcessSmeDisassocReq(pMac, pMsgBuf);
5382
5383 break;
5384
5385 case eWNI_SME_DISASSOC_CNF:
5386 case eWNI_SME_DEAUTH_CNF:
5387 __limProcessSmeDisassocCnf(pMac, pMsgBuf);
5388
5389 break;
5390
5391 case eWNI_SME_DEAUTH_REQ:
5392 __limProcessSmeDeauthReq(pMac, pMsgBuf);
5393
5394 break;
5395
Jeff Johnson295189b2012-06-20 16:38:30 -07005396
5397
5398 case eWNI_SME_SETCONTEXT_REQ:
5399 __limProcessSmeSetContextReq(pMac, pMsgBuf);
5400
5401 break;
5402
5403 case eWNI_SME_REMOVEKEY_REQ:
5404 __limProcessSmeRemoveKeyReq(pMac, pMsgBuf);
5405
5406 break;
5407
5408 case eWNI_SME_STOP_BSS_REQ:
5409 bufConsumed = __limProcessSmeStopBssReq(pMac, pMsg);
5410 break;
5411
5412 case eWNI_SME_ASSOC_CNF:
5413 case eWNI_SME_REASSOC_CNF:
5414 if (pMsg->type == eWNI_SME_ASSOC_CNF)
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005415 PELOG1(limLog(pMac, LOG1, FL("Received ASSOC_CNF message"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07005416 else
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005417 PELOG1(limLog(pMac, LOG1, FL("Received REASSOC_CNF message"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07005418 __limProcessSmeAssocCnfNew(pMac, pMsg->type, pMsgBuf);
5419 break;
5420
5421 case eWNI_SME_ADDTS_REQ:
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005422 PELOG1(limLog(pMac, LOG1, FL("Received ADDTS_REQ message"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07005423 __limProcessSmeAddtsReq(pMac, pMsgBuf);
5424 break;
5425
5426 case eWNI_SME_DELTS_REQ:
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005427 PELOG1(limLog(pMac, LOG1, FL("Received DELTS_REQ message"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07005428 __limProcessSmeDeltsReq(pMac, pMsgBuf);
5429 break;
5430
5431 case SIR_LIM_ADDTS_RSP_TIMEOUT:
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005432 PELOG1(limLog(pMac, LOG1, FL("Received SIR_LIM_ADDTS_RSP_TIMEOUT message "));)
Jeff Johnson295189b2012-06-20 16:38:30 -07005433 limProcessSmeAddtsRspTimeout(pMac, pMsg->bodyval);
5434 break;
5435
5436 case eWNI_SME_STA_STAT_REQ:
5437 case eWNI_SME_AGGR_STAT_REQ:
5438 case eWNI_SME_GLOBAL_STAT_REQ:
5439 case eWNI_SME_STAT_SUMM_REQ:
5440 __limProcessSmeStatsRequest( pMac, pMsgBuf);
5441 //HAL consumes pMsgBuf. It will be freed there. Set bufConsumed to false.
5442 bufConsumed = FALSE;
5443 break;
5444 case eWNI_SME_GET_STATISTICS_REQ:
5445 __limProcessSmeGetStatisticsRequest( pMac, pMsgBuf);
5446 //HAL consumes pMsgBuf. It will be freed there. Set bufConsumed to false.
5447 bufConsumed = FALSE;
5448 break;
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08005449#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_CCX || defined(FEATURE_WLAN_LFR)
5450 case eWNI_SME_GET_ROAM_RSSI_REQ:
5451 __limProcessSmeGetRoamRssiRequest( pMac, pMsgBuf);
5452 //HAL consumes pMsgBuf. It will be freed there. Set bufConsumed to false.
5453 bufConsumed = FALSE;
5454 break;
5455#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005456 case eWNI_SME_DEL_BA_PEER_IND:
5457 limProcessSmeDelBaPeerInd(pMac, pMsgBuf);
5458 break;
5459 case eWNI_SME_GET_SCANNED_CHANNEL_REQ:
5460 limProcessSmeGetScanChannelInfo(pMac, pMsgBuf);
5461 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005462 case eWNI_SME_GET_ASSOC_STAS_REQ:
5463 limProcessSmeGetAssocSTAsInfo(pMac, pMsgBuf);
5464 break;
5465 case eWNI_SME_TKIP_CNTR_MEAS_REQ:
5466 limProcessTkipCounterMeasures(pMac, pMsgBuf);
5467 break;
5468
5469 case eWNI_SME_HIDE_SSID_REQ:
5470 __limProcessSmeHideSSID(pMac, pMsgBuf);
5471 break;
5472 case eWNI_SME_UPDATE_APWPSIE_REQ:
5473 __limProcessSmeUpdateAPWPSIEs(pMac, pMsgBuf);
5474 break;
5475 case eWNI_SME_GET_WPSPBC_SESSION_REQ:
5476 limProcessSmeGetWPSPBCSessions(pMac, pMsgBuf);
5477 break;
5478
5479 case eWNI_SME_SET_APWPARSNIEs_REQ:
5480 __limProcessSmeSetWPARSNIEs(pMac, pMsgBuf);
5481 break;
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08005482
5483 case eWNI_SME_CHNG_MCC_BEACON_INTERVAL:
5484 //Update the beaconInterval
5485 __limProcessSmeChangeBI(pMac, pMsgBuf );
5486 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005487
5488#if defined WLAN_FEATURE_VOWIFI
5489 case eWNI_SME_NEIGHBOR_REPORT_REQ_IND:
5490 case eWNI_SME_BEACON_REPORT_RESP_XMIT_IND:
5491 __limProcessReportMessage(pMac, pMsg);
5492 break;
5493#endif
5494
5495#if defined WLAN_FEATURE_VOWIFI_11R
5496 case eWNI_SME_FT_PRE_AUTH_REQ:
5497 bufConsumed = (tANI_BOOLEAN)limProcessFTPreAuthReq(pMac, pMsg);
5498 break;
5499 case eWNI_SME_FT_UPDATE_KEY:
5500 limProcessFTUpdateKey(pMac, pMsgBuf);
5501 break;
5502
5503 case eWNI_SME_FT_AGGR_QOS_REQ:
5504 limProcessFTAggrQosReq(pMac, pMsgBuf);
5505 break;
5506#endif
5507
5508#if defined FEATURE_WLAN_CCX
5509 case eWNI_SME_CCX_ADJACENT_AP_REPORT:
5510 limProcessAdjacentAPRepMsg ( pMac, pMsgBuf );
5511 break;
5512#endif
5513 case eWNI_SME_ADD_STA_SELF_REQ:
5514 __limProcessSmeAddStaSelfReq( pMac, pMsgBuf );
5515 break;
5516 case eWNI_SME_DEL_STA_SELF_REQ:
5517 __limProcessSmeDelStaSelfReq( pMac, pMsgBuf );
5518 break;
5519
Jeff Johnson295189b2012-06-20 16:38:30 -07005520 case eWNI_SME_REGISTER_MGMT_FRAME_REQ:
5521 __limProcessSmeRegisterMgmtFrameReq( pMac, pMsgBuf );
5522 break;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08005523#ifdef FEATURE_WLAN_TDLS
5524 case eWNI_SME_TDLS_SEND_MGMT_REQ:
5525 limProcessSmeTdlsMgmtSendReq(pMac, pMsgBuf);
5526 break;
5527 case eWNI_SME_TDLS_ADD_STA_REQ:
5528 limProcessSmeTdlsAddStaReq(pMac, pMsgBuf);
5529 break;
5530 case eWNI_SME_TDLS_DEL_STA_REQ:
5531 limProcessSmeTdlsDelStaReq(pMac, pMsgBuf);
5532 break;
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05305533 case eWNI_SME_TDLS_LINK_ESTABLISH_REQ:
5534 limProcesSmeTdlsLinkEstablishReq(pMac, pMsgBuf);
5535 break;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08005536#endif
5537#ifdef FEATURE_WLAN_TDLS_INTERNAL
5538 case eWNI_SME_TDLS_DISCOVERY_START_REQ:
5539 limProcessSmeDisStartReq(pMac, pMsgBuf);
5540 break ;
5541 case eWNI_SME_TDLS_LINK_START_REQ:
5542 limProcessSmeLinkStartReq(pMac, pMsgBuf);
5543 break ;
5544 case eWNI_SME_TDLS_TEARDOWN_REQ:
5545 limProcessSmeTeardownReq(pMac, pMsgBuf);
5546 break ;
5547#endif
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05305548 case eWNI_SME_RESET_AP_CAPS_CHANGED:
5549 __limProcessSmeResetApCapsChange(pMac, pMsgBuf);
5550 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005551
schang86c22c42013-03-13 18:41:24 -07005552 case eWNI_SME_SET_TX_POWER_REQ:
5553 limSendSetTxPowerReq(pMac, pMsgBuf);
5554 break ;
5555
Jeff Johnson295189b2012-06-20 16:38:30 -07005556 default:
5557 vos_mem_free((v_VOID_t*)pMsg->bodyptr);
5558 pMsg->bodyptr = NULL;
5559 break;
5560 } // switch (msgType)
5561
5562 return bufConsumed;
5563} /*** end limProcessSmeReqMessages() ***/