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