blob: f1378bffbfd5511a07203024d9b605d8129867ac [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Abhishek Singheef5c992016-01-27 13:41:54 +05302 * Copyright (c) 2012-2016 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
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080079#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -070080/* These are the min/max tx power (non virtual rates) range
81 supported by prima hardware */
Sandeep Puligilla33ccf332013-12-19 16:06:42 +053082#define MIN_TX_PWR_CAP 8
83#define MAX_TX_PWR_CAP 22
Jeff Johnson295189b2012-06-20 16:38:30 -070084
85#endif
86
Sushant Kaushike3ca61c2015-03-19 18:33:25 +053087#define JOIN_FAILURE_TIMEOUT 1000 // in msecs
Viral Modid86bde22012-12-10 13:09:21 -080088/* This overhead is time for sending NOA start to host in case of GO/sending NULL data & receiving ACK
89 * 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 -080090 * taking care of sending null data and receiving ACK to/from AP/Also SetChannel with calibration is taking
91 * around 7ms .
Viral Modid86bde22012-12-10 13:09:21 -080092 */
Viral Modid440e682013-03-06 02:25:31 -080093#define SCAN_MESSAGING_OVERHEAD 20 // in msecs
94#define JOIN_NOA_DURATION 2000 // in msecs
95#define OEM_DATA_NOA_DURATION 60 // in msecs
96#define DEFAULT_PASSIVE_MAX_CHANNEL_TIME 110 // in msecs
Jeff Johnson295189b2012-06-20 16:38:30 -070097
Gopichand Nakkala096a1052012-12-21 07:05:34 -080098#define CONV_MS_TO_US 1024 //conversion factor from ms to us
99
Jeff Johnson295189b2012-06-20 16:38:30 -0700100// SME REQ processing function templates
101static void __limProcessSmeStartReq(tpAniSirGlobal, tANI_U32 *);
102static tANI_BOOLEAN __limProcessSmeSysReadyInd(tpAniSirGlobal, tANI_U32 *);
103static tANI_BOOLEAN __limProcessSmeStartBssReq(tpAniSirGlobal, tpSirMsgQ pMsg);
Viral Modid440e682013-03-06 02:25:31 -0800104static void __limProcessSmeScanReq(tpAniSirGlobal, tANI_U32 *);
Jeff Johnson295189b2012-06-20 16:38:30 -0700105static void __limProcessSmeJoinReq(tpAniSirGlobal, tANI_U32 *);
106static void __limProcessSmeReassocReq(tpAniSirGlobal, tANI_U32 *);
107static void __limProcessSmeDisassocReq(tpAniSirGlobal, tANI_U32 *);
108static void __limProcessSmeDisassocCnf(tpAniSirGlobal, tANI_U32 *);
109static void __limProcessSmeDeauthReq(tpAniSirGlobal, tANI_U32 *);
110static void __limProcessSmeSetContextReq(tpAniSirGlobal, tANI_U32 *);
111static tANI_BOOLEAN __limProcessSmeStopBssReq(tpAniSirGlobal, tpSirMsgQ pMsg);
112
Jeff Johnson295189b2012-06-20 16:38:30 -0700113void __limProcessSmeAssocCnfNew(tpAniSirGlobal, tANI_U32, tANI_U32 *);
114
Jeff Johnson295189b2012-06-20 16:38:30 -0700115extern void peRegisterTLHandle(tpAniSirGlobal pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -0700116
Jeff Johnson295189b2012-06-20 16:38:30 -0700117
Jeff Johnson295189b2012-06-20 16:38:30 -0700118#ifdef BACKGROUND_SCAN_ENABLED
119
120// start the background scan timers if it hasn't already started
121static void
122__limBackgroundScanInitiate(tpAniSirGlobal pMac)
123{
124 if (pMac->lim.gLimBackgroundScanStarted)
125 return;
126
127 //make sure timer is created first
128 if (TX_TIMER_VALID(pMac->lim.limTimers.gLimBackgroundScanTimer))
129 {
130 limDeactivateAndChangeTimer(pMac, eLIM_BACKGROUND_SCAN_TIMER);
Jeff Johnsone7245742012-09-05 17:12:55 -0700131 MTRACE(macTrace(pMac, TRACE_CODE_TIMER_ACTIVATE, NO_SESSION, eLIM_BACKGROUND_SCAN_TIMER));
Jeff Johnson295189b2012-06-20 16:38:30 -0700132 if (tx_timer_activate(&pMac->lim.limTimers.gLimBackgroundScanTimer) != TX_SUCCESS)
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700133 limLog(pMac, LOGP, FL("could not activate background scan timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700134 pMac->lim.gLimBackgroundScanStarted = true;
135 pMac->lim.gLimBackgroundScanChannelId = 0;
136 }
137}
138
139#endif // BACKGROUND_SCAN_ENABLED
Jeff Johnson295189b2012-06-20 16:38:30 -0700140
141// determine if a fresh scan request must be issued or not
142/*
143* PE will do fresh scan, if all of the active sessions are in good state (Link Est or BSS Started)
144* If one of the sessions is not in one of the above states, then PE does not do fresh scan
145* If no session exists (scanning very first time), then PE will always do fresh scan if SME
146* asks it to do that.
147*/
148static tANI_U8
149__limFreshScanReqd(tpAniSirGlobal pMac, tANI_U8 returnFreshResults)
150{
151
152 tANI_U8 validState = TRUE;
153 int i;
154
155 if(pMac->lim.gLimSmeState != eLIM_SME_IDLE_STATE)
156 {
Sushant Kaushik59e6f362015-08-11 15:41:00 +0530157 limLog(pMac, LOG1, FL("setting fresh scan as false. sme state is %d"),
158 pMac->lim.gLimSmeState);
Jeff Johnson295189b2012-06-20 16:38:30 -0700159 return FALSE;
160 }
161 for(i =0; i < pMac->lim.maxBssId; i++)
162 {
163
164 if(pMac->lim.gpSession[i].valid == TRUE)
165 {
166 if(!( ( ( (pMac->lim.gpSession[i].bssType == eSIR_INFRASTRUCTURE_MODE) ||
167 (pMac->lim.gpSession[i].limSystemRole == eLIM_BT_AMP_STA_ROLE))&&
168 (pMac->lim.gpSession[i].limSmeState == eLIM_SME_LINK_EST_STATE) )||
169
170 ( ( (pMac->lim.gpSession[i].bssType == eSIR_IBSS_MODE)||
171 (pMac->lim.gpSession[i].limSystemRole == eLIM_BT_AMP_AP_ROLE)||
172 (pMac->lim.gpSession[i].limSystemRole == eLIM_BT_AMP_STA_ROLE) )&&
173 (pMac->lim.gpSession[i].limSmeState == eLIM_SME_NORMAL_STATE) )
Jeff Johnson295189b2012-06-20 16:38:30 -0700174 || ( ( ( (pMac->lim.gpSession[i].bssType == eSIR_INFRA_AP_MODE)
175 && ( pMac->lim.gpSession[i].pePersona == VOS_P2P_GO_MODE) )
176 || (pMac->lim.gpSession[i].limSystemRole == eLIM_AP_ROLE) )
177 && (pMac->lim.gpSession[i].limSmeState == eLIM_SME_NORMAL_STATE) )
Jeff Johnson295189b2012-06-20 16:38:30 -0700178 ))
179 {
180 validState = FALSE;
Sushant Kaushik59e6f362015-08-11 15:41:00 +0530181 limLog(pMac, LOG1, FL("setting fresh scan as false."
182 "bssType is %d system role is %d, smestate is %d"),
183 pMac->lim.gpSession[i].bssType,
184 pMac->lim.gpSession[i].limSystemRole,
185 pMac->lim.gpSession[i].limSmeState);
Jeff Johnson295189b2012-06-20 16:38:30 -0700186 break;
187 }
188
189 }
190 }
Rashmi Ramanna6c13a342014-01-07 11:44:07 +0530191 limLog(pMac, LOG1, FL("FreshScanReqd: %d "), validState);
Jeff Johnson295189b2012-06-20 16:38:30 -0700192
193 if( (validState) && (returnFreshResults & SIR_BG_SCAN_RETURN_FRESH_RESULTS))
194 return TRUE;
195
196 return FALSE;
197}
198
Jeff Johnson295189b2012-06-20 16:38:30 -0700199
200
201/**
202 * __limIsSmeAssocCnfValid()
203 *
204 *FUNCTION:
205 * This function is called by limProcessLmmMessages() upon
206 * receiving SME_ASSOC_CNF.
207 *
208 *LOGIC:
209 * Message validity checks are performed in this function
210 *
211 *ASSUMPTIONS:
212 *
213 *NOTE:
214 *
215 * @param pMeasReq Pointer to Received ASSOC_CNF message
216 * @return true When received SME_ASSOC_CNF is formatted
217 * correctly
218 * false otherwise
219 */
220
221inline static tANI_U8
222__limIsSmeAssocCnfValid(tpSirSmeAssocCnf pAssocCnf)
223{
224 if (limIsGroupAddr(pAssocCnf->peerMacAddr))
225 return false;
226 else
227 return true;
228} /*** end __limIsSmeAssocCnfValid() ***/
229
230
231/**
232 * __limGetSmeJoinReqSizeForAlloc()
233 *
234 *FUNCTION:
235 * This function is called in various places to get IE length
236 * from tSirBssDescription structure
237 * number being scanned.
238 *
239 *PARAMS:
240 *
241 *LOGIC:
242 *
243 *ASSUMPTIONS:
244 * NA
245 *
246 *NOTE:
247 * NA
248 *
249 * @param pBssDescr
250 * @return Total IE length
251 */
252
253static tANI_U16
254__limGetSmeJoinReqSizeForAlloc(tANI_U8 *pBuf)
255{
256 tANI_U16 len = 0;
257
258 if (!pBuf)
259 return len;
260
261 pBuf += sizeof(tANI_U16);
262 len = limGetU16( pBuf );
263 return (len + sizeof( tANI_U16 ));
264} /*** end __limGetSmeJoinReqSizeForAlloc() ***/
265
266
267/**----------------------------------------------------------------
268\fn __limIsDeferedMsgForLearn
269
270\brief Has role only if 11h is enabled. Not used on STA side.
271 Defers the message if SME is in learn state and brings
272 the LIM back to normal mode.
273
274\param pMac
275\param pMsg - Pointer to message posted from SME to LIM.
276\return TRUE - If defered
277 FALSE - Otherwise
278------------------------------------------------------------------*/
279static tANI_BOOLEAN
280__limIsDeferedMsgForLearn(tpAniSirGlobal pMac, tpSirMsgQ pMsg)
281{
282 if (limIsSystemInScanState(pMac))
283 {
284 if (limDeferMsg(pMac, pMsg) != TX_SUCCESS)
285 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700286 PELOGE(limLog(pMac, LOGE, FL("Could not defer Msg = %d"), pMsg->type);)
Jeff Johnson295189b2012-06-20 16:38:30 -0700287 return eANI_BOOLEAN_FALSE;
288 }
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700289 PELOG1(limLog(pMac, LOG1, FL("Defer the message, in learn mode type = %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -0700290 pMsg->type);)
291
292 /** Send finish scan req to HAL only if LIM is not waiting for any response
293 * from HAL like init scan rsp, start scan rsp etc.
294 */
295 if (GET_LIM_PROCESS_DEFD_MESGS(pMac))
296 {
297 //Set the resume channel to Any valid channel (invalid).
298 //This will instruct HAL to set it to any previous valid channel.
299 peSetResumeChannel(pMac, 0, 0);
300 limSendHalFinishScanReq(pMac, eLIM_HAL_FINISH_LEARN_WAIT_STATE);
301 }
302
303 return eANI_BOOLEAN_TRUE;
304 }
305 return eANI_BOOLEAN_FALSE;
306}
307
308/**----------------------------------------------------------------
309\fn __limIsDeferedMsgForRadar
310
311\brief Has role only if 11h is enabled. Not used on STA side.
312 Defers the message if radar is detected.
313
314\param pMac
315\param pMsg - Pointer to message posted from SME to LIM.
316\return TRUE - If defered
317 FALSE - Otherwise
318------------------------------------------------------------------*/
319static tANI_BOOLEAN
320__limIsDeferedMsgForRadar(tpAniSirGlobal pMac, tpSirMsgQ pMsg)
321{
322 /** fRadarDetCurOperChan will be set only if we detect radar in current
323 * operating channel and System Role == AP ROLE */
Jeff Johnsone7245742012-09-05 17:12:55 -0700324 //TODO: Need to take care radar detection.
325 //if (LIM_IS_RADAR_DETECTED(pMac))
326 if( 0 )
Jeff Johnson295189b2012-06-20 16:38:30 -0700327 {
328 if (limDeferMsg(pMac, pMsg) != TX_SUCCESS)
329 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700330 PELOGE(limLog(pMac, LOGE, FL("Could not defer Msg = %d"), pMsg->type);)
Jeff Johnson295189b2012-06-20 16:38:30 -0700331 return eANI_BOOLEAN_FALSE;
332 }
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700333 PELOG1(limLog(pMac, LOG1, FL("Defer the message, in learn mode type = %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -0700334 pMsg->type);)
335 return eANI_BOOLEAN_TRUE;
336 }
337 return eANI_BOOLEAN_FALSE;
338}
339
340
341/**
342 * __limProcessSmeStartReq()
343 *
344 *FUNCTION:
345 * This function is called to process SME_START_REQ message
346 * from HDD or upper layer application.
347 *
348 *LOGIC:
349 *
350 *ASSUMPTIONS:
351 *
352 *NOTE:
353 *
354 * @param pMac Pointer to Global MAC structure
355 * @param *pMsgBuf A pointer to the SME message buffer
356 * @return None
357 */
358
359static void
360__limProcessSmeStartReq(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
361{
362 tSirResultCodes retCode = eSIR_SME_SUCCESS;
363 tANI_U8 smesessionId;
364 tANI_U16 smetransactionId;
365
366
Abhishek Singh3cbf6052014-12-15 16:46:42 +0530367 limLog(pMac, LOG1, FL("Received SME_START_REQ"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700368
369 limGetSessionInfo(pMac,(tANI_U8 *)pMsgBuf,&smesessionId,&smetransactionId);
370
371 if (pMac->lim.gLimSmeState == eLIM_SME_OFFLINE_STATE)
372 {
373 pMac->lim.gLimSmeState = eLIM_SME_IDLE_STATE;
374
Jeff Johnsone7245742012-09-05 17:12:55 -0700375 MTRACE(macTrace(pMac, TRACE_CODE_SME_STATE, NO_SESSION, pMac->lim.gLimSmeState));
Jeff Johnson295189b2012-06-20 16:38:30 -0700376
377 /// By default do not return after first scan match
378 pMac->lim.gLimReturnAfterFirstMatch = 0;
379
380 /// Initialize MLM state machine
381 limInitMlm(pMac);
382
383 /// By default return unique scan results
384 pMac->lim.gLimReturnUniqueResults = true;
385 pMac->lim.gLimSmeScanResultLength = 0;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -0700386#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
387 pMac->lim.gLimSmeLfrScanResultLength = 0;
388#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700389
Jeff Johnson295189b2012-06-20 16:38:30 -0700390 if (((tSirSmeStartReq *) pMsgBuf)->sendNewBssInd)
391 {
392 /*
393 * Need to indicate new BSSs found during background scanning to
394 * host. Update this parameter at CFG
395 */
396 if (cfgSetInt(pMac, WNI_CFG_NEW_BSS_FOUND_IND, ((tSirSmeStartReq *) pMsgBuf)->sendNewBssInd)
397 != eSIR_SUCCESS)
398 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700399 limLog(pMac, LOGP, FL("could not set NEIGHBOR_BSS_IND at CFG"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700400 retCode = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
401 }
402 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700403 }
404 else
405 {
406 /**
407 * Should not have received eWNI_SME_START_REQ in states
408 * other than OFFLINE. Return response to host and
409 * log error
410 */
Sushant Kaushik1b645382014-10-13 16:39:36 +0530411 limLog(pMac, LOGE, FL("Invalid SME_START_REQ received in SME state %d"),pMac->lim.gLimSmeState );
Jeff Johnson295189b2012-06-20 16:38:30 -0700412 limPrintSmeState(pMac, LOGE, pMac->lim.gLimSmeState);
413 retCode = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
414 }
415 limSendSmeRsp(pMac, eWNI_SME_START_RSP, retCode,smesessionId,smetransactionId);
416} /*** end __limProcessSmeStartReq() ***/
417
418
419/** -------------------------------------------------------------
420\fn __limProcessSmeSysReadyInd
421\brief handles the notification from HDD. PE just forwards this message to HAL.
422\param tpAniSirGlobal pMac
423\param tANI_U32* pMsgBuf
424\return TRUE-Posting to HAL failed, so PE will consume the buffer.
425\ FALSE-Posting to HAL successful, so HAL will consume the buffer.
426 -------------------------------------------------------------*/
427static tANI_BOOLEAN
428__limProcessSmeSysReadyInd(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
429{
430 tSirMsgQ msg;
431
432 msg.type = WDA_SYS_READY_IND;
433 msg.reserved = 0;
434 msg.bodyptr = pMsgBuf;
435 msg.bodyval = 0;
436
Jeff Johnson92751692013-03-06 16:00:33 -0800437 if (pMac->gDriverType != eDRIVER_TYPE_MFG)
Jeff Johnson295189b2012-06-20 16:38:30 -0700438 {
Jeff Johnson92751692013-03-06 16:00:33 -0800439 peRegisterTLHandle(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -0700440 }
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700441 PELOGW(limLog(pMac, LOGW, FL("sending WDA_SYS_READY_IND msg to HAL"));)
Jeff Johnsone7245742012-09-05 17:12:55 -0700442 MTRACE(macTraceMsgTx(pMac, NO_SESSION, msg.type));
Jeff Johnson295189b2012-06-20 16:38:30 -0700443
Jeff Johnson92751692013-03-06 16:00:33 -0800444 if (eSIR_SUCCESS != wdaPostCtrlMsg(pMac, &msg))
Jeff Johnson295189b2012-06-20 16:38:30 -0700445 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700446 limLog(pMac, LOGP, FL("wdaPostCtrlMsg failed"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700447 return eANI_BOOLEAN_TRUE;
448 }
449 return eANI_BOOLEAN_FALSE;
450}
451
Jeff Johnsone7245742012-09-05 17:12:55 -0700452#ifdef WLAN_FEATURE_11AC
Jeff Johnson295189b2012-06-20 16:38:30 -0700453
Jeff Johnsone7245742012-09-05 17:12:55 -0700454tANI_U32 limGetCenterChannel(tpAniSirGlobal pMac,tANI_U8 primarychanNum,ePhyChanBondState secondaryChanOffset, tANI_U8 chanWidth)
455{
456 if (chanWidth == WNI_CFG_VHT_CHANNEL_WIDTH_80MHZ)
457 {
458 switch(secondaryChanOffset)
459 {
460 case PHY_QUADRUPLE_CHANNEL_20MHZ_CENTERED_40MHZ_CENTERED:
461 return primarychanNum;
462 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_CENTERED:
463 return primarychanNum + 2;
464 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_CENTERED:
465 return primarychanNum - 2;
466 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_LOW:
467 return primarychanNum + 6;
468 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_LOW:
469 return primarychanNum + 2;
470 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_HIGH:
471 return primarychanNum - 2;
472 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_HIGH:
473 return primarychanNum - 6;
474 default :
475 return eSIR_CFG_INVALID_ID;
476 }
477 }
478 else if (chanWidth == WNI_CFG_VHT_CHANNEL_WIDTH_20_40MHZ)
479 {
480 switch(secondaryChanOffset)
481 {
482 case PHY_DOUBLE_CHANNEL_LOW_PRIMARY:
483 return primarychanNum + 2;
484 case PHY_DOUBLE_CHANNEL_HIGH_PRIMARY:
485 return primarychanNum - 2;
486 case PHY_QUADRUPLE_CHANNEL_20MHZ_CENTERED_40MHZ_CENTERED:
487 return primarychanNum;
488 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_CENTERED:
489 return primarychanNum + 2;
490 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_CENTERED:
491 return primarychanNum - 2;
492 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_LOW:
493 return primarychanNum + 2;
494 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_LOW:
495 return primarychanNum - 2;
496 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_HIGH:
497 return primarychanNum + 2;
498 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_HIGH:
499 return primarychanNum - 2;
500 default :
501 return eSIR_CFG_INVALID_ID;
502 }
503 }
504 return primarychanNum;
505}
506
507#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700508/**
509 * __limHandleSmeStartBssRequest()
510 *
511 *FUNCTION:
512 * This function is called to process SME_START_BSS_REQ message
513 * from HDD or upper layer application.
514 *
515 *LOGIC:
516 *
517 *ASSUMPTIONS:
518 *
519 *NOTE:
520 *
521 * @param pMac Pointer to Global MAC structure
522 * @param *pMsgBuf A pointer to the SME message buffer
523 * @return None
524 */
525
526static void
527__limHandleSmeStartBssRequest(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
528{
529 tANI_U16 size;
530 tANI_U32 val = 0;
531 tSirRetStatus retStatus;
532 tSirMacChanNum channelNumber;
Jeff Johnsonace91102013-04-05 08:03:18 -0700533 tLimMlmStartReq *pMlmStartReq = NULL;
534 tpSirSmeStartBssReq pSmeStartBssReq = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -0700535 tSirResultCodes retCode = eSIR_SME_SUCCESS;
536 tANI_U32 autoGenBssId = FALSE; //Flag Used in case of IBSS to Auto generate BSSID.
Jeff Johnson295189b2012-06-20 16:38:30 -0700537 tANI_U8 sessionId;
538 tpPESession psessionEntry = NULL;
539 tANI_U8 smesessionId;
540 tANI_U16 smetransactionId;
541
542#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM //FEATURE_WLAN_DIAG_SUPPORT
543 //Since the session is not created yet, sending NULL. The response should have the correct state.
544 limDiagEventReport(pMac, WLAN_PE_DIAG_START_BSS_REQ_EVENT, NULL, 0, 0);
545#endif //FEATURE_WLAN_DIAG_SUPPORT
546
Abhishek Singh3cbf6052014-12-15 16:46:42 +0530547 limLog(pMac, LOG1, FL("Received SME_START_BSS_REQ"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700548
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +0530549 /* Global Sme state and mlm states are not defined yet, for BT-AMP Suppoprt . TO BE DONE */
Jeff Johnson295189b2012-06-20 16:38:30 -0700550 if ( (pMac->lim.gLimSmeState == eLIM_SME_OFFLINE_STATE) ||
551 (pMac->lim.gLimSmeState == eLIM_SME_IDLE_STATE))
552 {
553 size = sizeof(tSirSmeStartBssReq) + SIR_MAC_MAX_IE_LENGTH;
554
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +0530555 pSmeStartBssReq = vos_mem_malloc(size);
556 if ( NULL == pSmeStartBssReq )
Jeff Johnson295189b2012-06-20 16:38:30 -0700557 {
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +0530558 PELOGE(limLog(pMac, LOGE, FL("AllocateMemory failed for pMac->lim.gpLimStartBssReq"));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700559 /// Send failure response to host
560 retCode = eSIR_SME_RESOURCES_UNAVAILABLE;
561 goto end;
562 }
563
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +0530564 vos_mem_set((void *)pSmeStartBssReq, size, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700565
566 if ((limStartBssReqSerDes(pMac, pSmeStartBssReq, (tANI_U8 *) pMsgBuf) == eSIR_FAILURE) ||
567 (!limIsSmeStartBssReqValid(pMac, pSmeStartBssReq)))
568 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700569 PELOGW(limLog(pMac, LOGW, FL("Received invalid eWNI_SME_START_BSS_REQ"));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700570 retCode = eSIR_SME_INVALID_PARAMETERS;
571 goto free;
572 }
573#if 0
574 PELOG3(limLog(pMac, LOG3,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700575 FL("Parsed START_BSS_REQ fields are bssType=%d, channelId=%d"),
Jeff Johnson295189b2012-06-20 16:38:30 -0700576 pMac->lim.gpLimStartBssReq->bssType, pMac->lim.gpLimStartBssReq->channelId);)
577#endif
578
579 /* This is the place where PE is going to create a session.
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +0530580 * If session is not existed, then create a new session */
Jeff Johnson295189b2012-06-20 16:38:30 -0700581 if((psessionEntry = peFindSessionByBssid(pMac,pSmeStartBssReq->bssId,&sessionId)) != NULL)
582 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700583 limLog(pMac, LOGW, FL("Session Already exists for given BSSID"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700584 retCode = eSIR_SME_BSS_ALREADY_STARTED_OR_JOINED;
585 psessionEntry = NULL;
586 goto free;
587 }
588 else
589 {
590 if((psessionEntry = peCreateSession(pMac,pSmeStartBssReq->bssId,&sessionId, pMac->lim.maxStation)) == NULL)
591 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700592 limLog(pMac, LOGW, FL("Session Can not be created "));
Jeff Johnson295189b2012-06-20 16:38:30 -0700593 retCode = eSIR_SME_RESOURCES_UNAVAILABLE;
594 goto free;
595 }
596
597 }
598
599 /* Store the session related parameters in newly created session */
600 psessionEntry->pLimStartBssReq = pSmeStartBssReq;
601
602 /* Store PE sessionId in session Table */
603 psessionEntry->peSessionId = sessionId;
604
605 /* Store SME session Id in sessionTable */
606 psessionEntry->smeSessionId = pSmeStartBssReq->sessionId;
607
608 psessionEntry->transactionId = pSmeStartBssReq->transactionId;
609
610 sirCopyMacAddr(psessionEntry->selfMacAddr,pSmeStartBssReq->selfMacAddr);
611
612 /* Copy SSID to session table */
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +0530613 vos_mem_copy( (tANI_U8 *)&psessionEntry->ssId,
Jeff Johnson295189b2012-06-20 16:38:30 -0700614 (tANI_U8 *)&pSmeStartBssReq->ssId,
615 (pSmeStartBssReq->ssId.length + 1));
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +0530616
Jeff Johnson295189b2012-06-20 16:38:30 -0700617 psessionEntry->bssType = pSmeStartBssReq->bssType;
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +0530618
Jeff Johnson295189b2012-06-20 16:38:30 -0700619 psessionEntry->nwType = pSmeStartBssReq->nwType;
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +0530620
Jeff Johnson295189b2012-06-20 16:38:30 -0700621 psessionEntry->beaconParams.beaconInterval = pSmeStartBssReq->beaconInterval;
622
623 /* Store the channel number in session Table */
624 psessionEntry->currentOperChannel = pSmeStartBssReq->channelId;
625
626 /*Store Persona */
627 psessionEntry->pePersona = pSmeStartBssReq->bssPersona;
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -0700628 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,FL("PE PERSONA=%d"),
Jeff Johnson295189b2012-06-20 16:38:30 -0700629 psessionEntry->pePersona);
630
631 /*Update the phymode*/
632 psessionEntry->gLimPhyMode = pSmeStartBssReq->nwType;
633
634 psessionEntry->maxTxPower = cfgGetRegulatoryMaxTransmitPower( pMac,
635 psessionEntry->currentOperChannel );
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +0530636
637#ifdef WLAN_FEATURE_AP_HT40_24G
638 /*Store Overlapping BSS Scan Parameters IEs to session table */
639 if (pSmeStartBssReq->apHT40_24GEnabled)
640 {
641 limInitOBSSScanParams(pMac, psessionEntry);
642 }
643#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700644 /* Store the dot 11 mode in to the session Table*/
645
646 psessionEntry->dot11mode = pSmeStartBssReq->dot11mode;
Jeff Johnsone7245742012-09-05 17:12:55 -0700647 psessionEntry->htCapability = IS_DOT11_MODE_HT(psessionEntry->dot11mode);
648#ifdef WLAN_FEATURE_11AC
649 psessionEntry->vhtCapability = IS_DOT11_MODE_VHT(psessionEntry->dot11mode);
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -0700650 VOS_TRACE(VOS_MODULE_ID_PE,VOS_TRACE_LEVEL_INFO,
651 FL("*****psessionEntry->vhtCapability = %d"),psessionEntry->vhtCapability);
Jeff Johnsone7245742012-09-05 17:12:55 -0700652#endif
Gopichand Nakkalab2d2c312013-01-04 11:41:02 -0800653
654 psessionEntry->txLdpcIniFeatureEnabled =
655 pSmeStartBssReq->txLdpcIniFeatureEnabled;
656
Chet Lanctot8cecea22014-02-11 19:09:36 -0800657#ifdef WLAN_FEATURE_11W
658 psessionEntry->limRmfEnabled = pSmeStartBssReq->pmfCapable ? 1 : 0;
659 limLog(pMac, LOG1, FL("Session RMF enabled: %d"), psessionEntry->limRmfEnabled);
660#endif
661
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +0530662 vos_mem_copy((void*)&psessionEntry->rateSet,
Jeff Johnson295189b2012-06-20 16:38:30 -0700663 (void*)&pSmeStartBssReq->operationalRateSet,
664 sizeof(tSirMacRateSet));
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +0530665 vos_mem_copy((void*)&psessionEntry->extRateSet,
Jeff Johnson295189b2012-06-20 16:38:30 -0700666 (void*)&pSmeStartBssReq->extendedRateSet,
667 sizeof(tSirMacRateSet));
668
669 switch(pSmeStartBssReq->bssType)
670 {
Jeff Johnson295189b2012-06-20 16:38:30 -0700671 case eSIR_INFRA_AP_MODE:
672 psessionEntry->limSystemRole = eLIM_AP_ROLE;
673 psessionEntry->privacy = pSmeStartBssReq->privacy;
674 psessionEntry->fwdWPSPBCProbeReq = pSmeStartBssReq->fwdWPSPBCProbeReq;
675 psessionEntry->authType = pSmeStartBssReq->authType;
676 /* Store the DTIM period */
677 psessionEntry->dtimPeriod = (tANI_U8)pSmeStartBssReq->dtimPeriod;
678 /*Enable/disable UAPSD*/
679 psessionEntry->apUapsdEnable = pSmeStartBssReq->apUapsdEnable;
680 if (psessionEntry->pePersona == VOS_P2P_GO_MODE)
681 {
682 psessionEntry->proxyProbeRspEn = 0;
683 }
684 else
685 {
686 /* To detect PBC overlap in SAP WPS mode, Host handles
687 * Probe Requests.
688 */
689 if(SAP_WPS_DISABLED == pSmeStartBssReq->wps_state)
690 {
691 psessionEntry->proxyProbeRspEn = 1;
692 }
693 else
694 {
695 psessionEntry->proxyProbeRspEn = 0;
696 }
697 }
698 psessionEntry->ssidHidden = pSmeStartBssReq->ssidHidden;
699 psessionEntry->wps_state = pSmeStartBssReq->wps_state;
krunal soni45b9eb62014-03-26 12:54:25 -0700700 limGetShortSlotFromPhyMode(pMac, psessionEntry,
701 psessionEntry->gLimPhyMode,
702 &psessionEntry->shortSlotTimeSupported);
Jeff Johnson295189b2012-06-20 16:38:30 -0700703 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700704 case eSIR_IBSS_MODE:
705 psessionEntry->limSystemRole = eLIM_STA_IN_IBSS_ROLE;
krunal soni45b9eb62014-03-26 12:54:25 -0700706 limGetShortSlotFromPhyMode(pMac, psessionEntry,
707 psessionEntry->gLimPhyMode,
708 &psessionEntry->shortSlotTimeSupported);
Abhishek Singhd5c31272014-03-07 14:46:50 +0530709 /* In WPA-NONE case we wont get the privacy bit in ibss config
710 * from supplicant, but we are updating WNI_CFG_PRIVACY_ENABLED
711 * on basis of Encryption type in csrRoamSetBssConfigCfg. So
712 * get the privacy info from WNI_CFG_PRIVACY_ENABLED
713 */
714 if (wlan_cfgGetInt(pMac, WNI_CFG_PRIVACY_ENABLED, &val)
715 != eSIR_SUCCESS)
716 limLog(pMac, LOGE, FL("cfg get WNI_CFG_PRIVACY_ENABLED"
717 " failed"));
718 psessionEntry->privacy =(tANI_U8) val;
krunal sonie9002db2013-11-25 14:24:17 -0800719 psessionEntry->isCoalesingInIBSSAllowed =
720 pSmeStartBssReq->isCoalesingInIBSSAllowed;
Jeff Johnson295189b2012-06-20 16:38:30 -0700721 break;
722
723 case eSIR_BTAMP_AP_MODE:
724 psessionEntry->limSystemRole = eLIM_BT_AMP_AP_ROLE;
725 break;
726
727 case eSIR_BTAMP_STA_MODE:
728 psessionEntry->limSystemRole = eLIM_BT_AMP_STA_ROLE;
729 break;
730
731 /* There is one more mode called auto mode. which is used no where */
732
733 //FORBUILD -TEMPFIX.. HOW TO use AUTO MODE?????
734
735
736 default:
737 //not used anywhere...used in scan function
738 break;
739 }
740
741 // BT-AMP: Allocate memory for the array of parsed (Re)Assoc request structure
742 if ( (pSmeStartBssReq->bssType == eSIR_BTAMP_AP_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -0700743 || (pSmeStartBssReq->bssType == eSIR_INFRA_AP_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -0700744 )
745 {
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +0530746 psessionEntry->parsedAssocReq = vos_mem_malloc(
747 psessionEntry->dph.dphHashTable.size * sizeof(tpSirAssocReq));
748 if ( NULL == psessionEntry->parsedAssocReq )
Jeff Johnson295189b2012-06-20 16:38:30 -0700749 {
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +0530750 limLog(pMac, LOGW, FL("AllocateMemory() failed"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700751 retCode = eSIR_SME_RESOURCES_UNAVAILABLE;
752 goto free;
753 }
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +0530754 vos_mem_set(psessionEntry->parsedAssocReq,
755 (psessionEntry->dph.dphHashTable.size * sizeof(tpSirAssocReq)),
756 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -0700757 }
758
759 /* Channel Bonding is not addressd yet for BT-AMP Support.. sunit will address channel bonding */
760 if (pSmeStartBssReq->channelId)
761 {
762 channelNumber = pSmeStartBssReq->channelId;
Jeff Johnsone7245742012-09-05 17:12:55 -0700763 psessionEntry->htSupportedChannelWidthSet = (pSmeStartBssReq->cbMode)?1:0; // This is already merged value of peer and self - done by csr in csrGetCBModeFromIes
764 psessionEntry->htRecommendedTxWidthSet = psessionEntry->htSupportedChannelWidthSet;
765 psessionEntry->htSecondaryChannelOffset = pSmeStartBssReq->cbMode;
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -0700766 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
Jeff Johnsone7245742012-09-05 17:12:55 -0700767 FL("cbMode %u"), pSmeStartBssReq->cbMode);
768#ifdef WLAN_FEATURE_11AC
769 if(psessionEntry->vhtCapability)
770 {
771 tANI_U32 centerChan;
772 tANI_U32 chanWidth;
Jeff Johnson295189b2012-06-20 16:38:30 -0700773
Jeff Johnsone7245742012-09-05 17:12:55 -0700774 if (wlan_cfgGetInt(pMac, WNI_CFG_VHT_CHANNEL_WIDTH,
775 &chanWidth) != eSIR_SUCCESS)
Jeff Johnson295189b2012-06-20 16:38:30 -0700776 {
Jeff Johnsone7245742012-09-05 17:12:55 -0700777 limLog(pMac, LOGP,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700778 FL("Unable to retrieve Channel Width from CFG"));
Jeff Johnsone7245742012-09-05 17:12:55 -0700779 }
Abhishek Singhb92f70c2014-04-28 12:13:08 +0530780
Abhishek Singh921926b2014-02-13 17:21:01 +0530781 if(channelNumber <= RF_CHAN_14 &&
Abhishek Singhb92f70c2014-04-28 12:13:08 +0530782 chanWidth != eHT_CHANNEL_WIDTH_20MHZ)
Jeff Johnsone7245742012-09-05 17:12:55 -0700783 {
Abhishek Singhb92f70c2014-04-28 12:13:08 +0530784 chanWidth = eHT_CHANNEL_WIDTH_20MHZ;
Abhishek Singh921926b2014-02-13 17:21:01 +0530785 limLog(pMac, LOG1, FL("Setting chanWidth to 20Mhz for"
786 " channel %d"),channelNumber);
Jeff Johnson295189b2012-06-20 16:38:30 -0700787 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700788
Abhishek Singhb92f70c2014-04-28 12:13:08 +0530789 if(chanWidth == eHT_CHANNEL_WIDTH_20MHZ ||
790 chanWidth == eHT_CHANNEL_WIDTH_40MHZ)
Abhishek Singh921926b2014-02-13 17:21:01 +0530791 {
Abhishek Singhb92f70c2014-04-28 12:13:08 +0530792 if (cfgSetInt(pMac, WNI_CFG_VHT_CHANNEL_WIDTH,
793 WNI_CFG_VHT_CHANNEL_WIDTH_20_40MHZ)
794 != eSIR_SUCCESS)
795 {
796 limLog(pMac, LOGP, FL("could not set "
797 " WNI_CFG_CHANNEL_BONDING_MODE at CFG"));
798 retCode = eSIR_LOGP_EXCEPTION;
799 goto free;
800 }
801 }
802 if (chanWidth == eHT_CHANNEL_WIDTH_80MHZ)
803 {
804 if (cfgSetInt(pMac, WNI_CFG_VHT_CHANNEL_WIDTH,
805 WNI_CFG_VHT_CHANNEL_WIDTH_80MHZ)
806 != eSIR_SUCCESS)
807 {
808 limLog(pMac, LOGP, FL("could not set "
809 " WNI_CFG_CHANNEL_BONDING_MODE at CFG"));
810 retCode = eSIR_LOGP_EXCEPTION;
811 goto free;
812 }
813
814 centerChan = limGetCenterChannel( pMac, channelNumber,
815 pSmeStartBssReq->cbMode,
816 WNI_CFG_VHT_CHANNEL_WIDTH_80MHZ);
Jeff Johnsone7245742012-09-05 17:12:55 -0700817 if(centerChan != eSIR_CFG_INVALID_ID)
818 {
Abhishek Singhb92f70c2014-04-28 12:13:08 +0530819 limLog(pMac, LOGW, FL("***Center Channel for "
820 "80MHZ channel width = %d"),centerChan);
Madan Mohan Koyyalamudi8b152b82012-10-18 20:56:27 -0700821 psessionEntry->apCenterChan = centerChan;
Abhishek Singh921926b2014-02-13 17:21:01 +0530822 if (cfgSetInt(pMac,
Abhishek Singhb92f70c2014-04-28 12:13:08 +0530823 WNI_CFG_VHT_CHANNEL_CENTER_FREQ_SEGMENT1,
824 centerChan) != eSIR_SUCCESS)
Jeff Johnsone7245742012-09-05 17:12:55 -0700825 {
Abhishek Singh921926b2014-02-13 17:21:01 +0530826 limLog(pMac, LOGP, FL("could not set "
Abhishek Singhb92f70c2014-04-28 12:13:08 +0530827 "WNI_CFG_CHANNEL_BONDING_MODE at CFG"));
Jeff Johnsone7245742012-09-05 17:12:55 -0700828 retCode = eSIR_LOGP_EXCEPTION;
829 goto free;
830 }
831 }
832 }
833
Abhishek Singhb92f70c2014-04-28 12:13:08 +0530834 /* All the translation is done by now for gVhtChannelWidth
835 * from .ini file to the actual values as defined in spec.
836 * So, grabing the spec value which is
837 * updated in .dat file by the above logic */
838 if (wlan_cfgGetInt(pMac, WNI_CFG_VHT_CHANNEL_WIDTH,
839 &chanWidth) != eSIR_SUCCESS)
840 {
841 limLog(pMac, LOGP,
842 FL("Unable to retrieve Channel Width from CFG"));
843 }
Madan Mohan Koyyalamudi8b152b82012-10-18 20:56:27 -0700844 /*For Sta+p2p-Go concurrency
845 vhtTxChannelWidthSet is used for storing p2p-GO channel width
846 apChanWidth is used for storing the AP channel width that the Sta is going to associate.
847 Initialize the apChanWidth same as p2p-GO channel width this gets over written once the station joins the AP
848 */
Jeff Johnsone7245742012-09-05 17:12:55 -0700849 psessionEntry->vhtTxChannelWidthSet = chanWidth;
Madan Mohan Koyyalamudi8b152b82012-10-18 20:56:27 -0700850 psessionEntry->apChanWidth = chanWidth;
Jeff Johnsone7245742012-09-05 17:12:55 -0700851 }
852 psessionEntry->htSecondaryChannelOffset = limGetHTCBState(pSmeStartBssReq->cbMode);
853#endif
854 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700855 else
856 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700857 PELOGW(limLog(pMac, LOGW, FL("Received invalid eWNI_SME_START_BSS_REQ"));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700858 retCode = eSIR_SME_INVALID_PARAMETERS;
859 goto free;
860 }
861
862 // Delete pre-auth list if any
863 limDeletePreAuthList(pMac);
864
865 // Delete IBSS peer BSSdescription list if any
866 //limIbssDelete(pMac); sep 26 review
867
868
869
870#ifdef FIXME_GEN6 //following code may not be required. limInitMlm is now being invoked during peStart
871 /// Initialize MLM state machine
Jeff Johnson295189b2012-06-20 16:38:30 -0700872 limInitMlm(pMac);
873#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700874
Jeff Johnsone7245742012-09-05 17:12:55 -0700875 psessionEntry->htCapability = IS_DOT11_MODE_HT(pSmeStartBssReq->dot11mode);
Jeff Johnson295189b2012-06-20 16:38:30 -0700876
Jeff Johnson295189b2012-06-20 16:38:30 -0700877 /* keep the RSN/WPA IE information in PE Session Entry
878 * later will be using this to check when received (Re)Assoc req
879 * */
880 limSetRSNieWPAiefromSmeStartBSSReqMessage(pMac,&pSmeStartBssReq->rsnIE,psessionEntry);
881
Jeff Johnson295189b2012-06-20 16:38:30 -0700882
Jeff Johnson295189b2012-06-20 16:38:30 -0700883 //Taken care for only softAP case rest need to be done
884 if (psessionEntry->limSystemRole == eLIM_AP_ROLE){
885 psessionEntry->gLimProtectionControl = pSmeStartBssReq->protEnabled;
886 /*each byte will have the following info
887 *bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0
888 *reserved reserved RIFS Lsig n-GF ht20 11g 11b*/
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +0530889 vos_mem_copy( (void *) &psessionEntry->cfgProtection,
Jeff Johnson295189b2012-06-20 16:38:30 -0700890 (void *) &pSmeStartBssReq->ht_capab,
Kiran Kumar Lokerea4db3dc2013-03-25 18:05:24 -0700891 sizeof( tANI_U16 ));
Jeff Johnson295189b2012-06-20 16:38:30 -0700892 psessionEntry->pAPWPSPBCSession = NULL; // Initialize WPS PBC session link list
893 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700894
895 // Prepare and Issue LIM_MLM_START_REQ to MLM
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +0530896 pMlmStartReq = vos_mem_malloc(sizeof(tLimMlmStartReq));
897 if ( NULL == pMlmStartReq )
Jeff Johnson295189b2012-06-20 16:38:30 -0700898 {
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +0530899 limLog(pMac, LOGP, FL("call to AllocateMemory failed for mlmStartReq"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700900 retCode = eSIR_SME_RESOURCES_UNAVAILABLE;
901 goto free;
902 }
903
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +0530904 vos_mem_set((void *) pMlmStartReq, sizeof(tLimMlmStartReq), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700905
906 /* Copy SSID to the MLM start structure */
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +0530907 vos_mem_copy( (tANI_U8 *) &pMlmStartReq->ssId,
Jeff Johnson295189b2012-06-20 16:38:30 -0700908 (tANI_U8 *) &pSmeStartBssReq->ssId,
909 pSmeStartBssReq->ssId.length + 1);
Jeff Johnson295189b2012-06-20 16:38:30 -0700910 pMlmStartReq->ssidHidden = pSmeStartBssReq->ssidHidden;
911 pMlmStartReq->obssProtEnabled = pSmeStartBssReq->obssProtEnabled;
Jeff Johnson295189b2012-06-20 16:38:30 -0700912
913
914 pMlmStartReq->bssType = psessionEntry->bssType;
915
916 /* Fill PE session Id from the session Table */
917 pMlmStartReq->sessionId = psessionEntry->peSessionId;
918
919 if( (pMlmStartReq->bssType == eSIR_BTAMP_STA_MODE) || (pMlmStartReq->bssType == eSIR_BTAMP_AP_MODE )
Jeff Johnson295189b2012-06-20 16:38:30 -0700920 || (pMlmStartReq->bssType == eSIR_INFRA_AP_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -0700921 )
922 {
923 //len = sizeof(tSirMacAddr);
924 //retStatus = wlan_cfgGetStr(pMac, WNI_CFG_STA_ID, (tANI_U8 *) pMlmStartReq->bssId, &len);
925 //if (retStatus != eSIR_SUCCESS)
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700926 //limLog(pMac, LOGP, FL("could not retrive BSSID, retStatus=%d"), retStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -0700927
928 /* Copy the BSSId from sessionTable to mlmStartReq struct */
929 sirCopyMacAddr(pMlmStartReq->bssId,psessionEntry->bssId);
930 }
931
932 else // ibss mode
933 {
934 pMac->lim.gLimIbssCoalescingHappened = false;
935
936 if((retStatus = wlan_cfgGetInt(pMac, WNI_CFG_IBSS_AUTO_BSSID, &autoGenBssId)) != eSIR_SUCCESS)
937 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700938 limLog(pMac, LOGP, FL("Could not retrieve Auto Gen BSSID, retStatus=%d"), retStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -0700939 retCode = eSIR_LOGP_EXCEPTION;
940 goto free;
941 }
942
943 if(!autoGenBssId)
944 {
945 // We're not auto generating BSSID. Instead, get it from session entry
946 sirCopyMacAddr(pMlmStartReq->bssId,psessionEntry->bssId);
947
948 if(pMlmStartReq->bssId[0] & 0x01)
949 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700950 PELOGE(limLog(pMac, LOGE, FL("Request to start IBSS with group BSSID\n Autogenerating the BSSID"));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700951 autoGenBssId = TRUE;
952 }
953 }
954
955 if( autoGenBssId )
956 { //if BSSID is not any uc id. then use locally generated BSSID.
957 //Autogenerate the BSSID
958 limGetRandomBssid( pMac, pMlmStartReq->bssId);
959 pMlmStartReq->bssId[0]= 0x02;
960
961 /* Copy randomly generated BSSID to the session Table */
962 sirCopyMacAddr(psessionEntry->bssId,pMlmStartReq->bssId);
963 }
964 }
965 /* store the channel num in mlmstart req structure */
966 pMlmStartReq->channelNumber = psessionEntry->currentOperChannel;
967 pMlmStartReq->cbMode = pSmeStartBssReq->cbMode;
968 pMlmStartReq->beaconPeriod = psessionEntry->beaconParams.beaconInterval;
969
Jeff Johnson295189b2012-06-20 16:38:30 -0700970 if(psessionEntry->limSystemRole == eLIM_AP_ROLE ){
971 pMlmStartReq->dtimPeriod = psessionEntry->dtimPeriod;
972 pMlmStartReq->wps_state = psessionEntry->wps_state;
973
974 }else
Jeff Johnson295189b2012-06-20 16:38:30 -0700975 {
976 if (wlan_cfgGetInt(pMac, WNI_CFG_DTIM_PERIOD, &val) != eSIR_SUCCESS)
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700977 limLog(pMac, LOGP, FL("could not retrieve DTIM Period"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700978 pMlmStartReq->dtimPeriod = (tANI_U8)val;
979 }
980
981 if (wlan_cfgGetInt(pMac, WNI_CFG_CFP_PERIOD, &val) != eSIR_SUCCESS)
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700982 limLog(pMac, LOGP, FL("could not retrieve Beacon interval"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700983 pMlmStartReq->cfParamSet.cfpPeriod = (tANI_U8)val;
984
985 if (wlan_cfgGetInt(pMac, WNI_CFG_CFP_MAX_DURATION, &val) != eSIR_SUCCESS)
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700986 limLog(pMac, LOGP, FL("could not retrieve CFPMaxDuration"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700987 pMlmStartReq->cfParamSet.cfpMaxDuration = (tANI_U16) val;
988
989 //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 +0530990 vos_mem_copy((void*)&pMlmStartReq->rateSet, (void*)&psessionEntry->rateSet,
Jeff Johnson295189b2012-06-20 16:38:30 -0700991 sizeof(tSirMacRateSet));
992
Jeff Johnson295189b2012-06-20 16:38:30 -0700993 // Now populate the 11n related parameters
994 pMlmStartReq->nwType = psessionEntry->nwType;
Jeff Johnsone7245742012-09-05 17:12:55 -0700995 pMlmStartReq->htCapable = psessionEntry->htCapability;
Jeff Johnson295189b2012-06-20 16:38:30 -0700996 //
997 // FIXME_GEN4 - Determine the appropriate defaults...
998 //
999 pMlmStartReq->htOperMode = pMac->lim.gHTOperMode;
1000 pMlmStartReq->dualCTSProtection = pMac->lim.gHTDualCTSProtection; // Unused
Jeff Johnsone7245742012-09-05 17:12:55 -07001001 pMlmStartReq->txChannelWidthSet = psessionEntry->htRecommendedTxWidthSet;
Jeff Johnson295189b2012-06-20 16:38:30 -07001002
1003 /* sep26 review */
1004 psessionEntry->limRFBand = limGetRFBand(channelNumber);
1005
1006 // Initialize 11h Enable Flag
1007 psessionEntry->lim11hEnable = 0;
1008 if((pMlmStartReq->bssType != eSIR_IBSS_MODE) &&
1009 (SIR_BAND_5_GHZ == psessionEntry->limRFBand) )
1010 {
1011 if (wlan_cfgGetInt(pMac, WNI_CFG_11H_ENABLED, &val) != eSIR_SUCCESS)
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001012 limLog(pMac, LOGP, FL("Fail to get WNI_CFG_11H_ENABLED "));
Jeff Johnson295189b2012-06-20 16:38:30 -07001013 psessionEntry->lim11hEnable = val;
1014 }
1015
1016 if (!psessionEntry->lim11hEnable)
1017 {
1018 if (cfgSetInt(pMac, WNI_CFG_LOCAL_POWER_CONSTRAINT, 0) != eSIR_SUCCESS)
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001019 limLog(pMac, LOGP, FL("Fail to get WNI_CFG_11H_ENABLED "));
Jeff Johnson295189b2012-06-20 16:38:30 -07001020 }
1021
Jeff Johnson295189b2012-06-20 16:38:30 -07001022 psessionEntry ->limPrevSmeState = psessionEntry->limSmeState;
1023 psessionEntry ->limSmeState = eLIM_SME_WT_START_BSS_STATE;
Jeff Johnsone7245742012-09-05 17:12:55 -07001024 MTRACE(macTrace(pMac, TRACE_CODE_SME_STATE, psessionEntry->peSessionId, psessionEntry ->limSmeState));
Jeff Johnson295189b2012-06-20 16:38:30 -07001025
1026 limPostMlmMessage(pMac, LIM_MLM_START_REQ, (tANI_U32 *) pMlmStartReq);
1027 return;
1028 }
1029 else
1030 {
1031
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001032 limLog(pMac, LOGE, FL("Received unexpected START_BSS_REQ, in state %X"),pMac->lim.gLimSmeState);
Jeff Johnson295189b2012-06-20 16:38:30 -07001033 retCode = eSIR_SME_BSS_ALREADY_STARTED_OR_JOINED;
1034 goto end;
1035 } // if (pMac->lim.gLimSmeState == eLIM_SME_OFFLINE_STATE)
1036
1037free:
Jeff Johnsonace91102013-04-05 08:03:18 -07001038 if ((psessionEntry != NULL) &&
1039 (psessionEntry->pLimStartBssReq == pSmeStartBssReq))
1040 {
1041 psessionEntry->pLimStartBssReq = NULL;
1042 }
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301043 vos_mem_free( pSmeStartBssReq);
1044 vos_mem_free( pMlmStartReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07001045
1046end:
1047
1048 /* This routine should return the sme sessionId and SME transaction Id */
1049 limGetSessionInfo(pMac,(tANI_U8*)pMsgBuf,&smesessionId,&smetransactionId);
1050
1051 if(NULL != psessionEntry)
1052 {
1053 peDeleteSession(pMac,psessionEntry);
1054 psessionEntry = NULL;
1055 }
1056 limSendSmeStartBssRsp(pMac, eWNI_SME_START_BSS_RSP, retCode,psessionEntry,smesessionId,smetransactionId);
1057} /*** end __limHandleSmeStartBssRequest() ***/
1058
1059
1060/**--------------------------------------------------------------
1061\fn __limProcessSmeStartBssReq
1062
1063\brief Wrapper for the function __limHandleSmeStartBssRequest
1064 This message will be defered until softmac come out of
1065 scan mode or if we have detected radar on the current
1066 operating channel.
1067\param pMac
1068\param pMsg
1069
1070\return TRUE - If we consumed the buffer
1071 FALSE - If have defered the message.
1072 ---------------------------------------------------------------*/
1073static tANI_BOOLEAN
1074__limProcessSmeStartBssReq(tpAniSirGlobal pMac, tpSirMsgQ pMsg)
1075{
1076 if (__limIsDeferedMsgForLearn(pMac, pMsg) ||
1077 __limIsDeferedMsgForRadar(pMac, pMsg))
1078 {
1079 /**
1080 * If message defered, buffer is not consumed yet.
1081 * So return false
1082 */
1083 return eANI_BOOLEAN_FALSE;
1084 }
1085
1086 __limHandleSmeStartBssRequest(pMac, (tANI_U32 *) pMsg->bodyptr);
1087 return eANI_BOOLEAN_TRUE;
1088}
1089
1090
1091/**
1092 * limGetRandomBssid()
1093 *
1094 * FUNCTION:This function is called to process generate the random number for bssid
1095 * This function is called to process SME_SCAN_REQ message
1096 * from HDD or upper layer application.
1097 *
1098 * LOGIC:
1099 *
1100 * ASSUMPTIONS:
1101 *
1102 * NOTE:
1103 * 1. geneartes the unique random number for bssid in ibss
1104 *
1105 * @param pMac Pointer to Global MAC structure
1106 * @param *data Pointer to bssid buffer
1107 * @return None
1108 */
1109void limGetRandomBssid(tpAniSirGlobal pMac, tANI_U8 *data)
1110{
1111 tANI_U32 random[2] ;
1112 random[0] = tx_time_get();
1113 random[0] |= (random[0] << 15) ;
1114 random[1] = random[0] >> 1;
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301115 vos_mem_copy( data, (tANI_U8*)random, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07001116}
1117
Ganesh Kondabattinif0fa07c2013-06-11 17:47:49 +05301118static eHalStatus limSendHalStartScanOffloadReq(tpAniSirGlobal pMac,
1119 tpSirSmeScanReq pScanReq)
1120{
1121 tSirScanOffloadReq *pScanOffloadReq;
1122 tANI_U8 *p;
1123 tSirMsgQ msg;
Ganesh Kondabattinif0fa07c2013-06-11 17:47:49 +05301124 tANI_U16 i, len;
1125 tSirRetStatus rc = eSIR_SUCCESS;
1126
1127 /* The tSirScanOffloadReq will reserve the space for first channel,
1128 so allocate the memory for (numChannels - 1) and uIEFieldLen */
1129 len = sizeof(tSirScanOffloadReq) + (pScanReq->channelList.numChannels - 1) +
1130 pScanReq->uIEFieldLen;
1131
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301132 pScanOffloadReq = vos_mem_malloc(len);
1133 if ( NULL == pScanOffloadReq )
Ganesh Kondabattinif0fa07c2013-06-11 17:47:49 +05301134 {
1135 limLog(pMac, LOGE,
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301136 FL("AllocateMemory failed for pScanOffloadReq"));
Ganesh Kondabattinif0fa07c2013-06-11 17:47:49 +05301137 return eHAL_STATUS_FAILURE;
1138 }
1139
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301140 vos_mem_set( (tANI_U8 *) pScanOffloadReq, len, 0);
Ganesh Kondabattinif0fa07c2013-06-11 17:47:49 +05301141
1142 msg.type = WDA_START_SCAN_OFFLOAD_REQ;
1143 msg.bodyptr = pScanOffloadReq;
1144 msg.bodyval = 0;
1145
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301146 vos_mem_copy((tANI_U8 *) pScanOffloadReq->bssId,
Ganesh Kondabattinif0fa07c2013-06-11 17:47:49 +05301147 (tANI_U8*) pScanReq->bssId,
1148 sizeof(tSirMacAddr));
1149
1150 if (pScanReq->numSsid > SIR_SCAN_MAX_NUM_SSID)
1151 {
1152 limLog(pMac, LOGE,
1153 FL("Invalid value (%d) for numSsid"), SIR_SCAN_MAX_NUM_SSID);
Kiet Lamb1233192013-11-28 13:38:20 +05301154 vos_mem_free (pScanOffloadReq);
Ganesh Kondabattinif0fa07c2013-06-11 17:47:49 +05301155 return eHAL_STATUS_FAILURE;
1156 }
1157
1158 pScanOffloadReq->numSsid = pScanReq->numSsid;
1159 for (i = 0; i < pScanOffloadReq->numSsid; i++)
1160 {
1161 pScanOffloadReq->ssId[i].length = pScanReq->ssId[i].length;
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301162 vos_mem_copy((tANI_U8 *) pScanOffloadReq->ssId[i].ssId,
Ganesh Kondabattinif0fa07c2013-06-11 17:47:49 +05301163 (tANI_U8 *) pScanReq->ssId[i].ssId,
1164 pScanOffloadReq->ssId[i].length);
1165 }
1166
1167 pScanOffloadReq->hiddenSsid = pScanReq->hiddenSsid;
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301168 vos_mem_copy((tANI_U8 *) pScanOffloadReq->selfMacAddr,
Ganesh Kondabattinif0fa07c2013-06-11 17:47:49 +05301169 (tANI_U8 *) pScanReq->selfMacAddr,
1170 sizeof(tSirMacAddr));
1171 pScanOffloadReq->bssType = pScanReq->bssType;
1172 pScanOffloadReq->dot11mode = pScanReq->dot11mode;
1173 pScanOffloadReq->scanType = pScanReq->scanType;
1174 pScanOffloadReq->minChannelTime = pScanReq->minChannelTime;
1175 pScanOffloadReq->maxChannelTime = pScanReq->maxChannelTime;
1176 pScanOffloadReq->p2pSearch = pScanReq->p2pSearch;
1177 pScanOffloadReq->sessionId = pScanReq->sessionId;
1178 pScanOffloadReq->channelList.numChannels =
1179 pScanReq->channelList.numChannels;
1180 p = &(pScanOffloadReq->channelList.channelNumber[0]);
1181 for (i = 0; i < pScanOffloadReq->channelList.numChannels; i++)
1182 p[i] = pScanReq->channelList.channelNumber[i];
1183
1184 pScanOffloadReq->uIEFieldLen = pScanReq->uIEFieldLen;
1185 pScanOffloadReq->uIEFieldOffset = len - pScanOffloadReq->uIEFieldLen;
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301186 vos_mem_copy((tANI_U8 *) p + i,
Ganesh Kondabattinif0fa07c2013-06-11 17:47:49 +05301187 (tANI_U8 *) pScanReq + pScanReq->uIEFieldOffset,
1188 pScanOffloadReq->uIEFieldLen);
1189
1190 rc = wdaPostCtrlMsg(pMac, &msg);
1191 if (rc != eSIR_SUCCESS)
1192 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001193 limLog(pMac, LOGE, FL("wdaPostCtrlMsg() return failure"));
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301194 vos_mem_free(pScanOffloadReq);
Ganesh Kondabattinif0fa07c2013-06-11 17:47:49 +05301195 return eHAL_STATUS_FAILURE;
1196 }
Rashmi Ramanna6c13a342014-01-07 11:44:07 +05301197 limLog(pMac, LOG1, FL("Processed Offload Scan Request Successfully"));
Ganesh Kondabattinif0fa07c2013-06-11 17:47:49 +05301198
1199 return eHAL_STATUS_SUCCESS;
1200}
Jeff Johnson295189b2012-06-20 16:38:30 -07001201
1202/**
1203 * __limProcessSmeScanReq()
1204 *
1205 *FUNCTION:
1206 * This function is called to process SME_SCAN_REQ message
1207 * from HDD or upper layer application.
1208 *
1209 *LOGIC:
1210 *
1211 *ASSUMPTIONS:
1212 *
1213 *NOTE:
1214 * 1. Periodic scanning should be requesting to return unique
1215 * scan results.
1216 *
1217 * @param pMac Pointer to Global MAC structure
1218 * @param *pMsgBuf A pointer to the SME message buffer
1219 * @return None
1220 */
1221
Viral Modid440e682013-03-06 02:25:31 -08001222static void
Jeff Johnson295189b2012-06-20 16:38:30 -07001223__limProcessSmeScanReq(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
1224{
1225 tANI_U32 len;
1226 tLimMlmScanReq *pMlmScanReq;
1227 tpSirSmeScanReq pScanReq;
1228 tANI_U8 i = 0;
1229
Sushant Kaushikb97a0082015-08-31 12:36:45 +05301230#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM //FEATURE_WLAN_DIAG_SUPPORT
Jeff Johnson295189b2012-06-20 16:38:30 -07001231 limDiagEventReport(pMac, WLAN_PE_DIAG_SCAN_REQ_EVENT, NULL, 0, 0);
1232#endif //FEATURE_WLAN_DIAG_SUPPORT
1233
1234 pScanReq = (tpSirSmeScanReq) pMsgBuf;
Sushant Kaushike0d2cce2014-04-10 14:36:07 +05301235 limLog(pMac, LOG1,FL("SME SCAN REQ numChan %d min %d max %d IELen %d"
1236 "first %d fresh %d unique %d type %s (%d)"
1237 " mode %s (%d)rsp %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07001238 pScanReq->channelList.numChannels,
1239 pScanReq->minChannelTime,
1240 pScanReq->maxChannelTime,
1241 pScanReq->uIEFieldLen,
1242 pScanReq->returnAfterFirstMatch,
1243 pScanReq->returnFreshResults,
1244 pScanReq->returnUniqueResults,
Sushant Kaushike0d2cce2014-04-10 14:36:07 +05301245 lim_ScanTypetoString(pScanReq->scanType),
Madan Mohan Koyyalamudi70bb4cb2012-10-18 19:31:25 -07001246 pScanReq->scanType,
Sushant Kaushike0d2cce2014-04-10 14:36:07 +05301247 lim_BackgroundScanModetoString(pScanReq->backgroundScanMode),
1248 pScanReq->backgroundScanMode, pMac->lim.gLimRspReqd ? 1 : 0);
Viral Modid86bde22012-12-10 13:09:21 -08001249
1250 /* Since scan req always requires a response, we will overwrite response required here.
1251 * This is added esp to take care of the condition where in p2p go case, we hold the scan req and
1252 * insert single NOA. We send the held scan request to FW later on getting start NOA ind from FW so
1253 * we lose state of the gLimRspReqd flag for the scan req if any other request comes by then.
1254 * e.g. While unit testing, we found when insert single NOA is done, we see a get stats request which turns the flag
1255 * gLimRspReqd to FALSE; now when we actually start the saved scan req for init scan after getting
1256 * NOA started, the gLimRspReqd being a global flag is showing FALSE instead of TRUE value for
1257 * this saved scan req. Since all scan reqs coming to lim require a response, there is no harm in setting
1258 * the global flag gLimRspReqd to TRUE here.
1259 */
1260 pMac->lim.gLimRspReqd = TRUE;
1261
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301262 /*copy the Self MAC address from SmeReq to the globalplace, used for sending probe req*/
Jeff Johnson295189b2012-06-20 16:38:30 -07001263 sirCopyMacAddr(pMac->lim.gSelfMacAddr, pScanReq->selfMacAddr);
1264
Abhishek Singhdaf95742015-10-13 14:53:21 +05301265 /* Check if scan req is not valid or link is already suspended*/
1266 if (!limIsSmeScanReqValid(pMac, pScanReq) || limIsLinkSuspended(pMac))
Jeff Johnson295189b2012-06-20 16:38:30 -07001267 {
Abhishek Singhdaf95742015-10-13 14:53:21 +05301268 limLog(pMac, LOGE,
1269 FL("Received SME_SCAN_REQ with invalid params or link is suspended %d"),
1270 limIsLinkSuspended(pMac));
Jeff Johnson295189b2012-06-20 16:38:30 -07001271
1272 if (pMac->lim.gLimRspReqd)
1273 {
1274 pMac->lim.gLimRspReqd = false;
1275
1276 limSendSmeScanRsp(pMac, sizeof(tSirSmeScanRsp), eSIR_SME_INVALID_PARAMETERS, pScanReq->sessionId, pScanReq->transactionId);
1277
1278 } // if (pMac->lim.gLimRspReqd)
1279
1280 return;
1281 }
1282
1283 //if scan is disabled then return as invalid scan request.
1284 //if scan in power save is disabled, and system is in power save mode, then ignore scan request.
1285 if( (pMac->lim.fScanDisabled) || (!pMac->lim.gScanInPowersave && !limIsSystemInActiveState(pMac)) )
1286 {
Rashmi Ramanna6c13a342014-01-07 11:44:07 +05301287 limLog(pMac, LOGE, FL("SCAN is disabled or SCAN in power save"
1288 " is disabled and system is in power save."));
Leela V Kiran Kumar Reddy Chirala6a458752013-02-16 15:41:27 -08001289 limSendSmeScanRsp(pMac, offsetof(tSirSmeScanRsp,bssDescription[0]), eSIR_SME_INVALID_PARAMETERS, pScanReq->sessionId, pScanReq->transactionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07001290 return;
1291 }
1292
1293
1294 /**
1295 * If scan request is received in idle, joinFailed
1296 * states or in link established state (in STA role)
1297 * or in normal state (in STA-in-IBSS/AP role) with
1298 * 'return fresh scan results' request from HDD or
1299 * it is periodic background scanning request,
1300 * trigger fresh scan request to MLM
1301 */
1302 if (__limFreshScanReqd(pMac, pScanReq->returnFreshResults))
1303 {
Ganesh Kondabattinif0fa07c2013-06-11 17:47:49 +05301304 if (pScanReq->returnFreshResults & SIR_BG_SCAN_PURGE_RESUTLS)
1305 {
1306 // Discard previously cached scan results
1307 limReInitScanResults(pMac);
1308 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001309
Ganesh Kondabattinif0fa07c2013-06-11 17:47:49 +05301310 pMac->lim.gLim24Band11dScanDone = 0;
1311 pMac->lim.gLim50Band11dScanDone = 0;
1312 pMac->lim.gLimReturnAfterFirstMatch =
1313 pScanReq->returnAfterFirstMatch;
1314 pMac->lim.gLimBackgroundScanMode =
1315 pScanReq->backgroundScanMode;
Jeff Johnson295189b2012-06-20 16:38:30 -07001316
Ganesh Kondabattinif0fa07c2013-06-11 17:47:49 +05301317 pMac->lim.gLimReturnUniqueResults =
1318 ((pScanReq->returnUniqueResults) > 0 ? true : false);
1319 /* De-activate Heartbeat timers for connected sessions while
1320 * scan is in progress if the system is in Active mode *
1321 * AND it is not a ROAMING ("background") scan */
1322 if(((ePMM_STATE_BMPS_WAKEUP == pMac->pmm.gPmmState) ||
1323 (ePMM_STATE_READY == pMac->pmm.gPmmState)) &&
1324 (pScanReq->backgroundScanMode != eSIR_ROAMING_SCAN ) &&
1325 (!IS_ACTIVEMODE_OFFLOAD_FEATURE_ENABLE))
1326 {
Jeff Johnson295189b2012-06-20 16:38:30 -07001327 for(i=0;i<pMac->lim.maxBssId;i++)
1328 {
Ganesh Kondabattinif0fa07c2013-06-11 17:47:49 +05301329 if((peFindSessionBySessionId(pMac,i) != NULL) &&
1330 (pMac->lim.gpSession[i].valid == TRUE) &&
1331 (eLIM_MLM_LINK_ESTABLISHED_STATE == pMac->lim.gpSession[i].limMlmState))
1332 {
1333 limHeartBeatDeactivateAndChangeTimer(pMac, peFindSessionBySessionId(pMac,i));
1334 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001335 }
Ganesh Kondabattinif0fa07c2013-06-11 17:47:49 +05301336 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001337
Ganesh Kondabattinif0fa07c2013-06-11 17:47:49 +05301338 if (pMac->fScanOffload)
1339 {
1340 if (eHAL_STATUS_SUCCESS !=
1341 limSendHalStartScanOffloadReq(pMac, pScanReq))
1342 {
Rashmi Ramanna6c13a342014-01-07 11:44:07 +05301343 limLog(pMac, LOGE, FL("Couldn't send Offload scan request"));
Ganesh Kondabattinif0fa07c2013-06-11 17:47:49 +05301344 limSendSmeScanRsp(pMac,
1345 offsetof(tSirSmeScanRsp, bssDescription[0]),
1346 eSIR_SME_INVALID_PARAMETERS,
1347 pScanReq->sessionId,
1348 pScanReq->transactionId);
1349 return;
1350 }
1351 }
1352 else
1353 {
1354
1355 /*Change Global SME state */
1356 /* Store the previous SME state */
Rashmi Ramanna6c13a342014-01-07 11:44:07 +05301357 limLog(pMac, LOG1, FL("Non Offload SCAN request "));
Ganesh Kondabattinif0fa07c2013-06-11 17:47:49 +05301358 pMac->lim.gLimPrevSmeState = pMac->lim.gLimSmeState;
1359 pMac->lim.gLimSmeState = eLIM_SME_WT_SCAN_STATE;
1360 MTRACE(macTrace(pMac, TRACE_CODE_SME_STATE, pScanReq->sessionId, pMac->lim.gLimSmeState));
1361
1362 if (pScanReq->channelList.numChannels == 0)
1363 {
1364 tANI_U32 cfg_len;
Rashmi Ramanna6c13a342014-01-07 11:44:07 +05301365
1366 limLog(pMac, LOG1,
1367 FL("Scan all channels as Number of channels is 0"));
Ganesh Kondabattinif0fa07c2013-06-11 17:47:49 +05301368 // Scan all channels
1369 len = sizeof(tLimMlmScanReq) +
Jeff Johnson295189b2012-06-20 16:38:30 -07001370 (sizeof( pScanReq->channelList.channelNumber ) * (WNI_CFG_VALID_CHANNEL_LIST_LEN - 1)) +
1371 pScanReq->uIEFieldLen;
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301372 pMlmScanReq = vos_mem_malloc(len);
1373 if ( NULL == pMlmScanReq )
Ganesh Kondabattinif0fa07c2013-06-11 17:47:49 +05301374 {
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301375 // Log error
1376 limLog(pMac, LOGP,
1377 FL("call to AllocateMemory failed for mlmScanReq (%d)"), len);
Jeff Johnson295189b2012-06-20 16:38:30 -07001378
Padma, Santhosh Kumar8fa85212015-02-18 12:24:56 +05301379 if (pMac->lim.gLimRspReqd)
1380 {
1381 pMac->lim.gLimRspReqd = false;
1382
1383 limSendSmeScanRsp(pMac, sizeof(tSirSmeScanRsp),
1384 eSIR_SME_RESOURCES_UNAVAILABLE,
1385 pScanReq->sessionId,
1386 pScanReq->transactionId);
1387 }
1388
Ganesh Kondabattinif0fa07c2013-06-11 17:47:49 +05301389 return;
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301390 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001391
Ganesh Kondabattinif0fa07c2013-06-11 17:47:49 +05301392 // Initialize this buffer
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301393 vos_mem_set( (tANI_U8 *) pMlmScanReq, len, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07001394
Ganesh Kondabattinif0fa07c2013-06-11 17:47:49 +05301395 cfg_len = WNI_CFG_VALID_CHANNEL_LIST_LEN;
1396 if (wlan_cfgGetStr(pMac, WNI_CFG_VALID_CHANNEL_LIST,
Jeff Johnson295189b2012-06-20 16:38:30 -07001397 pMlmScanReq->channelList.channelNumber,
1398 &cfg_len) != eSIR_SUCCESS)
Ganesh Kondabattinif0fa07c2013-06-11 17:47:49 +05301399 {
1400 /**
1401 * Could not get Valid channel list from CFG.
1402 * Log error.
1403 */
1404 limLog(pMac, LOGP,
1405 FL("could not retrieve Valid channel list"));
Padma, Santhosh Kumar778d8382015-03-04 17:41:22 +05301406
1407 if (pMac->lim.gLimRspReqd)
1408 {
1409 pMac->lim.gLimRspReqd = false;
1410
1411 limSendSmeScanRsp(pMac, sizeof(tSirSmeScanRsp),
1412 eSIR_SME_INVALID_PARAMETERS,
1413 pScanReq->sessionId,
1414 pScanReq->transactionId);
1415 }
Abhishek Singh2b055852015-10-07 14:14:13 +05301416 vos_mem_free(pMlmScanReq);
Padma, Santhosh Kumar778d8382015-03-04 17:41:22 +05301417 return;
Ganesh Kondabattinif0fa07c2013-06-11 17:47:49 +05301418 }
1419 pMlmScanReq->channelList.numChannels = (tANI_U8) cfg_len;
Padma, Santhosh Kumar778d8382015-03-04 17:41:22 +05301420
1421 //Ignore DFS channels if DFS scan is disabled
1422 if(pMac->scan.fEnableDFSChnlScan == DFS_CHNL_SCAN_DISABLED)
1423 {
1424 tANI_U8 numChan = 0;
1425 tANI_U8 channel_state;
1426 tANI_U8 *chan_ptr = pMlmScanReq->channelList.channelNumber;
1427
1428 limLog(pMac, LOG1,
1429 FL("Ignore DFS channels from valid channel list"));
1430
1431 VOS_TRACE_HEX_DUMP(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
1432 pMlmScanReq->channelList.channelNumber,
1433 pMlmScanReq->channelList.numChannels);
1434
1435 //Filter DFS channels
1436 for (i = 0; i < cfg_len; i++)
1437 {
1438 channel_state =
1439 vos_nv_getChannelEnabledState(*(chan_ptr + i));
1440
1441 //Allow channel if not DFS
1442 if(channel_state != NV_CHANNEL_DFS)
1443 {
1444 *(chan_ptr + numChan) = *(chan_ptr + i);
1445 numChan++;
1446 }
1447 }
1448 pMlmScanReq->channelList.numChannels = (tANI_U8) numChan;
1449
1450 limLog(pMac, LOG1, FL("No of valid channels %d, No of"
1451 "channels after filtering %d"), cfg_len, numChan);
1452
1453 limLog(pMac, LOG1, FL("Channel list after filtering: "));
1454
1455 VOS_TRACE_HEX_DUMP(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
1456 pMlmScanReq->channelList.channelNumber,
1457 pMlmScanReq->channelList.numChannels);
1458 }
Ganesh Kondabattinif0fa07c2013-06-11 17:47:49 +05301459 }
1460 else
1461 {
1462 len = sizeof( tLimMlmScanReq ) - sizeof( pScanReq->channelList.channelNumber ) +
1463 (sizeof( pScanReq->channelList.channelNumber ) * pScanReq->channelList.numChannels ) +
1464 pScanReq->uIEFieldLen;
Jeff Johnson295189b2012-06-20 16:38:30 -07001465
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301466 pMlmScanReq = vos_mem_malloc(len);
1467 if ( NULL == pMlmScanReq )
Ganesh Kondabattinif0fa07c2013-06-11 17:47:49 +05301468 {
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301469 // Log error
1470 limLog(pMac, LOGP,
1471 FL("call to AllocateMemory failed for mlmScanReq(%d)"), len);
Jeff Johnson295189b2012-06-20 16:38:30 -07001472
Padma, Santhosh Kumar8fa85212015-02-18 12:24:56 +05301473 if (pMac->lim.gLimRspReqd)
1474 {
1475 pMac->lim.gLimRspReqd = false;
1476
1477 limSendSmeScanRsp(pMac, sizeof(tSirSmeScanRsp),
1478 eSIR_SME_RESOURCES_UNAVAILABLE,
1479 pScanReq->sessionId,
1480 pScanReq->transactionId);
1481 }
1482
Ganesh Kondabattinif0fa07c2013-06-11 17:47:49 +05301483 return;
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301484 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001485
Ganesh Kondabattinif0fa07c2013-06-11 17:47:49 +05301486 // Initialize this buffer
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301487 vos_mem_set( (tANI_U8 *) pMlmScanReq, len, 0);
Ganesh Kondabattinif0fa07c2013-06-11 17:47:49 +05301488 pMlmScanReq->channelList.numChannels =
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301489 pScanReq->channelList.numChannels;
Jeff Johnson295189b2012-06-20 16:38:30 -07001490
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301491 vos_mem_copy( pMlmScanReq->channelList.channelNumber,
1492 pScanReq->channelList.channelNumber,
1493 pScanReq->channelList.numChannels);
1494 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001495
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301496 pMlmScanReq->uIEFieldLen = pScanReq->uIEFieldLen;
1497 pMlmScanReq->uIEFieldOffset = len - pScanReq->uIEFieldLen;
1498 if(pScanReq->uIEFieldLen)
1499 {
1500 vos_mem_copy( (tANI_U8 *)pMlmScanReq+ pMlmScanReq->uIEFieldOffset,
1501 (tANI_U8 *)pScanReq+(pScanReq->uIEFieldOffset),
1502 pScanReq->uIEFieldLen);
1503 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001504
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301505 pMlmScanReq->bssType = pScanReq->bssType;
1506 vos_mem_copy( pMlmScanReq->bssId,
1507 pScanReq->bssId,
1508 sizeof(tSirMacAddr));
1509 pMlmScanReq->numSsid = pScanReq->numSsid;
Jeff Johnson295189b2012-06-20 16:38:30 -07001510
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301511 i = 0;
1512 while (i < pMlmScanReq->numSsid)
1513 {
1514 vos_mem_copy( (tANI_U8 *) &pMlmScanReq->ssId[i],
Jeff Johnson295189b2012-06-20 16:38:30 -07001515 (tANI_U8 *) &pScanReq->ssId[i],
1516 pScanReq->ssId[i].length + 1);
1517
Ganesh Kondabattinif0fa07c2013-06-11 17:47:49 +05301518 i++;
1519 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001520
Jeff Johnson295189b2012-06-20 16:38:30 -07001521
Ganesh Kondabattinif0fa07c2013-06-11 17:47:49 +05301522 pMlmScanReq->scanType = pScanReq->scanType;
1523 pMlmScanReq->backgroundScanMode = pScanReq->backgroundScanMode;
Ganesh Kondabattini8f6e3b32014-08-25 16:07:54 +05301524 if (pMac->miracast_mode)
1525 {
1526 pMlmScanReq->minChannelTime = DEFAULT_MIN_CHAN_TIME_DURING_MIRACAST;
1527 pMlmScanReq->maxChannelTime = DEFAULT_MAX_CHAN_TIME_DURING_MIRACAST;
1528 }
1529 else
1530 {
1531 pMlmScanReq->minChannelTime = pScanReq->minChannelTime;
1532 pMlmScanReq->maxChannelTime = pScanReq->maxChannelTime;
1533 }
1534
Ganesh Kondabattinif0fa07c2013-06-11 17:47:49 +05301535 pMlmScanReq->minChannelTimeBtc = pScanReq->minChannelTimeBtc;
1536 pMlmScanReq->maxChannelTimeBtc = pScanReq->maxChannelTimeBtc;
1537 pMlmScanReq->dot11mode = pScanReq->dot11mode;
1538 pMlmScanReq->p2pSearch = pScanReq->p2pSearch;
Jeff Johnson295189b2012-06-20 16:38:30 -07001539
Ganesh Kondabattinif0fa07c2013-06-11 17:47:49 +05301540 //Store the smeSessionID and transaction ID for later use.
1541 pMac->lim.gSmeSessionId = pScanReq->sessionId;
1542 pMac->lim.gTransactionId = pScanReq->transactionId;
Jeff Johnson295189b2012-06-20 16:38:30 -07001543
Ganesh Kondabattinif0fa07c2013-06-11 17:47:49 +05301544 // Issue LIM_MLM_SCAN_REQ to MLM
Rashmi Ramanna6c13a342014-01-07 11:44:07 +05301545 limLog(pMac, LOG1, FL("Issue Scan request command to MLM "));
Ganesh Kondabattinif0fa07c2013-06-11 17:47:49 +05301546 limPostMlmMessage(pMac, LIM_MLM_SCAN_REQ, (tANI_U32 *) pMlmScanReq);
1547 }
1548 } // if ((pMac->lim.gLimSmeState == eLIM_SME_IDLE_STATE) || ...
Jeff Johnson295189b2012-06-20 16:38:30 -07001549
1550 else
1551 {
1552 /// In all other cases return 'cached' scan results
1553 if ((pMac->lim.gLimRspReqd) || pMac->lim.gLimReportBackgroundScanResults)
1554 {
1555 tANI_U16 scanRspLen = sizeof(tSirSmeScanRsp);
1556
1557 pMac->lim.gLimRspReqd = false;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07001558#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
1559 if (pScanReq->returnFreshResults & SIR_BG_SCAN_RETURN_LFR_CACHED_RESULTS)
Jeff Johnson295189b2012-06-20 16:38:30 -07001560 {
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07001561 pMac->lim.gLimSmeLfrScanResultLength = pMac->lim.gLimMlmLfrScanResultLength;
1562 if (pMac->lim.gLimSmeLfrScanResultLength == 0)
1563 {
1564 limSendSmeLfrScanRsp(pMac, scanRspLen,
1565 eSIR_SME_SUCCESS,
1566 pScanReq->sessionId,
1567 pScanReq->transactionId);
1568 }
1569 else
1570 {
1571 scanRspLen = sizeof(tSirSmeScanRsp) +
1572 pMac->lim.gLimSmeLfrScanResultLength -
1573 sizeof(tSirBssDescription);
1574 limSendSmeLfrScanRsp(pMac, scanRspLen, eSIR_SME_SUCCESS,
1575 pScanReq->sessionId, pScanReq->transactionId);
1576 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001577 }
1578 else
1579 {
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07001580#endif
1581 if (pMac->lim.gLimSmeScanResultLength == 0)
1582 {
1583 limSendSmeScanRsp(pMac, scanRspLen, eSIR_SME_SUCCESS,
1584 pScanReq->sessionId, pScanReq->transactionId);
1585 }
1586 else
1587 {
1588 scanRspLen = sizeof(tSirSmeScanRsp) +
1589 pMac->lim.gLimSmeScanResultLength -
1590 sizeof(tSirBssDescription);
1591 limSendSmeScanRsp(pMac, scanRspLen, eSIR_SME_SUCCESS,
1592 pScanReq->sessionId, pScanReq->transactionId);
1593 }
1594#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
Jeff Johnson295189b2012-06-20 16:38:30 -07001595 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07001596#endif
Rashmi Ramanna6c13a342014-01-07 11:44:07 +05301597 limLog(pMac, LOG1, FL("Cached scan results are returned "));
Jeff Johnson295189b2012-06-20 16:38:30 -07001598
1599 if (pScanReq->returnFreshResults & SIR_BG_SCAN_PURGE_RESUTLS)
1600 {
1601 // Discard previously cached scan results
1602 limReInitScanResults(pMac);
1603 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07001604#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
1605 if (pScanReq->returnFreshResults & SIR_BG_SCAN_PURGE_LFR_RESULTS)
1606 {
1607 // Discard previously cached scan results
1608 limReInitLfrScanResults(pMac);
1609 }
1610#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001611
1612 } // if (pMac->lim.gLimRspReqd)
1613 } // else ((pMac->lim.gLimSmeState == eLIM_SME_IDLE_STATE) || ...
1614
Jeff Johnson295189b2012-06-20 16:38:30 -07001615#ifdef BACKGROUND_SCAN_ENABLED
1616 // start background scans if needed
1617 // There is a bug opened against softmac. Need to enable when the bug is fixed.
1618 __limBackgroundScanInitiate(pMac);
1619#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001620
1621} /*** end __limProcessSmeScanReq() ***/
1622
Jeff Johnsone7245742012-09-05 17:12:55 -07001623#ifdef FEATURE_OEM_DATA_SUPPORT
Jeff Johnson295189b2012-06-20 16:38:30 -07001624
Jeff Johnsone7245742012-09-05 17:12:55 -07001625static void __limProcessSmeOemDataReq(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
1626{
1627 tpSirOemDataReq pOemDataReq;
1628 tLimMlmOemDataReq* pMlmOemDataReq;
1629
1630 pOemDataReq = (tpSirOemDataReq) pMsgBuf;
1631
1632 //post the lim mlm message now
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301633 pMlmOemDataReq = vos_mem_malloc(sizeof(tLimMlmOemDataReq));
1634 if ( NULL == pMlmOemDataReq )
Jeff Johnsone7245742012-09-05 17:12:55 -07001635 {
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301636 limLog(pMac, LOGP, FL("AllocateMemory failed for mlmOemDataReq"));
Jeff Johnsone7245742012-09-05 17:12:55 -07001637 return;
1638 }
1639
1640 //Initialize this buffer
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301641 vos_mem_set( pMlmOemDataReq, (sizeof(tLimMlmOemDataReq)), 0);
Jeff Johnsone7245742012-09-05 17:12:55 -07001642
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301643 vos_mem_copy( pMlmOemDataReq->selfMacAddr, pOemDataReq->selfMacAddr,
1644 sizeof(tSirMacAddr));
1645 vos_mem_copy( pMlmOemDataReq->oemDataReq, pOemDataReq->oemDataReq,
1646 OEM_DATA_REQ_SIZE);
Jeff Johnsone7245742012-09-05 17:12:55 -07001647
1648 //Issue LIM_MLM_OEM_DATA_REQ to MLM
1649 limPostMlmMessage(pMac, LIM_MLM_OEM_DATA_REQ, (tANI_U32*)pMlmOemDataReq);
1650
1651 return;
1652
1653} /*** end __limProcessSmeOemDataReq() ***/
1654
1655#endif //FEATURE_OEM_DATA_SUPPORT
Jeff Johnson295189b2012-06-20 16:38:30 -07001656
Gopichand Nakkalac178ac82013-05-30 19:53:39 +05301657/**
1658 * __limProcessClearDfsChannelList()
1659 *
1660 *FUNCTION:
1661 *Clear DFS channel list when country is changed/aquired.
1662.*This message is sent from SME.
1663 *
1664 *LOGIC:
1665 *
1666 *ASSUMPTIONS:
1667 *
1668 *NOTE:
1669 *
1670 * @param pMac Pointer to Global MAC structure
1671 * @param *pMsgBuf A pointer to the SME message buffer
1672 * @return None
1673 */
1674static void __limProcessClearDfsChannelList(tpAniSirGlobal pMac,
1675 tpSirMsgQ pMsg)
1676{
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301677 vos_mem_set( &pMac->lim.dfschannelList,
1678 sizeof(tSirDFSChannelList), 0);
Gopichand Nakkalac178ac82013-05-30 19:53:39 +05301679}
Jeff Johnson295189b2012-06-20 16:38:30 -07001680
1681/**
1682 * __limProcessSmeJoinReq()
1683 *
1684 *FUNCTION:
1685 * This function is called to process SME_JOIN_REQ message
1686 * from HDD or upper layer application.
1687 *
1688 *LOGIC:
1689 *
1690 *ASSUMPTIONS:
1691 *
1692 *NOTE:
1693 *
1694 * @param pMac Pointer to Global MAC structure
1695 * @param *pMsgBuf A pointer to the SME message buffer
1696 * @return None
1697 */
Jeff Johnson295189b2012-06-20 16:38:30 -07001698static void
1699__limProcessSmeJoinReq(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
1700{
1701 // tANI_U8 *pBuf;
1702 //tANI_U32 len;
1703// tSirMacAddr currentBssId;
1704 tpSirSmeJoinReq pSmeJoinReq = NULL;
1705 tLimMlmJoinReq *pMlmJoinReq;
1706 tSirResultCodes retCode = eSIR_SME_SUCCESS;
1707 tANI_U32 val = 0;
1708 tANI_U16 nSize;
1709 tANI_U8 sessionId;
1710 tpPESession psessionEntry = NULL;
1711 tANI_U8 smesessionId;
1712 tANI_U16 smetransactionId;
1713 tPowerdBm localPowerConstraint = 0, regMax = 0;
Agarwal Ashish87039eb2014-01-15 14:13:15 +05301714 tANI_U16 ieLen;
1715 v_U8_t *vendorIE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001716
1717#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM //FEATURE_WLAN_DIAG_SUPPORT
1718 //Not sending any session, since it is not created yet. The response whould have correct state.
1719 limDiagEventReport(pMac, WLAN_PE_DIAG_JOIN_REQ_EVENT, NULL, 0, 0);
1720#endif //FEATURE_WLAN_DIAG_SUPPORT
1721
Abhishek Singh3cbf6052014-12-15 16:46:42 +05301722 limLog(pMac, LOG1, FL("Received SME_JOIN_REQ"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001723
1724#ifdef WLAN_FEATURE_VOWIFI
1725 /* Need to read the CFG here itself as this is used in limExtractAPCapability() below.
1726 * This CFG is actually read in rrmUpdateConfig() which is called later. Because this is not
1727 * read, RRM related path before calling rrmUpdateConfig() is not getting executed causing issues
1728 * like not honoring power constraint on 1st association after driver loading. */
1729 if (wlan_cfgGetInt(pMac, WNI_CFG_RRM_ENABLED, &val) != eSIR_SUCCESS)
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001730 limLog(pMac, LOGP, FL("cfg get rrm enabled failed"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001731 pMac->rrm.rrmPEContext.rrmEnable = (val) ? 1 : 0;
1732 val = 0;
1733#endif /* WLAN_FEATURE_VOWIFI */
1734
1735 /**
1736 * Expect Join request in idle state.
1737 * Reassociate request is expected in link established state.
1738 */
1739
1740 /* Global SME and LIM states are not defined yet for BT-AMP Support */
1741 if(pMac->lim.gLimSmeState == eLIM_SME_IDLE_STATE)
1742 {
1743 nSize = __limGetSmeJoinReqSizeForAlloc((tANI_U8*) pMsgBuf);
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301744
1745 pSmeJoinReq = vos_mem_malloc(nSize);
1746 if ( NULL == pSmeJoinReq )
Jeff Johnson295189b2012-06-20 16:38:30 -07001747 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05301748 limLog(pMac, LOGP, FL("call to AllocateMemory failed for "
1749 "pSmeJoinReq"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001750 retCode = eSIR_SME_RESOURCES_UNAVAILABLE;
1751 goto end;
1752 }
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301753 (void) vos_mem_set((void *) pSmeJoinReq, nSize, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07001754
Jeff Johnson295189b2012-06-20 16:38:30 -07001755 if ((limJoinReqSerDes(pMac, pSmeJoinReq, (tANI_U8 *)pMsgBuf) == eSIR_FAILURE) ||
1756 (!limIsSmeJoinReqValid(pMac, pSmeJoinReq)))
1757 {
1758 /// Received invalid eWNI_SME_JOIN_REQ
1759 // Log the event
Padma, Santhosh Kumar2b47ca82014-01-03 16:57:27 +05301760 limLog(pMac, LOGW, FL("SessionId:%d Received SME_JOIN_REQ with"
1761 "invalid data"),pSmeJoinReq->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07001762 retCode = eSIR_SME_INVALID_PARAMETERS;
1763 goto end;
1764 }
1765
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301766 //pMac->lim.gpLimJoinReq = pSmeJoinReq; TO SUPPORT BT-AMP, review os sep 23
Jeff Johnson295189b2012-06-20 16:38:30 -07001767
1768 /* check for the existence of start BSS session */
1769#ifdef FIXME_GEN6
1770 if(pSmeJoinReq->bsstype == eSIR_BTAMP_AP_MODE)
1771 {
1772 if(peValidateBtJoinRequest(pMac)!= TRUE)
1773 {
Padma, Santhosh Kumar2b47ca82014-01-03 16:57:27 +05301774 limLog(pMac, LOGW, FL("SessionId:%d Start Bss session"
1775 "not present::SME_JOIN_REQ in unexpected state"),
1776 pSmeJoinReq->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07001777 retCode = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
1778 psessionEntry = NULL;
1779 goto end;
1780 }
1781 }
1782
1783#endif
1784
1785
1786 if((psessionEntry = peFindSessionByBssid(pMac,pSmeJoinReq->bssDescription.bssId,&sessionId)) != NULL)
1787 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05301788 limLog(pMac, LOGE, FL("Session(%d) Already exists for BSSID: "
Sushant Kaushik1b645382014-10-13 16:39:36 +05301789 MAC_ADDRESS_STR" in limSmeState = %d"),sessionId,
Abhishek Singh57aebef2014-02-03 18:47:44 +05301790 MAC_ADDR_ARRAY(pSmeJoinReq->bssDescription.bssId),
1791 psessionEntry->limSmeState);
Jeff Johnson295189b2012-06-20 16:38:30 -07001792
1793 if(psessionEntry->limSmeState == eLIM_SME_LINK_EST_STATE)
1794 {
1795 // Received eWNI_SME_JOIN_REQ for same
1796 // BSS as currently associated.
1797 // Log the event and send success
Padma, Santhosh Kumar2b47ca82014-01-03 16:57:27 +05301798 PELOGW(limLog(pMac, LOGW, FL("SessionId:%d Received"
1799 "SME_JOIN_REQ for currently joined BSS"),sessionId);)
Jeff Johnson295189b2012-06-20 16:38:30 -07001800 /// Send Join success response to host
Deepthi Gowrif3e27252013-12-11 20:50:01 +05301801 retCode = eSIR_SME_ALREADY_JOINED_A_BSS;
1802 psessionEntry = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07001803 goto end;
1804 }
1805 else
1806 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05301807 PELOGE(limLog(pMac, LOGE, FL("SME_JOIN_REQ not for"
1808 "currently joined BSS"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001809 retCode = eSIR_SME_REFUSED;
1810 psessionEntry = NULL;
1811 goto end;
1812 }
1813 }
1814 else /* Session Entry does not exist for given BSSId */
1815 {
1816 /* Try to Create a new session */
1817 if((psessionEntry = peCreateSession(pMac,pSmeJoinReq->bssDescription.bssId,&sessionId, pMac->lim.maxStation)) == NULL)
1818 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001819 limLog(pMac, LOGE, FL("Session Can not be created "));
Jeff Johnson295189b2012-06-20 16:38:30 -07001820 retCode = eSIR_SME_RESOURCES_UNAVAILABLE;
1821 goto end;
1822 }
Padma, Santhosh Kumar2b47ca82014-01-03 16:57:27 +05301823 else
1824 limLog(pMac,LOG1,FL("SessionId:%d New session created"),
1825 sessionId);
Masti, Narayanraddi67ea5912015-01-08 12:34:05 +05301826 }
1827
1828 if(psessionEntry != NULL && pSmeJoinReq->operationalRateSet.numRates > 0 ){
1829 if(!limCheck11BRateBitmap(pSmeJoinReq->rateBitMap)){
1830 psessionEntry->is11Gonly = true;
1831 }
1832 }
1833
krunal soni5afa96c2013-09-06 22:19:02 -07001834 psessionEntry->isAmsduSupportInAMPDU = pSmeJoinReq->isAmsduSupportInAMPDU;
Jeff Johnsone7245742012-09-05 17:12:55 -07001835
Jeff Johnson295189b2012-06-20 16:38:30 -07001836 /* Store Session related parameters */
1837 /* Store PE session Id in session Table */
1838 psessionEntry->peSessionId = sessionId;
1839
1840 /* store the smejoin req handle in session table */
1841 psessionEntry->pLimJoinReq = pSmeJoinReq;
1842
1843 /* Store SME session Id in sessionTable */
1844 psessionEntry->smeSessionId = pSmeJoinReq->sessionId;
1845
1846 /* Store SME transaction Id in session Table */
1847 psessionEntry->transactionId = pSmeJoinReq->transactionId;
1848
1849 /* Store beaconInterval */
1850 psessionEntry->beaconParams.beaconInterval = pSmeJoinReq->bssDescription.beaconInterval;
1851
1852 /* Copying of bssId is already done, while creating session */
1853 //sirCopyMacAddr(psessionEntry->bssId,pSmeJoinReq->bssId);
1854 sirCopyMacAddr(psessionEntry->selfMacAddr,pSmeJoinReq->selfMacAddr);
1855 psessionEntry->bssType = pSmeJoinReq->bsstype;
1856
1857 psessionEntry->statypeForBss = STA_ENTRY_PEER;
Sandeep Puligillaaea98a22013-12-04 13:36:32 +05301858 psessionEntry->limWmeEnabled = pSmeJoinReq->isWMEenabled;
1859 psessionEntry->limQosEnabled = pSmeJoinReq->isQosEnabled;
Sushant Kaushik74df8db2015-03-11 18:09:05 +05301860 psessionEntry->bOSENAssociation = pSmeJoinReq->bOSENAssociation;
Abhishek Singheef5c992016-01-27 13:41:54 +05301861 psessionEntry->bWPSAssociation = pSmeJoinReq->bWPSAssociation;
Jeff Johnson295189b2012-06-20 16:38:30 -07001862
Agarwal Ashish87039eb2014-01-15 14:13:15 +05301863 /* Store vendor specfic IE for CISCO AP */
1864 ieLen = (pSmeJoinReq->bssDescription.length +
1865 sizeof( pSmeJoinReq->bssDescription.length ) -
1866 GET_FIELD_OFFSET( tSirBssDescription, ieFields ));
1867
1868 vendorIE = limGetVendorIEOuiPtr(pMac, SIR_MAC_CISCO_OUI,
1869 SIR_MAC_CISCO_OUI_SIZE,
1870 ((tANI_U8 *)&pSmeJoinReq->bssDescription.ieFields) , ieLen);
1871
1872 if ( NULL != vendorIE )
1873 {
1874 limLog(pMac, LOGE,
1875 FL("DUT is trying to connect to Cisco AP"));
1876 psessionEntry->isCiscoVendorAP = TRUE;
1877 }
1878 else
1879 {
1880 psessionEntry->isCiscoVendorAP = FALSE;
1881 }
1882
Jeff Johnson295189b2012-06-20 16:38:30 -07001883 /* Copy the dot 11 mode in to the session table */
1884
1885 psessionEntry->dot11mode = pSmeJoinReq->dot11mode;
1886 psessionEntry->nwType = pSmeJoinReq->bssDescription.nwType;
Jeff Johnsone7245742012-09-05 17:12:55 -07001887#ifdef WLAN_FEATURE_11AC
1888 psessionEntry->vhtCapability = IS_DOT11_MODE_VHT(psessionEntry->dot11mode);
Jeff Johnson32d95a32012-09-10 13:15:23 -07001889 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO_MED,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001890 "***__limProcessSmeJoinReq: vhtCapability=%d****",psessionEntry->vhtCapability);
Shailender Karmuchi08f87c22013-01-17 12:51:24 -08001891 if (psessionEntry->vhtCapability )
1892 {
1893 psessionEntry->txBFIniFeatureEnabled = pSmeJoinReq->txBFIniFeatureEnabled;
1894
1895 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO_MED,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001896 "***__limProcessSmeJoinReq: txBFIniFeatureEnabled=%d****",
Shailender Karmuchi08f87c22013-01-17 12:51:24 -08001897 psessionEntry->txBFIniFeatureEnabled);
1898
1899 if( psessionEntry->txBFIniFeatureEnabled )
1900 {
1901 if (cfgSetInt(pMac, WNI_CFG_VHT_SU_BEAMFORMEE_CAP, psessionEntry->txBFIniFeatureEnabled)
1902 != eSIR_SUCCESS)
1903 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05301904 limLog(pMac, LOGP, FL("could not set "
1905 "WNI_CFG_VHT_SU_BEAMFORMEE_CAP at CFG"));
Shailender Karmuchi08f87c22013-01-17 12:51:24 -08001906 retCode = eSIR_LOGP_EXCEPTION;
1907 goto end;
1908 }
Shailender Karmuchicc3fe442013-02-16 18:18:33 -08001909 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO_MED,
Abhishek Singh57aebef2014-02-03 18:47:44 +05301910 "***__limProcessSmeJoinReq: txBFCsnValue=%d****",
1911 pSmeJoinReq->txBFCsnValue);
Shailender Karmuchicc3fe442013-02-16 18:18:33 -08001912
1913 if (cfgSetInt(pMac, WNI_CFG_VHT_CSN_BEAMFORMEE_ANT_SUPPORTED, pSmeJoinReq->txBFCsnValue)
Shailender Karmuchi08f87c22013-01-17 12:51:24 -08001914 != eSIR_SUCCESS)
1915 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05301916 limLog(pMac, LOGP, FL("could not set "
1917 "WNI_CFG_VHT_CSN_BEAMFORMEE_ANT_SUPPORTED at CFG"));
Shailender Karmuchi08f87c22013-01-17 12:51:24 -08001918 retCode = eSIR_LOGP_EXCEPTION;
1919 goto end;
1920 }
Abhishek Singh6d5d29c2014-07-03 14:25:22 +05301921
1922 if ( FALSE == pMac->isMuBfsessionexist )
1923 psessionEntry->txMuBformee = pSmeJoinReq->txMuBformee;
Shailender Karmuchi08f87c22013-01-17 12:51:24 -08001924 }
Abhishek Singh6d5d29c2014-07-03 14:25:22 +05301925
1926 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
1927 "SmeJoinReq:txMuBformee=%d psessionEntry: txMuBformee = %d",
1928 pSmeJoinReq->txMuBformee, psessionEntry->txMuBformee);
1929
1930 if(cfgSetInt(pMac, WNI_CFG_VHT_MU_BEAMFORMEE_CAP, psessionEntry->txMuBformee)
1931 != eSIR_SUCCESS)
1932 {
1933 limLog(pMac, LOGE, FL("could not set "
1934 "WNI_CFG_VHT_MU_BEAMFORMEE_CAP at CFG"));
1935 retCode = eSIR_LOGP_EXCEPTION;
1936 goto end;
1937 }
1938
Shailender Karmuchi08f87c22013-01-17 12:51:24 -08001939 }
1940
Jeff Johnsone7245742012-09-05 17:12:55 -07001941#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001942
1943 /*Phy mode*/
1944 psessionEntry->gLimPhyMode = pSmeJoinReq->bssDescription.nwType;
1945
Abhishek Singhca6ec5d2015-06-24 13:13:27 +05301946 handleHTCapabilityandHTInfo(pMac, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07001947 /* Copy The channel Id to the session Table */
1948 psessionEntry->currentOperChannel = pSmeJoinReq->bssDescription.channelId;
Jeff Johnsone7245742012-09-05 17:12:55 -07001949 psessionEntry->htSupportedChannelWidthSet = (pSmeJoinReq->cbMode)?1:0; // This is already merged value of peer and self - done by csr in csrGetCBModeFromIes
1950 psessionEntry->htRecommendedTxWidthSet = psessionEntry->htSupportedChannelWidthSet;
1951 psessionEntry->htSecondaryChannelOffset = pSmeJoinReq->cbMode;
Jeff Johnson295189b2012-06-20 16:38:30 -07001952
Chet Lanctot186b5732013-03-18 10:26:30 -07001953 /* Record if management frames need to be protected */
1954#ifdef WLAN_FEATURE_11W
1955 if(eSIR_ED_AES_128_CMAC == pSmeJoinReq->MgmtEncryptionType)
1956 {
1957 psessionEntry->limRmfEnabled = 1;
1958 }
1959 else
1960 {
1961 psessionEntry->limRmfEnabled = 0;
1962 }
1963#endif
1964
krunal soni8d13b092013-07-19 13:23:29 -07001965#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM
1966 psessionEntry->rssi = pSmeJoinReq->bssDescription.rssi;
1967#endif
1968
Jeff Johnson295189b2012-06-20 16:38:30 -07001969 /*Store Persona */
1970 psessionEntry->pePersona = pSmeJoinReq->staPersona;
1971 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
Abhishek Singh57aebef2014-02-03 18:47:44 +05301972 FL("PE PERSONA=%d cbMode %u"), psessionEntry->pePersona,
1973 pSmeJoinReq->cbMode);
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"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002033 return;
2034 }
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302035 (void) vos_mem_set((void *) pMlmJoinReq, val, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07002036
2037 /* PE SessionId is stored as a part of JoinReq*/
2038 pMlmJoinReq->sessionId = psessionEntry->peSessionId;
2039
2040 if (wlan_cfgGetInt(pMac, WNI_CFG_JOIN_FAILURE_TIMEOUT, (tANI_U32 *) &pMlmJoinReq->joinFailureTimeout)
2041 != eSIR_SUCCESS)
Sushant Kaushike3ca61c2015-03-19 18:33:25 +05302042 {
2043 limLog(pMac, LOGE, FL("could not retrieve JoinFailureTimer value "
2044 "setting it to default value"));
2045 pMlmJoinReq->joinFailureTimeout = JOIN_FAILURE_TIMEOUT;
2046 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002047
2048 /* copy operational rate from psessionEntry*/
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302049 vos_mem_copy((void*)&psessionEntry->rateSet, (void*)&pSmeJoinReq->operationalRateSet,
Jeff Johnson295189b2012-06-20 16:38:30 -07002050 sizeof(tSirMacRateSet));
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302051 vos_mem_copy((void*)&psessionEntry->extRateSet, (void*)&pSmeJoinReq->extendedRateSet,
Jeff Johnson295189b2012-06-20 16:38:30 -07002052 sizeof(tSirMacRateSet));
2053 //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 +05302054 vos_mem_copy((void*)&pMlmJoinReq->operationalRateSet, (void*)&psessionEntry->rateSet,
Jeff Johnson295189b2012-06-20 16:38:30 -07002055 sizeof(tSirMacRateSet));
2056
2057 psessionEntry->encryptType = pSmeJoinReq->UCEncryptionType;
2058
Jeff Johnson295189b2012-06-20 16:38:30 -07002059 pMlmJoinReq->bssDescription.length = psessionEntry->pLimJoinReq->bssDescription.length;
2060
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302061 vos_mem_copy((tANI_U8 *) &pMlmJoinReq->bssDescription.bssId,
Jeff Johnson295189b2012-06-20 16:38:30 -07002062 (tANI_U8 *) &psessionEntry->pLimJoinReq->bssDescription.bssId,
2063 psessionEntry->pLimJoinReq->bssDescription.length + 2);
2064
Jeff Johnson295189b2012-06-20 16:38:30 -07002065 psessionEntry->limCurrentBssCaps =
Jeff Johnsone7245742012-09-05 17:12:55 -07002066 psessionEntry->pLimJoinReq->bssDescription.capabilityInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07002067
Jeff Johnsone7245742012-09-05 17:12:55 -07002068 regMax = cfgGetRegulatoryMaxTransmitPower( pMac, psessionEntry->currentOperChannel );
Sandeep Puligillaa9eb9ad2014-05-27 14:42:50 +05302069 localPowerConstraint = regMax;
Jeff Johnsone7245742012-09-05 17:12:55 -07002070 limExtractApCapability( pMac,
2071 (tANI_U8 *) psessionEntry->pLimJoinReq->bssDescription.ieFields,
2072 limGetIElenFromBssDescription(&psessionEntry->pLimJoinReq->bssDescription),
2073 &psessionEntry->limCurrentBssQosCaps,
2074 &psessionEntry->limCurrentBssPropCap,
2075 &pMac->lim.gLimCurrentBssUapsd //TBD-RAJESH make gLimCurrentBssUapsd this session specific
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07002076 , &localPowerConstraint,
2077 psessionEntry
Sandeep Puligilla4ce02592014-04-22 09:05:57 +05302078 );
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
2098 if (pMac->lim.gLimCurrentBssUapsd)
2099 {
2100 pMac->lim.gUapsdPerAcBitmask = psessionEntry->pLimJoinReq->uapsdPerAcBitmask;
Abhishek Singh57aebef2014-02-03 18:47:44 +05302101 limLog( pMac, LOG1, FL("UAPSD flag for all AC - 0x%2x"),
2102 pMac->lim.gUapsdPerAcBitmask);
Jeff Johnson295189b2012-06-20 16:38:30 -07002103
2104 // resetting the dynamic uapsd mask
2105 pMac->lim.gUapsdPerAcDeliveryEnableMask = 0;
2106 pMac->lim.gUapsdPerAcTriggerEnableMask = 0;
2107 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002108
2109 psessionEntry->limRFBand = limGetRFBand(psessionEntry->currentOperChannel);
2110
2111 // Initialize 11h Enable Flag
2112 if(SIR_BAND_5_GHZ == psessionEntry->limRFBand)
2113 {
2114 if (wlan_cfgGetInt(pMac, WNI_CFG_11H_ENABLED, &val) != eSIR_SUCCESS)
Sushant Kaushike3ca61c2015-03-19 18:33:25 +05302115 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002116 limLog(pMac, LOGP, FL("Fail to get WNI_CFG_11H_ENABLED "));
Sushant Kaushike3ca61c2015-03-19 18:33:25 +05302117 psessionEntry->lim11hEnable = 1;
2118 }
2119 else
2120 psessionEntry->lim11hEnable = val;
Jeff Johnson295189b2012-06-20 16:38:30 -07002121 }
2122 else
2123 psessionEntry->lim11hEnable = 0;
2124
2125 //To care of the scenario when STA transitions from IBSS to Infrastructure mode.
2126 pMac->lim.gLimIbssCoalescingHappened = false;
2127
Jeff Johnsone7245742012-09-05 17:12:55 -07002128 psessionEntry->limPrevSmeState = psessionEntry->limSmeState;
2129 psessionEntry->limSmeState = eLIM_SME_WT_JOIN_STATE;
2130 MTRACE(macTrace(pMac, TRACE_CODE_SME_STATE, psessionEntry->peSessionId, psessionEntry->limSmeState));
Jeff Johnson295189b2012-06-20 16:38:30 -07002131
Abhishek Singh57aebef2014-02-03 18:47:44 +05302132 limLog(pMac, LOG1, FL("SME JoinReq:Sessionid %d SSID len %d SSID : %s "
2133 "Channel %d, BSSID "MAC_ADDRESS_STR), pMlmJoinReq->sessionId,
2134 psessionEntry->ssId.length,psessionEntry->ssId.ssId,
2135 psessionEntry->currentOperChannel,
2136 MAC_ADDR_ARRAY(psessionEntry->bssId));
Jeff Johnson295189b2012-06-20 16:38:30 -07002137
2138 /* Indicate whether spectrum management is enabled*/
2139 psessionEntry->spectrumMgtEnabled =
2140 pSmeJoinReq->spectrumMgtIndicator;
Rajesh Babu Prathipati043149f2014-06-06 13:33:45 +05302141
2142 /* Enable the spectrum management if this is a DFS channel */
2143 if (psessionEntry->countryInfoPresent &&
2144 limIsconnectedOnDFSChannel(psessionEntry->currentOperChannel))
2145 {
2146 psessionEntry->spectrumMgtEnabled = TRUE;
2147 }
2148
Abhishek Singh3cbf6052014-12-15 16:46:42 +05302149 limLog(pMac,LOG1,FL("SessionId: %d LIM_MLM_JOIN_REQ is posted to MLM "
2150 "SM"), pMlmJoinReq->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07002151 /* Issue LIM_MLM_JOIN_REQ to MLM */
2152 limPostMlmMessage(pMac, LIM_MLM_JOIN_REQ, (tANI_U32 *) pMlmJoinReq);
2153 return;
2154
2155 }
2156 else
2157 {
2158 /* Received eWNI_SME_JOIN_REQ un expected state */
Abhishek Singh57aebef2014-02-03 18:47:44 +05302159 limLog(pMac, LOGE, FL("received unexpected SME_JOIN_REQ "
Sushant Kaushik1b645382014-10-13 16:39:36 +05302160 "in state %d"), pMac->lim.gLimSmeState);
Jeff Johnson295189b2012-06-20 16:38:30 -07002161 limPrintSmeState(pMac, LOGE, pMac->lim.gLimSmeState);
2162 retCode = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
2163 psessionEntry = NULL;
2164 goto end;
2165
2166 }
2167
2168end:
2169 limGetSessionInfo(pMac,(tANI_U8*)pMsgBuf,&smesessionId,&smetransactionId);
2170
2171 if(pSmeJoinReq)
2172 {
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302173 vos_mem_free(pSmeJoinReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07002174 pSmeJoinReq = NULL;
2175 if (NULL != psessionEntry)
2176 {
2177 psessionEntry->pLimJoinReq = NULL;
2178 }
2179 }
2180
2181 if(retCode != eSIR_SME_SUCCESS)
2182 {
2183 if(NULL != psessionEntry)
2184 {
2185 peDeleteSession(pMac,psessionEntry);
2186 psessionEntry = NULL;
2187 }
2188 }
Abhishek Singh57aebef2014-02-03 18:47:44 +05302189 limLog(pMac, LOG1, FL("Sending failure status limSendSmeJoinReassocRsp"
2190 "on sessionid: %d with retCode = %d"),smesessionId, retCode);
Jeff Johnson295189b2012-06-20 16:38:30 -07002191 limSendSmeJoinReassocRsp(pMac, eWNI_SME_JOIN_RSP, retCode, eSIR_MAC_UNSPEC_FAILURE_STATUS,psessionEntry,smesessionId,smetransactionId);
2192} /*** end __limProcessSmeJoinReq() ***/
2193
2194
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002195#ifdef FEATURE_WLAN_ESE
Madan Mohan Koyyalamudi3282c572012-11-09 17:01:41 -08002196tANI_U8 limGetMaxTxPower(tPowerdBm regMax, tPowerdBm apTxPower, tANI_U8 iniTxPower)
Jeff Johnson295189b2012-06-20 16:38:30 -07002197{
2198 tANI_U8 maxTxPower = 0;
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302199 tANI_U8 txPower = VOS_MIN( regMax, (apTxPower) );
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002200 txPower = VOS_MIN(txPower, iniTxPower);
Jeff Johnson295189b2012-06-20 16:38:30 -07002201 if((txPower >= MIN_TX_PWR_CAP) && (txPower <= MAX_TX_PWR_CAP))
2202 maxTxPower = txPower;
2203 else if (txPower < MIN_TX_PWR_CAP)
2204 maxTxPower = MIN_TX_PWR_CAP;
2205 else
2206 maxTxPower = MAX_TX_PWR_CAP;
2207
2208 return (maxTxPower);
2209}
2210#endif
2211
Jeff Johnson295189b2012-06-20 16:38:30 -07002212/**
2213 * __limProcessSmeReassocReq()
2214 *
2215 *FUNCTION:
2216 * This function is called to process SME_REASSOC_REQ message
2217 * from HDD or upper layer application.
2218 *
2219 *LOGIC:
2220 *
2221 *ASSUMPTIONS:
2222 *
2223 *NOTE:
2224 *
2225 * @param pMac Pointer to Global MAC structure
2226 * @param *pMsgBuf A pointer to the SME message buffer
2227 * @return None
2228 */
2229
2230static void
2231__limProcessSmeReassocReq(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
2232{
2233 tANI_U16 caps;
2234 tANI_U32 val;
Srinivas Girigowdac16730e2013-01-16 13:39:39 -08002235 tpSirSmeJoinReq pReassocReq = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002236 tLimMlmReassocReq *pMlmReassocReq;
2237 tSirResultCodes retCode = eSIR_SME_SUCCESS;
2238 tpPESession psessionEntry = NULL;
2239 tANI_U8 sessionId;
2240 tANI_U8 smeSessionId;
2241 tANI_U16 transactionId;
2242 tPowerdBm localPowerConstraint = 0, regMax = 0;
2243 tANI_U32 teleBcnEn = 0;
Madan Mohan Koyyalamudi7df624d2012-10-31 16:32:50 -07002244 tANI_U16 nSize;
Jeff Johnson295189b2012-06-20 16:38:30 -07002245
2246
Abhishek Singh127a8442014-12-15 17:31:27 +05302247 limLog(pMac, LOG1, FL("Received SME_REASSOC_REQ"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002248
Madan Mohan Koyyalamudi7df624d2012-10-31 16:32:50 -07002249 nSize = __limGetSmeJoinReqSizeForAlloc((tANI_U8 *) pMsgBuf);
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302250 pReassocReq = vos_mem_malloc(nSize);
2251 if ( NULL == pReassocReq )
Jeff Johnson295189b2012-06-20 16:38:30 -07002252 {
2253 // Log error
2254 limLog(pMac, LOGP,
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302255 FL("call to AllocateMemory failed for pReassocReq"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002256
2257 retCode = eSIR_SME_RESOURCES_UNAVAILABLE;
2258 goto end;
2259 }
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302260 (void) vos_mem_set((void *) pReassocReq, nSize, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07002261 if ((limJoinReqSerDes(pMac, (tpSirSmeJoinReq) pReassocReq,
2262 (tANI_U8 *) pMsgBuf) == eSIR_FAILURE) ||
2263 (!limIsSmeJoinReqValid(pMac,
2264 (tpSirSmeJoinReq) pReassocReq)))
2265 {
2266 /// Received invalid eWNI_SME_REASSOC_REQ
2267 // Log the event
2268 limLog(pMac, LOGW,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002269 FL("received SME_REASSOC_REQ with invalid data"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002270
2271 retCode = eSIR_SME_INVALID_PARAMETERS;
2272 goto end;
2273 }
2274
2275 if((psessionEntry = peFindSessionByBssid(pMac,pReassocReq->bssDescription.bssId,&sessionId))==NULL)
2276 {
2277 limPrintMacAddr(pMac, pReassocReq->bssDescription.bssId, LOGE);
Srinivas Girigowda2a69dcf2013-09-13 14:48:34 -07002278 limLog(pMac, LOGE, FL("Session does not exist for given bssId"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002279 retCode = eSIR_SME_INVALID_PARAMETERS;
2280 goto end;
2281 }
2282
Sushant Kaushikb97a0082015-08-31 12:36:45 +05302283#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM //FEATURE_WLAN_DIAG_SUPPORT
Deepthi Gowri639d5042015-11-16 20:23:39 +05302284 limDiagEventReport(pMac, WLAN_PE_DIAG_REASSOC_REQ_EVENT, psessionEntry,
2285 eSIR_SUCCESS, eSIR_SUCCESS);
Jeff Johnson295189b2012-06-20 16:38:30 -07002286#endif //FEATURE_WLAN_DIAG_SUPPORT
2287 //pMac->lim.gpLimReassocReq = pReassocReq;//TO SUPPORT BT-AMP
2288
2289 /* Store the reassoc handle in the session Table.. 23rd sep review */
2290 psessionEntry->pLimReAssocReq = pReassocReq;
Padma, Santhosh Kumar0d25d102014-07-17 15:08:48 +05302291 psessionEntry->dot11mode = pReassocReq->dot11mode;
2292 psessionEntry->vhtCapability = IS_DOT11_MODE_VHT(pReassocReq->dot11mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07002293
2294 /**
2295 * Reassociate request is expected
2296 * in link established state only.
2297 */
2298
2299 if (psessionEntry->limSmeState != eLIM_SME_LINK_EST_STATE)
2300 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002301#if defined(WLAN_FEATURE_VOWIFI_11R) || defined(FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07002302 if (psessionEntry->limSmeState == eLIM_SME_WT_REASSOC_STATE)
2303 {
2304 // May be from 11r FT pre-auth. So lets check it before we bail out
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08002305 limLog(pMac, LOG1, FL("Session in reassoc state is %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002306 psessionEntry->peSessionId);
2307
2308 // Make sure its our preauth bssid
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302309 if (!vos_mem_compare( pReassocReq->bssDescription.bssId,
Jeff Johnson295189b2012-06-20 16:38:30 -07002310 pMac->ft.ftPEContext.pFTPreAuthReq->preAuthbssId, 6))
2311 {
2312 limPrintMacAddr(pMac, pReassocReq->bssDescription.bssId, LOGE);
2313 limPrintMacAddr(pMac, pMac->ft.ftPEContext.pFTPreAuthReq->preAuthbssId, LOGE);
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002314 limLog(pMac, LOGP, FL("Unknown bssId in reassoc state"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002315 retCode = eSIR_SME_INVALID_PARAMETERS;
2316 goto end;
2317 }
2318
2319 limProcessMlmFTReassocReq(pMac, pMsgBuf, psessionEntry);
2320 return;
2321 }
2322#endif
2323 /// Should not have received eWNI_SME_REASSOC_REQ
2324 // Log the event
2325 limLog(pMac, LOGE,
Sushant Kaushik1b645382014-10-13 16:39:36 +05302326 FL("received unexpected SME_REASSOC_REQ in state %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002327 psessionEntry->limSmeState);
2328 limPrintSmeState(pMac, LOGE, psessionEntry->limSmeState);
2329
2330 retCode = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
2331 goto end;
2332 }
2333
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302334 vos_mem_copy( psessionEntry->limReAssocbssId,
Jeff Johnson295189b2012-06-20 16:38:30 -07002335 psessionEntry->pLimReAssocReq->bssDescription.bssId,
2336 sizeof(tSirMacAddr));
2337
2338 psessionEntry->limReassocChannelId =
2339 psessionEntry->pLimReAssocReq->bssDescription.channelId;
2340
Jeff Johnsone7245742012-09-05 17:12:55 -07002341 psessionEntry->reAssocHtSupportedChannelWidthSet =
2342 (psessionEntry->pLimReAssocReq->cbMode)?1:0;
2343 psessionEntry->reAssocHtRecommendedTxWidthSet =
2344 psessionEntry->reAssocHtSupportedChannelWidthSet;
2345 psessionEntry->reAssocHtSecondaryChannelOffset =
2346 psessionEntry->pLimReAssocReq->cbMode;
2347
Jeff Johnson295189b2012-06-20 16:38:30 -07002348 psessionEntry->limReassocBssCaps =
2349 psessionEntry->pLimReAssocReq->bssDescription.capabilityInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07002350 regMax = cfgGetRegulatoryMaxTransmitPower( pMac, psessionEntry->currentOperChannel );
2351 localPowerConstraint = regMax;
2352 limExtractApCapability( pMac,
2353 (tANI_U8 *) psessionEntry->pLimReAssocReq->bssDescription.ieFields,
2354 limGetIElenFromBssDescription(
2355 &psessionEntry->pLimReAssocReq->bssDescription),
2356 &psessionEntry->limReassocBssQosCaps,
2357 &psessionEntry->limReassocBssPropCap,
2358 &pMac->lim.gLimCurrentBssUapsd //TBD-RAJESH make gLimReassocBssUapsd session specific
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07002359 , &localPowerConstraint,
2360 psessionEntry
Jeff Johnson295189b2012-06-20 16:38:30 -07002361 );
2362
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302363 psessionEntry->maxTxPower = VOS_MIN( regMax, (localPowerConstraint) );
Sushant Kaushikece4b562015-04-09 18:27:33 +05302364 if (!psessionEntry->maxTxPower)
2365 {
2366 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR, FL("Tx power "
2367 "is zero. Setting it to default value %d"),
2368 TX_POWER_DEFAULT);
2369 psessionEntry->maxTxPower = TX_POWER_DEFAULT;
2370 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002371#if defined WLAN_VOWIFI_DEBUG
Abhishek Singh57aebef2014-02-03 18:47:44 +05302372 limLog( pMac, LOGE, "Regulatory max = %d, local power constraint "
2373 "= %d, max tx = %d", regMax, localPowerConstraint,
2374 psessionEntry->maxTxPower );
Jeff Johnson295189b2012-06-20 16:38:30 -07002375#endif
2376 {
2377 #if 0
2378 if (wlan_cfgGetStr(pMac, WNI_CFG_SSID, pMac->lim.gLimReassocSSID.ssId,
2379 &cfgLen) != eSIR_SUCCESS)
2380 {
2381 /// Could not get SSID from CFG. Log error.
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002382 limLog(pMac, LOGP, FL("could not retrive SSID"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002383 }
2384 #endif//TO SUPPORT BT-AMP
2385
2386 /* Copy the SSID from sessio entry to local variable */
2387 #if 0
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302388 vos_mem_copy( pMac->lim.gLimReassocSSID.ssId,
Jeff Johnson295189b2012-06-20 16:38:30 -07002389 psessionEntry->ssId.ssId,
2390 psessionEntry->ssId.length);
2391 #endif
2392 psessionEntry->limReassocSSID.length = pReassocReq->ssId.length;
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302393 vos_mem_copy( psessionEntry->limReassocSSID.ssId,
Jeff Johnson295189b2012-06-20 16:38:30 -07002394 pReassocReq->ssId.ssId, psessionEntry->limReassocSSID.length);
2395
2396 }
2397
2398 if (pMac->lim.gLimCurrentBssUapsd)
2399 {
2400 pMac->lim.gUapsdPerAcBitmask = psessionEntry->pLimReAssocReq->uapsdPerAcBitmask;
Abhishek Singh57aebef2014-02-03 18:47:44 +05302401 limLog( pMac, LOG1, FL("UAPSD flag for all AC - 0x%2x"),
2402 pMac->lim.gUapsdPerAcBitmask);
Jeff Johnson295189b2012-06-20 16:38:30 -07002403 }
2404
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302405 pMlmReassocReq = vos_mem_malloc(sizeof(tLimMlmReassocReq));
2406 if ( NULL == pMlmReassocReq )
Jeff Johnson295189b2012-06-20 16:38:30 -07002407 {
2408 // Log error
2409 limLog(pMac, LOGP,
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302410 FL("call to AllocateMemory failed for mlmReassocReq"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002411
2412 retCode = eSIR_SME_RESOURCES_UNAVAILABLE;
2413 goto end;
2414 }
2415
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302416 vos_mem_copy( pMlmReassocReq->peerMacAddr,
Jeff Johnson295189b2012-06-20 16:38:30 -07002417 psessionEntry->limReAssocbssId,
2418 sizeof(tSirMacAddr));
2419
2420 if (wlan_cfgGetInt(pMac, WNI_CFG_REASSOCIATION_FAILURE_TIMEOUT,
2421 (tANI_U32 *) &pMlmReassocReq->reassocFailureTimeout)
2422 != eSIR_SUCCESS)
2423 {
2424 /**
2425 * Could not get ReassocFailureTimeout value
2426 * from CFG. Log error.
2427 */
2428 limLog(pMac, LOGP,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002429 FL("could not retrieve ReassocFailureTimeout value"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002430 }
2431
2432 if (cfgGetCapabilityInfo(pMac, &caps,psessionEntry) != eSIR_SUCCESS)
2433 {
2434 /**
2435 * Could not get Capabilities value
2436 * from CFG. Log error.
2437 */
2438 limLog(pMac, LOGP,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002439 FL("could not retrieve Capabilities value"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002440 }
2441 pMlmReassocReq->capabilityInfo = caps;
2442
2443 /* Update PE sessionId*/
2444 pMlmReassocReq->sessionId = sessionId;
2445
2446 /* If telescopic beaconing is enabled, set listen interval to
2447 WNI_CFG_TELE_BCN_MAX_LI */
2448 if(wlan_cfgGetInt(pMac, WNI_CFG_TELE_BCN_WAKEUP_EN, &teleBcnEn) !=
2449 eSIR_SUCCESS)
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002450 limLog(pMac, LOGP, FL("Couldn't get WNI_CFG_TELE_BCN_WAKEUP_EN"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002451
2452 val = WNI_CFG_LISTEN_INTERVAL_STADEF;
2453
2454 if(teleBcnEn)
2455 {
2456 if(wlan_cfgGetInt(pMac, WNI_CFG_TELE_BCN_MAX_LI, &val) !=
2457 eSIR_SUCCESS)
2458 {
2459 /**
2460 * Could not get ListenInterval value
2461 * from CFG. Log error.
2462 */
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002463 limLog(pMac, LOGP, FL("could not retrieve ListenInterval"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002464 }
2465 }
2466 else
2467 {
2468 if (wlan_cfgGetInt(pMac, WNI_CFG_LISTEN_INTERVAL, &val) != eSIR_SUCCESS)
2469 {
2470 /**
2471 * Could not get ListenInterval value
2472 * from CFG. Log error.
2473 */
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002474 limLog(pMac, LOGP, FL("could not retrieve ListenInterval"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002475 }
2476 }
2477
2478 /* Delete all BA sessions before Re-Assoc.
2479 * BA frames are class 3 frames and the session
2480 * is lost upon disassociation and reassociation.
2481 */
2482
Ganesh Kondabattini01f75c92014-07-07 19:27:41 +05302483 limDeleteBASessions(pMac, psessionEntry, BA_BOTH_DIRECTIONS,
2484 eSIR_MAC_UNSPEC_FAILURE_REASON);
Jeff Johnson295189b2012-06-20 16:38:30 -07002485
2486 pMlmReassocReq->listenInterval = (tANI_U16) val;
2487
2488 /* Indicate whether spectrum management is enabled*/
2489 psessionEntry->spectrumMgtEnabled = pReassocReq->spectrumMgtIndicator;
2490
Rajesh Babu Prathipati043149f2014-06-06 13:33:45 +05302491 /* Enable the spectrum management if this is a DFS channel */
2492 if (psessionEntry->countryInfoPresent &&
2493 limIsconnectedOnDFSChannel(psessionEntry->currentOperChannel))
2494 {
2495 psessionEntry->spectrumMgtEnabled = TRUE;
2496 }
2497
Jeff Johnson295189b2012-06-20 16:38:30 -07002498 psessionEntry->limPrevSmeState = psessionEntry->limSmeState;
2499 psessionEntry->limSmeState = eLIM_SME_WT_REASSOC_STATE;
2500
Jeff Johnsone7245742012-09-05 17:12:55 -07002501 MTRACE(macTrace(pMac, TRACE_CODE_SME_STATE, psessionEntry->peSessionId, psessionEntry->limSmeState));
Jeff Johnson295189b2012-06-20 16:38:30 -07002502
2503 limPostMlmMessage(pMac,
2504 LIM_MLM_REASSOC_REQ,
2505 (tANI_U32 *) pMlmReassocReq);
2506 return;
2507
2508end:
2509 if (pReassocReq)
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302510 vos_mem_free( pReassocReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07002511
2512 if (psessionEntry)
2513 {
2514 // error occurred after we determined the session so extract
2515 // session and transaction info from there
2516 smeSessionId = psessionEntry->smeSessionId;
2517 transactionId = psessionEntry->transactionId;
2518 }
2519 else
2520 {
2521 // error occurred before or during the time we determined the session
2522 // so extract the session and transaction info from the message
2523 limGetSessionInfo(pMac,(tANI_U8*)pMsgBuf, &smeSessionId, &transactionId);
2524 }
2525
2526 /// Send Reassoc failure response to host
2527 /// (note psessionEntry may be NULL, but that's OK)
2528 limSendSmeJoinReassocRsp(pMac, eWNI_SME_REASSOC_RSP,
2529 retCode, eSIR_MAC_UNSPEC_FAILURE_STATUS,
2530 psessionEntry, smeSessionId, transactionId);
2531
2532} /*** end __limProcessSmeReassocReq() ***/
2533
2534
2535tANI_BOOLEAN sendDisassocFrame = 1;
2536/**
2537 * __limProcessSmeDisassocReq()
2538 *
2539 *FUNCTION:
2540 * This function is called to process SME_DISASSOC_REQ message
2541 * from HDD or upper layer application.
2542 *
2543 *LOGIC:
2544 *
2545 *ASSUMPTIONS:
2546 *
2547 *NOTE:
2548 *
2549 * @param pMac Pointer to Global MAC structure
2550 * @param *pMsgBuf A pointer to the SME message buffer
2551 * @return None
2552 */
2553
2554static void
2555__limProcessSmeDisassocReq(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
2556{
2557 tANI_U16 disassocTrigger, reasonCode;
2558 tLimMlmDisassocReq *pMlmDisassocReq;
2559 tSirResultCodes retCode = eSIR_SME_SUCCESS;
Jeff Johnson43971f52012-07-17 12:26:56 -07002560 tSirRetStatus status;
Jeff Johnson295189b2012-06-20 16:38:30 -07002561 tSirSmeDisassocReq smeDisassocReq;
2562 tpPESession psessionEntry = NULL;
2563 tANI_U8 sessionId;
2564 tANI_U8 smesessionId;
2565 tANI_U16 smetransactionId;
2566
Jeff Johnson295189b2012-06-20 16:38:30 -07002567
Jeff Johnson43971f52012-07-17 12:26:56 -07002568 if (pMsgBuf == NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -07002569 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002570 limLog(pMac, LOGE, FL("Buffer is Pointing to NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002571 return;
2572 }
2573
Jeff Johnson43971f52012-07-17 12:26:56 -07002574 limGetSessionInfo(pMac, (tANI_U8 *)pMsgBuf,&smesessionId, &smetransactionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07002575
Jeff Johnson43971f52012-07-17 12:26:56 -07002576 status = limDisassocReqSerDes(pMac, &smeDisassocReq, (tANI_U8 *) pMsgBuf);
Jeff Johnson295189b2012-06-20 16:38:30 -07002577
Jeff Johnson43971f52012-07-17 12:26:56 -07002578 if ( (eSIR_FAILURE == status) ||
2579 (!limIsSmeDisassocReqValid(pMac, &smeDisassocReq, psessionEntry)) )
Jeff Johnson295189b2012-06-20 16:38:30 -07002580 {
2581 PELOGE(limLog(pMac, LOGE,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002582 FL("received invalid SME_DISASSOC_REQ message"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07002583
2584 if (pMac->lim.gLimRspReqd)
2585 {
2586 pMac->lim.gLimRspReqd = false;
2587
2588 retCode = eSIR_SME_INVALID_PARAMETERS;
2589 disassocTrigger = eLIM_HOST_DISASSOC;
2590 goto sendDisassoc;
2591 }
2592
2593 return;
2594 }
2595
Jeff Johnson295189b2012-06-20 16:38:30 -07002596 if((psessionEntry = peFindSessionByBssid(pMac,smeDisassocReq.bssId,&sessionId))== NULL)
2597 {
Abhishek Singhcd09b562013-12-24 16:02:20 +05302598 limLog(pMac, LOGE,FL("session does not exist for given bssId "MAC_ADDRESS_STR),
2599 MAC_ADDR_ARRAY(smeDisassocReq.bssId));
Jeff Johnson295189b2012-06-20 16:38:30 -07002600 retCode = eSIR_SME_INVALID_PARAMETERS;
2601 disassocTrigger = eLIM_HOST_DISASSOC;
2602 goto sendDisassoc;
2603
2604 }
Abhishek Singhcd09b562013-12-24 16:02:20 +05302605 limLog(pMac, LOG1, FL("received DISASSOC_REQ message on sessionid %d"
2606 "Systemrole %d Reason: %u SmeState: %d from: "MAC_ADDRESS_STR),
2607 smesessionId,psessionEntry->limSystemRole,
2608 smeDisassocReq.reasonCode, pMac->lim.gLimSmeState,
2609 MAC_ADDR_ARRAY(smeDisassocReq.peerMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07002610
2611#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM //FEATURE_WLAN_DIAG_SUPPORT
2612 limDiagEventReport(pMac, WLAN_PE_DIAG_DISASSOC_REQ_EVENT, psessionEntry, 0, smeDisassocReq.reasonCode);
2613#endif //FEATURE_WLAN_DIAG_SUPPORT
2614
2615 /* Update SME session Id and SME transaction ID*/
2616
2617 psessionEntry->smeSessionId = smesessionId;
2618 psessionEntry->transactionId = smetransactionId;
2619
2620 switch (psessionEntry->limSystemRole)
2621 {
2622 case eLIM_STA_ROLE:
2623 case eLIM_BT_AMP_STA_ROLE:
2624 switch (psessionEntry->limSmeState)
2625 {
2626 case eLIM_SME_ASSOCIATED_STATE:
2627 case eLIM_SME_LINK_EST_STATE:
Kanchanapally, Vidyullathac796fc62015-03-17 10:45:28 +05302628 limLog(pMac, LOG1, FL("Rcvd SME_DISASSOC_REQ while in "
2629 "limSmeState: %d "),psessionEntry->limSmeState);
2630
Jeff Johnson295189b2012-06-20 16:38:30 -07002631 psessionEntry->limPrevSmeState = psessionEntry->limSmeState;
2632 psessionEntry->limSmeState= eLIM_SME_WT_DISASSOC_STATE;
Hoonki Lee8c9e99f2013-04-18 22:59:11 -07002633#ifdef FEATURE_WLAN_TDLS
2634 /* Delete all TDLS peers connected before leaving BSS*/
2635 limDeleteTDLSPeers(pMac, psessionEntry);
2636#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07002637 MTRACE(macTrace(pMac, TRACE_CODE_SME_STATE, psessionEntry->peSessionId, psessionEntry->limSmeState));
Jeff Johnson295189b2012-06-20 16:38:30 -07002638 break;
2639
2640 case eLIM_SME_WT_DEAUTH_STATE:
2641 /* PE shall still process the DISASSOC_REQ and proceed with
2642 * link tear down even if it had already sent a DEAUTH_IND to
2643 * to SME. pMac->lim.gLimPrevSmeState shall remain the same as
2644 * its been set when PE entered WT_DEAUTH_STATE.
2645 */
2646 psessionEntry->limSmeState= eLIM_SME_WT_DISASSOC_STATE;
Jeff Johnsone7245742012-09-05 17:12:55 -07002647 MTRACE(macTrace(pMac, TRACE_CODE_SME_STATE, psessionEntry->peSessionId, psessionEntry->limSmeState));
Abhishek Singhcd09b562013-12-24 16:02:20 +05302648 limLog(pMac, LOG1, FL("Rcvd SME_DISASSOC_REQ while in "
2649 "SME_WT_DEAUTH_STATE. "));
Jeff Johnson295189b2012-06-20 16:38:30 -07002650 break;
2651
2652 case eLIM_SME_WT_DISASSOC_STATE:
2653 /* PE Recieved a Disassoc frame. Normally it gets DISASSOC_CNF but it
2654 * received DISASSOC_REQ. Which means host is also trying to disconnect.
2655 * PE can continue processing DISASSOC_REQ and send the response instead
2656 * of failing the request. SME will anyway ignore DEAUTH_IND that was sent
2657 * for disassoc frame.
2658 *
2659 * It will send a disassoc, which is ok. However, we can use the global flag
2660 * sendDisassoc to not send disassoc frame.
2661 */
Abhishek Singhcd09b562013-12-24 16:02:20 +05302662 limLog(pMac, LOG1, FL("Rcvd SME_DISASSOC_REQ while in "
2663 "SME_WT_DISASSOC_STATE. "));
Jeff Johnson295189b2012-06-20 16:38:30 -07002664 break;
2665
2666 case eLIM_SME_JOIN_FAILURE_STATE: {
2667 /** Return Success as we are already in Disconnected State*/
Abhishek Singhcd09b562013-12-24 16:02:20 +05302668 limLog(pMac, LOG1, FL("Rcvd SME_DISASSOC_REQ while in "
2669 "eLIM_SME_JOIN_FAILURE_STATE. "));
Jeff Johnson295189b2012-06-20 16:38:30 -07002670 if (pMac->lim.gLimRspReqd) {
2671 retCode = eSIR_SME_SUCCESS;
2672 disassocTrigger = eLIM_HOST_DISASSOC;
2673 goto sendDisassoc;
2674 }
2675 }break;
2676 default:
2677 /**
2678 * STA is not currently associated.
2679 * Log error and send response to host
2680 */
2681 limLog(pMac, LOGE,
Sushant Kaushik1b645382014-10-13 16:39:36 +05302682 FL("received unexpected SME_DISASSOC_REQ in state %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002683 psessionEntry->limSmeState);
2684 limPrintSmeState(pMac, LOGE, psessionEntry->limSmeState);
2685
2686 if (pMac->lim.gLimRspReqd)
2687 {
2688 if (psessionEntry->limSmeState !=
2689 eLIM_SME_WT_ASSOC_STATE)
2690 pMac->lim.gLimRspReqd = false;
2691
2692 retCode = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
2693 disassocTrigger = eLIM_HOST_DISASSOC;
2694 goto sendDisassoc;
2695 }
2696
2697 return;
2698 }
2699
2700 break;
2701
2702 case eLIM_AP_ROLE:
2703 case eLIM_BT_AMP_AP_ROLE:
2704 // Fall through
2705 break;
2706
2707 case eLIM_STA_IN_IBSS_ROLE:
2708 default: // eLIM_UNKNOWN_ROLE
2709 limLog(pMac, LOGE,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002710 FL("received unexpected SME_DISASSOC_REQ for role %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002711 psessionEntry->limSystemRole);
2712
2713 retCode = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
2714 disassocTrigger = eLIM_HOST_DISASSOC;
2715 goto sendDisassoc;
2716 } // end switch (pMac->lim.gLimSystemRole)
2717
Edhar, Mahesh Kumar03cf7ff2015-11-26 17:59:29 +05302718 disassocTrigger = eLIM_HOST_DISASSOC;
2719 reasonCode = smeDisassocReq.reasonCode;
Jeff Johnson295189b2012-06-20 16:38:30 -07002720
2721 if (smeDisassocReq.doNotSendOverTheAir)
2722 {
Abhishek Singhcd09b562013-12-24 16:02:20 +05302723 limLog(pMac, LOG1, FL("do not send dissoc over the air"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002724 sendDisassocFrame = 0;
2725 }
2726 // Trigger Disassociation frame to peer MAC entity
Sachin Ahuja2fea3d12014-12-18 17:31:31 +05302727 limLog(pMac, LOG1, FL("Sending Disasscoc with disassoc Trigger"
2728 " : %d, reasonCode : %d"),
2729 disassocTrigger, reasonCode);
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302730 pMlmDisassocReq = vos_mem_malloc(sizeof(tLimMlmDisassocReq));
2731 if ( NULL == pMlmDisassocReq )
Jeff Johnson295189b2012-06-20 16:38:30 -07002732 {
2733 // Log error
2734 limLog(pMac, LOGP,
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302735 FL("call to AllocateMemory failed for mlmDisassocReq"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002736
2737 return;
2738 }
2739
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302740 vos_mem_copy( (tANI_U8 *) &pMlmDisassocReq->peerMacAddr,
Jeff Johnson295189b2012-06-20 16:38:30 -07002741 (tANI_U8 *) &smeDisassocReq.peerMacAddr,
2742 sizeof(tSirMacAddr));
2743
2744 pMlmDisassocReq->reasonCode = reasonCode;
2745 pMlmDisassocReq->disassocTrigger = disassocTrigger;
2746
2747 /* Update PE session ID*/
2748 pMlmDisassocReq->sessionId = sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -07002749
2750 limPostMlmMessage(pMac,
2751 LIM_MLM_DISASSOC_REQ,
2752 (tANI_U32 *) pMlmDisassocReq);
2753 return;
2754
2755sendDisassoc:
2756 if (psessionEntry)
2757 limSendSmeDisassocNtf(pMac, smeDisassocReq.peerMacAddr,
2758 retCode,
2759 disassocTrigger,
Jeff Johnson295189b2012-06-20 16:38:30 -07002760 1,smesessionId,smetransactionId,psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07002761 else
2762 limSendSmeDisassocNtf(pMac, smeDisassocReq.peerMacAddr,
2763 retCode,
2764 disassocTrigger,
Sudhir Sattayappa Kohalli5a8ac222013-03-06 12:41:42 -08002765 1, smesessionId, smetransactionId, NULL);
Jeff Johnson295189b2012-06-20 16:38:30 -07002766
2767
2768} /*** end __limProcessSmeDisassocReq() ***/
2769
2770
2771/** -----------------------------------------------------------------
2772 \brief __limProcessSmeDisassocCnf() - Process SME_DISASSOC_CNF
2773
2774 This function is called to process SME_DISASSOC_CNF message
2775 from HDD or upper layer application.
2776
2777 \param pMac - global mac structure
2778 \param pStaDs - station dph hash node
2779 \return none
2780 \sa
2781 ----------------------------------------------------------------- */
2782static void
2783__limProcessSmeDisassocCnf(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
2784{
2785 tSirSmeDisassocCnf smeDisassocCnf;
2786 tANI_U16 aid;
2787 tpDphHashNode pStaDs;
2788 tSirRetStatus status = eSIR_SUCCESS;
2789 tpPESession psessionEntry;
2790 tANI_U8 sessionId;
2791
2792
Abhishek Singh3cbf6052014-12-15 16:46:42 +05302793 limLog(pMac, LOG1, FL("received SME_DISASSOC_CNF message"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002794
2795 status = limDisassocCnfSerDes(pMac, &smeDisassocCnf,(tANI_U8 *) pMsgBuf);
2796
2797 if (status == eSIR_FAILURE)
2798 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002799 PELOGE(limLog(pMac, LOGE, FL("invalid SME_DISASSOC_CNF message"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07002800 return;
2801 }
2802
2803 if((psessionEntry = peFindSessionByBssid(pMac, smeDisassocCnf.bssId, &sessionId))== NULL)
2804 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002805 limLog(pMac, LOGE,FL("session does not exist for given bssId"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002806 return;
2807 }
2808
2809 if (!limIsSmeDisassocCnfValid(pMac, &smeDisassocCnf, psessionEntry))
2810 {
Abhishek Singhcd09b562013-12-24 16:02:20 +05302811 limLog(pMac, LOGE, FL("received invalid SME_DISASSOC_CNF message"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002812 return;
2813 }
2814
2815#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM //FEATURE_WLAN_DIAG_SUPPORT
2816 if (smeDisassocCnf.messageType == eWNI_SME_DISASSOC_CNF)
2817 limDiagEventReport(pMac, WLAN_PE_DIAG_DISASSOC_CNF_EVENT, psessionEntry, (tANI_U16)smeDisassocCnf.statusCode, 0);
2818 else if (smeDisassocCnf.messageType == eWNI_SME_DEAUTH_CNF)
2819 limDiagEventReport(pMac, WLAN_PE_DIAG_DEAUTH_CNF_EVENT, psessionEntry, (tANI_U16)smeDisassocCnf.statusCode, 0);
2820#endif //FEATURE_WLAN_DIAG_SUPPORT
2821
2822 switch (psessionEntry->limSystemRole)
2823 {
2824 case eLIM_STA_ROLE:
2825 case eLIM_BT_AMP_STA_ROLE: //To test reconn
2826 if ((psessionEntry->limSmeState != eLIM_SME_IDLE_STATE) &&
2827 (psessionEntry->limSmeState != eLIM_SME_WT_DISASSOC_STATE) &&
2828 (psessionEntry->limSmeState != eLIM_SME_WT_DEAUTH_STATE))
2829 {
2830 limLog(pMac, LOGE,
Sushant Kaushik1b645382014-10-13 16:39:36 +05302831 FL("received unexp SME_DISASSOC_CNF in state %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002832 psessionEntry->limSmeState);
2833 limPrintSmeState(pMac, LOGE, psessionEntry->limSmeState);
2834 return;
2835 }
2836 break;
2837
2838 case eLIM_AP_ROLE:
2839 // Fall through
Jeff Johnson295189b2012-06-20 16:38:30 -07002840 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07002841
2842 case eLIM_STA_IN_IBSS_ROLE:
2843 default: // eLIM_UNKNOWN_ROLE
2844 limLog(pMac, LOGE,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002845 FL("received unexpected SME_DISASSOC_CNF role %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002846 psessionEntry->limSystemRole);
2847
2848 return;
2849 }
2850
2851
2852 if ( (psessionEntry->limSmeState == eLIM_SME_WT_DISASSOC_STATE) ||
2853 (psessionEntry->limSmeState == eLIM_SME_WT_DEAUTH_STATE)
Jeff Johnson295189b2012-06-20 16:38:30 -07002854 || (psessionEntry->limSystemRole == eLIM_AP_ROLE )
Jeff Johnson295189b2012-06-20 16:38:30 -07002855 )
2856 {
2857 pStaDs = dphLookupHashEntry(pMac, smeDisassocCnf.peerMacAddr, &aid, &psessionEntry->dph.dphHashTable);
2858 if (pStaDs == NULL)
2859 {
Abhishek Singhcd09b562013-12-24 16:02:20 +05302860 PELOGE(limLog(pMac, LOGE, FL("received DISASSOC_CNF for a STA that "
2861 "does not have context, addr= "MAC_ADDRESS_STR),
2862 MAC_ADDR_ARRAY(smeDisassocCnf.peerMacAddr));)
Jeff Johnson295189b2012-06-20 16:38:30 -07002863 return;
2864 }
Wu Gao742b7352015-10-16 19:10:40 +08002865
2866 if(aid != smeDisassocCnf.assocId)
2867 {
2868 PELOGE(limLog(pMac, LOGE, FL("same peerMacAddr but assocId is different "
2869 "aid=%d, assocId=%d, addr= "MAC_ADDRESS_STR),
2870 aid, smeDisassocCnf.assocId, MAC_ADDR_ARRAY(smeDisassocCnf.peerMacAddr));)
2871 return;
2872 }
Padma, Santhosh Kumar05600d32015-07-24 13:00:57 +05302873 /*
2874 * If MlM state is either of del_sta or del_bss state, then no need to
2875 * go ahead and clean up further as there must be some cleanup in
2876 * progress from upper layer disassoc/deauth request.
2877 */
2878 if((pStaDs->mlmStaContext.mlmState == eLIM_MLM_WT_DEL_STA_RSP_STATE) ||
2879 (pStaDs->mlmStaContext.mlmState == eLIM_MLM_WT_DEL_BSS_RSP_STATE))
2880 {
2881 limLog(pMac, LOGE, FL("No need to cleanup for addr:"MAC_ADDRESS_STR
2882 "as Mlm state is %d"),
2883 MAC_ADDR_ARRAY(smeDisassocCnf.peerMacAddr),
2884 pStaDs->mlmStaContext.mlmState);
2885 return;
2886 }
2887
Madan Mohan Koyyalamudi23001722012-10-31 16:48:56 -07002888 /* Delete FT session if there exists one */
2889 limFTCleanup(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -07002890 limCleanupRxPath(pMac, pStaDs, psessionEntry);
Madan Mohan Koyyalamudia67d4332012-11-29 11:35:23 -08002891
2892 limCleanUpDisassocDeauthReq(pMac, (char*)&smeDisassocCnf.peerMacAddr, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07002893 }
2894
2895 return;
2896}
2897
2898
2899/**
2900 * __limProcessSmeDeauthReq()
2901 *
2902 *FUNCTION:
2903 * This function is called to process SME_DEAUTH_REQ message
2904 * from HDD or upper layer application.
2905 *
2906 *LOGIC:
2907 *
2908 *ASSUMPTIONS:
2909 *
2910 *NOTE:
2911 *
2912 * @param pMac Pointer to Global MAC structure
2913 * @param *pMsgBuf A pointer to the SME message buffer
2914 * @return None
2915 */
2916
2917static void
2918__limProcessSmeDeauthReq(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
2919{
2920 tANI_U16 deauthTrigger, reasonCode;
2921 tLimMlmDeauthReq *pMlmDeauthReq;
2922 tSirSmeDeauthReq smeDeauthReq;
2923 tSirResultCodes retCode = eSIR_SME_SUCCESS;
2924 tSirRetStatus status = eSIR_SUCCESS;
2925 tpPESession psessionEntry;
2926 tANI_U8 sessionId; //PE sessionId
2927 tANI_U8 smesessionId;
2928 tANI_U16 smetransactionId;
2929
Jeff Johnson295189b2012-06-20 16:38:30 -07002930
2931 status = limDeauthReqSerDes(pMac, &smeDeauthReq,(tANI_U8 *) pMsgBuf);
Jeff Johnson295189b2012-06-20 16:38:30 -07002932 limGetSessionInfo(pMac,(tANI_U8 *)pMsgBuf,&smesessionId,&smetransactionId);
2933
2934 //We need to get a session first but we don't even know if the message is correct.
2935 if((psessionEntry = peFindSessionByBssid(pMac, smeDeauthReq.bssId, &sessionId)) == NULL)
2936 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002937 limLog(pMac, LOGE,FL("session does not exist for given bssId"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002938 retCode = eSIR_SME_INVALID_PARAMETERS;
2939 deauthTrigger = eLIM_HOST_DEAUTH;
2940 goto sendDeauth;
2941
2942 }
2943
2944 if ((status == eSIR_FAILURE) || (!limIsSmeDeauthReqValid(pMac, &smeDeauthReq, psessionEntry)))
2945 {
Sachin Ahuja42354142015-01-06 19:48:35 +05302946 PELOGE(limLog(pMac, LOGE,FL
2947 ("received invalid SME_DEAUTH_REQ message"));)
2948 pMac->lim.gLimRspReqd = false;
Jeff Johnson295189b2012-06-20 16:38:30 -07002949
Sachin Ahuja42354142015-01-06 19:48:35 +05302950 retCode = eSIR_SME_INVALID_PARAMETERS;
2951 deauthTrigger = eLIM_HOST_DEAUTH;
2952 goto sendDeauth;
Jeff Johnson295189b2012-06-20 16:38:30 -07002953 }
Abhishek Singhcd09b562013-12-24 16:02:20 +05302954 limLog(pMac, LOG1,FL("received DEAUTH_REQ message on sessionid %d "
2955 "Systemrole %d with reasoncode %u in limSmestate %d from "
2956 MAC_ADDRESS_STR), smesessionId, psessionEntry->limSystemRole,
2957 smeDeauthReq.reasonCode, psessionEntry->limSmeState,
2958 MAC_ADDR_ARRAY(smeDeauthReq.peerMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07002959#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM //FEATURE_WLAN_DIAG_SUPPORT
2960 limDiagEventReport(pMac, WLAN_PE_DIAG_DEAUTH_REQ_EVENT, psessionEntry, 0, smeDeauthReq.reasonCode);
2961#endif //FEATURE_WLAN_DIAG_SUPPORT
2962
2963 /* Update SME session ID and Transaction ID */
2964 psessionEntry->smeSessionId = smesessionId;
2965 psessionEntry->transactionId = smetransactionId;
2966
2967
2968 switch (psessionEntry->limSystemRole)
2969 {
2970 case eLIM_STA_ROLE:
2971 case eLIM_BT_AMP_STA_ROLE:
2972
2973 switch (psessionEntry->limSmeState)
2974 {
2975 case eLIM_SME_ASSOCIATED_STATE:
2976 case eLIM_SME_LINK_EST_STATE:
2977 case eLIM_SME_WT_ASSOC_STATE:
2978 case eLIM_SME_JOIN_FAILURE_STATE:
2979 case eLIM_SME_IDLE_STATE:
2980 psessionEntry->limPrevSmeState = psessionEntry->limSmeState;
2981 psessionEntry->limSmeState = eLIM_SME_WT_DEAUTH_STATE;
Varun Reddy Yeturue3bbf6e2013-02-08 18:50:55 -08002982 MTRACE(macTrace(pMac, TRACE_CODE_SME_STATE, psessionEntry->peSessionId, psessionEntry->limSmeState));
Jeff Johnson295189b2012-06-20 16:38:30 -07002983
2984 // Send Deauthentication request to MLM below
2985
2986 break;
Sachin Ahujaa100dcc2014-07-03 14:30:18 +05302987 case eLIM_SME_WT_DEAUTH_STATE:
2988 /*
2989 * PE Recieved a Deauth frame. Normally it gets
2990 * DEAUTH_CNF but it received DEAUTH_REQ. Which
2991 * means host is also trying to disconnect.
2992 * PE can continue processing DEAUTH_REQ and send
2993 * the response instead of failing the request.
2994 * SME will anyway ignore DEAUTH_IND that was sent
2995 * for deauth frame.
2996 */
2997 limLog(pMac, LOG1, FL("Rcvd SME_DEAUTH_REQ while in "
2998 "SME_WT_DEAUTH_STATE. "));
2999 break;
Padma, Santhosh Kumar05600d32015-07-24 13:00:57 +05303000 case eLIM_SME_WT_DISASSOC_STATE:
3001 /*
3002 * PE Recieved a Disassoc frame. Normally it gets
3003 * DISASSOC_CNF but it received DEAUTH_REQ. This means
3004 * host is also trying to disconnect.
3005 */
3006 limLog(pMac, LOG1, FL("Rcvd SME_DEAUTH_REQ while in "
3007 "SME_WT_DISASSOC_STATE. "));
3008 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003009 default:
3010 /**
3011 * STA is not in a state to deauthenticate with
3012 * peer. Log error and send response to host.
3013 */
3014 limLog(pMac, LOGE,
Sushant Kaushik1b645382014-10-13 16:39:36 +05303015 FL("received unexp SME_DEAUTH_REQ in state %d"),
Abhishek Singhcd09b562013-12-24 16:02:20 +05303016 psessionEntry->limSmeState);
Jeff Johnson295189b2012-06-20 16:38:30 -07003017 limPrintSmeState(pMac, LOGE, psessionEntry->limSmeState);
3018
3019 if (pMac->lim.gLimRspReqd)
3020 {
3021 pMac->lim.gLimRspReqd = false;
3022
3023 retCode = eSIR_SME_STA_NOT_AUTHENTICATED;
3024 deauthTrigger = eLIM_HOST_DEAUTH;
Leela Venkata Kiran Kumar Reddy Chirala56df73f2014-01-30 14:18:00 -08003025 /**
3026 *here we received deauth request from AP so sme state is
3027 eLIM_SME_WT_DEAUTH_STATE.if we have ISSUED delSta then
3028 mlm state should be eLIM_MLM_WT_DEL_STA_RSP_STATE and if
3029 we got delBSS rsp then mlm state should be eLIM_MLM_IDLE_STATE
3030 so the below condition captures the state where delSta
3031 not done and firmware still in connected state.
3032 */
3033 if (psessionEntry->limSmeState == eLIM_SME_WT_DEAUTH_STATE &&
3034 psessionEntry->limMlmState != eLIM_MLM_IDLE_STATE &&
3035 psessionEntry->limMlmState != eLIM_MLM_WT_DEL_STA_RSP_STATE)
3036 {
3037 retCode = eSIR_SME_DEAUTH_STATUS;
3038 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003039 goto sendDeauth;
3040 }
3041
3042 return;
3043 }
3044
3045 break;
3046
3047 case eLIM_STA_IN_IBSS_ROLE:
Abhishek Singh92fbac22015-03-24 17:57:36 +05303048 limLog(pMac, LOGE,FL("Deauth not allowed in IBSS"));
3049 if (pMac->lim.gLimRspReqd)
3050 {
3051 pMac->lim.gLimRspReqd = false;
3052 retCode = eSIR_SME_INVALID_PARAMETERS;
3053 deauthTrigger = eLIM_HOST_DEAUTH;
3054 goto sendDeauth;
3055 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003056 return;
3057
3058 case eLIM_AP_ROLE:
3059 // Fall through
3060
3061 break;
3062
3063 default:
3064 limLog(pMac, LOGE,
Sushant Kaushik1b645382014-10-13 16:39:36 +05303065 FL("received unexpected SME_DEAUTH_REQ for role %d"),
Abhishek Singhcd09b562013-12-24 16:02:20 +05303066 psessionEntry->limSystemRole);
Abhishek Singh92fbac22015-03-24 17:57:36 +05303067 if (pMac->lim.gLimRspReqd)
3068 {
3069 pMac->lim.gLimRspReqd = false;
Jeff Johnson295189b2012-06-20 16:38:30 -07003070
Abhishek Singh92fbac22015-03-24 17:57:36 +05303071 retCode = eSIR_SME_INVALID_PARAMETERS;
3072 deauthTrigger = eLIM_HOST_DEAUTH;
3073 goto sendDeauth;
3074 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003075 return;
Abhishek Singh92fbac22015-03-24 17:57:36 +05303076
Jeff Johnson295189b2012-06-20 16:38:30 -07003077 } // end switch (pMac->lim.gLimSystemRole)
3078
3079 if (smeDeauthReq.reasonCode == eLIM_LINK_MONITORING_DEAUTH)
3080 {
3081 /// Deauthentication is triggered by Link Monitoring
Abhishek Singh3cbf6052014-12-15 16:46:42 +05303082 limLog(pMac, LOG1,
3083 FL("Deauthentication is triggered by Link Monitoring"));
3084 limLog(pMac, LOG1,
3085 FL("Set Trigger to eLIM_LINK_MONITORING_DEAUTH"));
3086 limLog(pMac, LOG1,
3087 FL("and Reason to eSIR_MAC_UNSPEC_FAILURE_REASON"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003088 deauthTrigger = eLIM_LINK_MONITORING_DEAUTH;
3089 reasonCode = eSIR_MAC_UNSPEC_FAILURE_REASON;
3090 }
3091 else
3092 {
3093 deauthTrigger = eLIM_HOST_DEAUTH;
3094 reasonCode = smeDeauthReq.reasonCode;
3095 }
3096
3097 // Trigger Deauthentication frame to peer MAC entity
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303098 pMlmDeauthReq = vos_mem_malloc(sizeof(tLimMlmDeauthReq));
3099 if ( NULL == pMlmDeauthReq )
Jeff Johnson295189b2012-06-20 16:38:30 -07003100 {
3101 // Log error
Abhishek Singh92fbac22015-03-24 17:57:36 +05303102 limLog(pMac, LOGE,
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303103 FL("call to AllocateMemory failed for mlmDeauthReq"));
Abhishek Singh92fbac22015-03-24 17:57:36 +05303104 if (pMac->lim.gLimRspReqd)
3105 {
3106 pMac->lim.gLimRspReqd = false;
3107 retCode = eSIR_SME_RESOURCES_UNAVAILABLE;
3108 deauthTrigger = eLIM_HOST_DEAUTH;
3109 goto sendDeauth;
3110 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003111 return;
3112 }
3113
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303114 vos_mem_copy( (tANI_U8 *) &pMlmDeauthReq->peerMacAddr,
Jeff Johnson295189b2012-06-20 16:38:30 -07003115 (tANI_U8 *) &smeDeauthReq.peerMacAddr,
3116 sizeof(tSirMacAddr));
3117
3118 pMlmDeauthReq->reasonCode = reasonCode;
3119 pMlmDeauthReq->deauthTrigger = deauthTrigger;
Jeff Johnson295189b2012-06-20 16:38:30 -07003120
3121 /* Update PE session Id*/
3122 pMlmDeauthReq->sessionId = sessionId;
3123
3124 limPostMlmMessage(pMac,
3125 LIM_MLM_DEAUTH_REQ,
3126 (tANI_U32 *) pMlmDeauthReq);
3127 return;
3128
3129sendDeauth:
3130 limSendSmeDeauthNtf(pMac, smeDeauthReq.peerMacAddr,
3131 retCode,
3132 deauthTrigger,
Jeff Johnson295189b2012-06-20 16:38:30 -07003133 1,
Jeff Johnson295189b2012-06-20 16:38:30 -07003134 smesessionId, smetransactionId);
3135} /*** end __limProcessSmeDeauthReq() ***/
3136
3137
3138
3139/**
3140 * __limProcessSmeSetContextReq()
3141 *
3142 *FUNCTION:
3143 * This function is called to process SME_SETCONTEXT_REQ message
3144 * from HDD or upper layer application.
3145 *
3146 *LOGIC:
3147 *
3148 *ASSUMPTIONS:
3149 *
3150 *NOTE:
3151 *
3152 * @param pMac Pointer to Global MAC structure
3153 * @param *pMsgBuf A pointer to the SME message buffer
3154 * @return None
3155 */
3156
3157static void
3158__limProcessSmeSetContextReq(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
3159{
3160 tpSirSmeSetContextReq pSetContextReq;
3161 tLimMlmSetKeysReq *pMlmSetKeysReq;
3162 tpPESession psessionEntry;
3163 tANI_U8 sessionId; //PE sessionID
3164 tANI_U8 smesessionId;
3165 tANI_U16 smetransactionId;
3166
3167
3168 PELOG1(limLog(pMac, LOG1,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003169 FL("received SETCONTEXT_REQ message")););
Jeff Johnson295189b2012-06-20 16:38:30 -07003170
3171
3172 if(pMsgBuf == NULL)
3173 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003174 limLog(pMac, LOGE,FL("Buffer is Pointing to NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003175 return;
3176 }
3177
3178 limGetSessionInfo(pMac,(tANI_U8 *)pMsgBuf,&smesessionId,&smetransactionId);
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303179
3180 pSetContextReq = vos_mem_malloc(sizeof(tSirKeys) * SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS);
3181 if ( NULL == pSetContextReq )
Jeff Johnson295189b2012-06-20 16:38:30 -07003182 {
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303183 limLog(pMac, LOGP, FL("call to AllocateMemory failed for pSetContextReq"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003184 return;
3185 }
3186
3187 if ((limSetContextReqSerDes(pMac, pSetContextReq, (tANI_U8 *) pMsgBuf) == eSIR_FAILURE) ||
3188 (!limIsSmeSetContextReqValid(pMac, pSetContextReq)))
3189 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003190 limLog(pMac, LOGW, FL("received invalid SME_SETCONTEXT_REQ message"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003191 goto end;
3192 }
3193
3194 if(pSetContextReq->keyMaterial.numKeys > SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS)
3195 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003196 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 -07003197 limSendSmeSetContextRsp(pMac,
3198 pSetContextReq->peerMacAddr,
Jeff Johnson295189b2012-06-20 16:38:30 -07003199 1,
Jeff Johnson295189b2012-06-20 16:38:30 -07003200 eSIR_SME_INVALID_PARAMETERS,NULL,
3201 smesessionId,smetransactionId);
3202
3203 goto end;
3204 }
3205
3206
3207 if((psessionEntry = peFindSessionByBssid(pMac, pSetContextReq->bssId, &sessionId)) == NULL)
3208 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003209 limLog(pMac, LOGW, FL("Session does not exist for given BSSID"));
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#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM //FEATURE_WLAN_DIAG_SUPPORT
3220 limDiagEventReport(pMac, WLAN_PE_DIAG_SETCONTEXT_REQ_EVENT, psessionEntry, 0, 0);
3221#endif //FEATURE_WLAN_DIAG_SUPPORT
3222
3223
3224 if ((((psessionEntry->limSystemRole == eLIM_STA_ROLE) || (psessionEntry->limSystemRole == eLIM_BT_AMP_STA_ROLE)) &&
3225 (psessionEntry->limSmeState == eLIM_SME_LINK_EST_STATE)) ||
3226 (((psessionEntry->limSystemRole == eLIM_STA_IN_IBSS_ROLE) ||
3227 (psessionEntry->limSystemRole == eLIM_AP_ROLE)|| (psessionEntry->limSystemRole == eLIM_BT_AMP_AP_ROLE)) &&
3228 (psessionEntry->limSmeState == eLIM_SME_NORMAL_STATE)))
3229 {
3230 // Trigger MLM_SETKEYS_REQ
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303231 pMlmSetKeysReq = vos_mem_malloc(sizeof(tLimMlmSetKeysReq));
3232 if ( NULL == pMlmSetKeysReq )
Jeff Johnson295189b2012-06-20 16:38:30 -07003233 {
3234 // Log error
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303235 limLog(pMac, LOGP, FL("call to AllocateMemory failed for mlmSetKeysReq"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003236 goto end;
3237 }
Abhishek Singhb25e8442015-06-23 14:28:05 +05303238 vos_mem_zero(pMlmSetKeysReq,sizeof(tLimMlmSetKeysReq));
Jeff Johnson295189b2012-06-20 16:38:30 -07003239 pMlmSetKeysReq->edType = pSetContextReq->keyMaterial.edType;
3240 pMlmSetKeysReq->numKeys = pSetContextReq->keyMaterial.numKeys;
3241 if(pMlmSetKeysReq->numKeys > SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS)
3242 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003243 limLog(pMac, LOGP, FL("Num of keys exceeded max num of default keys limit"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003244 goto end;
3245 }
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303246 vos_mem_copy( (tANI_U8 *) &pMlmSetKeysReq->peerMacAddr,
Jeff Johnson295189b2012-06-20 16:38:30 -07003247 (tANI_U8 *) &pSetContextReq->peerMacAddr,
3248 sizeof(tSirMacAddr));
3249
Jeff Johnson295189b2012-06-20 16:38:30 -07003250
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303251 vos_mem_copy( (tANI_U8 *) &pMlmSetKeysReq->key,
Jeff Johnson295189b2012-06-20 16:38:30 -07003252 (tANI_U8 *) &pSetContextReq->keyMaterial.key,
3253 sizeof(tSirKeys) * (pMlmSetKeysReq->numKeys ? pMlmSetKeysReq->numKeys : 1));
3254
3255 pMlmSetKeysReq->sessionId = sessionId;
3256#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
3257 PELOG1(limLog(pMac, LOG1,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003258 FL("received SETCONTEXT_REQ message sessionId=%d"), pMlmSetKeysReq->sessionId););
Jeff Johnson295189b2012-06-20 16:38:30 -07003259#endif
3260
Jeff Johnson295189b2012-06-20 16:38:30 -07003261 if(((pSetContextReq->keyMaterial.edType == eSIR_ED_WEP40) || (pSetContextReq->keyMaterial.edType == eSIR_ED_WEP104))
3262 && (psessionEntry->limSystemRole == eLIM_AP_ROLE))
3263 {
3264 if(pSetContextReq->keyMaterial.key[0].keyLength)
3265 {
3266 tANI_U8 keyId;
3267 keyId = pSetContextReq->keyMaterial.key[0].keyId;
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303268 vos_mem_copy( (tANI_U8 *)&psessionEntry->WEPKeyMaterial[keyId],
Jeff Johnson295189b2012-06-20 16:38:30 -07003269 (tANI_U8 *) &pSetContextReq->keyMaterial, sizeof(tSirKeyMaterial));
3270 }
3271 else {
3272 tANI_U32 i;
3273 for( i = 0; i < SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS; i++)
3274 {
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303275 vos_mem_copy( (tANI_U8 *) &pMlmSetKeysReq->key[i],
Jeff Johnson295189b2012-06-20 16:38:30 -07003276 (tANI_U8 *)psessionEntry->WEPKeyMaterial[i].key, sizeof(tSirKeys));
3277 }
3278 }
3279 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003280
3281 limPostMlmMessage(pMac, LIM_MLM_SETKEYS_REQ, (tANI_U32 *) pMlmSetKeysReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07003282 }
3283 else
3284 {
3285 limLog(pMac, LOGE,
Sushant Kaushik1b645382014-10-13 16:39:36 +05303286 FL("received unexpected SME_SETCONTEXT_REQ for role %d, state=%d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07003287 psessionEntry->limSystemRole,
3288 psessionEntry->limSmeState);
3289 limPrintSmeState(pMac, LOGE, psessionEntry->limSmeState);
3290
3291 limSendSmeSetContextRsp(pMac, pSetContextReq->peerMacAddr,
Jeff Johnson295189b2012-06-20 16:38:30 -07003292 1,
Jeff Johnson295189b2012-06-20 16:38:30 -07003293 eSIR_SME_UNEXPECTED_REQ_RESULT_CODE,psessionEntry,
3294 smesessionId,
3295 smetransactionId);
3296 }
3297
3298end:
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05303299 vos_mem_zero(pSetContextReq,
3300 (sizeof(tSirKeys) * SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS));
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303301 vos_mem_free( pSetContextReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07003302 return;
3303} /*** end __limProcessSmeSetContextReq() ***/
3304
3305/**
3306 * __limProcessSmeRemoveKeyReq()
3307 *
3308 *FUNCTION:
3309 * This function is called to process SME_REMOVEKEY_REQ message
3310 * from HDD or upper layer application.
3311 *
3312 *LOGIC:
3313 *
3314 *ASSUMPTIONS:
3315 *
3316 *NOTE:
3317 *
3318 * @param pMac Pointer to Global MAC structure
3319 * @param *pMsgBuf A pointer to the SME message buffer
3320 * @return None
3321 */
3322
3323static void
3324__limProcessSmeRemoveKeyReq(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
3325{
3326 tpSirSmeRemoveKeyReq pRemoveKeyReq;
3327 tLimMlmRemoveKeyReq *pMlmRemoveKeyReq;
3328 tpPESession psessionEntry;
3329 tANI_U8 sessionId; //PE sessionID
3330 tANI_U8 smesessionId;
3331 tANI_U16 smetransactionId;
3332
Abhishek Singh3cbf6052014-12-15 16:46:42 +05303333 limLog(pMac, LOG1,
3334 FL("received SME_REMOVEKEY_REQ message"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003335
3336 if(pMsgBuf == NULL)
3337 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003338 limLog(pMac, LOGE,FL("Buffer is Pointing to NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003339 return;
3340 }
3341
3342
3343 limGetSessionInfo(pMac,(tANI_U8 *)pMsgBuf,&smesessionId,&smetransactionId);
3344
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303345 pRemoveKeyReq = vos_mem_malloc(sizeof(*pRemoveKeyReq));
3346 if ( NULL == pRemoveKeyReq )
Jeff Johnson295189b2012-06-20 16:38:30 -07003347 {
3348 //Log error
3349 limLog(pMac, LOGP,
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303350 FL("call to AllocateMemory failed for pRemoveKeyReq"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003351
3352 return;
3353 }
3354
3355 if ((limRemoveKeyReqSerDes(pMac,
3356 pRemoveKeyReq,
3357 (tANI_U8 *) pMsgBuf) == eSIR_FAILURE))
3358 {
3359 limLog(pMac, LOGW,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003360 FL("received invalid SME_REMOVECONTEXT_REQ message"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003361
3362 /* extra look up is needed since, session entry to be passed il limsendremovekey response */
3363
3364 if((psessionEntry = peFindSessionByBssid(pMac,pRemoveKeyReq->bssId,&sessionId))== NULL)
3365 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003366 limLog(pMac, LOGE,FL("session does not exist for given bssId"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003367 //goto end;
3368 }
3369
3370 limSendSmeRemoveKeyRsp(pMac,
3371 pRemoveKeyReq->peerMacAddr,
3372 eSIR_SME_INVALID_PARAMETERS,psessionEntry,
3373 smesessionId,smetransactionId);
3374
3375 goto end;
3376 }
3377
3378 if((psessionEntry = peFindSessionByBssid(pMac,pRemoveKeyReq->bssId, &sessionId))== NULL)
3379 {
3380 limLog(pMac, LOGE,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003381 FL("session does not exist for given bssId"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003382 limSendSmeRemoveKeyRsp(pMac,
3383 pRemoveKeyReq->peerMacAddr,
3384 eSIR_SME_UNEXPECTED_REQ_RESULT_CODE, NULL,
3385 smesessionId, smetransactionId);
3386 goto end;
3387 }
3388
3389
3390 if ((((psessionEntry->limSystemRole == eLIM_STA_ROLE)|| (psessionEntry->limSystemRole == eLIM_BT_AMP_STA_ROLE))&&
3391 (psessionEntry->limSmeState == eLIM_SME_LINK_EST_STATE)) ||
3392 (((psessionEntry->limSystemRole == eLIM_STA_IN_IBSS_ROLE) ||
3393 (psessionEntry->limSystemRole == eLIM_AP_ROLE)|| (psessionEntry->limSystemRole == eLIM_BT_AMP_AP_ROLE)) &&
3394 (psessionEntry->limSmeState == eLIM_SME_NORMAL_STATE)))
3395 {
3396 // Trigger MLM_REMOVEKEYS_REQ
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303397 pMlmRemoveKeyReq = vos_mem_malloc(sizeof(tLimMlmRemoveKeyReq));
3398 if ( NULL == pMlmRemoveKeyReq )
Jeff Johnson295189b2012-06-20 16:38:30 -07003399 {
3400 // Log error
3401 limLog(pMac, LOGP,
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303402 FL("call to AllocateMemory failed for mlmRemoveKeysReq"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003403
3404 goto end;
3405 }
3406
3407 pMlmRemoveKeyReq->edType = (tAniEdType)pRemoveKeyReq->edType;
3408 pMlmRemoveKeyReq->keyId = pRemoveKeyReq->keyId;
3409 pMlmRemoveKeyReq->wepType = pRemoveKeyReq->wepType;
3410 pMlmRemoveKeyReq->unicast = pRemoveKeyReq->unicast;
3411
3412 /* Update PE session Id */
3413 pMlmRemoveKeyReq->sessionId = sessionId;
3414
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303415 vos_mem_copy( (tANI_U8 *) &pMlmRemoveKeyReq->peerMacAddr,
Jeff Johnson295189b2012-06-20 16:38:30 -07003416 (tANI_U8 *) &pRemoveKeyReq->peerMacAddr,
3417 sizeof(tSirMacAddr));
3418
3419
3420 limPostMlmMessage(pMac,
3421 LIM_MLM_REMOVEKEY_REQ,
3422 (tANI_U32 *) pMlmRemoveKeyReq);
3423 }
3424 else
3425 {
3426 limLog(pMac, LOGE,
Sushant Kaushik1b645382014-10-13 16:39:36 +05303427 FL("received unexpected SME_REMOVEKEY_REQ for role %d, state=%d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07003428 psessionEntry->limSystemRole,
3429 psessionEntry->limSmeState);
3430 limPrintSmeState(pMac, LOGE, psessionEntry->limSmeState);
3431
3432 limSendSmeRemoveKeyRsp(pMac,
3433 pRemoveKeyReq->peerMacAddr,
3434 eSIR_SME_UNEXPECTED_REQ_RESULT_CODE,psessionEntry,
3435 smesessionId,smetransactionId);
3436 }
3437
3438end:
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303439 vos_mem_free( pRemoveKeyReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07003440} /*** end __limProcessSmeRemoveKeyReq() ***/
3441
Jeff Johnson295189b2012-06-20 16:38:30 -07003442void limProcessSmeGetScanChannelInfo(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
3443{
3444 tSirMsgQ mmhMsg;
3445 tpSmeGetScanChnRsp pSirSmeRsp;
3446 tANI_U16 len = 0;
Madan Mohan Koyyalamudide1b5bc2013-07-12 00:56:04 +05303447 tANI_U8 sessionId;
3448 tANI_U16 transactionId;
Jeff Johnson295189b2012-06-20 16:38:30 -07003449
3450 if(pMac->lim.scanChnInfo.numChnInfo > SIR_MAX_SUPPORTED_CHANNEL_LIST)
3451 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003452 limLog(pMac, LOGW, FL("numChn is out of bounds %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07003453 pMac->lim.scanChnInfo.numChnInfo);
3454 pMac->lim.scanChnInfo.numChnInfo = SIR_MAX_SUPPORTED_CHANNEL_LIST;
3455 }
3456
Abhishek Singh525045c2014-12-15 17:18:45 +05303457 limLog(pMac, LOG1,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003458 FL("Sending message %s with number of channels %d"),
Abhishek Singh525045c2014-12-15 17:18:45 +05303459 limMsgStr(eWNI_SME_GET_SCANNED_CHANNEL_RSP), pMac->lim.scanChnInfo.numChnInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -07003460
3461 len = sizeof(tSmeGetScanChnRsp) + (pMac->lim.scanChnInfo.numChnInfo - 1) * sizeof(tLimScanChn);
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303462 pSirSmeRsp = vos_mem_malloc(len);
3463 if ( NULL == pSirSmeRsp )
Jeff Johnson295189b2012-06-20 16:38:30 -07003464 {
3465 /// Buffer not available. Log error
3466 limLog(pMac, LOGP,
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303467 FL("call to AllocateMemory failed for JOIN/REASSOC_RSP"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003468
3469 return;
3470 }
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303471 vos_mem_set(pSirSmeRsp, len, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07003472
Jeff Johnson295189b2012-06-20 16:38:30 -07003473 pSirSmeRsp->mesgType = eWNI_SME_GET_SCANNED_CHANNEL_RSP;
3474 pSirSmeRsp->mesgLen = len;
Madan Mohan Koyyalamudide1b5bc2013-07-12 00:56:04 +05303475
3476 if (pMac->fScanOffload)
3477 {
3478 limGetSessionInfo(pMac,(tANI_U8 *)pMsgBuf,&sessionId,&transactionId);
3479 pSirSmeRsp->sessionId = sessionId;
3480 }
3481 else
3482 pSirSmeRsp->sessionId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003483
3484 if(pMac->lim.scanChnInfo.numChnInfo)
3485 {
3486 pSirSmeRsp->numChn = pMac->lim.scanChnInfo.numChnInfo;
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303487 vos_mem_copy( pSirSmeRsp->scanChn, pMac->lim.scanChnInfo.scanChn,
3488 sizeof(tLimScanChn) * pSirSmeRsp->numChn);
Jeff Johnson295189b2012-06-20 16:38:30 -07003489 }
3490 //Clear the list
3491 limRessetScanChannelInfo(pMac);
3492
3493 mmhMsg.type = eWNI_SME_GET_SCANNED_CHANNEL_RSP;
3494 mmhMsg.bodyptr = pSirSmeRsp;
3495 mmhMsg.bodyval = 0;
3496
3497 pMac->lim.gLimRspReqd = false;
Konamki, Sreelakshmi824f93e2015-07-31 12:55:48 +05303498 MTRACE(macTrace(pMac, TRACE_CODE_TX_SME_MSG, NO_SESSION, mmhMsg.type));
Jeff Johnson295189b2012-06-20 16:38:30 -07003499 limSysProcessMmhMsgApi(pMac, &mmhMsg, ePROT);
3500}
3501
3502
Jeff Johnson295189b2012-06-20 16:38:30 -07003503void limProcessSmeGetAssocSTAsInfo(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
3504{
Hanumantha Reddy Pothula0de10802016-02-11 17:29:27 +05303505 tSirSmeGetAssocSTAsReq getAssocSTAsReq = {0};
Jeff Johnson295189b2012-06-20 16:38:30 -07003506 tpDphHashNode pStaDs = NULL;
3507 tpPESession psessionEntry = NULL;
3508 tSap_Event sapEvent;
3509 tpWLAN_SAPEventCB pSapEventCallback = NULL;
3510 tpSap_AssocMacAddr pAssocStasTemp = NULL;// #include "sapApi.h"
3511 tANI_U8 sessionId = CSR_SESSION_ID_INVALID;
3512 tANI_U8 assocId = 0;
3513 tANI_U8 staCount = 0;
3514
3515 if (!limIsSmeGetAssocSTAsReqValid(pMac, &getAssocSTAsReq, (tANI_U8 *) pMsgBuf))
3516 {
3517 limLog(pMac, LOGE,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003518 FL("received invalid eWNI_SME_GET_ASSOC_STAS_REQ message"));
Girish Gowliafd42312014-07-24 13:13:59 +05303519 return;
Jeff Johnson295189b2012-06-20 16:38:30 -07003520 }
3521
3522 switch (getAssocSTAsReq.modId)
3523 {
3524/**
3525 case VOS_MODULE_ID_HAL:
3526 wdaPostCtrlMsg( pMac, &msgQ );
3527 return;
3528
3529 case VOS_MODULE_ID_TL:
3530 Post msg TL
3531 return;
3532*/
3533 case VOS_MODULE_ID_PE:
3534 default:
3535 break;
3536 }
3537
Jeff Johnson1250df42012-12-10 14:31:52 -08003538 // Get Associated stations from PE
Jeff Johnson295189b2012-06-20 16:38:30 -07003539 // Find PE session Entry
3540 if ((psessionEntry = peFindSessionByBssid(pMac, getAssocSTAsReq.bssId, &sessionId)) == NULL)
3541 {
3542 limLog(pMac, LOGE,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003543 FL("session does not exist for given bssId"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003544 goto limAssocStaEnd;
3545 }
3546
3547 if (psessionEntry->limSystemRole != eLIM_AP_ROLE)
3548 {
3549 limLog(pMac, LOGE,
Sushant Kaushik1b645382014-10-13 16:39:36 +05303550 FL("Received unexpected message in state %d, in role %d"),
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303551 psessionEntry->limSmeState, psessionEntry->limSystemRole);
Jeff Johnson295189b2012-06-20 16:38:30 -07003552 goto limAssocStaEnd;
3553 }
3554
3555 // Retrieve values obtained in the request message
3556 pSapEventCallback = (tpWLAN_SAPEventCB)getAssocSTAsReq.pSapEventCallback;
3557 pAssocStasTemp = (tpSap_AssocMacAddr)getAssocSTAsReq.pAssocStasArray;
3558
3559 for (assocId = 0; assocId < psessionEntry->dph.dphHashTable.size; assocId++)// Softap dphHashTable.size = 8
3560 {
3561 pStaDs = dphGetHashEntry(pMac, assocId, &psessionEntry->dph.dphHashTable);
3562
Abhishek Singh8a99b9f2015-03-31 14:18:26 +05303563 if ((NULL == pStaDs) || (NULL == pAssocStasTemp))
Jeff Johnson295189b2012-06-20 16:38:30 -07003564 continue;
3565
3566 if (pStaDs->valid)
3567 {
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303568 vos_mem_copy((tANI_U8 *)&pAssocStasTemp->staMac,
3569 (tANI_U8 *)&pStaDs->staAddr,
3570 sizeof(v_MACADDR_t)); // Mac address
Jeff Johnson295189b2012-06-20 16:38:30 -07003571 pAssocStasTemp->assocId = (v_U8_t)pStaDs->assocId; // Association Id
3572 pAssocStasTemp->staId = (v_U8_t)pStaDs->staIndex; // Station Id
3573
Kiet Lamb1233192013-11-28 13:38:20 +05303574 vos_mem_copy((tANI_U8 *)&pAssocStasTemp->supportedRates,
Leo Chang614d2072013-08-22 14:59:44 -07003575 (tANI_U8 *)&pStaDs->supportedRates,
3576 sizeof(tSirSupportedRates));
3577 pAssocStasTemp->ShortGI40Mhz = pStaDs->htShortGI40Mhz;
3578 pAssocStasTemp->ShortGI20Mhz = pStaDs->htShortGI20Mhz;
3579 pAssocStasTemp->Support40Mhz = pStaDs->htDsssCckRate40MHzSupport;
3580
Jeff Johnson295189b2012-06-20 16:38:30 -07003581 limLog(pMac, LOG1, FL("dph Station Number = %d"), staCount+1);
Arif Hussain24bafea2013-11-15 15:10:03 -08003582 limLog(pMac, LOG1, FL("MAC = " MAC_ADDRESS_STR),
3583 MAC_ADDR_ARRAY(pStaDs->staAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07003584 limLog(pMac, LOG1, FL("Association Id = %d"),pStaDs->assocId);
3585 limLog(pMac, LOG1, FL("Station Index = %d"),pStaDs->staIndex);
3586
3587 pAssocStasTemp++;
3588 staCount++;
3589 }
3590 }
3591
3592limAssocStaEnd:
3593 // Call hdd callback with sap event to send the list of associated stations from PE
3594 if (pSapEventCallback != NULL)
3595 {
3596 sapEvent.sapHddEventCode = eSAP_ASSOC_STA_CALLBACK_EVENT;
3597 sapEvent.sapevt.sapAssocStaListEvent.module = VOS_MODULE_ID_PE;
3598 sapEvent.sapevt.sapAssocStaListEvent.noOfAssocSta = staCount;
3599 sapEvent.sapevt.sapAssocStaListEvent.pAssocStas = (tpSap_AssocMacAddr)getAssocSTAsReq.pAssocStasArray;
3600 pSapEventCallback(&sapEvent, getAssocSTAsReq.pUsrContext);
3601 }
3602}
3603
3604
3605/**
3606 * limProcessSmeGetWPSPBCSessions
3607 *
3608 *FUNCTION:
3609 * This function is called when query the WPS PBC overlap message is received
3610 *
3611 *LOGIC:
3612 * This function parses get WPS PBC overlap information message and call callback to pass
3613 * WPS PBC overlap information back to hdd.
3614 *ASSUMPTIONS:
3615 *
3616 *
3617 *NOTE:
3618 *
3619 * @param pMac Pointer to Global MAC structure
3620 * @param pMsgBuf A pointer to WPS PBC overlap query message
3621*
3622 * @return None
3623 */
3624void limProcessSmeGetWPSPBCSessions(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
3625{
3626 tSirSmeGetWPSPBCSessionsReq GetWPSPBCSessionsReq;
3627 tpPESession psessionEntry = NULL;
3628 tSap_Event sapEvent;
3629 tpWLAN_SAPEventCB pSapEventCallback = NULL;
3630 tANI_U8 sessionId = CSR_SESSION_ID_INVALID;
3631 tSirMacAddr zeroMac = {0,0,0,0,0,0};
3632
3633 sapEvent.sapevt.sapGetWPSPBCSessionEvent.status = VOS_STATUS_E_FAULT;
3634
3635 if (limIsSmeGetWPSPBCSessionsReqValid(pMac, &GetWPSPBCSessionsReq, (tANI_U8 *) pMsgBuf) != eSIR_SUCCESS)
3636 {
3637 limLog(pMac, LOGE,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003638 FL("received invalid eWNI_SME_GET_ASSOC_STAS_REQ message"));
Girish Gowliafd42312014-07-24 13:13:59 +05303639 return;
Jeff Johnson295189b2012-06-20 16:38:30 -07003640 }
3641
Jeff Johnson1250df42012-12-10 14:31:52 -08003642 // Get Associated stations from PE
Jeff Johnson295189b2012-06-20 16:38:30 -07003643 // Find PE session Entry
3644 if ((psessionEntry = peFindSessionByBssid(pMac, GetWPSPBCSessionsReq.bssId, &sessionId)) == NULL)
3645 {
3646 limLog(pMac, LOGE,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003647 FL("session does not exist for given bssId"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003648 goto limGetWPSPBCSessionsEnd;
3649 }
3650
3651 if (psessionEntry->limSystemRole != eLIM_AP_ROLE)
3652 {
3653 limLog(pMac, LOGE,
Sushant Kaushik1b645382014-10-13 16:39:36 +05303654 FL("Received unexpected message in role %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07003655 psessionEntry->limSystemRole);
3656 goto limGetWPSPBCSessionsEnd;
3657 }
3658
Jeff Johnson1250df42012-12-10 14:31:52 -08003659 // Call hdd callback with sap event to send the WPS PBC overlap information
Jeff Johnson295189b2012-06-20 16:38:30 -07003660 sapEvent.sapHddEventCode = eSAP_GET_WPSPBC_SESSION_EVENT;
3661 sapEvent.sapevt.sapGetWPSPBCSessionEvent.module = VOS_MODULE_ID_PE;
3662
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303663 if (vos_mem_compare( zeroMac, GetWPSPBCSessionsReq.pRemoveMac, sizeof(tSirMacAddr)))
Jeff Johnson295189b2012-06-20 16:38:30 -07003664 { //This is GetWpsSession call
3665
3666 limGetWPSPBCSessions(pMac,
3667 sapEvent.sapevt.sapGetWPSPBCSessionEvent.addr.bytes, sapEvent.sapevt.sapGetWPSPBCSessionEvent.UUID_E,
3668 &sapEvent.sapevt.sapGetWPSPBCSessionEvent.wpsPBCOverlap, psessionEntry);
3669 }
3670 else
3671 {
3672 limRemovePBCSessions(pMac, GetWPSPBCSessionsReq.pRemoveMac,psessionEntry);
3673 /* don't have to inform the HDD/Host */
3674 return;
3675 }
3676
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003677 PELOG4(limLog(pMac, LOGE, FL("wpsPBCOverlap %d"), sapEvent.sapevt.sapGetWPSPBCSessionEvent.wpsPBCOverlap);)
Jeff Johnson295189b2012-06-20 16:38:30 -07003678 PELOG4(limPrintMacAddr(pMac, sapEvent.sapevt.sapGetWPSPBCSessionEvent.addr.bytes, LOG4);)
3679
3680 sapEvent.sapevt.sapGetWPSPBCSessionEvent.status = VOS_STATUS_SUCCESS;
3681
3682limGetWPSPBCSessionsEnd:
3683 pSapEventCallback = (tpWLAN_SAPEventCB)GetWPSPBCSessionsReq.pSapEventCallback;
Abhishek Singh8a99b9f2015-03-31 14:18:26 +05303684
3685 if (NULL != pSapEventCallback)
3686 pSapEventCallback(&sapEvent, GetWPSPBCSessionsReq.pUsrContext);
Jeff Johnson295189b2012-06-20 16:38:30 -07003687}
3688
Jeff Johnson295189b2012-06-20 16:38:30 -07003689
3690
3691/**
3692 * __limCounterMeasures()
3693 *
3694 * FUNCTION:
3695 * This function is called to "implement" MIC counter measure
3696 * and is *temporary* only
3697 *
3698 * LOGIC: on AP, disassoc all STA associated thru TKIP,
3699 * we don't do the proper STA disassoc sequence since the
3700 * BSS will be stoped anyway
3701 *
3702 *ASSUMPTIONS:
3703 *
3704 *NOTE:
3705 *
3706 * @param pMac Pointer to Global MAC structure
3707 * @return None
3708 */
3709
3710static void
3711__limCounterMeasures(tpAniSirGlobal pMac, tpPESession psessionEntry)
3712{
3713 tSirMacAddr mac = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
Abhishek Singh8944b222014-09-17 16:13:17 +05303714 /* If PMF is enabled then don't send broadcast disassociation */
3715 if ( ( (psessionEntry->limSystemRole == eLIM_AP_ROLE) ||
3716 (psessionEntry->limSystemRole == eLIM_BT_AMP_AP_ROLE) ||
3717 (psessionEntry->limSystemRole == eLIM_BT_AMP_STA_ROLE))
3718#ifdef WLAN_FEATURE_11W
3719 && !psessionEntry->limRmfEnabled
3720#endif
3721 )
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003722 limSendDisassocMgmtFrame(pMac, eSIR_MAC_MIC_FAILURE_REASON, mac, psessionEntry, FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003723
Jeff Johnson295189b2012-06-20 16:38:30 -07003724};
3725
3726
Jeff Johnson295189b2012-06-20 16:38:30 -07003727void
3728limProcessTkipCounterMeasures(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
3729{
3730 tSirSmeTkipCntrMeasReq tkipCntrMeasReq;
3731 tpPESession psessionEntry;
3732 tANI_U8 sessionId; //PE sessionId
3733
3734 if ( limTkipCntrMeasReqSerDes( pMac, &tkipCntrMeasReq, (tANI_U8 *) pMsgBuf ) != eSIR_SUCCESS )
3735 {
3736 limLog(pMac, LOGE,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003737 FL("received invalid eWNI_SME_TKIP_CNTR_MEAS_REQ message"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003738 return;
3739 }
3740
3741 if ( NULL == (psessionEntry = peFindSessionByBssid( pMac, tkipCntrMeasReq.bssId, &sessionId )) )
3742 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003743 limLog(pMac, LOGE, FL("session does not exist for given BSSID "));
Jeff Johnson295189b2012-06-20 16:38:30 -07003744 return;
3745 }
3746
3747 if ( tkipCntrMeasReq.bEnable )
3748 {
3749 __limCounterMeasures( pMac, psessionEntry );
3750 }
3751
3752 psessionEntry->bTkipCntrMeasActive = tkipCntrMeasReq.bEnable;
3753}
Jeff Johnson295189b2012-06-20 16:38:30 -07003754
3755
3756static void
3757__limHandleSmeStopBssRequest(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
3758{
3759 tSirSmeStopBssReq stopBssReq;
3760 tSirRetStatus status;
3761 tLimSmeStates prevState;
3762 tANI_U8 sessionId; //PE sessionId
3763 tpPESession psessionEntry;
3764 tANI_U8 smesessionId;
3765 tANI_U16 smetransactionId;
Sachin Ahuja51c08e62014-03-26 19:21:29 +05303766 tANI_U8 i = 0;
3767 tpDphHashNode pStaDs = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07003768
3769 limGetSessionInfo(pMac,(tANI_U8 *)pMsgBuf,&smesessionId,&smetransactionId);
3770
3771
3772
3773 if ((limStopBssReqSerDes(pMac, &stopBssReq, (tANI_U8 *) pMsgBuf) != eSIR_SUCCESS) ||
3774 !limIsSmeStopBssReqValid(pMsgBuf))
3775 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003776 PELOGW(limLog(pMac, LOGW, FL("received invalid SME_STOP_BSS_REQ message"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07003777 /// Send Stop BSS response to host
3778 limSendSmeRsp(pMac, eWNI_SME_STOP_BSS_RSP, eSIR_SME_INVALID_PARAMETERS,smesessionId,smetransactionId);
3779 return;
3780 }
3781
3782
3783 if((psessionEntry = peFindSessionByBssid(pMac,stopBssReq.bssId,&sessionId)) == NULL)
3784 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003785 limLog(pMac, LOGW, FL("session does not exist for given BSSID "));
Jeff Johnson295189b2012-06-20 16:38:30 -07003786 limSendSmeRsp(pMac, eWNI_SME_STOP_BSS_RSP, eSIR_SME_INVALID_PARAMETERS,smesessionId,smetransactionId);
3787 return;
3788 }
3789
3790#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM //FEATURE_WLAN_DIAG_SUPPORT
3791 limDiagEventReport(pMac, WLAN_PE_DIAG_STOP_BSS_REQ_EVENT, psessionEntry, 0, 0);
3792#endif //FEATURE_WLAN_DIAG_SUPPORT
3793
3794
3795 if ((psessionEntry->limSmeState != eLIM_SME_NORMAL_STATE) || /* Added For BT -AMP Support */
3796 (psessionEntry->limSystemRole == eLIM_STA_ROLE ))
3797 {
3798 /**
3799 * Should not have received STOP_BSS_REQ in states
3800 * other than 'normal' state or on STA in Infrastructure
3801 * mode. Log error and return response to host.
3802 */
3803 limLog(pMac, LOGE,
Sushant Kaushik1b645382014-10-13 16:39:36 +05303804 FL("received unexpected SME_STOP_BSS_REQ in state %d, for role %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07003805 psessionEntry->limSmeState, psessionEntry->limSystemRole);
3806 limPrintSmeState(pMac, LOGE, psessionEntry->limSmeState);
3807 /// Send Stop BSS response to host
3808 limSendSmeRsp(pMac, eWNI_SME_STOP_BSS_RSP, eSIR_SME_UNEXPECTED_REQ_RESULT_CODE,smesessionId,smetransactionId);
3809 return;
3810 }
3811
Jeff Johnson295189b2012-06-20 16:38:30 -07003812 if (psessionEntry->limSystemRole == eLIM_AP_ROLE )
3813 {
3814 limWPSPBCClose(pMac, psessionEntry);
3815 }
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003816 PELOGW(limLog(pMac, LOGW, FL("RECEIVED STOP_BSS_REQ with reason code=%d"), stopBssReq.reasonCode);)
Jeff Johnson295189b2012-06-20 16:38:30 -07003817
3818 prevState = psessionEntry->limSmeState;
3819
3820 psessionEntry->limSmeState = eLIM_SME_IDLE_STATE;
Jeff Johnsone7245742012-09-05 17:12:55 -07003821 MTRACE(macTrace(pMac, TRACE_CODE_SME_STATE, psessionEntry->peSessionId, psessionEntry->limSmeState));
Jeff Johnson295189b2012-06-20 16:38:30 -07003822
3823 /* Update SME session Id and Transaction Id */
3824 psessionEntry->smeSessionId = smesessionId;
3825 psessionEntry->transactionId = smetransactionId;
3826
Abhishek Singh8944b222014-09-17 16:13:17 +05303827 /* BTAMP_STA and STA_IN_IBSS should NOT send Disassoc frame.
3828 * If PMF is enabled then don't send broadcast disassociation */
3829 if ( ( (eLIM_STA_IN_IBSS_ROLE != psessionEntry->limSystemRole) &&
3830 (eLIM_BT_AMP_STA_ROLE != psessionEntry->limSystemRole) )
3831#ifdef WLAN_FEATURE_11W
3832 && !psessionEntry->limRmfEnabled
3833#endif
3834 )
Jeff Johnson295189b2012-06-20 16:38:30 -07003835 {
3836 tSirMacAddr bcAddr = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
3837 if ((stopBssReq.reasonCode == eSIR_SME_MIC_COUNTER_MEASURES))
3838 // Send disassoc all stations associated thru TKIP
3839 __limCounterMeasures(pMac,psessionEntry);
3840 else
Madan Mohan Koyyalamudi299b4862013-01-30 19:59:23 +05303841 limSendDisassocMgmtFrame(pMac, eSIR_MAC_DEAUTH_LEAVING_BSS_REASON, bcAddr, psessionEntry, FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003842 }
3843
3844 //limDelBss is also called as part of coalescing, when we send DEL BSS followed by Add Bss msg.
3845 pMac->lim.gLimIbssCoalescingHappened = false;
3846
Sachin Ahuja51c08e62014-03-26 19:21:29 +05303847 for(i = 1 ; i < pMac->lim.gLimAssocStaLimit ; i++)
3848 {
3849 pStaDs = dphGetHashEntry(pMac, i, &psessionEntry->dph.dphHashTable);
3850 if (NULL == pStaDs)
3851 continue;
3852 status = limDelSta(pMac, pStaDs, false, psessionEntry) ;
3853 if(eSIR_SUCCESS == status)
3854 {
3855 limDeleteDphHashEntry(pMac, pStaDs->staAddr, pStaDs->assocId, psessionEntry) ;
3856 limReleasePeerIdx(pMac, pStaDs->assocId, psessionEntry) ;
3857 }
3858 else
3859 {
3860 limLog(pMac, LOGE, FL("limDelSta failed with Status : %d"), status);
3861 VOS_ASSERT(0) ;
3862 }
3863 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003864 /* send a delBss to HAL and wait for a response */
3865 status = limDelBss(pMac, NULL,psessionEntry->bssIdx,psessionEntry);
3866
3867 if (status != eSIR_SUCCESS)
3868 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003869 PELOGE(limLog(pMac, LOGE, FL("delBss failed for bss %d"), psessionEntry->bssIdx);)
Jeff Johnson295189b2012-06-20 16:38:30 -07003870 psessionEntry->limSmeState= prevState;
3871
Jeff Johnsone7245742012-09-05 17:12:55 -07003872 MTRACE(macTrace(pMac, TRACE_CODE_SME_STATE, psessionEntry->peSessionId, psessionEntry->limSmeState));
Jeff Johnson295189b2012-06-20 16:38:30 -07003873
3874 limSendSmeRsp(pMac, eWNI_SME_STOP_BSS_RSP, eSIR_SME_STOP_BSS_FAILURE,smesessionId,smetransactionId);
3875 }
3876}
3877
3878
3879/**--------------------------------------------------------------
3880\fn __limProcessSmeStopBssReq
3881
3882\brief Wrapper for the function __limHandleSmeStopBssRequest
3883 This message will be defered until softmac come out of
3884 scan mode. Message should be handled even if we have
3885 detected radar in the current operating channel.
3886\param pMac
3887\param pMsg
3888
3889\return TRUE - If we consumed the buffer
3890 FALSE - If have defered the message.
3891 ---------------------------------------------------------------*/
3892static tANI_BOOLEAN
3893__limProcessSmeStopBssReq(tpAniSirGlobal pMac, tpSirMsgQ pMsg)
3894{
3895 if (__limIsDeferedMsgForLearn(pMac, pMsg))
3896 {
3897 /**
3898 * If message defered, buffer is not consumed yet.
3899 * So return false
3900 */
3901 return eANI_BOOLEAN_FALSE;
3902 }
3903 __limHandleSmeStopBssRequest(pMac, (tANI_U32 *) pMsg->bodyptr);
3904 return eANI_BOOLEAN_TRUE;
3905} /*** end __limProcessSmeStopBssReq() ***/
3906
3907
3908void limProcessSmeDelBssRsp(
3909 tpAniSirGlobal pMac,
3910 tANI_U32 body,tpPESession psessionEntry)
3911{
3912
3913 (void) body;
3914 SET_LIM_PROCESS_DEFD_MESGS(pMac, true);
3915 //TBD: get the sessionEntry
Ravi Joshib58ca0d2013-10-29 09:50:23 -07003916 limIbssDelete(pMac,psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07003917 dphHashTableClassInit(pMac, &psessionEntry->dph.dphHashTable);
3918 limDeletePreAuthList(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -07003919 limSendSmeRsp(pMac, eWNI_SME_STOP_BSS_RSP, eSIR_SME_SUCCESS,psessionEntry->smeSessionId,psessionEntry->transactionId);
3920 return;
3921}
3922
3923
Jeff Johnson295189b2012-06-20 16:38:30 -07003924/**---------------------------------------------------------------
3925\fn __limProcessSmeAssocCnfNew
3926\brief This function handles SME_ASSOC_CNF/SME_REASSOC_CNF
3927\ in BTAMP AP.
3928\
3929\param pMac
3930\param msgType - message type
3931\param pMsgBuf - a pointer to the SME message buffer
3932\return None
3933------------------------------------------------------------------*/
3934
3935 void
3936__limProcessSmeAssocCnfNew(tpAniSirGlobal pMac, tANI_U32 msgType, tANI_U32 *pMsgBuf)
3937{
3938 tSirSmeAssocCnf assocCnf;
3939 tpDphHashNode pStaDs = NULL;
3940 tpPESession psessionEntry= NULL;
3941 tANI_U8 sessionId;
3942
3943
3944 if(pMsgBuf == NULL)
3945 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003946 limLog(pMac, LOGE, FL("pMsgBuf is NULL "));
Jeff Johnson295189b2012-06-20 16:38:30 -07003947 goto end;
3948 }
3949
3950 if ((limAssocCnfSerDes(pMac, &assocCnf, (tANI_U8 *) pMsgBuf) == eSIR_FAILURE) ||
3951 !__limIsSmeAssocCnfValid(&assocCnf))
3952 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003953 limLog(pMac, LOGE, FL("Received invalid SME_RE(ASSOC)_CNF message "));
Jeff Johnson295189b2012-06-20 16:38:30 -07003954 goto end;
3955 }
3956
3957 if((psessionEntry = peFindSessionByBssid(pMac, assocCnf.bssId, &sessionId))== NULL)
3958 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003959 limLog(pMac, LOGE, FL("session does not exist for given bssId"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003960 goto end;
3961 }
3962
3963 if ( ((psessionEntry->limSystemRole != eLIM_AP_ROLE) && (psessionEntry->limSystemRole != eLIM_BT_AMP_AP_ROLE)) ||
3964 ((psessionEntry->limSmeState != eLIM_SME_NORMAL_STATE) && (psessionEntry->limSmeState != eLIM_SME_NORMAL_CHANNEL_SCAN_STATE)))
3965 {
Sushant Kaushik1b645382014-10-13 16:39:36 +05303966 limLog(pMac, LOGE, FL("Received unexpected message %X in state %d, in role %d"),
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303967 msgType, psessionEntry->limSmeState, psessionEntry->limSystemRole);
Jeff Johnson295189b2012-06-20 16:38:30 -07003968 goto end;
3969 }
3970
3971 pStaDs = dphGetHashEntry(pMac, assocCnf.aid, &psessionEntry->dph.dphHashTable);
3972
3973 if (pStaDs == NULL)
3974 {
Sachin Ahuja2fea3d12014-12-18 17:31:31 +05303975 limLog(pMac, LOGE,
3976 FL("Received invalid message %X due to no STA context, "
3977 "for aid %d, peer "),
3978 msgType, assocCnf.aid);
Jeff Johnson295189b2012-06-20 16:38:30 -07003979 limPrintMacAddr(pMac, assocCnf.peerMacAddr, LOG1);
3980
3981 /*
3982 ** send a DISASSOC_IND message to WSM to make sure
3983 ** the state in WSM and LIM is the same
3984 **/
3985 limSendSmeDisassocNtf( pMac, assocCnf.peerMacAddr, eSIR_SME_STA_NOT_ASSOCIATED,
3986 eLIM_PEER_ENTITY_DISASSOC, assocCnf.aid,psessionEntry->smeSessionId,psessionEntry->transactionId,psessionEntry);
3987 goto end;
3988 }
3989 if ((pStaDs &&
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303990 (( !vos_mem_compare( (tANI_U8 *) pStaDs->staAddr,
Jeff Johnson295189b2012-06-20 16:38:30 -07003991 (tANI_U8 *) assocCnf.peerMacAddr,
3992 sizeof(tSirMacAddr)) ) ||
3993 (pStaDs->mlmStaContext.mlmState != eLIM_MLM_WT_ASSOC_CNF_STATE) ||
3994 ((pStaDs->mlmStaContext.subType == LIM_ASSOC) &&
3995 (msgType != eWNI_SME_ASSOC_CNF)) ||
3996 ((pStaDs->mlmStaContext.subType == LIM_REASSOC) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07003997 (msgType != eWNI_SME_ASSOC_CNF))))) // since softap is passing this as ASSOC_CNF and subtype differs
Jeff Johnson295189b2012-06-20 16:38:30 -07003998 {
Sachin Ahuja2fea3d12014-12-18 17:31:31 +05303999 limLog(pMac, LOGE,
4000 FL("Received invalid message %X due to peerMacAddr mismatched "
4001 "or not in eLIM_MLM_WT_ASSOC_CNF_STATE state, for aid %d, peer "
4002 "StaD mlmState : %d"),
4003 msgType, assocCnf.aid, pStaDs->mlmStaContext.mlmState);
Jeff Johnson295189b2012-06-20 16:38:30 -07004004 limPrintMacAddr(pMac, assocCnf.peerMacAddr, LOG1);
4005 goto end;
4006 }
4007
4008 /*
4009 ** Deactivate/delet CNF_WAIT timer since ASSOC_CNF
4010 ** has been received
4011 **/
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004012 limLog(pMac, LOG1, FL("Received SME_ASSOC_CNF. Delete Timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004013 limDeactivateAndChangePerStaIdTimer(pMac, eLIM_CNF_WAIT_TIMER, pStaDs->assocId);
4014
4015 if (assocCnf.statusCode == eSIR_SME_SUCCESS)
4016 {
4017 /* In BTAMP-AP, PE already finished the WDA_ADD_STA sequence
4018 * when it had received Assoc Request frame. Now, PE just needs to send
4019 * Association Response frame to the requesting BTAMP-STA.
4020 */
4021 pStaDs->mlmStaContext.mlmState = eLIM_MLM_LINK_ESTABLISHED_STATE;
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004022 limLog(pMac, LOG1, FL("sending Assoc Rsp frame to STA (assoc id=%d) "), pStaDs->assocId);
Jeff Johnson295189b2012-06-20 16:38:30 -07004023 limSendAssocRspMgmtFrame( pMac, eSIR_SUCCESS, pStaDs->assocId, pStaDs->staAddr,
4024 pStaDs->mlmStaContext.subType, pStaDs, psessionEntry);
4025 goto end;
4026 } // (assocCnf.statusCode == eSIR_SME_SUCCESS)
4027 else
4028 {
4029 // SME_ASSOC_CNF status is non-success, so STA is not allowed to be associated
4030 /*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*/
4031 if(!pStaDs->mlmStaContext.updateContext)
4032 pStaDs->mlmStaContext.updateContext = 1;
Sachin Ahuja2fea3d12014-12-18 17:31:31 +05304033 limLog(pMac, LOG1, FL("Receive Assoc Cnf with status Code : %d(assoc id=%d) "),
4034 assocCnf.statusCode, pStaDs->assocId);
Jeff Johnson295189b2012-06-20 16:38:30 -07004035 limRejectAssociation(pMac, pStaDs->staAddr,
4036 pStaDs->mlmStaContext.subType,
4037 true, pStaDs->mlmStaContext.authType,
4038 pStaDs->assocId, true,
4039 eSIR_MAC_UNSPEC_FAILURE_STATUS, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07004040 }
4041
4042end:
4043 if((psessionEntry != NULL) && (pStaDs != NULL))
4044 {
4045 if ( psessionEntry->parsedAssocReq[pStaDs->assocId] != NULL )
4046 {
4047 if ( ((tpSirAssocReq)(psessionEntry->parsedAssocReq[pStaDs->assocId]))->assocReqFrame)
4048 {
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304049 vos_mem_free(((tpSirAssocReq)
4050 (psessionEntry->parsedAssocReq[pStaDs->assocId]))->assocReqFrame);
Jeff Johnson295189b2012-06-20 16:38:30 -07004051 ((tpSirAssocReq)(psessionEntry->parsedAssocReq[pStaDs->assocId]))->assocReqFrame = NULL;
4052 }
4053
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304054 vos_mem_free(psessionEntry->parsedAssocReq[pStaDs->assocId]);
Jeff Johnson295189b2012-06-20 16:38:30 -07004055 psessionEntry->parsedAssocReq[pStaDs->assocId] = NULL;
4056 }
4057 }
4058
4059} /*** end __limProcessSmeAssocCnfNew() ***/
4060
4061
Jeff Johnson295189b2012-06-20 16:38:30 -07004062
4063
4064static void
4065__limProcessSmeAddtsReq(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
4066{
4067 tpDphHashNode pStaDs;
4068 tSirMacAddr peerMac;
4069 tpSirAddtsReq pSirAddts;
4070 tANI_U32 timeout;
4071 tpPESession psessionEntry;
4072 tANI_U8 sessionId; //PE sessionId
4073 tANI_U8 smesessionId;
4074 tANI_U16 smetransactionId;
4075
4076
4077 if(pMsgBuf == NULL)
4078 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004079 limLog(pMac, LOGE,FL("Buffer is Pointing to NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004080 return;
4081 }
4082
4083 limGetSessionInfo(pMac,(tANI_U8 *)pMsgBuf,&smesessionId,&smetransactionId);
4084
4085 pSirAddts = (tpSirAddtsReq) pMsgBuf;
4086
4087 if((psessionEntry = peFindSessionByBssid(pMac, pSirAddts->bssId,&sessionId))== NULL)
4088 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004089 limLog(pMac, LOGE, "Session Does not exist for given bssId");
Jeff Johnson295189b2012-06-20 16:38:30 -07004090 return;
4091 }
4092#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM //FEATURE_WLAN_DIAG_SUPPORT
4093 limDiagEventReport(pMac, WLAN_PE_DIAG_ADDTS_REQ_EVENT, psessionEntry, 0, 0);
4094#endif //FEATURE_WLAN_DIAG_SUPPORT
4095
4096
4097
4098 /* if sta
4099 * - verify assoc state
4100 * - send addts request to ap
4101 * - wait for addts response from ap
4102 * if ap, just ignore with error log
4103 */
Abhishek Singh3cbf6052014-12-15 16:46:42 +05304104 limLog(pMac, LOG1,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004105 FL("Received SME_ADDTS_REQ (TSid %d, UP %d)"),
Jeff Johnson295189b2012-06-20 16:38:30 -07004106 pSirAddts->req.tspec.tsinfo.traffic.tsid,
Abhishek Singh3cbf6052014-12-15 16:46:42 +05304107 pSirAddts->req.tspec.tsinfo.traffic.userPrio);
Jeff Johnson295189b2012-06-20 16:38:30 -07004108
4109 if ((psessionEntry->limSystemRole != eLIM_STA_ROLE)&&(psessionEntry->limSystemRole != eLIM_BT_AMP_STA_ROLE))
4110 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004111 PELOGE(limLog(pMac, LOGE, "AddTs received on AP - ignoring");)
Jeff Johnson295189b2012-06-20 16:38:30 -07004112 limSendSmeAddtsRsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE, psessionEntry, pSirAddts->req.tspec,
4113 smesessionId,smetransactionId);
4114 return;
4115 }
4116
Jeff Johnson295189b2012-06-20 16:38:30 -07004117 pStaDs = dphGetHashEntry(pMac, DPH_STA_HASH_INDEX_PEER, &psessionEntry->dph.dphHashTable);
4118
4119 if(pStaDs == NULL)
4120 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004121 PELOGE(limLog(pMac, LOGE, "Cannot find AP context for addts req");)
Jeff Johnson295189b2012-06-20 16:38:30 -07004122 limSendSmeAddtsRsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE, psessionEntry, pSirAddts->req.tspec,
4123 smesessionId,smetransactionId);
4124 return;
4125 }
4126
4127 if ((! pStaDs->valid) ||
4128 (pStaDs->mlmStaContext.mlmState != eLIM_MLM_LINK_ESTABLISHED_STATE))
4129 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004130 PELOGE(limLog(pMac, LOGE, "AddTs received in invalid MLM state");)
Jeff Johnson295189b2012-06-20 16:38:30 -07004131 limSendSmeAddtsRsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE, psessionEntry, pSirAddts->req.tspec,
4132 smesessionId,smetransactionId);
4133 return;
4134 }
4135
4136 pSirAddts->req.wsmTspecPresent = 0;
4137 pSirAddts->req.wmeTspecPresent = 0;
4138 pSirAddts->req.lleTspecPresent = 0;
4139
4140 if ((pStaDs->wsmEnabled) &&
4141 (pSirAddts->req.tspec.tsinfo.traffic.accessPolicy != SIR_MAC_ACCESSPOLICY_EDCA))
4142 pSirAddts->req.wsmTspecPresent = 1;
4143 else if (pStaDs->wmeEnabled)
4144 pSirAddts->req.wmeTspecPresent = 1;
4145 else if (pStaDs->lleEnabled)
4146 pSirAddts->req.lleTspecPresent = 1;
4147 else
4148 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004149 PELOGW(limLog(pMac, LOGW, FL("ADDTS_REQ ignore - qos is disabled"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07004150 limSendSmeAddtsRsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE, psessionEntry, pSirAddts->req.tspec,
4151 smesessionId,smetransactionId);
4152 return;
4153 }
4154
4155 if ((psessionEntry->limSmeState != eLIM_SME_ASSOCIATED_STATE) &&
4156 (psessionEntry->limSmeState != eLIM_SME_LINK_EST_STATE))
4157 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004158 limLog(pMac, LOGE, "AddTs received in invalid LIMsme state (%d)",
Jeff Johnson295189b2012-06-20 16:38:30 -07004159 psessionEntry->limSmeState);
4160 limSendSmeAddtsRsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE, psessionEntry, pSirAddts->req.tspec,
4161 smesessionId,smetransactionId);
4162 return;
4163 }
4164
4165 if (pMac->lim.gLimAddtsSent)
4166 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004167 limLog(pMac, LOGE, "Addts (token %d, tsid %d, up %d) is still pending",
Jeff Johnson295189b2012-06-20 16:38:30 -07004168 pMac->lim.gLimAddtsReq.req.dialogToken,
4169 pMac->lim.gLimAddtsReq.req.tspec.tsinfo.traffic.tsid,
4170 pMac->lim.gLimAddtsReq.req.tspec.tsinfo.traffic.userPrio);
4171 limSendSmeAddtsRsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE, psessionEntry, pSirAddts->req.tspec,
4172 smesessionId,smetransactionId);
4173 return;
4174 }
4175
4176 #if 0
4177 val = sizeof(tSirMacAddr);
4178 if (wlan_cfgGetStr(pMac, WNI_CFG_BSSID, peerMac, &val) != eSIR_SUCCESS)
4179 {
4180 /// Could not get BSSID from CFG. Log error.
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004181 limLog(pMac, LOGP, FL("could not retrieve BSSID"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004182 return;
4183 }
4184 #endif
4185 sirCopyMacAddr(peerMac,psessionEntry->bssId);
4186
4187 // save the addts request
4188 pMac->lim.gLimAddtsSent = true;
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304189 vos_mem_copy( (tANI_U8 *) &pMac->lim.gLimAddtsReq, (tANI_U8 *) pSirAddts, sizeof(tSirAddtsReq));
Jeff Johnson295189b2012-06-20 16:38:30 -07004190
4191 // ship out the message now
4192 limSendAddtsReqActionFrame(pMac, peerMac, &pSirAddts->req,
4193 psessionEntry);
Abhishek Singh3cbf6052014-12-15 16:46:42 +05304194 limLog(pMac, LOG1, FL("Sent ADDTS request"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004195
4196 // start a timer to wait for the response
4197 if (pSirAddts->timeout)
4198 timeout = pSirAddts->timeout;
4199 else if (wlan_cfgGetInt(pMac, WNI_CFG_ADDTS_RSP_TIMEOUT, &timeout) != eSIR_SUCCESS)
4200 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004201 limLog(pMac, LOGP, FL("Unable to get Cfg param %d (Addts Rsp Timeout)"),
Jeff Johnson295189b2012-06-20 16:38:30 -07004202 WNI_CFG_ADDTS_RSP_TIMEOUT);
4203 return;
4204 }
4205
4206 timeout = SYS_MS_TO_TICKS(timeout);
4207 if (tx_timer_change(&pMac->lim.limTimers.gLimAddtsRspTimer, timeout, 0) != TX_SUCCESS)
4208 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004209 limLog(pMac, LOGP, FL("AddtsRsp timer change failed!"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004210 return;
4211 }
4212 pMac->lim.gLimAddtsRspTimerCount++;
4213 if (tx_timer_change_context(&pMac->lim.limTimers.gLimAddtsRspTimer,
4214 pMac->lim.gLimAddtsRspTimerCount) != TX_SUCCESS)
4215 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004216 limLog(pMac, LOGP, FL("AddtsRsp timer change failed!"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004217 return;
4218 }
Jeff Johnsone7245742012-09-05 17:12:55 -07004219 MTRACE(macTrace(pMac, TRACE_CODE_TIMER_ACTIVATE, psessionEntry->peSessionId, eLIM_ADDTS_RSP_TIMER));
Jeff Johnson295189b2012-06-20 16:38:30 -07004220
4221 //add the sessionId to the timer object
4222 pMac->lim.limTimers.gLimAddtsRspTimer.sessionId = sessionId;
4223 if (tx_timer_activate(&pMac->lim.limTimers.gLimAddtsRspTimer) != TX_SUCCESS)
4224 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004225 limLog(pMac, LOGP, FL("AddtsRsp timer activation failed!"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004226 return;
4227 }
4228 return;
4229}
4230
4231
4232static void
4233__limProcessSmeDeltsReq(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
4234{
4235 tSirMacAddr peerMacAddr;
4236 tANI_U8 ac;
4237 tSirMacTSInfo *pTsinfo;
4238 tpSirDeltsReq pDeltsReq = (tpSirDeltsReq) pMsgBuf;
4239 tpDphHashNode pStaDs = NULL;
4240 tpPESession psessionEntry;
4241 tANI_U8 sessionId;
4242 tANI_U32 status = eSIR_SUCCESS;
4243 tANI_U8 smesessionId;
4244 tANI_U16 smetransactionId;
4245
4246 limGetSessionInfo(pMac,(tANI_U8 *)pMsgBuf,&smesessionId,&smetransactionId);
4247
4248 if((psessionEntry = peFindSessionByBssid(pMac, pDeltsReq->bssId, &sessionId))== NULL)
4249 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004250 limLog(pMac, LOGE, "Session Does not exist for given bssId");
Jeff Johnson295189b2012-06-20 16:38:30 -07004251 status = eSIR_FAILURE;
4252 goto end;
4253 }
4254#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM //FEATURE_WLAN_DIAG_SUPPORT
4255 limDiagEventReport(pMac, WLAN_PE_DIAG_DELTS_REQ_EVENT, psessionEntry, 0, 0);
4256#endif //FEATURE_WLAN_DIAG_SUPPORT
4257
4258
4259 if (eSIR_SUCCESS != limValidateDeltsReq(pMac, pDeltsReq, peerMacAddr,psessionEntry))
4260 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004261 PELOGE(limLog(pMac, LOGE, FL("limValidateDeltsReq failed"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07004262 status = eSIR_FAILURE;
4263 limSendSmeDeltsRsp(pMac, pDeltsReq, eSIR_FAILURE,psessionEntry,smesessionId,smetransactionId);
4264 return;
4265 }
4266
Abhishek Singh3cbf6052014-12-15 16:46:42 +05304267 limLog(pMac, LOG1, FL("Sent DELTS request to station with "
4268 "assocId = %d MacAddr = "MAC_ADDRESS_STR),
4269 pDeltsReq->aid, MAC_ADDR_ARRAY(peerMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07004270
4271 limSendDeltsReqActionFrame(pMac, peerMacAddr, pDeltsReq->req.wmeTspecPresent, &pDeltsReq->req.tsinfo, &pDeltsReq->req.tspec,
4272 psessionEntry);
4273
4274 pTsinfo = pDeltsReq->req.wmeTspecPresent ? &pDeltsReq->req.tspec.tsinfo : &pDeltsReq->req.tsinfo;
4275
4276 /* We've successfully send DELTS frame to AP. Update the
4277 * dynamic UAPSD mask. The AC for this TSPEC to be deleted
4278 * is no longer trigger enabled or delivery enabled
4279 */
4280 limSetTspecUapsdMask(pMac, pTsinfo, CLEAR_UAPSD_MASK);
4281
4282 /* We're deleting the TSPEC, so this particular AC is no longer
4283 * admitted. PE needs to downgrade the EDCA
4284 * parameters(for the AC for which TS is being deleted) to the
4285 * next best AC for which ACM is not enabled, and send the
4286 * updated values to HAL.
4287 */
4288 ac = upToAc(pTsinfo->traffic.userPrio);
4289
4290 if(pTsinfo->traffic.direction == SIR_MAC_DIRECTION_UPLINK)
4291 {
4292 pMac->lim.gAcAdmitMask[SIR_MAC_DIRECTION_UPLINK] &= ~(1 << ac);
4293 }
4294 else if(pTsinfo->traffic.direction == SIR_MAC_DIRECTION_DNLINK)
4295 {
4296 pMac->lim.gAcAdmitMask[SIR_MAC_DIRECTION_DNLINK] &= ~(1 << ac);
4297 }
4298 else if(pTsinfo->traffic.direction == SIR_MAC_DIRECTION_BIDIR)
4299 {
4300 pMac->lim.gAcAdmitMask[SIR_MAC_DIRECTION_UPLINK] &= ~(1 << ac);
4301 pMac->lim.gAcAdmitMask[SIR_MAC_DIRECTION_DNLINK] &= ~(1 << ac);
4302 }
4303
4304 limSetActiveEdcaParams(pMac, psessionEntry->gLimEdcaParams, psessionEntry);
4305
4306 pStaDs = dphGetHashEntry(pMac, DPH_STA_HASH_INDEX_PEER, &psessionEntry->dph.dphHashTable);
4307 if (pStaDs != NULL)
4308 {
4309 if (pStaDs->aniPeer == eANI_BOOLEAN_TRUE)
4310 limSendEdcaParams(pMac, psessionEntry->gLimEdcaParamsActive, pStaDs->bssId, eANI_BOOLEAN_TRUE);
4311 else
4312 limSendEdcaParams(pMac, psessionEntry->gLimEdcaParamsActive, pStaDs->bssId, eANI_BOOLEAN_FALSE);
4313 status = eSIR_SUCCESS;
4314 }
4315 else
4316 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004317 limLog(pMac, LOGE, FL("Self entry missing in Hash Table "));
Jeff Johnson295189b2012-06-20 16:38:30 -07004318 status = eSIR_FAILURE;
4319 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004320#ifdef FEATURE_WLAN_ESE
4321#ifdef FEATURE_WLAN_ESE_UPLOAD
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004322 limSendSmeTsmIEInd(pMac, psessionEntry, 0, 0, 0);
4323#else
Jeff Johnson295189b2012-06-20 16:38:30 -07004324 limDeactivateAndChangeTimer(pMac,eLIM_TSM_TIMER);
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004325#endif /* FEATURE_WLAN_ESE_UPLOAD */
Jeff Johnson295189b2012-06-20 16:38:30 -07004326#endif
4327
4328 // send an sme response back
4329 end:
4330 limSendSmeDeltsRsp(pMac, pDeltsReq, eSIR_SUCCESS,psessionEntry,smesessionId,smetransactionId);
4331}
4332
4333
4334void
4335limProcessSmeAddtsRspTimeout(tpAniSirGlobal pMac, tANI_U32 param)
4336{
4337 //fetch the sessionEntry based on the sessionId
4338 tpPESession psessionEntry;
4339 if((psessionEntry = peFindSessionBySessionId(pMac, pMac->lim.limTimers.gLimAddtsRspTimer.sessionId))== NULL)
4340 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004341 limLog(pMac, LOGP,FL("Session Does not exist for given sessionID"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004342 return;
4343 }
4344
4345 if ( (psessionEntry->limSystemRole != eLIM_STA_ROLE) && (psessionEntry->limSystemRole != eLIM_BT_AMP_STA_ROLE) )
4346 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004347 limLog(pMac, LOGW, "AddtsRspTimeout in non-Sta role (%d)", psessionEntry->limSystemRole);
Jeff Johnson295189b2012-06-20 16:38:30 -07004348 pMac->lim.gLimAddtsSent = false;
4349 return;
4350 }
4351
4352 if (! pMac->lim.gLimAddtsSent)
4353 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004354 PELOGW(limLog(pMac, LOGW, "AddtsRspTimeout but no AddtsSent");)
Jeff Johnson295189b2012-06-20 16:38:30 -07004355 return;
4356 }
4357
4358 if (param != pMac->lim.gLimAddtsRspTimerCount)
4359 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004360 limLog(pMac, LOGE, FL("Invalid AddtsRsp Timer count %d (exp %d)"),
Jeff Johnson295189b2012-06-20 16:38:30 -07004361 param, pMac->lim.gLimAddtsRspTimerCount);
4362 return;
4363 }
4364
4365 // this a real response timeout
4366 pMac->lim.gLimAddtsSent = false;
4367 pMac->lim.gLimAddtsRspTimerCount++;
4368
4369 limSendSmeAddtsRsp(pMac, true, eSIR_SME_ADDTS_RSP_TIMEOUT, psessionEntry, pMac->lim.gLimAddtsReq.req.tspec,
4370 psessionEntry->smeSessionId, psessionEntry->transactionId);
4371}
4372
4373
4374/**
4375 * __limProcessSmeStatsRequest()
4376 *
4377 *FUNCTION:
4378 *
4379 *
4380 *NOTE:
4381 *
4382 * @param pMac Pointer to Global MAC structure
4383 * @param *pMsgBuf A pointer to the SME message buffer
4384 * @return None
4385 */
4386static void
4387__limProcessSmeStatsRequest(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
4388{
4389 tpAniGetStatsReq pStatsReq;
4390 tSirMsgQ msgQ;
4391 tpPESession psessionEntry;
4392 tANI_U8 sessionId;
4393
4394
4395 if(pMsgBuf == NULL)
4396 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004397 limLog(pMac, LOGE,FL("Buffer is Pointing to NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004398 return;
4399 }
4400
4401 pStatsReq = (tpAniGetStatsReq) pMsgBuf;
4402
4403 if((psessionEntry = peFindSessionByBssid(pMac,pStatsReq->bssId,&sessionId))== NULL)
4404 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004405 limLog(pMac, LOGE, FL("session does not exist for given bssId"));
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304406 vos_mem_free( pMsgBuf );
Leela Venkata Kiran Kumar Reddy Chiralad6c0fe22013-12-11 19:10:50 -08004407 pMsgBuf = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004408 return;
4409 }
4410
4411
4412
4413 switch(pStatsReq->msgType)
4414 {
4415 //Add Lim stats here. and send reqsponse.
4416
4417 //HAL maintained Stats.
4418 case eWNI_SME_STA_STAT_REQ:
4419 msgQ.type = WDA_STA_STAT_REQ;
4420 break;
4421 case eWNI_SME_AGGR_STAT_REQ:
4422 msgQ.type = WDA_AGGR_STAT_REQ;
4423 break;
4424 case eWNI_SME_GLOBAL_STAT_REQ:
4425 msgQ.type = WDA_GLOBAL_STAT_REQ;
4426 break;
4427 case eWNI_SME_STAT_SUMM_REQ:
4428 msgQ.type = WDA_STAT_SUMM_REQ;
4429 break;
4430 default: //Unknown request.
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004431 PELOGE(limLog(pMac, LOGE, "Unknown Statistics request");)
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304432 vos_mem_free( pMsgBuf );
Leela Venkata Kiran Kumar Reddy Chiralad6c0fe22013-12-11 19:10:50 -08004433 pMsgBuf = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004434 return;
4435 }
4436
Jeff Johnson295189b2012-06-20 16:38:30 -07004437 msgQ.reserved = 0;
4438 msgQ.bodyptr = pMsgBuf;
4439 msgQ.bodyval = 0;
Leela Venkata Kiran Kumar Reddy Chirala68a6abe2013-02-28 07:43:16 -08004440 if(NULL == psessionEntry)
4441 {
4442 MTRACE(macTraceMsgTx(pMac, NO_SESSION, msgQ.type));
4443 }
4444 else
4445 {
4446 MTRACE(macTraceMsgTx(pMac, psessionEntry->peSessionId, msgQ.type));
4447 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004448 if( eSIR_SUCCESS != (wdaPostCtrlMsg( pMac, &msgQ ))){
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004449 limLog(pMac, LOGP, "Unable to forward request");
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304450 vos_mem_free( pMsgBuf );
Leela Venkata Kiran Kumar Reddy Chiralad6c0fe22013-12-11 19:10:50 -08004451 pMsgBuf = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004452 return;
4453 }
4454
4455 return;
4456}
4457
4458
4459/**
4460 * __limProcessSmeGetStatisticsRequest()
4461 *
4462 *FUNCTION:
4463 *
4464 *
4465 *NOTE:
4466 *
4467 * @param pMac Pointer to Global MAC structure
4468 * @param *pMsgBuf A pointer to the SME message buffer
4469 * @return None
4470 */
4471static void
4472__limProcessSmeGetStatisticsRequest(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
4473{
4474 tpAniGetPEStatsReq pPEStatsReq;
4475 tSirMsgQ msgQ;
4476
4477 pPEStatsReq = (tpAniGetPEStatsReq) pMsgBuf;
4478
4479 //pPEStatsReq->msgType should be eWNI_SME_GET_STATISTICS_REQ
4480
4481 msgQ.type = WDA_GET_STATISTICS_REQ;
4482
Jeff Johnson295189b2012-06-20 16:38:30 -07004483 msgQ.reserved = 0;
4484 msgQ.bodyptr = pMsgBuf;
4485 msgQ.bodyval = 0;
Jeff Johnsone7245742012-09-05 17:12:55 -07004486 MTRACE(macTraceMsgTx(pMac, NO_SESSION, msgQ.type));
Jeff Johnson295189b2012-06-20 16:38:30 -07004487
4488 if( eSIR_SUCCESS != (wdaPostCtrlMsg( pMac, &msgQ ))){
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304489 vos_mem_free( pMsgBuf );
Leela Venkata Kiran Kumar Reddy Chiralad6c0fe22013-12-11 19:10:50 -08004490 pMsgBuf = NULL;
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004491 limLog(pMac, LOGP, "Unable to forward request");
Jeff Johnson295189b2012-06-20 16:38:30 -07004492 return;
4493 }
4494
4495 return;
4496}
4497
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004498#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004499/**
4500 *FUNCTION: __limProcessSmeGetTsmStatsRequest()
4501 *
4502 *NOTE:
4503 *
4504 * @param pMac Pointer to Global MAC structure
4505 * @param *pMsgBuf A pointer to the SME message buffer
4506 * @return None
4507 */
4508static void
4509__limProcessSmeGetTsmStatsRequest(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
4510{
4511 tSirMsgQ msgQ;
4512
4513 msgQ.type = WDA_TSM_STATS_REQ;
4514 msgQ.reserved = 0;
4515 msgQ.bodyptr = pMsgBuf;
4516 msgQ.bodyval = 0;
4517 MTRACE(macTraceMsgTx(pMac, NO_SESSION, msgQ.type));
4518
4519 if( eSIR_SUCCESS != (wdaPostCtrlMsg( pMac, &msgQ ))){
4520 vos_mem_free( pMsgBuf );
Leela Venkata Kiran Kumar Reddy Chiralad6c0fe22013-12-11 19:10:50 -08004521 pMsgBuf = NULL;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004522 limLog(pMac, LOGP, "Unable to forward request");
4523 return;
4524 }
4525}
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004526#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004527
4528
Jeff Johnson295189b2012-06-20 16:38:30 -07004529
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004530#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08004531/**
4532 * __limProcessSmeGetRoamRssiRequest()
4533 *
4534 *FUNCTION:
4535 *
4536 *
4537 *NOTE:
4538 *
4539 * @param pMac Pointer to Global MAC structure
4540 * @param *pMsgBuf A pointer to the SME message buffer
4541 * @return None
4542 */
4543static void
4544__limProcessSmeGetRoamRssiRequest(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
4545{
4546 tpAniGetRssiReq pPEGetRoamRssiReq = NULL;
4547 tSirMsgQ msgQ;
4548
4549 pPEGetRoamRssiReq = (tpAniGetRssiReq) pMsgBuf;
4550 msgQ.type = WDA_GET_ROAM_RSSI_REQ;
4551
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08004552 msgQ.reserved = 0;
4553 msgQ.bodyptr = pMsgBuf;
4554 msgQ.bodyval = 0;
4555 MTRACE(macTraceMsgTx(pMac, NO_SESSION, msgQ.type));
4556
4557 if( eSIR_SUCCESS != (wdaPostCtrlMsg( pMac, &msgQ ))){
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304558 vos_mem_free( pMsgBuf );
Leela Venkata Kiran Kumar Reddy Chiralad6c0fe22013-12-11 19:10:50 -08004559 pMsgBuf = NULL;
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004560 limLog(pMac, LOGP, "Unable to forward request");
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08004561 return;
4562 }
4563
4564 return;
4565}
4566#endif
4567
4568
Jeff Johnson295189b2012-06-20 16:38:30 -07004569static void
4570__limProcessSmeUpdateAPWPSIEs(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
4571{
4572 tpSirUpdateAPWPSIEsReq pUpdateAPWPSIEsReq;
4573 tpPESession psessionEntry;
4574 tANI_U8 sessionId; //PE sessionID
4575
4576 PELOG1(limLog(pMac, LOG1,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004577 FL("received UPDATE_APWPSIEs_REQ message")););
Jeff Johnson295189b2012-06-20 16:38:30 -07004578
4579 if(pMsgBuf == NULL)
4580 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004581 limLog(pMac, LOGE,FL("Buffer is Pointing to NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004582 return;
4583 }
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08004584
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304585 pUpdateAPWPSIEsReq = vos_mem_malloc(sizeof(tSirUpdateAPWPSIEsReq));
4586 if ( NULL == pUpdateAPWPSIEsReq )
Jeff Johnson295189b2012-06-20 16:38:30 -07004587 {
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304588 limLog(pMac, LOGP, FL("call to AllocateMemory failed for pUpdateAPWPSIEsReq"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004589 return;
4590 }
4591
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08004592 if ((limUpdateAPWPSIEsReqSerDes(pMac, pUpdateAPWPSIEsReq, (tANI_U8 *) pMsgBuf) == eSIR_FAILURE))
Jeff Johnson295189b2012-06-20 16:38:30 -07004593 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004594 limLog(pMac, LOGW, FL("received invalid SME_SETCONTEXT_REQ message"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004595 goto end;
4596 }
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08004597
Jeff Johnson295189b2012-06-20 16:38:30 -07004598 if((psessionEntry = peFindSessionByBssid(pMac, pUpdateAPWPSIEsReq->bssId, &sessionId)) == NULL)
4599 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004600 limLog(pMac, LOGW, FL("Session does not exist for given BSSID"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004601 goto end;
4602 }
4603
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304604 vos_mem_copy( &psessionEntry->APWPSIEs, &pUpdateAPWPSIEsReq->APWPSIEs, sizeof(tSirAPWPSIEs));
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08004605
Jeff Johnson295189b2012-06-20 16:38:30 -07004606 schSetFixedBeaconFields(pMac, psessionEntry);
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08004607 limSendBeaconInd(pMac, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07004608
4609end:
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304610 vos_mem_free( pUpdateAPWPSIEsReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07004611 return;
4612} /*** end __limProcessSmeUpdateAPWPSIEs(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf) ***/
4613
4614static void
4615__limProcessSmeHideSSID(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
4616{
4617 tpSirUpdateParams pUpdateParams;
4618 tpPESession psessionEntry;
4619
Abhishek Singh3cbf6052014-12-15 16:46:42 +05304620 limLog(pMac, LOG1,
4621 FL("received SME_HIDE_SSID message"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004622
4623 if(pMsgBuf == NULL)
4624 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004625 limLog(pMac, LOGE,FL("Buffer is Pointing to NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004626 return;
4627 }
4628
4629 pUpdateParams = (tpSirUpdateParams)pMsgBuf;
4630
4631 if((psessionEntry = peFindSessionBySessionId(pMac, pUpdateParams->sessionId)) == NULL)
4632 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004633 limLog(pMac, LOGW, "Session does not exist for given sessionId %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07004634 pUpdateParams->sessionId);
4635 return;
4636 }
4637
4638 /* Update the session entry */
4639 psessionEntry->ssidHidden = pUpdateParams->ssidHidden;
4640
4641 /* Update beacon */
4642 schSetFixedBeaconFields(pMac, psessionEntry);
4643 limSendBeaconInd(pMac, psessionEntry);
4644
4645 return;
4646} /*** end __limProcessSmeHideSSID(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf) ***/
4647
4648static void
4649__limProcessSmeSetWPARSNIEs(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
4650{
4651 tpSirUpdateAPWPARSNIEsReq pUpdateAPWPARSNIEsReq;
4652 tpPESession psessionEntry;
4653 tANI_U8 sessionId; //PE sessionID
4654
4655 if(pMsgBuf == NULL)
4656 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004657 limLog(pMac, LOGE,FL("Buffer is Pointing to NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004658 return;
4659 }
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304660
4661 pUpdateAPWPARSNIEsReq = vos_mem_malloc(sizeof(tSirUpdateAPWPSIEsReq));
4662 if ( NULL == pUpdateAPWPARSNIEsReq )
Jeff Johnson295189b2012-06-20 16:38:30 -07004663 {
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304664 limLog(pMac, LOGP, FL("call to AllocateMemory failed for pUpdateAPWPARSNIEsReq"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004665 return;
4666 }
4667
4668 if ((limUpdateAPWPARSNIEsReqSerDes(pMac, pUpdateAPWPARSNIEsReq, (tANI_U8 *) pMsgBuf) == eSIR_FAILURE))
4669 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004670 limLog(pMac, LOGW, FL("received invalid SME_SETCONTEXT_REQ message"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004671 goto end;
4672 }
4673
4674 if((psessionEntry = peFindSessionByBssid(pMac, pUpdateAPWPARSNIEsReq->bssId, &sessionId)) == NULL)
4675 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004676 limLog(pMac, LOGW, FL("Session does not exist for given BSSID"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004677 goto end;
4678 }
4679
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304680 vos_mem_copy(&psessionEntry->pLimStartBssReq->rsnIE,
4681 &pUpdateAPWPARSNIEsReq->APWPARSNIEs, sizeof(tSirRSNie));
Jeff Johnson295189b2012-06-20 16:38:30 -07004682
4683 limSetRSNieWPAiefromSmeStartBSSReqMessage(pMac, &psessionEntry->pLimStartBssReq->rsnIE, psessionEntry);
4684
4685 psessionEntry->pLimStartBssReq->privacy = 1;
4686 psessionEntry->privacy = 1;
4687
4688 schSetFixedBeaconFields(pMac, psessionEntry);
4689 limSendBeaconInd(pMac, psessionEntry);
4690
4691end:
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304692 vos_mem_free(pUpdateAPWPARSNIEsReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07004693 return;
4694} /*** end __limProcessSmeSetWPARSNIEs(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf) ***/
4695
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08004696/*
4697Update the beacon Interval dynamically if beaconInterval is different in MCC
4698*/
4699static void
4700__limProcessSmeChangeBI(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
4701{
4702 tpSirChangeBIParams pChangeBIParams;
4703 tpPESession psessionEntry;
4704 tANI_U8 sessionId = 0;
4705 tUpdateBeaconParams beaconParams;
4706
4707 PELOG1(limLog(pMac, LOG1,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004708 FL("received Update Beacon Interval message")););
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08004709
4710 if(pMsgBuf == NULL)
4711 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004712 limLog(pMac, LOGE,FL("Buffer is Pointing to NULL"));
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08004713 return;
4714 }
4715
Kaushik, Sushantfb156732014-01-07 15:36:03 +05304716 vos_mem_zero(&beaconParams, sizeof(tUpdateBeaconParams));
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08004717 pChangeBIParams = (tpSirChangeBIParams)pMsgBuf;
4718
4719 if((psessionEntry = peFindSessionByBssid(pMac, pChangeBIParams->bssId, &sessionId)) == NULL)
4720 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004721 limLog(pMac, LOGE, FL("Session does not exist for given BSSID"));
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08004722 return;
4723 }
4724
4725 /*Update sessionEntry Beacon Interval*/
4726 if(psessionEntry->beaconParams.beaconInterval !=
4727 pChangeBIParams->beaconInterval )
4728 {
4729 psessionEntry->beaconParams.beaconInterval = pChangeBIParams->beaconInterval;
4730 }
4731
4732 /*Update sch beaconInterval*/
4733 if(pMac->sch.schObject.gSchBeaconInterval !=
4734 pChangeBIParams->beaconInterval )
4735 {
4736 pMac->sch.schObject.gSchBeaconInterval = pChangeBIParams->beaconInterval;
4737
4738 PELOG1(limLog(pMac, LOG1,
4739 FL("LIM send update BeaconInterval Indication : %d"),pChangeBIParams->beaconInterval););
4740
4741 /* Update beacon */
4742 schSetFixedBeaconFields(pMac, psessionEntry);
4743
Sunil Ravib96f7b52013-05-22 21:40:05 -07004744 beaconParams.bssIdx = psessionEntry->bssIdx;
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08004745 //Set change in beacon Interval
4746 beaconParams.beaconInterval = pChangeBIParams->beaconInterval;
Jeff Johnson312557b2013-04-03 16:27:48 -07004747 beaconParams.paramChangeBitmap = PARAM_BCN_INTERVAL_CHANGED;
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08004748 limSendBeaconParams(pMac, &beaconParams, psessionEntry);
4749 }
4750
4751 return;
4752} /*** end __limProcessSmeChangeBI(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf) ***/
4753
Hardik Kantilal Patel62a3a762014-11-21 12:55:57 +05304754/** -------------------------------------------------------------
4755\fn
4756\brief handles indication message from HDD to update HT mode
4757\param tpAniSirGlobal pMac
4758\param tANI_U32 pMsgBuf
4759\return None
4760-------------------------------------------------------------*/
4761#ifdef WLAN_FEATURE_AP_HT40_24G
4762static void __limProcessSmeSetHT2040Mode(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
4763{
4764 tpSirSetHT2040Mode pSetHT2040Mode;
4765 tpPESession psessionEntry;
4766 tANI_U8 sessionId = 0;
4767 tUpdateVHTOpMode *pHtOpMode = NULL;
4768 vos_msg_t msg;
Jeff Johnson295189b2012-06-20 16:38:30 -07004769
Hardik Kantilal Patel62a3a762014-11-21 12:55:57 +05304770 PELOG1(limLog(pMac, LOGRW,
4771 FL("received Set HT 20/40 mode message")););
4772
4773 if(pMsgBuf == NULL)
4774 {
4775 limLog(pMac, LOGE,FL("Buffer is Pointing to NULL"));
4776 return;
4777 }
4778
4779 pSetHT2040Mode = (tpSirSetHT2040Mode)pMsgBuf;
4780
4781 if((psessionEntry = peFindSessionByBssid(pMac, pSetHT2040Mode->bssId,
4782 &sessionId)) == NULL)
4783 {
4784 limLog(pMac, LOGE, FL("Session does not exist for given BSSID "));
4785 limPrintMacAddr(pMac, pSetHT2040Mode->bssId, LOGE);
4786 return;
4787 }
4788
4789 limLog(pMac, LOGW, FL("Update session entry for cbMod=%d"),
4790 pSetHT2040Mode->cbMode);
4791
4792 /*Update sessionEntry HT related fields*/
4793 switch(pSetHT2040Mode->cbMode)
4794 {
4795 case PHY_SINGLE_CHANNEL_CENTERED:
4796 psessionEntry->htSecondaryChannelOffset = PHY_SINGLE_CHANNEL_CENTERED;
4797 psessionEntry->htRecommendedTxWidthSet = 0;
4798 break;
4799 case PHY_DOUBLE_CHANNEL_LOW_PRIMARY:
4800 psessionEntry->htSecondaryChannelOffset =
4801 PHY_DOUBLE_CHANNEL_LOW_PRIMARY;
4802 psessionEntry->htRecommendedTxWidthSet = 1;
4803 break;
4804 case PHY_DOUBLE_CHANNEL_HIGH_PRIMARY:
4805 psessionEntry->htSecondaryChannelOffset =
4806 PHY_DOUBLE_CHANNEL_HIGH_PRIMARY;
4807 psessionEntry->htRecommendedTxWidthSet = 1;
4808 break;
4809 default:
4810 limLog(pMac, LOGE,FL("Invalid cbMode"));
4811 return;
4812 }
4813
4814 limLog(pMac, LOGW, FL("Channel Bonding mode : %d"
4815 " htSecondaryChannelOffset: %d"
4816 " htRecommendedTxWidthSet :%d"),
4817 pSetHT2040Mode->cbMode,
4818 psessionEntry->htSecondaryChannelOffset,
4819 psessionEntry->htRecommendedTxWidthSet);
4820
4821 limLog(pMac, LOGW, FL("Update Beacon IEs"));
4822
4823 /* Update beacon */
4824 schSetFixedBeaconFields(pMac, psessionEntry);
4825 limSendBeaconInd(pMac, psessionEntry);
4826
4827 /* Update OP Mode */
4828 pHtOpMode = vos_mem_malloc(sizeof(tUpdateVHTOpMode));
4829 if ( NULL == pHtOpMode )
4830 {
4831 limLog(pMac, LOGE,
4832 FL("Not able to allocate memory for setting OP mode"));
4833 return;
4834 }
4835
4836 pHtOpMode->opMode = (psessionEntry->htSecondaryChannelOffset ==
4837 PHY_SINGLE_CHANNEL_CENTERED)?
4838 eHT_CHANNEL_WIDTH_20MHZ:eHT_CHANNEL_WIDTH_40MHZ;
4839
4840 /* Pass Self STA ID to FW. Based on Self STA ID FW will update the
4841 * operating mode for all connected STA.
4842 */
4843
4844 pHtOpMode->staId = psessionEntry->staId;
4845
4846 msg.type = WDA_UPDATE_OP_MODE;
4847 msg.reserved = 0;
4848 msg.bodyptr = pHtOpMode;
4849
4850 if (!VOS_IS_STATUS_SUCCESS(
4851 vos_mq_post_message(VOS_MODULE_ID_WDA, &msg)))
4852 {
4853 limLog(pMac, LOGE,
4854 FL("Not able to post WDA_UPDATE_OP_MODE message to WDA"));
4855 vos_mem_free(pHtOpMode);
4856 return;
4857 }
4858
4859 limLog(pMac, LOGW,
4860 FL("Notifed FW about OP mode: %d for staId=%d"),
4861 pHtOpMode->opMode, pHtOpMode->staId);
4862
4863 return;
4864}
4865#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004866
4867/** -------------------------------------------------------------
4868\fn limProcessSmeDelBaPeerInd
4869\brief handles indication message from HDD to send delete BA request
4870\param tpAniSirGlobal pMac
4871\param tANI_U32 pMsgBuf
4872\return None
4873-------------------------------------------------------------*/
4874void
4875limProcessSmeDelBaPeerInd(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
4876{
4877 tANI_U16 assocId =0;
4878 tpSmeDelBAPeerInd pSmeDelBAPeerInd = (tpSmeDelBAPeerInd)pMsgBuf;
4879 tpDphHashNode pSta;
4880 tpPESession psessionEntry;
4881 tANI_U8 sessionId;
4882
4883
4884
4885 if(NULL == pSmeDelBAPeerInd)
4886 return;
4887
4888 if ((psessionEntry = peFindSessionByBssid(pMac,pSmeDelBAPeerInd->bssId,&sessionId))==NULL)
4889 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004890 limLog(pMac, LOGE,FL("session does not exist for given bssId"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004891 return;
4892 }
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004893 limLog(pMac, LOGW, FL("called with staId = %d, tid = %d, baDirection = %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07004894 pSmeDelBAPeerInd->staIdx, pSmeDelBAPeerInd->baTID, pSmeDelBAPeerInd->baDirection);
4895
4896 pSta = dphLookupAssocId(pMac, pSmeDelBAPeerInd->staIdx, &assocId, &psessionEntry->dph.dphHashTable);
4897 if( eSIR_SUCCESS != limPostMlmDelBAReq( pMac,
4898 pSta,
4899 pSmeDelBAPeerInd->baDirection,
4900 pSmeDelBAPeerInd->baTID,
4901 eSIR_MAC_UNSPEC_FAILURE_REASON,psessionEntry))
4902 {
4903 limLog( pMac, LOGW,
4904 FL( "Failed to post LIM_MLM_DELBA_REQ to " ));
4905 if (pSta)
4906 limPrintMacAddr(pMac, pSta->staAddr, LOGW);
4907 }
4908}
4909
4910// --------------------------------------------------------------------
4911/**
4912 * __limProcessReportMessage
4913 *
4914 * FUNCTION: Processes the next received Radio Resource Management message
4915 *
4916 * LOGIC:
4917 *
4918 * ASSUMPTIONS:
4919 *
4920 * NOTE:
4921 *
4922 * @param None
4923 * @return None
4924 */
4925
4926void __limProcessReportMessage(tpAniSirGlobal pMac, tpSirMsgQ pMsg)
4927{
4928#ifdef WLAN_FEATURE_VOWIFI
4929 switch (pMsg->type)
4930 {
4931 case eWNI_SME_NEIGHBOR_REPORT_REQ_IND:
4932 rrmProcessNeighborReportReq( pMac, pMsg->bodyptr );
4933 break;
4934 case eWNI_SME_BEACON_REPORT_RESP_XMIT_IND:
4935 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004936#if defined(FEATURE_WLAN_ESE) && !defined(FEATURE_WLAN_ESE_UPLOAD)
Jeff Johnson295189b2012-06-20 16:38:30 -07004937 tpSirBeaconReportXmitInd pBcnReport=NULL;
4938 tpPESession psessionEntry=NULL;
4939 tANI_U8 sessionId;
4940
4941 if(pMsg->bodyptr == NULL)
4942 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004943 limLog(pMac, LOGE,FL("Buffer is Pointing to NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004944 return;
4945 }
4946 pBcnReport = (tpSirBeaconReportXmitInd )pMsg->bodyptr;
4947 if((psessionEntry = peFindSessionByBssid(pMac, pBcnReport->bssId,&sessionId))== NULL)
4948 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004949 limLog(pMac, LOGE, "Session Does not exist for given bssId");
Jeff Johnson295189b2012-06-20 16:38:30 -07004950 return;
4951 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004952 if (psessionEntry->isESEconnection)
4953 eseProcessBeaconReportXmit( pMac, pMsg->bodyptr);
Jeff Johnson295189b2012-06-20 16:38:30 -07004954 else
4955#endif
4956 rrmProcessBeaconReportXmit( pMac, pMsg->bodyptr );
4957 }
4958 break;
4959 }
4960#endif
4961}
4962
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004963#if defined(FEATURE_WLAN_ESE) || defined(WLAN_FEATURE_VOWIFI)
Jeff Johnson295189b2012-06-20 16:38:30 -07004964// --------------------------------------------------------------------
4965/**
4966 * limSendSetMaxTxPowerReq
4967 *
4968 * FUNCTION: Send SIR_HAL_SET_MAX_TX_POWER_REQ message to change the max tx power.
4969 *
4970 * LOGIC:
4971 *
4972 * ASSUMPTIONS:
4973 *
4974 * NOTE:
4975 *
4976 * @param txPower txPower to be set.
4977 * @param pSessionEntry session entry.
4978 * @return None
4979 */
4980tSirRetStatus
4981limSendSetMaxTxPowerReq ( tpAniSirGlobal pMac, tPowerdBm txPower, tpPESession pSessionEntry )
4982{
4983 tpMaxTxPowerParams pMaxTxParams = NULL;
4984 tSirRetStatus retCode = eSIR_SUCCESS;
4985 tSirMsgQ msgQ;
4986
4987 if( pSessionEntry == NULL )
4988 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004989 PELOGE(limLog(pMac, LOGE, "%s:%d: Inavalid parameters", __func__, __LINE__ );)
Jeff Johnson295189b2012-06-20 16:38:30 -07004990 return eSIR_FAILURE;
4991 }
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304992
4993 pMaxTxParams = vos_mem_malloc(sizeof(tMaxTxPowerParams));
4994 if ( NULL == pMaxTxParams )
Jeff Johnson295189b2012-06-20 16:38:30 -07004995 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004996 limLog( pMac, LOGP, "%s:%d:Unable to allocate memory for pMaxTxParams ", __func__, __LINE__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004997 return eSIR_MEM_ALLOC_FAILED;
4998
4999 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005000#if defined(WLAN_VOWIFI_DEBUG) || defined(FEATURE_WLAN_ESE)
Abhishek Singh3cbf6052014-12-15 16:46:42 +05305001 limLog( pMac, LOG1,
5002 FL(" Allocated memory for pMaxTxParams, which will be freed in other module"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005003#endif
Kiran Kumar Lokerea4db3dc2013-03-25 18:05:24 -07005004 if( pMaxTxParams == NULL )
5005 {
Abhishek Singh3cbf6052014-12-15 16:46:42 +05305006 limLog( pMac, LOGE, FL("pMaxTxParams is NULL"));
Kiran Kumar Lokerea4db3dc2013-03-25 18:05:24 -07005007 return eSIR_FAILURE;
5008 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005009 pMaxTxParams->power = txPower;
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05305010 vos_mem_copy( pMaxTxParams->bssId, pSessionEntry->bssId, sizeof(tSirMacAddr) );
5011 vos_mem_copy( pMaxTxParams->selfStaMacAddr, pSessionEntry->selfMacAddr, sizeof(tSirMacAddr) );
Jeff Johnson295189b2012-06-20 16:38:30 -07005012
Jeff Johnson68ce9c42013-04-08 10:33:28 -07005013 msgQ.type = WDA_SET_MAX_TX_POWER_REQ;
5014 msgQ.bodyptr = pMaxTxParams;
5015 msgQ.bodyval = 0;
Abhishek Singh3cbf6052014-12-15 16:46:42 +05305016 limLog(pMac, LOG1, FL("Posting WDA_SET_MAX_TX_POWER_REQ to WDA"));
Jeff Johnson68ce9c42013-04-08 10:33:28 -07005017 MTRACE(macTraceMsgTx(pMac, pSessionEntry->peSessionId, msgQ.type));
5018 retCode = wdaPostCtrlMsg(pMac, &msgQ);
5019 if (eSIR_SUCCESS != retCode)
5020 {
5021 PELOGE(limLog(pMac, LOGE, FL("wdaPostCtrlMsg() failed"));)
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05305022 vos_mem_free(pMaxTxParams);
Jeff Johnson68ce9c42013-04-08 10:33:28 -07005023 }
5024 return retCode;
Jeff Johnson295189b2012-06-20 16:38:30 -07005025}
5026#endif
5027
5028/**
5029 * __limProcessSmeAddStaSelfReq()
5030 *
5031 *FUNCTION:
5032 * This function is called to process SME_ADD_STA_SELF_REQ message
5033 * from SME. It sends a SIR_HAL_ADD_STA_SELF_REQ message to HAL.
5034 *
5035 *LOGIC:
5036 *
5037 *ASSUMPTIONS:
5038 *
5039 *NOTE:
5040 *
5041 * @param pMac Pointer to Global MAC structure
5042 * @param *pMsgBuf A pointer to the SME message buffer
5043 * @return None
5044 */
5045
5046static void
5047__limProcessSmeAddStaSelfReq(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
5048{
5049 tSirMsgQ msg;
5050 tpAddStaSelfParams pAddStaSelfParams;
5051 tpSirSmeAddStaSelfReq pSmeReq = (tpSirSmeAddStaSelfReq) pMsgBuf;
5052
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05305053 pAddStaSelfParams = vos_mem_malloc(sizeof(tAddStaSelfParams));
5054 if ( NULL == pAddStaSelfParams )
Jeff Johnson295189b2012-06-20 16:38:30 -07005055 {
5056 limLog( pMac, LOGP, FL("Unable to allocate memory for tAddSelfStaParams") );
5057 return;
5058 }
5059
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05305060 vos_mem_copy( pAddStaSelfParams->selfMacAddr, pSmeReq->selfMacAddr, sizeof(tSirMacAddr) );
Kiran Kumar Lokeread7dbc82013-10-07 20:12:50 -07005061 pAddStaSelfParams->currDeviceMode = pSmeReq->currDeviceMode;
Jeff Johnson295189b2012-06-20 16:38:30 -07005062 msg.type = SIR_HAL_ADD_STA_SELF_REQ;
5063 msg.reserved = 0;
5064 msg.bodyptr = pAddStaSelfParams;
5065 msg.bodyval = 0;
5066
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005067 PELOGW(limLog(pMac, LOG1, FL("sending SIR_HAL_ADD_STA_SELF_REQ msg to HAL"));)
Jeff Johnsone7245742012-09-05 17:12:55 -07005068 MTRACE(macTraceMsgTx(pMac, NO_SESSION, msg.type));
Jeff Johnson295189b2012-06-20 16:38:30 -07005069
5070 if(eSIR_SUCCESS != wdaPostCtrlMsg(pMac, &msg))
5071 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005072 limLog(pMac, LOGP, FL("wdaPostCtrlMsg failed"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005073 }
5074 return;
5075} /*** end __limProcessAddStaSelfReq() ***/
5076
5077
5078/**
5079 * __limProcessSmeDelStaSelfReq()
5080 *
5081 *FUNCTION:
5082 * This function is called to process SME_DEL_STA_SELF_REQ message
5083 * from SME. It sends a SIR_HAL_DEL_STA_SELF_REQ message to HAL.
5084 *
5085 *LOGIC:
5086 *
5087 *ASSUMPTIONS:
5088 *
5089 *NOTE:
5090 *
5091 * @param pMac Pointer to Global MAC structure
5092 * @param *pMsgBuf A pointer to the SME message buffer
5093 * @return None
5094 */
5095
5096static void
5097__limProcessSmeDelStaSelfReq(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
5098{
5099 tSirMsgQ msg;
5100 tpDelStaSelfParams pDelStaSelfParams;
5101 tpSirSmeDelStaSelfReq pSmeReq = (tpSirSmeDelStaSelfReq) pMsgBuf;
5102
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05305103 pDelStaSelfParams = vos_mem_malloc(sizeof( tDelStaSelfParams));
5104 if ( NULL == pDelStaSelfParams )
Jeff Johnson295189b2012-06-20 16:38:30 -07005105 {
5106 limLog( pMac, LOGP, FL("Unable to allocate memory for tDelStaSelfParams") );
5107 return;
5108 }
5109
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05305110 vos_mem_copy( pDelStaSelfParams->selfMacAddr, pSmeReq->selfMacAddr, sizeof(tSirMacAddr) );
Jeff Johnson295189b2012-06-20 16:38:30 -07005111
5112 msg.type = SIR_HAL_DEL_STA_SELF_REQ;
5113 msg.reserved = 0;
5114 msg.bodyptr = pDelStaSelfParams;
5115 msg.bodyval = 0;
5116
Mukul Sharmacaf4aca2015-04-17 20:01:40 +05305117 PELOGW(limLog(pMac, LOG1, FL("sending SIR_HAL_DEL_STA_SELF_REQ msg to HAL"));)
Jeff Johnsone7245742012-09-05 17:12:55 -07005118 MTRACE(macTraceMsgTx(pMac, NO_SESSION, msg.type));
Jeff Johnson295189b2012-06-20 16:38:30 -07005119
5120 if(eSIR_SUCCESS != wdaPostCtrlMsg(pMac, &msg))
5121 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005122 limLog(pMac, LOGP, FL("wdaPostCtrlMsg failed"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005123 }
5124 return;
5125} /*** end __limProcessSmeDelStaSelfReq() ***/
5126
5127
Jeff Johnson295189b2012-06-20 16:38:30 -07005128/**
5129 * __limProcessSmeRegisterMgmtFrameReq()
5130 *
5131 *FUNCTION:
5132 * This function is called to process eWNI_SME_REGISTER_MGMT_FRAME_REQ message
5133 * from SME. It Register this information within PE.
5134 *
5135 *LOGIC:
5136 *
5137 *ASSUMPTIONS:
5138 *
5139 *NOTE:
5140 *
5141 * @param pMac Pointer to Global MAC structure
5142 * @param *pMsgBuf A pointer to the SME message buffer
5143 * @return None
5144 */
5145static void
5146__limProcessSmeRegisterMgmtFrameReq(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
5147{
5148 VOS_STATUS vosStatus;
5149 tpSirRegisterMgmtFrame pSmeReq = (tpSirRegisterMgmtFrame)pMsgBuf;
5150 tpLimMgmtFrameRegistration pLimMgmtRegistration = NULL, pNext = NULL;
Jeff Johnsond13512a2012-07-17 11:42:19 -07005151 tANI_BOOLEAN match = VOS_FALSE;
Abhishek Singh3cbf6052014-12-15 16:46:42 +05305152 limLog(pMac, LOG1,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005153 FL("registerFrame %d, frameType %d, matchLen %d"),
Abhishek Singh3cbf6052014-12-15 16:46:42 +05305154 pSmeReq->registerFrame, pSmeReq->frameType, pSmeReq->matchLen);
Jeff Johnson295189b2012-06-20 16:38:30 -07005155
Jeff Johnsond13512a2012-07-17 11:42:19 -07005156 /* First check whether entry exists already*/
5157
5158 vos_list_peek_front(&pMac->lim.gLimMgmtFrameRegistratinQueue,
5159 (vos_list_node_t**)&pLimMgmtRegistration);
5160
5161 while(pLimMgmtRegistration != NULL)
5162 {
5163 if (pLimMgmtRegistration->frameType == pSmeReq->frameType)
5164 {
5165 if(pSmeReq->matchLen)
5166 {
5167 if (pLimMgmtRegistration->matchLen == pSmeReq->matchLen)
5168 {
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05305169 if (vos_mem_compare( pLimMgmtRegistration->matchData,
Jeff Johnsond13512a2012-07-17 11:42:19 -07005170 pSmeReq->matchData, pLimMgmtRegistration->matchLen))
5171 {
Madan Mohan Koyyalamudic537df22012-10-22 15:07:08 -07005172 /* found match! */
5173 match = VOS_TRUE;
5174 break;
Jeff Johnsond13512a2012-07-17 11:42:19 -07005175 }
5176 }
5177 }
5178 else
5179 {
Madan Mohan Koyyalamudic537df22012-10-22 15:07:08 -07005180 /* found match! */
Jeff Johnsond13512a2012-07-17 11:42:19 -07005181 match = VOS_TRUE;
5182 break;
5183 }
5184 }
5185 vosStatus = vos_list_peek_next (
5186 &pMac->lim.gLimMgmtFrameRegistratinQueue,
5187 (vos_list_node_t*) pLimMgmtRegistration,
5188 (vos_list_node_t**) &pNext );
5189
5190 pLimMgmtRegistration = pNext;
5191 pNext = NULL;
5192
5193 }
5194
5195 if (match)
5196 {
5197 vos_list_remove_node(&pMac->lim.gLimMgmtFrameRegistratinQueue,
5198 (vos_list_node_t*)pLimMgmtRegistration);
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05305199 vos_mem_free(pLimMgmtRegistration);
Jeff Johnsond13512a2012-07-17 11:42:19 -07005200 }
5201
Jeff Johnson295189b2012-06-20 16:38:30 -07005202 if(pSmeReq->registerFrame)
5203 {
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05305204 pLimMgmtRegistration = vos_mem_malloc(sizeof(tLimMgmtFrameRegistration) + pSmeReq->matchLen);
5205 if ( pLimMgmtRegistration != NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -07005206 {
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05305207 vos_mem_set((void*)pLimMgmtRegistration,
5208 sizeof(tLimMgmtFrameRegistration) + pSmeReq->matchLen, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005209 pLimMgmtRegistration->frameType = pSmeReq->frameType;
5210 pLimMgmtRegistration->matchLen = pSmeReq->matchLen;
5211 pLimMgmtRegistration->sessionId = pSmeReq->sessionId;
5212 if(pSmeReq->matchLen)
5213 {
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05305214 vos_mem_copy(pLimMgmtRegistration->matchData,
5215 pSmeReq->matchData, pSmeReq->matchLen);
Jeff Johnson295189b2012-06-20 16:38:30 -07005216 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005217 vos_list_insert_front(&pMac->lim.gLimMgmtFrameRegistratinQueue,
5218 &pLimMgmtRegistration->node);
5219 }
5220 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005221
5222 return;
5223} /*** end __limProcessSmeRegisterMgmtFrameReq() ***/
Viral Modid86bde22012-12-10 13:09:21 -08005224
5225static tANI_BOOLEAN
Viral Modid440e682013-03-06 02:25:31 -08005226__limInsertSingleShotNOAForScan(tpAniSirGlobal pMac, tANI_U32 noaDuration)
Viral Modid86bde22012-12-10 13:09:21 -08005227{
5228 tpP2pPsParams pMsgNoA;
5229 tSirMsgQ msg;
Vinay Malekal62757362012-12-17 12:15:51 -08005230
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05305231 pMsgNoA = vos_mem_malloc(sizeof( tP2pPsConfig ));
5232 if ( NULL == pMsgNoA )
Viral Modid86bde22012-12-10 13:09:21 -08005233 {
5234 limLog( pMac, LOGP,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005235 FL( "Unable to allocate memory during NoA Update" ));
Viral Modid440e682013-03-06 02:25:31 -08005236 goto error;
Viral Modid86bde22012-12-10 13:09:21 -08005237 }
5238
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05305239 vos_mem_set((tANI_U8 *)pMsgNoA, sizeof(tP2pPsConfig), 0);
Viral Modid86bde22012-12-10 13:09:21 -08005240 /* Below params used for opp PS/periodic NOA and are don't care in this case - so initialized to 0 */
5241 pMsgNoA->opp_ps = 0;
5242 pMsgNoA->ctWindow = 0;
5243 pMsgNoA->duration = 0;
5244 pMsgNoA->interval = 0;
5245 pMsgNoA->count = 0;
Vinay Malekal62757362012-12-17 12:15:51 -08005246
Vinay Malekal62757362012-12-17 12:15:51 -08005247 /* Below params used for Single Shot NOA - so assign proper values */
5248 pMsgNoA->psSelection = P2P_SINGLE_NOA;
Viral Modid440e682013-03-06 02:25:31 -08005249 pMsgNoA->single_noa_duration = noaDuration;
Gopichand Nakkala096a1052012-12-21 07:05:34 -08005250
Viral Modid86bde22012-12-10 13:09:21 -08005251 /* Start Insert NOA timer
5252 * 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 -08005253 * or any other failure or reason, we still need to process the deferred SME req. The insert NOA
5254 * timer of 500 ms will ensure the stored SME req always gets processed
Viral Modid86bde22012-12-10 13:09:21 -08005255 */
5256 if (tx_timer_activate(&pMac->lim.limTimers.gLimP2pSingleShotNoaInsertTimer)
5257 == TX_TIMER_ERROR)
5258 {
5259 /// Could not activate Insert NOA timer.
5260 // Log error
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005261 limLog(pMac, LOGP, FL("could not activate Insert Single Shot NOA during scan timer"));
Viral Modid86bde22012-12-10 13:09:21 -08005262
5263 // send the scan response back with status failure and do not even call insert NOA
5264 limSendSmeScanRsp(pMac, sizeof(tSirSmeScanRsp), eSIR_SME_SCAN_FAILED, pMac->lim.gSmeSessionId, pMac->lim.gTransactionId);
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05305265 vos_mem_free(pMsgNoA);
Viral Modid440e682013-03-06 02:25:31 -08005266 goto error;
Viral Modid86bde22012-12-10 13:09:21 -08005267 }
5268
Viral Modid440e682013-03-06 02:25:31 -08005269 MTRACE(macTrace(pMac, TRACE_CODE_TIMER_ACTIVATE, NO_SESSION, eLIM_INSERT_SINGLESHOT_NOA_TIMER));
5270
Viral Modid86bde22012-12-10 13:09:21 -08005271 msg.type = WDA_SET_P2P_GO_NOA_REQ;
5272 msg.reserved = 0;
5273 msg.bodyptr = pMsgNoA;
5274 msg.bodyval = 0;
5275
5276 if(eSIR_SUCCESS != wdaPostCtrlMsg(pMac, &msg))
5277 {
5278 /* 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 -07005279 limLog(pMac, LOGP, FL("wdaPost Msg failed"));
Viral Modid440e682013-03-06 02:25:31 -08005280 /* Deactivate the NOA timer in failure case */
5281 limDeactivateAndChangeTimer(pMac, eLIM_INSERT_SINGLESHOT_NOA_TIMER);
5282 goto error;
Viral Modid86bde22012-12-10 13:09:21 -08005283 }
Viral Modid440e682013-03-06 02:25:31 -08005284 return FALSE;
Viral Modid86bde22012-12-10 13:09:21 -08005285
Viral Modid440e682013-03-06 02:25:31 -08005286error:
5287 /* In any of the failure cases, just go ahead with the processing of registered deferred SME request without
5288 * worrying about the NOA
5289 */
5290 limProcessRegdDefdSmeReqAfterNOAStart(pMac);
5291 // msg buffer is consumed and freed in above function so return FALSE
Viral Modid86bde22012-12-10 13:09:21 -08005292 return FALSE;
5293
5294}
5295
Viral Modid440e682013-03-06 02:25:31 -08005296static void __limRegisterDeferredSmeReqForNOAStart(tpAniSirGlobal pMac, tANI_U16 msgType, tANI_U32 *pMsgBuf)
5297{
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005298 limLog(pMac, LOG1, FL("Reg msgType %d"), msgType) ;
Viral Modid440e682013-03-06 02:25:31 -08005299 pMac->lim.gDeferMsgTypeForNOA = msgType;
5300 pMac->lim.gpDefdSmeMsgForNOA = pMsgBuf;
5301}
5302
5303static void __limDeregisterDeferredSmeReqAfterNOAStart(tpAniSirGlobal pMac)
5304{
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005305 limLog(pMac, LOG1, FL("Dereg msgType %d"), pMac->lim.gDeferMsgTypeForNOA) ;
Viral Modid440e682013-03-06 02:25:31 -08005306 pMac->lim.gDeferMsgTypeForNOA = 0;
5307 if (pMac->lim.gpDefdSmeMsgForNOA != NULL)
5308 {
5309 /* __limProcessSmeScanReq consumed the buffer. We can free it. */
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05305310 vos_mem_free(pMac->lim.gpDefdSmeMsgForNOA);
Viral Modid440e682013-03-06 02:25:31 -08005311 pMac->lim.gpDefdSmeMsgForNOA = NULL;
5312 }
5313}
5314
5315static
Ganesh Kondabattini16930072014-08-22 16:02:34 +05305316tANI_U32 limCalculateNOADuration(tpAniSirGlobal pMac, tANI_U16 msgType,
5317 tANI_U32 *pMsgBuf, tANI_BOOLEAN isPassiveScan)
Viral Modid440e682013-03-06 02:25:31 -08005318{
5319 tANI_U32 noaDuration = 0;
5320
5321 switch (msgType)
5322 {
5323 case eWNI_SME_SCAN_REQ:
5324 {
5325 tANI_U32 val;
5326 tANI_U8 i;
5327 tpSirSmeScanReq pScanReq = (tpSirSmeScanReq) pMsgBuf;
5328 if (wlan_cfgGetInt(pMac, WNI_CFG_PASSIVE_MAXIMUM_CHANNEL_TIME, &val) != eSIR_SUCCESS)
5329 {
5330 /*
5331 * Could not get max channel value
5332 * from CFG. Log error.
5333 */
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005334 limLog(pMac, LOGP, FL("could not retrieve passive max channel value"));
Viral Modid440e682013-03-06 02:25:31 -08005335
5336 /* use a default value of 110ms */
5337 val = DEFAULT_PASSIVE_MAX_CHANNEL_TIME;
5338 }
5339
5340 for (i = 0; i < pScanReq->channelList.numChannels; i++) {
5341 tANI_U8 channelNum = pScanReq->channelList.channelNumber[i];
5342
Ganesh Kondabattini8f6e3b32014-08-25 16:07:54 +05305343 if (pMac->miracast_mode) {
5344 noaDuration += DEFAULT_MIN_CHAN_TIME_DURING_MIRACAST +
5345 DEFAULT_MAX_CHAN_TIME_DURING_MIRACAST;
5346 } else if (isPassiveScan || !limActiveScanAllowed(pMac, channelNum)) {
Viral Modid440e682013-03-06 02:25:31 -08005347 /* using the value from WNI_CFG_PASSIVE_MINIMUM_CHANNEL_TIME as is done in
5348 * void limContinuePostChannelScan(tpAniSirGlobal pMac)
5349 */
5350 noaDuration += val;
Ganesh Kondabattini16930072014-08-22 16:02:34 +05305351 } else {
5352 /* Use min + max channel time to calculate the total duration of scan */
5353 noaDuration += pScanReq->minChannelTime + pScanReq->maxChannelTime;
Viral Modid440e682013-03-06 02:25:31 -08005354 }
5355 }
5356
5357 /* Adding an overhead of 20ms to account for the scan messaging delays */
5358 noaDuration += SCAN_MESSAGING_OVERHEAD;
5359 noaDuration *= CONV_MS_TO_US;
5360
5361 break;
5362 }
5363
5364 case eWNI_SME_OEM_DATA_REQ:
5365 noaDuration = OEM_DATA_NOA_DURATION*CONV_MS_TO_US; // use 60 msec as default
5366 break;
5367
5368 case eWNI_SME_REMAIN_ON_CHANNEL_REQ:
5369 {
5370 tSirRemainOnChnReq *pRemainOnChnReq = (tSirRemainOnChnReq *) pMsgBuf;
5371 noaDuration = (pRemainOnChnReq->duration)*CONV_MS_TO_US;
5372 break;
5373 }
5374
5375 case eWNI_SME_JOIN_REQ:
5376 noaDuration = JOIN_NOA_DURATION*CONV_MS_TO_US;
5377 break;
5378
5379 default:
5380 noaDuration = 0;
5381 break;
5382
5383 }
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005384 limLog(pMac, LOGW, FL("msgType %d noa %d"), msgType, noaDuration);
Viral Modid440e682013-03-06 02:25:31 -08005385 return noaDuration;
5386}
5387
5388void limProcessRegdDefdSmeReqAfterNOAStart(tpAniSirGlobal pMac)
5389{
Gopichand Nakkala7c4c3b92013-03-25 18:08:31 +05305390 tANI_BOOLEAN bufConsumed = TRUE;
Viral Modid440e682013-03-06 02:25:31 -08005391
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005392 limLog(pMac, LOG1, FL("Process defd sme req %d"), pMac->lim.gDeferMsgTypeForNOA);
Viral Modid440e682013-03-06 02:25:31 -08005393 if ( (pMac->lim.gDeferMsgTypeForNOA != 0) &&
5394 (pMac->lim.gpDefdSmeMsgForNOA != NULL) )
5395 {
5396 switch (pMac->lim.gDeferMsgTypeForNOA)
5397 {
5398 case eWNI_SME_SCAN_REQ:
5399 __limProcessSmeScanReq(pMac, pMac->lim.gpDefdSmeMsgForNOA);
5400 break;
5401 case eWNI_SME_OEM_DATA_REQ:
5402 __limProcessSmeOemDataReq(pMac, pMac->lim.gpDefdSmeMsgForNOA);
5403 break;
5404 case eWNI_SME_REMAIN_ON_CHANNEL_REQ:
Gopichand Nakkala7c4c3b92013-03-25 18:08:31 +05305405 bufConsumed = limProcessRemainOnChnlReq(pMac, pMac->lim.gpDefdSmeMsgForNOA);
5406 /* limProcessRemainOnChnlReq doesnt want us to free the buffer since
5407 * it is freed in limRemainOnChnRsp. this change is to avoid "double free"
5408 */
5409 if (FALSE == bufConsumed)
5410 {
5411 pMac->lim.gpDefdSmeMsgForNOA = NULL;
5412 }
Viral Modid440e682013-03-06 02:25:31 -08005413 break;
5414 case eWNI_SME_JOIN_REQ:
5415 __limProcessSmeJoinReq(pMac, pMac->lim.gpDefdSmeMsgForNOA);
5416 break;
5417 default:
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005418 limLog(pMac, LOGE, FL("Unknown deferred msg type %d"), pMac->lim.gDeferMsgTypeForNOA);
Viral Modid440e682013-03-06 02:25:31 -08005419 break;
5420 }
5421 __limDeregisterDeferredSmeReqAfterNOAStart(pMac);
5422 }
5423 else
5424 {
5425 limLog( pMac, LOGW, FL("start received from FW when no sme deferred msg pending. Do nothing."
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005426 "It might happen sometime when NOA start ind and timeout happen at the same time"));
Viral Modid440e682013-03-06 02:25:31 -08005427 }
5428}
Jeff Johnson295189b2012-06-20 16:38:30 -07005429
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05305430static void
5431__limProcessSmeResetApCapsChange(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
5432{
5433 tpSirResetAPCapsChange pResetCapsChange;
5434 tpPESession psessionEntry;
5435 tANI_U8 sessionId = 0;
5436 if (pMsgBuf == NULL)
5437 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005438 limLog(pMac, LOGE,FL("Buffer is Pointing to NULL"));
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05305439 return;
5440 }
5441
5442 pResetCapsChange = (tpSirResetAPCapsChange)pMsgBuf;
5443 psessionEntry = peFindSessionByBssid(pMac, pResetCapsChange->bssId, &sessionId);
5444 if (psessionEntry == NULL)
5445 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005446 limLog(pMac, LOGE, FL("Session does not exist for given BSSID"));
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05305447 return;
5448 }
5449
5450 psessionEntry->limSentCapsChangeNtf = false;
5451 return;
5452}
5453
Siddharth Bhal6af5d4e2014-09-29 21:11:16 +05305454static void
5455__limProcessSmeSpoofMacAddrRequest(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
5456{
5457 tSirMsgQ msg;
5458 tpSpoofMacAddrReqParams pSpoofMacAddrParams;
5459 tpSirSpoofMacAddrReq pSmeReq = (tpSirSpoofMacAddrReq) pMsgBuf;
5460
5461 pSpoofMacAddrParams = vos_mem_malloc(sizeof( tSpoofMacAddrReqParams));
5462 if ( NULL == pSpoofMacAddrParams )
5463 {
Siddharth Bhal4f3187c2014-10-09 21:38:08 +05305464 limLog( pMac, LOGE, FL("Unable to allocate memory for tDelStaSelfParams") );
Siddharth Bhal6af5d4e2014-09-29 21:11:16 +05305465 return;
5466 }
5467
5468 vos_mem_copy( pSpoofMacAddrParams->macAddr, pSmeReq->macAddr, sizeof(tSirMacAddr) );
5469
Siddharth Bhal4f3187c2014-10-09 21:38:08 +05305470 vos_mem_copy(pMac->lim.spoofMacAddr, pSmeReq->macAddr, VOS_MAC_ADDRESS_LEN);
5471
5472 limLog( pMac, LOG1, FL("Recieved Spoofed Mac Addr request with Addr:"
5473 MAC_ADDRESS_STR), MAC_ADDR_ARRAY(pMac->lim.spoofMacAddr) );
5474
Siddharth Bhal6af5d4e2014-09-29 21:11:16 +05305475 msg.type = WDA_SPOOF_MAC_ADDR_REQ;
5476 msg.reserved = 0;
5477 msg.bodyptr = pSpoofMacAddrParams;
5478 msg.bodyval = 0;
5479
5480 limLog(pMac, LOG1, FL("sending SIR_HAL_SPOOF_MAC_ADDR_REQ msg to HAL"));
5481 MTRACE(macTraceMsgTx(pMac, NO_SESSION, msg.type));
5482
5483 if(eSIR_SUCCESS != wdaPostCtrlMsg(pMac, &msg))
5484 {
Siddharth Bhal4f3187c2014-10-09 21:38:08 +05305485 limLog(pMac, LOGE, FL("wdaPostCtrlMsg failed for SIR_HAL_SPOOF_MAC_ADDR_REQ"));
Siddharth Bhal6af5d4e2014-09-29 21:11:16 +05305486 vos_mem_free(pSpoofMacAddrParams);
5487 }
5488 return;
5489}
5490
Jeff Johnson295189b2012-06-20 16:38:30 -07005491/**
Abhishek Singh7d624e12015-11-30 14:29:27 +05305492 * lim_register_mgmt_frame_ind_cb() - Save the Management frame
5493 * indication callback in PE.
5494 * @pMac: Mac pointer
5495 * @pMsgBuf: Msg pointer containing the callback
5496 *
5497 * This function is used save the Management frame
5498 * indication callback in PE.
5499 *
5500 * Return: None
5501 */
5502static void lim_register_mgmt_frame_ind_cb(tpAniSirGlobal pMac,
5503 tANI_U32 *msg_buf)
5504{
5505 struct sir_sme_mgmt_frame_cb_req *sme_req =
5506 (struct sir_sme_mgmt_frame_cb_req *)msg_buf;
5507
5508 if (NULL == msg_buf)
5509 {
5510 limLog(pMac, LOGE, FL("msg_buf is null"));
5511 return;
5512 }
5513 if (sme_req->callback)
5514 pMac->mgmt_frame_ind_cb =
5515 (sir_mgmt_frame_ind_callback)sme_req->callback;
5516 else
5517 limLog(pMac, LOGE, FL("sme_req->callback is null"));
5518}
5519
5520/**
Jeff Johnson295189b2012-06-20 16:38:30 -07005521 * limProcessSmeReqMessages()
5522 *
5523 *FUNCTION:
5524 * This function is called by limProcessMessageQueue(). This
5525 * function processes SME request messages from HDD or upper layer
5526 * application.
5527 *
5528 *LOGIC:
5529 *
5530 *ASSUMPTIONS:
5531 *
5532 *NOTE:
5533 *
5534 * @param pMac Pointer to Global MAC structure
5535 * @param msgType Indicates the SME message type
5536 * @param *pMsgBuf A pointer to the SME message buffer
5537 * @return Boolean - TRUE - if pMsgBuf is consumed and can be freed.
5538 * FALSE - if pMsgBuf is not to be freed.
5539 */
5540
5541tANI_BOOLEAN
5542limProcessSmeReqMessages(tpAniSirGlobal pMac, tpSirMsgQ pMsg)
5543{
5544 tANI_BOOLEAN bufConsumed = TRUE; //Set this flag to false within case block of any following message, that doesnt want pMsgBuf to be freed.
5545 tANI_U32 *pMsgBuf = pMsg->bodyptr;
Sudhir Sattayappa Kohalliabf751c2013-06-30 15:37:18 -07005546 tpSirSmeScanReq pScanReq;
Ganesh Kondabattini16930072014-08-22 16:02:34 +05305547 tANI_BOOLEAN isPassiveScan = FALSE;
5548
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005549 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 -07005550 limMsgStr(pMsg->type), pMsg->type,
5551 limSmeStateStr(pMac->lim.gLimSmeState), pMac->lim.gLimSmeState,
5552 limMlmStateStr(pMac->lim.gLimMlmState), pMac->lim.gLimMlmState );)
5553
Sudhir Sattayappa Kohalliabf751c2013-06-30 15:37:18 -07005554 pScanReq = (tpSirSmeScanReq) pMsgBuf;
Viral Modid440e682013-03-06 02:25:31 -08005555 /* Special handling of some SME Req msgs where we have an existing GO session and
5556 * want to insert NOA before processing those msgs. These msgs will be processed later when
5557 * start event happens
5558 */
5559 switch (pMsg->type)
5560 {
5561 case eWNI_SME_SCAN_REQ:
Ganesh Kondabattini16930072014-08-22 16:02:34 +05305562 pScanReq = (tpSirSmeScanReq) pMsgBuf;
5563 isPassiveScan = (pScanReq->scanType == eSIR_PASSIVE_SCAN) ? TRUE : FALSE;
Viral Modid440e682013-03-06 02:25:31 -08005564 case eWNI_SME_REMAIN_ON_CHANNEL_REQ:
Sudhir Sattayappa Kohalliabf751c2013-06-30 15:37:18 -07005565
5566 /* If scan is disabled return from here
5567 */
5568 if (pMac->lim.fScanDisabled)
5569 {
Sudhir Sattayappa Kohalliabf751c2013-06-30 15:37:18 -07005570 if (pMsg->type == eWNI_SME_SCAN_REQ)
5571 {
5572 limSendSmeScanRsp(pMac,
5573 offsetof(tSirSmeScanRsp,bssDescription[0]),
5574 eSIR_SME_INVALID_PARAMETERS,
5575 pScanReq->sessionId,
5576 pScanReq->transactionId);
5577
5578 bufConsumed = TRUE;
5579 }
5580 else if (pMsg->type == eWNI_SME_REMAIN_ON_CHANNEL_REQ)
5581 {
5582 pMac->lim.gpDefdSmeMsgForNOA = NULL;
5583 pMac->lim.gpLimRemainOnChanReq = (tpSirRemainOnChnReq )pMsgBuf;
5584 limRemainOnChnRsp(pMac,eHAL_STATUS_FAILURE, NULL);
5585
5586 /*
5587 * limRemainOnChnRsp will free the buffer this change is to
5588 * avoid "double free"
5589 */
5590 bufConsumed = FALSE;
5591 }
5592
Rashmi Ramanna6c13a342014-01-07 11:44:07 +05305593 limLog(pMac, LOGE,
5594 FL("Error: Scan Disabled."
5595 " Return with error status for SME Message %s(%d)"),
5596 limMsgStr(pMsg->type), pMsg->type);
5597
Sudhir Sattayappa Kohalliabf751c2013-06-30 15:37:18 -07005598 return bufConsumed;
5599 }
5600 /*
5601 * Do not add BREAK here
5602 */
5603 case eWNI_SME_OEM_DATA_REQ:
Viral Modid440e682013-03-06 02:25:31 -08005604 case eWNI_SME_JOIN_REQ:
5605 /* If we have an existing P2P GO session we need to insert NOA before actually process this SME Req */
5606 if ((limIsNOAInsertReqd(pMac) == TRUE) && IS_FEATURE_SUPPORTED_BY_FW(P2P_GO_NOA_DECOUPLE_INIT_SCAN))
5607 {
5608 tANI_U32 noaDuration;
5609 __limRegisterDeferredSmeReqForNOAStart(pMac, pMsg->type, pMsgBuf);
Ganesh Kondabattini16930072014-08-22 16:02:34 +05305610 noaDuration = limCalculateNOADuration(pMac, pMsg->type, pMsgBuf, isPassiveScan);
Viral Modid440e682013-03-06 02:25:31 -08005611 bufConsumed = __limInsertSingleShotNOAForScan(pMac, noaDuration);
5612 return bufConsumed;
5613 }
5614 }
5615 /* If no insert NOA required then execute the code below */
5616
Jeff Johnson295189b2012-06-20 16:38:30 -07005617 switch (pMsg->type)
5618 {
5619 case eWNI_SME_START_REQ:
5620 __limProcessSmeStartReq(pMac, pMsgBuf);
5621 break;
5622
5623 case eWNI_SME_SYS_READY_IND:
5624 bufConsumed = __limProcessSmeSysReadyInd(pMac, pMsgBuf);
5625 break;
5626
Jeff Johnson295189b2012-06-20 16:38:30 -07005627 case eWNI_SME_START_BSS_REQ:
5628 bufConsumed = __limProcessSmeStartBssReq(pMac, pMsg);
5629 break;
5630
5631 case eWNI_SME_SCAN_REQ:
Viral Modid440e682013-03-06 02:25:31 -08005632 __limProcessSmeScanReq(pMac, pMsgBuf);
Jeff Johnson295189b2012-06-20 16:38:30 -07005633 break;
5634
Jeff Johnsone7245742012-09-05 17:12:55 -07005635#ifdef FEATURE_OEM_DATA_SUPPORT
5636 case eWNI_SME_OEM_DATA_REQ:
5637 __limProcessSmeOemDataReq(pMac, pMsgBuf);
Jeff Johnsone7245742012-09-05 17:12:55 -07005638 break;
5639#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005640 case eWNI_SME_REMAIN_ON_CHANNEL_REQ:
5641 bufConsumed = limProcessRemainOnChnlReq(pMac, pMsgBuf);
5642 break;
5643
5644 case eWNI_SME_UPDATE_NOA:
5645 __limProcessSmeNoAUpdate(pMac, pMsgBuf);
5646 break;
Gopichand Nakkalac178ac82013-05-30 19:53:39 +05305647 case eWNI_SME_CLEAR_DFS_CHANNEL_LIST:
5648 __limProcessClearDfsChannelList(pMac, pMsg);
5649 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005650 case eWNI_SME_JOIN_REQ:
5651 __limProcessSmeJoinReq(pMac, pMsgBuf);
Jeff Johnson295189b2012-06-20 16:38:30 -07005652 break;
5653
5654 case eWNI_SME_AUTH_REQ:
5655 // __limProcessSmeAuthReq(pMac, pMsgBuf);
5656
5657 break;
5658
5659 case eWNI_SME_REASSOC_REQ:
5660 __limProcessSmeReassocReq(pMac, pMsgBuf);
5661
5662 break;
5663
5664 case eWNI_SME_PROMISCUOUS_MODE_REQ:
5665 //__limProcessSmePromiscuousReq(pMac, pMsgBuf);
5666
5667 break;
5668
5669 case eWNI_SME_DISASSOC_REQ:
5670 __limProcessSmeDisassocReq(pMac, pMsgBuf);
5671
5672 break;
5673
5674 case eWNI_SME_DISASSOC_CNF:
5675 case eWNI_SME_DEAUTH_CNF:
5676 __limProcessSmeDisassocCnf(pMac, pMsgBuf);
5677
5678 break;
5679
5680 case eWNI_SME_DEAUTH_REQ:
5681 __limProcessSmeDeauthReq(pMac, pMsgBuf);
5682
5683 break;
5684
Jeff Johnson295189b2012-06-20 16:38:30 -07005685
5686
5687 case eWNI_SME_SETCONTEXT_REQ:
5688 __limProcessSmeSetContextReq(pMac, pMsgBuf);
5689
5690 break;
5691
5692 case eWNI_SME_REMOVEKEY_REQ:
5693 __limProcessSmeRemoveKeyReq(pMac, pMsgBuf);
5694
5695 break;
5696
5697 case eWNI_SME_STOP_BSS_REQ:
5698 bufConsumed = __limProcessSmeStopBssReq(pMac, pMsg);
5699 break;
5700
5701 case eWNI_SME_ASSOC_CNF:
5702 case eWNI_SME_REASSOC_CNF:
5703 if (pMsg->type == eWNI_SME_ASSOC_CNF)
Abhishek Singh3cbf6052014-12-15 16:46:42 +05305704 limLog(pMac, LOG1, FL("Received ASSOC_CNF message"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005705 else
Abhishek Singh3cbf6052014-12-15 16:46:42 +05305706 limLog(pMac, LOG1, FL("Received REASSOC_CNF message"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005707 __limProcessSmeAssocCnfNew(pMac, pMsg->type, pMsgBuf);
5708 break;
5709
5710 case eWNI_SME_ADDTS_REQ:
Abhishek Singh3cbf6052014-12-15 16:46:42 +05305711 limLog(pMac, LOG1, FL("Received ADDTS_REQ message"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005712 __limProcessSmeAddtsReq(pMac, pMsgBuf);
5713 break;
5714
5715 case eWNI_SME_DELTS_REQ:
Abhishek Singh3cbf6052014-12-15 16:46:42 +05305716 limLog(pMac, LOG1, FL("Received DELTS_REQ message"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005717 __limProcessSmeDeltsReq(pMac, pMsgBuf);
5718 break;
5719
5720 case SIR_LIM_ADDTS_RSP_TIMEOUT:
Abhishek Singh3cbf6052014-12-15 16:46:42 +05305721 limLog(pMac, LOG1, FL("Received SIR_LIM_ADDTS_RSP_TIMEOUT message "));
Jeff Johnson295189b2012-06-20 16:38:30 -07005722 limProcessSmeAddtsRspTimeout(pMac, pMsg->bodyval);
5723 break;
5724
5725 case eWNI_SME_STA_STAT_REQ:
5726 case eWNI_SME_AGGR_STAT_REQ:
5727 case eWNI_SME_GLOBAL_STAT_REQ:
5728 case eWNI_SME_STAT_SUMM_REQ:
5729 __limProcessSmeStatsRequest( pMac, pMsgBuf);
5730 //HAL consumes pMsgBuf. It will be freed there. Set bufConsumed to false.
5731 bufConsumed = FALSE;
5732 break;
5733 case eWNI_SME_GET_STATISTICS_REQ:
5734 __limProcessSmeGetStatisticsRequest( pMac, pMsgBuf);
5735 //HAL consumes pMsgBuf. It will be freed there. Set bufConsumed to false.
5736 bufConsumed = FALSE;
5737 break;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005738#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08005739 case eWNI_SME_GET_ROAM_RSSI_REQ:
5740 __limProcessSmeGetRoamRssiRequest( pMac, pMsgBuf);
5741 //HAL consumes pMsgBuf. It will be freed there. Set bufConsumed to false.
5742 bufConsumed = FALSE;
5743 break;
5744#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005745#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005746 case eWNI_SME_GET_TSM_STATS_REQ:
5747 __limProcessSmeGetTsmStatsRequest( pMac, pMsgBuf);
5748 bufConsumed = FALSE;
5749 break;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005750#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Jeff Johnson295189b2012-06-20 16:38:30 -07005751 case eWNI_SME_DEL_BA_PEER_IND:
5752 limProcessSmeDelBaPeerInd(pMac, pMsgBuf);
5753 break;
5754 case eWNI_SME_GET_SCANNED_CHANNEL_REQ:
5755 limProcessSmeGetScanChannelInfo(pMac, pMsgBuf);
5756 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005757 case eWNI_SME_GET_ASSOC_STAS_REQ:
5758 limProcessSmeGetAssocSTAsInfo(pMac, pMsgBuf);
5759 break;
5760 case eWNI_SME_TKIP_CNTR_MEAS_REQ:
5761 limProcessTkipCounterMeasures(pMac, pMsgBuf);
5762 break;
5763
5764 case eWNI_SME_HIDE_SSID_REQ:
5765 __limProcessSmeHideSSID(pMac, pMsgBuf);
5766 break;
5767 case eWNI_SME_UPDATE_APWPSIE_REQ:
5768 __limProcessSmeUpdateAPWPSIEs(pMac, pMsgBuf);
5769 break;
5770 case eWNI_SME_GET_WPSPBC_SESSION_REQ:
5771 limProcessSmeGetWPSPBCSessions(pMac, pMsgBuf);
5772 break;
5773
5774 case eWNI_SME_SET_APWPARSNIEs_REQ:
5775 __limProcessSmeSetWPARSNIEs(pMac, pMsgBuf);
5776 break;
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08005777
5778 case eWNI_SME_CHNG_MCC_BEACON_INTERVAL:
5779 //Update the beaconInterval
5780 __limProcessSmeChangeBI(pMac, pMsgBuf );
5781 break;
Hardik Kantilal Patel62a3a762014-11-21 12:55:57 +05305782
5783#ifdef WLAN_FEATURE_AP_HT40_24G
5784 case eWNI_SME_SET_HT_2040_MODE:
5785 __limProcessSmeSetHT2040Mode(pMac, pMsgBuf);
5786 break;
5787#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005788
5789#if defined WLAN_FEATURE_VOWIFI
5790 case eWNI_SME_NEIGHBOR_REPORT_REQ_IND:
5791 case eWNI_SME_BEACON_REPORT_RESP_XMIT_IND:
5792 __limProcessReportMessage(pMac, pMsg);
5793 break;
5794#endif
5795
5796#if defined WLAN_FEATURE_VOWIFI_11R
5797 case eWNI_SME_FT_PRE_AUTH_REQ:
5798 bufConsumed = (tANI_BOOLEAN)limProcessFTPreAuthReq(pMac, pMsg);
5799 break;
5800 case eWNI_SME_FT_UPDATE_KEY:
5801 limProcessFTUpdateKey(pMac, pMsgBuf);
5802 break;
5803
5804 case eWNI_SME_FT_AGGR_QOS_REQ:
5805 limProcessFTAggrQosReq(pMac, pMsgBuf);
5806 break;
5807#endif
5808
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005809#if defined(FEATURE_WLAN_ESE) && !defined(FEATURE_WLAN_ESE_UPLOAD)
5810 case eWNI_SME_ESE_ADJACENT_AP_REPORT:
Jeff Johnson295189b2012-06-20 16:38:30 -07005811 limProcessAdjacentAPRepMsg ( pMac, pMsgBuf );
5812 break;
5813#endif
5814 case eWNI_SME_ADD_STA_SELF_REQ:
5815 __limProcessSmeAddStaSelfReq( pMac, pMsgBuf );
5816 break;
5817 case eWNI_SME_DEL_STA_SELF_REQ:
5818 __limProcessSmeDelStaSelfReq( pMac, pMsgBuf );
5819 break;
5820
Jeff Johnson295189b2012-06-20 16:38:30 -07005821 case eWNI_SME_REGISTER_MGMT_FRAME_REQ:
5822 __limProcessSmeRegisterMgmtFrameReq( pMac, pMsgBuf );
5823 break;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08005824#ifdef FEATURE_WLAN_TDLS
5825 case eWNI_SME_TDLS_SEND_MGMT_REQ:
5826 limProcessSmeTdlsMgmtSendReq(pMac, pMsgBuf);
5827 break;
5828 case eWNI_SME_TDLS_ADD_STA_REQ:
5829 limProcessSmeTdlsAddStaReq(pMac, pMsgBuf);
5830 break;
5831 case eWNI_SME_TDLS_DEL_STA_REQ:
5832 limProcessSmeTdlsDelStaReq(pMac, pMsgBuf);
5833 break;
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05305834 case eWNI_SME_TDLS_LINK_ESTABLISH_REQ:
5835 limProcesSmeTdlsLinkEstablishReq(pMac, pMsgBuf);
5836 break;
Atul Mittalc0f739f2014-07-31 13:47:47 +05305837// tdlsoffchan
5838 case eWNI_SME_TDLS_CHANNEL_SWITCH_REQ:
5839 limProcesSmeTdlsChanSwitchReq(pMac, pMsgBuf);
5840 break;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08005841#endif
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05305842 case eWNI_SME_RESET_AP_CAPS_CHANGED:
5843 __limProcessSmeResetApCapsChange(pMac, pMsgBuf);
5844 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005845
schang86c22c42013-03-13 18:41:24 -07005846 case eWNI_SME_SET_TX_POWER_REQ:
5847 limSendSetTxPowerReq(pMac, pMsgBuf);
5848 break ;
5849
Abhishek Singh00b71972016-01-07 10:51:04 +05305850#ifdef WLAN_FEATURE_RMC
5851 case eWNI_SME_ENABLE_RMC_REQ:
5852 limProcessRMCMessages(pMac, eLIM_RMC_ENABLE_REQ, pMsgBuf);
5853 break ;
5854
5855 case eWNI_SME_DISABLE_RMC_REQ:
5856 limProcessRMCMessages(pMac, eLIM_RMC_DISABLE_REQ, pMsgBuf);
5857 break ;
5858#endif /* WLAN_FEATURE_RMC */
5859
Siddharth Bhal6af5d4e2014-09-29 21:11:16 +05305860 case eWNI_SME_MAC_SPOOF_ADDR_IND:
5861 __limProcessSmeSpoofMacAddrRequest(pMac, pMsgBuf);
5862 break ;
Abhishek Singh7d624e12015-11-30 14:29:27 +05305863 case eWNI_SME_REGISTER_MGMT_FRAME_CB:
5864 lim_register_mgmt_frame_ind_cb(pMac, pMsgBuf);
5865 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005866 default:
5867 vos_mem_free((v_VOID_t*)pMsg->bodyptr);
5868 pMsg->bodyptr = NULL;
5869 break;
5870 } // switch (msgType)
5871
5872 return bufConsumed;
5873} /*** end limProcessSmeReqMessages() ***/