blob: afc6eb437636374eea55b46a11e42bd2c5b4dc64 [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Agrawal Ashish01c66342017-01-27 12:52:25 +05302 * Copyright (c) 2012-2017 The Linux Foundation. All rights reserved.
Kiet Lam842dad02014-02-18 18:44:02 -08003 *
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"
Satyanarayana Dash6f438272015-03-03 18:01:06 +053044#include "wniCfg.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
Abhishek Singh00b71972016-01-07 10:51:04 +053062#ifdef WLAN_FEATURE_RMC
63#include "limRMC.h"
64#endif
65
Jeff Johnson295189b2012-06-20 16:38:30 -070066#include "sapApi.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070067
68#if defined WLAN_FEATURE_VOWIFI
69#include "rrmApi.h"
70#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080071#if defined(FEATURE_WLAN_ESE) && !defined(FEATURE_WLAN_ESE_UPLOAD)
72#include "eseApi.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070073#endif
74
75#if defined WLAN_FEATURE_VOWIFI_11R
76#include <limFT.h>
77#endif
78
Padma, Santhosh Kumar67f479b2016-12-28 15:43:42 +053079#ifdef WLAN_FEATURE_LFR_MBB
80#include "lim_mbb.h"
81#endif
82
Jeff Johnson295189b2012-06-20 16:38:30 -070083
Sushant Kaushike3ca61c2015-03-19 18:33:25 +053084#define JOIN_FAILURE_TIMEOUT 1000 // in msecs
Viral Modid86bde22012-12-10 13:09:21 -080085/* This overhead is time for sending NOA start to host in case of GO/sending NULL data & receiving ACK
86 * 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 -080087 * taking care of sending null data and receiving ACK to/from AP/Also SetChannel with calibration is taking
88 * around 7ms .
Viral Modid86bde22012-12-10 13:09:21 -080089 */
Viral Modid440e682013-03-06 02:25:31 -080090#define SCAN_MESSAGING_OVERHEAD 20 // in msecs
91#define JOIN_NOA_DURATION 2000 // in msecs
92#define OEM_DATA_NOA_DURATION 60 // in msecs
93#define DEFAULT_PASSIVE_MAX_CHANNEL_TIME 110 // in msecs
Jeff Johnson295189b2012-06-20 16:38:30 -070094
Gopichand Nakkala096a1052012-12-21 07:05:34 -080095#define CONV_MS_TO_US 1024 //conversion factor from ms to us
96
Jeff Johnson295189b2012-06-20 16:38:30 -070097// SME REQ processing function templates
98static void __limProcessSmeStartReq(tpAniSirGlobal, tANI_U32 *);
99static tANI_BOOLEAN __limProcessSmeSysReadyInd(tpAniSirGlobal, tANI_U32 *);
100static tANI_BOOLEAN __limProcessSmeStartBssReq(tpAniSirGlobal, tpSirMsgQ pMsg);
Viral Modid440e682013-03-06 02:25:31 -0800101static void __limProcessSmeScanReq(tpAniSirGlobal, tANI_U32 *);
Jeff Johnson295189b2012-06-20 16:38:30 -0700102static void __limProcessSmeJoinReq(tpAniSirGlobal, tANI_U32 *);
103static void __limProcessSmeReassocReq(tpAniSirGlobal, tANI_U32 *);
104static void __limProcessSmeDisassocReq(tpAniSirGlobal, tANI_U32 *);
105static void __limProcessSmeDisassocCnf(tpAniSirGlobal, tANI_U32 *);
106static void __limProcessSmeDeauthReq(tpAniSirGlobal, tANI_U32 *);
107static void __limProcessSmeSetContextReq(tpAniSirGlobal, tANI_U32 *);
108static tANI_BOOLEAN __limProcessSmeStopBssReq(tpAniSirGlobal, tpSirMsgQ pMsg);
109
Jeff Johnson295189b2012-06-20 16:38:30 -0700110void __limProcessSmeAssocCnfNew(tpAniSirGlobal, tANI_U32, tANI_U32 *);
111
Jeff Johnson295189b2012-06-20 16:38:30 -0700112extern void peRegisterTLHandle(tpAniSirGlobal pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -0700113
Jeff Johnson295189b2012-06-20 16:38:30 -0700114
Jeff Johnson295189b2012-06-20 16:38:30 -0700115#ifdef BACKGROUND_SCAN_ENABLED
116
117// start the background scan timers if it hasn't already started
118static void
119__limBackgroundScanInitiate(tpAniSirGlobal pMac)
120{
121 if (pMac->lim.gLimBackgroundScanStarted)
122 return;
123
124 //make sure timer is created first
125 if (TX_TIMER_VALID(pMac->lim.limTimers.gLimBackgroundScanTimer))
126 {
127 limDeactivateAndChangeTimer(pMac, eLIM_BACKGROUND_SCAN_TIMER);
Jeff Johnsone7245742012-09-05 17:12:55 -0700128 MTRACE(macTrace(pMac, TRACE_CODE_TIMER_ACTIVATE, NO_SESSION, eLIM_BACKGROUND_SCAN_TIMER));
Jeff Johnson295189b2012-06-20 16:38:30 -0700129 if (tx_timer_activate(&pMac->lim.limTimers.gLimBackgroundScanTimer) != TX_SUCCESS)
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700130 limLog(pMac, LOGP, FL("could not activate background scan timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700131 pMac->lim.gLimBackgroundScanStarted = true;
132 pMac->lim.gLimBackgroundScanChannelId = 0;
133 }
134}
135
136#endif // BACKGROUND_SCAN_ENABLED
Jeff Johnson295189b2012-06-20 16:38:30 -0700137
138// determine if a fresh scan request must be issued or not
139/*
140* PE will do fresh scan, if all of the active sessions are in good state (Link Est or BSS Started)
141* If one of the sessions is not in one of the above states, then PE does not do fresh scan
142* If no session exists (scanning very first time), then PE will always do fresh scan if SME
143* asks it to do that.
144*/
145static tANI_U8
146__limFreshScanReqd(tpAniSirGlobal pMac, tANI_U8 returnFreshResults)
147{
148
149 tANI_U8 validState = TRUE;
150 int i;
151
152 if(pMac->lim.gLimSmeState != eLIM_SME_IDLE_STATE)
153 {
Sushant Kaushik59e6f362015-08-11 15:41:00 +0530154 limLog(pMac, LOG1, FL("setting fresh scan as false. sme state is %d"),
155 pMac->lim.gLimSmeState);
Jeff Johnson295189b2012-06-20 16:38:30 -0700156 return FALSE;
157 }
158 for(i =0; i < pMac->lim.maxBssId; i++)
159 {
160
161 if(pMac->lim.gpSession[i].valid == TRUE)
162 {
163 if(!( ( ( (pMac->lim.gpSession[i].bssType == eSIR_INFRASTRUCTURE_MODE) ||
164 (pMac->lim.gpSession[i].limSystemRole == eLIM_BT_AMP_STA_ROLE))&&
165 (pMac->lim.gpSession[i].limSmeState == eLIM_SME_LINK_EST_STATE) )||
166
167 ( ( (pMac->lim.gpSession[i].bssType == eSIR_IBSS_MODE)||
168 (pMac->lim.gpSession[i].limSystemRole == eLIM_BT_AMP_AP_ROLE)||
169 (pMac->lim.gpSession[i].limSystemRole == eLIM_BT_AMP_STA_ROLE) )&&
170 (pMac->lim.gpSession[i].limSmeState == eLIM_SME_NORMAL_STATE) )
Jeff Johnson295189b2012-06-20 16:38:30 -0700171 || ( ( ( (pMac->lim.gpSession[i].bssType == eSIR_INFRA_AP_MODE)
172 && ( pMac->lim.gpSession[i].pePersona == VOS_P2P_GO_MODE) )
173 || (pMac->lim.gpSession[i].limSystemRole == eLIM_AP_ROLE) )
174 && (pMac->lim.gpSession[i].limSmeState == eLIM_SME_NORMAL_STATE) )
Jeff Johnson295189b2012-06-20 16:38:30 -0700175 ))
176 {
177 validState = FALSE;
Sushant Kaushik59e6f362015-08-11 15:41:00 +0530178 limLog(pMac, LOG1, FL("setting fresh scan as false."
179 "bssType is %d system role is %d, smestate is %d"),
180 pMac->lim.gpSession[i].bssType,
181 pMac->lim.gpSession[i].limSystemRole,
182 pMac->lim.gpSession[i].limSmeState);
Jeff Johnson295189b2012-06-20 16:38:30 -0700183 break;
184 }
185
186 }
187 }
Rashmi Ramanna6c13a342014-01-07 11:44:07 +0530188 limLog(pMac, LOG1, FL("FreshScanReqd: %d "), validState);
Jeff Johnson295189b2012-06-20 16:38:30 -0700189
190 if( (validState) && (returnFreshResults & SIR_BG_SCAN_RETURN_FRESH_RESULTS))
191 return TRUE;
192
193 return FALSE;
194}
195
Jeff Johnson295189b2012-06-20 16:38:30 -0700196
197
198/**
199 * __limIsSmeAssocCnfValid()
200 *
201 *FUNCTION:
202 * This function is called by limProcessLmmMessages() upon
203 * receiving SME_ASSOC_CNF.
204 *
205 *LOGIC:
206 * Message validity checks are performed in this function
207 *
208 *ASSUMPTIONS:
209 *
210 *NOTE:
211 *
212 * @param pMeasReq Pointer to Received ASSOC_CNF message
213 * @return true When received SME_ASSOC_CNF is formatted
214 * correctly
215 * false otherwise
216 */
217
218inline static tANI_U8
219__limIsSmeAssocCnfValid(tpSirSmeAssocCnf pAssocCnf)
220{
221 if (limIsGroupAddr(pAssocCnf->peerMacAddr))
222 return false;
223 else
224 return true;
225} /*** end __limIsSmeAssocCnfValid() ***/
226
227
228/**
229 * __limGetSmeJoinReqSizeForAlloc()
230 *
231 *FUNCTION:
232 * This function is called in various places to get IE length
233 * from tSirBssDescription structure
234 * number being scanned.
235 *
236 *PARAMS:
237 *
238 *LOGIC:
239 *
240 *ASSUMPTIONS:
241 * NA
242 *
243 *NOTE:
244 * NA
245 *
246 * @param pBssDescr
247 * @return Total IE length
248 */
249
Padma, Santhosh Kumarf4966dc2017-01-03 18:56:00 +0530250tANI_U16
Jeff Johnson295189b2012-06-20 16:38:30 -0700251__limGetSmeJoinReqSizeForAlloc(tANI_U8 *pBuf)
252{
253 tANI_U16 len = 0;
254
255 if (!pBuf)
256 return len;
257
258 pBuf += sizeof(tANI_U16);
259 len = limGetU16( pBuf );
260 return (len + sizeof( tANI_U16 ));
261} /*** end __limGetSmeJoinReqSizeForAlloc() ***/
262
263
264/**----------------------------------------------------------------
265\fn __limIsDeferedMsgForLearn
266
267\brief Has role only if 11h is enabled. Not used on STA side.
268 Defers the message if SME is in learn state and brings
269 the LIM back to normal mode.
270
271\param pMac
272\param pMsg - Pointer to message posted from SME to LIM.
273\return TRUE - If defered
274 FALSE - Otherwise
275------------------------------------------------------------------*/
276static tANI_BOOLEAN
277__limIsDeferedMsgForLearn(tpAniSirGlobal pMac, tpSirMsgQ pMsg)
278{
279 if (limIsSystemInScanState(pMac))
280 {
281 if (limDeferMsg(pMac, pMsg) != TX_SUCCESS)
282 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700283 PELOGE(limLog(pMac, LOGE, FL("Could not defer Msg = %d"), pMsg->type);)
Jeff Johnson295189b2012-06-20 16:38:30 -0700284 return eANI_BOOLEAN_FALSE;
285 }
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700286 PELOG1(limLog(pMac, LOG1, FL("Defer the message, in learn mode type = %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -0700287 pMsg->type);)
288
289 /** Send finish scan req to HAL only if LIM is not waiting for any response
290 * from HAL like init scan rsp, start scan rsp etc.
291 */
292 if (GET_LIM_PROCESS_DEFD_MESGS(pMac))
293 {
294 //Set the resume channel to Any valid channel (invalid).
295 //This will instruct HAL to set it to any previous valid channel.
296 peSetResumeChannel(pMac, 0, 0);
297 limSendHalFinishScanReq(pMac, eLIM_HAL_FINISH_LEARN_WAIT_STATE);
298 }
299
300 return eANI_BOOLEAN_TRUE;
301 }
302 return eANI_BOOLEAN_FALSE;
303}
304
305/**----------------------------------------------------------------
306\fn __limIsDeferedMsgForRadar
307
308\brief Has role only if 11h is enabled. Not used on STA side.
309 Defers the message if radar is detected.
310
311\param pMac
312\param pMsg - Pointer to message posted from SME to LIM.
313\return TRUE - If defered
314 FALSE - Otherwise
315------------------------------------------------------------------*/
316static tANI_BOOLEAN
317__limIsDeferedMsgForRadar(tpAniSirGlobal pMac, tpSirMsgQ pMsg)
318{
319 /** fRadarDetCurOperChan will be set only if we detect radar in current
320 * operating channel and System Role == AP ROLE */
Jeff Johnsone7245742012-09-05 17:12:55 -0700321 //TODO: Need to take care radar detection.
322 //if (LIM_IS_RADAR_DETECTED(pMac))
323 if( 0 )
Jeff Johnson295189b2012-06-20 16:38:30 -0700324 {
325 if (limDeferMsg(pMac, pMsg) != TX_SUCCESS)
326 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700327 PELOGE(limLog(pMac, LOGE, FL("Could not defer Msg = %d"), pMsg->type);)
Jeff Johnson295189b2012-06-20 16:38:30 -0700328 return eANI_BOOLEAN_FALSE;
329 }
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700330 PELOG1(limLog(pMac, LOG1, FL("Defer the message, in learn mode type = %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -0700331 pMsg->type);)
332 return eANI_BOOLEAN_TRUE;
333 }
334 return eANI_BOOLEAN_FALSE;
335}
336
337
338/**
339 * __limProcessSmeStartReq()
340 *
341 *FUNCTION:
342 * This function is called to process SME_START_REQ message
343 * from HDD or upper layer application.
344 *
345 *LOGIC:
346 *
347 *ASSUMPTIONS:
348 *
349 *NOTE:
350 *
351 * @param pMac Pointer to Global MAC structure
352 * @param *pMsgBuf A pointer to the SME message buffer
353 * @return None
354 */
355
356static void
357__limProcessSmeStartReq(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
358{
359 tSirResultCodes retCode = eSIR_SME_SUCCESS;
360 tANI_U8 smesessionId;
361 tANI_U16 smetransactionId;
362
363
Abhishek Singh3cbf6052014-12-15 16:46:42 +0530364 limLog(pMac, LOG1, FL("Received SME_START_REQ"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700365
366 limGetSessionInfo(pMac,(tANI_U8 *)pMsgBuf,&smesessionId,&smetransactionId);
367
368 if (pMac->lim.gLimSmeState == eLIM_SME_OFFLINE_STATE)
369 {
370 pMac->lim.gLimSmeState = eLIM_SME_IDLE_STATE;
371
Jeff Johnsone7245742012-09-05 17:12:55 -0700372 MTRACE(macTrace(pMac, TRACE_CODE_SME_STATE, NO_SESSION, pMac->lim.gLimSmeState));
Jeff Johnson295189b2012-06-20 16:38:30 -0700373
374 /// By default do not return after first scan match
375 pMac->lim.gLimReturnAfterFirstMatch = 0;
376
377 /// Initialize MLM state machine
378 limInitMlm(pMac);
379
380 /// By default return unique scan results
381 pMac->lim.gLimReturnUniqueResults = true;
382 pMac->lim.gLimSmeScanResultLength = 0;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -0700383#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
384 pMac->lim.gLimSmeLfrScanResultLength = 0;
385#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700386
Jeff Johnson295189b2012-06-20 16:38:30 -0700387 if (((tSirSmeStartReq *) pMsgBuf)->sendNewBssInd)
388 {
389 /*
390 * Need to indicate new BSSs found during background scanning to
391 * host. Update this parameter at CFG
392 */
393 if (cfgSetInt(pMac, WNI_CFG_NEW_BSS_FOUND_IND, ((tSirSmeStartReq *) pMsgBuf)->sendNewBssInd)
394 != eSIR_SUCCESS)
395 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700396 limLog(pMac, LOGP, FL("could not set NEIGHBOR_BSS_IND at CFG"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700397 retCode = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
398 }
399 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700400 }
401 else
402 {
403 /**
404 * Should not have received eWNI_SME_START_REQ in states
405 * other than OFFLINE. Return response to host and
406 * log error
407 */
Sushant Kaushik1b645382014-10-13 16:39:36 +0530408 limLog(pMac, LOGE, FL("Invalid SME_START_REQ received in SME state %d"),pMac->lim.gLimSmeState );
Jeff Johnson295189b2012-06-20 16:38:30 -0700409 limPrintSmeState(pMac, LOGE, pMac->lim.gLimSmeState);
410 retCode = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
411 }
412 limSendSmeRsp(pMac, eWNI_SME_START_RSP, retCode,smesessionId,smetransactionId);
413} /*** end __limProcessSmeStartReq() ***/
414
415
416/** -------------------------------------------------------------
417\fn __limProcessSmeSysReadyInd
418\brief handles the notification from HDD. PE just forwards this message to HAL.
419\param tpAniSirGlobal pMac
420\param tANI_U32* pMsgBuf
421\return TRUE-Posting to HAL failed, so PE will consume the buffer.
422\ FALSE-Posting to HAL successful, so HAL will consume the buffer.
423 -------------------------------------------------------------*/
424static tANI_BOOLEAN
425__limProcessSmeSysReadyInd(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
426{
427 tSirMsgQ msg;
428
429 msg.type = WDA_SYS_READY_IND;
430 msg.reserved = 0;
431 msg.bodyptr = pMsgBuf;
432 msg.bodyval = 0;
433
Jeff Johnson92751692013-03-06 16:00:33 -0800434 if (pMac->gDriverType != eDRIVER_TYPE_MFG)
Jeff Johnson295189b2012-06-20 16:38:30 -0700435 {
Jeff Johnson92751692013-03-06 16:00:33 -0800436 peRegisterTLHandle(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -0700437 }
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700438 PELOGW(limLog(pMac, LOGW, FL("sending WDA_SYS_READY_IND msg to HAL"));)
Jeff Johnsone7245742012-09-05 17:12:55 -0700439 MTRACE(macTraceMsgTx(pMac, NO_SESSION, msg.type));
Jeff Johnson295189b2012-06-20 16:38:30 -0700440
Jeff Johnson92751692013-03-06 16:00:33 -0800441 if (eSIR_SUCCESS != wdaPostCtrlMsg(pMac, &msg))
Jeff Johnson295189b2012-06-20 16:38:30 -0700442 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700443 limLog(pMac, LOGP, FL("wdaPostCtrlMsg failed"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700444 return eANI_BOOLEAN_TRUE;
445 }
446 return eANI_BOOLEAN_FALSE;
447}
448
Jeff Johnsone7245742012-09-05 17:12:55 -0700449#ifdef WLAN_FEATURE_11AC
Jeff Johnson295189b2012-06-20 16:38:30 -0700450
Jeff Johnsone7245742012-09-05 17:12:55 -0700451tANI_U32 limGetCenterChannel(tpAniSirGlobal pMac,tANI_U8 primarychanNum,ePhyChanBondState secondaryChanOffset, tANI_U8 chanWidth)
452{
453 if (chanWidth == WNI_CFG_VHT_CHANNEL_WIDTH_80MHZ)
454 {
455 switch(secondaryChanOffset)
456 {
457 case PHY_QUADRUPLE_CHANNEL_20MHZ_CENTERED_40MHZ_CENTERED:
458 return primarychanNum;
459 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_CENTERED:
460 return primarychanNum + 2;
461 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_CENTERED:
462 return primarychanNum - 2;
463 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_LOW:
464 return primarychanNum + 6;
465 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_LOW:
466 return primarychanNum + 2;
467 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_HIGH:
468 return primarychanNum - 2;
469 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_HIGH:
470 return primarychanNum - 6;
471 default :
472 return eSIR_CFG_INVALID_ID;
473 }
474 }
475 else if (chanWidth == WNI_CFG_VHT_CHANNEL_WIDTH_20_40MHZ)
476 {
477 switch(secondaryChanOffset)
478 {
479 case PHY_DOUBLE_CHANNEL_LOW_PRIMARY:
480 return primarychanNum + 2;
481 case PHY_DOUBLE_CHANNEL_HIGH_PRIMARY:
482 return primarychanNum - 2;
483 case PHY_QUADRUPLE_CHANNEL_20MHZ_CENTERED_40MHZ_CENTERED:
484 return primarychanNum;
485 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_CENTERED:
486 return primarychanNum + 2;
487 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_CENTERED:
488 return primarychanNum - 2;
489 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_LOW:
490 return primarychanNum + 2;
491 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_LOW:
492 return primarychanNum - 2;
493 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_HIGH:
494 return primarychanNum + 2;
495 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_HIGH:
496 return primarychanNum - 2;
497 default :
498 return eSIR_CFG_INVALID_ID;
499 }
500 }
501 return primarychanNum;
502}
503
504#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700505/**
506 * __limHandleSmeStartBssRequest()
507 *
508 *FUNCTION:
509 * This function is called to process SME_START_BSS_REQ message
510 * from HDD or upper layer application.
511 *
512 *LOGIC:
513 *
514 *ASSUMPTIONS:
515 *
516 *NOTE:
517 *
518 * @param pMac Pointer to Global MAC structure
519 * @param *pMsgBuf A pointer to the SME message buffer
520 * @return None
521 */
522
523static void
524__limHandleSmeStartBssRequest(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
525{
526 tANI_U16 size;
527 tANI_U32 val = 0;
528 tSirRetStatus retStatus;
529 tSirMacChanNum channelNumber;
Jeff Johnsonace91102013-04-05 08:03:18 -0700530 tLimMlmStartReq *pMlmStartReq = NULL;
531 tpSirSmeStartBssReq pSmeStartBssReq = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -0700532 tSirResultCodes retCode = eSIR_SME_SUCCESS;
533 tANI_U32 autoGenBssId = FALSE; //Flag Used in case of IBSS to Auto generate BSSID.
Jeff Johnson295189b2012-06-20 16:38:30 -0700534 tANI_U8 sessionId;
535 tpPESession psessionEntry = NULL;
536 tANI_U8 smesessionId;
537 tANI_U16 smetransactionId;
538
539#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM //FEATURE_WLAN_DIAG_SUPPORT
540 //Since the session is not created yet, sending NULL. The response should have the correct state.
541 limDiagEventReport(pMac, WLAN_PE_DIAG_START_BSS_REQ_EVENT, NULL, 0, 0);
542#endif //FEATURE_WLAN_DIAG_SUPPORT
543
Abhishek Singh3cbf6052014-12-15 16:46:42 +0530544 limLog(pMac, LOG1, FL("Received SME_START_BSS_REQ"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700545
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +0530546 /* Global Sme state and mlm states are not defined yet, for BT-AMP Suppoprt . TO BE DONE */
Jeff Johnson295189b2012-06-20 16:38:30 -0700547 if ( (pMac->lim.gLimSmeState == eLIM_SME_OFFLINE_STATE) ||
548 (pMac->lim.gLimSmeState == eLIM_SME_IDLE_STATE))
549 {
550 size = sizeof(tSirSmeStartBssReq) + SIR_MAC_MAX_IE_LENGTH;
551
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +0530552 pSmeStartBssReq = vos_mem_malloc(size);
553 if ( NULL == pSmeStartBssReq )
Jeff Johnson295189b2012-06-20 16:38:30 -0700554 {
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +0530555 PELOGE(limLog(pMac, LOGE, FL("AllocateMemory failed for pMac->lim.gpLimStartBssReq"));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700556 /// Send failure response to host
557 retCode = eSIR_SME_RESOURCES_UNAVAILABLE;
558 goto end;
559 }
560
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +0530561 vos_mem_set((void *)pSmeStartBssReq, size, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700562
563 if ((limStartBssReqSerDes(pMac, pSmeStartBssReq, (tANI_U8 *) pMsgBuf) == eSIR_FAILURE) ||
564 (!limIsSmeStartBssReqValid(pMac, pSmeStartBssReq)))
565 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700566 PELOGW(limLog(pMac, LOGW, FL("Received invalid eWNI_SME_START_BSS_REQ"));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700567 retCode = eSIR_SME_INVALID_PARAMETERS;
568 goto free;
569 }
570#if 0
571 PELOG3(limLog(pMac, LOG3,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700572 FL("Parsed START_BSS_REQ fields are bssType=%d, channelId=%d"),
Jeff Johnson295189b2012-06-20 16:38:30 -0700573 pMac->lim.gpLimStartBssReq->bssType, pMac->lim.gpLimStartBssReq->channelId);)
574#endif
575
576 /* This is the place where PE is going to create a session.
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +0530577 * If session is not existed, then create a new session */
Jeff Johnson295189b2012-06-20 16:38:30 -0700578 if((psessionEntry = peFindSessionByBssid(pMac,pSmeStartBssReq->bssId,&sessionId)) != NULL)
579 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700580 limLog(pMac, LOGW, FL("Session Already exists for given BSSID"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700581 retCode = eSIR_SME_BSS_ALREADY_STARTED_OR_JOINED;
582 psessionEntry = NULL;
583 goto free;
584 }
585 else
586 {
587 if((psessionEntry = peCreateSession(pMac,pSmeStartBssReq->bssId,&sessionId, pMac->lim.maxStation)) == NULL)
588 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700589 limLog(pMac, LOGW, FL("Session Can not be created "));
Jeff Johnson295189b2012-06-20 16:38:30 -0700590 retCode = eSIR_SME_RESOURCES_UNAVAILABLE;
591 goto free;
592 }
593
594 }
595
596 /* Store the session related parameters in newly created session */
597 psessionEntry->pLimStartBssReq = pSmeStartBssReq;
598
599 /* Store PE sessionId in session Table */
600 psessionEntry->peSessionId = sessionId;
601
602 /* Store SME session Id in sessionTable */
603 psessionEntry->smeSessionId = pSmeStartBssReq->sessionId;
604
605 psessionEntry->transactionId = pSmeStartBssReq->transactionId;
606
607 sirCopyMacAddr(psessionEntry->selfMacAddr,pSmeStartBssReq->selfMacAddr);
608
609 /* Copy SSID to session table */
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +0530610 vos_mem_copy( (tANI_U8 *)&psessionEntry->ssId,
Jeff Johnson295189b2012-06-20 16:38:30 -0700611 (tANI_U8 *)&pSmeStartBssReq->ssId,
612 (pSmeStartBssReq->ssId.length + 1));
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +0530613
Jeff Johnson295189b2012-06-20 16:38:30 -0700614 psessionEntry->bssType = pSmeStartBssReq->bssType;
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +0530615
Jeff Johnson295189b2012-06-20 16:38:30 -0700616 psessionEntry->nwType = pSmeStartBssReq->nwType;
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +0530617
Jeff Johnson295189b2012-06-20 16:38:30 -0700618 psessionEntry->beaconParams.beaconInterval = pSmeStartBssReq->beaconInterval;
619
620 /* Store the channel number in session Table */
621 psessionEntry->currentOperChannel = pSmeStartBssReq->channelId;
622
623 /*Store Persona */
624 psessionEntry->pePersona = pSmeStartBssReq->bssPersona;
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -0700625 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,FL("PE PERSONA=%d"),
Jeff Johnson295189b2012-06-20 16:38:30 -0700626 psessionEntry->pePersona);
627
628 /*Update the phymode*/
629 psessionEntry->gLimPhyMode = pSmeStartBssReq->nwType;
630
631 psessionEntry->maxTxPower = cfgGetRegulatoryMaxTransmitPower( pMac,
632 psessionEntry->currentOperChannel );
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +0530633
634#ifdef WLAN_FEATURE_AP_HT40_24G
635 /*Store Overlapping BSS Scan Parameters IEs to session table */
636 if (pSmeStartBssReq->apHT40_24GEnabled)
637 {
638 limInitOBSSScanParams(pMac, psessionEntry);
639 }
640#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700641 /* Store the dot 11 mode in to the session Table*/
642
643 psessionEntry->dot11mode = pSmeStartBssReq->dot11mode;
Jeff Johnsone7245742012-09-05 17:12:55 -0700644 psessionEntry->htCapability = IS_DOT11_MODE_HT(psessionEntry->dot11mode);
645#ifdef WLAN_FEATURE_11AC
646 psessionEntry->vhtCapability = IS_DOT11_MODE_VHT(psessionEntry->dot11mode);
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -0700647 VOS_TRACE(VOS_MODULE_ID_PE,VOS_TRACE_LEVEL_INFO,
648 FL("*****psessionEntry->vhtCapability = %d"),psessionEntry->vhtCapability);
Jeff Johnsone7245742012-09-05 17:12:55 -0700649#endif
Gopichand Nakkalab2d2c312013-01-04 11:41:02 -0800650
651 psessionEntry->txLdpcIniFeatureEnabled =
652 pSmeStartBssReq->txLdpcIniFeatureEnabled;
653
Chet Lanctot8cecea22014-02-11 19:09:36 -0800654#ifdef WLAN_FEATURE_11W
655 psessionEntry->limRmfEnabled = pSmeStartBssReq->pmfCapable ? 1 : 0;
656 limLog(pMac, LOG1, FL("Session RMF enabled: %d"), psessionEntry->limRmfEnabled);
657#endif
658
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +0530659 vos_mem_copy((void*)&psessionEntry->rateSet,
Jeff Johnson295189b2012-06-20 16:38:30 -0700660 (void*)&pSmeStartBssReq->operationalRateSet,
661 sizeof(tSirMacRateSet));
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +0530662 vos_mem_copy((void*)&psessionEntry->extRateSet,
Jeff Johnson295189b2012-06-20 16:38:30 -0700663 (void*)&pSmeStartBssReq->extendedRateSet,
664 sizeof(tSirMacRateSet));
665
666 switch(pSmeStartBssReq->bssType)
667 {
Jeff Johnson295189b2012-06-20 16:38:30 -0700668 case eSIR_INFRA_AP_MODE:
669 psessionEntry->limSystemRole = eLIM_AP_ROLE;
670 psessionEntry->privacy = pSmeStartBssReq->privacy;
671 psessionEntry->fwdWPSPBCProbeReq = pSmeStartBssReq->fwdWPSPBCProbeReq;
672 psessionEntry->authType = pSmeStartBssReq->authType;
673 /* Store the DTIM period */
674 psessionEntry->dtimPeriod = (tANI_U8)pSmeStartBssReq->dtimPeriod;
675 /*Enable/disable UAPSD*/
676 psessionEntry->apUapsdEnable = pSmeStartBssReq->apUapsdEnable;
677 if (psessionEntry->pePersona == VOS_P2P_GO_MODE)
678 {
679 psessionEntry->proxyProbeRspEn = 0;
680 }
681 else
682 {
683 /* To detect PBC overlap in SAP WPS mode, Host handles
684 * Probe Requests.
685 */
686 if(SAP_WPS_DISABLED == pSmeStartBssReq->wps_state)
687 {
688 psessionEntry->proxyProbeRspEn = 1;
689 }
690 else
691 {
692 psessionEntry->proxyProbeRspEn = 0;
693 }
694 }
695 psessionEntry->ssidHidden = pSmeStartBssReq->ssidHidden;
696 psessionEntry->wps_state = pSmeStartBssReq->wps_state;
krunal soni45b9eb62014-03-26 12:54:25 -0700697 limGetShortSlotFromPhyMode(pMac, psessionEntry,
698 psessionEntry->gLimPhyMode,
699 &psessionEntry->shortSlotTimeSupported);
Jeff Johnson295189b2012-06-20 16:38:30 -0700700 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700701 case eSIR_IBSS_MODE:
702 psessionEntry->limSystemRole = eLIM_STA_IN_IBSS_ROLE;
krunal soni45b9eb62014-03-26 12:54:25 -0700703 limGetShortSlotFromPhyMode(pMac, psessionEntry,
704 psessionEntry->gLimPhyMode,
705 &psessionEntry->shortSlotTimeSupported);
Abhishek Singhd5c31272014-03-07 14:46:50 +0530706 /* In WPA-NONE case we wont get the privacy bit in ibss config
707 * from supplicant, but we are updating WNI_CFG_PRIVACY_ENABLED
708 * on basis of Encryption type in csrRoamSetBssConfigCfg. So
709 * get the privacy info from WNI_CFG_PRIVACY_ENABLED
710 */
711 if (wlan_cfgGetInt(pMac, WNI_CFG_PRIVACY_ENABLED, &val)
712 != eSIR_SUCCESS)
713 limLog(pMac, LOGE, FL("cfg get WNI_CFG_PRIVACY_ENABLED"
714 " failed"));
715 psessionEntry->privacy =(tANI_U8) val;
krunal sonie9002db2013-11-25 14:24:17 -0800716 psessionEntry->isCoalesingInIBSSAllowed =
717 pSmeStartBssReq->isCoalesingInIBSSAllowed;
Jeff Johnson295189b2012-06-20 16:38:30 -0700718 break;
719
720 case eSIR_BTAMP_AP_MODE:
721 psessionEntry->limSystemRole = eLIM_BT_AMP_AP_ROLE;
722 break;
723
724 case eSIR_BTAMP_STA_MODE:
725 psessionEntry->limSystemRole = eLIM_BT_AMP_STA_ROLE;
726 break;
727
728 /* There is one more mode called auto mode. which is used no where */
729
730 //FORBUILD -TEMPFIX.. HOW TO use AUTO MODE?????
731
732
733 default:
734 //not used anywhere...used in scan function
735 break;
736 }
737
738 // BT-AMP: Allocate memory for the array of parsed (Re)Assoc request structure
739 if ( (pSmeStartBssReq->bssType == eSIR_BTAMP_AP_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -0700740 || (pSmeStartBssReq->bssType == eSIR_INFRA_AP_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -0700741 )
742 {
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +0530743 psessionEntry->parsedAssocReq = vos_mem_malloc(
744 psessionEntry->dph.dphHashTable.size * sizeof(tpSirAssocReq));
745 if ( NULL == psessionEntry->parsedAssocReq )
Jeff Johnson295189b2012-06-20 16:38:30 -0700746 {
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +0530747 limLog(pMac, LOGW, FL("AllocateMemory() failed"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700748 retCode = eSIR_SME_RESOURCES_UNAVAILABLE;
749 goto free;
750 }
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +0530751 vos_mem_set(psessionEntry->parsedAssocReq,
752 (psessionEntry->dph.dphHashTable.size * sizeof(tpSirAssocReq)),
753 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -0700754 }
755
756 /* Channel Bonding is not addressd yet for BT-AMP Support.. sunit will address channel bonding */
757 if (pSmeStartBssReq->channelId)
758 {
759 channelNumber = pSmeStartBssReq->channelId;
Jeff Johnsone7245742012-09-05 17:12:55 -0700760 psessionEntry->htSupportedChannelWidthSet = (pSmeStartBssReq->cbMode)?1:0; // This is already merged value of peer and self - done by csr in csrGetCBModeFromIes
761 psessionEntry->htRecommendedTxWidthSet = psessionEntry->htSupportedChannelWidthSet;
762 psessionEntry->htSecondaryChannelOffset = pSmeStartBssReq->cbMode;
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -0700763 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
Jeff Johnsone7245742012-09-05 17:12:55 -0700764 FL("cbMode %u"), pSmeStartBssReq->cbMode);
765#ifdef WLAN_FEATURE_11AC
766 if(psessionEntry->vhtCapability)
767 {
768 tANI_U32 centerChan;
769 tANI_U32 chanWidth;
Jeff Johnson295189b2012-06-20 16:38:30 -0700770
Jeff Johnsone7245742012-09-05 17:12:55 -0700771 if (wlan_cfgGetInt(pMac, WNI_CFG_VHT_CHANNEL_WIDTH,
772 &chanWidth) != eSIR_SUCCESS)
Jeff Johnson295189b2012-06-20 16:38:30 -0700773 {
Jeff Johnsone7245742012-09-05 17:12:55 -0700774 limLog(pMac, LOGP,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700775 FL("Unable to retrieve Channel Width from CFG"));
Jeff Johnsone7245742012-09-05 17:12:55 -0700776 }
Abhishek Singhb92f70c2014-04-28 12:13:08 +0530777
Abhishek Singh921926b2014-02-13 17:21:01 +0530778 if(channelNumber <= RF_CHAN_14 &&
Abhishek Singhb92f70c2014-04-28 12:13:08 +0530779 chanWidth != eHT_CHANNEL_WIDTH_20MHZ)
Jeff Johnsone7245742012-09-05 17:12:55 -0700780 {
Abhishek Singhb92f70c2014-04-28 12:13:08 +0530781 chanWidth = eHT_CHANNEL_WIDTH_20MHZ;
Abhishek Singh921926b2014-02-13 17:21:01 +0530782 limLog(pMac, LOG1, FL("Setting chanWidth to 20Mhz for"
783 " channel %d"),channelNumber);
Jeff Johnson295189b2012-06-20 16:38:30 -0700784 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700785
Abhishek Singhb92f70c2014-04-28 12:13:08 +0530786 if(chanWidth == eHT_CHANNEL_WIDTH_20MHZ ||
787 chanWidth == eHT_CHANNEL_WIDTH_40MHZ)
Abhishek Singh921926b2014-02-13 17:21:01 +0530788 {
Abhishek Singhb92f70c2014-04-28 12:13:08 +0530789 if (cfgSetInt(pMac, WNI_CFG_VHT_CHANNEL_WIDTH,
790 WNI_CFG_VHT_CHANNEL_WIDTH_20_40MHZ)
791 != eSIR_SUCCESS)
792 {
793 limLog(pMac, LOGP, FL("could not set "
794 " WNI_CFG_CHANNEL_BONDING_MODE at CFG"));
795 retCode = eSIR_LOGP_EXCEPTION;
796 goto free;
797 }
798 }
799 if (chanWidth == eHT_CHANNEL_WIDTH_80MHZ)
800 {
801 if (cfgSetInt(pMac, WNI_CFG_VHT_CHANNEL_WIDTH,
802 WNI_CFG_VHT_CHANNEL_WIDTH_80MHZ)
803 != eSIR_SUCCESS)
804 {
805 limLog(pMac, LOGP, FL("could not set "
806 " WNI_CFG_CHANNEL_BONDING_MODE at CFG"));
807 retCode = eSIR_LOGP_EXCEPTION;
808 goto free;
809 }
810
811 centerChan = limGetCenterChannel( pMac, channelNumber,
812 pSmeStartBssReq->cbMode,
813 WNI_CFG_VHT_CHANNEL_WIDTH_80MHZ);
Jeff Johnsone7245742012-09-05 17:12:55 -0700814 if(centerChan != eSIR_CFG_INVALID_ID)
815 {
Abhishek Singhb92f70c2014-04-28 12:13:08 +0530816 limLog(pMac, LOGW, FL("***Center Channel for "
817 "80MHZ channel width = %d"),centerChan);
Madan Mohan Koyyalamudi8b152b82012-10-18 20:56:27 -0700818 psessionEntry->apCenterChan = centerChan;
Abhishek Singh921926b2014-02-13 17:21:01 +0530819 if (cfgSetInt(pMac,
Abhishek Singhb92f70c2014-04-28 12:13:08 +0530820 WNI_CFG_VHT_CHANNEL_CENTER_FREQ_SEGMENT1,
821 centerChan) != eSIR_SUCCESS)
Jeff Johnsone7245742012-09-05 17:12:55 -0700822 {
Abhishek Singh921926b2014-02-13 17:21:01 +0530823 limLog(pMac, LOGP, FL("could not set "
Abhishek Singhb92f70c2014-04-28 12:13:08 +0530824 "WNI_CFG_CHANNEL_BONDING_MODE at CFG"));
Jeff Johnsone7245742012-09-05 17:12:55 -0700825 retCode = eSIR_LOGP_EXCEPTION;
826 goto free;
827 }
828 }
829 }
830
Abhishek Singhb92f70c2014-04-28 12:13:08 +0530831 /* All the translation is done by now for gVhtChannelWidth
832 * from .ini file to the actual values as defined in spec.
833 * So, grabing the spec value which is
834 * updated in .dat file by the above logic */
835 if (wlan_cfgGetInt(pMac, WNI_CFG_VHT_CHANNEL_WIDTH,
836 &chanWidth) != eSIR_SUCCESS)
837 {
838 limLog(pMac, LOGP,
839 FL("Unable to retrieve Channel Width from CFG"));
840 }
Madan Mohan Koyyalamudi8b152b82012-10-18 20:56:27 -0700841 /*For Sta+p2p-Go concurrency
842 vhtTxChannelWidthSet is used for storing p2p-GO channel width
843 apChanWidth is used for storing the AP channel width that the Sta is going to associate.
844 Initialize the apChanWidth same as p2p-GO channel width this gets over written once the station joins the AP
845 */
Jeff Johnsone7245742012-09-05 17:12:55 -0700846 psessionEntry->vhtTxChannelWidthSet = chanWidth;
Madan Mohan Koyyalamudi8b152b82012-10-18 20:56:27 -0700847 psessionEntry->apChanWidth = chanWidth;
Jeff Johnsone7245742012-09-05 17:12:55 -0700848 }
849 psessionEntry->htSecondaryChannelOffset = limGetHTCBState(pSmeStartBssReq->cbMode);
850#endif
851 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700852 else
853 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700854 PELOGW(limLog(pMac, LOGW, FL("Received invalid eWNI_SME_START_BSS_REQ"));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700855 retCode = eSIR_SME_INVALID_PARAMETERS;
856 goto free;
857 }
858
859 // Delete pre-auth list if any
860 limDeletePreAuthList(pMac);
861
862 // Delete IBSS peer BSSdescription list if any
863 //limIbssDelete(pMac); sep 26 review
864
865
866
867#ifdef FIXME_GEN6 //following code may not be required. limInitMlm is now being invoked during peStart
868 /// Initialize MLM state machine
Jeff Johnson295189b2012-06-20 16:38:30 -0700869 limInitMlm(pMac);
870#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700871
Jeff Johnsone7245742012-09-05 17:12:55 -0700872 psessionEntry->htCapability = IS_DOT11_MODE_HT(pSmeStartBssReq->dot11mode);
Jeff Johnson295189b2012-06-20 16:38:30 -0700873
Jeff Johnson295189b2012-06-20 16:38:30 -0700874 /* keep the RSN/WPA IE information in PE Session Entry
875 * later will be using this to check when received (Re)Assoc req
876 * */
877 limSetRSNieWPAiefromSmeStartBSSReqMessage(pMac,&pSmeStartBssReq->rsnIE,psessionEntry);
878
Jeff Johnson295189b2012-06-20 16:38:30 -0700879
Jeff Johnson295189b2012-06-20 16:38:30 -0700880 //Taken care for only softAP case rest need to be done
881 if (psessionEntry->limSystemRole == eLIM_AP_ROLE){
882 psessionEntry->gLimProtectionControl = pSmeStartBssReq->protEnabled;
883 /*each byte will have the following info
884 *bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0
885 *reserved reserved RIFS Lsig n-GF ht20 11g 11b*/
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +0530886 vos_mem_copy( (void *) &psessionEntry->cfgProtection,
Jeff Johnson295189b2012-06-20 16:38:30 -0700887 (void *) &pSmeStartBssReq->ht_capab,
Kiran Kumar Lokerea4db3dc2013-03-25 18:05:24 -0700888 sizeof( tANI_U16 ));
Jeff Johnson295189b2012-06-20 16:38:30 -0700889 psessionEntry->pAPWPSPBCSession = NULL; // Initialize WPS PBC session link list
890 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700891
892 // Prepare and Issue LIM_MLM_START_REQ to MLM
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +0530893 pMlmStartReq = vos_mem_malloc(sizeof(tLimMlmStartReq));
894 if ( NULL == pMlmStartReq )
Jeff Johnson295189b2012-06-20 16:38:30 -0700895 {
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +0530896 limLog(pMac, LOGP, FL("call to AllocateMemory failed for mlmStartReq"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700897 retCode = eSIR_SME_RESOURCES_UNAVAILABLE;
898 goto free;
899 }
900
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +0530901 vos_mem_set((void *) pMlmStartReq, sizeof(tLimMlmStartReq), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700902
903 /* Copy SSID to the MLM start structure */
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +0530904 vos_mem_copy( (tANI_U8 *) &pMlmStartReq->ssId,
Jeff Johnson295189b2012-06-20 16:38:30 -0700905 (tANI_U8 *) &pSmeStartBssReq->ssId,
906 pSmeStartBssReq->ssId.length + 1);
Jeff Johnson295189b2012-06-20 16:38:30 -0700907 pMlmStartReq->ssidHidden = pSmeStartBssReq->ssidHidden;
908 pMlmStartReq->obssProtEnabled = pSmeStartBssReq->obssProtEnabled;
Jeff Johnson295189b2012-06-20 16:38:30 -0700909
910
911 pMlmStartReq->bssType = psessionEntry->bssType;
912
913 /* Fill PE session Id from the session Table */
914 pMlmStartReq->sessionId = psessionEntry->peSessionId;
915
916 if( (pMlmStartReq->bssType == eSIR_BTAMP_STA_MODE) || (pMlmStartReq->bssType == eSIR_BTAMP_AP_MODE )
Jeff Johnson295189b2012-06-20 16:38:30 -0700917 || (pMlmStartReq->bssType == eSIR_INFRA_AP_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -0700918 )
919 {
920 //len = sizeof(tSirMacAddr);
921 //retStatus = wlan_cfgGetStr(pMac, WNI_CFG_STA_ID, (tANI_U8 *) pMlmStartReq->bssId, &len);
922 //if (retStatus != eSIR_SUCCESS)
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700923 //limLog(pMac, LOGP, FL("could not retrive BSSID, retStatus=%d"), retStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -0700924
925 /* Copy the BSSId from sessionTable to mlmStartReq struct */
926 sirCopyMacAddr(pMlmStartReq->bssId,psessionEntry->bssId);
927 }
928
929 else // ibss mode
930 {
931 pMac->lim.gLimIbssCoalescingHappened = false;
932
933 if((retStatus = wlan_cfgGetInt(pMac, WNI_CFG_IBSS_AUTO_BSSID, &autoGenBssId)) != eSIR_SUCCESS)
934 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700935 limLog(pMac, LOGP, FL("Could not retrieve Auto Gen BSSID, retStatus=%d"), retStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -0700936 retCode = eSIR_LOGP_EXCEPTION;
937 goto free;
938 }
939
940 if(!autoGenBssId)
941 {
942 // We're not auto generating BSSID. Instead, get it from session entry
943 sirCopyMacAddr(pMlmStartReq->bssId,psessionEntry->bssId);
944
945 if(pMlmStartReq->bssId[0] & 0x01)
946 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700947 PELOGE(limLog(pMac, LOGE, FL("Request to start IBSS with group BSSID\n Autogenerating the BSSID"));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700948 autoGenBssId = TRUE;
949 }
950 }
951
952 if( autoGenBssId )
953 { //if BSSID is not any uc id. then use locally generated BSSID.
954 //Autogenerate the BSSID
955 limGetRandomBssid( pMac, pMlmStartReq->bssId);
956 pMlmStartReq->bssId[0]= 0x02;
957
958 /* Copy randomly generated BSSID to the session Table */
959 sirCopyMacAddr(psessionEntry->bssId,pMlmStartReq->bssId);
960 }
961 }
962 /* store the channel num in mlmstart req structure */
963 pMlmStartReq->channelNumber = psessionEntry->currentOperChannel;
964 pMlmStartReq->cbMode = pSmeStartBssReq->cbMode;
965 pMlmStartReq->beaconPeriod = psessionEntry->beaconParams.beaconInterval;
966
Jeff Johnson295189b2012-06-20 16:38:30 -0700967 if(psessionEntry->limSystemRole == eLIM_AP_ROLE ){
968 pMlmStartReq->dtimPeriod = psessionEntry->dtimPeriod;
969 pMlmStartReq->wps_state = psessionEntry->wps_state;
970
971 }else
Jeff Johnson295189b2012-06-20 16:38:30 -0700972 {
973 if (wlan_cfgGetInt(pMac, WNI_CFG_DTIM_PERIOD, &val) != eSIR_SUCCESS)
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700974 limLog(pMac, LOGP, FL("could not retrieve DTIM Period"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700975 pMlmStartReq->dtimPeriod = (tANI_U8)val;
976 }
977
978 if (wlan_cfgGetInt(pMac, WNI_CFG_CFP_PERIOD, &val) != eSIR_SUCCESS)
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700979 limLog(pMac, LOGP, FL("could not retrieve Beacon interval"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700980 pMlmStartReq->cfParamSet.cfpPeriod = (tANI_U8)val;
981
982 if (wlan_cfgGetInt(pMac, WNI_CFG_CFP_MAX_DURATION, &val) != eSIR_SUCCESS)
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700983 limLog(pMac, LOGP, FL("could not retrieve CFPMaxDuration"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700984 pMlmStartReq->cfParamSet.cfpMaxDuration = (tANI_U16) val;
985
986 //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 +0530987 vos_mem_copy((void*)&pMlmStartReq->rateSet, (void*)&psessionEntry->rateSet,
Jeff Johnson295189b2012-06-20 16:38:30 -0700988 sizeof(tSirMacRateSet));
989
Jeff Johnson295189b2012-06-20 16:38:30 -0700990 // Now populate the 11n related parameters
991 pMlmStartReq->nwType = psessionEntry->nwType;
Jeff Johnsone7245742012-09-05 17:12:55 -0700992 pMlmStartReq->htCapable = psessionEntry->htCapability;
Jeff Johnson295189b2012-06-20 16:38:30 -0700993 //
994 // FIXME_GEN4 - Determine the appropriate defaults...
995 //
996 pMlmStartReq->htOperMode = pMac->lim.gHTOperMode;
997 pMlmStartReq->dualCTSProtection = pMac->lim.gHTDualCTSProtection; // Unused
Jeff Johnsone7245742012-09-05 17:12:55 -0700998 pMlmStartReq->txChannelWidthSet = psessionEntry->htRecommendedTxWidthSet;
Jeff Johnson295189b2012-06-20 16:38:30 -0700999
1000 /* sep26 review */
1001 psessionEntry->limRFBand = limGetRFBand(channelNumber);
1002
1003 // Initialize 11h Enable Flag
1004 psessionEntry->lim11hEnable = 0;
1005 if((pMlmStartReq->bssType != eSIR_IBSS_MODE) &&
1006 (SIR_BAND_5_GHZ == psessionEntry->limRFBand) )
1007 {
1008 if (wlan_cfgGetInt(pMac, WNI_CFG_11H_ENABLED, &val) != eSIR_SUCCESS)
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001009 limLog(pMac, LOGP, FL("Fail to get WNI_CFG_11H_ENABLED "));
Jeff Johnson295189b2012-06-20 16:38:30 -07001010 psessionEntry->lim11hEnable = val;
1011 }
1012
1013 if (!psessionEntry->lim11hEnable)
1014 {
1015 if (cfgSetInt(pMac, WNI_CFG_LOCAL_POWER_CONSTRAINT, 0) != eSIR_SUCCESS)
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001016 limLog(pMac, LOGP, FL("Fail to get WNI_CFG_11H_ENABLED "));
Jeff Johnson295189b2012-06-20 16:38:30 -07001017 }
1018
Jeff Johnson295189b2012-06-20 16:38:30 -07001019 psessionEntry ->limPrevSmeState = psessionEntry->limSmeState;
1020 psessionEntry ->limSmeState = eLIM_SME_WT_START_BSS_STATE;
Jeff Johnsone7245742012-09-05 17:12:55 -07001021 MTRACE(macTrace(pMac, TRACE_CODE_SME_STATE, psessionEntry->peSessionId, psessionEntry ->limSmeState));
Jeff Johnson295189b2012-06-20 16:38:30 -07001022
1023 limPostMlmMessage(pMac, LIM_MLM_START_REQ, (tANI_U32 *) pMlmStartReq);
1024 return;
1025 }
1026 else
1027 {
1028
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001029 limLog(pMac, LOGE, FL("Received unexpected START_BSS_REQ, in state %X"),pMac->lim.gLimSmeState);
Jeff Johnson295189b2012-06-20 16:38:30 -07001030 retCode = eSIR_SME_BSS_ALREADY_STARTED_OR_JOINED;
1031 goto end;
1032 } // if (pMac->lim.gLimSmeState == eLIM_SME_OFFLINE_STATE)
1033
1034free:
Jeff Johnsonace91102013-04-05 08:03:18 -07001035 if ((psessionEntry != NULL) &&
1036 (psessionEntry->pLimStartBssReq == pSmeStartBssReq))
1037 {
1038 psessionEntry->pLimStartBssReq = NULL;
1039 }
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301040 vos_mem_free( pSmeStartBssReq);
1041 vos_mem_free( pMlmStartReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07001042
1043end:
1044
1045 /* This routine should return the sme sessionId and SME transaction Id */
1046 limGetSessionInfo(pMac,(tANI_U8*)pMsgBuf,&smesessionId,&smetransactionId);
1047
1048 if(NULL != psessionEntry)
1049 {
1050 peDeleteSession(pMac,psessionEntry);
1051 psessionEntry = NULL;
1052 }
1053 limSendSmeStartBssRsp(pMac, eWNI_SME_START_BSS_RSP, retCode,psessionEntry,smesessionId,smetransactionId);
1054} /*** end __limHandleSmeStartBssRequest() ***/
1055
1056
1057/**--------------------------------------------------------------
1058\fn __limProcessSmeStartBssReq
1059
1060\brief Wrapper for the function __limHandleSmeStartBssRequest
1061 This message will be defered until softmac come out of
1062 scan mode or if we have detected radar on the current
1063 operating channel.
1064\param pMac
1065\param pMsg
1066
1067\return TRUE - If we consumed the buffer
1068 FALSE - If have defered the message.
1069 ---------------------------------------------------------------*/
1070static tANI_BOOLEAN
1071__limProcessSmeStartBssReq(tpAniSirGlobal pMac, tpSirMsgQ pMsg)
1072{
1073 if (__limIsDeferedMsgForLearn(pMac, pMsg) ||
1074 __limIsDeferedMsgForRadar(pMac, pMsg))
1075 {
1076 /**
1077 * If message defered, buffer is not consumed yet.
1078 * So return false
1079 */
1080 return eANI_BOOLEAN_FALSE;
1081 }
1082
1083 __limHandleSmeStartBssRequest(pMac, (tANI_U32 *) pMsg->bodyptr);
1084 return eANI_BOOLEAN_TRUE;
1085}
1086
1087
1088/**
1089 * limGetRandomBssid()
1090 *
1091 * FUNCTION:This function is called to process generate the random number for bssid
1092 * This function is called to process SME_SCAN_REQ message
1093 * from HDD or upper layer application.
1094 *
1095 * LOGIC:
1096 *
1097 * ASSUMPTIONS:
1098 *
1099 * NOTE:
1100 * 1. geneartes the unique random number for bssid in ibss
1101 *
1102 * @param pMac Pointer to Global MAC structure
1103 * @param *data Pointer to bssid buffer
1104 * @return None
1105 */
1106void limGetRandomBssid(tpAniSirGlobal pMac, tANI_U8 *data)
1107{
1108 tANI_U32 random[2] ;
1109 random[0] = tx_time_get();
1110 random[0] |= (random[0] << 15) ;
1111 random[1] = random[0] >> 1;
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301112 vos_mem_copy( data, (tANI_U8*)random, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07001113}
1114
Ganesh Kondabattinif0fa07c2013-06-11 17:47:49 +05301115static eHalStatus limSendHalStartScanOffloadReq(tpAniSirGlobal pMac,
1116 tpSirSmeScanReq pScanReq)
1117{
1118 tSirScanOffloadReq *pScanOffloadReq;
1119 tANI_U8 *p;
1120 tSirMsgQ msg;
Ganesh Kondabattinif0fa07c2013-06-11 17:47:49 +05301121 tANI_U16 i, len;
1122 tSirRetStatus rc = eSIR_SUCCESS;
1123
1124 /* The tSirScanOffloadReq will reserve the space for first channel,
1125 so allocate the memory for (numChannels - 1) and uIEFieldLen */
1126 len = sizeof(tSirScanOffloadReq) + (pScanReq->channelList.numChannels - 1) +
1127 pScanReq->uIEFieldLen;
1128
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301129 pScanOffloadReq = vos_mem_malloc(len);
1130 if ( NULL == pScanOffloadReq )
Ganesh Kondabattinif0fa07c2013-06-11 17:47:49 +05301131 {
1132 limLog(pMac, LOGE,
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301133 FL("AllocateMemory failed for pScanOffloadReq"));
Ganesh Kondabattinif0fa07c2013-06-11 17:47:49 +05301134 return eHAL_STATUS_FAILURE;
1135 }
1136
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301137 vos_mem_set( (tANI_U8 *) pScanOffloadReq, len, 0);
Ganesh Kondabattinif0fa07c2013-06-11 17:47:49 +05301138
1139 msg.type = WDA_START_SCAN_OFFLOAD_REQ;
1140 msg.bodyptr = pScanOffloadReq;
1141 msg.bodyval = 0;
1142
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301143 vos_mem_copy((tANI_U8 *) pScanOffloadReq->bssId,
Ganesh Kondabattinif0fa07c2013-06-11 17:47:49 +05301144 (tANI_U8*) pScanReq->bssId,
1145 sizeof(tSirMacAddr));
1146
1147 if (pScanReq->numSsid > SIR_SCAN_MAX_NUM_SSID)
1148 {
1149 limLog(pMac, LOGE,
1150 FL("Invalid value (%d) for numSsid"), SIR_SCAN_MAX_NUM_SSID);
Kiet Lamb1233192013-11-28 13:38:20 +05301151 vos_mem_free (pScanOffloadReq);
Ganesh Kondabattinif0fa07c2013-06-11 17:47:49 +05301152 return eHAL_STATUS_FAILURE;
1153 }
1154
1155 pScanOffloadReq->numSsid = pScanReq->numSsid;
1156 for (i = 0; i < pScanOffloadReq->numSsid; i++)
1157 {
1158 pScanOffloadReq->ssId[i].length = pScanReq->ssId[i].length;
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301159 vos_mem_copy((tANI_U8 *) pScanOffloadReq->ssId[i].ssId,
Ganesh Kondabattinif0fa07c2013-06-11 17:47:49 +05301160 (tANI_U8 *) pScanReq->ssId[i].ssId,
1161 pScanOffloadReq->ssId[i].length);
1162 }
1163
1164 pScanOffloadReq->hiddenSsid = pScanReq->hiddenSsid;
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301165 vos_mem_copy((tANI_U8 *) pScanOffloadReq->selfMacAddr,
Ganesh Kondabattinif0fa07c2013-06-11 17:47:49 +05301166 (tANI_U8 *) pScanReq->selfMacAddr,
1167 sizeof(tSirMacAddr));
1168 pScanOffloadReq->bssType = pScanReq->bssType;
1169 pScanOffloadReq->dot11mode = pScanReq->dot11mode;
1170 pScanOffloadReq->scanType = pScanReq->scanType;
1171 pScanOffloadReq->minChannelTime = pScanReq->minChannelTime;
1172 pScanOffloadReq->maxChannelTime = pScanReq->maxChannelTime;
1173 pScanOffloadReq->p2pSearch = pScanReq->p2pSearch;
1174 pScanOffloadReq->sessionId = pScanReq->sessionId;
1175 pScanOffloadReq->channelList.numChannels =
1176 pScanReq->channelList.numChannels;
1177 p = &(pScanOffloadReq->channelList.channelNumber[0]);
1178 for (i = 0; i < pScanOffloadReq->channelList.numChannels; i++)
1179 p[i] = pScanReq->channelList.channelNumber[i];
1180
1181 pScanOffloadReq->uIEFieldLen = pScanReq->uIEFieldLen;
1182 pScanOffloadReq->uIEFieldOffset = len - pScanOffloadReq->uIEFieldLen;
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301183 vos_mem_copy((tANI_U8 *) p + i,
Ganesh Kondabattinif0fa07c2013-06-11 17:47:49 +05301184 (tANI_U8 *) pScanReq + pScanReq->uIEFieldOffset,
1185 pScanOffloadReq->uIEFieldLen);
1186
1187 rc = wdaPostCtrlMsg(pMac, &msg);
1188 if (rc != eSIR_SUCCESS)
1189 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001190 limLog(pMac, LOGE, FL("wdaPostCtrlMsg() return failure"));
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301191 vos_mem_free(pScanOffloadReq);
Ganesh Kondabattinif0fa07c2013-06-11 17:47:49 +05301192 return eHAL_STATUS_FAILURE;
1193 }
Rashmi Ramanna6c13a342014-01-07 11:44:07 +05301194 limLog(pMac, LOG1, FL("Processed Offload Scan Request Successfully"));
Ganesh Kondabattinif0fa07c2013-06-11 17:47:49 +05301195
1196 return eHAL_STATUS_SUCCESS;
1197}
Jeff Johnson295189b2012-06-20 16:38:30 -07001198
1199/**
1200 * __limProcessSmeScanReq()
1201 *
1202 *FUNCTION:
1203 * This function is called to process SME_SCAN_REQ message
1204 * from HDD or upper layer application.
1205 *
1206 *LOGIC:
1207 *
1208 *ASSUMPTIONS:
1209 *
1210 *NOTE:
1211 * 1. Periodic scanning should be requesting to return unique
1212 * scan results.
1213 *
1214 * @param pMac Pointer to Global MAC structure
1215 * @param *pMsgBuf A pointer to the SME message buffer
1216 * @return None
1217 */
1218
Viral Modid440e682013-03-06 02:25:31 -08001219static void
Jeff Johnson295189b2012-06-20 16:38:30 -07001220__limProcessSmeScanReq(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
1221{
1222 tANI_U32 len;
1223 tLimMlmScanReq *pMlmScanReq;
1224 tpSirSmeScanReq pScanReq;
1225 tANI_U8 i = 0;
1226
Sushant Kaushikb97a0082015-08-31 12:36:45 +05301227#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM //FEATURE_WLAN_DIAG_SUPPORT
Jeff Johnson295189b2012-06-20 16:38:30 -07001228 limDiagEventReport(pMac, WLAN_PE_DIAG_SCAN_REQ_EVENT, NULL, 0, 0);
1229#endif //FEATURE_WLAN_DIAG_SUPPORT
1230
1231 pScanReq = (tpSirSmeScanReq) pMsgBuf;
Sushant Kaushike0d2cce2014-04-10 14:36:07 +05301232 limLog(pMac, LOG1,FL("SME SCAN REQ numChan %d min %d max %d IELen %d"
1233 "first %d fresh %d unique %d type %s (%d)"
1234 " mode %s (%d)rsp %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07001235 pScanReq->channelList.numChannels,
1236 pScanReq->minChannelTime,
1237 pScanReq->maxChannelTime,
1238 pScanReq->uIEFieldLen,
1239 pScanReq->returnAfterFirstMatch,
1240 pScanReq->returnFreshResults,
1241 pScanReq->returnUniqueResults,
Sushant Kaushike0d2cce2014-04-10 14:36:07 +05301242 lim_ScanTypetoString(pScanReq->scanType),
Madan Mohan Koyyalamudi70bb4cb2012-10-18 19:31:25 -07001243 pScanReq->scanType,
Sushant Kaushike0d2cce2014-04-10 14:36:07 +05301244 lim_BackgroundScanModetoString(pScanReq->backgroundScanMode),
1245 pScanReq->backgroundScanMode, pMac->lim.gLimRspReqd ? 1 : 0);
Viral Modid86bde22012-12-10 13:09:21 -08001246
1247 /* Since scan req always requires a response, we will overwrite response required here.
1248 * This is added esp to take care of the condition where in p2p go case, we hold the scan req and
1249 * insert single NOA. We send the held scan request to FW later on getting start NOA ind from FW so
1250 * we lose state of the gLimRspReqd flag for the scan req if any other request comes by then.
1251 * e.g. While unit testing, we found when insert single NOA is done, we see a get stats request which turns the flag
1252 * gLimRspReqd to FALSE; now when we actually start the saved scan req for init scan after getting
1253 * NOA started, the gLimRspReqd being a global flag is showing FALSE instead of TRUE value for
1254 * this saved scan req. Since all scan reqs coming to lim require a response, there is no harm in setting
1255 * the global flag gLimRspReqd to TRUE here.
1256 */
1257 pMac->lim.gLimRspReqd = TRUE;
1258
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301259 /*copy the Self MAC address from SmeReq to the globalplace, used for sending probe req*/
Jeff Johnson295189b2012-06-20 16:38:30 -07001260 sirCopyMacAddr(pMac->lim.gSelfMacAddr, pScanReq->selfMacAddr);
1261
Abhishek Singhdaf95742015-10-13 14:53:21 +05301262 /* Check if scan req is not valid or link is already suspended*/
1263 if (!limIsSmeScanReqValid(pMac, pScanReq) || limIsLinkSuspended(pMac))
Jeff Johnson295189b2012-06-20 16:38:30 -07001264 {
Abhishek Singhdaf95742015-10-13 14:53:21 +05301265 limLog(pMac, LOGE,
1266 FL("Received SME_SCAN_REQ with invalid params or link is suspended %d"),
1267 limIsLinkSuspended(pMac));
Jeff Johnson295189b2012-06-20 16:38:30 -07001268
1269 if (pMac->lim.gLimRspReqd)
1270 {
1271 pMac->lim.gLimRspReqd = false;
1272
1273 limSendSmeScanRsp(pMac, sizeof(tSirSmeScanRsp), eSIR_SME_INVALID_PARAMETERS, pScanReq->sessionId, pScanReq->transactionId);
1274
1275 } // if (pMac->lim.gLimRspReqd)
1276
1277 return;
1278 }
1279
1280 //if scan is disabled then return as invalid scan request.
1281 //if scan in power save is disabled, and system is in power save mode, then ignore scan request.
1282 if( (pMac->lim.fScanDisabled) || (!pMac->lim.gScanInPowersave && !limIsSystemInActiveState(pMac)) )
1283 {
Rashmi Ramanna6c13a342014-01-07 11:44:07 +05301284 limLog(pMac, LOGE, FL("SCAN is disabled or SCAN in power save"
1285 " is disabled and system is in power save."));
Leela V Kiran Kumar Reddy Chirala6a458752013-02-16 15:41:27 -08001286 limSendSmeScanRsp(pMac, offsetof(tSirSmeScanRsp,bssDescription[0]), eSIR_SME_INVALID_PARAMETERS, pScanReq->sessionId, pScanReq->transactionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07001287 return;
1288 }
1289
1290
1291 /**
1292 * If scan request is received in idle, joinFailed
1293 * states or in link established state (in STA role)
1294 * or in normal state (in STA-in-IBSS/AP role) with
1295 * 'return fresh scan results' request from HDD or
1296 * it is periodic background scanning request,
1297 * trigger fresh scan request to MLM
1298 */
1299 if (__limFreshScanReqd(pMac, pScanReq->returnFreshResults))
1300 {
Ganesh Kondabattinif0fa07c2013-06-11 17:47:49 +05301301 if (pScanReq->returnFreshResults & SIR_BG_SCAN_PURGE_RESUTLS)
1302 {
1303 // Discard previously cached scan results
1304 limReInitScanResults(pMac);
1305 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001306
Ganesh Kondabattinif0fa07c2013-06-11 17:47:49 +05301307 pMac->lim.gLim24Band11dScanDone = 0;
1308 pMac->lim.gLim50Band11dScanDone = 0;
1309 pMac->lim.gLimReturnAfterFirstMatch =
1310 pScanReq->returnAfterFirstMatch;
1311 pMac->lim.gLimBackgroundScanMode =
1312 pScanReq->backgroundScanMode;
Jeff Johnson295189b2012-06-20 16:38:30 -07001313
Ganesh Kondabattinif0fa07c2013-06-11 17:47:49 +05301314 pMac->lim.gLimReturnUniqueResults =
1315 ((pScanReq->returnUniqueResults) > 0 ? true : false);
1316 /* De-activate Heartbeat timers for connected sessions while
1317 * scan is in progress if the system is in Active mode *
1318 * AND it is not a ROAMING ("background") scan */
1319 if(((ePMM_STATE_BMPS_WAKEUP == pMac->pmm.gPmmState) ||
1320 (ePMM_STATE_READY == pMac->pmm.gPmmState)) &&
1321 (pScanReq->backgroundScanMode != eSIR_ROAMING_SCAN ) &&
1322 (!IS_ACTIVEMODE_OFFLOAD_FEATURE_ENABLE))
1323 {
Jeff Johnson295189b2012-06-20 16:38:30 -07001324 for(i=0;i<pMac->lim.maxBssId;i++)
1325 {
Ganesh Kondabattinif0fa07c2013-06-11 17:47:49 +05301326 if((peFindSessionBySessionId(pMac,i) != NULL) &&
1327 (pMac->lim.gpSession[i].valid == TRUE) &&
1328 (eLIM_MLM_LINK_ESTABLISHED_STATE == pMac->lim.gpSession[i].limMlmState))
1329 {
1330 limHeartBeatDeactivateAndChangeTimer(pMac, peFindSessionBySessionId(pMac,i));
1331 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001332 }
Ganesh Kondabattinif0fa07c2013-06-11 17:47:49 +05301333 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001334
Ganesh Kondabattinif0fa07c2013-06-11 17:47:49 +05301335 if (pMac->fScanOffload)
1336 {
1337 if (eHAL_STATUS_SUCCESS !=
1338 limSendHalStartScanOffloadReq(pMac, pScanReq))
1339 {
Rashmi Ramanna6c13a342014-01-07 11:44:07 +05301340 limLog(pMac, LOGE, FL("Couldn't send Offload scan request"));
Ganesh Kondabattinif0fa07c2013-06-11 17:47:49 +05301341 limSendSmeScanRsp(pMac,
1342 offsetof(tSirSmeScanRsp, bssDescription[0]),
1343 eSIR_SME_INVALID_PARAMETERS,
1344 pScanReq->sessionId,
1345 pScanReq->transactionId);
1346 return;
1347 }
1348 }
1349 else
1350 {
1351
1352 /*Change Global SME state */
1353 /* Store the previous SME state */
Rashmi Ramanna6c13a342014-01-07 11:44:07 +05301354 limLog(pMac, LOG1, FL("Non Offload SCAN request "));
Ganesh Kondabattinif0fa07c2013-06-11 17:47:49 +05301355 pMac->lim.gLimPrevSmeState = pMac->lim.gLimSmeState;
1356 pMac->lim.gLimSmeState = eLIM_SME_WT_SCAN_STATE;
1357 MTRACE(macTrace(pMac, TRACE_CODE_SME_STATE, pScanReq->sessionId, pMac->lim.gLimSmeState));
1358
1359 if (pScanReq->channelList.numChannels == 0)
1360 {
1361 tANI_U32 cfg_len;
Rashmi Ramanna6c13a342014-01-07 11:44:07 +05301362
1363 limLog(pMac, LOG1,
1364 FL("Scan all channels as Number of channels is 0"));
Ganesh Kondabattinif0fa07c2013-06-11 17:47:49 +05301365 // Scan all channels
1366 len = sizeof(tLimMlmScanReq) +
Jeff Johnson295189b2012-06-20 16:38:30 -07001367 (sizeof( pScanReq->channelList.channelNumber ) * (WNI_CFG_VALID_CHANNEL_LIST_LEN - 1)) +
1368 pScanReq->uIEFieldLen;
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301369 pMlmScanReq = vos_mem_malloc(len);
1370 if ( NULL == pMlmScanReq )
Ganesh Kondabattinif0fa07c2013-06-11 17:47:49 +05301371 {
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301372 // Log error
1373 limLog(pMac, LOGP,
1374 FL("call to AllocateMemory failed for mlmScanReq (%d)"), len);
Jeff Johnson295189b2012-06-20 16:38:30 -07001375
Padma, Santhosh Kumar8fa85212015-02-18 12:24:56 +05301376 if (pMac->lim.gLimRspReqd)
1377 {
1378 pMac->lim.gLimRspReqd = false;
1379
1380 limSendSmeScanRsp(pMac, sizeof(tSirSmeScanRsp),
1381 eSIR_SME_RESOURCES_UNAVAILABLE,
1382 pScanReq->sessionId,
1383 pScanReq->transactionId);
1384 }
1385
Ganesh Kondabattinif0fa07c2013-06-11 17:47:49 +05301386 return;
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301387 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001388
Ganesh Kondabattinif0fa07c2013-06-11 17:47:49 +05301389 // Initialize this buffer
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301390 vos_mem_set( (tANI_U8 *) pMlmScanReq, len, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07001391
Ganesh Kondabattinif0fa07c2013-06-11 17:47:49 +05301392 cfg_len = WNI_CFG_VALID_CHANNEL_LIST_LEN;
1393 if (wlan_cfgGetStr(pMac, WNI_CFG_VALID_CHANNEL_LIST,
Jeff Johnson295189b2012-06-20 16:38:30 -07001394 pMlmScanReq->channelList.channelNumber,
1395 &cfg_len) != eSIR_SUCCESS)
Ganesh Kondabattinif0fa07c2013-06-11 17:47:49 +05301396 {
1397 /**
1398 * Could not get Valid channel list from CFG.
1399 * Log error.
1400 */
1401 limLog(pMac, LOGP,
1402 FL("could not retrieve Valid channel list"));
Padma, Santhosh Kumar778d8382015-03-04 17:41:22 +05301403
1404 if (pMac->lim.gLimRspReqd)
1405 {
1406 pMac->lim.gLimRspReqd = false;
1407
1408 limSendSmeScanRsp(pMac, sizeof(tSirSmeScanRsp),
1409 eSIR_SME_INVALID_PARAMETERS,
1410 pScanReq->sessionId,
1411 pScanReq->transactionId);
1412 }
Abhishek Singh2b055852015-10-07 14:14:13 +05301413 vos_mem_free(pMlmScanReq);
Padma, Santhosh Kumar778d8382015-03-04 17:41:22 +05301414 return;
Ganesh Kondabattinif0fa07c2013-06-11 17:47:49 +05301415 }
1416 pMlmScanReq->channelList.numChannels = (tANI_U8) cfg_len;
Padma, Santhosh Kumar778d8382015-03-04 17:41:22 +05301417
1418 //Ignore DFS channels if DFS scan is disabled
1419 if(pMac->scan.fEnableDFSChnlScan == DFS_CHNL_SCAN_DISABLED)
1420 {
1421 tANI_U8 numChan = 0;
1422 tANI_U8 channel_state;
1423 tANI_U8 *chan_ptr = pMlmScanReq->channelList.channelNumber;
1424
1425 limLog(pMac, LOG1,
1426 FL("Ignore DFS channels from valid channel list"));
1427
1428 VOS_TRACE_HEX_DUMP(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
1429 pMlmScanReq->channelList.channelNumber,
1430 pMlmScanReq->channelList.numChannels);
1431
1432 //Filter DFS channels
1433 for (i = 0; i < cfg_len; i++)
1434 {
1435 channel_state =
1436 vos_nv_getChannelEnabledState(*(chan_ptr + i));
1437
1438 //Allow channel if not DFS
1439 if(channel_state != NV_CHANNEL_DFS)
1440 {
1441 *(chan_ptr + numChan) = *(chan_ptr + i);
1442 numChan++;
1443 }
1444 }
1445 pMlmScanReq->channelList.numChannels = (tANI_U8) numChan;
1446
1447 limLog(pMac, LOG1, FL("No of valid channels %d, No of"
1448 "channels after filtering %d"), cfg_len, numChan);
1449
1450 limLog(pMac, LOG1, FL("Channel list after filtering: "));
1451
1452 VOS_TRACE_HEX_DUMP(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
1453 pMlmScanReq->channelList.channelNumber,
1454 pMlmScanReq->channelList.numChannels);
1455 }
Ganesh Kondabattinif0fa07c2013-06-11 17:47:49 +05301456 }
1457 else
1458 {
1459 len = sizeof( tLimMlmScanReq ) - sizeof( pScanReq->channelList.channelNumber ) +
1460 (sizeof( pScanReq->channelList.channelNumber ) * pScanReq->channelList.numChannels ) +
1461 pScanReq->uIEFieldLen;
Jeff Johnson295189b2012-06-20 16:38:30 -07001462
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301463 pMlmScanReq = vos_mem_malloc(len);
1464 if ( NULL == pMlmScanReq )
Ganesh Kondabattinif0fa07c2013-06-11 17:47:49 +05301465 {
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301466 // Log error
1467 limLog(pMac, LOGP,
1468 FL("call to AllocateMemory failed for mlmScanReq(%d)"), len);
Jeff Johnson295189b2012-06-20 16:38:30 -07001469
Padma, Santhosh Kumar8fa85212015-02-18 12:24:56 +05301470 if (pMac->lim.gLimRspReqd)
1471 {
1472 pMac->lim.gLimRspReqd = false;
1473
1474 limSendSmeScanRsp(pMac, sizeof(tSirSmeScanRsp),
1475 eSIR_SME_RESOURCES_UNAVAILABLE,
1476 pScanReq->sessionId,
1477 pScanReq->transactionId);
1478 }
1479
Ganesh Kondabattinif0fa07c2013-06-11 17:47:49 +05301480 return;
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301481 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001482
Ganesh Kondabattinif0fa07c2013-06-11 17:47:49 +05301483 // Initialize this buffer
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301484 vos_mem_set( (tANI_U8 *) pMlmScanReq, len, 0);
Ganesh Kondabattinif0fa07c2013-06-11 17:47:49 +05301485 pMlmScanReq->channelList.numChannels =
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301486 pScanReq->channelList.numChannels;
Jeff Johnson295189b2012-06-20 16:38:30 -07001487
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301488 vos_mem_copy( pMlmScanReq->channelList.channelNumber,
1489 pScanReq->channelList.channelNumber,
1490 pScanReq->channelList.numChannels);
1491 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001492
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301493 pMlmScanReq->uIEFieldLen = pScanReq->uIEFieldLen;
1494 pMlmScanReq->uIEFieldOffset = len - pScanReq->uIEFieldLen;
1495 if(pScanReq->uIEFieldLen)
1496 {
1497 vos_mem_copy( (tANI_U8 *)pMlmScanReq+ pMlmScanReq->uIEFieldOffset,
1498 (tANI_U8 *)pScanReq+(pScanReq->uIEFieldOffset),
1499 pScanReq->uIEFieldLen);
1500 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001501
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301502 pMlmScanReq->bssType = pScanReq->bssType;
1503 vos_mem_copy( pMlmScanReq->bssId,
1504 pScanReq->bssId,
1505 sizeof(tSirMacAddr));
1506 pMlmScanReq->numSsid = pScanReq->numSsid;
Jeff Johnson295189b2012-06-20 16:38:30 -07001507
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301508 i = 0;
1509 while (i < pMlmScanReq->numSsid)
1510 {
1511 vos_mem_copy( (tANI_U8 *) &pMlmScanReq->ssId[i],
Jeff Johnson295189b2012-06-20 16:38:30 -07001512 (tANI_U8 *) &pScanReq->ssId[i],
1513 pScanReq->ssId[i].length + 1);
1514
Ganesh Kondabattinif0fa07c2013-06-11 17:47:49 +05301515 i++;
1516 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001517
Jeff Johnson295189b2012-06-20 16:38:30 -07001518
Ganesh Kondabattinif0fa07c2013-06-11 17:47:49 +05301519 pMlmScanReq->scanType = pScanReq->scanType;
1520 pMlmScanReq->backgroundScanMode = pScanReq->backgroundScanMode;
Ganesh Kondabattini8f6e3b32014-08-25 16:07:54 +05301521 if (pMac->miracast_mode)
1522 {
1523 pMlmScanReq->minChannelTime = DEFAULT_MIN_CHAN_TIME_DURING_MIRACAST;
1524 pMlmScanReq->maxChannelTime = DEFAULT_MAX_CHAN_TIME_DURING_MIRACAST;
1525 }
1526 else
1527 {
1528 pMlmScanReq->minChannelTime = pScanReq->minChannelTime;
1529 pMlmScanReq->maxChannelTime = pScanReq->maxChannelTime;
1530 }
1531
Abhishek Singh3a93ee42016-09-29 17:00:03 +05301532 pMlmScanReq->min_chntime_btc_esco =
1533 pScanReq->min_chntime_btc_esco;
1534 pMlmScanReq->max_chntime_btc_esco =
1535 pScanReq->max_chntime_btc_esco;
Ganesh Kondabattinif0fa07c2013-06-11 17:47:49 +05301536 pMlmScanReq->dot11mode = pScanReq->dot11mode;
1537 pMlmScanReq->p2pSearch = pScanReq->p2pSearch;
Jeff Johnson295189b2012-06-20 16:38:30 -07001538
Ganesh Kondabattinif0fa07c2013-06-11 17:47:49 +05301539 //Store the smeSessionID and transaction ID for later use.
1540 pMac->lim.gSmeSessionId = pScanReq->sessionId;
1541 pMac->lim.gTransactionId = pScanReq->transactionId;
Jeff Johnson295189b2012-06-20 16:38:30 -07001542
Ganesh Kondabattinif0fa07c2013-06-11 17:47:49 +05301543 // Issue LIM_MLM_SCAN_REQ to MLM
Rashmi Ramanna6c13a342014-01-07 11:44:07 +05301544 limLog(pMac, LOG1, FL("Issue Scan request command to MLM "));
Ganesh Kondabattinif0fa07c2013-06-11 17:47:49 +05301545 limPostMlmMessage(pMac, LIM_MLM_SCAN_REQ, (tANI_U32 *) pMlmScanReq);
1546 }
1547 } // if ((pMac->lim.gLimSmeState == eLIM_SME_IDLE_STATE) || ...
Jeff Johnson295189b2012-06-20 16:38:30 -07001548
1549 else
1550 {
1551 /// In all other cases return 'cached' scan results
1552 if ((pMac->lim.gLimRspReqd) || pMac->lim.gLimReportBackgroundScanResults)
1553 {
1554 tANI_U16 scanRspLen = sizeof(tSirSmeScanRsp);
1555
1556 pMac->lim.gLimRspReqd = false;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07001557#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
1558 if (pScanReq->returnFreshResults & SIR_BG_SCAN_RETURN_LFR_CACHED_RESULTS)
Jeff Johnson295189b2012-06-20 16:38:30 -07001559 {
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07001560 pMac->lim.gLimSmeLfrScanResultLength = pMac->lim.gLimMlmLfrScanResultLength;
1561 if (pMac->lim.gLimSmeLfrScanResultLength == 0)
1562 {
1563 limSendSmeLfrScanRsp(pMac, scanRspLen,
1564 eSIR_SME_SUCCESS,
1565 pScanReq->sessionId,
1566 pScanReq->transactionId);
1567 }
1568 else
1569 {
1570 scanRspLen = sizeof(tSirSmeScanRsp) +
1571 pMac->lim.gLimSmeLfrScanResultLength -
1572 sizeof(tSirBssDescription);
1573 limSendSmeLfrScanRsp(pMac, scanRspLen, eSIR_SME_SUCCESS,
1574 pScanReq->sessionId, pScanReq->transactionId);
1575 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001576 }
1577 else
1578 {
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07001579#endif
1580 if (pMac->lim.gLimSmeScanResultLength == 0)
1581 {
1582 limSendSmeScanRsp(pMac, scanRspLen, eSIR_SME_SUCCESS,
1583 pScanReq->sessionId, pScanReq->transactionId);
1584 }
1585 else
1586 {
1587 scanRspLen = sizeof(tSirSmeScanRsp) +
1588 pMac->lim.gLimSmeScanResultLength -
1589 sizeof(tSirBssDescription);
1590 limSendSmeScanRsp(pMac, scanRspLen, eSIR_SME_SUCCESS,
1591 pScanReq->sessionId, pScanReq->transactionId);
1592 }
1593#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
Jeff Johnson295189b2012-06-20 16:38:30 -07001594 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07001595#endif
Rashmi Ramanna6c13a342014-01-07 11:44:07 +05301596 limLog(pMac, LOG1, FL("Cached scan results are returned "));
Jeff Johnson295189b2012-06-20 16:38:30 -07001597
1598 if (pScanReq->returnFreshResults & SIR_BG_SCAN_PURGE_RESUTLS)
1599 {
1600 // Discard previously cached scan results
1601 limReInitScanResults(pMac);
1602 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07001603#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
1604 if (pScanReq->returnFreshResults & SIR_BG_SCAN_PURGE_LFR_RESULTS)
1605 {
1606 // Discard previously cached scan results
1607 limReInitLfrScanResults(pMac);
1608 }
1609#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001610
1611 } // if (pMac->lim.gLimRspReqd)
1612 } // else ((pMac->lim.gLimSmeState == eLIM_SME_IDLE_STATE) || ...
1613
Jeff Johnson295189b2012-06-20 16:38:30 -07001614#ifdef BACKGROUND_SCAN_ENABLED
1615 // start background scans if needed
1616 // There is a bug opened against softmac. Need to enable when the bug is fixed.
1617 __limBackgroundScanInitiate(pMac);
1618#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001619
1620} /*** end __limProcessSmeScanReq() ***/
1621
Jeff Johnsone7245742012-09-05 17:12:55 -07001622#ifdef FEATURE_OEM_DATA_SUPPORT
Jeff Johnson295189b2012-06-20 16:38:30 -07001623
Jeff Johnsone7245742012-09-05 17:12:55 -07001624static void __limProcessSmeOemDataReq(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
1625{
1626 tpSirOemDataReq pOemDataReq;
1627 tLimMlmOemDataReq* pMlmOemDataReq;
1628
1629 pOemDataReq = (tpSirOemDataReq) pMsgBuf;
1630
1631 //post the lim mlm message now
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301632 pMlmOemDataReq = vos_mem_malloc(sizeof(tLimMlmOemDataReq));
1633 if ( NULL == pMlmOemDataReq )
Jeff Johnsone7245742012-09-05 17:12:55 -07001634 {
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301635 limLog(pMac, LOGP, FL("AllocateMemory failed for mlmOemDataReq"));
Jeff Johnsone7245742012-09-05 17:12:55 -07001636 return;
1637 }
1638
1639 //Initialize this buffer
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301640 vos_mem_set( pMlmOemDataReq, (sizeof(tLimMlmOemDataReq)), 0);
Jeff Johnsone7245742012-09-05 17:12:55 -07001641
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301642 vos_mem_copy( pMlmOemDataReq->selfMacAddr, pOemDataReq->selfMacAddr,
1643 sizeof(tSirMacAddr));
1644 vos_mem_copy( pMlmOemDataReq->oemDataReq, pOemDataReq->oemDataReq,
1645 OEM_DATA_REQ_SIZE);
Jeff Johnsone7245742012-09-05 17:12:55 -07001646
1647 //Issue LIM_MLM_OEM_DATA_REQ to MLM
1648 limPostMlmMessage(pMac, LIM_MLM_OEM_DATA_REQ, (tANI_U32*)pMlmOemDataReq);
1649
1650 return;
1651
1652} /*** end __limProcessSmeOemDataReq() ***/
1653
1654#endif //FEATURE_OEM_DATA_SUPPORT
Jeff Johnson295189b2012-06-20 16:38:30 -07001655
Gopichand Nakkalac178ac82013-05-30 19:53:39 +05301656/**
1657 * __limProcessClearDfsChannelList()
1658 *
1659 *FUNCTION:
1660 *Clear DFS channel list when country is changed/aquired.
1661.*This message is sent from SME.
1662 *
1663 *LOGIC:
1664 *
1665 *ASSUMPTIONS:
1666 *
1667 *NOTE:
1668 *
1669 * @param pMac Pointer to Global MAC structure
1670 * @param *pMsgBuf A pointer to the SME message buffer
1671 * @return None
1672 */
1673static void __limProcessClearDfsChannelList(tpAniSirGlobal pMac,
1674 tpSirMsgQ pMsg)
1675{
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301676 vos_mem_set( &pMac->lim.dfschannelList,
1677 sizeof(tSirDFSChannelList), 0);
Gopichand Nakkalac178ac82013-05-30 19:53:39 +05301678}
Jeff Johnson295189b2012-06-20 16:38:30 -07001679
1680/**
1681 * __limProcessSmeJoinReq()
1682 *
1683 *FUNCTION:
1684 * This function is called to process SME_JOIN_REQ message
1685 * from HDD or upper layer application.
1686 *
1687 *LOGIC:
1688 *
1689 *ASSUMPTIONS:
1690 *
1691 *NOTE:
1692 *
1693 * @param pMac Pointer to Global MAC structure
1694 * @param *pMsgBuf A pointer to the SME message buffer
1695 * @return None
1696 */
Jeff Johnson295189b2012-06-20 16:38:30 -07001697static void
1698__limProcessSmeJoinReq(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
1699{
1700 // tANI_U8 *pBuf;
1701 //tANI_U32 len;
1702// tSirMacAddr currentBssId;
1703 tpSirSmeJoinReq pSmeJoinReq = NULL;
1704 tLimMlmJoinReq *pMlmJoinReq;
1705 tSirResultCodes retCode = eSIR_SME_SUCCESS;
1706 tANI_U32 val = 0;
1707 tANI_U16 nSize;
1708 tANI_U8 sessionId;
1709 tpPESession psessionEntry = NULL;
Nitesh Shah54046ee2016-07-19 15:23:51 +05301710 tANI_U8 smesessionId = 0;
1711 tANI_U16 smetransactionId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001712 tPowerdBm localPowerConstraint = 0, regMax = 0;
Agarwal Ashish87039eb2014-01-15 14:13:15 +05301713 tANI_U16 ieLen;
1714 v_U8_t *vendorIE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001715
1716#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM //FEATURE_WLAN_DIAG_SUPPORT
1717 //Not sending any session, since it is not created yet. The response whould have correct state.
1718 limDiagEventReport(pMac, WLAN_PE_DIAG_JOIN_REQ_EVENT, NULL, 0, 0);
1719#endif //FEATURE_WLAN_DIAG_SUPPORT
1720
Abhishek Singh3cbf6052014-12-15 16:46:42 +05301721 limLog(pMac, LOG1, FL("Received SME_JOIN_REQ"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001722
1723#ifdef WLAN_FEATURE_VOWIFI
1724 /* Need to read the CFG here itself as this is used in limExtractAPCapability() below.
1725 * This CFG is actually read in rrmUpdateConfig() which is called later. Because this is not
1726 * read, RRM related path before calling rrmUpdateConfig() is not getting executed causing issues
1727 * like not honoring power constraint on 1st association after driver loading. */
1728 if (wlan_cfgGetInt(pMac, WNI_CFG_RRM_ENABLED, &val) != eSIR_SUCCESS)
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001729 limLog(pMac, LOGP, FL("cfg get rrm enabled failed"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001730 pMac->rrm.rrmPEContext.rrmEnable = (val) ? 1 : 0;
1731 val = 0;
1732#endif /* WLAN_FEATURE_VOWIFI */
1733
1734 /**
1735 * Expect Join request in idle state.
1736 * Reassociate request is expected in link established state.
1737 */
1738
1739 /* Global SME and LIM states are not defined yet for BT-AMP Support */
1740 if(pMac->lim.gLimSmeState == eLIM_SME_IDLE_STATE)
1741 {
1742 nSize = __limGetSmeJoinReqSizeForAlloc((tANI_U8*) pMsgBuf);
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301743
1744 pSmeJoinReq = vos_mem_malloc(nSize);
1745 if ( NULL == pSmeJoinReq )
Jeff Johnson295189b2012-06-20 16:38:30 -07001746 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05301747 limLog(pMac, LOGP, FL("call to AllocateMemory failed for "
1748 "pSmeJoinReq"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001749 retCode = eSIR_SME_RESOURCES_UNAVAILABLE;
1750 goto end;
1751 }
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301752 (void) vos_mem_set((void *) pSmeJoinReq, nSize, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07001753
Jeff Johnson295189b2012-06-20 16:38:30 -07001754 if ((limJoinReqSerDes(pMac, pSmeJoinReq, (tANI_U8 *)pMsgBuf) == eSIR_FAILURE) ||
1755 (!limIsSmeJoinReqValid(pMac, pSmeJoinReq)))
1756 {
1757 /// Received invalid eWNI_SME_JOIN_REQ
1758 // Log the event
Padma, Santhosh Kumar2b47ca82014-01-03 16:57:27 +05301759 limLog(pMac, LOGW, FL("SessionId:%d Received SME_JOIN_REQ with"
1760 "invalid data"),pSmeJoinReq->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07001761 retCode = eSIR_SME_INVALID_PARAMETERS;
1762 goto end;
1763 }
1764
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301765 //pMac->lim.gpLimJoinReq = pSmeJoinReq; TO SUPPORT BT-AMP, review os sep 23
Jeff Johnson295189b2012-06-20 16:38:30 -07001766
1767 /* check for the existence of start BSS session */
1768#ifdef FIXME_GEN6
1769 if(pSmeJoinReq->bsstype == eSIR_BTAMP_AP_MODE)
1770 {
1771 if(peValidateBtJoinRequest(pMac)!= TRUE)
1772 {
Padma, Santhosh Kumar2b47ca82014-01-03 16:57:27 +05301773 limLog(pMac, LOGW, FL("SessionId:%d Start Bss session"
1774 "not present::SME_JOIN_REQ in unexpected state"),
1775 pSmeJoinReq->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07001776 retCode = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
1777 psessionEntry = NULL;
1778 goto end;
1779 }
1780 }
1781
1782#endif
1783
1784
1785 if((psessionEntry = peFindSessionByBssid(pMac,pSmeJoinReq->bssDescription.bssId,&sessionId)) != NULL)
1786 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05301787 limLog(pMac, LOGE, FL("Session(%d) Already exists for BSSID: "
Sushant Kaushik1b645382014-10-13 16:39:36 +05301788 MAC_ADDRESS_STR" in limSmeState = %d"),sessionId,
Abhishek Singh57aebef2014-02-03 18:47:44 +05301789 MAC_ADDR_ARRAY(pSmeJoinReq->bssDescription.bssId),
1790 psessionEntry->limSmeState);
Jeff Johnson295189b2012-06-20 16:38:30 -07001791
1792 if(psessionEntry->limSmeState == eLIM_SME_LINK_EST_STATE)
1793 {
1794 // Received eWNI_SME_JOIN_REQ for same
1795 // BSS as currently associated.
1796 // Log the event and send success
Padma, Santhosh Kumar2b47ca82014-01-03 16:57:27 +05301797 PELOGW(limLog(pMac, LOGW, FL("SessionId:%d Received"
1798 "SME_JOIN_REQ for currently joined BSS"),sessionId);)
Jeff Johnson295189b2012-06-20 16:38:30 -07001799 /// Send Join success response to host
Deepthi Gowrif3e27252013-12-11 20:50:01 +05301800 retCode = eSIR_SME_ALREADY_JOINED_A_BSS;
1801 psessionEntry = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07001802 goto end;
1803 }
1804 else
1805 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05301806 PELOGE(limLog(pMac, LOGE, FL("SME_JOIN_REQ not for"
1807 "currently joined BSS"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001808 retCode = eSIR_SME_REFUSED;
1809 psessionEntry = NULL;
1810 goto end;
1811 }
1812 }
1813 else /* Session Entry does not exist for given BSSId */
1814 {
1815 /* Try to Create a new session */
1816 if((psessionEntry = peCreateSession(pMac,pSmeJoinReq->bssDescription.bssId,&sessionId, pMac->lim.maxStation)) == NULL)
1817 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001818 limLog(pMac, LOGE, FL("Session Can not be created "));
Jeff Johnson295189b2012-06-20 16:38:30 -07001819 retCode = eSIR_SME_RESOURCES_UNAVAILABLE;
1820 goto end;
1821 }
Padma, Santhosh Kumar2b47ca82014-01-03 16:57:27 +05301822 else
1823 limLog(pMac,LOG1,FL("SessionId:%d New session created"),
1824 sessionId);
Masti, Narayanraddi67ea5912015-01-08 12:34:05 +05301825 }
1826
1827 if(psessionEntry != NULL && pSmeJoinReq->operationalRateSet.numRates > 0 ){
1828 if(!limCheck11BRateBitmap(pSmeJoinReq->rateBitMap)){
1829 psessionEntry->is11Gonly = true;
1830 }
1831 }
1832
krunal soni5afa96c2013-09-06 22:19:02 -07001833 psessionEntry->isAmsduSupportInAMPDU = pSmeJoinReq->isAmsduSupportInAMPDU;
Jeff Johnsone7245742012-09-05 17:12:55 -07001834
Jeff Johnson295189b2012-06-20 16:38:30 -07001835 /* Store Session related parameters */
1836 /* Store PE session Id in session Table */
1837 psessionEntry->peSessionId = sessionId;
1838
1839 /* store the smejoin req handle in session table */
1840 psessionEntry->pLimJoinReq = pSmeJoinReq;
1841
1842 /* Store SME session Id in sessionTable */
1843 psessionEntry->smeSessionId = pSmeJoinReq->sessionId;
1844
1845 /* Store SME transaction Id in session Table */
1846 psessionEntry->transactionId = pSmeJoinReq->transactionId;
1847
1848 /* Store beaconInterval */
1849 psessionEntry->beaconParams.beaconInterval = pSmeJoinReq->bssDescription.beaconInterval;
1850
1851 /* Copying of bssId is already done, while creating session */
1852 //sirCopyMacAddr(psessionEntry->bssId,pSmeJoinReq->bssId);
1853 sirCopyMacAddr(psessionEntry->selfMacAddr,pSmeJoinReq->selfMacAddr);
1854 psessionEntry->bssType = pSmeJoinReq->bsstype;
1855
1856 psessionEntry->statypeForBss = STA_ENTRY_PEER;
Sandeep Puligillaaea98a22013-12-04 13:36:32 +05301857 psessionEntry->limWmeEnabled = pSmeJoinReq->isWMEenabled;
1858 psessionEntry->limQosEnabled = pSmeJoinReq->isQosEnabled;
Sushant Kaushik74df8db2015-03-11 18:09:05 +05301859 psessionEntry->bOSENAssociation = pSmeJoinReq->bOSENAssociation;
Abhishek Singheef5c992016-01-27 13:41:54 +05301860 psessionEntry->bWPSAssociation = pSmeJoinReq->bWPSAssociation;
Jeff Johnson295189b2012-06-20 16:38:30 -07001861
Agarwal Ashish87039eb2014-01-15 14:13:15 +05301862 /* Store vendor specfic IE for CISCO AP */
Abhishek Singhbad2b322016-10-21 11:22:33 +05301863 ieLen = GET_IE_LEN_IN_BSS(pSmeJoinReq->bssDescription.length);
Agarwal Ashish87039eb2014-01-15 14:13:15 +05301864
1865 vendorIE = limGetVendorIEOuiPtr(pMac, SIR_MAC_CISCO_OUI,
1866 SIR_MAC_CISCO_OUI_SIZE,
1867 ((tANI_U8 *)&pSmeJoinReq->bssDescription.ieFields) , ieLen);
1868
1869 if ( NULL != vendorIE )
1870 {
1871 limLog(pMac, LOGE,
1872 FL("DUT is trying to connect to Cisco AP"));
1873 psessionEntry->isCiscoVendorAP = TRUE;
1874 }
1875 else
1876 {
1877 psessionEntry->isCiscoVendorAP = FALSE;
1878 }
1879
Jeff Johnson295189b2012-06-20 16:38:30 -07001880 /* Copy the dot 11 mode in to the session table */
1881
1882 psessionEntry->dot11mode = pSmeJoinReq->dot11mode;
1883 psessionEntry->nwType = pSmeJoinReq->bssDescription.nwType;
Jeff Johnsone7245742012-09-05 17:12:55 -07001884#ifdef WLAN_FEATURE_11AC
1885 psessionEntry->vhtCapability = IS_DOT11_MODE_VHT(psessionEntry->dot11mode);
Jeff Johnson32d95a32012-09-10 13:15:23 -07001886 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO_MED,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001887 "***__limProcessSmeJoinReq: vhtCapability=%d****",psessionEntry->vhtCapability);
Shailender Karmuchi08f87c22013-01-17 12:51:24 -08001888 if (psessionEntry->vhtCapability )
1889 {
1890 psessionEntry->txBFIniFeatureEnabled = pSmeJoinReq->txBFIniFeatureEnabled;
1891
1892 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO_MED,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001893 "***__limProcessSmeJoinReq: txBFIniFeatureEnabled=%d****",
Shailender Karmuchi08f87c22013-01-17 12:51:24 -08001894 psessionEntry->txBFIniFeatureEnabled);
1895
Selvaraj, Sridhar716d30f2016-07-28 18:54:03 +05301896 if (cfgSetInt(pMac, WNI_CFG_VHT_SU_BEAMFORMEE_CAP,
1897 psessionEntry->txBFIniFeatureEnabled) != eSIR_SUCCESS)
1898 {
1899 limLog(pMac, LOGP, FL("could not set "
1900 "WNI_CFG_VHT_SU_BEAMFORMEE_CAP at CFG"));
1901 retCode = eSIR_LOGP_EXCEPTION;
1902 goto end;
1903 }
Shailender Karmuchi08f87c22013-01-17 12:51:24 -08001904 if( psessionEntry->txBFIniFeatureEnabled )
1905 {
Shailender Karmuchicc3fe442013-02-16 18:18:33 -08001906 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO_MED,
Abhishek Singh57aebef2014-02-03 18:47:44 +05301907 "***__limProcessSmeJoinReq: txBFCsnValue=%d****",
1908 pSmeJoinReq->txBFCsnValue);
Shailender Karmuchicc3fe442013-02-16 18:18:33 -08001909
1910 if (cfgSetInt(pMac, WNI_CFG_VHT_CSN_BEAMFORMEE_ANT_SUPPORTED, pSmeJoinReq->txBFCsnValue)
Shailender Karmuchi08f87c22013-01-17 12:51:24 -08001911 != eSIR_SUCCESS)
1912 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05301913 limLog(pMac, LOGP, FL("could not set "
1914 "WNI_CFG_VHT_CSN_BEAMFORMEE_ANT_SUPPORTED at CFG"));
Shailender Karmuchi08f87c22013-01-17 12:51:24 -08001915 retCode = eSIR_LOGP_EXCEPTION;
1916 goto end;
1917 }
Abhishek Singh6d5d29c2014-07-03 14:25:22 +05301918
1919 if ( FALSE == pMac->isMuBfsessionexist )
1920 psessionEntry->txMuBformee = pSmeJoinReq->txMuBformee;
Shailender Karmuchi08f87c22013-01-17 12:51:24 -08001921 }
Abhishek Singh6d5d29c2014-07-03 14:25:22 +05301922
1923 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
1924 "SmeJoinReq:txMuBformee=%d psessionEntry: txMuBformee = %d",
1925 pSmeJoinReq->txMuBformee, psessionEntry->txMuBformee);
1926
1927 if(cfgSetInt(pMac, WNI_CFG_VHT_MU_BEAMFORMEE_CAP, psessionEntry->txMuBformee)
1928 != eSIR_SUCCESS)
1929 {
1930 limLog(pMac, LOGE, FL("could not set "
1931 "WNI_CFG_VHT_MU_BEAMFORMEE_CAP at CFG"));
1932 retCode = eSIR_LOGP_EXCEPTION;
1933 goto end;
1934 }
1935
Shailender Karmuchi08f87c22013-01-17 12:51:24 -08001936 }
1937
Jeff Johnsone7245742012-09-05 17:12:55 -07001938#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001939
1940 /*Phy mode*/
1941 psessionEntry->gLimPhyMode = pSmeJoinReq->bssDescription.nwType;
1942
Abhishek Singhca6ec5d2015-06-24 13:13:27 +05301943 handleHTCapabilityandHTInfo(pMac, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07001944 /* Copy The channel Id to the session Table */
1945 psessionEntry->currentOperChannel = pSmeJoinReq->bssDescription.channelId;
Abhishek Singhe3beee22017-07-31 15:35:40 +05301946 psessionEntry->force_24ghz_in_ht20 = pSmeJoinReq->force_24ghz_in_ht20;
Jeff Johnsone7245742012-09-05 17:12:55 -07001947 psessionEntry->htSupportedChannelWidthSet = (pSmeJoinReq->cbMode)?1:0; // This is already merged value of peer and self - done by csr in csrGetCBModeFromIes
1948 psessionEntry->htRecommendedTxWidthSet = psessionEntry->htSupportedChannelWidthSet;
1949 psessionEntry->htSecondaryChannelOffset = pSmeJoinReq->cbMode;
Jeff Johnson295189b2012-06-20 16:38:30 -07001950
Chet Lanctot186b5732013-03-18 10:26:30 -07001951 /* Record if management frames need to be protected */
1952#ifdef WLAN_FEATURE_11W
1953 if(eSIR_ED_AES_128_CMAC == pSmeJoinReq->MgmtEncryptionType)
1954 {
1955 psessionEntry->limRmfEnabled = 1;
1956 }
1957 else
1958 {
1959 psessionEntry->limRmfEnabled = 0;
1960 }
1961#endif
1962
krunal soni8d13b092013-07-19 13:23:29 -07001963#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM
1964 psessionEntry->rssi = pSmeJoinReq->bssDescription.rssi;
1965#endif
1966
Jeff Johnson295189b2012-06-20 16:38:30 -07001967 /*Store Persona */
1968 psessionEntry->pePersona = pSmeJoinReq->staPersona;
1969 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
Abhishek Singhe3beee22017-07-31 15:35:40 +05301970 FL("PE PERSONA=%d cbMode %u force_24ghz_in_ht20 %d"),
1971 psessionEntry->pePersona,
1972 pSmeJoinReq->cbMode,
1973 psessionEntry->force_24ghz_in_ht20);
Jeff Johnson295189b2012-06-20 16:38:30 -07001974
1975 /* Copy the SSID from smejoinreq to session entry */
1976 psessionEntry->ssId.length = pSmeJoinReq->ssId.length;
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301977 vos_mem_copy( psessionEntry->ssId.ssId,
1978 pSmeJoinReq->ssId.ssId, psessionEntry->ssId.length);
1979
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001980 // Determin 11r or ESE connection based on input from SME
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301981 // which inturn is dependent on the profile the user wants to connect
1982 // to, So input is coming from supplicant
Jeff Johnson295189b2012-06-20 16:38:30 -07001983#ifdef WLAN_FEATURE_VOWIFI_11R
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301984 psessionEntry->is11Rconnection = pSmeJoinReq->is11Rconnection;
Jeff Johnson295189b2012-06-20 16:38:30 -07001985#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001986#ifdef FEATURE_WLAN_ESE
1987 psessionEntry->isESEconnection = pSmeJoinReq->isESEconnection;
Jeff Johnson295189b2012-06-20 16:38:30 -07001988#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001989#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301990 psessionEntry->isFastTransitionEnabled = pSmeJoinReq->isFastTransitionEnabled;
Jeff Johnson295189b2012-06-20 16:38:30 -07001991#endif
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301992
Jeff Johnson43971f52012-07-17 12:26:56 -07001993#ifdef FEATURE_WLAN_LFR
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301994 psessionEntry->isFastRoamIniFeatureEnabled = pSmeJoinReq->isFastRoamIniFeatureEnabled;
Jeff Johnson43971f52012-07-17 12:26:56 -07001995#endif
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301996 psessionEntry->txLdpcIniFeatureEnabled = pSmeJoinReq->txLdpcIniFeatureEnabled;
Gopichand Nakkalab2d2c312013-01-04 11:41:02 -08001997
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301998 if (psessionEntry->bssType == eSIR_INFRASTRUCTURE_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07001999 {
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302000 psessionEntry->limSystemRole = eLIM_STA_ROLE;
2001 }
2002 else if (psessionEntry->bssType == eSIR_BTAMP_AP_MODE)
2003 {
2004 psessionEntry->limSystemRole = eLIM_BT_AMP_STA_ROLE;
2005 }
2006 else
2007 {
2008 /* Throw an error and return and make sure to delete the session.*/
Abhishek Singh57aebef2014-02-03 18:47:44 +05302009 limLog(pMac, LOGE, FL("received SME_JOIN_REQ with invalid"
2010 " bss type %d"), psessionEntry->bssType);
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302011 retCode = eSIR_SME_INVALID_PARAMETERS;
2012 goto end;
2013 }
2014
2015 if (pSmeJoinReq->addIEScan.length)
2016 {
2017 vos_mem_copy( &psessionEntry->pLimJoinReq->addIEScan,
Jeff Johnson295189b2012-06-20 16:38:30 -07002018 &pSmeJoinReq->addIEScan, sizeof(tSirAddie));
2019 }
2020
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302021 if (pSmeJoinReq->addIEAssoc.length)
Jeff Johnson295189b2012-06-20 16:38:30 -07002022 {
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302023 vos_mem_copy( &psessionEntry->pLimJoinReq->addIEAssoc,
Jeff Johnson295189b2012-06-20 16:38:30 -07002024 &pSmeJoinReq->addIEAssoc, sizeof(tSirAddie));
2025 }
2026
Jeff Johnson295189b2012-06-20 16:38:30 -07002027 val = sizeof(tLimMlmJoinReq) + psessionEntry->pLimJoinReq->bssDescription.length + 2;
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302028 pMlmJoinReq = vos_mem_malloc(val);
2029 if ( NULL == pMlmJoinReq )
Jeff Johnson295189b2012-06-20 16:38:30 -07002030 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05302031 limLog(pMac, LOGP, FL("call to AllocateMemory "
2032 "failed for mlmJoinReq"));
Nitesh Shah54046ee2016-07-19 15:23:51 +05302033 retCode = eSIR_SME_RESOURCES_UNAVAILABLE;
2034 goto end;
Jeff Johnson295189b2012-06-20 16:38:30 -07002035 }
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302036 (void) vos_mem_set((void *) pMlmJoinReq, val, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07002037
2038 /* PE SessionId is stored as a part of JoinReq*/
2039 pMlmJoinReq->sessionId = psessionEntry->peSessionId;
2040
2041 if (wlan_cfgGetInt(pMac, WNI_CFG_JOIN_FAILURE_TIMEOUT, (tANI_U32 *) &pMlmJoinReq->joinFailureTimeout)
2042 != eSIR_SUCCESS)
Sushant Kaushike3ca61c2015-03-19 18:33:25 +05302043 {
2044 limLog(pMac, LOGE, FL("could not retrieve JoinFailureTimer value "
2045 "setting it to default value"));
2046 pMlmJoinReq->joinFailureTimeout = JOIN_FAILURE_TIMEOUT;
2047 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002048
2049 /* copy operational rate from psessionEntry*/
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302050 vos_mem_copy((void*)&psessionEntry->rateSet, (void*)&pSmeJoinReq->operationalRateSet,
Jeff Johnson295189b2012-06-20 16:38:30 -07002051 sizeof(tSirMacRateSet));
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302052 vos_mem_copy((void*)&psessionEntry->extRateSet, (void*)&pSmeJoinReq->extendedRateSet,
Jeff Johnson295189b2012-06-20 16:38:30 -07002053 sizeof(tSirMacRateSet));
2054 //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 +05302055 vos_mem_copy((void*)&pMlmJoinReq->operationalRateSet, (void*)&psessionEntry->rateSet,
Jeff Johnson295189b2012-06-20 16:38:30 -07002056 sizeof(tSirMacRateSet));
2057
2058 psessionEntry->encryptType = pSmeJoinReq->UCEncryptionType;
2059
Jeff Johnson295189b2012-06-20 16:38:30 -07002060 pMlmJoinReq->bssDescription.length = psessionEntry->pLimJoinReq->bssDescription.length;
2061
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302062 vos_mem_copy((tANI_U8 *) &pMlmJoinReq->bssDescription.bssId,
Jeff Johnson295189b2012-06-20 16:38:30 -07002063 (tANI_U8 *) &psessionEntry->pLimJoinReq->bssDescription.bssId,
2064 psessionEntry->pLimJoinReq->bssDescription.length + 2);
2065
Jeff Johnson295189b2012-06-20 16:38:30 -07002066 psessionEntry->limCurrentBssCaps =
Jeff Johnsone7245742012-09-05 17:12:55 -07002067 psessionEntry->pLimJoinReq->bssDescription.capabilityInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07002068
Jeff Johnsone7245742012-09-05 17:12:55 -07002069 regMax = cfgGetRegulatoryMaxTransmitPower( pMac, psessionEntry->currentOperChannel );
Sandeep Puligillaa9eb9ad2014-05-27 14:42:50 +05302070 localPowerConstraint = regMax;
Abhishek Singhbad2b322016-10-21 11:22:33 +05302071 limExtractApCapability(pMac,
2072 (tANI_U8 *) psessionEntry->pLimJoinReq->bssDescription.ieFields,
2073 GET_IE_LEN_IN_BSS(psessionEntry->pLimJoinReq->bssDescription.length),
2074 &psessionEntry->limCurrentBssQosCaps,
2075 &psessionEntry->limCurrentBssPropCap,
2076 &pMac->lim.gLimCurrentBssUapsd,
2077 &localPowerConstraint,
2078 psessionEntry);
Sandeep Puligillaa9eb9ad2014-05-27 14:42:50 +05302079
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002080#ifdef FEATURE_WLAN_ESE
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002081 psessionEntry->maxTxPower = limGetMaxTxPower(regMax, localPowerConstraint, pMac->roam.configParam.nTxPowerCap);
Jeff Johnson295189b2012-06-20 16:38:30 -07002082#else
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302083 psessionEntry->maxTxPower = VOS_MIN( regMax, (localPowerConstraint) );
Jeff Johnson295189b2012-06-20 16:38:30 -07002084#endif
Sushant Kaushikece4b562015-04-09 18:27:33 +05302085 if (!psessionEntry->maxTxPower)
2086 {
2087 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR, FL("Tx power"
2088 "is zero. Setting it to default value %d"),
2089 TX_POWER_DEFAULT);
2090 psessionEntry->maxTxPower = TX_POWER_DEFAULT;
2091 }
2092
Sandeep Puligilla4ce02592014-04-22 09:05:57 +05302093 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
2094 "Regulatory max = %d, local power constraint = %d,"
Abhishek Singh57aebef2014-02-03 18:47:44 +05302095 " max tx = %d", regMax, localPowerConstraint,
2096 psessionEntry->maxTxPower );
Jeff Johnson295189b2012-06-20 16:38:30 -07002097
Agrawal Ashish0a4edfb2017-02-24 14:37:09 +05302098 if (pSmeJoinReq->powerCap.maxTxPower > psessionEntry->maxTxPower)
2099 {
2100 pSmeJoinReq->powerCap.maxTxPower = psessionEntry->maxTxPower;
2101 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
2102 "Update MaxTxPower in join Req to %d",
2103 pSmeJoinReq->powerCap.maxTxPower);
2104 }
2105
Jeff Johnson295189b2012-06-20 16:38:30 -07002106 if (pMac->lim.gLimCurrentBssUapsd)
2107 {
2108 pMac->lim.gUapsdPerAcBitmask = psessionEntry->pLimJoinReq->uapsdPerAcBitmask;
Abhishek Singh57aebef2014-02-03 18:47:44 +05302109 limLog( pMac, LOG1, FL("UAPSD flag for all AC - 0x%2x"),
2110 pMac->lim.gUapsdPerAcBitmask);
Jeff Johnson295189b2012-06-20 16:38:30 -07002111
2112 // resetting the dynamic uapsd mask
2113 pMac->lim.gUapsdPerAcDeliveryEnableMask = 0;
2114 pMac->lim.gUapsdPerAcTriggerEnableMask = 0;
2115 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002116
2117 psessionEntry->limRFBand = limGetRFBand(psessionEntry->currentOperChannel);
2118
2119 // Initialize 11h Enable Flag
2120 if(SIR_BAND_5_GHZ == psessionEntry->limRFBand)
2121 {
2122 if (wlan_cfgGetInt(pMac, WNI_CFG_11H_ENABLED, &val) != eSIR_SUCCESS)
Sushant Kaushike3ca61c2015-03-19 18:33:25 +05302123 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002124 limLog(pMac, LOGP, FL("Fail to get WNI_CFG_11H_ENABLED "));
Sushant Kaushike3ca61c2015-03-19 18:33:25 +05302125 psessionEntry->lim11hEnable = 1;
2126 }
2127 else
2128 psessionEntry->lim11hEnable = val;
Jeff Johnson295189b2012-06-20 16:38:30 -07002129 }
2130 else
2131 psessionEntry->lim11hEnable = 0;
2132
2133 //To care of the scenario when STA transitions from IBSS to Infrastructure mode.
2134 pMac->lim.gLimIbssCoalescingHappened = false;
2135
Jeff Johnsone7245742012-09-05 17:12:55 -07002136 psessionEntry->limPrevSmeState = psessionEntry->limSmeState;
2137 psessionEntry->limSmeState = eLIM_SME_WT_JOIN_STATE;
2138 MTRACE(macTrace(pMac, TRACE_CODE_SME_STATE, psessionEntry->peSessionId, psessionEntry->limSmeState));
Jeff Johnson295189b2012-06-20 16:38:30 -07002139
Abhishek Singh57aebef2014-02-03 18:47:44 +05302140 limLog(pMac, LOG1, FL("SME JoinReq:Sessionid %d SSID len %d SSID : %s "
2141 "Channel %d, BSSID "MAC_ADDRESS_STR), pMlmJoinReq->sessionId,
2142 psessionEntry->ssId.length,psessionEntry->ssId.ssId,
2143 psessionEntry->currentOperChannel,
2144 MAC_ADDR_ARRAY(psessionEntry->bssId));
Jeff Johnson295189b2012-06-20 16:38:30 -07002145
2146 /* Indicate whether spectrum management is enabled*/
2147 psessionEntry->spectrumMgtEnabled =
2148 pSmeJoinReq->spectrumMgtIndicator;
Rajesh Babu Prathipati043149f2014-06-06 13:33:45 +05302149
2150 /* Enable the spectrum management if this is a DFS channel */
2151 if (psessionEntry->countryInfoPresent &&
2152 limIsconnectedOnDFSChannel(psessionEntry->currentOperChannel))
2153 {
2154 psessionEntry->spectrumMgtEnabled = TRUE;
2155 }
2156
Abhishek Singh3cbf6052014-12-15 16:46:42 +05302157 limLog(pMac,LOG1,FL("SessionId: %d LIM_MLM_JOIN_REQ is posted to MLM "
2158 "SM"), pMlmJoinReq->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07002159 /* Issue LIM_MLM_JOIN_REQ to MLM */
2160 limPostMlmMessage(pMac, LIM_MLM_JOIN_REQ, (tANI_U32 *) pMlmJoinReq);
2161 return;
2162
2163 }
2164 else
2165 {
2166 /* Received eWNI_SME_JOIN_REQ un expected state */
Abhishek Singh57aebef2014-02-03 18:47:44 +05302167 limLog(pMac, LOGE, FL("received unexpected SME_JOIN_REQ "
Sushant Kaushik1b645382014-10-13 16:39:36 +05302168 "in state %d"), pMac->lim.gLimSmeState);
Jeff Johnson295189b2012-06-20 16:38:30 -07002169 limPrintSmeState(pMac, LOGE, pMac->lim.gLimSmeState);
2170 retCode = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
2171 psessionEntry = NULL;
2172 goto end;
2173
2174 }
2175
2176end:
2177 limGetSessionInfo(pMac,(tANI_U8*)pMsgBuf,&smesessionId,&smetransactionId);
2178
2179 if(pSmeJoinReq)
2180 {
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302181 vos_mem_free(pSmeJoinReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07002182 pSmeJoinReq = NULL;
2183 if (NULL != psessionEntry)
2184 {
2185 psessionEntry->pLimJoinReq = NULL;
2186 }
2187 }
2188
2189 if(retCode != eSIR_SME_SUCCESS)
2190 {
2191 if(NULL != psessionEntry)
2192 {
2193 peDeleteSession(pMac,psessionEntry);
2194 psessionEntry = NULL;
2195 }
2196 }
Abhishek Singh57aebef2014-02-03 18:47:44 +05302197 limLog(pMac, LOG1, FL("Sending failure status limSendSmeJoinReassocRsp"
2198 "on sessionid: %d with retCode = %d"),smesessionId, retCode);
Jeff Johnson295189b2012-06-20 16:38:30 -07002199 limSendSmeJoinReassocRsp(pMac, eWNI_SME_JOIN_RSP, retCode, eSIR_MAC_UNSPEC_FAILURE_STATUS,psessionEntry,smesessionId,smetransactionId);
2200} /*** end __limProcessSmeJoinReq() ***/
2201
2202
Agrawal Ashish01c66342017-01-27 12:52:25 +05302203#if defined FEATURE_WLAN_ESE || defined WLAN_FEATURE_VOWIFI
Madan Mohan Koyyalamudi3282c572012-11-09 17:01:41 -08002204tANI_U8 limGetMaxTxPower(tPowerdBm regMax, tPowerdBm apTxPower, tANI_U8 iniTxPower)
Jeff Johnson295189b2012-06-20 16:38:30 -07002205{
2206 tANI_U8 maxTxPower = 0;
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302207 tANI_U8 txPower = VOS_MIN( regMax, (apTxPower) );
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002208 txPower = VOS_MIN(txPower, iniTxPower);
Jeff Johnson295189b2012-06-20 16:38:30 -07002209 if((txPower >= MIN_TX_PWR_CAP) && (txPower <= MAX_TX_PWR_CAP))
2210 maxTxPower = txPower;
2211 else if (txPower < MIN_TX_PWR_CAP)
2212 maxTxPower = MIN_TX_PWR_CAP;
2213 else
2214 maxTxPower = MAX_TX_PWR_CAP;
2215
2216 return (maxTxPower);
2217}
2218#endif
2219
Jeff Johnson295189b2012-06-20 16:38:30 -07002220/**
2221 * __limProcessSmeReassocReq()
2222 *
2223 *FUNCTION:
2224 * This function is called to process SME_REASSOC_REQ message
2225 * from HDD or upper layer application.
2226 *
2227 *LOGIC:
2228 *
2229 *ASSUMPTIONS:
2230 *
2231 *NOTE:
2232 *
2233 * @param pMac Pointer to Global MAC structure
2234 * @param *pMsgBuf A pointer to the SME message buffer
2235 * @return None
2236 */
2237
2238static void
2239__limProcessSmeReassocReq(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
2240{
2241 tANI_U16 caps;
2242 tANI_U32 val;
Srinivas Girigowdac16730e2013-01-16 13:39:39 -08002243 tpSirSmeJoinReq pReassocReq = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002244 tLimMlmReassocReq *pMlmReassocReq;
2245 tSirResultCodes retCode = eSIR_SME_SUCCESS;
2246 tpPESession psessionEntry = NULL;
2247 tANI_U8 sessionId;
2248 tANI_U8 smeSessionId;
2249 tANI_U16 transactionId;
2250 tPowerdBm localPowerConstraint = 0, regMax = 0;
2251 tANI_U32 teleBcnEn = 0;
Madan Mohan Koyyalamudi7df624d2012-10-31 16:32:50 -07002252 tANI_U16 nSize;
Jeff Johnson295189b2012-06-20 16:38:30 -07002253
2254
Abhishek Singh127a8442014-12-15 17:31:27 +05302255 limLog(pMac, LOG1, FL("Received SME_REASSOC_REQ"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002256
Madan Mohan Koyyalamudi7df624d2012-10-31 16:32:50 -07002257 nSize = __limGetSmeJoinReqSizeForAlloc((tANI_U8 *) pMsgBuf);
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302258 pReassocReq = vos_mem_malloc(nSize);
2259 if ( NULL == pReassocReq )
Jeff Johnson295189b2012-06-20 16:38:30 -07002260 {
2261 // Log error
2262 limLog(pMac, LOGP,
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302263 FL("call to AllocateMemory failed for pReassocReq"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002264
2265 retCode = eSIR_SME_RESOURCES_UNAVAILABLE;
2266 goto end;
2267 }
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302268 (void) vos_mem_set((void *) pReassocReq, nSize, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07002269 if ((limJoinReqSerDes(pMac, (tpSirSmeJoinReq) pReassocReq,
2270 (tANI_U8 *) pMsgBuf) == eSIR_FAILURE) ||
2271 (!limIsSmeJoinReqValid(pMac,
2272 (tpSirSmeJoinReq) pReassocReq)))
2273 {
2274 /// Received invalid eWNI_SME_REASSOC_REQ
2275 // Log the event
2276 limLog(pMac, LOGW,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002277 FL("received SME_REASSOC_REQ with invalid data"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002278
2279 retCode = eSIR_SME_INVALID_PARAMETERS;
2280 goto end;
2281 }
2282
2283 if((psessionEntry = peFindSessionByBssid(pMac,pReassocReq->bssDescription.bssId,&sessionId))==NULL)
2284 {
2285 limPrintMacAddr(pMac, pReassocReq->bssDescription.bssId, LOGE);
Srinivas Girigowda2a69dcf2013-09-13 14:48:34 -07002286 limLog(pMac, LOGE, FL("Session does not exist for given bssId"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002287 retCode = eSIR_SME_INVALID_PARAMETERS;
2288 goto end;
2289 }
2290
Sushant Kaushikb97a0082015-08-31 12:36:45 +05302291#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM //FEATURE_WLAN_DIAG_SUPPORT
Deepthi Gowri639d5042015-11-16 20:23:39 +05302292 limDiagEventReport(pMac, WLAN_PE_DIAG_REASSOC_REQ_EVENT, psessionEntry,
2293 eSIR_SUCCESS, eSIR_SUCCESS);
Jeff Johnson295189b2012-06-20 16:38:30 -07002294#endif //FEATURE_WLAN_DIAG_SUPPORT
2295 //pMac->lim.gpLimReassocReq = pReassocReq;//TO SUPPORT BT-AMP
2296
2297 /* Store the reassoc handle in the session Table.. 23rd sep review */
2298 psessionEntry->pLimReAssocReq = pReassocReq;
Padma, Santhosh Kumar0d25d102014-07-17 15:08:48 +05302299 psessionEntry->dot11mode = pReassocReq->dot11mode;
2300 psessionEntry->vhtCapability = IS_DOT11_MODE_VHT(pReassocReq->dot11mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07002301
2302 /**
2303 * Reassociate request is expected
2304 * in link established state only.
2305 */
2306
2307 if (psessionEntry->limSmeState != eLIM_SME_LINK_EST_STATE)
2308 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002309#if defined(WLAN_FEATURE_VOWIFI_11R) || defined(FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07002310 if (psessionEntry->limSmeState == eLIM_SME_WT_REASSOC_STATE)
2311 {
2312 // May be from 11r FT pre-auth. So lets check it before we bail out
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08002313 limLog(pMac, LOG1, FL("Session in reassoc state is %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002314 psessionEntry->peSessionId);
2315
2316 // Make sure its our preauth bssid
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302317 if (!vos_mem_compare( pReassocReq->bssDescription.bssId,
Jeff Johnson295189b2012-06-20 16:38:30 -07002318 pMac->ft.ftPEContext.pFTPreAuthReq->preAuthbssId, 6))
2319 {
2320 limPrintMacAddr(pMac, pReassocReq->bssDescription.bssId, LOGE);
2321 limPrintMacAddr(pMac, pMac->ft.ftPEContext.pFTPreAuthReq->preAuthbssId, LOGE);
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002322 limLog(pMac, LOGP, FL("Unknown bssId in reassoc state"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002323 retCode = eSIR_SME_INVALID_PARAMETERS;
2324 goto end;
2325 }
2326
2327 limProcessMlmFTReassocReq(pMac, pMsgBuf, psessionEntry);
2328 return;
2329 }
2330#endif
2331 /// Should not have received eWNI_SME_REASSOC_REQ
2332 // Log the event
2333 limLog(pMac, LOGE,
Sushant Kaushik1b645382014-10-13 16:39:36 +05302334 FL("received unexpected SME_REASSOC_REQ in state %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002335 psessionEntry->limSmeState);
2336 limPrintSmeState(pMac, LOGE, psessionEntry->limSmeState);
2337
2338 retCode = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
2339 goto end;
2340 }
2341
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302342 vos_mem_copy( psessionEntry->limReAssocbssId,
Jeff Johnson295189b2012-06-20 16:38:30 -07002343 psessionEntry->pLimReAssocReq->bssDescription.bssId,
2344 sizeof(tSirMacAddr));
2345
2346 psessionEntry->limReassocChannelId =
2347 psessionEntry->pLimReAssocReq->bssDescription.channelId;
2348
Jeff Johnsone7245742012-09-05 17:12:55 -07002349 psessionEntry->reAssocHtSupportedChannelWidthSet =
2350 (psessionEntry->pLimReAssocReq->cbMode)?1:0;
2351 psessionEntry->reAssocHtRecommendedTxWidthSet =
2352 psessionEntry->reAssocHtSupportedChannelWidthSet;
2353 psessionEntry->reAssocHtSecondaryChannelOffset =
2354 psessionEntry->pLimReAssocReq->cbMode;
2355
Jeff Johnson295189b2012-06-20 16:38:30 -07002356 psessionEntry->limReassocBssCaps =
2357 psessionEntry->pLimReAssocReq->bssDescription.capabilityInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07002358 regMax = cfgGetRegulatoryMaxTransmitPower( pMac, psessionEntry->currentOperChannel );
2359 localPowerConstraint = regMax;
Abhishek Singhbad2b322016-10-21 11:22:33 +05302360 limExtractApCapability(pMac,
2361 (tANI_U8 *) psessionEntry->pLimReAssocReq->bssDescription.ieFields,
2362 GET_IE_LEN_IN_BSS(
2363 psessionEntry->pLimReAssocReq->bssDescription.length),
2364 &psessionEntry->limReassocBssQosCaps,
2365 &psessionEntry->limReassocBssPropCap,
2366 &pMac->lim.gLimCurrentBssUapsd,
2367 &localPowerConstraint,
2368 psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07002369
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302370 psessionEntry->maxTxPower = VOS_MIN( regMax, (localPowerConstraint) );
Sushant Kaushikece4b562015-04-09 18:27:33 +05302371 if (!psessionEntry->maxTxPower)
2372 {
2373 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR, FL("Tx power "
2374 "is zero. Setting it to default value %d"),
2375 TX_POWER_DEFAULT);
2376 psessionEntry->maxTxPower = TX_POWER_DEFAULT;
2377 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002378#if defined WLAN_VOWIFI_DEBUG
Abhishek Singh57aebef2014-02-03 18:47:44 +05302379 limLog( pMac, LOGE, "Regulatory max = %d, local power constraint "
2380 "= %d, max tx = %d", regMax, localPowerConstraint,
2381 psessionEntry->maxTxPower );
Jeff Johnson295189b2012-06-20 16:38:30 -07002382#endif
2383 {
2384 #if 0
2385 if (wlan_cfgGetStr(pMac, WNI_CFG_SSID, pMac->lim.gLimReassocSSID.ssId,
2386 &cfgLen) != eSIR_SUCCESS)
2387 {
2388 /// Could not get SSID from CFG. Log error.
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002389 limLog(pMac, LOGP, FL("could not retrive SSID"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002390 }
2391 #endif//TO SUPPORT BT-AMP
2392
2393 /* Copy the SSID from sessio entry to local variable */
2394 #if 0
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302395 vos_mem_copy( pMac->lim.gLimReassocSSID.ssId,
Jeff Johnson295189b2012-06-20 16:38:30 -07002396 psessionEntry->ssId.ssId,
2397 psessionEntry->ssId.length);
2398 #endif
2399 psessionEntry->limReassocSSID.length = pReassocReq->ssId.length;
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302400 vos_mem_copy( psessionEntry->limReassocSSID.ssId,
Jeff Johnson295189b2012-06-20 16:38:30 -07002401 pReassocReq->ssId.ssId, psessionEntry->limReassocSSID.length);
2402
2403 }
2404
2405 if (pMac->lim.gLimCurrentBssUapsd)
2406 {
2407 pMac->lim.gUapsdPerAcBitmask = psessionEntry->pLimReAssocReq->uapsdPerAcBitmask;
Abhishek Singh57aebef2014-02-03 18:47:44 +05302408 limLog( pMac, LOG1, FL("UAPSD flag for all AC - 0x%2x"),
2409 pMac->lim.gUapsdPerAcBitmask);
Jeff Johnson295189b2012-06-20 16:38:30 -07002410 }
2411
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302412 pMlmReassocReq = vos_mem_malloc(sizeof(tLimMlmReassocReq));
2413 if ( NULL == pMlmReassocReq )
Jeff Johnson295189b2012-06-20 16:38:30 -07002414 {
2415 // Log error
2416 limLog(pMac, LOGP,
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302417 FL("call to AllocateMemory failed for mlmReassocReq"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002418
2419 retCode = eSIR_SME_RESOURCES_UNAVAILABLE;
2420 goto end;
2421 }
2422
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302423 vos_mem_copy( pMlmReassocReq->peerMacAddr,
Jeff Johnson295189b2012-06-20 16:38:30 -07002424 psessionEntry->limReAssocbssId,
2425 sizeof(tSirMacAddr));
2426
2427 if (wlan_cfgGetInt(pMac, WNI_CFG_REASSOCIATION_FAILURE_TIMEOUT,
2428 (tANI_U32 *) &pMlmReassocReq->reassocFailureTimeout)
2429 != eSIR_SUCCESS)
2430 {
2431 /**
2432 * Could not get ReassocFailureTimeout value
2433 * from CFG. Log error.
2434 */
2435 limLog(pMac, LOGP,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002436 FL("could not retrieve ReassocFailureTimeout value"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002437 }
2438
2439 if (cfgGetCapabilityInfo(pMac, &caps,psessionEntry) != eSIR_SUCCESS)
2440 {
2441 /**
2442 * Could not get Capabilities value
2443 * from CFG. Log error.
2444 */
2445 limLog(pMac, LOGP,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002446 FL("could not retrieve Capabilities value"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002447 }
Selvaraj, Sridhar5f149192016-04-15 12:53:28 +05302448
2449 lim_update_caps_info_for_bss(pMac, &caps,
2450 pReassocReq->bssDescription.capabilityInfo);
2451
2452 limLog(pMac, LOG1, FL("Capabilities info Reassoc: 0x%X"), caps);
2453
Jeff Johnson295189b2012-06-20 16:38:30 -07002454 pMlmReassocReq->capabilityInfo = caps;
2455
2456 /* Update PE sessionId*/
2457 pMlmReassocReq->sessionId = sessionId;
2458
2459 /* If telescopic beaconing is enabled, set listen interval to
2460 WNI_CFG_TELE_BCN_MAX_LI */
2461 if(wlan_cfgGetInt(pMac, WNI_CFG_TELE_BCN_WAKEUP_EN, &teleBcnEn) !=
2462 eSIR_SUCCESS)
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002463 limLog(pMac, LOGP, FL("Couldn't get WNI_CFG_TELE_BCN_WAKEUP_EN"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002464
2465 val = WNI_CFG_LISTEN_INTERVAL_STADEF;
2466
2467 if(teleBcnEn)
2468 {
2469 if(wlan_cfgGetInt(pMac, WNI_CFG_TELE_BCN_MAX_LI, &val) !=
2470 eSIR_SUCCESS)
2471 {
2472 /**
2473 * Could not get ListenInterval value
2474 * from CFG. Log error.
2475 */
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002476 limLog(pMac, LOGP, FL("could not retrieve ListenInterval"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002477 }
2478 }
2479 else
2480 {
2481 if (wlan_cfgGetInt(pMac, WNI_CFG_LISTEN_INTERVAL, &val) != eSIR_SUCCESS)
2482 {
2483 /**
2484 * Could not get ListenInterval value
2485 * from CFG. Log error.
2486 */
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002487 limLog(pMac, LOGP, FL("could not retrieve ListenInterval"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002488 }
2489 }
2490
2491 /* Delete all BA sessions before Re-Assoc.
2492 * BA frames are class 3 frames and the session
2493 * is lost upon disassociation and reassociation.
2494 */
2495
Ganesh Kondabattini01f75c92014-07-07 19:27:41 +05302496 limDeleteBASessions(pMac, psessionEntry, BA_BOTH_DIRECTIONS,
2497 eSIR_MAC_UNSPEC_FAILURE_REASON);
Jeff Johnson295189b2012-06-20 16:38:30 -07002498
2499 pMlmReassocReq->listenInterval = (tANI_U16) val;
2500
2501 /* Indicate whether spectrum management is enabled*/
2502 psessionEntry->spectrumMgtEnabled = pReassocReq->spectrumMgtIndicator;
2503
Rajesh Babu Prathipati043149f2014-06-06 13:33:45 +05302504 /* Enable the spectrum management if this is a DFS channel */
2505 if (psessionEntry->countryInfoPresent &&
2506 limIsconnectedOnDFSChannel(psessionEntry->currentOperChannel))
2507 {
2508 psessionEntry->spectrumMgtEnabled = TRUE;
2509 }
2510
Jeff Johnson295189b2012-06-20 16:38:30 -07002511 psessionEntry->limPrevSmeState = psessionEntry->limSmeState;
2512 psessionEntry->limSmeState = eLIM_SME_WT_REASSOC_STATE;
2513
Jeff Johnsone7245742012-09-05 17:12:55 -07002514 MTRACE(macTrace(pMac, TRACE_CODE_SME_STATE, psessionEntry->peSessionId, psessionEntry->limSmeState));
Jeff Johnson295189b2012-06-20 16:38:30 -07002515
2516 limPostMlmMessage(pMac,
2517 LIM_MLM_REASSOC_REQ,
2518 (tANI_U32 *) pMlmReassocReq);
2519 return;
2520
2521end:
2522 if (pReassocReq)
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302523 vos_mem_free( pReassocReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07002524
2525 if (psessionEntry)
2526 {
2527 // error occurred after we determined the session so extract
2528 // session and transaction info from there
2529 smeSessionId = psessionEntry->smeSessionId;
2530 transactionId = psessionEntry->transactionId;
2531 }
2532 else
2533 {
2534 // error occurred before or during the time we determined the session
2535 // so extract the session and transaction info from the message
2536 limGetSessionInfo(pMac,(tANI_U8*)pMsgBuf, &smeSessionId, &transactionId);
2537 }
2538
2539 /// Send Reassoc failure response to host
2540 /// (note psessionEntry may be NULL, but that's OK)
2541 limSendSmeJoinReassocRsp(pMac, eWNI_SME_REASSOC_RSP,
2542 retCode, eSIR_MAC_UNSPEC_FAILURE_STATUS,
2543 psessionEntry, smeSessionId, transactionId);
2544
2545} /*** end __limProcessSmeReassocReq() ***/
2546
2547
2548tANI_BOOLEAN sendDisassocFrame = 1;
2549/**
2550 * __limProcessSmeDisassocReq()
2551 *
2552 *FUNCTION:
2553 * This function is called to process SME_DISASSOC_REQ message
2554 * from HDD or upper layer application.
2555 *
2556 *LOGIC:
2557 *
2558 *ASSUMPTIONS:
2559 *
2560 *NOTE:
2561 *
2562 * @param pMac Pointer to Global MAC structure
2563 * @param *pMsgBuf A pointer to the SME message buffer
2564 * @return None
2565 */
2566
2567static void
2568__limProcessSmeDisassocReq(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
2569{
2570 tANI_U16 disassocTrigger, reasonCode;
2571 tLimMlmDisassocReq *pMlmDisassocReq;
2572 tSirResultCodes retCode = eSIR_SME_SUCCESS;
Jeff Johnson43971f52012-07-17 12:26:56 -07002573 tSirRetStatus status;
Jeff Johnson295189b2012-06-20 16:38:30 -07002574 tSirSmeDisassocReq smeDisassocReq;
2575 tpPESession psessionEntry = NULL;
2576 tANI_U8 sessionId;
2577 tANI_U8 smesessionId;
2578 tANI_U16 smetransactionId;
2579
Jeff Johnson295189b2012-06-20 16:38:30 -07002580
Jeff Johnson43971f52012-07-17 12:26:56 -07002581 if (pMsgBuf == NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -07002582 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002583 limLog(pMac, LOGE, FL("Buffer is Pointing to NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002584 return;
2585 }
2586
Jeff Johnson43971f52012-07-17 12:26:56 -07002587 limGetSessionInfo(pMac, (tANI_U8 *)pMsgBuf,&smesessionId, &smetransactionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07002588
Jeff Johnson43971f52012-07-17 12:26:56 -07002589 status = limDisassocReqSerDes(pMac, &smeDisassocReq, (tANI_U8 *) pMsgBuf);
Jeff Johnson295189b2012-06-20 16:38:30 -07002590
Jeff Johnson43971f52012-07-17 12:26:56 -07002591 if ( (eSIR_FAILURE == status) ||
2592 (!limIsSmeDisassocReqValid(pMac, &smeDisassocReq, psessionEntry)) )
Jeff Johnson295189b2012-06-20 16:38:30 -07002593 {
2594 PELOGE(limLog(pMac, LOGE,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002595 FL("received invalid SME_DISASSOC_REQ message"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07002596
2597 if (pMac->lim.gLimRspReqd)
2598 {
2599 pMac->lim.gLimRspReqd = false;
2600
2601 retCode = eSIR_SME_INVALID_PARAMETERS;
2602 disassocTrigger = eLIM_HOST_DISASSOC;
2603 goto sendDisassoc;
2604 }
2605
2606 return;
2607 }
2608
Jeff Johnson295189b2012-06-20 16:38:30 -07002609 if((psessionEntry = peFindSessionByBssid(pMac,smeDisassocReq.bssId,&sessionId))== NULL)
2610 {
Abhishek Singhcd09b562013-12-24 16:02:20 +05302611 limLog(pMac, LOGE,FL("session does not exist for given bssId "MAC_ADDRESS_STR),
2612 MAC_ADDR_ARRAY(smeDisassocReq.bssId));
Jeff Johnson295189b2012-06-20 16:38:30 -07002613 retCode = eSIR_SME_INVALID_PARAMETERS;
2614 disassocTrigger = eLIM_HOST_DISASSOC;
2615 goto sendDisassoc;
2616
2617 }
Abhishek Singhcd09b562013-12-24 16:02:20 +05302618 limLog(pMac, LOG1, FL("received DISASSOC_REQ message on sessionid %d"
2619 "Systemrole %d Reason: %u SmeState: %d from: "MAC_ADDRESS_STR),
2620 smesessionId,psessionEntry->limSystemRole,
2621 smeDisassocReq.reasonCode, pMac->lim.gLimSmeState,
2622 MAC_ADDR_ARRAY(smeDisassocReq.peerMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07002623
2624#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM //FEATURE_WLAN_DIAG_SUPPORT
2625 limDiagEventReport(pMac, WLAN_PE_DIAG_DISASSOC_REQ_EVENT, psessionEntry, 0, smeDisassocReq.reasonCode);
2626#endif //FEATURE_WLAN_DIAG_SUPPORT
2627
2628 /* Update SME session Id and SME transaction ID*/
2629
2630 psessionEntry->smeSessionId = smesessionId;
2631 psessionEntry->transactionId = smetransactionId;
2632
2633 switch (psessionEntry->limSystemRole)
2634 {
2635 case eLIM_STA_ROLE:
2636 case eLIM_BT_AMP_STA_ROLE:
2637 switch (psessionEntry->limSmeState)
2638 {
2639 case eLIM_SME_ASSOCIATED_STATE:
2640 case eLIM_SME_LINK_EST_STATE:
Kanchanapally, Vidyullathac796fc62015-03-17 10:45:28 +05302641 limLog(pMac, LOG1, FL("Rcvd SME_DISASSOC_REQ while in "
2642 "limSmeState: %d "),psessionEntry->limSmeState);
2643
Jeff Johnson295189b2012-06-20 16:38:30 -07002644 psessionEntry->limPrevSmeState = psessionEntry->limSmeState;
2645 psessionEntry->limSmeState= eLIM_SME_WT_DISASSOC_STATE;
Hoonki Lee8c9e99f2013-04-18 22:59:11 -07002646#ifdef FEATURE_WLAN_TDLS
2647 /* Delete all TDLS peers connected before leaving BSS*/
2648 limDeleteTDLSPeers(pMac, psessionEntry);
2649#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07002650 MTRACE(macTrace(pMac, TRACE_CODE_SME_STATE, psessionEntry->peSessionId, psessionEntry->limSmeState));
Jeff Johnson295189b2012-06-20 16:38:30 -07002651 break;
2652
2653 case eLIM_SME_WT_DEAUTH_STATE:
2654 /* PE shall still process the DISASSOC_REQ and proceed with
2655 * link tear down even if it had already sent a DEAUTH_IND to
2656 * to SME. pMac->lim.gLimPrevSmeState shall remain the same as
2657 * its been set when PE entered WT_DEAUTH_STATE.
2658 */
2659 psessionEntry->limSmeState= eLIM_SME_WT_DISASSOC_STATE;
Jeff Johnsone7245742012-09-05 17:12:55 -07002660 MTRACE(macTrace(pMac, TRACE_CODE_SME_STATE, psessionEntry->peSessionId, psessionEntry->limSmeState));
Abhishek Singhcd09b562013-12-24 16:02:20 +05302661 limLog(pMac, LOG1, FL("Rcvd SME_DISASSOC_REQ while in "
2662 "SME_WT_DEAUTH_STATE. "));
Jeff Johnson295189b2012-06-20 16:38:30 -07002663 break;
2664
2665 case eLIM_SME_WT_DISASSOC_STATE:
2666 /* PE Recieved a Disassoc frame. Normally it gets DISASSOC_CNF but it
2667 * received DISASSOC_REQ. Which means host is also trying to disconnect.
2668 * PE can continue processing DISASSOC_REQ and send the response instead
2669 * of failing the request. SME will anyway ignore DEAUTH_IND that was sent
2670 * for disassoc frame.
2671 *
2672 * It will send a disassoc, which is ok. However, we can use the global flag
2673 * sendDisassoc to not send disassoc frame.
2674 */
Abhishek Singhcd09b562013-12-24 16:02:20 +05302675 limLog(pMac, LOG1, FL("Rcvd SME_DISASSOC_REQ while in "
2676 "SME_WT_DISASSOC_STATE. "));
Jeff Johnson295189b2012-06-20 16:38:30 -07002677 break;
2678
2679 case eLIM_SME_JOIN_FAILURE_STATE: {
2680 /** Return Success as we are already in Disconnected State*/
Abhishek Singhcd09b562013-12-24 16:02:20 +05302681 limLog(pMac, LOG1, FL("Rcvd SME_DISASSOC_REQ while in "
2682 "eLIM_SME_JOIN_FAILURE_STATE. "));
Jeff Johnson295189b2012-06-20 16:38:30 -07002683 if (pMac->lim.gLimRspReqd) {
2684 retCode = eSIR_SME_SUCCESS;
2685 disassocTrigger = eLIM_HOST_DISASSOC;
2686 goto sendDisassoc;
2687 }
2688 }break;
2689 default:
2690 /**
2691 * STA is not currently associated.
2692 * Log error and send response to host
2693 */
2694 limLog(pMac, LOGE,
Sushant Kaushik1b645382014-10-13 16:39:36 +05302695 FL("received unexpected SME_DISASSOC_REQ in state %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002696 psessionEntry->limSmeState);
2697 limPrintSmeState(pMac, LOGE, psessionEntry->limSmeState);
2698
2699 if (pMac->lim.gLimRspReqd)
2700 {
2701 if (psessionEntry->limSmeState !=
2702 eLIM_SME_WT_ASSOC_STATE)
2703 pMac->lim.gLimRspReqd = false;
2704
2705 retCode = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
2706 disassocTrigger = eLIM_HOST_DISASSOC;
2707 goto sendDisassoc;
2708 }
2709
2710 return;
2711 }
2712
2713 break;
2714
2715 case eLIM_AP_ROLE:
2716 case eLIM_BT_AMP_AP_ROLE:
2717 // Fall through
2718 break;
2719
2720 case eLIM_STA_IN_IBSS_ROLE:
2721 default: // eLIM_UNKNOWN_ROLE
2722 limLog(pMac, LOGE,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002723 FL("received unexpected SME_DISASSOC_REQ for role %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002724 psessionEntry->limSystemRole);
2725
2726 retCode = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
2727 disassocTrigger = eLIM_HOST_DISASSOC;
2728 goto sendDisassoc;
2729 } // end switch (pMac->lim.gLimSystemRole)
2730
Edhar, Mahesh Kumar03cf7ff2015-11-26 17:59:29 +05302731 disassocTrigger = eLIM_HOST_DISASSOC;
2732 reasonCode = smeDisassocReq.reasonCode;
Jeff Johnson295189b2012-06-20 16:38:30 -07002733
2734 if (smeDisassocReq.doNotSendOverTheAir)
2735 {
Abhishek Singhcd09b562013-12-24 16:02:20 +05302736 limLog(pMac, LOG1, FL("do not send dissoc over the air"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002737 sendDisassocFrame = 0;
2738 }
2739 // Trigger Disassociation frame to peer MAC entity
Sachin Ahuja2fea3d12014-12-18 17:31:31 +05302740 limLog(pMac, LOG1, FL("Sending Disasscoc with disassoc Trigger"
2741 " : %d, reasonCode : %d"),
2742 disassocTrigger, reasonCode);
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302743 pMlmDisassocReq = vos_mem_malloc(sizeof(tLimMlmDisassocReq));
2744 if ( NULL == pMlmDisassocReq )
Jeff Johnson295189b2012-06-20 16:38:30 -07002745 {
2746 // Log error
2747 limLog(pMac, LOGP,
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302748 FL("call to AllocateMemory failed for mlmDisassocReq"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002749
2750 return;
2751 }
2752
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302753 vos_mem_copy( (tANI_U8 *) &pMlmDisassocReq->peerMacAddr,
Jeff Johnson295189b2012-06-20 16:38:30 -07002754 (tANI_U8 *) &smeDisassocReq.peerMacAddr,
2755 sizeof(tSirMacAddr));
2756
2757 pMlmDisassocReq->reasonCode = reasonCode;
2758 pMlmDisassocReq->disassocTrigger = disassocTrigger;
2759
2760 /* Update PE session ID*/
2761 pMlmDisassocReq->sessionId = sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -07002762
2763 limPostMlmMessage(pMac,
2764 LIM_MLM_DISASSOC_REQ,
2765 (tANI_U32 *) pMlmDisassocReq);
2766 return;
2767
2768sendDisassoc:
2769 if (psessionEntry)
2770 limSendSmeDisassocNtf(pMac, smeDisassocReq.peerMacAddr,
2771 retCode,
2772 disassocTrigger,
Jeff Johnson295189b2012-06-20 16:38:30 -07002773 1,smesessionId,smetransactionId,psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07002774 else
2775 limSendSmeDisassocNtf(pMac, smeDisassocReq.peerMacAddr,
2776 retCode,
2777 disassocTrigger,
Sudhir Sattayappa Kohalli5a8ac222013-03-06 12:41:42 -08002778 1, smesessionId, smetransactionId, NULL);
Jeff Johnson295189b2012-06-20 16:38:30 -07002779
2780
2781} /*** end __limProcessSmeDisassocReq() ***/
2782
2783
2784/** -----------------------------------------------------------------
2785 \brief __limProcessSmeDisassocCnf() - Process SME_DISASSOC_CNF
2786
2787 This function is called to process SME_DISASSOC_CNF message
2788 from HDD or upper layer application.
2789
2790 \param pMac - global mac structure
2791 \param pStaDs - station dph hash node
2792 \return none
2793 \sa
2794 ----------------------------------------------------------------- */
2795static void
2796__limProcessSmeDisassocCnf(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
2797{
2798 tSirSmeDisassocCnf smeDisassocCnf;
2799 tANI_U16 aid;
2800 tpDphHashNode pStaDs;
2801 tSirRetStatus status = eSIR_SUCCESS;
2802 tpPESession psessionEntry;
2803 tANI_U8 sessionId;
2804
2805
Abhishek Singh3cbf6052014-12-15 16:46:42 +05302806 limLog(pMac, LOG1, FL("received SME_DISASSOC_CNF message"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002807
2808 status = limDisassocCnfSerDes(pMac, &smeDisassocCnf,(tANI_U8 *) pMsgBuf);
2809
2810 if (status == eSIR_FAILURE)
2811 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002812 PELOGE(limLog(pMac, LOGE, FL("invalid SME_DISASSOC_CNF message"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07002813 return;
2814 }
2815
2816 if((psessionEntry = peFindSessionByBssid(pMac, smeDisassocCnf.bssId, &sessionId))== NULL)
2817 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002818 limLog(pMac, LOGE,FL("session does not exist for given bssId"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002819 return;
2820 }
2821
2822 if (!limIsSmeDisassocCnfValid(pMac, &smeDisassocCnf, psessionEntry))
2823 {
Abhishek Singhcd09b562013-12-24 16:02:20 +05302824 limLog(pMac, LOGE, FL("received invalid SME_DISASSOC_CNF message"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002825 return;
2826 }
2827
2828#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM //FEATURE_WLAN_DIAG_SUPPORT
2829 if (smeDisassocCnf.messageType == eWNI_SME_DISASSOC_CNF)
2830 limDiagEventReport(pMac, WLAN_PE_DIAG_DISASSOC_CNF_EVENT, psessionEntry, (tANI_U16)smeDisassocCnf.statusCode, 0);
2831 else if (smeDisassocCnf.messageType == eWNI_SME_DEAUTH_CNF)
2832 limDiagEventReport(pMac, WLAN_PE_DIAG_DEAUTH_CNF_EVENT, psessionEntry, (tANI_U16)smeDisassocCnf.statusCode, 0);
2833#endif //FEATURE_WLAN_DIAG_SUPPORT
2834
2835 switch (psessionEntry->limSystemRole)
2836 {
2837 case eLIM_STA_ROLE:
2838 case eLIM_BT_AMP_STA_ROLE: //To test reconn
2839 if ((psessionEntry->limSmeState != eLIM_SME_IDLE_STATE) &&
2840 (psessionEntry->limSmeState != eLIM_SME_WT_DISASSOC_STATE) &&
2841 (psessionEntry->limSmeState != eLIM_SME_WT_DEAUTH_STATE))
2842 {
2843 limLog(pMac, LOGE,
Sushant Kaushik1b645382014-10-13 16:39:36 +05302844 FL("received unexp SME_DISASSOC_CNF in state %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002845 psessionEntry->limSmeState);
2846 limPrintSmeState(pMac, LOGE, psessionEntry->limSmeState);
2847 return;
2848 }
2849 break;
2850
2851 case eLIM_AP_ROLE:
2852 // Fall through
Jeff Johnson295189b2012-06-20 16:38:30 -07002853 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07002854
2855 case eLIM_STA_IN_IBSS_ROLE:
2856 default: // eLIM_UNKNOWN_ROLE
2857 limLog(pMac, LOGE,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002858 FL("received unexpected SME_DISASSOC_CNF role %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002859 psessionEntry->limSystemRole);
2860
2861 return;
2862 }
2863
2864
2865 if ( (psessionEntry->limSmeState == eLIM_SME_WT_DISASSOC_STATE) ||
2866 (psessionEntry->limSmeState == eLIM_SME_WT_DEAUTH_STATE)
Jeff Johnson295189b2012-06-20 16:38:30 -07002867 || (psessionEntry->limSystemRole == eLIM_AP_ROLE )
Jeff Johnson295189b2012-06-20 16:38:30 -07002868 )
2869 {
2870 pStaDs = dphLookupHashEntry(pMac, smeDisassocCnf.peerMacAddr, &aid, &psessionEntry->dph.dphHashTable);
2871 if (pStaDs == NULL)
2872 {
Abhishek Singhcd09b562013-12-24 16:02:20 +05302873 PELOGE(limLog(pMac, LOGE, FL("received DISASSOC_CNF for a STA that "
2874 "does not have context, addr= "MAC_ADDRESS_STR),
2875 MAC_ADDR_ARRAY(smeDisassocCnf.peerMacAddr));)
Jeff Johnson295189b2012-06-20 16:38:30 -07002876 return;
2877 }
Wu Gao742b7352015-10-16 19:10:40 +08002878
2879 if(aid != smeDisassocCnf.assocId)
2880 {
2881 PELOGE(limLog(pMac, LOGE, FL("same peerMacAddr but assocId is different "
2882 "aid=%d, assocId=%d, addr= "MAC_ADDRESS_STR),
2883 aid, smeDisassocCnf.assocId, MAC_ADDR_ARRAY(smeDisassocCnf.peerMacAddr));)
2884 return;
2885 }
Padma, Santhosh Kumar05600d32015-07-24 13:00:57 +05302886 /*
2887 * If MlM state is either of del_sta or del_bss state, then no need to
2888 * go ahead and clean up further as there must be some cleanup in
2889 * progress from upper layer disassoc/deauth request.
2890 */
2891 if((pStaDs->mlmStaContext.mlmState == eLIM_MLM_WT_DEL_STA_RSP_STATE) ||
2892 (pStaDs->mlmStaContext.mlmState == eLIM_MLM_WT_DEL_BSS_RSP_STATE))
2893 {
2894 limLog(pMac, LOGE, FL("No need to cleanup for addr:"MAC_ADDRESS_STR
2895 "as Mlm state is %d"),
2896 MAC_ADDR_ARRAY(smeDisassocCnf.peerMacAddr),
2897 pStaDs->mlmStaContext.mlmState);
2898 return;
2899 }
2900
Madan Mohan Koyyalamudi23001722012-10-31 16:48:56 -07002901 /* Delete FT session if there exists one */
2902 limFTCleanup(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -07002903 limCleanupRxPath(pMac, pStaDs, psessionEntry);
Madan Mohan Koyyalamudia67d4332012-11-29 11:35:23 -08002904
2905 limCleanUpDisassocDeauthReq(pMac, (char*)&smeDisassocCnf.peerMacAddr, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07002906 }
2907
2908 return;
2909}
2910
2911
2912/**
2913 * __limProcessSmeDeauthReq()
2914 *
2915 *FUNCTION:
2916 * This function is called to process SME_DEAUTH_REQ message
2917 * from HDD or upper layer application.
2918 *
2919 *LOGIC:
2920 *
2921 *ASSUMPTIONS:
2922 *
2923 *NOTE:
2924 *
2925 * @param pMac Pointer to Global MAC structure
2926 * @param *pMsgBuf A pointer to the SME message buffer
2927 * @return None
2928 */
2929
2930static void
2931__limProcessSmeDeauthReq(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
2932{
2933 tANI_U16 deauthTrigger, reasonCode;
2934 tLimMlmDeauthReq *pMlmDeauthReq;
2935 tSirSmeDeauthReq smeDeauthReq;
2936 tSirResultCodes retCode = eSIR_SME_SUCCESS;
2937 tSirRetStatus status = eSIR_SUCCESS;
2938 tpPESession psessionEntry;
2939 tANI_U8 sessionId; //PE sessionId
2940 tANI_U8 smesessionId;
2941 tANI_U16 smetransactionId;
2942
Jeff Johnson295189b2012-06-20 16:38:30 -07002943
2944 status = limDeauthReqSerDes(pMac, &smeDeauthReq,(tANI_U8 *) pMsgBuf);
Jeff Johnson295189b2012-06-20 16:38:30 -07002945 limGetSessionInfo(pMac,(tANI_U8 *)pMsgBuf,&smesessionId,&smetransactionId);
2946
2947 //We need to get a session first but we don't even know if the message is correct.
2948 if((psessionEntry = peFindSessionByBssid(pMac, smeDeauthReq.bssId, &sessionId)) == NULL)
2949 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002950 limLog(pMac, LOGE,FL("session does not exist for given bssId"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002951 retCode = eSIR_SME_INVALID_PARAMETERS;
2952 deauthTrigger = eLIM_HOST_DEAUTH;
2953 goto sendDeauth;
2954
2955 }
2956
2957 if ((status == eSIR_FAILURE) || (!limIsSmeDeauthReqValid(pMac, &smeDeauthReq, psessionEntry)))
2958 {
Sachin Ahuja42354142015-01-06 19:48:35 +05302959 PELOGE(limLog(pMac, LOGE,FL
2960 ("received invalid SME_DEAUTH_REQ message"));)
2961 pMac->lim.gLimRspReqd = false;
Jeff Johnson295189b2012-06-20 16:38:30 -07002962
Sachin Ahuja42354142015-01-06 19:48:35 +05302963 retCode = eSIR_SME_INVALID_PARAMETERS;
2964 deauthTrigger = eLIM_HOST_DEAUTH;
2965 goto sendDeauth;
Jeff Johnson295189b2012-06-20 16:38:30 -07002966 }
Abhishek Singhcd09b562013-12-24 16:02:20 +05302967 limLog(pMac, LOG1,FL("received DEAUTH_REQ message on sessionid %d "
2968 "Systemrole %d with reasoncode %u in limSmestate %d from "
2969 MAC_ADDRESS_STR), smesessionId, psessionEntry->limSystemRole,
2970 smeDeauthReq.reasonCode, psessionEntry->limSmeState,
2971 MAC_ADDR_ARRAY(smeDeauthReq.peerMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07002972#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM //FEATURE_WLAN_DIAG_SUPPORT
2973 limDiagEventReport(pMac, WLAN_PE_DIAG_DEAUTH_REQ_EVENT, psessionEntry, 0, smeDeauthReq.reasonCode);
2974#endif //FEATURE_WLAN_DIAG_SUPPORT
2975
2976 /* Update SME session ID and Transaction ID */
2977 psessionEntry->smeSessionId = smesessionId;
2978 psessionEntry->transactionId = smetransactionId;
2979
2980
2981 switch (psessionEntry->limSystemRole)
2982 {
2983 case eLIM_STA_ROLE:
2984 case eLIM_BT_AMP_STA_ROLE:
2985
2986 switch (psessionEntry->limSmeState)
2987 {
2988 case eLIM_SME_ASSOCIATED_STATE:
2989 case eLIM_SME_LINK_EST_STATE:
2990 case eLIM_SME_WT_ASSOC_STATE:
2991 case eLIM_SME_JOIN_FAILURE_STATE:
2992 case eLIM_SME_IDLE_STATE:
2993 psessionEntry->limPrevSmeState = psessionEntry->limSmeState;
2994 psessionEntry->limSmeState = eLIM_SME_WT_DEAUTH_STATE;
Varun Reddy Yeturue3bbf6e2013-02-08 18:50:55 -08002995 MTRACE(macTrace(pMac, TRACE_CODE_SME_STATE, psessionEntry->peSessionId, psessionEntry->limSmeState));
Jeff Johnson295189b2012-06-20 16:38:30 -07002996
2997 // Send Deauthentication request to MLM below
2998
2999 break;
Sachin Ahujaa100dcc2014-07-03 14:30:18 +05303000 case eLIM_SME_WT_DEAUTH_STATE:
3001 /*
3002 * PE Recieved a Deauth frame. Normally it gets
3003 * DEAUTH_CNF but it received DEAUTH_REQ. Which
3004 * means host is also trying to disconnect.
3005 * PE can continue processing DEAUTH_REQ and send
3006 * the response instead of failing the request.
3007 * SME will anyway ignore DEAUTH_IND that was sent
3008 * for deauth frame.
3009 */
3010 limLog(pMac, LOG1, FL("Rcvd SME_DEAUTH_REQ while in "
3011 "SME_WT_DEAUTH_STATE. "));
3012 break;
Padma, Santhosh Kumar05600d32015-07-24 13:00:57 +05303013 case eLIM_SME_WT_DISASSOC_STATE:
3014 /*
3015 * PE Recieved a Disassoc frame. Normally it gets
3016 * DISASSOC_CNF but it received DEAUTH_REQ. This means
3017 * host is also trying to disconnect.
3018 */
3019 limLog(pMac, LOG1, FL("Rcvd SME_DEAUTH_REQ while in "
3020 "SME_WT_DISASSOC_STATE. "));
3021 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003022 default:
3023 /**
3024 * STA is not in a state to deauthenticate with
3025 * peer. Log error and send response to host.
3026 */
3027 limLog(pMac, LOGE,
Sushant Kaushik1b645382014-10-13 16:39:36 +05303028 FL("received unexp SME_DEAUTH_REQ in state %d"),
Abhishek Singhcd09b562013-12-24 16:02:20 +05303029 psessionEntry->limSmeState);
Jeff Johnson295189b2012-06-20 16:38:30 -07003030 limPrintSmeState(pMac, LOGE, psessionEntry->limSmeState);
3031
3032 if (pMac->lim.gLimRspReqd)
3033 {
3034 pMac->lim.gLimRspReqd = false;
3035
3036 retCode = eSIR_SME_STA_NOT_AUTHENTICATED;
3037 deauthTrigger = eLIM_HOST_DEAUTH;
Leela Venkata Kiran Kumar Reddy Chirala56df73f2014-01-30 14:18:00 -08003038 /**
3039 *here we received deauth request from AP so sme state is
3040 eLIM_SME_WT_DEAUTH_STATE.if we have ISSUED delSta then
3041 mlm state should be eLIM_MLM_WT_DEL_STA_RSP_STATE and if
3042 we got delBSS rsp then mlm state should be eLIM_MLM_IDLE_STATE
3043 so the below condition captures the state where delSta
3044 not done and firmware still in connected state.
3045 */
3046 if (psessionEntry->limSmeState == eLIM_SME_WT_DEAUTH_STATE &&
3047 psessionEntry->limMlmState != eLIM_MLM_IDLE_STATE &&
3048 psessionEntry->limMlmState != eLIM_MLM_WT_DEL_STA_RSP_STATE)
3049 {
3050 retCode = eSIR_SME_DEAUTH_STATUS;
3051 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003052 goto sendDeauth;
3053 }
3054
3055 return;
3056 }
3057
3058 break;
3059
3060 case eLIM_STA_IN_IBSS_ROLE:
Abhishek Singh92fbac22015-03-24 17:57:36 +05303061 limLog(pMac, LOGE,FL("Deauth not allowed in IBSS"));
3062 if (pMac->lim.gLimRspReqd)
3063 {
3064 pMac->lim.gLimRspReqd = false;
3065 retCode = eSIR_SME_INVALID_PARAMETERS;
3066 deauthTrigger = eLIM_HOST_DEAUTH;
3067 goto sendDeauth;
3068 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003069 return;
3070
3071 case eLIM_AP_ROLE:
3072 // Fall through
3073
3074 break;
3075
3076 default:
3077 limLog(pMac, LOGE,
Sushant Kaushik1b645382014-10-13 16:39:36 +05303078 FL("received unexpected SME_DEAUTH_REQ for role %d"),
Abhishek Singhcd09b562013-12-24 16:02:20 +05303079 psessionEntry->limSystemRole);
Abhishek Singh92fbac22015-03-24 17:57:36 +05303080 if (pMac->lim.gLimRspReqd)
3081 {
3082 pMac->lim.gLimRspReqd = false;
Jeff Johnson295189b2012-06-20 16:38:30 -07003083
Abhishek Singh92fbac22015-03-24 17:57:36 +05303084 retCode = eSIR_SME_INVALID_PARAMETERS;
3085 deauthTrigger = eLIM_HOST_DEAUTH;
3086 goto sendDeauth;
3087 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003088 return;
Abhishek Singh92fbac22015-03-24 17:57:36 +05303089
Jeff Johnson295189b2012-06-20 16:38:30 -07003090 } // end switch (pMac->lim.gLimSystemRole)
3091
3092 if (smeDeauthReq.reasonCode == eLIM_LINK_MONITORING_DEAUTH)
3093 {
3094 /// Deauthentication is triggered by Link Monitoring
Abhishek Singh3cbf6052014-12-15 16:46:42 +05303095 limLog(pMac, LOG1,
3096 FL("Deauthentication is triggered by Link Monitoring"));
3097 limLog(pMac, LOG1,
3098 FL("Set Trigger to eLIM_LINK_MONITORING_DEAUTH"));
3099 limLog(pMac, LOG1,
3100 FL("and Reason to eSIR_MAC_UNSPEC_FAILURE_REASON"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003101 deauthTrigger = eLIM_LINK_MONITORING_DEAUTH;
3102 reasonCode = eSIR_MAC_UNSPEC_FAILURE_REASON;
3103 }
3104 else
3105 {
3106 deauthTrigger = eLIM_HOST_DEAUTH;
3107 reasonCode = smeDeauthReq.reasonCode;
3108 }
3109
3110 // Trigger Deauthentication frame to peer MAC entity
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303111 pMlmDeauthReq = vos_mem_malloc(sizeof(tLimMlmDeauthReq));
3112 if ( NULL == pMlmDeauthReq )
Jeff Johnson295189b2012-06-20 16:38:30 -07003113 {
3114 // Log error
Abhishek Singh92fbac22015-03-24 17:57:36 +05303115 limLog(pMac, LOGE,
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303116 FL("call to AllocateMemory failed for mlmDeauthReq"));
Abhishek Singh92fbac22015-03-24 17:57:36 +05303117 if (pMac->lim.gLimRspReqd)
3118 {
3119 pMac->lim.gLimRspReqd = false;
3120 retCode = eSIR_SME_RESOURCES_UNAVAILABLE;
3121 deauthTrigger = eLIM_HOST_DEAUTH;
3122 goto sendDeauth;
3123 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003124 return;
3125 }
3126
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303127 vos_mem_copy( (tANI_U8 *) &pMlmDeauthReq->peerMacAddr,
Jeff Johnson295189b2012-06-20 16:38:30 -07003128 (tANI_U8 *) &smeDeauthReq.peerMacAddr,
3129 sizeof(tSirMacAddr));
3130
3131 pMlmDeauthReq->reasonCode = reasonCode;
3132 pMlmDeauthReq->deauthTrigger = deauthTrigger;
Jeff Johnson295189b2012-06-20 16:38:30 -07003133
3134 /* Update PE session Id*/
3135 pMlmDeauthReq->sessionId = sessionId;
3136
3137 limPostMlmMessage(pMac,
3138 LIM_MLM_DEAUTH_REQ,
3139 (tANI_U32 *) pMlmDeauthReq);
3140 return;
3141
3142sendDeauth:
3143 limSendSmeDeauthNtf(pMac, smeDeauthReq.peerMacAddr,
3144 retCode,
3145 deauthTrigger,
Jeff Johnson295189b2012-06-20 16:38:30 -07003146 1,
Jeff Johnson295189b2012-06-20 16:38:30 -07003147 smesessionId, smetransactionId);
3148} /*** end __limProcessSmeDeauthReq() ***/
3149
3150
3151
3152/**
3153 * __limProcessSmeSetContextReq()
3154 *
3155 *FUNCTION:
3156 * This function is called to process SME_SETCONTEXT_REQ message
3157 * from HDD or upper layer application.
3158 *
3159 *LOGIC:
3160 *
3161 *ASSUMPTIONS:
3162 *
3163 *NOTE:
3164 *
3165 * @param pMac Pointer to Global MAC structure
3166 * @param *pMsgBuf A pointer to the SME message buffer
3167 * @return None
3168 */
3169
3170static void
3171__limProcessSmeSetContextReq(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
3172{
3173 tpSirSmeSetContextReq pSetContextReq;
3174 tLimMlmSetKeysReq *pMlmSetKeysReq;
3175 tpPESession psessionEntry;
3176 tANI_U8 sessionId; //PE sessionID
3177 tANI_U8 smesessionId;
3178 tANI_U16 smetransactionId;
3179
3180
3181 PELOG1(limLog(pMac, LOG1,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003182 FL("received SETCONTEXT_REQ message")););
Jeff Johnson295189b2012-06-20 16:38:30 -07003183
3184
3185 if(pMsgBuf == NULL)
3186 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003187 limLog(pMac, LOGE,FL("Buffer is Pointing to NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003188 return;
3189 }
3190
3191 limGetSessionInfo(pMac,(tANI_U8 *)pMsgBuf,&smesessionId,&smetransactionId);
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303192
3193 pSetContextReq = vos_mem_malloc(sizeof(tSirKeys) * SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS);
3194 if ( NULL == pSetContextReq )
Jeff Johnson295189b2012-06-20 16:38:30 -07003195 {
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303196 limLog(pMac, LOGP, FL("call to AllocateMemory failed for pSetContextReq"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003197 return;
3198 }
3199
3200 if ((limSetContextReqSerDes(pMac, pSetContextReq, (tANI_U8 *) pMsgBuf) == eSIR_FAILURE) ||
3201 (!limIsSmeSetContextReqValid(pMac, pSetContextReq)))
3202 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003203 limLog(pMac, LOGW, FL("received invalid SME_SETCONTEXT_REQ message"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003204 goto end;
3205 }
3206
3207 if(pSetContextReq->keyMaterial.numKeys > SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS)
3208 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003209 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 -07003210 limSendSmeSetContextRsp(pMac,
3211 pSetContextReq->peerMacAddr,
Jeff Johnson295189b2012-06-20 16:38:30 -07003212 1,
Jeff Johnson295189b2012-06-20 16:38:30 -07003213 eSIR_SME_INVALID_PARAMETERS,NULL,
3214 smesessionId,smetransactionId);
3215
3216 goto end;
3217 }
3218
3219
3220 if((psessionEntry = peFindSessionByBssid(pMac, pSetContextReq->bssId, &sessionId)) == NULL)
3221 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003222 limLog(pMac, LOGW, FL("Session does not exist for given BSSID"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003223 limSendSmeSetContextRsp(pMac,
3224 pSetContextReq->peerMacAddr,
Jeff Johnson295189b2012-06-20 16:38:30 -07003225 1,
Jeff Johnson295189b2012-06-20 16:38:30 -07003226 eSIR_SME_INVALID_PARAMETERS,NULL,
3227 smesessionId,smetransactionId);
3228
3229 goto end;
3230 }
3231
3232#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM //FEATURE_WLAN_DIAG_SUPPORT
3233 limDiagEventReport(pMac, WLAN_PE_DIAG_SETCONTEXT_REQ_EVENT, psessionEntry, 0, 0);
3234#endif //FEATURE_WLAN_DIAG_SUPPORT
3235
3236
3237 if ((((psessionEntry->limSystemRole == eLIM_STA_ROLE) || (psessionEntry->limSystemRole == eLIM_BT_AMP_STA_ROLE)) &&
3238 (psessionEntry->limSmeState == eLIM_SME_LINK_EST_STATE)) ||
3239 (((psessionEntry->limSystemRole == eLIM_STA_IN_IBSS_ROLE) ||
3240 (psessionEntry->limSystemRole == eLIM_AP_ROLE)|| (psessionEntry->limSystemRole == eLIM_BT_AMP_AP_ROLE)) &&
3241 (psessionEntry->limSmeState == eLIM_SME_NORMAL_STATE)))
3242 {
3243 // Trigger MLM_SETKEYS_REQ
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303244 pMlmSetKeysReq = vos_mem_malloc(sizeof(tLimMlmSetKeysReq));
3245 if ( NULL == pMlmSetKeysReq )
Jeff Johnson295189b2012-06-20 16:38:30 -07003246 {
3247 // Log error
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303248 limLog(pMac, LOGP, FL("call to AllocateMemory failed for mlmSetKeysReq"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003249 goto end;
3250 }
Abhishek Singhb25e8442015-06-23 14:28:05 +05303251 vos_mem_zero(pMlmSetKeysReq,sizeof(tLimMlmSetKeysReq));
Jeff Johnson295189b2012-06-20 16:38:30 -07003252 pMlmSetKeysReq->edType = pSetContextReq->keyMaterial.edType;
3253 pMlmSetKeysReq->numKeys = pSetContextReq->keyMaterial.numKeys;
3254 if(pMlmSetKeysReq->numKeys > SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS)
3255 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003256 limLog(pMac, LOGP, FL("Num of keys exceeded max num of default keys limit"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003257 goto end;
3258 }
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303259 vos_mem_copy( (tANI_U8 *) &pMlmSetKeysReq->peerMacAddr,
Jeff Johnson295189b2012-06-20 16:38:30 -07003260 (tANI_U8 *) &pSetContextReq->peerMacAddr,
3261 sizeof(tSirMacAddr));
3262
Jeff Johnson295189b2012-06-20 16:38:30 -07003263
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303264 vos_mem_copy( (tANI_U8 *) &pMlmSetKeysReq->key,
Jeff Johnson295189b2012-06-20 16:38:30 -07003265 (tANI_U8 *) &pSetContextReq->keyMaterial.key,
3266 sizeof(tSirKeys) * (pMlmSetKeysReq->numKeys ? pMlmSetKeysReq->numKeys : 1));
3267
3268 pMlmSetKeysReq->sessionId = sessionId;
3269#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
3270 PELOG1(limLog(pMac, LOG1,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003271 FL("received SETCONTEXT_REQ message sessionId=%d"), pMlmSetKeysReq->sessionId););
Jeff Johnson295189b2012-06-20 16:38:30 -07003272#endif
3273
Jeff Johnson295189b2012-06-20 16:38:30 -07003274 if(((pSetContextReq->keyMaterial.edType == eSIR_ED_WEP40) || (pSetContextReq->keyMaterial.edType == eSIR_ED_WEP104))
3275 && (psessionEntry->limSystemRole == eLIM_AP_ROLE))
3276 {
3277 if(pSetContextReq->keyMaterial.key[0].keyLength)
3278 {
3279 tANI_U8 keyId;
3280 keyId = pSetContextReq->keyMaterial.key[0].keyId;
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303281 vos_mem_copy( (tANI_U8 *)&psessionEntry->WEPKeyMaterial[keyId],
Jeff Johnson295189b2012-06-20 16:38:30 -07003282 (tANI_U8 *) &pSetContextReq->keyMaterial, sizeof(tSirKeyMaterial));
3283 }
3284 else {
3285 tANI_U32 i;
3286 for( i = 0; i < SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS; i++)
3287 {
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303288 vos_mem_copy( (tANI_U8 *) &pMlmSetKeysReq->key[i],
Jeff Johnson295189b2012-06-20 16:38:30 -07003289 (tANI_U8 *)psessionEntry->WEPKeyMaterial[i].key, sizeof(tSirKeys));
3290 }
3291 }
3292 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003293
3294 limPostMlmMessage(pMac, LIM_MLM_SETKEYS_REQ, (tANI_U32 *) pMlmSetKeysReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07003295 }
3296 else
3297 {
3298 limLog(pMac, LOGE,
Sushant Kaushik1b645382014-10-13 16:39:36 +05303299 FL("received unexpected SME_SETCONTEXT_REQ for role %d, state=%d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07003300 psessionEntry->limSystemRole,
3301 psessionEntry->limSmeState);
3302 limPrintSmeState(pMac, LOGE, psessionEntry->limSmeState);
3303
3304 limSendSmeSetContextRsp(pMac, pSetContextReq->peerMacAddr,
Jeff Johnson295189b2012-06-20 16:38:30 -07003305 1,
Jeff Johnson295189b2012-06-20 16:38:30 -07003306 eSIR_SME_UNEXPECTED_REQ_RESULT_CODE,psessionEntry,
3307 smesessionId,
3308 smetransactionId);
3309 }
3310
3311end:
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05303312 vos_mem_zero(pSetContextReq,
3313 (sizeof(tSirKeys) * SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS));
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303314 vos_mem_free( pSetContextReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07003315 return;
3316} /*** end __limProcessSmeSetContextReq() ***/
3317
3318/**
3319 * __limProcessSmeRemoveKeyReq()
3320 *
3321 *FUNCTION:
3322 * This function is called to process SME_REMOVEKEY_REQ message
3323 * from HDD or upper layer application.
3324 *
3325 *LOGIC:
3326 *
3327 *ASSUMPTIONS:
3328 *
3329 *NOTE:
3330 *
3331 * @param pMac Pointer to Global MAC structure
3332 * @param *pMsgBuf A pointer to the SME message buffer
3333 * @return None
3334 */
3335
3336static void
3337__limProcessSmeRemoveKeyReq(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
3338{
3339 tpSirSmeRemoveKeyReq pRemoveKeyReq;
3340 tLimMlmRemoveKeyReq *pMlmRemoveKeyReq;
3341 tpPESession psessionEntry;
3342 tANI_U8 sessionId; //PE sessionID
3343 tANI_U8 smesessionId;
3344 tANI_U16 smetransactionId;
3345
Abhishek Singh3cbf6052014-12-15 16:46:42 +05303346 limLog(pMac, LOG1,
3347 FL("received SME_REMOVEKEY_REQ message"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003348
3349 if(pMsgBuf == NULL)
3350 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003351 limLog(pMac, LOGE,FL("Buffer is Pointing to NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003352 return;
3353 }
3354
3355
3356 limGetSessionInfo(pMac,(tANI_U8 *)pMsgBuf,&smesessionId,&smetransactionId);
3357
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303358 pRemoveKeyReq = vos_mem_malloc(sizeof(*pRemoveKeyReq));
3359 if ( NULL == pRemoveKeyReq )
Jeff Johnson295189b2012-06-20 16:38:30 -07003360 {
3361 //Log error
3362 limLog(pMac, LOGP,
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303363 FL("call to AllocateMemory failed for pRemoveKeyReq"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003364
3365 return;
3366 }
3367
3368 if ((limRemoveKeyReqSerDes(pMac,
3369 pRemoveKeyReq,
3370 (tANI_U8 *) pMsgBuf) == eSIR_FAILURE))
3371 {
3372 limLog(pMac, LOGW,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003373 FL("received invalid SME_REMOVECONTEXT_REQ message"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003374
3375 /* extra look up is needed since, session entry to be passed il limsendremovekey response */
3376
3377 if((psessionEntry = peFindSessionByBssid(pMac,pRemoveKeyReq->bssId,&sessionId))== NULL)
3378 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003379 limLog(pMac, LOGE,FL("session does not exist for given bssId"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003380 //goto end;
3381 }
3382
3383 limSendSmeRemoveKeyRsp(pMac,
3384 pRemoveKeyReq->peerMacAddr,
3385 eSIR_SME_INVALID_PARAMETERS,psessionEntry,
3386 smesessionId,smetransactionId);
3387
3388 goto end;
3389 }
3390
3391 if((psessionEntry = peFindSessionByBssid(pMac,pRemoveKeyReq->bssId, &sessionId))== NULL)
3392 {
3393 limLog(pMac, LOGE,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003394 FL("session does not exist for given bssId"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003395 limSendSmeRemoveKeyRsp(pMac,
3396 pRemoveKeyReq->peerMacAddr,
3397 eSIR_SME_UNEXPECTED_REQ_RESULT_CODE, NULL,
3398 smesessionId, smetransactionId);
3399 goto end;
3400 }
3401
3402
3403 if ((((psessionEntry->limSystemRole == eLIM_STA_ROLE)|| (psessionEntry->limSystemRole == eLIM_BT_AMP_STA_ROLE))&&
3404 (psessionEntry->limSmeState == eLIM_SME_LINK_EST_STATE)) ||
3405 (((psessionEntry->limSystemRole == eLIM_STA_IN_IBSS_ROLE) ||
3406 (psessionEntry->limSystemRole == eLIM_AP_ROLE)|| (psessionEntry->limSystemRole == eLIM_BT_AMP_AP_ROLE)) &&
3407 (psessionEntry->limSmeState == eLIM_SME_NORMAL_STATE)))
3408 {
3409 // Trigger MLM_REMOVEKEYS_REQ
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303410 pMlmRemoveKeyReq = vos_mem_malloc(sizeof(tLimMlmRemoveKeyReq));
3411 if ( NULL == pMlmRemoveKeyReq )
Jeff Johnson295189b2012-06-20 16:38:30 -07003412 {
3413 // Log error
3414 limLog(pMac, LOGP,
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303415 FL("call to AllocateMemory failed for mlmRemoveKeysReq"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003416
3417 goto end;
3418 }
3419
3420 pMlmRemoveKeyReq->edType = (tAniEdType)pRemoveKeyReq->edType;
3421 pMlmRemoveKeyReq->keyId = pRemoveKeyReq->keyId;
3422 pMlmRemoveKeyReq->wepType = pRemoveKeyReq->wepType;
3423 pMlmRemoveKeyReq->unicast = pRemoveKeyReq->unicast;
3424
3425 /* Update PE session Id */
3426 pMlmRemoveKeyReq->sessionId = sessionId;
3427
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303428 vos_mem_copy( (tANI_U8 *) &pMlmRemoveKeyReq->peerMacAddr,
Jeff Johnson295189b2012-06-20 16:38:30 -07003429 (tANI_U8 *) &pRemoveKeyReq->peerMacAddr,
3430 sizeof(tSirMacAddr));
3431
3432
3433 limPostMlmMessage(pMac,
3434 LIM_MLM_REMOVEKEY_REQ,
3435 (tANI_U32 *) pMlmRemoveKeyReq);
3436 }
3437 else
3438 {
3439 limLog(pMac, LOGE,
Sushant Kaushik1b645382014-10-13 16:39:36 +05303440 FL("received unexpected SME_REMOVEKEY_REQ for role %d, state=%d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07003441 psessionEntry->limSystemRole,
3442 psessionEntry->limSmeState);
3443 limPrintSmeState(pMac, LOGE, psessionEntry->limSmeState);
3444
3445 limSendSmeRemoveKeyRsp(pMac,
3446 pRemoveKeyReq->peerMacAddr,
3447 eSIR_SME_UNEXPECTED_REQ_RESULT_CODE,psessionEntry,
3448 smesessionId,smetransactionId);
3449 }
3450
3451end:
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303452 vos_mem_free( pRemoveKeyReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07003453} /*** end __limProcessSmeRemoveKeyReq() ***/
3454
Jeff Johnson295189b2012-06-20 16:38:30 -07003455void limProcessSmeGetScanChannelInfo(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
3456{
3457 tSirMsgQ mmhMsg;
3458 tpSmeGetScanChnRsp pSirSmeRsp;
3459 tANI_U16 len = 0;
Madan Mohan Koyyalamudide1b5bc2013-07-12 00:56:04 +05303460 tANI_U8 sessionId;
3461 tANI_U16 transactionId;
Jeff Johnson295189b2012-06-20 16:38:30 -07003462
3463 if(pMac->lim.scanChnInfo.numChnInfo > SIR_MAX_SUPPORTED_CHANNEL_LIST)
3464 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003465 limLog(pMac, LOGW, FL("numChn is out of bounds %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07003466 pMac->lim.scanChnInfo.numChnInfo);
3467 pMac->lim.scanChnInfo.numChnInfo = SIR_MAX_SUPPORTED_CHANNEL_LIST;
3468 }
3469
Abhishek Singh525045c2014-12-15 17:18:45 +05303470 limLog(pMac, LOG1,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003471 FL("Sending message %s with number of channels %d"),
Abhishek Singh525045c2014-12-15 17:18:45 +05303472 limMsgStr(eWNI_SME_GET_SCANNED_CHANNEL_RSP), pMac->lim.scanChnInfo.numChnInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -07003473
3474 len = sizeof(tSmeGetScanChnRsp) + (pMac->lim.scanChnInfo.numChnInfo - 1) * sizeof(tLimScanChn);
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303475 pSirSmeRsp = vos_mem_malloc(len);
3476 if ( NULL == pSirSmeRsp )
Jeff Johnson295189b2012-06-20 16:38:30 -07003477 {
3478 /// Buffer not available. Log error
3479 limLog(pMac, LOGP,
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303480 FL("call to AllocateMemory failed for JOIN/REASSOC_RSP"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003481
3482 return;
3483 }
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303484 vos_mem_set(pSirSmeRsp, len, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07003485
Jeff Johnson295189b2012-06-20 16:38:30 -07003486 pSirSmeRsp->mesgType = eWNI_SME_GET_SCANNED_CHANNEL_RSP;
3487 pSirSmeRsp->mesgLen = len;
Madan Mohan Koyyalamudide1b5bc2013-07-12 00:56:04 +05303488
3489 if (pMac->fScanOffload)
3490 {
3491 limGetSessionInfo(pMac,(tANI_U8 *)pMsgBuf,&sessionId,&transactionId);
3492 pSirSmeRsp->sessionId = sessionId;
3493 }
3494 else
3495 pSirSmeRsp->sessionId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003496
3497 if(pMac->lim.scanChnInfo.numChnInfo)
3498 {
3499 pSirSmeRsp->numChn = pMac->lim.scanChnInfo.numChnInfo;
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303500 vos_mem_copy( pSirSmeRsp->scanChn, pMac->lim.scanChnInfo.scanChn,
3501 sizeof(tLimScanChn) * pSirSmeRsp->numChn);
Jeff Johnson295189b2012-06-20 16:38:30 -07003502 }
3503 //Clear the list
3504 limRessetScanChannelInfo(pMac);
3505
3506 mmhMsg.type = eWNI_SME_GET_SCANNED_CHANNEL_RSP;
3507 mmhMsg.bodyptr = pSirSmeRsp;
3508 mmhMsg.bodyval = 0;
3509
3510 pMac->lim.gLimRspReqd = false;
Konamki, Sreelakshmi824f93e2015-07-31 12:55:48 +05303511 MTRACE(macTrace(pMac, TRACE_CODE_TX_SME_MSG, NO_SESSION, mmhMsg.type));
Jeff Johnson295189b2012-06-20 16:38:30 -07003512 limSysProcessMmhMsgApi(pMac, &mmhMsg, ePROT);
3513}
3514
3515
Jeff Johnson295189b2012-06-20 16:38:30 -07003516void limProcessSmeGetAssocSTAsInfo(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
3517{
Hanumantha Reddy Pothula0de10802016-02-11 17:29:27 +05303518 tSirSmeGetAssocSTAsReq getAssocSTAsReq = {0};
Jeff Johnson295189b2012-06-20 16:38:30 -07003519 tpDphHashNode pStaDs = NULL;
3520 tpPESession psessionEntry = NULL;
3521 tSap_Event sapEvent;
3522 tpWLAN_SAPEventCB pSapEventCallback = NULL;
3523 tpSap_AssocMacAddr pAssocStasTemp = NULL;// #include "sapApi.h"
3524 tANI_U8 sessionId = CSR_SESSION_ID_INVALID;
3525 tANI_U8 assocId = 0;
3526 tANI_U8 staCount = 0;
3527
3528 if (!limIsSmeGetAssocSTAsReqValid(pMac, &getAssocSTAsReq, (tANI_U8 *) pMsgBuf))
3529 {
3530 limLog(pMac, LOGE,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003531 FL("received invalid eWNI_SME_GET_ASSOC_STAS_REQ message"));
Girish Gowliafd42312014-07-24 13:13:59 +05303532 return;
Jeff Johnson295189b2012-06-20 16:38:30 -07003533 }
3534
3535 switch (getAssocSTAsReq.modId)
3536 {
3537/**
3538 case VOS_MODULE_ID_HAL:
3539 wdaPostCtrlMsg( pMac, &msgQ );
3540 return;
3541
3542 case VOS_MODULE_ID_TL:
3543 Post msg TL
3544 return;
3545*/
3546 case VOS_MODULE_ID_PE:
3547 default:
3548 break;
3549 }
3550
Jeff Johnson1250df42012-12-10 14:31:52 -08003551 // Get Associated stations from PE
Jeff Johnson295189b2012-06-20 16:38:30 -07003552 // Find PE session Entry
3553 if ((psessionEntry = peFindSessionByBssid(pMac, getAssocSTAsReq.bssId, &sessionId)) == NULL)
3554 {
3555 limLog(pMac, LOGE,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003556 FL("session does not exist for given bssId"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003557 goto limAssocStaEnd;
3558 }
3559
3560 if (psessionEntry->limSystemRole != eLIM_AP_ROLE)
3561 {
3562 limLog(pMac, LOGE,
Sushant Kaushik1b645382014-10-13 16:39:36 +05303563 FL("Received unexpected message in state %d, in role %d"),
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303564 psessionEntry->limSmeState, psessionEntry->limSystemRole);
Jeff Johnson295189b2012-06-20 16:38:30 -07003565 goto limAssocStaEnd;
3566 }
3567
3568 // Retrieve values obtained in the request message
3569 pSapEventCallback = (tpWLAN_SAPEventCB)getAssocSTAsReq.pSapEventCallback;
3570 pAssocStasTemp = (tpSap_AssocMacAddr)getAssocSTAsReq.pAssocStasArray;
3571
3572 for (assocId = 0; assocId < psessionEntry->dph.dphHashTable.size; assocId++)// Softap dphHashTable.size = 8
3573 {
3574 pStaDs = dphGetHashEntry(pMac, assocId, &psessionEntry->dph.dphHashTable);
3575
Abhishek Singh8a99b9f2015-03-31 14:18:26 +05303576 if ((NULL == pStaDs) || (NULL == pAssocStasTemp))
Jeff Johnson295189b2012-06-20 16:38:30 -07003577 continue;
3578
3579 if (pStaDs->valid)
3580 {
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303581 vos_mem_copy((tANI_U8 *)&pAssocStasTemp->staMac,
3582 (tANI_U8 *)&pStaDs->staAddr,
3583 sizeof(v_MACADDR_t)); // Mac address
Jeff Johnson295189b2012-06-20 16:38:30 -07003584 pAssocStasTemp->assocId = (v_U8_t)pStaDs->assocId; // Association Id
3585 pAssocStasTemp->staId = (v_U8_t)pStaDs->staIndex; // Station Id
3586
Kiet Lamb1233192013-11-28 13:38:20 +05303587 vos_mem_copy((tANI_U8 *)&pAssocStasTemp->supportedRates,
Leo Chang614d2072013-08-22 14:59:44 -07003588 (tANI_U8 *)&pStaDs->supportedRates,
3589 sizeof(tSirSupportedRates));
3590 pAssocStasTemp->ShortGI40Mhz = pStaDs->htShortGI40Mhz;
3591 pAssocStasTemp->ShortGI20Mhz = pStaDs->htShortGI20Mhz;
3592 pAssocStasTemp->Support40Mhz = pStaDs->htDsssCckRate40MHzSupport;
3593
Jeff Johnson295189b2012-06-20 16:38:30 -07003594 limLog(pMac, LOG1, FL("dph Station Number = %d"), staCount+1);
Arif Hussain24bafea2013-11-15 15:10:03 -08003595 limLog(pMac, LOG1, FL("MAC = " MAC_ADDRESS_STR),
3596 MAC_ADDR_ARRAY(pStaDs->staAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07003597 limLog(pMac, LOG1, FL("Association Id = %d"),pStaDs->assocId);
3598 limLog(pMac, LOG1, FL("Station Index = %d"),pStaDs->staIndex);
3599
3600 pAssocStasTemp++;
3601 staCount++;
3602 }
3603 }
3604
3605limAssocStaEnd:
3606 // Call hdd callback with sap event to send the list of associated stations from PE
3607 if (pSapEventCallback != NULL)
3608 {
3609 sapEvent.sapHddEventCode = eSAP_ASSOC_STA_CALLBACK_EVENT;
3610 sapEvent.sapevt.sapAssocStaListEvent.module = VOS_MODULE_ID_PE;
3611 sapEvent.sapevt.sapAssocStaListEvent.noOfAssocSta = staCount;
3612 sapEvent.sapevt.sapAssocStaListEvent.pAssocStas = (tpSap_AssocMacAddr)getAssocSTAsReq.pAssocStasArray;
3613 pSapEventCallback(&sapEvent, getAssocSTAsReq.pUsrContext);
3614 }
3615}
3616
3617
3618/**
3619 * limProcessSmeGetWPSPBCSessions
3620 *
3621 *FUNCTION:
3622 * This function is called when query the WPS PBC overlap message is received
3623 *
3624 *LOGIC:
3625 * This function parses get WPS PBC overlap information message and call callback to pass
3626 * WPS PBC overlap information back to hdd.
3627 *ASSUMPTIONS:
3628 *
3629 *
3630 *NOTE:
3631 *
3632 * @param pMac Pointer to Global MAC structure
3633 * @param pMsgBuf A pointer to WPS PBC overlap query message
3634*
3635 * @return None
3636 */
3637void limProcessSmeGetWPSPBCSessions(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
3638{
3639 tSirSmeGetWPSPBCSessionsReq GetWPSPBCSessionsReq;
3640 tpPESession psessionEntry = NULL;
3641 tSap_Event sapEvent;
3642 tpWLAN_SAPEventCB pSapEventCallback = NULL;
3643 tANI_U8 sessionId = CSR_SESSION_ID_INVALID;
3644 tSirMacAddr zeroMac = {0,0,0,0,0,0};
3645
3646 sapEvent.sapevt.sapGetWPSPBCSessionEvent.status = VOS_STATUS_E_FAULT;
3647
3648 if (limIsSmeGetWPSPBCSessionsReqValid(pMac, &GetWPSPBCSessionsReq, (tANI_U8 *) pMsgBuf) != eSIR_SUCCESS)
3649 {
3650 limLog(pMac, LOGE,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003651 FL("received invalid eWNI_SME_GET_ASSOC_STAS_REQ message"));
Girish Gowliafd42312014-07-24 13:13:59 +05303652 return;
Jeff Johnson295189b2012-06-20 16:38:30 -07003653 }
3654
Jeff Johnson1250df42012-12-10 14:31:52 -08003655 // Get Associated stations from PE
Jeff Johnson295189b2012-06-20 16:38:30 -07003656 // Find PE session Entry
3657 if ((psessionEntry = peFindSessionByBssid(pMac, GetWPSPBCSessionsReq.bssId, &sessionId)) == NULL)
3658 {
3659 limLog(pMac, LOGE,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003660 FL("session does not exist for given bssId"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003661 goto limGetWPSPBCSessionsEnd;
3662 }
3663
3664 if (psessionEntry->limSystemRole != eLIM_AP_ROLE)
3665 {
3666 limLog(pMac, LOGE,
Sushant Kaushik1b645382014-10-13 16:39:36 +05303667 FL("Received unexpected message in role %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07003668 psessionEntry->limSystemRole);
3669 goto limGetWPSPBCSessionsEnd;
3670 }
3671
Jeff Johnson1250df42012-12-10 14:31:52 -08003672 // Call hdd callback with sap event to send the WPS PBC overlap information
Jeff Johnson295189b2012-06-20 16:38:30 -07003673 sapEvent.sapHddEventCode = eSAP_GET_WPSPBC_SESSION_EVENT;
3674 sapEvent.sapevt.sapGetWPSPBCSessionEvent.module = VOS_MODULE_ID_PE;
3675
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303676 if (vos_mem_compare( zeroMac, GetWPSPBCSessionsReq.pRemoveMac, sizeof(tSirMacAddr)))
Jeff Johnson295189b2012-06-20 16:38:30 -07003677 { //This is GetWpsSession call
3678
3679 limGetWPSPBCSessions(pMac,
3680 sapEvent.sapevt.sapGetWPSPBCSessionEvent.addr.bytes, sapEvent.sapevt.sapGetWPSPBCSessionEvent.UUID_E,
3681 &sapEvent.sapevt.sapGetWPSPBCSessionEvent.wpsPBCOverlap, psessionEntry);
3682 }
3683 else
3684 {
3685 limRemovePBCSessions(pMac, GetWPSPBCSessionsReq.pRemoveMac,psessionEntry);
3686 /* don't have to inform the HDD/Host */
3687 return;
3688 }
3689
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003690 PELOG4(limLog(pMac, LOGE, FL("wpsPBCOverlap %d"), sapEvent.sapevt.sapGetWPSPBCSessionEvent.wpsPBCOverlap);)
Jeff Johnson295189b2012-06-20 16:38:30 -07003691 PELOG4(limPrintMacAddr(pMac, sapEvent.sapevt.sapGetWPSPBCSessionEvent.addr.bytes, LOG4);)
3692
3693 sapEvent.sapevt.sapGetWPSPBCSessionEvent.status = VOS_STATUS_SUCCESS;
3694
3695limGetWPSPBCSessionsEnd:
3696 pSapEventCallback = (tpWLAN_SAPEventCB)GetWPSPBCSessionsReq.pSapEventCallback;
Abhishek Singh8a99b9f2015-03-31 14:18:26 +05303697
3698 if (NULL != pSapEventCallback)
3699 pSapEventCallback(&sapEvent, GetWPSPBCSessionsReq.pUsrContext);
Jeff Johnson295189b2012-06-20 16:38:30 -07003700}
3701
Jeff Johnson295189b2012-06-20 16:38:30 -07003702
3703
3704/**
3705 * __limCounterMeasures()
3706 *
3707 * FUNCTION:
3708 * This function is called to "implement" MIC counter measure
3709 * and is *temporary* only
3710 *
3711 * LOGIC: on AP, disassoc all STA associated thru TKIP,
3712 * we don't do the proper STA disassoc sequence since the
3713 * BSS will be stoped anyway
3714 *
3715 *ASSUMPTIONS:
3716 *
3717 *NOTE:
3718 *
3719 * @param pMac Pointer to Global MAC structure
3720 * @return None
3721 */
3722
3723static void
3724__limCounterMeasures(tpAniSirGlobal pMac, tpPESession psessionEntry)
3725{
3726 tSirMacAddr mac = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
Abhishek Singh8944b222014-09-17 16:13:17 +05303727 /* If PMF is enabled then don't send broadcast disassociation */
3728 if ( ( (psessionEntry->limSystemRole == eLIM_AP_ROLE) ||
3729 (psessionEntry->limSystemRole == eLIM_BT_AMP_AP_ROLE) ||
3730 (psessionEntry->limSystemRole == eLIM_BT_AMP_STA_ROLE))
3731#ifdef WLAN_FEATURE_11W
3732 && !psessionEntry->limRmfEnabled
3733#endif
3734 )
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003735 limSendDisassocMgmtFrame(pMac, eSIR_MAC_MIC_FAILURE_REASON, mac, psessionEntry, FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003736
Jeff Johnson295189b2012-06-20 16:38:30 -07003737};
3738
3739
Jeff Johnson295189b2012-06-20 16:38:30 -07003740void
3741limProcessTkipCounterMeasures(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
3742{
3743 tSirSmeTkipCntrMeasReq tkipCntrMeasReq;
3744 tpPESession psessionEntry;
3745 tANI_U8 sessionId; //PE sessionId
3746
3747 if ( limTkipCntrMeasReqSerDes( pMac, &tkipCntrMeasReq, (tANI_U8 *) pMsgBuf ) != eSIR_SUCCESS )
3748 {
3749 limLog(pMac, LOGE,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003750 FL("received invalid eWNI_SME_TKIP_CNTR_MEAS_REQ message"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003751 return;
3752 }
3753
3754 if ( NULL == (psessionEntry = peFindSessionByBssid( pMac, tkipCntrMeasReq.bssId, &sessionId )) )
3755 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003756 limLog(pMac, LOGE, FL("session does not exist for given BSSID "));
Jeff Johnson295189b2012-06-20 16:38:30 -07003757 return;
3758 }
3759
3760 if ( tkipCntrMeasReq.bEnable )
3761 {
3762 __limCounterMeasures( pMac, psessionEntry );
3763 }
3764
3765 psessionEntry->bTkipCntrMeasActive = tkipCntrMeasReq.bEnable;
3766}
Jeff Johnson295189b2012-06-20 16:38:30 -07003767
3768
3769static void
3770__limHandleSmeStopBssRequest(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
3771{
3772 tSirSmeStopBssReq stopBssReq;
3773 tSirRetStatus status;
3774 tLimSmeStates prevState;
3775 tANI_U8 sessionId; //PE sessionId
3776 tpPESession psessionEntry;
3777 tANI_U8 smesessionId;
3778 tANI_U16 smetransactionId;
Sachin Ahuja51c08e62014-03-26 19:21:29 +05303779 tANI_U8 i = 0;
3780 tpDphHashNode pStaDs = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07003781
3782 limGetSessionInfo(pMac,(tANI_U8 *)pMsgBuf,&smesessionId,&smetransactionId);
3783
3784
3785
3786 if ((limStopBssReqSerDes(pMac, &stopBssReq, (tANI_U8 *) pMsgBuf) != eSIR_SUCCESS) ||
3787 !limIsSmeStopBssReqValid(pMsgBuf))
3788 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003789 PELOGW(limLog(pMac, LOGW, FL("received invalid SME_STOP_BSS_REQ message"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07003790 /// Send Stop BSS response to host
3791 limSendSmeRsp(pMac, eWNI_SME_STOP_BSS_RSP, eSIR_SME_INVALID_PARAMETERS,smesessionId,smetransactionId);
3792 return;
3793 }
3794
3795
3796 if((psessionEntry = peFindSessionByBssid(pMac,stopBssReq.bssId,&sessionId)) == NULL)
3797 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003798 limLog(pMac, LOGW, FL("session does not exist for given BSSID "));
Jeff Johnson295189b2012-06-20 16:38:30 -07003799 limSendSmeRsp(pMac, eWNI_SME_STOP_BSS_RSP, eSIR_SME_INVALID_PARAMETERS,smesessionId,smetransactionId);
3800 return;
3801 }
3802
3803#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM //FEATURE_WLAN_DIAG_SUPPORT
3804 limDiagEventReport(pMac, WLAN_PE_DIAG_STOP_BSS_REQ_EVENT, psessionEntry, 0, 0);
3805#endif //FEATURE_WLAN_DIAG_SUPPORT
3806
3807
3808 if ((psessionEntry->limSmeState != eLIM_SME_NORMAL_STATE) || /* Added For BT -AMP Support */
3809 (psessionEntry->limSystemRole == eLIM_STA_ROLE ))
3810 {
3811 /**
3812 * Should not have received STOP_BSS_REQ in states
3813 * other than 'normal' state or on STA in Infrastructure
3814 * mode. Log error and return response to host.
3815 */
3816 limLog(pMac, LOGE,
Sushant Kaushik1b645382014-10-13 16:39:36 +05303817 FL("received unexpected SME_STOP_BSS_REQ in state %d, for role %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07003818 psessionEntry->limSmeState, psessionEntry->limSystemRole);
3819 limPrintSmeState(pMac, LOGE, psessionEntry->limSmeState);
3820 /// Send Stop BSS response to host
3821 limSendSmeRsp(pMac, eWNI_SME_STOP_BSS_RSP, eSIR_SME_UNEXPECTED_REQ_RESULT_CODE,smesessionId,smetransactionId);
3822 return;
3823 }
3824
Jeff Johnson295189b2012-06-20 16:38:30 -07003825 if (psessionEntry->limSystemRole == eLIM_AP_ROLE )
3826 {
3827 limWPSPBCClose(pMac, psessionEntry);
3828 }
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003829 PELOGW(limLog(pMac, LOGW, FL("RECEIVED STOP_BSS_REQ with reason code=%d"), stopBssReq.reasonCode);)
Jeff Johnson295189b2012-06-20 16:38:30 -07003830
3831 prevState = psessionEntry->limSmeState;
3832
3833 psessionEntry->limSmeState = eLIM_SME_IDLE_STATE;
Jeff Johnsone7245742012-09-05 17:12:55 -07003834 MTRACE(macTrace(pMac, TRACE_CODE_SME_STATE, psessionEntry->peSessionId, psessionEntry->limSmeState));
Jeff Johnson295189b2012-06-20 16:38:30 -07003835
3836 /* Update SME session Id and Transaction Id */
3837 psessionEntry->smeSessionId = smesessionId;
3838 psessionEntry->transactionId = smetransactionId;
3839
Abhishek Singh8944b222014-09-17 16:13:17 +05303840 /* BTAMP_STA and STA_IN_IBSS should NOT send Disassoc frame.
3841 * If PMF is enabled then don't send broadcast disassociation */
3842 if ( ( (eLIM_STA_IN_IBSS_ROLE != psessionEntry->limSystemRole) &&
3843 (eLIM_BT_AMP_STA_ROLE != psessionEntry->limSystemRole) )
3844#ifdef WLAN_FEATURE_11W
3845 && !psessionEntry->limRmfEnabled
3846#endif
3847 )
Jeff Johnson295189b2012-06-20 16:38:30 -07003848 {
3849 tSirMacAddr bcAddr = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
3850 if ((stopBssReq.reasonCode == eSIR_SME_MIC_COUNTER_MEASURES))
3851 // Send disassoc all stations associated thru TKIP
3852 __limCounterMeasures(pMac,psessionEntry);
3853 else
Madan Mohan Koyyalamudi299b4862013-01-30 19:59:23 +05303854 limSendDisassocMgmtFrame(pMac, eSIR_MAC_DEAUTH_LEAVING_BSS_REASON, bcAddr, psessionEntry, FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003855 }
3856
3857 //limDelBss is also called as part of coalescing, when we send DEL BSS followed by Add Bss msg.
3858 pMac->lim.gLimIbssCoalescingHappened = false;
3859
Sachin Ahuja51c08e62014-03-26 19:21:29 +05303860 for(i = 1 ; i < pMac->lim.gLimAssocStaLimit ; i++)
3861 {
3862 pStaDs = dphGetHashEntry(pMac, i, &psessionEntry->dph.dphHashTable);
3863 if (NULL == pStaDs)
3864 continue;
3865 status = limDelSta(pMac, pStaDs, false, psessionEntry) ;
3866 if(eSIR_SUCCESS == status)
3867 {
3868 limDeleteDphHashEntry(pMac, pStaDs->staAddr, pStaDs->assocId, psessionEntry) ;
3869 limReleasePeerIdx(pMac, pStaDs->assocId, psessionEntry) ;
3870 }
3871 else
3872 {
3873 limLog(pMac, LOGE, FL("limDelSta failed with Status : %d"), status);
3874 VOS_ASSERT(0) ;
3875 }
3876 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003877 /* send a delBss to HAL and wait for a response */
3878 status = limDelBss(pMac, NULL,psessionEntry->bssIdx,psessionEntry);
3879
3880 if (status != eSIR_SUCCESS)
3881 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003882 PELOGE(limLog(pMac, LOGE, FL("delBss failed for bss %d"), psessionEntry->bssIdx);)
Jeff Johnson295189b2012-06-20 16:38:30 -07003883 psessionEntry->limSmeState= prevState;
3884
Jeff Johnsone7245742012-09-05 17:12:55 -07003885 MTRACE(macTrace(pMac, TRACE_CODE_SME_STATE, psessionEntry->peSessionId, psessionEntry->limSmeState));
Jeff Johnson295189b2012-06-20 16:38:30 -07003886
3887 limSendSmeRsp(pMac, eWNI_SME_STOP_BSS_RSP, eSIR_SME_STOP_BSS_FAILURE,smesessionId,smetransactionId);
3888 }
3889}
3890
3891
3892/**--------------------------------------------------------------
3893\fn __limProcessSmeStopBssReq
3894
3895\brief Wrapper for the function __limHandleSmeStopBssRequest
3896 This message will be defered until softmac come out of
3897 scan mode. Message should be handled even if we have
3898 detected radar in the current operating channel.
3899\param pMac
3900\param pMsg
3901
3902\return TRUE - If we consumed the buffer
3903 FALSE - If have defered the message.
3904 ---------------------------------------------------------------*/
3905static tANI_BOOLEAN
3906__limProcessSmeStopBssReq(tpAniSirGlobal pMac, tpSirMsgQ pMsg)
3907{
3908 if (__limIsDeferedMsgForLearn(pMac, pMsg))
3909 {
3910 /**
3911 * If message defered, buffer is not consumed yet.
3912 * So return false
3913 */
3914 return eANI_BOOLEAN_FALSE;
3915 }
3916 __limHandleSmeStopBssRequest(pMac, (tANI_U32 *) pMsg->bodyptr);
3917 return eANI_BOOLEAN_TRUE;
3918} /*** end __limProcessSmeStopBssReq() ***/
3919
3920
3921void limProcessSmeDelBssRsp(
3922 tpAniSirGlobal pMac,
3923 tANI_U32 body,tpPESession psessionEntry)
3924{
3925
3926 (void) body;
3927 SET_LIM_PROCESS_DEFD_MESGS(pMac, true);
3928 //TBD: get the sessionEntry
Ravi Joshib58ca0d2013-10-29 09:50:23 -07003929 limIbssDelete(pMac,psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07003930 dphHashTableClassInit(pMac, &psessionEntry->dph.dphHashTable);
3931 limDeletePreAuthList(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -07003932 limSendSmeRsp(pMac, eWNI_SME_STOP_BSS_RSP, eSIR_SME_SUCCESS,psessionEntry->smeSessionId,psessionEntry->transactionId);
3933 return;
3934}
3935
3936
Jeff Johnson295189b2012-06-20 16:38:30 -07003937/**---------------------------------------------------------------
3938\fn __limProcessSmeAssocCnfNew
3939\brief This function handles SME_ASSOC_CNF/SME_REASSOC_CNF
3940\ in BTAMP AP.
3941\
3942\param pMac
3943\param msgType - message type
3944\param pMsgBuf - a pointer to the SME message buffer
3945\return None
3946------------------------------------------------------------------*/
3947
3948 void
3949__limProcessSmeAssocCnfNew(tpAniSirGlobal pMac, tANI_U32 msgType, tANI_U32 *pMsgBuf)
3950{
3951 tSirSmeAssocCnf assocCnf;
3952 tpDphHashNode pStaDs = NULL;
3953 tpPESession psessionEntry= NULL;
3954 tANI_U8 sessionId;
3955
3956
3957 if(pMsgBuf == NULL)
3958 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003959 limLog(pMac, LOGE, FL("pMsgBuf is NULL "));
Jeff Johnson295189b2012-06-20 16:38:30 -07003960 goto end;
3961 }
3962
3963 if ((limAssocCnfSerDes(pMac, &assocCnf, (tANI_U8 *) pMsgBuf) == eSIR_FAILURE) ||
3964 !__limIsSmeAssocCnfValid(&assocCnf))
3965 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003966 limLog(pMac, LOGE, FL("Received invalid SME_RE(ASSOC)_CNF message "));
Jeff Johnson295189b2012-06-20 16:38:30 -07003967 goto end;
3968 }
3969
3970 if((psessionEntry = peFindSessionByBssid(pMac, assocCnf.bssId, &sessionId))== NULL)
3971 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003972 limLog(pMac, LOGE, FL("session does not exist for given bssId"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003973 goto end;
3974 }
3975
3976 if ( ((psessionEntry->limSystemRole != eLIM_AP_ROLE) && (psessionEntry->limSystemRole != eLIM_BT_AMP_AP_ROLE)) ||
3977 ((psessionEntry->limSmeState != eLIM_SME_NORMAL_STATE) && (psessionEntry->limSmeState != eLIM_SME_NORMAL_CHANNEL_SCAN_STATE)))
3978 {
Sushant Kaushik1b645382014-10-13 16:39:36 +05303979 limLog(pMac, LOGE, FL("Received unexpected message %X in state %d, in role %d"),
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303980 msgType, psessionEntry->limSmeState, psessionEntry->limSystemRole);
Jeff Johnson295189b2012-06-20 16:38:30 -07003981 goto end;
3982 }
3983
3984 pStaDs = dphGetHashEntry(pMac, assocCnf.aid, &psessionEntry->dph.dphHashTable);
3985
3986 if (pStaDs == NULL)
3987 {
Sachin Ahuja2fea3d12014-12-18 17:31:31 +05303988 limLog(pMac, LOGE,
3989 FL("Received invalid message %X due to no STA context, "
3990 "for aid %d, peer "),
3991 msgType, assocCnf.aid);
Jeff Johnson295189b2012-06-20 16:38:30 -07003992 limPrintMacAddr(pMac, assocCnf.peerMacAddr, LOG1);
3993
3994 /*
3995 ** send a DISASSOC_IND message to WSM to make sure
3996 ** the state in WSM and LIM is the same
3997 **/
3998 limSendSmeDisassocNtf( pMac, assocCnf.peerMacAddr, eSIR_SME_STA_NOT_ASSOCIATED,
3999 eLIM_PEER_ENTITY_DISASSOC, assocCnf.aid,psessionEntry->smeSessionId,psessionEntry->transactionId,psessionEntry);
4000 goto end;
4001 }
4002 if ((pStaDs &&
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304003 (( !vos_mem_compare( (tANI_U8 *) pStaDs->staAddr,
Jeff Johnson295189b2012-06-20 16:38:30 -07004004 (tANI_U8 *) assocCnf.peerMacAddr,
4005 sizeof(tSirMacAddr)) ) ||
4006 (pStaDs->mlmStaContext.mlmState != eLIM_MLM_WT_ASSOC_CNF_STATE) ||
4007 ((pStaDs->mlmStaContext.subType == LIM_ASSOC) &&
4008 (msgType != eWNI_SME_ASSOC_CNF)) ||
4009 ((pStaDs->mlmStaContext.subType == LIM_REASSOC) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07004010 (msgType != eWNI_SME_ASSOC_CNF))))) // since softap is passing this as ASSOC_CNF and subtype differs
Jeff Johnson295189b2012-06-20 16:38:30 -07004011 {
Sachin Ahuja2fea3d12014-12-18 17:31:31 +05304012 limLog(pMac, LOGE,
4013 FL("Received invalid message %X due to peerMacAddr mismatched "
4014 "or not in eLIM_MLM_WT_ASSOC_CNF_STATE state, for aid %d, peer "
4015 "StaD mlmState : %d"),
4016 msgType, assocCnf.aid, pStaDs->mlmStaContext.mlmState);
Jeff Johnson295189b2012-06-20 16:38:30 -07004017 limPrintMacAddr(pMac, assocCnf.peerMacAddr, LOG1);
4018 goto end;
4019 }
4020
4021 /*
4022 ** Deactivate/delet CNF_WAIT timer since ASSOC_CNF
4023 ** has been received
4024 **/
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004025 limLog(pMac, LOG1, FL("Received SME_ASSOC_CNF. Delete Timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004026 limDeactivateAndChangePerStaIdTimer(pMac, eLIM_CNF_WAIT_TIMER, pStaDs->assocId);
4027
4028 if (assocCnf.statusCode == eSIR_SME_SUCCESS)
4029 {
4030 /* In BTAMP-AP, PE already finished the WDA_ADD_STA sequence
4031 * when it had received Assoc Request frame. Now, PE just needs to send
4032 * Association Response frame to the requesting BTAMP-STA.
4033 */
4034 pStaDs->mlmStaContext.mlmState = eLIM_MLM_LINK_ESTABLISHED_STATE;
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004035 limLog(pMac, LOG1, FL("sending Assoc Rsp frame to STA (assoc id=%d) "), pStaDs->assocId);
Kapil Gupta956c0c42017-06-16 19:24:31 +05304036 limSendAssocRspMgmtFrame(pMac, eSIR_SUCCESS, pStaDs->assocId,
4037 pStaDs->staAddr,
4038 pStaDs->mlmStaContext.subType, pStaDs,
4039 psessionEntry, NULL);
Jeff Johnson295189b2012-06-20 16:38:30 -07004040 goto end;
4041 } // (assocCnf.statusCode == eSIR_SME_SUCCESS)
4042 else
4043 {
4044 // SME_ASSOC_CNF status is non-success, so STA is not allowed to be associated
4045 /*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*/
4046 if(!pStaDs->mlmStaContext.updateContext)
4047 pStaDs->mlmStaContext.updateContext = 1;
Sachin Ahuja2fea3d12014-12-18 17:31:31 +05304048 limLog(pMac, LOG1, FL("Receive Assoc Cnf with status Code : %d(assoc id=%d) "),
4049 assocCnf.statusCode, pStaDs->assocId);
Jeff Johnson295189b2012-06-20 16:38:30 -07004050 limRejectAssociation(pMac, pStaDs->staAddr,
4051 pStaDs->mlmStaContext.subType,
4052 true, pStaDs->mlmStaContext.authType,
4053 pStaDs->assocId, true,
4054 eSIR_MAC_UNSPEC_FAILURE_STATUS, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07004055 }
4056
4057end:
4058 if((psessionEntry != NULL) && (pStaDs != NULL))
4059 {
4060 if ( psessionEntry->parsedAssocReq[pStaDs->assocId] != NULL )
4061 {
4062 if ( ((tpSirAssocReq)(psessionEntry->parsedAssocReq[pStaDs->assocId]))->assocReqFrame)
4063 {
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304064 vos_mem_free(((tpSirAssocReq)
4065 (psessionEntry->parsedAssocReq[pStaDs->assocId]))->assocReqFrame);
Jeff Johnson295189b2012-06-20 16:38:30 -07004066 ((tpSirAssocReq)(psessionEntry->parsedAssocReq[pStaDs->assocId]))->assocReqFrame = NULL;
4067 }
4068
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304069 vos_mem_free(psessionEntry->parsedAssocReq[pStaDs->assocId]);
Jeff Johnson295189b2012-06-20 16:38:30 -07004070 psessionEntry->parsedAssocReq[pStaDs->assocId] = NULL;
4071 }
4072 }
4073
4074} /*** end __limProcessSmeAssocCnfNew() ***/
4075
Agrawal Ashisha8e8a722016-10-18 19:07:45 +05304076#ifdef SAP_AUTH_OFFLOAD
4077/**
4078 * __lim_process_sme_assoc_offload_cnf() station connection confirmation
4079 * message from SME.
4080 * @pMac: SirGlobal handler
4081 * @msgType: message type
4082 * @pMsgBuf: message body
4083 *
4084 * This function handles the station connect confirm of
4085 * Software AP authentication offload feature
4086 *
4087 * Return: None
4088 */
4089 static void
4090__lim_process_sme_assoc_offload_cnf(tpAniSirGlobal pmac,
4091 tANI_U32 msg_type,
4092 tANI_U32 *pmsg_buf)
4093{
4094 tSirSmeAssocCnf assoc_cnf;
4095 tpDphHashNode sta_ds = NULL;
4096 tpPESession psession_entry= NULL;
4097 tANI_U8 session_id;
4098 tANI_U16 aid=0;
Jeff Johnson295189b2012-06-20 16:38:30 -07004099
Agrawal Ashisha8e8a722016-10-18 19:07:45 +05304100 if (pmsg_buf == NULL)
4101 {
4102 limLog(pmac, LOGE, FL("pmsg_buf is NULL "));
4103 return;
4104 }
4105
4106 if ((limAssocCnfSerDes(pmac, &assoc_cnf, (tANI_U8 *) pmsg_buf) ==
4107 eSIR_FAILURE) || !__limIsSmeAssocCnfValid(&assoc_cnf))
4108 {
4109 limLog(pmac, LOGE, FL("Received invalid SME_RE(ASSOC)_CNF message "));
4110 return;
4111 }
4112
4113 if((psession_entry =
4114 peFindSessionByBssid(pmac, assoc_cnf.bssId, &session_id))== NULL)
4115 {
4116 limLog(pmac, LOGE, FL("session does not exist for given bssId"));
4117 goto end;
4118 }
4119
4120 if ((!LIM_IS_AP_ROLE(psession_entry)) ||
4121 ((psession_entry->limSmeState != eLIM_SME_NORMAL_STATE) &&
4122 (psession_entry->limSmeState != eLIM_SME_NORMAL_CHANNEL_SCAN_STATE)))
4123 {
4124 limLog(pmac, LOGE,
4125 FL("Received unexpected message %X in state %X, in role %X"),
4126 msg_type, psession_entry->limSmeState,
4127 GET_LIM_SYSTEM_ROLE(psession_entry));
4128 goto end;
4129 }
4130 sta_ds = dphGetHashEntry(pmac,
4131 assoc_cnf.aid,
4132 &psession_entry->dph.dphHashTable);
4133 if (sta_ds != NULL)
4134 {
4135 aid = sta_ds->assocId;
4136 /* Deactivate/delete CNF_WAIT timer since ASSOC_CNF
4137 * has been received */
4138 limDeactivateAndChangePerStaIdTimer(pmac,
4139 eLIM_CNF_WAIT_TIMER,
4140 aid);
4141 }
Agrawal Ashish25d9ef12017-01-10 20:27:50 +05304142 if (assoc_cnf.statusCode == eSIR_SME_SUCCESS)
4143 {
4144 sta_ds->mlmStaContext.mlmState = eLIM_MLM_LINK_ESTABLISHED_STATE;
4145 limLog(pmac, LOG1, FL("Set mlmState to eLIM_MLM_LINK_ESTABLISHED_STATE"));
4146 }
Agrawal Ashisha8e8a722016-10-18 19:07:45 +05304147
4148end:
4149 if((psession_entry != NULL) && (sta_ds != NULL))
4150 {
4151 if ( psession_entry->parsedAssocReq[aid] != NULL )
4152 {
4153 if ( ((tpSirAssocReq)
4154 (psession_entry->parsedAssocReq[aid]))->assocReqFrame)
4155 {
4156 vos_mem_free(((tpSirAssocReq)
4157 (psession_entry->parsedAssocReq[aid]))->assocReqFrame);
4158 ((tpSirAssocReq)
4159 (psession_entry->parsedAssocReq[aid]))->assocReqFrame =
4160 NULL;
4161 }
4162 vos_mem_free(psession_entry->parsedAssocReq[aid]);
4163 psession_entry->parsedAssocReq[aid] = NULL;
4164 }
4165 }
4166
4167} /*** end __lim_process_sme_assoc_offload_cnf() ***/
4168#endif /* SAP_AUTH_OFFLOAD */
Jeff Johnson295189b2012-06-20 16:38:30 -07004169
4170
4171static void
4172__limProcessSmeAddtsReq(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
4173{
4174 tpDphHashNode pStaDs;
4175 tSirMacAddr peerMac;
4176 tpSirAddtsReq pSirAddts;
4177 tANI_U32 timeout;
4178 tpPESession psessionEntry;
4179 tANI_U8 sessionId; //PE sessionId
4180 tANI_U8 smesessionId;
4181 tANI_U16 smetransactionId;
4182
4183
4184 if(pMsgBuf == NULL)
4185 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004186 limLog(pMac, LOGE,FL("Buffer is Pointing to NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004187 return;
4188 }
4189
4190 limGetSessionInfo(pMac,(tANI_U8 *)pMsgBuf,&smesessionId,&smetransactionId);
4191
4192 pSirAddts = (tpSirAddtsReq) pMsgBuf;
4193
4194 if((psessionEntry = peFindSessionByBssid(pMac, pSirAddts->bssId,&sessionId))== NULL)
4195 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004196 limLog(pMac, LOGE, "Session Does not exist for given bssId");
Jeff Johnson295189b2012-06-20 16:38:30 -07004197 return;
4198 }
4199#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM //FEATURE_WLAN_DIAG_SUPPORT
4200 limDiagEventReport(pMac, WLAN_PE_DIAG_ADDTS_REQ_EVENT, psessionEntry, 0, 0);
4201#endif //FEATURE_WLAN_DIAG_SUPPORT
4202
4203
4204
4205 /* if sta
4206 * - verify assoc state
4207 * - send addts request to ap
4208 * - wait for addts response from ap
4209 * if ap, just ignore with error log
4210 */
Abhishek Singh3cbf6052014-12-15 16:46:42 +05304211 limLog(pMac, LOG1,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004212 FL("Received SME_ADDTS_REQ (TSid %d, UP %d)"),
Jeff Johnson295189b2012-06-20 16:38:30 -07004213 pSirAddts->req.tspec.tsinfo.traffic.tsid,
Abhishek Singh3cbf6052014-12-15 16:46:42 +05304214 pSirAddts->req.tspec.tsinfo.traffic.userPrio);
Jeff Johnson295189b2012-06-20 16:38:30 -07004215
4216 if ((psessionEntry->limSystemRole != eLIM_STA_ROLE)&&(psessionEntry->limSystemRole != eLIM_BT_AMP_STA_ROLE))
4217 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004218 PELOGE(limLog(pMac, LOGE, "AddTs received on AP - ignoring");)
Jeff Johnson295189b2012-06-20 16:38:30 -07004219 limSendSmeAddtsRsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE, psessionEntry, pSirAddts->req.tspec,
4220 smesessionId,smetransactionId);
4221 return;
4222 }
4223
Jeff Johnson295189b2012-06-20 16:38:30 -07004224 pStaDs = dphGetHashEntry(pMac, DPH_STA_HASH_INDEX_PEER, &psessionEntry->dph.dphHashTable);
4225
4226 if(pStaDs == NULL)
4227 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004228 PELOGE(limLog(pMac, LOGE, "Cannot find AP context for addts req");)
Jeff Johnson295189b2012-06-20 16:38:30 -07004229 limSendSmeAddtsRsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE, psessionEntry, pSirAddts->req.tspec,
4230 smesessionId,smetransactionId);
4231 return;
4232 }
4233
4234 if ((! pStaDs->valid) ||
4235 (pStaDs->mlmStaContext.mlmState != eLIM_MLM_LINK_ESTABLISHED_STATE))
4236 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004237 PELOGE(limLog(pMac, LOGE, "AddTs received in invalid MLM state");)
Jeff Johnson295189b2012-06-20 16:38:30 -07004238 limSendSmeAddtsRsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE, psessionEntry, pSirAddts->req.tspec,
4239 smesessionId,smetransactionId);
4240 return;
4241 }
4242
4243 pSirAddts->req.wsmTspecPresent = 0;
4244 pSirAddts->req.wmeTspecPresent = 0;
4245 pSirAddts->req.lleTspecPresent = 0;
4246
4247 if ((pStaDs->wsmEnabled) &&
4248 (pSirAddts->req.tspec.tsinfo.traffic.accessPolicy != SIR_MAC_ACCESSPOLICY_EDCA))
4249 pSirAddts->req.wsmTspecPresent = 1;
4250 else if (pStaDs->wmeEnabled)
4251 pSirAddts->req.wmeTspecPresent = 1;
4252 else if (pStaDs->lleEnabled)
4253 pSirAddts->req.lleTspecPresent = 1;
4254 else
4255 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004256 PELOGW(limLog(pMac, LOGW, FL("ADDTS_REQ ignore - qos is disabled"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07004257 limSendSmeAddtsRsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE, psessionEntry, pSirAddts->req.tspec,
4258 smesessionId,smetransactionId);
4259 return;
4260 }
4261
4262 if ((psessionEntry->limSmeState != eLIM_SME_ASSOCIATED_STATE) &&
4263 (psessionEntry->limSmeState != eLIM_SME_LINK_EST_STATE))
4264 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004265 limLog(pMac, LOGE, "AddTs received in invalid LIMsme state (%d)",
Jeff Johnson295189b2012-06-20 16:38:30 -07004266 psessionEntry->limSmeState);
4267 limSendSmeAddtsRsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE, psessionEntry, pSirAddts->req.tspec,
4268 smesessionId,smetransactionId);
4269 return;
4270 }
4271
4272 if (pMac->lim.gLimAddtsSent)
4273 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004274 limLog(pMac, LOGE, "Addts (token %d, tsid %d, up %d) is still pending",
Jeff Johnson295189b2012-06-20 16:38:30 -07004275 pMac->lim.gLimAddtsReq.req.dialogToken,
4276 pMac->lim.gLimAddtsReq.req.tspec.tsinfo.traffic.tsid,
4277 pMac->lim.gLimAddtsReq.req.tspec.tsinfo.traffic.userPrio);
4278 limSendSmeAddtsRsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE, psessionEntry, pSirAddts->req.tspec,
4279 smesessionId,smetransactionId);
4280 return;
4281 }
4282
4283 #if 0
4284 val = sizeof(tSirMacAddr);
4285 if (wlan_cfgGetStr(pMac, WNI_CFG_BSSID, peerMac, &val) != eSIR_SUCCESS)
4286 {
4287 /// Could not get BSSID from CFG. Log error.
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004288 limLog(pMac, LOGP, FL("could not retrieve BSSID"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004289 return;
4290 }
4291 #endif
4292 sirCopyMacAddr(peerMac,psessionEntry->bssId);
4293
4294 // save the addts request
4295 pMac->lim.gLimAddtsSent = true;
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304296 vos_mem_copy( (tANI_U8 *) &pMac->lim.gLimAddtsReq, (tANI_U8 *) pSirAddts, sizeof(tSirAddtsReq));
Jeff Johnson295189b2012-06-20 16:38:30 -07004297
4298 // ship out the message now
4299 limSendAddtsReqActionFrame(pMac, peerMac, &pSirAddts->req,
4300 psessionEntry);
Abhishek Singh3cbf6052014-12-15 16:46:42 +05304301 limLog(pMac, LOG1, FL("Sent ADDTS request"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004302
4303 // start a timer to wait for the response
4304 if (pSirAddts->timeout)
4305 timeout = pSirAddts->timeout;
4306 else if (wlan_cfgGetInt(pMac, WNI_CFG_ADDTS_RSP_TIMEOUT, &timeout) != eSIR_SUCCESS)
4307 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004308 limLog(pMac, LOGP, FL("Unable to get Cfg param %d (Addts Rsp Timeout)"),
Jeff Johnson295189b2012-06-20 16:38:30 -07004309 WNI_CFG_ADDTS_RSP_TIMEOUT);
4310 return;
4311 }
4312
4313 timeout = SYS_MS_TO_TICKS(timeout);
4314 if (tx_timer_change(&pMac->lim.limTimers.gLimAddtsRspTimer, timeout, 0) != TX_SUCCESS)
4315 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004316 limLog(pMac, LOGP, FL("AddtsRsp timer change failed!"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004317 return;
4318 }
4319 pMac->lim.gLimAddtsRspTimerCount++;
4320 if (tx_timer_change_context(&pMac->lim.limTimers.gLimAddtsRspTimer,
4321 pMac->lim.gLimAddtsRspTimerCount) != TX_SUCCESS)
4322 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004323 limLog(pMac, LOGP, FL("AddtsRsp timer change failed!"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004324 return;
4325 }
Jeff Johnsone7245742012-09-05 17:12:55 -07004326 MTRACE(macTrace(pMac, TRACE_CODE_TIMER_ACTIVATE, psessionEntry->peSessionId, eLIM_ADDTS_RSP_TIMER));
Jeff Johnson295189b2012-06-20 16:38:30 -07004327
4328 //add the sessionId to the timer object
4329 pMac->lim.limTimers.gLimAddtsRspTimer.sessionId = sessionId;
4330 if (tx_timer_activate(&pMac->lim.limTimers.gLimAddtsRspTimer) != TX_SUCCESS)
4331 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004332 limLog(pMac, LOGP, FL("AddtsRsp timer activation failed!"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004333 return;
4334 }
4335 return;
4336}
4337
4338
4339static void
4340__limProcessSmeDeltsReq(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
4341{
4342 tSirMacAddr peerMacAddr;
4343 tANI_U8 ac;
4344 tSirMacTSInfo *pTsinfo;
4345 tpSirDeltsReq pDeltsReq = (tpSirDeltsReq) pMsgBuf;
4346 tpDphHashNode pStaDs = NULL;
4347 tpPESession psessionEntry;
4348 tANI_U8 sessionId;
4349 tANI_U32 status = eSIR_SUCCESS;
4350 tANI_U8 smesessionId;
4351 tANI_U16 smetransactionId;
4352
4353 limGetSessionInfo(pMac,(tANI_U8 *)pMsgBuf,&smesessionId,&smetransactionId);
4354
4355 if((psessionEntry = peFindSessionByBssid(pMac, pDeltsReq->bssId, &sessionId))== NULL)
4356 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004357 limLog(pMac, LOGE, "Session Does not exist for given bssId");
Jeff Johnson295189b2012-06-20 16:38:30 -07004358 status = eSIR_FAILURE;
4359 goto end;
4360 }
4361#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM //FEATURE_WLAN_DIAG_SUPPORT
4362 limDiagEventReport(pMac, WLAN_PE_DIAG_DELTS_REQ_EVENT, psessionEntry, 0, 0);
4363#endif //FEATURE_WLAN_DIAG_SUPPORT
4364
4365
4366 if (eSIR_SUCCESS != limValidateDeltsReq(pMac, pDeltsReq, peerMacAddr,psessionEntry))
4367 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004368 PELOGE(limLog(pMac, LOGE, FL("limValidateDeltsReq failed"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07004369 status = eSIR_FAILURE;
4370 limSendSmeDeltsRsp(pMac, pDeltsReq, eSIR_FAILURE,psessionEntry,smesessionId,smetransactionId);
4371 return;
4372 }
4373
Abhishek Singh3cbf6052014-12-15 16:46:42 +05304374 limLog(pMac, LOG1, FL("Sent DELTS request to station with "
4375 "assocId = %d MacAddr = "MAC_ADDRESS_STR),
4376 pDeltsReq->aid, MAC_ADDR_ARRAY(peerMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07004377
4378 limSendDeltsReqActionFrame(pMac, peerMacAddr, pDeltsReq->req.wmeTspecPresent, &pDeltsReq->req.tsinfo, &pDeltsReq->req.tspec,
4379 psessionEntry);
4380
4381 pTsinfo = pDeltsReq->req.wmeTspecPresent ? &pDeltsReq->req.tspec.tsinfo : &pDeltsReq->req.tsinfo;
4382
4383 /* We've successfully send DELTS frame to AP. Update the
4384 * dynamic UAPSD mask. The AC for this TSPEC to be deleted
4385 * is no longer trigger enabled or delivery enabled
4386 */
4387 limSetTspecUapsdMask(pMac, pTsinfo, CLEAR_UAPSD_MASK);
4388
4389 /* We're deleting the TSPEC, so this particular AC is no longer
4390 * admitted. PE needs to downgrade the EDCA
4391 * parameters(for the AC for which TS is being deleted) to the
4392 * next best AC for which ACM is not enabled, and send the
4393 * updated values to HAL.
4394 */
4395 ac = upToAc(pTsinfo->traffic.userPrio);
4396
4397 if(pTsinfo->traffic.direction == SIR_MAC_DIRECTION_UPLINK)
4398 {
4399 pMac->lim.gAcAdmitMask[SIR_MAC_DIRECTION_UPLINK] &= ~(1 << ac);
4400 }
4401 else if(pTsinfo->traffic.direction == SIR_MAC_DIRECTION_DNLINK)
4402 {
4403 pMac->lim.gAcAdmitMask[SIR_MAC_DIRECTION_DNLINK] &= ~(1 << ac);
4404 }
4405 else if(pTsinfo->traffic.direction == SIR_MAC_DIRECTION_BIDIR)
4406 {
4407 pMac->lim.gAcAdmitMask[SIR_MAC_DIRECTION_UPLINK] &= ~(1 << ac);
4408 pMac->lim.gAcAdmitMask[SIR_MAC_DIRECTION_DNLINK] &= ~(1 << ac);
4409 }
4410
4411 limSetActiveEdcaParams(pMac, psessionEntry->gLimEdcaParams, psessionEntry);
4412
4413 pStaDs = dphGetHashEntry(pMac, DPH_STA_HASH_INDEX_PEER, &psessionEntry->dph.dphHashTable);
4414 if (pStaDs != NULL)
4415 {
4416 if (pStaDs->aniPeer == eANI_BOOLEAN_TRUE)
4417 limSendEdcaParams(pMac, psessionEntry->gLimEdcaParamsActive, pStaDs->bssId, eANI_BOOLEAN_TRUE);
4418 else
4419 limSendEdcaParams(pMac, psessionEntry->gLimEdcaParamsActive, pStaDs->bssId, eANI_BOOLEAN_FALSE);
4420 status = eSIR_SUCCESS;
4421 }
4422 else
4423 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004424 limLog(pMac, LOGE, FL("Self entry missing in Hash Table "));
Jeff Johnson295189b2012-06-20 16:38:30 -07004425 status = eSIR_FAILURE;
4426 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004427#ifdef FEATURE_WLAN_ESE
4428#ifdef FEATURE_WLAN_ESE_UPLOAD
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004429 limSendSmeTsmIEInd(pMac, psessionEntry, 0, 0, 0);
4430#else
Jeff Johnson295189b2012-06-20 16:38:30 -07004431 limDeactivateAndChangeTimer(pMac,eLIM_TSM_TIMER);
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004432#endif /* FEATURE_WLAN_ESE_UPLOAD */
Jeff Johnson295189b2012-06-20 16:38:30 -07004433#endif
4434
4435 // send an sme response back
4436 end:
4437 limSendSmeDeltsRsp(pMac, pDeltsReq, eSIR_SUCCESS,psessionEntry,smesessionId,smetransactionId);
4438}
4439
4440
4441void
4442limProcessSmeAddtsRspTimeout(tpAniSirGlobal pMac, tANI_U32 param)
4443{
4444 //fetch the sessionEntry based on the sessionId
4445 tpPESession psessionEntry;
4446 if((psessionEntry = peFindSessionBySessionId(pMac, pMac->lim.limTimers.gLimAddtsRspTimer.sessionId))== NULL)
4447 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004448 limLog(pMac, LOGP,FL("Session Does not exist for given sessionID"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004449 return;
4450 }
4451
4452 if ( (psessionEntry->limSystemRole != eLIM_STA_ROLE) && (psessionEntry->limSystemRole != eLIM_BT_AMP_STA_ROLE) )
4453 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004454 limLog(pMac, LOGW, "AddtsRspTimeout in non-Sta role (%d)", psessionEntry->limSystemRole);
Jeff Johnson295189b2012-06-20 16:38:30 -07004455 pMac->lim.gLimAddtsSent = false;
4456 return;
4457 }
4458
4459 if (! pMac->lim.gLimAddtsSent)
4460 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004461 PELOGW(limLog(pMac, LOGW, "AddtsRspTimeout but no AddtsSent");)
Jeff Johnson295189b2012-06-20 16:38:30 -07004462 return;
4463 }
4464
4465 if (param != pMac->lim.gLimAddtsRspTimerCount)
4466 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004467 limLog(pMac, LOGE, FL("Invalid AddtsRsp Timer count %d (exp %d)"),
Jeff Johnson295189b2012-06-20 16:38:30 -07004468 param, pMac->lim.gLimAddtsRspTimerCount);
4469 return;
4470 }
4471
4472 // this a real response timeout
4473 pMac->lim.gLimAddtsSent = false;
4474 pMac->lim.gLimAddtsRspTimerCount++;
4475
4476 limSendSmeAddtsRsp(pMac, true, eSIR_SME_ADDTS_RSP_TIMEOUT, psessionEntry, pMac->lim.gLimAddtsReq.req.tspec,
4477 psessionEntry->smeSessionId, psessionEntry->transactionId);
4478}
4479
4480
4481/**
4482 * __limProcessSmeStatsRequest()
4483 *
4484 *FUNCTION:
4485 *
4486 *
4487 *NOTE:
4488 *
4489 * @param pMac Pointer to Global MAC structure
4490 * @param *pMsgBuf A pointer to the SME message buffer
4491 * @return None
4492 */
4493static void
4494__limProcessSmeStatsRequest(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
4495{
4496 tpAniGetStatsReq pStatsReq;
4497 tSirMsgQ msgQ;
4498 tpPESession psessionEntry;
4499 tANI_U8 sessionId;
4500
4501
4502 if(pMsgBuf == NULL)
4503 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004504 limLog(pMac, LOGE,FL("Buffer is Pointing to NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004505 return;
4506 }
4507
4508 pStatsReq = (tpAniGetStatsReq) pMsgBuf;
4509
4510 if((psessionEntry = peFindSessionByBssid(pMac,pStatsReq->bssId,&sessionId))== NULL)
4511 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004512 limLog(pMac, LOGE, FL("session does not exist for given bssId"));
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304513 vos_mem_free( pMsgBuf );
Leela Venkata Kiran Kumar Reddy Chiralad6c0fe22013-12-11 19:10:50 -08004514 pMsgBuf = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004515 return;
4516 }
4517
4518
4519
4520 switch(pStatsReq->msgType)
4521 {
4522 //Add Lim stats here. and send reqsponse.
4523
4524 //HAL maintained Stats.
4525 case eWNI_SME_STA_STAT_REQ:
4526 msgQ.type = WDA_STA_STAT_REQ;
4527 break;
4528 case eWNI_SME_AGGR_STAT_REQ:
4529 msgQ.type = WDA_AGGR_STAT_REQ;
4530 break;
4531 case eWNI_SME_GLOBAL_STAT_REQ:
4532 msgQ.type = WDA_GLOBAL_STAT_REQ;
4533 break;
4534 case eWNI_SME_STAT_SUMM_REQ:
4535 msgQ.type = WDA_STAT_SUMM_REQ;
4536 break;
4537 default: //Unknown request.
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004538 PELOGE(limLog(pMac, LOGE, "Unknown Statistics request");)
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304539 vos_mem_free( pMsgBuf );
Leela Venkata Kiran Kumar Reddy Chiralad6c0fe22013-12-11 19:10:50 -08004540 pMsgBuf = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004541 return;
4542 }
4543
Jeff Johnson295189b2012-06-20 16:38:30 -07004544 msgQ.reserved = 0;
4545 msgQ.bodyptr = pMsgBuf;
4546 msgQ.bodyval = 0;
Leela Venkata Kiran Kumar Reddy Chirala68a6abe2013-02-28 07:43:16 -08004547 if(NULL == psessionEntry)
4548 {
4549 MTRACE(macTraceMsgTx(pMac, NO_SESSION, msgQ.type));
4550 }
4551 else
4552 {
4553 MTRACE(macTraceMsgTx(pMac, psessionEntry->peSessionId, msgQ.type));
4554 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004555 if( eSIR_SUCCESS != (wdaPostCtrlMsg( pMac, &msgQ ))){
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004556 limLog(pMac, LOGP, "Unable to forward request");
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304557 vos_mem_free( pMsgBuf );
Leela Venkata Kiran Kumar Reddy Chiralad6c0fe22013-12-11 19:10:50 -08004558 pMsgBuf = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004559 return;
4560 }
4561
4562 return;
4563}
4564
4565
4566/**
4567 * __limProcessSmeGetStatisticsRequest()
4568 *
4569 *FUNCTION:
4570 *
4571 *
4572 *NOTE:
4573 *
4574 * @param pMac Pointer to Global MAC structure
4575 * @param *pMsgBuf A pointer to the SME message buffer
4576 * @return None
4577 */
4578static void
4579__limProcessSmeGetStatisticsRequest(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
4580{
4581 tpAniGetPEStatsReq pPEStatsReq;
4582 tSirMsgQ msgQ;
4583
4584 pPEStatsReq = (tpAniGetPEStatsReq) pMsgBuf;
4585
4586 //pPEStatsReq->msgType should be eWNI_SME_GET_STATISTICS_REQ
4587
4588 msgQ.type = WDA_GET_STATISTICS_REQ;
4589
Jeff Johnson295189b2012-06-20 16:38:30 -07004590 msgQ.reserved = 0;
4591 msgQ.bodyptr = pMsgBuf;
4592 msgQ.bodyval = 0;
Jeff Johnsone7245742012-09-05 17:12:55 -07004593 MTRACE(macTraceMsgTx(pMac, NO_SESSION, msgQ.type));
Jeff Johnson295189b2012-06-20 16:38:30 -07004594
4595 if( eSIR_SUCCESS != (wdaPostCtrlMsg( pMac, &msgQ ))){
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304596 vos_mem_free( pMsgBuf );
Leela Venkata Kiran Kumar Reddy Chiralad6c0fe22013-12-11 19:10:50 -08004597 pMsgBuf = NULL;
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004598 limLog(pMac, LOGP, "Unable to forward request");
Jeff Johnson295189b2012-06-20 16:38:30 -07004599 return;
4600 }
4601
4602 return;
4603}
4604
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004605#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004606/**
4607 *FUNCTION: __limProcessSmeGetTsmStatsRequest()
4608 *
4609 *NOTE:
4610 *
4611 * @param pMac Pointer to Global MAC structure
4612 * @param *pMsgBuf A pointer to the SME message buffer
4613 * @return None
4614 */
4615static void
4616__limProcessSmeGetTsmStatsRequest(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
4617{
4618 tSirMsgQ msgQ;
4619
4620 msgQ.type = WDA_TSM_STATS_REQ;
4621 msgQ.reserved = 0;
4622 msgQ.bodyptr = pMsgBuf;
4623 msgQ.bodyval = 0;
4624 MTRACE(macTraceMsgTx(pMac, NO_SESSION, msgQ.type));
4625
4626 if( eSIR_SUCCESS != (wdaPostCtrlMsg( pMac, &msgQ ))){
4627 vos_mem_free( pMsgBuf );
Leela Venkata Kiran Kumar Reddy Chiralad6c0fe22013-12-11 19:10:50 -08004628 pMsgBuf = NULL;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004629 limLog(pMac, LOGP, "Unable to forward request");
4630 return;
4631 }
4632}
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004633#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004634
4635
Jeff Johnson295189b2012-06-20 16:38:30 -07004636
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004637#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08004638/**
4639 * __limProcessSmeGetRoamRssiRequest()
4640 *
4641 *FUNCTION:
4642 *
4643 *
4644 *NOTE:
4645 *
4646 * @param pMac Pointer to Global MAC structure
4647 * @param *pMsgBuf A pointer to the SME message buffer
4648 * @return None
4649 */
4650static void
4651__limProcessSmeGetRoamRssiRequest(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
4652{
4653 tpAniGetRssiReq pPEGetRoamRssiReq = NULL;
4654 tSirMsgQ msgQ;
4655
4656 pPEGetRoamRssiReq = (tpAniGetRssiReq) pMsgBuf;
4657 msgQ.type = WDA_GET_ROAM_RSSI_REQ;
4658
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08004659 msgQ.reserved = 0;
4660 msgQ.bodyptr = pMsgBuf;
4661 msgQ.bodyval = 0;
4662 MTRACE(macTraceMsgTx(pMac, NO_SESSION, msgQ.type));
4663
4664 if( eSIR_SUCCESS != (wdaPostCtrlMsg( pMac, &msgQ ))){
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304665 vos_mem_free( pMsgBuf );
Leela Venkata Kiran Kumar Reddy Chiralad6c0fe22013-12-11 19:10:50 -08004666 pMsgBuf = NULL;
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004667 limLog(pMac, LOGP, "Unable to forward request");
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08004668 return;
4669 }
4670
4671 return;
4672}
4673#endif
4674
4675
Jeff Johnson295189b2012-06-20 16:38:30 -07004676static void
4677__limProcessSmeUpdateAPWPSIEs(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
4678{
4679 tpSirUpdateAPWPSIEsReq pUpdateAPWPSIEsReq;
4680 tpPESession psessionEntry;
4681 tANI_U8 sessionId; //PE sessionID
4682
4683 PELOG1(limLog(pMac, LOG1,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004684 FL("received UPDATE_APWPSIEs_REQ message")););
Jeff Johnson295189b2012-06-20 16:38:30 -07004685
4686 if(pMsgBuf == NULL)
4687 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004688 limLog(pMac, LOGE,FL("Buffer is Pointing to NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004689 return;
4690 }
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08004691
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304692 pUpdateAPWPSIEsReq = vos_mem_malloc(sizeof(tSirUpdateAPWPSIEsReq));
4693 if ( NULL == pUpdateAPWPSIEsReq )
Jeff Johnson295189b2012-06-20 16:38:30 -07004694 {
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304695 limLog(pMac, LOGP, FL("call to AllocateMemory failed for pUpdateAPWPSIEsReq"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004696 return;
4697 }
4698
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08004699 if ((limUpdateAPWPSIEsReqSerDes(pMac, pUpdateAPWPSIEsReq, (tANI_U8 *) pMsgBuf) == eSIR_FAILURE))
Jeff Johnson295189b2012-06-20 16:38:30 -07004700 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004701 limLog(pMac, LOGW, FL("received invalid SME_SETCONTEXT_REQ message"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004702 goto end;
4703 }
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08004704
Jeff Johnson295189b2012-06-20 16:38:30 -07004705 if((psessionEntry = peFindSessionByBssid(pMac, pUpdateAPWPSIEsReq->bssId, &sessionId)) == NULL)
4706 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004707 limLog(pMac, LOGW, FL("Session does not exist for given BSSID"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004708 goto end;
4709 }
4710
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304711 vos_mem_copy( &psessionEntry->APWPSIEs, &pUpdateAPWPSIEsReq->APWPSIEs, sizeof(tSirAPWPSIEs));
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08004712
Jeff Johnson295189b2012-06-20 16:38:30 -07004713 schSetFixedBeaconFields(pMac, psessionEntry);
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08004714 limSendBeaconInd(pMac, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07004715
4716end:
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304717 vos_mem_free( pUpdateAPWPSIEsReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07004718 return;
4719} /*** end __limProcessSmeUpdateAPWPSIEs(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf) ***/
4720
4721static void
4722__limProcessSmeHideSSID(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
4723{
4724 tpSirUpdateParams pUpdateParams;
4725 tpPESession psessionEntry;
4726
Abhishek Singh3cbf6052014-12-15 16:46:42 +05304727 limLog(pMac, LOG1,
4728 FL("received SME_HIDE_SSID message"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004729
4730 if(pMsgBuf == NULL)
4731 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004732 limLog(pMac, LOGE,FL("Buffer is Pointing to NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004733 return;
4734 }
4735
4736 pUpdateParams = (tpSirUpdateParams)pMsgBuf;
4737
4738 if((psessionEntry = peFindSessionBySessionId(pMac, pUpdateParams->sessionId)) == NULL)
4739 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004740 limLog(pMac, LOGW, "Session does not exist for given sessionId %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07004741 pUpdateParams->sessionId);
4742 return;
4743 }
4744
4745 /* Update the session entry */
4746 psessionEntry->ssidHidden = pUpdateParams->ssidHidden;
4747
4748 /* Update beacon */
4749 schSetFixedBeaconFields(pMac, psessionEntry);
4750 limSendBeaconInd(pMac, psessionEntry);
4751
4752 return;
4753} /*** end __limProcessSmeHideSSID(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf) ***/
4754
4755static void
4756__limProcessSmeSetWPARSNIEs(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
4757{
4758 tpSirUpdateAPWPARSNIEsReq pUpdateAPWPARSNIEsReq;
4759 tpPESession psessionEntry;
4760 tANI_U8 sessionId; //PE sessionID
4761
4762 if(pMsgBuf == NULL)
4763 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004764 limLog(pMac, LOGE,FL("Buffer is Pointing to NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004765 return;
4766 }
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304767
4768 pUpdateAPWPARSNIEsReq = vos_mem_malloc(sizeof(tSirUpdateAPWPSIEsReq));
4769 if ( NULL == pUpdateAPWPARSNIEsReq )
Jeff Johnson295189b2012-06-20 16:38:30 -07004770 {
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304771 limLog(pMac, LOGP, FL("call to AllocateMemory failed for pUpdateAPWPARSNIEsReq"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004772 return;
4773 }
4774
4775 if ((limUpdateAPWPARSNIEsReqSerDes(pMac, pUpdateAPWPARSNIEsReq, (tANI_U8 *) pMsgBuf) == eSIR_FAILURE))
4776 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004777 limLog(pMac, LOGW, FL("received invalid SME_SETCONTEXT_REQ message"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004778 goto end;
4779 }
4780
4781 if((psessionEntry = peFindSessionByBssid(pMac, pUpdateAPWPARSNIEsReq->bssId, &sessionId)) == NULL)
4782 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004783 limLog(pMac, LOGW, FL("Session does not exist for given BSSID"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004784 goto end;
4785 }
4786
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304787 vos_mem_copy(&psessionEntry->pLimStartBssReq->rsnIE,
4788 &pUpdateAPWPARSNIEsReq->APWPARSNIEs, sizeof(tSirRSNie));
Jeff Johnson295189b2012-06-20 16:38:30 -07004789
4790 limSetRSNieWPAiefromSmeStartBSSReqMessage(pMac, &psessionEntry->pLimStartBssReq->rsnIE, psessionEntry);
4791
4792 psessionEntry->pLimStartBssReq->privacy = 1;
4793 psessionEntry->privacy = 1;
4794
4795 schSetFixedBeaconFields(pMac, psessionEntry);
4796 limSendBeaconInd(pMac, psessionEntry);
4797
4798end:
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304799 vos_mem_free(pUpdateAPWPARSNIEsReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07004800 return;
4801} /*** end __limProcessSmeSetWPARSNIEs(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf) ***/
4802
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08004803/*
4804Update the beacon Interval dynamically if beaconInterval is different in MCC
4805*/
4806static void
4807__limProcessSmeChangeBI(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
4808{
4809 tpSirChangeBIParams pChangeBIParams;
4810 tpPESession psessionEntry;
4811 tANI_U8 sessionId = 0;
4812 tUpdateBeaconParams beaconParams;
4813
4814 PELOG1(limLog(pMac, LOG1,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004815 FL("received Update Beacon Interval message")););
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08004816
4817 if(pMsgBuf == NULL)
4818 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004819 limLog(pMac, LOGE,FL("Buffer is Pointing to NULL"));
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08004820 return;
4821 }
4822
Kaushik, Sushantfb156732014-01-07 15:36:03 +05304823 vos_mem_zero(&beaconParams, sizeof(tUpdateBeaconParams));
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08004824 pChangeBIParams = (tpSirChangeBIParams)pMsgBuf;
4825
4826 if((psessionEntry = peFindSessionByBssid(pMac, pChangeBIParams->bssId, &sessionId)) == NULL)
4827 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004828 limLog(pMac, LOGE, FL("Session does not exist for given BSSID"));
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08004829 return;
4830 }
4831
4832 /*Update sessionEntry Beacon Interval*/
4833 if(psessionEntry->beaconParams.beaconInterval !=
4834 pChangeBIParams->beaconInterval )
4835 {
4836 psessionEntry->beaconParams.beaconInterval = pChangeBIParams->beaconInterval;
4837 }
4838
4839 /*Update sch beaconInterval*/
4840 if(pMac->sch.schObject.gSchBeaconInterval !=
4841 pChangeBIParams->beaconInterval )
4842 {
4843 pMac->sch.schObject.gSchBeaconInterval = pChangeBIParams->beaconInterval;
4844
4845 PELOG1(limLog(pMac, LOG1,
4846 FL("LIM send update BeaconInterval Indication : %d"),pChangeBIParams->beaconInterval););
4847
4848 /* Update beacon */
4849 schSetFixedBeaconFields(pMac, psessionEntry);
4850
Sunil Ravib96f7b52013-05-22 21:40:05 -07004851 beaconParams.bssIdx = psessionEntry->bssIdx;
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08004852 //Set change in beacon Interval
4853 beaconParams.beaconInterval = pChangeBIParams->beaconInterval;
Jeff Johnson312557b2013-04-03 16:27:48 -07004854 beaconParams.paramChangeBitmap = PARAM_BCN_INTERVAL_CHANGED;
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08004855 limSendBeaconParams(pMac, &beaconParams, psessionEntry);
4856 }
4857
4858 return;
4859} /*** end __limProcessSmeChangeBI(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf) ***/
4860
Hardik Kantilal Patel62a3a762014-11-21 12:55:57 +05304861/** -------------------------------------------------------------
4862\fn
4863\brief handles indication message from HDD to update HT mode
4864\param tpAniSirGlobal pMac
4865\param tANI_U32 pMsgBuf
4866\return None
4867-------------------------------------------------------------*/
4868#ifdef WLAN_FEATURE_AP_HT40_24G
4869static void __limProcessSmeSetHT2040Mode(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
4870{
4871 tpSirSetHT2040Mode pSetHT2040Mode;
4872 tpPESession psessionEntry;
4873 tANI_U8 sessionId = 0;
4874 tUpdateVHTOpMode *pHtOpMode = NULL;
4875 vos_msg_t msg;
Jeff Johnson295189b2012-06-20 16:38:30 -07004876
Hardik Kantilal Patel62a3a762014-11-21 12:55:57 +05304877 PELOG1(limLog(pMac, LOGRW,
4878 FL("received Set HT 20/40 mode message")););
4879
4880 if(pMsgBuf == NULL)
4881 {
4882 limLog(pMac, LOGE,FL("Buffer is Pointing to NULL"));
4883 return;
4884 }
4885
4886 pSetHT2040Mode = (tpSirSetHT2040Mode)pMsgBuf;
4887
4888 if((psessionEntry = peFindSessionByBssid(pMac, pSetHT2040Mode->bssId,
4889 &sessionId)) == NULL)
4890 {
4891 limLog(pMac, LOGE, FL("Session does not exist for given BSSID "));
4892 limPrintMacAddr(pMac, pSetHT2040Mode->bssId, LOGE);
4893 return;
4894 }
4895
4896 limLog(pMac, LOGW, FL("Update session entry for cbMod=%d"),
4897 pSetHT2040Mode->cbMode);
4898
4899 /*Update sessionEntry HT related fields*/
4900 switch(pSetHT2040Mode->cbMode)
4901 {
4902 case PHY_SINGLE_CHANNEL_CENTERED:
4903 psessionEntry->htSecondaryChannelOffset = PHY_SINGLE_CHANNEL_CENTERED;
4904 psessionEntry->htRecommendedTxWidthSet = 0;
4905 break;
4906 case PHY_DOUBLE_CHANNEL_LOW_PRIMARY:
4907 psessionEntry->htSecondaryChannelOffset =
4908 PHY_DOUBLE_CHANNEL_LOW_PRIMARY;
4909 psessionEntry->htRecommendedTxWidthSet = 1;
4910 break;
4911 case PHY_DOUBLE_CHANNEL_HIGH_PRIMARY:
4912 psessionEntry->htSecondaryChannelOffset =
4913 PHY_DOUBLE_CHANNEL_HIGH_PRIMARY;
4914 psessionEntry->htRecommendedTxWidthSet = 1;
4915 break;
4916 default:
4917 limLog(pMac, LOGE,FL("Invalid cbMode"));
4918 return;
4919 }
4920
4921 limLog(pMac, LOGW, FL("Channel Bonding mode : %d"
4922 " htSecondaryChannelOffset: %d"
4923 " htRecommendedTxWidthSet :%d"),
4924 pSetHT2040Mode->cbMode,
4925 psessionEntry->htSecondaryChannelOffset,
4926 psessionEntry->htRecommendedTxWidthSet);
4927
4928 limLog(pMac, LOGW, FL("Update Beacon IEs"));
4929
4930 /* Update beacon */
4931 schSetFixedBeaconFields(pMac, psessionEntry);
4932 limSendBeaconInd(pMac, psessionEntry);
4933
4934 /* Update OP Mode */
4935 pHtOpMode = vos_mem_malloc(sizeof(tUpdateVHTOpMode));
4936 if ( NULL == pHtOpMode )
4937 {
4938 limLog(pMac, LOGE,
4939 FL("Not able to allocate memory for setting OP mode"));
4940 return;
4941 }
4942
4943 pHtOpMode->opMode = (psessionEntry->htSecondaryChannelOffset ==
4944 PHY_SINGLE_CHANNEL_CENTERED)?
4945 eHT_CHANNEL_WIDTH_20MHZ:eHT_CHANNEL_WIDTH_40MHZ;
4946
4947 /* Pass Self STA ID to FW. Based on Self STA ID FW will update the
4948 * operating mode for all connected STA.
4949 */
4950
4951 pHtOpMode->staId = psessionEntry->staId;
4952
4953 msg.type = WDA_UPDATE_OP_MODE;
4954 msg.reserved = 0;
4955 msg.bodyptr = pHtOpMode;
4956
4957 if (!VOS_IS_STATUS_SUCCESS(
4958 vos_mq_post_message(VOS_MODULE_ID_WDA, &msg)))
4959 {
4960 limLog(pMac, LOGE,
4961 FL("Not able to post WDA_UPDATE_OP_MODE message to WDA"));
4962 vos_mem_free(pHtOpMode);
4963 return;
4964 }
4965
4966 limLog(pMac, LOGW,
4967 FL("Notifed FW about OP mode: %d for staId=%d"),
4968 pHtOpMode->opMode, pHtOpMode->staId);
4969
4970 return;
4971}
4972#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004973
4974/** -------------------------------------------------------------
4975\fn limProcessSmeDelBaPeerInd
4976\brief handles indication message from HDD to send delete BA request
4977\param tpAniSirGlobal pMac
4978\param tANI_U32 pMsgBuf
4979\return None
4980-------------------------------------------------------------*/
4981void
4982limProcessSmeDelBaPeerInd(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
4983{
4984 tANI_U16 assocId =0;
4985 tpSmeDelBAPeerInd pSmeDelBAPeerInd = (tpSmeDelBAPeerInd)pMsgBuf;
4986 tpDphHashNode pSta;
4987 tpPESession psessionEntry;
4988 tANI_U8 sessionId;
4989
4990
4991
4992 if(NULL == pSmeDelBAPeerInd)
4993 return;
4994
4995 if ((psessionEntry = peFindSessionByBssid(pMac,pSmeDelBAPeerInd->bssId,&sessionId))==NULL)
4996 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004997 limLog(pMac, LOGE,FL("session does not exist for given bssId"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004998 return;
4999 }
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005000 limLog(pMac, LOGW, FL("called with staId = %d, tid = %d, baDirection = %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07005001 pSmeDelBAPeerInd->staIdx, pSmeDelBAPeerInd->baTID, pSmeDelBAPeerInd->baDirection);
5002
5003 pSta = dphLookupAssocId(pMac, pSmeDelBAPeerInd->staIdx, &assocId, &psessionEntry->dph.dphHashTable);
5004 if( eSIR_SUCCESS != limPostMlmDelBAReq( pMac,
5005 pSta,
5006 pSmeDelBAPeerInd->baDirection,
5007 pSmeDelBAPeerInd->baTID,
5008 eSIR_MAC_UNSPEC_FAILURE_REASON,psessionEntry))
5009 {
5010 limLog( pMac, LOGW,
5011 FL( "Failed to post LIM_MLM_DELBA_REQ to " ));
5012 if (pSta)
5013 limPrintMacAddr(pMac, pSta->staAddr, LOGW);
5014 }
5015}
5016
5017// --------------------------------------------------------------------
5018/**
5019 * __limProcessReportMessage
5020 *
5021 * FUNCTION: Processes the next received Radio Resource Management message
5022 *
5023 * LOGIC:
5024 *
5025 * ASSUMPTIONS:
5026 *
5027 * NOTE:
5028 *
5029 * @param None
5030 * @return None
5031 */
5032
5033void __limProcessReportMessage(tpAniSirGlobal pMac, tpSirMsgQ pMsg)
5034{
5035#ifdef WLAN_FEATURE_VOWIFI
5036 switch (pMsg->type)
5037 {
5038 case eWNI_SME_NEIGHBOR_REPORT_REQ_IND:
5039 rrmProcessNeighborReportReq( pMac, pMsg->bodyptr );
5040 break;
5041 case eWNI_SME_BEACON_REPORT_RESP_XMIT_IND:
5042 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005043#if defined(FEATURE_WLAN_ESE) && !defined(FEATURE_WLAN_ESE_UPLOAD)
Jeff Johnson295189b2012-06-20 16:38:30 -07005044 tpSirBeaconReportXmitInd pBcnReport=NULL;
5045 tpPESession psessionEntry=NULL;
5046 tANI_U8 sessionId;
Padma, Santhosh Kumar20d45a12016-04-05 13:11:00 +05305047 tpEsePEContext pEseContext = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005048
5049 if(pMsg->bodyptr == NULL)
5050 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005051 limLog(pMac, LOGE,FL("Buffer is Pointing to NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005052 return;
5053 }
5054 pBcnReport = (tpSirBeaconReportXmitInd )pMsg->bodyptr;
5055 if((psessionEntry = peFindSessionByBssid(pMac, pBcnReport->bssId,&sessionId))== NULL)
5056 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005057 limLog(pMac, LOGE, "Session Does not exist for given bssId");
Jeff Johnson295189b2012-06-20 16:38:30 -07005058 return;
5059 }
Padma, Santhosh Kumar20d45a12016-04-05 13:11:00 +05305060
5061 pEseContext = &psessionEntry->eseContext;
5062
5063 if (psessionEntry->isESEconnection && pEseContext->curMeasReq.isValid)
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005064 eseProcessBeaconReportXmit( pMac, pMsg->bodyptr);
Jeff Johnson295189b2012-06-20 16:38:30 -07005065 else
5066#endif
5067 rrmProcessBeaconReportXmit( pMac, pMsg->bodyptr );
5068 }
5069 break;
5070 }
5071#endif
5072}
5073
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005074#if defined(FEATURE_WLAN_ESE) || defined(WLAN_FEATURE_VOWIFI)
Jeff Johnson295189b2012-06-20 16:38:30 -07005075// --------------------------------------------------------------------
5076/**
5077 * limSendSetMaxTxPowerReq
5078 *
5079 * FUNCTION: Send SIR_HAL_SET_MAX_TX_POWER_REQ message to change the max tx power.
5080 *
5081 * LOGIC:
5082 *
5083 * ASSUMPTIONS:
5084 *
5085 * NOTE:
5086 *
5087 * @param txPower txPower to be set.
5088 * @param pSessionEntry session entry.
5089 * @return None
5090 */
5091tSirRetStatus
5092limSendSetMaxTxPowerReq ( tpAniSirGlobal pMac, tPowerdBm txPower, tpPESession pSessionEntry )
5093{
5094 tpMaxTxPowerParams pMaxTxParams = NULL;
5095 tSirRetStatus retCode = eSIR_SUCCESS;
5096 tSirMsgQ msgQ;
5097
5098 if( pSessionEntry == NULL )
5099 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005100 PELOGE(limLog(pMac, LOGE, "%s:%d: Inavalid parameters", __func__, __LINE__ );)
Jeff Johnson295189b2012-06-20 16:38:30 -07005101 return eSIR_FAILURE;
5102 }
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05305103
5104 pMaxTxParams = vos_mem_malloc(sizeof(tMaxTxPowerParams));
5105 if ( NULL == pMaxTxParams )
Jeff Johnson295189b2012-06-20 16:38:30 -07005106 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005107 limLog( pMac, LOGP, "%s:%d:Unable to allocate memory for pMaxTxParams ", __func__, __LINE__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005108 return eSIR_MEM_ALLOC_FAILED;
5109
5110 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005111#if defined(WLAN_VOWIFI_DEBUG) || defined(FEATURE_WLAN_ESE)
Abhishek Singh3cbf6052014-12-15 16:46:42 +05305112 limLog( pMac, LOG1,
5113 FL(" Allocated memory for pMaxTxParams, which will be freed in other module"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005114#endif
Kiran Kumar Lokerea4db3dc2013-03-25 18:05:24 -07005115 if( pMaxTxParams == NULL )
5116 {
Abhishek Singh3cbf6052014-12-15 16:46:42 +05305117 limLog( pMac, LOGE, FL("pMaxTxParams is NULL"));
Kiran Kumar Lokerea4db3dc2013-03-25 18:05:24 -07005118 return eSIR_FAILURE;
5119 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005120 pMaxTxParams->power = txPower;
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05305121 vos_mem_copy( pMaxTxParams->bssId, pSessionEntry->bssId, sizeof(tSirMacAddr) );
5122 vos_mem_copy( pMaxTxParams->selfStaMacAddr, pSessionEntry->selfMacAddr, sizeof(tSirMacAddr) );
Jeff Johnson295189b2012-06-20 16:38:30 -07005123
Jeff Johnson68ce9c42013-04-08 10:33:28 -07005124 msgQ.type = WDA_SET_MAX_TX_POWER_REQ;
5125 msgQ.bodyptr = pMaxTxParams;
5126 msgQ.bodyval = 0;
Abhishek Singh3cbf6052014-12-15 16:46:42 +05305127 limLog(pMac, LOG1, FL("Posting WDA_SET_MAX_TX_POWER_REQ to WDA"));
Jeff Johnson68ce9c42013-04-08 10:33:28 -07005128 MTRACE(macTraceMsgTx(pMac, pSessionEntry->peSessionId, msgQ.type));
5129 retCode = wdaPostCtrlMsg(pMac, &msgQ);
5130 if (eSIR_SUCCESS != retCode)
5131 {
5132 PELOGE(limLog(pMac, LOGE, FL("wdaPostCtrlMsg() failed"));)
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05305133 vos_mem_free(pMaxTxParams);
Jeff Johnson68ce9c42013-04-08 10:33:28 -07005134 }
5135 return retCode;
Jeff Johnson295189b2012-06-20 16:38:30 -07005136}
5137#endif
5138
5139/**
5140 * __limProcessSmeAddStaSelfReq()
5141 *
5142 *FUNCTION:
5143 * This function is called to process SME_ADD_STA_SELF_REQ message
5144 * from SME. It sends a SIR_HAL_ADD_STA_SELF_REQ message to HAL.
5145 *
5146 *LOGIC:
5147 *
5148 *ASSUMPTIONS:
5149 *
5150 *NOTE:
5151 *
5152 * @param pMac Pointer to Global MAC structure
5153 * @param *pMsgBuf A pointer to the SME message buffer
5154 * @return None
5155 */
5156
5157static void
5158__limProcessSmeAddStaSelfReq(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
5159{
5160 tSirMsgQ msg;
5161 tpAddStaSelfParams pAddStaSelfParams;
5162 tpSirSmeAddStaSelfReq pSmeReq = (tpSirSmeAddStaSelfReq) pMsgBuf;
5163
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05305164 pAddStaSelfParams = vos_mem_malloc(sizeof(tAddStaSelfParams));
5165 if ( NULL == pAddStaSelfParams )
Jeff Johnson295189b2012-06-20 16:38:30 -07005166 {
5167 limLog( pMac, LOGP, FL("Unable to allocate memory for tAddSelfStaParams") );
5168 return;
5169 }
5170
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05305171 vos_mem_copy( pAddStaSelfParams->selfMacAddr, pSmeReq->selfMacAddr, sizeof(tSirMacAddr) );
Kiran Kumar Lokeread7dbc82013-10-07 20:12:50 -07005172 pAddStaSelfParams->currDeviceMode = pSmeReq->currDeviceMode;
Jeff Johnson295189b2012-06-20 16:38:30 -07005173 msg.type = SIR_HAL_ADD_STA_SELF_REQ;
5174 msg.reserved = 0;
5175 msg.bodyptr = pAddStaSelfParams;
5176 msg.bodyval = 0;
5177
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005178 PELOGW(limLog(pMac, LOG1, FL("sending SIR_HAL_ADD_STA_SELF_REQ msg to HAL"));)
Jeff Johnsone7245742012-09-05 17:12:55 -07005179 MTRACE(macTraceMsgTx(pMac, NO_SESSION, msg.type));
Jeff Johnson295189b2012-06-20 16:38:30 -07005180
5181 if(eSIR_SUCCESS != wdaPostCtrlMsg(pMac, &msg))
5182 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005183 limLog(pMac, LOGP, FL("wdaPostCtrlMsg failed"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005184 }
5185 return;
5186} /*** end __limProcessAddStaSelfReq() ***/
5187
5188
5189/**
5190 * __limProcessSmeDelStaSelfReq()
5191 *
5192 *FUNCTION:
5193 * This function is called to process SME_DEL_STA_SELF_REQ message
5194 * from SME. It sends a SIR_HAL_DEL_STA_SELF_REQ message to HAL.
5195 *
5196 *LOGIC:
5197 *
5198 *ASSUMPTIONS:
5199 *
5200 *NOTE:
5201 *
5202 * @param pMac Pointer to Global MAC structure
5203 * @param *pMsgBuf A pointer to the SME message buffer
5204 * @return None
5205 */
5206
5207static void
5208__limProcessSmeDelStaSelfReq(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
5209{
5210 tSirMsgQ msg;
5211 tpDelStaSelfParams pDelStaSelfParams;
5212 tpSirSmeDelStaSelfReq pSmeReq = (tpSirSmeDelStaSelfReq) pMsgBuf;
5213
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05305214 pDelStaSelfParams = vos_mem_malloc(sizeof( tDelStaSelfParams));
5215 if ( NULL == pDelStaSelfParams )
Jeff Johnson295189b2012-06-20 16:38:30 -07005216 {
5217 limLog( pMac, LOGP, FL("Unable to allocate memory for tDelStaSelfParams") );
5218 return;
5219 }
5220
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05305221 vos_mem_copy( pDelStaSelfParams->selfMacAddr, pSmeReq->selfMacAddr, sizeof(tSirMacAddr) );
Jeff Johnson295189b2012-06-20 16:38:30 -07005222
5223 msg.type = SIR_HAL_DEL_STA_SELF_REQ;
5224 msg.reserved = 0;
5225 msg.bodyptr = pDelStaSelfParams;
5226 msg.bodyval = 0;
5227
Mukul Sharmacaf4aca2015-04-17 20:01:40 +05305228 PELOGW(limLog(pMac, LOG1, FL("sending SIR_HAL_DEL_STA_SELF_REQ msg to HAL"));)
Jeff Johnsone7245742012-09-05 17:12:55 -07005229 MTRACE(macTraceMsgTx(pMac, NO_SESSION, msg.type));
Jeff Johnson295189b2012-06-20 16:38:30 -07005230
5231 if(eSIR_SUCCESS != wdaPostCtrlMsg(pMac, &msg))
5232 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005233 limLog(pMac, LOGP, FL("wdaPostCtrlMsg failed"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005234 }
5235 return;
5236} /*** end __limProcessSmeDelStaSelfReq() ***/
5237
5238
Jeff Johnson295189b2012-06-20 16:38:30 -07005239/**
5240 * __limProcessSmeRegisterMgmtFrameReq()
5241 *
5242 *FUNCTION:
5243 * This function is called to process eWNI_SME_REGISTER_MGMT_FRAME_REQ message
5244 * from SME. It Register this information within PE.
5245 *
5246 *LOGIC:
5247 *
5248 *ASSUMPTIONS:
5249 *
5250 *NOTE:
5251 *
5252 * @param pMac Pointer to Global MAC structure
5253 * @param *pMsgBuf A pointer to the SME message buffer
5254 * @return None
5255 */
5256static void
5257__limProcessSmeRegisterMgmtFrameReq(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
5258{
5259 VOS_STATUS vosStatus;
5260 tpSirRegisterMgmtFrame pSmeReq = (tpSirRegisterMgmtFrame)pMsgBuf;
5261 tpLimMgmtFrameRegistration pLimMgmtRegistration = NULL, pNext = NULL;
Jeff Johnsond13512a2012-07-17 11:42:19 -07005262 tANI_BOOLEAN match = VOS_FALSE;
Abhishek Singh3cbf6052014-12-15 16:46:42 +05305263 limLog(pMac, LOG1,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005264 FL("registerFrame %d, frameType %d, matchLen %d"),
Abhishek Singh3cbf6052014-12-15 16:46:42 +05305265 pSmeReq->registerFrame, pSmeReq->frameType, pSmeReq->matchLen);
Jeff Johnson295189b2012-06-20 16:38:30 -07005266
Jeff Johnsond13512a2012-07-17 11:42:19 -07005267 /* First check whether entry exists already*/
5268
5269 vos_list_peek_front(&pMac->lim.gLimMgmtFrameRegistratinQueue,
5270 (vos_list_node_t**)&pLimMgmtRegistration);
5271
5272 while(pLimMgmtRegistration != NULL)
5273 {
5274 if (pLimMgmtRegistration->frameType == pSmeReq->frameType)
5275 {
5276 if(pSmeReq->matchLen)
5277 {
5278 if (pLimMgmtRegistration->matchLen == pSmeReq->matchLen)
5279 {
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05305280 if (vos_mem_compare( pLimMgmtRegistration->matchData,
Jeff Johnsond13512a2012-07-17 11:42:19 -07005281 pSmeReq->matchData, pLimMgmtRegistration->matchLen))
5282 {
Madan Mohan Koyyalamudic537df22012-10-22 15:07:08 -07005283 /* found match! */
5284 match = VOS_TRUE;
5285 break;
Jeff Johnsond13512a2012-07-17 11:42:19 -07005286 }
5287 }
5288 }
5289 else
5290 {
Madan Mohan Koyyalamudic537df22012-10-22 15:07:08 -07005291 /* found match! */
Jeff Johnsond13512a2012-07-17 11:42:19 -07005292 match = VOS_TRUE;
5293 break;
5294 }
5295 }
5296 vosStatus = vos_list_peek_next (
5297 &pMac->lim.gLimMgmtFrameRegistratinQueue,
5298 (vos_list_node_t*) pLimMgmtRegistration,
5299 (vos_list_node_t**) &pNext );
5300
5301 pLimMgmtRegistration = pNext;
5302 pNext = NULL;
5303
5304 }
5305
5306 if (match)
5307 {
5308 vos_list_remove_node(&pMac->lim.gLimMgmtFrameRegistratinQueue,
5309 (vos_list_node_t*)pLimMgmtRegistration);
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05305310 vos_mem_free(pLimMgmtRegistration);
Jeff Johnsond13512a2012-07-17 11:42:19 -07005311 }
5312
Jeff Johnson295189b2012-06-20 16:38:30 -07005313 if(pSmeReq->registerFrame)
5314 {
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05305315 pLimMgmtRegistration = vos_mem_malloc(sizeof(tLimMgmtFrameRegistration) + pSmeReq->matchLen);
5316 if ( pLimMgmtRegistration != NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -07005317 {
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05305318 vos_mem_set((void*)pLimMgmtRegistration,
5319 sizeof(tLimMgmtFrameRegistration) + pSmeReq->matchLen, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005320 pLimMgmtRegistration->frameType = pSmeReq->frameType;
5321 pLimMgmtRegistration->matchLen = pSmeReq->matchLen;
5322 pLimMgmtRegistration->sessionId = pSmeReq->sessionId;
5323 if(pSmeReq->matchLen)
5324 {
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05305325 vos_mem_copy(pLimMgmtRegistration->matchData,
5326 pSmeReq->matchData, pSmeReq->matchLen);
Jeff Johnson295189b2012-06-20 16:38:30 -07005327 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005328 vos_list_insert_front(&pMac->lim.gLimMgmtFrameRegistratinQueue,
5329 &pLimMgmtRegistration->node);
5330 }
5331 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005332
5333 return;
5334} /*** end __limProcessSmeRegisterMgmtFrameReq() ***/
Viral Modid86bde22012-12-10 13:09:21 -08005335
5336static tANI_BOOLEAN
Viral Modid440e682013-03-06 02:25:31 -08005337__limInsertSingleShotNOAForScan(tpAniSirGlobal pMac, tANI_U32 noaDuration)
Viral Modid86bde22012-12-10 13:09:21 -08005338{
5339 tpP2pPsParams pMsgNoA;
5340 tSirMsgQ msg;
Vinay Malekal62757362012-12-17 12:15:51 -08005341
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05305342 pMsgNoA = vos_mem_malloc(sizeof( tP2pPsConfig ));
5343 if ( NULL == pMsgNoA )
Viral Modid86bde22012-12-10 13:09:21 -08005344 {
5345 limLog( pMac, LOGP,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005346 FL( "Unable to allocate memory during NoA Update" ));
Viral Modid440e682013-03-06 02:25:31 -08005347 goto error;
Viral Modid86bde22012-12-10 13:09:21 -08005348 }
5349
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05305350 vos_mem_set((tANI_U8 *)pMsgNoA, sizeof(tP2pPsConfig), 0);
Viral Modid86bde22012-12-10 13:09:21 -08005351 /* Below params used for opp PS/periodic NOA and are don't care in this case - so initialized to 0 */
5352 pMsgNoA->opp_ps = 0;
5353 pMsgNoA->ctWindow = 0;
5354 pMsgNoA->duration = 0;
5355 pMsgNoA->interval = 0;
5356 pMsgNoA->count = 0;
Vinay Malekal62757362012-12-17 12:15:51 -08005357
Vinay Malekal62757362012-12-17 12:15:51 -08005358 /* Below params used for Single Shot NOA - so assign proper values */
5359 pMsgNoA->psSelection = P2P_SINGLE_NOA;
Viral Modid440e682013-03-06 02:25:31 -08005360 pMsgNoA->single_noa_duration = noaDuration;
Gopichand Nakkala096a1052012-12-21 07:05:34 -08005361
Viral Modid86bde22012-12-10 13:09:21 -08005362 /* Start Insert NOA timer
5363 * 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 -08005364 * or any other failure or reason, we still need to process the deferred SME req. The insert NOA
5365 * timer of 500 ms will ensure the stored SME req always gets processed
Viral Modid86bde22012-12-10 13:09:21 -08005366 */
5367 if (tx_timer_activate(&pMac->lim.limTimers.gLimP2pSingleShotNoaInsertTimer)
5368 == TX_TIMER_ERROR)
5369 {
5370 /// Could not activate Insert NOA timer.
5371 // Log error
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005372 limLog(pMac, LOGP, FL("could not activate Insert Single Shot NOA during scan timer"));
Viral Modid86bde22012-12-10 13:09:21 -08005373
5374 // send the scan response back with status failure and do not even call insert NOA
5375 limSendSmeScanRsp(pMac, sizeof(tSirSmeScanRsp), eSIR_SME_SCAN_FAILED, pMac->lim.gSmeSessionId, pMac->lim.gTransactionId);
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05305376 vos_mem_free(pMsgNoA);
Viral Modid440e682013-03-06 02:25:31 -08005377 goto error;
Viral Modid86bde22012-12-10 13:09:21 -08005378 }
5379
Viral Modid440e682013-03-06 02:25:31 -08005380 MTRACE(macTrace(pMac, TRACE_CODE_TIMER_ACTIVATE, NO_SESSION, eLIM_INSERT_SINGLESHOT_NOA_TIMER));
5381
Viral Modid86bde22012-12-10 13:09:21 -08005382 msg.type = WDA_SET_P2P_GO_NOA_REQ;
5383 msg.reserved = 0;
5384 msg.bodyptr = pMsgNoA;
5385 msg.bodyval = 0;
5386
5387 if(eSIR_SUCCESS != wdaPostCtrlMsg(pMac, &msg))
5388 {
5389 /* 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 -07005390 limLog(pMac, LOGP, FL("wdaPost Msg failed"));
Viral Modid440e682013-03-06 02:25:31 -08005391 /* Deactivate the NOA timer in failure case */
5392 limDeactivateAndChangeTimer(pMac, eLIM_INSERT_SINGLESHOT_NOA_TIMER);
5393 goto error;
Viral Modid86bde22012-12-10 13:09:21 -08005394 }
Viral Modid440e682013-03-06 02:25:31 -08005395 return FALSE;
Viral Modid86bde22012-12-10 13:09:21 -08005396
Viral Modid440e682013-03-06 02:25:31 -08005397error:
5398 /* In any of the failure cases, just go ahead with the processing of registered deferred SME request without
5399 * worrying about the NOA
5400 */
5401 limProcessRegdDefdSmeReqAfterNOAStart(pMac);
5402 // msg buffer is consumed and freed in above function so return FALSE
Viral Modid86bde22012-12-10 13:09:21 -08005403 return FALSE;
5404
5405}
5406
Viral Modid440e682013-03-06 02:25:31 -08005407static void __limRegisterDeferredSmeReqForNOAStart(tpAniSirGlobal pMac, tANI_U16 msgType, tANI_U32 *pMsgBuf)
5408{
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005409 limLog(pMac, LOG1, FL("Reg msgType %d"), msgType) ;
Viral Modid440e682013-03-06 02:25:31 -08005410 pMac->lim.gDeferMsgTypeForNOA = msgType;
5411 pMac->lim.gpDefdSmeMsgForNOA = pMsgBuf;
5412}
5413
5414static void __limDeregisterDeferredSmeReqAfterNOAStart(tpAniSirGlobal pMac)
5415{
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005416 limLog(pMac, LOG1, FL("Dereg msgType %d"), pMac->lim.gDeferMsgTypeForNOA) ;
Viral Modid440e682013-03-06 02:25:31 -08005417 pMac->lim.gDeferMsgTypeForNOA = 0;
5418 if (pMac->lim.gpDefdSmeMsgForNOA != NULL)
5419 {
5420 /* __limProcessSmeScanReq consumed the buffer. We can free it. */
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05305421 vos_mem_free(pMac->lim.gpDefdSmeMsgForNOA);
Viral Modid440e682013-03-06 02:25:31 -08005422 pMac->lim.gpDefdSmeMsgForNOA = NULL;
5423 }
5424}
5425
5426static
Ganesh Kondabattini16930072014-08-22 16:02:34 +05305427tANI_U32 limCalculateNOADuration(tpAniSirGlobal pMac, tANI_U16 msgType,
5428 tANI_U32 *pMsgBuf, tANI_BOOLEAN isPassiveScan)
Viral Modid440e682013-03-06 02:25:31 -08005429{
5430 tANI_U32 noaDuration = 0;
5431
5432 switch (msgType)
5433 {
5434 case eWNI_SME_SCAN_REQ:
5435 {
5436 tANI_U32 val;
5437 tANI_U8 i;
5438 tpSirSmeScanReq pScanReq = (tpSirSmeScanReq) pMsgBuf;
5439 if (wlan_cfgGetInt(pMac, WNI_CFG_PASSIVE_MAXIMUM_CHANNEL_TIME, &val) != eSIR_SUCCESS)
5440 {
5441 /*
5442 * Could not get max channel value
5443 * from CFG. Log error.
5444 */
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005445 limLog(pMac, LOGP, FL("could not retrieve passive max channel value"));
Viral Modid440e682013-03-06 02:25:31 -08005446
5447 /* use a default value of 110ms */
5448 val = DEFAULT_PASSIVE_MAX_CHANNEL_TIME;
5449 }
5450
5451 for (i = 0; i < pScanReq->channelList.numChannels; i++) {
5452 tANI_U8 channelNum = pScanReq->channelList.channelNumber[i];
5453
Ganesh Kondabattini8f6e3b32014-08-25 16:07:54 +05305454 if (pMac->miracast_mode) {
5455 noaDuration += DEFAULT_MIN_CHAN_TIME_DURING_MIRACAST +
5456 DEFAULT_MAX_CHAN_TIME_DURING_MIRACAST;
5457 } else if (isPassiveScan || !limActiveScanAllowed(pMac, channelNum)) {
Viral Modid440e682013-03-06 02:25:31 -08005458 /* using the value from WNI_CFG_PASSIVE_MINIMUM_CHANNEL_TIME as is done in
5459 * void limContinuePostChannelScan(tpAniSirGlobal pMac)
5460 */
5461 noaDuration += val;
Ganesh Kondabattini16930072014-08-22 16:02:34 +05305462 } else {
5463 /* Use min + max channel time to calculate the total duration of scan */
5464 noaDuration += pScanReq->minChannelTime + pScanReq->maxChannelTime;
Viral Modid440e682013-03-06 02:25:31 -08005465 }
5466 }
5467
5468 /* Adding an overhead of 20ms to account for the scan messaging delays */
5469 noaDuration += SCAN_MESSAGING_OVERHEAD;
5470 noaDuration *= CONV_MS_TO_US;
5471
5472 break;
5473 }
5474
5475 case eWNI_SME_OEM_DATA_REQ:
5476 noaDuration = OEM_DATA_NOA_DURATION*CONV_MS_TO_US; // use 60 msec as default
5477 break;
5478
5479 case eWNI_SME_REMAIN_ON_CHANNEL_REQ:
5480 {
5481 tSirRemainOnChnReq *pRemainOnChnReq = (tSirRemainOnChnReq *) pMsgBuf;
5482 noaDuration = (pRemainOnChnReq->duration)*CONV_MS_TO_US;
5483 break;
5484 }
5485
5486 case eWNI_SME_JOIN_REQ:
5487 noaDuration = JOIN_NOA_DURATION*CONV_MS_TO_US;
5488 break;
5489
5490 default:
5491 noaDuration = 0;
5492 break;
5493
5494 }
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005495 limLog(pMac, LOGW, FL("msgType %d noa %d"), msgType, noaDuration);
Viral Modid440e682013-03-06 02:25:31 -08005496 return noaDuration;
5497}
5498
5499void limProcessRegdDefdSmeReqAfterNOAStart(tpAniSirGlobal pMac)
5500{
Gopichand Nakkala7c4c3b92013-03-25 18:08:31 +05305501 tANI_BOOLEAN bufConsumed = TRUE;
Viral Modid440e682013-03-06 02:25:31 -08005502
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005503 limLog(pMac, LOG1, FL("Process defd sme req %d"), pMac->lim.gDeferMsgTypeForNOA);
Viral Modid440e682013-03-06 02:25:31 -08005504 if ( (pMac->lim.gDeferMsgTypeForNOA != 0) &&
5505 (pMac->lim.gpDefdSmeMsgForNOA != NULL) )
5506 {
5507 switch (pMac->lim.gDeferMsgTypeForNOA)
5508 {
5509 case eWNI_SME_SCAN_REQ:
5510 __limProcessSmeScanReq(pMac, pMac->lim.gpDefdSmeMsgForNOA);
5511 break;
5512 case eWNI_SME_OEM_DATA_REQ:
5513 __limProcessSmeOemDataReq(pMac, pMac->lim.gpDefdSmeMsgForNOA);
5514 break;
5515 case eWNI_SME_REMAIN_ON_CHANNEL_REQ:
Gopichand Nakkala7c4c3b92013-03-25 18:08:31 +05305516 bufConsumed = limProcessRemainOnChnlReq(pMac, pMac->lim.gpDefdSmeMsgForNOA);
5517 /* limProcessRemainOnChnlReq doesnt want us to free the buffer since
5518 * it is freed in limRemainOnChnRsp. this change is to avoid "double free"
5519 */
5520 if (FALSE == bufConsumed)
5521 {
5522 pMac->lim.gpDefdSmeMsgForNOA = NULL;
5523 }
Viral Modid440e682013-03-06 02:25:31 -08005524 break;
5525 case eWNI_SME_JOIN_REQ:
5526 __limProcessSmeJoinReq(pMac, pMac->lim.gpDefdSmeMsgForNOA);
5527 break;
5528 default:
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005529 limLog(pMac, LOGE, FL("Unknown deferred msg type %d"), pMac->lim.gDeferMsgTypeForNOA);
Viral Modid440e682013-03-06 02:25:31 -08005530 break;
5531 }
5532 __limDeregisterDeferredSmeReqAfterNOAStart(pMac);
5533 }
5534 else
5535 {
5536 limLog( pMac, LOGW, FL("start received from FW when no sme deferred msg pending. Do nothing."
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005537 "It might happen sometime when NOA start ind and timeout happen at the same time"));
Viral Modid440e682013-03-06 02:25:31 -08005538 }
5539}
Jeff Johnson295189b2012-06-20 16:38:30 -07005540
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05305541static void
5542__limProcessSmeResetApCapsChange(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
5543{
5544 tpSirResetAPCapsChange pResetCapsChange;
5545 tpPESession psessionEntry;
5546 tANI_U8 sessionId = 0;
5547 if (pMsgBuf == NULL)
5548 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005549 limLog(pMac, LOGE,FL("Buffer is Pointing to NULL"));
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05305550 return;
5551 }
5552
5553 pResetCapsChange = (tpSirResetAPCapsChange)pMsgBuf;
5554 psessionEntry = peFindSessionByBssid(pMac, pResetCapsChange->bssId, &sessionId);
5555 if (psessionEntry == NULL)
5556 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005557 limLog(pMac, LOGE, FL("Session does not exist for given BSSID"));
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05305558 return;
5559 }
5560
5561 psessionEntry->limSentCapsChangeNtf = false;
5562 return;
5563}
5564
Siddharth Bhal6af5d4e2014-09-29 21:11:16 +05305565static void
5566__limProcessSmeSpoofMacAddrRequest(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
5567{
5568 tSirMsgQ msg;
5569 tpSpoofMacAddrReqParams pSpoofMacAddrParams;
5570 tpSirSpoofMacAddrReq pSmeReq = (tpSirSpoofMacAddrReq) pMsgBuf;
5571
5572 pSpoofMacAddrParams = vos_mem_malloc(sizeof( tSpoofMacAddrReqParams));
5573 if ( NULL == pSpoofMacAddrParams )
5574 {
Siddharth Bhal4f3187c2014-10-09 21:38:08 +05305575 limLog( pMac, LOGE, FL("Unable to allocate memory for tDelStaSelfParams") );
Siddharth Bhal6af5d4e2014-09-29 21:11:16 +05305576 return;
5577 }
5578
5579 vos_mem_copy( pSpoofMacAddrParams->macAddr, pSmeReq->macAddr, sizeof(tSirMacAddr) );
5580
Siddharth Bhal4f3187c2014-10-09 21:38:08 +05305581 vos_mem_copy(pMac->lim.spoofMacAddr, pSmeReq->macAddr, VOS_MAC_ADDRESS_LEN);
5582
5583 limLog( pMac, LOG1, FL("Recieved Spoofed Mac Addr request with Addr:"
5584 MAC_ADDRESS_STR), MAC_ADDR_ARRAY(pMac->lim.spoofMacAddr) );
5585
Siddharth Bhal6af5d4e2014-09-29 21:11:16 +05305586 msg.type = WDA_SPOOF_MAC_ADDR_REQ;
5587 msg.reserved = 0;
5588 msg.bodyptr = pSpoofMacAddrParams;
5589 msg.bodyval = 0;
5590
5591 limLog(pMac, LOG1, FL("sending SIR_HAL_SPOOF_MAC_ADDR_REQ msg to HAL"));
5592 MTRACE(macTraceMsgTx(pMac, NO_SESSION, msg.type));
5593
5594 if(eSIR_SUCCESS != wdaPostCtrlMsg(pMac, &msg))
5595 {
Siddharth Bhal4f3187c2014-10-09 21:38:08 +05305596 limLog(pMac, LOGE, FL("wdaPostCtrlMsg failed for SIR_HAL_SPOOF_MAC_ADDR_REQ"));
Siddharth Bhal6af5d4e2014-09-29 21:11:16 +05305597 vos_mem_free(pSpoofMacAddrParams);
5598 }
5599 return;
5600}
5601
Jeff Johnson295189b2012-06-20 16:38:30 -07005602/**
Abhishek Singh7d624e12015-11-30 14:29:27 +05305603 * lim_register_mgmt_frame_ind_cb() - Save the Management frame
5604 * indication callback in PE.
5605 * @pMac: Mac pointer
5606 * @pMsgBuf: Msg pointer containing the callback
5607 *
5608 * This function is used save the Management frame
5609 * indication callback in PE.
5610 *
5611 * Return: None
5612 */
5613static void lim_register_mgmt_frame_ind_cb(tpAniSirGlobal pMac,
5614 tANI_U32 *msg_buf)
5615{
5616 struct sir_sme_mgmt_frame_cb_req *sme_req =
5617 (struct sir_sme_mgmt_frame_cb_req *)msg_buf;
5618
5619 if (NULL == msg_buf)
5620 {
5621 limLog(pMac, LOGE, FL("msg_buf is null"));
5622 return;
5623 }
5624 if (sme_req->callback)
5625 pMac->mgmt_frame_ind_cb =
5626 (sir_mgmt_frame_ind_callback)sme_req->callback;
5627 else
5628 limLog(pMac, LOGE, FL("sme_req->callback is null"));
5629}
Abhishek Singh2b0cf1c2017-10-30 17:36:38 +05305630
5631/**
5632 * lim_send_chan_switch_action_frame() - send channel switch action frame to all
5633 * connected peers
5634 * @mac_ctx: Pointer to Global MAC structure
5635 * @new_channel: new channel
5636 * @session_entry: ap session
5637 *
5638 * Return: None
5639 */
5640static void lim_send_chan_switch_action_frame(tpAniSirGlobal mac_ctx,
5641 uint16_t new_channel, tpPESession session_entry)
5642{
5643 uint16_t op_class;
5644 uint8_t switch_mode = 0, i;
5645 tpDphHashNode psta;
5646 uint8_t switch_count;
5647 tpDphHashNode dph_node_array_ptr;
5648 offset_t ch_offset;
5649
5650 if (session_entry->gLimChannelSwitch.secondarySubBand >=
5651 PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_CENTERED)
5652 ch_offset = BW80;
5653 else
5654 ch_offset = session_entry->gLimChannelSwitch.secondarySubBand;
5655
5656 op_class = limGetOPClassFromChannel(mac_ctx->scan.countryCodeCurrent,
5657 new_channel, ch_offset);
5658
5659 switch_mode = session_entry->gLimChannelSwitch.switchMode;
5660
5661 switch_count = session_entry->gLimChannelSwitch.switchCount;
5662 dph_node_array_ptr = session_entry->dph.dphHashTable.pDphNodeArray;
5663
5664 for (i = 0; i < (mac_ctx->lim.maxStation + 1); i++) {
5665 psta = dph_node_array_ptr + i;
5666 if (!(psta && psta->added))
5667 continue;
5668 if (psta->staType == STA_ENTRY_PEER)
5669 lim_send_extended_chan_switch_action_frame(mac_ctx, psta->staAddr,
5670 switch_mode, op_class, new_channel,
5671 switch_count, session_entry);
5672 }
5673}
5674
Abhishek Singh02605092017-10-25 14:06:12 +05305675/**
5676 * lim_process_sme_set_csa_ie_request() - process sme dfs csa ie req
5677 *
5678 * @mac_ctx: Pointer to Global MAC structure
5679 * @msg_buf: pointer to the SME message buffer
5680 *
5681 * This function processes SME request messages from HDD or upper layer
5682 * application.
5683 *
5684 * Return: None
5685 */
5686static void lim_process_sme_set_csa_ie_request(tpAniSirGlobal mac_ctx,
5687 uint32_t *msg_buf)
5688{
5689 struct sir_ecsa_ie_req *csa_ie_req = (struct sir_ecsa_ie_req *)msg_buf;
5690 uint8_t session_id;
5691 tpPESession session_entry = NULL;
5692 tLimWiderBWChannelSwitchInfo *wider_bw_ch_switch;
5693
5694 if (!csa_ie_req) {
5695 limLog(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
5696 return;
5697 }
5698
5699 session_entry = peFindSessionByBssid(mac_ctx,
5700 csa_ie_req->bssid, &session_id);
5701 if (!session_entry) {
5702 limLog(mac_ctx, LOGE,
5703 FL("Session not found for given BSSID" MAC_ADDRESS_STR),
5704 MAC_ADDR_ARRAY(csa_ie_req->bssid));
5705 return;
5706 }
5707
5708 if (session_entry->valid && !LIM_IS_AP_ROLE(session_entry)) {
5709 limLog(mac_ctx, LOGE, FL("Invalid SystemRole %d"),
5710 GET_LIM_SYSTEM_ROLE(session_entry));
5711 return;
5712 }
5713
5714 /* target channel */
5715 session_entry->gLimChannelSwitch.primaryChannel = csa_ie_req->new_chan;
5716
5717 /* Channel switch announcement needs to be included in beacon */
5718 session_entry->include_ecsa_ie = true;
5719 session_entry->gLimChannelSwitch.switchCount =
5720 CHANNEL_SWITCH_BEACON_COUNT;
5721 session_entry->gLimChannelSwitch.secondarySubBand =
5722 csa_ie_req->cb_mode;
5723 session_entry->gLimChannelSwitch.switchMode = SAP_CHANNEL_SWITCH_MODE;
5724
5725 /* Now encode the Wider Ch BW element depending on the ch width */
5726 if (session_entry->vhtCapability &&
5727 (csa_ie_req->cb_mode >=
5728 PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_CENTERED)) {
5729 wider_bw_ch_switch = &session_entry->gLimWiderBWChannelSwitch;
5730 session_entry->include_wide_ch_bw_ie = true;
5731 wider_bw_ch_switch->newChanWidth = WNI_CFG_VHT_CHANNEL_WIDTH_80MHZ;
5732 /* Fetch the center channel based on the channel width */
5733 wider_bw_ch_switch->newCenterChanFreq0 =
5734 limGetCenterChannel(mac_ctx, csa_ie_req->new_chan,
5735 csa_ie_req->cb_mode,
5736 WNI_CFG_VHT_CHANNEL_WIDTH_80MHZ);
5737 }
5738 /* Send ECSA/CSA IE request from here */
5739 if (schSetFixedBeaconFields(mac_ctx, session_entry) != eSIR_SUCCESS) {
5740 limLog(mac_ctx, LOGE, FL("Unable to set CSA IE in beacon"));
5741 return;
5742 }
5743
Abhishek Singh2b0cf1c2017-10-30 17:36:38 +05305744 limSendBeaconInd(mac_ctx, session_entry);
Abhishek Singh02605092017-10-25 14:06:12 +05305745
Abhishek Singh2b0cf1c2017-10-30 17:36:38 +05305746 lim_send_chan_switch_action_frame(mac_ctx,
5747 csa_ie_req->new_chan, session_entry);
5748
5749 limLog(mac_ctx, LOG1, FL("IE count:%d chan:%d secondarySubBand:%d"),
Abhishek Singh02605092017-10-25 14:06:12 +05305750 session_entry->gLimChannelSwitch.switchCount,
5751 session_entry->gLimChannelSwitch.primaryChannel,
5752 session_entry->gLimChannelSwitch.secondarySubBand);
Abhishek Singh550aa8c2017-10-30 17:34:53 +05305753
5754 mac_ctx->lim.limTimers.g_lim_ap_ecsa_timer.sessionId =
5755 session_entry->peSessionId;
5756 limDeactivateAndChangeTimer(mac_ctx, eLIM_AP_ECSA_TIMER);
5757
5758 if (tx_timer_activate(&mac_ctx->lim.limTimers.g_lim_ap_ecsa_timer) !=
5759 TX_SUCCESS)
5760 {
5761 limLog(mac_ctx, LOGE, FL("Couldn't activate g_lim_ap_ecsa_timer"));
5762 lim_process_ap_ecsa_timeout(mac_ctx);
5763 }
5764}
5765
5766/**
5767 * lim_process_sme_channel_change_request() - process sme ch change req
5768 *
5769 * @mac_ctx: Pointer to Global MAC structure
5770 * @msg_buf: pointer to the SME message buffer
5771 *
5772 * This function is called to process SME_CHANNEL_CHANGE_REQ message
5773 *
5774 * Return: None
5775 */
5776static void lim_process_sme_channel_change_request(tpAniSirGlobal mac_ctx,
5777 uint32_t *msg_buf)
5778{
5779 struct sir_channel_chanege_req *ch_change_req;
5780 tpPESession session_entry;
5781 uint8_t session_id; /* PE session_id */
5782 int8_t max_tx_pwr;
5783 uint32_t val = 0;
Abhishek Singh02b823e2017-10-30 17:53:20 +05305784 uint8_t cb_mode;
Abhishek Singh550aa8c2017-10-30 17:34:53 +05305785
5786 if (!msg_buf) {
5787 limLog(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
5788 return;
5789 }
5790 ch_change_req = (struct sir_channel_chanege_req *)msg_buf;
5791
5792 max_tx_pwr = cfgGetRegulatoryMaxTransmitPower(mac_ctx,
5793 ch_change_req->new_chan);
5794
5795 if ((max_tx_pwr == WDA_MAX_TXPOWER_INVALID)) {
5796 limLog(mac_ctx, LOGE, FL("Invalid Request/max_tx_pwr"));
5797 return;
5798 }
5799
5800 session_entry = peFindSessionByBssid(mac_ctx,
5801 ch_change_req->bssid, &session_id);
5802 if (!session_entry) {
5803 limLog(mac_ctx, LOGE,
5804 FL("Session not found for given BSSID" MAC_ADDRESS_STR),
5805 MAC_ADDR_ARRAY(ch_change_req->bssid));
5806 return;
5807 }
5808
5809 if (session_entry->valid && !LIM_IS_AP_ROLE(session_entry)) {
5810 limLog(mac_ctx, LOGE, FL("Invalid SystemRole %d"),
5811 GET_LIM_SYSTEM_ROLE(session_entry));
5812 return;
5813 }
5814 if (session_entry->currentOperChannel ==
5815 ch_change_req->new_chan) {
5816 limLog(mac_ctx, LOGE, FL("target CH is same as current CH %d"),
5817 session_entry->currentOperChannel);
5818 return;
5819 }
5820
5821 session_entry->channelChangeReasonCode =
5822 LIM_SWITCH_CHANNEL_SAP_ECSA;
Abhishek Singhe3af5042017-11-30 11:42:23 +05305823 session_entry->channelChangeCSA = LIM_SWITCH_CHANNEL_CSA;
Abhishek Singh550aa8c2017-10-30 17:34:53 +05305824
Abhishek Singh02b823e2017-10-30 17:53:20 +05305825 limLog(mac_ctx, LOG1, FL("switch old chnl %d to new chnl %d, cb_mode %d"),
Abhishek Singh550aa8c2017-10-30 17:34:53 +05305826 session_entry->currentOperChannel,
5827 ch_change_req->new_chan,
5828 ch_change_req->cb_mode);
5829
Abhishek Singh02b823e2017-10-30 17:53:20 +05305830 cb_mode = ch_change_req->cb_mode;
5831
5832 if (session_entry->vhtCapability) {
5833 if (cb_mode <= PHY_DOUBLE_CHANNEL_HIGH_PRIMARY) {
5834 session_entry->vhtTxChannelWidthSet =
5835 WNI_CFG_VHT_CHANNEL_WIDTH_20_40MHZ;
5836 session_entry->apChanWidth = WNI_CFG_VHT_CHANNEL_WIDTH_20_40MHZ;
5837 /*
5838 * In case of DFS operation, If AP falls back to lower
5839 * bandwidth [< 80Mhz] then there is no need of
5840 * Center freq segment. So reset it to zero.
5841 */
5842 if (cfgSetInt(mac_ctx, WNI_CFG_VHT_CHANNEL_CENTER_FREQ_SEGMENT1, 0)
5843 != eSIR_SUCCESS)
5844 limLog(mac_ctx, LOGE,
5845 FL("couldn't set center freq seg 0 in beacon"));
5846 if (cfgSetInt(mac_ctx, WNI_CFG_VHT_CHANNEL_WIDTH,
5847 WNI_CFG_VHT_CHANNEL_WIDTH_20_40MHZ) != eSIR_SUCCESS)
5848 limLog(mac_ctx, LOGE, FL("could not set channel width to 20/40 in CFG"));
5849 session_entry->apCenterChan = 0;
5850 } else {
5851 uint32_t center_chan;
5852
5853 session_entry->vhtTxChannelWidthSet =
5854 WNI_CFG_VHT_CHANNEL_WIDTH_80MHZ;
5855 session_entry->apChanWidth = WNI_CFG_VHT_CHANNEL_WIDTH_80MHZ;
5856 center_chan = limGetCenterChannel(mac_ctx, ch_change_req->new_chan,
5857 cb_mode, WNI_CFG_VHT_CHANNEL_WIDTH_80MHZ);
5858 limLog(mac_ctx, LOGW,
5859 FL("***Center Channel for 80MHZ channel width = %d"),
5860 center_chan);
5861 session_entry->apCenterChan = center_chan;
5862 if (cfgSetInt(mac_ctx, WNI_CFG_VHT_CHANNEL_CENTER_FREQ_SEGMENT1,
5863 center_chan) != eSIR_SUCCESS)
5864 limLog(mac_ctx, LOGE, FL("could not set center freq seg 0 in beacon"));
5865 if (cfgSetInt(mac_ctx, WNI_CFG_VHT_CHANNEL_WIDTH,
5866 WNI_CFG_VHT_CHANNEL_WIDTH_80MHZ) != eSIR_SUCCESS)
5867 limLog(mac_ctx, LOGE, FL("could not set channel width to 80 in CFG"));
5868 }
5869 }
5870
Abhishek Singh550aa8c2017-10-30 17:34:53 +05305871 /* Store the New Channel Params in session_entry */
Abhishek Singh02b823e2017-10-30 17:53:20 +05305872 session_entry->htSecondaryChannelOffset = limGetHTCBState(cb_mode);
5873 session_entry->htSupportedChannelWidthSet = (cb_mode ? 1 : 0);
Abhishek Singh550aa8c2017-10-30 17:34:53 +05305874 session_entry->htRecommendedTxWidthSet =
5875 session_entry->htSupportedChannelWidthSet;
5876 session_entry->currentOperChannel = ch_change_req->new_chan;
5877 session_entry->limRFBand = limGetRFBand(session_entry->currentOperChannel);
5878 /* Initialize 11h Enable Flag */
5879 if (SIR_BAND_5_GHZ == session_entry->limRFBand) {
5880 if (wlan_cfgGetInt(mac_ctx, WNI_CFG_11H_ENABLED, &val) != eSIR_SUCCESS)
5881 limLog(mac_ctx, LOGE, FL("Fail to get WNI_CFG_11H_ENABLED"));
5882 }
5883
5884 session_entry->lim11hEnable = val;
5885 session_entry->dot11mode = ch_change_req->dot11mode;
5886 vos_mem_copy(&session_entry->rateSet, &ch_change_req->operational_rateset,
5887 sizeof(session_entry->rateSet));
5888 vos_mem_copy(&session_entry->extRateSet, &ch_change_req->extended_rateset,
5889 sizeof(session_entry->extRateSet));
5890 limSetChannel(mac_ctx, ch_change_req->new_chan,
5891 session_entry->htSecondaryChannelOffset,
5892 max_tx_pwr, session_entry->peSessionId);
Abhishek Singh02605092017-10-25 14:06:12 +05305893}
Abhishek Singh7d624e12015-11-30 14:29:27 +05305894
5895/**
Jeff Johnson295189b2012-06-20 16:38:30 -07005896 * limProcessSmeReqMessages()
5897 *
5898 *FUNCTION:
5899 * This function is called by limProcessMessageQueue(). This
5900 * function processes SME request messages from HDD or upper layer
5901 * application.
5902 *
5903 *LOGIC:
5904 *
5905 *ASSUMPTIONS:
5906 *
5907 *NOTE:
5908 *
5909 * @param pMac Pointer to Global MAC structure
5910 * @param msgType Indicates the SME message type
5911 * @param *pMsgBuf A pointer to the SME message buffer
5912 * @return Boolean - TRUE - if pMsgBuf is consumed and can be freed.
5913 * FALSE - if pMsgBuf is not to be freed.
5914 */
5915
5916tANI_BOOLEAN
5917limProcessSmeReqMessages(tpAniSirGlobal pMac, tpSirMsgQ pMsg)
5918{
5919 tANI_BOOLEAN bufConsumed = TRUE; //Set this flag to false within case block of any following message, that doesnt want pMsgBuf to be freed.
5920 tANI_U32 *pMsgBuf = pMsg->bodyptr;
Sudhir Sattayappa Kohalliabf751c2013-06-30 15:37:18 -07005921 tpSirSmeScanReq pScanReq;
Ganesh Kondabattini16930072014-08-22 16:02:34 +05305922 tANI_BOOLEAN isPassiveScan = FALSE;
5923
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005924 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 -07005925 limMsgStr(pMsg->type), pMsg->type,
5926 limSmeStateStr(pMac->lim.gLimSmeState), pMac->lim.gLimSmeState,
5927 limMlmStateStr(pMac->lim.gLimMlmState), pMac->lim.gLimMlmState );)
5928
Sudhir Sattayappa Kohalliabf751c2013-06-30 15:37:18 -07005929 pScanReq = (tpSirSmeScanReq) pMsgBuf;
Viral Modid440e682013-03-06 02:25:31 -08005930 /* Special handling of some SME Req msgs where we have an existing GO session and
5931 * want to insert NOA before processing those msgs. These msgs will be processed later when
5932 * start event happens
5933 */
5934 switch (pMsg->type)
5935 {
5936 case eWNI_SME_SCAN_REQ:
Ganesh Kondabattini16930072014-08-22 16:02:34 +05305937 pScanReq = (tpSirSmeScanReq) pMsgBuf;
5938 isPassiveScan = (pScanReq->scanType == eSIR_PASSIVE_SCAN) ? TRUE : FALSE;
Viral Modid440e682013-03-06 02:25:31 -08005939 case eWNI_SME_REMAIN_ON_CHANNEL_REQ:
Sudhir Sattayappa Kohalliabf751c2013-06-30 15:37:18 -07005940
5941 /* If scan is disabled return from here
5942 */
5943 if (pMac->lim.fScanDisabled)
5944 {
Sudhir Sattayappa Kohalliabf751c2013-06-30 15:37:18 -07005945 if (pMsg->type == eWNI_SME_SCAN_REQ)
5946 {
5947 limSendSmeScanRsp(pMac,
5948 offsetof(tSirSmeScanRsp,bssDescription[0]),
5949 eSIR_SME_INVALID_PARAMETERS,
5950 pScanReq->sessionId,
5951 pScanReq->transactionId);
5952
5953 bufConsumed = TRUE;
5954 }
5955 else if (pMsg->type == eWNI_SME_REMAIN_ON_CHANNEL_REQ)
5956 {
5957 pMac->lim.gpDefdSmeMsgForNOA = NULL;
5958 pMac->lim.gpLimRemainOnChanReq = (tpSirRemainOnChnReq )pMsgBuf;
5959 limRemainOnChnRsp(pMac,eHAL_STATUS_FAILURE, NULL);
5960
5961 /*
5962 * limRemainOnChnRsp will free the buffer this change is to
5963 * avoid "double free"
5964 */
5965 bufConsumed = FALSE;
5966 }
5967
Rashmi Ramanna6c13a342014-01-07 11:44:07 +05305968 limLog(pMac, LOGE,
5969 FL("Error: Scan Disabled."
5970 " Return with error status for SME Message %s(%d)"),
5971 limMsgStr(pMsg->type), pMsg->type);
5972
Sudhir Sattayappa Kohalliabf751c2013-06-30 15:37:18 -07005973 return bufConsumed;
5974 }
5975 /*
5976 * Do not add BREAK here
5977 */
5978 case eWNI_SME_OEM_DATA_REQ:
Viral Modid440e682013-03-06 02:25:31 -08005979 case eWNI_SME_JOIN_REQ:
5980 /* If we have an existing P2P GO session we need to insert NOA before actually process this SME Req */
5981 if ((limIsNOAInsertReqd(pMac) == TRUE) && IS_FEATURE_SUPPORTED_BY_FW(P2P_GO_NOA_DECOUPLE_INIT_SCAN))
5982 {
5983 tANI_U32 noaDuration;
5984 __limRegisterDeferredSmeReqForNOAStart(pMac, pMsg->type, pMsgBuf);
Ganesh Kondabattini16930072014-08-22 16:02:34 +05305985 noaDuration = limCalculateNOADuration(pMac, pMsg->type, pMsgBuf, isPassiveScan);
Viral Modid440e682013-03-06 02:25:31 -08005986 bufConsumed = __limInsertSingleShotNOAForScan(pMac, noaDuration);
5987 return bufConsumed;
5988 }
5989 }
5990 /* If no insert NOA required then execute the code below */
5991
Jeff Johnson295189b2012-06-20 16:38:30 -07005992 switch (pMsg->type)
5993 {
5994 case eWNI_SME_START_REQ:
5995 __limProcessSmeStartReq(pMac, pMsgBuf);
5996 break;
5997
5998 case eWNI_SME_SYS_READY_IND:
5999 bufConsumed = __limProcessSmeSysReadyInd(pMac, pMsgBuf);
6000 break;
6001
Jeff Johnson295189b2012-06-20 16:38:30 -07006002 case eWNI_SME_START_BSS_REQ:
6003 bufConsumed = __limProcessSmeStartBssReq(pMac, pMsg);
6004 break;
6005
6006 case eWNI_SME_SCAN_REQ:
Viral Modid440e682013-03-06 02:25:31 -08006007 __limProcessSmeScanReq(pMac, pMsgBuf);
Jeff Johnson295189b2012-06-20 16:38:30 -07006008 break;
6009
Jeff Johnsone7245742012-09-05 17:12:55 -07006010#ifdef FEATURE_OEM_DATA_SUPPORT
6011 case eWNI_SME_OEM_DATA_REQ:
6012 __limProcessSmeOemDataReq(pMac, pMsgBuf);
Jeff Johnsone7245742012-09-05 17:12:55 -07006013 break;
6014#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006015 case eWNI_SME_REMAIN_ON_CHANNEL_REQ:
6016 bufConsumed = limProcessRemainOnChnlReq(pMac, pMsgBuf);
6017 break;
6018
6019 case eWNI_SME_UPDATE_NOA:
6020 __limProcessSmeNoAUpdate(pMac, pMsgBuf);
6021 break;
Gopichand Nakkalac178ac82013-05-30 19:53:39 +05306022 case eWNI_SME_CLEAR_DFS_CHANNEL_LIST:
6023 __limProcessClearDfsChannelList(pMac, pMsg);
6024 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006025 case eWNI_SME_JOIN_REQ:
6026 __limProcessSmeJoinReq(pMac, pMsgBuf);
Jeff Johnson295189b2012-06-20 16:38:30 -07006027 break;
6028
6029 case eWNI_SME_AUTH_REQ:
6030 // __limProcessSmeAuthReq(pMac, pMsgBuf);
6031
6032 break;
6033
6034 case eWNI_SME_REASSOC_REQ:
6035 __limProcessSmeReassocReq(pMac, pMsgBuf);
6036
6037 break;
6038
6039 case eWNI_SME_PROMISCUOUS_MODE_REQ:
6040 //__limProcessSmePromiscuousReq(pMac, pMsgBuf);
6041
6042 break;
6043
6044 case eWNI_SME_DISASSOC_REQ:
6045 __limProcessSmeDisassocReq(pMac, pMsgBuf);
6046
6047 break;
6048
6049 case eWNI_SME_DISASSOC_CNF:
6050 case eWNI_SME_DEAUTH_CNF:
6051 __limProcessSmeDisassocCnf(pMac, pMsgBuf);
6052
6053 break;
6054
6055 case eWNI_SME_DEAUTH_REQ:
6056 __limProcessSmeDeauthReq(pMac, pMsgBuf);
6057
6058 break;
6059
Jeff Johnson295189b2012-06-20 16:38:30 -07006060
6061
6062 case eWNI_SME_SETCONTEXT_REQ:
6063 __limProcessSmeSetContextReq(pMac, pMsgBuf);
6064
6065 break;
6066
6067 case eWNI_SME_REMOVEKEY_REQ:
6068 __limProcessSmeRemoveKeyReq(pMac, pMsgBuf);
6069
6070 break;
6071
6072 case eWNI_SME_STOP_BSS_REQ:
6073 bufConsumed = __limProcessSmeStopBssReq(pMac, pMsg);
6074 break;
6075
6076 case eWNI_SME_ASSOC_CNF:
6077 case eWNI_SME_REASSOC_CNF:
6078 if (pMsg->type == eWNI_SME_ASSOC_CNF)
Abhishek Singh3cbf6052014-12-15 16:46:42 +05306079 limLog(pMac, LOG1, FL("Received ASSOC_CNF message"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006080 else
Abhishek Singh3cbf6052014-12-15 16:46:42 +05306081 limLog(pMac, LOG1, FL("Received REASSOC_CNF message"));
Agrawal Ashisha8e8a722016-10-18 19:07:45 +05306082#ifdef SAP_AUTH_OFFLOAD
6083 if (pMac->sap_auth_offload)
6084 __lim_process_sme_assoc_offload_cnf(pMac, pMsg->type, pMsgBuf);
6085 else
6086 __limProcessSmeAssocCnfNew(pMac, pMsg->type, pMsgBuf);
6087#else
Jeff Johnson295189b2012-06-20 16:38:30 -07006088 __limProcessSmeAssocCnfNew(pMac, pMsg->type, pMsgBuf);
Agrawal Ashisha8e8a722016-10-18 19:07:45 +05306089#endif /* SAP_AUTH_OFFLOAD */
Jeff Johnson295189b2012-06-20 16:38:30 -07006090 break;
6091
6092 case eWNI_SME_ADDTS_REQ:
Abhishek Singh3cbf6052014-12-15 16:46:42 +05306093 limLog(pMac, LOG1, FL("Received ADDTS_REQ message"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006094 __limProcessSmeAddtsReq(pMac, pMsgBuf);
6095 break;
6096
6097 case eWNI_SME_DELTS_REQ:
Abhishek Singh3cbf6052014-12-15 16:46:42 +05306098 limLog(pMac, LOG1, FL("Received DELTS_REQ message"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006099 __limProcessSmeDeltsReq(pMac, pMsgBuf);
6100 break;
6101
6102 case SIR_LIM_ADDTS_RSP_TIMEOUT:
Abhishek Singh3cbf6052014-12-15 16:46:42 +05306103 limLog(pMac, LOG1, FL("Received SIR_LIM_ADDTS_RSP_TIMEOUT message "));
Jeff Johnson295189b2012-06-20 16:38:30 -07006104 limProcessSmeAddtsRspTimeout(pMac, pMsg->bodyval);
6105 break;
6106
6107 case eWNI_SME_STA_STAT_REQ:
6108 case eWNI_SME_AGGR_STAT_REQ:
6109 case eWNI_SME_GLOBAL_STAT_REQ:
6110 case eWNI_SME_STAT_SUMM_REQ:
6111 __limProcessSmeStatsRequest( pMac, pMsgBuf);
6112 //HAL consumes pMsgBuf. It will be freed there. Set bufConsumed to false.
6113 bufConsumed = FALSE;
6114 break;
6115 case eWNI_SME_GET_STATISTICS_REQ:
6116 __limProcessSmeGetStatisticsRequest( pMac, pMsgBuf);
6117 //HAL consumes pMsgBuf. It will be freed there. Set bufConsumed to false.
6118 bufConsumed = FALSE;
6119 break;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08006120#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08006121 case eWNI_SME_GET_ROAM_RSSI_REQ:
6122 __limProcessSmeGetRoamRssiRequest( pMac, pMsgBuf);
6123 //HAL consumes pMsgBuf. It will be freed there. Set bufConsumed to false.
6124 bufConsumed = FALSE;
6125 break;
6126#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08006127#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07006128 case eWNI_SME_GET_TSM_STATS_REQ:
6129 __limProcessSmeGetTsmStatsRequest( pMac, pMsgBuf);
6130 bufConsumed = FALSE;
6131 break;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08006132#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Jeff Johnson295189b2012-06-20 16:38:30 -07006133 case eWNI_SME_DEL_BA_PEER_IND:
6134 limProcessSmeDelBaPeerInd(pMac, pMsgBuf);
6135 break;
6136 case eWNI_SME_GET_SCANNED_CHANNEL_REQ:
6137 limProcessSmeGetScanChannelInfo(pMac, pMsgBuf);
6138 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006139 case eWNI_SME_GET_ASSOC_STAS_REQ:
6140 limProcessSmeGetAssocSTAsInfo(pMac, pMsgBuf);
6141 break;
6142 case eWNI_SME_TKIP_CNTR_MEAS_REQ:
6143 limProcessTkipCounterMeasures(pMac, pMsgBuf);
6144 break;
6145
6146 case eWNI_SME_HIDE_SSID_REQ:
6147 __limProcessSmeHideSSID(pMac, pMsgBuf);
6148 break;
6149 case eWNI_SME_UPDATE_APWPSIE_REQ:
6150 __limProcessSmeUpdateAPWPSIEs(pMac, pMsgBuf);
6151 break;
6152 case eWNI_SME_GET_WPSPBC_SESSION_REQ:
6153 limProcessSmeGetWPSPBCSessions(pMac, pMsgBuf);
6154 break;
6155
6156 case eWNI_SME_SET_APWPARSNIEs_REQ:
6157 __limProcessSmeSetWPARSNIEs(pMac, pMsgBuf);
6158 break;
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08006159
6160 case eWNI_SME_CHNG_MCC_BEACON_INTERVAL:
6161 //Update the beaconInterval
6162 __limProcessSmeChangeBI(pMac, pMsgBuf );
6163 break;
Hardik Kantilal Patel62a3a762014-11-21 12:55:57 +05306164
6165#ifdef WLAN_FEATURE_AP_HT40_24G
6166 case eWNI_SME_SET_HT_2040_MODE:
6167 __limProcessSmeSetHT2040Mode(pMac, pMsgBuf);
6168 break;
6169#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006170
6171#if defined WLAN_FEATURE_VOWIFI
6172 case eWNI_SME_NEIGHBOR_REPORT_REQ_IND:
6173 case eWNI_SME_BEACON_REPORT_RESP_XMIT_IND:
6174 __limProcessReportMessage(pMac, pMsg);
6175 break;
6176#endif
6177
6178#if defined WLAN_FEATURE_VOWIFI_11R
6179 case eWNI_SME_FT_PRE_AUTH_REQ:
6180 bufConsumed = (tANI_BOOLEAN)limProcessFTPreAuthReq(pMac, pMsg);
6181 break;
6182 case eWNI_SME_FT_UPDATE_KEY:
6183 limProcessFTUpdateKey(pMac, pMsgBuf);
6184 break;
6185
6186 case eWNI_SME_FT_AGGR_QOS_REQ:
6187 limProcessFTAggrQosReq(pMac, pMsgBuf);
6188 break;
6189#endif
6190
Padma, Santhosh Kumar67f479b2016-12-28 15:43:42 +05306191#ifdef WLAN_FEATURE_LFR_MBB
6192 case eWNI_SME_MBB_PRE_AUTH_REASSOC_REQ:
6193 lim_process_pre_auth_reassoc_req(pMac, pMsg);
6194 bufConsumed = FALSE;
6195 break;
6196#endif
6197
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08006198#if defined(FEATURE_WLAN_ESE) && !defined(FEATURE_WLAN_ESE_UPLOAD)
6199 case eWNI_SME_ESE_ADJACENT_AP_REPORT:
Jeff Johnson295189b2012-06-20 16:38:30 -07006200 limProcessAdjacentAPRepMsg ( pMac, pMsgBuf );
6201 break;
6202#endif
6203 case eWNI_SME_ADD_STA_SELF_REQ:
6204 __limProcessSmeAddStaSelfReq( pMac, pMsgBuf );
6205 break;
6206 case eWNI_SME_DEL_STA_SELF_REQ:
6207 __limProcessSmeDelStaSelfReq( pMac, pMsgBuf );
6208 break;
6209
Jeff Johnson295189b2012-06-20 16:38:30 -07006210 case eWNI_SME_REGISTER_MGMT_FRAME_REQ:
6211 __limProcessSmeRegisterMgmtFrameReq( pMac, pMsgBuf );
6212 break;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08006213#ifdef FEATURE_WLAN_TDLS
6214 case eWNI_SME_TDLS_SEND_MGMT_REQ:
6215 limProcessSmeTdlsMgmtSendReq(pMac, pMsgBuf);
6216 break;
6217 case eWNI_SME_TDLS_ADD_STA_REQ:
6218 limProcessSmeTdlsAddStaReq(pMac, pMsgBuf);
6219 break;
6220 case eWNI_SME_TDLS_DEL_STA_REQ:
6221 limProcessSmeTdlsDelStaReq(pMac, pMsgBuf);
6222 break;
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05306223 case eWNI_SME_TDLS_LINK_ESTABLISH_REQ:
6224 limProcesSmeTdlsLinkEstablishReq(pMac, pMsgBuf);
6225 break;
Atul Mittalc0f739f2014-07-31 13:47:47 +05306226// tdlsoffchan
6227 case eWNI_SME_TDLS_CHANNEL_SWITCH_REQ:
6228 limProcesSmeTdlsChanSwitchReq(pMac, pMsgBuf);
6229 break;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08006230#endif
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05306231 case eWNI_SME_RESET_AP_CAPS_CHANGED:
6232 __limProcessSmeResetApCapsChange(pMac, pMsgBuf);
6233 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006234
schang86c22c42013-03-13 18:41:24 -07006235 case eWNI_SME_SET_TX_POWER_REQ:
6236 limSendSetTxPowerReq(pMac, pMsgBuf);
6237 break ;
6238
Abhishek Singh00b71972016-01-07 10:51:04 +05306239#ifdef WLAN_FEATURE_RMC
6240 case eWNI_SME_ENABLE_RMC_REQ:
6241 limProcessRMCMessages(pMac, eLIM_RMC_ENABLE_REQ, pMsgBuf);
6242 break ;
6243
6244 case eWNI_SME_DISABLE_RMC_REQ:
6245 limProcessRMCMessages(pMac, eLIM_RMC_DISABLE_REQ, pMsgBuf);
6246 break ;
6247#endif /* WLAN_FEATURE_RMC */
6248
Siddharth Bhal6af5d4e2014-09-29 21:11:16 +05306249 case eWNI_SME_MAC_SPOOF_ADDR_IND:
6250 __limProcessSmeSpoofMacAddrRequest(pMac, pMsgBuf);
6251 break ;
Abhishek Singh7d624e12015-11-30 14:29:27 +05306252 case eWNI_SME_REGISTER_MGMT_FRAME_CB:
6253 lim_register_mgmt_frame_ind_cb(pMac, pMsgBuf);
6254 break;
Abhishek Singh02605092017-10-25 14:06:12 +05306255 case eWNI_SME_SET_CHAN_SW_IE_REQ:
6256 lim_process_sme_set_csa_ie_request(pMac, pMsgBuf);
Abhishek Singh550aa8c2017-10-30 17:34:53 +05306257 break;
6258 case eWNI_SME_ECSA_CHAN_CHANGE_REQ:
6259 lim_process_sme_channel_change_request(pMac, pMsgBuf);
6260 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006261 default:
6262 vos_mem_free((v_VOID_t*)pMsg->bodyptr);
6263 pMsg->bodyptr = NULL;
6264 break;
6265 } // switch (msgType)
6266
6267 return bufConsumed;
6268} /*** end limProcessSmeReqMessages() ***/