blob: e0522a1edd66b592ef0b0d1bc4391bf92e3aa522 [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
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070079#if defined(FEATURE_WLAN_CCX) && !defined(FEATURE_WLAN_CCX_UPLOAD)
Jeff Johnson295189b2012-06-20 16:38:30 -070080#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;
Ravi Joshi27216f12013-10-19 17:04:39 -0700691 psessionEntry->shortSlotTimeSupported =
692 limGetShortSlotFromPhyMode(pMac, psessionEntry,
693 psessionEntry->gLimPhyMode);
krunal sonie9002db2013-11-25 14:24:17 -0800694 psessionEntry->isCoalesingInIBSSAllowed =
695 pSmeStartBssReq->isCoalesingInIBSSAllowed;
Jeff Johnson295189b2012-06-20 16:38:30 -0700696 break;
697
698 case eSIR_BTAMP_AP_MODE:
699 psessionEntry->limSystemRole = eLIM_BT_AMP_AP_ROLE;
700 break;
701
702 case eSIR_BTAMP_STA_MODE:
703 psessionEntry->limSystemRole = eLIM_BT_AMP_STA_ROLE;
704 break;
705
706 /* There is one more mode called auto mode. which is used no where */
707
708 //FORBUILD -TEMPFIX.. HOW TO use AUTO MODE?????
709
710
711 default:
712 //not used anywhere...used in scan function
713 break;
714 }
715
716 // BT-AMP: Allocate memory for the array of parsed (Re)Assoc request structure
717 if ( (pSmeStartBssReq->bssType == eSIR_BTAMP_AP_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -0700718 || (pSmeStartBssReq->bssType == eSIR_INFRA_AP_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -0700719 )
720 {
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +0530721 psessionEntry->parsedAssocReq = vos_mem_malloc(
722 psessionEntry->dph.dphHashTable.size * sizeof(tpSirAssocReq));
723 if ( NULL == psessionEntry->parsedAssocReq )
Jeff Johnson295189b2012-06-20 16:38:30 -0700724 {
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +0530725 limLog(pMac, LOGW, FL("AllocateMemory() failed"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700726 retCode = eSIR_SME_RESOURCES_UNAVAILABLE;
727 goto free;
728 }
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +0530729 vos_mem_set(psessionEntry->parsedAssocReq,
730 (psessionEntry->dph.dphHashTable.size * sizeof(tpSirAssocReq)),
731 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -0700732 }
733
734 /* Channel Bonding is not addressd yet for BT-AMP Support.. sunit will address channel bonding */
735 if (pSmeStartBssReq->channelId)
736 {
737 channelNumber = pSmeStartBssReq->channelId;
Jeff Johnsone7245742012-09-05 17:12:55 -0700738 psessionEntry->htSupportedChannelWidthSet = (pSmeStartBssReq->cbMode)?1:0; // This is already merged value of peer and self - done by csr in csrGetCBModeFromIes
739 psessionEntry->htRecommendedTxWidthSet = psessionEntry->htSupportedChannelWidthSet;
740 psessionEntry->htSecondaryChannelOffset = pSmeStartBssReq->cbMode;
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -0700741 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
Jeff Johnsone7245742012-09-05 17:12:55 -0700742 FL("cbMode %u"), pSmeStartBssReq->cbMode);
743#ifdef WLAN_FEATURE_11AC
744 if(psessionEntry->vhtCapability)
745 {
746 tANI_U32 centerChan;
747 tANI_U32 chanWidth;
Jeff Johnson295189b2012-06-20 16:38:30 -0700748
Jeff Johnsone7245742012-09-05 17:12:55 -0700749 if (wlan_cfgGetInt(pMac, WNI_CFG_VHT_CHANNEL_WIDTH,
750 &chanWidth) != eSIR_SUCCESS)
Jeff Johnson295189b2012-06-20 16:38:30 -0700751 {
Jeff Johnsone7245742012-09-05 17:12:55 -0700752 limLog(pMac, LOGP,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700753 FL("Unable to retrieve Channel Width from CFG"));
Jeff Johnsone7245742012-09-05 17:12:55 -0700754 }
755
756 if(chanWidth == eHT_CHANNEL_WIDTH_20MHZ || chanWidth == eHT_CHANNEL_WIDTH_40MHZ)
757 {
758 if (cfgSetInt(pMac, WNI_CFG_VHT_CHANNEL_WIDTH, WNI_CFG_VHT_CHANNEL_WIDTH_20_40MHZ)
759 != eSIR_SUCCESS)
Jeff Johnson295189b2012-06-20 16:38:30 -0700760 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700761 limLog(pMac, LOGP, FL("could not set WNI_CFG_CHANNEL_BONDING_MODE at CFG"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700762 retCode = eSIR_LOGP_EXCEPTION;
Jeff Johnsone7245742012-09-05 17:12:55 -0700763 goto free;
Jeff Johnson295189b2012-06-20 16:38:30 -0700764 }
765 }
Jeff Johnsone7245742012-09-05 17:12:55 -0700766 if (chanWidth == eHT_CHANNEL_WIDTH_80MHZ)
767 {
768 if (cfgSetInt(pMac, WNI_CFG_VHT_CHANNEL_WIDTH, WNI_CFG_VHT_CHANNEL_WIDTH_80MHZ)
769 != eSIR_SUCCESS)
770 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700771 limLog(pMac, LOGP, FL("could not set WNI_CFG_CHANNEL_BONDING_MODE at CFG"));
Jeff Johnsone7245742012-09-05 17:12:55 -0700772 retCode = eSIR_LOGP_EXCEPTION;
773 goto free;
774 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700775
Jeff Johnsone7245742012-09-05 17:12:55 -0700776 centerChan = limGetCenterChannel(pMac,channelNumber,pSmeStartBssReq->cbMode,WNI_CFG_VHT_CHANNEL_WIDTH_80MHZ);
777 if(centerChan != eSIR_CFG_INVALID_ID)
778 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -0800779 limLog(pMac, LOGW, FL("***Center Channel for 80MHZ channel width = %d"),centerChan);
Madan Mohan Koyyalamudi8b152b82012-10-18 20:56:27 -0700780 psessionEntry->apCenterChan = centerChan;
Jeff Johnsone7245742012-09-05 17:12:55 -0700781 if (cfgSetInt(pMac, WNI_CFG_VHT_CHANNEL_CENTER_FREQ_SEGMENT1, centerChan)
782 != eSIR_SUCCESS)
783 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700784 limLog(pMac, LOGP, FL("could not set WNI_CFG_CHANNEL_BONDING_MODE at CFG"));
Jeff Johnsone7245742012-09-05 17:12:55 -0700785 retCode = eSIR_LOGP_EXCEPTION;
786 goto free;
787 }
788 }
789 }
790
791 /* All the translation is done by now for gVhtChannelWidth from .ini file to
792 * the actual values as defined in spec. So, grabing the spec value which is
793 * updated in .dat file by the above logic */
794 if (wlan_cfgGetInt(pMac, WNI_CFG_VHT_CHANNEL_WIDTH,
795 &chanWidth) != eSIR_SUCCESS)
796 {
797 limLog(pMac, LOGP,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700798 FL("Unable to retrieve Channel Width from CFG"));
Jeff Johnsone7245742012-09-05 17:12:55 -0700799 }
Madan Mohan Koyyalamudi8b152b82012-10-18 20:56:27 -0700800 /*For Sta+p2p-Go concurrency
801 vhtTxChannelWidthSet is used for storing p2p-GO channel width
802 apChanWidth is used for storing the AP channel width that the Sta is going to associate.
803 Initialize the apChanWidth same as p2p-GO channel width this gets over written once the station joins the AP
804 */
Jeff Johnsone7245742012-09-05 17:12:55 -0700805 psessionEntry->vhtTxChannelWidthSet = chanWidth;
Madan Mohan Koyyalamudi8b152b82012-10-18 20:56:27 -0700806 psessionEntry->apChanWidth = chanWidth;
Jeff Johnsone7245742012-09-05 17:12:55 -0700807 }
808 psessionEntry->htSecondaryChannelOffset = limGetHTCBState(pSmeStartBssReq->cbMode);
809#endif
810 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700811 else
812 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700813 PELOGW(limLog(pMac, LOGW, FL("Received invalid eWNI_SME_START_BSS_REQ"));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700814 retCode = eSIR_SME_INVALID_PARAMETERS;
815 goto free;
816 }
817
818 // Delete pre-auth list if any
819 limDeletePreAuthList(pMac);
820
821 // Delete IBSS peer BSSdescription list if any
822 //limIbssDelete(pMac); sep 26 review
823
824
825
826#ifdef FIXME_GEN6 //following code may not be required. limInitMlm is now being invoked during peStart
827 /// Initialize MLM state machine
Jeff Johnson295189b2012-06-20 16:38:30 -0700828 limInitMlm(pMac);
829#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700830
Jeff Johnsone7245742012-09-05 17:12:55 -0700831 psessionEntry->htCapability = IS_DOT11_MODE_HT(pSmeStartBssReq->dot11mode);
Jeff Johnson295189b2012-06-20 16:38:30 -0700832
Jeff Johnson295189b2012-06-20 16:38:30 -0700833 /* keep the RSN/WPA IE information in PE Session Entry
834 * later will be using this to check when received (Re)Assoc req
835 * */
836 limSetRSNieWPAiefromSmeStartBSSReqMessage(pMac,&pSmeStartBssReq->rsnIE,psessionEntry);
837
Jeff Johnson295189b2012-06-20 16:38:30 -0700838
Jeff Johnson295189b2012-06-20 16:38:30 -0700839 //Taken care for only softAP case rest need to be done
840 if (psessionEntry->limSystemRole == eLIM_AP_ROLE){
841 psessionEntry->gLimProtectionControl = pSmeStartBssReq->protEnabled;
842 /*each byte will have the following info
843 *bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0
844 *reserved reserved RIFS Lsig n-GF ht20 11g 11b*/
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +0530845 vos_mem_copy( (void *) &psessionEntry->cfgProtection,
Jeff Johnson295189b2012-06-20 16:38:30 -0700846 (void *) &pSmeStartBssReq->ht_capab,
Kiran Kumar Lokerea4db3dc2013-03-25 18:05:24 -0700847 sizeof( tANI_U16 ));
Jeff Johnson295189b2012-06-20 16:38:30 -0700848 psessionEntry->pAPWPSPBCSession = NULL; // Initialize WPS PBC session link list
849 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700850
851 // Prepare and Issue LIM_MLM_START_REQ to MLM
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +0530852 pMlmStartReq = vos_mem_malloc(sizeof(tLimMlmStartReq));
853 if ( NULL == pMlmStartReq )
Jeff Johnson295189b2012-06-20 16:38:30 -0700854 {
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +0530855 limLog(pMac, LOGP, FL("call to AllocateMemory failed for mlmStartReq"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700856 retCode = eSIR_SME_RESOURCES_UNAVAILABLE;
857 goto free;
858 }
859
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +0530860 vos_mem_set((void *) pMlmStartReq, sizeof(tLimMlmStartReq), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700861
862 /* Copy SSID to the MLM start structure */
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +0530863 vos_mem_copy( (tANI_U8 *) &pMlmStartReq->ssId,
Jeff Johnson295189b2012-06-20 16:38:30 -0700864 (tANI_U8 *) &pSmeStartBssReq->ssId,
865 pSmeStartBssReq->ssId.length + 1);
Jeff Johnson295189b2012-06-20 16:38:30 -0700866 pMlmStartReq->ssidHidden = pSmeStartBssReq->ssidHidden;
867 pMlmStartReq->obssProtEnabled = pSmeStartBssReq->obssProtEnabled;
Jeff Johnson295189b2012-06-20 16:38:30 -0700868
869
870 pMlmStartReq->bssType = psessionEntry->bssType;
871
872 /* Fill PE session Id from the session Table */
873 pMlmStartReq->sessionId = psessionEntry->peSessionId;
874
875 if( (pMlmStartReq->bssType == eSIR_BTAMP_STA_MODE) || (pMlmStartReq->bssType == eSIR_BTAMP_AP_MODE )
Jeff Johnson295189b2012-06-20 16:38:30 -0700876 || (pMlmStartReq->bssType == eSIR_INFRA_AP_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -0700877 )
878 {
879 //len = sizeof(tSirMacAddr);
880 //retStatus = wlan_cfgGetStr(pMac, WNI_CFG_STA_ID, (tANI_U8 *) pMlmStartReq->bssId, &len);
881 //if (retStatus != eSIR_SUCCESS)
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700882 //limLog(pMac, LOGP, FL("could not retrive BSSID, retStatus=%d"), retStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -0700883
884 /* Copy the BSSId from sessionTable to mlmStartReq struct */
885 sirCopyMacAddr(pMlmStartReq->bssId,psessionEntry->bssId);
886 }
887
888 else // ibss mode
889 {
890 pMac->lim.gLimIbssCoalescingHappened = false;
891
892 if((retStatus = wlan_cfgGetInt(pMac, WNI_CFG_IBSS_AUTO_BSSID, &autoGenBssId)) != eSIR_SUCCESS)
893 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700894 limLog(pMac, LOGP, FL("Could not retrieve Auto Gen BSSID, retStatus=%d"), retStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -0700895 retCode = eSIR_LOGP_EXCEPTION;
896 goto free;
897 }
898
899 if(!autoGenBssId)
900 {
901 // We're not auto generating BSSID. Instead, get it from session entry
902 sirCopyMacAddr(pMlmStartReq->bssId,psessionEntry->bssId);
903
904 if(pMlmStartReq->bssId[0] & 0x01)
905 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700906 PELOGE(limLog(pMac, LOGE, FL("Request to start IBSS with group BSSID\n Autogenerating the BSSID"));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700907 autoGenBssId = TRUE;
908 }
909 }
910
911 if( autoGenBssId )
912 { //if BSSID is not any uc id. then use locally generated BSSID.
913 //Autogenerate the BSSID
914 limGetRandomBssid( pMac, pMlmStartReq->bssId);
915 pMlmStartReq->bssId[0]= 0x02;
916
917 /* Copy randomly generated BSSID to the session Table */
918 sirCopyMacAddr(psessionEntry->bssId,pMlmStartReq->bssId);
919 }
920 }
921 /* store the channel num in mlmstart req structure */
922 pMlmStartReq->channelNumber = psessionEntry->currentOperChannel;
923 pMlmStartReq->cbMode = pSmeStartBssReq->cbMode;
924 pMlmStartReq->beaconPeriod = psessionEntry->beaconParams.beaconInterval;
925
Jeff Johnson295189b2012-06-20 16:38:30 -0700926 if(psessionEntry->limSystemRole == eLIM_AP_ROLE ){
927 pMlmStartReq->dtimPeriod = psessionEntry->dtimPeriod;
928 pMlmStartReq->wps_state = psessionEntry->wps_state;
929
930 }else
Jeff Johnson295189b2012-06-20 16:38:30 -0700931 {
932 if (wlan_cfgGetInt(pMac, WNI_CFG_DTIM_PERIOD, &val) != eSIR_SUCCESS)
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700933 limLog(pMac, LOGP, FL("could not retrieve DTIM Period"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700934 pMlmStartReq->dtimPeriod = (tANI_U8)val;
935 }
936
937 if (wlan_cfgGetInt(pMac, WNI_CFG_CFP_PERIOD, &val) != eSIR_SUCCESS)
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700938 limLog(pMac, LOGP, FL("could not retrieve Beacon interval"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700939 pMlmStartReq->cfParamSet.cfpPeriod = (tANI_U8)val;
940
941 if (wlan_cfgGetInt(pMac, WNI_CFG_CFP_MAX_DURATION, &val) != eSIR_SUCCESS)
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700942 limLog(pMac, LOGP, FL("could not retrieve CFPMaxDuration"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700943 pMlmStartReq->cfParamSet.cfpMaxDuration = (tANI_U16) val;
944
945 //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 +0530946 vos_mem_copy((void*)&pMlmStartReq->rateSet, (void*)&psessionEntry->rateSet,
Jeff Johnson295189b2012-06-20 16:38:30 -0700947 sizeof(tSirMacRateSet));
948
Jeff Johnson295189b2012-06-20 16:38:30 -0700949 // Now populate the 11n related parameters
950 pMlmStartReq->nwType = psessionEntry->nwType;
Jeff Johnsone7245742012-09-05 17:12:55 -0700951 pMlmStartReq->htCapable = psessionEntry->htCapability;
Jeff Johnson295189b2012-06-20 16:38:30 -0700952 //
953 // FIXME_GEN4 - Determine the appropriate defaults...
954 //
955 pMlmStartReq->htOperMode = pMac->lim.gHTOperMode;
956 pMlmStartReq->dualCTSProtection = pMac->lim.gHTDualCTSProtection; // Unused
Jeff Johnsone7245742012-09-05 17:12:55 -0700957 pMlmStartReq->txChannelWidthSet = psessionEntry->htRecommendedTxWidthSet;
Jeff Johnson295189b2012-06-20 16:38:30 -0700958
959 /* sep26 review */
960 psessionEntry->limRFBand = limGetRFBand(channelNumber);
961
962 // Initialize 11h Enable Flag
963 psessionEntry->lim11hEnable = 0;
964 if((pMlmStartReq->bssType != eSIR_IBSS_MODE) &&
965 (SIR_BAND_5_GHZ == psessionEntry->limRFBand) )
966 {
967 if (wlan_cfgGetInt(pMac, WNI_CFG_11H_ENABLED, &val) != eSIR_SUCCESS)
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700968 limLog(pMac, LOGP, FL("Fail to get WNI_CFG_11H_ENABLED "));
Jeff Johnson295189b2012-06-20 16:38:30 -0700969 psessionEntry->lim11hEnable = val;
970 }
971
972 if (!psessionEntry->lim11hEnable)
973 {
974 if (cfgSetInt(pMac, WNI_CFG_LOCAL_POWER_CONSTRAINT, 0) != eSIR_SUCCESS)
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700975 limLog(pMac, LOGP, FL("Fail to get WNI_CFG_11H_ENABLED "));
Jeff Johnson295189b2012-06-20 16:38:30 -0700976 }
977
Jeff Johnson295189b2012-06-20 16:38:30 -0700978 psessionEntry ->limPrevSmeState = psessionEntry->limSmeState;
979 psessionEntry ->limSmeState = eLIM_SME_WT_START_BSS_STATE;
Jeff Johnsone7245742012-09-05 17:12:55 -0700980 MTRACE(macTrace(pMac, TRACE_CODE_SME_STATE, psessionEntry->peSessionId, psessionEntry ->limSmeState));
Jeff Johnson295189b2012-06-20 16:38:30 -0700981
982 limPostMlmMessage(pMac, LIM_MLM_START_REQ, (tANI_U32 *) pMlmStartReq);
983 return;
984 }
985 else
986 {
987
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700988 limLog(pMac, LOGE, FL("Received unexpected START_BSS_REQ, in state %X"),pMac->lim.gLimSmeState);
Jeff Johnson295189b2012-06-20 16:38:30 -0700989 retCode = eSIR_SME_BSS_ALREADY_STARTED_OR_JOINED;
990 goto end;
991 } // if (pMac->lim.gLimSmeState == eLIM_SME_OFFLINE_STATE)
992
993free:
Jeff Johnsonace91102013-04-05 08:03:18 -0700994 if ((psessionEntry != NULL) &&
995 (psessionEntry->pLimStartBssReq == pSmeStartBssReq))
996 {
997 psessionEntry->pLimStartBssReq = NULL;
998 }
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +0530999 vos_mem_free( pSmeStartBssReq);
1000 vos_mem_free( pMlmStartReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07001001
1002end:
1003
1004 /* This routine should return the sme sessionId and SME transaction Id */
1005 limGetSessionInfo(pMac,(tANI_U8*)pMsgBuf,&smesessionId,&smetransactionId);
1006
1007 if(NULL != psessionEntry)
1008 {
1009 peDeleteSession(pMac,psessionEntry);
1010 psessionEntry = NULL;
1011 }
1012 limSendSmeStartBssRsp(pMac, eWNI_SME_START_BSS_RSP, retCode,psessionEntry,smesessionId,smetransactionId);
1013} /*** end __limHandleSmeStartBssRequest() ***/
1014
1015
1016/**--------------------------------------------------------------
1017\fn __limProcessSmeStartBssReq
1018
1019\brief Wrapper for the function __limHandleSmeStartBssRequest
1020 This message will be defered until softmac come out of
1021 scan mode or if we have detected radar on the current
1022 operating channel.
1023\param pMac
1024\param pMsg
1025
1026\return TRUE - If we consumed the buffer
1027 FALSE - If have defered the message.
1028 ---------------------------------------------------------------*/
1029static tANI_BOOLEAN
1030__limProcessSmeStartBssReq(tpAniSirGlobal pMac, tpSirMsgQ pMsg)
1031{
1032 if (__limIsDeferedMsgForLearn(pMac, pMsg) ||
1033 __limIsDeferedMsgForRadar(pMac, pMsg))
1034 {
1035 /**
1036 * If message defered, buffer is not consumed yet.
1037 * So return false
1038 */
1039 return eANI_BOOLEAN_FALSE;
1040 }
1041
1042 __limHandleSmeStartBssRequest(pMac, (tANI_U32 *) pMsg->bodyptr);
1043 return eANI_BOOLEAN_TRUE;
1044}
1045
1046
1047/**
1048 * limGetRandomBssid()
1049 *
1050 * FUNCTION:This function is called to process generate the random number for bssid
1051 * This function is called to process SME_SCAN_REQ message
1052 * from HDD or upper layer application.
1053 *
1054 * LOGIC:
1055 *
1056 * ASSUMPTIONS:
1057 *
1058 * NOTE:
1059 * 1. geneartes the unique random number for bssid in ibss
1060 *
1061 * @param pMac Pointer to Global MAC structure
1062 * @param *data Pointer to bssid buffer
1063 * @return None
1064 */
1065void limGetRandomBssid(tpAniSirGlobal pMac, tANI_U8 *data)
1066{
1067 tANI_U32 random[2] ;
1068 random[0] = tx_time_get();
1069 random[0] |= (random[0] << 15) ;
1070 random[1] = random[0] >> 1;
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301071 vos_mem_copy( data, (tANI_U8*)random, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07001072}
1073
Ganesh Kondabattinif0fa07c2013-06-11 17:47:49 +05301074static eHalStatus limSendHalStartScanOffloadReq(tpAniSirGlobal pMac,
1075 tpSirSmeScanReq pScanReq)
1076{
1077 tSirScanOffloadReq *pScanOffloadReq;
1078 tANI_U8 *p;
1079 tSirMsgQ msg;
Ganesh Kondabattinif0fa07c2013-06-11 17:47:49 +05301080 tANI_U16 i, len;
1081 tSirRetStatus rc = eSIR_SUCCESS;
1082
1083 /* The tSirScanOffloadReq will reserve the space for first channel,
1084 so allocate the memory for (numChannels - 1) and uIEFieldLen */
1085 len = sizeof(tSirScanOffloadReq) + (pScanReq->channelList.numChannels - 1) +
1086 pScanReq->uIEFieldLen;
1087
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301088 pScanOffloadReq = vos_mem_malloc(len);
1089 if ( NULL == pScanOffloadReq )
Ganesh Kondabattinif0fa07c2013-06-11 17:47:49 +05301090 {
1091 limLog(pMac, LOGE,
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301092 FL("AllocateMemory failed for pScanOffloadReq"));
Ganesh Kondabattinif0fa07c2013-06-11 17:47:49 +05301093 return eHAL_STATUS_FAILURE;
1094 }
1095
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301096 vos_mem_set( (tANI_U8 *) pScanOffloadReq, len, 0);
Ganesh Kondabattinif0fa07c2013-06-11 17:47:49 +05301097
1098 msg.type = WDA_START_SCAN_OFFLOAD_REQ;
1099 msg.bodyptr = pScanOffloadReq;
1100 msg.bodyval = 0;
1101
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301102 vos_mem_copy((tANI_U8 *) pScanOffloadReq->bssId,
Ganesh Kondabattinif0fa07c2013-06-11 17:47:49 +05301103 (tANI_U8*) pScanReq->bssId,
1104 sizeof(tSirMacAddr));
1105
1106 if (pScanReq->numSsid > SIR_SCAN_MAX_NUM_SSID)
1107 {
1108 limLog(pMac, LOGE,
1109 FL("Invalid value (%d) for numSsid"), SIR_SCAN_MAX_NUM_SSID);
Kiet Lamb1233192013-11-28 13:38:20 +05301110 vos_mem_free (pScanOffloadReq);
Ganesh Kondabattinif0fa07c2013-06-11 17:47:49 +05301111 return eHAL_STATUS_FAILURE;
1112 }
1113
1114 pScanOffloadReq->numSsid = pScanReq->numSsid;
1115 for (i = 0; i < pScanOffloadReq->numSsid; i++)
1116 {
1117 pScanOffloadReq->ssId[i].length = pScanReq->ssId[i].length;
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301118 vos_mem_copy((tANI_U8 *) pScanOffloadReq->ssId[i].ssId,
Ganesh Kondabattinif0fa07c2013-06-11 17:47:49 +05301119 (tANI_U8 *) pScanReq->ssId[i].ssId,
1120 pScanOffloadReq->ssId[i].length);
1121 }
1122
1123 pScanOffloadReq->hiddenSsid = pScanReq->hiddenSsid;
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301124 vos_mem_copy((tANI_U8 *) pScanOffloadReq->selfMacAddr,
Ganesh Kondabattinif0fa07c2013-06-11 17:47:49 +05301125 (tANI_U8 *) pScanReq->selfMacAddr,
1126 sizeof(tSirMacAddr));
1127 pScanOffloadReq->bssType = pScanReq->bssType;
1128 pScanOffloadReq->dot11mode = pScanReq->dot11mode;
1129 pScanOffloadReq->scanType = pScanReq->scanType;
1130 pScanOffloadReq->minChannelTime = pScanReq->minChannelTime;
1131 pScanOffloadReq->maxChannelTime = pScanReq->maxChannelTime;
1132 pScanOffloadReq->p2pSearch = pScanReq->p2pSearch;
1133 pScanOffloadReq->sessionId = pScanReq->sessionId;
1134 pScanOffloadReq->channelList.numChannels =
1135 pScanReq->channelList.numChannels;
1136 p = &(pScanOffloadReq->channelList.channelNumber[0]);
1137 for (i = 0; i < pScanOffloadReq->channelList.numChannels; i++)
1138 p[i] = pScanReq->channelList.channelNumber[i];
1139
1140 pScanOffloadReq->uIEFieldLen = pScanReq->uIEFieldLen;
1141 pScanOffloadReq->uIEFieldOffset = len - pScanOffloadReq->uIEFieldLen;
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301142 vos_mem_copy((tANI_U8 *) p + i,
Ganesh Kondabattinif0fa07c2013-06-11 17:47:49 +05301143 (tANI_U8 *) pScanReq + pScanReq->uIEFieldOffset,
1144 pScanOffloadReq->uIEFieldLen);
1145
1146 rc = wdaPostCtrlMsg(pMac, &msg);
1147 if (rc != eSIR_SUCCESS)
1148 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001149 limLog(pMac, LOGE, FL("wdaPostCtrlMsg() return failure"));
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301150 vos_mem_free(pScanOffloadReq);
Ganesh Kondabattinif0fa07c2013-06-11 17:47:49 +05301151 return eHAL_STATUS_FAILURE;
1152 }
1153
1154 return eHAL_STATUS_SUCCESS;
1155}
Jeff Johnson295189b2012-06-20 16:38:30 -07001156
1157/**
1158 * __limProcessSmeScanReq()
1159 *
1160 *FUNCTION:
1161 * This function is called to process SME_SCAN_REQ message
1162 * from HDD or upper layer application.
1163 *
1164 *LOGIC:
1165 *
1166 *ASSUMPTIONS:
1167 *
1168 *NOTE:
1169 * 1. Periodic scanning should be requesting to return unique
1170 * scan results.
1171 *
1172 * @param pMac Pointer to Global MAC structure
1173 * @param *pMsgBuf A pointer to the SME message buffer
1174 * @return None
1175 */
1176
Viral Modid440e682013-03-06 02:25:31 -08001177static void
Jeff Johnson295189b2012-06-20 16:38:30 -07001178__limProcessSmeScanReq(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
1179{
1180 tANI_U32 len;
1181 tLimMlmScanReq *pMlmScanReq;
1182 tpSirSmeScanReq pScanReq;
1183 tANI_U8 i = 0;
1184
1185#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM //FEATURE_WLAN_DIAG_SUPPORT
1186 limDiagEventReport(pMac, WLAN_PE_DIAG_SCAN_REQ_EVENT, NULL, 0, 0);
1187#endif //FEATURE_WLAN_DIAG_SUPPORT
1188
1189 pScanReq = (tpSirSmeScanReq) pMsgBuf;
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001190 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 -07001191 pScanReq->channelList.numChannels,
1192 pScanReq->minChannelTime,
1193 pScanReq->maxChannelTime,
1194 pScanReq->uIEFieldLen,
1195 pScanReq->returnAfterFirstMatch,
1196 pScanReq->returnFreshResults,
1197 pScanReq->returnUniqueResults,
Madan Mohan Koyyalamudi70bb4cb2012-10-18 19:31:25 -07001198 pScanReq->scanType,
1199 pScanReq->backgroundScanMode,
1200 pMac->lim.gLimRspReqd ? 1 : 0);)
Viral Modid86bde22012-12-10 13:09:21 -08001201
1202 /* Since scan req always requires a response, we will overwrite response required here.
1203 * This is added esp to take care of the condition where in p2p go case, we hold the scan req and
1204 * insert single NOA. We send the held scan request to FW later on getting start NOA ind from FW so
1205 * we lose state of the gLimRspReqd flag for the scan req if any other request comes by then.
1206 * e.g. While unit testing, we found when insert single NOA is done, we see a get stats request which turns the flag
1207 * gLimRspReqd to FALSE; now when we actually start the saved scan req for init scan after getting
1208 * NOA started, the gLimRspReqd being a global flag is showing FALSE instead of TRUE value for
1209 * this saved scan req. Since all scan reqs coming to lim require a response, there is no harm in setting
1210 * the global flag gLimRspReqd to TRUE here.
1211 */
1212 pMac->lim.gLimRspReqd = TRUE;
1213
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301214 /*copy the Self MAC address from SmeReq to the globalplace, used for sending probe req*/
Jeff Johnson295189b2012-06-20 16:38:30 -07001215 sirCopyMacAddr(pMac->lim.gSelfMacAddr, pScanReq->selfMacAddr);
1216
1217 /* This routine should return the sme sessionId and SME transaction Id */
1218
1219 if (!limIsSmeScanReqValid(pMac, pScanReq))
1220 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001221 PELOGW(limLog(pMac, LOGW, FL("Received SME_SCAN_REQ with invalid parameters"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001222
1223 if (pMac->lim.gLimRspReqd)
1224 {
1225 pMac->lim.gLimRspReqd = false;
1226
1227 limSendSmeScanRsp(pMac, sizeof(tSirSmeScanRsp), eSIR_SME_INVALID_PARAMETERS, pScanReq->sessionId, pScanReq->transactionId);
1228
1229 } // if (pMac->lim.gLimRspReqd)
1230
1231 return;
1232 }
1233
1234 //if scan is disabled then return as invalid scan request.
1235 //if scan in power save is disabled, and system is in power save mode, then ignore scan request.
1236 if( (pMac->lim.fScanDisabled) || (!pMac->lim.gScanInPowersave && !limIsSystemInActiveState(pMac)) )
1237 {
Leela V Kiran Kumar Reddy Chirala6a458752013-02-16 15:41:27 -08001238 limSendSmeScanRsp(pMac, offsetof(tSirSmeScanRsp,bssDescription[0]), eSIR_SME_INVALID_PARAMETERS, pScanReq->sessionId, pScanReq->transactionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07001239 return;
1240 }
1241
1242
1243 /**
1244 * If scan request is received in idle, joinFailed
1245 * states or in link established state (in STA role)
1246 * or in normal state (in STA-in-IBSS/AP role) with
1247 * 'return fresh scan results' request from HDD or
1248 * it is periodic background scanning request,
1249 * trigger fresh scan request to MLM
1250 */
1251 if (__limFreshScanReqd(pMac, pScanReq->returnFreshResults))
1252 {
Ganesh Kondabattinif0fa07c2013-06-11 17:47:49 +05301253 if (pScanReq->returnFreshResults & SIR_BG_SCAN_PURGE_RESUTLS)
1254 {
1255 // Discard previously cached scan results
1256 limReInitScanResults(pMac);
1257 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001258
Ganesh Kondabattinif0fa07c2013-06-11 17:47:49 +05301259 pMac->lim.gLim24Band11dScanDone = 0;
1260 pMac->lim.gLim50Band11dScanDone = 0;
1261 pMac->lim.gLimReturnAfterFirstMatch =
1262 pScanReq->returnAfterFirstMatch;
1263 pMac->lim.gLimBackgroundScanMode =
1264 pScanReq->backgroundScanMode;
Jeff Johnson295189b2012-06-20 16:38:30 -07001265
Ganesh Kondabattinif0fa07c2013-06-11 17:47:49 +05301266 pMac->lim.gLimReturnUniqueResults =
1267 ((pScanReq->returnUniqueResults) > 0 ? true : false);
1268 /* De-activate Heartbeat timers for connected sessions while
1269 * scan is in progress if the system is in Active mode *
1270 * AND it is not a ROAMING ("background") scan */
1271 if(((ePMM_STATE_BMPS_WAKEUP == pMac->pmm.gPmmState) ||
1272 (ePMM_STATE_READY == pMac->pmm.gPmmState)) &&
1273 (pScanReq->backgroundScanMode != eSIR_ROAMING_SCAN ) &&
1274 (!IS_ACTIVEMODE_OFFLOAD_FEATURE_ENABLE))
1275 {
Jeff Johnson295189b2012-06-20 16:38:30 -07001276 for(i=0;i<pMac->lim.maxBssId;i++)
1277 {
Ganesh Kondabattinif0fa07c2013-06-11 17:47:49 +05301278 if((peFindSessionBySessionId(pMac,i) != NULL) &&
1279 (pMac->lim.gpSession[i].valid == TRUE) &&
1280 (eLIM_MLM_LINK_ESTABLISHED_STATE == pMac->lim.gpSession[i].limMlmState))
1281 {
1282 limHeartBeatDeactivateAndChangeTimer(pMac, peFindSessionBySessionId(pMac,i));
1283 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001284 }
Ganesh Kondabattinif0fa07c2013-06-11 17:47:49 +05301285 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001286
Ganesh Kondabattinif0fa07c2013-06-11 17:47:49 +05301287 if (pMac->fScanOffload)
1288 {
1289 if (eHAL_STATUS_SUCCESS !=
1290 limSendHalStartScanOffloadReq(pMac, pScanReq))
1291 {
1292 limSendSmeScanRsp(pMac,
1293 offsetof(tSirSmeScanRsp, bssDescription[0]),
1294 eSIR_SME_INVALID_PARAMETERS,
1295 pScanReq->sessionId,
1296 pScanReq->transactionId);
1297 return;
1298 }
1299 }
1300 else
1301 {
1302
1303 /*Change Global SME state */
1304 /* Store the previous SME state */
1305 pMac->lim.gLimPrevSmeState = pMac->lim.gLimSmeState;
1306 pMac->lim.gLimSmeState = eLIM_SME_WT_SCAN_STATE;
1307 MTRACE(macTrace(pMac, TRACE_CODE_SME_STATE, pScanReq->sessionId, pMac->lim.gLimSmeState));
1308
1309 if (pScanReq->channelList.numChannels == 0)
1310 {
1311 tANI_U32 cfg_len;
1312 // Scan all channels
1313 len = sizeof(tLimMlmScanReq) +
Jeff Johnson295189b2012-06-20 16:38:30 -07001314 (sizeof( pScanReq->channelList.channelNumber ) * (WNI_CFG_VALID_CHANNEL_LIST_LEN - 1)) +
1315 pScanReq->uIEFieldLen;
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301316 pMlmScanReq = vos_mem_malloc(len);
1317 if ( NULL == pMlmScanReq )
Ganesh Kondabattinif0fa07c2013-06-11 17:47:49 +05301318 {
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301319 // Log error
1320 limLog(pMac, LOGP,
1321 FL("call to AllocateMemory failed for mlmScanReq (%d)"), len);
Jeff Johnson295189b2012-06-20 16:38:30 -07001322
Ganesh Kondabattinif0fa07c2013-06-11 17:47:49 +05301323 return;
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301324 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001325
Ganesh Kondabattinif0fa07c2013-06-11 17:47:49 +05301326 // Initialize this buffer
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301327 vos_mem_set( (tANI_U8 *) pMlmScanReq, len, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07001328
Ganesh Kondabattinif0fa07c2013-06-11 17:47:49 +05301329 cfg_len = WNI_CFG_VALID_CHANNEL_LIST_LEN;
1330 if (wlan_cfgGetStr(pMac, WNI_CFG_VALID_CHANNEL_LIST,
Jeff Johnson295189b2012-06-20 16:38:30 -07001331 pMlmScanReq->channelList.channelNumber,
1332 &cfg_len) != eSIR_SUCCESS)
Ganesh Kondabattinif0fa07c2013-06-11 17:47:49 +05301333 {
1334 /**
1335 * Could not get Valid channel list from CFG.
1336 * Log error.
1337 */
1338 limLog(pMac, LOGP,
1339 FL("could not retrieve Valid channel list"));
1340 }
1341 pMlmScanReq->channelList.numChannels = (tANI_U8) cfg_len;
1342 }
1343 else
1344 {
1345 len = sizeof( tLimMlmScanReq ) - sizeof( pScanReq->channelList.channelNumber ) +
1346 (sizeof( pScanReq->channelList.channelNumber ) * pScanReq->channelList.numChannels ) +
1347 pScanReq->uIEFieldLen;
Jeff Johnson295189b2012-06-20 16:38:30 -07001348
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301349 pMlmScanReq = vos_mem_malloc(len);
1350 if ( NULL == pMlmScanReq )
Ganesh Kondabattinif0fa07c2013-06-11 17:47:49 +05301351 {
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301352 // Log error
1353 limLog(pMac, LOGP,
1354 FL("call to AllocateMemory failed for mlmScanReq(%d)"), len);
Jeff Johnson295189b2012-06-20 16:38:30 -07001355
Ganesh Kondabattinif0fa07c2013-06-11 17:47:49 +05301356 return;
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301357 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001358
Ganesh Kondabattinif0fa07c2013-06-11 17:47:49 +05301359 // Initialize this buffer
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301360 vos_mem_set( (tANI_U8 *) pMlmScanReq, len, 0);
Ganesh Kondabattinif0fa07c2013-06-11 17:47:49 +05301361 pMlmScanReq->channelList.numChannels =
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301362 pScanReq->channelList.numChannels;
Jeff Johnson295189b2012-06-20 16:38:30 -07001363
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301364 vos_mem_copy( pMlmScanReq->channelList.channelNumber,
1365 pScanReq->channelList.channelNumber,
1366 pScanReq->channelList.numChannels);
1367 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001368
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301369 pMlmScanReq->uIEFieldLen = pScanReq->uIEFieldLen;
1370 pMlmScanReq->uIEFieldOffset = len - pScanReq->uIEFieldLen;
1371 if(pScanReq->uIEFieldLen)
1372 {
1373 vos_mem_copy( (tANI_U8 *)pMlmScanReq+ pMlmScanReq->uIEFieldOffset,
1374 (tANI_U8 *)pScanReq+(pScanReq->uIEFieldOffset),
1375 pScanReq->uIEFieldLen);
1376 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001377
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301378 pMlmScanReq->bssType = pScanReq->bssType;
1379 vos_mem_copy( pMlmScanReq->bssId,
1380 pScanReq->bssId,
1381 sizeof(tSirMacAddr));
1382 pMlmScanReq->numSsid = pScanReq->numSsid;
Jeff Johnson295189b2012-06-20 16:38:30 -07001383
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301384 i = 0;
1385 while (i < pMlmScanReq->numSsid)
1386 {
1387 vos_mem_copy( (tANI_U8 *) &pMlmScanReq->ssId[i],
Jeff Johnson295189b2012-06-20 16:38:30 -07001388 (tANI_U8 *) &pScanReq->ssId[i],
1389 pScanReq->ssId[i].length + 1);
1390
Ganesh Kondabattinif0fa07c2013-06-11 17:47:49 +05301391 i++;
1392 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001393
Jeff Johnson295189b2012-06-20 16:38:30 -07001394
Ganesh Kondabattinif0fa07c2013-06-11 17:47:49 +05301395 pMlmScanReq->scanType = pScanReq->scanType;
1396 pMlmScanReq->backgroundScanMode = pScanReq->backgroundScanMode;
1397 pMlmScanReq->minChannelTime = pScanReq->minChannelTime;
1398 pMlmScanReq->maxChannelTime = pScanReq->maxChannelTime;
1399 pMlmScanReq->minChannelTimeBtc = pScanReq->minChannelTimeBtc;
1400 pMlmScanReq->maxChannelTimeBtc = pScanReq->maxChannelTimeBtc;
1401 pMlmScanReq->dot11mode = pScanReq->dot11mode;
1402 pMlmScanReq->p2pSearch = pScanReq->p2pSearch;
Jeff Johnson295189b2012-06-20 16:38:30 -07001403
Ganesh Kondabattinif0fa07c2013-06-11 17:47:49 +05301404 //Store the smeSessionID and transaction ID for later use.
1405 pMac->lim.gSmeSessionId = pScanReq->sessionId;
1406 pMac->lim.gTransactionId = pScanReq->transactionId;
Jeff Johnson295189b2012-06-20 16:38:30 -07001407
Ganesh Kondabattinif0fa07c2013-06-11 17:47:49 +05301408 // Issue LIM_MLM_SCAN_REQ to MLM
1409 limPostMlmMessage(pMac, LIM_MLM_SCAN_REQ, (tANI_U32 *) pMlmScanReq);
1410 }
1411 } // if ((pMac->lim.gLimSmeState == eLIM_SME_IDLE_STATE) || ...
Jeff Johnson295189b2012-06-20 16:38:30 -07001412
1413 else
1414 {
1415 /// In all other cases return 'cached' scan results
1416 if ((pMac->lim.gLimRspReqd) || pMac->lim.gLimReportBackgroundScanResults)
1417 {
1418 tANI_U16 scanRspLen = sizeof(tSirSmeScanRsp);
1419
1420 pMac->lim.gLimRspReqd = false;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07001421#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
1422 if (pScanReq->returnFreshResults & SIR_BG_SCAN_RETURN_LFR_CACHED_RESULTS)
Jeff Johnson295189b2012-06-20 16:38:30 -07001423 {
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07001424 pMac->lim.gLimSmeLfrScanResultLength = pMac->lim.gLimMlmLfrScanResultLength;
1425 if (pMac->lim.gLimSmeLfrScanResultLength == 0)
1426 {
1427 limSendSmeLfrScanRsp(pMac, scanRspLen,
1428 eSIR_SME_SUCCESS,
1429 pScanReq->sessionId,
1430 pScanReq->transactionId);
1431 }
1432 else
1433 {
1434 scanRspLen = sizeof(tSirSmeScanRsp) +
1435 pMac->lim.gLimSmeLfrScanResultLength -
1436 sizeof(tSirBssDescription);
1437 limSendSmeLfrScanRsp(pMac, scanRspLen, eSIR_SME_SUCCESS,
1438 pScanReq->sessionId, pScanReq->transactionId);
1439 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001440 }
1441 else
1442 {
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07001443#endif
1444 if (pMac->lim.gLimSmeScanResultLength == 0)
1445 {
1446 limSendSmeScanRsp(pMac, scanRspLen, eSIR_SME_SUCCESS,
1447 pScanReq->sessionId, pScanReq->transactionId);
1448 }
1449 else
1450 {
1451 scanRspLen = sizeof(tSirSmeScanRsp) +
1452 pMac->lim.gLimSmeScanResultLength -
1453 sizeof(tSirBssDescription);
1454 limSendSmeScanRsp(pMac, scanRspLen, eSIR_SME_SUCCESS,
1455 pScanReq->sessionId, pScanReq->transactionId);
1456 }
1457#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
Jeff Johnson295189b2012-06-20 16:38:30 -07001458 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07001459#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001460
1461 if (pScanReq->returnFreshResults & SIR_BG_SCAN_PURGE_RESUTLS)
1462 {
1463 // Discard previously cached scan results
1464 limReInitScanResults(pMac);
1465 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07001466#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
1467 if (pScanReq->returnFreshResults & SIR_BG_SCAN_PURGE_LFR_RESULTS)
1468 {
1469 // Discard previously cached scan results
1470 limReInitLfrScanResults(pMac);
1471 }
1472#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001473
1474 } // if (pMac->lim.gLimRspReqd)
1475 } // else ((pMac->lim.gLimSmeState == eLIM_SME_IDLE_STATE) || ...
1476
Jeff Johnson295189b2012-06-20 16:38:30 -07001477#ifdef BACKGROUND_SCAN_ENABLED
1478 // start background scans if needed
1479 // There is a bug opened against softmac. Need to enable when the bug is fixed.
1480 __limBackgroundScanInitiate(pMac);
1481#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001482
1483} /*** end __limProcessSmeScanReq() ***/
1484
Jeff Johnsone7245742012-09-05 17:12:55 -07001485#ifdef FEATURE_OEM_DATA_SUPPORT
Jeff Johnson295189b2012-06-20 16:38:30 -07001486
Jeff Johnsone7245742012-09-05 17:12:55 -07001487static void __limProcessSmeOemDataReq(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
1488{
1489 tpSirOemDataReq pOemDataReq;
1490 tLimMlmOemDataReq* pMlmOemDataReq;
1491
1492 pOemDataReq = (tpSirOemDataReq) pMsgBuf;
1493
1494 //post the lim mlm message now
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301495 pMlmOemDataReq = vos_mem_malloc(sizeof(tLimMlmOemDataReq));
1496 if ( NULL == pMlmOemDataReq )
Jeff Johnsone7245742012-09-05 17:12:55 -07001497 {
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301498 limLog(pMac, LOGP, FL("AllocateMemory failed for mlmOemDataReq"));
Jeff Johnsone7245742012-09-05 17:12:55 -07001499 return;
1500 }
1501
1502 //Initialize this buffer
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301503 vos_mem_set( pMlmOemDataReq, (sizeof(tLimMlmOemDataReq)), 0);
Jeff Johnsone7245742012-09-05 17:12:55 -07001504
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301505 vos_mem_copy( pMlmOemDataReq->selfMacAddr, pOemDataReq->selfMacAddr,
1506 sizeof(tSirMacAddr));
1507 vos_mem_copy( pMlmOemDataReq->oemDataReq, pOemDataReq->oemDataReq,
1508 OEM_DATA_REQ_SIZE);
Jeff Johnsone7245742012-09-05 17:12:55 -07001509
1510 //Issue LIM_MLM_OEM_DATA_REQ to MLM
1511 limPostMlmMessage(pMac, LIM_MLM_OEM_DATA_REQ, (tANI_U32*)pMlmOemDataReq);
1512
1513 return;
1514
1515} /*** end __limProcessSmeOemDataReq() ***/
1516
1517#endif //FEATURE_OEM_DATA_SUPPORT
Jeff Johnson295189b2012-06-20 16:38:30 -07001518
Gopichand Nakkalac178ac82013-05-30 19:53:39 +05301519/**
1520 * __limProcessClearDfsChannelList()
1521 *
1522 *FUNCTION:
1523 *Clear DFS channel list when country is changed/aquired.
1524.*This message is sent from SME.
1525 *
1526 *LOGIC:
1527 *
1528 *ASSUMPTIONS:
1529 *
1530 *NOTE:
1531 *
1532 * @param pMac Pointer to Global MAC structure
1533 * @param *pMsgBuf A pointer to the SME message buffer
1534 * @return None
1535 */
1536static void __limProcessClearDfsChannelList(tpAniSirGlobal pMac,
1537 tpSirMsgQ pMsg)
1538{
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301539 vos_mem_set( &pMac->lim.dfschannelList,
1540 sizeof(tSirDFSChannelList), 0);
Gopichand Nakkalac178ac82013-05-30 19:53:39 +05301541}
Jeff Johnson295189b2012-06-20 16:38:30 -07001542
1543/**
1544 * __limProcessSmeJoinReq()
1545 *
1546 *FUNCTION:
1547 * This function is called to process SME_JOIN_REQ message
1548 * from HDD or upper layer application.
1549 *
1550 *LOGIC:
1551 *
1552 *ASSUMPTIONS:
1553 *
1554 *NOTE:
1555 *
1556 * @param pMac Pointer to Global MAC structure
1557 * @param *pMsgBuf A pointer to the SME message buffer
1558 * @return None
1559 */
Jeff Johnson295189b2012-06-20 16:38:30 -07001560static void
1561__limProcessSmeJoinReq(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
1562{
1563 // tANI_U8 *pBuf;
1564 //tANI_U32 len;
1565// tSirMacAddr currentBssId;
1566 tpSirSmeJoinReq pSmeJoinReq = NULL;
1567 tLimMlmJoinReq *pMlmJoinReq;
1568 tSirResultCodes retCode = eSIR_SME_SUCCESS;
1569 tANI_U32 val = 0;
1570 tANI_U16 nSize;
1571 tANI_U8 sessionId;
1572 tpPESession psessionEntry = NULL;
1573 tANI_U8 smesessionId;
1574 tANI_U16 smetransactionId;
1575 tPowerdBm localPowerConstraint = 0, regMax = 0;
1576
1577#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM //FEATURE_WLAN_DIAG_SUPPORT
1578 //Not sending any session, since it is not created yet. The response whould have correct state.
1579 limDiagEventReport(pMac, WLAN_PE_DIAG_JOIN_REQ_EVENT, NULL, 0, 0);
1580#endif //FEATURE_WLAN_DIAG_SUPPORT
1581
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001582 PELOG1(limLog(pMac, LOG1, FL("Received SME_JOIN_REQ"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001583
1584#ifdef WLAN_FEATURE_VOWIFI
1585 /* Need to read the CFG here itself as this is used in limExtractAPCapability() below.
1586 * This CFG is actually read in rrmUpdateConfig() which is called later. Because this is not
1587 * read, RRM related path before calling rrmUpdateConfig() is not getting executed causing issues
1588 * like not honoring power constraint on 1st association after driver loading. */
1589 if (wlan_cfgGetInt(pMac, WNI_CFG_RRM_ENABLED, &val) != eSIR_SUCCESS)
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001590 limLog(pMac, LOGP, FL("cfg get rrm enabled failed"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001591 pMac->rrm.rrmPEContext.rrmEnable = (val) ? 1 : 0;
1592 val = 0;
1593#endif /* WLAN_FEATURE_VOWIFI */
1594
1595 /**
1596 * Expect Join request in idle state.
1597 * Reassociate request is expected in link established state.
1598 */
1599
1600 /* Global SME and LIM states are not defined yet for BT-AMP Support */
1601 if(pMac->lim.gLimSmeState == eLIM_SME_IDLE_STATE)
1602 {
1603 nSize = __limGetSmeJoinReqSizeForAlloc((tANI_U8*) pMsgBuf);
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301604
1605 pSmeJoinReq = vos_mem_malloc(nSize);
1606 if ( NULL == pSmeJoinReq )
Jeff Johnson295189b2012-06-20 16:38:30 -07001607 {
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301608 limLog(pMac, LOGP, FL("call to AllocateMemory failed for pSmeJoinReq"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001609 retCode = eSIR_SME_RESOURCES_UNAVAILABLE;
1610 goto end;
1611 }
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301612 (void) vos_mem_set((void *) pSmeJoinReq, nSize, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07001613
Jeff Johnson295189b2012-06-20 16:38:30 -07001614 if ((limJoinReqSerDes(pMac, pSmeJoinReq, (tANI_U8 *)pMsgBuf) == eSIR_FAILURE) ||
1615 (!limIsSmeJoinReqValid(pMac, pSmeJoinReq)))
1616 {
1617 /// Received invalid eWNI_SME_JOIN_REQ
1618 // Log the event
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001619 limLog(pMac, LOGW, FL("received SME_JOIN_REQ with invalid data"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001620 retCode = eSIR_SME_INVALID_PARAMETERS;
1621 goto end;
1622 }
1623
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301624 //pMac->lim.gpLimJoinReq = pSmeJoinReq; TO SUPPORT BT-AMP, review os sep 23
Jeff Johnson295189b2012-06-20 16:38:30 -07001625
1626 /* check for the existence of start BSS session */
1627#ifdef FIXME_GEN6
1628 if(pSmeJoinReq->bsstype == eSIR_BTAMP_AP_MODE)
1629 {
1630 if(peValidateBtJoinRequest(pMac)!= TRUE)
1631 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001632 limLog(pMac, LOGW, FL("Start Bss session not present::SME_JOIN_REQ in unexpected state"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001633 retCode = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
1634 psessionEntry = NULL;
1635 goto end;
1636 }
1637 }
1638
1639#endif
1640
1641
1642 if((psessionEntry = peFindSessionByBssid(pMac,pSmeJoinReq->bssDescription.bssId,&sessionId)) != NULL)
1643 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001644 limLog(pMac, LOGE, FL("Session Already exists for given BSSID"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001645
1646 if(psessionEntry->limSmeState == eLIM_SME_LINK_EST_STATE)
1647 {
1648 // Received eWNI_SME_JOIN_REQ for same
1649 // BSS as currently associated.
1650 // Log the event and send success
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001651 PELOGW(limLog(pMac, LOGW, FL("Received SME_JOIN_REQ for currently joined BSS"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001652 /// Send Join success response to host
Deepthi Gowrif3e27252013-12-11 20:50:01 +05301653 retCode = eSIR_SME_ALREADY_JOINED_A_BSS;
1654 psessionEntry = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07001655 goto end;
1656 }
1657 else
1658 {
1659 retCode = eSIR_SME_REFUSED;
1660 psessionEntry = NULL;
1661 goto end;
1662 }
1663 }
1664 else /* Session Entry does not exist for given BSSId */
1665 {
1666 /* Try to Create a new session */
1667 if((psessionEntry = peCreateSession(pMac,pSmeJoinReq->bssDescription.bssId,&sessionId, pMac->lim.maxStation)) == NULL)
1668 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001669 limLog(pMac, LOGE, FL("Session Can not be created "));
Jeff Johnson295189b2012-06-20 16:38:30 -07001670 retCode = eSIR_SME_RESOURCES_UNAVAILABLE;
1671 goto end;
1672 }
1673 }
Jeff Johnsone7245742012-09-05 17:12:55 -07001674 handleHTCapabilityandHTInfo(pMac, psessionEntry);
krunal soni5afa96c2013-09-06 22:19:02 -07001675 psessionEntry->isAmsduSupportInAMPDU = pSmeJoinReq->isAmsduSupportInAMPDU;
Jeff Johnsone7245742012-09-05 17:12:55 -07001676
Jeff Johnson295189b2012-06-20 16:38:30 -07001677 /* Store Session related parameters */
1678 /* Store PE session Id in session Table */
1679 psessionEntry->peSessionId = sessionId;
1680
1681 /* store the smejoin req handle in session table */
1682 psessionEntry->pLimJoinReq = pSmeJoinReq;
1683
1684 /* Store SME session Id in sessionTable */
1685 psessionEntry->smeSessionId = pSmeJoinReq->sessionId;
1686
1687 /* Store SME transaction Id in session Table */
1688 psessionEntry->transactionId = pSmeJoinReq->transactionId;
1689
1690 /* Store beaconInterval */
1691 psessionEntry->beaconParams.beaconInterval = pSmeJoinReq->bssDescription.beaconInterval;
1692
1693 /* Copying of bssId is already done, while creating session */
1694 //sirCopyMacAddr(psessionEntry->bssId,pSmeJoinReq->bssId);
1695 sirCopyMacAddr(psessionEntry->selfMacAddr,pSmeJoinReq->selfMacAddr);
1696 psessionEntry->bssType = pSmeJoinReq->bsstype;
1697
1698 psessionEntry->statypeForBss = STA_ENTRY_PEER;
Sandeep Puligillaaea98a22013-12-04 13:36:32 +05301699 psessionEntry->limWmeEnabled = pSmeJoinReq->isWMEenabled;
1700 psessionEntry->limQosEnabled = pSmeJoinReq->isQosEnabled;
Jeff Johnson295189b2012-06-20 16:38:30 -07001701
1702 /* Copy the dot 11 mode in to the session table */
1703
1704 psessionEntry->dot11mode = pSmeJoinReq->dot11mode;
1705 psessionEntry->nwType = pSmeJoinReq->bssDescription.nwType;
Jeff Johnsone7245742012-09-05 17:12:55 -07001706#ifdef WLAN_FEATURE_11AC
1707 psessionEntry->vhtCapability = IS_DOT11_MODE_VHT(psessionEntry->dot11mode);
Jeff Johnson32d95a32012-09-10 13:15:23 -07001708 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO_MED,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001709 "***__limProcessSmeJoinReq: vhtCapability=%d****",psessionEntry->vhtCapability);
Shailender Karmuchi08f87c22013-01-17 12:51:24 -08001710 if (psessionEntry->vhtCapability )
1711 {
1712 psessionEntry->txBFIniFeatureEnabled = pSmeJoinReq->txBFIniFeatureEnabled;
1713
1714 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO_MED,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001715 "***__limProcessSmeJoinReq: txBFIniFeatureEnabled=%d****",
Shailender Karmuchi08f87c22013-01-17 12:51:24 -08001716 psessionEntry->txBFIniFeatureEnabled);
1717
1718 if( psessionEntry->txBFIniFeatureEnabled )
1719 {
1720 if (cfgSetInt(pMac, WNI_CFG_VHT_SU_BEAMFORMEE_CAP, psessionEntry->txBFIniFeatureEnabled)
1721 != eSIR_SUCCESS)
1722 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001723 limLog(pMac, LOGP, FL("could not set WNI_CFG_VHT_SU_BEAMFORMEE_CAP at CFG"));
Shailender Karmuchi08f87c22013-01-17 12:51:24 -08001724 retCode = eSIR_LOGP_EXCEPTION;
1725 goto end;
1726 }
Shailender Karmuchicc3fe442013-02-16 18:18:33 -08001727 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO_MED,
Leela V Kiran Kumar Reddy Chirala6a458752013-02-16 15:41:27 -08001728 "***__limProcessSmeJoinReq: txBFCsnValue=%d****", pSmeJoinReq->txBFCsnValue);
Shailender Karmuchicc3fe442013-02-16 18:18:33 -08001729
1730 if (cfgSetInt(pMac, WNI_CFG_VHT_CSN_BEAMFORMEE_ANT_SUPPORTED, pSmeJoinReq->txBFCsnValue)
Shailender Karmuchi08f87c22013-01-17 12:51:24 -08001731 != eSIR_SUCCESS)
1732 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001733 limLog(pMac, LOGP, FL("could not set WNI_CFG_VHT_CSN_BEAMFORMEE_ANT_SUPPORTED at CFG"));
Shailender Karmuchi08f87c22013-01-17 12:51:24 -08001734 retCode = eSIR_LOGP_EXCEPTION;
1735 goto end;
1736 }
1737 }
1738 }
1739
Jeff Johnsone7245742012-09-05 17:12:55 -07001740#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001741
1742 /*Phy mode*/
1743 psessionEntry->gLimPhyMode = pSmeJoinReq->bssDescription.nwType;
1744
1745 /* Copy The channel Id to the session Table */
1746 psessionEntry->currentOperChannel = pSmeJoinReq->bssDescription.channelId;
Jeff Johnsone7245742012-09-05 17:12:55 -07001747 psessionEntry->htSupportedChannelWidthSet = (pSmeJoinReq->cbMode)?1:0; // This is already merged value of peer and self - done by csr in csrGetCBModeFromIes
1748 psessionEntry->htRecommendedTxWidthSet = psessionEntry->htSupportedChannelWidthSet;
1749 psessionEntry->htSecondaryChannelOffset = pSmeJoinReq->cbMode;
Jeff Johnson295189b2012-06-20 16:38:30 -07001750
Chet Lanctot186b5732013-03-18 10:26:30 -07001751 /* Record if management frames need to be protected */
1752#ifdef WLAN_FEATURE_11W
1753 if(eSIR_ED_AES_128_CMAC == pSmeJoinReq->MgmtEncryptionType)
1754 {
1755 psessionEntry->limRmfEnabled = 1;
1756 }
1757 else
1758 {
1759 psessionEntry->limRmfEnabled = 0;
1760 }
1761#endif
1762
krunal soni8d13b092013-07-19 13:23:29 -07001763#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM
1764 psessionEntry->rssi = pSmeJoinReq->bssDescription.rssi;
1765#endif
1766
Jeff Johnson295189b2012-06-20 16:38:30 -07001767 /*Store Persona */
1768 psessionEntry->pePersona = pSmeJoinReq->staPersona;
1769 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
Jeff Johnsone7245742012-09-05 17:12:55 -07001770 FL("PE PERSONA=%d cbMode %u"), psessionEntry->pePersona, pSmeJoinReq->cbMode);
Jeff Johnson295189b2012-06-20 16:38:30 -07001771
1772 /* Copy the SSID from smejoinreq to session entry */
1773 psessionEntry->ssId.length = pSmeJoinReq->ssId.length;
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301774 vos_mem_copy( psessionEntry->ssId.ssId,
1775 pSmeJoinReq->ssId.ssId, psessionEntry->ssId.length);
1776
1777 // Determin 11r or CCX connection based on input from SME
1778 // which inturn is dependent on the profile the user wants to connect
1779 // to, So input is coming from supplicant
Jeff Johnson295189b2012-06-20 16:38:30 -07001780#ifdef WLAN_FEATURE_VOWIFI_11R
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301781 psessionEntry->is11Rconnection = pSmeJoinReq->is11Rconnection;
Jeff Johnson295189b2012-06-20 16:38:30 -07001782#endif
1783#ifdef FEATURE_WLAN_CCX
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301784 psessionEntry->isCCXconnection = pSmeJoinReq->isCCXconnection;
Jeff Johnson295189b2012-06-20 16:38:30 -07001785#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001786#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_CCX || defined(FEATURE_WLAN_LFR)
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301787 psessionEntry->isFastTransitionEnabled = pSmeJoinReq->isFastTransitionEnabled;
Jeff Johnson295189b2012-06-20 16:38:30 -07001788#endif
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301789
Jeff Johnson43971f52012-07-17 12:26:56 -07001790#ifdef FEATURE_WLAN_LFR
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301791 psessionEntry->isFastRoamIniFeatureEnabled = pSmeJoinReq->isFastRoamIniFeatureEnabled;
Jeff Johnson43971f52012-07-17 12:26:56 -07001792#endif
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301793 psessionEntry->txLdpcIniFeatureEnabled = pSmeJoinReq->txLdpcIniFeatureEnabled;
Gopichand Nakkalab2d2c312013-01-04 11:41:02 -08001794
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301795 if (psessionEntry->bssType == eSIR_INFRASTRUCTURE_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07001796 {
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301797 psessionEntry->limSystemRole = eLIM_STA_ROLE;
1798 }
1799 else if (psessionEntry->bssType == eSIR_BTAMP_AP_MODE)
1800 {
1801 psessionEntry->limSystemRole = eLIM_BT_AMP_STA_ROLE;
1802 }
1803 else
1804 {
1805 /* Throw an error and return and make sure to delete the session.*/
1806 limLog(pMac, LOGW, FL("received SME_JOIN_REQ with invalid bss type"));
1807 retCode = eSIR_SME_INVALID_PARAMETERS;
1808 goto end;
1809 }
1810
1811 if (pSmeJoinReq->addIEScan.length)
1812 {
1813 vos_mem_copy( &psessionEntry->pLimJoinReq->addIEScan,
Jeff Johnson295189b2012-06-20 16:38:30 -07001814 &pSmeJoinReq->addIEScan, sizeof(tSirAddie));
1815 }
1816
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301817 if (pSmeJoinReq->addIEAssoc.length)
Jeff Johnson295189b2012-06-20 16:38:30 -07001818 {
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301819 vos_mem_copy( &psessionEntry->pLimJoinReq->addIEAssoc,
Jeff Johnson295189b2012-06-20 16:38:30 -07001820 &pSmeJoinReq->addIEAssoc, sizeof(tSirAddie));
1821 }
1822
Jeff Johnson295189b2012-06-20 16:38:30 -07001823 val = sizeof(tLimMlmJoinReq) + psessionEntry->pLimJoinReq->bssDescription.length + 2;
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301824 pMlmJoinReq = vos_mem_malloc(val);
1825 if ( NULL == pMlmJoinReq )
Jeff Johnson295189b2012-06-20 16:38:30 -07001826 {
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301827 limLog(pMac, LOGP, FL("call to AllocateMemory failed for mlmJoinReq"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001828 return;
1829 }
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301830 (void) vos_mem_set((void *) pMlmJoinReq, val, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07001831
1832 /* PE SessionId is stored as a part of JoinReq*/
1833 pMlmJoinReq->sessionId = psessionEntry->peSessionId;
1834
1835 if (wlan_cfgGetInt(pMac, WNI_CFG_JOIN_FAILURE_TIMEOUT, (tANI_U32 *) &pMlmJoinReq->joinFailureTimeout)
1836 != eSIR_SUCCESS)
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001837 limLog(pMac, LOGP, FL("could not retrieve JoinFailureTimer value"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001838
1839 /* copy operational rate from psessionEntry*/
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301840 vos_mem_copy((void*)&psessionEntry->rateSet, (void*)&pSmeJoinReq->operationalRateSet,
Jeff Johnson295189b2012-06-20 16:38:30 -07001841 sizeof(tSirMacRateSet));
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301842 vos_mem_copy((void*)&psessionEntry->extRateSet, (void*)&pSmeJoinReq->extendedRateSet,
Jeff Johnson295189b2012-06-20 16:38:30 -07001843 sizeof(tSirMacRateSet));
1844 //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 +05301845 vos_mem_copy((void*)&pMlmJoinReq->operationalRateSet, (void*)&psessionEntry->rateSet,
Jeff Johnson295189b2012-06-20 16:38:30 -07001846 sizeof(tSirMacRateSet));
1847
1848 psessionEntry->encryptType = pSmeJoinReq->UCEncryptionType;
1849
Jeff Johnson295189b2012-06-20 16:38:30 -07001850 pMlmJoinReq->bssDescription.length = psessionEntry->pLimJoinReq->bssDescription.length;
1851
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301852 vos_mem_copy((tANI_U8 *) &pMlmJoinReq->bssDescription.bssId,
Jeff Johnson295189b2012-06-20 16:38:30 -07001853 (tANI_U8 *) &psessionEntry->pLimJoinReq->bssDescription.bssId,
1854 psessionEntry->pLimJoinReq->bssDescription.length + 2);
1855
Jeff Johnson295189b2012-06-20 16:38:30 -07001856 psessionEntry->limCurrentBssCaps =
Jeff Johnsone7245742012-09-05 17:12:55 -07001857 psessionEntry->pLimJoinReq->bssDescription.capabilityInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07001858
Jeff Johnsone7245742012-09-05 17:12:55 -07001859 regMax = cfgGetRegulatoryMaxTransmitPower( pMac, psessionEntry->currentOperChannel );
1860 localPowerConstraint = regMax;
1861 limExtractApCapability( pMac,
1862 (tANI_U8 *) psessionEntry->pLimJoinReq->bssDescription.ieFields,
1863 limGetIElenFromBssDescription(&psessionEntry->pLimJoinReq->bssDescription),
1864 &psessionEntry->limCurrentBssQosCaps,
1865 &psessionEntry->limCurrentBssPropCap,
1866 &pMac->lim.gLimCurrentBssUapsd //TBD-RAJESH make gLimCurrentBssUapsd this session specific
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07001867 , &localPowerConstraint,
1868 psessionEntry
Jeff Johnsone7245742012-09-05 17:12:55 -07001869 );
Jeff Johnson295189b2012-06-20 16:38:30 -07001870#ifdef FEATURE_WLAN_CCX
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001871 psessionEntry->maxTxPower = limGetMaxTxPower(regMax, localPowerConstraint, pMac->roam.configParam.nTxPowerCap);
Jeff Johnson295189b2012-06-20 16:38:30 -07001872#else
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301873 psessionEntry->maxTxPower = VOS_MIN( regMax, (localPowerConstraint) );
Jeff Johnson295189b2012-06-20 16:38:30 -07001874#endif
1875#if defined WLAN_VOWIFI_DEBUG
1876 limLog( pMac, LOGE, "Regulatory max = %d, local power constraint = %d, max tx = %d", regMax, localPowerConstraint, psessionEntry->maxTxPower );
1877#endif
1878
1879 if (pMac->lim.gLimCurrentBssUapsd)
1880 {
1881 pMac->lim.gUapsdPerAcBitmask = psessionEntry->pLimJoinReq->uapsdPerAcBitmask;
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001882 limLog( pMac, LOG1, FL("UAPSD flag for all AC - 0x%2x"), pMac->lim.gUapsdPerAcBitmask);
Jeff Johnson295189b2012-06-20 16:38:30 -07001883
1884 // resetting the dynamic uapsd mask
1885 pMac->lim.gUapsdPerAcDeliveryEnableMask = 0;
1886 pMac->lim.gUapsdPerAcTriggerEnableMask = 0;
1887 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001888
1889 psessionEntry->limRFBand = limGetRFBand(psessionEntry->currentOperChannel);
1890
1891 // Initialize 11h Enable Flag
1892 if(SIR_BAND_5_GHZ == psessionEntry->limRFBand)
1893 {
1894 if (wlan_cfgGetInt(pMac, WNI_CFG_11H_ENABLED, &val) != eSIR_SUCCESS)
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001895 limLog(pMac, LOGP, FL("Fail to get WNI_CFG_11H_ENABLED "));
Jeff Johnson295189b2012-06-20 16:38:30 -07001896 psessionEntry->lim11hEnable = val;
1897 }
1898 else
1899 psessionEntry->lim11hEnable = 0;
1900
1901 //To care of the scenario when STA transitions from IBSS to Infrastructure mode.
1902 pMac->lim.gLimIbssCoalescingHappened = false;
1903
Jeff Johnsone7245742012-09-05 17:12:55 -07001904 psessionEntry->limPrevSmeState = psessionEntry->limSmeState;
1905 psessionEntry->limSmeState = eLIM_SME_WT_JOIN_STATE;
1906 MTRACE(macTrace(pMac, TRACE_CODE_SME_STATE, psessionEntry->peSessionId, psessionEntry->limSmeState));
Jeff Johnson295189b2012-06-20 16:38:30 -07001907
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001908 PELOG1(limLog(pMac, LOG1, FL("SME JoinReq: SSID %d.%c%c%c%c%c%c"),
Jeff Johnson295189b2012-06-20 16:38:30 -07001909 psessionEntry->ssId.length,
1910 psessionEntry->ssId.ssId[0],
1911 psessionEntry->ssId.ssId[1],
1912 psessionEntry->ssId.ssId[2],
1913 psessionEntry->ssId.ssId[3],
1914 psessionEntry->ssId.ssId[4],
1915 psessionEntry->ssId.ssId[5]);
Arif Hussaina7c8e412013-11-20 11:06:42 -08001916 limLog(pMac, LOG1, FL("Channel %d, BSSID "MAC_ADDRESS_STR),
Jeff Johnson295189b2012-06-20 16:38:30 -07001917 psessionEntry->currentOperChannel,
Arif Hussaina7c8e412013-11-20 11:06:42 -08001918 MAC_ADDR_ARRAY(psessionEntry->bssId));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001919
1920 /* Indicate whether spectrum management is enabled*/
1921 psessionEntry->spectrumMgtEnabled =
1922 pSmeJoinReq->spectrumMgtIndicator;
1923 /* Issue LIM_MLM_JOIN_REQ to MLM */
1924 limPostMlmMessage(pMac, LIM_MLM_JOIN_REQ, (tANI_U32 *) pMlmJoinReq);
1925 return;
1926
1927 }
1928 else
1929 {
1930 /* Received eWNI_SME_JOIN_REQ un expected state */
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001931 limLog(pMac, LOGE, FL("received unexpected SME_JOIN_REQ in state %X"), pMac->lim.gLimSmeState);
Jeff Johnson295189b2012-06-20 16:38:30 -07001932 limPrintSmeState(pMac, LOGE, pMac->lim.gLimSmeState);
1933 retCode = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
1934 psessionEntry = NULL;
1935 goto end;
1936
1937 }
1938
1939end:
1940 limGetSessionInfo(pMac,(tANI_U8*)pMsgBuf,&smesessionId,&smetransactionId);
1941
1942 if(pSmeJoinReq)
1943 {
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301944 vos_mem_free(pSmeJoinReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07001945 pSmeJoinReq = NULL;
1946 if (NULL != psessionEntry)
1947 {
1948 psessionEntry->pLimJoinReq = NULL;
1949 }
1950 }
1951
1952 if(retCode != eSIR_SME_SUCCESS)
1953 {
1954 if(NULL != psessionEntry)
1955 {
1956 peDeleteSession(pMac,psessionEntry);
1957 psessionEntry = NULL;
1958 }
1959 }
1960
1961 limSendSmeJoinReassocRsp(pMac, eWNI_SME_JOIN_RSP, retCode, eSIR_MAC_UNSPEC_FAILURE_STATUS,psessionEntry,smesessionId,smetransactionId);
1962} /*** end __limProcessSmeJoinReq() ***/
1963
1964
1965#ifdef FEATURE_WLAN_CCX
Madan Mohan Koyyalamudi3282c572012-11-09 17:01:41 -08001966tANI_U8 limGetMaxTxPower(tPowerdBm regMax, tPowerdBm apTxPower, tANI_U8 iniTxPower)
Jeff Johnson295189b2012-06-20 16:38:30 -07001967{
1968 tANI_U8 maxTxPower = 0;
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301969 tANI_U8 txPower = VOS_MIN( regMax, (apTxPower) );
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001970 txPower = VOS_MIN(txPower, iniTxPower);
Jeff Johnson295189b2012-06-20 16:38:30 -07001971 if((txPower >= MIN_TX_PWR_CAP) && (txPower <= MAX_TX_PWR_CAP))
1972 maxTxPower = txPower;
1973 else if (txPower < MIN_TX_PWR_CAP)
1974 maxTxPower = MIN_TX_PWR_CAP;
1975 else
1976 maxTxPower = MAX_TX_PWR_CAP;
1977
1978 return (maxTxPower);
1979}
1980#endif
1981
Jeff Johnson295189b2012-06-20 16:38:30 -07001982/**
1983 * __limProcessSmeReassocReq()
1984 *
1985 *FUNCTION:
1986 * This function is called to process SME_REASSOC_REQ message
1987 * from HDD or upper layer application.
1988 *
1989 *LOGIC:
1990 *
1991 *ASSUMPTIONS:
1992 *
1993 *NOTE:
1994 *
1995 * @param pMac Pointer to Global MAC structure
1996 * @param *pMsgBuf A pointer to the SME message buffer
1997 * @return None
1998 */
1999
2000static void
2001__limProcessSmeReassocReq(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
2002{
2003 tANI_U16 caps;
2004 tANI_U32 val;
Srinivas Girigowdac16730e2013-01-16 13:39:39 -08002005 tpSirSmeJoinReq pReassocReq = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002006 tLimMlmReassocReq *pMlmReassocReq;
2007 tSirResultCodes retCode = eSIR_SME_SUCCESS;
2008 tpPESession psessionEntry = NULL;
2009 tANI_U8 sessionId;
2010 tANI_U8 smeSessionId;
2011 tANI_U16 transactionId;
2012 tPowerdBm localPowerConstraint = 0, regMax = 0;
2013 tANI_U32 teleBcnEn = 0;
Madan Mohan Koyyalamudi7df624d2012-10-31 16:32:50 -07002014 tANI_U16 nSize;
Jeff Johnson295189b2012-06-20 16:38:30 -07002015
2016
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002017 PELOG3(limLog(pMac, LOG3, FL("Received REASSOC_REQ"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07002018
Madan Mohan Koyyalamudi7df624d2012-10-31 16:32:50 -07002019 nSize = __limGetSmeJoinReqSizeForAlloc((tANI_U8 *) pMsgBuf);
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302020 pReassocReq = vos_mem_malloc(nSize);
2021 if ( NULL == pReassocReq )
Jeff Johnson295189b2012-06-20 16:38:30 -07002022 {
2023 // Log error
2024 limLog(pMac, LOGP,
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302025 FL("call to AllocateMemory failed for pReassocReq"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002026
2027 retCode = eSIR_SME_RESOURCES_UNAVAILABLE;
2028 goto end;
2029 }
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302030 (void) vos_mem_set((void *) pReassocReq, nSize, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07002031 if ((limJoinReqSerDes(pMac, (tpSirSmeJoinReq) pReassocReq,
2032 (tANI_U8 *) pMsgBuf) == eSIR_FAILURE) ||
2033 (!limIsSmeJoinReqValid(pMac,
2034 (tpSirSmeJoinReq) pReassocReq)))
2035 {
2036 /// Received invalid eWNI_SME_REASSOC_REQ
2037 // Log the event
2038 limLog(pMac, LOGW,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002039 FL("received SME_REASSOC_REQ with invalid data"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002040
2041 retCode = eSIR_SME_INVALID_PARAMETERS;
2042 goto end;
2043 }
2044
2045 if((psessionEntry = peFindSessionByBssid(pMac,pReassocReq->bssDescription.bssId,&sessionId))==NULL)
2046 {
2047 limPrintMacAddr(pMac, pReassocReq->bssDescription.bssId, LOGE);
Srinivas Girigowda2a69dcf2013-09-13 14:48:34 -07002048 limLog(pMac, LOGE, FL("Session does not exist for given bssId"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002049 retCode = eSIR_SME_INVALID_PARAMETERS;
2050 goto end;
2051 }
2052
2053#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM //FEATURE_WLAN_DIAG_SUPPORT
2054 limDiagEventReport(pMac, WLAN_PE_DIAG_REASSOC_REQ_EVENT, psessionEntry, 0, 0);
2055#endif //FEATURE_WLAN_DIAG_SUPPORT
2056 //pMac->lim.gpLimReassocReq = pReassocReq;//TO SUPPORT BT-AMP
2057
2058 /* Store the reassoc handle in the session Table.. 23rd sep review */
2059 psessionEntry->pLimReAssocReq = pReassocReq;
2060
2061 /**
2062 * Reassociate request is expected
2063 * in link established state only.
2064 */
2065
2066 if (psessionEntry->limSmeState != eLIM_SME_LINK_EST_STATE)
2067 {
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002068#if defined(WLAN_FEATURE_VOWIFI_11R) || defined(FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07002069 if (psessionEntry->limSmeState == eLIM_SME_WT_REASSOC_STATE)
2070 {
2071 // May be from 11r FT pre-auth. So lets check it before we bail out
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08002072 limLog(pMac, LOG1, FL("Session in reassoc state is %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002073 psessionEntry->peSessionId);
2074
2075 // Make sure its our preauth bssid
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302076 if (!vos_mem_compare( pReassocReq->bssDescription.bssId,
Jeff Johnson295189b2012-06-20 16:38:30 -07002077 pMac->ft.ftPEContext.pFTPreAuthReq->preAuthbssId, 6))
2078 {
2079 limPrintMacAddr(pMac, pReassocReq->bssDescription.bssId, LOGE);
2080 limPrintMacAddr(pMac, pMac->ft.ftPEContext.pFTPreAuthReq->preAuthbssId, LOGE);
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002081 limLog(pMac, LOGP, FL("Unknown bssId in reassoc state"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002082 retCode = eSIR_SME_INVALID_PARAMETERS;
2083 goto end;
2084 }
2085
2086 limProcessMlmFTReassocReq(pMac, pMsgBuf, psessionEntry);
2087 return;
2088 }
2089#endif
2090 /// Should not have received eWNI_SME_REASSOC_REQ
2091 // Log the event
2092 limLog(pMac, LOGE,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002093 FL("received unexpected SME_REASSOC_REQ in state %X"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002094 psessionEntry->limSmeState);
2095 limPrintSmeState(pMac, LOGE, psessionEntry->limSmeState);
2096
2097 retCode = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
2098 goto end;
2099 }
2100
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302101 vos_mem_copy( psessionEntry->limReAssocbssId,
Jeff Johnson295189b2012-06-20 16:38:30 -07002102 psessionEntry->pLimReAssocReq->bssDescription.bssId,
2103 sizeof(tSirMacAddr));
2104
2105 psessionEntry->limReassocChannelId =
2106 psessionEntry->pLimReAssocReq->bssDescription.channelId;
2107
Jeff Johnsone7245742012-09-05 17:12:55 -07002108 psessionEntry->reAssocHtSupportedChannelWidthSet =
2109 (psessionEntry->pLimReAssocReq->cbMode)?1:0;
2110 psessionEntry->reAssocHtRecommendedTxWidthSet =
2111 psessionEntry->reAssocHtSupportedChannelWidthSet;
2112 psessionEntry->reAssocHtSecondaryChannelOffset =
2113 psessionEntry->pLimReAssocReq->cbMode;
2114
Jeff Johnson295189b2012-06-20 16:38:30 -07002115 psessionEntry->limReassocBssCaps =
2116 psessionEntry->pLimReAssocReq->bssDescription.capabilityInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07002117 regMax = cfgGetRegulatoryMaxTransmitPower( pMac, psessionEntry->currentOperChannel );
2118 localPowerConstraint = regMax;
2119 limExtractApCapability( pMac,
2120 (tANI_U8 *) psessionEntry->pLimReAssocReq->bssDescription.ieFields,
2121 limGetIElenFromBssDescription(
2122 &psessionEntry->pLimReAssocReq->bssDescription),
2123 &psessionEntry->limReassocBssQosCaps,
2124 &psessionEntry->limReassocBssPropCap,
2125 &pMac->lim.gLimCurrentBssUapsd //TBD-RAJESH make gLimReassocBssUapsd session specific
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07002126 , &localPowerConstraint,
2127 psessionEntry
Jeff Johnson295189b2012-06-20 16:38:30 -07002128 );
2129
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302130 psessionEntry->maxTxPower = VOS_MIN( regMax, (localPowerConstraint) );
Jeff Johnson295189b2012-06-20 16:38:30 -07002131#if defined WLAN_VOWIFI_DEBUG
2132 limLog( pMac, LOGE, "Regulatory max = %d, local power constraint = %d, max tx = %d", regMax, localPowerConstraint, psessionEntry->maxTxPower );
2133#endif
2134 {
2135 #if 0
2136 if (wlan_cfgGetStr(pMac, WNI_CFG_SSID, pMac->lim.gLimReassocSSID.ssId,
2137 &cfgLen) != eSIR_SUCCESS)
2138 {
2139 /// Could not get SSID from CFG. Log error.
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002140 limLog(pMac, LOGP, FL("could not retrive SSID"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002141 }
2142 #endif//TO SUPPORT BT-AMP
2143
2144 /* Copy the SSID from sessio entry to local variable */
2145 #if 0
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302146 vos_mem_copy( pMac->lim.gLimReassocSSID.ssId,
Jeff Johnson295189b2012-06-20 16:38:30 -07002147 psessionEntry->ssId.ssId,
2148 psessionEntry->ssId.length);
2149 #endif
2150 psessionEntry->limReassocSSID.length = pReassocReq->ssId.length;
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302151 vos_mem_copy( psessionEntry->limReassocSSID.ssId,
Jeff Johnson295189b2012-06-20 16:38:30 -07002152 pReassocReq->ssId.ssId, psessionEntry->limReassocSSID.length);
2153
2154 }
2155
2156 if (pMac->lim.gLimCurrentBssUapsd)
2157 {
2158 pMac->lim.gUapsdPerAcBitmask = psessionEntry->pLimReAssocReq->uapsdPerAcBitmask;
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002159 limLog( pMac, LOG1, FL("UAPSD flag for all AC - 0x%2x"), pMac->lim.gUapsdPerAcBitmask);
Jeff Johnson295189b2012-06-20 16:38:30 -07002160 }
2161
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302162 pMlmReassocReq = vos_mem_malloc(sizeof(tLimMlmReassocReq));
2163 if ( NULL == pMlmReassocReq )
Jeff Johnson295189b2012-06-20 16:38:30 -07002164 {
2165 // Log error
2166 limLog(pMac, LOGP,
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302167 FL("call to AllocateMemory failed for mlmReassocReq"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002168
2169 retCode = eSIR_SME_RESOURCES_UNAVAILABLE;
2170 goto end;
2171 }
2172
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302173 vos_mem_copy( pMlmReassocReq->peerMacAddr,
Jeff Johnson295189b2012-06-20 16:38:30 -07002174 psessionEntry->limReAssocbssId,
2175 sizeof(tSirMacAddr));
2176
2177 if (wlan_cfgGetInt(pMac, WNI_CFG_REASSOCIATION_FAILURE_TIMEOUT,
2178 (tANI_U32 *) &pMlmReassocReq->reassocFailureTimeout)
2179 != eSIR_SUCCESS)
2180 {
2181 /**
2182 * Could not get ReassocFailureTimeout value
2183 * from CFG. Log error.
2184 */
2185 limLog(pMac, LOGP,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002186 FL("could not retrieve ReassocFailureTimeout value"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002187 }
2188
2189 if (cfgGetCapabilityInfo(pMac, &caps,psessionEntry) != eSIR_SUCCESS)
2190 {
2191 /**
2192 * Could not get Capabilities value
2193 * from CFG. Log error.
2194 */
2195 limLog(pMac, LOGP,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002196 FL("could not retrieve Capabilities value"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002197 }
2198 pMlmReassocReq->capabilityInfo = caps;
2199
2200 /* Update PE sessionId*/
2201 pMlmReassocReq->sessionId = sessionId;
2202
2203 /* If telescopic beaconing is enabled, set listen interval to
2204 WNI_CFG_TELE_BCN_MAX_LI */
2205 if(wlan_cfgGetInt(pMac, WNI_CFG_TELE_BCN_WAKEUP_EN, &teleBcnEn) !=
2206 eSIR_SUCCESS)
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002207 limLog(pMac, LOGP, FL("Couldn't get WNI_CFG_TELE_BCN_WAKEUP_EN"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002208
2209 val = WNI_CFG_LISTEN_INTERVAL_STADEF;
2210
2211 if(teleBcnEn)
2212 {
2213 if(wlan_cfgGetInt(pMac, WNI_CFG_TELE_BCN_MAX_LI, &val) !=
2214 eSIR_SUCCESS)
2215 {
2216 /**
2217 * Could not get ListenInterval value
2218 * from CFG. Log error.
2219 */
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002220 limLog(pMac, LOGP, FL("could not retrieve ListenInterval"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002221 }
2222 }
2223 else
2224 {
2225 if (wlan_cfgGetInt(pMac, WNI_CFG_LISTEN_INTERVAL, &val) != eSIR_SUCCESS)
2226 {
2227 /**
2228 * Could not get ListenInterval value
2229 * from CFG. Log error.
2230 */
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002231 limLog(pMac, LOGP, FL("could not retrieve ListenInterval"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002232 }
2233 }
2234
2235 /* Delete all BA sessions before Re-Assoc.
2236 * BA frames are class 3 frames and the session
2237 * is lost upon disassociation and reassociation.
2238 */
2239
Kiran Kumar Lokere458d7322013-05-29 14:29:43 -07002240 limDeleteBASessions(pMac, psessionEntry, BA_BOTH_DIRECTIONS);
Jeff Johnson295189b2012-06-20 16:38:30 -07002241
2242 pMlmReassocReq->listenInterval = (tANI_U16) val;
2243
2244 /* Indicate whether spectrum management is enabled*/
2245 psessionEntry->spectrumMgtEnabled = pReassocReq->spectrumMgtIndicator;
2246
2247 psessionEntry->limPrevSmeState = psessionEntry->limSmeState;
2248 psessionEntry->limSmeState = eLIM_SME_WT_REASSOC_STATE;
2249
Jeff Johnsone7245742012-09-05 17:12:55 -07002250 MTRACE(macTrace(pMac, TRACE_CODE_SME_STATE, psessionEntry->peSessionId, psessionEntry->limSmeState));
Jeff Johnson295189b2012-06-20 16:38:30 -07002251
2252 limPostMlmMessage(pMac,
2253 LIM_MLM_REASSOC_REQ,
2254 (tANI_U32 *) pMlmReassocReq);
2255 return;
2256
2257end:
2258 if (pReassocReq)
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302259 vos_mem_free( pReassocReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07002260
2261 if (psessionEntry)
2262 {
2263 // error occurred after we determined the session so extract
2264 // session and transaction info from there
2265 smeSessionId = psessionEntry->smeSessionId;
2266 transactionId = psessionEntry->transactionId;
2267 }
2268 else
2269 {
2270 // error occurred before or during the time we determined the session
2271 // so extract the session and transaction info from the message
2272 limGetSessionInfo(pMac,(tANI_U8*)pMsgBuf, &smeSessionId, &transactionId);
2273 }
2274
2275 /// Send Reassoc failure response to host
2276 /// (note psessionEntry may be NULL, but that's OK)
2277 limSendSmeJoinReassocRsp(pMac, eWNI_SME_REASSOC_RSP,
2278 retCode, eSIR_MAC_UNSPEC_FAILURE_STATUS,
2279 psessionEntry, smeSessionId, transactionId);
2280
2281} /*** end __limProcessSmeReassocReq() ***/
2282
2283
2284tANI_BOOLEAN sendDisassocFrame = 1;
2285/**
2286 * __limProcessSmeDisassocReq()
2287 *
2288 *FUNCTION:
2289 * This function is called to process SME_DISASSOC_REQ message
2290 * from HDD or upper layer application.
2291 *
2292 *LOGIC:
2293 *
2294 *ASSUMPTIONS:
2295 *
2296 *NOTE:
2297 *
2298 * @param pMac Pointer to Global MAC structure
2299 * @param *pMsgBuf A pointer to the SME message buffer
2300 * @return None
2301 */
2302
2303static void
2304__limProcessSmeDisassocReq(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
2305{
2306 tANI_U16 disassocTrigger, reasonCode;
2307 tLimMlmDisassocReq *pMlmDisassocReq;
2308 tSirResultCodes retCode = eSIR_SME_SUCCESS;
Jeff Johnson43971f52012-07-17 12:26:56 -07002309 tSirRetStatus status;
Jeff Johnson295189b2012-06-20 16:38:30 -07002310 tSirSmeDisassocReq smeDisassocReq;
2311 tpPESession psessionEntry = NULL;
2312 tANI_U8 sessionId;
2313 tANI_U8 smesessionId;
2314 tANI_U16 smetransactionId;
2315
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002316 PELOG1(limLog(pMac, LOG1,FL("received DISASSOC_REQ message"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07002317
Jeff Johnson43971f52012-07-17 12:26:56 -07002318 if (pMsgBuf == NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -07002319 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002320 limLog(pMac, LOGE, FL("Buffer is Pointing to NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002321 return;
2322 }
2323
Jeff Johnson43971f52012-07-17 12:26:56 -07002324 limGetSessionInfo(pMac, (tANI_U8 *)pMsgBuf,&smesessionId, &smetransactionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07002325
Jeff Johnson43971f52012-07-17 12:26:56 -07002326 status = limDisassocReqSerDes(pMac, &smeDisassocReq, (tANI_U8 *) pMsgBuf);
Jeff Johnson295189b2012-06-20 16:38:30 -07002327
Jeff Johnson43971f52012-07-17 12:26:56 -07002328 if ( (eSIR_FAILURE == status) ||
2329 (!limIsSmeDisassocReqValid(pMac, &smeDisassocReq, psessionEntry)) )
Jeff Johnson295189b2012-06-20 16:38:30 -07002330 {
2331 PELOGE(limLog(pMac, LOGE,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002332 FL("received invalid SME_DISASSOC_REQ message"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07002333
2334 if (pMac->lim.gLimRspReqd)
2335 {
2336 pMac->lim.gLimRspReqd = false;
2337
2338 retCode = eSIR_SME_INVALID_PARAMETERS;
2339 disassocTrigger = eLIM_HOST_DISASSOC;
2340 goto sendDisassoc;
2341 }
2342
2343 return;
2344 }
2345
2346
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002347 PELOG1(limLog(pMac, LOG1, FL("received DISASSOC_REQ message. Reason: %d global SmeState: %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002348 smeDisassocReq.reasonCode, pMac->lim.gLimSmeState);)
2349
2350
2351 if((psessionEntry = peFindSessionByBssid(pMac,smeDisassocReq.bssId,&sessionId))== NULL)
2352 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002353 limLog(pMac, LOGE,FL("session does not exist for given bssId"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002354 retCode = eSIR_SME_INVALID_PARAMETERS;
2355 disassocTrigger = eLIM_HOST_DISASSOC;
2356 goto sendDisassoc;
2357
2358 }
2359
2360#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM //FEATURE_WLAN_DIAG_SUPPORT
2361 limDiagEventReport(pMac, WLAN_PE_DIAG_DISASSOC_REQ_EVENT, psessionEntry, 0, smeDisassocReq.reasonCode);
2362#endif //FEATURE_WLAN_DIAG_SUPPORT
2363
2364 /* Update SME session Id and SME transaction ID*/
2365
2366 psessionEntry->smeSessionId = smesessionId;
2367 psessionEntry->transactionId = smetransactionId;
2368
2369 switch (psessionEntry->limSystemRole)
2370 {
2371 case eLIM_STA_ROLE:
2372 case eLIM_BT_AMP_STA_ROLE:
2373 switch (psessionEntry->limSmeState)
2374 {
2375 case eLIM_SME_ASSOCIATED_STATE:
2376 case eLIM_SME_LINK_EST_STATE:
2377 psessionEntry->limPrevSmeState = psessionEntry->limSmeState;
2378 psessionEntry->limSmeState= eLIM_SME_WT_DISASSOC_STATE;
Hoonki Lee8c9e99f2013-04-18 22:59:11 -07002379#ifdef FEATURE_WLAN_TDLS
2380 /* Delete all TDLS peers connected before leaving BSS*/
2381 limDeleteTDLSPeers(pMac, psessionEntry);
2382#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07002383 MTRACE(macTrace(pMac, TRACE_CODE_SME_STATE, psessionEntry->peSessionId, psessionEntry->limSmeState));
Jeff Johnson295189b2012-06-20 16:38:30 -07002384 break;
2385
2386 case eLIM_SME_WT_DEAUTH_STATE:
2387 /* PE shall still process the DISASSOC_REQ and proceed with
2388 * link tear down even if it had already sent a DEAUTH_IND to
2389 * to SME. pMac->lim.gLimPrevSmeState shall remain the same as
2390 * its been set when PE entered WT_DEAUTH_STATE.
2391 */
2392 psessionEntry->limSmeState= eLIM_SME_WT_DISASSOC_STATE;
Jeff Johnsone7245742012-09-05 17:12:55 -07002393 MTRACE(macTrace(pMac, TRACE_CODE_SME_STATE, psessionEntry->peSessionId, psessionEntry->limSmeState));
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002394 limLog(pMac, LOG1, FL("Rcvd SME_DISASSOC_REQ while in SME_WT_DEAUTH_STATE. "));
Jeff Johnson295189b2012-06-20 16:38:30 -07002395 break;
2396
2397 case eLIM_SME_WT_DISASSOC_STATE:
2398 /* PE Recieved a Disassoc frame. Normally it gets DISASSOC_CNF but it
2399 * received DISASSOC_REQ. Which means host is also trying to disconnect.
2400 * PE can continue processing DISASSOC_REQ and send the response instead
2401 * of failing the request. SME will anyway ignore DEAUTH_IND that was sent
2402 * for disassoc frame.
2403 *
2404 * It will send a disassoc, which is ok. However, we can use the global flag
2405 * sendDisassoc to not send disassoc frame.
2406 */
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002407 limLog(pMac, LOG1, FL("Rcvd SME_DISASSOC_REQ while in SME_WT_DISASSOC_STATE. "));
Jeff Johnson295189b2012-06-20 16:38:30 -07002408 break;
2409
2410 case eLIM_SME_JOIN_FAILURE_STATE: {
2411 /** Return Success as we are already in Disconnected State*/
2412 if (pMac->lim.gLimRspReqd) {
2413 retCode = eSIR_SME_SUCCESS;
2414 disassocTrigger = eLIM_HOST_DISASSOC;
2415 goto sendDisassoc;
2416 }
2417 }break;
2418 default:
2419 /**
2420 * STA is not currently associated.
2421 * Log error and send response to host
2422 */
2423 limLog(pMac, LOGE,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002424 FL("received unexpected SME_DISASSOC_REQ in state %X"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002425 psessionEntry->limSmeState);
2426 limPrintSmeState(pMac, LOGE, psessionEntry->limSmeState);
2427
2428 if (pMac->lim.gLimRspReqd)
2429 {
2430 if (psessionEntry->limSmeState !=
2431 eLIM_SME_WT_ASSOC_STATE)
2432 pMac->lim.gLimRspReqd = false;
2433
2434 retCode = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
2435 disassocTrigger = eLIM_HOST_DISASSOC;
2436 goto sendDisassoc;
2437 }
2438
2439 return;
2440 }
2441
2442 break;
2443
2444 case eLIM_AP_ROLE:
2445 case eLIM_BT_AMP_AP_ROLE:
2446 // Fall through
2447 break;
2448
2449 case eLIM_STA_IN_IBSS_ROLE:
2450 default: // eLIM_UNKNOWN_ROLE
2451 limLog(pMac, LOGE,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002452 FL("received unexpected SME_DISASSOC_REQ for role %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002453 psessionEntry->limSystemRole);
2454
2455 retCode = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
2456 disassocTrigger = eLIM_HOST_DISASSOC;
2457 goto sendDisassoc;
2458 } // end switch (pMac->lim.gLimSystemRole)
2459
2460 if (smeDisassocReq.reasonCode == eLIM_LINK_MONITORING_DISASSOC)
2461 {
2462 /// Disassociation is triggered by Link Monitoring
2463 disassocTrigger = eLIM_LINK_MONITORING_DISASSOC;
2464 reasonCode = eSIR_MAC_DISASSOC_DUE_TO_INACTIVITY_REASON;
2465 }
2466 else
2467 {
2468 disassocTrigger = eLIM_HOST_DISASSOC;
2469 reasonCode = smeDisassocReq.reasonCode;
2470 }
2471
2472 if (smeDisassocReq.doNotSendOverTheAir)
2473 {
2474 sendDisassocFrame = 0;
2475 }
2476 // Trigger Disassociation frame to peer MAC entity
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302477
2478 pMlmDisassocReq = vos_mem_malloc(sizeof(tLimMlmDisassocReq));
2479 if ( NULL == pMlmDisassocReq )
Jeff Johnson295189b2012-06-20 16:38:30 -07002480 {
2481 // Log error
2482 limLog(pMac, LOGP,
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302483 FL("call to AllocateMemory failed for mlmDisassocReq"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002484
2485 return;
2486 }
2487
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302488 vos_mem_copy( (tANI_U8 *) &pMlmDisassocReq->peerMacAddr,
Jeff Johnson295189b2012-06-20 16:38:30 -07002489 (tANI_U8 *) &smeDisassocReq.peerMacAddr,
2490 sizeof(tSirMacAddr));
2491
2492 pMlmDisassocReq->reasonCode = reasonCode;
2493 pMlmDisassocReq->disassocTrigger = disassocTrigger;
2494
2495 /* Update PE session ID*/
2496 pMlmDisassocReq->sessionId = sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -07002497
2498 limPostMlmMessage(pMac,
2499 LIM_MLM_DISASSOC_REQ,
2500 (tANI_U32 *) pMlmDisassocReq);
2501 return;
2502
2503sendDisassoc:
2504 if (psessionEntry)
2505 limSendSmeDisassocNtf(pMac, smeDisassocReq.peerMacAddr,
2506 retCode,
2507 disassocTrigger,
Jeff Johnson295189b2012-06-20 16:38:30 -07002508 1,smesessionId,smetransactionId,psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07002509 else
2510 limSendSmeDisassocNtf(pMac, smeDisassocReq.peerMacAddr,
2511 retCode,
2512 disassocTrigger,
Sudhir Sattayappa Kohalli5a8ac222013-03-06 12:41:42 -08002513 1, smesessionId, smetransactionId, NULL);
Jeff Johnson295189b2012-06-20 16:38:30 -07002514
2515
2516} /*** end __limProcessSmeDisassocReq() ***/
2517
2518
2519/** -----------------------------------------------------------------
2520 \brief __limProcessSmeDisassocCnf() - Process SME_DISASSOC_CNF
2521
2522 This function is called to process SME_DISASSOC_CNF message
2523 from HDD or upper layer application.
2524
2525 \param pMac - global mac structure
2526 \param pStaDs - station dph hash node
2527 \return none
2528 \sa
2529 ----------------------------------------------------------------- */
2530static void
2531__limProcessSmeDisassocCnf(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
2532{
2533 tSirSmeDisassocCnf smeDisassocCnf;
2534 tANI_U16 aid;
2535 tpDphHashNode pStaDs;
2536 tSirRetStatus status = eSIR_SUCCESS;
2537 tpPESession psessionEntry;
2538 tANI_U8 sessionId;
2539
2540
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002541 PELOG1(limLog(pMac, LOG1, FL("received DISASSOC_CNF message"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07002542
2543 status = limDisassocCnfSerDes(pMac, &smeDisassocCnf,(tANI_U8 *) pMsgBuf);
2544
2545 if (status == eSIR_FAILURE)
2546 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002547 PELOGE(limLog(pMac, LOGE, FL("invalid SME_DISASSOC_CNF message"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07002548 return;
2549 }
2550
2551 if((psessionEntry = peFindSessionByBssid(pMac, smeDisassocCnf.bssId, &sessionId))== NULL)
2552 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002553 limLog(pMac, LOGE,FL("session does not exist for given bssId"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002554 return;
2555 }
2556
2557 if (!limIsSmeDisassocCnfValid(pMac, &smeDisassocCnf, psessionEntry))
2558 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002559 limLog(pMac, LOGW, FL("received invalid SME_DISASSOC_CNF message"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002560 return;
2561 }
2562
2563#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM //FEATURE_WLAN_DIAG_SUPPORT
2564 if (smeDisassocCnf.messageType == eWNI_SME_DISASSOC_CNF)
2565 limDiagEventReport(pMac, WLAN_PE_DIAG_DISASSOC_CNF_EVENT, psessionEntry, (tANI_U16)smeDisassocCnf.statusCode, 0);
2566 else if (smeDisassocCnf.messageType == eWNI_SME_DEAUTH_CNF)
2567 limDiagEventReport(pMac, WLAN_PE_DIAG_DEAUTH_CNF_EVENT, psessionEntry, (tANI_U16)smeDisassocCnf.statusCode, 0);
2568#endif //FEATURE_WLAN_DIAG_SUPPORT
2569
2570 switch (psessionEntry->limSystemRole)
2571 {
2572 case eLIM_STA_ROLE:
2573 case eLIM_BT_AMP_STA_ROLE: //To test reconn
2574 if ((psessionEntry->limSmeState != eLIM_SME_IDLE_STATE) &&
2575 (psessionEntry->limSmeState != eLIM_SME_WT_DISASSOC_STATE) &&
2576 (psessionEntry->limSmeState != eLIM_SME_WT_DEAUTH_STATE))
2577 {
2578 limLog(pMac, LOGE,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002579 FL("received unexp SME_DISASSOC_CNF in state %X"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002580 psessionEntry->limSmeState);
2581 limPrintSmeState(pMac, LOGE, psessionEntry->limSmeState);
2582 return;
2583 }
2584 break;
2585
2586 case eLIM_AP_ROLE:
2587 // Fall through
Jeff Johnson295189b2012-06-20 16:38:30 -07002588 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07002589
2590 case eLIM_STA_IN_IBSS_ROLE:
2591 default: // eLIM_UNKNOWN_ROLE
2592 limLog(pMac, LOGE,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002593 FL("received unexpected SME_DISASSOC_CNF role %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002594 psessionEntry->limSystemRole);
2595
2596 return;
2597 }
2598
2599
2600 if ( (psessionEntry->limSmeState == eLIM_SME_WT_DISASSOC_STATE) ||
2601 (psessionEntry->limSmeState == eLIM_SME_WT_DEAUTH_STATE)
Jeff Johnson295189b2012-06-20 16:38:30 -07002602 || (psessionEntry->limSystemRole == eLIM_AP_ROLE )
Jeff Johnson295189b2012-06-20 16:38:30 -07002603 )
2604 {
2605 pStaDs = dphLookupHashEntry(pMac, smeDisassocCnf.peerMacAddr, &aid, &psessionEntry->dph.dphHashTable);
2606 if (pStaDs == NULL)
2607 {
2608 PELOGW(limLog(pMac, LOGW, FL("received DISASSOC_CNF for a STA that does not have context, addr= "));
2609 limPrintMacAddr(pMac, smeDisassocCnf.peerMacAddr, LOGW);)
2610 return;
2611 }
Madan Mohan Koyyalamudi23001722012-10-31 16:48:56 -07002612 /* Delete FT session if there exists one */
2613 limFTCleanup(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -07002614 limCleanupRxPath(pMac, pStaDs, psessionEntry);
Madan Mohan Koyyalamudia67d4332012-11-29 11:35:23 -08002615
2616 limCleanUpDisassocDeauthReq(pMac, (char*)&smeDisassocCnf.peerMacAddr, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07002617 }
2618
2619 return;
2620}
2621
2622
2623/**
2624 * __limProcessSmeDeauthReq()
2625 *
2626 *FUNCTION:
2627 * This function is called to process SME_DEAUTH_REQ message
2628 * from HDD or upper layer application.
2629 *
2630 *LOGIC:
2631 *
2632 *ASSUMPTIONS:
2633 *
2634 *NOTE:
2635 *
2636 * @param pMac Pointer to Global MAC structure
2637 * @param *pMsgBuf A pointer to the SME message buffer
2638 * @return None
2639 */
2640
2641static void
2642__limProcessSmeDeauthReq(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
2643{
2644 tANI_U16 deauthTrigger, reasonCode;
2645 tLimMlmDeauthReq *pMlmDeauthReq;
2646 tSirSmeDeauthReq smeDeauthReq;
2647 tSirResultCodes retCode = eSIR_SME_SUCCESS;
2648 tSirRetStatus status = eSIR_SUCCESS;
2649 tpPESession psessionEntry;
2650 tANI_U8 sessionId; //PE sessionId
2651 tANI_U8 smesessionId;
2652 tANI_U16 smetransactionId;
2653
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002654 PELOG1(limLog(pMac, LOG1,FL("received DEAUTH_REQ message"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07002655
2656 status = limDeauthReqSerDes(pMac, &smeDeauthReq,(tANI_U8 *) pMsgBuf);
2657
2658 limGetSessionInfo(pMac,(tANI_U8 *)pMsgBuf,&smesessionId,&smetransactionId);
2659
2660 //We need to get a session first but we don't even know if the message is correct.
2661 if((psessionEntry = peFindSessionByBssid(pMac, smeDeauthReq.bssId, &sessionId)) == NULL)
2662 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002663 limLog(pMac, LOGE,FL("session does not exist for given bssId"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002664 retCode = eSIR_SME_INVALID_PARAMETERS;
2665 deauthTrigger = eLIM_HOST_DEAUTH;
2666 goto sendDeauth;
2667
2668 }
2669
2670 if ((status == eSIR_FAILURE) || (!limIsSmeDeauthReqValid(pMac, &smeDeauthReq, psessionEntry)))
2671 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002672 PELOGE(limLog(pMac, LOGW,FL("received invalid SME_DEAUTH_REQ message"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07002673 if (pMac->lim.gLimRspReqd)
2674 {
2675 pMac->lim.gLimRspReqd = false;
2676
2677 retCode = eSIR_SME_INVALID_PARAMETERS;
2678 deauthTrigger = eLIM_HOST_DEAUTH;
2679 goto sendDeauth;
2680 }
2681
2682 return;
2683 }
2684
2685#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM //FEATURE_WLAN_DIAG_SUPPORT
2686 limDiagEventReport(pMac, WLAN_PE_DIAG_DEAUTH_REQ_EVENT, psessionEntry, 0, smeDeauthReq.reasonCode);
2687#endif //FEATURE_WLAN_DIAG_SUPPORT
2688
2689 /* Update SME session ID and Transaction ID */
2690 psessionEntry->smeSessionId = smesessionId;
2691 psessionEntry->transactionId = smetransactionId;
2692
2693
2694 switch (psessionEntry->limSystemRole)
2695 {
2696 case eLIM_STA_ROLE:
2697 case eLIM_BT_AMP_STA_ROLE:
2698
2699 switch (psessionEntry->limSmeState)
2700 {
2701 case eLIM_SME_ASSOCIATED_STATE:
2702 case eLIM_SME_LINK_EST_STATE:
2703 case eLIM_SME_WT_ASSOC_STATE:
2704 case eLIM_SME_JOIN_FAILURE_STATE:
2705 case eLIM_SME_IDLE_STATE:
2706 psessionEntry->limPrevSmeState = psessionEntry->limSmeState;
2707 psessionEntry->limSmeState = eLIM_SME_WT_DEAUTH_STATE;
Varun Reddy Yeturue3bbf6e2013-02-08 18:50:55 -08002708 MTRACE(macTrace(pMac, TRACE_CODE_SME_STATE, psessionEntry->peSessionId, psessionEntry->limSmeState));
Jeff Johnson295189b2012-06-20 16:38:30 -07002709
2710 // Send Deauthentication request to MLM below
2711
2712 break;
2713
2714 default:
2715 /**
2716 * STA is not in a state to deauthenticate with
2717 * peer. Log error and send response to host.
2718 */
2719 limLog(pMac, LOGE,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002720 FL("received unexp SME_DEAUTH_REQ in state %X"),psessionEntry->limSmeState);
Jeff Johnson295189b2012-06-20 16:38:30 -07002721 limPrintSmeState(pMac, LOGE, psessionEntry->limSmeState);
2722
2723 if (pMac->lim.gLimRspReqd)
2724 {
2725 pMac->lim.gLimRspReqd = false;
2726
2727 retCode = eSIR_SME_STA_NOT_AUTHENTICATED;
2728 deauthTrigger = eLIM_HOST_DEAUTH;
2729 goto sendDeauth;
2730 }
2731
2732 return;
2733 }
2734
2735 break;
2736
2737 case eLIM_STA_IN_IBSS_ROLE:
2738
2739 return;
2740
2741 case eLIM_AP_ROLE:
2742 // Fall through
2743
2744 break;
2745
2746 default:
2747 limLog(pMac, LOGE,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002748 FL("received unexpected SME_DEAUTH_REQ for role %X"),psessionEntry->limSystemRole);
Jeff Johnson295189b2012-06-20 16:38:30 -07002749
2750 return;
2751 } // end switch (pMac->lim.gLimSystemRole)
2752
2753 if (smeDeauthReq.reasonCode == eLIM_LINK_MONITORING_DEAUTH)
2754 {
2755 /// Deauthentication is triggered by Link Monitoring
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002756 PELOG1(limLog(pMac, LOG1, FL("**** Lost link with AP ****"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07002757 deauthTrigger = eLIM_LINK_MONITORING_DEAUTH;
2758 reasonCode = eSIR_MAC_UNSPEC_FAILURE_REASON;
2759 }
2760 else
2761 {
2762 deauthTrigger = eLIM_HOST_DEAUTH;
2763 reasonCode = smeDeauthReq.reasonCode;
2764 }
2765
2766 // Trigger Deauthentication frame to peer MAC entity
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302767 pMlmDeauthReq = vos_mem_malloc(sizeof(tLimMlmDeauthReq));
2768 if ( NULL == pMlmDeauthReq )
Jeff Johnson295189b2012-06-20 16:38:30 -07002769 {
2770 // Log error
2771 limLog(pMac, LOGP,
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302772 FL("call to AllocateMemory failed for mlmDeauthReq"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002773
2774 return;
2775 }
2776
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302777 vos_mem_copy( (tANI_U8 *) &pMlmDeauthReq->peerMacAddr,
Jeff Johnson295189b2012-06-20 16:38:30 -07002778 (tANI_U8 *) &smeDeauthReq.peerMacAddr,
2779 sizeof(tSirMacAddr));
2780
2781 pMlmDeauthReq->reasonCode = reasonCode;
2782 pMlmDeauthReq->deauthTrigger = deauthTrigger;
Jeff Johnson295189b2012-06-20 16:38:30 -07002783
2784 /* Update PE session Id*/
2785 pMlmDeauthReq->sessionId = sessionId;
2786
2787 limPostMlmMessage(pMac,
2788 LIM_MLM_DEAUTH_REQ,
2789 (tANI_U32 *) pMlmDeauthReq);
2790 return;
2791
2792sendDeauth:
2793 limSendSmeDeauthNtf(pMac, smeDeauthReq.peerMacAddr,
2794 retCode,
2795 deauthTrigger,
Jeff Johnson295189b2012-06-20 16:38:30 -07002796 1,
Jeff Johnson295189b2012-06-20 16:38:30 -07002797 smesessionId, smetransactionId);
2798} /*** end __limProcessSmeDeauthReq() ***/
2799
2800
2801
2802/**
2803 * __limProcessSmeSetContextReq()
2804 *
2805 *FUNCTION:
2806 * This function is called to process SME_SETCONTEXT_REQ message
2807 * from HDD or upper layer application.
2808 *
2809 *LOGIC:
2810 *
2811 *ASSUMPTIONS:
2812 *
2813 *NOTE:
2814 *
2815 * @param pMac Pointer to Global MAC structure
2816 * @param *pMsgBuf A pointer to the SME message buffer
2817 * @return None
2818 */
2819
2820static void
2821__limProcessSmeSetContextReq(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
2822{
2823 tpSirSmeSetContextReq pSetContextReq;
2824 tLimMlmSetKeysReq *pMlmSetKeysReq;
2825 tpPESession psessionEntry;
2826 tANI_U8 sessionId; //PE sessionID
2827 tANI_U8 smesessionId;
2828 tANI_U16 smetransactionId;
2829
2830
2831 PELOG1(limLog(pMac, LOG1,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002832 FL("received SETCONTEXT_REQ message")););
Jeff Johnson295189b2012-06-20 16:38:30 -07002833
2834
2835 if(pMsgBuf == NULL)
2836 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002837 limLog(pMac, LOGE,FL("Buffer is Pointing to NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002838 return;
2839 }
2840
2841 limGetSessionInfo(pMac,(tANI_U8 *)pMsgBuf,&smesessionId,&smetransactionId);
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302842
2843 pSetContextReq = vos_mem_malloc(sizeof(tSirKeys) * SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS);
2844 if ( NULL == pSetContextReq )
Jeff Johnson295189b2012-06-20 16:38:30 -07002845 {
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302846 limLog(pMac, LOGP, FL("call to AllocateMemory failed for pSetContextReq"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002847 return;
2848 }
2849
2850 if ((limSetContextReqSerDes(pMac, pSetContextReq, (tANI_U8 *) pMsgBuf) == eSIR_FAILURE) ||
2851 (!limIsSmeSetContextReqValid(pMac, pSetContextReq)))
2852 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002853 limLog(pMac, LOGW, FL("received invalid SME_SETCONTEXT_REQ message"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002854 goto end;
2855 }
2856
2857 if(pSetContextReq->keyMaterial.numKeys > SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS)
2858 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002859 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 -07002860 limSendSmeSetContextRsp(pMac,
2861 pSetContextReq->peerMacAddr,
Jeff Johnson295189b2012-06-20 16:38:30 -07002862 1,
Jeff Johnson295189b2012-06-20 16:38:30 -07002863 eSIR_SME_INVALID_PARAMETERS,NULL,
2864 smesessionId,smetransactionId);
2865
2866 goto end;
2867 }
2868
2869
2870 if((psessionEntry = peFindSessionByBssid(pMac, pSetContextReq->bssId, &sessionId)) == NULL)
2871 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002872 limLog(pMac, LOGW, FL("Session does not exist for given BSSID"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002873 limSendSmeSetContextRsp(pMac,
2874 pSetContextReq->peerMacAddr,
Jeff Johnson295189b2012-06-20 16:38:30 -07002875 1,
Jeff Johnson295189b2012-06-20 16:38:30 -07002876 eSIR_SME_INVALID_PARAMETERS,NULL,
2877 smesessionId,smetransactionId);
2878
2879 goto end;
2880 }
2881
2882#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM //FEATURE_WLAN_DIAG_SUPPORT
2883 limDiagEventReport(pMac, WLAN_PE_DIAG_SETCONTEXT_REQ_EVENT, psessionEntry, 0, 0);
2884#endif //FEATURE_WLAN_DIAG_SUPPORT
2885
2886
2887 if ((((psessionEntry->limSystemRole == eLIM_STA_ROLE) || (psessionEntry->limSystemRole == eLIM_BT_AMP_STA_ROLE)) &&
2888 (psessionEntry->limSmeState == eLIM_SME_LINK_EST_STATE)) ||
2889 (((psessionEntry->limSystemRole == eLIM_STA_IN_IBSS_ROLE) ||
2890 (psessionEntry->limSystemRole == eLIM_AP_ROLE)|| (psessionEntry->limSystemRole == eLIM_BT_AMP_AP_ROLE)) &&
2891 (psessionEntry->limSmeState == eLIM_SME_NORMAL_STATE)))
2892 {
2893 // Trigger MLM_SETKEYS_REQ
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302894 pMlmSetKeysReq = vos_mem_malloc(sizeof(tLimMlmSetKeysReq));
2895 if ( NULL == pMlmSetKeysReq )
Jeff Johnson295189b2012-06-20 16:38:30 -07002896 {
2897 // Log error
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302898 limLog(pMac, LOGP, FL("call to AllocateMemory failed for mlmSetKeysReq"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002899 goto end;
2900 }
2901
2902 pMlmSetKeysReq->edType = pSetContextReq->keyMaterial.edType;
2903 pMlmSetKeysReq->numKeys = pSetContextReq->keyMaterial.numKeys;
2904 if(pMlmSetKeysReq->numKeys > SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS)
2905 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002906 limLog(pMac, LOGP, FL("Num of keys exceeded max num of default keys limit"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002907 goto end;
2908 }
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302909 vos_mem_copy( (tANI_U8 *) &pMlmSetKeysReq->peerMacAddr,
Jeff Johnson295189b2012-06-20 16:38:30 -07002910 (tANI_U8 *) &pSetContextReq->peerMacAddr,
2911 sizeof(tSirMacAddr));
2912
Jeff Johnson295189b2012-06-20 16:38:30 -07002913
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302914 vos_mem_copy( (tANI_U8 *) &pMlmSetKeysReq->key,
Jeff Johnson295189b2012-06-20 16:38:30 -07002915 (tANI_U8 *) &pSetContextReq->keyMaterial.key,
2916 sizeof(tSirKeys) * (pMlmSetKeysReq->numKeys ? pMlmSetKeysReq->numKeys : 1));
2917
2918 pMlmSetKeysReq->sessionId = sessionId;
2919#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
2920 PELOG1(limLog(pMac, LOG1,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002921 FL("received SETCONTEXT_REQ message sessionId=%d"), pMlmSetKeysReq->sessionId););
Jeff Johnson295189b2012-06-20 16:38:30 -07002922#endif
2923
Jeff Johnson295189b2012-06-20 16:38:30 -07002924 if(((pSetContextReq->keyMaterial.edType == eSIR_ED_WEP40) || (pSetContextReq->keyMaterial.edType == eSIR_ED_WEP104))
2925 && (psessionEntry->limSystemRole == eLIM_AP_ROLE))
2926 {
2927 if(pSetContextReq->keyMaterial.key[0].keyLength)
2928 {
2929 tANI_U8 keyId;
2930 keyId = pSetContextReq->keyMaterial.key[0].keyId;
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302931 vos_mem_copy( (tANI_U8 *)&psessionEntry->WEPKeyMaterial[keyId],
Jeff Johnson295189b2012-06-20 16:38:30 -07002932 (tANI_U8 *) &pSetContextReq->keyMaterial, sizeof(tSirKeyMaterial));
2933 }
2934 else {
2935 tANI_U32 i;
2936 for( i = 0; i < SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS; i++)
2937 {
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302938 vos_mem_copy( (tANI_U8 *) &pMlmSetKeysReq->key[i],
Jeff Johnson295189b2012-06-20 16:38:30 -07002939 (tANI_U8 *)psessionEntry->WEPKeyMaterial[i].key, sizeof(tSirKeys));
2940 }
2941 }
2942 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002943
2944 limPostMlmMessage(pMac, LIM_MLM_SETKEYS_REQ, (tANI_U32 *) pMlmSetKeysReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07002945 }
2946 else
2947 {
2948 limLog(pMac, LOGE,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002949 FL("received unexpected SME_SETCONTEXT_REQ for role %d, state=%X"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002950 psessionEntry->limSystemRole,
2951 psessionEntry->limSmeState);
2952 limPrintSmeState(pMac, LOGE, psessionEntry->limSmeState);
2953
2954 limSendSmeSetContextRsp(pMac, pSetContextReq->peerMacAddr,
Jeff Johnson295189b2012-06-20 16:38:30 -07002955 1,
Jeff Johnson295189b2012-06-20 16:38:30 -07002956 eSIR_SME_UNEXPECTED_REQ_RESULT_CODE,psessionEntry,
2957 smesessionId,
2958 smetransactionId);
2959 }
2960
2961end:
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302962 vos_mem_free( pSetContextReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07002963 return;
2964} /*** end __limProcessSmeSetContextReq() ***/
2965
2966/**
2967 * __limProcessSmeRemoveKeyReq()
2968 *
2969 *FUNCTION:
2970 * This function is called to process SME_REMOVEKEY_REQ message
2971 * from HDD or upper layer application.
2972 *
2973 *LOGIC:
2974 *
2975 *ASSUMPTIONS:
2976 *
2977 *NOTE:
2978 *
2979 * @param pMac Pointer to Global MAC structure
2980 * @param *pMsgBuf A pointer to the SME message buffer
2981 * @return None
2982 */
2983
2984static void
2985__limProcessSmeRemoveKeyReq(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
2986{
2987 tpSirSmeRemoveKeyReq pRemoveKeyReq;
2988 tLimMlmRemoveKeyReq *pMlmRemoveKeyReq;
2989 tpPESession psessionEntry;
2990 tANI_U8 sessionId; //PE sessionID
2991 tANI_U8 smesessionId;
2992 tANI_U16 smetransactionId;
2993
2994 PELOG1(limLog(pMac, LOG1,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002995 FL("received REMOVEKEY_REQ message"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07002996
2997 if(pMsgBuf == NULL)
2998 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002999 limLog(pMac, LOGE,FL("Buffer is Pointing to NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003000 return;
3001 }
3002
3003
3004 limGetSessionInfo(pMac,(tANI_U8 *)pMsgBuf,&smesessionId,&smetransactionId);
3005
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303006 pRemoveKeyReq = vos_mem_malloc(sizeof(*pRemoveKeyReq));
3007 if ( NULL == pRemoveKeyReq )
Jeff Johnson295189b2012-06-20 16:38:30 -07003008 {
3009 //Log error
3010 limLog(pMac, LOGP,
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303011 FL("call to AllocateMemory failed for pRemoveKeyReq"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003012
3013 return;
3014 }
3015
3016 if ((limRemoveKeyReqSerDes(pMac,
3017 pRemoveKeyReq,
3018 (tANI_U8 *) pMsgBuf) == eSIR_FAILURE))
3019 {
3020 limLog(pMac, LOGW,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003021 FL("received invalid SME_REMOVECONTEXT_REQ message"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003022
3023 /* extra look up is needed since, session entry to be passed il limsendremovekey response */
3024
3025 if((psessionEntry = peFindSessionByBssid(pMac,pRemoveKeyReq->bssId,&sessionId))== NULL)
3026 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003027 limLog(pMac, LOGE,FL("session does not exist for given bssId"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003028 //goto end;
3029 }
3030
3031 limSendSmeRemoveKeyRsp(pMac,
3032 pRemoveKeyReq->peerMacAddr,
3033 eSIR_SME_INVALID_PARAMETERS,psessionEntry,
3034 smesessionId,smetransactionId);
3035
3036 goto end;
3037 }
3038
3039 if((psessionEntry = peFindSessionByBssid(pMac,pRemoveKeyReq->bssId, &sessionId))== NULL)
3040 {
3041 limLog(pMac, LOGE,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003042 FL("session does not exist for given bssId"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003043 limSendSmeRemoveKeyRsp(pMac,
3044 pRemoveKeyReq->peerMacAddr,
3045 eSIR_SME_UNEXPECTED_REQ_RESULT_CODE, NULL,
3046 smesessionId, smetransactionId);
3047 goto end;
3048 }
3049
3050
3051 if ((((psessionEntry->limSystemRole == eLIM_STA_ROLE)|| (psessionEntry->limSystemRole == eLIM_BT_AMP_STA_ROLE))&&
3052 (psessionEntry->limSmeState == eLIM_SME_LINK_EST_STATE)) ||
3053 (((psessionEntry->limSystemRole == eLIM_STA_IN_IBSS_ROLE) ||
3054 (psessionEntry->limSystemRole == eLIM_AP_ROLE)|| (psessionEntry->limSystemRole == eLIM_BT_AMP_AP_ROLE)) &&
3055 (psessionEntry->limSmeState == eLIM_SME_NORMAL_STATE)))
3056 {
3057 // Trigger MLM_REMOVEKEYS_REQ
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303058 pMlmRemoveKeyReq = vos_mem_malloc(sizeof(tLimMlmRemoveKeyReq));
3059 if ( NULL == pMlmRemoveKeyReq )
Jeff Johnson295189b2012-06-20 16:38:30 -07003060 {
3061 // Log error
3062 limLog(pMac, LOGP,
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303063 FL("call to AllocateMemory failed for mlmRemoveKeysReq"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003064
3065 goto end;
3066 }
3067
3068 pMlmRemoveKeyReq->edType = (tAniEdType)pRemoveKeyReq->edType;
3069 pMlmRemoveKeyReq->keyId = pRemoveKeyReq->keyId;
3070 pMlmRemoveKeyReq->wepType = pRemoveKeyReq->wepType;
3071 pMlmRemoveKeyReq->unicast = pRemoveKeyReq->unicast;
3072
3073 /* Update PE session Id */
3074 pMlmRemoveKeyReq->sessionId = sessionId;
3075
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303076 vos_mem_copy( (tANI_U8 *) &pMlmRemoveKeyReq->peerMacAddr,
Jeff Johnson295189b2012-06-20 16:38:30 -07003077 (tANI_U8 *) &pRemoveKeyReq->peerMacAddr,
3078 sizeof(tSirMacAddr));
3079
3080
3081 limPostMlmMessage(pMac,
3082 LIM_MLM_REMOVEKEY_REQ,
3083 (tANI_U32 *) pMlmRemoveKeyReq);
3084 }
3085 else
3086 {
3087 limLog(pMac, LOGE,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003088 FL("received unexpected SME_REMOVEKEY_REQ for role %d, state=%X"),
Jeff Johnson295189b2012-06-20 16:38:30 -07003089 psessionEntry->limSystemRole,
3090 psessionEntry->limSmeState);
3091 limPrintSmeState(pMac, LOGE, psessionEntry->limSmeState);
3092
3093 limSendSmeRemoveKeyRsp(pMac,
3094 pRemoveKeyReq->peerMacAddr,
3095 eSIR_SME_UNEXPECTED_REQ_RESULT_CODE,psessionEntry,
3096 smesessionId,smetransactionId);
3097 }
3098
3099end:
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303100 vos_mem_free( pRemoveKeyReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07003101} /*** end __limProcessSmeRemoveKeyReq() ***/
3102
Jeff Johnson295189b2012-06-20 16:38:30 -07003103void limProcessSmeGetScanChannelInfo(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
3104{
3105 tSirMsgQ mmhMsg;
3106 tpSmeGetScanChnRsp pSirSmeRsp;
3107 tANI_U16 len = 0;
Madan Mohan Koyyalamudide1b5bc2013-07-12 00:56:04 +05303108 tANI_U8 sessionId;
3109 tANI_U16 transactionId;
Jeff Johnson295189b2012-06-20 16:38:30 -07003110
3111 if(pMac->lim.scanChnInfo.numChnInfo > SIR_MAX_SUPPORTED_CHANNEL_LIST)
3112 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003113 limLog(pMac, LOGW, FL("numChn is out of bounds %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07003114 pMac->lim.scanChnInfo.numChnInfo);
3115 pMac->lim.scanChnInfo.numChnInfo = SIR_MAX_SUPPORTED_CHANNEL_LIST;
3116 }
3117
3118 PELOG2(limLog(pMac, LOG2,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003119 FL("Sending message %s with number of channels %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07003120 limMsgStr(eWNI_SME_GET_SCANNED_CHANNEL_RSP), pMac->lim.scanChnInfo.numChnInfo);)
3121
3122 len = sizeof(tSmeGetScanChnRsp) + (pMac->lim.scanChnInfo.numChnInfo - 1) * sizeof(tLimScanChn);
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303123 pSirSmeRsp = vos_mem_malloc(len);
3124 if ( NULL == pSirSmeRsp )
Jeff Johnson295189b2012-06-20 16:38:30 -07003125 {
3126 /// Buffer not available. Log error
3127 limLog(pMac, LOGP,
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303128 FL("call to AllocateMemory failed for JOIN/REASSOC_RSP"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003129
3130 return;
3131 }
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303132 vos_mem_set(pSirSmeRsp, len, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07003133
Jeff Johnson295189b2012-06-20 16:38:30 -07003134 pSirSmeRsp->mesgType = eWNI_SME_GET_SCANNED_CHANNEL_RSP;
3135 pSirSmeRsp->mesgLen = len;
Madan Mohan Koyyalamudide1b5bc2013-07-12 00:56:04 +05303136
3137 if (pMac->fScanOffload)
3138 {
3139 limGetSessionInfo(pMac,(tANI_U8 *)pMsgBuf,&sessionId,&transactionId);
3140 pSirSmeRsp->sessionId = sessionId;
3141 }
3142 else
3143 pSirSmeRsp->sessionId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003144
3145 if(pMac->lim.scanChnInfo.numChnInfo)
3146 {
3147 pSirSmeRsp->numChn = pMac->lim.scanChnInfo.numChnInfo;
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303148 vos_mem_copy( pSirSmeRsp->scanChn, pMac->lim.scanChnInfo.scanChn,
3149 sizeof(tLimScanChn) * pSirSmeRsp->numChn);
Jeff Johnson295189b2012-06-20 16:38:30 -07003150 }
3151 //Clear the list
3152 limRessetScanChannelInfo(pMac);
3153
3154 mmhMsg.type = eWNI_SME_GET_SCANNED_CHANNEL_RSP;
3155 mmhMsg.bodyptr = pSirSmeRsp;
3156 mmhMsg.bodyval = 0;
3157
3158 pMac->lim.gLimRspReqd = false;
Jeff Johnsone7245742012-09-05 17:12:55 -07003159 MTRACE(macTraceMsgTx(pMac, NO_SESSION, mmhMsg.type));
Jeff Johnson295189b2012-06-20 16:38:30 -07003160 limSysProcessMmhMsgApi(pMac, &mmhMsg, ePROT);
3161}
3162
3163
Jeff Johnson295189b2012-06-20 16:38:30 -07003164void limProcessSmeGetAssocSTAsInfo(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
3165{
3166 tSirSmeGetAssocSTAsReq getAssocSTAsReq;
3167 tpDphHashNode pStaDs = NULL;
3168 tpPESession psessionEntry = NULL;
3169 tSap_Event sapEvent;
3170 tpWLAN_SAPEventCB pSapEventCallback = NULL;
3171 tpSap_AssocMacAddr pAssocStasTemp = NULL;// #include "sapApi.h"
3172 tANI_U8 sessionId = CSR_SESSION_ID_INVALID;
3173 tANI_U8 assocId = 0;
3174 tANI_U8 staCount = 0;
3175
3176 if (!limIsSmeGetAssocSTAsReqValid(pMac, &getAssocSTAsReq, (tANI_U8 *) pMsgBuf))
3177 {
3178 limLog(pMac, LOGE,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003179 FL("received invalid eWNI_SME_GET_ASSOC_STAS_REQ message"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003180 goto limAssocStaEnd;
3181 }
3182
3183 switch (getAssocSTAsReq.modId)
3184 {
3185/**
3186 case VOS_MODULE_ID_HAL:
3187 wdaPostCtrlMsg( pMac, &msgQ );
3188 return;
3189
3190 case VOS_MODULE_ID_TL:
3191 Post msg TL
3192 return;
3193*/
3194 case VOS_MODULE_ID_PE:
3195 default:
3196 break;
3197 }
3198
Jeff Johnson1250df42012-12-10 14:31:52 -08003199 // Get Associated stations from PE
Jeff Johnson295189b2012-06-20 16:38:30 -07003200 // Find PE session Entry
3201 if ((psessionEntry = peFindSessionByBssid(pMac, getAssocSTAsReq.bssId, &sessionId)) == NULL)
3202 {
3203 limLog(pMac, LOGE,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003204 FL("session does not exist for given bssId"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003205 goto limAssocStaEnd;
3206 }
3207
3208 if (psessionEntry->limSystemRole != eLIM_AP_ROLE)
3209 {
3210 limLog(pMac, LOGE,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003211 FL("Received unexpected message in state %X, in role %X"),
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303212 psessionEntry->limSmeState, psessionEntry->limSystemRole);
Jeff Johnson295189b2012-06-20 16:38:30 -07003213 goto limAssocStaEnd;
3214 }
3215
3216 // Retrieve values obtained in the request message
3217 pSapEventCallback = (tpWLAN_SAPEventCB)getAssocSTAsReq.pSapEventCallback;
3218 pAssocStasTemp = (tpSap_AssocMacAddr)getAssocSTAsReq.pAssocStasArray;
3219
3220 for (assocId = 0; assocId < psessionEntry->dph.dphHashTable.size; assocId++)// Softap dphHashTable.size = 8
3221 {
3222 pStaDs = dphGetHashEntry(pMac, assocId, &psessionEntry->dph.dphHashTable);
3223
3224 if (NULL == pStaDs)
3225 continue;
3226
3227 if (pStaDs->valid)
3228 {
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303229 vos_mem_copy((tANI_U8 *)&pAssocStasTemp->staMac,
3230 (tANI_U8 *)&pStaDs->staAddr,
3231 sizeof(v_MACADDR_t)); // Mac address
Jeff Johnson295189b2012-06-20 16:38:30 -07003232 pAssocStasTemp->assocId = (v_U8_t)pStaDs->assocId; // Association Id
3233 pAssocStasTemp->staId = (v_U8_t)pStaDs->staIndex; // Station Id
3234
Kiet Lamb1233192013-11-28 13:38:20 +05303235 vos_mem_copy((tANI_U8 *)&pAssocStasTemp->supportedRates,
Leo Chang614d2072013-08-22 14:59:44 -07003236 (tANI_U8 *)&pStaDs->supportedRates,
3237 sizeof(tSirSupportedRates));
3238 pAssocStasTemp->ShortGI40Mhz = pStaDs->htShortGI40Mhz;
3239 pAssocStasTemp->ShortGI20Mhz = pStaDs->htShortGI20Mhz;
3240 pAssocStasTemp->Support40Mhz = pStaDs->htDsssCckRate40MHzSupport;
3241
Jeff Johnson295189b2012-06-20 16:38:30 -07003242 limLog(pMac, LOG1, FL("dph Station Number = %d"), staCount+1);
Arif Hussain24bafea2013-11-15 15:10:03 -08003243 limLog(pMac, LOG1, FL("MAC = " MAC_ADDRESS_STR),
3244 MAC_ADDR_ARRAY(pStaDs->staAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07003245 limLog(pMac, LOG1, FL("Association Id = %d"),pStaDs->assocId);
3246 limLog(pMac, LOG1, FL("Station Index = %d"),pStaDs->staIndex);
3247
3248 pAssocStasTemp++;
3249 staCount++;
3250 }
3251 }
3252
3253limAssocStaEnd:
3254 // Call hdd callback with sap event to send the list of associated stations from PE
3255 if (pSapEventCallback != NULL)
3256 {
3257 sapEvent.sapHddEventCode = eSAP_ASSOC_STA_CALLBACK_EVENT;
3258 sapEvent.sapevt.sapAssocStaListEvent.module = VOS_MODULE_ID_PE;
3259 sapEvent.sapevt.sapAssocStaListEvent.noOfAssocSta = staCount;
3260 sapEvent.sapevt.sapAssocStaListEvent.pAssocStas = (tpSap_AssocMacAddr)getAssocSTAsReq.pAssocStasArray;
3261 pSapEventCallback(&sapEvent, getAssocSTAsReq.pUsrContext);
3262 }
3263}
3264
3265
3266/**
3267 * limProcessSmeGetWPSPBCSessions
3268 *
3269 *FUNCTION:
3270 * This function is called when query the WPS PBC overlap message is received
3271 *
3272 *LOGIC:
3273 * This function parses get WPS PBC overlap information message and call callback to pass
3274 * WPS PBC overlap information back to hdd.
3275 *ASSUMPTIONS:
3276 *
3277 *
3278 *NOTE:
3279 *
3280 * @param pMac Pointer to Global MAC structure
3281 * @param pMsgBuf A pointer to WPS PBC overlap query message
3282*
3283 * @return None
3284 */
3285void limProcessSmeGetWPSPBCSessions(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
3286{
3287 tSirSmeGetWPSPBCSessionsReq GetWPSPBCSessionsReq;
3288 tpPESession psessionEntry = NULL;
3289 tSap_Event sapEvent;
3290 tpWLAN_SAPEventCB pSapEventCallback = NULL;
3291 tANI_U8 sessionId = CSR_SESSION_ID_INVALID;
3292 tSirMacAddr zeroMac = {0,0,0,0,0,0};
3293
3294 sapEvent.sapevt.sapGetWPSPBCSessionEvent.status = VOS_STATUS_E_FAULT;
3295
3296 if (limIsSmeGetWPSPBCSessionsReqValid(pMac, &GetWPSPBCSessionsReq, (tANI_U8 *) pMsgBuf) != eSIR_SUCCESS)
3297 {
3298 limLog(pMac, LOGE,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003299 FL("received invalid eWNI_SME_GET_ASSOC_STAS_REQ message"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003300 goto limGetWPSPBCSessionsEnd;
3301 }
3302
Jeff Johnson1250df42012-12-10 14:31:52 -08003303 // Get Associated stations from PE
Jeff Johnson295189b2012-06-20 16:38:30 -07003304 // Find PE session Entry
3305 if ((psessionEntry = peFindSessionByBssid(pMac, GetWPSPBCSessionsReq.bssId, &sessionId)) == NULL)
3306 {
3307 limLog(pMac, LOGE,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003308 FL("session does not exist for given bssId"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003309 goto limGetWPSPBCSessionsEnd;
3310 }
3311
3312 if (psessionEntry->limSystemRole != eLIM_AP_ROLE)
3313 {
3314 limLog(pMac, LOGE,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003315 FL("Received unexpected message in role %X"),
Jeff Johnson295189b2012-06-20 16:38:30 -07003316 psessionEntry->limSystemRole);
3317 goto limGetWPSPBCSessionsEnd;
3318 }
3319
Jeff Johnson1250df42012-12-10 14:31:52 -08003320 // Call hdd callback with sap event to send the WPS PBC overlap information
Jeff Johnson295189b2012-06-20 16:38:30 -07003321 sapEvent.sapHddEventCode = eSAP_GET_WPSPBC_SESSION_EVENT;
3322 sapEvent.sapevt.sapGetWPSPBCSessionEvent.module = VOS_MODULE_ID_PE;
3323
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303324 if (vos_mem_compare( zeroMac, GetWPSPBCSessionsReq.pRemoveMac, sizeof(tSirMacAddr)))
Jeff Johnson295189b2012-06-20 16:38:30 -07003325 { //This is GetWpsSession call
3326
3327 limGetWPSPBCSessions(pMac,
3328 sapEvent.sapevt.sapGetWPSPBCSessionEvent.addr.bytes, sapEvent.sapevt.sapGetWPSPBCSessionEvent.UUID_E,
3329 &sapEvent.sapevt.sapGetWPSPBCSessionEvent.wpsPBCOverlap, psessionEntry);
3330 }
3331 else
3332 {
3333 limRemovePBCSessions(pMac, GetWPSPBCSessionsReq.pRemoveMac,psessionEntry);
3334 /* don't have to inform the HDD/Host */
3335 return;
3336 }
3337
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003338 PELOG4(limLog(pMac, LOGE, FL("wpsPBCOverlap %d"), sapEvent.sapevt.sapGetWPSPBCSessionEvent.wpsPBCOverlap);)
Jeff Johnson295189b2012-06-20 16:38:30 -07003339 PELOG4(limPrintMacAddr(pMac, sapEvent.sapevt.sapGetWPSPBCSessionEvent.addr.bytes, LOG4);)
3340
3341 sapEvent.sapevt.sapGetWPSPBCSessionEvent.status = VOS_STATUS_SUCCESS;
3342
3343limGetWPSPBCSessionsEnd:
3344 pSapEventCallback = (tpWLAN_SAPEventCB)GetWPSPBCSessionsReq.pSapEventCallback;
3345 pSapEventCallback(&sapEvent, GetWPSPBCSessionsReq.pUsrContext);
3346}
3347
Jeff Johnson295189b2012-06-20 16:38:30 -07003348
3349
3350/**
3351 * __limCounterMeasures()
3352 *
3353 * FUNCTION:
3354 * This function is called to "implement" MIC counter measure
3355 * and is *temporary* only
3356 *
3357 * LOGIC: on AP, disassoc all STA associated thru TKIP,
3358 * we don't do the proper STA disassoc sequence since the
3359 * BSS will be stoped anyway
3360 *
3361 *ASSUMPTIONS:
3362 *
3363 *NOTE:
3364 *
3365 * @param pMac Pointer to Global MAC structure
3366 * @return None
3367 */
3368
3369static void
3370__limCounterMeasures(tpAniSirGlobal pMac, tpPESession psessionEntry)
3371{
3372 tSirMacAddr mac = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
3373 if ( (psessionEntry->limSystemRole == eLIM_AP_ROLE) || (psessionEntry->limSystemRole == eLIM_BT_AMP_AP_ROLE)
3374 || (psessionEntry->limSystemRole == eLIM_BT_AMP_STA_ROLE) )
3375
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003376 limSendDisassocMgmtFrame(pMac, eSIR_MAC_MIC_FAILURE_REASON, mac, psessionEntry, FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003377
Jeff Johnson295189b2012-06-20 16:38:30 -07003378};
3379
3380
Jeff Johnson295189b2012-06-20 16:38:30 -07003381void
3382limProcessTkipCounterMeasures(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
3383{
3384 tSirSmeTkipCntrMeasReq tkipCntrMeasReq;
3385 tpPESession psessionEntry;
3386 tANI_U8 sessionId; //PE sessionId
3387
3388 if ( limTkipCntrMeasReqSerDes( pMac, &tkipCntrMeasReq, (tANI_U8 *) pMsgBuf ) != eSIR_SUCCESS )
3389 {
3390 limLog(pMac, LOGE,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003391 FL("received invalid eWNI_SME_TKIP_CNTR_MEAS_REQ message"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003392 return;
3393 }
3394
3395 if ( NULL == (psessionEntry = peFindSessionByBssid( pMac, tkipCntrMeasReq.bssId, &sessionId )) )
3396 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003397 limLog(pMac, LOGE, FL("session does not exist for given BSSID "));
Jeff Johnson295189b2012-06-20 16:38:30 -07003398 return;
3399 }
3400
3401 if ( tkipCntrMeasReq.bEnable )
3402 {
3403 __limCounterMeasures( pMac, psessionEntry );
3404 }
3405
3406 psessionEntry->bTkipCntrMeasActive = tkipCntrMeasReq.bEnable;
3407}
Jeff Johnson295189b2012-06-20 16:38:30 -07003408
3409
3410static void
3411__limHandleSmeStopBssRequest(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
3412{
3413 tSirSmeStopBssReq stopBssReq;
3414 tSirRetStatus status;
3415 tLimSmeStates prevState;
3416 tANI_U8 sessionId; //PE sessionId
3417 tpPESession psessionEntry;
3418 tANI_U8 smesessionId;
3419 tANI_U16 smetransactionId;
3420
3421 limGetSessionInfo(pMac,(tANI_U8 *)pMsgBuf,&smesessionId,&smetransactionId);
3422
3423
3424
3425 if ((limStopBssReqSerDes(pMac, &stopBssReq, (tANI_U8 *) pMsgBuf) != eSIR_SUCCESS) ||
3426 !limIsSmeStopBssReqValid(pMsgBuf))
3427 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003428 PELOGW(limLog(pMac, LOGW, FL("received invalid SME_STOP_BSS_REQ message"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07003429 /// Send Stop BSS response to host
3430 limSendSmeRsp(pMac, eWNI_SME_STOP_BSS_RSP, eSIR_SME_INVALID_PARAMETERS,smesessionId,smetransactionId);
3431 return;
3432 }
3433
3434
3435 if((psessionEntry = peFindSessionByBssid(pMac,stopBssReq.bssId,&sessionId)) == NULL)
3436 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003437 limLog(pMac, LOGW, FL("session does not exist for given BSSID "));
Jeff Johnson295189b2012-06-20 16:38:30 -07003438 limSendSmeRsp(pMac, eWNI_SME_STOP_BSS_RSP, eSIR_SME_INVALID_PARAMETERS,smesessionId,smetransactionId);
3439 return;
3440 }
3441
3442#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM //FEATURE_WLAN_DIAG_SUPPORT
3443 limDiagEventReport(pMac, WLAN_PE_DIAG_STOP_BSS_REQ_EVENT, psessionEntry, 0, 0);
3444#endif //FEATURE_WLAN_DIAG_SUPPORT
3445
3446
3447 if ((psessionEntry->limSmeState != eLIM_SME_NORMAL_STATE) || /* Added For BT -AMP Support */
3448 (psessionEntry->limSystemRole == eLIM_STA_ROLE ))
3449 {
3450 /**
3451 * Should not have received STOP_BSS_REQ in states
3452 * other than 'normal' state or on STA in Infrastructure
3453 * mode. Log error and return response to host.
3454 */
3455 limLog(pMac, LOGE,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003456 FL("received unexpected SME_STOP_BSS_REQ in state %X, for role %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07003457 psessionEntry->limSmeState, psessionEntry->limSystemRole);
3458 limPrintSmeState(pMac, LOGE, psessionEntry->limSmeState);
3459 /// Send Stop BSS response to host
3460 limSendSmeRsp(pMac, eWNI_SME_STOP_BSS_RSP, eSIR_SME_UNEXPECTED_REQ_RESULT_CODE,smesessionId,smetransactionId);
3461 return;
3462 }
3463
Jeff Johnson295189b2012-06-20 16:38:30 -07003464 if (psessionEntry->limSystemRole == eLIM_AP_ROLE )
3465 {
3466 limWPSPBCClose(pMac, psessionEntry);
3467 }
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003468 PELOGW(limLog(pMac, LOGW, FL("RECEIVED STOP_BSS_REQ with reason code=%d"), stopBssReq.reasonCode);)
Jeff Johnson295189b2012-06-20 16:38:30 -07003469
3470 prevState = psessionEntry->limSmeState;
3471
3472 psessionEntry->limSmeState = eLIM_SME_IDLE_STATE;
Jeff Johnsone7245742012-09-05 17:12:55 -07003473 MTRACE(macTrace(pMac, TRACE_CODE_SME_STATE, psessionEntry->peSessionId, psessionEntry->limSmeState));
Jeff Johnson295189b2012-06-20 16:38:30 -07003474
3475 /* Update SME session Id and Transaction Id */
3476 psessionEntry->smeSessionId = smesessionId;
3477 psessionEntry->transactionId = smetransactionId;
3478
3479 /* BTAMP_STA and STA_IN_IBSS should NOT send Disassoc frame */
3480 if ( (eLIM_STA_IN_IBSS_ROLE != psessionEntry->limSystemRole) && (eLIM_BT_AMP_STA_ROLE != psessionEntry->limSystemRole) )
3481 {
3482 tSirMacAddr bcAddr = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
3483 if ((stopBssReq.reasonCode == eSIR_SME_MIC_COUNTER_MEASURES))
3484 // Send disassoc all stations associated thru TKIP
3485 __limCounterMeasures(pMac,psessionEntry);
3486 else
Madan Mohan Koyyalamudi299b4862013-01-30 19:59:23 +05303487 limSendDisassocMgmtFrame(pMac, eSIR_MAC_DEAUTH_LEAVING_BSS_REASON, bcAddr, psessionEntry, FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003488 }
3489
3490 //limDelBss is also called as part of coalescing, when we send DEL BSS followed by Add Bss msg.
3491 pMac->lim.gLimIbssCoalescingHappened = false;
3492
3493 /* send a delBss to HAL and wait for a response */
3494 status = limDelBss(pMac, NULL,psessionEntry->bssIdx,psessionEntry);
3495
3496 if (status != eSIR_SUCCESS)
3497 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003498 PELOGE(limLog(pMac, LOGE, FL("delBss failed for bss %d"), psessionEntry->bssIdx);)
Jeff Johnson295189b2012-06-20 16:38:30 -07003499 psessionEntry->limSmeState= prevState;
3500
Jeff Johnsone7245742012-09-05 17:12:55 -07003501 MTRACE(macTrace(pMac, TRACE_CODE_SME_STATE, psessionEntry->peSessionId, psessionEntry->limSmeState));
Jeff Johnson295189b2012-06-20 16:38:30 -07003502
3503 limSendSmeRsp(pMac, eWNI_SME_STOP_BSS_RSP, eSIR_SME_STOP_BSS_FAILURE,smesessionId,smetransactionId);
3504 }
3505}
3506
3507
3508/**--------------------------------------------------------------
3509\fn __limProcessSmeStopBssReq
3510
3511\brief Wrapper for the function __limHandleSmeStopBssRequest
3512 This message will be defered until softmac come out of
3513 scan mode. Message should be handled even if we have
3514 detected radar in the current operating channel.
3515\param pMac
3516\param pMsg
3517
3518\return TRUE - If we consumed the buffer
3519 FALSE - If have defered the message.
3520 ---------------------------------------------------------------*/
3521static tANI_BOOLEAN
3522__limProcessSmeStopBssReq(tpAniSirGlobal pMac, tpSirMsgQ pMsg)
3523{
3524 if (__limIsDeferedMsgForLearn(pMac, pMsg))
3525 {
3526 /**
3527 * If message defered, buffer is not consumed yet.
3528 * So return false
3529 */
3530 return eANI_BOOLEAN_FALSE;
3531 }
3532 __limHandleSmeStopBssRequest(pMac, (tANI_U32 *) pMsg->bodyptr);
3533 return eANI_BOOLEAN_TRUE;
3534} /*** end __limProcessSmeStopBssReq() ***/
3535
3536
3537void limProcessSmeDelBssRsp(
3538 tpAniSirGlobal pMac,
3539 tANI_U32 body,tpPESession psessionEntry)
3540{
3541
3542 (void) body;
3543 SET_LIM_PROCESS_DEFD_MESGS(pMac, true);
3544 //TBD: get the sessionEntry
Ravi Joshib58ca0d2013-10-29 09:50:23 -07003545 limIbssDelete(pMac,psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07003546 dphHashTableClassInit(pMac, &psessionEntry->dph.dphHashTable);
3547 limDeletePreAuthList(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -07003548 limSendSmeRsp(pMac, eWNI_SME_STOP_BSS_RSP, eSIR_SME_SUCCESS,psessionEntry->smeSessionId,psessionEntry->transactionId);
3549 return;
3550}
3551
3552
Jeff Johnson295189b2012-06-20 16:38:30 -07003553/**---------------------------------------------------------------
3554\fn __limProcessSmeAssocCnfNew
3555\brief This function handles SME_ASSOC_CNF/SME_REASSOC_CNF
3556\ in BTAMP AP.
3557\
3558\param pMac
3559\param msgType - message type
3560\param pMsgBuf - a pointer to the SME message buffer
3561\return None
3562------------------------------------------------------------------*/
3563
3564 void
3565__limProcessSmeAssocCnfNew(tpAniSirGlobal pMac, tANI_U32 msgType, tANI_U32 *pMsgBuf)
3566{
3567 tSirSmeAssocCnf assocCnf;
3568 tpDphHashNode pStaDs = NULL;
3569 tpPESession psessionEntry= NULL;
3570 tANI_U8 sessionId;
3571
3572
3573 if(pMsgBuf == NULL)
3574 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003575 limLog(pMac, LOGE, FL("pMsgBuf is NULL "));
Jeff Johnson295189b2012-06-20 16:38:30 -07003576 goto end;
3577 }
3578
3579 if ((limAssocCnfSerDes(pMac, &assocCnf, (tANI_U8 *) pMsgBuf) == eSIR_FAILURE) ||
3580 !__limIsSmeAssocCnfValid(&assocCnf))
3581 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003582 limLog(pMac, LOGE, FL("Received invalid SME_RE(ASSOC)_CNF message "));
Jeff Johnson295189b2012-06-20 16:38:30 -07003583 goto end;
3584 }
3585
3586 if((psessionEntry = peFindSessionByBssid(pMac, assocCnf.bssId, &sessionId))== NULL)
3587 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003588 limLog(pMac, LOGE, FL("session does not exist for given bssId"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003589 goto end;
3590 }
3591
3592 if ( ((psessionEntry->limSystemRole != eLIM_AP_ROLE) && (psessionEntry->limSystemRole != eLIM_BT_AMP_AP_ROLE)) ||
3593 ((psessionEntry->limSmeState != eLIM_SME_NORMAL_STATE) && (psessionEntry->limSmeState != eLIM_SME_NORMAL_CHANNEL_SCAN_STATE)))
3594 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003595 limLog(pMac, LOGE, FL("Received unexpected message %X in state %X, in role %X"),
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303596 msgType, psessionEntry->limSmeState, psessionEntry->limSystemRole);
Jeff Johnson295189b2012-06-20 16:38:30 -07003597 goto end;
3598 }
3599
3600 pStaDs = dphGetHashEntry(pMac, assocCnf.aid, &psessionEntry->dph.dphHashTable);
3601
3602 if (pStaDs == NULL)
3603 {
3604 limLog(pMac, LOG1,
3605 FL("Received invalid message %X due to no STA context, for aid %d, peer "),
3606 msgType, assocCnf.aid);
3607 limPrintMacAddr(pMac, assocCnf.peerMacAddr, LOG1);
3608
3609 /*
3610 ** send a DISASSOC_IND message to WSM to make sure
3611 ** the state in WSM and LIM is the same
3612 **/
3613 limSendSmeDisassocNtf( pMac, assocCnf.peerMacAddr, eSIR_SME_STA_NOT_ASSOCIATED,
3614 eLIM_PEER_ENTITY_DISASSOC, assocCnf.aid,psessionEntry->smeSessionId,psessionEntry->transactionId,psessionEntry);
3615 goto end;
3616 }
3617 if ((pStaDs &&
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303618 (( !vos_mem_compare( (tANI_U8 *) pStaDs->staAddr,
Jeff Johnson295189b2012-06-20 16:38:30 -07003619 (tANI_U8 *) assocCnf.peerMacAddr,
3620 sizeof(tSirMacAddr)) ) ||
3621 (pStaDs->mlmStaContext.mlmState != eLIM_MLM_WT_ASSOC_CNF_STATE) ||
3622 ((pStaDs->mlmStaContext.subType == LIM_ASSOC) &&
3623 (msgType != eWNI_SME_ASSOC_CNF)) ||
3624 ((pStaDs->mlmStaContext.subType == LIM_REASSOC) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07003625 (msgType != eWNI_SME_ASSOC_CNF))))) // since softap is passing this as ASSOC_CNF and subtype differs
Jeff Johnson295189b2012-06-20 16:38:30 -07003626 {
3627 limLog(pMac, LOG1,
3628 FL("Received invalid message %X due to peerMacAddr mismatched or not in eLIM_MLM_WT_ASSOC_CNF_STATE state, for aid %d, peer "),
3629 msgType, assocCnf.aid);
3630 limPrintMacAddr(pMac, assocCnf.peerMacAddr, LOG1);
3631 goto end;
3632 }
3633
3634 /*
3635 ** Deactivate/delet CNF_WAIT timer since ASSOC_CNF
3636 ** has been received
3637 **/
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003638 limLog(pMac, LOG1, FL("Received SME_ASSOC_CNF. Delete Timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003639 limDeactivateAndChangePerStaIdTimer(pMac, eLIM_CNF_WAIT_TIMER, pStaDs->assocId);
3640
3641 if (assocCnf.statusCode == eSIR_SME_SUCCESS)
3642 {
3643 /* In BTAMP-AP, PE already finished the WDA_ADD_STA sequence
3644 * when it had received Assoc Request frame. Now, PE just needs to send
3645 * Association Response frame to the requesting BTAMP-STA.
3646 */
3647 pStaDs->mlmStaContext.mlmState = eLIM_MLM_LINK_ESTABLISHED_STATE;
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003648 limLog(pMac, LOG1, FL("sending Assoc Rsp frame to STA (assoc id=%d) "), pStaDs->assocId);
Jeff Johnson295189b2012-06-20 16:38:30 -07003649 limSendAssocRspMgmtFrame( pMac, eSIR_SUCCESS, pStaDs->assocId, pStaDs->staAddr,
3650 pStaDs->mlmStaContext.subType, pStaDs, psessionEntry);
3651 goto end;
3652 } // (assocCnf.statusCode == eSIR_SME_SUCCESS)
3653 else
3654 {
3655 // SME_ASSOC_CNF status is non-success, so STA is not allowed to be associated
3656 /*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*/
3657 if(!pStaDs->mlmStaContext.updateContext)
3658 pStaDs->mlmStaContext.updateContext = 1;
3659 limRejectAssociation(pMac, pStaDs->staAddr,
3660 pStaDs->mlmStaContext.subType,
3661 true, pStaDs->mlmStaContext.authType,
3662 pStaDs->assocId, true,
3663 eSIR_MAC_UNSPEC_FAILURE_STATUS, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07003664 }
3665
3666end:
3667 if((psessionEntry != NULL) && (pStaDs != NULL))
3668 {
3669 if ( psessionEntry->parsedAssocReq[pStaDs->assocId] != NULL )
3670 {
3671 if ( ((tpSirAssocReq)(psessionEntry->parsedAssocReq[pStaDs->assocId]))->assocReqFrame)
3672 {
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303673 vos_mem_free(((tpSirAssocReq)
3674 (psessionEntry->parsedAssocReq[pStaDs->assocId]))->assocReqFrame);
Jeff Johnson295189b2012-06-20 16:38:30 -07003675 ((tpSirAssocReq)(psessionEntry->parsedAssocReq[pStaDs->assocId]))->assocReqFrame = NULL;
3676 }
3677
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303678 vos_mem_free(psessionEntry->parsedAssocReq[pStaDs->assocId]);
Jeff Johnson295189b2012-06-20 16:38:30 -07003679 psessionEntry->parsedAssocReq[pStaDs->assocId] = NULL;
3680 }
3681 }
3682
3683} /*** end __limProcessSmeAssocCnfNew() ***/
3684
3685
Jeff Johnson295189b2012-06-20 16:38:30 -07003686
3687
3688static void
3689__limProcessSmeAddtsReq(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
3690{
3691 tpDphHashNode pStaDs;
3692 tSirMacAddr peerMac;
3693 tpSirAddtsReq pSirAddts;
3694 tANI_U32 timeout;
3695 tpPESession psessionEntry;
3696 tANI_U8 sessionId; //PE sessionId
3697 tANI_U8 smesessionId;
3698 tANI_U16 smetransactionId;
3699
3700
3701 if(pMsgBuf == NULL)
3702 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003703 limLog(pMac, LOGE,FL("Buffer is Pointing to NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003704 return;
3705 }
3706
3707 limGetSessionInfo(pMac,(tANI_U8 *)pMsgBuf,&smesessionId,&smetransactionId);
3708
3709 pSirAddts = (tpSirAddtsReq) pMsgBuf;
3710
3711 if((psessionEntry = peFindSessionByBssid(pMac, pSirAddts->bssId,&sessionId))== NULL)
3712 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003713 limLog(pMac, LOGE, "Session Does not exist for given bssId");
Jeff Johnson295189b2012-06-20 16:38:30 -07003714 return;
3715 }
3716#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM //FEATURE_WLAN_DIAG_SUPPORT
3717 limDiagEventReport(pMac, WLAN_PE_DIAG_ADDTS_REQ_EVENT, psessionEntry, 0, 0);
3718#endif //FEATURE_WLAN_DIAG_SUPPORT
3719
3720
3721
3722 /* if sta
3723 * - verify assoc state
3724 * - send addts request to ap
3725 * - wait for addts response from ap
3726 * if ap, just ignore with error log
3727 */
3728 PELOG1(limLog(pMac, LOG1,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003729 FL("Received SME_ADDTS_REQ (TSid %d, UP %d)"),
Jeff Johnson295189b2012-06-20 16:38:30 -07003730 pSirAddts->req.tspec.tsinfo.traffic.tsid,
3731 pSirAddts->req.tspec.tsinfo.traffic.userPrio);)
3732
3733 if ((psessionEntry->limSystemRole != eLIM_STA_ROLE)&&(psessionEntry->limSystemRole != eLIM_BT_AMP_STA_ROLE))
3734 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003735 PELOGE(limLog(pMac, LOGE, "AddTs received on AP - ignoring");)
Jeff Johnson295189b2012-06-20 16:38:30 -07003736 limSendSmeAddtsRsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE, psessionEntry, pSirAddts->req.tspec,
3737 smesessionId,smetransactionId);
3738 return;
3739 }
3740
3741 //Ignore the request if STA is in 11B mode.
3742 if(psessionEntry->dot11mode == WNI_CFG_DOT11_MODE_11B)
3743 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003744 PELOGE(limLog(pMac, LOGE, "AddTS received while Dot11Mode is 11B - ignoring");)
Jeff Johnson295189b2012-06-20 16:38:30 -07003745 limSendSmeAddtsRsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE, psessionEntry, pSirAddts->req.tspec,
3746 smesessionId,smetransactionId);
3747 return;
3748 }
3749
3750
3751 pStaDs = dphGetHashEntry(pMac, DPH_STA_HASH_INDEX_PEER, &psessionEntry->dph.dphHashTable);
3752
3753 if(pStaDs == NULL)
3754 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003755 PELOGE(limLog(pMac, LOGE, "Cannot find AP context for addts req");)
Jeff Johnson295189b2012-06-20 16:38:30 -07003756 limSendSmeAddtsRsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE, psessionEntry, pSirAddts->req.tspec,
3757 smesessionId,smetransactionId);
3758 return;
3759 }
3760
3761 if ((! pStaDs->valid) ||
3762 (pStaDs->mlmStaContext.mlmState != eLIM_MLM_LINK_ESTABLISHED_STATE))
3763 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003764 PELOGE(limLog(pMac, LOGE, "AddTs received in invalid MLM state");)
Jeff Johnson295189b2012-06-20 16:38:30 -07003765 limSendSmeAddtsRsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE, psessionEntry, pSirAddts->req.tspec,
3766 smesessionId,smetransactionId);
3767 return;
3768 }
3769
3770 pSirAddts->req.wsmTspecPresent = 0;
3771 pSirAddts->req.wmeTspecPresent = 0;
3772 pSirAddts->req.lleTspecPresent = 0;
3773
3774 if ((pStaDs->wsmEnabled) &&
3775 (pSirAddts->req.tspec.tsinfo.traffic.accessPolicy != SIR_MAC_ACCESSPOLICY_EDCA))
3776 pSirAddts->req.wsmTspecPresent = 1;
3777 else if (pStaDs->wmeEnabled)
3778 pSirAddts->req.wmeTspecPresent = 1;
3779 else if (pStaDs->lleEnabled)
3780 pSirAddts->req.lleTspecPresent = 1;
3781 else
3782 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003783 PELOGW(limLog(pMac, LOGW, FL("ADDTS_REQ ignore - qos is disabled"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07003784 limSendSmeAddtsRsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE, psessionEntry, pSirAddts->req.tspec,
3785 smesessionId,smetransactionId);
3786 return;
3787 }
3788
3789 if ((psessionEntry->limSmeState != eLIM_SME_ASSOCIATED_STATE) &&
3790 (psessionEntry->limSmeState != eLIM_SME_LINK_EST_STATE))
3791 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003792 limLog(pMac, LOGE, "AddTs received in invalid LIMsme state (%d)",
Jeff Johnson295189b2012-06-20 16:38:30 -07003793 psessionEntry->limSmeState);
3794 limSendSmeAddtsRsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE, psessionEntry, pSirAddts->req.tspec,
3795 smesessionId,smetransactionId);
3796 return;
3797 }
3798
3799 if (pMac->lim.gLimAddtsSent)
3800 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003801 limLog(pMac, LOGE, "Addts (token %d, tsid %d, up %d) is still pending",
Jeff Johnson295189b2012-06-20 16:38:30 -07003802 pMac->lim.gLimAddtsReq.req.dialogToken,
3803 pMac->lim.gLimAddtsReq.req.tspec.tsinfo.traffic.tsid,
3804 pMac->lim.gLimAddtsReq.req.tspec.tsinfo.traffic.userPrio);
3805 limSendSmeAddtsRsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE, psessionEntry, pSirAddts->req.tspec,
3806 smesessionId,smetransactionId);
3807 return;
3808 }
3809
3810 #if 0
3811 val = sizeof(tSirMacAddr);
3812 if (wlan_cfgGetStr(pMac, WNI_CFG_BSSID, peerMac, &val) != eSIR_SUCCESS)
3813 {
3814 /// Could not get BSSID from CFG. Log error.
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003815 limLog(pMac, LOGP, FL("could not retrieve BSSID"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003816 return;
3817 }
3818 #endif
3819 sirCopyMacAddr(peerMac,psessionEntry->bssId);
3820
3821 // save the addts request
3822 pMac->lim.gLimAddtsSent = true;
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303823 vos_mem_copy( (tANI_U8 *) &pMac->lim.gLimAddtsReq, (tANI_U8 *) pSirAddts, sizeof(tSirAddtsReq));
Jeff Johnson295189b2012-06-20 16:38:30 -07003824
3825 // ship out the message now
3826 limSendAddtsReqActionFrame(pMac, peerMac, &pSirAddts->req,
3827 psessionEntry);
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003828 PELOG1(limLog(pMac, LOG1, "Sent ADDTS request");)
Jeff Johnson295189b2012-06-20 16:38:30 -07003829
3830 // start a timer to wait for the response
3831 if (pSirAddts->timeout)
3832 timeout = pSirAddts->timeout;
3833 else if (wlan_cfgGetInt(pMac, WNI_CFG_ADDTS_RSP_TIMEOUT, &timeout) != eSIR_SUCCESS)
3834 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003835 limLog(pMac, LOGP, FL("Unable to get Cfg param %d (Addts Rsp Timeout)"),
Jeff Johnson295189b2012-06-20 16:38:30 -07003836 WNI_CFG_ADDTS_RSP_TIMEOUT);
3837 return;
3838 }
3839
3840 timeout = SYS_MS_TO_TICKS(timeout);
3841 if (tx_timer_change(&pMac->lim.limTimers.gLimAddtsRspTimer, timeout, 0) != TX_SUCCESS)
3842 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003843 limLog(pMac, LOGP, FL("AddtsRsp timer change failed!"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003844 return;
3845 }
3846 pMac->lim.gLimAddtsRspTimerCount++;
3847 if (tx_timer_change_context(&pMac->lim.limTimers.gLimAddtsRspTimer,
3848 pMac->lim.gLimAddtsRspTimerCount) != TX_SUCCESS)
3849 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003850 limLog(pMac, LOGP, FL("AddtsRsp timer change failed!"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003851 return;
3852 }
Jeff Johnsone7245742012-09-05 17:12:55 -07003853 MTRACE(macTrace(pMac, TRACE_CODE_TIMER_ACTIVATE, psessionEntry->peSessionId, eLIM_ADDTS_RSP_TIMER));
Jeff Johnson295189b2012-06-20 16:38:30 -07003854
3855 //add the sessionId to the timer object
3856 pMac->lim.limTimers.gLimAddtsRspTimer.sessionId = sessionId;
3857 if (tx_timer_activate(&pMac->lim.limTimers.gLimAddtsRspTimer) != TX_SUCCESS)
3858 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003859 limLog(pMac, LOGP, FL("AddtsRsp timer activation failed!"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003860 return;
3861 }
3862 return;
3863}
3864
3865
3866static void
3867__limProcessSmeDeltsReq(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
3868{
3869 tSirMacAddr peerMacAddr;
3870 tANI_U8 ac;
3871 tSirMacTSInfo *pTsinfo;
3872 tpSirDeltsReq pDeltsReq = (tpSirDeltsReq) pMsgBuf;
3873 tpDphHashNode pStaDs = NULL;
3874 tpPESession psessionEntry;
3875 tANI_U8 sessionId;
3876 tANI_U32 status = eSIR_SUCCESS;
3877 tANI_U8 smesessionId;
3878 tANI_U16 smetransactionId;
3879
3880 limGetSessionInfo(pMac,(tANI_U8 *)pMsgBuf,&smesessionId,&smetransactionId);
3881
3882 if((psessionEntry = peFindSessionByBssid(pMac, pDeltsReq->bssId, &sessionId))== NULL)
3883 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003884 limLog(pMac, LOGE, "Session Does not exist for given bssId");
Jeff Johnson295189b2012-06-20 16:38:30 -07003885 status = eSIR_FAILURE;
3886 goto end;
3887 }
3888#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM //FEATURE_WLAN_DIAG_SUPPORT
3889 limDiagEventReport(pMac, WLAN_PE_DIAG_DELTS_REQ_EVENT, psessionEntry, 0, 0);
3890#endif //FEATURE_WLAN_DIAG_SUPPORT
3891
3892
3893 if (eSIR_SUCCESS != limValidateDeltsReq(pMac, pDeltsReq, peerMacAddr,psessionEntry))
3894 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003895 PELOGE(limLog(pMac, LOGE, FL("limValidateDeltsReq failed"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07003896 status = eSIR_FAILURE;
3897 limSendSmeDeltsRsp(pMac, pDeltsReq, eSIR_FAILURE,psessionEntry,smesessionId,smetransactionId);
3898 return;
3899 }
3900
Arif Hussaina7c8e412013-11-20 11:06:42 -08003901 PELOG1(limLog(pMac, LOG1, FL("Sent DELTS request to station with "
3902 "assocId = %d MacAddr = "MAC_ADDRESS_STR),
3903 pDeltsReq->aid, MAC_ADDR_ARRAY(peerMacAddr));)
Jeff Johnson295189b2012-06-20 16:38:30 -07003904
3905 limSendDeltsReqActionFrame(pMac, peerMacAddr, pDeltsReq->req.wmeTspecPresent, &pDeltsReq->req.tsinfo, &pDeltsReq->req.tspec,
3906 psessionEntry);
3907
3908 pTsinfo = pDeltsReq->req.wmeTspecPresent ? &pDeltsReq->req.tspec.tsinfo : &pDeltsReq->req.tsinfo;
3909
3910 /* We've successfully send DELTS frame to AP. Update the
3911 * dynamic UAPSD mask. The AC for this TSPEC to be deleted
3912 * is no longer trigger enabled or delivery enabled
3913 */
3914 limSetTspecUapsdMask(pMac, pTsinfo, CLEAR_UAPSD_MASK);
3915
3916 /* We're deleting the TSPEC, so this particular AC is no longer
3917 * admitted. PE needs to downgrade the EDCA
3918 * parameters(for the AC for which TS is being deleted) to the
3919 * next best AC for which ACM is not enabled, and send the
3920 * updated values to HAL.
3921 */
3922 ac = upToAc(pTsinfo->traffic.userPrio);
3923
3924 if(pTsinfo->traffic.direction == SIR_MAC_DIRECTION_UPLINK)
3925 {
3926 pMac->lim.gAcAdmitMask[SIR_MAC_DIRECTION_UPLINK] &= ~(1 << ac);
3927 }
3928 else if(pTsinfo->traffic.direction == SIR_MAC_DIRECTION_DNLINK)
3929 {
3930 pMac->lim.gAcAdmitMask[SIR_MAC_DIRECTION_DNLINK] &= ~(1 << ac);
3931 }
3932 else if(pTsinfo->traffic.direction == SIR_MAC_DIRECTION_BIDIR)
3933 {
3934 pMac->lim.gAcAdmitMask[SIR_MAC_DIRECTION_UPLINK] &= ~(1 << ac);
3935 pMac->lim.gAcAdmitMask[SIR_MAC_DIRECTION_DNLINK] &= ~(1 << ac);
3936 }
3937
3938 limSetActiveEdcaParams(pMac, psessionEntry->gLimEdcaParams, psessionEntry);
3939
3940 pStaDs = dphGetHashEntry(pMac, DPH_STA_HASH_INDEX_PEER, &psessionEntry->dph.dphHashTable);
3941 if (pStaDs != NULL)
3942 {
3943 if (pStaDs->aniPeer == eANI_BOOLEAN_TRUE)
3944 limSendEdcaParams(pMac, psessionEntry->gLimEdcaParamsActive, pStaDs->bssId, eANI_BOOLEAN_TRUE);
3945 else
3946 limSendEdcaParams(pMac, psessionEntry->gLimEdcaParamsActive, pStaDs->bssId, eANI_BOOLEAN_FALSE);
3947 status = eSIR_SUCCESS;
3948 }
3949 else
3950 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003951 limLog(pMac, LOGE, FL("Self entry missing in Hash Table "));
Jeff Johnson295189b2012-06-20 16:38:30 -07003952 status = eSIR_FAILURE;
3953 }
3954#ifdef FEATURE_WLAN_CCX
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07003955#ifdef FEATURE_WLAN_CCX_UPLOAD
3956 limSendSmeTsmIEInd(pMac, psessionEntry, 0, 0, 0);
3957#else
Jeff Johnson295189b2012-06-20 16:38:30 -07003958 limDeactivateAndChangeTimer(pMac,eLIM_TSM_TIMER);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07003959#endif /* FEATURE_WLAN_CCX_UPLOAD */
Jeff Johnson295189b2012-06-20 16:38:30 -07003960#endif
3961
3962 // send an sme response back
3963 end:
3964 limSendSmeDeltsRsp(pMac, pDeltsReq, eSIR_SUCCESS,psessionEntry,smesessionId,smetransactionId);
3965}
3966
3967
3968void
3969limProcessSmeAddtsRspTimeout(tpAniSirGlobal pMac, tANI_U32 param)
3970{
3971 //fetch the sessionEntry based on the sessionId
3972 tpPESession psessionEntry;
3973 if((psessionEntry = peFindSessionBySessionId(pMac, pMac->lim.limTimers.gLimAddtsRspTimer.sessionId))== NULL)
3974 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003975 limLog(pMac, LOGP,FL("Session Does not exist for given sessionID"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003976 return;
3977 }
3978
3979 if ( (psessionEntry->limSystemRole != eLIM_STA_ROLE) && (psessionEntry->limSystemRole != eLIM_BT_AMP_STA_ROLE) )
3980 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003981 limLog(pMac, LOGW, "AddtsRspTimeout in non-Sta role (%d)", psessionEntry->limSystemRole);
Jeff Johnson295189b2012-06-20 16:38:30 -07003982 pMac->lim.gLimAddtsSent = false;
3983 return;
3984 }
3985
3986 if (! pMac->lim.gLimAddtsSent)
3987 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003988 PELOGW(limLog(pMac, LOGW, "AddtsRspTimeout but no AddtsSent");)
Jeff Johnson295189b2012-06-20 16:38:30 -07003989 return;
3990 }
3991
3992 if (param != pMac->lim.gLimAddtsRspTimerCount)
3993 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003994 limLog(pMac, LOGE, FL("Invalid AddtsRsp Timer count %d (exp %d)"),
Jeff Johnson295189b2012-06-20 16:38:30 -07003995 param, pMac->lim.gLimAddtsRspTimerCount);
3996 return;
3997 }
3998
3999 // this a real response timeout
4000 pMac->lim.gLimAddtsSent = false;
4001 pMac->lim.gLimAddtsRspTimerCount++;
4002
4003 limSendSmeAddtsRsp(pMac, true, eSIR_SME_ADDTS_RSP_TIMEOUT, psessionEntry, pMac->lim.gLimAddtsReq.req.tspec,
4004 psessionEntry->smeSessionId, psessionEntry->transactionId);
4005}
4006
4007
4008/**
4009 * __limProcessSmeStatsRequest()
4010 *
4011 *FUNCTION:
4012 *
4013 *
4014 *NOTE:
4015 *
4016 * @param pMac Pointer to Global MAC structure
4017 * @param *pMsgBuf A pointer to the SME message buffer
4018 * @return None
4019 */
4020static void
4021__limProcessSmeStatsRequest(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
4022{
4023 tpAniGetStatsReq pStatsReq;
4024 tSirMsgQ msgQ;
4025 tpPESession psessionEntry;
4026 tANI_U8 sessionId;
4027
4028
4029 if(pMsgBuf == NULL)
4030 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004031 limLog(pMac, LOGE,FL("Buffer is Pointing to NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004032 return;
4033 }
4034
4035 pStatsReq = (tpAniGetStatsReq) pMsgBuf;
4036
4037 if((psessionEntry = peFindSessionByBssid(pMac,pStatsReq->bssId,&sessionId))== NULL)
4038 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004039 limLog(pMac, LOGE, FL("session does not exist for given bssId"));
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304040 vos_mem_free( pMsgBuf );
Leela Venkata Kiran Kumar Reddy Chiralad6c0fe22013-12-11 19:10:50 -08004041 pMsgBuf = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004042 return;
4043 }
4044
4045
4046
4047 switch(pStatsReq->msgType)
4048 {
4049 //Add Lim stats here. and send reqsponse.
4050
4051 //HAL maintained Stats.
4052 case eWNI_SME_STA_STAT_REQ:
4053 msgQ.type = WDA_STA_STAT_REQ;
4054 break;
4055 case eWNI_SME_AGGR_STAT_REQ:
4056 msgQ.type = WDA_AGGR_STAT_REQ;
4057 break;
4058 case eWNI_SME_GLOBAL_STAT_REQ:
4059 msgQ.type = WDA_GLOBAL_STAT_REQ;
4060 break;
4061 case eWNI_SME_STAT_SUMM_REQ:
4062 msgQ.type = WDA_STAT_SUMM_REQ;
4063 break;
4064 default: //Unknown request.
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004065 PELOGE(limLog(pMac, LOGE, "Unknown Statistics request");)
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304066 vos_mem_free( pMsgBuf );
Leela Venkata Kiran Kumar Reddy Chiralad6c0fe22013-12-11 19:10:50 -08004067 pMsgBuf = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004068 return;
4069 }
4070
Jeff Johnson295189b2012-06-20 16:38:30 -07004071 msgQ.reserved = 0;
4072 msgQ.bodyptr = pMsgBuf;
4073 msgQ.bodyval = 0;
Leela Venkata Kiran Kumar Reddy Chirala68a6abe2013-02-28 07:43:16 -08004074 if(NULL == psessionEntry)
4075 {
4076 MTRACE(macTraceMsgTx(pMac, NO_SESSION, msgQ.type));
4077 }
4078 else
4079 {
4080 MTRACE(macTraceMsgTx(pMac, psessionEntry->peSessionId, msgQ.type));
4081 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004082 if( eSIR_SUCCESS != (wdaPostCtrlMsg( pMac, &msgQ ))){
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004083 limLog(pMac, LOGP, "Unable to forward request");
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304084 vos_mem_free( pMsgBuf );
Leela Venkata Kiran Kumar Reddy Chiralad6c0fe22013-12-11 19:10:50 -08004085 pMsgBuf = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004086 return;
4087 }
4088
4089 return;
4090}
4091
4092
4093/**
4094 * __limProcessSmeGetStatisticsRequest()
4095 *
4096 *FUNCTION:
4097 *
4098 *
4099 *NOTE:
4100 *
4101 * @param pMac Pointer to Global MAC structure
4102 * @param *pMsgBuf A pointer to the SME message buffer
4103 * @return None
4104 */
4105static void
4106__limProcessSmeGetStatisticsRequest(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
4107{
4108 tpAniGetPEStatsReq pPEStatsReq;
4109 tSirMsgQ msgQ;
4110
4111 pPEStatsReq = (tpAniGetPEStatsReq) pMsgBuf;
4112
4113 //pPEStatsReq->msgType should be eWNI_SME_GET_STATISTICS_REQ
4114
4115 msgQ.type = WDA_GET_STATISTICS_REQ;
4116
Jeff Johnson295189b2012-06-20 16:38:30 -07004117 msgQ.reserved = 0;
4118 msgQ.bodyptr = pMsgBuf;
4119 msgQ.bodyval = 0;
Jeff Johnsone7245742012-09-05 17:12:55 -07004120 MTRACE(macTraceMsgTx(pMac, NO_SESSION, msgQ.type));
Jeff Johnson295189b2012-06-20 16:38:30 -07004121
4122 if( eSIR_SUCCESS != (wdaPostCtrlMsg( pMac, &msgQ ))){
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304123 vos_mem_free( pMsgBuf );
Leela Venkata Kiran Kumar Reddy Chiralad6c0fe22013-12-11 19:10:50 -08004124 pMsgBuf = NULL;
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004125 limLog(pMac, LOGP, "Unable to forward request");
Jeff Johnson295189b2012-06-20 16:38:30 -07004126 return;
4127 }
4128
4129 return;
4130}
4131
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004132#if defined(FEATURE_WLAN_CCX) && defined(FEATURE_WLAN_CCX_UPLOAD)
4133/**
4134 *FUNCTION: __limProcessSmeGetTsmStatsRequest()
4135 *
4136 *NOTE:
4137 *
4138 * @param pMac Pointer to Global MAC structure
4139 * @param *pMsgBuf A pointer to the SME message buffer
4140 * @return None
4141 */
4142static void
4143__limProcessSmeGetTsmStatsRequest(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
4144{
4145 tSirMsgQ msgQ;
4146
4147 msgQ.type = WDA_TSM_STATS_REQ;
4148 msgQ.reserved = 0;
4149 msgQ.bodyptr = pMsgBuf;
4150 msgQ.bodyval = 0;
4151 MTRACE(macTraceMsgTx(pMac, NO_SESSION, msgQ.type));
4152
4153 if( eSIR_SUCCESS != (wdaPostCtrlMsg( pMac, &msgQ ))){
4154 vos_mem_free( pMsgBuf );
Leela Venkata Kiran Kumar Reddy Chiralad6c0fe22013-12-11 19:10:50 -08004155 pMsgBuf = NULL;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004156 limLog(pMac, LOGP, "Unable to forward request");
4157 return;
4158 }
4159}
4160#endif /* FEATURE_WLAN_CCX && FEATURE_WLAN_CCX_UPLOAD */
4161
4162
Jeff Johnson295189b2012-06-20 16:38:30 -07004163
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08004164#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_CCX || defined(FEATURE_WLAN_LFR)
4165/**
4166 * __limProcessSmeGetRoamRssiRequest()
4167 *
4168 *FUNCTION:
4169 *
4170 *
4171 *NOTE:
4172 *
4173 * @param pMac Pointer to Global MAC structure
4174 * @param *pMsgBuf A pointer to the SME message buffer
4175 * @return None
4176 */
4177static void
4178__limProcessSmeGetRoamRssiRequest(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
4179{
4180 tpAniGetRssiReq pPEGetRoamRssiReq = NULL;
4181 tSirMsgQ msgQ;
4182
4183 pPEGetRoamRssiReq = (tpAniGetRssiReq) pMsgBuf;
4184 msgQ.type = WDA_GET_ROAM_RSSI_REQ;
4185
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08004186 msgQ.reserved = 0;
4187 msgQ.bodyptr = pMsgBuf;
4188 msgQ.bodyval = 0;
4189 MTRACE(macTraceMsgTx(pMac, NO_SESSION, msgQ.type));
4190
4191 if( eSIR_SUCCESS != (wdaPostCtrlMsg( pMac, &msgQ ))){
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304192 vos_mem_free( pMsgBuf );
Leela Venkata Kiran Kumar Reddy Chiralad6c0fe22013-12-11 19:10:50 -08004193 pMsgBuf = NULL;
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004194 limLog(pMac, LOGP, "Unable to forward request");
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08004195 return;
4196 }
4197
4198 return;
4199}
4200#endif
4201
4202
Jeff Johnson295189b2012-06-20 16:38:30 -07004203static void
4204__limProcessSmeUpdateAPWPSIEs(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
4205{
4206 tpSirUpdateAPWPSIEsReq pUpdateAPWPSIEsReq;
4207 tpPESession psessionEntry;
4208 tANI_U8 sessionId; //PE sessionID
4209
4210 PELOG1(limLog(pMac, LOG1,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004211 FL("received UPDATE_APWPSIEs_REQ message")););
Jeff Johnson295189b2012-06-20 16:38:30 -07004212
4213 if(pMsgBuf == NULL)
4214 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004215 limLog(pMac, LOGE,FL("Buffer is Pointing to NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004216 return;
4217 }
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08004218
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304219 pUpdateAPWPSIEsReq = vos_mem_malloc(sizeof(tSirUpdateAPWPSIEsReq));
4220 if ( NULL == pUpdateAPWPSIEsReq )
Jeff Johnson295189b2012-06-20 16:38:30 -07004221 {
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304222 limLog(pMac, LOGP, FL("call to AllocateMemory failed for pUpdateAPWPSIEsReq"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004223 return;
4224 }
4225
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08004226 if ((limUpdateAPWPSIEsReqSerDes(pMac, pUpdateAPWPSIEsReq, (tANI_U8 *) pMsgBuf) == eSIR_FAILURE))
Jeff Johnson295189b2012-06-20 16:38:30 -07004227 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004228 limLog(pMac, LOGW, FL("received invalid SME_SETCONTEXT_REQ message"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004229 goto end;
4230 }
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08004231
Jeff Johnson295189b2012-06-20 16:38:30 -07004232 if((psessionEntry = peFindSessionByBssid(pMac, pUpdateAPWPSIEsReq->bssId, &sessionId)) == NULL)
4233 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004234 limLog(pMac, LOGW, FL("Session does not exist for given BSSID"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004235 goto end;
4236 }
4237
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304238 vos_mem_copy( &psessionEntry->APWPSIEs, &pUpdateAPWPSIEsReq->APWPSIEs, sizeof(tSirAPWPSIEs));
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08004239
Jeff Johnson295189b2012-06-20 16:38:30 -07004240 schSetFixedBeaconFields(pMac, psessionEntry);
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08004241 limSendBeaconInd(pMac, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07004242
4243end:
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304244 vos_mem_free( pUpdateAPWPSIEsReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07004245 return;
4246} /*** end __limProcessSmeUpdateAPWPSIEs(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf) ***/
4247
4248static void
4249__limProcessSmeHideSSID(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
4250{
4251 tpSirUpdateParams pUpdateParams;
4252 tpPESession psessionEntry;
4253
4254 PELOG1(limLog(pMac, LOG1,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004255 FL("received HIDE_SSID message")););
Jeff Johnson295189b2012-06-20 16:38:30 -07004256
4257 if(pMsgBuf == NULL)
4258 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004259 limLog(pMac, LOGE,FL("Buffer is Pointing to NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004260 return;
4261 }
4262
4263 pUpdateParams = (tpSirUpdateParams)pMsgBuf;
4264
4265 if((psessionEntry = peFindSessionBySessionId(pMac, pUpdateParams->sessionId)) == NULL)
4266 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004267 limLog(pMac, LOGW, "Session does not exist for given sessionId %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07004268 pUpdateParams->sessionId);
4269 return;
4270 }
4271
4272 /* Update the session entry */
4273 psessionEntry->ssidHidden = pUpdateParams->ssidHidden;
4274
4275 /* Update beacon */
4276 schSetFixedBeaconFields(pMac, psessionEntry);
4277 limSendBeaconInd(pMac, psessionEntry);
4278
4279 return;
4280} /*** end __limProcessSmeHideSSID(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf) ***/
4281
4282static void
4283__limProcessSmeSetWPARSNIEs(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
4284{
4285 tpSirUpdateAPWPARSNIEsReq pUpdateAPWPARSNIEsReq;
4286 tpPESession psessionEntry;
4287 tANI_U8 sessionId; //PE sessionID
4288
4289 if(pMsgBuf == NULL)
4290 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004291 limLog(pMac, LOGE,FL("Buffer is Pointing to NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004292 return;
4293 }
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304294
4295 pUpdateAPWPARSNIEsReq = vos_mem_malloc(sizeof(tSirUpdateAPWPSIEsReq));
4296 if ( NULL == pUpdateAPWPARSNIEsReq )
Jeff Johnson295189b2012-06-20 16:38:30 -07004297 {
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304298 limLog(pMac, LOGP, FL("call to AllocateMemory failed for pUpdateAPWPARSNIEsReq"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004299 return;
4300 }
4301
4302 if ((limUpdateAPWPARSNIEsReqSerDes(pMac, pUpdateAPWPARSNIEsReq, (tANI_U8 *) pMsgBuf) == eSIR_FAILURE))
4303 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004304 limLog(pMac, LOGW, FL("received invalid SME_SETCONTEXT_REQ message"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004305 goto end;
4306 }
4307
4308 if((psessionEntry = peFindSessionByBssid(pMac, pUpdateAPWPARSNIEsReq->bssId, &sessionId)) == NULL)
4309 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004310 limLog(pMac, LOGW, FL("Session does not exist for given BSSID"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004311 goto end;
4312 }
4313
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304314 vos_mem_copy(&psessionEntry->pLimStartBssReq->rsnIE,
4315 &pUpdateAPWPARSNIEsReq->APWPARSNIEs, sizeof(tSirRSNie));
Jeff Johnson295189b2012-06-20 16:38:30 -07004316
4317 limSetRSNieWPAiefromSmeStartBSSReqMessage(pMac, &psessionEntry->pLimStartBssReq->rsnIE, psessionEntry);
4318
4319 psessionEntry->pLimStartBssReq->privacy = 1;
4320 psessionEntry->privacy = 1;
4321
4322 schSetFixedBeaconFields(pMac, psessionEntry);
4323 limSendBeaconInd(pMac, psessionEntry);
4324
4325end:
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304326 vos_mem_free(pUpdateAPWPARSNIEsReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07004327 return;
4328} /*** end __limProcessSmeSetWPARSNIEs(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf) ***/
4329
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08004330/*
4331Update the beacon Interval dynamically if beaconInterval is different in MCC
4332*/
4333static void
4334__limProcessSmeChangeBI(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
4335{
4336 tpSirChangeBIParams pChangeBIParams;
4337 tpPESession psessionEntry;
4338 tANI_U8 sessionId = 0;
4339 tUpdateBeaconParams beaconParams;
4340
4341 PELOG1(limLog(pMac, LOG1,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004342 FL("received Update Beacon Interval message")););
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08004343
4344 if(pMsgBuf == NULL)
4345 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004346 limLog(pMac, LOGE,FL("Buffer is Pointing to NULL"));
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08004347 return;
4348 }
4349
4350 pChangeBIParams = (tpSirChangeBIParams)pMsgBuf;
4351
4352 if((psessionEntry = peFindSessionByBssid(pMac, pChangeBIParams->bssId, &sessionId)) == NULL)
4353 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004354 limLog(pMac, LOGE, FL("Session does not exist for given BSSID"));
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08004355 return;
4356 }
4357
4358 /*Update sessionEntry Beacon Interval*/
4359 if(psessionEntry->beaconParams.beaconInterval !=
4360 pChangeBIParams->beaconInterval )
4361 {
4362 psessionEntry->beaconParams.beaconInterval = pChangeBIParams->beaconInterval;
4363 }
4364
4365 /*Update sch beaconInterval*/
4366 if(pMac->sch.schObject.gSchBeaconInterval !=
4367 pChangeBIParams->beaconInterval )
4368 {
4369 pMac->sch.schObject.gSchBeaconInterval = pChangeBIParams->beaconInterval;
4370
4371 PELOG1(limLog(pMac, LOG1,
4372 FL("LIM send update BeaconInterval Indication : %d"),pChangeBIParams->beaconInterval););
4373
4374 /* Update beacon */
4375 schSetFixedBeaconFields(pMac, psessionEntry);
4376
Sunil Ravib96f7b52013-05-22 21:40:05 -07004377 beaconParams.bssIdx = psessionEntry->bssIdx;
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08004378 //Set change in beacon Interval
4379 beaconParams.beaconInterval = pChangeBIParams->beaconInterval;
Jeff Johnson312557b2013-04-03 16:27:48 -07004380 beaconParams.paramChangeBitmap = PARAM_BCN_INTERVAL_CHANGED;
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08004381 limSendBeaconParams(pMac, &beaconParams, psessionEntry);
4382 }
4383
4384 return;
4385} /*** end __limProcessSmeChangeBI(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf) ***/
4386
Jeff Johnson295189b2012-06-20 16:38:30 -07004387
4388
4389/** -------------------------------------------------------------
4390\fn limProcessSmeDelBaPeerInd
4391\brief handles indication message from HDD to send delete BA request
4392\param tpAniSirGlobal pMac
4393\param tANI_U32 pMsgBuf
4394\return None
4395-------------------------------------------------------------*/
4396void
4397limProcessSmeDelBaPeerInd(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
4398{
4399 tANI_U16 assocId =0;
4400 tpSmeDelBAPeerInd pSmeDelBAPeerInd = (tpSmeDelBAPeerInd)pMsgBuf;
4401 tpDphHashNode pSta;
4402 tpPESession psessionEntry;
4403 tANI_U8 sessionId;
4404
4405
4406
4407 if(NULL == pSmeDelBAPeerInd)
4408 return;
4409
4410 if ((psessionEntry = peFindSessionByBssid(pMac,pSmeDelBAPeerInd->bssId,&sessionId))==NULL)
4411 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004412 limLog(pMac, LOGE,FL("session does not exist for given bssId"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004413 return;
4414 }
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004415 limLog(pMac, LOGW, FL("called with staId = %d, tid = %d, baDirection = %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07004416 pSmeDelBAPeerInd->staIdx, pSmeDelBAPeerInd->baTID, pSmeDelBAPeerInd->baDirection);
4417
4418 pSta = dphLookupAssocId(pMac, pSmeDelBAPeerInd->staIdx, &assocId, &psessionEntry->dph.dphHashTable);
4419 if( eSIR_SUCCESS != limPostMlmDelBAReq( pMac,
4420 pSta,
4421 pSmeDelBAPeerInd->baDirection,
4422 pSmeDelBAPeerInd->baTID,
4423 eSIR_MAC_UNSPEC_FAILURE_REASON,psessionEntry))
4424 {
4425 limLog( pMac, LOGW,
4426 FL( "Failed to post LIM_MLM_DELBA_REQ to " ));
4427 if (pSta)
4428 limPrintMacAddr(pMac, pSta->staAddr, LOGW);
4429 }
4430}
4431
4432// --------------------------------------------------------------------
4433/**
4434 * __limProcessReportMessage
4435 *
4436 * FUNCTION: Processes the next received Radio Resource Management message
4437 *
4438 * LOGIC:
4439 *
4440 * ASSUMPTIONS:
4441 *
4442 * NOTE:
4443 *
4444 * @param None
4445 * @return None
4446 */
4447
4448void __limProcessReportMessage(tpAniSirGlobal pMac, tpSirMsgQ pMsg)
4449{
4450#ifdef WLAN_FEATURE_VOWIFI
4451 switch (pMsg->type)
4452 {
4453 case eWNI_SME_NEIGHBOR_REPORT_REQ_IND:
4454 rrmProcessNeighborReportReq( pMac, pMsg->bodyptr );
4455 break;
4456 case eWNI_SME_BEACON_REPORT_RESP_XMIT_IND:
4457 {
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004458#if defined(FEATURE_WLAN_CCX) && !defined(FEATURE_WLAN_CCX_UPLOAD)
Jeff Johnson295189b2012-06-20 16:38:30 -07004459 tpSirBeaconReportXmitInd pBcnReport=NULL;
4460 tpPESession psessionEntry=NULL;
4461 tANI_U8 sessionId;
4462
4463 if(pMsg->bodyptr == NULL)
4464 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004465 limLog(pMac, LOGE,FL("Buffer is Pointing to NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004466 return;
4467 }
4468 pBcnReport = (tpSirBeaconReportXmitInd )pMsg->bodyptr;
4469 if((psessionEntry = peFindSessionByBssid(pMac, pBcnReport->bssId,&sessionId))== NULL)
4470 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004471 limLog(pMac, LOGE, "Session Does not exist for given bssId");
Jeff Johnson295189b2012-06-20 16:38:30 -07004472 return;
4473 }
4474 if (psessionEntry->isCCXconnection)
4475 ccxProcessBeaconReportXmit( pMac, pMsg->bodyptr);
4476 else
4477#endif
4478 rrmProcessBeaconReportXmit( pMac, pMsg->bodyptr );
4479 }
4480 break;
4481 }
4482#endif
4483}
4484
4485#if defined(FEATURE_WLAN_CCX) || defined(WLAN_FEATURE_VOWIFI)
4486// --------------------------------------------------------------------
4487/**
4488 * limSendSetMaxTxPowerReq
4489 *
4490 * FUNCTION: Send SIR_HAL_SET_MAX_TX_POWER_REQ message to change the max tx power.
4491 *
4492 * LOGIC:
4493 *
4494 * ASSUMPTIONS:
4495 *
4496 * NOTE:
4497 *
4498 * @param txPower txPower to be set.
4499 * @param pSessionEntry session entry.
4500 * @return None
4501 */
4502tSirRetStatus
4503limSendSetMaxTxPowerReq ( tpAniSirGlobal pMac, tPowerdBm txPower, tpPESession pSessionEntry )
4504{
4505 tpMaxTxPowerParams pMaxTxParams = NULL;
4506 tSirRetStatus retCode = eSIR_SUCCESS;
4507 tSirMsgQ msgQ;
4508
4509 if( pSessionEntry == NULL )
4510 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004511 PELOGE(limLog(pMac, LOGE, "%s:%d: Inavalid parameters", __func__, __LINE__ );)
Jeff Johnson295189b2012-06-20 16:38:30 -07004512 return eSIR_FAILURE;
4513 }
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304514
4515 pMaxTxParams = vos_mem_malloc(sizeof(tMaxTxPowerParams));
4516 if ( NULL == pMaxTxParams )
Jeff Johnson295189b2012-06-20 16:38:30 -07004517 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004518 limLog( pMac, LOGP, "%s:%d:Unable to allocate memory for pMaxTxParams ", __func__, __LINE__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004519 return eSIR_MEM_ALLOC_FAILED;
4520
4521 }
4522#if defined(WLAN_VOWIFI_DEBUG) || defined(FEATURE_WLAN_CCX)
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004523 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 -07004524#endif
Kiran Kumar Lokerea4db3dc2013-03-25 18:05:24 -07004525 if( pMaxTxParams == NULL )
4526 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004527 limLog( pMac, LOGE, "%s:%d: pMaxTxParams is NULL", __func__, __LINE__);
Kiran Kumar Lokerea4db3dc2013-03-25 18:05:24 -07004528 return eSIR_FAILURE;
4529 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004530 pMaxTxParams->power = txPower;
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304531 vos_mem_copy( pMaxTxParams->bssId, pSessionEntry->bssId, sizeof(tSirMacAddr) );
4532 vos_mem_copy( pMaxTxParams->selfStaMacAddr, pSessionEntry->selfMacAddr, sizeof(tSirMacAddr) );
Jeff Johnson295189b2012-06-20 16:38:30 -07004533
Jeff Johnson68ce9c42013-04-08 10:33:28 -07004534 msgQ.type = WDA_SET_MAX_TX_POWER_REQ;
4535 msgQ.bodyptr = pMaxTxParams;
4536 msgQ.bodyval = 0;
4537 PELOG1(limLog(pMac, LOG1, FL("Posting WDA_SET_MAX_TX_POWER_REQ to WDA"));)
4538 MTRACE(macTraceMsgTx(pMac, pSessionEntry->peSessionId, msgQ.type));
4539 retCode = wdaPostCtrlMsg(pMac, &msgQ);
4540 if (eSIR_SUCCESS != retCode)
4541 {
4542 PELOGE(limLog(pMac, LOGE, FL("wdaPostCtrlMsg() failed"));)
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304543 vos_mem_free(pMaxTxParams);
Jeff Johnson68ce9c42013-04-08 10:33:28 -07004544 }
4545 return retCode;
Jeff Johnson295189b2012-06-20 16:38:30 -07004546}
4547#endif
4548
4549/**
4550 * __limProcessSmeAddStaSelfReq()
4551 *
4552 *FUNCTION:
4553 * This function is called to process SME_ADD_STA_SELF_REQ message
4554 * from SME. It sends a SIR_HAL_ADD_STA_SELF_REQ message to HAL.
4555 *
4556 *LOGIC:
4557 *
4558 *ASSUMPTIONS:
4559 *
4560 *NOTE:
4561 *
4562 * @param pMac Pointer to Global MAC structure
4563 * @param *pMsgBuf A pointer to the SME message buffer
4564 * @return None
4565 */
4566
4567static void
4568__limProcessSmeAddStaSelfReq(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
4569{
4570 tSirMsgQ msg;
4571 tpAddStaSelfParams pAddStaSelfParams;
4572 tpSirSmeAddStaSelfReq pSmeReq = (tpSirSmeAddStaSelfReq) pMsgBuf;
4573
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304574 pAddStaSelfParams = vos_mem_malloc(sizeof(tAddStaSelfParams));
4575 if ( NULL == pAddStaSelfParams )
Jeff Johnson295189b2012-06-20 16:38:30 -07004576 {
4577 limLog( pMac, LOGP, FL("Unable to allocate memory for tAddSelfStaParams") );
4578 return;
4579 }
4580
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304581 vos_mem_copy( pAddStaSelfParams->selfMacAddr, pSmeReq->selfMacAddr, sizeof(tSirMacAddr) );
Kiran Kumar Lokeread7dbc82013-10-07 20:12:50 -07004582 pAddStaSelfParams->currDeviceMode = pSmeReq->currDeviceMode;
Jeff Johnson295189b2012-06-20 16:38:30 -07004583 msg.type = SIR_HAL_ADD_STA_SELF_REQ;
4584 msg.reserved = 0;
4585 msg.bodyptr = pAddStaSelfParams;
4586 msg.bodyval = 0;
4587
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004588 PELOGW(limLog(pMac, LOG1, FL("sending SIR_HAL_ADD_STA_SELF_REQ msg to HAL"));)
Jeff Johnsone7245742012-09-05 17:12:55 -07004589 MTRACE(macTraceMsgTx(pMac, NO_SESSION, msg.type));
Jeff Johnson295189b2012-06-20 16:38:30 -07004590
4591 if(eSIR_SUCCESS != wdaPostCtrlMsg(pMac, &msg))
4592 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004593 limLog(pMac, LOGP, FL("wdaPostCtrlMsg failed"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004594 }
4595 return;
4596} /*** end __limProcessAddStaSelfReq() ***/
4597
4598
4599/**
4600 * __limProcessSmeDelStaSelfReq()
4601 *
4602 *FUNCTION:
4603 * This function is called to process SME_DEL_STA_SELF_REQ message
4604 * from SME. It sends a SIR_HAL_DEL_STA_SELF_REQ message to HAL.
4605 *
4606 *LOGIC:
4607 *
4608 *ASSUMPTIONS:
4609 *
4610 *NOTE:
4611 *
4612 * @param pMac Pointer to Global MAC structure
4613 * @param *pMsgBuf A pointer to the SME message buffer
4614 * @return None
4615 */
4616
4617static void
4618__limProcessSmeDelStaSelfReq(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
4619{
4620 tSirMsgQ msg;
4621 tpDelStaSelfParams pDelStaSelfParams;
4622 tpSirSmeDelStaSelfReq pSmeReq = (tpSirSmeDelStaSelfReq) pMsgBuf;
4623
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304624 pDelStaSelfParams = vos_mem_malloc(sizeof( tDelStaSelfParams));
4625 if ( NULL == pDelStaSelfParams )
Jeff Johnson295189b2012-06-20 16:38:30 -07004626 {
4627 limLog( pMac, LOGP, FL("Unable to allocate memory for tDelStaSelfParams") );
4628 return;
4629 }
4630
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304631 vos_mem_copy( pDelStaSelfParams->selfMacAddr, pSmeReq->selfMacAddr, sizeof(tSirMacAddr) );
Jeff Johnson295189b2012-06-20 16:38:30 -07004632
4633 msg.type = SIR_HAL_DEL_STA_SELF_REQ;
4634 msg.reserved = 0;
4635 msg.bodyptr = pDelStaSelfParams;
4636 msg.bodyval = 0;
4637
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004638 PELOGW(limLog(pMac, LOG1, FL("sending SIR_HAL_ADD_STA_SELF_REQ msg to HAL"));)
Jeff Johnsone7245742012-09-05 17:12:55 -07004639 MTRACE(macTraceMsgTx(pMac, NO_SESSION, msg.type));
Jeff Johnson295189b2012-06-20 16:38:30 -07004640
4641 if(eSIR_SUCCESS != wdaPostCtrlMsg(pMac, &msg))
4642 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004643 limLog(pMac, LOGP, FL("wdaPostCtrlMsg failed"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004644 }
4645 return;
4646} /*** end __limProcessSmeDelStaSelfReq() ***/
4647
4648
Jeff Johnson295189b2012-06-20 16:38:30 -07004649/**
4650 * __limProcessSmeRegisterMgmtFrameReq()
4651 *
4652 *FUNCTION:
4653 * This function is called to process eWNI_SME_REGISTER_MGMT_FRAME_REQ message
4654 * from SME. It Register this information within PE.
4655 *
4656 *LOGIC:
4657 *
4658 *ASSUMPTIONS:
4659 *
4660 *NOTE:
4661 *
4662 * @param pMac Pointer to Global MAC structure
4663 * @param *pMsgBuf A pointer to the SME message buffer
4664 * @return None
4665 */
4666static void
4667__limProcessSmeRegisterMgmtFrameReq(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
4668{
4669 VOS_STATUS vosStatus;
4670 tpSirRegisterMgmtFrame pSmeReq = (tpSirRegisterMgmtFrame)pMsgBuf;
4671 tpLimMgmtFrameRegistration pLimMgmtRegistration = NULL, pNext = NULL;
Jeff Johnsond13512a2012-07-17 11:42:19 -07004672 tANI_BOOLEAN match = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07004673 PELOG1(limLog(pMac, LOG1,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004674 FL("registerFrame %d, frameType %d, matchLen %d"),
Jeff Johnsone7245742012-09-05 17:12:55 -07004675 pSmeReq->registerFrame, pSmeReq->frameType, pSmeReq->matchLen);)
Jeff Johnson295189b2012-06-20 16:38:30 -07004676
Jeff Johnsond13512a2012-07-17 11:42:19 -07004677 /* First check whether entry exists already*/
4678
4679 vos_list_peek_front(&pMac->lim.gLimMgmtFrameRegistratinQueue,
4680 (vos_list_node_t**)&pLimMgmtRegistration);
4681
4682 while(pLimMgmtRegistration != NULL)
4683 {
4684 if (pLimMgmtRegistration->frameType == pSmeReq->frameType)
4685 {
4686 if(pSmeReq->matchLen)
4687 {
4688 if (pLimMgmtRegistration->matchLen == pSmeReq->matchLen)
4689 {
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304690 if (vos_mem_compare( pLimMgmtRegistration->matchData,
Jeff Johnsond13512a2012-07-17 11:42:19 -07004691 pSmeReq->matchData, pLimMgmtRegistration->matchLen))
4692 {
Madan Mohan Koyyalamudic537df22012-10-22 15:07:08 -07004693 /* found match! */
4694 match = VOS_TRUE;
4695 break;
Jeff Johnsond13512a2012-07-17 11:42:19 -07004696 }
4697 }
4698 }
4699 else
4700 {
Madan Mohan Koyyalamudic537df22012-10-22 15:07:08 -07004701 /* found match! */
Jeff Johnsond13512a2012-07-17 11:42:19 -07004702 match = VOS_TRUE;
4703 break;
4704 }
4705 }
4706 vosStatus = vos_list_peek_next (
4707 &pMac->lim.gLimMgmtFrameRegistratinQueue,
4708 (vos_list_node_t*) pLimMgmtRegistration,
4709 (vos_list_node_t**) &pNext );
4710
4711 pLimMgmtRegistration = pNext;
4712 pNext = NULL;
4713
4714 }
4715
4716 if (match)
4717 {
4718 vos_list_remove_node(&pMac->lim.gLimMgmtFrameRegistratinQueue,
4719 (vos_list_node_t*)pLimMgmtRegistration);
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304720 vos_mem_free(pLimMgmtRegistration);
Jeff Johnsond13512a2012-07-17 11:42:19 -07004721 }
4722
Jeff Johnson295189b2012-06-20 16:38:30 -07004723 if(pSmeReq->registerFrame)
4724 {
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304725 pLimMgmtRegistration = vos_mem_malloc(sizeof(tLimMgmtFrameRegistration) + pSmeReq->matchLen);
4726 if ( pLimMgmtRegistration != NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -07004727 {
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304728 vos_mem_set((void*)pLimMgmtRegistration,
4729 sizeof(tLimMgmtFrameRegistration) + pSmeReq->matchLen, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004730 pLimMgmtRegistration->frameType = pSmeReq->frameType;
4731 pLimMgmtRegistration->matchLen = pSmeReq->matchLen;
4732 pLimMgmtRegistration->sessionId = pSmeReq->sessionId;
4733 if(pSmeReq->matchLen)
4734 {
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304735 vos_mem_copy(pLimMgmtRegistration->matchData,
4736 pSmeReq->matchData, pSmeReq->matchLen);
Jeff Johnson295189b2012-06-20 16:38:30 -07004737 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004738 vos_list_insert_front(&pMac->lim.gLimMgmtFrameRegistratinQueue,
4739 &pLimMgmtRegistration->node);
4740 }
4741 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004742
4743 return;
4744} /*** end __limProcessSmeRegisterMgmtFrameReq() ***/
Viral Modid86bde22012-12-10 13:09:21 -08004745
4746static tANI_BOOLEAN
Viral Modid440e682013-03-06 02:25:31 -08004747__limInsertSingleShotNOAForScan(tpAniSirGlobal pMac, tANI_U32 noaDuration)
Viral Modid86bde22012-12-10 13:09:21 -08004748{
4749 tpP2pPsParams pMsgNoA;
4750 tSirMsgQ msg;
Vinay Malekal62757362012-12-17 12:15:51 -08004751
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304752 pMsgNoA = vos_mem_malloc(sizeof( tP2pPsConfig ));
4753 if ( NULL == pMsgNoA )
Viral Modid86bde22012-12-10 13:09:21 -08004754 {
4755 limLog( pMac, LOGP,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004756 FL( "Unable to allocate memory during NoA Update" ));
Viral Modid440e682013-03-06 02:25:31 -08004757 goto error;
Viral Modid86bde22012-12-10 13:09:21 -08004758 }
4759
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304760 vos_mem_set((tANI_U8 *)pMsgNoA, sizeof(tP2pPsConfig), 0);
Viral Modid86bde22012-12-10 13:09:21 -08004761 /* Below params used for opp PS/periodic NOA and are don't care in this case - so initialized to 0 */
4762 pMsgNoA->opp_ps = 0;
4763 pMsgNoA->ctWindow = 0;
4764 pMsgNoA->duration = 0;
4765 pMsgNoA->interval = 0;
4766 pMsgNoA->count = 0;
Vinay Malekal62757362012-12-17 12:15:51 -08004767
Vinay Malekal62757362012-12-17 12:15:51 -08004768 /* Below params used for Single Shot NOA - so assign proper values */
4769 pMsgNoA->psSelection = P2P_SINGLE_NOA;
Viral Modid440e682013-03-06 02:25:31 -08004770 pMsgNoA->single_noa_duration = noaDuration;
Gopichand Nakkala096a1052012-12-21 07:05:34 -08004771
Viral Modid86bde22012-12-10 13:09:21 -08004772 /* Start Insert NOA timer
4773 * 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 -08004774 * or any other failure or reason, we still need to process the deferred SME req. The insert NOA
4775 * timer of 500 ms will ensure the stored SME req always gets processed
Viral Modid86bde22012-12-10 13:09:21 -08004776 */
4777 if (tx_timer_activate(&pMac->lim.limTimers.gLimP2pSingleShotNoaInsertTimer)
4778 == TX_TIMER_ERROR)
4779 {
4780 /// Could not activate Insert NOA timer.
4781 // Log error
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004782 limLog(pMac, LOGP, FL("could not activate Insert Single Shot NOA during scan timer"));
Viral Modid86bde22012-12-10 13:09:21 -08004783
4784 // send the scan response back with status failure and do not even call insert NOA
4785 limSendSmeScanRsp(pMac, sizeof(tSirSmeScanRsp), eSIR_SME_SCAN_FAILED, pMac->lim.gSmeSessionId, pMac->lim.gTransactionId);
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304786 vos_mem_free(pMsgNoA);
Viral Modid440e682013-03-06 02:25:31 -08004787 goto error;
Viral Modid86bde22012-12-10 13:09:21 -08004788 }
4789
Viral Modid440e682013-03-06 02:25:31 -08004790 MTRACE(macTrace(pMac, TRACE_CODE_TIMER_ACTIVATE, NO_SESSION, eLIM_INSERT_SINGLESHOT_NOA_TIMER));
4791
Viral Modid86bde22012-12-10 13:09:21 -08004792 msg.type = WDA_SET_P2P_GO_NOA_REQ;
4793 msg.reserved = 0;
4794 msg.bodyptr = pMsgNoA;
4795 msg.bodyval = 0;
4796
4797 if(eSIR_SUCCESS != wdaPostCtrlMsg(pMac, &msg))
4798 {
4799 /* 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 -07004800 limLog(pMac, LOGP, FL("wdaPost Msg failed"));
Viral Modid440e682013-03-06 02:25:31 -08004801 /* Deactivate the NOA timer in failure case */
4802 limDeactivateAndChangeTimer(pMac, eLIM_INSERT_SINGLESHOT_NOA_TIMER);
4803 goto error;
Viral Modid86bde22012-12-10 13:09:21 -08004804 }
Viral Modid440e682013-03-06 02:25:31 -08004805 return FALSE;
Viral Modid86bde22012-12-10 13:09:21 -08004806
Viral Modid440e682013-03-06 02:25:31 -08004807error:
4808 /* In any of the failure cases, just go ahead with the processing of registered deferred SME request without
4809 * worrying about the NOA
4810 */
4811 limProcessRegdDefdSmeReqAfterNOAStart(pMac);
4812 // msg buffer is consumed and freed in above function so return FALSE
Viral Modid86bde22012-12-10 13:09:21 -08004813 return FALSE;
4814
4815}
4816
Viral Modid440e682013-03-06 02:25:31 -08004817static void __limRegisterDeferredSmeReqForNOAStart(tpAniSirGlobal pMac, tANI_U16 msgType, tANI_U32 *pMsgBuf)
4818{
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004819 limLog(pMac, LOG1, FL("Reg msgType %d"), msgType) ;
Viral Modid440e682013-03-06 02:25:31 -08004820 pMac->lim.gDeferMsgTypeForNOA = msgType;
4821 pMac->lim.gpDefdSmeMsgForNOA = pMsgBuf;
4822}
4823
4824static void __limDeregisterDeferredSmeReqAfterNOAStart(tpAniSirGlobal pMac)
4825{
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004826 limLog(pMac, LOG1, FL("Dereg msgType %d"), pMac->lim.gDeferMsgTypeForNOA) ;
Viral Modid440e682013-03-06 02:25:31 -08004827 pMac->lim.gDeferMsgTypeForNOA = 0;
4828 if (pMac->lim.gpDefdSmeMsgForNOA != NULL)
4829 {
4830 /* __limProcessSmeScanReq consumed the buffer. We can free it. */
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304831 vos_mem_free(pMac->lim.gpDefdSmeMsgForNOA);
Viral Modid440e682013-03-06 02:25:31 -08004832 pMac->lim.gpDefdSmeMsgForNOA = NULL;
4833 }
4834}
4835
4836static
4837tANI_U32 limCalculateNOADuration(tpAniSirGlobal pMac, tANI_U16 msgType, tANI_U32 *pMsgBuf)
4838{
4839 tANI_U32 noaDuration = 0;
4840
4841 switch (msgType)
4842 {
4843 case eWNI_SME_SCAN_REQ:
4844 {
4845 tANI_U32 val;
4846 tANI_U8 i;
4847 tpSirSmeScanReq pScanReq = (tpSirSmeScanReq) pMsgBuf;
4848 if (wlan_cfgGetInt(pMac, WNI_CFG_PASSIVE_MAXIMUM_CHANNEL_TIME, &val) != eSIR_SUCCESS)
4849 {
4850 /*
4851 * Could not get max channel value
4852 * from CFG. Log error.
4853 */
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004854 limLog(pMac, LOGP, FL("could not retrieve passive max channel value"));
Viral Modid440e682013-03-06 02:25:31 -08004855
4856 /* use a default value of 110ms */
4857 val = DEFAULT_PASSIVE_MAX_CHANNEL_TIME;
4858 }
4859
4860 for (i = 0; i < pScanReq->channelList.numChannels; i++) {
4861 tANI_U8 channelNum = pScanReq->channelList.channelNumber[i];
4862
4863 if (limActiveScanAllowed(pMac, channelNum)) {
4864 /* Use min + max channel time to calculate the total duration of scan */
4865 noaDuration += pScanReq->minChannelTime + pScanReq->maxChannelTime;
4866 } else {
4867 /* using the value from WNI_CFG_PASSIVE_MINIMUM_CHANNEL_TIME as is done in
4868 * void limContinuePostChannelScan(tpAniSirGlobal pMac)
4869 */
4870 noaDuration += val;
4871 }
4872 }
4873
4874 /* Adding an overhead of 20ms to account for the scan messaging delays */
4875 noaDuration += SCAN_MESSAGING_OVERHEAD;
4876 noaDuration *= CONV_MS_TO_US;
4877
4878 break;
4879 }
4880
4881 case eWNI_SME_OEM_DATA_REQ:
4882 noaDuration = OEM_DATA_NOA_DURATION*CONV_MS_TO_US; // use 60 msec as default
4883 break;
4884
4885 case eWNI_SME_REMAIN_ON_CHANNEL_REQ:
4886 {
4887 tSirRemainOnChnReq *pRemainOnChnReq = (tSirRemainOnChnReq *) pMsgBuf;
4888 noaDuration = (pRemainOnChnReq->duration)*CONV_MS_TO_US;
4889 break;
4890 }
4891
4892 case eWNI_SME_JOIN_REQ:
4893 noaDuration = JOIN_NOA_DURATION*CONV_MS_TO_US;
4894 break;
4895
4896 default:
4897 noaDuration = 0;
4898 break;
4899
4900 }
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004901 limLog(pMac, LOGW, FL("msgType %d noa %d"), msgType, noaDuration);
Viral Modid440e682013-03-06 02:25:31 -08004902 return noaDuration;
4903}
4904
4905void limProcessRegdDefdSmeReqAfterNOAStart(tpAniSirGlobal pMac)
4906{
Gopichand Nakkala7c4c3b92013-03-25 18:08:31 +05304907 tANI_BOOLEAN bufConsumed = TRUE;
Viral Modid440e682013-03-06 02:25:31 -08004908
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004909 limLog(pMac, LOG1, FL("Process defd sme req %d"), pMac->lim.gDeferMsgTypeForNOA);
Viral Modid440e682013-03-06 02:25:31 -08004910 if ( (pMac->lim.gDeferMsgTypeForNOA != 0) &&
4911 (pMac->lim.gpDefdSmeMsgForNOA != NULL) )
4912 {
4913 switch (pMac->lim.gDeferMsgTypeForNOA)
4914 {
4915 case eWNI_SME_SCAN_REQ:
4916 __limProcessSmeScanReq(pMac, pMac->lim.gpDefdSmeMsgForNOA);
4917 break;
4918 case eWNI_SME_OEM_DATA_REQ:
4919 __limProcessSmeOemDataReq(pMac, pMac->lim.gpDefdSmeMsgForNOA);
4920 break;
4921 case eWNI_SME_REMAIN_ON_CHANNEL_REQ:
Gopichand Nakkala7c4c3b92013-03-25 18:08:31 +05304922 bufConsumed = limProcessRemainOnChnlReq(pMac, pMac->lim.gpDefdSmeMsgForNOA);
4923 /* limProcessRemainOnChnlReq doesnt want us to free the buffer since
4924 * it is freed in limRemainOnChnRsp. this change is to avoid "double free"
4925 */
4926 if (FALSE == bufConsumed)
4927 {
4928 pMac->lim.gpDefdSmeMsgForNOA = NULL;
4929 }
Viral Modid440e682013-03-06 02:25:31 -08004930 break;
4931 case eWNI_SME_JOIN_REQ:
4932 __limProcessSmeJoinReq(pMac, pMac->lim.gpDefdSmeMsgForNOA);
4933 break;
4934 default:
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004935 limLog(pMac, LOGE, FL("Unknown deferred msg type %d"), pMac->lim.gDeferMsgTypeForNOA);
Viral Modid440e682013-03-06 02:25:31 -08004936 break;
4937 }
4938 __limDeregisterDeferredSmeReqAfterNOAStart(pMac);
4939 }
4940 else
4941 {
4942 limLog( pMac, LOGW, FL("start received from FW when no sme deferred msg pending. Do nothing."
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004943 "It might happen sometime when NOA start ind and timeout happen at the same time"));
Viral Modid440e682013-03-06 02:25:31 -08004944 }
4945}
Jeff Johnson295189b2012-06-20 16:38:30 -07004946
Mohit Khanna698ba2a2012-12-04 15:08:18 -08004947#ifdef FEATURE_WLAN_TDLS_INTERNAL
4948/*
4949 * Process Discovery request recieved from SME and transmit to AP.
4950 */
4951static tSirRetStatus limProcessSmeDisStartReq(tpAniSirGlobal pMac,
4952 tANI_U32 *pMsgBuf)
4953{
4954 /* get all discovery request parameters */
4955 tSirTdlsDisReq *disReq = (tSirTdlsDisReq *) pMsgBuf ;
4956 tpPESession psessionEntry;
4957 tANI_U8 sessionId;
4958
4959 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004960 ("Discovery Req Recieved")) ;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08004961
4962 if((psessionEntry = peFindSessionByBssid(pMac, disReq->bssid, &sessionId))
4963 == NULL)
4964 {
4965 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004966 "PE Session does not exist for given sme sessionId %d",
Mohit Khanna698ba2a2012-12-04 15:08:18 -08004967 disReq->sessionId);
4968 goto lim_tdls_dis_start_error;
4969 }
4970
4971 /* check if we are in proper state to work as TDLS client */
4972 if (psessionEntry->limSystemRole != eLIM_STA_ROLE)
4973 {
4974 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004975 "dis req received in wrong system Role %d",
Mohit Khanna698ba2a2012-12-04 15:08:18 -08004976 psessionEntry->limSystemRole);
4977 goto lim_tdls_dis_start_error;
4978 }
4979
4980 /*
4981 * if we are still good, go ahead and check if we are in proper state to
4982 * do TDLS discovery procedure.
4983 */
4984 if ((psessionEntry->limSmeState != eLIM_SME_ASSOCIATED_STATE) &&
4985 (psessionEntry->limSmeState != eLIM_SME_LINK_EST_STATE))
4986 {
4987
4988 limLog(pMac, LOGE, "dis req received in invalid LIMsme \
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004989 state (%d)", psessionEntry->limSmeState);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08004990 goto lim_tdls_dis_start_error;
4991 }
4992
4993 /*
4994 * if we are still good, go ahead and transmit TDLS discovery request,
4995 * and save Dis Req info for future reference.
4996 */
4997
4998#if 0 // TDLS_hklee: D13 no need to open Addr2 unknown data packet
4999 /*
5000 * send message to HAL to set RXP filters to receieve frame on
5001 * direct link..
5002 */
5003 //limSetLinkState(pMac, eSIR_LINK_TDLS_DISCOVERY_STATE,
5004 // psessionEntry->bssId) ;
5005#endif
5006
5007 /* save dis request message for matching dialog token */
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05305008 vos_mem_copy((tANI_U8 *) &pMac->lim.gLimTdlsDisReq,
5009 (tANI_U8 *) disReq, sizeof(tSirTdlsDisReq));
Mohit Khanna698ba2a2012-12-04 15:08:18 -08005010
5011 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005012 "Transmit Discovery Request Frame") ;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08005013 /* format TDLS discovery request frame and transmit it */
5014 limSendTdlsDisReqFrame(pMac, disReq->peerMac, disReq->dialog,
5015 psessionEntry) ;
5016
5017 /* prepare for response */
5018 pMac->lim.gLimTdlsDisStaCount = 0 ;
5019 pMac->lim.gLimTdlsDisResultList = NULL ;
5020
5021 /*
5022 * start TDLS discovery request timer to wait for discovery responses
5023 * from all TDLS enabled clients in BSS.
5024 */
5025
5026 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005027 ("Start Discovery request Timeout Timer")) ;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08005028 MTRACE(macTrace(pMac, TRACE_CODE_TIMER_ACTIVATE, 0,
5029 eLIM_TDLS_DISCOVERY_RSP_WAIT));
5030
5031 /* assign appropriate sessionId to the timer object */
5032 pMac->lim.limTimers.gLimTdlsDisRspWaitTimer.sessionId =
5033 psessionEntry->peSessionId;
5034
5035 if (tx_timer_activate(&pMac->lim.limTimers.gLimTdlsDisRspWaitTimer)
5036 != TX_SUCCESS)
5037 {
5038 limLog(pMac, LOGP, FL("TDLS discovery response timer \
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005039 activation failed!"));
Mohit Khanna698ba2a2012-12-04 15:08:18 -08005040 goto lim_tdls_dis_start_error;
5041 }
5042 /*
5043 * when timer expired, eWNI_SME_TDLS_DISCOVERY_START_RSP is sent
5044 * back to SME
5045 */
5046 return (eSIR_SUCCESS) ;
5047lim_tdls_dis_start_error:
5048 /* in error case, PE has to sent the response SME immediately with error code */
5049 limSendSmeTdlsDisRsp(pMac, eSIR_FAILURE,
5050 eWNI_SME_TDLS_DISCOVERY_START_RSP);
5051 return eSIR_FAILURE;
5052}
5053/*
5054 * Process link start request recieved from SME and transmit to AP.
5055 */
5056eHalStatus limProcessSmeLinkStartReq(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
5057{
5058 /* get all discovery request parameters */
5059 tSirTdlsSetupReq *setupReq = (tSirTdlsSetupReq *) pMsgBuf ;
5060 tLimTdlsLinkSetupInfo *linkSetupInfo;
5061 //tLimTdlsLinkSetupPeer *setupPeer;
5062 tpPESession psessionEntry;
5063 tANI_U8 sessionId;
5064 eHalStatus status;
5065
5066 if((psessionEntry = peFindSessionByBssid(pMac,
5067 setupReq->bssid, &sessionId)) == NULL)
5068 {
5069 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005070 "PE Session does not exist for given sme sessionId %d",
Mohit Khanna698ba2a2012-12-04 15:08:18 -08005071 setupReq->sessionId);
5072 goto lim_tdls_link_start_error;
5073 }
5074
5075 /* check if we are in proper state to work as TDLS client */
5076 if (psessionEntry->limSystemRole != eLIM_STA_ROLE)
5077 {
5078 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005079 "TDLS link setup req received in wrong system Role %d",
Mohit Khanna698ba2a2012-12-04 15:08:18 -08005080 psessionEntry->limSystemRole);
5081 goto lim_tdls_link_start_error;
5082 }
5083
5084 /*
5085 * if we are still good, go ahead and check if we are in proper state to
5086 * do TDLS setup procedure.
5087 */
5088 if ((psessionEntry->limSmeState != eLIM_SME_ASSOCIATED_STATE) &&
5089 (psessionEntry->limSmeState != eLIM_SME_LINK_EST_STATE))
5090 {
5091 limLog(pMac, LOGE, "Setup request in invalid LIMsme \
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005092 state (%d)", pMac->lim.gLimSmeState);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08005093 goto lim_tdls_link_start_error;
5094 }
5095
5096 /*
5097 * Now, go ahead and transmit TDLS discovery request, and save setup Req
5098 * info for future reference.
5099 */
5100 /* create node for Link setup */
5101 linkSetupInfo = &pMac->lim.gLimTdlsLinkSetupInfo ;
5102 //setupPeer = NULL ;
5103
5104 status = limTdlsPrepareSetupReqFrame(pMac, linkSetupInfo, setupReq->dialog,
5105 setupReq->peerMac, psessionEntry) ;
5106 if(eHAL_STATUS_SUCCESS == status)
5107 /* in case of success, eWNI_SME_TDLS_LINK_START_RSP is sent back to SME later when
5108 TDLS setup cnf TX complete is successful. */
5109 return eSIR_SUCCESS;
5110#if 0
5111
5112 /*
5113 * we allocate the TDLS setup Peer Memory here, we will free'd this
Jeff Johnsonfeddb2d2012-12-10 14:41:22 -08005114 * memory after teardown, if the link is successfully setup or
Mohit Khanna698ba2a2012-12-04 15:08:18 -08005115 * free this memory if any timeout is happen in link setup procedure
5116 */
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05305117 setupPeer = vos_mem_malloc(sizeof( tLimTdlsLinkSetupPeer ));
5118 if ( NULL == setupPeer )
Mohit Khanna698ba2a2012-12-04 15:08:18 -08005119 {
5120 limLog( pMac, LOGP,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005121 FL( "Unable to allocate memory during ADD_STA" ));
Mohit Khanna698ba2a2012-12-04 15:08:18 -08005122 VOS_ASSERT(0) ;
5123 return eSIR_MEM_ALLOC_FAILED;
5124 }
5125 setupPeer->dialog = setupReq->dialog ;
5126 setupPeer->tdls_prev_link_state = setupPeer->tdls_link_state ;
5127 setupPeer->tdls_link_state = TDLS_LINK_SETUP_START_STATE ;
5128 /* TDLS_sessionize: remember sessionId for future */
5129 setupPeer->tdls_sessionId = psessionEntry->peSessionId;
5130 setupPeer->tdls_bIsResponder = 1;
5131
5132 /*
5133 * we only populate peer MAC, so it can assit us to find the
5134 * TDLS peer after response/or after response timeout
5135 */
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05305136 vos_mem_copy(setupPeer->peerMac, setupReq->peerMac,
Mohit Khanna698ba2a2012-12-04 15:08:18 -08005137 sizeof(tSirMacAddr)) ;
5138 /* format TDLS discovery request frame and transmit it */
5139 limSendTdlsLinkSetupReqFrame(pMac, setupReq->peerMac,
5140 setupReq->dialog, psessionEntry, NULL, 0) ;
5141
5142 limStartTdlsTimer(pMac, psessionEntry->peSessionId,
5143 &setupPeer->gLimTdlsLinkSetupRspTimeoutTimer,
5144 (tANI_U32)setupPeer->peerMac, WNI_CFG_TDLS_LINK_SETUP_RSP_TIMEOUT,
5145 SIR_LIM_TDLS_LINK_SETUP_RSP_TIMEOUT) ;
5146 /* update setup peer list */
5147 setupPeer->next = linkSetupInfo->tdlsLinkSetupList ;
5148 linkSetupInfo->tdlsLinkSetupList = setupPeer ;
5149 /* in case of success, eWNI_SME_TDLS_LINK_START_RSP is sent back to SME later when
5150 TDLS setup cnf TX complete is successful. --> see limTdlsSetupCnfTxComplete() */
5151 return eSIR_SUCCESS ;
5152#endif
5153lim_tdls_link_start_error:
5154 /* in case of error, return immediately to SME */
5155 limSendSmeTdlsLinkStartRsp(pMac, eSIR_FAILURE, setupReq->peerMac,
5156 eWNI_SME_TDLS_LINK_START_RSP);
5157 return eSIR_FAILURE ;
5158}
5159
5160/*
5161 * Process link teardown request recieved from SME and transmit to AP.
5162 */
5163eHalStatus limProcessSmeTeardownReq(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
5164{
5165 /* get all discovery request parameters */
5166 tSirTdlsTeardownReq *teardownReq = (tSirTdlsTeardownReq *) pMsgBuf ;
5167 tLimTdlsLinkSetupPeer *setupPeer;
5168 tpPESession psessionEntry;
5169 tANI_U8 sessionId;
5170
5171 if((psessionEntry = peFindSessionByBssid(pMac, teardownReq->bssid, &sessionId)) == NULL)
5172 {
5173 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005174 "PE Session does not exist for given sme sessionId %d", teardownReq->sessionId);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08005175 goto lim_tdls_teardown_req_error;
5176 }
5177
5178 /* check if we are in proper state to work as TDLS client */
5179 if (psessionEntry->limSystemRole != eLIM_STA_ROLE)
5180 {
5181 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005182 "TDLS teardown req received in wrong system Role %d", psessionEntry->limSystemRole);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08005183 goto lim_tdls_teardown_req_error;
5184 }
5185
5186 /*
5187 * if we are still good, go ahead and check if we are in proper state to
5188 * do TDLS setup procedure.
5189 */
5190 if ((psessionEntry->limSmeState != eLIM_SME_ASSOCIATED_STATE) &&
5191 (psessionEntry->limSmeState != eLIM_SME_LINK_EST_STATE))
5192 {
5193 limLog(pMac, LOGE, "TDLS teardwon req received in invalid LIMsme \
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005194 state (%d)", psessionEntry->limSmeState);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08005195 goto lim_tdls_teardown_req_error;
5196 }
5197
5198 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
Arif Hussain24bafea2013-11-15 15:10:03 -08005199 "Teardown for peer = " MAC_ADDRESS_STR, MAC_ADDR_ARRAY(teardownReq->peerMac));
Mohit Khanna698ba2a2012-12-04 15:08:18 -08005200 /*
5201 * Now, go ahead and transmit TDLS teardown request, and save teardown info
5202 * info for future reference.
5203 */
5204 /* Verify if this link is setup */
5205 setupPeer = NULL ;
5206 limTdlsFindLinkPeer(pMac, teardownReq->peerMac, &setupPeer);
5207 if(NULL == setupPeer)
5208 {
5209 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005210 ("invalid Peer on teardown ")) ;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08005211 goto lim_tdls_teardown_req_error;
5212 }
5213
5214
5215 (setupPeer)->tdls_prev_link_state = (setupPeer)->tdls_link_state ;
5216 (setupPeer)->tdls_link_state = TDLS_LINK_TEARDOWN_START_STATE ;
5217 /* TDLS_sessionize: check sessionId in case */
5218 if((setupPeer)->tdls_sessionId != psessionEntry->peSessionId)
5219 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005220 limLog(pMac, LOGE, "TDLS teardown req; stored sessionId (%d) not matched from peSessionId (%d)", \
Mohit Khanna698ba2a2012-12-04 15:08:18 -08005221 (setupPeer)->tdls_sessionId, psessionEntry->limSmeState);
5222 (setupPeer)->tdls_sessionId = psessionEntry->peSessionId;
5223 }
5224
5225 /* format TDLS teardown request frame and transmit it */
5226 if(eSIR_SUCCESS != limSendTdlsTeardownFrame(pMac, teardownReq->peerMac,
5227 eSIR_MAC_TDLS_TEARDOWN_UNSPEC_REASON, psessionEntry, NULL, 0 ))
5228 {
5229 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005230 ("couldn't send teardown frame ")) ;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08005231 goto lim_tdls_teardown_req_error;
5232 }
5233 /* in case of success, eWNI_SME_TDLS_TEARDOWN_RSP is sent back to SME later when
5234 TDLS teardown TX complete is successful. --> see limTdlsTeardownTxComplete() */
5235 return eSIR_SUCCESS;
5236lim_tdls_teardown_req_error:
5237 /* in case of error, return immediately to SME */
5238 limSendSmeTdlsTeardownRsp(pMac, eSIR_FAILURE, teardownReq->peerMac,
5239 eWNI_SME_TDLS_TEARDOWN_RSP);
5240 return eSIR_FAILURE;
5241}
5242
5243
5244#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005245
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05305246static void
5247__limProcessSmeResetApCapsChange(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
5248{
5249 tpSirResetAPCapsChange pResetCapsChange;
5250 tpPESession psessionEntry;
5251 tANI_U8 sessionId = 0;
5252 if (pMsgBuf == NULL)
5253 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005254 limLog(pMac, LOGE,FL("Buffer is Pointing to NULL"));
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05305255 return;
5256 }
5257
5258 pResetCapsChange = (tpSirResetAPCapsChange)pMsgBuf;
5259 psessionEntry = peFindSessionByBssid(pMac, pResetCapsChange->bssId, &sessionId);
5260 if (psessionEntry == NULL)
5261 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005262 limLog(pMac, LOGE, FL("Session does not exist for given BSSID"));
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05305263 return;
5264 }
5265
5266 psessionEntry->limSentCapsChangeNtf = false;
5267 return;
5268}
5269
Jeff Johnson295189b2012-06-20 16:38:30 -07005270/**
5271 * limProcessSmeReqMessages()
5272 *
5273 *FUNCTION:
5274 * This function is called by limProcessMessageQueue(). This
5275 * function processes SME request messages from HDD or upper layer
5276 * application.
5277 *
5278 *LOGIC:
5279 *
5280 *ASSUMPTIONS:
5281 *
5282 *NOTE:
5283 *
5284 * @param pMac Pointer to Global MAC structure
5285 * @param msgType Indicates the SME message type
5286 * @param *pMsgBuf A pointer to the SME message buffer
5287 * @return Boolean - TRUE - if pMsgBuf is consumed and can be freed.
5288 * FALSE - if pMsgBuf is not to be freed.
5289 */
5290
5291tANI_BOOLEAN
5292limProcessSmeReqMessages(tpAniSirGlobal pMac, tpSirMsgQ pMsg)
5293{
5294 tANI_BOOLEAN bufConsumed = TRUE; //Set this flag to false within case block of any following message, that doesnt want pMsgBuf to be freed.
5295 tANI_U32 *pMsgBuf = pMsg->bodyptr;
Sudhir Sattayappa Kohalliabf751c2013-06-30 15:37:18 -07005296 tpSirSmeScanReq pScanReq;
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005297 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 -07005298 limMsgStr(pMsg->type), pMsg->type,
5299 limSmeStateStr(pMac->lim.gLimSmeState), pMac->lim.gLimSmeState,
5300 limMlmStateStr(pMac->lim.gLimMlmState), pMac->lim.gLimMlmState );)
5301
Sudhir Sattayappa Kohalliabf751c2013-06-30 15:37:18 -07005302 pScanReq = (tpSirSmeScanReq) pMsgBuf;
Viral Modid440e682013-03-06 02:25:31 -08005303 /* Special handling of some SME Req msgs where we have an existing GO session and
5304 * want to insert NOA before processing those msgs. These msgs will be processed later when
5305 * start event happens
5306 */
5307 switch (pMsg->type)
5308 {
5309 case eWNI_SME_SCAN_REQ:
Viral Modid440e682013-03-06 02:25:31 -08005310 case eWNI_SME_REMAIN_ON_CHANNEL_REQ:
Sudhir Sattayappa Kohalliabf751c2013-06-30 15:37:18 -07005311
5312 /* If scan is disabled return from here
5313 */
5314 if (pMac->lim.fScanDisabled)
5315 {
5316 PELOGE(limLog(pMac, LOGE, FL("Error: Scan Disabled"));)
5317 if (pMsg->type == eWNI_SME_SCAN_REQ)
5318 {
5319 limSendSmeScanRsp(pMac,
5320 offsetof(tSirSmeScanRsp,bssDescription[0]),
5321 eSIR_SME_INVALID_PARAMETERS,
5322 pScanReq->sessionId,
5323 pScanReq->transactionId);
5324
5325 bufConsumed = TRUE;
5326 }
5327 else if (pMsg->type == eWNI_SME_REMAIN_ON_CHANNEL_REQ)
5328 {
5329 pMac->lim.gpDefdSmeMsgForNOA = NULL;
5330 pMac->lim.gpLimRemainOnChanReq = (tpSirRemainOnChnReq )pMsgBuf;
5331 limRemainOnChnRsp(pMac,eHAL_STATUS_FAILURE, NULL);
5332
5333 /*
5334 * limRemainOnChnRsp will free the buffer this change is to
5335 * avoid "double free"
5336 */
5337 bufConsumed = FALSE;
5338 }
5339
5340 return bufConsumed;
5341 }
5342 /*
5343 * Do not add BREAK here
5344 */
5345 case eWNI_SME_OEM_DATA_REQ:
Viral Modid440e682013-03-06 02:25:31 -08005346 case eWNI_SME_JOIN_REQ:
5347 /* If we have an existing P2P GO session we need to insert NOA before actually process this SME Req */
5348 if ((limIsNOAInsertReqd(pMac) == TRUE) && IS_FEATURE_SUPPORTED_BY_FW(P2P_GO_NOA_DECOUPLE_INIT_SCAN))
5349 {
5350 tANI_U32 noaDuration;
5351 __limRegisterDeferredSmeReqForNOAStart(pMac, pMsg->type, pMsgBuf);
5352 noaDuration = limCalculateNOADuration(pMac, pMsg->type, pMsgBuf);
5353 bufConsumed = __limInsertSingleShotNOAForScan(pMac, noaDuration);
5354 return bufConsumed;
5355 }
5356 }
5357 /* If no insert NOA required then execute the code below */
5358
Jeff Johnson295189b2012-06-20 16:38:30 -07005359 switch (pMsg->type)
5360 {
5361 case eWNI_SME_START_REQ:
5362 __limProcessSmeStartReq(pMac, pMsgBuf);
5363 break;
5364
5365 case eWNI_SME_SYS_READY_IND:
5366 bufConsumed = __limProcessSmeSysReadyInd(pMac, pMsgBuf);
5367 break;
5368
Jeff Johnson295189b2012-06-20 16:38:30 -07005369 case eWNI_SME_START_BSS_REQ:
5370 bufConsumed = __limProcessSmeStartBssReq(pMac, pMsg);
5371 break;
5372
5373 case eWNI_SME_SCAN_REQ:
Viral Modid440e682013-03-06 02:25:31 -08005374 __limProcessSmeScanReq(pMac, pMsgBuf);
Jeff Johnson295189b2012-06-20 16:38:30 -07005375 break;
5376
Jeff Johnsone7245742012-09-05 17:12:55 -07005377#ifdef FEATURE_OEM_DATA_SUPPORT
5378 case eWNI_SME_OEM_DATA_REQ:
5379 __limProcessSmeOemDataReq(pMac, pMsgBuf);
Jeff Johnsone7245742012-09-05 17:12:55 -07005380 break;
5381#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005382 case eWNI_SME_REMAIN_ON_CHANNEL_REQ:
5383 bufConsumed = limProcessRemainOnChnlReq(pMac, pMsgBuf);
5384 break;
5385
5386 case eWNI_SME_UPDATE_NOA:
5387 __limProcessSmeNoAUpdate(pMac, pMsgBuf);
5388 break;
Gopichand Nakkalac178ac82013-05-30 19:53:39 +05305389 case eWNI_SME_CLEAR_DFS_CHANNEL_LIST:
5390 __limProcessClearDfsChannelList(pMac, pMsg);
5391 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005392 case eWNI_SME_JOIN_REQ:
5393 __limProcessSmeJoinReq(pMac, pMsgBuf);
Jeff Johnson295189b2012-06-20 16:38:30 -07005394 break;
5395
5396 case eWNI_SME_AUTH_REQ:
5397 // __limProcessSmeAuthReq(pMac, pMsgBuf);
5398
5399 break;
5400
5401 case eWNI_SME_REASSOC_REQ:
5402 __limProcessSmeReassocReq(pMac, pMsgBuf);
5403
5404 break;
5405
5406 case eWNI_SME_PROMISCUOUS_MODE_REQ:
5407 //__limProcessSmePromiscuousReq(pMac, pMsgBuf);
5408
5409 break;
5410
5411 case eWNI_SME_DISASSOC_REQ:
5412 __limProcessSmeDisassocReq(pMac, pMsgBuf);
5413
5414 break;
5415
5416 case eWNI_SME_DISASSOC_CNF:
5417 case eWNI_SME_DEAUTH_CNF:
5418 __limProcessSmeDisassocCnf(pMac, pMsgBuf);
5419
5420 break;
5421
5422 case eWNI_SME_DEAUTH_REQ:
5423 __limProcessSmeDeauthReq(pMac, pMsgBuf);
5424
5425 break;
5426
Jeff Johnson295189b2012-06-20 16:38:30 -07005427
5428
5429 case eWNI_SME_SETCONTEXT_REQ:
5430 __limProcessSmeSetContextReq(pMac, pMsgBuf);
5431
5432 break;
5433
5434 case eWNI_SME_REMOVEKEY_REQ:
5435 __limProcessSmeRemoveKeyReq(pMac, pMsgBuf);
5436
5437 break;
5438
5439 case eWNI_SME_STOP_BSS_REQ:
5440 bufConsumed = __limProcessSmeStopBssReq(pMac, pMsg);
5441 break;
5442
5443 case eWNI_SME_ASSOC_CNF:
5444 case eWNI_SME_REASSOC_CNF:
5445 if (pMsg->type == eWNI_SME_ASSOC_CNF)
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005446 PELOG1(limLog(pMac, LOG1, FL("Received ASSOC_CNF message"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07005447 else
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005448 PELOG1(limLog(pMac, LOG1, FL("Received REASSOC_CNF message"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07005449 __limProcessSmeAssocCnfNew(pMac, pMsg->type, pMsgBuf);
5450 break;
5451
5452 case eWNI_SME_ADDTS_REQ:
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005453 PELOG1(limLog(pMac, LOG1, FL("Received ADDTS_REQ message"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07005454 __limProcessSmeAddtsReq(pMac, pMsgBuf);
5455 break;
5456
5457 case eWNI_SME_DELTS_REQ:
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005458 PELOG1(limLog(pMac, LOG1, FL("Received DELTS_REQ message"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07005459 __limProcessSmeDeltsReq(pMac, pMsgBuf);
5460 break;
5461
5462 case SIR_LIM_ADDTS_RSP_TIMEOUT:
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005463 PELOG1(limLog(pMac, LOG1, FL("Received SIR_LIM_ADDTS_RSP_TIMEOUT message "));)
Jeff Johnson295189b2012-06-20 16:38:30 -07005464 limProcessSmeAddtsRspTimeout(pMac, pMsg->bodyval);
5465 break;
5466
5467 case eWNI_SME_STA_STAT_REQ:
5468 case eWNI_SME_AGGR_STAT_REQ:
5469 case eWNI_SME_GLOBAL_STAT_REQ:
5470 case eWNI_SME_STAT_SUMM_REQ:
5471 __limProcessSmeStatsRequest( pMac, pMsgBuf);
5472 //HAL consumes pMsgBuf. It will be freed there. Set bufConsumed to false.
5473 bufConsumed = FALSE;
5474 break;
5475 case eWNI_SME_GET_STATISTICS_REQ:
5476 __limProcessSmeGetStatisticsRequest( pMac, pMsgBuf);
5477 //HAL consumes pMsgBuf. It will be freed there. Set bufConsumed to false.
5478 bufConsumed = FALSE;
5479 break;
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08005480#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_CCX || defined(FEATURE_WLAN_LFR)
5481 case eWNI_SME_GET_ROAM_RSSI_REQ:
5482 __limProcessSmeGetRoamRssiRequest( pMac, pMsgBuf);
5483 //HAL consumes pMsgBuf. It will be freed there. Set bufConsumed to false.
5484 bufConsumed = FALSE;
5485 break;
5486#endif
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005487#if defined(FEATURE_WLAN_CCX) && defined(FEATURE_WLAN_CCX_UPLOAD)
5488 case eWNI_SME_GET_TSM_STATS_REQ:
5489 __limProcessSmeGetTsmStatsRequest( pMac, pMsgBuf);
5490 bufConsumed = FALSE;
5491 break;
5492#endif /* FEATURE_WLAN_CCX && FEATURE_WLAN_CCX_UPLOAD */
Jeff Johnson295189b2012-06-20 16:38:30 -07005493 case eWNI_SME_DEL_BA_PEER_IND:
5494 limProcessSmeDelBaPeerInd(pMac, pMsgBuf);
5495 break;
5496 case eWNI_SME_GET_SCANNED_CHANNEL_REQ:
5497 limProcessSmeGetScanChannelInfo(pMac, pMsgBuf);
5498 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005499 case eWNI_SME_GET_ASSOC_STAS_REQ:
5500 limProcessSmeGetAssocSTAsInfo(pMac, pMsgBuf);
5501 break;
5502 case eWNI_SME_TKIP_CNTR_MEAS_REQ:
5503 limProcessTkipCounterMeasures(pMac, pMsgBuf);
5504 break;
5505
5506 case eWNI_SME_HIDE_SSID_REQ:
5507 __limProcessSmeHideSSID(pMac, pMsgBuf);
5508 break;
5509 case eWNI_SME_UPDATE_APWPSIE_REQ:
5510 __limProcessSmeUpdateAPWPSIEs(pMac, pMsgBuf);
5511 break;
5512 case eWNI_SME_GET_WPSPBC_SESSION_REQ:
5513 limProcessSmeGetWPSPBCSessions(pMac, pMsgBuf);
5514 break;
5515
5516 case eWNI_SME_SET_APWPARSNIEs_REQ:
5517 __limProcessSmeSetWPARSNIEs(pMac, pMsgBuf);
5518 break;
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08005519
5520 case eWNI_SME_CHNG_MCC_BEACON_INTERVAL:
5521 //Update the beaconInterval
5522 __limProcessSmeChangeBI(pMac, pMsgBuf );
5523 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005524
5525#if defined WLAN_FEATURE_VOWIFI
5526 case eWNI_SME_NEIGHBOR_REPORT_REQ_IND:
5527 case eWNI_SME_BEACON_REPORT_RESP_XMIT_IND:
5528 __limProcessReportMessage(pMac, pMsg);
5529 break;
5530#endif
5531
5532#if defined WLAN_FEATURE_VOWIFI_11R
5533 case eWNI_SME_FT_PRE_AUTH_REQ:
5534 bufConsumed = (tANI_BOOLEAN)limProcessFTPreAuthReq(pMac, pMsg);
5535 break;
5536 case eWNI_SME_FT_UPDATE_KEY:
5537 limProcessFTUpdateKey(pMac, pMsgBuf);
5538 break;
5539
5540 case eWNI_SME_FT_AGGR_QOS_REQ:
5541 limProcessFTAggrQosReq(pMac, pMsgBuf);
5542 break;
5543#endif
5544
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005545#if defined(FEATURE_WLAN_CCX) && !defined(FEATURE_WLAN_CCX_UPLOAD)
Jeff Johnson295189b2012-06-20 16:38:30 -07005546 case eWNI_SME_CCX_ADJACENT_AP_REPORT:
5547 limProcessAdjacentAPRepMsg ( pMac, pMsgBuf );
5548 break;
5549#endif
5550 case eWNI_SME_ADD_STA_SELF_REQ:
5551 __limProcessSmeAddStaSelfReq( pMac, pMsgBuf );
5552 break;
5553 case eWNI_SME_DEL_STA_SELF_REQ:
5554 __limProcessSmeDelStaSelfReq( pMac, pMsgBuf );
5555 break;
5556
Jeff Johnson295189b2012-06-20 16:38:30 -07005557 case eWNI_SME_REGISTER_MGMT_FRAME_REQ:
5558 __limProcessSmeRegisterMgmtFrameReq( pMac, pMsgBuf );
5559 break;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08005560#ifdef FEATURE_WLAN_TDLS
5561 case eWNI_SME_TDLS_SEND_MGMT_REQ:
5562 limProcessSmeTdlsMgmtSendReq(pMac, pMsgBuf);
5563 break;
5564 case eWNI_SME_TDLS_ADD_STA_REQ:
5565 limProcessSmeTdlsAddStaReq(pMac, pMsgBuf);
5566 break;
5567 case eWNI_SME_TDLS_DEL_STA_REQ:
5568 limProcessSmeTdlsDelStaReq(pMac, pMsgBuf);
5569 break;
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05305570 case eWNI_SME_TDLS_LINK_ESTABLISH_REQ:
5571 limProcesSmeTdlsLinkEstablishReq(pMac, pMsgBuf);
5572 break;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08005573#endif
5574#ifdef FEATURE_WLAN_TDLS_INTERNAL
5575 case eWNI_SME_TDLS_DISCOVERY_START_REQ:
5576 limProcessSmeDisStartReq(pMac, pMsgBuf);
5577 break ;
5578 case eWNI_SME_TDLS_LINK_START_REQ:
5579 limProcessSmeLinkStartReq(pMac, pMsgBuf);
5580 break ;
5581 case eWNI_SME_TDLS_TEARDOWN_REQ:
5582 limProcessSmeTeardownReq(pMac, pMsgBuf);
5583 break ;
5584#endif
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05305585 case eWNI_SME_RESET_AP_CAPS_CHANGED:
5586 __limProcessSmeResetApCapsChange(pMac, pMsgBuf);
5587 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005588
schang86c22c42013-03-13 18:41:24 -07005589 case eWNI_SME_SET_TX_POWER_REQ:
5590 limSendSetTxPowerReq(pMac, pMsgBuf);
5591 break ;
5592
Jeff Johnson295189b2012-06-20 16:38:30 -07005593 default:
5594 vos_mem_free((v_VOID_t*)pMsg->bodyptr);
5595 pMsg->bodyptr = NULL;
5596 break;
5597 } // switch (msgType)
5598
5599 return bufConsumed;
5600} /*** end limProcessSmeReqMessages() ***/