blob: 7ade82a56918610447f1a207a1bd9634ca6da73f [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Jeff Johnson32d95a32012-09-10 13:15:23 -07002 * Copyright (c) 2012, The Linux Foundation. All rights reserved.
Jeff Johnson295189b2012-06-20 16:38:30 -07003 *
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
22/*
23 * Airgo Networks, Inc proprietary. All rights reserved.
24 * This file limProcessSmeReqMessages.cc contains the code
25 * for processing SME request messages.
26 * Author: Chandra Modumudi
27 * Date: 02/11/02
28 * History:-
29 * Date Modified by Modification Information
30 * --------------------------------------------------------------------
31 *
32 */
33
34#include "palTypes.h"
35#include "wniApi.h"
36#ifdef ANI_PRODUCT_TYPE_AP
37#include "wniCfgAp.h"
38#else
39#include "wniCfgSta.h"
40#endif
41#include "cfgApi.h"
42#include "sirApi.h"
43#include "schApi.h"
44#include "utilsApi.h"
45#include "limTypes.h"
46#include "limUtils.h"
47#include "limAssocUtils.h"
48#include "limSecurityUtils.h"
49#include "limSerDesUtils.h"
50#include "limSmeReqUtils.h"
51#include "limIbssPeerMgmt.h"
52#include "limAdmitControl.h"
53#include "dphHashTable.h"
54#include "limSendMessages.h"
55#include "limApi.h"
56#include "wmmApsd.h"
57
58#ifdef WLAN_SOFTAP_FEATURE
59#include "sapApi.h"
60#endif
61
62#if defined WLAN_FEATURE_VOWIFI
63#include "rrmApi.h"
64#endif
65#if defined FEATURE_WLAN_CCX
66#include "ccxApi.h"
67#endif
68
69#if defined WLAN_FEATURE_VOWIFI_11R
70#include <limFT.h>
71#endif
72
73#ifdef FEATURE_WLAN_CCX
74/* These are the min/max tx power (non virtual rates) range
75 supported by prima hardware */
76#define MIN_TX_PWR_CAP 12
77#define MAX_TX_PWR_CAP 19
78
79#endif
80
81
82// SME REQ processing function templates
83static void __limProcessSmeStartReq(tpAniSirGlobal, tANI_U32 *);
84static tANI_BOOLEAN __limProcessSmeSysReadyInd(tpAniSirGlobal, tANI_U32 *);
85static tANI_BOOLEAN __limProcessSmeStartBssReq(tpAniSirGlobal, tpSirMsgQ pMsg);
86static void __limProcessSmeScanReq(tpAniSirGlobal, tANI_U32 *);
87static void __limProcessSmeJoinReq(tpAniSirGlobal, tANI_U32 *);
88static void __limProcessSmeReassocReq(tpAniSirGlobal, tANI_U32 *);
89static void __limProcessSmeDisassocReq(tpAniSirGlobal, tANI_U32 *);
90static void __limProcessSmeDisassocCnf(tpAniSirGlobal, tANI_U32 *);
91static void __limProcessSmeDeauthReq(tpAniSirGlobal, tANI_U32 *);
92static void __limProcessSmeSetContextReq(tpAniSirGlobal, tANI_U32 *);
93static tANI_BOOLEAN __limProcessSmeStopBssReq(tpAniSirGlobal, tpSirMsgQ pMsg);
94
95#if 0
96 static void __limProcessSmeAuthReq(tpAniSirGlobal, tANI_U32 *);
97 static void __limProcessSmePromiscuousReq(tpAniSirGlobal, tANI_U32 *);
98#endif
99
100#ifdef ANI_PRODUCT_TYPE_AP
101static void __limProcessSmeAssocCnf(tpAniSirGlobal, tANI_U32, tANI_U32 *);
102#endif
103void __limProcessSmeAssocCnfNew(tpAniSirGlobal, tANI_U32, tANI_U32 *);
104
105#ifdef VOSS_ENABLED
106extern void peRegisterTLHandle(tpAniSirGlobal pMac);
107#endif
108
109#ifdef WLAN_FEATURE_P2P
110extern int limProcessRemainOnChnlReq(tpAniSirGlobal pMac, tANI_U32 *pMsg);
111#endif
112
113#ifdef ANI_PRODUCT_TYPE_CLIENT
114#ifdef BACKGROUND_SCAN_ENABLED
115
116// start the background scan timers if it hasn't already started
117static void
118__limBackgroundScanInitiate(tpAniSirGlobal pMac)
119{
120 if (pMac->lim.gLimBackgroundScanStarted)
121 return;
122
123 //make sure timer is created first
124 if (TX_TIMER_VALID(pMac->lim.limTimers.gLimBackgroundScanTimer))
125 {
126 limDeactivateAndChangeTimer(pMac, eLIM_BACKGROUND_SCAN_TIMER);
Jeff Johnsone7245742012-09-05 17:12:55 -0700127 MTRACE(macTrace(pMac, TRACE_CODE_TIMER_ACTIVATE, NO_SESSION, eLIM_BACKGROUND_SCAN_TIMER));
Jeff Johnson295189b2012-06-20 16:38:30 -0700128 if (tx_timer_activate(&pMac->lim.limTimers.gLimBackgroundScanTimer) != TX_SUCCESS)
129 limLog(pMac, LOGP, FL("could not activate background scan timer\n"));
130 pMac->lim.gLimBackgroundScanStarted = true;
131 pMac->lim.gLimBackgroundScanChannelId = 0;
132 }
133}
134
135#endif // BACKGROUND_SCAN_ENABLED
136#endif
137
138// determine if a fresh scan request must be issued or not
139/*
140* PE will do fresh scan, if all of the active sessions are in good state (Link Est or BSS Started)
141* If one of the sessions is not in one of the above states, then PE does not do fresh scan
142* If no session exists (scanning very first time), then PE will always do fresh scan if SME
143* asks it to do that.
144*/
145static tANI_U8
146__limFreshScanReqd(tpAniSirGlobal pMac, tANI_U8 returnFreshResults)
147{
148
149 tANI_U8 validState = TRUE;
150 int i;
151
152 if(pMac->lim.gLimSmeState != eLIM_SME_IDLE_STATE)
153 {
154 return FALSE;
155 }
156 for(i =0; i < pMac->lim.maxBssId; i++)
157 {
158
159 if(pMac->lim.gpSession[i].valid == TRUE)
160 {
161 if(!( ( ( (pMac->lim.gpSession[i].bssType == eSIR_INFRASTRUCTURE_MODE) ||
162 (pMac->lim.gpSession[i].limSystemRole == eLIM_BT_AMP_STA_ROLE))&&
163 (pMac->lim.gpSession[i].limSmeState == eLIM_SME_LINK_EST_STATE) )||
164
165 ( ( (pMac->lim.gpSession[i].bssType == eSIR_IBSS_MODE)||
166 (pMac->lim.gpSession[i].limSystemRole == eLIM_BT_AMP_AP_ROLE)||
167 (pMac->lim.gpSession[i].limSystemRole == eLIM_BT_AMP_STA_ROLE) )&&
168 (pMac->lim.gpSession[i].limSmeState == eLIM_SME_NORMAL_STATE) )
169#ifdef WLAN_FEATURE_P2P
170 || ( ( ( (pMac->lim.gpSession[i].bssType == eSIR_INFRA_AP_MODE)
171 && ( pMac->lim.gpSession[i].pePersona == VOS_P2P_GO_MODE) )
172 || (pMac->lim.gpSession[i].limSystemRole == eLIM_AP_ROLE) )
173 && (pMac->lim.gpSession[i].limSmeState == eLIM_SME_NORMAL_STATE) )
174#endif
175 ))
176 {
177 validState = FALSE;
178 break;
179 }
180
181 }
182 }
183 PELOG1(limLog(pMac, LOG1, FL("FreshScanReqd: %d \n"), validState);)
184
185 if( (validState) && (returnFreshResults & SIR_BG_SCAN_RETURN_FRESH_RESULTS))
186 return TRUE;
187
188 return FALSE;
189}
190
191#if (WNI_POLARIS_FW_PACKAGE == ADVANCED) && defined(ANI_PRODUCT_TYPE_AP)
192static tANI_BOOLEAN __limProcessSmeSwitchChlReq(tpAniSirGlobal, tpSirMsgQ pMsg);
193#endif
194
195
196/**
197 * __limIsSmeAssocCnfValid()
198 *
199 *FUNCTION:
200 * This function is called by limProcessLmmMessages() upon
201 * receiving SME_ASSOC_CNF.
202 *
203 *LOGIC:
204 * Message validity checks are performed in this function
205 *
206 *ASSUMPTIONS:
207 *
208 *NOTE:
209 *
210 * @param pMeasReq Pointer to Received ASSOC_CNF message
211 * @return true When received SME_ASSOC_CNF is formatted
212 * correctly
213 * false otherwise
214 */
215
216inline static tANI_U8
217__limIsSmeAssocCnfValid(tpSirSmeAssocCnf pAssocCnf)
218{
219 if (limIsGroupAddr(pAssocCnf->peerMacAddr))
220 return false;
221 else
222 return true;
223} /*** end __limIsSmeAssocCnfValid() ***/
224
225
226/**
227 * __limGetSmeJoinReqSizeForAlloc()
228 *
229 *FUNCTION:
230 * This function is called in various places to get IE length
231 * from tSirBssDescription structure
232 * number being scanned.
233 *
234 *PARAMS:
235 *
236 *LOGIC:
237 *
238 *ASSUMPTIONS:
239 * NA
240 *
241 *NOTE:
242 * NA
243 *
244 * @param pBssDescr
245 * @return Total IE length
246 */
247
248static tANI_U16
249__limGetSmeJoinReqSizeForAlloc(tANI_U8 *pBuf)
250{
251 tANI_U16 len = 0;
252
253 if (!pBuf)
254 return len;
255
256 pBuf += sizeof(tANI_U16);
257 len = limGetU16( pBuf );
258 return (len + sizeof( tANI_U16 ));
259} /*** end __limGetSmeJoinReqSizeForAlloc() ***/
260
261
262/**----------------------------------------------------------------
263\fn __limIsDeferedMsgForLearn
264
265\brief Has role only if 11h is enabled. Not used on STA side.
266 Defers the message if SME is in learn state and brings
267 the LIM back to normal mode.
268
269\param pMac
270\param pMsg - Pointer to message posted from SME to LIM.
271\return TRUE - If defered
272 FALSE - Otherwise
273------------------------------------------------------------------*/
274static tANI_BOOLEAN
275__limIsDeferedMsgForLearn(tpAniSirGlobal pMac, tpSirMsgQ pMsg)
276{
277 if (limIsSystemInScanState(pMac))
278 {
279 if (limDeferMsg(pMac, pMsg) != TX_SUCCESS)
280 {
281 PELOGE(limLog(pMac, LOGE, FL("Could not defer Msg = %d\n"), pMsg->type);)
282 return eANI_BOOLEAN_FALSE;
283 }
284 PELOG1(limLog(pMac, LOG1, FL("Defer the message, in learn mode type = %d\n"),
285 pMsg->type);)
286
287 /** Send finish scan req to HAL only if LIM is not waiting for any response
288 * from HAL like init scan rsp, start scan rsp etc.
289 */
290 if (GET_LIM_PROCESS_DEFD_MESGS(pMac))
291 {
292 //Set the resume channel to Any valid channel (invalid).
293 //This will instruct HAL to set it to any previous valid channel.
294 peSetResumeChannel(pMac, 0, 0);
295 limSendHalFinishScanReq(pMac, eLIM_HAL_FINISH_LEARN_WAIT_STATE);
296 }
297
298 return eANI_BOOLEAN_TRUE;
299 }
300 return eANI_BOOLEAN_FALSE;
301}
302
303/**----------------------------------------------------------------
304\fn __limIsDeferedMsgForRadar
305
306\brief Has role only if 11h is enabled. Not used on STA side.
307 Defers the message if radar is detected.
308
309\param pMac
310\param pMsg - Pointer to message posted from SME to LIM.
311\return TRUE - If defered
312 FALSE - Otherwise
313------------------------------------------------------------------*/
314static tANI_BOOLEAN
315__limIsDeferedMsgForRadar(tpAniSirGlobal pMac, tpSirMsgQ pMsg)
316{
317 /** fRadarDetCurOperChan will be set only if we detect radar in current
318 * operating channel and System Role == AP ROLE */
Jeff Johnsone7245742012-09-05 17:12:55 -0700319 //TODO: Need to take care radar detection.
320 //if (LIM_IS_RADAR_DETECTED(pMac))
321 if( 0 )
Jeff Johnson295189b2012-06-20 16:38:30 -0700322 {
323 if (limDeferMsg(pMac, pMsg) != TX_SUCCESS)
324 {
325 PELOGE(limLog(pMac, LOGE, FL("Could not defer Msg = %d\n"), pMsg->type);)
326 return eANI_BOOLEAN_FALSE;
327 }
328 PELOG1(limLog(pMac, LOG1, FL("Defer the message, in learn mode type = %d\n"),
329 pMsg->type);)
330 return eANI_BOOLEAN_TRUE;
331 }
332 return eANI_BOOLEAN_FALSE;
333}
334
335
336/**
337 * __limProcessSmeStartReq()
338 *
339 *FUNCTION:
340 * This function is called to process SME_START_REQ message
341 * from HDD or upper layer application.
342 *
343 *LOGIC:
344 *
345 *ASSUMPTIONS:
346 *
347 *NOTE:
348 *
349 * @param pMac Pointer to Global MAC structure
350 * @param *pMsgBuf A pointer to the SME message buffer
351 * @return None
352 */
353
354static void
355__limProcessSmeStartReq(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
356{
357 tSirResultCodes retCode = eSIR_SME_SUCCESS;
358 tANI_U8 smesessionId;
359 tANI_U16 smetransactionId;
360
361
362 PELOG1(limLog(pMac, LOG1, FL("Received START_REQ\n"));)
363
364 limGetSessionInfo(pMac,(tANI_U8 *)pMsgBuf,&smesessionId,&smetransactionId);
365
366 if (pMac->lim.gLimSmeState == eLIM_SME_OFFLINE_STATE)
367 {
368 pMac->lim.gLimSmeState = eLIM_SME_IDLE_STATE;
369
Jeff Johnsone7245742012-09-05 17:12:55 -0700370 MTRACE(macTrace(pMac, TRACE_CODE_SME_STATE, NO_SESSION, pMac->lim.gLimSmeState));
Jeff Johnson295189b2012-06-20 16:38:30 -0700371
372 /// By default do not return after first scan match
373 pMac->lim.gLimReturnAfterFirstMatch = 0;
374
375 /// Initialize MLM state machine
376 limInitMlm(pMac);
377
378 /// By default return unique scan results
379 pMac->lim.gLimReturnUniqueResults = true;
380 pMac->lim.gLimSmeScanResultLength = 0;
381
382#if defined(ANI_PRODUCT_TYPE_CLIENT) || defined(ANI_AP_CLIENT_SDK)
383 if (((tSirSmeStartReq *) pMsgBuf)->sendNewBssInd)
384 {
385 /*
386 * Need to indicate new BSSs found during background scanning to
387 * host. Update this parameter at CFG
388 */
389 if (cfgSetInt(pMac, WNI_CFG_NEW_BSS_FOUND_IND, ((tSirSmeStartReq *) pMsgBuf)->sendNewBssInd)
390 != eSIR_SUCCESS)
391 {
392 limLog(pMac, LOGP, FL("could not set NEIGHBOR_BSS_IND at CFG\n"));
393 retCode = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
394 }
395 }
396#endif
397 }
398 else
399 {
400 /**
401 * Should not have received eWNI_SME_START_REQ in states
402 * other than OFFLINE. Return response to host and
403 * log error
404 */
405 limLog(pMac, LOGE, FL("Invalid SME_START_REQ received in SME state %X\n"),pMac->lim.gLimSmeState );
406 limPrintSmeState(pMac, LOGE, pMac->lim.gLimSmeState);
407 retCode = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
408 }
409 limSendSmeRsp(pMac, eWNI_SME_START_RSP, retCode,smesessionId,smetransactionId);
410} /*** end __limProcessSmeStartReq() ***/
411
412
413/** -------------------------------------------------------------
414\fn __limProcessSmeSysReadyInd
415\brief handles the notification from HDD. PE just forwards this message to HAL.
416\param tpAniSirGlobal pMac
417\param tANI_U32* pMsgBuf
418\return TRUE-Posting to HAL failed, so PE will consume the buffer.
419\ FALSE-Posting to HAL successful, so HAL will consume the buffer.
420 -------------------------------------------------------------*/
421static tANI_BOOLEAN
422__limProcessSmeSysReadyInd(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
423{
424 tSirMsgQ msg;
425
426 msg.type = WDA_SYS_READY_IND;
427 msg.reserved = 0;
428 msg.bodyptr = pMsgBuf;
429 msg.bodyval = 0;
430
431#ifdef VOSS_ENABLED
432 if(pMac->gDriverType != eDRIVER_TYPE_MFG)
433 {
434 peRegisterTLHandle(pMac);
435 }
436#endif
437 PELOGW(limLog(pMac, LOGW, FL("sending WDA_SYS_READY_IND msg to HAL\n"));)
Jeff Johnsone7245742012-09-05 17:12:55 -0700438 MTRACE(macTraceMsgTx(pMac, NO_SESSION, msg.type));
Jeff Johnson295189b2012-06-20 16:38:30 -0700439
440 if(eSIR_SUCCESS != wdaPostCtrlMsg(pMac, &msg))
441 {
442 limLog(pMac, LOGP, FL("wdaPostCtrlMsg failed\n"));
443 return eANI_BOOLEAN_TRUE;
444 }
445 return eANI_BOOLEAN_FALSE;
446}
447
Jeff Johnsone7245742012-09-05 17:12:55 -0700448#ifdef WLAN_FEATURE_11AC
Jeff Johnson295189b2012-06-20 16:38:30 -0700449
Jeff Johnsone7245742012-09-05 17:12:55 -0700450tANI_U32 limGetCenterChannel(tpAniSirGlobal pMac,tANI_U8 primarychanNum,ePhyChanBondState secondaryChanOffset, tANI_U8 chanWidth)
451{
452 if (chanWidth == WNI_CFG_VHT_CHANNEL_WIDTH_80MHZ)
453 {
454 switch(secondaryChanOffset)
455 {
456 case PHY_QUADRUPLE_CHANNEL_20MHZ_CENTERED_40MHZ_CENTERED:
457 return primarychanNum;
458 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_CENTERED:
459 return primarychanNum + 2;
460 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_CENTERED:
461 return primarychanNum - 2;
462 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_LOW:
463 return primarychanNum + 6;
464 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_LOW:
465 return primarychanNum + 2;
466 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_HIGH:
467 return primarychanNum - 2;
468 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_HIGH:
469 return primarychanNum - 6;
470 default :
471 return eSIR_CFG_INVALID_ID;
472 }
473 }
474 else if (chanWidth == WNI_CFG_VHT_CHANNEL_WIDTH_20_40MHZ)
475 {
476 switch(secondaryChanOffset)
477 {
478 case PHY_DOUBLE_CHANNEL_LOW_PRIMARY:
479 return primarychanNum + 2;
480 case PHY_DOUBLE_CHANNEL_HIGH_PRIMARY:
481 return primarychanNum - 2;
482 case PHY_QUADRUPLE_CHANNEL_20MHZ_CENTERED_40MHZ_CENTERED:
483 return primarychanNum;
484 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_CENTERED:
485 return primarychanNum + 2;
486 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_CENTERED:
487 return primarychanNum - 2;
488 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_LOW:
489 return primarychanNum + 2;
490 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_LOW:
491 return primarychanNum - 2;
492 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_HIGH:
493 return primarychanNum + 2;
494 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_HIGH:
495 return primarychanNum - 2;
496 default :
497 return eSIR_CFG_INVALID_ID;
498 }
499 }
500 return primarychanNum;
501}
502
503#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700504/**
505 * __limHandleSmeStartBssRequest()
506 *
507 *FUNCTION:
508 * This function is called to process SME_START_BSS_REQ message
509 * from HDD or upper layer application.
510 *
511 *LOGIC:
512 *
513 *ASSUMPTIONS:
514 *
515 *NOTE:
516 *
517 * @param pMac Pointer to Global MAC structure
518 * @param *pMsgBuf A pointer to the SME message buffer
519 * @return None
520 */
521
522static void
523__limHandleSmeStartBssRequest(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
524{
525 tANI_U16 size;
526 tANI_U32 val = 0;
527 tSirRetStatus retStatus;
528 tSirMacChanNum channelNumber;
529 tLimMlmStartReq *pMlmStartReq;
530 tpSirSmeStartBssReq pSmeStartBssReq; //Local variable for Start BSS Req.. Added For BT-AMP Support
531 tSirResultCodes retCode = eSIR_SME_SUCCESS;
532 tANI_U32 autoGenBssId = FALSE; //Flag Used in case of IBSS to Auto generate BSSID.
Jeff Johnson295189b2012-06-20 16:38:30 -0700533 tANI_U8 sessionId;
534 tpPESession psessionEntry = NULL;
535 tANI_U8 smesessionId;
536 tANI_U16 smetransactionId;
537
538#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM //FEATURE_WLAN_DIAG_SUPPORT
539 //Since the session is not created yet, sending NULL. The response should have the correct state.
540 limDiagEventReport(pMac, WLAN_PE_DIAG_START_BSS_REQ_EVENT, NULL, 0, 0);
541#endif //FEATURE_WLAN_DIAG_SUPPORT
542
543 PELOG1(limLog(pMac, LOG1, FL("Received START_BSS_REQ\n"));)
544
545 /* Global Sme state and mlm states are not defined yet , for BT-AMP Suppoprt . TO BE DONE */
546 if ( (pMac->lim.gLimSmeState == eLIM_SME_OFFLINE_STATE) ||
547 (pMac->lim.gLimSmeState == eLIM_SME_IDLE_STATE))
548 {
549 size = sizeof(tSirSmeStartBssReq) + SIR_MAC_MAX_IE_LENGTH;
550
551#ifdef ANI_PRODUCT_TYPE_AP
552 size + = ANI_WDS_INFO_MAX_LENGTH;
553#endif
554
555 if( eHAL_STATUS_SUCCESS != palAllocateMemory( pMac->hHdd, (void **)&pSmeStartBssReq, size))
556 {
557 PELOGE(limLog(pMac, LOGE, FL("palAllocateMemory failed for pMac->lim.gpLimStartBssReq\n"));)
558 /// Send failure response to host
559 retCode = eSIR_SME_RESOURCES_UNAVAILABLE;
560 goto end;
561 }
562
563 (void) palZeroMemory(pMac->hHdd, (void *)pSmeStartBssReq, size);
564
565 if ((limStartBssReqSerDes(pMac, pSmeStartBssReq, (tANI_U8 *) pMsgBuf) == eSIR_FAILURE) ||
566 (!limIsSmeStartBssReqValid(pMac, pSmeStartBssReq)))
567 {
568 PELOGW(limLog(pMac, LOGW, FL("Received invalid eWNI_SME_START_BSS_REQ\n"));)
569 retCode = eSIR_SME_INVALID_PARAMETERS;
570 goto free;
571 }
572#if 0
573 PELOG3(limLog(pMac, LOG3,
574 FL("Parsed START_BSS_REQ fields are bssType=%d, channelId=%d\n"),
575 pMac->lim.gpLimStartBssReq->bssType, pMac->lim.gpLimStartBssReq->channelId);)
576#endif
577
578 /* This is the place where PE is going to create a session.
579 * If session is not existed , then create a new session */
580 if((psessionEntry = peFindSessionByBssid(pMac,pSmeStartBssReq->bssId,&sessionId)) != NULL)
581 {
582 limLog(pMac, LOGW, FL("Session Already exists for given BSSID\n"));
583 retCode = eSIR_SME_BSS_ALREADY_STARTED_OR_JOINED;
584 psessionEntry = NULL;
585 goto free;
586 }
587 else
588 {
589 if((psessionEntry = peCreateSession(pMac,pSmeStartBssReq->bssId,&sessionId, pMac->lim.maxStation)) == NULL)
590 {
591 limLog(pMac, LOGW, FL("Session Can not be created \n"));
592 retCode = eSIR_SME_RESOURCES_UNAVAILABLE;
593 goto free;
594 }
595
596 }
597
598 /* Store the session related parameters in newly created session */
599 psessionEntry->pLimStartBssReq = pSmeStartBssReq;
600
601 /* Store PE sessionId in session Table */
602 psessionEntry->peSessionId = sessionId;
603
604 /* Store SME session Id in sessionTable */
605 psessionEntry->smeSessionId = pSmeStartBssReq->sessionId;
606
607 psessionEntry->transactionId = pSmeStartBssReq->transactionId;
608
609 sirCopyMacAddr(psessionEntry->selfMacAddr,pSmeStartBssReq->selfMacAddr);
610
611 /* Copy SSID to session table */
612 palCopyMemory( pMac->hHdd, (tANI_U8 *)&psessionEntry->ssId,
613 (tANI_U8 *)&pSmeStartBssReq->ssId,
614 (pSmeStartBssReq->ssId.length + 1));
615
616
617
618 psessionEntry->bssType = pSmeStartBssReq->bssType;
619
620 psessionEntry->nwType = pSmeStartBssReq->nwType;
621
622 psessionEntry->beaconParams.beaconInterval = pSmeStartBssReq->beaconInterval;
623
624 /* Store the channel number in session Table */
625 psessionEntry->currentOperChannel = pSmeStartBssReq->channelId;
626
627 /*Store Persona */
628 psessionEntry->pePersona = pSmeStartBssReq->bssPersona;
629 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,FL("PE PERSONA=%d\n"),
630 psessionEntry->pePersona);
631
632 /*Update the phymode*/
633 psessionEntry->gLimPhyMode = pSmeStartBssReq->nwType;
634
635 psessionEntry->maxTxPower = cfgGetRegulatoryMaxTransmitPower( pMac,
636 psessionEntry->currentOperChannel );
637 /* Store the dot 11 mode in to the session Table*/
638
639 psessionEntry->dot11mode = pSmeStartBssReq->dot11mode;
Jeff Johnsone7245742012-09-05 17:12:55 -0700640 psessionEntry->htCapability = IS_DOT11_MODE_HT(psessionEntry->dot11mode);
641#ifdef WLAN_FEATURE_11AC
642 psessionEntry->vhtCapability = IS_DOT11_MODE_VHT(psessionEntry->dot11mode);
643 VOS_TRACE(VOS_MODULE_ID_PE,VOS_TRACE_LEVEL_FATAL,
644 FL("*****psessionEntry->vhtCapability = %d\n"),psessionEntry->vhtCapability);
645#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700646 palCopyMemory(pMac->hHdd, (void*)&psessionEntry->rateSet,
647 (void*)&pSmeStartBssReq->operationalRateSet,
648 sizeof(tSirMacRateSet));
649 palCopyMemory(pMac->hHdd, (void*)&psessionEntry->extRateSet,
650 (void*)&pSmeStartBssReq->extendedRateSet,
651 sizeof(tSirMacRateSet));
652
653 switch(pSmeStartBssReq->bssType)
654 {
655#ifdef WLAN_SOFTAP_FEATURE
656 case eSIR_INFRA_AP_MODE:
657 psessionEntry->limSystemRole = eLIM_AP_ROLE;
658 psessionEntry->privacy = pSmeStartBssReq->privacy;
659 psessionEntry->fwdWPSPBCProbeReq = pSmeStartBssReq->fwdWPSPBCProbeReq;
660 psessionEntry->authType = pSmeStartBssReq->authType;
661 /* Store the DTIM period */
662 psessionEntry->dtimPeriod = (tANI_U8)pSmeStartBssReq->dtimPeriod;
663 /*Enable/disable UAPSD*/
664 psessionEntry->apUapsdEnable = pSmeStartBssReq->apUapsdEnable;
665 if (psessionEntry->pePersona == VOS_P2P_GO_MODE)
666 {
667 psessionEntry->proxyProbeRspEn = 0;
668 }
669 else
670 {
671 /* To detect PBC overlap in SAP WPS mode, Host handles
672 * Probe Requests.
673 */
674 if(SAP_WPS_DISABLED == pSmeStartBssReq->wps_state)
675 {
676 psessionEntry->proxyProbeRspEn = 1;
677 }
678 else
679 {
680 psessionEntry->proxyProbeRspEn = 0;
681 }
682 }
683 psessionEntry->ssidHidden = pSmeStartBssReq->ssidHidden;
684 psessionEntry->wps_state = pSmeStartBssReq->wps_state;
685 break;
686#endif
687 case eSIR_IBSS_MODE:
688 psessionEntry->limSystemRole = eLIM_STA_IN_IBSS_ROLE;
689 break;
690
691 case eSIR_BTAMP_AP_MODE:
692 psessionEntry->limSystemRole = eLIM_BT_AMP_AP_ROLE;
693 break;
694
695 case eSIR_BTAMP_STA_MODE:
696 psessionEntry->limSystemRole = eLIM_BT_AMP_STA_ROLE;
697 break;
698
699 /* There is one more mode called auto mode. which is used no where */
700
701 //FORBUILD -TEMPFIX.. HOW TO use AUTO MODE?????
702
703
704 default:
705 //not used anywhere...used in scan function
706 break;
707 }
708
709 // BT-AMP: Allocate memory for the array of parsed (Re)Assoc request structure
710 if ( (pSmeStartBssReq->bssType == eSIR_BTAMP_AP_MODE)
711#ifdef WLAN_SOFTAP_FEATURE
712 || (pSmeStartBssReq->bssType == eSIR_INFRA_AP_MODE)
713#endif
714 )
715 {
716 if( eHAL_STATUS_SUCCESS != palAllocateMemory( pMac->hHdd, (void **)&psessionEntry->parsedAssocReq,
717 (psessionEntry->dph.dphHashTable.size * sizeof(tpSirAssocReq)) ))
718 {
719 limLog(pMac, LOGW, FL("palAllocateMemory() failed\n"));
720 retCode = eSIR_SME_RESOURCES_UNAVAILABLE;
721 goto free;
722 }
723 palZeroMemory(pMac->hHdd, psessionEntry->parsedAssocReq, (psessionEntry->dph.dphHashTable.size * sizeof(tpSirAssocReq)) );
724 }
725
726 /* Channel Bonding is not addressd yet for BT-AMP Support.. sunit will address channel bonding */
727 if (pSmeStartBssReq->channelId)
728 {
729 channelNumber = pSmeStartBssReq->channelId;
Jeff Johnsone7245742012-09-05 17:12:55 -0700730 psessionEntry->htSupportedChannelWidthSet = (pSmeStartBssReq->cbMode)?1:0; // This is already merged value of peer and self - done by csr in csrGetCBModeFromIes
731 psessionEntry->htRecommendedTxWidthSet = psessionEntry->htSupportedChannelWidthSet;
732 psessionEntry->htSecondaryChannelOffset = pSmeStartBssReq->cbMode;
733 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
734 FL("cbMode %u"), pSmeStartBssReq->cbMode);
735#ifdef WLAN_FEATURE_11AC
736 if(psessionEntry->vhtCapability)
737 {
738 tANI_U32 centerChan;
739 tANI_U32 chanWidth;
Jeff Johnson295189b2012-06-20 16:38:30 -0700740
Jeff Johnsone7245742012-09-05 17:12:55 -0700741 if (wlan_cfgGetInt(pMac, WNI_CFG_VHT_CHANNEL_WIDTH,
742 &chanWidth) != eSIR_SUCCESS)
Jeff Johnson295189b2012-06-20 16:38:30 -0700743 {
Jeff Johnsone7245742012-09-05 17:12:55 -0700744 limLog(pMac, LOGP,
745 FL("Unable to retrieve Channel Width from CFG\n"));
746 }
747
748 if(chanWidth == eHT_CHANNEL_WIDTH_20MHZ || chanWidth == eHT_CHANNEL_WIDTH_40MHZ)
749 {
750 if (cfgSetInt(pMac, WNI_CFG_VHT_CHANNEL_WIDTH, WNI_CFG_VHT_CHANNEL_WIDTH_20_40MHZ)
751 != eSIR_SUCCESS)
Jeff Johnson295189b2012-06-20 16:38:30 -0700752 {
753 limLog(pMac, LOGP, FL("could not set WNI_CFG_CHANNEL_BONDING_MODE at CFG\n"));
754 retCode = eSIR_LOGP_EXCEPTION;
Jeff Johnsone7245742012-09-05 17:12:55 -0700755 goto free;
Jeff Johnson295189b2012-06-20 16:38:30 -0700756 }
757 }
Jeff Johnsone7245742012-09-05 17:12:55 -0700758 if (chanWidth == eHT_CHANNEL_WIDTH_80MHZ)
759 {
760 if (cfgSetInt(pMac, WNI_CFG_VHT_CHANNEL_WIDTH, WNI_CFG_VHT_CHANNEL_WIDTH_80MHZ)
761 != eSIR_SUCCESS)
762 {
763 limLog(pMac, LOGP, FL("could not set WNI_CFG_CHANNEL_BONDING_MODE at CFG\n"));
764 retCode = eSIR_LOGP_EXCEPTION;
765 goto free;
766 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700767
Jeff Johnsone7245742012-09-05 17:12:55 -0700768 centerChan = limGetCenterChannel(pMac,channelNumber,pSmeStartBssReq->cbMode,WNI_CFG_VHT_CHANNEL_WIDTH_80MHZ);
769 if(centerChan != eSIR_CFG_INVALID_ID)
770 {
771 limLog(pMac, LOGW, FL("***Center Channel for 80MHZ channel width = %ld\n"),centerChan);
772 if (cfgSetInt(pMac, WNI_CFG_VHT_CHANNEL_CENTER_FREQ_SEGMENT1, centerChan)
773 != eSIR_SUCCESS)
774 {
775 limLog(pMac, LOGP, FL("could not set WNI_CFG_CHANNEL_BONDING_MODE at CFG\n"));
776 retCode = eSIR_LOGP_EXCEPTION;
777 goto free;
778 }
779 }
780 }
781
782 /* All the translation is done by now for gVhtChannelWidth from .ini file to
783 * the actual values as defined in spec. So, grabing the spec value which is
784 * updated in .dat file by the above logic */
785 if (wlan_cfgGetInt(pMac, WNI_CFG_VHT_CHANNEL_WIDTH,
786 &chanWidth) != eSIR_SUCCESS)
787 {
788 limLog(pMac, LOGP,
789 FL("Unable to retrieve Channel Width from CFG\n"));
790 }
791
792 psessionEntry->vhtTxChannelWidthSet = chanWidth;
793 }
794 psessionEntry->htSecondaryChannelOffset = limGetHTCBState(pSmeStartBssReq->cbMode);
795#endif
796 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700797 else
798 {
799 PELOGW(limLog(pMac, LOGW, FL("Received invalid eWNI_SME_START_BSS_REQ\n"));)
800 retCode = eSIR_SME_INVALID_PARAMETERS;
801 goto free;
802 }
803
804 // Delete pre-auth list if any
805 limDeletePreAuthList(pMac);
806
807 // Delete IBSS peer BSSdescription list if any
808 //limIbssDelete(pMac); sep 26 review
809
810
811
812#ifdef FIXME_GEN6 //following code may not be required. limInitMlm is now being invoked during peStart
813 /// Initialize MLM state machine
Jeff Johnson295189b2012-06-20 16:38:30 -0700814 limInitMlm(pMac);
815#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700816
Jeff Johnsone7245742012-09-05 17:12:55 -0700817 psessionEntry->htCapability = IS_DOT11_MODE_HT(pSmeStartBssReq->dot11mode);
Jeff Johnson295189b2012-06-20 16:38:30 -0700818
819#ifdef WLAN_SOFTAP_FEATURE
820 /* keep the RSN/WPA IE information in PE Session Entry
821 * later will be using this to check when received (Re)Assoc req
822 * */
823 limSetRSNieWPAiefromSmeStartBSSReqMessage(pMac,&pSmeStartBssReq->rsnIE,psessionEntry);
824
825#endif
826
827#ifdef WLAN_SOFTAP_FEATURE
828 //Taken care for only softAP case rest need to be done
829 if (psessionEntry->limSystemRole == eLIM_AP_ROLE){
830 psessionEntry->gLimProtectionControl = pSmeStartBssReq->protEnabled;
831 /*each byte will have the following info
832 *bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0
833 *reserved reserved RIFS Lsig n-GF ht20 11g 11b*/
834 palCopyMemory( pMac->hHdd, (void *) &psessionEntry->cfgProtection,
835 (void *) &pSmeStartBssReq->ht_capab,
836 sizeof( tCfgProtection ));
837 psessionEntry->pAPWPSPBCSession = NULL; // Initialize WPS PBC session link list
838 }
839#endif
840
841 // Prepare and Issue LIM_MLM_START_REQ to MLM
842 if( eHAL_STATUS_SUCCESS != palAllocateMemory( pMac->hHdd, (void **)&pMlmStartReq, sizeof(tLimMlmStartReq)))
843 {
844 limLog(pMac, LOGP, FL("call to palAllocateMemory failed for mlmStartReq\n"));
845 retCode = eSIR_SME_RESOURCES_UNAVAILABLE;
846 goto free;
847 }
848
849 (void)palZeroMemory(pMac->hHdd, (void *) pMlmStartReq, sizeof(tLimMlmStartReq));
850
851 /* Copy SSID to the MLM start structure */
852 palCopyMemory( pMac->hHdd, (tANI_U8 *) &pMlmStartReq->ssId,
853 (tANI_U8 *) &pSmeStartBssReq->ssId,
854 pSmeStartBssReq->ssId.length + 1);
855#ifdef WLAN_SOFTAP_FEATURE
856 pMlmStartReq->ssidHidden = pSmeStartBssReq->ssidHidden;
857 pMlmStartReq->obssProtEnabled = pSmeStartBssReq->obssProtEnabled;
858#endif
859
860
861 pMlmStartReq->bssType = psessionEntry->bssType;
862
863 /* Fill PE session Id from the session Table */
864 pMlmStartReq->sessionId = psessionEntry->peSessionId;
865
866 if( (pMlmStartReq->bssType == eSIR_BTAMP_STA_MODE) || (pMlmStartReq->bssType == eSIR_BTAMP_AP_MODE )
867#ifdef WLAN_SOFTAP_FEATURE
868 || (pMlmStartReq->bssType == eSIR_INFRA_AP_MODE)
869#endif
870 )
871 {
872 //len = sizeof(tSirMacAddr);
873 //retStatus = wlan_cfgGetStr(pMac, WNI_CFG_STA_ID, (tANI_U8 *) pMlmStartReq->bssId, &len);
874 //if (retStatus != eSIR_SUCCESS)
875 //limLog(pMac, LOGP, FL("could not retrive BSSID, retStatus=%d\n"), retStatus);
876
877 /* Copy the BSSId from sessionTable to mlmStartReq struct */
878 sirCopyMacAddr(pMlmStartReq->bssId,psessionEntry->bssId);
879 }
880
881 else // ibss mode
882 {
883 pMac->lim.gLimIbssCoalescingHappened = false;
884
885 if((retStatus = wlan_cfgGetInt(pMac, WNI_CFG_IBSS_AUTO_BSSID, &autoGenBssId)) != eSIR_SUCCESS)
886 {
887 limLog(pMac, LOGP, FL("Could not retrieve Auto Gen BSSID, retStatus=%d\n"), retStatus);
888 retCode = eSIR_LOGP_EXCEPTION;
889 goto free;
890 }
891
892 if(!autoGenBssId)
893 {
894 // We're not auto generating BSSID. Instead, get it from session entry
895 sirCopyMacAddr(pMlmStartReq->bssId,psessionEntry->bssId);
896
897 if(pMlmStartReq->bssId[0] & 0x01)
898 {
899 PELOGE(limLog(pMac, LOGE, FL("Request to start IBSS with group BSSID\n Autogenerating the BSSID\n"));)
900 autoGenBssId = TRUE;
901 }
902 }
903
904 if( autoGenBssId )
905 { //if BSSID is not any uc id. then use locally generated BSSID.
906 //Autogenerate the BSSID
907 limGetRandomBssid( pMac, pMlmStartReq->bssId);
908 pMlmStartReq->bssId[0]= 0x02;
909
910 /* Copy randomly generated BSSID to the session Table */
911 sirCopyMacAddr(psessionEntry->bssId,pMlmStartReq->bssId);
912 }
913 }
914 /* store the channel num in mlmstart req structure */
915 pMlmStartReq->channelNumber = psessionEntry->currentOperChannel;
916 pMlmStartReq->cbMode = pSmeStartBssReq->cbMode;
917 pMlmStartReq->beaconPeriod = psessionEntry->beaconParams.beaconInterval;
918
919#ifdef WLAN_SOFTAP_FEATURE
920 if(psessionEntry->limSystemRole == eLIM_AP_ROLE ){
921 pMlmStartReq->dtimPeriod = psessionEntry->dtimPeriod;
922 pMlmStartReq->wps_state = psessionEntry->wps_state;
923
924 }else
925#endif
926 {
927 if (wlan_cfgGetInt(pMac, WNI_CFG_DTIM_PERIOD, &val) != eSIR_SUCCESS)
928 limLog(pMac, LOGP, FL("could not retrieve DTIM Period\n"));
929 pMlmStartReq->dtimPeriod = (tANI_U8)val;
930 }
931
932 if (wlan_cfgGetInt(pMac, WNI_CFG_CFP_PERIOD, &val) != eSIR_SUCCESS)
933 limLog(pMac, LOGP, FL("could not retrieve Beacon interval\n"));
934 pMlmStartReq->cfParamSet.cfpPeriod = (tANI_U8)val;
935
936 if (wlan_cfgGetInt(pMac, WNI_CFG_CFP_MAX_DURATION, &val) != eSIR_SUCCESS)
937 limLog(pMac, LOGP, FL("could not retrieve CFPMaxDuration\n"));
938 pMlmStartReq->cfParamSet.cfpMaxDuration = (tANI_U16) val;
939
940 //this may not be needed anymore now, as rateSet is now included in the session entry and MLM has session context.
941 palCopyMemory(pMac->hHdd, (void*)&pMlmStartReq->rateSet, (void*)&psessionEntry->rateSet,
942 sizeof(tSirMacRateSet));
943
944
945 // Now populate the 11n related parameters
946 pMlmStartReq->nwType = psessionEntry->nwType;
Jeff Johnsone7245742012-09-05 17:12:55 -0700947 pMlmStartReq->htCapable = psessionEntry->htCapability;
Jeff Johnson295189b2012-06-20 16:38:30 -0700948 //
949 // FIXME_GEN4 - Determine the appropriate defaults...
950 //
951 pMlmStartReq->htOperMode = pMac->lim.gHTOperMode;
952 pMlmStartReq->dualCTSProtection = pMac->lim.gHTDualCTSProtection; // Unused
Jeff Johnsone7245742012-09-05 17:12:55 -0700953 pMlmStartReq->txChannelWidthSet = psessionEntry->htRecommendedTxWidthSet;
Jeff Johnson295189b2012-06-20 16:38:30 -0700954
955 /* sep26 review */
956 psessionEntry->limRFBand = limGetRFBand(channelNumber);
957
958 // Initialize 11h Enable Flag
959 psessionEntry->lim11hEnable = 0;
960 if((pMlmStartReq->bssType != eSIR_IBSS_MODE) &&
961 (SIR_BAND_5_GHZ == psessionEntry->limRFBand) )
962 {
963 if (wlan_cfgGetInt(pMac, WNI_CFG_11H_ENABLED, &val) != eSIR_SUCCESS)
964 limLog(pMac, LOGP, FL("Fail to get WNI_CFG_11H_ENABLED \n"));
965 psessionEntry->lim11hEnable = val;
966 }
967
968 if (!psessionEntry->lim11hEnable)
969 {
970 if (cfgSetInt(pMac, WNI_CFG_LOCAL_POWER_CONSTRAINT, 0) != eSIR_SUCCESS)
971 limLog(pMac, LOGP, FL("Fail to get WNI_CFG_11H_ENABLED \n"));
972 }
973
Jeff Johnson295189b2012-06-20 16:38:30 -0700974 psessionEntry ->limPrevSmeState = psessionEntry->limSmeState;
975 psessionEntry ->limSmeState = eLIM_SME_WT_START_BSS_STATE;
Jeff Johnsone7245742012-09-05 17:12:55 -0700976 MTRACE(macTrace(pMac, TRACE_CODE_SME_STATE, psessionEntry->peSessionId, psessionEntry ->limSmeState));
Jeff Johnson295189b2012-06-20 16:38:30 -0700977
978 limPostMlmMessage(pMac, LIM_MLM_START_REQ, (tANI_U32 *) pMlmStartReq);
979 return;
980 }
981 else
982 {
983
984 limLog(pMac, LOGE, FL("Received unexpected START_BSS_REQ, in state %X\n"),pMac->lim.gLimSmeState);
985 retCode = eSIR_SME_BSS_ALREADY_STARTED_OR_JOINED;
986 goto end;
987 } // if (pMac->lim.gLimSmeState == eLIM_SME_OFFLINE_STATE)
988
989free:
990 palFreeMemory( pMac->hHdd, pSmeStartBssReq);
991 pSmeStartBssReq = NULL;
992
993end:
994
995 /* This routine should return the sme sessionId and SME transaction Id */
996 limGetSessionInfo(pMac,(tANI_U8*)pMsgBuf,&smesessionId,&smetransactionId);
997
998 if(NULL != psessionEntry)
999 {
1000 peDeleteSession(pMac,psessionEntry);
1001 psessionEntry = NULL;
1002 }
1003 limSendSmeStartBssRsp(pMac, eWNI_SME_START_BSS_RSP, retCode,psessionEntry,smesessionId,smetransactionId);
1004} /*** end __limHandleSmeStartBssRequest() ***/
1005
1006
1007/**--------------------------------------------------------------
1008\fn __limProcessSmeStartBssReq
1009
1010\brief Wrapper for the function __limHandleSmeStartBssRequest
1011 This message will be defered until softmac come out of
1012 scan mode or if we have detected radar on the current
1013 operating channel.
1014\param pMac
1015\param pMsg
1016
1017\return TRUE - If we consumed the buffer
1018 FALSE - If have defered the message.
1019 ---------------------------------------------------------------*/
1020static tANI_BOOLEAN
1021__limProcessSmeStartBssReq(tpAniSirGlobal pMac, tpSirMsgQ pMsg)
1022{
1023 if (__limIsDeferedMsgForLearn(pMac, pMsg) ||
1024 __limIsDeferedMsgForRadar(pMac, pMsg))
1025 {
1026 /**
1027 * If message defered, buffer is not consumed yet.
1028 * So return false
1029 */
1030 return eANI_BOOLEAN_FALSE;
1031 }
1032
1033 __limHandleSmeStartBssRequest(pMac, (tANI_U32 *) pMsg->bodyptr);
1034 return eANI_BOOLEAN_TRUE;
1035}
1036
1037
1038/**
1039 * limGetRandomBssid()
1040 *
1041 * FUNCTION:This function is called to process generate the random number for bssid
1042 * This function is called to process SME_SCAN_REQ message
1043 * from HDD or upper layer application.
1044 *
1045 * LOGIC:
1046 *
1047 * ASSUMPTIONS:
1048 *
1049 * NOTE:
1050 * 1. geneartes the unique random number for bssid in ibss
1051 *
1052 * @param pMac Pointer to Global MAC structure
1053 * @param *data Pointer to bssid buffer
1054 * @return None
1055 */
1056void limGetRandomBssid(tpAniSirGlobal pMac, tANI_U8 *data)
1057{
1058 tANI_U32 random[2] ;
1059 random[0] = tx_time_get();
1060 random[0] |= (random[0] << 15) ;
1061 random[1] = random[0] >> 1;
1062 palCopyMemory(pMac->hHdd, data, (tANI_U8*)random, sizeof(tSirMacAddr));
1063}
1064
1065
1066/**
1067 * __limProcessSmeScanReq()
1068 *
1069 *FUNCTION:
1070 * This function is called to process SME_SCAN_REQ message
1071 * from HDD or upper layer application.
1072 *
1073 *LOGIC:
1074 *
1075 *ASSUMPTIONS:
1076 *
1077 *NOTE:
1078 * 1. Periodic scanning should be requesting to return unique
1079 * scan results.
1080 *
1081 * @param pMac Pointer to Global MAC structure
1082 * @param *pMsgBuf A pointer to the SME message buffer
1083 * @return None
1084 */
1085
1086static void
1087__limProcessSmeScanReq(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
1088{
1089 tANI_U32 len;
1090 tLimMlmScanReq *pMlmScanReq;
1091 tpSirSmeScanReq pScanReq;
1092 tANI_U8 i = 0;
1093
1094#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM //FEATURE_WLAN_DIAG_SUPPORT
1095 limDiagEventReport(pMac, WLAN_PE_DIAG_SCAN_REQ_EVENT, NULL, 0, 0);
1096#endif //FEATURE_WLAN_DIAG_SUPPORT
1097
1098 pScanReq = (tpSirSmeScanReq) pMsgBuf;
1099 PELOG1(limLog(pMac, LOG1, FL("SME SCAN REQ numChan %d min %d max %d IELen %d first %d fresh %d unique %d type %d rsp %d\n"),
1100 pScanReq->channelList.numChannels,
1101 pScanReq->minChannelTime,
1102 pScanReq->maxChannelTime,
1103 pScanReq->uIEFieldLen,
1104 pScanReq->returnAfterFirstMatch,
1105 pScanReq->returnFreshResults,
1106 pScanReq->returnUniqueResults,
1107 pScanReq->scanType, pMac->lim.gLimRspReqd ? 1 : 0);)
1108
1109 /*copy the Self MAC address from SmeReq to the globalplace , used for sending probe req.discussed on code review sep18*/
1110 sirCopyMacAddr(pMac->lim.gSelfMacAddr, pScanReq->selfMacAddr);
1111
1112 /* This routine should return the sme sessionId and SME transaction Id */
1113
1114 if (!limIsSmeScanReqValid(pMac, pScanReq))
1115 {
1116 PELOGW(limLog(pMac, LOGW, FL("Received SME_SCAN_REQ with invalid parameters\n"));)
1117
1118 if (pMac->lim.gLimRspReqd)
1119 {
1120 pMac->lim.gLimRspReqd = false;
1121
1122 limSendSmeScanRsp(pMac, sizeof(tSirSmeScanRsp), eSIR_SME_INVALID_PARAMETERS, pScanReq->sessionId, pScanReq->transactionId);
1123
1124 } // if (pMac->lim.gLimRspReqd)
1125
1126 return;
1127 }
1128
1129 //if scan is disabled then return as invalid scan request.
1130 //if scan in power save is disabled, and system is in power save mode, then ignore scan request.
1131 if( (pMac->lim.fScanDisabled) || (!pMac->lim.gScanInPowersave && !limIsSystemInActiveState(pMac)) )
1132 {
1133 limSendSmeScanRsp(pMac, 8, eSIR_SME_INVALID_PARAMETERS, pScanReq->sessionId, pScanReq->transactionId);
1134 return;
1135 }
1136
1137
1138 /**
1139 * If scan request is received in idle, joinFailed
1140 * states or in link established state (in STA role)
1141 * or in normal state (in STA-in-IBSS/AP role) with
1142 * 'return fresh scan results' request from HDD or
1143 * it is periodic background scanning request,
1144 * trigger fresh scan request to MLM
1145 */
1146 if (__limFreshScanReqd(pMac, pScanReq->returnFreshResults))
1147 {
1148 #if 0
1149 // Update global SME state
1150 pMac->lim.gLimPrevSmeState = pMac->lim.gLimSmeState;
1151 if ((pMac->lim.gLimSmeState == eLIM_SME_IDLE_STATE) ||
1152 (pMac->lim.gLimSmeState == eLIM_SME_JOIN_FAILURE_STATE))
1153 pMac->lim.gLimSmeState = eLIM_SME_WT_SCAN_STATE;
1154 else if (pMac->lim.gLimSmeState == eLIM_SME_NORMAL_STATE)
1155 pMac->lim.gLimSmeState = eLIM_SME_NORMAL_CHANNEL_SCAN_STATE;
1156 else
1157
1158 #endif //TO SUPPORT BT-AMP
1159
1160 /*Change Global SME state */
1161
1162 /* Store the previous SME state */
1163
1164 pMac->lim.gLimPrevSmeState = pMac->lim.gLimSmeState;
1165
1166 pMac->lim.gLimSmeState = eLIM_SME_WT_SCAN_STATE;
Jeff Johnsone7245742012-09-05 17:12:55 -07001167 MTRACE(macTrace(pMac, TRACE_CODE_SME_STATE, NO_SESSION, pMac->lim.gLimSmeState));
Jeff Johnson295189b2012-06-20 16:38:30 -07001168
1169 if (pScanReq->returnFreshResults & SIR_BG_SCAN_PURGE_RESUTLS)
1170 {
1171 // Discard previously cached scan results
1172 limReInitScanResults(pMac);
1173 }
1174
1175 pMac->lim.gLim24Band11dScanDone = 0;
1176 pMac->lim.gLim50Band11dScanDone = 0;
1177 pMac->lim.gLimReturnAfterFirstMatch =
1178 pScanReq->returnAfterFirstMatch;
1179
1180 pMac->lim.gLimReturnUniqueResults =
1181 ((pScanReq->returnUniqueResults) > 0 ? true : false);
1182 /* De-activate Heartbeat timers for connected sessions while
1183 * scan is in progress if the system is in Active mode */
1184 if((ePMM_STATE_BMPS_WAKEUP == pMac->pmm.gPmmState) ||
1185 (ePMM_STATE_READY == pMac->pmm.gPmmState))
1186 {
1187 for(i=0;i<pMac->lim.maxBssId;i++)
1188 {
Jeff Johnson32d95a32012-09-10 13:15:23 -07001189 if((peFindSessionBySessionId(pMac,i) != NULL) &&
1190 (pMac->lim.gpSession[i].valid == TRUE) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07001191 (eLIM_MLM_LINK_ESTABLISHED_STATE == pMac->lim.gpSession[i].limMlmState))
1192 {
1193 limHeartBeatDeactivateAndChangeTimer(pMac, peFindSessionBySessionId(pMac,i));
1194 }
1195 }
1196 }
1197
1198 if (pScanReq->channelList.numChannels == 0)
1199 {
1200 tANI_U32 cfg_len;
1201 // Scan all channels
1202 len = sizeof(tLimMlmScanReq) +
1203 (sizeof( pScanReq->channelList.channelNumber ) * (WNI_CFG_VALID_CHANNEL_LIST_LEN - 1)) +
1204 pScanReq->uIEFieldLen;
1205 if( eHAL_STATUS_SUCCESS != palAllocateMemory( pMac->hHdd, (void **)&pMlmScanReq, len) )
1206 {
1207 // Log error
1208 limLog(pMac, LOGP,
1209 FL("call to palAllocateMemory failed for mlmScanReq (%d)\n"), len);
1210
1211 return;
1212 }
1213
1214 // Initialize this buffer
1215 palZeroMemory( pMac->hHdd, (tANI_U8 *) pMlmScanReq, len );
1216
1217 cfg_len = WNI_CFG_VALID_CHANNEL_LIST_LEN;
1218 if (wlan_cfgGetStr(pMac, WNI_CFG_VALID_CHANNEL_LIST,
1219 pMlmScanReq->channelList.channelNumber,
1220 &cfg_len) != eSIR_SUCCESS)
1221 {
1222 /**
1223 * Could not get Valid channel list from CFG.
1224 * Log error.
1225 */
1226 limLog(pMac, LOGP,
1227 FL("could not retrieve Valid channel list\n"));
1228 }
1229 pMlmScanReq->channelList.numChannels = (tANI_U8) cfg_len;
1230 }
1231 else
1232 {
1233 len = sizeof( tLimMlmScanReq ) - sizeof( pScanReq->channelList.channelNumber ) +
1234 (sizeof( pScanReq->channelList.channelNumber ) * pScanReq->channelList.numChannels ) +
1235 pScanReq->uIEFieldLen;
1236
1237 if( eHAL_STATUS_SUCCESS != palAllocateMemory( pMac->hHdd, (void **)&pMlmScanReq, len) )
1238 {
1239 // Log error
1240 limLog(pMac, LOGP,
1241 FL("call to palAllocateMemory failed for mlmScanReq(%d)\n"), len);
1242
1243 return;
1244 }
1245
1246 // Initialize this buffer
1247 palZeroMemory( pMac->hHdd, (tANI_U8 *) pMlmScanReq, len);
1248 pMlmScanReq->channelList.numChannels =
1249 pScanReq->channelList.numChannels;
1250
1251 palCopyMemory( pMac->hHdd, pMlmScanReq->channelList.channelNumber,
1252 pScanReq->channelList.channelNumber,
1253 pScanReq->channelList.numChannels);
1254 }
1255
1256 pMlmScanReq->uIEFieldLen = pScanReq->uIEFieldLen;
1257 pMlmScanReq->uIEFieldOffset = len - pScanReq->uIEFieldLen;
1258
1259 if(pScanReq->uIEFieldLen)
1260 {
1261 palCopyMemory( pMac->hHdd, (tANI_U8 *)pMlmScanReq+ pMlmScanReq->uIEFieldOffset,
1262 (tANI_U8 *)pScanReq+(pScanReq->uIEFieldOffset),
1263 pScanReq->uIEFieldLen);
1264 }
1265
1266 pMlmScanReq->bssType = pScanReq->bssType;
1267 palCopyMemory( pMac->hHdd, pMlmScanReq->bssId,
1268 pScanReq->bssId,
1269 sizeof(tSirMacAddr));
1270 pMlmScanReq->numSsid = pScanReq->numSsid;
1271
1272 i = 0;
1273 while (i < pMlmScanReq->numSsid)
1274 {
1275 palCopyMemory( pMac->hHdd, (tANI_U8 *) &pMlmScanReq->ssId[i],
1276 (tANI_U8 *) &pScanReq->ssId[i],
1277 pScanReq->ssId[i].length + 1);
1278
1279 i++;
1280 }
1281
1282
1283 pMlmScanReq->scanType = pScanReq->scanType;
1284 pMlmScanReq->backgroundScanMode = pScanReq->backgroundScanMode;
1285 pMlmScanReq->minChannelTime = pScanReq->minChannelTime;
1286 pMlmScanReq->maxChannelTime = pScanReq->maxChannelTime;
1287 pMlmScanReq->dot11mode = pScanReq->dot11mode;
1288#ifdef WLAN_FEATURE_P2P
1289 pMlmScanReq->p2pSearch = pScanReq->p2pSearch;
Jeff Johnsone7245742012-09-05 17:12:55 -07001290 pMlmScanReq->skipDfsChnlInP2pSearch = pScanReq->skipDfsChnlInP2pSearch;
Jeff Johnson295189b2012-06-20 16:38:30 -07001291#endif
1292
1293 //Store the smeSessionID and transaction ID for later use.
1294 pMac->lim.gSmeSessionId = pScanReq->sessionId;
1295 pMac->lim.gTransactionId = pScanReq->transactionId;
1296
1297 // Issue LIM_MLM_SCAN_REQ to MLM
1298 limPostMlmMessage(pMac, LIM_MLM_SCAN_REQ, (tANI_U32 *) pMlmScanReq);
1299
1300 } // if ((pMac->lim.gLimSmeState == eLIM_SME_IDLE_STATE) || ...
1301
1302 else
1303 {
1304 /// In all other cases return 'cached' scan results
1305 if ((pMac->lim.gLimRspReqd) || pMac->lim.gLimReportBackgroundScanResults)
1306 {
1307 tANI_U16 scanRspLen = sizeof(tSirSmeScanRsp);
1308
1309 pMac->lim.gLimRspReqd = false;
1310
1311 if (pMac->lim.gLimSmeScanResultLength == 0)
1312 {
1313 limSendSmeScanRsp(pMac, scanRspLen, eSIR_SME_SUCCESS, pScanReq->sessionId, pScanReq->transactionId);
1314 }
1315 else
1316 {
1317 scanRspLen = sizeof(tSirSmeScanRsp) +
1318 pMac->lim.gLimSmeScanResultLength -
1319 sizeof(tSirBssDescription);
1320 limSendSmeScanRsp(pMac, scanRspLen, eSIR_SME_SUCCESS, pScanReq->sessionId, pScanReq->transactionId);
1321 }
1322
1323 if (pScanReq->returnFreshResults & SIR_BG_SCAN_PURGE_RESUTLS)
1324 {
1325 // Discard previously cached scan results
1326 limReInitScanResults(pMac);
1327 }
1328
1329 } // if (pMac->lim.gLimRspReqd)
1330 } // else ((pMac->lim.gLimSmeState == eLIM_SME_IDLE_STATE) || ...
1331
1332#if defined(ANI_PRODUCT_TYPE_CLIENT) || defined(ANI_AP_CLIENT_SDK)
1333#ifdef BACKGROUND_SCAN_ENABLED
1334 // start background scans if needed
1335 // There is a bug opened against softmac. Need to enable when the bug is fixed.
1336 __limBackgroundScanInitiate(pMac);
1337#endif
1338#endif
1339
1340} /*** end __limProcessSmeScanReq() ***/
1341
Jeff Johnsone7245742012-09-05 17:12:55 -07001342#ifdef FEATURE_OEM_DATA_SUPPORT
Jeff Johnson295189b2012-06-20 16:38:30 -07001343
Jeff Johnsone7245742012-09-05 17:12:55 -07001344static void __limProcessSmeOemDataReq(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
1345{
1346 tpSirOemDataReq pOemDataReq;
1347 tLimMlmOemDataReq* pMlmOemDataReq;
1348
1349 pOemDataReq = (tpSirOemDataReq) pMsgBuf;
1350
1351 //post the lim mlm message now
1352 if(eHAL_STATUS_SUCCESS != palAllocateMemory(pMac->hHdd, (void**)&pMlmOemDataReq, (sizeof(tLimMlmOemDataReq))))
1353 {
1354 limLog(pMac, LOGP, FL("palAllocateMemory failed for mlmOemDataReq\n"));
1355 return;
1356 }
1357
1358 //Initialize this buffer
1359 palZeroMemory(pMac->hHdd, pMlmOemDataReq, (sizeof(tLimMlmOemDataReq)));
1360
1361 palCopyMemory(pMac->hHdd, pMlmOemDataReq->selfMacAddr, pOemDataReq->selfMacAddr, sizeof(tSirMacAddr));
1362 palCopyMemory(pMac->hHdd, pMlmOemDataReq->oemDataReq, pOemDataReq->oemDataReq, OEM_DATA_REQ_SIZE);
1363
1364 //Issue LIM_MLM_OEM_DATA_REQ to MLM
1365 limPostMlmMessage(pMac, LIM_MLM_OEM_DATA_REQ, (tANI_U32*)pMlmOemDataReq);
1366
1367 return;
1368
1369} /*** end __limProcessSmeOemDataReq() ***/
1370
1371#endif //FEATURE_OEM_DATA_SUPPORT
Jeff Johnson295189b2012-06-20 16:38:30 -07001372
1373
1374/**
1375 * __limProcessSmeJoinReq()
1376 *
1377 *FUNCTION:
1378 * This function is called to process SME_JOIN_REQ message
1379 * from HDD or upper layer application.
1380 *
1381 *LOGIC:
1382 *
1383 *ASSUMPTIONS:
1384 *
1385 *NOTE:
1386 *
1387 * @param pMac Pointer to Global MAC structure
1388 * @param *pMsgBuf A pointer to the SME message buffer
1389 * @return None
1390 */
Jeff Johnson295189b2012-06-20 16:38:30 -07001391static void
1392__limProcessSmeJoinReq(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
1393{
1394 // tANI_U8 *pBuf;
1395 //tANI_U32 len;
1396// tSirMacAddr currentBssId;
1397 tpSirSmeJoinReq pSmeJoinReq = NULL;
1398 tLimMlmJoinReq *pMlmJoinReq;
1399 tSirResultCodes retCode = eSIR_SME_SUCCESS;
1400 tANI_U32 val = 0;
1401 tANI_U16 nSize;
1402 tANI_U8 sessionId;
1403 tpPESession psessionEntry = NULL;
1404 tANI_U8 smesessionId;
1405 tANI_U16 smetransactionId;
1406 tPowerdBm localPowerConstraint = 0, regMax = 0;
1407
1408#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM //FEATURE_WLAN_DIAG_SUPPORT
1409 //Not sending any session, since it is not created yet. The response whould have correct state.
1410 limDiagEventReport(pMac, WLAN_PE_DIAG_JOIN_REQ_EVENT, NULL, 0, 0);
1411#endif //FEATURE_WLAN_DIAG_SUPPORT
1412
1413 PELOG1(limLog(pMac, LOG1, FL("Received SME_JOIN_REQ\n"));)
1414
1415#ifdef WLAN_FEATURE_VOWIFI
1416 /* Need to read the CFG here itself as this is used in limExtractAPCapability() below.
1417 * This CFG is actually read in rrmUpdateConfig() which is called later. Because this is not
1418 * read, RRM related path before calling rrmUpdateConfig() is not getting executed causing issues
1419 * like not honoring power constraint on 1st association after driver loading. */
1420 if (wlan_cfgGetInt(pMac, WNI_CFG_RRM_ENABLED, &val) != eSIR_SUCCESS)
1421 limLog(pMac, LOGP, FL("cfg get rrm enabled failed\n"));
1422 pMac->rrm.rrmPEContext.rrmEnable = (val) ? 1 : 0;
1423 val = 0;
1424#endif /* WLAN_FEATURE_VOWIFI */
1425
1426 /**
1427 * Expect Join request in idle state.
1428 * Reassociate request is expected in link established state.
1429 */
1430
1431 /* Global SME and LIM states are not defined yet for BT-AMP Support */
1432 if(pMac->lim.gLimSmeState == eLIM_SME_IDLE_STATE)
1433 {
1434 nSize = __limGetSmeJoinReqSizeForAlloc((tANI_U8*) pMsgBuf);
1435 if( eHAL_STATUS_SUCCESS != palAllocateMemory( pMac->hHdd, (void **)&pSmeJoinReq, nSize))
1436 {
1437 limLog(pMac, LOGP, FL("call to palAllocateMemory failed for pSmeJoinReq\n"));
1438 retCode = eSIR_SME_RESOURCES_UNAVAILABLE;
1439 goto end;
1440 }
1441 (void) palZeroMemory(pMac->hHdd, (void *) pSmeJoinReq, nSize);
1442
Jeff Johnson295189b2012-06-20 16:38:30 -07001443 if ((limJoinReqSerDes(pMac, pSmeJoinReq, (tANI_U8 *)pMsgBuf) == eSIR_FAILURE) ||
1444 (!limIsSmeJoinReqValid(pMac, pSmeJoinReq)))
1445 {
1446 /// Received invalid eWNI_SME_JOIN_REQ
1447 // Log the event
1448 limLog(pMac, LOGW, FL("received SME_JOIN_REQ with invalid data\n"));
1449 retCode = eSIR_SME_INVALID_PARAMETERS;
1450 goto end;
1451 }
1452
1453 //pMac->lim.gpLimJoinReq = pSmeJoinReq; TO SUPPORT BT-AMP ,review os sep 23
1454
1455 /* check for the existence of start BSS session */
1456#ifdef FIXME_GEN6
1457 if(pSmeJoinReq->bsstype == eSIR_BTAMP_AP_MODE)
1458 {
1459 if(peValidateBtJoinRequest(pMac)!= TRUE)
1460 {
1461 limLog(pMac, LOGW, FL("Start Bss session not present::SME_JOIN_REQ in unexpected state\n"));
1462 retCode = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
1463 psessionEntry = NULL;
1464 goto end;
1465 }
1466 }
1467
1468#endif
1469
1470
1471 if((psessionEntry = peFindSessionByBssid(pMac,pSmeJoinReq->bssDescription.bssId,&sessionId)) != NULL)
1472 {
1473 limLog(pMac, LOGE, FL("Session Already exists for given BSSID\n"));
1474
1475 if(psessionEntry->limSmeState == eLIM_SME_LINK_EST_STATE)
1476 {
1477 // Received eWNI_SME_JOIN_REQ for same
1478 // BSS as currently associated.
1479 // Log the event and send success
1480 PELOGW(limLog(pMac, LOGW, FL("Received SME_JOIN_REQ for currently joined BSS\n"));)
1481 /// Send Join success response to host
1482 retCode = eSIR_SME_SUCCESS;
1483 goto end;
1484 }
1485 else
1486 {
1487 retCode = eSIR_SME_REFUSED;
1488 psessionEntry = NULL;
1489 goto end;
1490 }
1491 }
1492 else /* Session Entry does not exist for given BSSId */
1493 {
1494 /* Try to Create a new session */
1495 if((psessionEntry = peCreateSession(pMac,pSmeJoinReq->bssDescription.bssId,&sessionId, pMac->lim.maxStation)) == NULL)
1496 {
1497 limLog(pMac, LOGE, FL("Session Can not be created \n"));
1498 retCode = eSIR_SME_RESOURCES_UNAVAILABLE;
1499 goto end;
1500 }
1501 }
Jeff Johnsone7245742012-09-05 17:12:55 -07001502 handleHTCapabilityandHTInfo(pMac, psessionEntry);
1503
Jeff Johnson295189b2012-06-20 16:38:30 -07001504 /* Store Session related parameters */
1505 /* Store PE session Id in session Table */
1506 psessionEntry->peSessionId = sessionId;
1507
1508 /* store the smejoin req handle in session table */
1509 psessionEntry->pLimJoinReq = pSmeJoinReq;
1510
1511 /* Store SME session Id in sessionTable */
1512 psessionEntry->smeSessionId = pSmeJoinReq->sessionId;
1513
1514 /* Store SME transaction Id in session Table */
1515 psessionEntry->transactionId = pSmeJoinReq->transactionId;
1516
1517 /* Store beaconInterval */
1518 psessionEntry->beaconParams.beaconInterval = pSmeJoinReq->bssDescription.beaconInterval;
1519
1520 /* Copying of bssId is already done, while creating session */
1521 //sirCopyMacAddr(psessionEntry->bssId,pSmeJoinReq->bssId);
1522 sirCopyMacAddr(psessionEntry->selfMacAddr,pSmeJoinReq->selfMacAddr);
1523 psessionEntry->bssType = pSmeJoinReq->bsstype;
1524
1525 psessionEntry->statypeForBss = STA_ENTRY_PEER;
1526
1527 /* Copy the dot 11 mode in to the session table */
1528
1529 psessionEntry->dot11mode = pSmeJoinReq->dot11mode;
1530 psessionEntry->nwType = pSmeJoinReq->bssDescription.nwType;
Jeff Johnsone7245742012-09-05 17:12:55 -07001531#ifdef WLAN_FEATURE_11AC
1532 psessionEntry->vhtCapability = IS_DOT11_MODE_VHT(psessionEntry->dot11mode);
Jeff Johnson32d95a32012-09-10 13:15:23 -07001533 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO_MED,
Jeff Johnsone7245742012-09-05 17:12:55 -07001534 "***__limProcessSmeJoinReq: vhtCapability=%d****\n",psessionEntry->vhtCapability);
1535#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001536
1537 /*Phy mode*/
1538 psessionEntry->gLimPhyMode = pSmeJoinReq->bssDescription.nwType;
1539
1540 /* Copy The channel Id to the session Table */
1541 psessionEntry->currentOperChannel = pSmeJoinReq->bssDescription.channelId;
Jeff Johnsone7245742012-09-05 17:12:55 -07001542 psessionEntry->htSupportedChannelWidthSet = (pSmeJoinReq->cbMode)?1:0; // This is already merged value of peer and self - done by csr in csrGetCBModeFromIes
1543 psessionEntry->htRecommendedTxWidthSet = psessionEntry->htSupportedChannelWidthSet;
1544 psessionEntry->htSecondaryChannelOffset = pSmeJoinReq->cbMode;
Jeff Johnson295189b2012-06-20 16:38:30 -07001545
1546 /*Store Persona */
1547 psessionEntry->pePersona = pSmeJoinReq->staPersona;
1548 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
Jeff Johnsone7245742012-09-05 17:12:55 -07001549 FL("PE PERSONA=%d cbMode %u"), psessionEntry->pePersona, pSmeJoinReq->cbMode);
Jeff Johnson295189b2012-06-20 16:38:30 -07001550
1551 /* Copy the SSID from smejoinreq to session entry */
1552 psessionEntry->ssId.length = pSmeJoinReq->ssId.length;
1553 palCopyMemory( pMac->hHdd,psessionEntry->ssId.ssId,pSmeJoinReq->ssId.ssId,psessionEntry->ssId.length);
1554
1555 /* Copy the SSID from smejoinreq to session entry */
1556 psessionEntry->ssId.length = pSmeJoinReq->ssId.length;
1557 palCopyMemory( pMac->hHdd,psessionEntry->ssId.ssId,pSmeJoinReq->ssId.ssId,psessionEntry->ssId.length);
1558
1559 // Determin 11r or CCX connection based on input from SME
1560 // which inturn is dependent on the profile the user wants to connect
1561 // to, So input is coming from supplicant
1562#ifdef WLAN_FEATURE_VOWIFI_11R
1563 psessionEntry->is11Rconnection = pSmeJoinReq->is11Rconnection;
1564#endif
1565#ifdef FEATURE_WLAN_CCX
1566 psessionEntry->isCCXconnection = pSmeJoinReq->isCCXconnection;
1567#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001568#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_CCX || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07001569 psessionEntry->isFastTransitionEnabled = pSmeJoinReq->isFastTransitionEnabled;
1570#endif
1571
Jeff Johnson43971f52012-07-17 12:26:56 -07001572#ifdef FEATURE_WLAN_LFR
1573 psessionEntry->isFastRoamIniFeatureEnabled = pSmeJoinReq->isFastRoamIniFeatureEnabled;
1574#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001575 if(psessionEntry->bssType == eSIR_INFRASTRUCTURE_MODE)
1576 {
1577 psessionEntry->limSystemRole = eLIM_STA_ROLE;
1578 }
1579 else if(psessionEntry->bssType == eSIR_BTAMP_AP_MODE)
1580 {
1581 psessionEntry->limSystemRole = eLIM_BT_AMP_STA_ROLE;
1582 }
1583 else
1584 {
1585 /* Throw an error and return and make sure to delete the session.*/
1586 limLog(pMac, LOGW, FL("received SME_JOIN_REQ with invalid bss type\n"));
1587 retCode = eSIR_SME_INVALID_PARAMETERS;
1588 goto end;
1589 }
1590
1591 if(pSmeJoinReq->addIEScan.length)
1592 {
1593 palCopyMemory(pMac->hHdd, &psessionEntry->pLimJoinReq->addIEScan,
1594 &pSmeJoinReq->addIEScan, sizeof(tSirAddie));
1595 }
1596
1597 if(pSmeJoinReq->addIEAssoc.length)
1598 {
1599 palCopyMemory(pMac->hHdd, &psessionEntry->pLimJoinReq->addIEAssoc,
1600 &pSmeJoinReq->addIEAssoc, sizeof(tSirAddie));
1601 }
1602
1603#if (WNI_POLARIS_FW_PACKAGE == ADVANCED) && defined(ANI_PRODUCT_TYPE_AP)
1604
1605 val = sizeof(tLimMlmJoinReq) + sizeof(tSirMacSSidIE) +
1606 sizeof(tSirMacRateSetIE) + sizeof(tSirMacDsParamSetIE);
1607#else
1608 val = sizeof(tLimMlmJoinReq) + psessionEntry->pLimJoinReq->bssDescription.length + 2;
1609#endif
1610 if( eHAL_STATUS_SUCCESS != palAllocateMemory( pMac->hHdd, (void **)&pMlmJoinReq, val))
1611 {
1612 limLog(pMac, LOGP, FL("call to palAllocateMemory failed for mlmJoinReq\n"));
1613 return;
1614 }
1615 (void) palZeroMemory(pMac->hHdd, (void *) pMlmJoinReq, val);
1616
1617 /* PE SessionId is stored as a part of JoinReq*/
1618 pMlmJoinReq->sessionId = psessionEntry->peSessionId;
1619
1620 if (wlan_cfgGetInt(pMac, WNI_CFG_JOIN_FAILURE_TIMEOUT, (tANI_U32 *) &pMlmJoinReq->joinFailureTimeout)
1621 != eSIR_SUCCESS)
1622 limLog(pMac, LOGP, FL("could not retrieve JoinFailureTimer value\n"));
1623
1624 /* copy operational rate from psessionEntry*/
1625 palCopyMemory(pMac->hHdd, (void*)&psessionEntry->rateSet, (void*)&pSmeJoinReq->operationalRateSet,
1626 sizeof(tSirMacRateSet));
1627 palCopyMemory(pMac->hHdd, (void*)&psessionEntry->extRateSet, (void*)&pSmeJoinReq->extendedRateSet,
1628 sizeof(tSirMacRateSet));
1629 //this may not be needed anymore now, as rateSet is now included in the session entry and MLM has session context.
1630 palCopyMemory(pMac->hHdd, (void*)&pMlmJoinReq->operationalRateSet, (void*)&psessionEntry->rateSet,
1631 sizeof(tSirMacRateSet));
1632
1633 psessionEntry->encryptType = pSmeJoinReq->UCEncryptionType;
1634
1635#if (WNI_POLARIS_FW_PACKAGE == ADVANCED) && defined(ANI_PRODUCT_TYPE_AP)
1636 palCopyMemory( pMac->hHdd, pMlmJoinReq->bssDescription.bssId,
1637 pMac->lim.gpLimJoinReq->neighborBssList.bssList[0].bssId,
1638 sizeof(tSirMacAddr));
1639
1640 pMlmJoinReq->bssDescription.capabilityInfo = 1;
1641
1642 pMlmJoinReq->bssDescription.aniIndicator =
1643 (tANI_U8) pMac->lim.gpLimJoinReq->neighborBssList.bssList[0].wniIndicator;
1644
1645 pMlmJoinReq->bssDescription.nwType =
1646 pMac->lim.gpLimJoinReq->neighborBssList.bssList[0].nwType;
1647
1648 pMlmJoinReq->bssDescription.channelId =
1649 pMac->lim.gpLimJoinReq->neighborBssList.bssList[0].channelId;
1650
1651 limCopyNeighborInfoToCfg(pMac,
1652 pMac->lim.gpLimJoinReq->neighborBssList.bssList[0], psessionEntry);
1653
1654 palCopyMemory( pMac->hHdd, pMac->lim.gLimCurrentBssId,
1655 pMac->lim.gpLimJoinReq->neighborBssList.bssList[0].bssId,
1656 sizeof(tSirMacAddr));
1657
1658 pMac->lim.gLimCurrentChannelId =
1659 pMac->lim.gpLimJoinReq->neighborBssList.bssList[0].channelId;
1660
1661 pMac->lim.gLimCurrentBssCaps =
1662 pMac->lim.gpLimJoinReq->neighborBssList.bssList[0].capabilityInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07001663 palCopyMemory( pMac->hHdd,
1664 (tANI_U8 *) &pMac->lim.gLimCurrentSSID,
1665 (tANI_U8 *) &pMac->lim.gpLimJoinReq->neighborBssList.bssList[0].ssId,
1666 pMac->lim.gpLimJoinReq->neighborBssList.bssList[0].ssId.length+1);
1667#else
1668 pMlmJoinReq->bssDescription.length = psessionEntry->pLimJoinReq->bssDescription.length;
1669
1670 palCopyMemory( pMac->hHdd,
1671 (tANI_U8 *) &pMlmJoinReq->bssDescription.bssId,
1672 (tANI_U8 *) &psessionEntry->pLimJoinReq->bssDescription.bssId,
1673 psessionEntry->pLimJoinReq->bssDescription.length + 2);
1674
Jeff Johnson295189b2012-06-20 16:38:30 -07001675 psessionEntry->limCurrentBssCaps =
Jeff Johnsone7245742012-09-05 17:12:55 -07001676 psessionEntry->pLimJoinReq->bssDescription.capabilityInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07001677
Jeff Johnsone7245742012-09-05 17:12:55 -07001678 regMax = cfgGetRegulatoryMaxTransmitPower( pMac, psessionEntry->currentOperChannel );
1679 localPowerConstraint = regMax;
1680 limExtractApCapability( pMac,
1681 (tANI_U8 *) psessionEntry->pLimJoinReq->bssDescription.ieFields,
1682 limGetIElenFromBssDescription(&psessionEntry->pLimJoinReq->bssDescription),
1683 &psessionEntry->limCurrentBssQosCaps,
1684 &psessionEntry->limCurrentBssPropCap,
1685 &pMac->lim.gLimCurrentBssUapsd //TBD-RAJESH make gLimCurrentBssUapsd this session specific
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07001686 , &localPowerConstraint,
1687 psessionEntry
Jeff Johnsone7245742012-09-05 17:12:55 -07001688 );
Jeff Johnson295189b2012-06-20 16:38:30 -07001689#ifdef FEATURE_WLAN_CCX
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001690 psessionEntry->maxTxPower = limGetMaxTxPower(regMax, localPowerConstraint, pMac->roam.configParam.nTxPowerCap);
Jeff Johnson295189b2012-06-20 16:38:30 -07001691#else
1692 psessionEntry->maxTxPower = VOS_MIN( regMax , (localPowerConstraint) );
1693#endif
1694#if defined WLAN_VOWIFI_DEBUG
1695 limLog( pMac, LOGE, "Regulatory max = %d, local power constraint = %d, max tx = %d", regMax, localPowerConstraint, psessionEntry->maxTxPower );
1696#endif
1697
1698 if (pMac->lim.gLimCurrentBssUapsd)
1699 {
1700 pMac->lim.gUapsdPerAcBitmask = psessionEntry->pLimJoinReq->uapsdPerAcBitmask;
1701 limLog( pMac, LOG1, FL("UAPSD flag for all AC - 0x%2x\n"), pMac->lim.gUapsdPerAcBitmask);
1702
1703 // resetting the dynamic uapsd mask
1704 pMac->lim.gUapsdPerAcDeliveryEnableMask = 0;
1705 pMac->lim.gUapsdPerAcTriggerEnableMask = 0;
1706 }
1707#endif
1708
1709 psessionEntry->limRFBand = limGetRFBand(psessionEntry->currentOperChannel);
1710
1711 // Initialize 11h Enable Flag
1712 if(SIR_BAND_5_GHZ == psessionEntry->limRFBand)
1713 {
1714 if (wlan_cfgGetInt(pMac, WNI_CFG_11H_ENABLED, &val) != eSIR_SUCCESS)
1715 limLog(pMac, LOGP, FL("Fail to get WNI_CFG_11H_ENABLED \n"));
1716 psessionEntry->lim11hEnable = val;
1717 }
1718 else
1719 psessionEntry->lim11hEnable = 0;
1720
1721 //To care of the scenario when STA transitions from IBSS to Infrastructure mode.
1722 pMac->lim.gLimIbssCoalescingHappened = false;
1723
Jeff Johnsone7245742012-09-05 17:12:55 -07001724 psessionEntry->limPrevSmeState = psessionEntry->limSmeState;
1725 psessionEntry->limSmeState = eLIM_SME_WT_JOIN_STATE;
1726 MTRACE(macTrace(pMac, TRACE_CODE_SME_STATE, psessionEntry->peSessionId, psessionEntry->limSmeState));
Jeff Johnson295189b2012-06-20 16:38:30 -07001727
1728 PELOG1(limLog(pMac, LOG1, FL("SME JoinReq: SSID %d.%c%c%c%c%c%c\n"),
1729 psessionEntry->ssId.length,
1730 psessionEntry->ssId.ssId[0],
1731 psessionEntry->ssId.ssId[1],
1732 psessionEntry->ssId.ssId[2],
1733 psessionEntry->ssId.ssId[3],
1734 psessionEntry->ssId.ssId[4],
1735 psessionEntry->ssId.ssId[5]);
1736 limLog(pMac, LOG1, FL("Channel %d, BSSID %x:%x:%x:%x:%x:%x\n"),
1737 psessionEntry->currentOperChannel,
1738 psessionEntry->bssId[0],
1739 psessionEntry->bssId[1],
1740 psessionEntry->bssId[2],
1741 psessionEntry->bssId[3],
1742 psessionEntry->bssId[4],
1743 psessionEntry->bssId[5]);)
1744
1745 /* Indicate whether spectrum management is enabled*/
1746 psessionEntry->spectrumMgtEnabled =
1747 pSmeJoinReq->spectrumMgtIndicator;
1748 /* Issue LIM_MLM_JOIN_REQ to MLM */
1749 limPostMlmMessage(pMac, LIM_MLM_JOIN_REQ, (tANI_U32 *) pMlmJoinReq);
1750 return;
1751
1752 }
1753 else
1754 {
1755 /* Received eWNI_SME_JOIN_REQ un expected state */
1756 limLog(pMac, LOGE, FL("received unexpected SME_JOIN_REQ in state %X\n"), pMac->lim.gLimSmeState);
1757 limPrintSmeState(pMac, LOGE, pMac->lim.gLimSmeState);
1758 retCode = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
1759 psessionEntry = NULL;
1760 goto end;
1761
1762 }
1763
1764end:
1765 limGetSessionInfo(pMac,(tANI_U8*)pMsgBuf,&smesessionId,&smetransactionId);
1766
1767 if(pSmeJoinReq)
1768 {
1769 palFreeMemory( pMac->hHdd, pSmeJoinReq);
1770 pSmeJoinReq = NULL;
1771 if (NULL != psessionEntry)
1772 {
1773 psessionEntry->pLimJoinReq = NULL;
1774 }
1775 }
1776
1777 if(retCode != eSIR_SME_SUCCESS)
1778 {
1779 if(NULL != psessionEntry)
1780 {
1781 peDeleteSession(pMac,psessionEntry);
1782 psessionEntry = NULL;
1783 }
1784 }
1785
1786 limSendSmeJoinReassocRsp(pMac, eWNI_SME_JOIN_RSP, retCode, eSIR_MAC_UNSPEC_FAILURE_STATUS,psessionEntry,smesessionId,smetransactionId);
1787} /*** end __limProcessSmeJoinReq() ***/
1788
1789
1790#ifdef FEATURE_WLAN_CCX
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001791tANI_U8 limGetMaxTxPower(tPowerdBm regMax, tPowerdBm apTxPower, tPowerdBm iniTxPower)
Jeff Johnson295189b2012-06-20 16:38:30 -07001792{
1793 tANI_U8 maxTxPower = 0;
1794 tANI_U8 txPower = VOS_MIN( regMax , (apTxPower) );
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001795 txPower = VOS_MIN(txPower, iniTxPower);
Jeff Johnson295189b2012-06-20 16:38:30 -07001796 if((txPower >= MIN_TX_PWR_CAP) && (txPower <= MAX_TX_PWR_CAP))
1797 maxTxPower = txPower;
1798 else if (txPower < MIN_TX_PWR_CAP)
1799 maxTxPower = MIN_TX_PWR_CAP;
1800 else
1801 maxTxPower = MAX_TX_PWR_CAP;
1802
1803 return (maxTxPower);
1804}
1805#endif
1806
Jeff Johnson295189b2012-06-20 16:38:30 -07001807/**
1808 * __limProcessSmeReassocReq()
1809 *
1810 *FUNCTION:
1811 * This function is called to process SME_REASSOC_REQ message
1812 * from HDD or upper layer application.
1813 *
1814 *LOGIC:
1815 *
1816 *ASSUMPTIONS:
1817 *
1818 *NOTE:
1819 *
1820 * @param pMac Pointer to Global MAC structure
1821 * @param *pMsgBuf A pointer to the SME message buffer
1822 * @return None
1823 */
1824
1825static void
1826__limProcessSmeReassocReq(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
1827{
1828 tANI_U16 caps;
1829 tANI_U32 val;
1830 tpSirSmeReassocReq pReassocReq = NULL;
1831 tLimMlmReassocReq *pMlmReassocReq;
1832 tSirResultCodes retCode = eSIR_SME_SUCCESS;
1833 tpPESession psessionEntry = NULL;
1834 tANI_U8 sessionId;
1835 tANI_U8 smeSessionId;
1836 tANI_U16 transactionId;
1837 tPowerdBm localPowerConstraint = 0, regMax = 0;
1838 tANI_U32 teleBcnEn = 0;
1839
1840
1841 PELOG3(limLog(pMac, LOG3, FL("Received REASSOC_REQ\n"));)
1842
1843
1844 if( eHAL_STATUS_SUCCESS != palAllocateMemory( pMac->hHdd, (void **)&pReassocReq, __limGetSmeJoinReqSizeForAlloc((tANI_U8 *) pMsgBuf)))
1845 {
1846 // Log error
1847 limLog(pMac, LOGP,
1848 FL("call to palAllocateMemory failed for pReassocReq\n"));
1849
1850 retCode = eSIR_SME_RESOURCES_UNAVAILABLE;
1851 goto end;
1852 }
1853
1854
1855 if ((limJoinReqSerDes(pMac, (tpSirSmeJoinReq) pReassocReq,
1856 (tANI_U8 *) pMsgBuf) == eSIR_FAILURE) ||
1857 (!limIsSmeJoinReqValid(pMac,
1858 (tpSirSmeJoinReq) pReassocReq)))
1859 {
1860 /// Received invalid eWNI_SME_REASSOC_REQ
1861 // Log the event
1862 limLog(pMac, LOGW,
1863 FL("received SME_REASSOC_REQ with invalid data\n"));
1864
1865 retCode = eSIR_SME_INVALID_PARAMETERS;
1866 goto end;
1867 }
1868
1869 if((psessionEntry = peFindSessionByBssid(pMac,pReassocReq->bssDescription.bssId,&sessionId))==NULL)
1870 {
1871 limPrintMacAddr(pMac, pReassocReq->bssDescription.bssId, LOGE);
1872 limLog(pMac, LOGP, FL("Session does not exist for given bssId\n"));
1873 retCode = eSIR_SME_INVALID_PARAMETERS;
1874 goto end;
1875 }
1876
1877#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM //FEATURE_WLAN_DIAG_SUPPORT
1878 limDiagEventReport(pMac, WLAN_PE_DIAG_REASSOC_REQ_EVENT, psessionEntry, 0, 0);
1879#endif //FEATURE_WLAN_DIAG_SUPPORT
1880 //pMac->lim.gpLimReassocReq = pReassocReq;//TO SUPPORT BT-AMP
1881
1882 /* Store the reassoc handle in the session Table.. 23rd sep review */
1883 psessionEntry->pLimReAssocReq = pReassocReq;
1884
1885 /**
1886 * Reassociate request is expected
1887 * in link established state only.
1888 */
1889
1890 if (psessionEntry->limSmeState != eLIM_SME_LINK_EST_STATE)
1891 {
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001892#if defined(WLAN_FEATURE_VOWIFI_11R) || defined(FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07001893 if (psessionEntry->limSmeState == eLIM_SME_WT_REASSOC_STATE)
1894 {
1895 // May be from 11r FT pre-auth. So lets check it before we bail out
1896 limLog(pMac, LOGE, FL("Session in reassoc state is %d\n"),
1897 psessionEntry->peSessionId);
1898
1899 // Make sure its our preauth bssid
1900 if (!palEqualMemory( pMac->hHdd, pReassocReq->bssDescription.bssId,
1901 pMac->ft.ftPEContext.pFTPreAuthReq->preAuthbssId, 6))
1902 {
1903 limPrintMacAddr(pMac, pReassocReq->bssDescription.bssId, LOGE);
1904 limPrintMacAddr(pMac, pMac->ft.ftPEContext.pFTPreAuthReq->preAuthbssId, LOGE);
1905 limLog(pMac, LOGP, FL("Unknown bssId in reassoc state\n"));
1906 retCode = eSIR_SME_INVALID_PARAMETERS;
1907 goto end;
1908 }
1909
1910 limProcessMlmFTReassocReq(pMac, pMsgBuf, psessionEntry);
1911 return;
1912 }
1913#endif
1914 /// Should not have received eWNI_SME_REASSOC_REQ
1915 // Log the event
1916 limLog(pMac, LOGE,
1917 FL("received unexpected SME_REASSOC_REQ in state %X\n"),
1918 psessionEntry->limSmeState);
1919 limPrintSmeState(pMac, LOGE, psessionEntry->limSmeState);
1920
1921 retCode = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
1922 goto end;
1923 }
1924
Jeff Johnson295189b2012-06-20 16:38:30 -07001925 palCopyMemory( pMac->hHdd,
1926 psessionEntry->limReAssocbssId,
1927 psessionEntry->pLimReAssocReq->bssDescription.bssId,
1928 sizeof(tSirMacAddr));
1929
1930 psessionEntry->limReassocChannelId =
1931 psessionEntry->pLimReAssocReq->bssDescription.channelId;
1932
Jeff Johnsone7245742012-09-05 17:12:55 -07001933 psessionEntry->reAssocHtSupportedChannelWidthSet =
1934 (psessionEntry->pLimReAssocReq->cbMode)?1:0;
1935 psessionEntry->reAssocHtRecommendedTxWidthSet =
1936 psessionEntry->reAssocHtSupportedChannelWidthSet;
1937 psessionEntry->reAssocHtSecondaryChannelOffset =
1938 psessionEntry->pLimReAssocReq->cbMode;
1939
Jeff Johnson295189b2012-06-20 16:38:30 -07001940 psessionEntry->limReassocBssCaps =
1941 psessionEntry->pLimReAssocReq->bssDescription.capabilityInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07001942 regMax = cfgGetRegulatoryMaxTransmitPower( pMac, psessionEntry->currentOperChannel );
1943 localPowerConstraint = regMax;
1944 limExtractApCapability( pMac,
1945 (tANI_U8 *) psessionEntry->pLimReAssocReq->bssDescription.ieFields,
1946 limGetIElenFromBssDescription(
1947 &psessionEntry->pLimReAssocReq->bssDescription),
1948 &psessionEntry->limReassocBssQosCaps,
1949 &psessionEntry->limReassocBssPropCap,
1950 &pMac->lim.gLimCurrentBssUapsd //TBD-RAJESH make gLimReassocBssUapsd session specific
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07001951 , &localPowerConstraint,
1952 psessionEntry
Jeff Johnson295189b2012-06-20 16:38:30 -07001953 );
1954
1955 psessionEntry->maxTxPower = VOS_MIN( regMax , (localPowerConstraint) );
1956#if defined WLAN_VOWIFI_DEBUG
1957 limLog( pMac, LOGE, "Regulatory max = %d, local power constraint = %d, max tx = %d", regMax, localPowerConstraint, psessionEntry->maxTxPower );
1958#endif
1959 {
1960 #if 0
1961 if (wlan_cfgGetStr(pMac, WNI_CFG_SSID, pMac->lim.gLimReassocSSID.ssId,
1962 &cfgLen) != eSIR_SUCCESS)
1963 {
1964 /// Could not get SSID from CFG. Log error.
1965 limLog(pMac, LOGP, FL("could not retrive SSID\n"));
1966 }
1967 #endif//TO SUPPORT BT-AMP
1968
1969 /* Copy the SSID from sessio entry to local variable */
1970 #if 0
1971 palCopyMemory( pMac->hHdd, pMac->lim.gLimReassocSSID.ssId,
1972 psessionEntry->ssId.ssId,
1973 psessionEntry->ssId.length);
1974 #endif
1975 psessionEntry->limReassocSSID.length = pReassocReq->ssId.length;
1976 palCopyMemory( pMac->hHdd, psessionEntry->limReassocSSID.ssId,
1977 pReassocReq->ssId.ssId, psessionEntry->limReassocSSID.length);
1978
1979 }
1980
1981 if (pMac->lim.gLimCurrentBssUapsd)
1982 {
1983 pMac->lim.gUapsdPerAcBitmask = psessionEntry->pLimReAssocReq->uapsdPerAcBitmask;
1984 limLog( pMac, LOG1, FL("UAPSD flag for all AC - 0x%2x\n"), pMac->lim.gUapsdPerAcBitmask);
1985 }
1986
Jeff Johnson295189b2012-06-20 16:38:30 -07001987 if( eHAL_STATUS_SUCCESS != palAllocateMemory( pMac->hHdd, (void **)&pMlmReassocReq, sizeof(tLimMlmReassocReq)))
1988 {
1989 // Log error
1990 limLog(pMac, LOGP,
1991 FL("call to palAllocateMemory failed for mlmReassocReq\n"));
1992
1993 retCode = eSIR_SME_RESOURCES_UNAVAILABLE;
1994 goto end;
1995 }
1996
1997 palCopyMemory( pMac->hHdd, pMlmReassocReq->peerMacAddr,
1998 psessionEntry->limReAssocbssId,
1999 sizeof(tSirMacAddr));
2000
2001 if (wlan_cfgGetInt(pMac, WNI_CFG_REASSOCIATION_FAILURE_TIMEOUT,
2002 (tANI_U32 *) &pMlmReassocReq->reassocFailureTimeout)
2003 != eSIR_SUCCESS)
2004 {
2005 /**
2006 * Could not get ReassocFailureTimeout value
2007 * from CFG. Log error.
2008 */
2009 limLog(pMac, LOGP,
2010 FL("could not retrieve ReassocFailureTimeout value\n"));
2011 }
2012
2013 if (cfgGetCapabilityInfo(pMac, &caps,psessionEntry) != eSIR_SUCCESS)
2014 {
2015 /**
2016 * Could not get Capabilities value
2017 * from CFG. Log error.
2018 */
2019 limLog(pMac, LOGP,
2020 FL("could not retrieve Capabilities value\n"));
2021 }
2022 pMlmReassocReq->capabilityInfo = caps;
2023
2024 /* Update PE sessionId*/
2025 pMlmReassocReq->sessionId = sessionId;
2026
2027 /* If telescopic beaconing is enabled, set listen interval to
2028 WNI_CFG_TELE_BCN_MAX_LI */
2029 if(wlan_cfgGetInt(pMac, WNI_CFG_TELE_BCN_WAKEUP_EN, &teleBcnEn) !=
2030 eSIR_SUCCESS)
2031 limLog(pMac, LOGP, FL("Couldn't get WNI_CFG_TELE_BCN_WAKEUP_EN\n"));
2032
2033 val = WNI_CFG_LISTEN_INTERVAL_STADEF;
2034
2035 if(teleBcnEn)
2036 {
2037 if(wlan_cfgGetInt(pMac, WNI_CFG_TELE_BCN_MAX_LI, &val) !=
2038 eSIR_SUCCESS)
2039 {
2040 /**
2041 * Could not get ListenInterval value
2042 * from CFG. Log error.
2043 */
2044 limLog(pMac, LOGP, FL("could not retrieve ListenInterval\n"));
2045 }
2046 }
2047 else
2048 {
2049 if (wlan_cfgGetInt(pMac, WNI_CFG_LISTEN_INTERVAL, &val) != eSIR_SUCCESS)
2050 {
2051 /**
2052 * Could not get ListenInterval value
2053 * from CFG. Log error.
2054 */
2055 limLog(pMac, LOGP, FL("could not retrieve ListenInterval\n"));
2056 }
2057 }
2058
2059 /* Delete all BA sessions before Re-Assoc.
2060 * BA frames are class 3 frames and the session
2061 * is lost upon disassociation and reassociation.
2062 */
2063
2064 limDelAllBASessions(pMac);
2065
2066 pMlmReassocReq->listenInterval = (tANI_U16) val;
2067
2068 /* Indicate whether spectrum management is enabled*/
2069 psessionEntry->spectrumMgtEnabled = pReassocReq->spectrumMgtIndicator;
2070
2071 psessionEntry->limPrevSmeState = psessionEntry->limSmeState;
2072 psessionEntry->limSmeState = eLIM_SME_WT_REASSOC_STATE;
2073
Jeff Johnsone7245742012-09-05 17:12:55 -07002074 MTRACE(macTrace(pMac, TRACE_CODE_SME_STATE, psessionEntry->peSessionId, psessionEntry->limSmeState));
Jeff Johnson295189b2012-06-20 16:38:30 -07002075
2076 limPostMlmMessage(pMac,
2077 LIM_MLM_REASSOC_REQ,
2078 (tANI_U32 *) pMlmReassocReq);
2079 return;
2080
2081end:
2082 if (pReassocReq)
2083 palFreeMemory( pMac->hHdd, pReassocReq);
2084
2085 if (psessionEntry)
2086 {
2087 // error occurred after we determined the session so extract
2088 // session and transaction info from there
2089 smeSessionId = psessionEntry->smeSessionId;
2090 transactionId = psessionEntry->transactionId;
2091 }
2092 else
2093 {
2094 // error occurred before or during the time we determined the session
2095 // so extract the session and transaction info from the message
2096 limGetSessionInfo(pMac,(tANI_U8*)pMsgBuf, &smeSessionId, &transactionId);
2097 }
2098
2099 /// Send Reassoc failure response to host
2100 /// (note psessionEntry may be NULL, but that's OK)
2101 limSendSmeJoinReassocRsp(pMac, eWNI_SME_REASSOC_RSP,
2102 retCode, eSIR_MAC_UNSPEC_FAILURE_STATUS,
2103 psessionEntry, smeSessionId, transactionId);
2104
2105} /*** end __limProcessSmeReassocReq() ***/
2106
2107
2108tANI_BOOLEAN sendDisassocFrame = 1;
2109/**
2110 * __limProcessSmeDisassocReq()
2111 *
2112 *FUNCTION:
2113 * This function is called to process SME_DISASSOC_REQ message
2114 * from HDD or upper layer application.
2115 *
2116 *LOGIC:
2117 *
2118 *ASSUMPTIONS:
2119 *
2120 *NOTE:
2121 *
2122 * @param pMac Pointer to Global MAC structure
2123 * @param *pMsgBuf A pointer to the SME message buffer
2124 * @return None
2125 */
2126
2127static void
2128__limProcessSmeDisassocReq(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
2129{
2130 tANI_U16 disassocTrigger, reasonCode;
2131 tLimMlmDisassocReq *pMlmDisassocReq;
2132 tSirResultCodes retCode = eSIR_SME_SUCCESS;
Jeff Johnson43971f52012-07-17 12:26:56 -07002133 tSirRetStatus status;
Jeff Johnson295189b2012-06-20 16:38:30 -07002134 tSirSmeDisassocReq smeDisassocReq;
2135 tpPESession psessionEntry = NULL;
2136 tANI_U8 sessionId;
2137 tANI_U8 smesessionId;
2138 tANI_U16 smetransactionId;
2139
2140 PELOG1(limLog(pMac, LOG1,FL("received DISASSOC_REQ message\n"));)
2141
Jeff Johnson43971f52012-07-17 12:26:56 -07002142 if (pMsgBuf == NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -07002143 {
Jeff Johnson43971f52012-07-17 12:26:56 -07002144 limLog(pMac, LOGE, FL("Buffer is Pointing to NULL\n"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002145 return;
2146 }
2147
Jeff Johnson43971f52012-07-17 12:26:56 -07002148 limGetSessionInfo(pMac, (tANI_U8 *)pMsgBuf,&smesessionId, &smetransactionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07002149
Jeff Johnson43971f52012-07-17 12:26:56 -07002150 status = limDisassocReqSerDes(pMac, &smeDisassocReq, (tANI_U8 *) pMsgBuf);
Jeff Johnson295189b2012-06-20 16:38:30 -07002151
Jeff Johnson43971f52012-07-17 12:26:56 -07002152 if ( (eSIR_FAILURE == status) ||
2153 (!limIsSmeDisassocReqValid(pMac, &smeDisassocReq, psessionEntry)) )
Jeff Johnson295189b2012-06-20 16:38:30 -07002154 {
2155 PELOGE(limLog(pMac, LOGE,
2156 FL("received invalid SME_DISASSOC_REQ message\n"));)
2157
2158 if (pMac->lim.gLimRspReqd)
2159 {
2160 pMac->lim.gLimRspReqd = false;
2161
2162 retCode = eSIR_SME_INVALID_PARAMETERS;
2163 disassocTrigger = eLIM_HOST_DISASSOC;
2164 goto sendDisassoc;
2165 }
2166
2167 return;
2168 }
2169
2170
Jeff Johnsone7245742012-09-05 17:12:55 -07002171 PELOGE(limLog(pMac, LOGE, FL("received DISASSOC_REQ message. Reason: %d global SmeState: %d\n"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002172 smeDisassocReq.reasonCode, pMac->lim.gLimSmeState);)
2173
2174
2175 if((psessionEntry = peFindSessionByBssid(pMac,smeDisassocReq.bssId,&sessionId))== NULL)
2176 {
2177 limLog(pMac, LOGE,FL("session does not exist for given bssId\n"));
2178 retCode = eSIR_SME_INVALID_PARAMETERS;
2179 disassocTrigger = eLIM_HOST_DISASSOC;
2180 goto sendDisassoc;
2181
2182 }
2183
2184#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM //FEATURE_WLAN_DIAG_SUPPORT
2185 limDiagEventReport(pMac, WLAN_PE_DIAG_DISASSOC_REQ_EVENT, psessionEntry, 0, smeDisassocReq.reasonCode);
2186#endif //FEATURE_WLAN_DIAG_SUPPORT
2187
2188 /* Update SME session Id and SME transaction ID*/
2189
2190 psessionEntry->smeSessionId = smesessionId;
2191 psessionEntry->transactionId = smetransactionId;
2192
2193 switch (psessionEntry->limSystemRole)
2194 {
2195 case eLIM_STA_ROLE:
2196 case eLIM_BT_AMP_STA_ROLE:
2197 switch (psessionEntry->limSmeState)
2198 {
2199 case eLIM_SME_ASSOCIATED_STATE:
2200 case eLIM_SME_LINK_EST_STATE:
2201 psessionEntry->limPrevSmeState = psessionEntry->limSmeState;
2202 psessionEntry->limSmeState= eLIM_SME_WT_DISASSOC_STATE;
Jeff Johnsone7245742012-09-05 17:12:55 -07002203 MTRACE(macTrace(pMac, TRACE_CODE_SME_STATE, psessionEntry->peSessionId, psessionEntry->limSmeState));
Jeff Johnson295189b2012-06-20 16:38:30 -07002204 break;
2205
2206 case eLIM_SME_WT_DEAUTH_STATE:
2207 /* PE shall still process the DISASSOC_REQ and proceed with
2208 * link tear down even if it had already sent a DEAUTH_IND to
2209 * to SME. pMac->lim.gLimPrevSmeState shall remain the same as
2210 * its been set when PE entered WT_DEAUTH_STATE.
2211 */
2212 psessionEntry->limSmeState= eLIM_SME_WT_DISASSOC_STATE;
Jeff Johnsone7245742012-09-05 17:12:55 -07002213 MTRACE(macTrace(pMac, TRACE_CODE_SME_STATE, psessionEntry->peSessionId, psessionEntry->limSmeState));
Jeff Johnson295189b2012-06-20 16:38:30 -07002214 limLog(pMac, LOG1, FL("Rcvd SME_DISASSOC_REQ while in SME_WT_DEAUTH_STATE. \n"));
2215 break;
2216
2217 case eLIM_SME_WT_DISASSOC_STATE:
2218 /* PE Recieved a Disassoc frame. Normally it gets DISASSOC_CNF but it
2219 * received DISASSOC_REQ. Which means host is also trying to disconnect.
2220 * PE can continue processing DISASSOC_REQ and send the response instead
2221 * of failing the request. SME will anyway ignore DEAUTH_IND that was sent
2222 * for disassoc frame.
2223 *
2224 * It will send a disassoc, which is ok. However, we can use the global flag
2225 * sendDisassoc to not send disassoc frame.
2226 */
2227 limLog(pMac, LOG1, FL("Rcvd SME_DISASSOC_REQ while in SME_WT_DISASSOC_STATE. \n"));
2228 break;
2229
2230 case eLIM_SME_JOIN_FAILURE_STATE: {
2231 /** Return Success as we are already in Disconnected State*/
2232 if (pMac->lim.gLimRspReqd) {
2233 retCode = eSIR_SME_SUCCESS;
2234 disassocTrigger = eLIM_HOST_DISASSOC;
2235 goto sendDisassoc;
2236 }
2237 }break;
2238 default:
2239 /**
2240 * STA is not currently associated.
2241 * Log error and send response to host
2242 */
2243 limLog(pMac, LOGE,
2244 FL("received unexpected SME_DISASSOC_REQ in state %X\n"),
2245 psessionEntry->limSmeState);
2246 limPrintSmeState(pMac, LOGE, psessionEntry->limSmeState);
2247
2248 if (pMac->lim.gLimRspReqd)
2249 {
2250 if (psessionEntry->limSmeState !=
2251 eLIM_SME_WT_ASSOC_STATE)
2252 pMac->lim.gLimRspReqd = false;
2253
2254 retCode = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
2255 disassocTrigger = eLIM_HOST_DISASSOC;
2256 goto sendDisassoc;
2257 }
2258
2259 return;
2260 }
2261
2262 break;
2263
2264 case eLIM_AP_ROLE:
2265 case eLIM_BT_AMP_AP_ROLE:
2266 // Fall through
2267 break;
2268
2269 case eLIM_STA_IN_IBSS_ROLE:
2270 default: // eLIM_UNKNOWN_ROLE
2271 limLog(pMac, LOGE,
2272 FL("received unexpected SME_DISASSOC_REQ for role %d\n"),
2273 psessionEntry->limSystemRole);
2274
2275 retCode = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
2276 disassocTrigger = eLIM_HOST_DISASSOC;
2277 goto sendDisassoc;
2278 } // end switch (pMac->lim.gLimSystemRole)
2279
2280 if (smeDisassocReq.reasonCode == eLIM_LINK_MONITORING_DISASSOC)
2281 {
2282 /// Disassociation is triggered by Link Monitoring
2283 disassocTrigger = eLIM_LINK_MONITORING_DISASSOC;
2284 reasonCode = eSIR_MAC_DISASSOC_DUE_TO_INACTIVITY_REASON;
2285 }
2286 else
2287 {
2288 disassocTrigger = eLIM_HOST_DISASSOC;
2289 reasonCode = smeDisassocReq.reasonCode;
2290 }
2291
2292 if (smeDisassocReq.doNotSendOverTheAir)
2293 {
2294 sendDisassocFrame = 0;
2295 }
2296 // Trigger Disassociation frame to peer MAC entity
2297 if( eHAL_STATUS_SUCCESS != palAllocateMemory( pMac->hHdd, (void **)&pMlmDisassocReq, sizeof(tLimMlmDisassocReq)))
2298 {
2299 // Log error
2300 limLog(pMac, LOGP,
2301 FL("call to palAllocateMemory failed for mlmDisassocReq\n"));
2302
2303 return;
2304 }
2305
2306 palCopyMemory( pMac->hHdd, (tANI_U8 *) &pMlmDisassocReq->peerMacAddr,
2307 (tANI_U8 *) &smeDisassocReq.peerMacAddr,
2308 sizeof(tSirMacAddr));
2309
2310 pMlmDisassocReq->reasonCode = reasonCode;
2311 pMlmDisassocReq->disassocTrigger = disassocTrigger;
2312
2313 /* Update PE session ID*/
2314 pMlmDisassocReq->sessionId = sessionId;
2315#ifdef ANI_PRODUCT_TYPE_AP
2316 pMlmDisassocReq->aid = smeDisassocReq.aid;
2317#endif
2318
2319 limPostMlmMessage(pMac,
2320 LIM_MLM_DISASSOC_REQ,
2321 (tANI_U32 *) pMlmDisassocReq);
2322 return;
2323
2324sendDisassoc:
2325 if (psessionEntry)
2326 limSendSmeDisassocNtf(pMac, smeDisassocReq.peerMacAddr,
2327 retCode,
2328 disassocTrigger,
2329#ifdef ANI_PRODUCT_TYPE_AP
2330 smeDisassocReq.aid);
2331#else
2332 1,smesessionId,smetransactionId,psessionEntry);
2333#endif
2334 else
2335 limSendSmeDisassocNtf(pMac, smeDisassocReq.peerMacAddr,
2336 retCode,
2337 disassocTrigger,
2338#ifdef ANI_PRODUCT_TYPE_AP
2339 smeDisassocReq.aid);
2340#else
2341 1, 0, 0, NULL);
2342#endif
2343
2344
2345} /*** end __limProcessSmeDisassocReq() ***/
2346
2347
2348/** -----------------------------------------------------------------
2349 \brief __limProcessSmeDisassocCnf() - Process SME_DISASSOC_CNF
2350
2351 This function is called to process SME_DISASSOC_CNF message
2352 from HDD or upper layer application.
2353
2354 \param pMac - global mac structure
2355 \param pStaDs - station dph hash node
2356 \return none
2357 \sa
2358 ----------------------------------------------------------------- */
2359static void
2360__limProcessSmeDisassocCnf(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
2361{
2362 tSirSmeDisassocCnf smeDisassocCnf;
2363 tANI_U16 aid;
2364 tpDphHashNode pStaDs;
2365 tSirRetStatus status = eSIR_SUCCESS;
2366 tpPESession psessionEntry;
2367 tANI_U8 sessionId;
2368
2369
2370 PELOG1(limLog(pMac, LOG1, FL("received DISASSOC_CNF message\n"));)
2371
2372 status = limDisassocCnfSerDes(pMac, &smeDisassocCnf,(tANI_U8 *) pMsgBuf);
2373
2374 if (status == eSIR_FAILURE)
2375 {
2376 PELOGE(limLog(pMac, LOGE, FL("invalid SME_DISASSOC_CNF message\n"));)
2377 return;
2378 }
2379
2380 if((psessionEntry = peFindSessionByBssid(pMac, smeDisassocCnf.bssId, &sessionId))== NULL)
2381 {
2382 limLog(pMac, LOGE,FL("session does not exist for given bssId\n"));
2383 return;
2384 }
2385
2386 if (!limIsSmeDisassocCnfValid(pMac, &smeDisassocCnf, psessionEntry))
2387 {
2388 limLog(pMac, LOGW, FL("received invalid SME_DISASSOC_CNF message\n"));
2389 return;
2390 }
2391
2392#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM //FEATURE_WLAN_DIAG_SUPPORT
2393 if (smeDisassocCnf.messageType == eWNI_SME_DISASSOC_CNF)
2394 limDiagEventReport(pMac, WLAN_PE_DIAG_DISASSOC_CNF_EVENT, psessionEntry, (tANI_U16)smeDisassocCnf.statusCode, 0);
2395 else if (smeDisassocCnf.messageType == eWNI_SME_DEAUTH_CNF)
2396 limDiagEventReport(pMac, WLAN_PE_DIAG_DEAUTH_CNF_EVENT, psessionEntry, (tANI_U16)smeDisassocCnf.statusCode, 0);
2397#endif //FEATURE_WLAN_DIAG_SUPPORT
2398
2399 switch (psessionEntry->limSystemRole)
2400 {
2401 case eLIM_STA_ROLE:
2402 case eLIM_BT_AMP_STA_ROLE: //To test reconn
2403 if ((psessionEntry->limSmeState != eLIM_SME_IDLE_STATE) &&
2404 (psessionEntry->limSmeState != eLIM_SME_WT_DISASSOC_STATE) &&
2405 (psessionEntry->limSmeState != eLIM_SME_WT_DEAUTH_STATE))
2406 {
2407 limLog(pMac, LOGE,
2408 FL("received unexp SME_DISASSOC_CNF in state %X\n"),
2409 psessionEntry->limSmeState);
2410 limPrintSmeState(pMac, LOGE, psessionEntry->limSmeState);
2411 return;
2412 }
2413 break;
2414
2415 case eLIM_AP_ROLE:
2416 // Fall through
2417#ifdef WLAN_SOFTAP_FEATURE
2418 break;
2419#else
2420 return;
2421#endif
2422
2423 case eLIM_STA_IN_IBSS_ROLE:
2424 default: // eLIM_UNKNOWN_ROLE
2425 limLog(pMac, LOGE,
2426 FL("received unexpected SME_DISASSOC_CNF role %d\n"),
2427 psessionEntry->limSystemRole);
2428
2429 return;
2430 }
2431
2432
2433 if ( (psessionEntry->limSmeState == eLIM_SME_WT_DISASSOC_STATE) ||
2434 (psessionEntry->limSmeState == eLIM_SME_WT_DEAUTH_STATE)
2435#ifdef WLAN_SOFTAP_FEATURE
2436 || (psessionEntry->limSystemRole == eLIM_AP_ROLE )
2437#endif
2438 )
2439 {
2440 pStaDs = dphLookupHashEntry(pMac, smeDisassocCnf.peerMacAddr, &aid, &psessionEntry->dph.dphHashTable);
2441 if (pStaDs == NULL)
2442 {
2443 PELOGW(limLog(pMac, LOGW, FL("received DISASSOC_CNF for a STA that does not have context, addr= "));
2444 limPrintMacAddr(pMac, smeDisassocCnf.peerMacAddr, LOGW);)
2445 return;
2446 }
2447 limCleanupRxPath(pMac, pStaDs, psessionEntry);
2448 }
2449
2450 return;
2451}
2452
2453
2454/**
2455 * __limProcessSmeDeauthReq()
2456 *
2457 *FUNCTION:
2458 * This function is called to process SME_DEAUTH_REQ message
2459 * from HDD or upper layer application.
2460 *
2461 *LOGIC:
2462 *
2463 *ASSUMPTIONS:
2464 *
2465 *NOTE:
2466 *
2467 * @param pMac Pointer to Global MAC structure
2468 * @param *pMsgBuf A pointer to the SME message buffer
2469 * @return None
2470 */
2471
2472static void
2473__limProcessSmeDeauthReq(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
2474{
2475 tANI_U16 deauthTrigger, reasonCode;
2476 tLimMlmDeauthReq *pMlmDeauthReq;
2477 tSirSmeDeauthReq smeDeauthReq;
2478 tSirResultCodes retCode = eSIR_SME_SUCCESS;
2479 tSirRetStatus status = eSIR_SUCCESS;
2480 tpPESession psessionEntry;
2481 tANI_U8 sessionId; //PE sessionId
2482 tANI_U8 smesessionId;
2483 tANI_U16 smetransactionId;
2484
2485 PELOG1(limLog(pMac, LOG1,FL("received DEAUTH_REQ message\n"));)
2486
2487 status = limDeauthReqSerDes(pMac, &smeDeauthReq,(tANI_U8 *) pMsgBuf);
2488
2489 limGetSessionInfo(pMac,(tANI_U8 *)pMsgBuf,&smesessionId,&smetransactionId);
2490
2491 //We need to get a session first but we don't even know if the message is correct.
2492 if((psessionEntry = peFindSessionByBssid(pMac, smeDeauthReq.bssId, &sessionId)) == NULL)
2493 {
2494 limLog(pMac, LOGE,FL("session does not exist for given bssId\n"));
2495 retCode = eSIR_SME_INVALID_PARAMETERS;
2496 deauthTrigger = eLIM_HOST_DEAUTH;
2497 goto sendDeauth;
2498
2499 }
2500
2501 if ((status == eSIR_FAILURE) || (!limIsSmeDeauthReqValid(pMac, &smeDeauthReq, psessionEntry)))
2502 {
2503 PELOGE(limLog(pMac, LOGW,FL("received invalid SME_DEAUTH_REQ message\n"));)
2504 if (pMac->lim.gLimRspReqd)
2505 {
2506 pMac->lim.gLimRspReqd = false;
2507
2508 retCode = eSIR_SME_INVALID_PARAMETERS;
2509 deauthTrigger = eLIM_HOST_DEAUTH;
2510 goto sendDeauth;
2511 }
2512
2513 return;
2514 }
2515
2516#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM //FEATURE_WLAN_DIAG_SUPPORT
2517 limDiagEventReport(pMac, WLAN_PE_DIAG_DEAUTH_REQ_EVENT, psessionEntry, 0, smeDeauthReq.reasonCode);
2518#endif //FEATURE_WLAN_DIAG_SUPPORT
2519
2520 /* Update SME session ID and Transaction ID */
2521 psessionEntry->smeSessionId = smesessionId;
2522 psessionEntry->transactionId = smetransactionId;
2523
2524
2525 switch (psessionEntry->limSystemRole)
2526 {
2527 case eLIM_STA_ROLE:
2528 case eLIM_BT_AMP_STA_ROLE:
2529
2530 switch (psessionEntry->limSmeState)
2531 {
2532 case eLIM_SME_ASSOCIATED_STATE:
2533 case eLIM_SME_LINK_EST_STATE:
2534 case eLIM_SME_WT_ASSOC_STATE:
2535 case eLIM_SME_JOIN_FAILURE_STATE:
2536 case eLIM_SME_IDLE_STATE:
2537 psessionEntry->limPrevSmeState = psessionEntry->limSmeState;
2538 psessionEntry->limSmeState = eLIM_SME_WT_DEAUTH_STATE;
Jeff Johnsone7245742012-09-05 17:12:55 -07002539 MTRACE(macTrace(pMac, TRACE_CODE_SME_STATE, psessionEntry->peSessionId, pMac->lim.gLimSmeState));
Jeff Johnson295189b2012-06-20 16:38:30 -07002540
2541 // Send Deauthentication request to MLM below
2542
2543 break;
2544
2545 default:
2546 /**
2547 * STA is not in a state to deauthenticate with
2548 * peer. Log error and send response to host.
2549 */
2550 limLog(pMac, LOGE,
2551 FL("received unexp SME_DEAUTH_REQ in state %X\n"),psessionEntry->limSmeState);
2552 limPrintSmeState(pMac, LOGE, psessionEntry->limSmeState);
2553
2554 if (pMac->lim.gLimRspReqd)
2555 {
2556 pMac->lim.gLimRspReqd = false;
2557
2558 retCode = eSIR_SME_STA_NOT_AUTHENTICATED;
2559 deauthTrigger = eLIM_HOST_DEAUTH;
2560 goto sendDeauth;
2561 }
2562
2563 return;
2564 }
2565
2566 break;
2567
2568 case eLIM_STA_IN_IBSS_ROLE:
2569
2570 return;
2571
2572 case eLIM_AP_ROLE:
2573 // Fall through
2574
2575 break;
2576
2577 default:
2578 limLog(pMac, LOGE,
2579 FL("received unexpected SME_DEAUTH_REQ for role %X\n"),psessionEntry->limSystemRole);
2580
2581 return;
2582 } // end switch (pMac->lim.gLimSystemRole)
2583
2584 if (smeDeauthReq.reasonCode == eLIM_LINK_MONITORING_DEAUTH)
2585 {
2586 /// Deauthentication is triggered by Link Monitoring
2587 PELOG1(limLog(pMac, LOG1, FL("**** Lost link with AP ****\n"));)
2588 deauthTrigger = eLIM_LINK_MONITORING_DEAUTH;
2589 reasonCode = eSIR_MAC_UNSPEC_FAILURE_REASON;
2590 }
2591 else
2592 {
2593 deauthTrigger = eLIM_HOST_DEAUTH;
2594 reasonCode = smeDeauthReq.reasonCode;
2595 }
2596
2597 // Trigger Deauthentication frame to peer MAC entity
2598 if( eHAL_STATUS_SUCCESS != palAllocateMemory( pMac->hHdd, (void **)&pMlmDeauthReq, sizeof(tLimMlmDeauthReq)))
2599 {
2600 // Log error
2601 limLog(pMac, LOGP,
2602 FL("call to palAllocateMemory failed for mlmDeauthReq\n"));
2603
2604 return;
2605 }
2606
2607 palCopyMemory( pMac->hHdd, (tANI_U8 *) &pMlmDeauthReq->peerMacAddr,
2608 (tANI_U8 *) &smeDeauthReq.peerMacAddr,
2609 sizeof(tSirMacAddr));
2610
2611 pMlmDeauthReq->reasonCode = reasonCode;
2612 pMlmDeauthReq->deauthTrigger = deauthTrigger;
2613#ifdef ANI_PRODUCT_TYPE_AP
2614 pMlmDeauthReq->aid = smeDeauthReq.aid;
2615#endif
2616
2617 /* Update PE session Id*/
2618 pMlmDeauthReq->sessionId = sessionId;
2619
2620 limPostMlmMessage(pMac,
2621 LIM_MLM_DEAUTH_REQ,
2622 (tANI_U32 *) pMlmDeauthReq);
2623 return;
2624
2625sendDeauth:
2626 limSendSmeDeauthNtf(pMac, smeDeauthReq.peerMacAddr,
2627 retCode,
2628 deauthTrigger,
2629#ifdef ANI_PRODUCT_TYPE_AP
2630 smeDeauthReq.aid,
2631#else
2632 1,
2633#endif
2634 smesessionId, smetransactionId);
2635} /*** end __limProcessSmeDeauthReq() ***/
2636
2637
2638
2639/**
2640 * __limProcessSmeSetContextReq()
2641 *
2642 *FUNCTION:
2643 * This function is called to process SME_SETCONTEXT_REQ message
2644 * from HDD or upper layer application.
2645 *
2646 *LOGIC:
2647 *
2648 *ASSUMPTIONS:
2649 *
2650 *NOTE:
2651 *
2652 * @param pMac Pointer to Global MAC structure
2653 * @param *pMsgBuf A pointer to the SME message buffer
2654 * @return None
2655 */
2656
2657static void
2658__limProcessSmeSetContextReq(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
2659{
2660 tpSirSmeSetContextReq pSetContextReq;
2661 tLimMlmSetKeysReq *pMlmSetKeysReq;
2662 tpPESession psessionEntry;
2663 tANI_U8 sessionId; //PE sessionID
2664 tANI_U8 smesessionId;
2665 tANI_U16 smetransactionId;
2666
2667
2668 PELOG1(limLog(pMac, LOG1,
2669 FL("received SETCONTEXT_REQ message\n")););
2670
2671
2672 if(pMsgBuf == NULL)
2673 {
2674 limLog(pMac, LOGE,FL("Buffer is Pointing to NULL\n"));
2675 return;
2676 }
2677
2678 limGetSessionInfo(pMac,(tANI_U8 *)pMsgBuf,&smesessionId,&smetransactionId);
2679
2680 if( eHAL_STATUS_SUCCESS != palAllocateMemory( pMac->hHdd, (void **)&pSetContextReq,
2681 (sizeof(tSirKeys) * SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS)))
2682 {
2683 limLog(pMac, LOGP, FL("call to palAllocateMemory failed for pSetContextReq\n"));
2684 return;
2685 }
2686
2687 if ((limSetContextReqSerDes(pMac, pSetContextReq, (tANI_U8 *) pMsgBuf) == eSIR_FAILURE) ||
2688 (!limIsSmeSetContextReqValid(pMac, pSetContextReq)))
2689 {
2690 limLog(pMac, LOGW, FL("received invalid SME_SETCONTEXT_REQ message\n"));
2691 goto end;
2692 }
2693
2694 if(pSetContextReq->keyMaterial.numKeys > SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS)
2695 {
2696 PELOGE(limLog(pMac, LOGE, FL("numKeys:%d is more than SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS\n"), pSetContextReq->keyMaterial.numKeys);)
2697 limSendSmeSetContextRsp(pMac,
2698 pSetContextReq->peerMacAddr,
2699#ifdef ANI_PRODUCT_TYPE_AP
2700 pSetContextReq->aid,
2701#else
2702 1,
2703#endif
2704 eSIR_SME_INVALID_PARAMETERS,NULL,
2705 smesessionId,smetransactionId);
2706
2707 goto end;
2708 }
2709
2710
2711 if((psessionEntry = peFindSessionByBssid(pMac, pSetContextReq->bssId, &sessionId)) == NULL)
2712 {
2713 limLog(pMac, LOGW, FL("Session does not exist for given BSSID\n"));
2714 limSendSmeSetContextRsp(pMac,
2715 pSetContextReq->peerMacAddr,
2716#ifdef ANI_PRODUCT_TYPE_AP
2717 pSetContextReq->aid,
2718#else
2719 1,
2720#endif
2721 eSIR_SME_INVALID_PARAMETERS,NULL,
2722 smesessionId,smetransactionId);
2723
2724 goto end;
2725 }
2726
2727#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM //FEATURE_WLAN_DIAG_SUPPORT
2728 limDiagEventReport(pMac, WLAN_PE_DIAG_SETCONTEXT_REQ_EVENT, psessionEntry, 0, 0);
2729#endif //FEATURE_WLAN_DIAG_SUPPORT
2730
2731
2732 if ((((psessionEntry->limSystemRole == eLIM_STA_ROLE) || (psessionEntry->limSystemRole == eLIM_BT_AMP_STA_ROLE)) &&
2733 (psessionEntry->limSmeState == eLIM_SME_LINK_EST_STATE)) ||
2734 (((psessionEntry->limSystemRole == eLIM_STA_IN_IBSS_ROLE) ||
2735 (psessionEntry->limSystemRole == eLIM_AP_ROLE)|| (psessionEntry->limSystemRole == eLIM_BT_AMP_AP_ROLE)) &&
2736 (psessionEntry->limSmeState == eLIM_SME_NORMAL_STATE)))
2737 {
2738 // Trigger MLM_SETKEYS_REQ
2739 if( eHAL_STATUS_SUCCESS != palAllocateMemory( pMac->hHdd, (void **)&pMlmSetKeysReq, sizeof(tLimMlmSetKeysReq)))
2740 {
2741 // Log error
2742 limLog(pMac, LOGP, FL("call to palAllocateMemory failed for mlmSetKeysReq\n"));
2743 goto end;
2744 }
2745
2746 pMlmSetKeysReq->edType = pSetContextReq->keyMaterial.edType;
2747 pMlmSetKeysReq->numKeys = pSetContextReq->keyMaterial.numKeys;
2748 if(pMlmSetKeysReq->numKeys > SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS)
2749 {
2750 limLog(pMac, LOGP, FL("Num of keys exceeded max num of default keys limit\n"));
2751 goto end;
2752 }
2753 palCopyMemory( pMac->hHdd, (tANI_U8 *) &pMlmSetKeysReq->peerMacAddr,
2754 (tANI_U8 *) &pSetContextReq->peerMacAddr,
2755 sizeof(tSirMacAddr));
2756
2757#ifdef ANI_PRODUCT_TYPE_AP
2758 pMlmSetKeysReq->aid = pSetContextReq->aid;
2759#endif
2760
2761 palCopyMemory( pMac->hHdd, (tANI_U8 *) &pMlmSetKeysReq->key,
2762 (tANI_U8 *) &pSetContextReq->keyMaterial.key,
2763 sizeof(tSirKeys) * (pMlmSetKeysReq->numKeys ? pMlmSetKeysReq->numKeys : 1));
2764
2765 pMlmSetKeysReq->sessionId = sessionId;
2766#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
2767 PELOG1(limLog(pMac, LOG1,
2768 FL("received SETCONTEXT_REQ message sessionId=%d\n"), pMlmSetKeysReq->sessionId););
2769#endif
2770
2771#ifdef WLAN_SOFTAP_FEATURE
2772 if(((pSetContextReq->keyMaterial.edType == eSIR_ED_WEP40) || (pSetContextReq->keyMaterial.edType == eSIR_ED_WEP104))
2773 && (psessionEntry->limSystemRole == eLIM_AP_ROLE))
2774 {
2775 if(pSetContextReq->keyMaterial.key[0].keyLength)
2776 {
2777 tANI_U8 keyId;
2778 keyId = pSetContextReq->keyMaterial.key[0].keyId;
2779 palCopyMemory(pMac, (tANI_U8 *)&psessionEntry->WEPKeyMaterial[keyId],
2780 (tANI_U8 *) &pSetContextReq->keyMaterial, sizeof(tSirKeyMaterial));
2781 }
2782 else {
2783 tANI_U32 i;
2784 for( i = 0; i < SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS; i++)
2785 {
2786 palCopyMemory( pMac->hHdd, (tANI_U8 *) &pMlmSetKeysReq->key[i],
2787 (tANI_U8 *)psessionEntry->WEPKeyMaterial[i].key, sizeof(tSirKeys));
2788 }
2789 }
2790 }
2791#endif
2792
2793 limPostMlmMessage(pMac, LIM_MLM_SETKEYS_REQ, (tANI_U32 *) pMlmSetKeysReq);
2794
2795#ifdef ANI_AP_SDK
2796 /* For SDK acting as STA under Linux, need to consider the AP as *
2797 * as authenticatated. */
2798 if ( (psessionEntry->limSystemRole == eLIM_STA_ROLE) &&
2799 (psessionEntry->limSmeState == eLIM_SME_LINK_EST_STATE))
2800 {
2801 tpDphHashNode pSta;
2802 pSta = dphGetHashEntry(pMac, 0, &psessionEntry->dph.dphHashTable);
2803 if (pSta)
2804 pSta->staAuthenticated = 1;
2805 }
2806#endif
2807 }
2808 else
2809 {
2810 limLog(pMac, LOGE,
2811 FL("received unexpected SME_SETCONTEXT_REQ for role %d, state=%X\n"),
2812 psessionEntry->limSystemRole,
2813 psessionEntry->limSmeState);
2814 limPrintSmeState(pMac, LOGE, psessionEntry->limSmeState);
2815
2816 limSendSmeSetContextRsp(pMac, pSetContextReq->peerMacAddr,
2817#ifdef ANI_PRODUCT_TYPE_AP
2818 pSetContextReq->aid,
2819#else
2820 1,
2821#endif
2822 eSIR_SME_UNEXPECTED_REQ_RESULT_CODE,psessionEntry,
2823 smesessionId,
2824 smetransactionId);
2825 }
2826
2827end:
2828 palFreeMemory( pMac->hHdd, pSetContextReq);
2829 return;
2830} /*** end __limProcessSmeSetContextReq() ***/
2831
2832/**
2833 * __limProcessSmeRemoveKeyReq()
2834 *
2835 *FUNCTION:
2836 * This function is called to process SME_REMOVEKEY_REQ message
2837 * from HDD or upper layer application.
2838 *
2839 *LOGIC:
2840 *
2841 *ASSUMPTIONS:
2842 *
2843 *NOTE:
2844 *
2845 * @param pMac Pointer to Global MAC structure
2846 * @param *pMsgBuf A pointer to the SME message buffer
2847 * @return None
2848 */
2849
2850static void
2851__limProcessSmeRemoveKeyReq(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
2852{
2853 tpSirSmeRemoveKeyReq pRemoveKeyReq;
2854 tLimMlmRemoveKeyReq *pMlmRemoveKeyReq;
2855 tpPESession psessionEntry;
2856 tANI_U8 sessionId; //PE sessionID
2857 tANI_U8 smesessionId;
2858 tANI_U16 smetransactionId;
2859
2860 PELOG1(limLog(pMac, LOG1,
2861 FL("received REMOVEKEY_REQ message\n"));)
2862
2863 if(pMsgBuf == NULL)
2864 {
2865 limLog(pMac, LOGE,FL("Buffer is Pointing to NULL\n"));
2866 return;
2867 }
2868
2869
2870 limGetSessionInfo(pMac,(tANI_U8 *)pMsgBuf,&smesessionId,&smetransactionId);
2871
2872 if( eHAL_STATUS_SUCCESS != palAllocateMemory( pMac->hHdd, (void **)&pRemoveKeyReq,
2873 (sizeof(*pRemoveKeyReq))))
2874 {
2875 //Log error
2876 limLog(pMac, LOGP,
2877 FL("call to palAllocateMemory failed for pRemoveKeyReq\n"));
2878
2879 return;
2880 }
2881
2882 if ((limRemoveKeyReqSerDes(pMac,
2883 pRemoveKeyReq,
2884 (tANI_U8 *) pMsgBuf) == eSIR_FAILURE))
2885 {
2886 limLog(pMac, LOGW,
2887 FL("received invalid SME_REMOVECONTEXT_REQ message\n"));
2888
2889 /* extra look up is needed since, session entry to be passed il limsendremovekey response */
2890
2891 if((psessionEntry = peFindSessionByBssid(pMac,pRemoveKeyReq->bssId,&sessionId))== NULL)
2892 {
2893 limLog(pMac, LOGE,FL("session does not exist for given bssId\n"));
2894 //goto end;
2895 }
2896
2897 limSendSmeRemoveKeyRsp(pMac,
2898 pRemoveKeyReq->peerMacAddr,
2899 eSIR_SME_INVALID_PARAMETERS,psessionEntry,
2900 smesessionId,smetransactionId);
2901
2902 goto end;
2903 }
2904
2905 if((psessionEntry = peFindSessionByBssid(pMac,pRemoveKeyReq->bssId, &sessionId))== NULL)
2906 {
2907 limLog(pMac, LOGE,
2908 FL("session does not exist for given bssId\n"));
2909 limSendSmeRemoveKeyRsp(pMac,
2910 pRemoveKeyReq->peerMacAddr,
2911 eSIR_SME_UNEXPECTED_REQ_RESULT_CODE, NULL,
2912 smesessionId, smetransactionId);
2913 goto end;
2914 }
2915
2916
2917 if ((((psessionEntry->limSystemRole == eLIM_STA_ROLE)|| (psessionEntry->limSystemRole == eLIM_BT_AMP_STA_ROLE))&&
2918 (psessionEntry->limSmeState == eLIM_SME_LINK_EST_STATE)) ||
2919 (((psessionEntry->limSystemRole == eLIM_STA_IN_IBSS_ROLE) ||
2920 (psessionEntry->limSystemRole == eLIM_AP_ROLE)|| (psessionEntry->limSystemRole == eLIM_BT_AMP_AP_ROLE)) &&
2921 (psessionEntry->limSmeState == eLIM_SME_NORMAL_STATE)))
2922 {
2923 // Trigger MLM_REMOVEKEYS_REQ
2924 if( eHAL_STATUS_SUCCESS != palAllocateMemory( pMac->hHdd, (void **)&pMlmRemoveKeyReq, sizeof(tLimMlmRemoveKeyReq)))
2925 {
2926 // Log error
2927 limLog(pMac, LOGP,
2928 FL("call to palAllocateMemory failed for mlmRemoveKeysReq\n"));
2929
2930 goto end;
2931 }
2932
2933 pMlmRemoveKeyReq->edType = (tAniEdType)pRemoveKeyReq->edType;
2934 pMlmRemoveKeyReq->keyId = pRemoveKeyReq->keyId;
2935 pMlmRemoveKeyReq->wepType = pRemoveKeyReq->wepType;
2936 pMlmRemoveKeyReq->unicast = pRemoveKeyReq->unicast;
2937
2938 /* Update PE session Id */
2939 pMlmRemoveKeyReq->sessionId = sessionId;
2940
2941 palCopyMemory( pMac->hHdd, (tANI_U8 *) &pMlmRemoveKeyReq->peerMacAddr,
2942 (tANI_U8 *) &pRemoveKeyReq->peerMacAddr,
2943 sizeof(tSirMacAddr));
2944
2945
2946 limPostMlmMessage(pMac,
2947 LIM_MLM_REMOVEKEY_REQ,
2948 (tANI_U32 *) pMlmRemoveKeyReq);
2949 }
2950 else
2951 {
2952 limLog(pMac, LOGE,
2953 FL("received unexpected SME_REMOVEKEY_REQ for role %d, state=%X\n"),
2954 psessionEntry->limSystemRole,
2955 psessionEntry->limSmeState);
2956 limPrintSmeState(pMac, LOGE, psessionEntry->limSmeState);
2957
2958 limSendSmeRemoveKeyRsp(pMac,
2959 pRemoveKeyReq->peerMacAddr,
2960 eSIR_SME_UNEXPECTED_REQ_RESULT_CODE,psessionEntry,
2961 smesessionId,smetransactionId);
2962 }
2963
2964end:
2965 palFreeMemory( pMac->hHdd, pRemoveKeyReq);
2966} /*** end __limProcessSmeRemoveKeyReq() ***/
2967
Jeff Johnson295189b2012-06-20 16:38:30 -07002968void limProcessSmeGetScanChannelInfo(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
2969{
2970 tSirMsgQ mmhMsg;
2971 tpSmeGetScanChnRsp pSirSmeRsp;
2972 tANI_U16 len = 0;
2973
2974 if(pMac->lim.scanChnInfo.numChnInfo > SIR_MAX_SUPPORTED_CHANNEL_LIST)
2975 {
2976 limLog(pMac, LOGW, FL("numChn is out of bounds %d\n"),
2977 pMac->lim.scanChnInfo.numChnInfo);
2978 pMac->lim.scanChnInfo.numChnInfo = SIR_MAX_SUPPORTED_CHANNEL_LIST;
2979 }
2980
2981 PELOG2(limLog(pMac, LOG2,
2982 FL("Sending message %s with number of channels %d\n"),
2983 limMsgStr(eWNI_SME_GET_SCANNED_CHANNEL_RSP), pMac->lim.scanChnInfo.numChnInfo);)
2984
2985 len = sizeof(tSmeGetScanChnRsp) + (pMac->lim.scanChnInfo.numChnInfo - 1) * sizeof(tLimScanChn);
2986 if( eHAL_STATUS_SUCCESS != palAllocateMemory( pMac->hHdd, (void **)&pSirSmeRsp, len ))
2987 {
2988 /// Buffer not available. Log error
2989 limLog(pMac, LOGP,
2990 FL("call to palAllocateMemory failed for JOIN/REASSOC_RSP\n"));
2991
2992 return;
2993 }
2994 palZeroMemory(pMac->hHdd, pSirSmeRsp, len);
2995
2996#if defined(ANI_PRODUCT_TYPE_AP) && defined(ANI_LITTLE_BYTE_ENDIAN)
2997 sirStoreU16N((tANI_U8*)&pSirSmeRsp->mesgType, eWNI_SME_GET_SCANNED_CHANNEL_RSP);
2998 sirStoreU16N((tANI_U8*)&pSirSmeRsp->mesgLen, len);
2999#else
3000 pSirSmeRsp->mesgType = eWNI_SME_GET_SCANNED_CHANNEL_RSP;
3001 pSirSmeRsp->mesgLen = len;
3002#endif
3003 pSirSmeRsp->sessionId = 0;
3004
3005 if(pMac->lim.scanChnInfo.numChnInfo)
3006 {
3007 pSirSmeRsp->numChn = pMac->lim.scanChnInfo.numChnInfo;
3008 palCopyMemory(pMac->hHdd, pSirSmeRsp->scanChn, pMac->lim.scanChnInfo.scanChn, sizeof(tLimScanChn) * pSirSmeRsp->numChn);
3009 }
3010 //Clear the list
3011 limRessetScanChannelInfo(pMac);
3012
3013 mmhMsg.type = eWNI_SME_GET_SCANNED_CHANNEL_RSP;
3014 mmhMsg.bodyptr = pSirSmeRsp;
3015 mmhMsg.bodyval = 0;
3016
3017 pMac->lim.gLimRspReqd = false;
Jeff Johnsone7245742012-09-05 17:12:55 -07003018 MTRACE(macTraceMsgTx(pMac, NO_SESSION, mmhMsg.type));
Jeff Johnson295189b2012-06-20 16:38:30 -07003019 limSysProcessMmhMsgApi(pMac, &mmhMsg, ePROT);
3020}
3021
3022
3023#ifdef WLAN_SOFTAP_FEATURE
3024void limProcessSmeGetAssocSTAsInfo(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
3025{
3026 tSirSmeGetAssocSTAsReq getAssocSTAsReq;
3027 tpDphHashNode pStaDs = NULL;
3028 tpPESession psessionEntry = NULL;
3029 tSap_Event sapEvent;
3030 tpWLAN_SAPEventCB pSapEventCallback = NULL;
3031 tpSap_AssocMacAddr pAssocStasTemp = NULL;// #include "sapApi.h"
3032 tANI_U8 sessionId = CSR_SESSION_ID_INVALID;
3033 tANI_U8 assocId = 0;
3034 tANI_U8 staCount = 0;
3035
3036 if (!limIsSmeGetAssocSTAsReqValid(pMac, &getAssocSTAsReq, (tANI_U8 *) pMsgBuf))
3037 {
3038 limLog(pMac, LOGE,
3039 FL("received invalid eWNI_SME_GET_ASSOC_STAS_REQ message\n"));
3040 goto limAssocStaEnd;
3041 }
3042
3043 switch (getAssocSTAsReq.modId)
3044 {
3045/**
3046 case VOS_MODULE_ID_HAL:
3047 wdaPostCtrlMsg( pMac, &msgQ );
3048 return;
3049
3050 case VOS_MODULE_ID_TL:
3051 Post msg TL
3052 return;
3053*/
3054 case VOS_MODULE_ID_PE:
3055 default:
3056 break;
3057 }
3058
3059 // Get Assoctiated stations from PE
3060 // Find PE session Entry
3061 if ((psessionEntry = peFindSessionByBssid(pMac, getAssocSTAsReq.bssId, &sessionId)) == NULL)
3062 {
3063 limLog(pMac, LOGE,
3064 FL("session does not exist for given bssId\n"));
3065 goto limAssocStaEnd;
3066 }
3067
3068 if (psessionEntry->limSystemRole != eLIM_AP_ROLE)
3069 {
3070 limLog(pMac, LOGE,
3071 FL("Received unexpected message in state %X, in role %X\n"),
3072 psessionEntry->limSmeState , psessionEntry->limSystemRole);
3073 goto limAssocStaEnd;
3074 }
3075
3076 // Retrieve values obtained in the request message
3077 pSapEventCallback = (tpWLAN_SAPEventCB)getAssocSTAsReq.pSapEventCallback;
3078 pAssocStasTemp = (tpSap_AssocMacAddr)getAssocSTAsReq.pAssocStasArray;
3079
3080 for (assocId = 0; assocId < psessionEntry->dph.dphHashTable.size; assocId++)// Softap dphHashTable.size = 8
3081 {
3082 pStaDs = dphGetHashEntry(pMac, assocId, &psessionEntry->dph.dphHashTable);
3083
3084 if (NULL == pStaDs)
3085 continue;
3086
3087 if (pStaDs->valid)
3088 {
3089 palCopyMemory(pMac->hHdd, (tANI_U8 *)&pAssocStasTemp->staMac,
3090 (tANI_U8 *)&pStaDs->staAddr,
3091 sizeof(v_MACADDR_t)); // Mac address
3092 pAssocStasTemp->assocId = (v_U8_t)pStaDs->assocId; // Association Id
3093 pAssocStasTemp->staId = (v_U8_t)pStaDs->staIndex; // Station Id
3094
3095 limLog(pMac, LOG1, FL("dph Station Number = %d"), staCount+1);
3096 limLog(pMac, LOG1, FL("MAC = %02x:%02x:%02x:%02x:%02x:%02x"),
3097 pStaDs->staAddr[0],
3098 pStaDs->staAddr[1],
3099 pStaDs->staAddr[2],
3100 pStaDs->staAddr[3],
3101 pStaDs->staAddr[4],
3102 pStaDs->staAddr[5]);
3103 limLog(pMac, LOG1, FL("Association Id = %d"),pStaDs->assocId);
3104 limLog(pMac, LOG1, FL("Station Index = %d"),pStaDs->staIndex);
3105
3106 pAssocStasTemp++;
3107 staCount++;
3108 }
3109 }
3110
3111limAssocStaEnd:
3112 // Call hdd callback with sap event to send the list of associated stations from PE
3113 if (pSapEventCallback != NULL)
3114 {
3115 sapEvent.sapHddEventCode = eSAP_ASSOC_STA_CALLBACK_EVENT;
3116 sapEvent.sapevt.sapAssocStaListEvent.module = VOS_MODULE_ID_PE;
3117 sapEvent.sapevt.sapAssocStaListEvent.noOfAssocSta = staCount;
3118 sapEvent.sapevt.sapAssocStaListEvent.pAssocStas = (tpSap_AssocMacAddr)getAssocSTAsReq.pAssocStasArray;
3119 pSapEventCallback(&sapEvent, getAssocSTAsReq.pUsrContext);
3120 }
3121}
3122
3123
3124/**
3125 * limProcessSmeGetWPSPBCSessions
3126 *
3127 *FUNCTION:
3128 * This function is called when query the WPS PBC overlap message is received
3129 *
3130 *LOGIC:
3131 * This function parses get WPS PBC overlap information message and call callback to pass
3132 * WPS PBC overlap information back to hdd.
3133 *ASSUMPTIONS:
3134 *
3135 *
3136 *NOTE:
3137 *
3138 * @param pMac Pointer to Global MAC structure
3139 * @param pMsgBuf A pointer to WPS PBC overlap query message
3140*
3141 * @return None
3142 */
3143void limProcessSmeGetWPSPBCSessions(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
3144{
3145 tSirSmeGetWPSPBCSessionsReq GetWPSPBCSessionsReq;
3146 tpPESession psessionEntry = NULL;
3147 tSap_Event sapEvent;
3148 tpWLAN_SAPEventCB pSapEventCallback = NULL;
3149 tANI_U8 sessionId = CSR_SESSION_ID_INVALID;
3150 tSirMacAddr zeroMac = {0,0,0,0,0,0};
3151
3152 sapEvent.sapevt.sapGetWPSPBCSessionEvent.status = VOS_STATUS_E_FAULT;
3153
3154 if (limIsSmeGetWPSPBCSessionsReqValid(pMac, &GetWPSPBCSessionsReq, (tANI_U8 *) pMsgBuf) != eSIR_SUCCESS)
3155 {
3156 limLog(pMac, LOGE,
3157 FL("received invalid eWNI_SME_GET_ASSOC_STAS_REQ message\n"));
3158 goto limGetWPSPBCSessionsEnd;
3159 }
3160
3161 // Get Assoctiated stations from PE
3162 // Find PE session Entry
3163 if ((psessionEntry = peFindSessionByBssid(pMac, GetWPSPBCSessionsReq.bssId, &sessionId)) == NULL)
3164 {
3165 limLog(pMac, LOGE,
3166 FL("session does not exist for given bssId\n"));
3167 goto limGetWPSPBCSessionsEnd;
3168 }
3169
3170 if (psessionEntry->limSystemRole != eLIM_AP_ROLE)
3171 {
3172 limLog(pMac, LOGE,
3173 FL("Received unexpected message in role %X\n"),
3174 psessionEntry->limSystemRole);
3175 goto limGetWPSPBCSessionsEnd;
3176 }
3177
3178 // Call hdd callback with sap event to send the WPS PBC overlap infromation
3179 sapEvent.sapHddEventCode = eSAP_GET_WPSPBC_SESSION_EVENT;
3180 sapEvent.sapevt.sapGetWPSPBCSessionEvent.module = VOS_MODULE_ID_PE;
3181
3182 if (palEqualMemory(pMac->hHdd, zeroMac, GetWPSPBCSessionsReq.pRemoveMac, sizeof(tSirMacAddr)))
3183 { //This is GetWpsSession call
3184
3185 limGetWPSPBCSessions(pMac,
3186 sapEvent.sapevt.sapGetWPSPBCSessionEvent.addr.bytes, sapEvent.sapevt.sapGetWPSPBCSessionEvent.UUID_E,
3187 &sapEvent.sapevt.sapGetWPSPBCSessionEvent.wpsPBCOverlap, psessionEntry);
3188 }
3189 else
3190 {
3191 limRemovePBCSessions(pMac, GetWPSPBCSessionsReq.pRemoveMac,psessionEntry);
3192 /* don't have to inform the HDD/Host */
3193 return;
3194 }
3195
3196 PELOG4(limLog(pMac, LOGE, FL("wpsPBCOverlap %d\n"), sapEvent.sapevt.sapGetWPSPBCSessionEvent.wpsPBCOverlap);)
3197 PELOG4(limPrintMacAddr(pMac, sapEvent.sapevt.sapGetWPSPBCSessionEvent.addr.bytes, LOG4);)
3198
3199 sapEvent.sapevt.sapGetWPSPBCSessionEvent.status = VOS_STATUS_SUCCESS;
3200
3201limGetWPSPBCSessionsEnd:
3202 pSapEventCallback = (tpWLAN_SAPEventCB)GetWPSPBCSessionsReq.pSapEventCallback;
3203 pSapEventCallback(&sapEvent, GetWPSPBCSessionsReq.pUsrContext);
3204}
3205
3206#endif
3207
3208
3209/**
3210 * __limCounterMeasures()
3211 *
3212 * FUNCTION:
3213 * This function is called to "implement" MIC counter measure
3214 * and is *temporary* only
3215 *
3216 * LOGIC: on AP, disassoc all STA associated thru TKIP,
3217 * we don't do the proper STA disassoc sequence since the
3218 * BSS will be stoped anyway
3219 *
3220 *ASSUMPTIONS:
3221 *
3222 *NOTE:
3223 *
3224 * @param pMac Pointer to Global MAC structure
3225 * @return None
3226 */
3227
3228static void
3229__limCounterMeasures(tpAniSirGlobal pMac, tpPESession psessionEntry)
3230{
3231 tSirMacAddr mac = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
3232 if ( (psessionEntry->limSystemRole == eLIM_AP_ROLE) || (psessionEntry->limSystemRole == eLIM_BT_AMP_AP_ROLE)
3233 || (psessionEntry->limSystemRole == eLIM_BT_AMP_STA_ROLE) )
3234
3235 limSendDisassocMgmtFrame(pMac, eSIR_MAC_MIC_FAILURE_REASON, mac, psessionEntry);
3236
3237 tx_thread_sleep(10);
3238};
3239
3240
3241#ifdef WLAN_SOFTAP_FEATURE
3242void
3243limProcessTkipCounterMeasures(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
3244{
3245 tSirSmeTkipCntrMeasReq tkipCntrMeasReq;
3246 tpPESession psessionEntry;
3247 tANI_U8 sessionId; //PE sessionId
3248
3249 if ( limTkipCntrMeasReqSerDes( pMac, &tkipCntrMeasReq, (tANI_U8 *) pMsgBuf ) != eSIR_SUCCESS )
3250 {
3251 limLog(pMac, LOGE,
3252 FL("received invalid eWNI_SME_TKIP_CNTR_MEAS_REQ message\n"));
3253 return;
3254 }
3255
3256 if ( NULL == (psessionEntry = peFindSessionByBssid( pMac, tkipCntrMeasReq.bssId, &sessionId )) )
3257 {
3258 limLog(pMac, LOGE, FL("session does not exist for given BSSID \n"));
3259 return;
3260 }
3261
3262 if ( tkipCntrMeasReq.bEnable )
3263 {
3264 __limCounterMeasures( pMac, psessionEntry );
3265 }
3266
3267 psessionEntry->bTkipCntrMeasActive = tkipCntrMeasReq.bEnable;
3268}
3269#endif
3270
3271
3272static void
3273__limHandleSmeStopBssRequest(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
3274{
3275 tSirSmeStopBssReq stopBssReq;
3276 tSirRetStatus status;
3277 tLimSmeStates prevState;
3278 tANI_U8 sessionId; //PE sessionId
3279 tpPESession psessionEntry;
3280 tANI_U8 smesessionId;
3281 tANI_U16 smetransactionId;
3282
3283 limGetSessionInfo(pMac,(tANI_U8 *)pMsgBuf,&smesessionId,&smetransactionId);
3284
3285
3286
3287 if ((limStopBssReqSerDes(pMac, &stopBssReq, (tANI_U8 *) pMsgBuf) != eSIR_SUCCESS) ||
3288 !limIsSmeStopBssReqValid(pMsgBuf))
3289 {
3290 PELOGW(limLog(pMac, LOGW, FL("received invalid SME_STOP_BSS_REQ message\n"));)
3291 /// Send Stop BSS response to host
3292 limSendSmeRsp(pMac, eWNI_SME_STOP_BSS_RSP, eSIR_SME_INVALID_PARAMETERS,smesessionId,smetransactionId);
3293 return;
3294 }
3295
3296
3297 if((psessionEntry = peFindSessionByBssid(pMac,stopBssReq.bssId,&sessionId)) == NULL)
3298 {
3299 limLog(pMac, LOGW, FL("session does not exist for given BSSID \n"));
3300 limSendSmeRsp(pMac, eWNI_SME_STOP_BSS_RSP, eSIR_SME_INVALID_PARAMETERS,smesessionId,smetransactionId);
3301 return;
3302 }
3303
3304#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM //FEATURE_WLAN_DIAG_SUPPORT
3305 limDiagEventReport(pMac, WLAN_PE_DIAG_STOP_BSS_REQ_EVENT, psessionEntry, 0, 0);
3306#endif //FEATURE_WLAN_DIAG_SUPPORT
3307
3308
3309 if ((psessionEntry->limSmeState != eLIM_SME_NORMAL_STATE) || /* Added For BT -AMP Support */
3310 (psessionEntry->limSystemRole == eLIM_STA_ROLE ))
3311 {
3312 /**
3313 * Should not have received STOP_BSS_REQ in states
3314 * other than 'normal' state or on STA in Infrastructure
3315 * mode. Log error and return response to host.
3316 */
3317 limLog(pMac, LOGE,
3318 FL("received unexpected SME_STOP_BSS_REQ in state %X, for role %d\n"),
3319 psessionEntry->limSmeState, psessionEntry->limSystemRole);
3320 limPrintSmeState(pMac, LOGE, psessionEntry->limSmeState);
3321 /// Send Stop BSS response to host
3322 limSendSmeRsp(pMac, eWNI_SME_STOP_BSS_RSP, eSIR_SME_UNEXPECTED_REQ_RESULT_CODE,smesessionId,smetransactionId);
3323 return;
3324 }
3325
3326#ifdef WLAN_SOFTAP_FEATURE
3327 if (psessionEntry->limSystemRole == eLIM_AP_ROLE )
3328 {
3329 limWPSPBCClose(pMac, psessionEntry);
3330 }
3331#endif
3332 PELOGW(limLog(pMac, LOGW, FL("RECEIVED STOP_BSS_REQ with reason code=%d\n"), stopBssReq.reasonCode);)
3333
3334 prevState = psessionEntry->limSmeState;
3335
3336 psessionEntry->limSmeState = eLIM_SME_IDLE_STATE;
Jeff Johnsone7245742012-09-05 17:12:55 -07003337 MTRACE(macTrace(pMac, TRACE_CODE_SME_STATE, psessionEntry->peSessionId, psessionEntry->limSmeState));
Jeff Johnson295189b2012-06-20 16:38:30 -07003338
3339 /* Update SME session Id and Transaction Id */
3340 psessionEntry->smeSessionId = smesessionId;
3341 psessionEntry->transactionId = smetransactionId;
3342
3343 /* BTAMP_STA and STA_IN_IBSS should NOT send Disassoc frame */
3344 if ( (eLIM_STA_IN_IBSS_ROLE != psessionEntry->limSystemRole) && (eLIM_BT_AMP_STA_ROLE != psessionEntry->limSystemRole) )
3345 {
3346 tSirMacAddr bcAddr = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
3347 if ((stopBssReq.reasonCode == eSIR_SME_MIC_COUNTER_MEASURES))
3348 // Send disassoc all stations associated thru TKIP
3349 __limCounterMeasures(pMac,psessionEntry);
3350 else
3351 limSendDisassocMgmtFrame(pMac, eSIR_MAC_DISASSOC_LEAVING_BSS_REASON, bcAddr,psessionEntry);
3352 }
3353
3354 //limDelBss is also called as part of coalescing, when we send DEL BSS followed by Add Bss msg.
3355 pMac->lim.gLimIbssCoalescingHappened = false;
3356
3357 /* send a delBss to HAL and wait for a response */
3358 status = limDelBss(pMac, NULL,psessionEntry->bssIdx,psessionEntry);
3359
3360 if (status != eSIR_SUCCESS)
3361 {
3362 PELOGE(limLog(pMac, LOGE, FL("delBss failed for bss %d\n"), psessionEntry->bssIdx);)
3363 psessionEntry->limSmeState= prevState;
3364
Jeff Johnsone7245742012-09-05 17:12:55 -07003365 MTRACE(macTrace(pMac, TRACE_CODE_SME_STATE, psessionEntry->peSessionId, psessionEntry->limSmeState));
Jeff Johnson295189b2012-06-20 16:38:30 -07003366
3367 limSendSmeRsp(pMac, eWNI_SME_STOP_BSS_RSP, eSIR_SME_STOP_BSS_FAILURE,smesessionId,smetransactionId);
3368 }
3369}
3370
3371
3372/**--------------------------------------------------------------
3373\fn __limProcessSmeStopBssReq
3374
3375\brief Wrapper for the function __limHandleSmeStopBssRequest
3376 This message will be defered until softmac come out of
3377 scan mode. Message should be handled even if we have
3378 detected radar in the current operating channel.
3379\param pMac
3380\param pMsg
3381
3382\return TRUE - If we consumed the buffer
3383 FALSE - If have defered the message.
3384 ---------------------------------------------------------------*/
3385static tANI_BOOLEAN
3386__limProcessSmeStopBssReq(tpAniSirGlobal pMac, tpSirMsgQ pMsg)
3387{
3388 if (__limIsDeferedMsgForLearn(pMac, pMsg))
3389 {
3390 /**
3391 * If message defered, buffer is not consumed yet.
3392 * So return false
3393 */
3394 return eANI_BOOLEAN_FALSE;
3395 }
3396 __limHandleSmeStopBssRequest(pMac, (tANI_U32 *) pMsg->bodyptr);
3397 return eANI_BOOLEAN_TRUE;
3398} /*** end __limProcessSmeStopBssReq() ***/
3399
3400
3401void limProcessSmeDelBssRsp(
3402 tpAniSirGlobal pMac,
3403 tANI_U32 body,tpPESession psessionEntry)
3404{
3405
3406 (void) body;
3407 SET_LIM_PROCESS_DEFD_MESGS(pMac, true);
3408 //TBD: get the sessionEntry
3409 dphHashTableClassInit(pMac, &psessionEntry->dph.dphHashTable);
3410 limDeletePreAuthList(pMac);
3411 limIbssDelete(pMac,psessionEntry);
3412 limSendSmeRsp(pMac, eWNI_SME_STOP_BSS_RSP, eSIR_SME_SUCCESS,psessionEntry->smeSessionId,psessionEntry->transactionId);
3413 return;
3414}
3415
3416
3417#if 0
3418/**
3419 * __limProcessSmePromiscuousReq()
3420 *
3421 *FUNCTION:
3422 * This function is called to process SME_PROMISCUOUS_REQ message
3423 * from HDD or upper layer application.
3424 *
3425 *LOGIC:
3426 *
3427 *ASSUMPTIONS:
3428 *
3429 *NOTE:
3430 *
3431 * @param pMac Pointer to Global MAC structure
3432 * @param *pMsgBuf A pointer to the SME message buffer
3433 * @return None
3434 */
3435
3436static void
3437__limProcessSmePromiscuousReq(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
3438{
3439
3440 tANI_U32 cfg = sizeof(tSirMacAddr);
3441 tSirMacAddr currentBssId;
3442 tLimMlmDisassocReq *pMlmDisassocReq;
3443 tSirMacAddr bcAddr = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
3444
3445
3446 if(pMsgBuf == NULL)
3447 {
3448 limLog(pMac, LOGE,FL("Buffer is Pointing to NULL\n"));
3449 return;
3450 }
3451
3452 PELOG1(limLog(pMac, LOG1,
3453 FL("received PROMISCUOUS_REQ message\n"));)
3454
3455 if (wlan_cfgGetStr(pMac, WNI_CFG_BSSID, currentBssId, &cfg) !=
3456 eSIR_SUCCESS)
3457 {
3458 /// Could not get BSSID from CFG. Log error.
3459 limLog(pMac, LOGP, FL("could not retrieve BSSID\n"));
3460 }
3461
3462 if ((((pMac->lim.gLimSystemRole == eLIM_STA_ROLE) ||
3463 (pMac->lim.gLimSystemRole == eLIM_STA_IN_IBSS_ROLE)) &&
3464 ((pMac->lim.gLimSmeState == eLIM_SME_ASSOCIATED_STATE) ||
3465 (pMac->lim.gLimSmeState == eLIM_SME_LINK_EST_STATE))) ||
3466 ((pMac->lim.gLimSystemRole == eLIM_AP_ROLE) &&
3467 (pMac->lim.gLimSmeState == eLIM_SME_NORMAL_STATE)))
3468 {
3469 // Trigger Disassociation frame to peer MAC entity
3470 if( eHAL_STATUS_SUCCESS != palAllocateMemory( pMac->hHdd, (void **)&pMlmDisassocReq, sizeof(tLimMlmDisassocReq)))
3471 {
3472 // Log error
3473 limLog(pMac, LOGP,
3474 FL("call to palAllocateMemory failed for mlmDisassocReq\n"));
3475
3476 return;
3477 }
3478
3479 if (pMac->lim.gLimSystemRole == eLIM_AP_ROLE)
3480 palCopyMemory( pMac->hHdd, (tANI_U8 *) &pMlmDisassocReq->peerMacAddr,
3481 (tANI_U8 *) &bcAddr,
3482 sizeof(tSirMacAddr));
3483 else
3484 palCopyMemory( pMac->hHdd, pMlmDisassocReq->peerMacAddr,
3485 currentBssId,
3486 sizeof(tSirMacAddr));
3487
3488 pMlmDisassocReq->reasonCode =
3489 eSIR_MAC_DISASSOC_LEAVING_BSS_REASON;
3490 pMlmDisassocReq->disassocTrigger =
3491 eLIM_PROMISCUOUS_MODE_DISASSOC;
3492
3493 pMac->lim.gLimPrevSmeState = pMac->lim.gLimSmeState;
3494 pMac->lim.gLimSmeState = eLIM_SME_WT_DISASSOC_STATE;
3495 MTRACE(macTrace(pMac, TRACE_CODE_SME_STATE, 0, pMac->lim.gLimSmeState));
3496
3497 limPostMlmMessage(pMac,
3498 LIM_MLM_DISASSOC_REQ,
3499 (tANI_U32 *) pMlmDisassocReq);
3500 }
3501 else
3502 {
3503 // Send Promiscuous mode response to host
3504 limSendSmePromiscuousModeRsp(pMac);
3505
3506 pMac->lim.gLimSmeState = eLIM_SME_OFFLINE_STATE;
3507 MTRACE(macTrace(pMac, TRACE_CODE_SME_STATE, 0, pMac->lim.gLimSmeState));
3508 }
3509
3510} /*** end __limProcessSmePromiscuousReq() ***/
3511#endif
3512
3513
3514/**---------------------------------------------------------------
3515\fn __limProcessSmeAssocCnfNew
3516\brief This function handles SME_ASSOC_CNF/SME_REASSOC_CNF
3517\ in BTAMP AP.
3518\
3519\param pMac
3520\param msgType - message type
3521\param pMsgBuf - a pointer to the SME message buffer
3522\return None
3523------------------------------------------------------------------*/
3524
3525 void
3526__limProcessSmeAssocCnfNew(tpAniSirGlobal pMac, tANI_U32 msgType, tANI_U32 *pMsgBuf)
3527{
3528 tSirSmeAssocCnf assocCnf;
3529 tpDphHashNode pStaDs = NULL;
3530 tpPESession psessionEntry= NULL;
3531 tANI_U8 sessionId;
3532
3533
3534 if(pMsgBuf == NULL)
3535 {
3536 limLog(pMac, LOGE, FL("pMsgBuf is NULL \n"));
3537 goto end;
3538 }
3539
3540 if ((limAssocCnfSerDes(pMac, &assocCnf, (tANI_U8 *) pMsgBuf) == eSIR_FAILURE) ||
3541 !__limIsSmeAssocCnfValid(&assocCnf))
3542 {
3543 limLog(pMac, LOGE, FL("Received invalid SME_RE(ASSOC)_CNF message \n"));
3544 goto end;
3545 }
3546
3547 if((psessionEntry = peFindSessionByBssid(pMac, assocCnf.bssId, &sessionId))== NULL)
3548 {
3549 limLog(pMac, LOGE, FL("session does not exist for given bssId\n"));
3550 goto end;
3551 }
3552
3553 if ( ((psessionEntry->limSystemRole != eLIM_AP_ROLE) && (psessionEntry->limSystemRole != eLIM_BT_AMP_AP_ROLE)) ||
3554 ((psessionEntry->limSmeState != eLIM_SME_NORMAL_STATE) && (psessionEntry->limSmeState != eLIM_SME_NORMAL_CHANNEL_SCAN_STATE)))
3555 {
3556 limLog(pMac, LOGE, FL("Received unexpected message %X in state %X, in role %X\n"),
3557 msgType, psessionEntry->limSmeState , psessionEntry->limSystemRole);
3558 goto end;
3559 }
3560
3561 pStaDs = dphGetHashEntry(pMac, assocCnf.aid, &psessionEntry->dph.dphHashTable);
3562
3563 if (pStaDs == NULL)
3564 {
3565 limLog(pMac, LOG1,
3566 FL("Received invalid message %X due to no STA context, for aid %d, peer "),
3567 msgType, assocCnf.aid);
3568 limPrintMacAddr(pMac, assocCnf.peerMacAddr, LOG1);
3569
3570 /*
3571 ** send a DISASSOC_IND message to WSM to make sure
3572 ** the state in WSM and LIM is the same
3573 **/
3574 limSendSmeDisassocNtf( pMac, assocCnf.peerMacAddr, eSIR_SME_STA_NOT_ASSOCIATED,
3575 eLIM_PEER_ENTITY_DISASSOC, assocCnf.aid,psessionEntry->smeSessionId,psessionEntry->transactionId,psessionEntry);
3576 goto end;
3577 }
3578 if ((pStaDs &&
3579 (( !palEqualMemory( pMac->hHdd,(tANI_U8 *) pStaDs->staAddr,
3580 (tANI_U8 *) assocCnf.peerMacAddr,
3581 sizeof(tSirMacAddr)) ) ||
3582 (pStaDs->mlmStaContext.mlmState != eLIM_MLM_WT_ASSOC_CNF_STATE) ||
3583 ((pStaDs->mlmStaContext.subType == LIM_ASSOC) &&
3584 (msgType != eWNI_SME_ASSOC_CNF)) ||
3585 ((pStaDs->mlmStaContext.subType == LIM_REASSOC) &&
3586#ifdef WLAN_SOFTAP_FEATURE
3587 (msgType != eWNI_SME_ASSOC_CNF))))) // since softap is passing this as ASSOC_CNF and subtype differs
3588#else
3589 (msgType != eWNI_SME_REASSOC_CNF)))))
3590#endif
3591 {
3592 limLog(pMac, LOG1,
3593 FL("Received invalid message %X due to peerMacAddr mismatched or not in eLIM_MLM_WT_ASSOC_CNF_STATE state, for aid %d, peer "),
3594 msgType, assocCnf.aid);
3595 limPrintMacAddr(pMac, assocCnf.peerMacAddr, LOG1);
3596 goto end;
3597 }
3598
3599 /*
3600 ** Deactivate/delet CNF_WAIT timer since ASSOC_CNF
3601 ** has been received
3602 **/
3603 limLog(pMac, LOG1, FL("Received SME_ASSOC_CNF. Delete Timer\n"));
3604 limDeactivateAndChangePerStaIdTimer(pMac, eLIM_CNF_WAIT_TIMER, pStaDs->assocId);
3605
3606 if (assocCnf.statusCode == eSIR_SME_SUCCESS)
3607 {
3608 /* In BTAMP-AP, PE already finished the WDA_ADD_STA sequence
3609 * when it had received Assoc Request frame. Now, PE just needs to send
3610 * Association Response frame to the requesting BTAMP-STA.
3611 */
3612 pStaDs->mlmStaContext.mlmState = eLIM_MLM_LINK_ESTABLISHED_STATE;
3613 limLog(pMac, LOG1, FL("sending Assoc Rsp frame to STA (assoc id=%d) \n"), pStaDs->assocId);
3614 limSendAssocRspMgmtFrame( pMac, eSIR_SUCCESS, pStaDs->assocId, pStaDs->staAddr,
3615 pStaDs->mlmStaContext.subType, pStaDs, psessionEntry);
3616 goto end;
3617 } // (assocCnf.statusCode == eSIR_SME_SUCCESS)
3618 else
3619 {
3620 // SME_ASSOC_CNF status is non-success, so STA is not allowed to be associated
3621 /*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*/
3622 if(!pStaDs->mlmStaContext.updateContext)
3623 pStaDs->mlmStaContext.updateContext = 1;
3624 limRejectAssociation(pMac, pStaDs->staAddr,
3625 pStaDs->mlmStaContext.subType,
3626 true, pStaDs->mlmStaContext.authType,
3627 pStaDs->assocId, true,
3628 eSIR_MAC_UNSPEC_FAILURE_STATUS, psessionEntry);
3629 return;
3630 }
3631
3632end:
3633 if((psessionEntry != NULL) && (pStaDs != NULL))
3634 {
3635 if ( psessionEntry->parsedAssocReq[pStaDs->assocId] != NULL )
3636 {
3637 if ( ((tpSirAssocReq)(psessionEntry->parsedAssocReq[pStaDs->assocId]))->assocReqFrame)
3638 {
3639 palFreeMemory(pMac->hHdd,((tpSirAssocReq)(psessionEntry->parsedAssocReq[pStaDs->assocId]))->assocReqFrame);
3640 ((tpSirAssocReq)(psessionEntry->parsedAssocReq[pStaDs->assocId]))->assocReqFrame = NULL;
3641 }
3642
3643 palFreeMemory(pMac->hHdd, psessionEntry->parsedAssocReq[pStaDs->assocId]);
3644 psessionEntry->parsedAssocReq[pStaDs->assocId] = NULL;
3645 }
3646 }
3647
3648} /*** end __limProcessSmeAssocCnfNew() ***/
3649
3650
3651#ifdef ANI_PRODUCT_TYPE_AP
3652/**
3653 * __limProcessSmeAssocCnf()
3654 *
3655 *FUNCTION:
3656 * This function is called by limProcessSmeMessages() upon
3657 * receiving SME_ASSOC_CNF/SME_REASSOC_CNF from WSM.
3658 *
3659 *LOGIC:
3660 *
3661 *ASSUMPTIONS:
3662 *
3663 *NOTE:
3664 *
3665 * @param pMac Pointer to Global MAC structure
3666 * @param *pMsgBuf A pointer to the SME message buffer
3667 *
3668 * @return None
3669 */
3670
3671static void
3672__limProcessSmeAssocCnf(tpAniSirGlobal pMac, tANI_U32 msgType, tANI_U32 *pMsgBuf)
3673{
3674 tSirSmeAssocCnf assocCnf;
3675 tpDphHashNode pStaDs;
3676 tpPESession psessionEntry;
3677 tANI_U8 sessionId;
3678 tHalBitVal cbBitVal;
3679 tANI_U8 tspecIdx = 0; //index in the lim tspec table.
3680
3681 if(pMsgBuf == NULL)
3682 {
3683 limLog(pMac, LOGE,FL("Buffer is Pointing to NULL\n"));
3684 return;
3685 }
3686
3687 if ((limAssocCnfSerDes(pMac, &assocCnf, (tANI_U8 *) pMsgBuf) ==
3688 eSIR_FAILURE) ||
3689 !__limIsSmeAssocCnfValid(&assocCnf))
3690 {
3691 limLog(pMac, LOGW,
3692 FL("Received re/assocCnf message with invalid parameters\n"));
3693
3694 return;
3695 }
3696
3697 if((psessionEntry = peFindSessionByBssid(pMac,assocCnf->bssId,&sessionId))== NULL)
3698 {
3699
3700 limLog(pMac, LOGE,
3701 FL("session does not exist for given bssId\n"));
3702 return;
3703 }
3704
3705#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM //FEATURE_WLAN_DIAG_SUPPORT
3706 limDiagEventReport(pMac, WLAN_PE_DIAG_ASSOC_CNF_EVENT, psessionEntry, 0, 0);
3707#endif //FEATURE_WLAN_DIAG_SUPPORT
3708
3709 if ( ((psessionEntry->limSystemRole != eLIM_AP_ROLE) && (psessionEntry->limSystemRole != eLIM_BT_AMP_AP_ROLE)) ||
3710 ((psessionEntry->limSmeState != eLIM_SME_NORMAL_STATE) && (psessionEntry->limSmeState != eLIM_SME_NORMAL_CHANNEL_SCAN_STATE)))
3711 {
3712 limLog(pMac, LOGE,
3713 FL("Received unexpected message %X in state %X, in role %X\n"),
3714 msgType, psessionEntry->limSmeState , psessionEntry->limSystemRole);
3715
3716 return;
3717 }
3718
3719 pStaDs = dphGetHashEntry(pMac, assocCnf.aid, &psessionEntry->dph.dphHashTable);
3720
3721
3722 if (pStaDs == NULL)
3723 {
3724
3725 PELOG1(limLog(pMac, LOG1,
3726 FL("Received invalid message %X due to no STA context, for aid %d, peer "),
3727 msgType, assocCnf.aid);
3728 limPrintMacAddr(pMac, assocCnf.peerMacAddr, LOG1);)
3729
3730 /*
3731 ** send a DISASSOC_IND message to WSM to make sure
3732 ** the state in WSM and LIM is the same
3733 **/
3734
3735 limSendSmeDisassocNtf(pMac,
3736 assocCnf.peerMacAddr,
3737 eSIR_SME_STA_NOT_ASSOCIATED,
3738 eLIM_PEER_ENTITY_DISASSOC,
3739 assocCnf.aid,psessionEntry);
3740
3741 return;
3742 }
3743 if ((pStaDs &&
3744 (( !palEqualMemory( pMac->hHdd,(tANI_U8 *) pStaDs->staAddr,
3745 (tANI_U8 *) assocCnf.peerMacAddr,
3746 sizeof(tSirMacAddr)) ) ||
3747 (pStaDs->mlmStaContext.mlmState !=
3748 eLIM_MLM_WT_ASSOC_CNF_STATE) ||
3749 ((pStaDs->mlmStaContext.subType == LIM_ASSOC) &&
3750 (msgType != eWNI_SME_ASSOC_CNF)) ||
3751 ((pStaDs->mlmStaContext.subType == LIM_REASSOC) &&
3752 (msgType != eWNI_SME_REASSOC_CNF)))))
3753 {
3754 PELOG1(limLog(pMac, LOG1,
3755 FL("Received invalid message %X due to peerMacAddr mismatched or not in eLIM_MLM_WT_ASSOC_CNF_STATE state, for aid %d, peer "),
3756 msgType, assocCnf.aid);
3757 limPrintMacAddr(pMac, assocCnf.peerMacAddr, LOG1);)
3758
3759 return;
3760 }
3761
3762 /*
3763 ** Deactivate/delet CNF_WAIT timer since ASSOC_CNF
3764 ** has been received
3765 **/
3766
3767 PELOG1(limLog(pMac, LOG1, FL("Received Cnf. Delete Timer\n"));)
3768 limDeactivateAndChangePerStaIdTimer(pMac, eLIM_CNF_WAIT_TIMER,
3769 pStaDs->assocId);
3770
3771 if (assocCnf.statusCode == eSIR_SME_SUCCESS)
3772 {
3773 tSirMacScheduleIE schedule;
3774
3775 // If STA is a TITAN-compatible device, then setup
3776 // the TITAN proprietary capabilities appropriately
3777 // in the per STA DS, as per the local TITAN Prop
3778 // capabilities of this AP
3779
3780 // STA is allowed to be associated
3781 if (pStaDs->mlmStaContext.updateContext)
3782 {
3783
3784 tLimMlmStates mlmPrevState = pStaDs->mlmStaContext.mlmState;
3785 //we need to set the mlmState here in order differentiate in limDelSta.
3786 pStaDs->mlmStaContext.mlmState = eLIM_MLM_WT_ASSOC_DEL_STA_RSP_STATE;
3787 if(limDelSta(pMac, pStaDs, true,psessionEntry) != eSIR_SUCCESS)
3788 {
3789 limLog(pMac, LOGE,
3790 FL("could not DEL STA with assocId=%d staId %d\n"),
3791 pStaDs->assocId, pStaDs->staIndex);
3792
3793 limRejectAssociation(pMac,
3794 pStaDs->staAddr,
3795 pStaDs->mlmStaContext.subType,
3796 true, pStaDs->mlmStaContext.authType,
3797 pStaDs->assocId, true,
3798 (tSirResultCodes) eSIR_MAC_UNSPEC_FAILURE_STATUS,
3799 psessionEntry);
3800
3801 //Restoring the state back.
3802 pStaDs->mlmStaContext.mlmState = mlmPrevState;
3803 return;
3804 }
3805 return;
3806 }
3807 else
3808 {
3809 // Add STA context at HW
3810 if (limAddSta(pMac, pStaDs,psessionEntry) != eSIR_SUCCESS)
3811 {
3812 limLog(pMac, LOGE,
3813 FL("could not Add STA with assocId=%d\n"),
3814 pStaDs->assocId);
3815
3816 // delete the TS if it has already been added.
3817 // send the response with error status.
3818 if(pStaDs->qos.addtsPresent)
3819 {
3820 limAdmitControlDeleteTS(pMac, pStaDs->assocId, &pStaDs->qos.addts.tspec.tsinfo, NULL, &tspecIdx);
3821 }
3822
3823 limRejectAssociation(pMac,
3824 pStaDs->staAddr,
3825 pStaDs->mlmStaContext.subType,
3826 true, pStaDs->mlmStaContext.authType,
3827 pStaDs->assocId, true,
3828 (tSirResultCodes) eSIR_MAC_UNSPEC_FAILURE_STATUS,
3829 psessionEntry);
3830
3831 }
3832 return;
3833 }
3834
3835 } // if (assocCnf.statusCode == eSIR_SME_SUCCESS)
3836 else
3837 {
3838 // STA is not allowed to be associated
3839 limRejectAssociation(pMac, pStaDs->staAddr,
3840 pStaDs->mlmStaContext.subType,
3841 true, pStaDs->mlmStaContext.authType,
3842 pStaDs->assocId, true,
3843 assocCnf.statusCode, psessionEntry);
3844 }
3845} /*** end __limProcessSmeAssocCnf() ***/
3846#endif
3847
3848
3849static void
3850__limProcessSmeAddtsReq(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
3851{
3852 tpDphHashNode pStaDs;
3853 tSirMacAddr peerMac;
3854 tpSirAddtsReq pSirAddts;
3855 tANI_U32 timeout;
3856 tpPESession psessionEntry;
3857 tANI_U8 sessionId; //PE sessionId
3858 tANI_U8 smesessionId;
3859 tANI_U16 smetransactionId;
3860
3861
3862 if(pMsgBuf == NULL)
3863 {
3864 limLog(pMac, LOGE,FL("Buffer is Pointing to NULL\n"));
3865 return;
3866 }
3867
3868 limGetSessionInfo(pMac,(tANI_U8 *)pMsgBuf,&smesessionId,&smetransactionId);
3869
3870 pSirAddts = (tpSirAddtsReq) pMsgBuf;
3871
3872 if((psessionEntry = peFindSessionByBssid(pMac, pSirAddts->bssId,&sessionId))== NULL)
3873 {
3874 limLog(pMac, LOGE, "Session Does not exist for given bssId\n");
3875 return;
3876 }
3877#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM //FEATURE_WLAN_DIAG_SUPPORT
3878 limDiagEventReport(pMac, WLAN_PE_DIAG_ADDTS_REQ_EVENT, psessionEntry, 0, 0);
3879#endif //FEATURE_WLAN_DIAG_SUPPORT
3880
3881
3882
3883 /* if sta
3884 * - verify assoc state
3885 * - send addts request to ap
3886 * - wait for addts response from ap
3887 * if ap, just ignore with error log
3888 */
3889 PELOG1(limLog(pMac, LOG1,
3890 FL("Received SME_ADDTS_REQ (TSid %d, UP %d)\n"),
3891 pSirAddts->req.tspec.tsinfo.traffic.tsid,
3892 pSirAddts->req.tspec.tsinfo.traffic.userPrio);)
3893
3894 if ((psessionEntry->limSystemRole != eLIM_STA_ROLE)&&(psessionEntry->limSystemRole != eLIM_BT_AMP_STA_ROLE))
3895 {
3896 PELOGE(limLog(pMac, LOGE, "AddTs received on AP - ignoring\n");)
3897 limSendSmeAddtsRsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE, psessionEntry, pSirAddts->req.tspec,
3898 smesessionId,smetransactionId);
3899 return;
3900 }
3901
3902 //Ignore the request if STA is in 11B mode.
3903 if(psessionEntry->dot11mode == WNI_CFG_DOT11_MODE_11B)
3904 {
3905 PELOGE(limLog(pMac, LOGE, "AddTS received while Dot11Mode is 11B - ignoring\n");)
3906 limSendSmeAddtsRsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE, psessionEntry, pSirAddts->req.tspec,
3907 smesessionId,smetransactionId);
3908 return;
3909 }
3910
3911
3912 pStaDs = dphGetHashEntry(pMac, DPH_STA_HASH_INDEX_PEER, &psessionEntry->dph.dphHashTable);
3913
3914 if(pStaDs == NULL)
3915 {
3916 PELOGE(limLog(pMac, LOGE, "Cannot find AP context for addts req\n");)
3917 limSendSmeAddtsRsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE, psessionEntry, pSirAddts->req.tspec,
3918 smesessionId,smetransactionId);
3919 return;
3920 }
3921
3922 if ((! pStaDs->valid) ||
3923 (pStaDs->mlmStaContext.mlmState != eLIM_MLM_LINK_ESTABLISHED_STATE))
3924 {
3925 PELOGE(limLog(pMac, LOGE, "AddTs received in invalid MLM state\n");)
3926 limSendSmeAddtsRsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE, psessionEntry, pSirAddts->req.tspec,
3927 smesessionId,smetransactionId);
3928 return;
3929 }
3930
3931 pSirAddts->req.wsmTspecPresent = 0;
3932 pSirAddts->req.wmeTspecPresent = 0;
3933 pSirAddts->req.lleTspecPresent = 0;
3934
3935 if ((pStaDs->wsmEnabled) &&
3936 (pSirAddts->req.tspec.tsinfo.traffic.accessPolicy != SIR_MAC_ACCESSPOLICY_EDCA))
3937 pSirAddts->req.wsmTspecPresent = 1;
3938 else if (pStaDs->wmeEnabled)
3939 pSirAddts->req.wmeTspecPresent = 1;
3940 else if (pStaDs->lleEnabled)
3941 pSirAddts->req.lleTspecPresent = 1;
3942 else
3943 {
3944 PELOGW(limLog(pMac, LOGW, FL("ADDTS_REQ ignore - qos is disabled\n"));)
3945 limSendSmeAddtsRsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE, psessionEntry, pSirAddts->req.tspec,
3946 smesessionId,smetransactionId);
3947 return;
3948 }
3949
3950 if ((psessionEntry->limSmeState != eLIM_SME_ASSOCIATED_STATE) &&
3951 (psessionEntry->limSmeState != eLIM_SME_LINK_EST_STATE))
3952 {
3953 limLog(pMac, LOGE, "AddTs received in invalid LIMsme state (%d)\n",
3954 psessionEntry->limSmeState);
3955 limSendSmeAddtsRsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE, psessionEntry, pSirAddts->req.tspec,
3956 smesessionId,smetransactionId);
3957 return;
3958 }
3959
3960 if (pMac->lim.gLimAddtsSent)
3961 {
3962 limLog(pMac, LOGE, "Addts (token %d, tsid %d, up %d) is still pending\n",
3963 pMac->lim.gLimAddtsReq.req.dialogToken,
3964 pMac->lim.gLimAddtsReq.req.tspec.tsinfo.traffic.tsid,
3965 pMac->lim.gLimAddtsReq.req.tspec.tsinfo.traffic.userPrio);
3966 limSendSmeAddtsRsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE, psessionEntry, pSirAddts->req.tspec,
3967 smesessionId,smetransactionId);
3968 return;
3969 }
3970
3971 #if 0
3972 val = sizeof(tSirMacAddr);
3973 if (wlan_cfgGetStr(pMac, WNI_CFG_BSSID, peerMac, &val) != eSIR_SUCCESS)
3974 {
3975 /// Could not get BSSID from CFG. Log error.
3976 limLog(pMac, LOGP, FL("could not retrieve BSSID\n"));
3977 return;
3978 }
3979 #endif
3980 sirCopyMacAddr(peerMac,psessionEntry->bssId);
3981
3982 // save the addts request
3983 pMac->lim.gLimAddtsSent = true;
3984 palCopyMemory( pMac->hHdd, (tANI_U8 *) &pMac->lim.gLimAddtsReq, (tANI_U8 *) pSirAddts, sizeof(tSirAddtsReq));
3985
3986 // ship out the message now
3987 limSendAddtsReqActionFrame(pMac, peerMac, &pSirAddts->req,
3988 psessionEntry);
3989 PELOG1(limLog(pMac, LOG1, "Sent ADDTS request\n");)
3990
3991 // start a timer to wait for the response
3992 if (pSirAddts->timeout)
3993 timeout = pSirAddts->timeout;
3994 else if (wlan_cfgGetInt(pMac, WNI_CFG_ADDTS_RSP_TIMEOUT, &timeout) != eSIR_SUCCESS)
3995 {
3996 limLog(pMac, LOGP, FL("Unable to get Cfg param %d (Addts Rsp Timeout)\n"),
3997 WNI_CFG_ADDTS_RSP_TIMEOUT);
3998 return;
3999 }
4000
4001 timeout = SYS_MS_TO_TICKS(timeout);
4002 if (tx_timer_change(&pMac->lim.limTimers.gLimAddtsRspTimer, timeout, 0) != TX_SUCCESS)
4003 {
4004 limLog(pMac, LOGP, FL("AddtsRsp timer change failed!\n"));
4005 return;
4006 }
4007 pMac->lim.gLimAddtsRspTimerCount++;
4008 if (tx_timer_change_context(&pMac->lim.limTimers.gLimAddtsRspTimer,
4009 pMac->lim.gLimAddtsRspTimerCount) != TX_SUCCESS)
4010 {
4011 limLog(pMac, LOGP, FL("AddtsRsp timer change failed!\n"));
4012 return;
4013 }
Jeff Johnsone7245742012-09-05 17:12:55 -07004014 MTRACE(macTrace(pMac, TRACE_CODE_TIMER_ACTIVATE, psessionEntry->peSessionId, eLIM_ADDTS_RSP_TIMER));
Jeff Johnson295189b2012-06-20 16:38:30 -07004015
4016 //add the sessionId to the timer object
4017 pMac->lim.limTimers.gLimAddtsRspTimer.sessionId = sessionId;
4018 if (tx_timer_activate(&pMac->lim.limTimers.gLimAddtsRspTimer) != TX_SUCCESS)
4019 {
4020 limLog(pMac, LOGP, FL("AddtsRsp timer activation failed!\n"));
4021 return;
4022 }
4023 return;
4024}
4025
4026
4027static void
4028__limProcessSmeDeltsReq(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
4029{
4030 tSirMacAddr peerMacAddr;
4031 tANI_U8 ac;
4032 tSirMacTSInfo *pTsinfo;
4033 tpSirDeltsReq pDeltsReq = (tpSirDeltsReq) pMsgBuf;
4034 tpDphHashNode pStaDs = NULL;
4035 tpPESession psessionEntry;
4036 tANI_U8 sessionId;
4037 tANI_U32 status = eSIR_SUCCESS;
4038 tANI_U8 smesessionId;
4039 tANI_U16 smetransactionId;
4040
4041 limGetSessionInfo(pMac,(tANI_U8 *)pMsgBuf,&smesessionId,&smetransactionId);
4042
4043 if((psessionEntry = peFindSessionByBssid(pMac, pDeltsReq->bssId, &sessionId))== NULL)
4044 {
4045 limLog(pMac, LOGE, "Session Does not exist for given bssId\n");
4046 status = eSIR_FAILURE;
4047 goto end;
4048 }
4049#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM //FEATURE_WLAN_DIAG_SUPPORT
4050 limDiagEventReport(pMac, WLAN_PE_DIAG_DELTS_REQ_EVENT, psessionEntry, 0, 0);
4051#endif //FEATURE_WLAN_DIAG_SUPPORT
4052
4053
4054 if (eSIR_SUCCESS != limValidateDeltsReq(pMac, pDeltsReq, peerMacAddr,psessionEntry))
4055 {
4056 PELOGE(limLog(pMac, LOGE, FL("limValidateDeltsReq failed\n"));)
4057 status = eSIR_FAILURE;
4058 limSendSmeDeltsRsp(pMac, pDeltsReq, eSIR_FAILURE,psessionEntry,smesessionId,smetransactionId);
4059 return;
4060 }
4061
4062 PELOG1(limLog(pMac, LOG1, FL("Sent DELTS request to station with assocId = %d MacAddr = %x:%x:%x:%x:%x:%x\n"),
4063 pDeltsReq->aid, peerMacAddr[0], peerMacAddr[1], peerMacAddr[2],
4064 peerMacAddr[3], peerMacAddr[4], peerMacAddr[5]);)
4065
4066 limSendDeltsReqActionFrame(pMac, peerMacAddr, pDeltsReq->req.wmeTspecPresent, &pDeltsReq->req.tsinfo, &pDeltsReq->req.tspec,
4067 psessionEntry);
4068
4069 pTsinfo = pDeltsReq->req.wmeTspecPresent ? &pDeltsReq->req.tspec.tsinfo : &pDeltsReq->req.tsinfo;
4070
4071 /* We've successfully send DELTS frame to AP. Update the
4072 * dynamic UAPSD mask. The AC for this TSPEC to be deleted
4073 * is no longer trigger enabled or delivery enabled
4074 */
4075 limSetTspecUapsdMask(pMac, pTsinfo, CLEAR_UAPSD_MASK);
4076
4077 /* We're deleting the TSPEC, so this particular AC is no longer
4078 * admitted. PE needs to downgrade the EDCA
4079 * parameters(for the AC for which TS is being deleted) to the
4080 * next best AC for which ACM is not enabled, and send the
4081 * updated values to HAL.
4082 */
4083 ac = upToAc(pTsinfo->traffic.userPrio);
4084
4085 if(pTsinfo->traffic.direction == SIR_MAC_DIRECTION_UPLINK)
4086 {
4087 pMac->lim.gAcAdmitMask[SIR_MAC_DIRECTION_UPLINK] &= ~(1 << ac);
4088 }
4089 else if(pTsinfo->traffic.direction == SIR_MAC_DIRECTION_DNLINK)
4090 {
4091 pMac->lim.gAcAdmitMask[SIR_MAC_DIRECTION_DNLINK] &= ~(1 << ac);
4092 }
4093 else if(pTsinfo->traffic.direction == SIR_MAC_DIRECTION_BIDIR)
4094 {
4095 pMac->lim.gAcAdmitMask[SIR_MAC_DIRECTION_UPLINK] &= ~(1 << ac);
4096 pMac->lim.gAcAdmitMask[SIR_MAC_DIRECTION_DNLINK] &= ~(1 << ac);
4097 }
4098
4099 limSetActiveEdcaParams(pMac, psessionEntry->gLimEdcaParams, psessionEntry);
4100
4101 pStaDs = dphGetHashEntry(pMac, DPH_STA_HASH_INDEX_PEER, &psessionEntry->dph.dphHashTable);
4102 if (pStaDs != NULL)
4103 {
4104 if (pStaDs->aniPeer == eANI_BOOLEAN_TRUE)
4105 limSendEdcaParams(pMac, psessionEntry->gLimEdcaParamsActive, pStaDs->bssId, eANI_BOOLEAN_TRUE);
4106 else
4107 limSendEdcaParams(pMac, psessionEntry->gLimEdcaParamsActive, pStaDs->bssId, eANI_BOOLEAN_FALSE);
4108 status = eSIR_SUCCESS;
4109 }
4110 else
4111 {
4112 limLog(pMac, LOGE, FL("Self entry missing in Hash Table \n"));
4113 status = eSIR_FAILURE;
4114 }
4115#ifdef FEATURE_WLAN_CCX
4116 limDeactivateAndChangeTimer(pMac,eLIM_TSM_TIMER);
4117#endif
4118
4119 // send an sme response back
4120 end:
4121 limSendSmeDeltsRsp(pMac, pDeltsReq, eSIR_SUCCESS,psessionEntry,smesessionId,smetransactionId);
4122}
4123
4124
4125void
4126limProcessSmeAddtsRspTimeout(tpAniSirGlobal pMac, tANI_U32 param)
4127{
4128 //fetch the sessionEntry based on the sessionId
4129 tpPESession psessionEntry;
4130 if((psessionEntry = peFindSessionBySessionId(pMac, pMac->lim.limTimers.gLimAddtsRspTimer.sessionId))== NULL)
4131 {
4132 limLog(pMac, LOGP,FL("Session Does not exist for given sessionID\n"));
4133 return;
4134 }
4135
4136 if ( (psessionEntry->limSystemRole != eLIM_STA_ROLE) && (psessionEntry->limSystemRole != eLIM_BT_AMP_STA_ROLE) )
4137 {
4138 limLog(pMac, LOGW, "AddtsRspTimeout in non-Sta role (%d)\n", psessionEntry->limSystemRole);
4139 pMac->lim.gLimAddtsSent = false;
4140 return;
4141 }
4142
4143 if (! pMac->lim.gLimAddtsSent)
4144 {
4145 PELOGW(limLog(pMac, LOGW, "AddtsRspTimeout but no AddtsSent\n");)
4146 return;
4147 }
4148
4149 if (param != pMac->lim.gLimAddtsRspTimerCount)
4150 {
4151 limLog(pMac, LOGE, FL("Invalid AddtsRsp Timer count %d (exp %d)\n"),
4152 param, pMac->lim.gLimAddtsRspTimerCount);
4153 return;
4154 }
4155
4156 // this a real response timeout
4157 pMac->lim.gLimAddtsSent = false;
4158 pMac->lim.gLimAddtsRspTimerCount++;
4159
4160 limSendSmeAddtsRsp(pMac, true, eSIR_SME_ADDTS_RSP_TIMEOUT, psessionEntry, pMac->lim.gLimAddtsReq.req.tspec,
4161 psessionEntry->smeSessionId, psessionEntry->transactionId);
4162}
4163
4164
4165/**
4166 * __limProcessSmeStatsRequest()
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__limProcessSmeStatsRequest(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
4179{
4180 tpAniGetStatsReq pStatsReq;
4181 tSirMsgQ msgQ;
4182 tpPESession psessionEntry;
4183 tANI_U8 sessionId;
4184
4185
4186 if(pMsgBuf == NULL)
4187 {
4188 limLog(pMac, LOGE,FL("Buffer is Pointing to NULL\n"));
4189 return;
4190 }
4191
4192 pStatsReq = (tpAniGetStatsReq) pMsgBuf;
4193
4194 if((psessionEntry = peFindSessionByBssid(pMac,pStatsReq->bssId,&sessionId))== NULL)
4195 {
4196 limLog(pMac, LOGE, FL("session does not exist for given bssId\n"));
Jeff Johnsone7245742012-09-05 17:12:55 -07004197 palFreeMemory( pMac, pMsgBuf );
Jeff Johnson295189b2012-06-20 16:38:30 -07004198 return;
4199 }
4200
4201
4202
4203 switch(pStatsReq->msgType)
4204 {
4205 //Add Lim stats here. and send reqsponse.
4206
4207 //HAL maintained Stats.
4208 case eWNI_SME_STA_STAT_REQ:
4209 msgQ.type = WDA_STA_STAT_REQ;
4210 break;
4211 case eWNI_SME_AGGR_STAT_REQ:
4212 msgQ.type = WDA_AGGR_STAT_REQ;
4213 break;
4214 case eWNI_SME_GLOBAL_STAT_REQ:
4215 msgQ.type = WDA_GLOBAL_STAT_REQ;
4216 break;
4217 case eWNI_SME_STAT_SUMM_REQ:
4218 msgQ.type = WDA_STAT_SUMM_REQ;
4219 break;
4220 default: //Unknown request.
4221 PELOGE(limLog(pMac, LOGE, "Unknown Statistics request\n");)
4222 palFreeMemory( pMac, pMsgBuf );
4223 return;
4224 }
4225
4226 if ( !pMac->lim.gLimRspReqd )
4227 {
4228 palFreeMemory( pMac, pMsgBuf );
4229 return;
4230 }
4231 else
4232 {
4233 pMac->lim.gLimRspReqd = FALSE;
4234 }
4235
4236 msgQ.reserved = 0;
4237 msgQ.bodyptr = pMsgBuf;
4238 msgQ.bodyval = 0;
Jeff Johnsone7245742012-09-05 17:12:55 -07004239 MTRACE(macTraceMsgTx(pMac, psessionEntry->peSessionId, msgQ.type));
Jeff Johnson295189b2012-06-20 16:38:30 -07004240
4241 if( eSIR_SUCCESS != (wdaPostCtrlMsg( pMac, &msgQ ))){
4242 limLog(pMac, LOGP, "Unable to forward request\n");
Jeff Johnsone7245742012-09-05 17:12:55 -07004243 palFreeMemory( pMac, pMsgBuf );
Jeff Johnson295189b2012-06-20 16:38:30 -07004244 return;
4245 }
4246
4247 return;
4248}
4249
4250
4251/**
4252 * __limProcessSmeGetStatisticsRequest()
4253 *
4254 *FUNCTION:
4255 *
4256 *
4257 *NOTE:
4258 *
4259 * @param pMac Pointer to Global MAC structure
4260 * @param *pMsgBuf A pointer to the SME message buffer
4261 * @return None
4262 */
4263static void
4264__limProcessSmeGetStatisticsRequest(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
4265{
4266 tpAniGetPEStatsReq pPEStatsReq;
4267 tSirMsgQ msgQ;
4268
4269 pPEStatsReq = (tpAniGetPEStatsReq) pMsgBuf;
4270
4271 //pPEStatsReq->msgType should be eWNI_SME_GET_STATISTICS_REQ
4272
4273 msgQ.type = WDA_GET_STATISTICS_REQ;
4274
4275 if ( !pMac->lim.gLimRspReqd )
4276 {
4277 palFreeMemory( pMac, pMsgBuf );
4278 return;
4279 }
4280 else
4281 {
4282 pMac->lim.gLimRspReqd = FALSE;
4283 }
4284
4285 msgQ.reserved = 0;
4286 msgQ.bodyptr = pMsgBuf;
4287 msgQ.bodyval = 0;
Jeff Johnsone7245742012-09-05 17:12:55 -07004288 MTRACE(macTraceMsgTx(pMac, NO_SESSION, msgQ.type));
Jeff Johnson295189b2012-06-20 16:38:30 -07004289
4290 if( eSIR_SUCCESS != (wdaPostCtrlMsg( pMac, &msgQ ))){
4291 palFreeMemory( pMac, pMsgBuf );
4292 limLog(pMac, LOGP, "Unable to forward request\n");
4293 return;
4294 }
4295
4296 return;
4297}
4298
4299
4300#ifdef WLAN_SOFTAP_FEATURE
4301static void
4302__limProcessSmeUpdateAPWPSIEs(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
4303{
4304 tpSirUpdateAPWPSIEsReq pUpdateAPWPSIEsReq;
4305 tpPESession psessionEntry;
4306 tANI_U8 sessionId; //PE sessionID
4307
4308 PELOG1(limLog(pMac, LOG1,
4309 FL("received UPDATE_APWPSIEs_REQ message\n")););
4310
4311 if(pMsgBuf == NULL)
4312 {
4313 limLog(pMac, LOGE,FL("Buffer is Pointing to NULL\n"));
4314 return;
4315 }
4316
4317 if( palAllocateMemory( pMac->hHdd, (void **)&pUpdateAPWPSIEsReq, sizeof(tSirUpdateAPWPSIEsReq)))
4318 {
4319 limLog(pMac, LOGP, FL("call to palAllocateMemory failed for pUpdateAPWPSIEsReq\n"));
4320 return;
4321 }
4322
4323 if ((limUpdateAPWPSIEsReqSerDes(pMac, pUpdateAPWPSIEsReq, (tANI_U8 *) pMsgBuf) == eSIR_FAILURE))
4324 {
4325 limLog(pMac, LOGW, FL("received invalid SME_SETCONTEXT_REQ message\n"));
4326 goto end;
4327 }
4328
4329 if((psessionEntry = peFindSessionByBssid(pMac, pUpdateAPWPSIEsReq->bssId, &sessionId)) == NULL)
4330 {
4331 limLog(pMac, LOGW, FL("Session does not exist for given BSSID\n"));
4332 goto end;
4333 }
4334
4335 palCopyMemory(pMac->hHdd, &psessionEntry->APWPSIEs, &pUpdateAPWPSIEsReq->APWPSIEs, sizeof(tSirAPWPSIEs));
4336
4337 schSetFixedBeaconFields(pMac, psessionEntry);
4338 limSendBeaconInd(pMac, psessionEntry);
4339
4340end:
4341 palFreeMemory( pMac->hHdd, pUpdateAPWPSIEsReq);
4342 return;
4343} /*** end __limProcessSmeUpdateAPWPSIEs(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf) ***/
4344
4345static void
4346__limProcessSmeHideSSID(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
4347{
4348 tpSirUpdateParams pUpdateParams;
4349 tpPESession psessionEntry;
4350
4351 PELOG1(limLog(pMac, LOG1,
4352 FL("received HIDE_SSID message\n")););
4353
4354 if(pMsgBuf == NULL)
4355 {
4356 limLog(pMac, LOGE,FL("Buffer is Pointing to NULL\n"));
4357 return;
4358 }
4359
4360 pUpdateParams = (tpSirUpdateParams)pMsgBuf;
4361
4362 if((psessionEntry = peFindSessionBySessionId(pMac, pUpdateParams->sessionId)) == NULL)
4363 {
4364 limLog(pMac, LOGW, "Session does not exist for given sessionId %d\n",
4365 pUpdateParams->sessionId);
4366 return;
4367 }
4368
4369 /* Update the session entry */
4370 psessionEntry->ssidHidden = pUpdateParams->ssidHidden;
4371
4372 /* Update beacon */
4373 schSetFixedBeaconFields(pMac, psessionEntry);
4374 limSendBeaconInd(pMac, psessionEntry);
4375
4376 return;
4377} /*** end __limProcessSmeHideSSID(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf) ***/
4378
4379static void
4380__limProcessSmeSetWPARSNIEs(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
4381{
4382 tpSirUpdateAPWPARSNIEsReq pUpdateAPWPARSNIEsReq;
4383 tpPESession psessionEntry;
4384 tANI_U8 sessionId; //PE sessionID
4385
4386 if(pMsgBuf == NULL)
4387 {
4388 limLog(pMac, LOGE,FL("Buffer is Pointing to NULL\n"));
4389 return;
4390 }
4391
4392 if( palAllocateMemory( pMac->hHdd, (void **)&pUpdateAPWPARSNIEsReq, sizeof(tSirUpdateAPWPSIEsReq)))
4393 {
4394 limLog(pMac, LOGP, FL("call to palAllocateMemory failed for pUpdateAPWPARSNIEsReq\n"));
4395 return;
4396 }
4397
4398 if ((limUpdateAPWPARSNIEsReqSerDes(pMac, pUpdateAPWPARSNIEsReq, (tANI_U8 *) pMsgBuf) == eSIR_FAILURE))
4399 {
4400 limLog(pMac, LOGW, FL("received invalid SME_SETCONTEXT_REQ message\n"));
4401 goto end;
4402 }
4403
4404 if((psessionEntry = peFindSessionByBssid(pMac, pUpdateAPWPARSNIEsReq->bssId, &sessionId)) == NULL)
4405 {
4406 limLog(pMac, LOGW, FL("Session does not exist for given BSSID\n"));
4407 goto end;
4408 }
4409
4410 palCopyMemory(pMac->hHdd, &psessionEntry->pLimStartBssReq->rsnIE, &pUpdateAPWPARSNIEsReq->APWPARSNIEs, sizeof(tSirRSNie));
4411
4412 limSetRSNieWPAiefromSmeStartBSSReqMessage(pMac, &psessionEntry->pLimStartBssReq->rsnIE, psessionEntry);
4413
4414 psessionEntry->pLimStartBssReq->privacy = 1;
4415 psessionEntry->privacy = 1;
4416
4417 schSetFixedBeaconFields(pMac, psessionEntry);
4418 limSendBeaconInd(pMac, psessionEntry);
4419
4420end:
4421 palFreeMemory( pMac->hHdd, pUpdateAPWPARSNIEsReq);
4422 return;
4423} /*** end __limProcessSmeSetWPARSNIEs(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf) ***/
4424
4425#endif
4426
4427
4428/** -------------------------------------------------------------
4429\fn limProcessSmeDelBaPeerInd
4430\brief handles indication message from HDD to send delete BA request
4431\param tpAniSirGlobal pMac
4432\param tANI_U32 pMsgBuf
4433\return None
4434-------------------------------------------------------------*/
4435void
4436limProcessSmeDelBaPeerInd(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
4437{
4438 tANI_U16 assocId =0;
4439 tpSmeDelBAPeerInd pSmeDelBAPeerInd = (tpSmeDelBAPeerInd)pMsgBuf;
4440 tpDphHashNode pSta;
4441 tpPESession psessionEntry;
4442 tANI_U8 sessionId;
4443
4444
4445
4446 if(NULL == pSmeDelBAPeerInd)
4447 return;
4448
4449 if ((psessionEntry = peFindSessionByBssid(pMac,pSmeDelBAPeerInd->bssId,&sessionId))==NULL)
4450 {
4451 limLog(pMac, LOGE,FL("session does not exist for given bssId\n"));
4452 return;
4453 }
4454 limLog(pMac, LOGW, FL("called with staId = %d, tid = %d, baDirection = %d\n"),
4455 pSmeDelBAPeerInd->staIdx, pSmeDelBAPeerInd->baTID, pSmeDelBAPeerInd->baDirection);
4456
4457 pSta = dphLookupAssocId(pMac, pSmeDelBAPeerInd->staIdx, &assocId, &psessionEntry->dph.dphHashTable);
4458 if( eSIR_SUCCESS != limPostMlmDelBAReq( pMac,
4459 pSta,
4460 pSmeDelBAPeerInd->baDirection,
4461 pSmeDelBAPeerInd->baTID,
4462 eSIR_MAC_UNSPEC_FAILURE_REASON,psessionEntry))
4463 {
4464 limLog( pMac, LOGW,
4465 FL( "Failed to post LIM_MLM_DELBA_REQ to " ));
4466 if (pSta)
4467 limPrintMacAddr(pMac, pSta->staAddr, LOGW);
4468 }
4469}
4470
4471// --------------------------------------------------------------------
4472/**
4473 * __limProcessReportMessage
4474 *
4475 * FUNCTION: Processes the next received Radio Resource Management message
4476 *
4477 * LOGIC:
4478 *
4479 * ASSUMPTIONS:
4480 *
4481 * NOTE:
4482 *
4483 * @param None
4484 * @return None
4485 */
4486
4487void __limProcessReportMessage(tpAniSirGlobal pMac, tpSirMsgQ pMsg)
4488{
4489#ifdef WLAN_FEATURE_VOWIFI
4490 switch (pMsg->type)
4491 {
4492 case eWNI_SME_NEIGHBOR_REPORT_REQ_IND:
4493 rrmProcessNeighborReportReq( pMac, pMsg->bodyptr );
4494 break;
4495 case eWNI_SME_BEACON_REPORT_RESP_XMIT_IND:
4496 {
4497#if defined FEATURE_WLAN_CCX
4498 tpSirBeaconReportXmitInd pBcnReport=NULL;
4499 tpPESession psessionEntry=NULL;
4500 tANI_U8 sessionId;
4501
4502 if(pMsg->bodyptr == NULL)
4503 {
4504 limLog(pMac, LOGE,FL("Buffer is Pointing to NULL\n"));
4505 return;
4506 }
4507 pBcnReport = (tpSirBeaconReportXmitInd )pMsg->bodyptr;
4508 if((psessionEntry = peFindSessionByBssid(pMac, pBcnReport->bssId,&sessionId))== NULL)
4509 {
4510 limLog(pMac, LOGE, "Session Does not exist for given bssId\n");
4511 return;
4512 }
4513 if (psessionEntry->isCCXconnection)
4514 ccxProcessBeaconReportXmit( pMac, pMsg->bodyptr);
4515 else
4516#endif
4517 rrmProcessBeaconReportXmit( pMac, pMsg->bodyptr );
4518 }
4519 break;
4520 }
4521#endif
4522}
4523
4524#if defined(FEATURE_WLAN_CCX) || defined(WLAN_FEATURE_VOWIFI)
4525// --------------------------------------------------------------------
4526/**
4527 * limSendSetMaxTxPowerReq
4528 *
4529 * FUNCTION: Send SIR_HAL_SET_MAX_TX_POWER_REQ message to change the max tx power.
4530 *
4531 * LOGIC:
4532 *
4533 * ASSUMPTIONS:
4534 *
4535 * NOTE:
4536 *
4537 * @param txPower txPower to be set.
4538 * @param pSessionEntry session entry.
4539 * @return None
4540 */
4541tSirRetStatus
4542limSendSetMaxTxPowerReq ( tpAniSirGlobal pMac, tPowerdBm txPower, tpPESession pSessionEntry )
4543{
4544 tpMaxTxPowerParams pMaxTxParams = NULL;
4545 tSirRetStatus retCode = eSIR_SUCCESS;
4546 tSirMsgQ msgQ;
4547
4548 if( pSessionEntry == NULL )
4549 {
4550 PELOGE(limLog(pMac, LOGE, "%s:%d: Inavalid parameters\n", __func__, __LINE__ );)
4551 return eSIR_FAILURE;
4552 }
4553 if( eHAL_STATUS_SUCCESS != palAllocateMemory( pMac->hHdd,
4554 (void **) &pMaxTxParams, sizeof(tMaxTxPowerParams) ) )
4555 {
4556 limLog( pMac, LOGP, "%s:%d:Unable to allocate memory for pMaxTxParams \n", __func__, __LINE__);
4557 return eSIR_MEM_ALLOC_FAILED;
4558
4559 }
4560#if defined(WLAN_VOWIFI_DEBUG) || defined(FEATURE_WLAN_CCX)
4561 PELOG1(limLog( pMac, LOG1, "%s:%d: Allocated memory for pMaxTxParams...will be freed in other module\n", __func__, __LINE__ );)
4562#endif
4563 pMaxTxParams->power = txPower;
4564 palCopyMemory( pMac->hHdd, pMaxTxParams->bssId, pSessionEntry->bssId, sizeof(tSirMacAddr) );
4565 palCopyMemory( pMac->hHdd, pMaxTxParams->selfStaMacAddr, pSessionEntry->selfMacAddr, sizeof(tSirMacAddr) );
4566
4567 msgQ.type = WDA_SET_MAX_TX_POWER_REQ;
4568 msgQ.bodyptr = pMaxTxParams;
4569 msgQ.bodyval = 0;
4570 PELOGW(limLog(pMac, LOG1, FL("Posting WDA_SET_MAX_TX_POWER_REQ to WDA\n"));)
4571 if(eSIR_SUCCESS != (retCode = wdaPostCtrlMsg(pMac, &msgQ)))
4572 {
4573 PELOGW(limLog(pMac, LOGW, FL("wdaPostCtrlMsg() failed\n"));)
4574 if (NULL != pMaxTxParams)
4575 {
4576 palFreeMemory(pMac->hHdd, (tANI_U8*)pMaxTxParams);
4577 }
4578 return retCode;
4579 }
4580 return retCode;
4581}
4582#endif
4583
4584/**
4585 * __limProcessSmeAddStaSelfReq()
4586 *
4587 *FUNCTION:
4588 * This function is called to process SME_ADD_STA_SELF_REQ message
4589 * from SME. It sends a SIR_HAL_ADD_STA_SELF_REQ message to HAL.
4590 *
4591 *LOGIC:
4592 *
4593 *ASSUMPTIONS:
4594 *
4595 *NOTE:
4596 *
4597 * @param pMac Pointer to Global MAC structure
4598 * @param *pMsgBuf A pointer to the SME message buffer
4599 * @return None
4600 */
4601
4602static void
4603__limProcessSmeAddStaSelfReq(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
4604{
4605 tSirMsgQ msg;
4606 tpAddStaSelfParams pAddStaSelfParams;
4607 tpSirSmeAddStaSelfReq pSmeReq = (tpSirSmeAddStaSelfReq) pMsgBuf;
4608
4609 if ( eHAL_STATUS_SUCCESS != palAllocateMemory( pMac->hHdd, (void**) &pAddStaSelfParams,
4610 sizeof( tAddStaSelfParams) ) )
4611 {
4612 limLog( pMac, LOGP, FL("Unable to allocate memory for tAddSelfStaParams") );
4613 return;
4614 }
4615
4616 palCopyMemory( pMac->hHdd, pAddStaSelfParams->selfMacAddr, pSmeReq->selfMacAddr, sizeof(tSirMacAddr) );
4617
4618 msg.type = SIR_HAL_ADD_STA_SELF_REQ;
4619 msg.reserved = 0;
4620 msg.bodyptr = pAddStaSelfParams;
4621 msg.bodyval = 0;
4622
4623 PELOGW(limLog(pMac, LOG1, FL("sending SIR_HAL_ADD_STA_SELF_REQ msg to HAL\n"));)
Jeff Johnsone7245742012-09-05 17:12:55 -07004624 MTRACE(macTraceMsgTx(pMac, NO_SESSION, msg.type));
Jeff Johnson295189b2012-06-20 16:38:30 -07004625
4626 if(eSIR_SUCCESS != wdaPostCtrlMsg(pMac, &msg))
4627 {
4628 limLog(pMac, LOGP, FL("wdaPostCtrlMsg failed\n"));
4629 }
4630 return;
4631} /*** end __limProcessAddStaSelfReq() ***/
4632
4633
4634/**
4635 * __limProcessSmeDelStaSelfReq()
4636 *
4637 *FUNCTION:
4638 * This function is called to process SME_DEL_STA_SELF_REQ message
4639 * from SME. It sends a SIR_HAL_DEL_STA_SELF_REQ message to HAL.
4640 *
4641 *LOGIC:
4642 *
4643 *ASSUMPTIONS:
4644 *
4645 *NOTE:
4646 *
4647 * @param pMac Pointer to Global MAC structure
4648 * @param *pMsgBuf A pointer to the SME message buffer
4649 * @return None
4650 */
4651
4652static void
4653__limProcessSmeDelStaSelfReq(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
4654{
4655 tSirMsgQ msg;
4656 tpDelStaSelfParams pDelStaSelfParams;
4657 tpSirSmeDelStaSelfReq pSmeReq = (tpSirSmeDelStaSelfReq) pMsgBuf;
4658
4659 if ( eHAL_STATUS_SUCCESS != palAllocateMemory( pMac->hHdd, (void**) &pDelStaSelfParams,
4660 sizeof( tDelStaSelfParams) ) )
4661 {
4662 limLog( pMac, LOGP, FL("Unable to allocate memory for tDelStaSelfParams") );
4663 return;
4664 }
4665
4666 palCopyMemory( pMac->hHdd, pDelStaSelfParams->selfMacAddr, pSmeReq->selfMacAddr, sizeof(tSirMacAddr) );
4667
4668 msg.type = SIR_HAL_DEL_STA_SELF_REQ;
4669 msg.reserved = 0;
4670 msg.bodyptr = pDelStaSelfParams;
4671 msg.bodyval = 0;
4672
4673 PELOGW(limLog(pMac, LOG1, FL("sending SIR_HAL_ADD_STA_SELF_REQ msg to HAL\n"));)
Jeff Johnsone7245742012-09-05 17:12:55 -07004674 MTRACE(macTraceMsgTx(pMac, NO_SESSION, msg.type));
Jeff Johnson295189b2012-06-20 16:38:30 -07004675
4676 if(eSIR_SUCCESS != wdaPostCtrlMsg(pMac, &msg))
4677 {
4678 limLog(pMac, LOGP, FL("wdaPostCtrlMsg failed\n"));
4679 }
4680 return;
4681} /*** end __limProcessSmeDelStaSelfReq() ***/
4682
4683
4684#ifdef WLAN_FEATURE_P2P
4685/**
4686 * __limProcessSmeRegisterMgmtFrameReq()
4687 *
4688 *FUNCTION:
4689 * This function is called to process eWNI_SME_REGISTER_MGMT_FRAME_REQ message
4690 * from SME. It Register this information within PE.
4691 *
4692 *LOGIC:
4693 *
4694 *ASSUMPTIONS:
4695 *
4696 *NOTE:
4697 *
4698 * @param pMac Pointer to Global MAC structure
4699 * @param *pMsgBuf A pointer to the SME message buffer
4700 * @return None
4701 */
4702static void
4703__limProcessSmeRegisterMgmtFrameReq(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
4704{
4705 VOS_STATUS vosStatus;
4706 tpSirRegisterMgmtFrame pSmeReq = (tpSirRegisterMgmtFrame)pMsgBuf;
4707 tpLimMgmtFrameRegistration pLimMgmtRegistration = NULL, pNext = NULL;
Jeff Johnsond13512a2012-07-17 11:42:19 -07004708 tANI_BOOLEAN match = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07004709 PELOG1(limLog(pMac, LOG1,
Jeff Johnsone7245742012-09-05 17:12:55 -07004710 FL("registerFrame %d, frameType %d, matchLen %d\n"),
4711 pSmeReq->registerFrame, pSmeReq->frameType, pSmeReq->matchLen);)
Jeff Johnson295189b2012-06-20 16:38:30 -07004712
Jeff Johnsond13512a2012-07-17 11:42:19 -07004713 /* First check whether entry exists already*/
4714
4715 vos_list_peek_front(&pMac->lim.gLimMgmtFrameRegistratinQueue,
4716 (vos_list_node_t**)&pLimMgmtRegistration);
4717
4718 while(pLimMgmtRegistration != NULL)
4719 {
4720 if (pLimMgmtRegistration->frameType == pSmeReq->frameType)
4721 {
4722 if(pSmeReq->matchLen)
4723 {
4724 if (pLimMgmtRegistration->matchLen == pSmeReq->matchLen)
4725 {
4726 if (palEqualMemory(pMac, pLimMgmtRegistration->matchData,
4727 pSmeReq->matchData, pLimMgmtRegistration->matchLen))
4728 {
Madan Mohan Koyyalamudie233e292012-09-18 17:38:02 -07004729 if(pSmeReq->selfMacAddr)
4730 {
4731 if(palEqualMemory(pMac, pLimMgmtRegistration->selfMacAddr,
4732 pSmeReq->selfMacAddr, VOS_MAC_ADDR_SIZE))
4733 {
4734 /* found match! */
4735 match = VOS_TRUE;
4736 break;
4737 }
4738 }
Jeff Johnsond13512a2012-07-17 11:42:19 -07004739 }
4740 }
4741 }
4742 else
4743 {
4744 /* found match! */
4745 match = VOS_TRUE;
4746 break;
4747 }
4748 }
4749 vosStatus = vos_list_peek_next (
4750 &pMac->lim.gLimMgmtFrameRegistratinQueue,
4751 (vos_list_node_t*) pLimMgmtRegistration,
4752 (vos_list_node_t**) &pNext );
4753
4754 pLimMgmtRegistration = pNext;
4755 pNext = NULL;
4756
4757 }
4758
4759 if (match)
4760 {
4761 vos_list_remove_node(&pMac->lim.gLimMgmtFrameRegistratinQueue,
4762 (vos_list_node_t*)pLimMgmtRegistration);
4763 palFreeMemory(pMac,pLimMgmtRegistration);
4764 }
4765
Jeff Johnson295189b2012-06-20 16:38:30 -07004766 if(pSmeReq->registerFrame)
4767 {
4768 palAllocateMemory(pMac, (void**)&pLimMgmtRegistration,
4769 sizeof(tLimMgmtFrameRegistration) + pSmeReq->matchLen);
4770 if(pLimMgmtRegistration != NULL)
4771 {
4772 palZeroMemory(pMac, (void*)pLimMgmtRegistration,
4773 sizeof(tLimMgmtFrameRegistration) + pSmeReq->matchLen );
4774 pLimMgmtRegistration->frameType = pSmeReq->frameType;
4775 pLimMgmtRegistration->matchLen = pSmeReq->matchLen;
4776 pLimMgmtRegistration->sessionId = pSmeReq->sessionId;
4777 if(pSmeReq->matchLen)
4778 {
4779 palCopyMemory(pMac,pLimMgmtRegistration->matchData,
4780 pSmeReq->matchData, pSmeReq->matchLen);
4781 }
Madan Mohan Koyyalamudie233e292012-09-18 17:38:02 -07004782 if(pSmeReq->selfMacAddr)
4783 {
4784 palCopyMemory( pMac, pLimMgmtRegistration->selfMacAddr,
4785 pSmeReq->selfMacAddr, VOS_MAC_ADDR_SIZE);
4786 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004787 vos_list_insert_front(&pMac->lim.gLimMgmtFrameRegistratinQueue,
4788 &pLimMgmtRegistration->node);
4789 }
4790 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004791
4792 return;
4793} /*** end __limProcessSmeRegisterMgmtFrameReq() ***/
4794#endif
4795
4796
4797/**
4798 * limProcessSmeReqMessages()
4799 *
4800 *FUNCTION:
4801 * This function is called by limProcessMessageQueue(). This
4802 * function processes SME request messages from HDD or upper layer
4803 * application.
4804 *
4805 *LOGIC:
4806 *
4807 *ASSUMPTIONS:
4808 *
4809 *NOTE:
4810 *
4811 * @param pMac Pointer to Global MAC structure
4812 * @param msgType Indicates the SME message type
4813 * @param *pMsgBuf A pointer to the SME message buffer
4814 * @return Boolean - TRUE - if pMsgBuf is consumed and can be freed.
4815 * FALSE - if pMsgBuf is not to be freed.
4816 */
4817
4818tANI_BOOLEAN
4819limProcessSmeReqMessages(tpAniSirGlobal pMac, tpSirMsgQ pMsg)
4820{
4821 tANI_BOOLEAN bufConsumed = TRUE; //Set this flag to false within case block of any following message, that doesnt want pMsgBuf to be freed.
4822 tANI_U32 *pMsgBuf = pMsg->bodyptr;
4823
Jeff Johnsone7245742012-09-05 17:12:55 -07004824 PELOG1(limLog(pMac, LOG1, FL("LIM Received SME Message %s(%d) Global LimSmeState:%s(%d) Global LimMlmState: %s(%d)\n"),
Jeff Johnson295189b2012-06-20 16:38:30 -07004825 limMsgStr(pMsg->type), pMsg->type,
4826 limSmeStateStr(pMac->lim.gLimSmeState), pMac->lim.gLimSmeState,
4827 limMlmStateStr(pMac->lim.gLimMlmState), pMac->lim.gLimMlmState );)
4828
4829 switch (pMsg->type)
4830 {
4831 case eWNI_SME_START_REQ:
4832 __limProcessSmeStartReq(pMac, pMsgBuf);
4833 break;
4834
4835 case eWNI_SME_SYS_READY_IND:
4836 bufConsumed = __limProcessSmeSysReadyInd(pMac, pMsgBuf);
4837 break;
4838
4839
4840 case eWNI_SME_START_BSS_REQ:
4841 bufConsumed = __limProcessSmeStartBssReq(pMac, pMsg);
4842 break;
4843
4844 case eWNI_SME_SCAN_REQ:
4845 __limProcessSmeScanReq(pMac, pMsgBuf);
4846
4847 break;
4848
Jeff Johnsone7245742012-09-05 17:12:55 -07004849#ifdef FEATURE_OEM_DATA_SUPPORT
4850 case eWNI_SME_OEM_DATA_REQ:
4851 __limProcessSmeOemDataReq(pMac, pMsgBuf);
4852
4853 break;
4854#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004855#ifdef WLAN_FEATURE_P2P
4856 case eWNI_SME_REMAIN_ON_CHANNEL_REQ:
4857 bufConsumed = limProcessRemainOnChnlReq(pMac, pMsgBuf);
4858 break;
4859
4860 case eWNI_SME_UPDATE_NOA:
4861 __limProcessSmeNoAUpdate(pMac, pMsgBuf);
4862 break;
4863#endif
4864 case eWNI_SME_JOIN_REQ:
4865 __limProcessSmeJoinReq(pMac, pMsgBuf);
4866
4867 break;
4868
4869 case eWNI_SME_AUTH_REQ:
4870 // __limProcessSmeAuthReq(pMac, pMsgBuf);
4871
4872 break;
4873
4874 case eWNI_SME_REASSOC_REQ:
4875 __limProcessSmeReassocReq(pMac, pMsgBuf);
4876
4877 break;
4878
4879 case eWNI_SME_PROMISCUOUS_MODE_REQ:
4880 //__limProcessSmePromiscuousReq(pMac, pMsgBuf);
4881
4882 break;
4883
4884 case eWNI_SME_DISASSOC_REQ:
4885 __limProcessSmeDisassocReq(pMac, pMsgBuf);
4886
4887 break;
4888
4889 case eWNI_SME_DISASSOC_CNF:
4890 case eWNI_SME_DEAUTH_CNF:
4891 __limProcessSmeDisassocCnf(pMac, pMsgBuf);
4892
4893 break;
4894
4895 case eWNI_SME_DEAUTH_REQ:
4896 __limProcessSmeDeauthReq(pMac, pMsgBuf);
4897
4898 break;
4899
4900#if (WNI_POLARIS_FW_PACKAGE == ADVANCED) && defined(ANI_PRODUCT_TYPE_AP)
4901 case eWNI_SME_SWITCH_CHL_REQ:
4902 case eWNI_SME_SWITCH_CHL_CB_PRIMARY_REQ:
4903 case eWNI_SME_SWITCH_CHL_CB_SECONDARY_REQ:
4904 bufConsumed = __limProcessSmeSwitchChlReq(pMac, pMsg);
4905 break;
4906#endif
4907
4908
4909 case eWNI_SME_SETCONTEXT_REQ:
4910 __limProcessSmeSetContextReq(pMac, pMsgBuf);
4911
4912 break;
4913
4914 case eWNI_SME_REMOVEKEY_REQ:
4915 __limProcessSmeRemoveKeyReq(pMac, pMsgBuf);
4916
4917 break;
4918
4919 case eWNI_SME_STOP_BSS_REQ:
4920 bufConsumed = __limProcessSmeStopBssReq(pMac, pMsg);
4921 break;
4922
4923 case eWNI_SME_ASSOC_CNF:
4924 case eWNI_SME_REASSOC_CNF:
4925 if (pMsg->type == eWNI_SME_ASSOC_CNF)
4926 PELOG1(limLog(pMac, LOG1, FL("Received ASSOC_CNF message\n"));)
4927 else
4928 PELOG1(limLog(pMac, LOG1, FL("Received REASSOC_CNF message\n"));)
4929#ifdef ANI_PRODUCT_TYPE_AP
4930 __limProcessSmeAssocCnf(pMac, pMsg->type, pMsgBuf);
4931#endif
4932 __limProcessSmeAssocCnfNew(pMac, pMsg->type, pMsgBuf);
4933 break;
4934
4935 case eWNI_SME_ADDTS_REQ:
4936 PELOG1(limLog(pMac, LOG1, FL("Received ADDTS_REQ message\n"));)
4937 __limProcessSmeAddtsReq(pMac, pMsgBuf);
4938 break;
4939
4940 case eWNI_SME_DELTS_REQ:
4941 PELOG1(limLog(pMac, LOG1, FL("Received DELTS_REQ message\n"));)
4942 __limProcessSmeDeltsReq(pMac, pMsgBuf);
4943 break;
4944
4945 case SIR_LIM_ADDTS_RSP_TIMEOUT:
4946 PELOG1(limLog(pMac, LOG1, FL("Received SIR_LIM_ADDTS_RSP_TIMEOUT message \n"));)
4947 limProcessSmeAddtsRspTimeout(pMac, pMsg->bodyval);
4948 break;
4949
4950 case eWNI_SME_STA_STAT_REQ:
4951 case eWNI_SME_AGGR_STAT_REQ:
4952 case eWNI_SME_GLOBAL_STAT_REQ:
4953 case eWNI_SME_STAT_SUMM_REQ:
4954 __limProcessSmeStatsRequest( pMac, pMsgBuf);
4955 //HAL consumes pMsgBuf. It will be freed there. Set bufConsumed to false.
4956 bufConsumed = FALSE;
4957 break;
4958 case eWNI_SME_GET_STATISTICS_REQ:
4959 __limProcessSmeGetStatisticsRequest( pMac, pMsgBuf);
4960 //HAL consumes pMsgBuf. It will be freed there. Set bufConsumed to false.
4961 bufConsumed = FALSE;
4962 break;
4963 case eWNI_SME_DEL_BA_PEER_IND:
4964 limProcessSmeDelBaPeerInd(pMac, pMsgBuf);
4965 break;
4966 case eWNI_SME_GET_SCANNED_CHANNEL_REQ:
4967 limProcessSmeGetScanChannelInfo(pMac, pMsgBuf);
4968 break;
4969#ifdef WLAN_SOFTAP_FEATURE
4970 case eWNI_SME_GET_ASSOC_STAS_REQ:
4971 limProcessSmeGetAssocSTAsInfo(pMac, pMsgBuf);
4972 break;
4973 case eWNI_SME_TKIP_CNTR_MEAS_REQ:
4974 limProcessTkipCounterMeasures(pMac, pMsgBuf);
4975 break;
4976
4977 case eWNI_SME_HIDE_SSID_REQ:
4978 __limProcessSmeHideSSID(pMac, pMsgBuf);
4979 break;
4980 case eWNI_SME_UPDATE_APWPSIE_REQ:
4981 __limProcessSmeUpdateAPWPSIEs(pMac, pMsgBuf);
4982 break;
4983 case eWNI_SME_GET_WPSPBC_SESSION_REQ:
4984 limProcessSmeGetWPSPBCSessions(pMac, pMsgBuf);
4985 break;
4986
4987 case eWNI_SME_SET_APWPARSNIEs_REQ:
4988 __limProcessSmeSetWPARSNIEs(pMac, pMsgBuf);
4989 break;
4990#endif
4991
4992#if defined WLAN_FEATURE_VOWIFI
4993 case eWNI_SME_NEIGHBOR_REPORT_REQ_IND:
4994 case eWNI_SME_BEACON_REPORT_RESP_XMIT_IND:
4995 __limProcessReportMessage(pMac, pMsg);
4996 break;
4997#endif
4998
4999#if defined WLAN_FEATURE_VOWIFI_11R
5000 case eWNI_SME_FT_PRE_AUTH_REQ:
5001 bufConsumed = (tANI_BOOLEAN)limProcessFTPreAuthReq(pMac, pMsg);
5002 break;
5003 case eWNI_SME_FT_UPDATE_KEY:
5004 limProcessFTUpdateKey(pMac, pMsgBuf);
5005 break;
5006
5007 case eWNI_SME_FT_AGGR_QOS_REQ:
5008 limProcessFTAggrQosReq(pMac, pMsgBuf);
5009 break;
5010#endif
5011
5012#if defined FEATURE_WLAN_CCX
5013 case eWNI_SME_CCX_ADJACENT_AP_REPORT:
5014 limProcessAdjacentAPRepMsg ( pMac, pMsgBuf );
5015 break;
5016#endif
5017 case eWNI_SME_ADD_STA_SELF_REQ:
5018 __limProcessSmeAddStaSelfReq( pMac, pMsgBuf );
5019 break;
5020 case eWNI_SME_DEL_STA_SELF_REQ:
5021 __limProcessSmeDelStaSelfReq( pMac, pMsgBuf );
5022 break;
5023
5024#ifdef WLAN_FEATURE_P2P
5025 case eWNI_SME_REGISTER_MGMT_FRAME_REQ:
5026 __limProcessSmeRegisterMgmtFrameReq( pMac, pMsgBuf );
5027 break;
5028#endif
5029
5030
5031 default:
5032 vos_mem_free((v_VOID_t*)pMsg->bodyptr);
5033 pMsg->bodyptr = NULL;
5034 break;
5035 } // switch (msgType)
5036
5037 return bufConsumed;
5038} /*** end limProcessSmeReqMessages() ***/