blob: 47590aab5387993fd6f97bc2f275f44630d1aef5 [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Kiet Lam842dad02014-02-18 18:44:02 -08002 * Copyright (c) 2012-2013 The Linux Foundation. All rights reserved.
3 *
4 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
5 *
6 *
7 * Permission to use, copy, modify, and/or distribute this software for
8 * any purpose with or without fee is hereby granted, provided that the
9 * above copyright notice and this permission notice appear in all
10 * copies.
11 *
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
13 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
14 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
15 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
16 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
17 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
18 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19 * PERFORMANCE OF THIS SOFTWARE.
20 */
21
22/*
Kiet Lama7f454d2014-07-24 12:04:06 -070023 * This file was originally distributed by Qualcomm Atheros, Inc.
24 * under proprietary terms before Copyright ownership was assigned
25 * to the Linux Foundation.
Gopichand Nakkala92f07d82013-01-08 21:16:34 -080026 */
Kiet Lam842dad02014-02-18 18:44:02 -080027
28
Kiet Lama7f454d2014-07-24 12:04:06 -070029
30
Gopichand Nakkala92f07d82013-01-08 21:16:34 -080031/*
Jeff Johnson295189b2012-06-20 16:38:30 -070032 * This file limProcessSmeReqMessages.cc contains the code
33 * for processing SME request messages.
34 * Author: Chandra Modumudi
35 * Date: 02/11/02
36 * History:-
37 * Date Modified by Modification Information
38 * --------------------------------------------------------------------
39 *
40 */
41
42#include "palTypes.h"
43#include "wniApi.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070044#include "wniCfgSta.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070045#include "cfgApi.h"
46#include "sirApi.h"
47#include "schApi.h"
48#include "utilsApi.h"
49#include "limTypes.h"
50#include "limUtils.h"
51#include "limAssocUtils.h"
52#include "limSecurityUtils.h"
53#include "limSerDesUtils.h"
54#include "limSmeReqUtils.h"
55#include "limIbssPeerMgmt.h"
56#include "limAdmitControl.h"
57#include "dphHashTable.h"
58#include "limSendMessages.h"
59#include "limApi.h"
60#include "wmmApsd.h"
61
Jeff Johnson295189b2012-06-20 16:38:30 -070062#include "sapApi.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070063
64#if defined WLAN_FEATURE_VOWIFI
65#include "rrmApi.h"
66#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080067#if defined(FEATURE_WLAN_ESE) && !defined(FEATURE_WLAN_ESE_UPLOAD)
68#include "eseApi.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070069#endif
70
71#if defined WLAN_FEATURE_VOWIFI_11R
72#include <limFT.h>
73#endif
74
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080075#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -070076/* These are the min/max tx power (non virtual rates) range
77 supported by prima hardware */
Sandeep Puligilla33ccf332013-12-19 16:06:42 +053078#define MIN_TX_PWR_CAP 8
79#define MAX_TX_PWR_CAP 22
Jeff Johnson295189b2012-06-20 16:38:30 -070080
81#endif
82
Viral Modid86bde22012-12-10 13:09:21 -080083/* This overhead is time for sending NOA start to host in case of GO/sending NULL data & receiving ACK
84 * in case of P2P Client and starting actual scanning with init scan req/rsp plus in case of concurrency,
Sunil Ravi24fd3aa2013-01-21 22:12:06 -080085 * taking care of sending null data and receiving ACK to/from AP/Also SetChannel with calibration is taking
86 * around 7ms .
Viral Modid86bde22012-12-10 13:09:21 -080087 */
Viral Modid440e682013-03-06 02:25:31 -080088#define SCAN_MESSAGING_OVERHEAD 20 // in msecs
89#define JOIN_NOA_DURATION 2000 // in msecs
90#define OEM_DATA_NOA_DURATION 60 // in msecs
91#define DEFAULT_PASSIVE_MAX_CHANNEL_TIME 110 // in msecs
Jeff Johnson295189b2012-06-20 16:38:30 -070092
Gopichand Nakkala096a1052012-12-21 07:05:34 -080093#define CONV_MS_TO_US 1024 //conversion factor from ms to us
94
Jeff Johnson295189b2012-06-20 16:38:30 -070095// SME REQ processing function templates
96static void __limProcessSmeStartReq(tpAniSirGlobal, tANI_U32 *);
97static tANI_BOOLEAN __limProcessSmeSysReadyInd(tpAniSirGlobal, tANI_U32 *);
98static tANI_BOOLEAN __limProcessSmeStartBssReq(tpAniSirGlobal, tpSirMsgQ pMsg);
Viral Modid440e682013-03-06 02:25:31 -080099static void __limProcessSmeScanReq(tpAniSirGlobal, tANI_U32 *);
Jeff Johnson295189b2012-06-20 16:38:30 -0700100static void __limProcessSmeJoinReq(tpAniSirGlobal, tANI_U32 *);
101static void __limProcessSmeReassocReq(tpAniSirGlobal, tANI_U32 *);
102static void __limProcessSmeDisassocReq(tpAniSirGlobal, tANI_U32 *);
103static void __limProcessSmeDisassocCnf(tpAniSirGlobal, tANI_U32 *);
104static void __limProcessSmeDeauthReq(tpAniSirGlobal, tANI_U32 *);
105static void __limProcessSmeSetContextReq(tpAniSirGlobal, tANI_U32 *);
106static tANI_BOOLEAN __limProcessSmeStopBssReq(tpAniSirGlobal, tpSirMsgQ pMsg);
107
Jeff Johnson295189b2012-06-20 16:38:30 -0700108void __limProcessSmeAssocCnfNew(tpAniSirGlobal, tANI_U32, tANI_U32 *);
109
Jeff Johnson295189b2012-06-20 16:38:30 -0700110extern void peRegisterTLHandle(tpAniSirGlobal pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -0700111
Jeff Johnson295189b2012-06-20 16:38:30 -0700112
Jeff Johnson295189b2012-06-20 16:38:30 -0700113#ifdef BACKGROUND_SCAN_ENABLED
114
115// start the background scan timers if it hasn't already started
116static void
117__limBackgroundScanInitiate(tpAniSirGlobal pMac)
118{
119 if (pMac->lim.gLimBackgroundScanStarted)
120 return;
121
122 //make sure timer is created first
123 if (TX_TIMER_VALID(pMac->lim.limTimers.gLimBackgroundScanTimer))
124 {
125 limDeactivateAndChangeTimer(pMac, eLIM_BACKGROUND_SCAN_TIMER);
Jeff Johnsone7245742012-09-05 17:12:55 -0700126 MTRACE(macTrace(pMac, TRACE_CODE_TIMER_ACTIVATE, NO_SESSION, eLIM_BACKGROUND_SCAN_TIMER));
Jeff Johnson295189b2012-06-20 16:38:30 -0700127 if (tx_timer_activate(&pMac->lim.limTimers.gLimBackgroundScanTimer) != TX_SUCCESS)
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700128 limLog(pMac, LOGP, FL("could not activate background scan timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700129 pMac->lim.gLimBackgroundScanStarted = true;
130 pMac->lim.gLimBackgroundScanChannelId = 0;
131 }
132}
133
134#endif // BACKGROUND_SCAN_ENABLED
Jeff Johnson295189b2012-06-20 16:38:30 -0700135
136// determine if a fresh scan request must be issued or not
137/*
138* PE will do fresh scan, if all of the active sessions are in good state (Link Est or BSS Started)
139* If one of the sessions is not in one of the above states, then PE does not do fresh scan
140* If no session exists (scanning very first time), then PE will always do fresh scan if SME
141* asks it to do that.
142*/
143static tANI_U8
144__limFreshScanReqd(tpAniSirGlobal pMac, tANI_U8 returnFreshResults)
145{
146
147 tANI_U8 validState = TRUE;
148 int i;
149
150 if(pMac->lim.gLimSmeState != eLIM_SME_IDLE_STATE)
151 {
152 return FALSE;
153 }
154 for(i =0; i < pMac->lim.maxBssId; i++)
155 {
156
157 if(pMac->lim.gpSession[i].valid == TRUE)
158 {
159 if(!( ( ( (pMac->lim.gpSession[i].bssType == eSIR_INFRASTRUCTURE_MODE) ||
160 (pMac->lim.gpSession[i].limSystemRole == eLIM_BT_AMP_STA_ROLE))&&
161 (pMac->lim.gpSession[i].limSmeState == eLIM_SME_LINK_EST_STATE) )||
162
163 ( ( (pMac->lim.gpSession[i].bssType == eSIR_IBSS_MODE)||
164 (pMac->lim.gpSession[i].limSystemRole == eLIM_BT_AMP_AP_ROLE)||
165 (pMac->lim.gpSession[i].limSystemRole == eLIM_BT_AMP_STA_ROLE) )&&
166 (pMac->lim.gpSession[i].limSmeState == eLIM_SME_NORMAL_STATE) )
Jeff Johnson295189b2012-06-20 16:38:30 -0700167 || ( ( ( (pMac->lim.gpSession[i].bssType == eSIR_INFRA_AP_MODE)
168 && ( pMac->lim.gpSession[i].pePersona == VOS_P2P_GO_MODE) )
169 || (pMac->lim.gpSession[i].limSystemRole == eLIM_AP_ROLE) )
170 && (pMac->lim.gpSession[i].limSmeState == eLIM_SME_NORMAL_STATE) )
Jeff Johnson295189b2012-06-20 16:38:30 -0700171 ))
172 {
173 validState = FALSE;
174 break;
175 }
176
177 }
178 }
Rashmi Ramanna6c13a342014-01-07 11:44:07 +0530179 limLog(pMac, LOG1, FL("FreshScanReqd: %d "), validState);
Jeff Johnson295189b2012-06-20 16:38:30 -0700180
181 if( (validState) && (returnFreshResults & SIR_BG_SCAN_RETURN_FRESH_RESULTS))
182 return TRUE;
183
184 return FALSE;
185}
186
Jeff Johnson295189b2012-06-20 16:38:30 -0700187
188
189/**
190 * __limIsSmeAssocCnfValid()
191 *
192 *FUNCTION:
193 * This function is called by limProcessLmmMessages() upon
194 * receiving SME_ASSOC_CNF.
195 *
196 *LOGIC:
197 * Message validity checks are performed in this function
198 *
199 *ASSUMPTIONS:
200 *
201 *NOTE:
202 *
203 * @param pMeasReq Pointer to Received ASSOC_CNF message
204 * @return true When received SME_ASSOC_CNF is formatted
205 * correctly
206 * false otherwise
207 */
208
209inline static tANI_U8
210__limIsSmeAssocCnfValid(tpSirSmeAssocCnf pAssocCnf)
211{
212 if (limIsGroupAddr(pAssocCnf->peerMacAddr))
213 return false;
214 else
215 return true;
216} /*** end __limIsSmeAssocCnfValid() ***/
217
218
219/**
220 * __limGetSmeJoinReqSizeForAlloc()
221 *
222 *FUNCTION:
223 * This function is called in various places to get IE length
224 * from tSirBssDescription structure
225 * number being scanned.
226 *
227 *PARAMS:
228 *
229 *LOGIC:
230 *
231 *ASSUMPTIONS:
232 * NA
233 *
234 *NOTE:
235 * NA
236 *
237 * @param pBssDescr
238 * @return Total IE length
239 */
240
241static tANI_U16
242__limGetSmeJoinReqSizeForAlloc(tANI_U8 *pBuf)
243{
244 tANI_U16 len = 0;
245
246 if (!pBuf)
247 return len;
248
249 pBuf += sizeof(tANI_U16);
250 len = limGetU16( pBuf );
251 return (len + sizeof( tANI_U16 ));
252} /*** end __limGetSmeJoinReqSizeForAlloc() ***/
253
254
255/**----------------------------------------------------------------
256\fn __limIsDeferedMsgForLearn
257
258\brief Has role only if 11h is enabled. Not used on STA side.
259 Defers the message if SME is in learn state and brings
260 the LIM back to normal mode.
261
262\param pMac
263\param pMsg - Pointer to message posted from SME to LIM.
264\return TRUE - If defered
265 FALSE - Otherwise
266------------------------------------------------------------------*/
267static tANI_BOOLEAN
268__limIsDeferedMsgForLearn(tpAniSirGlobal pMac, tpSirMsgQ pMsg)
269{
270 if (limIsSystemInScanState(pMac))
271 {
272 if (limDeferMsg(pMac, pMsg) != TX_SUCCESS)
273 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700274 PELOGE(limLog(pMac, LOGE, FL("Could not defer Msg = %d"), pMsg->type);)
Jeff Johnson295189b2012-06-20 16:38:30 -0700275 return eANI_BOOLEAN_FALSE;
276 }
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700277 PELOG1(limLog(pMac, LOG1, FL("Defer the message, in learn mode type = %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -0700278 pMsg->type);)
279
280 /** Send finish scan req to HAL only if LIM is not waiting for any response
281 * from HAL like init scan rsp, start scan rsp etc.
282 */
283 if (GET_LIM_PROCESS_DEFD_MESGS(pMac))
284 {
285 //Set the resume channel to Any valid channel (invalid).
286 //This will instruct HAL to set it to any previous valid channel.
287 peSetResumeChannel(pMac, 0, 0);
288 limSendHalFinishScanReq(pMac, eLIM_HAL_FINISH_LEARN_WAIT_STATE);
289 }
290
291 return eANI_BOOLEAN_TRUE;
292 }
293 return eANI_BOOLEAN_FALSE;
294}
295
296/**----------------------------------------------------------------
297\fn __limIsDeferedMsgForRadar
298
299\brief Has role only if 11h is enabled. Not used on STA side.
300 Defers the message if radar is detected.
301
302\param pMac
303\param pMsg - Pointer to message posted from SME to LIM.
304\return TRUE - If defered
305 FALSE - Otherwise
306------------------------------------------------------------------*/
307static tANI_BOOLEAN
308__limIsDeferedMsgForRadar(tpAniSirGlobal pMac, tpSirMsgQ pMsg)
309{
310 /** fRadarDetCurOperChan will be set only if we detect radar in current
311 * operating channel and System Role == AP ROLE */
Jeff Johnsone7245742012-09-05 17:12:55 -0700312 //TODO: Need to take care radar detection.
313 //if (LIM_IS_RADAR_DETECTED(pMac))
314 if( 0 )
Jeff Johnson295189b2012-06-20 16:38:30 -0700315 {
316 if (limDeferMsg(pMac, pMsg) != TX_SUCCESS)
317 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700318 PELOGE(limLog(pMac, LOGE, FL("Could not defer Msg = %d"), pMsg->type);)
Jeff Johnson295189b2012-06-20 16:38:30 -0700319 return eANI_BOOLEAN_FALSE;
320 }
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700321 PELOG1(limLog(pMac, LOG1, FL("Defer the message, in learn mode type = %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -0700322 pMsg->type);)
323 return eANI_BOOLEAN_TRUE;
324 }
325 return eANI_BOOLEAN_FALSE;
326}
327
328
329/**
330 * __limProcessSmeStartReq()
331 *
332 *FUNCTION:
333 * This function is called to process SME_START_REQ message
334 * from HDD or upper layer application.
335 *
336 *LOGIC:
337 *
338 *ASSUMPTIONS:
339 *
340 *NOTE:
341 *
342 * @param pMac Pointer to Global MAC structure
343 * @param *pMsgBuf A pointer to the SME message buffer
344 * @return None
345 */
346
347static void
348__limProcessSmeStartReq(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
349{
350 tSirResultCodes retCode = eSIR_SME_SUCCESS;
351 tANI_U8 smesessionId;
352 tANI_U16 smetransactionId;
353
354
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700355 PELOG1(limLog(pMac, LOG1, FL("Received START_REQ"));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700356
357 limGetSessionInfo(pMac,(tANI_U8 *)pMsgBuf,&smesessionId,&smetransactionId);
358
359 if (pMac->lim.gLimSmeState == eLIM_SME_OFFLINE_STATE)
360 {
361 pMac->lim.gLimSmeState = eLIM_SME_IDLE_STATE;
362
Jeff Johnsone7245742012-09-05 17:12:55 -0700363 MTRACE(macTrace(pMac, TRACE_CODE_SME_STATE, NO_SESSION, pMac->lim.gLimSmeState));
Jeff Johnson295189b2012-06-20 16:38:30 -0700364
365 /// By default do not return after first scan match
366 pMac->lim.gLimReturnAfterFirstMatch = 0;
367
368 /// Initialize MLM state machine
369 limInitMlm(pMac);
370
371 /// By default return unique scan results
372 pMac->lim.gLimReturnUniqueResults = true;
373 pMac->lim.gLimSmeScanResultLength = 0;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -0700374#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
375 pMac->lim.gLimSmeLfrScanResultLength = 0;
376#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700377
Jeff Johnson295189b2012-06-20 16:38:30 -0700378 if (((tSirSmeStartReq *) pMsgBuf)->sendNewBssInd)
379 {
380 /*
381 * Need to indicate new BSSs found during background scanning to
382 * host. Update this parameter at CFG
383 */
384 if (cfgSetInt(pMac, WNI_CFG_NEW_BSS_FOUND_IND, ((tSirSmeStartReq *) pMsgBuf)->sendNewBssInd)
385 != eSIR_SUCCESS)
386 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700387 limLog(pMac, LOGP, FL("could not set NEIGHBOR_BSS_IND at CFG"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700388 retCode = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
389 }
390 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700391 }
392 else
393 {
394 /**
395 * Should not have received eWNI_SME_START_REQ in states
396 * other than OFFLINE. Return response to host and
397 * log error
398 */
Sushant Kaushik1b645382014-10-13 16:39:36 +0530399 limLog(pMac, LOGE, FL("Invalid SME_START_REQ received in SME state %d"),pMac->lim.gLimSmeState );
Jeff Johnson295189b2012-06-20 16:38:30 -0700400 limPrintSmeState(pMac, LOGE, pMac->lim.gLimSmeState);
401 retCode = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
402 }
403 limSendSmeRsp(pMac, eWNI_SME_START_RSP, retCode,smesessionId,smetransactionId);
404} /*** end __limProcessSmeStartReq() ***/
405
406
407/** -------------------------------------------------------------
408\fn __limProcessSmeSysReadyInd
409\brief handles the notification from HDD. PE just forwards this message to HAL.
410\param tpAniSirGlobal pMac
411\param tANI_U32* pMsgBuf
412\return TRUE-Posting to HAL failed, so PE will consume the buffer.
413\ FALSE-Posting to HAL successful, so HAL will consume the buffer.
414 -------------------------------------------------------------*/
415static tANI_BOOLEAN
416__limProcessSmeSysReadyInd(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
417{
418 tSirMsgQ msg;
419
420 msg.type = WDA_SYS_READY_IND;
421 msg.reserved = 0;
422 msg.bodyptr = pMsgBuf;
423 msg.bodyval = 0;
424
Jeff Johnson92751692013-03-06 16:00:33 -0800425 if (pMac->gDriverType != eDRIVER_TYPE_MFG)
Jeff Johnson295189b2012-06-20 16:38:30 -0700426 {
Jeff Johnson92751692013-03-06 16:00:33 -0800427 peRegisterTLHandle(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -0700428 }
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700429 PELOGW(limLog(pMac, LOGW, FL("sending WDA_SYS_READY_IND msg to HAL"));)
Jeff Johnsone7245742012-09-05 17:12:55 -0700430 MTRACE(macTraceMsgTx(pMac, NO_SESSION, msg.type));
Jeff Johnson295189b2012-06-20 16:38:30 -0700431
Jeff Johnson92751692013-03-06 16:00:33 -0800432 if (eSIR_SUCCESS != wdaPostCtrlMsg(pMac, &msg))
Jeff Johnson295189b2012-06-20 16:38:30 -0700433 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700434 limLog(pMac, LOGP, FL("wdaPostCtrlMsg failed"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700435 return eANI_BOOLEAN_TRUE;
436 }
437 return eANI_BOOLEAN_FALSE;
438}
439
Jeff Johnsone7245742012-09-05 17:12:55 -0700440#ifdef WLAN_FEATURE_11AC
Jeff Johnson295189b2012-06-20 16:38:30 -0700441
Jeff Johnsone7245742012-09-05 17:12:55 -0700442tANI_U32 limGetCenterChannel(tpAniSirGlobal pMac,tANI_U8 primarychanNum,ePhyChanBondState secondaryChanOffset, tANI_U8 chanWidth)
443{
444 if (chanWidth == WNI_CFG_VHT_CHANNEL_WIDTH_80MHZ)
445 {
446 switch(secondaryChanOffset)
447 {
448 case PHY_QUADRUPLE_CHANNEL_20MHZ_CENTERED_40MHZ_CENTERED:
449 return primarychanNum;
450 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_CENTERED:
451 return primarychanNum + 2;
452 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_CENTERED:
453 return primarychanNum - 2;
454 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_LOW:
455 return primarychanNum + 6;
456 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_LOW:
457 return primarychanNum + 2;
458 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_HIGH:
459 return primarychanNum - 2;
460 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_HIGH:
461 return primarychanNum - 6;
462 default :
463 return eSIR_CFG_INVALID_ID;
464 }
465 }
466 else if (chanWidth == WNI_CFG_VHT_CHANNEL_WIDTH_20_40MHZ)
467 {
468 switch(secondaryChanOffset)
469 {
470 case PHY_DOUBLE_CHANNEL_LOW_PRIMARY:
471 return primarychanNum + 2;
472 case PHY_DOUBLE_CHANNEL_HIGH_PRIMARY:
473 return primarychanNum - 2;
474 case PHY_QUADRUPLE_CHANNEL_20MHZ_CENTERED_40MHZ_CENTERED:
475 return primarychanNum;
476 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_CENTERED:
477 return primarychanNum + 2;
478 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_CENTERED:
479 return primarychanNum - 2;
480 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_LOW:
481 return primarychanNum + 2;
482 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_LOW:
483 return primarychanNum - 2;
484 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_HIGH:
485 return primarychanNum + 2;
486 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_HIGH:
487 return primarychanNum - 2;
488 default :
489 return eSIR_CFG_INVALID_ID;
490 }
491 }
492 return primarychanNum;
493}
494
495#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700496/**
497 * __limHandleSmeStartBssRequest()
498 *
499 *FUNCTION:
500 * This function is called to process SME_START_BSS_REQ message
501 * from HDD or upper layer application.
502 *
503 *LOGIC:
504 *
505 *ASSUMPTIONS:
506 *
507 *NOTE:
508 *
509 * @param pMac Pointer to Global MAC structure
510 * @param *pMsgBuf A pointer to the SME message buffer
511 * @return None
512 */
513
514static void
515__limHandleSmeStartBssRequest(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
516{
517 tANI_U16 size;
518 tANI_U32 val = 0;
519 tSirRetStatus retStatus;
520 tSirMacChanNum channelNumber;
Jeff Johnsonace91102013-04-05 08:03:18 -0700521 tLimMlmStartReq *pMlmStartReq = NULL;
522 tpSirSmeStartBssReq pSmeStartBssReq = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -0700523 tSirResultCodes retCode = eSIR_SME_SUCCESS;
524 tANI_U32 autoGenBssId = FALSE; //Flag Used in case of IBSS to Auto generate BSSID.
Jeff Johnson295189b2012-06-20 16:38:30 -0700525 tANI_U8 sessionId;
526 tpPESession psessionEntry = NULL;
527 tANI_U8 smesessionId;
528 tANI_U16 smetransactionId;
529
530#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM //FEATURE_WLAN_DIAG_SUPPORT
531 //Since the session is not created yet, sending NULL. The response should have the correct state.
532 limDiagEventReport(pMac, WLAN_PE_DIAG_START_BSS_REQ_EVENT, NULL, 0, 0);
533#endif //FEATURE_WLAN_DIAG_SUPPORT
534
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700535 PELOG1(limLog(pMac, LOG1, FL("Received START_BSS_REQ"));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700536
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +0530537 /* Global Sme state and mlm states are not defined yet, for BT-AMP Suppoprt . TO BE DONE */
Jeff Johnson295189b2012-06-20 16:38:30 -0700538 if ( (pMac->lim.gLimSmeState == eLIM_SME_OFFLINE_STATE) ||
539 (pMac->lim.gLimSmeState == eLIM_SME_IDLE_STATE))
540 {
541 size = sizeof(tSirSmeStartBssReq) + SIR_MAC_MAX_IE_LENGTH;
542
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +0530543 pSmeStartBssReq = vos_mem_malloc(size);
544 if ( NULL == pSmeStartBssReq )
Jeff Johnson295189b2012-06-20 16:38:30 -0700545 {
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +0530546 PELOGE(limLog(pMac, LOGE, FL("AllocateMemory failed for pMac->lim.gpLimStartBssReq"));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700547 /// Send failure response to host
548 retCode = eSIR_SME_RESOURCES_UNAVAILABLE;
549 goto end;
550 }
551
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +0530552 vos_mem_set((void *)pSmeStartBssReq, size, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700553
554 if ((limStartBssReqSerDes(pMac, pSmeStartBssReq, (tANI_U8 *) pMsgBuf) == eSIR_FAILURE) ||
555 (!limIsSmeStartBssReqValid(pMac, pSmeStartBssReq)))
556 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700557 PELOGW(limLog(pMac, LOGW, FL("Received invalid eWNI_SME_START_BSS_REQ"));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700558 retCode = eSIR_SME_INVALID_PARAMETERS;
559 goto free;
560 }
561#if 0
562 PELOG3(limLog(pMac, LOG3,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700563 FL("Parsed START_BSS_REQ fields are bssType=%d, channelId=%d"),
Jeff Johnson295189b2012-06-20 16:38:30 -0700564 pMac->lim.gpLimStartBssReq->bssType, pMac->lim.gpLimStartBssReq->channelId);)
565#endif
566
567 /* This is the place where PE is going to create a session.
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +0530568 * If session is not existed, then create a new session */
Jeff Johnson295189b2012-06-20 16:38:30 -0700569 if((psessionEntry = peFindSessionByBssid(pMac,pSmeStartBssReq->bssId,&sessionId)) != NULL)
570 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700571 limLog(pMac, LOGW, FL("Session Already exists for given BSSID"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700572 retCode = eSIR_SME_BSS_ALREADY_STARTED_OR_JOINED;
573 psessionEntry = NULL;
574 goto free;
575 }
576 else
577 {
578 if((psessionEntry = peCreateSession(pMac,pSmeStartBssReq->bssId,&sessionId, pMac->lim.maxStation)) == NULL)
579 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700580 limLog(pMac, LOGW, FL("Session Can not be created "));
Jeff Johnson295189b2012-06-20 16:38:30 -0700581 retCode = eSIR_SME_RESOURCES_UNAVAILABLE;
582 goto free;
583 }
584
585 }
586
587 /* Store the session related parameters in newly created session */
588 psessionEntry->pLimStartBssReq = pSmeStartBssReq;
589
590 /* Store PE sessionId in session Table */
591 psessionEntry->peSessionId = sessionId;
592
593 /* Store SME session Id in sessionTable */
594 psessionEntry->smeSessionId = pSmeStartBssReq->sessionId;
595
596 psessionEntry->transactionId = pSmeStartBssReq->transactionId;
597
598 sirCopyMacAddr(psessionEntry->selfMacAddr,pSmeStartBssReq->selfMacAddr);
599
600 /* Copy SSID to session table */
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +0530601 vos_mem_copy( (tANI_U8 *)&psessionEntry->ssId,
Jeff Johnson295189b2012-06-20 16:38:30 -0700602 (tANI_U8 *)&pSmeStartBssReq->ssId,
603 (pSmeStartBssReq->ssId.length + 1));
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +0530604
Jeff Johnson295189b2012-06-20 16:38:30 -0700605 psessionEntry->bssType = pSmeStartBssReq->bssType;
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +0530606
Jeff Johnson295189b2012-06-20 16:38:30 -0700607 psessionEntry->nwType = pSmeStartBssReq->nwType;
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +0530608
Jeff Johnson295189b2012-06-20 16:38:30 -0700609 psessionEntry->beaconParams.beaconInterval = pSmeStartBssReq->beaconInterval;
610
611 /* Store the channel number in session Table */
612 psessionEntry->currentOperChannel = pSmeStartBssReq->channelId;
613
614 /*Store Persona */
615 psessionEntry->pePersona = pSmeStartBssReq->bssPersona;
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -0700616 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,FL("PE PERSONA=%d"),
Jeff Johnson295189b2012-06-20 16:38:30 -0700617 psessionEntry->pePersona);
618
619 /*Update the phymode*/
620 psessionEntry->gLimPhyMode = pSmeStartBssReq->nwType;
621
622 psessionEntry->maxTxPower = cfgGetRegulatoryMaxTransmitPower( pMac,
623 psessionEntry->currentOperChannel );
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +0530624
625#ifdef WLAN_FEATURE_AP_HT40_24G
626 /*Store Overlapping BSS Scan Parameters IEs to session table */
627 if (pSmeStartBssReq->apHT40_24GEnabled)
628 {
629 limInitOBSSScanParams(pMac, psessionEntry);
630 }
631#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700632 /* Store the dot 11 mode in to the session Table*/
633
634 psessionEntry->dot11mode = pSmeStartBssReq->dot11mode;
Jeff Johnsone7245742012-09-05 17:12:55 -0700635 psessionEntry->htCapability = IS_DOT11_MODE_HT(psessionEntry->dot11mode);
636#ifdef WLAN_FEATURE_11AC
637 psessionEntry->vhtCapability = IS_DOT11_MODE_VHT(psessionEntry->dot11mode);
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -0700638 VOS_TRACE(VOS_MODULE_ID_PE,VOS_TRACE_LEVEL_INFO,
639 FL("*****psessionEntry->vhtCapability = %d"),psessionEntry->vhtCapability);
Jeff Johnsone7245742012-09-05 17:12:55 -0700640#endif
Gopichand Nakkalab2d2c312013-01-04 11:41:02 -0800641
642 psessionEntry->txLdpcIniFeatureEnabled =
643 pSmeStartBssReq->txLdpcIniFeatureEnabled;
644
Chet Lanctot8cecea22014-02-11 19:09:36 -0800645#ifdef WLAN_FEATURE_11W
646 psessionEntry->limRmfEnabled = pSmeStartBssReq->pmfCapable ? 1 : 0;
647 limLog(pMac, LOG1, FL("Session RMF enabled: %d"), psessionEntry->limRmfEnabled);
648#endif
649
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +0530650 vos_mem_copy((void*)&psessionEntry->rateSet,
Jeff Johnson295189b2012-06-20 16:38:30 -0700651 (void*)&pSmeStartBssReq->operationalRateSet,
652 sizeof(tSirMacRateSet));
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +0530653 vos_mem_copy((void*)&psessionEntry->extRateSet,
Jeff Johnson295189b2012-06-20 16:38:30 -0700654 (void*)&pSmeStartBssReq->extendedRateSet,
655 sizeof(tSirMacRateSet));
656
657 switch(pSmeStartBssReq->bssType)
658 {
Jeff Johnson295189b2012-06-20 16:38:30 -0700659 case eSIR_INFRA_AP_MODE:
660 psessionEntry->limSystemRole = eLIM_AP_ROLE;
661 psessionEntry->privacy = pSmeStartBssReq->privacy;
662 psessionEntry->fwdWPSPBCProbeReq = pSmeStartBssReq->fwdWPSPBCProbeReq;
663 psessionEntry->authType = pSmeStartBssReq->authType;
664 /* Store the DTIM period */
665 psessionEntry->dtimPeriod = (tANI_U8)pSmeStartBssReq->dtimPeriod;
666 /*Enable/disable UAPSD*/
667 psessionEntry->apUapsdEnable = pSmeStartBssReq->apUapsdEnable;
668 if (psessionEntry->pePersona == VOS_P2P_GO_MODE)
669 {
670 psessionEntry->proxyProbeRspEn = 0;
671 }
672 else
673 {
674 /* To detect PBC overlap in SAP WPS mode, Host handles
675 * Probe Requests.
676 */
677 if(SAP_WPS_DISABLED == pSmeStartBssReq->wps_state)
678 {
679 psessionEntry->proxyProbeRspEn = 1;
680 }
681 else
682 {
683 psessionEntry->proxyProbeRspEn = 0;
684 }
685 }
686 psessionEntry->ssidHidden = pSmeStartBssReq->ssidHidden;
687 psessionEntry->wps_state = pSmeStartBssReq->wps_state;
krunal soni45b9eb62014-03-26 12:54:25 -0700688 limGetShortSlotFromPhyMode(pMac, psessionEntry,
689 psessionEntry->gLimPhyMode,
690 &psessionEntry->shortSlotTimeSupported);
Jeff Johnson295189b2012-06-20 16:38:30 -0700691 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700692 case eSIR_IBSS_MODE:
693 psessionEntry->limSystemRole = eLIM_STA_IN_IBSS_ROLE;
krunal soni45b9eb62014-03-26 12:54:25 -0700694 limGetShortSlotFromPhyMode(pMac, psessionEntry,
695 psessionEntry->gLimPhyMode,
696 &psessionEntry->shortSlotTimeSupported);
Abhishek Singhd5c31272014-03-07 14:46:50 +0530697 /* In WPA-NONE case we wont get the privacy bit in ibss config
698 * from supplicant, but we are updating WNI_CFG_PRIVACY_ENABLED
699 * on basis of Encryption type in csrRoamSetBssConfigCfg. So
700 * get the privacy info from WNI_CFG_PRIVACY_ENABLED
701 */
702 if (wlan_cfgGetInt(pMac, WNI_CFG_PRIVACY_ENABLED, &val)
703 != eSIR_SUCCESS)
704 limLog(pMac, LOGE, FL("cfg get WNI_CFG_PRIVACY_ENABLED"
705 " failed"));
706 psessionEntry->privacy =(tANI_U8) val;
krunal sonie9002db2013-11-25 14:24:17 -0800707 psessionEntry->isCoalesingInIBSSAllowed =
708 pSmeStartBssReq->isCoalesingInIBSSAllowed;
Jeff Johnson295189b2012-06-20 16:38:30 -0700709 break;
710
711 case eSIR_BTAMP_AP_MODE:
712 psessionEntry->limSystemRole = eLIM_BT_AMP_AP_ROLE;
713 break;
714
715 case eSIR_BTAMP_STA_MODE:
716 psessionEntry->limSystemRole = eLIM_BT_AMP_STA_ROLE;
717 break;
718
719 /* There is one more mode called auto mode. which is used no where */
720
721 //FORBUILD -TEMPFIX.. HOW TO use AUTO MODE?????
722
723
724 default:
725 //not used anywhere...used in scan function
726 break;
727 }
728
729 // BT-AMP: Allocate memory for the array of parsed (Re)Assoc request structure
730 if ( (pSmeStartBssReq->bssType == eSIR_BTAMP_AP_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -0700731 || (pSmeStartBssReq->bssType == eSIR_INFRA_AP_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -0700732 )
733 {
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +0530734 psessionEntry->parsedAssocReq = vos_mem_malloc(
735 psessionEntry->dph.dphHashTable.size * sizeof(tpSirAssocReq));
736 if ( NULL == psessionEntry->parsedAssocReq )
Jeff Johnson295189b2012-06-20 16:38:30 -0700737 {
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +0530738 limLog(pMac, LOGW, FL("AllocateMemory() failed"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700739 retCode = eSIR_SME_RESOURCES_UNAVAILABLE;
740 goto free;
741 }
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +0530742 vos_mem_set(psessionEntry->parsedAssocReq,
743 (psessionEntry->dph.dphHashTable.size * sizeof(tpSirAssocReq)),
744 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -0700745 }
746
747 /* Channel Bonding is not addressd yet for BT-AMP Support.. sunit will address channel bonding */
748 if (pSmeStartBssReq->channelId)
749 {
750 channelNumber = pSmeStartBssReq->channelId;
Jeff Johnsone7245742012-09-05 17:12:55 -0700751 psessionEntry->htSupportedChannelWidthSet = (pSmeStartBssReq->cbMode)?1:0; // This is already merged value of peer and self - done by csr in csrGetCBModeFromIes
752 psessionEntry->htRecommendedTxWidthSet = psessionEntry->htSupportedChannelWidthSet;
753 psessionEntry->htSecondaryChannelOffset = pSmeStartBssReq->cbMode;
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -0700754 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
Jeff Johnsone7245742012-09-05 17:12:55 -0700755 FL("cbMode %u"), pSmeStartBssReq->cbMode);
756#ifdef WLAN_FEATURE_11AC
757 if(psessionEntry->vhtCapability)
758 {
759 tANI_U32 centerChan;
760 tANI_U32 chanWidth;
Jeff Johnson295189b2012-06-20 16:38:30 -0700761
Jeff Johnsone7245742012-09-05 17:12:55 -0700762 if (wlan_cfgGetInt(pMac, WNI_CFG_VHT_CHANNEL_WIDTH,
763 &chanWidth) != eSIR_SUCCESS)
Jeff Johnson295189b2012-06-20 16:38:30 -0700764 {
Jeff Johnsone7245742012-09-05 17:12:55 -0700765 limLog(pMac, LOGP,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700766 FL("Unable to retrieve Channel Width from CFG"));
Jeff Johnsone7245742012-09-05 17:12:55 -0700767 }
Abhishek Singhb92f70c2014-04-28 12:13:08 +0530768
Abhishek Singh921926b2014-02-13 17:21:01 +0530769 if(channelNumber <= RF_CHAN_14 &&
Abhishek Singhb92f70c2014-04-28 12:13:08 +0530770 chanWidth != eHT_CHANNEL_WIDTH_20MHZ)
Jeff Johnsone7245742012-09-05 17:12:55 -0700771 {
Abhishek Singhb92f70c2014-04-28 12:13:08 +0530772 chanWidth = eHT_CHANNEL_WIDTH_20MHZ;
Abhishek Singh921926b2014-02-13 17:21:01 +0530773 limLog(pMac, LOG1, FL("Setting chanWidth to 20Mhz for"
774 " channel %d"),channelNumber);
Jeff Johnson295189b2012-06-20 16:38:30 -0700775 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700776
Abhishek Singhb92f70c2014-04-28 12:13:08 +0530777 if(chanWidth == eHT_CHANNEL_WIDTH_20MHZ ||
778 chanWidth == eHT_CHANNEL_WIDTH_40MHZ)
Abhishek Singh921926b2014-02-13 17:21:01 +0530779 {
Abhishek Singhb92f70c2014-04-28 12:13:08 +0530780 if (cfgSetInt(pMac, WNI_CFG_VHT_CHANNEL_WIDTH,
781 WNI_CFG_VHT_CHANNEL_WIDTH_20_40MHZ)
782 != eSIR_SUCCESS)
783 {
784 limLog(pMac, LOGP, FL("could not set "
785 " WNI_CFG_CHANNEL_BONDING_MODE at CFG"));
786 retCode = eSIR_LOGP_EXCEPTION;
787 goto free;
788 }
789 }
790 if (chanWidth == eHT_CHANNEL_WIDTH_80MHZ)
791 {
792 if (cfgSetInt(pMac, WNI_CFG_VHT_CHANNEL_WIDTH,
793 WNI_CFG_VHT_CHANNEL_WIDTH_80MHZ)
794 != eSIR_SUCCESS)
795 {
796 limLog(pMac, LOGP, FL("could not set "
797 " WNI_CFG_CHANNEL_BONDING_MODE at CFG"));
798 retCode = eSIR_LOGP_EXCEPTION;
799 goto free;
800 }
801
802 centerChan = limGetCenterChannel( pMac, channelNumber,
803 pSmeStartBssReq->cbMode,
804 WNI_CFG_VHT_CHANNEL_WIDTH_80MHZ);
Jeff Johnsone7245742012-09-05 17:12:55 -0700805 if(centerChan != eSIR_CFG_INVALID_ID)
806 {
Abhishek Singhb92f70c2014-04-28 12:13:08 +0530807 limLog(pMac, LOGW, FL("***Center Channel for "
808 "80MHZ channel width = %d"),centerChan);
Madan Mohan Koyyalamudi8b152b82012-10-18 20:56:27 -0700809 psessionEntry->apCenterChan = centerChan;
Abhishek Singh921926b2014-02-13 17:21:01 +0530810 if (cfgSetInt(pMac,
Abhishek Singhb92f70c2014-04-28 12:13:08 +0530811 WNI_CFG_VHT_CHANNEL_CENTER_FREQ_SEGMENT1,
812 centerChan) != eSIR_SUCCESS)
Jeff Johnsone7245742012-09-05 17:12:55 -0700813 {
Abhishek Singh921926b2014-02-13 17:21:01 +0530814 limLog(pMac, LOGP, FL("could not set "
Abhishek Singhb92f70c2014-04-28 12:13:08 +0530815 "WNI_CFG_CHANNEL_BONDING_MODE at CFG"));
Jeff Johnsone7245742012-09-05 17:12:55 -0700816 retCode = eSIR_LOGP_EXCEPTION;
817 goto free;
818 }
819 }
820 }
821
Abhishek Singhb92f70c2014-04-28 12:13:08 +0530822 /* All the translation is done by now for gVhtChannelWidth
823 * from .ini file to the actual values as defined in spec.
824 * So, grabing the spec value which is
825 * updated in .dat file by the above logic */
826 if (wlan_cfgGetInt(pMac, WNI_CFG_VHT_CHANNEL_WIDTH,
827 &chanWidth) != eSIR_SUCCESS)
828 {
829 limLog(pMac, LOGP,
830 FL("Unable to retrieve Channel Width from CFG"));
831 }
Madan Mohan Koyyalamudi8b152b82012-10-18 20:56:27 -0700832 /*For Sta+p2p-Go concurrency
833 vhtTxChannelWidthSet is used for storing p2p-GO channel width
834 apChanWidth is used for storing the AP channel width that the Sta is going to associate.
835 Initialize the apChanWidth same as p2p-GO channel width this gets over written once the station joins the AP
836 */
Jeff Johnsone7245742012-09-05 17:12:55 -0700837 psessionEntry->vhtTxChannelWidthSet = chanWidth;
Madan Mohan Koyyalamudi8b152b82012-10-18 20:56:27 -0700838 psessionEntry->apChanWidth = chanWidth;
Jeff Johnsone7245742012-09-05 17:12:55 -0700839 }
840 psessionEntry->htSecondaryChannelOffset = limGetHTCBState(pSmeStartBssReq->cbMode);
841#endif
842 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700843 else
844 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700845 PELOGW(limLog(pMac, LOGW, FL("Received invalid eWNI_SME_START_BSS_REQ"));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700846 retCode = eSIR_SME_INVALID_PARAMETERS;
847 goto free;
848 }
849
850 // Delete pre-auth list if any
851 limDeletePreAuthList(pMac);
852
853 // Delete IBSS peer BSSdescription list if any
854 //limIbssDelete(pMac); sep 26 review
855
856
857
858#ifdef FIXME_GEN6 //following code may not be required. limInitMlm is now being invoked during peStart
859 /// Initialize MLM state machine
Jeff Johnson295189b2012-06-20 16:38:30 -0700860 limInitMlm(pMac);
861#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700862
Jeff Johnsone7245742012-09-05 17:12:55 -0700863 psessionEntry->htCapability = IS_DOT11_MODE_HT(pSmeStartBssReq->dot11mode);
Jeff Johnson295189b2012-06-20 16:38:30 -0700864
Jeff Johnson295189b2012-06-20 16:38:30 -0700865 /* keep the RSN/WPA IE information in PE Session Entry
866 * later will be using this to check when received (Re)Assoc req
867 * */
868 limSetRSNieWPAiefromSmeStartBSSReqMessage(pMac,&pSmeStartBssReq->rsnIE,psessionEntry);
869
Jeff Johnson295189b2012-06-20 16:38:30 -0700870
Jeff Johnson295189b2012-06-20 16:38:30 -0700871 //Taken care for only softAP case rest need to be done
872 if (psessionEntry->limSystemRole == eLIM_AP_ROLE){
873 psessionEntry->gLimProtectionControl = pSmeStartBssReq->protEnabled;
874 /*each byte will have the following info
875 *bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0
876 *reserved reserved RIFS Lsig n-GF ht20 11g 11b*/
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +0530877 vos_mem_copy( (void *) &psessionEntry->cfgProtection,
Jeff Johnson295189b2012-06-20 16:38:30 -0700878 (void *) &pSmeStartBssReq->ht_capab,
Kiran Kumar Lokerea4db3dc2013-03-25 18:05:24 -0700879 sizeof( tANI_U16 ));
Jeff Johnson295189b2012-06-20 16:38:30 -0700880 psessionEntry->pAPWPSPBCSession = NULL; // Initialize WPS PBC session link list
881 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700882
883 // Prepare and Issue LIM_MLM_START_REQ to MLM
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +0530884 pMlmStartReq = vos_mem_malloc(sizeof(tLimMlmStartReq));
885 if ( NULL == pMlmStartReq )
Jeff Johnson295189b2012-06-20 16:38:30 -0700886 {
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +0530887 limLog(pMac, LOGP, FL("call to AllocateMemory failed for mlmStartReq"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700888 retCode = eSIR_SME_RESOURCES_UNAVAILABLE;
889 goto free;
890 }
891
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +0530892 vos_mem_set((void *) pMlmStartReq, sizeof(tLimMlmStartReq), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700893
894 /* Copy SSID to the MLM start structure */
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +0530895 vos_mem_copy( (tANI_U8 *) &pMlmStartReq->ssId,
Jeff Johnson295189b2012-06-20 16:38:30 -0700896 (tANI_U8 *) &pSmeStartBssReq->ssId,
897 pSmeStartBssReq->ssId.length + 1);
Jeff Johnson295189b2012-06-20 16:38:30 -0700898 pMlmStartReq->ssidHidden = pSmeStartBssReq->ssidHidden;
899 pMlmStartReq->obssProtEnabled = pSmeStartBssReq->obssProtEnabled;
Jeff Johnson295189b2012-06-20 16:38:30 -0700900
901
902 pMlmStartReq->bssType = psessionEntry->bssType;
903
904 /* Fill PE session Id from the session Table */
905 pMlmStartReq->sessionId = psessionEntry->peSessionId;
906
907 if( (pMlmStartReq->bssType == eSIR_BTAMP_STA_MODE) || (pMlmStartReq->bssType == eSIR_BTAMP_AP_MODE )
Jeff Johnson295189b2012-06-20 16:38:30 -0700908 || (pMlmStartReq->bssType == eSIR_INFRA_AP_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -0700909 )
910 {
911 //len = sizeof(tSirMacAddr);
912 //retStatus = wlan_cfgGetStr(pMac, WNI_CFG_STA_ID, (tANI_U8 *) pMlmStartReq->bssId, &len);
913 //if (retStatus != eSIR_SUCCESS)
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700914 //limLog(pMac, LOGP, FL("could not retrive BSSID, retStatus=%d"), retStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -0700915
916 /* Copy the BSSId from sessionTable to mlmStartReq struct */
917 sirCopyMacAddr(pMlmStartReq->bssId,psessionEntry->bssId);
918 }
919
920 else // ibss mode
921 {
922 pMac->lim.gLimIbssCoalescingHappened = false;
923
924 if((retStatus = wlan_cfgGetInt(pMac, WNI_CFG_IBSS_AUTO_BSSID, &autoGenBssId)) != eSIR_SUCCESS)
925 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700926 limLog(pMac, LOGP, FL("Could not retrieve Auto Gen BSSID, retStatus=%d"), retStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -0700927 retCode = eSIR_LOGP_EXCEPTION;
928 goto free;
929 }
930
931 if(!autoGenBssId)
932 {
933 // We're not auto generating BSSID. Instead, get it from session entry
934 sirCopyMacAddr(pMlmStartReq->bssId,psessionEntry->bssId);
935
936 if(pMlmStartReq->bssId[0] & 0x01)
937 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700938 PELOGE(limLog(pMac, LOGE, FL("Request to start IBSS with group BSSID\n Autogenerating the BSSID"));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700939 autoGenBssId = TRUE;
940 }
941 }
942
943 if( autoGenBssId )
944 { //if BSSID is not any uc id. then use locally generated BSSID.
945 //Autogenerate the BSSID
946 limGetRandomBssid( pMac, pMlmStartReq->bssId);
947 pMlmStartReq->bssId[0]= 0x02;
948
949 /* Copy randomly generated BSSID to the session Table */
950 sirCopyMacAddr(psessionEntry->bssId,pMlmStartReq->bssId);
951 }
952 }
953 /* store the channel num in mlmstart req structure */
954 pMlmStartReq->channelNumber = psessionEntry->currentOperChannel;
955 pMlmStartReq->cbMode = pSmeStartBssReq->cbMode;
956 pMlmStartReq->beaconPeriod = psessionEntry->beaconParams.beaconInterval;
957
Jeff Johnson295189b2012-06-20 16:38:30 -0700958 if(psessionEntry->limSystemRole == eLIM_AP_ROLE ){
959 pMlmStartReq->dtimPeriod = psessionEntry->dtimPeriod;
960 pMlmStartReq->wps_state = psessionEntry->wps_state;
961
962 }else
Jeff Johnson295189b2012-06-20 16:38:30 -0700963 {
964 if (wlan_cfgGetInt(pMac, WNI_CFG_DTIM_PERIOD, &val) != eSIR_SUCCESS)
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700965 limLog(pMac, LOGP, FL("could not retrieve DTIM Period"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700966 pMlmStartReq->dtimPeriod = (tANI_U8)val;
967 }
968
969 if (wlan_cfgGetInt(pMac, WNI_CFG_CFP_PERIOD, &val) != eSIR_SUCCESS)
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700970 limLog(pMac, LOGP, FL("could not retrieve Beacon interval"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700971 pMlmStartReq->cfParamSet.cfpPeriod = (tANI_U8)val;
972
973 if (wlan_cfgGetInt(pMac, WNI_CFG_CFP_MAX_DURATION, &val) != eSIR_SUCCESS)
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700974 limLog(pMac, LOGP, FL("could not retrieve CFPMaxDuration"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700975 pMlmStartReq->cfParamSet.cfpMaxDuration = (tANI_U16) val;
976
977 //this may not be needed anymore now, as rateSet is now included in the session entry and MLM has session context.
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +0530978 vos_mem_copy((void*)&pMlmStartReq->rateSet, (void*)&psessionEntry->rateSet,
Jeff Johnson295189b2012-06-20 16:38:30 -0700979 sizeof(tSirMacRateSet));
980
Jeff Johnson295189b2012-06-20 16:38:30 -0700981 // Now populate the 11n related parameters
982 pMlmStartReq->nwType = psessionEntry->nwType;
Jeff Johnsone7245742012-09-05 17:12:55 -0700983 pMlmStartReq->htCapable = psessionEntry->htCapability;
Jeff Johnson295189b2012-06-20 16:38:30 -0700984 //
985 // FIXME_GEN4 - Determine the appropriate defaults...
986 //
987 pMlmStartReq->htOperMode = pMac->lim.gHTOperMode;
988 pMlmStartReq->dualCTSProtection = pMac->lim.gHTDualCTSProtection; // Unused
Jeff Johnsone7245742012-09-05 17:12:55 -0700989 pMlmStartReq->txChannelWidthSet = psessionEntry->htRecommendedTxWidthSet;
Jeff Johnson295189b2012-06-20 16:38:30 -0700990
991 /* sep26 review */
992 psessionEntry->limRFBand = limGetRFBand(channelNumber);
993
994 // Initialize 11h Enable Flag
995 psessionEntry->lim11hEnable = 0;
996 if((pMlmStartReq->bssType != eSIR_IBSS_MODE) &&
997 (SIR_BAND_5_GHZ == psessionEntry->limRFBand) )
998 {
999 if (wlan_cfgGetInt(pMac, WNI_CFG_11H_ENABLED, &val) != eSIR_SUCCESS)
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001000 limLog(pMac, LOGP, FL("Fail to get WNI_CFG_11H_ENABLED "));
Jeff Johnson295189b2012-06-20 16:38:30 -07001001 psessionEntry->lim11hEnable = val;
1002 }
1003
1004 if (!psessionEntry->lim11hEnable)
1005 {
1006 if (cfgSetInt(pMac, WNI_CFG_LOCAL_POWER_CONSTRAINT, 0) != eSIR_SUCCESS)
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001007 limLog(pMac, LOGP, FL("Fail to get WNI_CFG_11H_ENABLED "));
Jeff Johnson295189b2012-06-20 16:38:30 -07001008 }
1009
Jeff Johnson295189b2012-06-20 16:38:30 -07001010 psessionEntry ->limPrevSmeState = psessionEntry->limSmeState;
1011 psessionEntry ->limSmeState = eLIM_SME_WT_START_BSS_STATE;
Jeff Johnsone7245742012-09-05 17:12:55 -07001012 MTRACE(macTrace(pMac, TRACE_CODE_SME_STATE, psessionEntry->peSessionId, psessionEntry ->limSmeState));
Jeff Johnson295189b2012-06-20 16:38:30 -07001013
1014 limPostMlmMessage(pMac, LIM_MLM_START_REQ, (tANI_U32 *) pMlmStartReq);
1015 return;
1016 }
1017 else
1018 {
1019
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001020 limLog(pMac, LOGE, FL("Received unexpected START_BSS_REQ, in state %X"),pMac->lim.gLimSmeState);
Jeff Johnson295189b2012-06-20 16:38:30 -07001021 retCode = eSIR_SME_BSS_ALREADY_STARTED_OR_JOINED;
1022 goto end;
1023 } // if (pMac->lim.gLimSmeState == eLIM_SME_OFFLINE_STATE)
1024
1025free:
Jeff Johnsonace91102013-04-05 08:03:18 -07001026 if ((psessionEntry != NULL) &&
1027 (psessionEntry->pLimStartBssReq == pSmeStartBssReq))
1028 {
1029 psessionEntry->pLimStartBssReq = NULL;
1030 }
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301031 vos_mem_free( pSmeStartBssReq);
1032 vos_mem_free( pMlmStartReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07001033
1034end:
1035
1036 /* This routine should return the sme sessionId and SME transaction Id */
1037 limGetSessionInfo(pMac,(tANI_U8*)pMsgBuf,&smesessionId,&smetransactionId);
1038
1039 if(NULL != psessionEntry)
1040 {
1041 peDeleteSession(pMac,psessionEntry);
1042 psessionEntry = NULL;
1043 }
1044 limSendSmeStartBssRsp(pMac, eWNI_SME_START_BSS_RSP, retCode,psessionEntry,smesessionId,smetransactionId);
1045} /*** end __limHandleSmeStartBssRequest() ***/
1046
1047
1048/**--------------------------------------------------------------
1049\fn __limProcessSmeStartBssReq
1050
1051\brief Wrapper for the function __limHandleSmeStartBssRequest
1052 This message will be defered until softmac come out of
1053 scan mode or if we have detected radar on the current
1054 operating channel.
1055\param pMac
1056\param pMsg
1057
1058\return TRUE - If we consumed the buffer
1059 FALSE - If have defered the message.
1060 ---------------------------------------------------------------*/
1061static tANI_BOOLEAN
1062__limProcessSmeStartBssReq(tpAniSirGlobal pMac, tpSirMsgQ pMsg)
1063{
1064 if (__limIsDeferedMsgForLearn(pMac, pMsg) ||
1065 __limIsDeferedMsgForRadar(pMac, pMsg))
1066 {
1067 /**
1068 * If message defered, buffer is not consumed yet.
1069 * So return false
1070 */
1071 return eANI_BOOLEAN_FALSE;
1072 }
1073
1074 __limHandleSmeStartBssRequest(pMac, (tANI_U32 *) pMsg->bodyptr);
1075 return eANI_BOOLEAN_TRUE;
1076}
1077
1078
1079/**
1080 * limGetRandomBssid()
1081 *
1082 * FUNCTION:This function is called to process generate the random number for bssid
1083 * This function is called to process SME_SCAN_REQ message
1084 * from HDD or upper layer application.
1085 *
1086 * LOGIC:
1087 *
1088 * ASSUMPTIONS:
1089 *
1090 * NOTE:
1091 * 1. geneartes the unique random number for bssid in ibss
1092 *
1093 * @param pMac Pointer to Global MAC structure
1094 * @param *data Pointer to bssid buffer
1095 * @return None
1096 */
1097void limGetRandomBssid(tpAniSirGlobal pMac, tANI_U8 *data)
1098{
1099 tANI_U32 random[2] ;
1100 random[0] = tx_time_get();
1101 random[0] |= (random[0] << 15) ;
1102 random[1] = random[0] >> 1;
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301103 vos_mem_copy( data, (tANI_U8*)random, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07001104}
1105
Ganesh Kondabattinif0fa07c2013-06-11 17:47:49 +05301106static eHalStatus limSendHalStartScanOffloadReq(tpAniSirGlobal pMac,
1107 tpSirSmeScanReq pScanReq)
1108{
1109 tSirScanOffloadReq *pScanOffloadReq;
1110 tANI_U8 *p;
1111 tSirMsgQ msg;
Ganesh Kondabattinif0fa07c2013-06-11 17:47:49 +05301112 tANI_U16 i, len;
1113 tSirRetStatus rc = eSIR_SUCCESS;
1114
1115 /* The tSirScanOffloadReq will reserve the space for first channel,
1116 so allocate the memory for (numChannels - 1) and uIEFieldLen */
1117 len = sizeof(tSirScanOffloadReq) + (pScanReq->channelList.numChannels - 1) +
1118 pScanReq->uIEFieldLen;
1119
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301120 pScanOffloadReq = vos_mem_malloc(len);
1121 if ( NULL == pScanOffloadReq )
Ganesh Kondabattinif0fa07c2013-06-11 17:47:49 +05301122 {
1123 limLog(pMac, LOGE,
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301124 FL("AllocateMemory failed for pScanOffloadReq"));
Ganesh Kondabattinif0fa07c2013-06-11 17:47:49 +05301125 return eHAL_STATUS_FAILURE;
1126 }
1127
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301128 vos_mem_set( (tANI_U8 *) pScanOffloadReq, len, 0);
Ganesh Kondabattinif0fa07c2013-06-11 17:47:49 +05301129
1130 msg.type = WDA_START_SCAN_OFFLOAD_REQ;
1131 msg.bodyptr = pScanOffloadReq;
1132 msg.bodyval = 0;
1133
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301134 vos_mem_copy((tANI_U8 *) pScanOffloadReq->bssId,
Ganesh Kondabattinif0fa07c2013-06-11 17:47:49 +05301135 (tANI_U8*) pScanReq->bssId,
1136 sizeof(tSirMacAddr));
1137
1138 if (pScanReq->numSsid > SIR_SCAN_MAX_NUM_SSID)
1139 {
1140 limLog(pMac, LOGE,
1141 FL("Invalid value (%d) for numSsid"), SIR_SCAN_MAX_NUM_SSID);
Kiet Lamb1233192013-11-28 13:38:20 +05301142 vos_mem_free (pScanOffloadReq);
Ganesh Kondabattinif0fa07c2013-06-11 17:47:49 +05301143 return eHAL_STATUS_FAILURE;
1144 }
1145
1146 pScanOffloadReq->numSsid = pScanReq->numSsid;
1147 for (i = 0; i < pScanOffloadReq->numSsid; i++)
1148 {
1149 pScanOffloadReq->ssId[i].length = pScanReq->ssId[i].length;
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301150 vos_mem_copy((tANI_U8 *) pScanOffloadReq->ssId[i].ssId,
Ganesh Kondabattinif0fa07c2013-06-11 17:47:49 +05301151 (tANI_U8 *) pScanReq->ssId[i].ssId,
1152 pScanOffloadReq->ssId[i].length);
1153 }
1154
1155 pScanOffloadReq->hiddenSsid = pScanReq->hiddenSsid;
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301156 vos_mem_copy((tANI_U8 *) pScanOffloadReq->selfMacAddr,
Ganesh Kondabattinif0fa07c2013-06-11 17:47:49 +05301157 (tANI_U8 *) pScanReq->selfMacAddr,
1158 sizeof(tSirMacAddr));
1159 pScanOffloadReq->bssType = pScanReq->bssType;
1160 pScanOffloadReq->dot11mode = pScanReq->dot11mode;
1161 pScanOffloadReq->scanType = pScanReq->scanType;
1162 pScanOffloadReq->minChannelTime = pScanReq->minChannelTime;
1163 pScanOffloadReq->maxChannelTime = pScanReq->maxChannelTime;
1164 pScanOffloadReq->p2pSearch = pScanReq->p2pSearch;
1165 pScanOffloadReq->sessionId = pScanReq->sessionId;
1166 pScanOffloadReq->channelList.numChannels =
1167 pScanReq->channelList.numChannels;
1168 p = &(pScanOffloadReq->channelList.channelNumber[0]);
1169 for (i = 0; i < pScanOffloadReq->channelList.numChannels; i++)
1170 p[i] = pScanReq->channelList.channelNumber[i];
1171
1172 pScanOffloadReq->uIEFieldLen = pScanReq->uIEFieldLen;
1173 pScanOffloadReq->uIEFieldOffset = len - pScanOffloadReq->uIEFieldLen;
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301174 vos_mem_copy((tANI_U8 *) p + i,
Ganesh Kondabattinif0fa07c2013-06-11 17:47:49 +05301175 (tANI_U8 *) pScanReq + pScanReq->uIEFieldOffset,
1176 pScanOffloadReq->uIEFieldLen);
1177
1178 rc = wdaPostCtrlMsg(pMac, &msg);
1179 if (rc != eSIR_SUCCESS)
1180 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001181 limLog(pMac, LOGE, FL("wdaPostCtrlMsg() return failure"));
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301182 vos_mem_free(pScanOffloadReq);
Ganesh Kondabattinif0fa07c2013-06-11 17:47:49 +05301183 return eHAL_STATUS_FAILURE;
1184 }
Rashmi Ramanna6c13a342014-01-07 11:44:07 +05301185 limLog(pMac, LOG1, FL("Processed Offload Scan Request Successfully"));
Ganesh Kondabattinif0fa07c2013-06-11 17:47:49 +05301186
1187 return eHAL_STATUS_SUCCESS;
1188}
Jeff Johnson295189b2012-06-20 16:38:30 -07001189
1190/**
1191 * __limProcessSmeScanReq()
1192 *
1193 *FUNCTION:
1194 * This function is called to process SME_SCAN_REQ message
1195 * from HDD or upper layer application.
1196 *
1197 *LOGIC:
1198 *
1199 *ASSUMPTIONS:
1200 *
1201 *NOTE:
1202 * 1. Periodic scanning should be requesting to return unique
1203 * scan results.
1204 *
1205 * @param pMac Pointer to Global MAC structure
1206 * @param *pMsgBuf A pointer to the SME message buffer
1207 * @return None
1208 */
1209
Viral Modid440e682013-03-06 02:25:31 -08001210static void
Jeff Johnson295189b2012-06-20 16:38:30 -07001211__limProcessSmeScanReq(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
1212{
1213 tANI_U32 len;
1214 tLimMlmScanReq *pMlmScanReq;
1215 tpSirSmeScanReq pScanReq;
1216 tANI_U8 i = 0;
1217
1218#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM //FEATURE_WLAN_DIAG_SUPPORT
1219 limDiagEventReport(pMac, WLAN_PE_DIAG_SCAN_REQ_EVENT, NULL, 0, 0);
1220#endif //FEATURE_WLAN_DIAG_SUPPORT
1221
1222 pScanReq = (tpSirSmeScanReq) pMsgBuf;
Sushant Kaushike0d2cce2014-04-10 14:36:07 +05301223 limLog(pMac, LOG1,FL("SME SCAN REQ numChan %d min %d max %d IELen %d"
1224 "first %d fresh %d unique %d type %s (%d)"
1225 " mode %s (%d)rsp %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07001226 pScanReq->channelList.numChannels,
1227 pScanReq->minChannelTime,
1228 pScanReq->maxChannelTime,
1229 pScanReq->uIEFieldLen,
1230 pScanReq->returnAfterFirstMatch,
1231 pScanReq->returnFreshResults,
1232 pScanReq->returnUniqueResults,
Sushant Kaushike0d2cce2014-04-10 14:36:07 +05301233 lim_ScanTypetoString(pScanReq->scanType),
Madan Mohan Koyyalamudi70bb4cb2012-10-18 19:31:25 -07001234 pScanReq->scanType,
Sushant Kaushike0d2cce2014-04-10 14:36:07 +05301235 lim_BackgroundScanModetoString(pScanReq->backgroundScanMode),
1236 pScanReq->backgroundScanMode, pMac->lim.gLimRspReqd ? 1 : 0);
Viral Modid86bde22012-12-10 13:09:21 -08001237
1238 /* Since scan req always requires a response, we will overwrite response required here.
1239 * This is added esp to take care of the condition where in p2p go case, we hold the scan req and
1240 * insert single NOA. We send the held scan request to FW later on getting start NOA ind from FW so
1241 * we lose state of the gLimRspReqd flag for the scan req if any other request comes by then.
1242 * e.g. While unit testing, we found when insert single NOA is done, we see a get stats request which turns the flag
1243 * gLimRspReqd to FALSE; now when we actually start the saved scan req for init scan after getting
1244 * NOA started, the gLimRspReqd being a global flag is showing FALSE instead of TRUE value for
1245 * this saved scan req. Since all scan reqs coming to lim require a response, there is no harm in setting
1246 * the global flag gLimRspReqd to TRUE here.
1247 */
1248 pMac->lim.gLimRspReqd = TRUE;
1249
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301250 /*copy the Self MAC address from SmeReq to the globalplace, used for sending probe req*/
Jeff Johnson295189b2012-06-20 16:38:30 -07001251 sirCopyMacAddr(pMac->lim.gSelfMacAddr, pScanReq->selfMacAddr);
1252
1253 /* This routine should return the sme sessionId and SME transaction Id */
1254
1255 if (!limIsSmeScanReqValid(pMac, pScanReq))
1256 {
Rashmi Ramanna6c13a342014-01-07 11:44:07 +05301257 limLog(pMac, LOGE, FL("Received SME_SCAN_REQ with invalid parameters"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001258
1259 if (pMac->lim.gLimRspReqd)
1260 {
1261 pMac->lim.gLimRspReqd = false;
1262
1263 limSendSmeScanRsp(pMac, sizeof(tSirSmeScanRsp), eSIR_SME_INVALID_PARAMETERS, pScanReq->sessionId, pScanReq->transactionId);
1264
1265 } // if (pMac->lim.gLimRspReqd)
1266
1267 return;
1268 }
1269
1270 //if scan is disabled then return as invalid scan request.
1271 //if scan in power save is disabled, and system is in power save mode, then ignore scan request.
1272 if( (pMac->lim.fScanDisabled) || (!pMac->lim.gScanInPowersave && !limIsSystemInActiveState(pMac)) )
1273 {
Rashmi Ramanna6c13a342014-01-07 11:44:07 +05301274 limLog(pMac, LOGE, FL("SCAN is disabled or SCAN in power save"
1275 " is disabled and system is in power save."));
Leela V Kiran Kumar Reddy Chirala6a458752013-02-16 15:41:27 -08001276 limSendSmeScanRsp(pMac, offsetof(tSirSmeScanRsp,bssDescription[0]), eSIR_SME_INVALID_PARAMETERS, pScanReq->sessionId, pScanReq->transactionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07001277 return;
1278 }
1279
1280
1281 /**
1282 * If scan request is received in idle, joinFailed
1283 * states or in link established state (in STA role)
1284 * or in normal state (in STA-in-IBSS/AP role) with
1285 * 'return fresh scan results' request from HDD or
1286 * it is periodic background scanning request,
1287 * trigger fresh scan request to MLM
1288 */
1289 if (__limFreshScanReqd(pMac, pScanReq->returnFreshResults))
1290 {
Ganesh Kondabattinif0fa07c2013-06-11 17:47:49 +05301291 if (pScanReq->returnFreshResults & SIR_BG_SCAN_PURGE_RESUTLS)
1292 {
1293 // Discard previously cached scan results
1294 limReInitScanResults(pMac);
1295 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001296
Ganesh Kondabattinif0fa07c2013-06-11 17:47:49 +05301297 pMac->lim.gLim24Band11dScanDone = 0;
1298 pMac->lim.gLim50Band11dScanDone = 0;
1299 pMac->lim.gLimReturnAfterFirstMatch =
1300 pScanReq->returnAfterFirstMatch;
1301 pMac->lim.gLimBackgroundScanMode =
1302 pScanReq->backgroundScanMode;
Jeff Johnson295189b2012-06-20 16:38:30 -07001303
Ganesh Kondabattinif0fa07c2013-06-11 17:47:49 +05301304 pMac->lim.gLimReturnUniqueResults =
1305 ((pScanReq->returnUniqueResults) > 0 ? true : false);
1306 /* De-activate Heartbeat timers for connected sessions while
1307 * scan is in progress if the system is in Active mode *
1308 * AND it is not a ROAMING ("background") scan */
1309 if(((ePMM_STATE_BMPS_WAKEUP == pMac->pmm.gPmmState) ||
1310 (ePMM_STATE_READY == pMac->pmm.gPmmState)) &&
1311 (pScanReq->backgroundScanMode != eSIR_ROAMING_SCAN ) &&
1312 (!IS_ACTIVEMODE_OFFLOAD_FEATURE_ENABLE))
1313 {
Jeff Johnson295189b2012-06-20 16:38:30 -07001314 for(i=0;i<pMac->lim.maxBssId;i++)
1315 {
Ganesh Kondabattinif0fa07c2013-06-11 17:47:49 +05301316 if((peFindSessionBySessionId(pMac,i) != NULL) &&
1317 (pMac->lim.gpSession[i].valid == TRUE) &&
1318 (eLIM_MLM_LINK_ESTABLISHED_STATE == pMac->lim.gpSession[i].limMlmState))
1319 {
1320 limHeartBeatDeactivateAndChangeTimer(pMac, peFindSessionBySessionId(pMac,i));
1321 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001322 }
Ganesh Kondabattinif0fa07c2013-06-11 17:47:49 +05301323 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001324
Ganesh Kondabattinif0fa07c2013-06-11 17:47:49 +05301325 if (pMac->fScanOffload)
1326 {
1327 if (eHAL_STATUS_SUCCESS !=
1328 limSendHalStartScanOffloadReq(pMac, pScanReq))
1329 {
Rashmi Ramanna6c13a342014-01-07 11:44:07 +05301330 limLog(pMac, LOGE, FL("Couldn't send Offload scan request"));
Ganesh Kondabattinif0fa07c2013-06-11 17:47:49 +05301331 limSendSmeScanRsp(pMac,
1332 offsetof(tSirSmeScanRsp, bssDescription[0]),
1333 eSIR_SME_INVALID_PARAMETERS,
1334 pScanReq->sessionId,
1335 pScanReq->transactionId);
1336 return;
1337 }
1338 }
1339 else
1340 {
1341
1342 /*Change Global SME state */
1343 /* Store the previous SME state */
Rashmi Ramanna6c13a342014-01-07 11:44:07 +05301344 limLog(pMac, LOG1, FL("Non Offload SCAN request "));
Ganesh Kondabattinif0fa07c2013-06-11 17:47:49 +05301345 pMac->lim.gLimPrevSmeState = pMac->lim.gLimSmeState;
1346 pMac->lim.gLimSmeState = eLIM_SME_WT_SCAN_STATE;
1347 MTRACE(macTrace(pMac, TRACE_CODE_SME_STATE, pScanReq->sessionId, pMac->lim.gLimSmeState));
1348
1349 if (pScanReq->channelList.numChannels == 0)
1350 {
1351 tANI_U32 cfg_len;
Rashmi Ramanna6c13a342014-01-07 11:44:07 +05301352
1353 limLog(pMac, LOG1,
1354 FL("Scan all channels as Number of channels is 0"));
Ganesh Kondabattinif0fa07c2013-06-11 17:47:49 +05301355 // Scan all channels
1356 len = sizeof(tLimMlmScanReq) +
Jeff Johnson295189b2012-06-20 16:38:30 -07001357 (sizeof( pScanReq->channelList.channelNumber ) * (WNI_CFG_VALID_CHANNEL_LIST_LEN - 1)) +
1358 pScanReq->uIEFieldLen;
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301359 pMlmScanReq = vos_mem_malloc(len);
1360 if ( NULL == pMlmScanReq )
Ganesh Kondabattinif0fa07c2013-06-11 17:47:49 +05301361 {
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301362 // Log error
1363 limLog(pMac, LOGP,
1364 FL("call to AllocateMemory failed for mlmScanReq (%d)"), len);
Jeff Johnson295189b2012-06-20 16:38:30 -07001365
Ganesh Kondabattinif0fa07c2013-06-11 17:47:49 +05301366 return;
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301367 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001368
Ganesh Kondabattinif0fa07c2013-06-11 17:47:49 +05301369 // Initialize this buffer
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301370 vos_mem_set( (tANI_U8 *) pMlmScanReq, len, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07001371
Ganesh Kondabattinif0fa07c2013-06-11 17:47:49 +05301372 cfg_len = WNI_CFG_VALID_CHANNEL_LIST_LEN;
1373 if (wlan_cfgGetStr(pMac, WNI_CFG_VALID_CHANNEL_LIST,
Jeff Johnson295189b2012-06-20 16:38:30 -07001374 pMlmScanReq->channelList.channelNumber,
1375 &cfg_len) != eSIR_SUCCESS)
Ganesh Kondabattinif0fa07c2013-06-11 17:47:49 +05301376 {
1377 /**
1378 * Could not get Valid channel list from CFG.
1379 * Log error.
1380 */
1381 limLog(pMac, LOGP,
1382 FL("could not retrieve Valid channel list"));
1383 }
1384 pMlmScanReq->channelList.numChannels = (tANI_U8) cfg_len;
1385 }
1386 else
1387 {
1388 len = sizeof( tLimMlmScanReq ) - sizeof( pScanReq->channelList.channelNumber ) +
1389 (sizeof( pScanReq->channelList.channelNumber ) * pScanReq->channelList.numChannels ) +
1390 pScanReq->uIEFieldLen;
Jeff Johnson295189b2012-06-20 16:38:30 -07001391
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301392 pMlmScanReq = vos_mem_malloc(len);
1393 if ( NULL == pMlmScanReq )
Ganesh Kondabattinif0fa07c2013-06-11 17:47:49 +05301394 {
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301395 // Log error
1396 limLog(pMac, LOGP,
1397 FL("call to AllocateMemory failed for mlmScanReq(%d)"), len);
Jeff Johnson295189b2012-06-20 16:38:30 -07001398
Ganesh Kondabattinif0fa07c2013-06-11 17:47:49 +05301399 return;
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301400 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001401
Ganesh Kondabattinif0fa07c2013-06-11 17:47:49 +05301402 // Initialize this buffer
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301403 vos_mem_set( (tANI_U8 *) pMlmScanReq, len, 0);
Ganesh Kondabattinif0fa07c2013-06-11 17:47:49 +05301404 pMlmScanReq->channelList.numChannels =
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301405 pScanReq->channelList.numChannels;
Jeff Johnson295189b2012-06-20 16:38:30 -07001406
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301407 vos_mem_copy( pMlmScanReq->channelList.channelNumber,
1408 pScanReq->channelList.channelNumber,
1409 pScanReq->channelList.numChannels);
1410 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001411
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301412 pMlmScanReq->uIEFieldLen = pScanReq->uIEFieldLen;
1413 pMlmScanReq->uIEFieldOffset = len - pScanReq->uIEFieldLen;
1414 if(pScanReq->uIEFieldLen)
1415 {
1416 vos_mem_copy( (tANI_U8 *)pMlmScanReq+ pMlmScanReq->uIEFieldOffset,
1417 (tANI_U8 *)pScanReq+(pScanReq->uIEFieldOffset),
1418 pScanReq->uIEFieldLen);
1419 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001420
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301421 pMlmScanReq->bssType = pScanReq->bssType;
1422 vos_mem_copy( pMlmScanReq->bssId,
1423 pScanReq->bssId,
1424 sizeof(tSirMacAddr));
1425 pMlmScanReq->numSsid = pScanReq->numSsid;
Jeff Johnson295189b2012-06-20 16:38:30 -07001426
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301427 i = 0;
1428 while (i < pMlmScanReq->numSsid)
1429 {
1430 vos_mem_copy( (tANI_U8 *) &pMlmScanReq->ssId[i],
Jeff Johnson295189b2012-06-20 16:38:30 -07001431 (tANI_U8 *) &pScanReq->ssId[i],
1432 pScanReq->ssId[i].length + 1);
1433
Ganesh Kondabattinif0fa07c2013-06-11 17:47:49 +05301434 i++;
1435 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001436
Jeff Johnson295189b2012-06-20 16:38:30 -07001437
Ganesh Kondabattinif0fa07c2013-06-11 17:47:49 +05301438 pMlmScanReq->scanType = pScanReq->scanType;
1439 pMlmScanReq->backgroundScanMode = pScanReq->backgroundScanMode;
Ganesh Kondabattini8f6e3b32014-08-25 16:07:54 +05301440 if (pMac->miracast_mode)
1441 {
1442 pMlmScanReq->minChannelTime = DEFAULT_MIN_CHAN_TIME_DURING_MIRACAST;
1443 pMlmScanReq->maxChannelTime = DEFAULT_MAX_CHAN_TIME_DURING_MIRACAST;
1444 }
1445 else
1446 {
1447 pMlmScanReq->minChannelTime = pScanReq->minChannelTime;
1448 pMlmScanReq->maxChannelTime = pScanReq->maxChannelTime;
1449 }
1450
Ganesh Kondabattinif0fa07c2013-06-11 17:47:49 +05301451 pMlmScanReq->minChannelTimeBtc = pScanReq->minChannelTimeBtc;
1452 pMlmScanReq->maxChannelTimeBtc = pScanReq->maxChannelTimeBtc;
1453 pMlmScanReq->dot11mode = pScanReq->dot11mode;
1454 pMlmScanReq->p2pSearch = pScanReq->p2pSearch;
Jeff Johnson295189b2012-06-20 16:38:30 -07001455
Ganesh Kondabattinif0fa07c2013-06-11 17:47:49 +05301456 //Store the smeSessionID and transaction ID for later use.
1457 pMac->lim.gSmeSessionId = pScanReq->sessionId;
1458 pMac->lim.gTransactionId = pScanReq->transactionId;
Jeff Johnson295189b2012-06-20 16:38:30 -07001459
Ganesh Kondabattinif0fa07c2013-06-11 17:47:49 +05301460 // Issue LIM_MLM_SCAN_REQ to MLM
Rashmi Ramanna6c13a342014-01-07 11:44:07 +05301461 limLog(pMac, LOG1, FL("Issue Scan request command to MLM "));
Ganesh Kondabattinif0fa07c2013-06-11 17:47:49 +05301462 limPostMlmMessage(pMac, LIM_MLM_SCAN_REQ, (tANI_U32 *) pMlmScanReq);
1463 }
1464 } // if ((pMac->lim.gLimSmeState == eLIM_SME_IDLE_STATE) || ...
Jeff Johnson295189b2012-06-20 16:38:30 -07001465
1466 else
1467 {
1468 /// In all other cases return 'cached' scan results
1469 if ((pMac->lim.gLimRspReqd) || pMac->lim.gLimReportBackgroundScanResults)
1470 {
1471 tANI_U16 scanRspLen = sizeof(tSirSmeScanRsp);
1472
1473 pMac->lim.gLimRspReqd = false;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07001474#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
1475 if (pScanReq->returnFreshResults & SIR_BG_SCAN_RETURN_LFR_CACHED_RESULTS)
Jeff Johnson295189b2012-06-20 16:38:30 -07001476 {
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07001477 pMac->lim.gLimSmeLfrScanResultLength = pMac->lim.gLimMlmLfrScanResultLength;
1478 if (pMac->lim.gLimSmeLfrScanResultLength == 0)
1479 {
1480 limSendSmeLfrScanRsp(pMac, scanRspLen,
1481 eSIR_SME_SUCCESS,
1482 pScanReq->sessionId,
1483 pScanReq->transactionId);
1484 }
1485 else
1486 {
1487 scanRspLen = sizeof(tSirSmeScanRsp) +
1488 pMac->lim.gLimSmeLfrScanResultLength -
1489 sizeof(tSirBssDescription);
1490 limSendSmeLfrScanRsp(pMac, scanRspLen, eSIR_SME_SUCCESS,
1491 pScanReq->sessionId, pScanReq->transactionId);
1492 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001493 }
1494 else
1495 {
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07001496#endif
1497 if (pMac->lim.gLimSmeScanResultLength == 0)
1498 {
1499 limSendSmeScanRsp(pMac, scanRspLen, eSIR_SME_SUCCESS,
1500 pScanReq->sessionId, pScanReq->transactionId);
1501 }
1502 else
1503 {
1504 scanRspLen = sizeof(tSirSmeScanRsp) +
1505 pMac->lim.gLimSmeScanResultLength -
1506 sizeof(tSirBssDescription);
1507 limSendSmeScanRsp(pMac, scanRspLen, eSIR_SME_SUCCESS,
1508 pScanReq->sessionId, pScanReq->transactionId);
1509 }
1510#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
Jeff Johnson295189b2012-06-20 16:38:30 -07001511 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07001512#endif
Rashmi Ramanna6c13a342014-01-07 11:44:07 +05301513 limLog(pMac, LOG1, FL("Cached scan results are returned "));
Jeff Johnson295189b2012-06-20 16:38:30 -07001514
1515 if (pScanReq->returnFreshResults & SIR_BG_SCAN_PURGE_RESUTLS)
1516 {
1517 // Discard previously cached scan results
1518 limReInitScanResults(pMac);
1519 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07001520#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
1521 if (pScanReq->returnFreshResults & SIR_BG_SCAN_PURGE_LFR_RESULTS)
1522 {
1523 // Discard previously cached scan results
1524 limReInitLfrScanResults(pMac);
1525 }
1526#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001527
1528 } // if (pMac->lim.gLimRspReqd)
1529 } // else ((pMac->lim.gLimSmeState == eLIM_SME_IDLE_STATE) || ...
1530
Jeff Johnson295189b2012-06-20 16:38:30 -07001531#ifdef BACKGROUND_SCAN_ENABLED
1532 // start background scans if needed
1533 // There is a bug opened against softmac. Need to enable when the bug is fixed.
1534 __limBackgroundScanInitiate(pMac);
1535#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001536
1537} /*** end __limProcessSmeScanReq() ***/
1538
Jeff Johnsone7245742012-09-05 17:12:55 -07001539#ifdef FEATURE_OEM_DATA_SUPPORT
Jeff Johnson295189b2012-06-20 16:38:30 -07001540
Jeff Johnsone7245742012-09-05 17:12:55 -07001541static void __limProcessSmeOemDataReq(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
1542{
1543 tpSirOemDataReq pOemDataReq;
1544 tLimMlmOemDataReq* pMlmOemDataReq;
1545
1546 pOemDataReq = (tpSirOemDataReq) pMsgBuf;
1547
1548 //post the lim mlm message now
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301549 pMlmOemDataReq = vos_mem_malloc(sizeof(tLimMlmOemDataReq));
1550 if ( NULL == pMlmOemDataReq )
Jeff Johnsone7245742012-09-05 17:12:55 -07001551 {
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301552 limLog(pMac, LOGP, FL("AllocateMemory failed for mlmOemDataReq"));
Jeff Johnsone7245742012-09-05 17:12:55 -07001553 return;
1554 }
1555
1556 //Initialize this buffer
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301557 vos_mem_set( pMlmOemDataReq, (sizeof(tLimMlmOemDataReq)), 0);
Jeff Johnsone7245742012-09-05 17:12:55 -07001558
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301559 vos_mem_copy( pMlmOemDataReq->selfMacAddr, pOemDataReq->selfMacAddr,
1560 sizeof(tSirMacAddr));
1561 vos_mem_copy( pMlmOemDataReq->oemDataReq, pOemDataReq->oemDataReq,
1562 OEM_DATA_REQ_SIZE);
Jeff Johnsone7245742012-09-05 17:12:55 -07001563
1564 //Issue LIM_MLM_OEM_DATA_REQ to MLM
1565 limPostMlmMessage(pMac, LIM_MLM_OEM_DATA_REQ, (tANI_U32*)pMlmOemDataReq);
1566
1567 return;
1568
1569} /*** end __limProcessSmeOemDataReq() ***/
1570
1571#endif //FEATURE_OEM_DATA_SUPPORT
Jeff Johnson295189b2012-06-20 16:38:30 -07001572
Gopichand Nakkalac178ac82013-05-30 19:53:39 +05301573/**
1574 * __limProcessClearDfsChannelList()
1575 *
1576 *FUNCTION:
1577 *Clear DFS channel list when country is changed/aquired.
1578.*This message is sent from SME.
1579 *
1580 *LOGIC:
1581 *
1582 *ASSUMPTIONS:
1583 *
1584 *NOTE:
1585 *
1586 * @param pMac Pointer to Global MAC structure
1587 * @param *pMsgBuf A pointer to the SME message buffer
1588 * @return None
1589 */
1590static void __limProcessClearDfsChannelList(tpAniSirGlobal pMac,
1591 tpSirMsgQ pMsg)
1592{
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301593 vos_mem_set( &pMac->lim.dfschannelList,
1594 sizeof(tSirDFSChannelList), 0);
Gopichand Nakkalac178ac82013-05-30 19:53:39 +05301595}
Jeff Johnson295189b2012-06-20 16:38:30 -07001596
1597/**
1598 * __limProcessSmeJoinReq()
1599 *
1600 *FUNCTION:
1601 * This function is called to process SME_JOIN_REQ message
1602 * from HDD or upper layer application.
1603 *
1604 *LOGIC:
1605 *
1606 *ASSUMPTIONS:
1607 *
1608 *NOTE:
1609 *
1610 * @param pMac Pointer to Global MAC structure
1611 * @param *pMsgBuf A pointer to the SME message buffer
1612 * @return None
1613 */
Jeff Johnson295189b2012-06-20 16:38:30 -07001614static void
1615__limProcessSmeJoinReq(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
1616{
1617 // tANI_U8 *pBuf;
1618 //tANI_U32 len;
1619// tSirMacAddr currentBssId;
1620 tpSirSmeJoinReq pSmeJoinReq = NULL;
1621 tLimMlmJoinReq *pMlmJoinReq;
1622 tSirResultCodes retCode = eSIR_SME_SUCCESS;
1623 tANI_U32 val = 0;
1624 tANI_U16 nSize;
1625 tANI_U8 sessionId;
1626 tpPESession psessionEntry = NULL;
1627 tANI_U8 smesessionId;
1628 tANI_U16 smetransactionId;
1629 tPowerdBm localPowerConstraint = 0, regMax = 0;
Agarwal Ashish87039eb2014-01-15 14:13:15 +05301630 tANI_U16 ieLen;
1631 v_U8_t *vendorIE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001632
1633#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM //FEATURE_WLAN_DIAG_SUPPORT
1634 //Not sending any session, since it is not created yet. The response whould have correct state.
1635 limDiagEventReport(pMac, WLAN_PE_DIAG_JOIN_REQ_EVENT, NULL, 0, 0);
1636#endif //FEATURE_WLAN_DIAG_SUPPORT
1637
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001638 PELOG1(limLog(pMac, LOG1, FL("Received SME_JOIN_REQ"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001639
1640#ifdef WLAN_FEATURE_VOWIFI
1641 /* Need to read the CFG here itself as this is used in limExtractAPCapability() below.
1642 * This CFG is actually read in rrmUpdateConfig() which is called later. Because this is not
1643 * read, RRM related path before calling rrmUpdateConfig() is not getting executed causing issues
1644 * like not honoring power constraint on 1st association after driver loading. */
1645 if (wlan_cfgGetInt(pMac, WNI_CFG_RRM_ENABLED, &val) != eSIR_SUCCESS)
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001646 limLog(pMac, LOGP, FL("cfg get rrm enabled failed"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001647 pMac->rrm.rrmPEContext.rrmEnable = (val) ? 1 : 0;
1648 val = 0;
1649#endif /* WLAN_FEATURE_VOWIFI */
1650
1651 /**
1652 * Expect Join request in idle state.
1653 * Reassociate request is expected in link established state.
1654 */
1655
1656 /* Global SME and LIM states are not defined yet for BT-AMP Support */
1657 if(pMac->lim.gLimSmeState == eLIM_SME_IDLE_STATE)
1658 {
1659 nSize = __limGetSmeJoinReqSizeForAlloc((tANI_U8*) pMsgBuf);
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301660
1661 pSmeJoinReq = vos_mem_malloc(nSize);
1662 if ( NULL == pSmeJoinReq )
Jeff Johnson295189b2012-06-20 16:38:30 -07001663 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05301664 limLog(pMac, LOGP, FL("call to AllocateMemory failed for "
1665 "pSmeJoinReq"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001666 retCode = eSIR_SME_RESOURCES_UNAVAILABLE;
1667 goto end;
1668 }
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301669 (void) vos_mem_set((void *) pSmeJoinReq, nSize, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07001670
Jeff Johnson295189b2012-06-20 16:38:30 -07001671 if ((limJoinReqSerDes(pMac, pSmeJoinReq, (tANI_U8 *)pMsgBuf) == eSIR_FAILURE) ||
1672 (!limIsSmeJoinReqValid(pMac, pSmeJoinReq)))
1673 {
1674 /// Received invalid eWNI_SME_JOIN_REQ
1675 // Log the event
Padma, Santhosh Kumar2b47ca82014-01-03 16:57:27 +05301676 limLog(pMac, LOGW, FL("SessionId:%d Received SME_JOIN_REQ with"
1677 "invalid data"),pSmeJoinReq->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07001678 retCode = eSIR_SME_INVALID_PARAMETERS;
1679 goto end;
1680 }
1681
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301682 //pMac->lim.gpLimJoinReq = pSmeJoinReq; TO SUPPORT BT-AMP, review os sep 23
Jeff Johnson295189b2012-06-20 16:38:30 -07001683
1684 /* check for the existence of start BSS session */
1685#ifdef FIXME_GEN6
1686 if(pSmeJoinReq->bsstype == eSIR_BTAMP_AP_MODE)
1687 {
1688 if(peValidateBtJoinRequest(pMac)!= TRUE)
1689 {
Padma, Santhosh Kumar2b47ca82014-01-03 16:57:27 +05301690 limLog(pMac, LOGW, FL("SessionId:%d Start Bss session"
1691 "not present::SME_JOIN_REQ in unexpected state"),
1692 pSmeJoinReq->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07001693 retCode = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
1694 psessionEntry = NULL;
1695 goto end;
1696 }
1697 }
1698
1699#endif
1700
1701
1702 if((psessionEntry = peFindSessionByBssid(pMac,pSmeJoinReq->bssDescription.bssId,&sessionId)) != NULL)
1703 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05301704 limLog(pMac, LOGE, FL("Session(%d) Already exists for BSSID: "
Sushant Kaushik1b645382014-10-13 16:39:36 +05301705 MAC_ADDRESS_STR" in limSmeState = %d"),sessionId,
Abhishek Singh57aebef2014-02-03 18:47:44 +05301706 MAC_ADDR_ARRAY(pSmeJoinReq->bssDescription.bssId),
1707 psessionEntry->limSmeState);
Jeff Johnson295189b2012-06-20 16:38:30 -07001708
1709 if(psessionEntry->limSmeState == eLIM_SME_LINK_EST_STATE)
1710 {
1711 // Received eWNI_SME_JOIN_REQ for same
1712 // BSS as currently associated.
1713 // Log the event and send success
Padma, Santhosh Kumar2b47ca82014-01-03 16:57:27 +05301714 PELOGW(limLog(pMac, LOGW, FL("SessionId:%d Received"
1715 "SME_JOIN_REQ for currently joined BSS"),sessionId);)
Jeff Johnson295189b2012-06-20 16:38:30 -07001716 /// Send Join success response to host
Deepthi Gowrif3e27252013-12-11 20:50:01 +05301717 retCode = eSIR_SME_ALREADY_JOINED_A_BSS;
1718 psessionEntry = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07001719 goto end;
1720 }
1721 else
1722 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05301723 PELOGE(limLog(pMac, LOGE, FL("SME_JOIN_REQ not for"
1724 "currently joined BSS"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001725 retCode = eSIR_SME_REFUSED;
1726 psessionEntry = NULL;
1727 goto end;
1728 }
1729 }
1730 else /* Session Entry does not exist for given BSSId */
1731 {
1732 /* Try to Create a new session */
1733 if((psessionEntry = peCreateSession(pMac,pSmeJoinReq->bssDescription.bssId,&sessionId, pMac->lim.maxStation)) == NULL)
1734 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001735 limLog(pMac, LOGE, FL("Session Can not be created "));
Jeff Johnson295189b2012-06-20 16:38:30 -07001736 retCode = eSIR_SME_RESOURCES_UNAVAILABLE;
1737 goto end;
1738 }
Padma, Santhosh Kumar2b47ca82014-01-03 16:57:27 +05301739 else
1740 limLog(pMac,LOG1,FL("SessionId:%d New session created"),
1741 sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07001742 }
Jeff Johnsone7245742012-09-05 17:12:55 -07001743 handleHTCapabilityandHTInfo(pMac, psessionEntry);
krunal soni5afa96c2013-09-06 22:19:02 -07001744 psessionEntry->isAmsduSupportInAMPDU = pSmeJoinReq->isAmsduSupportInAMPDU;
Jeff Johnsone7245742012-09-05 17:12:55 -07001745
Jeff Johnson295189b2012-06-20 16:38:30 -07001746 /* Store Session related parameters */
1747 /* Store PE session Id in session Table */
1748 psessionEntry->peSessionId = sessionId;
1749
1750 /* store the smejoin req handle in session table */
1751 psessionEntry->pLimJoinReq = pSmeJoinReq;
1752
1753 /* Store SME session Id in sessionTable */
1754 psessionEntry->smeSessionId = pSmeJoinReq->sessionId;
1755
1756 /* Store SME transaction Id in session Table */
1757 psessionEntry->transactionId = pSmeJoinReq->transactionId;
1758
1759 /* Store beaconInterval */
1760 psessionEntry->beaconParams.beaconInterval = pSmeJoinReq->bssDescription.beaconInterval;
1761
1762 /* Copying of bssId is already done, while creating session */
1763 //sirCopyMacAddr(psessionEntry->bssId,pSmeJoinReq->bssId);
1764 sirCopyMacAddr(psessionEntry->selfMacAddr,pSmeJoinReq->selfMacAddr);
1765 psessionEntry->bssType = pSmeJoinReq->bsstype;
1766
1767 psessionEntry->statypeForBss = STA_ENTRY_PEER;
Sandeep Puligillaaea98a22013-12-04 13:36:32 +05301768 psessionEntry->limWmeEnabled = pSmeJoinReq->isWMEenabled;
1769 psessionEntry->limQosEnabled = pSmeJoinReq->isQosEnabled;
Jeff Johnson295189b2012-06-20 16:38:30 -07001770
Agarwal Ashish87039eb2014-01-15 14:13:15 +05301771 /* Store vendor specfic IE for CISCO AP */
1772 ieLen = (pSmeJoinReq->bssDescription.length +
1773 sizeof( pSmeJoinReq->bssDescription.length ) -
1774 GET_FIELD_OFFSET( tSirBssDescription, ieFields ));
1775
1776 vendorIE = limGetVendorIEOuiPtr(pMac, SIR_MAC_CISCO_OUI,
1777 SIR_MAC_CISCO_OUI_SIZE,
1778 ((tANI_U8 *)&pSmeJoinReq->bssDescription.ieFields) , ieLen);
1779
1780 if ( NULL != vendorIE )
1781 {
1782 limLog(pMac, LOGE,
1783 FL("DUT is trying to connect to Cisco AP"));
1784 psessionEntry->isCiscoVendorAP = TRUE;
1785 }
1786 else
1787 {
1788 psessionEntry->isCiscoVendorAP = FALSE;
1789 }
1790
Jeff Johnson295189b2012-06-20 16:38:30 -07001791 /* Copy the dot 11 mode in to the session table */
1792
1793 psessionEntry->dot11mode = pSmeJoinReq->dot11mode;
1794 psessionEntry->nwType = pSmeJoinReq->bssDescription.nwType;
Jeff Johnsone7245742012-09-05 17:12:55 -07001795#ifdef WLAN_FEATURE_11AC
1796 psessionEntry->vhtCapability = IS_DOT11_MODE_VHT(psessionEntry->dot11mode);
Jeff Johnson32d95a32012-09-10 13:15:23 -07001797 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO_MED,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001798 "***__limProcessSmeJoinReq: vhtCapability=%d****",psessionEntry->vhtCapability);
Shailender Karmuchi08f87c22013-01-17 12:51:24 -08001799 if (psessionEntry->vhtCapability )
1800 {
1801 psessionEntry->txBFIniFeatureEnabled = pSmeJoinReq->txBFIniFeatureEnabled;
1802
1803 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO_MED,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001804 "***__limProcessSmeJoinReq: txBFIniFeatureEnabled=%d****",
Shailender Karmuchi08f87c22013-01-17 12:51:24 -08001805 psessionEntry->txBFIniFeatureEnabled);
1806
1807 if( psessionEntry->txBFIniFeatureEnabled )
1808 {
1809 if (cfgSetInt(pMac, WNI_CFG_VHT_SU_BEAMFORMEE_CAP, psessionEntry->txBFIniFeatureEnabled)
1810 != eSIR_SUCCESS)
1811 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05301812 limLog(pMac, LOGP, FL("could not set "
1813 "WNI_CFG_VHT_SU_BEAMFORMEE_CAP at CFG"));
Shailender Karmuchi08f87c22013-01-17 12:51:24 -08001814 retCode = eSIR_LOGP_EXCEPTION;
1815 goto end;
1816 }
Shailender Karmuchicc3fe442013-02-16 18:18:33 -08001817 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO_MED,
Abhishek Singh57aebef2014-02-03 18:47:44 +05301818 "***__limProcessSmeJoinReq: txBFCsnValue=%d****",
1819 pSmeJoinReq->txBFCsnValue);
Shailender Karmuchicc3fe442013-02-16 18:18:33 -08001820
1821 if (cfgSetInt(pMac, WNI_CFG_VHT_CSN_BEAMFORMEE_ANT_SUPPORTED, pSmeJoinReq->txBFCsnValue)
Shailender Karmuchi08f87c22013-01-17 12:51:24 -08001822 != eSIR_SUCCESS)
1823 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05301824 limLog(pMac, LOGP, FL("could not set "
1825 "WNI_CFG_VHT_CSN_BEAMFORMEE_ANT_SUPPORTED at CFG"));
Shailender Karmuchi08f87c22013-01-17 12:51:24 -08001826 retCode = eSIR_LOGP_EXCEPTION;
1827 goto end;
1828 }
Abhishek Singh6d5d29c2014-07-03 14:25:22 +05301829
1830 if ( FALSE == pMac->isMuBfsessionexist )
1831 psessionEntry->txMuBformee = pSmeJoinReq->txMuBformee;
Shailender Karmuchi08f87c22013-01-17 12:51:24 -08001832 }
Abhishek Singh6d5d29c2014-07-03 14:25:22 +05301833
1834 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
1835 "SmeJoinReq:txMuBformee=%d psessionEntry: txMuBformee = %d",
1836 pSmeJoinReq->txMuBformee, psessionEntry->txMuBformee);
1837
1838 if(cfgSetInt(pMac, WNI_CFG_VHT_MU_BEAMFORMEE_CAP, psessionEntry->txMuBformee)
1839 != eSIR_SUCCESS)
1840 {
1841 limLog(pMac, LOGE, FL("could not set "
1842 "WNI_CFG_VHT_MU_BEAMFORMEE_CAP at CFG"));
1843 retCode = eSIR_LOGP_EXCEPTION;
1844 goto end;
1845 }
1846
Shailender Karmuchi08f87c22013-01-17 12:51:24 -08001847 }
1848
Jeff Johnsone7245742012-09-05 17:12:55 -07001849#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001850
1851 /*Phy mode*/
1852 psessionEntry->gLimPhyMode = pSmeJoinReq->bssDescription.nwType;
1853
1854 /* Copy The channel Id to the session Table */
1855 psessionEntry->currentOperChannel = pSmeJoinReq->bssDescription.channelId;
Jeff Johnsone7245742012-09-05 17:12:55 -07001856 psessionEntry->htSupportedChannelWidthSet = (pSmeJoinReq->cbMode)?1:0; // This is already merged value of peer and self - done by csr in csrGetCBModeFromIes
1857 psessionEntry->htRecommendedTxWidthSet = psessionEntry->htSupportedChannelWidthSet;
1858 psessionEntry->htSecondaryChannelOffset = pSmeJoinReq->cbMode;
Jeff Johnson295189b2012-06-20 16:38:30 -07001859
Chet Lanctot186b5732013-03-18 10:26:30 -07001860 /* Record if management frames need to be protected */
1861#ifdef WLAN_FEATURE_11W
1862 if(eSIR_ED_AES_128_CMAC == pSmeJoinReq->MgmtEncryptionType)
1863 {
1864 psessionEntry->limRmfEnabled = 1;
1865 }
1866 else
1867 {
1868 psessionEntry->limRmfEnabled = 0;
1869 }
1870#endif
1871
krunal soni8d13b092013-07-19 13:23:29 -07001872#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM
1873 psessionEntry->rssi = pSmeJoinReq->bssDescription.rssi;
1874#endif
1875
Jeff Johnson295189b2012-06-20 16:38:30 -07001876 /*Store Persona */
1877 psessionEntry->pePersona = pSmeJoinReq->staPersona;
1878 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
Abhishek Singh57aebef2014-02-03 18:47:44 +05301879 FL("PE PERSONA=%d cbMode %u"), psessionEntry->pePersona,
1880 pSmeJoinReq->cbMode);
Jeff Johnson295189b2012-06-20 16:38:30 -07001881
1882 /* Copy the SSID from smejoinreq to session entry */
1883 psessionEntry->ssId.length = pSmeJoinReq->ssId.length;
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301884 vos_mem_copy( psessionEntry->ssId.ssId,
1885 pSmeJoinReq->ssId.ssId, psessionEntry->ssId.length);
1886
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001887 // Determin 11r or ESE connection based on input from SME
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301888 // which inturn is dependent on the profile the user wants to connect
1889 // to, So input is coming from supplicant
Jeff Johnson295189b2012-06-20 16:38:30 -07001890#ifdef WLAN_FEATURE_VOWIFI_11R
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301891 psessionEntry->is11Rconnection = pSmeJoinReq->is11Rconnection;
Jeff Johnson295189b2012-06-20 16:38:30 -07001892#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001893#ifdef FEATURE_WLAN_ESE
1894 psessionEntry->isESEconnection = pSmeJoinReq->isESEconnection;
Jeff Johnson295189b2012-06-20 16:38:30 -07001895#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001896#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301897 psessionEntry->isFastTransitionEnabled = pSmeJoinReq->isFastTransitionEnabled;
Jeff Johnson295189b2012-06-20 16:38:30 -07001898#endif
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301899
Jeff Johnson43971f52012-07-17 12:26:56 -07001900#ifdef FEATURE_WLAN_LFR
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301901 psessionEntry->isFastRoamIniFeatureEnabled = pSmeJoinReq->isFastRoamIniFeatureEnabled;
Jeff Johnson43971f52012-07-17 12:26:56 -07001902#endif
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301903 psessionEntry->txLdpcIniFeatureEnabled = pSmeJoinReq->txLdpcIniFeatureEnabled;
Gopichand Nakkalab2d2c312013-01-04 11:41:02 -08001904
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301905 if (psessionEntry->bssType == eSIR_INFRASTRUCTURE_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07001906 {
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301907 psessionEntry->limSystemRole = eLIM_STA_ROLE;
1908 }
1909 else if (psessionEntry->bssType == eSIR_BTAMP_AP_MODE)
1910 {
1911 psessionEntry->limSystemRole = eLIM_BT_AMP_STA_ROLE;
1912 }
1913 else
1914 {
1915 /* Throw an error and return and make sure to delete the session.*/
Abhishek Singh57aebef2014-02-03 18:47:44 +05301916 limLog(pMac, LOGE, FL("received SME_JOIN_REQ with invalid"
1917 " bss type %d"), psessionEntry->bssType);
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301918 retCode = eSIR_SME_INVALID_PARAMETERS;
1919 goto end;
1920 }
1921
1922 if (pSmeJoinReq->addIEScan.length)
1923 {
1924 vos_mem_copy( &psessionEntry->pLimJoinReq->addIEScan,
Jeff Johnson295189b2012-06-20 16:38:30 -07001925 &pSmeJoinReq->addIEScan, sizeof(tSirAddie));
1926 }
1927
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301928 if (pSmeJoinReq->addIEAssoc.length)
Jeff Johnson295189b2012-06-20 16:38:30 -07001929 {
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301930 vos_mem_copy( &psessionEntry->pLimJoinReq->addIEAssoc,
Jeff Johnson295189b2012-06-20 16:38:30 -07001931 &pSmeJoinReq->addIEAssoc, sizeof(tSirAddie));
1932 }
1933
Jeff Johnson295189b2012-06-20 16:38:30 -07001934 val = sizeof(tLimMlmJoinReq) + psessionEntry->pLimJoinReq->bssDescription.length + 2;
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301935 pMlmJoinReq = vos_mem_malloc(val);
1936 if ( NULL == pMlmJoinReq )
Jeff Johnson295189b2012-06-20 16:38:30 -07001937 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05301938 limLog(pMac, LOGP, FL("call to AllocateMemory "
1939 "failed for mlmJoinReq"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001940 return;
1941 }
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301942 (void) vos_mem_set((void *) pMlmJoinReq, val, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07001943
1944 /* PE SessionId is stored as a part of JoinReq*/
1945 pMlmJoinReq->sessionId = psessionEntry->peSessionId;
1946
1947 if (wlan_cfgGetInt(pMac, WNI_CFG_JOIN_FAILURE_TIMEOUT, (tANI_U32 *) &pMlmJoinReq->joinFailureTimeout)
1948 != eSIR_SUCCESS)
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001949 limLog(pMac, LOGP, FL("could not retrieve JoinFailureTimer value"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001950
1951 /* copy operational rate from psessionEntry*/
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301952 vos_mem_copy((void*)&psessionEntry->rateSet, (void*)&pSmeJoinReq->operationalRateSet,
Jeff Johnson295189b2012-06-20 16:38:30 -07001953 sizeof(tSirMacRateSet));
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301954 vos_mem_copy((void*)&psessionEntry->extRateSet, (void*)&pSmeJoinReq->extendedRateSet,
Jeff Johnson295189b2012-06-20 16:38:30 -07001955 sizeof(tSirMacRateSet));
1956 //this may not be needed anymore now, as rateSet is now included in the session entry and MLM has session context.
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301957 vos_mem_copy((void*)&pMlmJoinReq->operationalRateSet, (void*)&psessionEntry->rateSet,
Jeff Johnson295189b2012-06-20 16:38:30 -07001958 sizeof(tSirMacRateSet));
1959
1960 psessionEntry->encryptType = pSmeJoinReq->UCEncryptionType;
1961
Jeff Johnson295189b2012-06-20 16:38:30 -07001962 pMlmJoinReq->bssDescription.length = psessionEntry->pLimJoinReq->bssDescription.length;
1963
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301964 vos_mem_copy((tANI_U8 *) &pMlmJoinReq->bssDescription.bssId,
Jeff Johnson295189b2012-06-20 16:38:30 -07001965 (tANI_U8 *) &psessionEntry->pLimJoinReq->bssDescription.bssId,
1966 psessionEntry->pLimJoinReq->bssDescription.length + 2);
1967
Jeff Johnson295189b2012-06-20 16:38:30 -07001968 psessionEntry->limCurrentBssCaps =
Jeff Johnsone7245742012-09-05 17:12:55 -07001969 psessionEntry->pLimJoinReq->bssDescription.capabilityInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07001970
Jeff Johnsone7245742012-09-05 17:12:55 -07001971 regMax = cfgGetRegulatoryMaxTransmitPower( pMac, psessionEntry->currentOperChannel );
Sandeep Puligillaa9eb9ad2014-05-27 14:42:50 +05301972 localPowerConstraint = regMax;
Jeff Johnsone7245742012-09-05 17:12:55 -07001973 limExtractApCapability( pMac,
1974 (tANI_U8 *) psessionEntry->pLimJoinReq->bssDescription.ieFields,
1975 limGetIElenFromBssDescription(&psessionEntry->pLimJoinReq->bssDescription),
1976 &psessionEntry->limCurrentBssQosCaps,
1977 &psessionEntry->limCurrentBssPropCap,
1978 &pMac->lim.gLimCurrentBssUapsd //TBD-RAJESH make gLimCurrentBssUapsd this session specific
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07001979 , &localPowerConstraint,
1980 psessionEntry
Sandeep Puligilla4ce02592014-04-22 09:05:57 +05301981 );
Sandeep Puligillaa9eb9ad2014-05-27 14:42:50 +05301982
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001983#ifdef FEATURE_WLAN_ESE
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001984 psessionEntry->maxTxPower = limGetMaxTxPower(regMax, localPowerConstraint, pMac->roam.configParam.nTxPowerCap);
Jeff Johnson295189b2012-06-20 16:38:30 -07001985#else
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301986 psessionEntry->maxTxPower = VOS_MIN( regMax, (localPowerConstraint) );
Jeff Johnson295189b2012-06-20 16:38:30 -07001987#endif
Sandeep Puligilla4ce02592014-04-22 09:05:57 +05301988 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
1989 "Regulatory max = %d, local power constraint = %d,"
Abhishek Singh57aebef2014-02-03 18:47:44 +05301990 " max tx = %d", regMax, localPowerConstraint,
1991 psessionEntry->maxTxPower );
Jeff Johnson295189b2012-06-20 16:38:30 -07001992
1993 if (pMac->lim.gLimCurrentBssUapsd)
1994 {
1995 pMac->lim.gUapsdPerAcBitmask = psessionEntry->pLimJoinReq->uapsdPerAcBitmask;
Abhishek Singh57aebef2014-02-03 18:47:44 +05301996 limLog( pMac, LOG1, FL("UAPSD flag for all AC - 0x%2x"),
1997 pMac->lim.gUapsdPerAcBitmask);
Jeff Johnson295189b2012-06-20 16:38:30 -07001998
1999 // resetting the dynamic uapsd mask
2000 pMac->lim.gUapsdPerAcDeliveryEnableMask = 0;
2001 pMac->lim.gUapsdPerAcTriggerEnableMask = 0;
2002 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002003
2004 psessionEntry->limRFBand = limGetRFBand(psessionEntry->currentOperChannel);
2005
2006 // Initialize 11h Enable Flag
2007 if(SIR_BAND_5_GHZ == psessionEntry->limRFBand)
2008 {
2009 if (wlan_cfgGetInt(pMac, WNI_CFG_11H_ENABLED, &val) != eSIR_SUCCESS)
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002010 limLog(pMac, LOGP, FL("Fail to get WNI_CFG_11H_ENABLED "));
Jeff Johnson295189b2012-06-20 16:38:30 -07002011 psessionEntry->lim11hEnable = val;
2012 }
2013 else
2014 psessionEntry->lim11hEnable = 0;
2015
2016 //To care of the scenario when STA transitions from IBSS to Infrastructure mode.
2017 pMac->lim.gLimIbssCoalescingHappened = false;
2018
Jeff Johnsone7245742012-09-05 17:12:55 -07002019 psessionEntry->limPrevSmeState = psessionEntry->limSmeState;
2020 psessionEntry->limSmeState = eLIM_SME_WT_JOIN_STATE;
2021 MTRACE(macTrace(pMac, TRACE_CODE_SME_STATE, psessionEntry->peSessionId, psessionEntry->limSmeState));
Jeff Johnson295189b2012-06-20 16:38:30 -07002022
Abhishek Singh57aebef2014-02-03 18:47:44 +05302023 limLog(pMac, LOG1, FL("SME JoinReq:Sessionid %d SSID len %d SSID : %s "
2024 "Channel %d, BSSID "MAC_ADDRESS_STR), pMlmJoinReq->sessionId,
2025 psessionEntry->ssId.length,psessionEntry->ssId.ssId,
2026 psessionEntry->currentOperChannel,
2027 MAC_ADDR_ARRAY(psessionEntry->bssId));
Jeff Johnson295189b2012-06-20 16:38:30 -07002028
2029 /* Indicate whether spectrum management is enabled*/
2030 psessionEntry->spectrumMgtEnabled =
2031 pSmeJoinReq->spectrumMgtIndicator;
Rajesh Babu Prathipati043149f2014-06-06 13:33:45 +05302032
2033 /* Enable the spectrum management if this is a DFS channel */
2034 if (psessionEntry->countryInfoPresent &&
2035 limIsconnectedOnDFSChannel(psessionEntry->currentOperChannel))
2036 {
2037 psessionEntry->spectrumMgtEnabled = TRUE;
2038 }
2039
Padma, Santhosh Kumar2b47ca82014-01-03 16:57:27 +05302040 PELOG1(limLog(pMac,LOG1,FL("SessionId:%d MLM_JOIN_REQ is posted to MLM"
2041 "SM"),pMlmJoinReq->sessionId));
Jeff Johnson295189b2012-06-20 16:38:30 -07002042 /* Issue LIM_MLM_JOIN_REQ to MLM */
2043 limPostMlmMessage(pMac, LIM_MLM_JOIN_REQ, (tANI_U32 *) pMlmJoinReq);
2044 return;
2045
2046 }
2047 else
2048 {
2049 /* Received eWNI_SME_JOIN_REQ un expected state */
Abhishek Singh57aebef2014-02-03 18:47:44 +05302050 limLog(pMac, LOGE, FL("received unexpected SME_JOIN_REQ "
Sushant Kaushik1b645382014-10-13 16:39:36 +05302051 "in state %d"), pMac->lim.gLimSmeState);
Jeff Johnson295189b2012-06-20 16:38:30 -07002052 limPrintSmeState(pMac, LOGE, pMac->lim.gLimSmeState);
2053 retCode = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
2054 psessionEntry = NULL;
2055 goto end;
2056
2057 }
2058
2059end:
2060 limGetSessionInfo(pMac,(tANI_U8*)pMsgBuf,&smesessionId,&smetransactionId);
2061
2062 if(pSmeJoinReq)
2063 {
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302064 vos_mem_free(pSmeJoinReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07002065 pSmeJoinReq = NULL;
2066 if (NULL != psessionEntry)
2067 {
2068 psessionEntry->pLimJoinReq = NULL;
2069 }
2070 }
2071
2072 if(retCode != eSIR_SME_SUCCESS)
2073 {
2074 if(NULL != psessionEntry)
2075 {
2076 peDeleteSession(pMac,psessionEntry);
2077 psessionEntry = NULL;
2078 }
2079 }
Abhishek Singh57aebef2014-02-03 18:47:44 +05302080 limLog(pMac, LOG1, FL("Sending failure status limSendSmeJoinReassocRsp"
2081 "on sessionid: %d with retCode = %d"),smesessionId, retCode);
Jeff Johnson295189b2012-06-20 16:38:30 -07002082 limSendSmeJoinReassocRsp(pMac, eWNI_SME_JOIN_RSP, retCode, eSIR_MAC_UNSPEC_FAILURE_STATUS,psessionEntry,smesessionId,smetransactionId);
2083} /*** end __limProcessSmeJoinReq() ***/
2084
2085
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002086#ifdef FEATURE_WLAN_ESE
Madan Mohan Koyyalamudi3282c572012-11-09 17:01:41 -08002087tANI_U8 limGetMaxTxPower(tPowerdBm regMax, tPowerdBm apTxPower, tANI_U8 iniTxPower)
Jeff Johnson295189b2012-06-20 16:38:30 -07002088{
2089 tANI_U8 maxTxPower = 0;
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302090 tANI_U8 txPower = VOS_MIN( regMax, (apTxPower) );
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002091 txPower = VOS_MIN(txPower, iniTxPower);
Jeff Johnson295189b2012-06-20 16:38:30 -07002092 if((txPower >= MIN_TX_PWR_CAP) && (txPower <= MAX_TX_PWR_CAP))
2093 maxTxPower = txPower;
2094 else if (txPower < MIN_TX_PWR_CAP)
2095 maxTxPower = MIN_TX_PWR_CAP;
2096 else
2097 maxTxPower = MAX_TX_PWR_CAP;
2098
2099 return (maxTxPower);
2100}
2101#endif
2102
Jeff Johnson295189b2012-06-20 16:38:30 -07002103/**
2104 * __limProcessSmeReassocReq()
2105 *
2106 *FUNCTION:
2107 * This function is called to process SME_REASSOC_REQ message
2108 * from HDD or upper layer application.
2109 *
2110 *LOGIC:
2111 *
2112 *ASSUMPTIONS:
2113 *
2114 *NOTE:
2115 *
2116 * @param pMac Pointer to Global MAC structure
2117 * @param *pMsgBuf A pointer to the SME message buffer
2118 * @return None
2119 */
2120
2121static void
2122__limProcessSmeReassocReq(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
2123{
2124 tANI_U16 caps;
2125 tANI_U32 val;
Srinivas Girigowdac16730e2013-01-16 13:39:39 -08002126 tpSirSmeJoinReq pReassocReq = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002127 tLimMlmReassocReq *pMlmReassocReq;
2128 tSirResultCodes retCode = eSIR_SME_SUCCESS;
2129 tpPESession psessionEntry = NULL;
2130 tANI_U8 sessionId;
2131 tANI_U8 smeSessionId;
2132 tANI_U16 transactionId;
2133 tPowerdBm localPowerConstraint = 0, regMax = 0;
2134 tANI_U32 teleBcnEn = 0;
Madan Mohan Koyyalamudi7df624d2012-10-31 16:32:50 -07002135 tANI_U16 nSize;
Jeff Johnson295189b2012-06-20 16:38:30 -07002136
2137
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002138 PELOG3(limLog(pMac, LOG3, FL("Received REASSOC_REQ"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07002139
Madan Mohan Koyyalamudi7df624d2012-10-31 16:32:50 -07002140 nSize = __limGetSmeJoinReqSizeForAlloc((tANI_U8 *) pMsgBuf);
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302141 pReassocReq = vos_mem_malloc(nSize);
2142 if ( NULL == pReassocReq )
Jeff Johnson295189b2012-06-20 16:38:30 -07002143 {
2144 // Log error
2145 limLog(pMac, LOGP,
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302146 FL("call to AllocateMemory failed for pReassocReq"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002147
2148 retCode = eSIR_SME_RESOURCES_UNAVAILABLE;
2149 goto end;
2150 }
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302151 (void) vos_mem_set((void *) pReassocReq, nSize, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07002152 if ((limJoinReqSerDes(pMac, (tpSirSmeJoinReq) pReassocReq,
2153 (tANI_U8 *) pMsgBuf) == eSIR_FAILURE) ||
2154 (!limIsSmeJoinReqValid(pMac,
2155 (tpSirSmeJoinReq) pReassocReq)))
2156 {
2157 /// Received invalid eWNI_SME_REASSOC_REQ
2158 // Log the event
2159 limLog(pMac, LOGW,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002160 FL("received SME_REASSOC_REQ with invalid data"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002161
2162 retCode = eSIR_SME_INVALID_PARAMETERS;
2163 goto end;
2164 }
2165
2166 if((psessionEntry = peFindSessionByBssid(pMac,pReassocReq->bssDescription.bssId,&sessionId))==NULL)
2167 {
2168 limPrintMacAddr(pMac, pReassocReq->bssDescription.bssId, LOGE);
Srinivas Girigowda2a69dcf2013-09-13 14:48:34 -07002169 limLog(pMac, LOGE, FL("Session does not exist for given bssId"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002170 retCode = eSIR_SME_INVALID_PARAMETERS;
2171 goto end;
2172 }
2173
2174#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM //FEATURE_WLAN_DIAG_SUPPORT
2175 limDiagEventReport(pMac, WLAN_PE_DIAG_REASSOC_REQ_EVENT, psessionEntry, 0, 0);
2176#endif //FEATURE_WLAN_DIAG_SUPPORT
2177 //pMac->lim.gpLimReassocReq = pReassocReq;//TO SUPPORT BT-AMP
2178
2179 /* Store the reassoc handle in the session Table.. 23rd sep review */
2180 psessionEntry->pLimReAssocReq = pReassocReq;
Padma, Santhosh Kumar0d25d102014-07-17 15:08:48 +05302181 psessionEntry->dot11mode = pReassocReq->dot11mode;
2182 psessionEntry->vhtCapability = IS_DOT11_MODE_VHT(pReassocReq->dot11mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07002183
2184 /**
2185 * Reassociate request is expected
2186 * in link established state only.
2187 */
2188
2189 if (psessionEntry->limSmeState != eLIM_SME_LINK_EST_STATE)
2190 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002191#if defined(WLAN_FEATURE_VOWIFI_11R) || defined(FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07002192 if (psessionEntry->limSmeState == eLIM_SME_WT_REASSOC_STATE)
2193 {
2194 // May be from 11r FT pre-auth. So lets check it before we bail out
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08002195 limLog(pMac, LOG1, FL("Session in reassoc state is %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002196 psessionEntry->peSessionId);
2197
2198 // Make sure its our preauth bssid
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302199 if (!vos_mem_compare( pReassocReq->bssDescription.bssId,
Jeff Johnson295189b2012-06-20 16:38:30 -07002200 pMac->ft.ftPEContext.pFTPreAuthReq->preAuthbssId, 6))
2201 {
2202 limPrintMacAddr(pMac, pReassocReq->bssDescription.bssId, LOGE);
2203 limPrintMacAddr(pMac, pMac->ft.ftPEContext.pFTPreAuthReq->preAuthbssId, LOGE);
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002204 limLog(pMac, LOGP, FL("Unknown bssId in reassoc state"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002205 retCode = eSIR_SME_INVALID_PARAMETERS;
2206 goto end;
2207 }
2208
2209 limProcessMlmFTReassocReq(pMac, pMsgBuf, psessionEntry);
2210 return;
2211 }
2212#endif
2213 /// Should not have received eWNI_SME_REASSOC_REQ
2214 // Log the event
2215 limLog(pMac, LOGE,
Sushant Kaushik1b645382014-10-13 16:39:36 +05302216 FL("received unexpected SME_REASSOC_REQ in state %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002217 psessionEntry->limSmeState);
2218 limPrintSmeState(pMac, LOGE, psessionEntry->limSmeState);
2219
2220 retCode = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
2221 goto end;
2222 }
2223
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302224 vos_mem_copy( psessionEntry->limReAssocbssId,
Jeff Johnson295189b2012-06-20 16:38:30 -07002225 psessionEntry->pLimReAssocReq->bssDescription.bssId,
2226 sizeof(tSirMacAddr));
2227
2228 psessionEntry->limReassocChannelId =
2229 psessionEntry->pLimReAssocReq->bssDescription.channelId;
2230
Jeff Johnsone7245742012-09-05 17:12:55 -07002231 psessionEntry->reAssocHtSupportedChannelWidthSet =
2232 (psessionEntry->pLimReAssocReq->cbMode)?1:0;
2233 psessionEntry->reAssocHtRecommendedTxWidthSet =
2234 psessionEntry->reAssocHtSupportedChannelWidthSet;
2235 psessionEntry->reAssocHtSecondaryChannelOffset =
2236 psessionEntry->pLimReAssocReq->cbMode;
2237
Jeff Johnson295189b2012-06-20 16:38:30 -07002238 psessionEntry->limReassocBssCaps =
2239 psessionEntry->pLimReAssocReq->bssDescription.capabilityInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07002240 regMax = cfgGetRegulatoryMaxTransmitPower( pMac, psessionEntry->currentOperChannel );
2241 localPowerConstraint = regMax;
2242 limExtractApCapability( pMac,
2243 (tANI_U8 *) psessionEntry->pLimReAssocReq->bssDescription.ieFields,
2244 limGetIElenFromBssDescription(
2245 &psessionEntry->pLimReAssocReq->bssDescription),
2246 &psessionEntry->limReassocBssQosCaps,
2247 &psessionEntry->limReassocBssPropCap,
2248 &pMac->lim.gLimCurrentBssUapsd //TBD-RAJESH make gLimReassocBssUapsd session specific
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07002249 , &localPowerConstraint,
2250 psessionEntry
Jeff Johnson295189b2012-06-20 16:38:30 -07002251 );
2252
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302253 psessionEntry->maxTxPower = VOS_MIN( regMax, (localPowerConstraint) );
Jeff Johnson295189b2012-06-20 16:38:30 -07002254#if defined WLAN_VOWIFI_DEBUG
Abhishek Singh57aebef2014-02-03 18:47:44 +05302255 limLog( pMac, LOGE, "Regulatory max = %d, local power constraint "
2256 "= %d, max tx = %d", regMax, localPowerConstraint,
2257 psessionEntry->maxTxPower );
Jeff Johnson295189b2012-06-20 16:38:30 -07002258#endif
2259 {
2260 #if 0
2261 if (wlan_cfgGetStr(pMac, WNI_CFG_SSID, pMac->lim.gLimReassocSSID.ssId,
2262 &cfgLen) != eSIR_SUCCESS)
2263 {
2264 /// Could not get SSID from CFG. Log error.
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002265 limLog(pMac, LOGP, FL("could not retrive SSID"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002266 }
2267 #endif//TO SUPPORT BT-AMP
2268
2269 /* Copy the SSID from sessio entry to local variable */
2270 #if 0
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302271 vos_mem_copy( pMac->lim.gLimReassocSSID.ssId,
Jeff Johnson295189b2012-06-20 16:38:30 -07002272 psessionEntry->ssId.ssId,
2273 psessionEntry->ssId.length);
2274 #endif
2275 psessionEntry->limReassocSSID.length = pReassocReq->ssId.length;
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302276 vos_mem_copy( psessionEntry->limReassocSSID.ssId,
Jeff Johnson295189b2012-06-20 16:38:30 -07002277 pReassocReq->ssId.ssId, psessionEntry->limReassocSSID.length);
2278
2279 }
2280
2281 if (pMac->lim.gLimCurrentBssUapsd)
2282 {
2283 pMac->lim.gUapsdPerAcBitmask = psessionEntry->pLimReAssocReq->uapsdPerAcBitmask;
Abhishek Singh57aebef2014-02-03 18:47:44 +05302284 limLog( pMac, LOG1, FL("UAPSD flag for all AC - 0x%2x"),
2285 pMac->lim.gUapsdPerAcBitmask);
Jeff Johnson295189b2012-06-20 16:38:30 -07002286 }
2287
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302288 pMlmReassocReq = vos_mem_malloc(sizeof(tLimMlmReassocReq));
2289 if ( NULL == pMlmReassocReq )
Jeff Johnson295189b2012-06-20 16:38:30 -07002290 {
2291 // Log error
2292 limLog(pMac, LOGP,
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302293 FL("call to AllocateMemory failed for mlmReassocReq"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002294
2295 retCode = eSIR_SME_RESOURCES_UNAVAILABLE;
2296 goto end;
2297 }
2298
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302299 vos_mem_copy( pMlmReassocReq->peerMacAddr,
Jeff Johnson295189b2012-06-20 16:38:30 -07002300 psessionEntry->limReAssocbssId,
2301 sizeof(tSirMacAddr));
2302
2303 if (wlan_cfgGetInt(pMac, WNI_CFG_REASSOCIATION_FAILURE_TIMEOUT,
2304 (tANI_U32 *) &pMlmReassocReq->reassocFailureTimeout)
2305 != eSIR_SUCCESS)
2306 {
2307 /**
2308 * Could not get ReassocFailureTimeout value
2309 * from CFG. Log error.
2310 */
2311 limLog(pMac, LOGP,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002312 FL("could not retrieve ReassocFailureTimeout value"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002313 }
2314
2315 if (cfgGetCapabilityInfo(pMac, &caps,psessionEntry) != eSIR_SUCCESS)
2316 {
2317 /**
2318 * Could not get Capabilities value
2319 * from CFG. Log error.
2320 */
2321 limLog(pMac, LOGP,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002322 FL("could not retrieve Capabilities value"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002323 }
2324 pMlmReassocReq->capabilityInfo = caps;
2325
2326 /* Update PE sessionId*/
2327 pMlmReassocReq->sessionId = sessionId;
2328
2329 /* If telescopic beaconing is enabled, set listen interval to
2330 WNI_CFG_TELE_BCN_MAX_LI */
2331 if(wlan_cfgGetInt(pMac, WNI_CFG_TELE_BCN_WAKEUP_EN, &teleBcnEn) !=
2332 eSIR_SUCCESS)
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002333 limLog(pMac, LOGP, FL("Couldn't get WNI_CFG_TELE_BCN_WAKEUP_EN"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002334
2335 val = WNI_CFG_LISTEN_INTERVAL_STADEF;
2336
2337 if(teleBcnEn)
2338 {
2339 if(wlan_cfgGetInt(pMac, WNI_CFG_TELE_BCN_MAX_LI, &val) !=
2340 eSIR_SUCCESS)
2341 {
2342 /**
2343 * Could not get ListenInterval value
2344 * from CFG. Log error.
2345 */
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002346 limLog(pMac, LOGP, FL("could not retrieve ListenInterval"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002347 }
2348 }
2349 else
2350 {
2351 if (wlan_cfgGetInt(pMac, WNI_CFG_LISTEN_INTERVAL, &val) != eSIR_SUCCESS)
2352 {
2353 /**
2354 * Could not get ListenInterval value
2355 * from CFG. Log error.
2356 */
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002357 limLog(pMac, LOGP, FL("could not retrieve ListenInterval"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002358 }
2359 }
2360
2361 /* Delete all BA sessions before Re-Assoc.
2362 * BA frames are class 3 frames and the session
2363 * is lost upon disassociation and reassociation.
2364 */
2365
Ganesh Kondabattini01f75c92014-07-07 19:27:41 +05302366 limDeleteBASessions(pMac, psessionEntry, BA_BOTH_DIRECTIONS,
2367 eSIR_MAC_UNSPEC_FAILURE_REASON);
Jeff Johnson295189b2012-06-20 16:38:30 -07002368
2369 pMlmReassocReq->listenInterval = (tANI_U16) val;
2370
2371 /* Indicate whether spectrum management is enabled*/
2372 psessionEntry->spectrumMgtEnabled = pReassocReq->spectrumMgtIndicator;
2373
Rajesh Babu Prathipati043149f2014-06-06 13:33:45 +05302374 /* Enable the spectrum management if this is a DFS channel */
2375 if (psessionEntry->countryInfoPresent &&
2376 limIsconnectedOnDFSChannel(psessionEntry->currentOperChannel))
2377 {
2378 psessionEntry->spectrumMgtEnabled = TRUE;
2379 }
2380
Jeff Johnson295189b2012-06-20 16:38:30 -07002381 psessionEntry->limPrevSmeState = psessionEntry->limSmeState;
2382 psessionEntry->limSmeState = eLIM_SME_WT_REASSOC_STATE;
2383
Jeff Johnsone7245742012-09-05 17:12:55 -07002384 MTRACE(macTrace(pMac, TRACE_CODE_SME_STATE, psessionEntry->peSessionId, psessionEntry->limSmeState));
Jeff Johnson295189b2012-06-20 16:38:30 -07002385
2386 limPostMlmMessage(pMac,
2387 LIM_MLM_REASSOC_REQ,
2388 (tANI_U32 *) pMlmReassocReq);
2389 return;
2390
2391end:
2392 if (pReassocReq)
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302393 vos_mem_free( pReassocReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07002394
2395 if (psessionEntry)
2396 {
2397 // error occurred after we determined the session so extract
2398 // session and transaction info from there
2399 smeSessionId = psessionEntry->smeSessionId;
2400 transactionId = psessionEntry->transactionId;
2401 }
2402 else
2403 {
2404 // error occurred before or during the time we determined the session
2405 // so extract the session and transaction info from the message
2406 limGetSessionInfo(pMac,(tANI_U8*)pMsgBuf, &smeSessionId, &transactionId);
2407 }
2408
2409 /// Send Reassoc failure response to host
2410 /// (note psessionEntry may be NULL, but that's OK)
2411 limSendSmeJoinReassocRsp(pMac, eWNI_SME_REASSOC_RSP,
2412 retCode, eSIR_MAC_UNSPEC_FAILURE_STATUS,
2413 psessionEntry, smeSessionId, transactionId);
2414
2415} /*** end __limProcessSmeReassocReq() ***/
2416
2417
2418tANI_BOOLEAN sendDisassocFrame = 1;
2419/**
2420 * __limProcessSmeDisassocReq()
2421 *
2422 *FUNCTION:
2423 * This function is called to process SME_DISASSOC_REQ message
2424 * from HDD or upper layer application.
2425 *
2426 *LOGIC:
2427 *
2428 *ASSUMPTIONS:
2429 *
2430 *NOTE:
2431 *
2432 * @param pMac Pointer to Global MAC structure
2433 * @param *pMsgBuf A pointer to the SME message buffer
2434 * @return None
2435 */
2436
2437static void
2438__limProcessSmeDisassocReq(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
2439{
2440 tANI_U16 disassocTrigger, reasonCode;
2441 tLimMlmDisassocReq *pMlmDisassocReq;
2442 tSirResultCodes retCode = eSIR_SME_SUCCESS;
Jeff Johnson43971f52012-07-17 12:26:56 -07002443 tSirRetStatus status;
Jeff Johnson295189b2012-06-20 16:38:30 -07002444 tSirSmeDisassocReq smeDisassocReq;
2445 tpPESession psessionEntry = NULL;
2446 tANI_U8 sessionId;
2447 tANI_U8 smesessionId;
2448 tANI_U16 smetransactionId;
2449
Jeff Johnson295189b2012-06-20 16:38:30 -07002450
Jeff Johnson43971f52012-07-17 12:26:56 -07002451 if (pMsgBuf == NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -07002452 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002453 limLog(pMac, LOGE, FL("Buffer is Pointing to NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002454 return;
2455 }
2456
Jeff Johnson43971f52012-07-17 12:26:56 -07002457 limGetSessionInfo(pMac, (tANI_U8 *)pMsgBuf,&smesessionId, &smetransactionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07002458
Jeff Johnson43971f52012-07-17 12:26:56 -07002459 status = limDisassocReqSerDes(pMac, &smeDisassocReq, (tANI_U8 *) pMsgBuf);
Jeff Johnson295189b2012-06-20 16:38:30 -07002460
Jeff Johnson43971f52012-07-17 12:26:56 -07002461 if ( (eSIR_FAILURE == status) ||
2462 (!limIsSmeDisassocReqValid(pMac, &smeDisassocReq, psessionEntry)) )
Jeff Johnson295189b2012-06-20 16:38:30 -07002463 {
2464 PELOGE(limLog(pMac, LOGE,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002465 FL("received invalid SME_DISASSOC_REQ message"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07002466
2467 if (pMac->lim.gLimRspReqd)
2468 {
2469 pMac->lim.gLimRspReqd = false;
2470
2471 retCode = eSIR_SME_INVALID_PARAMETERS;
2472 disassocTrigger = eLIM_HOST_DISASSOC;
2473 goto sendDisassoc;
2474 }
2475
2476 return;
2477 }
2478
Jeff Johnson295189b2012-06-20 16:38:30 -07002479 if((psessionEntry = peFindSessionByBssid(pMac,smeDisassocReq.bssId,&sessionId))== NULL)
2480 {
Abhishek Singhcd09b562013-12-24 16:02:20 +05302481 limLog(pMac, LOGE,FL("session does not exist for given bssId "MAC_ADDRESS_STR),
2482 MAC_ADDR_ARRAY(smeDisassocReq.bssId));
Jeff Johnson295189b2012-06-20 16:38:30 -07002483 retCode = eSIR_SME_INVALID_PARAMETERS;
2484 disassocTrigger = eLIM_HOST_DISASSOC;
2485 goto sendDisassoc;
2486
2487 }
Abhishek Singhcd09b562013-12-24 16:02:20 +05302488 limLog(pMac, LOG1, FL("received DISASSOC_REQ message on sessionid %d"
2489 "Systemrole %d Reason: %u SmeState: %d from: "MAC_ADDRESS_STR),
2490 smesessionId,psessionEntry->limSystemRole,
2491 smeDisassocReq.reasonCode, pMac->lim.gLimSmeState,
2492 MAC_ADDR_ARRAY(smeDisassocReq.peerMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07002493
2494#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM //FEATURE_WLAN_DIAG_SUPPORT
2495 limDiagEventReport(pMac, WLAN_PE_DIAG_DISASSOC_REQ_EVENT, psessionEntry, 0, smeDisassocReq.reasonCode);
2496#endif //FEATURE_WLAN_DIAG_SUPPORT
2497
2498 /* Update SME session Id and SME transaction ID*/
2499
2500 psessionEntry->smeSessionId = smesessionId;
2501 psessionEntry->transactionId = smetransactionId;
2502
2503 switch (psessionEntry->limSystemRole)
2504 {
2505 case eLIM_STA_ROLE:
2506 case eLIM_BT_AMP_STA_ROLE:
2507 switch (psessionEntry->limSmeState)
2508 {
2509 case eLIM_SME_ASSOCIATED_STATE:
2510 case eLIM_SME_LINK_EST_STATE:
2511 psessionEntry->limPrevSmeState = psessionEntry->limSmeState;
2512 psessionEntry->limSmeState= eLIM_SME_WT_DISASSOC_STATE;
Hoonki Lee8c9e99f2013-04-18 22:59:11 -07002513#ifdef FEATURE_WLAN_TDLS
2514 /* Delete all TDLS peers connected before leaving BSS*/
2515 limDeleteTDLSPeers(pMac, psessionEntry);
2516#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07002517 MTRACE(macTrace(pMac, TRACE_CODE_SME_STATE, psessionEntry->peSessionId, psessionEntry->limSmeState));
Abhishek Singhcd09b562013-12-24 16:02:20 +05302518 limLog(pMac, LOG1, FL("Rcvd SME_DISASSOC_REQ while in "
2519 "limSmeState: %d "),psessionEntry->limSmeState);
Jeff Johnson295189b2012-06-20 16:38:30 -07002520 break;
2521
2522 case eLIM_SME_WT_DEAUTH_STATE:
2523 /* PE shall still process the DISASSOC_REQ and proceed with
2524 * link tear down even if it had already sent a DEAUTH_IND to
2525 * to SME. pMac->lim.gLimPrevSmeState shall remain the same as
2526 * its been set when PE entered WT_DEAUTH_STATE.
2527 */
2528 psessionEntry->limSmeState= eLIM_SME_WT_DISASSOC_STATE;
Jeff Johnsone7245742012-09-05 17:12:55 -07002529 MTRACE(macTrace(pMac, TRACE_CODE_SME_STATE, psessionEntry->peSessionId, psessionEntry->limSmeState));
Abhishek Singhcd09b562013-12-24 16:02:20 +05302530 limLog(pMac, LOG1, FL("Rcvd SME_DISASSOC_REQ while in "
2531 "SME_WT_DEAUTH_STATE. "));
Jeff Johnson295189b2012-06-20 16:38:30 -07002532 break;
2533
2534 case eLIM_SME_WT_DISASSOC_STATE:
2535 /* PE Recieved a Disassoc frame. Normally it gets DISASSOC_CNF but it
2536 * received DISASSOC_REQ. Which means host is also trying to disconnect.
2537 * PE can continue processing DISASSOC_REQ and send the response instead
2538 * of failing the request. SME will anyway ignore DEAUTH_IND that was sent
2539 * for disassoc frame.
2540 *
2541 * It will send a disassoc, which is ok. However, we can use the global flag
2542 * sendDisassoc to not send disassoc frame.
2543 */
Abhishek Singhcd09b562013-12-24 16:02:20 +05302544 limLog(pMac, LOG1, FL("Rcvd SME_DISASSOC_REQ while in "
2545 "SME_WT_DISASSOC_STATE. "));
Jeff Johnson295189b2012-06-20 16:38:30 -07002546 break;
2547
2548 case eLIM_SME_JOIN_FAILURE_STATE: {
2549 /** Return Success as we are already in Disconnected State*/
Abhishek Singhcd09b562013-12-24 16:02:20 +05302550 limLog(pMac, LOG1, FL("Rcvd SME_DISASSOC_REQ while in "
2551 "eLIM_SME_JOIN_FAILURE_STATE. "));
Jeff Johnson295189b2012-06-20 16:38:30 -07002552 if (pMac->lim.gLimRspReqd) {
2553 retCode = eSIR_SME_SUCCESS;
2554 disassocTrigger = eLIM_HOST_DISASSOC;
2555 goto sendDisassoc;
2556 }
2557 }break;
2558 default:
2559 /**
2560 * STA is not currently associated.
2561 * Log error and send response to host
2562 */
2563 limLog(pMac, LOGE,
Sushant Kaushik1b645382014-10-13 16:39:36 +05302564 FL("received unexpected SME_DISASSOC_REQ in state %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002565 psessionEntry->limSmeState);
2566 limPrintSmeState(pMac, LOGE, psessionEntry->limSmeState);
2567
2568 if (pMac->lim.gLimRspReqd)
2569 {
2570 if (psessionEntry->limSmeState !=
2571 eLIM_SME_WT_ASSOC_STATE)
2572 pMac->lim.gLimRspReqd = false;
2573
2574 retCode = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
2575 disassocTrigger = eLIM_HOST_DISASSOC;
2576 goto sendDisassoc;
2577 }
2578
2579 return;
2580 }
2581
2582 break;
2583
2584 case eLIM_AP_ROLE:
2585 case eLIM_BT_AMP_AP_ROLE:
2586 // Fall through
2587 break;
2588
2589 case eLIM_STA_IN_IBSS_ROLE:
2590 default: // eLIM_UNKNOWN_ROLE
2591 limLog(pMac, LOGE,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002592 FL("received unexpected SME_DISASSOC_REQ for role %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002593 psessionEntry->limSystemRole);
2594
2595 retCode = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
2596 disassocTrigger = eLIM_HOST_DISASSOC;
2597 goto sendDisassoc;
2598 } // end switch (pMac->lim.gLimSystemRole)
2599
2600 if (smeDisassocReq.reasonCode == eLIM_LINK_MONITORING_DISASSOC)
2601 {
2602 /// Disassociation is triggered by Link Monitoring
Abhishek Singhcd09b562013-12-24 16:02:20 +05302603 limLog(pMac, LOG1, FL("**** Lost link with AP ****"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002604 disassocTrigger = eLIM_LINK_MONITORING_DISASSOC;
2605 reasonCode = eSIR_MAC_DISASSOC_DUE_TO_INACTIVITY_REASON;
2606 }
2607 else
2608 {
2609 disassocTrigger = eLIM_HOST_DISASSOC;
2610 reasonCode = smeDisassocReq.reasonCode;
2611 }
2612
2613 if (smeDisassocReq.doNotSendOverTheAir)
2614 {
Abhishek Singhcd09b562013-12-24 16:02:20 +05302615 limLog(pMac, LOG1, FL("do not send dissoc over the air"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002616 sendDisassocFrame = 0;
2617 }
2618 // Trigger Disassociation frame to peer MAC entity
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302619
2620 pMlmDisassocReq = vos_mem_malloc(sizeof(tLimMlmDisassocReq));
2621 if ( NULL == pMlmDisassocReq )
Jeff Johnson295189b2012-06-20 16:38:30 -07002622 {
2623 // Log error
2624 limLog(pMac, LOGP,
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302625 FL("call to AllocateMemory failed for mlmDisassocReq"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002626
2627 return;
2628 }
2629
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302630 vos_mem_copy( (tANI_U8 *) &pMlmDisassocReq->peerMacAddr,
Jeff Johnson295189b2012-06-20 16:38:30 -07002631 (tANI_U8 *) &smeDisassocReq.peerMacAddr,
2632 sizeof(tSirMacAddr));
2633
2634 pMlmDisassocReq->reasonCode = reasonCode;
2635 pMlmDisassocReq->disassocTrigger = disassocTrigger;
2636
2637 /* Update PE session ID*/
2638 pMlmDisassocReq->sessionId = sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -07002639
2640 limPostMlmMessage(pMac,
2641 LIM_MLM_DISASSOC_REQ,
2642 (tANI_U32 *) pMlmDisassocReq);
2643 return;
2644
2645sendDisassoc:
2646 if (psessionEntry)
2647 limSendSmeDisassocNtf(pMac, smeDisassocReq.peerMacAddr,
2648 retCode,
2649 disassocTrigger,
Jeff Johnson295189b2012-06-20 16:38:30 -07002650 1,smesessionId,smetransactionId,psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07002651 else
2652 limSendSmeDisassocNtf(pMac, smeDisassocReq.peerMacAddr,
2653 retCode,
2654 disassocTrigger,
Sudhir Sattayappa Kohalli5a8ac222013-03-06 12:41:42 -08002655 1, smesessionId, smetransactionId, NULL);
Jeff Johnson295189b2012-06-20 16:38:30 -07002656
2657
2658} /*** end __limProcessSmeDisassocReq() ***/
2659
2660
2661/** -----------------------------------------------------------------
2662 \brief __limProcessSmeDisassocCnf() - Process SME_DISASSOC_CNF
2663
2664 This function is called to process SME_DISASSOC_CNF message
2665 from HDD or upper layer application.
2666
2667 \param pMac - global mac structure
2668 \param pStaDs - station dph hash node
2669 \return none
2670 \sa
2671 ----------------------------------------------------------------- */
2672static void
2673__limProcessSmeDisassocCnf(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
2674{
2675 tSirSmeDisassocCnf smeDisassocCnf;
2676 tANI_U16 aid;
2677 tpDphHashNode pStaDs;
2678 tSirRetStatus status = eSIR_SUCCESS;
2679 tpPESession psessionEntry;
2680 tANI_U8 sessionId;
2681
2682
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002683 PELOG1(limLog(pMac, LOG1, FL("received DISASSOC_CNF message"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07002684
2685 status = limDisassocCnfSerDes(pMac, &smeDisassocCnf,(tANI_U8 *) pMsgBuf);
2686
2687 if (status == eSIR_FAILURE)
2688 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002689 PELOGE(limLog(pMac, LOGE, FL("invalid SME_DISASSOC_CNF message"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07002690 return;
2691 }
2692
2693 if((psessionEntry = peFindSessionByBssid(pMac, smeDisassocCnf.bssId, &sessionId))== NULL)
2694 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002695 limLog(pMac, LOGE,FL("session does not exist for given bssId"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002696 return;
2697 }
2698
2699 if (!limIsSmeDisassocCnfValid(pMac, &smeDisassocCnf, psessionEntry))
2700 {
Abhishek Singhcd09b562013-12-24 16:02:20 +05302701 limLog(pMac, LOGE, FL("received invalid SME_DISASSOC_CNF message"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002702 return;
2703 }
2704
2705#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM //FEATURE_WLAN_DIAG_SUPPORT
2706 if (smeDisassocCnf.messageType == eWNI_SME_DISASSOC_CNF)
2707 limDiagEventReport(pMac, WLAN_PE_DIAG_DISASSOC_CNF_EVENT, psessionEntry, (tANI_U16)smeDisassocCnf.statusCode, 0);
2708 else if (smeDisassocCnf.messageType == eWNI_SME_DEAUTH_CNF)
2709 limDiagEventReport(pMac, WLAN_PE_DIAG_DEAUTH_CNF_EVENT, psessionEntry, (tANI_U16)smeDisassocCnf.statusCode, 0);
2710#endif //FEATURE_WLAN_DIAG_SUPPORT
2711
2712 switch (psessionEntry->limSystemRole)
2713 {
2714 case eLIM_STA_ROLE:
2715 case eLIM_BT_AMP_STA_ROLE: //To test reconn
2716 if ((psessionEntry->limSmeState != eLIM_SME_IDLE_STATE) &&
2717 (psessionEntry->limSmeState != eLIM_SME_WT_DISASSOC_STATE) &&
2718 (psessionEntry->limSmeState != eLIM_SME_WT_DEAUTH_STATE))
2719 {
2720 limLog(pMac, LOGE,
Sushant Kaushik1b645382014-10-13 16:39:36 +05302721 FL("received unexp SME_DISASSOC_CNF in state %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002722 psessionEntry->limSmeState);
2723 limPrintSmeState(pMac, LOGE, psessionEntry->limSmeState);
2724 return;
2725 }
2726 break;
2727
2728 case eLIM_AP_ROLE:
2729 // Fall through
Jeff Johnson295189b2012-06-20 16:38:30 -07002730 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07002731
2732 case eLIM_STA_IN_IBSS_ROLE:
2733 default: // eLIM_UNKNOWN_ROLE
2734 limLog(pMac, LOGE,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002735 FL("received unexpected SME_DISASSOC_CNF role %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002736 psessionEntry->limSystemRole);
2737
2738 return;
2739 }
2740
2741
2742 if ( (psessionEntry->limSmeState == eLIM_SME_WT_DISASSOC_STATE) ||
2743 (psessionEntry->limSmeState == eLIM_SME_WT_DEAUTH_STATE)
Jeff Johnson295189b2012-06-20 16:38:30 -07002744 || (psessionEntry->limSystemRole == eLIM_AP_ROLE )
Jeff Johnson295189b2012-06-20 16:38:30 -07002745 )
2746 {
2747 pStaDs = dphLookupHashEntry(pMac, smeDisassocCnf.peerMacAddr, &aid, &psessionEntry->dph.dphHashTable);
2748 if (pStaDs == NULL)
2749 {
Abhishek Singhcd09b562013-12-24 16:02:20 +05302750 PELOGE(limLog(pMac, LOGE, FL("received DISASSOC_CNF for a STA that "
2751 "does not have context, addr= "MAC_ADDRESS_STR),
2752 MAC_ADDR_ARRAY(smeDisassocCnf.peerMacAddr));)
Jeff Johnson295189b2012-06-20 16:38:30 -07002753 return;
2754 }
Madan Mohan Koyyalamudi23001722012-10-31 16:48:56 -07002755 /* Delete FT session if there exists one */
2756 limFTCleanup(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -07002757 limCleanupRxPath(pMac, pStaDs, psessionEntry);
Madan Mohan Koyyalamudia67d4332012-11-29 11:35:23 -08002758
2759 limCleanUpDisassocDeauthReq(pMac, (char*)&smeDisassocCnf.peerMacAddr, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07002760 }
2761
2762 return;
2763}
2764
2765
2766/**
2767 * __limProcessSmeDeauthReq()
2768 *
2769 *FUNCTION:
2770 * This function is called to process SME_DEAUTH_REQ message
2771 * from HDD or upper layer application.
2772 *
2773 *LOGIC:
2774 *
2775 *ASSUMPTIONS:
2776 *
2777 *NOTE:
2778 *
2779 * @param pMac Pointer to Global MAC structure
2780 * @param *pMsgBuf A pointer to the SME message buffer
2781 * @return None
2782 */
2783
2784static void
2785__limProcessSmeDeauthReq(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
2786{
2787 tANI_U16 deauthTrigger, reasonCode;
2788 tLimMlmDeauthReq *pMlmDeauthReq;
2789 tSirSmeDeauthReq smeDeauthReq;
2790 tSirResultCodes retCode = eSIR_SME_SUCCESS;
2791 tSirRetStatus status = eSIR_SUCCESS;
2792 tpPESession psessionEntry;
2793 tANI_U8 sessionId; //PE sessionId
2794 tANI_U8 smesessionId;
2795 tANI_U16 smetransactionId;
2796
Jeff Johnson295189b2012-06-20 16:38:30 -07002797
2798 status = limDeauthReqSerDes(pMac, &smeDeauthReq,(tANI_U8 *) pMsgBuf);
Jeff Johnson295189b2012-06-20 16:38:30 -07002799 limGetSessionInfo(pMac,(tANI_U8 *)pMsgBuf,&smesessionId,&smetransactionId);
2800
2801 //We need to get a session first but we don't even know if the message is correct.
2802 if((psessionEntry = peFindSessionByBssid(pMac, smeDeauthReq.bssId, &sessionId)) == NULL)
2803 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002804 limLog(pMac, LOGE,FL("session does not exist for given bssId"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002805 retCode = eSIR_SME_INVALID_PARAMETERS;
2806 deauthTrigger = eLIM_HOST_DEAUTH;
2807 goto sendDeauth;
2808
2809 }
2810
2811 if ((status == eSIR_FAILURE) || (!limIsSmeDeauthReqValid(pMac, &smeDeauthReq, psessionEntry)))
2812 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002813 PELOGE(limLog(pMac, LOGW,FL("received invalid SME_DEAUTH_REQ message"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07002814 if (pMac->lim.gLimRspReqd)
2815 {
2816 pMac->lim.gLimRspReqd = false;
2817
2818 retCode = eSIR_SME_INVALID_PARAMETERS;
2819 deauthTrigger = eLIM_HOST_DEAUTH;
2820 goto sendDeauth;
2821 }
2822
2823 return;
2824 }
Abhishek Singhcd09b562013-12-24 16:02:20 +05302825 limLog(pMac, LOG1,FL("received DEAUTH_REQ message on sessionid %d "
2826 "Systemrole %d with reasoncode %u in limSmestate %d from "
2827 MAC_ADDRESS_STR), smesessionId, psessionEntry->limSystemRole,
2828 smeDeauthReq.reasonCode, psessionEntry->limSmeState,
2829 MAC_ADDR_ARRAY(smeDeauthReq.peerMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07002830#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM //FEATURE_WLAN_DIAG_SUPPORT
2831 limDiagEventReport(pMac, WLAN_PE_DIAG_DEAUTH_REQ_EVENT, psessionEntry, 0, smeDeauthReq.reasonCode);
2832#endif //FEATURE_WLAN_DIAG_SUPPORT
2833
2834 /* Update SME session ID and Transaction ID */
2835 psessionEntry->smeSessionId = smesessionId;
2836 psessionEntry->transactionId = smetransactionId;
2837
2838
2839 switch (psessionEntry->limSystemRole)
2840 {
2841 case eLIM_STA_ROLE:
2842 case eLIM_BT_AMP_STA_ROLE:
2843
2844 switch (psessionEntry->limSmeState)
2845 {
2846 case eLIM_SME_ASSOCIATED_STATE:
2847 case eLIM_SME_LINK_EST_STATE:
2848 case eLIM_SME_WT_ASSOC_STATE:
2849 case eLIM_SME_JOIN_FAILURE_STATE:
2850 case eLIM_SME_IDLE_STATE:
2851 psessionEntry->limPrevSmeState = psessionEntry->limSmeState;
2852 psessionEntry->limSmeState = eLIM_SME_WT_DEAUTH_STATE;
Varun Reddy Yeturue3bbf6e2013-02-08 18:50:55 -08002853 MTRACE(macTrace(pMac, TRACE_CODE_SME_STATE, psessionEntry->peSessionId, psessionEntry->limSmeState));
Jeff Johnson295189b2012-06-20 16:38:30 -07002854
2855 // Send Deauthentication request to MLM below
2856
2857 break;
Sachin Ahujaa100dcc2014-07-03 14:30:18 +05302858 case eLIM_SME_WT_DEAUTH_STATE:
2859 /*
2860 * PE Recieved a Deauth frame. Normally it gets
2861 * DEAUTH_CNF but it received DEAUTH_REQ. Which
2862 * means host is also trying to disconnect.
2863 * PE can continue processing DEAUTH_REQ and send
2864 * the response instead of failing the request.
2865 * SME will anyway ignore DEAUTH_IND that was sent
2866 * for deauth frame.
2867 */
2868 limLog(pMac, LOG1, FL("Rcvd SME_DEAUTH_REQ while in "
2869 "SME_WT_DEAUTH_STATE. "));
2870 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07002871 default:
2872 /**
2873 * STA is not in a state to deauthenticate with
2874 * peer. Log error and send response to host.
2875 */
2876 limLog(pMac, LOGE,
Sushant Kaushik1b645382014-10-13 16:39:36 +05302877 FL("received unexp SME_DEAUTH_REQ in state %d"),
Abhishek Singhcd09b562013-12-24 16:02:20 +05302878 psessionEntry->limSmeState);
Jeff Johnson295189b2012-06-20 16:38:30 -07002879 limPrintSmeState(pMac, LOGE, psessionEntry->limSmeState);
2880
2881 if (pMac->lim.gLimRspReqd)
2882 {
2883 pMac->lim.gLimRspReqd = false;
2884
2885 retCode = eSIR_SME_STA_NOT_AUTHENTICATED;
2886 deauthTrigger = eLIM_HOST_DEAUTH;
Leela Venkata Kiran Kumar Reddy Chirala56df73f2014-01-30 14:18:00 -08002887 /**
2888 *here we received deauth request from AP so sme state is
2889 eLIM_SME_WT_DEAUTH_STATE.if we have ISSUED delSta then
2890 mlm state should be eLIM_MLM_WT_DEL_STA_RSP_STATE and if
2891 we got delBSS rsp then mlm state should be eLIM_MLM_IDLE_STATE
2892 so the below condition captures the state where delSta
2893 not done and firmware still in connected state.
2894 */
2895 if (psessionEntry->limSmeState == eLIM_SME_WT_DEAUTH_STATE &&
2896 psessionEntry->limMlmState != eLIM_MLM_IDLE_STATE &&
2897 psessionEntry->limMlmState != eLIM_MLM_WT_DEL_STA_RSP_STATE)
2898 {
2899 retCode = eSIR_SME_DEAUTH_STATUS;
2900 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002901 goto sendDeauth;
2902 }
2903
2904 return;
2905 }
2906
2907 break;
2908
2909 case eLIM_STA_IN_IBSS_ROLE:
2910
2911 return;
2912
2913 case eLIM_AP_ROLE:
2914 // Fall through
2915
2916 break;
2917
2918 default:
2919 limLog(pMac, LOGE,
Sushant Kaushik1b645382014-10-13 16:39:36 +05302920 FL("received unexpected SME_DEAUTH_REQ for role %d"),
Abhishek Singhcd09b562013-12-24 16:02:20 +05302921 psessionEntry->limSystemRole);
Jeff Johnson295189b2012-06-20 16:38:30 -07002922
2923 return;
2924 } // end switch (pMac->lim.gLimSystemRole)
2925
2926 if (smeDeauthReq.reasonCode == eLIM_LINK_MONITORING_DEAUTH)
2927 {
2928 /// Deauthentication is triggered by Link Monitoring
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002929 PELOG1(limLog(pMac, LOG1, FL("**** Lost link with AP ****"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07002930 deauthTrigger = eLIM_LINK_MONITORING_DEAUTH;
2931 reasonCode = eSIR_MAC_UNSPEC_FAILURE_REASON;
2932 }
2933 else
2934 {
2935 deauthTrigger = eLIM_HOST_DEAUTH;
2936 reasonCode = smeDeauthReq.reasonCode;
2937 }
2938
2939 // Trigger Deauthentication frame to peer MAC entity
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302940 pMlmDeauthReq = vos_mem_malloc(sizeof(tLimMlmDeauthReq));
2941 if ( NULL == pMlmDeauthReq )
Jeff Johnson295189b2012-06-20 16:38:30 -07002942 {
2943 // Log error
2944 limLog(pMac, LOGP,
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302945 FL("call to AllocateMemory failed for mlmDeauthReq"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002946
2947 return;
2948 }
2949
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302950 vos_mem_copy( (tANI_U8 *) &pMlmDeauthReq->peerMacAddr,
Jeff Johnson295189b2012-06-20 16:38:30 -07002951 (tANI_U8 *) &smeDeauthReq.peerMacAddr,
2952 sizeof(tSirMacAddr));
2953
2954 pMlmDeauthReq->reasonCode = reasonCode;
2955 pMlmDeauthReq->deauthTrigger = deauthTrigger;
Jeff Johnson295189b2012-06-20 16:38:30 -07002956
2957 /* Update PE session Id*/
2958 pMlmDeauthReq->sessionId = sessionId;
2959
2960 limPostMlmMessage(pMac,
2961 LIM_MLM_DEAUTH_REQ,
2962 (tANI_U32 *) pMlmDeauthReq);
2963 return;
2964
2965sendDeauth:
2966 limSendSmeDeauthNtf(pMac, smeDeauthReq.peerMacAddr,
2967 retCode,
2968 deauthTrigger,
Jeff Johnson295189b2012-06-20 16:38:30 -07002969 1,
Jeff Johnson295189b2012-06-20 16:38:30 -07002970 smesessionId, smetransactionId);
2971} /*** end __limProcessSmeDeauthReq() ***/
2972
2973
2974
2975/**
2976 * __limProcessSmeSetContextReq()
2977 *
2978 *FUNCTION:
2979 * This function is called to process SME_SETCONTEXT_REQ message
2980 * from HDD or upper layer application.
2981 *
2982 *LOGIC:
2983 *
2984 *ASSUMPTIONS:
2985 *
2986 *NOTE:
2987 *
2988 * @param pMac Pointer to Global MAC structure
2989 * @param *pMsgBuf A pointer to the SME message buffer
2990 * @return None
2991 */
2992
2993static void
2994__limProcessSmeSetContextReq(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
2995{
2996 tpSirSmeSetContextReq pSetContextReq;
2997 tLimMlmSetKeysReq *pMlmSetKeysReq;
2998 tpPESession psessionEntry;
2999 tANI_U8 sessionId; //PE sessionID
3000 tANI_U8 smesessionId;
3001 tANI_U16 smetransactionId;
3002
3003
3004 PELOG1(limLog(pMac, LOG1,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003005 FL("received SETCONTEXT_REQ message")););
Jeff Johnson295189b2012-06-20 16:38:30 -07003006
3007
3008 if(pMsgBuf == NULL)
3009 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003010 limLog(pMac, LOGE,FL("Buffer is Pointing to NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003011 return;
3012 }
3013
3014 limGetSessionInfo(pMac,(tANI_U8 *)pMsgBuf,&smesessionId,&smetransactionId);
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303015
3016 pSetContextReq = vos_mem_malloc(sizeof(tSirKeys) * SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS);
3017 if ( NULL == pSetContextReq )
Jeff Johnson295189b2012-06-20 16:38:30 -07003018 {
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303019 limLog(pMac, LOGP, FL("call to AllocateMemory failed for pSetContextReq"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003020 return;
3021 }
3022
3023 if ((limSetContextReqSerDes(pMac, pSetContextReq, (tANI_U8 *) pMsgBuf) == eSIR_FAILURE) ||
3024 (!limIsSmeSetContextReqValid(pMac, pSetContextReq)))
3025 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003026 limLog(pMac, LOGW, FL("received invalid SME_SETCONTEXT_REQ message"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003027 goto end;
3028 }
3029
3030 if(pSetContextReq->keyMaterial.numKeys > SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS)
3031 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003032 PELOGE(limLog(pMac, LOGE, FL("numKeys:%d is more than SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS"), pSetContextReq->keyMaterial.numKeys);)
Jeff Johnson295189b2012-06-20 16:38:30 -07003033 limSendSmeSetContextRsp(pMac,
3034 pSetContextReq->peerMacAddr,
Jeff Johnson295189b2012-06-20 16:38:30 -07003035 1,
Jeff Johnson295189b2012-06-20 16:38:30 -07003036 eSIR_SME_INVALID_PARAMETERS,NULL,
3037 smesessionId,smetransactionId);
3038
3039 goto end;
3040 }
3041
3042
3043 if((psessionEntry = peFindSessionByBssid(pMac, pSetContextReq->bssId, &sessionId)) == NULL)
3044 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003045 limLog(pMac, LOGW, FL("Session does not exist for given BSSID"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003046 limSendSmeSetContextRsp(pMac,
3047 pSetContextReq->peerMacAddr,
Jeff Johnson295189b2012-06-20 16:38:30 -07003048 1,
Jeff Johnson295189b2012-06-20 16:38:30 -07003049 eSIR_SME_INVALID_PARAMETERS,NULL,
3050 smesessionId,smetransactionId);
3051
3052 goto end;
3053 }
3054
3055#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM //FEATURE_WLAN_DIAG_SUPPORT
3056 limDiagEventReport(pMac, WLAN_PE_DIAG_SETCONTEXT_REQ_EVENT, psessionEntry, 0, 0);
3057#endif //FEATURE_WLAN_DIAG_SUPPORT
3058
3059
3060 if ((((psessionEntry->limSystemRole == eLIM_STA_ROLE) || (psessionEntry->limSystemRole == eLIM_BT_AMP_STA_ROLE)) &&
3061 (psessionEntry->limSmeState == eLIM_SME_LINK_EST_STATE)) ||
3062 (((psessionEntry->limSystemRole == eLIM_STA_IN_IBSS_ROLE) ||
3063 (psessionEntry->limSystemRole == eLIM_AP_ROLE)|| (psessionEntry->limSystemRole == eLIM_BT_AMP_AP_ROLE)) &&
3064 (psessionEntry->limSmeState == eLIM_SME_NORMAL_STATE)))
3065 {
3066 // Trigger MLM_SETKEYS_REQ
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303067 pMlmSetKeysReq = vos_mem_malloc(sizeof(tLimMlmSetKeysReq));
3068 if ( NULL == pMlmSetKeysReq )
Jeff Johnson295189b2012-06-20 16:38:30 -07003069 {
3070 // Log error
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303071 limLog(pMac, LOGP, FL("call to AllocateMemory failed for mlmSetKeysReq"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003072 goto end;
3073 }
3074
3075 pMlmSetKeysReq->edType = pSetContextReq->keyMaterial.edType;
3076 pMlmSetKeysReq->numKeys = pSetContextReq->keyMaterial.numKeys;
3077 if(pMlmSetKeysReq->numKeys > SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS)
3078 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003079 limLog(pMac, LOGP, FL("Num of keys exceeded max num of default keys limit"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003080 goto end;
3081 }
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303082 vos_mem_copy( (tANI_U8 *) &pMlmSetKeysReq->peerMacAddr,
Jeff Johnson295189b2012-06-20 16:38:30 -07003083 (tANI_U8 *) &pSetContextReq->peerMacAddr,
3084 sizeof(tSirMacAddr));
3085
Jeff Johnson295189b2012-06-20 16:38:30 -07003086
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303087 vos_mem_copy( (tANI_U8 *) &pMlmSetKeysReq->key,
Jeff Johnson295189b2012-06-20 16:38:30 -07003088 (tANI_U8 *) &pSetContextReq->keyMaterial.key,
3089 sizeof(tSirKeys) * (pMlmSetKeysReq->numKeys ? pMlmSetKeysReq->numKeys : 1));
3090
3091 pMlmSetKeysReq->sessionId = sessionId;
3092#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
3093 PELOG1(limLog(pMac, LOG1,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003094 FL("received SETCONTEXT_REQ message sessionId=%d"), pMlmSetKeysReq->sessionId););
Jeff Johnson295189b2012-06-20 16:38:30 -07003095#endif
3096
Jeff Johnson295189b2012-06-20 16:38:30 -07003097 if(((pSetContextReq->keyMaterial.edType == eSIR_ED_WEP40) || (pSetContextReq->keyMaterial.edType == eSIR_ED_WEP104))
3098 && (psessionEntry->limSystemRole == eLIM_AP_ROLE))
3099 {
3100 if(pSetContextReq->keyMaterial.key[0].keyLength)
3101 {
3102 tANI_U8 keyId;
3103 keyId = pSetContextReq->keyMaterial.key[0].keyId;
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303104 vos_mem_copy( (tANI_U8 *)&psessionEntry->WEPKeyMaterial[keyId],
Jeff Johnson295189b2012-06-20 16:38:30 -07003105 (tANI_U8 *) &pSetContextReq->keyMaterial, sizeof(tSirKeyMaterial));
3106 }
3107 else {
3108 tANI_U32 i;
3109 for( i = 0; i < SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS; i++)
3110 {
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303111 vos_mem_copy( (tANI_U8 *) &pMlmSetKeysReq->key[i],
Jeff Johnson295189b2012-06-20 16:38:30 -07003112 (tANI_U8 *)psessionEntry->WEPKeyMaterial[i].key, sizeof(tSirKeys));
3113 }
3114 }
3115 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003116
3117 limPostMlmMessage(pMac, LIM_MLM_SETKEYS_REQ, (tANI_U32 *) pMlmSetKeysReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07003118 }
3119 else
3120 {
3121 limLog(pMac, LOGE,
Sushant Kaushik1b645382014-10-13 16:39:36 +05303122 FL("received unexpected SME_SETCONTEXT_REQ for role %d, state=%d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07003123 psessionEntry->limSystemRole,
3124 psessionEntry->limSmeState);
3125 limPrintSmeState(pMac, LOGE, psessionEntry->limSmeState);
3126
3127 limSendSmeSetContextRsp(pMac, pSetContextReq->peerMacAddr,
Jeff Johnson295189b2012-06-20 16:38:30 -07003128 1,
Jeff Johnson295189b2012-06-20 16:38:30 -07003129 eSIR_SME_UNEXPECTED_REQ_RESULT_CODE,psessionEntry,
3130 smesessionId,
3131 smetransactionId);
3132 }
3133
3134end:
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05303135 vos_mem_zero(pSetContextReq,
3136 (sizeof(tSirKeys) * SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS));
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303137 vos_mem_free( pSetContextReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07003138 return;
3139} /*** end __limProcessSmeSetContextReq() ***/
3140
3141/**
3142 * __limProcessSmeRemoveKeyReq()
3143 *
3144 *FUNCTION:
3145 * This function is called to process SME_REMOVEKEY_REQ message
3146 * from HDD or upper layer application.
3147 *
3148 *LOGIC:
3149 *
3150 *ASSUMPTIONS:
3151 *
3152 *NOTE:
3153 *
3154 * @param pMac Pointer to Global MAC structure
3155 * @param *pMsgBuf A pointer to the SME message buffer
3156 * @return None
3157 */
3158
3159static void
3160__limProcessSmeRemoveKeyReq(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
3161{
3162 tpSirSmeRemoveKeyReq pRemoveKeyReq;
3163 tLimMlmRemoveKeyReq *pMlmRemoveKeyReq;
3164 tpPESession psessionEntry;
3165 tANI_U8 sessionId; //PE sessionID
3166 tANI_U8 smesessionId;
3167 tANI_U16 smetransactionId;
3168
3169 PELOG1(limLog(pMac, LOG1,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003170 FL("received REMOVEKEY_REQ message"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07003171
3172 if(pMsgBuf == NULL)
3173 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003174 limLog(pMac, LOGE,FL("Buffer is Pointing to NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003175 return;
3176 }
3177
3178
3179 limGetSessionInfo(pMac,(tANI_U8 *)pMsgBuf,&smesessionId,&smetransactionId);
3180
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303181 pRemoveKeyReq = vos_mem_malloc(sizeof(*pRemoveKeyReq));
3182 if ( NULL == pRemoveKeyReq )
Jeff Johnson295189b2012-06-20 16:38:30 -07003183 {
3184 //Log error
3185 limLog(pMac, LOGP,
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303186 FL("call to AllocateMemory failed for pRemoveKeyReq"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003187
3188 return;
3189 }
3190
3191 if ((limRemoveKeyReqSerDes(pMac,
3192 pRemoveKeyReq,
3193 (tANI_U8 *) pMsgBuf) == eSIR_FAILURE))
3194 {
3195 limLog(pMac, LOGW,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003196 FL("received invalid SME_REMOVECONTEXT_REQ message"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003197
3198 /* extra look up is needed since, session entry to be passed il limsendremovekey response */
3199
3200 if((psessionEntry = peFindSessionByBssid(pMac,pRemoveKeyReq->bssId,&sessionId))== NULL)
3201 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003202 limLog(pMac, LOGE,FL("session does not exist for given bssId"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003203 //goto end;
3204 }
3205
3206 limSendSmeRemoveKeyRsp(pMac,
3207 pRemoveKeyReq->peerMacAddr,
3208 eSIR_SME_INVALID_PARAMETERS,psessionEntry,
3209 smesessionId,smetransactionId);
3210
3211 goto end;
3212 }
3213
3214 if((psessionEntry = peFindSessionByBssid(pMac,pRemoveKeyReq->bssId, &sessionId))== NULL)
3215 {
3216 limLog(pMac, LOGE,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003217 FL("session does not exist for given bssId"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003218 limSendSmeRemoveKeyRsp(pMac,
3219 pRemoveKeyReq->peerMacAddr,
3220 eSIR_SME_UNEXPECTED_REQ_RESULT_CODE, NULL,
3221 smesessionId, smetransactionId);
3222 goto end;
3223 }
3224
3225
3226 if ((((psessionEntry->limSystemRole == eLIM_STA_ROLE)|| (psessionEntry->limSystemRole == eLIM_BT_AMP_STA_ROLE))&&
3227 (psessionEntry->limSmeState == eLIM_SME_LINK_EST_STATE)) ||
3228 (((psessionEntry->limSystemRole == eLIM_STA_IN_IBSS_ROLE) ||
3229 (psessionEntry->limSystemRole == eLIM_AP_ROLE)|| (psessionEntry->limSystemRole == eLIM_BT_AMP_AP_ROLE)) &&
3230 (psessionEntry->limSmeState == eLIM_SME_NORMAL_STATE)))
3231 {
3232 // Trigger MLM_REMOVEKEYS_REQ
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303233 pMlmRemoveKeyReq = vos_mem_malloc(sizeof(tLimMlmRemoveKeyReq));
3234 if ( NULL == pMlmRemoveKeyReq )
Jeff Johnson295189b2012-06-20 16:38:30 -07003235 {
3236 // Log error
3237 limLog(pMac, LOGP,
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303238 FL("call to AllocateMemory failed for mlmRemoveKeysReq"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003239
3240 goto end;
3241 }
3242
3243 pMlmRemoveKeyReq->edType = (tAniEdType)pRemoveKeyReq->edType;
3244 pMlmRemoveKeyReq->keyId = pRemoveKeyReq->keyId;
3245 pMlmRemoveKeyReq->wepType = pRemoveKeyReq->wepType;
3246 pMlmRemoveKeyReq->unicast = pRemoveKeyReq->unicast;
3247
3248 /* Update PE session Id */
3249 pMlmRemoveKeyReq->sessionId = sessionId;
3250
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303251 vos_mem_copy( (tANI_U8 *) &pMlmRemoveKeyReq->peerMacAddr,
Jeff Johnson295189b2012-06-20 16:38:30 -07003252 (tANI_U8 *) &pRemoveKeyReq->peerMacAddr,
3253 sizeof(tSirMacAddr));
3254
3255
3256 limPostMlmMessage(pMac,
3257 LIM_MLM_REMOVEKEY_REQ,
3258 (tANI_U32 *) pMlmRemoveKeyReq);
3259 }
3260 else
3261 {
3262 limLog(pMac, LOGE,
Sushant Kaushik1b645382014-10-13 16:39:36 +05303263 FL("received unexpected SME_REMOVEKEY_REQ for role %d, state=%d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07003264 psessionEntry->limSystemRole,
3265 psessionEntry->limSmeState);
3266 limPrintSmeState(pMac, LOGE, psessionEntry->limSmeState);
3267
3268 limSendSmeRemoveKeyRsp(pMac,
3269 pRemoveKeyReq->peerMacAddr,
3270 eSIR_SME_UNEXPECTED_REQ_RESULT_CODE,psessionEntry,
3271 smesessionId,smetransactionId);
3272 }
3273
3274end:
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303275 vos_mem_free( pRemoveKeyReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07003276} /*** end __limProcessSmeRemoveKeyReq() ***/
3277
Jeff Johnson295189b2012-06-20 16:38:30 -07003278void limProcessSmeGetScanChannelInfo(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
3279{
3280 tSirMsgQ mmhMsg;
3281 tpSmeGetScanChnRsp pSirSmeRsp;
3282 tANI_U16 len = 0;
Madan Mohan Koyyalamudide1b5bc2013-07-12 00:56:04 +05303283 tANI_U8 sessionId;
3284 tANI_U16 transactionId;
Jeff Johnson295189b2012-06-20 16:38:30 -07003285
3286 if(pMac->lim.scanChnInfo.numChnInfo > SIR_MAX_SUPPORTED_CHANNEL_LIST)
3287 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003288 limLog(pMac, LOGW, FL("numChn is out of bounds %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07003289 pMac->lim.scanChnInfo.numChnInfo);
3290 pMac->lim.scanChnInfo.numChnInfo = SIR_MAX_SUPPORTED_CHANNEL_LIST;
3291 }
3292
3293 PELOG2(limLog(pMac, LOG2,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003294 FL("Sending message %s with number of channels %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07003295 limMsgStr(eWNI_SME_GET_SCANNED_CHANNEL_RSP), pMac->lim.scanChnInfo.numChnInfo);)
3296
3297 len = sizeof(tSmeGetScanChnRsp) + (pMac->lim.scanChnInfo.numChnInfo - 1) * sizeof(tLimScanChn);
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303298 pSirSmeRsp = vos_mem_malloc(len);
3299 if ( NULL == pSirSmeRsp )
Jeff Johnson295189b2012-06-20 16:38:30 -07003300 {
3301 /// Buffer not available. Log error
3302 limLog(pMac, LOGP,
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303303 FL("call to AllocateMemory failed for JOIN/REASSOC_RSP"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003304
3305 return;
3306 }
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303307 vos_mem_set(pSirSmeRsp, len, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07003308
Jeff Johnson295189b2012-06-20 16:38:30 -07003309 pSirSmeRsp->mesgType = eWNI_SME_GET_SCANNED_CHANNEL_RSP;
3310 pSirSmeRsp->mesgLen = len;
Madan Mohan Koyyalamudide1b5bc2013-07-12 00:56:04 +05303311
3312 if (pMac->fScanOffload)
3313 {
3314 limGetSessionInfo(pMac,(tANI_U8 *)pMsgBuf,&sessionId,&transactionId);
3315 pSirSmeRsp->sessionId = sessionId;
3316 }
3317 else
3318 pSirSmeRsp->sessionId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003319
3320 if(pMac->lim.scanChnInfo.numChnInfo)
3321 {
3322 pSirSmeRsp->numChn = pMac->lim.scanChnInfo.numChnInfo;
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303323 vos_mem_copy( pSirSmeRsp->scanChn, pMac->lim.scanChnInfo.scanChn,
3324 sizeof(tLimScanChn) * pSirSmeRsp->numChn);
Jeff Johnson295189b2012-06-20 16:38:30 -07003325 }
3326 //Clear the list
3327 limRessetScanChannelInfo(pMac);
3328
3329 mmhMsg.type = eWNI_SME_GET_SCANNED_CHANNEL_RSP;
3330 mmhMsg.bodyptr = pSirSmeRsp;
3331 mmhMsg.bodyval = 0;
3332
3333 pMac->lim.gLimRspReqd = false;
Jeff Johnsone7245742012-09-05 17:12:55 -07003334 MTRACE(macTraceMsgTx(pMac, NO_SESSION, mmhMsg.type));
Jeff Johnson295189b2012-06-20 16:38:30 -07003335 limSysProcessMmhMsgApi(pMac, &mmhMsg, ePROT);
3336}
3337
3338
Jeff Johnson295189b2012-06-20 16:38:30 -07003339void limProcessSmeGetAssocSTAsInfo(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
3340{
3341 tSirSmeGetAssocSTAsReq getAssocSTAsReq;
3342 tpDphHashNode pStaDs = NULL;
3343 tpPESession psessionEntry = NULL;
3344 tSap_Event sapEvent;
3345 tpWLAN_SAPEventCB pSapEventCallback = NULL;
3346 tpSap_AssocMacAddr pAssocStasTemp = NULL;// #include "sapApi.h"
3347 tANI_U8 sessionId = CSR_SESSION_ID_INVALID;
3348 tANI_U8 assocId = 0;
3349 tANI_U8 staCount = 0;
3350
3351 if (!limIsSmeGetAssocSTAsReqValid(pMac, &getAssocSTAsReq, (tANI_U8 *) pMsgBuf))
3352 {
3353 limLog(pMac, LOGE,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003354 FL("received invalid eWNI_SME_GET_ASSOC_STAS_REQ message"));
Girish Gowliafd42312014-07-24 13:13:59 +05303355 return;
Jeff Johnson295189b2012-06-20 16:38:30 -07003356 }
3357
3358 switch (getAssocSTAsReq.modId)
3359 {
3360/**
3361 case VOS_MODULE_ID_HAL:
3362 wdaPostCtrlMsg( pMac, &msgQ );
3363 return;
3364
3365 case VOS_MODULE_ID_TL:
3366 Post msg TL
3367 return;
3368*/
3369 case VOS_MODULE_ID_PE:
3370 default:
3371 break;
3372 }
3373
Jeff Johnson1250df42012-12-10 14:31:52 -08003374 // Get Associated stations from PE
Jeff Johnson295189b2012-06-20 16:38:30 -07003375 // Find PE session Entry
3376 if ((psessionEntry = peFindSessionByBssid(pMac, getAssocSTAsReq.bssId, &sessionId)) == NULL)
3377 {
3378 limLog(pMac, LOGE,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003379 FL("session does not exist for given bssId"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003380 goto limAssocStaEnd;
3381 }
3382
3383 if (psessionEntry->limSystemRole != eLIM_AP_ROLE)
3384 {
3385 limLog(pMac, LOGE,
Sushant Kaushik1b645382014-10-13 16:39:36 +05303386 FL("Received unexpected message in state %d, in role %d"),
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303387 psessionEntry->limSmeState, psessionEntry->limSystemRole);
Jeff Johnson295189b2012-06-20 16:38:30 -07003388 goto limAssocStaEnd;
3389 }
3390
3391 // Retrieve values obtained in the request message
3392 pSapEventCallback = (tpWLAN_SAPEventCB)getAssocSTAsReq.pSapEventCallback;
3393 pAssocStasTemp = (tpSap_AssocMacAddr)getAssocSTAsReq.pAssocStasArray;
3394
3395 for (assocId = 0; assocId < psessionEntry->dph.dphHashTable.size; assocId++)// Softap dphHashTable.size = 8
3396 {
3397 pStaDs = dphGetHashEntry(pMac, assocId, &psessionEntry->dph.dphHashTable);
3398
3399 if (NULL == pStaDs)
3400 continue;
3401
3402 if (pStaDs->valid)
3403 {
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303404 vos_mem_copy((tANI_U8 *)&pAssocStasTemp->staMac,
3405 (tANI_U8 *)&pStaDs->staAddr,
3406 sizeof(v_MACADDR_t)); // Mac address
Jeff Johnson295189b2012-06-20 16:38:30 -07003407 pAssocStasTemp->assocId = (v_U8_t)pStaDs->assocId; // Association Id
3408 pAssocStasTemp->staId = (v_U8_t)pStaDs->staIndex; // Station Id
3409
Kiet Lamb1233192013-11-28 13:38:20 +05303410 vos_mem_copy((tANI_U8 *)&pAssocStasTemp->supportedRates,
Leo Chang614d2072013-08-22 14:59:44 -07003411 (tANI_U8 *)&pStaDs->supportedRates,
3412 sizeof(tSirSupportedRates));
3413 pAssocStasTemp->ShortGI40Mhz = pStaDs->htShortGI40Mhz;
3414 pAssocStasTemp->ShortGI20Mhz = pStaDs->htShortGI20Mhz;
3415 pAssocStasTemp->Support40Mhz = pStaDs->htDsssCckRate40MHzSupport;
3416
Jeff Johnson295189b2012-06-20 16:38:30 -07003417 limLog(pMac, LOG1, FL("dph Station Number = %d"), staCount+1);
Arif Hussain24bafea2013-11-15 15:10:03 -08003418 limLog(pMac, LOG1, FL("MAC = " MAC_ADDRESS_STR),
3419 MAC_ADDR_ARRAY(pStaDs->staAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07003420 limLog(pMac, LOG1, FL("Association Id = %d"),pStaDs->assocId);
3421 limLog(pMac, LOG1, FL("Station Index = %d"),pStaDs->staIndex);
3422
3423 pAssocStasTemp++;
3424 staCount++;
3425 }
3426 }
3427
3428limAssocStaEnd:
3429 // Call hdd callback with sap event to send the list of associated stations from PE
3430 if (pSapEventCallback != NULL)
3431 {
3432 sapEvent.sapHddEventCode = eSAP_ASSOC_STA_CALLBACK_EVENT;
3433 sapEvent.sapevt.sapAssocStaListEvent.module = VOS_MODULE_ID_PE;
3434 sapEvent.sapevt.sapAssocStaListEvent.noOfAssocSta = staCount;
3435 sapEvent.sapevt.sapAssocStaListEvent.pAssocStas = (tpSap_AssocMacAddr)getAssocSTAsReq.pAssocStasArray;
3436 pSapEventCallback(&sapEvent, getAssocSTAsReq.pUsrContext);
3437 }
3438}
3439
3440
3441/**
3442 * limProcessSmeGetWPSPBCSessions
3443 *
3444 *FUNCTION:
3445 * This function is called when query the WPS PBC overlap message is received
3446 *
3447 *LOGIC:
3448 * This function parses get WPS PBC overlap information message and call callback to pass
3449 * WPS PBC overlap information back to hdd.
3450 *ASSUMPTIONS:
3451 *
3452 *
3453 *NOTE:
3454 *
3455 * @param pMac Pointer to Global MAC structure
3456 * @param pMsgBuf A pointer to WPS PBC overlap query message
3457*
3458 * @return None
3459 */
3460void limProcessSmeGetWPSPBCSessions(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
3461{
3462 tSirSmeGetWPSPBCSessionsReq GetWPSPBCSessionsReq;
3463 tpPESession psessionEntry = NULL;
3464 tSap_Event sapEvent;
3465 tpWLAN_SAPEventCB pSapEventCallback = NULL;
3466 tANI_U8 sessionId = CSR_SESSION_ID_INVALID;
3467 tSirMacAddr zeroMac = {0,0,0,0,0,0};
3468
3469 sapEvent.sapevt.sapGetWPSPBCSessionEvent.status = VOS_STATUS_E_FAULT;
3470
3471 if (limIsSmeGetWPSPBCSessionsReqValid(pMac, &GetWPSPBCSessionsReq, (tANI_U8 *) pMsgBuf) != eSIR_SUCCESS)
3472 {
3473 limLog(pMac, LOGE,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003474 FL("received invalid eWNI_SME_GET_ASSOC_STAS_REQ message"));
Girish Gowliafd42312014-07-24 13:13:59 +05303475 return;
Jeff Johnson295189b2012-06-20 16:38:30 -07003476 }
3477
Jeff Johnson1250df42012-12-10 14:31:52 -08003478 // Get Associated stations from PE
Jeff Johnson295189b2012-06-20 16:38:30 -07003479 // Find PE session Entry
3480 if ((psessionEntry = peFindSessionByBssid(pMac, GetWPSPBCSessionsReq.bssId, &sessionId)) == NULL)
3481 {
3482 limLog(pMac, LOGE,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003483 FL("session does not exist for given bssId"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003484 goto limGetWPSPBCSessionsEnd;
3485 }
3486
3487 if (psessionEntry->limSystemRole != eLIM_AP_ROLE)
3488 {
3489 limLog(pMac, LOGE,
Sushant Kaushik1b645382014-10-13 16:39:36 +05303490 FL("Received unexpected message in role %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07003491 psessionEntry->limSystemRole);
3492 goto limGetWPSPBCSessionsEnd;
3493 }
3494
Jeff Johnson1250df42012-12-10 14:31:52 -08003495 // Call hdd callback with sap event to send the WPS PBC overlap information
Jeff Johnson295189b2012-06-20 16:38:30 -07003496 sapEvent.sapHddEventCode = eSAP_GET_WPSPBC_SESSION_EVENT;
3497 sapEvent.sapevt.sapGetWPSPBCSessionEvent.module = VOS_MODULE_ID_PE;
3498
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303499 if (vos_mem_compare( zeroMac, GetWPSPBCSessionsReq.pRemoveMac, sizeof(tSirMacAddr)))
Jeff Johnson295189b2012-06-20 16:38:30 -07003500 { //This is GetWpsSession call
3501
3502 limGetWPSPBCSessions(pMac,
3503 sapEvent.sapevt.sapGetWPSPBCSessionEvent.addr.bytes, sapEvent.sapevt.sapGetWPSPBCSessionEvent.UUID_E,
3504 &sapEvent.sapevt.sapGetWPSPBCSessionEvent.wpsPBCOverlap, psessionEntry);
3505 }
3506 else
3507 {
3508 limRemovePBCSessions(pMac, GetWPSPBCSessionsReq.pRemoveMac,psessionEntry);
3509 /* don't have to inform the HDD/Host */
3510 return;
3511 }
3512
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003513 PELOG4(limLog(pMac, LOGE, FL("wpsPBCOverlap %d"), sapEvent.sapevt.sapGetWPSPBCSessionEvent.wpsPBCOverlap);)
Jeff Johnson295189b2012-06-20 16:38:30 -07003514 PELOG4(limPrintMacAddr(pMac, sapEvent.sapevt.sapGetWPSPBCSessionEvent.addr.bytes, LOG4);)
3515
3516 sapEvent.sapevt.sapGetWPSPBCSessionEvent.status = VOS_STATUS_SUCCESS;
3517
3518limGetWPSPBCSessionsEnd:
3519 pSapEventCallback = (tpWLAN_SAPEventCB)GetWPSPBCSessionsReq.pSapEventCallback;
3520 pSapEventCallback(&sapEvent, GetWPSPBCSessionsReq.pUsrContext);
3521}
3522
Jeff Johnson295189b2012-06-20 16:38:30 -07003523
3524
3525/**
3526 * __limCounterMeasures()
3527 *
3528 * FUNCTION:
3529 * This function is called to "implement" MIC counter measure
3530 * and is *temporary* only
3531 *
3532 * LOGIC: on AP, disassoc all STA associated thru TKIP,
3533 * we don't do the proper STA disassoc sequence since the
3534 * BSS will be stoped anyway
3535 *
3536 *ASSUMPTIONS:
3537 *
3538 *NOTE:
3539 *
3540 * @param pMac Pointer to Global MAC structure
3541 * @return None
3542 */
3543
3544static void
3545__limCounterMeasures(tpAniSirGlobal pMac, tpPESession psessionEntry)
3546{
3547 tSirMacAddr mac = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
Abhishek Singh8944b222014-09-17 16:13:17 +05303548 /* If PMF is enabled then don't send broadcast disassociation */
3549 if ( ( (psessionEntry->limSystemRole == eLIM_AP_ROLE) ||
3550 (psessionEntry->limSystemRole == eLIM_BT_AMP_AP_ROLE) ||
3551 (psessionEntry->limSystemRole == eLIM_BT_AMP_STA_ROLE))
3552#ifdef WLAN_FEATURE_11W
3553 && !psessionEntry->limRmfEnabled
3554#endif
3555 )
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003556 limSendDisassocMgmtFrame(pMac, eSIR_MAC_MIC_FAILURE_REASON, mac, psessionEntry, FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003557
Jeff Johnson295189b2012-06-20 16:38:30 -07003558};
3559
3560
Jeff Johnson295189b2012-06-20 16:38:30 -07003561void
3562limProcessTkipCounterMeasures(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
3563{
3564 tSirSmeTkipCntrMeasReq tkipCntrMeasReq;
3565 tpPESession psessionEntry;
3566 tANI_U8 sessionId; //PE sessionId
3567
3568 if ( limTkipCntrMeasReqSerDes( pMac, &tkipCntrMeasReq, (tANI_U8 *) pMsgBuf ) != eSIR_SUCCESS )
3569 {
3570 limLog(pMac, LOGE,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003571 FL("received invalid eWNI_SME_TKIP_CNTR_MEAS_REQ message"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003572 return;
3573 }
3574
3575 if ( NULL == (psessionEntry = peFindSessionByBssid( pMac, tkipCntrMeasReq.bssId, &sessionId )) )
3576 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003577 limLog(pMac, LOGE, FL("session does not exist for given BSSID "));
Jeff Johnson295189b2012-06-20 16:38:30 -07003578 return;
3579 }
3580
3581 if ( tkipCntrMeasReq.bEnable )
3582 {
3583 __limCounterMeasures( pMac, psessionEntry );
3584 }
3585
3586 psessionEntry->bTkipCntrMeasActive = tkipCntrMeasReq.bEnable;
3587}
Jeff Johnson295189b2012-06-20 16:38:30 -07003588
3589
3590static void
3591__limHandleSmeStopBssRequest(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
3592{
3593 tSirSmeStopBssReq stopBssReq;
3594 tSirRetStatus status;
3595 tLimSmeStates prevState;
3596 tANI_U8 sessionId; //PE sessionId
3597 tpPESession psessionEntry;
3598 tANI_U8 smesessionId;
3599 tANI_U16 smetransactionId;
Sachin Ahuja51c08e62014-03-26 19:21:29 +05303600 tANI_U8 i = 0;
3601 tpDphHashNode pStaDs = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07003602
3603 limGetSessionInfo(pMac,(tANI_U8 *)pMsgBuf,&smesessionId,&smetransactionId);
3604
3605
3606
3607 if ((limStopBssReqSerDes(pMac, &stopBssReq, (tANI_U8 *) pMsgBuf) != eSIR_SUCCESS) ||
3608 !limIsSmeStopBssReqValid(pMsgBuf))
3609 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003610 PELOGW(limLog(pMac, LOGW, FL("received invalid SME_STOP_BSS_REQ message"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07003611 /// Send Stop BSS response to host
3612 limSendSmeRsp(pMac, eWNI_SME_STOP_BSS_RSP, eSIR_SME_INVALID_PARAMETERS,smesessionId,smetransactionId);
3613 return;
3614 }
3615
3616
3617 if((psessionEntry = peFindSessionByBssid(pMac,stopBssReq.bssId,&sessionId)) == NULL)
3618 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003619 limLog(pMac, LOGW, FL("session does not exist for given BSSID "));
Jeff Johnson295189b2012-06-20 16:38:30 -07003620 limSendSmeRsp(pMac, eWNI_SME_STOP_BSS_RSP, eSIR_SME_INVALID_PARAMETERS,smesessionId,smetransactionId);
3621 return;
3622 }
3623
3624#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM //FEATURE_WLAN_DIAG_SUPPORT
3625 limDiagEventReport(pMac, WLAN_PE_DIAG_STOP_BSS_REQ_EVENT, psessionEntry, 0, 0);
3626#endif //FEATURE_WLAN_DIAG_SUPPORT
3627
3628
3629 if ((psessionEntry->limSmeState != eLIM_SME_NORMAL_STATE) || /* Added For BT -AMP Support */
3630 (psessionEntry->limSystemRole == eLIM_STA_ROLE ))
3631 {
3632 /**
3633 * Should not have received STOP_BSS_REQ in states
3634 * other than 'normal' state or on STA in Infrastructure
3635 * mode. Log error and return response to host.
3636 */
3637 limLog(pMac, LOGE,
Sushant Kaushik1b645382014-10-13 16:39:36 +05303638 FL("received unexpected SME_STOP_BSS_REQ in state %d, for role %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07003639 psessionEntry->limSmeState, psessionEntry->limSystemRole);
3640 limPrintSmeState(pMac, LOGE, psessionEntry->limSmeState);
3641 /// Send Stop BSS response to host
3642 limSendSmeRsp(pMac, eWNI_SME_STOP_BSS_RSP, eSIR_SME_UNEXPECTED_REQ_RESULT_CODE,smesessionId,smetransactionId);
3643 return;
3644 }
3645
Jeff Johnson295189b2012-06-20 16:38:30 -07003646 if (psessionEntry->limSystemRole == eLIM_AP_ROLE )
3647 {
3648 limWPSPBCClose(pMac, psessionEntry);
3649 }
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003650 PELOGW(limLog(pMac, LOGW, FL("RECEIVED STOP_BSS_REQ with reason code=%d"), stopBssReq.reasonCode);)
Jeff Johnson295189b2012-06-20 16:38:30 -07003651
3652 prevState = psessionEntry->limSmeState;
3653
3654 psessionEntry->limSmeState = eLIM_SME_IDLE_STATE;
Jeff Johnsone7245742012-09-05 17:12:55 -07003655 MTRACE(macTrace(pMac, TRACE_CODE_SME_STATE, psessionEntry->peSessionId, psessionEntry->limSmeState));
Jeff Johnson295189b2012-06-20 16:38:30 -07003656
3657 /* Update SME session Id and Transaction Id */
3658 psessionEntry->smeSessionId = smesessionId;
3659 psessionEntry->transactionId = smetransactionId;
3660
Abhishek Singh8944b222014-09-17 16:13:17 +05303661 /* BTAMP_STA and STA_IN_IBSS should NOT send Disassoc frame.
3662 * If PMF is enabled then don't send broadcast disassociation */
3663 if ( ( (eLIM_STA_IN_IBSS_ROLE != psessionEntry->limSystemRole) &&
3664 (eLIM_BT_AMP_STA_ROLE != psessionEntry->limSystemRole) )
3665#ifdef WLAN_FEATURE_11W
3666 && !psessionEntry->limRmfEnabled
3667#endif
3668 )
Jeff Johnson295189b2012-06-20 16:38:30 -07003669 {
3670 tSirMacAddr bcAddr = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
3671 if ((stopBssReq.reasonCode == eSIR_SME_MIC_COUNTER_MEASURES))
3672 // Send disassoc all stations associated thru TKIP
3673 __limCounterMeasures(pMac,psessionEntry);
3674 else
Madan Mohan Koyyalamudi299b4862013-01-30 19:59:23 +05303675 limSendDisassocMgmtFrame(pMac, eSIR_MAC_DEAUTH_LEAVING_BSS_REASON, bcAddr, psessionEntry, FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003676 }
3677
3678 //limDelBss is also called as part of coalescing, when we send DEL BSS followed by Add Bss msg.
3679 pMac->lim.gLimIbssCoalescingHappened = false;
3680
Sachin Ahuja51c08e62014-03-26 19:21:29 +05303681 for(i = 1 ; i < pMac->lim.gLimAssocStaLimit ; i++)
3682 {
3683 pStaDs = dphGetHashEntry(pMac, i, &psessionEntry->dph.dphHashTable);
3684 if (NULL == pStaDs)
3685 continue;
3686 status = limDelSta(pMac, pStaDs, false, psessionEntry) ;
3687 if(eSIR_SUCCESS == status)
3688 {
3689 limDeleteDphHashEntry(pMac, pStaDs->staAddr, pStaDs->assocId, psessionEntry) ;
3690 limReleasePeerIdx(pMac, pStaDs->assocId, psessionEntry) ;
3691 }
3692 else
3693 {
3694 limLog(pMac, LOGE, FL("limDelSta failed with Status : %d"), status);
3695 VOS_ASSERT(0) ;
3696 }
3697 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003698 /* send a delBss to HAL and wait for a response */
3699 status = limDelBss(pMac, NULL,psessionEntry->bssIdx,psessionEntry);
3700
3701 if (status != eSIR_SUCCESS)
3702 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003703 PELOGE(limLog(pMac, LOGE, FL("delBss failed for bss %d"), psessionEntry->bssIdx);)
Jeff Johnson295189b2012-06-20 16:38:30 -07003704 psessionEntry->limSmeState= prevState;
3705
Jeff Johnsone7245742012-09-05 17:12:55 -07003706 MTRACE(macTrace(pMac, TRACE_CODE_SME_STATE, psessionEntry->peSessionId, psessionEntry->limSmeState));
Jeff Johnson295189b2012-06-20 16:38:30 -07003707
3708 limSendSmeRsp(pMac, eWNI_SME_STOP_BSS_RSP, eSIR_SME_STOP_BSS_FAILURE,smesessionId,smetransactionId);
3709 }
3710}
3711
3712
3713/**--------------------------------------------------------------
3714\fn __limProcessSmeStopBssReq
3715
3716\brief Wrapper for the function __limHandleSmeStopBssRequest
3717 This message will be defered until softmac come out of
3718 scan mode. Message should be handled even if we have
3719 detected radar in the current operating channel.
3720\param pMac
3721\param pMsg
3722
3723\return TRUE - If we consumed the buffer
3724 FALSE - If have defered the message.
3725 ---------------------------------------------------------------*/
3726static tANI_BOOLEAN
3727__limProcessSmeStopBssReq(tpAniSirGlobal pMac, tpSirMsgQ pMsg)
3728{
3729 if (__limIsDeferedMsgForLearn(pMac, pMsg))
3730 {
3731 /**
3732 * If message defered, buffer is not consumed yet.
3733 * So return false
3734 */
3735 return eANI_BOOLEAN_FALSE;
3736 }
3737 __limHandleSmeStopBssRequest(pMac, (tANI_U32 *) pMsg->bodyptr);
3738 return eANI_BOOLEAN_TRUE;
3739} /*** end __limProcessSmeStopBssReq() ***/
3740
3741
3742void limProcessSmeDelBssRsp(
3743 tpAniSirGlobal pMac,
3744 tANI_U32 body,tpPESession psessionEntry)
3745{
3746
3747 (void) body;
3748 SET_LIM_PROCESS_DEFD_MESGS(pMac, true);
3749 //TBD: get the sessionEntry
Ravi Joshib58ca0d2013-10-29 09:50:23 -07003750 limIbssDelete(pMac,psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07003751 dphHashTableClassInit(pMac, &psessionEntry->dph.dphHashTable);
3752 limDeletePreAuthList(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -07003753 limSendSmeRsp(pMac, eWNI_SME_STOP_BSS_RSP, eSIR_SME_SUCCESS,psessionEntry->smeSessionId,psessionEntry->transactionId);
3754 return;
3755}
3756
3757
Jeff Johnson295189b2012-06-20 16:38:30 -07003758/**---------------------------------------------------------------
3759\fn __limProcessSmeAssocCnfNew
3760\brief This function handles SME_ASSOC_CNF/SME_REASSOC_CNF
3761\ in BTAMP AP.
3762\
3763\param pMac
3764\param msgType - message type
3765\param pMsgBuf - a pointer to the SME message buffer
3766\return None
3767------------------------------------------------------------------*/
3768
3769 void
3770__limProcessSmeAssocCnfNew(tpAniSirGlobal pMac, tANI_U32 msgType, tANI_U32 *pMsgBuf)
3771{
3772 tSirSmeAssocCnf assocCnf;
3773 tpDphHashNode pStaDs = NULL;
3774 tpPESession psessionEntry= NULL;
3775 tANI_U8 sessionId;
3776
3777
3778 if(pMsgBuf == NULL)
3779 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003780 limLog(pMac, LOGE, FL("pMsgBuf is NULL "));
Jeff Johnson295189b2012-06-20 16:38:30 -07003781 goto end;
3782 }
3783
3784 if ((limAssocCnfSerDes(pMac, &assocCnf, (tANI_U8 *) pMsgBuf) == eSIR_FAILURE) ||
3785 !__limIsSmeAssocCnfValid(&assocCnf))
3786 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003787 limLog(pMac, LOGE, FL("Received invalid SME_RE(ASSOC)_CNF message "));
Jeff Johnson295189b2012-06-20 16:38:30 -07003788 goto end;
3789 }
3790
3791 if((psessionEntry = peFindSessionByBssid(pMac, assocCnf.bssId, &sessionId))== NULL)
3792 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003793 limLog(pMac, LOGE, FL("session does not exist for given bssId"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003794 goto end;
3795 }
3796
3797 if ( ((psessionEntry->limSystemRole != eLIM_AP_ROLE) && (psessionEntry->limSystemRole != eLIM_BT_AMP_AP_ROLE)) ||
3798 ((psessionEntry->limSmeState != eLIM_SME_NORMAL_STATE) && (psessionEntry->limSmeState != eLIM_SME_NORMAL_CHANNEL_SCAN_STATE)))
3799 {
Sushant Kaushik1b645382014-10-13 16:39:36 +05303800 limLog(pMac, LOGE, FL("Received unexpected message %X in state %d, in role %d"),
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303801 msgType, psessionEntry->limSmeState, psessionEntry->limSystemRole);
Jeff Johnson295189b2012-06-20 16:38:30 -07003802 goto end;
3803 }
3804
3805 pStaDs = dphGetHashEntry(pMac, assocCnf.aid, &psessionEntry->dph.dphHashTable);
3806
3807 if (pStaDs == NULL)
3808 {
3809 limLog(pMac, LOG1,
3810 FL("Received invalid message %X due to no STA context, for aid %d, peer "),
3811 msgType, assocCnf.aid);
3812 limPrintMacAddr(pMac, assocCnf.peerMacAddr, LOG1);
3813
3814 /*
3815 ** send a DISASSOC_IND message to WSM to make sure
3816 ** the state in WSM and LIM is the same
3817 **/
3818 limSendSmeDisassocNtf( pMac, assocCnf.peerMacAddr, eSIR_SME_STA_NOT_ASSOCIATED,
3819 eLIM_PEER_ENTITY_DISASSOC, assocCnf.aid,psessionEntry->smeSessionId,psessionEntry->transactionId,psessionEntry);
3820 goto end;
3821 }
3822 if ((pStaDs &&
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303823 (( !vos_mem_compare( (tANI_U8 *) pStaDs->staAddr,
Jeff Johnson295189b2012-06-20 16:38:30 -07003824 (tANI_U8 *) assocCnf.peerMacAddr,
3825 sizeof(tSirMacAddr)) ) ||
3826 (pStaDs->mlmStaContext.mlmState != eLIM_MLM_WT_ASSOC_CNF_STATE) ||
3827 ((pStaDs->mlmStaContext.subType == LIM_ASSOC) &&
3828 (msgType != eWNI_SME_ASSOC_CNF)) ||
3829 ((pStaDs->mlmStaContext.subType == LIM_REASSOC) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07003830 (msgType != eWNI_SME_ASSOC_CNF))))) // since softap is passing this as ASSOC_CNF and subtype differs
Jeff Johnson295189b2012-06-20 16:38:30 -07003831 {
3832 limLog(pMac, LOG1,
3833 FL("Received invalid message %X due to peerMacAddr mismatched or not in eLIM_MLM_WT_ASSOC_CNF_STATE state, for aid %d, peer "),
3834 msgType, assocCnf.aid);
3835 limPrintMacAddr(pMac, assocCnf.peerMacAddr, LOG1);
3836 goto end;
3837 }
3838
3839 /*
3840 ** Deactivate/delet CNF_WAIT timer since ASSOC_CNF
3841 ** has been received
3842 **/
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003843 limLog(pMac, LOG1, FL("Received SME_ASSOC_CNF. Delete Timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003844 limDeactivateAndChangePerStaIdTimer(pMac, eLIM_CNF_WAIT_TIMER, pStaDs->assocId);
3845
3846 if (assocCnf.statusCode == eSIR_SME_SUCCESS)
3847 {
3848 /* In BTAMP-AP, PE already finished the WDA_ADD_STA sequence
3849 * when it had received Assoc Request frame. Now, PE just needs to send
3850 * Association Response frame to the requesting BTAMP-STA.
3851 */
3852 pStaDs->mlmStaContext.mlmState = eLIM_MLM_LINK_ESTABLISHED_STATE;
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003853 limLog(pMac, LOG1, FL("sending Assoc Rsp frame to STA (assoc id=%d) "), pStaDs->assocId);
Jeff Johnson295189b2012-06-20 16:38:30 -07003854 limSendAssocRspMgmtFrame( pMac, eSIR_SUCCESS, pStaDs->assocId, pStaDs->staAddr,
3855 pStaDs->mlmStaContext.subType, pStaDs, psessionEntry);
3856 goto end;
3857 } // (assocCnf.statusCode == eSIR_SME_SUCCESS)
3858 else
3859 {
3860 // SME_ASSOC_CNF status is non-success, so STA is not allowed to be associated
3861 /*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*/
3862 if(!pStaDs->mlmStaContext.updateContext)
3863 pStaDs->mlmStaContext.updateContext = 1;
3864 limRejectAssociation(pMac, pStaDs->staAddr,
3865 pStaDs->mlmStaContext.subType,
3866 true, pStaDs->mlmStaContext.authType,
3867 pStaDs->assocId, true,
3868 eSIR_MAC_UNSPEC_FAILURE_STATUS, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07003869 }
3870
3871end:
3872 if((psessionEntry != NULL) && (pStaDs != NULL))
3873 {
3874 if ( psessionEntry->parsedAssocReq[pStaDs->assocId] != NULL )
3875 {
3876 if ( ((tpSirAssocReq)(psessionEntry->parsedAssocReq[pStaDs->assocId]))->assocReqFrame)
3877 {
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303878 vos_mem_free(((tpSirAssocReq)
3879 (psessionEntry->parsedAssocReq[pStaDs->assocId]))->assocReqFrame);
Jeff Johnson295189b2012-06-20 16:38:30 -07003880 ((tpSirAssocReq)(psessionEntry->parsedAssocReq[pStaDs->assocId]))->assocReqFrame = NULL;
3881 }
3882
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303883 vos_mem_free(psessionEntry->parsedAssocReq[pStaDs->assocId]);
Jeff Johnson295189b2012-06-20 16:38:30 -07003884 psessionEntry->parsedAssocReq[pStaDs->assocId] = NULL;
3885 }
3886 }
3887
3888} /*** end __limProcessSmeAssocCnfNew() ***/
3889
3890
Jeff Johnson295189b2012-06-20 16:38:30 -07003891
3892
3893static void
3894__limProcessSmeAddtsReq(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
3895{
3896 tpDphHashNode pStaDs;
3897 tSirMacAddr peerMac;
3898 tpSirAddtsReq pSirAddts;
3899 tANI_U32 timeout;
3900 tpPESession psessionEntry;
3901 tANI_U8 sessionId; //PE sessionId
3902 tANI_U8 smesessionId;
3903 tANI_U16 smetransactionId;
3904
3905
3906 if(pMsgBuf == NULL)
3907 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003908 limLog(pMac, LOGE,FL("Buffer is Pointing to NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003909 return;
3910 }
3911
3912 limGetSessionInfo(pMac,(tANI_U8 *)pMsgBuf,&smesessionId,&smetransactionId);
3913
3914 pSirAddts = (tpSirAddtsReq) pMsgBuf;
3915
3916 if((psessionEntry = peFindSessionByBssid(pMac, pSirAddts->bssId,&sessionId))== NULL)
3917 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003918 limLog(pMac, LOGE, "Session Does not exist for given bssId");
Jeff Johnson295189b2012-06-20 16:38:30 -07003919 return;
3920 }
3921#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM //FEATURE_WLAN_DIAG_SUPPORT
3922 limDiagEventReport(pMac, WLAN_PE_DIAG_ADDTS_REQ_EVENT, psessionEntry, 0, 0);
3923#endif //FEATURE_WLAN_DIAG_SUPPORT
3924
3925
3926
3927 /* if sta
3928 * - verify assoc state
3929 * - send addts request to ap
3930 * - wait for addts response from ap
3931 * if ap, just ignore with error log
3932 */
3933 PELOG1(limLog(pMac, LOG1,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003934 FL("Received SME_ADDTS_REQ (TSid %d, UP %d)"),
Jeff Johnson295189b2012-06-20 16:38:30 -07003935 pSirAddts->req.tspec.tsinfo.traffic.tsid,
3936 pSirAddts->req.tspec.tsinfo.traffic.userPrio);)
3937
3938 if ((psessionEntry->limSystemRole != eLIM_STA_ROLE)&&(psessionEntry->limSystemRole != eLIM_BT_AMP_STA_ROLE))
3939 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003940 PELOGE(limLog(pMac, LOGE, "AddTs received on AP - ignoring");)
Jeff Johnson295189b2012-06-20 16:38:30 -07003941 limSendSmeAddtsRsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE, psessionEntry, pSirAddts->req.tspec,
3942 smesessionId,smetransactionId);
3943 return;
3944 }
3945
3946 //Ignore the request if STA is in 11B mode.
3947 if(psessionEntry->dot11mode == WNI_CFG_DOT11_MODE_11B)
3948 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003949 PELOGE(limLog(pMac, LOGE, "AddTS received while Dot11Mode is 11B - ignoring");)
Jeff Johnson295189b2012-06-20 16:38:30 -07003950 limSendSmeAddtsRsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE, psessionEntry, pSirAddts->req.tspec,
3951 smesessionId,smetransactionId);
3952 return;
3953 }
3954
3955
3956 pStaDs = dphGetHashEntry(pMac, DPH_STA_HASH_INDEX_PEER, &psessionEntry->dph.dphHashTable);
3957
3958 if(pStaDs == NULL)
3959 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003960 PELOGE(limLog(pMac, LOGE, "Cannot find AP context for addts req");)
Jeff Johnson295189b2012-06-20 16:38:30 -07003961 limSendSmeAddtsRsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE, psessionEntry, pSirAddts->req.tspec,
3962 smesessionId,smetransactionId);
3963 return;
3964 }
3965
3966 if ((! pStaDs->valid) ||
3967 (pStaDs->mlmStaContext.mlmState != eLIM_MLM_LINK_ESTABLISHED_STATE))
3968 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003969 PELOGE(limLog(pMac, LOGE, "AddTs received in invalid MLM state");)
Jeff Johnson295189b2012-06-20 16:38:30 -07003970 limSendSmeAddtsRsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE, psessionEntry, pSirAddts->req.tspec,
3971 smesessionId,smetransactionId);
3972 return;
3973 }
3974
3975 pSirAddts->req.wsmTspecPresent = 0;
3976 pSirAddts->req.wmeTspecPresent = 0;
3977 pSirAddts->req.lleTspecPresent = 0;
3978
3979 if ((pStaDs->wsmEnabled) &&
3980 (pSirAddts->req.tspec.tsinfo.traffic.accessPolicy != SIR_MAC_ACCESSPOLICY_EDCA))
3981 pSirAddts->req.wsmTspecPresent = 1;
3982 else if (pStaDs->wmeEnabled)
3983 pSirAddts->req.wmeTspecPresent = 1;
3984 else if (pStaDs->lleEnabled)
3985 pSirAddts->req.lleTspecPresent = 1;
3986 else
3987 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003988 PELOGW(limLog(pMac, LOGW, FL("ADDTS_REQ ignore - qos is disabled"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07003989 limSendSmeAddtsRsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE, psessionEntry, pSirAddts->req.tspec,
3990 smesessionId,smetransactionId);
3991 return;
3992 }
3993
3994 if ((psessionEntry->limSmeState != eLIM_SME_ASSOCIATED_STATE) &&
3995 (psessionEntry->limSmeState != eLIM_SME_LINK_EST_STATE))
3996 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003997 limLog(pMac, LOGE, "AddTs received in invalid LIMsme state (%d)",
Jeff Johnson295189b2012-06-20 16:38:30 -07003998 psessionEntry->limSmeState);
3999 limSendSmeAddtsRsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE, psessionEntry, pSirAddts->req.tspec,
4000 smesessionId,smetransactionId);
4001 return;
4002 }
4003
4004 if (pMac->lim.gLimAddtsSent)
4005 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004006 limLog(pMac, LOGE, "Addts (token %d, tsid %d, up %d) is still pending",
Jeff Johnson295189b2012-06-20 16:38:30 -07004007 pMac->lim.gLimAddtsReq.req.dialogToken,
4008 pMac->lim.gLimAddtsReq.req.tspec.tsinfo.traffic.tsid,
4009 pMac->lim.gLimAddtsReq.req.tspec.tsinfo.traffic.userPrio);
4010 limSendSmeAddtsRsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE, psessionEntry, pSirAddts->req.tspec,
4011 smesessionId,smetransactionId);
4012 return;
4013 }
4014
4015 #if 0
4016 val = sizeof(tSirMacAddr);
4017 if (wlan_cfgGetStr(pMac, WNI_CFG_BSSID, peerMac, &val) != eSIR_SUCCESS)
4018 {
4019 /// Could not get BSSID from CFG. Log error.
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004020 limLog(pMac, LOGP, FL("could not retrieve BSSID"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004021 return;
4022 }
4023 #endif
4024 sirCopyMacAddr(peerMac,psessionEntry->bssId);
4025
4026 // save the addts request
4027 pMac->lim.gLimAddtsSent = true;
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304028 vos_mem_copy( (tANI_U8 *) &pMac->lim.gLimAddtsReq, (tANI_U8 *) pSirAddts, sizeof(tSirAddtsReq));
Jeff Johnson295189b2012-06-20 16:38:30 -07004029
4030 // ship out the message now
4031 limSendAddtsReqActionFrame(pMac, peerMac, &pSirAddts->req,
4032 psessionEntry);
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004033 PELOG1(limLog(pMac, LOG1, "Sent ADDTS request");)
Jeff Johnson295189b2012-06-20 16:38:30 -07004034
4035 // start a timer to wait for the response
4036 if (pSirAddts->timeout)
4037 timeout = pSirAddts->timeout;
4038 else if (wlan_cfgGetInt(pMac, WNI_CFG_ADDTS_RSP_TIMEOUT, &timeout) != eSIR_SUCCESS)
4039 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004040 limLog(pMac, LOGP, FL("Unable to get Cfg param %d (Addts Rsp Timeout)"),
Jeff Johnson295189b2012-06-20 16:38:30 -07004041 WNI_CFG_ADDTS_RSP_TIMEOUT);
4042 return;
4043 }
4044
4045 timeout = SYS_MS_TO_TICKS(timeout);
4046 if (tx_timer_change(&pMac->lim.limTimers.gLimAddtsRspTimer, timeout, 0) != TX_SUCCESS)
4047 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004048 limLog(pMac, LOGP, FL("AddtsRsp timer change failed!"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004049 return;
4050 }
4051 pMac->lim.gLimAddtsRspTimerCount++;
4052 if (tx_timer_change_context(&pMac->lim.limTimers.gLimAddtsRspTimer,
4053 pMac->lim.gLimAddtsRspTimerCount) != TX_SUCCESS)
4054 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004055 limLog(pMac, LOGP, FL("AddtsRsp timer change failed!"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004056 return;
4057 }
Jeff Johnsone7245742012-09-05 17:12:55 -07004058 MTRACE(macTrace(pMac, TRACE_CODE_TIMER_ACTIVATE, psessionEntry->peSessionId, eLIM_ADDTS_RSP_TIMER));
Jeff Johnson295189b2012-06-20 16:38:30 -07004059
4060 //add the sessionId to the timer object
4061 pMac->lim.limTimers.gLimAddtsRspTimer.sessionId = sessionId;
4062 if (tx_timer_activate(&pMac->lim.limTimers.gLimAddtsRspTimer) != TX_SUCCESS)
4063 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004064 limLog(pMac, LOGP, FL("AddtsRsp timer activation failed!"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004065 return;
4066 }
4067 return;
4068}
4069
4070
4071static void
4072__limProcessSmeDeltsReq(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
4073{
4074 tSirMacAddr peerMacAddr;
4075 tANI_U8 ac;
4076 tSirMacTSInfo *pTsinfo;
4077 tpSirDeltsReq pDeltsReq = (tpSirDeltsReq) pMsgBuf;
4078 tpDphHashNode pStaDs = NULL;
4079 tpPESession psessionEntry;
4080 tANI_U8 sessionId;
4081 tANI_U32 status = eSIR_SUCCESS;
4082 tANI_U8 smesessionId;
4083 tANI_U16 smetransactionId;
4084
4085 limGetSessionInfo(pMac,(tANI_U8 *)pMsgBuf,&smesessionId,&smetransactionId);
4086
4087 if((psessionEntry = peFindSessionByBssid(pMac, pDeltsReq->bssId, &sessionId))== NULL)
4088 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004089 limLog(pMac, LOGE, "Session Does not exist for given bssId");
Jeff Johnson295189b2012-06-20 16:38:30 -07004090 status = eSIR_FAILURE;
4091 goto end;
4092 }
4093#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM //FEATURE_WLAN_DIAG_SUPPORT
4094 limDiagEventReport(pMac, WLAN_PE_DIAG_DELTS_REQ_EVENT, psessionEntry, 0, 0);
4095#endif //FEATURE_WLAN_DIAG_SUPPORT
4096
4097
4098 if (eSIR_SUCCESS != limValidateDeltsReq(pMac, pDeltsReq, peerMacAddr,psessionEntry))
4099 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004100 PELOGE(limLog(pMac, LOGE, FL("limValidateDeltsReq failed"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07004101 status = eSIR_FAILURE;
4102 limSendSmeDeltsRsp(pMac, pDeltsReq, eSIR_FAILURE,psessionEntry,smesessionId,smetransactionId);
4103 return;
4104 }
4105
Arif Hussaina7c8e412013-11-20 11:06:42 -08004106 PELOG1(limLog(pMac, LOG1, FL("Sent DELTS request to station with "
4107 "assocId = %d MacAddr = "MAC_ADDRESS_STR),
4108 pDeltsReq->aid, MAC_ADDR_ARRAY(peerMacAddr));)
Jeff Johnson295189b2012-06-20 16:38:30 -07004109
4110 limSendDeltsReqActionFrame(pMac, peerMacAddr, pDeltsReq->req.wmeTspecPresent, &pDeltsReq->req.tsinfo, &pDeltsReq->req.tspec,
4111 psessionEntry);
4112
4113 pTsinfo = pDeltsReq->req.wmeTspecPresent ? &pDeltsReq->req.tspec.tsinfo : &pDeltsReq->req.tsinfo;
4114
4115 /* We've successfully send DELTS frame to AP. Update the
4116 * dynamic UAPSD mask. The AC for this TSPEC to be deleted
4117 * is no longer trigger enabled or delivery enabled
4118 */
4119 limSetTspecUapsdMask(pMac, pTsinfo, CLEAR_UAPSD_MASK);
4120
4121 /* We're deleting the TSPEC, so this particular AC is no longer
4122 * admitted. PE needs to downgrade the EDCA
4123 * parameters(for the AC for which TS is being deleted) to the
4124 * next best AC for which ACM is not enabled, and send the
4125 * updated values to HAL.
4126 */
4127 ac = upToAc(pTsinfo->traffic.userPrio);
4128
4129 if(pTsinfo->traffic.direction == SIR_MAC_DIRECTION_UPLINK)
4130 {
4131 pMac->lim.gAcAdmitMask[SIR_MAC_DIRECTION_UPLINK] &= ~(1 << ac);
4132 }
4133 else if(pTsinfo->traffic.direction == SIR_MAC_DIRECTION_DNLINK)
4134 {
4135 pMac->lim.gAcAdmitMask[SIR_MAC_DIRECTION_DNLINK] &= ~(1 << ac);
4136 }
4137 else if(pTsinfo->traffic.direction == SIR_MAC_DIRECTION_BIDIR)
4138 {
4139 pMac->lim.gAcAdmitMask[SIR_MAC_DIRECTION_UPLINK] &= ~(1 << ac);
4140 pMac->lim.gAcAdmitMask[SIR_MAC_DIRECTION_DNLINK] &= ~(1 << ac);
4141 }
4142
4143 limSetActiveEdcaParams(pMac, psessionEntry->gLimEdcaParams, psessionEntry);
4144
4145 pStaDs = dphGetHashEntry(pMac, DPH_STA_HASH_INDEX_PEER, &psessionEntry->dph.dphHashTable);
4146 if (pStaDs != NULL)
4147 {
4148 if (pStaDs->aniPeer == eANI_BOOLEAN_TRUE)
4149 limSendEdcaParams(pMac, psessionEntry->gLimEdcaParamsActive, pStaDs->bssId, eANI_BOOLEAN_TRUE);
4150 else
4151 limSendEdcaParams(pMac, psessionEntry->gLimEdcaParamsActive, pStaDs->bssId, eANI_BOOLEAN_FALSE);
4152 status = eSIR_SUCCESS;
4153 }
4154 else
4155 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004156 limLog(pMac, LOGE, FL("Self entry missing in Hash Table "));
Jeff Johnson295189b2012-06-20 16:38:30 -07004157 status = eSIR_FAILURE;
4158 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004159#ifdef FEATURE_WLAN_ESE
4160#ifdef FEATURE_WLAN_ESE_UPLOAD
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004161 limSendSmeTsmIEInd(pMac, psessionEntry, 0, 0, 0);
4162#else
Jeff Johnson295189b2012-06-20 16:38:30 -07004163 limDeactivateAndChangeTimer(pMac,eLIM_TSM_TIMER);
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004164#endif /* FEATURE_WLAN_ESE_UPLOAD */
Jeff Johnson295189b2012-06-20 16:38:30 -07004165#endif
4166
4167 // send an sme response back
4168 end:
4169 limSendSmeDeltsRsp(pMac, pDeltsReq, eSIR_SUCCESS,psessionEntry,smesessionId,smetransactionId);
4170}
4171
4172
4173void
4174limProcessSmeAddtsRspTimeout(tpAniSirGlobal pMac, tANI_U32 param)
4175{
4176 //fetch the sessionEntry based on the sessionId
4177 tpPESession psessionEntry;
4178 if((psessionEntry = peFindSessionBySessionId(pMac, pMac->lim.limTimers.gLimAddtsRspTimer.sessionId))== NULL)
4179 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004180 limLog(pMac, LOGP,FL("Session Does not exist for given sessionID"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004181 return;
4182 }
4183
4184 if ( (psessionEntry->limSystemRole != eLIM_STA_ROLE) && (psessionEntry->limSystemRole != eLIM_BT_AMP_STA_ROLE) )
4185 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004186 limLog(pMac, LOGW, "AddtsRspTimeout in non-Sta role (%d)", psessionEntry->limSystemRole);
Jeff Johnson295189b2012-06-20 16:38:30 -07004187 pMac->lim.gLimAddtsSent = false;
4188 return;
4189 }
4190
4191 if (! pMac->lim.gLimAddtsSent)
4192 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004193 PELOGW(limLog(pMac, LOGW, "AddtsRspTimeout but no AddtsSent");)
Jeff Johnson295189b2012-06-20 16:38:30 -07004194 return;
4195 }
4196
4197 if (param != pMac->lim.gLimAddtsRspTimerCount)
4198 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004199 limLog(pMac, LOGE, FL("Invalid AddtsRsp Timer count %d (exp %d)"),
Jeff Johnson295189b2012-06-20 16:38:30 -07004200 param, pMac->lim.gLimAddtsRspTimerCount);
4201 return;
4202 }
4203
4204 // this a real response timeout
4205 pMac->lim.gLimAddtsSent = false;
4206 pMac->lim.gLimAddtsRspTimerCount++;
4207
4208 limSendSmeAddtsRsp(pMac, true, eSIR_SME_ADDTS_RSP_TIMEOUT, psessionEntry, pMac->lim.gLimAddtsReq.req.tspec,
4209 psessionEntry->smeSessionId, psessionEntry->transactionId);
4210}
4211
4212
4213/**
4214 * __limProcessSmeStatsRequest()
4215 *
4216 *FUNCTION:
4217 *
4218 *
4219 *NOTE:
4220 *
4221 * @param pMac Pointer to Global MAC structure
4222 * @param *pMsgBuf A pointer to the SME message buffer
4223 * @return None
4224 */
4225static void
4226__limProcessSmeStatsRequest(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
4227{
4228 tpAniGetStatsReq pStatsReq;
4229 tSirMsgQ msgQ;
4230 tpPESession psessionEntry;
4231 tANI_U8 sessionId;
4232
4233
4234 if(pMsgBuf == NULL)
4235 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004236 limLog(pMac, LOGE,FL("Buffer is Pointing to NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004237 return;
4238 }
4239
4240 pStatsReq = (tpAniGetStatsReq) pMsgBuf;
4241
4242 if((psessionEntry = peFindSessionByBssid(pMac,pStatsReq->bssId,&sessionId))== NULL)
4243 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004244 limLog(pMac, LOGE, FL("session does not exist for given bssId"));
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304245 vos_mem_free( pMsgBuf );
Leela Venkata Kiran Kumar Reddy Chiralad6c0fe22013-12-11 19:10:50 -08004246 pMsgBuf = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004247 return;
4248 }
4249
4250
4251
4252 switch(pStatsReq->msgType)
4253 {
4254 //Add Lim stats here. and send reqsponse.
4255
4256 //HAL maintained Stats.
4257 case eWNI_SME_STA_STAT_REQ:
4258 msgQ.type = WDA_STA_STAT_REQ;
4259 break;
4260 case eWNI_SME_AGGR_STAT_REQ:
4261 msgQ.type = WDA_AGGR_STAT_REQ;
4262 break;
4263 case eWNI_SME_GLOBAL_STAT_REQ:
4264 msgQ.type = WDA_GLOBAL_STAT_REQ;
4265 break;
4266 case eWNI_SME_STAT_SUMM_REQ:
4267 msgQ.type = WDA_STAT_SUMM_REQ;
4268 break;
4269 default: //Unknown request.
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004270 PELOGE(limLog(pMac, LOGE, "Unknown Statistics request");)
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304271 vos_mem_free( pMsgBuf );
Leela Venkata Kiran Kumar Reddy Chiralad6c0fe22013-12-11 19:10:50 -08004272 pMsgBuf = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004273 return;
4274 }
4275
Jeff Johnson295189b2012-06-20 16:38:30 -07004276 msgQ.reserved = 0;
4277 msgQ.bodyptr = pMsgBuf;
4278 msgQ.bodyval = 0;
Leela Venkata Kiran Kumar Reddy Chirala68a6abe2013-02-28 07:43:16 -08004279 if(NULL == psessionEntry)
4280 {
4281 MTRACE(macTraceMsgTx(pMac, NO_SESSION, msgQ.type));
4282 }
4283 else
4284 {
4285 MTRACE(macTraceMsgTx(pMac, psessionEntry->peSessionId, msgQ.type));
4286 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004287 if( eSIR_SUCCESS != (wdaPostCtrlMsg( pMac, &msgQ ))){
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004288 limLog(pMac, LOGP, "Unable to forward request");
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304289 vos_mem_free( pMsgBuf );
Leela Venkata Kiran Kumar Reddy Chiralad6c0fe22013-12-11 19:10:50 -08004290 pMsgBuf = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004291 return;
4292 }
4293
4294 return;
4295}
4296
4297
4298/**
4299 * __limProcessSmeGetStatisticsRequest()
4300 *
4301 *FUNCTION:
4302 *
4303 *
4304 *NOTE:
4305 *
4306 * @param pMac Pointer to Global MAC structure
4307 * @param *pMsgBuf A pointer to the SME message buffer
4308 * @return None
4309 */
4310static void
4311__limProcessSmeGetStatisticsRequest(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
4312{
4313 tpAniGetPEStatsReq pPEStatsReq;
4314 tSirMsgQ msgQ;
4315
4316 pPEStatsReq = (tpAniGetPEStatsReq) pMsgBuf;
4317
4318 //pPEStatsReq->msgType should be eWNI_SME_GET_STATISTICS_REQ
4319
4320 msgQ.type = WDA_GET_STATISTICS_REQ;
4321
Jeff Johnson295189b2012-06-20 16:38:30 -07004322 msgQ.reserved = 0;
4323 msgQ.bodyptr = pMsgBuf;
4324 msgQ.bodyval = 0;
Jeff Johnsone7245742012-09-05 17:12:55 -07004325 MTRACE(macTraceMsgTx(pMac, NO_SESSION, msgQ.type));
Jeff Johnson295189b2012-06-20 16:38:30 -07004326
4327 if( eSIR_SUCCESS != (wdaPostCtrlMsg( pMac, &msgQ ))){
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304328 vos_mem_free( pMsgBuf );
Leela Venkata Kiran Kumar Reddy Chiralad6c0fe22013-12-11 19:10:50 -08004329 pMsgBuf = NULL;
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004330 limLog(pMac, LOGP, "Unable to forward request");
Jeff Johnson295189b2012-06-20 16:38:30 -07004331 return;
4332 }
4333
4334 return;
4335}
4336
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004337#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004338/**
4339 *FUNCTION: __limProcessSmeGetTsmStatsRequest()
4340 *
4341 *NOTE:
4342 *
4343 * @param pMac Pointer to Global MAC structure
4344 * @param *pMsgBuf A pointer to the SME message buffer
4345 * @return None
4346 */
4347static void
4348__limProcessSmeGetTsmStatsRequest(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
4349{
4350 tSirMsgQ msgQ;
4351
4352 msgQ.type = WDA_TSM_STATS_REQ;
4353 msgQ.reserved = 0;
4354 msgQ.bodyptr = pMsgBuf;
4355 msgQ.bodyval = 0;
4356 MTRACE(macTraceMsgTx(pMac, NO_SESSION, msgQ.type));
4357
4358 if( eSIR_SUCCESS != (wdaPostCtrlMsg( pMac, &msgQ ))){
4359 vos_mem_free( pMsgBuf );
Leela Venkata Kiran Kumar Reddy Chiralad6c0fe22013-12-11 19:10:50 -08004360 pMsgBuf = NULL;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004361 limLog(pMac, LOGP, "Unable to forward request");
4362 return;
4363 }
4364}
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004365#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004366
4367
Jeff Johnson295189b2012-06-20 16:38:30 -07004368
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004369#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08004370/**
4371 * __limProcessSmeGetRoamRssiRequest()
4372 *
4373 *FUNCTION:
4374 *
4375 *
4376 *NOTE:
4377 *
4378 * @param pMac Pointer to Global MAC structure
4379 * @param *pMsgBuf A pointer to the SME message buffer
4380 * @return None
4381 */
4382static void
4383__limProcessSmeGetRoamRssiRequest(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
4384{
4385 tpAniGetRssiReq pPEGetRoamRssiReq = NULL;
4386 tSirMsgQ msgQ;
4387
4388 pPEGetRoamRssiReq = (tpAniGetRssiReq) pMsgBuf;
4389 msgQ.type = WDA_GET_ROAM_RSSI_REQ;
4390
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08004391 msgQ.reserved = 0;
4392 msgQ.bodyptr = pMsgBuf;
4393 msgQ.bodyval = 0;
4394 MTRACE(macTraceMsgTx(pMac, NO_SESSION, msgQ.type));
4395
4396 if( eSIR_SUCCESS != (wdaPostCtrlMsg( pMac, &msgQ ))){
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304397 vos_mem_free( pMsgBuf );
Leela Venkata Kiran Kumar Reddy Chiralad6c0fe22013-12-11 19:10:50 -08004398 pMsgBuf = NULL;
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004399 limLog(pMac, LOGP, "Unable to forward request");
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08004400 return;
4401 }
4402
4403 return;
4404}
4405#endif
4406
4407
Jeff Johnson295189b2012-06-20 16:38:30 -07004408static void
4409__limProcessSmeUpdateAPWPSIEs(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
4410{
4411 tpSirUpdateAPWPSIEsReq pUpdateAPWPSIEsReq;
4412 tpPESession psessionEntry;
4413 tANI_U8 sessionId; //PE sessionID
4414
4415 PELOG1(limLog(pMac, LOG1,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004416 FL("received UPDATE_APWPSIEs_REQ message")););
Jeff Johnson295189b2012-06-20 16:38:30 -07004417
4418 if(pMsgBuf == NULL)
4419 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004420 limLog(pMac, LOGE,FL("Buffer is Pointing to NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004421 return;
4422 }
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08004423
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304424 pUpdateAPWPSIEsReq = vos_mem_malloc(sizeof(tSirUpdateAPWPSIEsReq));
4425 if ( NULL == pUpdateAPWPSIEsReq )
Jeff Johnson295189b2012-06-20 16:38:30 -07004426 {
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304427 limLog(pMac, LOGP, FL("call to AllocateMemory failed for pUpdateAPWPSIEsReq"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004428 return;
4429 }
4430
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08004431 if ((limUpdateAPWPSIEsReqSerDes(pMac, pUpdateAPWPSIEsReq, (tANI_U8 *) pMsgBuf) == eSIR_FAILURE))
Jeff Johnson295189b2012-06-20 16:38:30 -07004432 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004433 limLog(pMac, LOGW, FL("received invalid SME_SETCONTEXT_REQ message"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004434 goto end;
4435 }
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08004436
Jeff Johnson295189b2012-06-20 16:38:30 -07004437 if((psessionEntry = peFindSessionByBssid(pMac, pUpdateAPWPSIEsReq->bssId, &sessionId)) == NULL)
4438 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004439 limLog(pMac, LOGW, FL("Session does not exist for given BSSID"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004440 goto end;
4441 }
4442
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304443 vos_mem_copy( &psessionEntry->APWPSIEs, &pUpdateAPWPSIEsReq->APWPSIEs, sizeof(tSirAPWPSIEs));
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08004444
Jeff Johnson295189b2012-06-20 16:38:30 -07004445 schSetFixedBeaconFields(pMac, psessionEntry);
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08004446 limSendBeaconInd(pMac, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07004447
4448end:
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304449 vos_mem_free( pUpdateAPWPSIEsReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07004450 return;
4451} /*** end __limProcessSmeUpdateAPWPSIEs(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf) ***/
4452
4453static void
4454__limProcessSmeHideSSID(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
4455{
4456 tpSirUpdateParams pUpdateParams;
4457 tpPESession psessionEntry;
4458
4459 PELOG1(limLog(pMac, LOG1,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004460 FL("received HIDE_SSID message")););
Jeff Johnson295189b2012-06-20 16:38:30 -07004461
4462 if(pMsgBuf == NULL)
4463 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004464 limLog(pMac, LOGE,FL("Buffer is Pointing to NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004465 return;
4466 }
4467
4468 pUpdateParams = (tpSirUpdateParams)pMsgBuf;
4469
4470 if((psessionEntry = peFindSessionBySessionId(pMac, pUpdateParams->sessionId)) == NULL)
4471 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004472 limLog(pMac, LOGW, "Session does not exist for given sessionId %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07004473 pUpdateParams->sessionId);
4474 return;
4475 }
4476
4477 /* Update the session entry */
4478 psessionEntry->ssidHidden = pUpdateParams->ssidHidden;
4479
4480 /* Update beacon */
4481 schSetFixedBeaconFields(pMac, psessionEntry);
4482 limSendBeaconInd(pMac, psessionEntry);
4483
4484 return;
4485} /*** end __limProcessSmeHideSSID(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf) ***/
4486
4487static void
4488__limProcessSmeSetWPARSNIEs(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
4489{
4490 tpSirUpdateAPWPARSNIEsReq pUpdateAPWPARSNIEsReq;
4491 tpPESession psessionEntry;
4492 tANI_U8 sessionId; //PE sessionID
4493
4494 if(pMsgBuf == NULL)
4495 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004496 limLog(pMac, LOGE,FL("Buffer is Pointing to NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004497 return;
4498 }
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304499
4500 pUpdateAPWPARSNIEsReq = vos_mem_malloc(sizeof(tSirUpdateAPWPSIEsReq));
4501 if ( NULL == pUpdateAPWPARSNIEsReq )
Jeff Johnson295189b2012-06-20 16:38:30 -07004502 {
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304503 limLog(pMac, LOGP, FL("call to AllocateMemory failed for pUpdateAPWPARSNIEsReq"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004504 return;
4505 }
4506
4507 if ((limUpdateAPWPARSNIEsReqSerDes(pMac, pUpdateAPWPARSNIEsReq, (tANI_U8 *) pMsgBuf) == eSIR_FAILURE))
4508 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004509 limLog(pMac, LOGW, FL("received invalid SME_SETCONTEXT_REQ message"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004510 goto end;
4511 }
4512
4513 if((psessionEntry = peFindSessionByBssid(pMac, pUpdateAPWPARSNIEsReq->bssId, &sessionId)) == NULL)
4514 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004515 limLog(pMac, LOGW, FL("Session does not exist for given BSSID"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004516 goto end;
4517 }
4518
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304519 vos_mem_copy(&psessionEntry->pLimStartBssReq->rsnIE,
4520 &pUpdateAPWPARSNIEsReq->APWPARSNIEs, sizeof(tSirRSNie));
Jeff Johnson295189b2012-06-20 16:38:30 -07004521
4522 limSetRSNieWPAiefromSmeStartBSSReqMessage(pMac, &psessionEntry->pLimStartBssReq->rsnIE, psessionEntry);
4523
4524 psessionEntry->pLimStartBssReq->privacy = 1;
4525 psessionEntry->privacy = 1;
4526
4527 schSetFixedBeaconFields(pMac, psessionEntry);
4528 limSendBeaconInd(pMac, psessionEntry);
4529
4530end:
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304531 vos_mem_free(pUpdateAPWPARSNIEsReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07004532 return;
4533} /*** end __limProcessSmeSetWPARSNIEs(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf) ***/
4534
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08004535/*
4536Update the beacon Interval dynamically if beaconInterval is different in MCC
4537*/
4538static void
4539__limProcessSmeChangeBI(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
4540{
4541 tpSirChangeBIParams pChangeBIParams;
4542 tpPESession psessionEntry;
4543 tANI_U8 sessionId = 0;
4544 tUpdateBeaconParams beaconParams;
4545
4546 PELOG1(limLog(pMac, LOG1,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004547 FL("received Update Beacon Interval message")););
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08004548
4549 if(pMsgBuf == NULL)
4550 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004551 limLog(pMac, LOGE,FL("Buffer is Pointing to NULL"));
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08004552 return;
4553 }
4554
Kaushik, Sushantfb156732014-01-07 15:36:03 +05304555 vos_mem_zero(&beaconParams, sizeof(tUpdateBeaconParams));
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08004556 pChangeBIParams = (tpSirChangeBIParams)pMsgBuf;
4557
4558 if((psessionEntry = peFindSessionByBssid(pMac, pChangeBIParams->bssId, &sessionId)) == NULL)
4559 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004560 limLog(pMac, LOGE, FL("Session does not exist for given BSSID"));
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08004561 return;
4562 }
4563
4564 /*Update sessionEntry Beacon Interval*/
4565 if(psessionEntry->beaconParams.beaconInterval !=
4566 pChangeBIParams->beaconInterval )
4567 {
4568 psessionEntry->beaconParams.beaconInterval = pChangeBIParams->beaconInterval;
4569 }
4570
4571 /*Update sch beaconInterval*/
4572 if(pMac->sch.schObject.gSchBeaconInterval !=
4573 pChangeBIParams->beaconInterval )
4574 {
4575 pMac->sch.schObject.gSchBeaconInterval = pChangeBIParams->beaconInterval;
4576
4577 PELOG1(limLog(pMac, LOG1,
4578 FL("LIM send update BeaconInterval Indication : %d"),pChangeBIParams->beaconInterval););
4579
4580 /* Update beacon */
4581 schSetFixedBeaconFields(pMac, psessionEntry);
4582
Sunil Ravib96f7b52013-05-22 21:40:05 -07004583 beaconParams.bssIdx = psessionEntry->bssIdx;
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08004584 //Set change in beacon Interval
4585 beaconParams.beaconInterval = pChangeBIParams->beaconInterval;
Jeff Johnson312557b2013-04-03 16:27:48 -07004586 beaconParams.paramChangeBitmap = PARAM_BCN_INTERVAL_CHANGED;
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08004587 limSendBeaconParams(pMac, &beaconParams, psessionEntry);
4588 }
4589
4590 return;
4591} /*** end __limProcessSmeChangeBI(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf) ***/
4592
Hardik Kantilal Patel62a3a762014-11-21 12:55:57 +05304593/** -------------------------------------------------------------
4594\fn
4595\brief handles indication message from HDD to update HT mode
4596\param tpAniSirGlobal pMac
4597\param tANI_U32 pMsgBuf
4598\return None
4599-------------------------------------------------------------*/
4600#ifdef WLAN_FEATURE_AP_HT40_24G
4601static void __limProcessSmeSetHT2040Mode(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
4602{
4603 tpSirSetHT2040Mode pSetHT2040Mode;
4604 tpPESession psessionEntry;
4605 tANI_U8 sessionId = 0;
4606 tUpdateVHTOpMode *pHtOpMode = NULL;
4607 vos_msg_t msg;
Jeff Johnson295189b2012-06-20 16:38:30 -07004608
Hardik Kantilal Patel62a3a762014-11-21 12:55:57 +05304609 PELOG1(limLog(pMac, LOGRW,
4610 FL("received Set HT 20/40 mode message")););
4611
4612 if(pMsgBuf == NULL)
4613 {
4614 limLog(pMac, LOGE,FL("Buffer is Pointing to NULL"));
4615 return;
4616 }
4617
4618 pSetHT2040Mode = (tpSirSetHT2040Mode)pMsgBuf;
4619
4620 if((psessionEntry = peFindSessionByBssid(pMac, pSetHT2040Mode->bssId,
4621 &sessionId)) == NULL)
4622 {
4623 limLog(pMac, LOGE, FL("Session does not exist for given BSSID "));
4624 limPrintMacAddr(pMac, pSetHT2040Mode->bssId, LOGE);
4625 return;
4626 }
4627
4628 limLog(pMac, LOGW, FL("Update session entry for cbMod=%d"),
4629 pSetHT2040Mode->cbMode);
4630
4631 /*Update sessionEntry HT related fields*/
4632 switch(pSetHT2040Mode->cbMode)
4633 {
4634 case PHY_SINGLE_CHANNEL_CENTERED:
4635 psessionEntry->htSecondaryChannelOffset = PHY_SINGLE_CHANNEL_CENTERED;
4636 psessionEntry->htRecommendedTxWidthSet = 0;
4637 break;
4638 case PHY_DOUBLE_CHANNEL_LOW_PRIMARY:
4639 psessionEntry->htSecondaryChannelOffset =
4640 PHY_DOUBLE_CHANNEL_LOW_PRIMARY;
4641 psessionEntry->htRecommendedTxWidthSet = 1;
4642 break;
4643 case PHY_DOUBLE_CHANNEL_HIGH_PRIMARY:
4644 psessionEntry->htSecondaryChannelOffset =
4645 PHY_DOUBLE_CHANNEL_HIGH_PRIMARY;
4646 psessionEntry->htRecommendedTxWidthSet = 1;
4647 break;
4648 default:
4649 limLog(pMac, LOGE,FL("Invalid cbMode"));
4650 return;
4651 }
4652
4653 limLog(pMac, LOGW, FL("Channel Bonding mode : %d"
4654 " htSecondaryChannelOffset: %d"
4655 " htRecommendedTxWidthSet :%d"),
4656 pSetHT2040Mode->cbMode,
4657 psessionEntry->htSecondaryChannelOffset,
4658 psessionEntry->htRecommendedTxWidthSet);
4659
4660 limLog(pMac, LOGW, FL("Update Beacon IEs"));
4661
4662 /* Update beacon */
4663 schSetFixedBeaconFields(pMac, psessionEntry);
4664 limSendBeaconInd(pMac, psessionEntry);
4665
4666 /* Update OP Mode */
4667 pHtOpMode = vos_mem_malloc(sizeof(tUpdateVHTOpMode));
4668 if ( NULL == pHtOpMode )
4669 {
4670 limLog(pMac, LOGE,
4671 FL("Not able to allocate memory for setting OP mode"));
4672 return;
4673 }
4674
4675 pHtOpMode->opMode = (psessionEntry->htSecondaryChannelOffset ==
4676 PHY_SINGLE_CHANNEL_CENTERED)?
4677 eHT_CHANNEL_WIDTH_20MHZ:eHT_CHANNEL_WIDTH_40MHZ;
4678
4679 /* Pass Self STA ID to FW. Based on Self STA ID FW will update the
4680 * operating mode for all connected STA.
4681 */
4682
4683 pHtOpMode->staId = psessionEntry->staId;
4684
4685 msg.type = WDA_UPDATE_OP_MODE;
4686 msg.reserved = 0;
4687 msg.bodyptr = pHtOpMode;
4688
4689 if (!VOS_IS_STATUS_SUCCESS(
4690 vos_mq_post_message(VOS_MODULE_ID_WDA, &msg)))
4691 {
4692 limLog(pMac, LOGE,
4693 FL("Not able to post WDA_UPDATE_OP_MODE message to WDA"));
4694 vos_mem_free(pHtOpMode);
4695 return;
4696 }
4697
4698 limLog(pMac, LOGW,
4699 FL("Notifed FW about OP mode: %d for staId=%d"),
4700 pHtOpMode->opMode, pHtOpMode->staId);
4701
4702 return;
4703}
4704#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004705
4706/** -------------------------------------------------------------
4707\fn limProcessSmeDelBaPeerInd
4708\brief handles indication message from HDD to send delete BA request
4709\param tpAniSirGlobal pMac
4710\param tANI_U32 pMsgBuf
4711\return None
4712-------------------------------------------------------------*/
4713void
4714limProcessSmeDelBaPeerInd(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
4715{
4716 tANI_U16 assocId =0;
4717 tpSmeDelBAPeerInd pSmeDelBAPeerInd = (tpSmeDelBAPeerInd)pMsgBuf;
4718 tpDphHashNode pSta;
4719 tpPESession psessionEntry;
4720 tANI_U8 sessionId;
4721
4722
4723
4724 if(NULL == pSmeDelBAPeerInd)
4725 return;
4726
4727 if ((psessionEntry = peFindSessionByBssid(pMac,pSmeDelBAPeerInd->bssId,&sessionId))==NULL)
4728 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004729 limLog(pMac, LOGE,FL("session does not exist for given bssId"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004730 return;
4731 }
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004732 limLog(pMac, LOGW, FL("called with staId = %d, tid = %d, baDirection = %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07004733 pSmeDelBAPeerInd->staIdx, pSmeDelBAPeerInd->baTID, pSmeDelBAPeerInd->baDirection);
4734
4735 pSta = dphLookupAssocId(pMac, pSmeDelBAPeerInd->staIdx, &assocId, &psessionEntry->dph.dphHashTable);
4736 if( eSIR_SUCCESS != limPostMlmDelBAReq( pMac,
4737 pSta,
4738 pSmeDelBAPeerInd->baDirection,
4739 pSmeDelBAPeerInd->baTID,
4740 eSIR_MAC_UNSPEC_FAILURE_REASON,psessionEntry))
4741 {
4742 limLog( pMac, LOGW,
4743 FL( "Failed to post LIM_MLM_DELBA_REQ to " ));
4744 if (pSta)
4745 limPrintMacAddr(pMac, pSta->staAddr, LOGW);
4746 }
4747}
4748
4749// --------------------------------------------------------------------
4750/**
4751 * __limProcessReportMessage
4752 *
4753 * FUNCTION: Processes the next received Radio Resource Management message
4754 *
4755 * LOGIC:
4756 *
4757 * ASSUMPTIONS:
4758 *
4759 * NOTE:
4760 *
4761 * @param None
4762 * @return None
4763 */
4764
4765void __limProcessReportMessage(tpAniSirGlobal pMac, tpSirMsgQ pMsg)
4766{
4767#ifdef WLAN_FEATURE_VOWIFI
4768 switch (pMsg->type)
4769 {
4770 case eWNI_SME_NEIGHBOR_REPORT_REQ_IND:
4771 rrmProcessNeighborReportReq( pMac, pMsg->bodyptr );
4772 break;
4773 case eWNI_SME_BEACON_REPORT_RESP_XMIT_IND:
4774 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004775#if defined(FEATURE_WLAN_ESE) && !defined(FEATURE_WLAN_ESE_UPLOAD)
Jeff Johnson295189b2012-06-20 16:38:30 -07004776 tpSirBeaconReportXmitInd pBcnReport=NULL;
4777 tpPESession psessionEntry=NULL;
4778 tANI_U8 sessionId;
4779
4780 if(pMsg->bodyptr == NULL)
4781 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004782 limLog(pMac, LOGE,FL("Buffer is Pointing to NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004783 return;
4784 }
4785 pBcnReport = (tpSirBeaconReportXmitInd )pMsg->bodyptr;
4786 if((psessionEntry = peFindSessionByBssid(pMac, pBcnReport->bssId,&sessionId))== NULL)
4787 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004788 limLog(pMac, LOGE, "Session Does not exist for given bssId");
Jeff Johnson295189b2012-06-20 16:38:30 -07004789 return;
4790 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004791 if (psessionEntry->isESEconnection)
4792 eseProcessBeaconReportXmit( pMac, pMsg->bodyptr);
Jeff Johnson295189b2012-06-20 16:38:30 -07004793 else
4794#endif
4795 rrmProcessBeaconReportXmit( pMac, pMsg->bodyptr );
4796 }
4797 break;
4798 }
4799#endif
4800}
4801
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004802#if defined(FEATURE_WLAN_ESE) || defined(WLAN_FEATURE_VOWIFI)
Jeff Johnson295189b2012-06-20 16:38:30 -07004803// --------------------------------------------------------------------
4804/**
4805 * limSendSetMaxTxPowerReq
4806 *
4807 * FUNCTION: Send SIR_HAL_SET_MAX_TX_POWER_REQ message to change the max tx power.
4808 *
4809 * LOGIC:
4810 *
4811 * ASSUMPTIONS:
4812 *
4813 * NOTE:
4814 *
4815 * @param txPower txPower to be set.
4816 * @param pSessionEntry session entry.
4817 * @return None
4818 */
4819tSirRetStatus
4820limSendSetMaxTxPowerReq ( tpAniSirGlobal pMac, tPowerdBm txPower, tpPESession pSessionEntry )
4821{
4822 tpMaxTxPowerParams pMaxTxParams = NULL;
4823 tSirRetStatus retCode = eSIR_SUCCESS;
4824 tSirMsgQ msgQ;
4825
4826 if( pSessionEntry == NULL )
4827 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004828 PELOGE(limLog(pMac, LOGE, "%s:%d: Inavalid parameters", __func__, __LINE__ );)
Jeff Johnson295189b2012-06-20 16:38:30 -07004829 return eSIR_FAILURE;
4830 }
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304831
4832 pMaxTxParams = vos_mem_malloc(sizeof(tMaxTxPowerParams));
4833 if ( NULL == pMaxTxParams )
Jeff Johnson295189b2012-06-20 16:38:30 -07004834 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004835 limLog( pMac, LOGP, "%s:%d:Unable to allocate memory for pMaxTxParams ", __func__, __LINE__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004836 return eSIR_MEM_ALLOC_FAILED;
4837
4838 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004839#if defined(WLAN_VOWIFI_DEBUG) || defined(FEATURE_WLAN_ESE)
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004840 PELOG1(limLog( pMac, LOG1, "%s:%d: Allocated memory for pMaxTxParams...will be freed in other module", __func__, __LINE__ );)
Jeff Johnson295189b2012-06-20 16:38:30 -07004841#endif
Kiran Kumar Lokerea4db3dc2013-03-25 18:05:24 -07004842 if( pMaxTxParams == NULL )
4843 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004844 limLog( pMac, LOGE, "%s:%d: pMaxTxParams is NULL", __func__, __LINE__);
Kiran Kumar Lokerea4db3dc2013-03-25 18:05:24 -07004845 return eSIR_FAILURE;
4846 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004847 pMaxTxParams->power = txPower;
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304848 vos_mem_copy( pMaxTxParams->bssId, pSessionEntry->bssId, sizeof(tSirMacAddr) );
4849 vos_mem_copy( pMaxTxParams->selfStaMacAddr, pSessionEntry->selfMacAddr, sizeof(tSirMacAddr) );
Jeff Johnson295189b2012-06-20 16:38:30 -07004850
Jeff Johnson68ce9c42013-04-08 10:33:28 -07004851 msgQ.type = WDA_SET_MAX_TX_POWER_REQ;
4852 msgQ.bodyptr = pMaxTxParams;
4853 msgQ.bodyval = 0;
4854 PELOG1(limLog(pMac, LOG1, FL("Posting WDA_SET_MAX_TX_POWER_REQ to WDA"));)
4855 MTRACE(macTraceMsgTx(pMac, pSessionEntry->peSessionId, msgQ.type));
4856 retCode = wdaPostCtrlMsg(pMac, &msgQ);
4857 if (eSIR_SUCCESS != retCode)
4858 {
4859 PELOGE(limLog(pMac, LOGE, FL("wdaPostCtrlMsg() failed"));)
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304860 vos_mem_free(pMaxTxParams);
Jeff Johnson68ce9c42013-04-08 10:33:28 -07004861 }
4862 return retCode;
Jeff Johnson295189b2012-06-20 16:38:30 -07004863}
4864#endif
4865
4866/**
4867 * __limProcessSmeAddStaSelfReq()
4868 *
4869 *FUNCTION:
4870 * This function is called to process SME_ADD_STA_SELF_REQ message
4871 * from SME. It sends a SIR_HAL_ADD_STA_SELF_REQ message to HAL.
4872 *
4873 *LOGIC:
4874 *
4875 *ASSUMPTIONS:
4876 *
4877 *NOTE:
4878 *
4879 * @param pMac Pointer to Global MAC structure
4880 * @param *pMsgBuf A pointer to the SME message buffer
4881 * @return None
4882 */
4883
4884static void
4885__limProcessSmeAddStaSelfReq(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
4886{
4887 tSirMsgQ msg;
4888 tpAddStaSelfParams pAddStaSelfParams;
4889 tpSirSmeAddStaSelfReq pSmeReq = (tpSirSmeAddStaSelfReq) pMsgBuf;
4890
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304891 pAddStaSelfParams = vos_mem_malloc(sizeof(tAddStaSelfParams));
4892 if ( NULL == pAddStaSelfParams )
Jeff Johnson295189b2012-06-20 16:38:30 -07004893 {
4894 limLog( pMac, LOGP, FL("Unable to allocate memory for tAddSelfStaParams") );
4895 return;
4896 }
4897
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304898 vos_mem_copy( pAddStaSelfParams->selfMacAddr, pSmeReq->selfMacAddr, sizeof(tSirMacAddr) );
Kiran Kumar Lokeread7dbc82013-10-07 20:12:50 -07004899 pAddStaSelfParams->currDeviceMode = pSmeReq->currDeviceMode;
Jeff Johnson295189b2012-06-20 16:38:30 -07004900 msg.type = SIR_HAL_ADD_STA_SELF_REQ;
4901 msg.reserved = 0;
4902 msg.bodyptr = pAddStaSelfParams;
4903 msg.bodyval = 0;
4904
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004905 PELOGW(limLog(pMac, LOG1, FL("sending SIR_HAL_ADD_STA_SELF_REQ msg to HAL"));)
Jeff Johnsone7245742012-09-05 17:12:55 -07004906 MTRACE(macTraceMsgTx(pMac, NO_SESSION, msg.type));
Jeff Johnson295189b2012-06-20 16:38:30 -07004907
4908 if(eSIR_SUCCESS != wdaPostCtrlMsg(pMac, &msg))
4909 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004910 limLog(pMac, LOGP, FL("wdaPostCtrlMsg failed"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004911 }
4912 return;
4913} /*** end __limProcessAddStaSelfReq() ***/
4914
4915
4916/**
4917 * __limProcessSmeDelStaSelfReq()
4918 *
4919 *FUNCTION:
4920 * This function is called to process SME_DEL_STA_SELF_REQ message
4921 * from SME. It sends a SIR_HAL_DEL_STA_SELF_REQ message to HAL.
4922 *
4923 *LOGIC:
4924 *
4925 *ASSUMPTIONS:
4926 *
4927 *NOTE:
4928 *
4929 * @param pMac Pointer to Global MAC structure
4930 * @param *pMsgBuf A pointer to the SME message buffer
4931 * @return None
4932 */
4933
4934static void
4935__limProcessSmeDelStaSelfReq(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
4936{
4937 tSirMsgQ msg;
4938 tpDelStaSelfParams pDelStaSelfParams;
4939 tpSirSmeDelStaSelfReq pSmeReq = (tpSirSmeDelStaSelfReq) pMsgBuf;
4940
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304941 pDelStaSelfParams = vos_mem_malloc(sizeof( tDelStaSelfParams));
4942 if ( NULL == pDelStaSelfParams )
Jeff Johnson295189b2012-06-20 16:38:30 -07004943 {
4944 limLog( pMac, LOGP, FL("Unable to allocate memory for tDelStaSelfParams") );
4945 return;
4946 }
4947
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304948 vos_mem_copy( pDelStaSelfParams->selfMacAddr, pSmeReq->selfMacAddr, sizeof(tSirMacAddr) );
Jeff Johnson295189b2012-06-20 16:38:30 -07004949
4950 msg.type = SIR_HAL_DEL_STA_SELF_REQ;
4951 msg.reserved = 0;
4952 msg.bodyptr = pDelStaSelfParams;
4953 msg.bodyval = 0;
4954
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004955 PELOGW(limLog(pMac, LOG1, FL("sending SIR_HAL_ADD_STA_SELF_REQ msg to HAL"));)
Jeff Johnsone7245742012-09-05 17:12:55 -07004956 MTRACE(macTraceMsgTx(pMac, NO_SESSION, msg.type));
Jeff Johnson295189b2012-06-20 16:38:30 -07004957
4958 if(eSIR_SUCCESS != wdaPostCtrlMsg(pMac, &msg))
4959 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004960 limLog(pMac, LOGP, FL("wdaPostCtrlMsg failed"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004961 }
4962 return;
4963} /*** end __limProcessSmeDelStaSelfReq() ***/
4964
4965
Jeff Johnson295189b2012-06-20 16:38:30 -07004966/**
4967 * __limProcessSmeRegisterMgmtFrameReq()
4968 *
4969 *FUNCTION:
4970 * This function is called to process eWNI_SME_REGISTER_MGMT_FRAME_REQ message
4971 * from SME. It Register this information within PE.
4972 *
4973 *LOGIC:
4974 *
4975 *ASSUMPTIONS:
4976 *
4977 *NOTE:
4978 *
4979 * @param pMac Pointer to Global MAC structure
4980 * @param *pMsgBuf A pointer to the SME message buffer
4981 * @return None
4982 */
4983static void
4984__limProcessSmeRegisterMgmtFrameReq(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
4985{
4986 VOS_STATUS vosStatus;
4987 tpSirRegisterMgmtFrame pSmeReq = (tpSirRegisterMgmtFrame)pMsgBuf;
4988 tpLimMgmtFrameRegistration pLimMgmtRegistration = NULL, pNext = NULL;
Jeff Johnsond13512a2012-07-17 11:42:19 -07004989 tANI_BOOLEAN match = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07004990 PELOG1(limLog(pMac, LOG1,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004991 FL("registerFrame %d, frameType %d, matchLen %d"),
Jeff Johnsone7245742012-09-05 17:12:55 -07004992 pSmeReq->registerFrame, pSmeReq->frameType, pSmeReq->matchLen);)
Jeff Johnson295189b2012-06-20 16:38:30 -07004993
Jeff Johnsond13512a2012-07-17 11:42:19 -07004994 /* First check whether entry exists already*/
4995
4996 vos_list_peek_front(&pMac->lim.gLimMgmtFrameRegistratinQueue,
4997 (vos_list_node_t**)&pLimMgmtRegistration);
4998
4999 while(pLimMgmtRegistration != NULL)
5000 {
5001 if (pLimMgmtRegistration->frameType == pSmeReq->frameType)
5002 {
5003 if(pSmeReq->matchLen)
5004 {
5005 if (pLimMgmtRegistration->matchLen == pSmeReq->matchLen)
5006 {
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05305007 if (vos_mem_compare( pLimMgmtRegistration->matchData,
Jeff Johnsond13512a2012-07-17 11:42:19 -07005008 pSmeReq->matchData, pLimMgmtRegistration->matchLen))
5009 {
Madan Mohan Koyyalamudic537df22012-10-22 15:07:08 -07005010 /* found match! */
5011 match = VOS_TRUE;
5012 break;
Jeff Johnsond13512a2012-07-17 11:42:19 -07005013 }
5014 }
5015 }
5016 else
5017 {
Madan Mohan Koyyalamudic537df22012-10-22 15:07:08 -07005018 /* found match! */
Jeff Johnsond13512a2012-07-17 11:42:19 -07005019 match = VOS_TRUE;
5020 break;
5021 }
5022 }
5023 vosStatus = vos_list_peek_next (
5024 &pMac->lim.gLimMgmtFrameRegistratinQueue,
5025 (vos_list_node_t*) pLimMgmtRegistration,
5026 (vos_list_node_t**) &pNext );
5027
5028 pLimMgmtRegistration = pNext;
5029 pNext = NULL;
5030
5031 }
5032
5033 if (match)
5034 {
5035 vos_list_remove_node(&pMac->lim.gLimMgmtFrameRegistratinQueue,
5036 (vos_list_node_t*)pLimMgmtRegistration);
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05305037 vos_mem_free(pLimMgmtRegistration);
Jeff Johnsond13512a2012-07-17 11:42:19 -07005038 }
5039
Jeff Johnson295189b2012-06-20 16:38:30 -07005040 if(pSmeReq->registerFrame)
5041 {
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05305042 pLimMgmtRegistration = vos_mem_malloc(sizeof(tLimMgmtFrameRegistration) + pSmeReq->matchLen);
5043 if ( pLimMgmtRegistration != NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -07005044 {
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05305045 vos_mem_set((void*)pLimMgmtRegistration,
5046 sizeof(tLimMgmtFrameRegistration) + pSmeReq->matchLen, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005047 pLimMgmtRegistration->frameType = pSmeReq->frameType;
5048 pLimMgmtRegistration->matchLen = pSmeReq->matchLen;
5049 pLimMgmtRegistration->sessionId = pSmeReq->sessionId;
5050 if(pSmeReq->matchLen)
5051 {
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05305052 vos_mem_copy(pLimMgmtRegistration->matchData,
5053 pSmeReq->matchData, pSmeReq->matchLen);
Jeff Johnson295189b2012-06-20 16:38:30 -07005054 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005055 vos_list_insert_front(&pMac->lim.gLimMgmtFrameRegistratinQueue,
5056 &pLimMgmtRegistration->node);
5057 }
5058 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005059
5060 return;
5061} /*** end __limProcessSmeRegisterMgmtFrameReq() ***/
Viral Modid86bde22012-12-10 13:09:21 -08005062
5063static tANI_BOOLEAN
Viral Modid440e682013-03-06 02:25:31 -08005064__limInsertSingleShotNOAForScan(tpAniSirGlobal pMac, tANI_U32 noaDuration)
Viral Modid86bde22012-12-10 13:09:21 -08005065{
5066 tpP2pPsParams pMsgNoA;
5067 tSirMsgQ msg;
Vinay Malekal62757362012-12-17 12:15:51 -08005068
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05305069 pMsgNoA = vos_mem_malloc(sizeof( tP2pPsConfig ));
5070 if ( NULL == pMsgNoA )
Viral Modid86bde22012-12-10 13:09:21 -08005071 {
5072 limLog( pMac, LOGP,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005073 FL( "Unable to allocate memory during NoA Update" ));
Viral Modid440e682013-03-06 02:25:31 -08005074 goto error;
Viral Modid86bde22012-12-10 13:09:21 -08005075 }
5076
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05305077 vos_mem_set((tANI_U8 *)pMsgNoA, sizeof(tP2pPsConfig), 0);
Viral Modid86bde22012-12-10 13:09:21 -08005078 /* Below params used for opp PS/periodic NOA and are don't care in this case - so initialized to 0 */
5079 pMsgNoA->opp_ps = 0;
5080 pMsgNoA->ctWindow = 0;
5081 pMsgNoA->duration = 0;
5082 pMsgNoA->interval = 0;
5083 pMsgNoA->count = 0;
Vinay Malekal62757362012-12-17 12:15:51 -08005084
Vinay Malekal62757362012-12-17 12:15:51 -08005085 /* Below params used for Single Shot NOA - so assign proper values */
5086 pMsgNoA->psSelection = P2P_SINGLE_NOA;
Viral Modid440e682013-03-06 02:25:31 -08005087 pMsgNoA->single_noa_duration = noaDuration;
Gopichand Nakkala096a1052012-12-21 07:05:34 -08005088
Viral Modid86bde22012-12-10 13:09:21 -08005089 /* Start Insert NOA timer
5090 * If insert NOA req fails or NOA rsp fails or start NOA indication doesn't come from FW due to GO session deletion
Viral Modid440e682013-03-06 02:25:31 -08005091 * or any other failure or reason, we still need to process the deferred SME req. The insert NOA
5092 * timer of 500 ms will ensure the stored SME req always gets processed
Viral Modid86bde22012-12-10 13:09:21 -08005093 */
5094 if (tx_timer_activate(&pMac->lim.limTimers.gLimP2pSingleShotNoaInsertTimer)
5095 == TX_TIMER_ERROR)
5096 {
5097 /// Could not activate Insert NOA timer.
5098 // Log error
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005099 limLog(pMac, LOGP, FL("could not activate Insert Single Shot NOA during scan timer"));
Viral Modid86bde22012-12-10 13:09:21 -08005100
5101 // send the scan response back with status failure and do not even call insert NOA
5102 limSendSmeScanRsp(pMac, sizeof(tSirSmeScanRsp), eSIR_SME_SCAN_FAILED, pMac->lim.gSmeSessionId, pMac->lim.gTransactionId);
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05305103 vos_mem_free(pMsgNoA);
Viral Modid440e682013-03-06 02:25:31 -08005104 goto error;
Viral Modid86bde22012-12-10 13:09:21 -08005105 }
5106
Viral Modid440e682013-03-06 02:25:31 -08005107 MTRACE(macTrace(pMac, TRACE_CODE_TIMER_ACTIVATE, NO_SESSION, eLIM_INSERT_SINGLESHOT_NOA_TIMER));
5108
Viral Modid86bde22012-12-10 13:09:21 -08005109 msg.type = WDA_SET_P2P_GO_NOA_REQ;
5110 msg.reserved = 0;
5111 msg.bodyptr = pMsgNoA;
5112 msg.bodyval = 0;
5113
5114 if(eSIR_SUCCESS != wdaPostCtrlMsg(pMac, &msg))
5115 {
5116 /* In this failure case, timer is already started, so its expiration will take care of sending scan response */
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005117 limLog(pMac, LOGP, FL("wdaPost Msg failed"));
Viral Modid440e682013-03-06 02:25:31 -08005118 /* Deactivate the NOA timer in failure case */
5119 limDeactivateAndChangeTimer(pMac, eLIM_INSERT_SINGLESHOT_NOA_TIMER);
5120 goto error;
Viral Modid86bde22012-12-10 13:09:21 -08005121 }
Viral Modid440e682013-03-06 02:25:31 -08005122 return FALSE;
Viral Modid86bde22012-12-10 13:09:21 -08005123
Viral Modid440e682013-03-06 02:25:31 -08005124error:
5125 /* In any of the failure cases, just go ahead with the processing of registered deferred SME request without
5126 * worrying about the NOA
5127 */
5128 limProcessRegdDefdSmeReqAfterNOAStart(pMac);
5129 // msg buffer is consumed and freed in above function so return FALSE
Viral Modid86bde22012-12-10 13:09:21 -08005130 return FALSE;
5131
5132}
5133
Viral Modid440e682013-03-06 02:25:31 -08005134static void __limRegisterDeferredSmeReqForNOAStart(tpAniSirGlobal pMac, tANI_U16 msgType, tANI_U32 *pMsgBuf)
5135{
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005136 limLog(pMac, LOG1, FL("Reg msgType %d"), msgType) ;
Viral Modid440e682013-03-06 02:25:31 -08005137 pMac->lim.gDeferMsgTypeForNOA = msgType;
5138 pMac->lim.gpDefdSmeMsgForNOA = pMsgBuf;
5139}
5140
5141static void __limDeregisterDeferredSmeReqAfterNOAStart(tpAniSirGlobal pMac)
5142{
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005143 limLog(pMac, LOG1, FL("Dereg msgType %d"), pMac->lim.gDeferMsgTypeForNOA) ;
Viral Modid440e682013-03-06 02:25:31 -08005144 pMac->lim.gDeferMsgTypeForNOA = 0;
5145 if (pMac->lim.gpDefdSmeMsgForNOA != NULL)
5146 {
5147 /* __limProcessSmeScanReq consumed the buffer. We can free it. */
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05305148 vos_mem_free(pMac->lim.gpDefdSmeMsgForNOA);
Viral Modid440e682013-03-06 02:25:31 -08005149 pMac->lim.gpDefdSmeMsgForNOA = NULL;
5150 }
5151}
5152
5153static
Ganesh Kondabattini16930072014-08-22 16:02:34 +05305154tANI_U32 limCalculateNOADuration(tpAniSirGlobal pMac, tANI_U16 msgType,
5155 tANI_U32 *pMsgBuf, tANI_BOOLEAN isPassiveScan)
Viral Modid440e682013-03-06 02:25:31 -08005156{
5157 tANI_U32 noaDuration = 0;
5158
5159 switch (msgType)
5160 {
5161 case eWNI_SME_SCAN_REQ:
5162 {
5163 tANI_U32 val;
5164 tANI_U8 i;
5165 tpSirSmeScanReq pScanReq = (tpSirSmeScanReq) pMsgBuf;
5166 if (wlan_cfgGetInt(pMac, WNI_CFG_PASSIVE_MAXIMUM_CHANNEL_TIME, &val) != eSIR_SUCCESS)
5167 {
5168 /*
5169 * Could not get max channel value
5170 * from CFG. Log error.
5171 */
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005172 limLog(pMac, LOGP, FL("could not retrieve passive max channel value"));
Viral Modid440e682013-03-06 02:25:31 -08005173
5174 /* use a default value of 110ms */
5175 val = DEFAULT_PASSIVE_MAX_CHANNEL_TIME;
5176 }
5177
5178 for (i = 0; i < pScanReq->channelList.numChannels; i++) {
5179 tANI_U8 channelNum = pScanReq->channelList.channelNumber[i];
5180
Ganesh Kondabattini8f6e3b32014-08-25 16:07:54 +05305181 if (pMac->miracast_mode) {
5182 noaDuration += DEFAULT_MIN_CHAN_TIME_DURING_MIRACAST +
5183 DEFAULT_MAX_CHAN_TIME_DURING_MIRACAST;
5184 } else if (isPassiveScan || !limActiveScanAllowed(pMac, channelNum)) {
Viral Modid440e682013-03-06 02:25:31 -08005185 /* using the value from WNI_CFG_PASSIVE_MINIMUM_CHANNEL_TIME as is done in
5186 * void limContinuePostChannelScan(tpAniSirGlobal pMac)
5187 */
5188 noaDuration += val;
Ganesh Kondabattini16930072014-08-22 16:02:34 +05305189 } else {
5190 /* Use min + max channel time to calculate the total duration of scan */
5191 noaDuration += pScanReq->minChannelTime + pScanReq->maxChannelTime;
Viral Modid440e682013-03-06 02:25:31 -08005192 }
5193 }
5194
5195 /* Adding an overhead of 20ms to account for the scan messaging delays */
5196 noaDuration += SCAN_MESSAGING_OVERHEAD;
5197 noaDuration *= CONV_MS_TO_US;
5198
5199 break;
5200 }
5201
5202 case eWNI_SME_OEM_DATA_REQ:
5203 noaDuration = OEM_DATA_NOA_DURATION*CONV_MS_TO_US; // use 60 msec as default
5204 break;
5205
5206 case eWNI_SME_REMAIN_ON_CHANNEL_REQ:
5207 {
5208 tSirRemainOnChnReq *pRemainOnChnReq = (tSirRemainOnChnReq *) pMsgBuf;
5209 noaDuration = (pRemainOnChnReq->duration)*CONV_MS_TO_US;
5210 break;
5211 }
5212
5213 case eWNI_SME_JOIN_REQ:
5214 noaDuration = JOIN_NOA_DURATION*CONV_MS_TO_US;
5215 break;
5216
5217 default:
5218 noaDuration = 0;
5219 break;
5220
5221 }
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005222 limLog(pMac, LOGW, FL("msgType %d noa %d"), msgType, noaDuration);
Viral Modid440e682013-03-06 02:25:31 -08005223 return noaDuration;
5224}
5225
5226void limProcessRegdDefdSmeReqAfterNOAStart(tpAniSirGlobal pMac)
5227{
Gopichand Nakkala7c4c3b92013-03-25 18:08:31 +05305228 tANI_BOOLEAN bufConsumed = TRUE;
Viral Modid440e682013-03-06 02:25:31 -08005229
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005230 limLog(pMac, LOG1, FL("Process defd sme req %d"), pMac->lim.gDeferMsgTypeForNOA);
Viral Modid440e682013-03-06 02:25:31 -08005231 if ( (pMac->lim.gDeferMsgTypeForNOA != 0) &&
5232 (pMac->lim.gpDefdSmeMsgForNOA != NULL) )
5233 {
5234 switch (pMac->lim.gDeferMsgTypeForNOA)
5235 {
5236 case eWNI_SME_SCAN_REQ:
5237 __limProcessSmeScanReq(pMac, pMac->lim.gpDefdSmeMsgForNOA);
5238 break;
5239 case eWNI_SME_OEM_DATA_REQ:
5240 __limProcessSmeOemDataReq(pMac, pMac->lim.gpDefdSmeMsgForNOA);
5241 break;
5242 case eWNI_SME_REMAIN_ON_CHANNEL_REQ:
Gopichand Nakkala7c4c3b92013-03-25 18:08:31 +05305243 bufConsumed = limProcessRemainOnChnlReq(pMac, pMac->lim.gpDefdSmeMsgForNOA);
5244 /* limProcessRemainOnChnlReq doesnt want us to free the buffer since
5245 * it is freed in limRemainOnChnRsp. this change is to avoid "double free"
5246 */
5247 if (FALSE == bufConsumed)
5248 {
5249 pMac->lim.gpDefdSmeMsgForNOA = NULL;
5250 }
Viral Modid440e682013-03-06 02:25:31 -08005251 break;
5252 case eWNI_SME_JOIN_REQ:
5253 __limProcessSmeJoinReq(pMac, pMac->lim.gpDefdSmeMsgForNOA);
5254 break;
5255 default:
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005256 limLog(pMac, LOGE, FL("Unknown deferred msg type %d"), pMac->lim.gDeferMsgTypeForNOA);
Viral Modid440e682013-03-06 02:25:31 -08005257 break;
5258 }
5259 __limDeregisterDeferredSmeReqAfterNOAStart(pMac);
5260 }
5261 else
5262 {
5263 limLog( pMac, LOGW, FL("start received from FW when no sme deferred msg pending. Do nothing."
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005264 "It might happen sometime when NOA start ind and timeout happen at the same time"));
Viral Modid440e682013-03-06 02:25:31 -08005265 }
5266}
Jeff Johnson295189b2012-06-20 16:38:30 -07005267
Mohit Khanna698ba2a2012-12-04 15:08:18 -08005268#ifdef FEATURE_WLAN_TDLS_INTERNAL
5269/*
5270 * Process Discovery request recieved from SME and transmit to AP.
5271 */
5272static tSirRetStatus limProcessSmeDisStartReq(tpAniSirGlobal pMac,
5273 tANI_U32 *pMsgBuf)
5274{
5275 /* get all discovery request parameters */
5276 tSirTdlsDisReq *disReq = (tSirTdlsDisReq *) pMsgBuf ;
5277 tpPESession psessionEntry;
5278 tANI_U8 sessionId;
5279
5280 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005281 ("Discovery Req Recieved")) ;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08005282
5283 if((psessionEntry = peFindSessionByBssid(pMac, disReq->bssid, &sessionId))
5284 == NULL)
5285 {
5286 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005287 "PE Session does not exist for given sme sessionId %d",
Mohit Khanna698ba2a2012-12-04 15:08:18 -08005288 disReq->sessionId);
5289 goto lim_tdls_dis_start_error;
5290 }
5291
5292 /* check if we are in proper state to work as TDLS client */
5293 if (psessionEntry->limSystemRole != eLIM_STA_ROLE)
5294 {
5295 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005296 "dis req received in wrong system Role %d",
Mohit Khanna698ba2a2012-12-04 15:08:18 -08005297 psessionEntry->limSystemRole);
5298 goto lim_tdls_dis_start_error;
5299 }
5300
5301 /*
5302 * if we are still good, go ahead and check if we are in proper state to
5303 * do TDLS discovery procedure.
5304 */
5305 if ((psessionEntry->limSmeState != eLIM_SME_ASSOCIATED_STATE) &&
5306 (psessionEntry->limSmeState != eLIM_SME_LINK_EST_STATE))
5307 {
5308
5309 limLog(pMac, LOGE, "dis req received in invalid LIMsme \
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005310 state (%d)", psessionEntry->limSmeState);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08005311 goto lim_tdls_dis_start_error;
5312 }
5313
5314 /*
5315 * if we are still good, go ahead and transmit TDLS discovery request,
5316 * and save Dis Req info for future reference.
5317 */
5318
5319#if 0 // TDLS_hklee: D13 no need to open Addr2 unknown data packet
5320 /*
5321 * send message to HAL to set RXP filters to receieve frame on
5322 * direct link..
5323 */
5324 //limSetLinkState(pMac, eSIR_LINK_TDLS_DISCOVERY_STATE,
5325 // psessionEntry->bssId) ;
5326#endif
5327
5328 /* save dis request message for matching dialog token */
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05305329 vos_mem_copy((tANI_U8 *) &pMac->lim.gLimTdlsDisReq,
5330 (tANI_U8 *) disReq, sizeof(tSirTdlsDisReq));
Mohit Khanna698ba2a2012-12-04 15:08:18 -08005331
5332 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005333 "Transmit Discovery Request Frame") ;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08005334 /* format TDLS discovery request frame and transmit it */
5335 limSendTdlsDisReqFrame(pMac, disReq->peerMac, disReq->dialog,
5336 psessionEntry) ;
5337
5338 /* prepare for response */
5339 pMac->lim.gLimTdlsDisStaCount = 0 ;
5340 pMac->lim.gLimTdlsDisResultList = NULL ;
5341
5342 /*
5343 * start TDLS discovery request timer to wait for discovery responses
5344 * from all TDLS enabled clients in BSS.
5345 */
5346
5347 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005348 ("Start Discovery request Timeout Timer")) ;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08005349 MTRACE(macTrace(pMac, TRACE_CODE_TIMER_ACTIVATE, 0,
5350 eLIM_TDLS_DISCOVERY_RSP_WAIT));
5351
5352 /* assign appropriate sessionId to the timer object */
5353 pMac->lim.limTimers.gLimTdlsDisRspWaitTimer.sessionId =
5354 psessionEntry->peSessionId;
5355
5356 if (tx_timer_activate(&pMac->lim.limTimers.gLimTdlsDisRspWaitTimer)
5357 != TX_SUCCESS)
5358 {
5359 limLog(pMac, LOGP, FL("TDLS discovery response timer \
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005360 activation failed!"));
Mohit Khanna698ba2a2012-12-04 15:08:18 -08005361 goto lim_tdls_dis_start_error;
5362 }
5363 /*
5364 * when timer expired, eWNI_SME_TDLS_DISCOVERY_START_RSP is sent
5365 * back to SME
5366 */
5367 return (eSIR_SUCCESS) ;
5368lim_tdls_dis_start_error:
5369 /* in error case, PE has to sent the response SME immediately with error code */
5370 limSendSmeTdlsDisRsp(pMac, eSIR_FAILURE,
5371 eWNI_SME_TDLS_DISCOVERY_START_RSP);
5372 return eSIR_FAILURE;
5373}
5374/*
5375 * Process link start request recieved from SME and transmit to AP.
5376 */
5377eHalStatus limProcessSmeLinkStartReq(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
5378{
5379 /* get all discovery request parameters */
5380 tSirTdlsSetupReq *setupReq = (tSirTdlsSetupReq *) pMsgBuf ;
5381 tLimTdlsLinkSetupInfo *linkSetupInfo;
5382 //tLimTdlsLinkSetupPeer *setupPeer;
5383 tpPESession psessionEntry;
5384 tANI_U8 sessionId;
5385 eHalStatus status;
5386
5387 if((psessionEntry = peFindSessionByBssid(pMac,
5388 setupReq->bssid, &sessionId)) == NULL)
5389 {
5390 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005391 "PE Session does not exist for given sme sessionId %d",
Mohit Khanna698ba2a2012-12-04 15:08:18 -08005392 setupReq->sessionId);
5393 goto lim_tdls_link_start_error;
5394 }
5395
5396 /* check if we are in proper state to work as TDLS client */
5397 if (psessionEntry->limSystemRole != eLIM_STA_ROLE)
5398 {
5399 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005400 "TDLS link setup req received in wrong system Role %d",
Mohit Khanna698ba2a2012-12-04 15:08:18 -08005401 psessionEntry->limSystemRole);
5402 goto lim_tdls_link_start_error;
5403 }
5404
5405 /*
5406 * if we are still good, go ahead and check if we are in proper state to
5407 * do TDLS setup procedure.
5408 */
5409 if ((psessionEntry->limSmeState != eLIM_SME_ASSOCIATED_STATE) &&
5410 (psessionEntry->limSmeState != eLIM_SME_LINK_EST_STATE))
5411 {
5412 limLog(pMac, LOGE, "Setup request in invalid LIMsme \
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005413 state (%d)", pMac->lim.gLimSmeState);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08005414 goto lim_tdls_link_start_error;
5415 }
5416
5417 /*
5418 * Now, go ahead and transmit TDLS discovery request, and save setup Req
5419 * info for future reference.
5420 */
5421 /* create node for Link setup */
5422 linkSetupInfo = &pMac->lim.gLimTdlsLinkSetupInfo ;
5423 //setupPeer = NULL ;
5424
5425 status = limTdlsPrepareSetupReqFrame(pMac, linkSetupInfo, setupReq->dialog,
5426 setupReq->peerMac, psessionEntry) ;
5427 if(eHAL_STATUS_SUCCESS == status)
5428 /* in case of success, eWNI_SME_TDLS_LINK_START_RSP is sent back to SME later when
5429 TDLS setup cnf TX complete is successful. */
5430 return eSIR_SUCCESS;
5431#if 0
5432
5433 /*
5434 * we allocate the TDLS setup Peer Memory here, we will free'd this
Jeff Johnsonfeddb2d2012-12-10 14:41:22 -08005435 * memory after teardown, if the link is successfully setup or
Mohit Khanna698ba2a2012-12-04 15:08:18 -08005436 * free this memory if any timeout is happen in link setup procedure
5437 */
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05305438 setupPeer = vos_mem_malloc(sizeof( tLimTdlsLinkSetupPeer ));
5439 if ( NULL == setupPeer )
Mohit Khanna698ba2a2012-12-04 15:08:18 -08005440 {
5441 limLog( pMac, LOGP,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005442 FL( "Unable to allocate memory during ADD_STA" ));
Mohit Khanna698ba2a2012-12-04 15:08:18 -08005443 VOS_ASSERT(0) ;
5444 return eSIR_MEM_ALLOC_FAILED;
5445 }
5446 setupPeer->dialog = setupReq->dialog ;
5447 setupPeer->tdls_prev_link_state = setupPeer->tdls_link_state ;
5448 setupPeer->tdls_link_state = TDLS_LINK_SETUP_START_STATE ;
5449 /* TDLS_sessionize: remember sessionId for future */
5450 setupPeer->tdls_sessionId = psessionEntry->peSessionId;
5451 setupPeer->tdls_bIsResponder = 1;
5452
5453 /*
5454 * we only populate peer MAC, so it can assit us to find the
5455 * TDLS peer after response/or after response timeout
5456 */
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05305457 vos_mem_copy(setupPeer->peerMac, setupReq->peerMac,
Mohit Khanna698ba2a2012-12-04 15:08:18 -08005458 sizeof(tSirMacAddr)) ;
5459 /* format TDLS discovery request frame and transmit it */
5460 limSendTdlsLinkSetupReqFrame(pMac, setupReq->peerMac,
5461 setupReq->dialog, psessionEntry, NULL, 0) ;
5462
5463 limStartTdlsTimer(pMac, psessionEntry->peSessionId,
5464 &setupPeer->gLimTdlsLinkSetupRspTimeoutTimer,
5465 (tANI_U32)setupPeer->peerMac, WNI_CFG_TDLS_LINK_SETUP_RSP_TIMEOUT,
5466 SIR_LIM_TDLS_LINK_SETUP_RSP_TIMEOUT) ;
5467 /* update setup peer list */
5468 setupPeer->next = linkSetupInfo->tdlsLinkSetupList ;
5469 linkSetupInfo->tdlsLinkSetupList = setupPeer ;
5470 /* in case of success, eWNI_SME_TDLS_LINK_START_RSP is sent back to SME later when
5471 TDLS setup cnf TX complete is successful. --> see limTdlsSetupCnfTxComplete() */
5472 return eSIR_SUCCESS ;
5473#endif
5474lim_tdls_link_start_error:
5475 /* in case of error, return immediately to SME */
5476 limSendSmeTdlsLinkStartRsp(pMac, eSIR_FAILURE, setupReq->peerMac,
5477 eWNI_SME_TDLS_LINK_START_RSP);
5478 return eSIR_FAILURE ;
5479}
5480
5481/*
5482 * Process link teardown request recieved from SME and transmit to AP.
5483 */
5484eHalStatus limProcessSmeTeardownReq(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
5485{
5486 /* get all discovery request parameters */
5487 tSirTdlsTeardownReq *teardownReq = (tSirTdlsTeardownReq *) pMsgBuf ;
5488 tLimTdlsLinkSetupPeer *setupPeer;
5489 tpPESession psessionEntry;
5490 tANI_U8 sessionId;
5491
5492 if((psessionEntry = peFindSessionByBssid(pMac, teardownReq->bssid, &sessionId)) == NULL)
5493 {
5494 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005495 "PE Session does not exist for given sme sessionId %d", teardownReq->sessionId);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08005496 goto lim_tdls_teardown_req_error;
5497 }
5498
5499 /* check if we are in proper state to work as TDLS client */
5500 if (psessionEntry->limSystemRole != eLIM_STA_ROLE)
5501 {
5502 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005503 "TDLS teardown req received in wrong system Role %d", psessionEntry->limSystemRole);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08005504 goto lim_tdls_teardown_req_error;
5505 }
5506
5507 /*
5508 * if we are still good, go ahead and check if we are in proper state to
5509 * do TDLS setup procedure.
5510 */
5511 if ((psessionEntry->limSmeState != eLIM_SME_ASSOCIATED_STATE) &&
5512 (psessionEntry->limSmeState != eLIM_SME_LINK_EST_STATE))
5513 {
5514 limLog(pMac, LOGE, "TDLS teardwon req received in invalid LIMsme \
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005515 state (%d)", psessionEntry->limSmeState);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08005516 goto lim_tdls_teardown_req_error;
5517 }
5518
5519 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
Arif Hussain24bafea2013-11-15 15:10:03 -08005520 "Teardown for peer = " MAC_ADDRESS_STR, MAC_ADDR_ARRAY(teardownReq->peerMac));
Mohit Khanna698ba2a2012-12-04 15:08:18 -08005521 /*
5522 * Now, go ahead and transmit TDLS teardown request, and save teardown info
5523 * info for future reference.
5524 */
5525 /* Verify if this link is setup */
5526 setupPeer = NULL ;
5527 limTdlsFindLinkPeer(pMac, teardownReq->peerMac, &setupPeer);
5528 if(NULL == setupPeer)
5529 {
5530 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005531 ("invalid Peer on teardown ")) ;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08005532 goto lim_tdls_teardown_req_error;
5533 }
5534
5535
5536 (setupPeer)->tdls_prev_link_state = (setupPeer)->tdls_link_state ;
5537 (setupPeer)->tdls_link_state = TDLS_LINK_TEARDOWN_START_STATE ;
5538 /* TDLS_sessionize: check sessionId in case */
5539 if((setupPeer)->tdls_sessionId != psessionEntry->peSessionId)
5540 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005541 limLog(pMac, LOGE, "TDLS teardown req; stored sessionId (%d) not matched from peSessionId (%d)", \
Mohit Khanna698ba2a2012-12-04 15:08:18 -08005542 (setupPeer)->tdls_sessionId, psessionEntry->limSmeState);
5543 (setupPeer)->tdls_sessionId = psessionEntry->peSessionId;
5544 }
5545
5546 /* format TDLS teardown request frame and transmit it */
5547 if(eSIR_SUCCESS != limSendTdlsTeardownFrame(pMac, teardownReq->peerMac,
5548 eSIR_MAC_TDLS_TEARDOWN_UNSPEC_REASON, psessionEntry, NULL, 0 ))
5549 {
5550 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005551 ("couldn't send teardown frame ")) ;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08005552 goto lim_tdls_teardown_req_error;
5553 }
5554 /* in case of success, eWNI_SME_TDLS_TEARDOWN_RSP is sent back to SME later when
5555 TDLS teardown TX complete is successful. --> see limTdlsTeardownTxComplete() */
5556 return eSIR_SUCCESS;
5557lim_tdls_teardown_req_error:
5558 /* in case of error, return immediately to SME */
5559 limSendSmeTdlsTeardownRsp(pMac, eSIR_FAILURE, teardownReq->peerMac,
5560 eWNI_SME_TDLS_TEARDOWN_RSP);
5561 return eSIR_FAILURE;
5562}
5563
5564
5565#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005566
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05305567static void
5568__limProcessSmeResetApCapsChange(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
5569{
5570 tpSirResetAPCapsChange pResetCapsChange;
5571 tpPESession psessionEntry;
5572 tANI_U8 sessionId = 0;
5573 if (pMsgBuf == NULL)
5574 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005575 limLog(pMac, LOGE,FL("Buffer is Pointing to NULL"));
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05305576 return;
5577 }
5578
5579 pResetCapsChange = (tpSirResetAPCapsChange)pMsgBuf;
5580 psessionEntry = peFindSessionByBssid(pMac, pResetCapsChange->bssId, &sessionId);
5581 if (psessionEntry == NULL)
5582 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005583 limLog(pMac, LOGE, FL("Session does not exist for given BSSID"));
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05305584 return;
5585 }
5586
5587 psessionEntry->limSentCapsChangeNtf = false;
5588 return;
5589}
5590
Siddharth Bhal6af5d4e2014-09-29 21:11:16 +05305591static void
5592__limProcessSmeSpoofMacAddrRequest(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
5593{
5594 tSirMsgQ msg;
5595 tpSpoofMacAddrReqParams pSpoofMacAddrParams;
5596 tpSirSpoofMacAddrReq pSmeReq = (tpSirSpoofMacAddrReq) pMsgBuf;
5597
5598 pSpoofMacAddrParams = vos_mem_malloc(sizeof( tSpoofMacAddrReqParams));
5599 if ( NULL == pSpoofMacAddrParams )
5600 {
Siddharth Bhal4f3187c2014-10-09 21:38:08 +05305601 limLog( pMac, LOGE, FL("Unable to allocate memory for tDelStaSelfParams") );
Siddharth Bhal6af5d4e2014-09-29 21:11:16 +05305602 return;
5603 }
5604
5605 vos_mem_copy( pSpoofMacAddrParams->macAddr, pSmeReq->macAddr, sizeof(tSirMacAddr) );
5606
Siddharth Bhal4f3187c2014-10-09 21:38:08 +05305607 vos_mem_copy(pMac->lim.spoofMacAddr, pSmeReq->macAddr, VOS_MAC_ADDRESS_LEN);
5608
5609 limLog( pMac, LOG1, FL("Recieved Spoofed Mac Addr request with Addr:"
5610 MAC_ADDRESS_STR), MAC_ADDR_ARRAY(pMac->lim.spoofMacAddr) );
5611
Siddharth Bhal6af5d4e2014-09-29 21:11:16 +05305612 msg.type = WDA_SPOOF_MAC_ADDR_REQ;
5613 msg.reserved = 0;
5614 msg.bodyptr = pSpoofMacAddrParams;
5615 msg.bodyval = 0;
5616
5617 limLog(pMac, LOG1, FL("sending SIR_HAL_SPOOF_MAC_ADDR_REQ msg to HAL"));
5618 MTRACE(macTraceMsgTx(pMac, NO_SESSION, msg.type));
5619
5620 if(eSIR_SUCCESS != wdaPostCtrlMsg(pMac, &msg))
5621 {
Siddharth Bhal4f3187c2014-10-09 21:38:08 +05305622 limLog(pMac, LOGE, FL("wdaPostCtrlMsg failed for SIR_HAL_SPOOF_MAC_ADDR_REQ"));
Siddharth Bhal6af5d4e2014-09-29 21:11:16 +05305623 vos_mem_free(pSpoofMacAddrParams);
5624 }
5625 return;
5626}
5627
Jeff Johnson295189b2012-06-20 16:38:30 -07005628/**
5629 * limProcessSmeReqMessages()
5630 *
5631 *FUNCTION:
5632 * This function is called by limProcessMessageQueue(). This
5633 * function processes SME request messages from HDD or upper layer
5634 * application.
5635 *
5636 *LOGIC:
5637 *
5638 *ASSUMPTIONS:
5639 *
5640 *NOTE:
5641 *
5642 * @param pMac Pointer to Global MAC structure
5643 * @param msgType Indicates the SME message type
5644 * @param *pMsgBuf A pointer to the SME message buffer
5645 * @return Boolean - TRUE - if pMsgBuf is consumed and can be freed.
5646 * FALSE - if pMsgBuf is not to be freed.
5647 */
5648
5649tANI_BOOLEAN
5650limProcessSmeReqMessages(tpAniSirGlobal pMac, tpSirMsgQ pMsg)
5651{
5652 tANI_BOOLEAN bufConsumed = TRUE; //Set this flag to false within case block of any following message, that doesnt want pMsgBuf to be freed.
5653 tANI_U32 *pMsgBuf = pMsg->bodyptr;
Sudhir Sattayappa Kohalliabf751c2013-06-30 15:37:18 -07005654 tpSirSmeScanReq pScanReq;
Ganesh Kondabattini16930072014-08-22 16:02:34 +05305655 tANI_BOOLEAN isPassiveScan = FALSE;
5656
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005657 PELOG1(limLog(pMac, LOG1, FL("LIM Received SME Message %s(%d) Global LimSmeState:%s(%d) Global LimMlmState: %s(%d)"),
Jeff Johnson295189b2012-06-20 16:38:30 -07005658 limMsgStr(pMsg->type), pMsg->type,
5659 limSmeStateStr(pMac->lim.gLimSmeState), pMac->lim.gLimSmeState,
5660 limMlmStateStr(pMac->lim.gLimMlmState), pMac->lim.gLimMlmState );)
5661
Sudhir Sattayappa Kohalliabf751c2013-06-30 15:37:18 -07005662 pScanReq = (tpSirSmeScanReq) pMsgBuf;
Viral Modid440e682013-03-06 02:25:31 -08005663 /* Special handling of some SME Req msgs where we have an existing GO session and
5664 * want to insert NOA before processing those msgs. These msgs will be processed later when
5665 * start event happens
5666 */
5667 switch (pMsg->type)
5668 {
5669 case eWNI_SME_SCAN_REQ:
Ganesh Kondabattini16930072014-08-22 16:02:34 +05305670 pScanReq = (tpSirSmeScanReq) pMsgBuf;
5671 isPassiveScan = (pScanReq->scanType == eSIR_PASSIVE_SCAN) ? TRUE : FALSE;
Viral Modid440e682013-03-06 02:25:31 -08005672 case eWNI_SME_REMAIN_ON_CHANNEL_REQ:
Sudhir Sattayappa Kohalliabf751c2013-06-30 15:37:18 -07005673
5674 /* If scan is disabled return from here
5675 */
5676 if (pMac->lim.fScanDisabled)
5677 {
Sudhir Sattayappa Kohalliabf751c2013-06-30 15:37:18 -07005678 if (pMsg->type == eWNI_SME_SCAN_REQ)
5679 {
5680 limSendSmeScanRsp(pMac,
5681 offsetof(tSirSmeScanRsp,bssDescription[0]),
5682 eSIR_SME_INVALID_PARAMETERS,
5683 pScanReq->sessionId,
5684 pScanReq->transactionId);
5685
5686 bufConsumed = TRUE;
5687 }
5688 else if (pMsg->type == eWNI_SME_REMAIN_ON_CHANNEL_REQ)
5689 {
5690 pMac->lim.gpDefdSmeMsgForNOA = NULL;
5691 pMac->lim.gpLimRemainOnChanReq = (tpSirRemainOnChnReq )pMsgBuf;
5692 limRemainOnChnRsp(pMac,eHAL_STATUS_FAILURE, NULL);
5693
5694 /*
5695 * limRemainOnChnRsp will free the buffer this change is to
5696 * avoid "double free"
5697 */
5698 bufConsumed = FALSE;
5699 }
5700
Rashmi Ramanna6c13a342014-01-07 11:44:07 +05305701 limLog(pMac, LOGE,
5702 FL("Error: Scan Disabled."
5703 " Return with error status for SME Message %s(%d)"),
5704 limMsgStr(pMsg->type), pMsg->type);
5705
Sudhir Sattayappa Kohalliabf751c2013-06-30 15:37:18 -07005706 return bufConsumed;
5707 }
5708 /*
5709 * Do not add BREAK here
5710 */
5711 case eWNI_SME_OEM_DATA_REQ:
Viral Modid440e682013-03-06 02:25:31 -08005712 case eWNI_SME_JOIN_REQ:
5713 /* If we have an existing P2P GO session we need to insert NOA before actually process this SME Req */
5714 if ((limIsNOAInsertReqd(pMac) == TRUE) && IS_FEATURE_SUPPORTED_BY_FW(P2P_GO_NOA_DECOUPLE_INIT_SCAN))
5715 {
5716 tANI_U32 noaDuration;
5717 __limRegisterDeferredSmeReqForNOAStart(pMac, pMsg->type, pMsgBuf);
Ganesh Kondabattini16930072014-08-22 16:02:34 +05305718 noaDuration = limCalculateNOADuration(pMac, pMsg->type, pMsgBuf, isPassiveScan);
Viral Modid440e682013-03-06 02:25:31 -08005719 bufConsumed = __limInsertSingleShotNOAForScan(pMac, noaDuration);
5720 return bufConsumed;
5721 }
5722 }
5723 /* If no insert NOA required then execute the code below */
5724
Jeff Johnson295189b2012-06-20 16:38:30 -07005725 switch (pMsg->type)
5726 {
5727 case eWNI_SME_START_REQ:
5728 __limProcessSmeStartReq(pMac, pMsgBuf);
5729 break;
5730
5731 case eWNI_SME_SYS_READY_IND:
5732 bufConsumed = __limProcessSmeSysReadyInd(pMac, pMsgBuf);
5733 break;
5734
Jeff Johnson295189b2012-06-20 16:38:30 -07005735 case eWNI_SME_START_BSS_REQ:
5736 bufConsumed = __limProcessSmeStartBssReq(pMac, pMsg);
5737 break;
5738
5739 case eWNI_SME_SCAN_REQ:
Viral Modid440e682013-03-06 02:25:31 -08005740 __limProcessSmeScanReq(pMac, pMsgBuf);
Jeff Johnson295189b2012-06-20 16:38:30 -07005741 break;
5742
Jeff Johnsone7245742012-09-05 17:12:55 -07005743#ifdef FEATURE_OEM_DATA_SUPPORT
5744 case eWNI_SME_OEM_DATA_REQ:
5745 __limProcessSmeOemDataReq(pMac, pMsgBuf);
Jeff Johnsone7245742012-09-05 17:12:55 -07005746 break;
5747#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005748 case eWNI_SME_REMAIN_ON_CHANNEL_REQ:
5749 bufConsumed = limProcessRemainOnChnlReq(pMac, pMsgBuf);
5750 break;
5751
5752 case eWNI_SME_UPDATE_NOA:
5753 __limProcessSmeNoAUpdate(pMac, pMsgBuf);
5754 break;
Gopichand Nakkalac178ac82013-05-30 19:53:39 +05305755 case eWNI_SME_CLEAR_DFS_CHANNEL_LIST:
5756 __limProcessClearDfsChannelList(pMac, pMsg);
5757 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005758 case eWNI_SME_JOIN_REQ:
5759 __limProcessSmeJoinReq(pMac, pMsgBuf);
Jeff Johnson295189b2012-06-20 16:38:30 -07005760 break;
5761
5762 case eWNI_SME_AUTH_REQ:
5763 // __limProcessSmeAuthReq(pMac, pMsgBuf);
5764
5765 break;
5766
5767 case eWNI_SME_REASSOC_REQ:
5768 __limProcessSmeReassocReq(pMac, pMsgBuf);
5769
5770 break;
5771
5772 case eWNI_SME_PROMISCUOUS_MODE_REQ:
5773 //__limProcessSmePromiscuousReq(pMac, pMsgBuf);
5774
5775 break;
5776
5777 case eWNI_SME_DISASSOC_REQ:
5778 __limProcessSmeDisassocReq(pMac, pMsgBuf);
5779
5780 break;
5781
5782 case eWNI_SME_DISASSOC_CNF:
5783 case eWNI_SME_DEAUTH_CNF:
5784 __limProcessSmeDisassocCnf(pMac, pMsgBuf);
5785
5786 break;
5787
5788 case eWNI_SME_DEAUTH_REQ:
5789 __limProcessSmeDeauthReq(pMac, pMsgBuf);
5790
5791 break;
5792
Jeff Johnson295189b2012-06-20 16:38:30 -07005793
5794
5795 case eWNI_SME_SETCONTEXT_REQ:
5796 __limProcessSmeSetContextReq(pMac, pMsgBuf);
5797
5798 break;
5799
5800 case eWNI_SME_REMOVEKEY_REQ:
5801 __limProcessSmeRemoveKeyReq(pMac, pMsgBuf);
5802
5803 break;
5804
5805 case eWNI_SME_STOP_BSS_REQ:
5806 bufConsumed = __limProcessSmeStopBssReq(pMac, pMsg);
5807 break;
5808
5809 case eWNI_SME_ASSOC_CNF:
5810 case eWNI_SME_REASSOC_CNF:
5811 if (pMsg->type == eWNI_SME_ASSOC_CNF)
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005812 PELOG1(limLog(pMac, LOG1, FL("Received ASSOC_CNF message"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07005813 else
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005814 PELOG1(limLog(pMac, LOG1, FL("Received REASSOC_CNF message"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07005815 __limProcessSmeAssocCnfNew(pMac, pMsg->type, pMsgBuf);
5816 break;
5817
5818 case eWNI_SME_ADDTS_REQ:
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005819 PELOG1(limLog(pMac, LOG1, FL("Received ADDTS_REQ message"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07005820 __limProcessSmeAddtsReq(pMac, pMsgBuf);
5821 break;
5822
5823 case eWNI_SME_DELTS_REQ:
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005824 PELOG1(limLog(pMac, LOG1, FL("Received DELTS_REQ message"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07005825 __limProcessSmeDeltsReq(pMac, pMsgBuf);
5826 break;
5827
5828 case SIR_LIM_ADDTS_RSP_TIMEOUT:
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005829 PELOG1(limLog(pMac, LOG1, FL("Received SIR_LIM_ADDTS_RSP_TIMEOUT message "));)
Jeff Johnson295189b2012-06-20 16:38:30 -07005830 limProcessSmeAddtsRspTimeout(pMac, pMsg->bodyval);
5831 break;
5832
5833 case eWNI_SME_STA_STAT_REQ:
5834 case eWNI_SME_AGGR_STAT_REQ:
5835 case eWNI_SME_GLOBAL_STAT_REQ:
5836 case eWNI_SME_STAT_SUMM_REQ:
5837 __limProcessSmeStatsRequest( pMac, pMsgBuf);
5838 //HAL consumes pMsgBuf. It will be freed there. Set bufConsumed to false.
5839 bufConsumed = FALSE;
5840 break;
5841 case eWNI_SME_GET_STATISTICS_REQ:
5842 __limProcessSmeGetStatisticsRequest( pMac, pMsgBuf);
5843 //HAL consumes pMsgBuf. It will be freed there. Set bufConsumed to false.
5844 bufConsumed = FALSE;
5845 break;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005846#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08005847 case eWNI_SME_GET_ROAM_RSSI_REQ:
5848 __limProcessSmeGetRoamRssiRequest( pMac, pMsgBuf);
5849 //HAL consumes pMsgBuf. It will be freed there. Set bufConsumed to false.
5850 bufConsumed = FALSE;
5851 break;
5852#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005853#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005854 case eWNI_SME_GET_TSM_STATS_REQ:
5855 __limProcessSmeGetTsmStatsRequest( pMac, pMsgBuf);
5856 bufConsumed = FALSE;
5857 break;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005858#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Jeff Johnson295189b2012-06-20 16:38:30 -07005859 case eWNI_SME_DEL_BA_PEER_IND:
5860 limProcessSmeDelBaPeerInd(pMac, pMsgBuf);
5861 break;
5862 case eWNI_SME_GET_SCANNED_CHANNEL_REQ:
5863 limProcessSmeGetScanChannelInfo(pMac, pMsgBuf);
5864 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005865 case eWNI_SME_GET_ASSOC_STAS_REQ:
5866 limProcessSmeGetAssocSTAsInfo(pMac, pMsgBuf);
5867 break;
5868 case eWNI_SME_TKIP_CNTR_MEAS_REQ:
5869 limProcessTkipCounterMeasures(pMac, pMsgBuf);
5870 break;
5871
5872 case eWNI_SME_HIDE_SSID_REQ:
5873 __limProcessSmeHideSSID(pMac, pMsgBuf);
5874 break;
5875 case eWNI_SME_UPDATE_APWPSIE_REQ:
5876 __limProcessSmeUpdateAPWPSIEs(pMac, pMsgBuf);
5877 break;
5878 case eWNI_SME_GET_WPSPBC_SESSION_REQ:
5879 limProcessSmeGetWPSPBCSessions(pMac, pMsgBuf);
5880 break;
5881
5882 case eWNI_SME_SET_APWPARSNIEs_REQ:
5883 __limProcessSmeSetWPARSNIEs(pMac, pMsgBuf);
5884 break;
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08005885
5886 case eWNI_SME_CHNG_MCC_BEACON_INTERVAL:
5887 //Update the beaconInterval
5888 __limProcessSmeChangeBI(pMac, pMsgBuf );
5889 break;
Hardik Kantilal Patel62a3a762014-11-21 12:55:57 +05305890
5891#ifdef WLAN_FEATURE_AP_HT40_24G
5892 case eWNI_SME_SET_HT_2040_MODE:
5893 __limProcessSmeSetHT2040Mode(pMac, pMsgBuf);
5894 break;
5895#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005896
5897#if defined WLAN_FEATURE_VOWIFI
5898 case eWNI_SME_NEIGHBOR_REPORT_REQ_IND:
5899 case eWNI_SME_BEACON_REPORT_RESP_XMIT_IND:
5900 __limProcessReportMessage(pMac, pMsg);
5901 break;
5902#endif
5903
5904#if defined WLAN_FEATURE_VOWIFI_11R
5905 case eWNI_SME_FT_PRE_AUTH_REQ:
5906 bufConsumed = (tANI_BOOLEAN)limProcessFTPreAuthReq(pMac, pMsg);
5907 break;
5908 case eWNI_SME_FT_UPDATE_KEY:
5909 limProcessFTUpdateKey(pMac, pMsgBuf);
5910 break;
5911
5912 case eWNI_SME_FT_AGGR_QOS_REQ:
5913 limProcessFTAggrQosReq(pMac, pMsgBuf);
5914 break;
5915#endif
5916
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005917#if defined(FEATURE_WLAN_ESE) && !defined(FEATURE_WLAN_ESE_UPLOAD)
5918 case eWNI_SME_ESE_ADJACENT_AP_REPORT:
Jeff Johnson295189b2012-06-20 16:38:30 -07005919 limProcessAdjacentAPRepMsg ( pMac, pMsgBuf );
5920 break;
5921#endif
5922 case eWNI_SME_ADD_STA_SELF_REQ:
5923 __limProcessSmeAddStaSelfReq( pMac, pMsgBuf );
5924 break;
5925 case eWNI_SME_DEL_STA_SELF_REQ:
5926 __limProcessSmeDelStaSelfReq( pMac, pMsgBuf );
5927 break;
5928
Jeff Johnson295189b2012-06-20 16:38:30 -07005929 case eWNI_SME_REGISTER_MGMT_FRAME_REQ:
5930 __limProcessSmeRegisterMgmtFrameReq( pMac, pMsgBuf );
5931 break;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08005932#ifdef FEATURE_WLAN_TDLS
5933 case eWNI_SME_TDLS_SEND_MGMT_REQ:
5934 limProcessSmeTdlsMgmtSendReq(pMac, pMsgBuf);
5935 break;
5936 case eWNI_SME_TDLS_ADD_STA_REQ:
5937 limProcessSmeTdlsAddStaReq(pMac, pMsgBuf);
5938 break;
5939 case eWNI_SME_TDLS_DEL_STA_REQ:
5940 limProcessSmeTdlsDelStaReq(pMac, pMsgBuf);
5941 break;
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05305942 case eWNI_SME_TDLS_LINK_ESTABLISH_REQ:
5943 limProcesSmeTdlsLinkEstablishReq(pMac, pMsgBuf);
5944 break;
Atul Mittalc0f739f2014-07-31 13:47:47 +05305945// tdlsoffchan
5946 case eWNI_SME_TDLS_CHANNEL_SWITCH_REQ:
5947 limProcesSmeTdlsChanSwitchReq(pMac, pMsgBuf);
5948 break;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08005949#endif
5950#ifdef FEATURE_WLAN_TDLS_INTERNAL
5951 case eWNI_SME_TDLS_DISCOVERY_START_REQ:
5952 limProcessSmeDisStartReq(pMac, pMsgBuf);
5953 break ;
5954 case eWNI_SME_TDLS_LINK_START_REQ:
5955 limProcessSmeLinkStartReq(pMac, pMsgBuf);
5956 break ;
5957 case eWNI_SME_TDLS_TEARDOWN_REQ:
5958 limProcessSmeTeardownReq(pMac, pMsgBuf);
5959 break ;
5960#endif
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05305961 case eWNI_SME_RESET_AP_CAPS_CHANGED:
5962 __limProcessSmeResetApCapsChange(pMac, pMsgBuf);
5963 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005964
schang86c22c42013-03-13 18:41:24 -07005965 case eWNI_SME_SET_TX_POWER_REQ:
5966 limSendSetTxPowerReq(pMac, pMsgBuf);
5967 break ;
5968
Siddharth Bhal6af5d4e2014-09-29 21:11:16 +05305969 case eWNI_SME_MAC_SPOOF_ADDR_IND:
5970 __limProcessSmeSpoofMacAddrRequest(pMac, pMsgBuf);
5971 break ;
5972
Jeff Johnson295189b2012-06-20 16:38:30 -07005973 default:
5974 vos_mem_free((v_VOID_t*)pMsg->bodyptr);
5975 pMsg->bodyptr = NULL;
5976 break;
5977 } // switch (msgType)
5978
5979 return bufConsumed;
5980} /*** end limProcessSmeReqMessages() ***/