blob: 72840abcec440ed45c5c8ab4b2c72a0110ec3cc6 [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
Abhishek Singh3a93ee42016-09-29 17:00:03 +05301535 pMlmScanReq->min_chntime_btc_esco =
1536 pScanReq->min_chntime_btc_esco;
1537 pMlmScanReq->max_chntime_btc_esco =
1538 pScanReq->max_chntime_btc_esco;
Ganesh Kondabattinif0fa07c2013-06-11 17:47:49 +05301539 pMlmScanReq->dot11mode = pScanReq->dot11mode;
1540 pMlmScanReq->p2pSearch = pScanReq->p2pSearch;
Jeff Johnson295189b2012-06-20 16:38:30 -07001541
Ganesh Kondabattinif0fa07c2013-06-11 17:47:49 +05301542 //Store the smeSessionID and transaction ID for later use.
1543 pMac->lim.gSmeSessionId = pScanReq->sessionId;
1544 pMac->lim.gTransactionId = pScanReq->transactionId;
Jeff Johnson295189b2012-06-20 16:38:30 -07001545
Ganesh Kondabattinif0fa07c2013-06-11 17:47:49 +05301546 // Issue LIM_MLM_SCAN_REQ to MLM
Rashmi Ramanna6c13a342014-01-07 11:44:07 +05301547 limLog(pMac, LOG1, FL("Issue Scan request command to MLM "));
Ganesh Kondabattinif0fa07c2013-06-11 17:47:49 +05301548 limPostMlmMessage(pMac, LIM_MLM_SCAN_REQ, (tANI_U32 *) pMlmScanReq);
1549 }
1550 } // if ((pMac->lim.gLimSmeState == eLIM_SME_IDLE_STATE) || ...
Jeff Johnson295189b2012-06-20 16:38:30 -07001551
1552 else
1553 {
1554 /// In all other cases return 'cached' scan results
1555 if ((pMac->lim.gLimRspReqd) || pMac->lim.gLimReportBackgroundScanResults)
1556 {
1557 tANI_U16 scanRspLen = sizeof(tSirSmeScanRsp);
1558
1559 pMac->lim.gLimRspReqd = false;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07001560#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
1561 if (pScanReq->returnFreshResults & SIR_BG_SCAN_RETURN_LFR_CACHED_RESULTS)
Jeff Johnson295189b2012-06-20 16:38:30 -07001562 {
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07001563 pMac->lim.gLimSmeLfrScanResultLength = pMac->lim.gLimMlmLfrScanResultLength;
1564 if (pMac->lim.gLimSmeLfrScanResultLength == 0)
1565 {
1566 limSendSmeLfrScanRsp(pMac, scanRspLen,
1567 eSIR_SME_SUCCESS,
1568 pScanReq->sessionId,
1569 pScanReq->transactionId);
1570 }
1571 else
1572 {
1573 scanRspLen = sizeof(tSirSmeScanRsp) +
1574 pMac->lim.gLimSmeLfrScanResultLength -
1575 sizeof(tSirBssDescription);
1576 limSendSmeLfrScanRsp(pMac, scanRspLen, eSIR_SME_SUCCESS,
1577 pScanReq->sessionId, pScanReq->transactionId);
1578 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001579 }
1580 else
1581 {
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07001582#endif
1583 if (pMac->lim.gLimSmeScanResultLength == 0)
1584 {
1585 limSendSmeScanRsp(pMac, scanRspLen, eSIR_SME_SUCCESS,
1586 pScanReq->sessionId, pScanReq->transactionId);
1587 }
1588 else
1589 {
1590 scanRspLen = sizeof(tSirSmeScanRsp) +
1591 pMac->lim.gLimSmeScanResultLength -
1592 sizeof(tSirBssDescription);
1593 limSendSmeScanRsp(pMac, scanRspLen, eSIR_SME_SUCCESS,
1594 pScanReq->sessionId, pScanReq->transactionId);
1595 }
1596#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
Jeff Johnson295189b2012-06-20 16:38:30 -07001597 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07001598#endif
Rashmi Ramanna6c13a342014-01-07 11:44:07 +05301599 limLog(pMac, LOG1, FL("Cached scan results are returned "));
Jeff Johnson295189b2012-06-20 16:38:30 -07001600
1601 if (pScanReq->returnFreshResults & SIR_BG_SCAN_PURGE_RESUTLS)
1602 {
1603 // Discard previously cached scan results
1604 limReInitScanResults(pMac);
1605 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07001606#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
1607 if (pScanReq->returnFreshResults & SIR_BG_SCAN_PURGE_LFR_RESULTS)
1608 {
1609 // Discard previously cached scan results
1610 limReInitLfrScanResults(pMac);
1611 }
1612#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001613
1614 } // if (pMac->lim.gLimRspReqd)
1615 } // else ((pMac->lim.gLimSmeState == eLIM_SME_IDLE_STATE) || ...
1616
Jeff Johnson295189b2012-06-20 16:38:30 -07001617#ifdef BACKGROUND_SCAN_ENABLED
1618 // start background scans if needed
1619 // There is a bug opened against softmac. Need to enable when the bug is fixed.
1620 __limBackgroundScanInitiate(pMac);
1621#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001622
1623} /*** end __limProcessSmeScanReq() ***/
1624
Jeff Johnsone7245742012-09-05 17:12:55 -07001625#ifdef FEATURE_OEM_DATA_SUPPORT
Jeff Johnson295189b2012-06-20 16:38:30 -07001626
Jeff Johnsone7245742012-09-05 17:12:55 -07001627static void __limProcessSmeOemDataReq(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
1628{
1629 tpSirOemDataReq pOemDataReq;
1630 tLimMlmOemDataReq* pMlmOemDataReq;
1631
1632 pOemDataReq = (tpSirOemDataReq) pMsgBuf;
1633
1634 //post the lim mlm message now
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301635 pMlmOemDataReq = vos_mem_malloc(sizeof(tLimMlmOemDataReq));
1636 if ( NULL == pMlmOemDataReq )
Jeff Johnsone7245742012-09-05 17:12:55 -07001637 {
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301638 limLog(pMac, LOGP, FL("AllocateMemory failed for mlmOemDataReq"));
Jeff Johnsone7245742012-09-05 17:12:55 -07001639 return;
1640 }
1641
1642 //Initialize this buffer
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301643 vos_mem_set( pMlmOemDataReq, (sizeof(tLimMlmOemDataReq)), 0);
Jeff Johnsone7245742012-09-05 17:12:55 -07001644
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301645 vos_mem_copy( pMlmOemDataReq->selfMacAddr, pOemDataReq->selfMacAddr,
1646 sizeof(tSirMacAddr));
1647 vos_mem_copy( pMlmOemDataReq->oemDataReq, pOemDataReq->oemDataReq,
1648 OEM_DATA_REQ_SIZE);
Jeff Johnsone7245742012-09-05 17:12:55 -07001649
1650 //Issue LIM_MLM_OEM_DATA_REQ to MLM
1651 limPostMlmMessage(pMac, LIM_MLM_OEM_DATA_REQ, (tANI_U32*)pMlmOemDataReq);
1652
1653 return;
1654
1655} /*** end __limProcessSmeOemDataReq() ***/
1656
1657#endif //FEATURE_OEM_DATA_SUPPORT
Jeff Johnson295189b2012-06-20 16:38:30 -07001658
Gopichand Nakkalac178ac82013-05-30 19:53:39 +05301659/**
1660 * __limProcessClearDfsChannelList()
1661 *
1662 *FUNCTION:
1663 *Clear DFS channel list when country is changed/aquired.
1664.*This message is sent from SME.
1665 *
1666 *LOGIC:
1667 *
1668 *ASSUMPTIONS:
1669 *
1670 *NOTE:
1671 *
1672 * @param pMac Pointer to Global MAC structure
1673 * @param *pMsgBuf A pointer to the SME message buffer
1674 * @return None
1675 */
1676static void __limProcessClearDfsChannelList(tpAniSirGlobal pMac,
1677 tpSirMsgQ pMsg)
1678{
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301679 vos_mem_set( &pMac->lim.dfschannelList,
1680 sizeof(tSirDFSChannelList), 0);
Gopichand Nakkalac178ac82013-05-30 19:53:39 +05301681}
Jeff Johnson295189b2012-06-20 16:38:30 -07001682
1683/**
1684 * __limProcessSmeJoinReq()
1685 *
1686 *FUNCTION:
1687 * This function is called to process SME_JOIN_REQ message
1688 * from HDD or upper layer application.
1689 *
1690 *LOGIC:
1691 *
1692 *ASSUMPTIONS:
1693 *
1694 *NOTE:
1695 *
1696 * @param pMac Pointer to Global MAC structure
1697 * @param *pMsgBuf A pointer to the SME message buffer
1698 * @return None
1699 */
Jeff Johnson295189b2012-06-20 16:38:30 -07001700static void
1701__limProcessSmeJoinReq(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
1702{
1703 // tANI_U8 *pBuf;
1704 //tANI_U32 len;
1705// tSirMacAddr currentBssId;
1706 tpSirSmeJoinReq pSmeJoinReq = NULL;
1707 tLimMlmJoinReq *pMlmJoinReq;
1708 tSirResultCodes retCode = eSIR_SME_SUCCESS;
1709 tANI_U32 val = 0;
1710 tANI_U16 nSize;
1711 tANI_U8 sessionId;
1712 tpPESession psessionEntry = NULL;
Nitesh Shah54046ee2016-07-19 15:23:51 +05301713 tANI_U8 smesessionId = 0;
1714 tANI_U16 smetransactionId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001715 tPowerdBm localPowerConstraint = 0, regMax = 0;
Agarwal Ashish87039eb2014-01-15 14:13:15 +05301716 tANI_U16 ieLen;
1717 v_U8_t *vendorIE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001718
1719#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM //FEATURE_WLAN_DIAG_SUPPORT
1720 //Not sending any session, since it is not created yet. The response whould have correct state.
1721 limDiagEventReport(pMac, WLAN_PE_DIAG_JOIN_REQ_EVENT, NULL, 0, 0);
1722#endif //FEATURE_WLAN_DIAG_SUPPORT
1723
Abhishek Singh3cbf6052014-12-15 16:46:42 +05301724 limLog(pMac, LOG1, FL("Received SME_JOIN_REQ"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001725
1726#ifdef WLAN_FEATURE_VOWIFI
1727 /* Need to read the CFG here itself as this is used in limExtractAPCapability() below.
1728 * This CFG is actually read in rrmUpdateConfig() which is called later. Because this is not
1729 * read, RRM related path before calling rrmUpdateConfig() is not getting executed causing issues
1730 * like not honoring power constraint on 1st association after driver loading. */
1731 if (wlan_cfgGetInt(pMac, WNI_CFG_RRM_ENABLED, &val) != eSIR_SUCCESS)
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001732 limLog(pMac, LOGP, FL("cfg get rrm enabled failed"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001733 pMac->rrm.rrmPEContext.rrmEnable = (val) ? 1 : 0;
1734 val = 0;
1735#endif /* WLAN_FEATURE_VOWIFI */
1736
1737 /**
1738 * Expect Join request in idle state.
1739 * Reassociate request is expected in link established state.
1740 */
1741
1742 /* Global SME and LIM states are not defined yet for BT-AMP Support */
1743 if(pMac->lim.gLimSmeState == eLIM_SME_IDLE_STATE)
1744 {
1745 nSize = __limGetSmeJoinReqSizeForAlloc((tANI_U8*) pMsgBuf);
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301746
1747 pSmeJoinReq = vos_mem_malloc(nSize);
1748 if ( NULL == pSmeJoinReq )
Jeff Johnson295189b2012-06-20 16:38:30 -07001749 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05301750 limLog(pMac, LOGP, FL("call to AllocateMemory failed for "
1751 "pSmeJoinReq"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001752 retCode = eSIR_SME_RESOURCES_UNAVAILABLE;
1753 goto end;
1754 }
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301755 (void) vos_mem_set((void *) pSmeJoinReq, nSize, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07001756
Jeff Johnson295189b2012-06-20 16:38:30 -07001757 if ((limJoinReqSerDes(pMac, pSmeJoinReq, (tANI_U8 *)pMsgBuf) == eSIR_FAILURE) ||
1758 (!limIsSmeJoinReqValid(pMac, pSmeJoinReq)))
1759 {
1760 /// Received invalid eWNI_SME_JOIN_REQ
1761 // Log the event
Padma, Santhosh Kumar2b47ca82014-01-03 16:57:27 +05301762 limLog(pMac, LOGW, FL("SessionId:%d Received SME_JOIN_REQ with"
1763 "invalid data"),pSmeJoinReq->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07001764 retCode = eSIR_SME_INVALID_PARAMETERS;
1765 goto end;
1766 }
1767
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301768 //pMac->lim.gpLimJoinReq = pSmeJoinReq; TO SUPPORT BT-AMP, review os sep 23
Jeff Johnson295189b2012-06-20 16:38:30 -07001769
1770 /* check for the existence of start BSS session */
1771#ifdef FIXME_GEN6
1772 if(pSmeJoinReq->bsstype == eSIR_BTAMP_AP_MODE)
1773 {
1774 if(peValidateBtJoinRequest(pMac)!= TRUE)
1775 {
Padma, Santhosh Kumar2b47ca82014-01-03 16:57:27 +05301776 limLog(pMac, LOGW, FL("SessionId:%d Start Bss session"
1777 "not present::SME_JOIN_REQ in unexpected state"),
1778 pSmeJoinReq->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07001779 retCode = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
1780 psessionEntry = NULL;
1781 goto end;
1782 }
1783 }
1784
1785#endif
1786
1787
1788 if((psessionEntry = peFindSessionByBssid(pMac,pSmeJoinReq->bssDescription.bssId,&sessionId)) != NULL)
1789 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05301790 limLog(pMac, LOGE, FL("Session(%d) Already exists for BSSID: "
Sushant Kaushik1b645382014-10-13 16:39:36 +05301791 MAC_ADDRESS_STR" in limSmeState = %d"),sessionId,
Abhishek Singh57aebef2014-02-03 18:47:44 +05301792 MAC_ADDR_ARRAY(pSmeJoinReq->bssDescription.bssId),
1793 psessionEntry->limSmeState);
Jeff Johnson295189b2012-06-20 16:38:30 -07001794
1795 if(psessionEntry->limSmeState == eLIM_SME_LINK_EST_STATE)
1796 {
1797 // Received eWNI_SME_JOIN_REQ for same
1798 // BSS as currently associated.
1799 // Log the event and send success
Padma, Santhosh Kumar2b47ca82014-01-03 16:57:27 +05301800 PELOGW(limLog(pMac, LOGW, FL("SessionId:%d Received"
1801 "SME_JOIN_REQ for currently joined BSS"),sessionId);)
Jeff Johnson295189b2012-06-20 16:38:30 -07001802 /// Send Join success response to host
Deepthi Gowrif3e27252013-12-11 20:50:01 +05301803 retCode = eSIR_SME_ALREADY_JOINED_A_BSS;
1804 psessionEntry = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07001805 goto end;
1806 }
1807 else
1808 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05301809 PELOGE(limLog(pMac, LOGE, FL("SME_JOIN_REQ not for"
1810 "currently joined BSS"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001811 retCode = eSIR_SME_REFUSED;
1812 psessionEntry = NULL;
1813 goto end;
1814 }
1815 }
1816 else /* Session Entry does not exist for given BSSId */
1817 {
1818 /* Try to Create a new session */
1819 if((psessionEntry = peCreateSession(pMac,pSmeJoinReq->bssDescription.bssId,&sessionId, pMac->lim.maxStation)) == NULL)
1820 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001821 limLog(pMac, LOGE, FL("Session Can not be created "));
Jeff Johnson295189b2012-06-20 16:38:30 -07001822 retCode = eSIR_SME_RESOURCES_UNAVAILABLE;
1823 goto end;
1824 }
Padma, Santhosh Kumar2b47ca82014-01-03 16:57:27 +05301825 else
1826 limLog(pMac,LOG1,FL("SessionId:%d New session created"),
1827 sessionId);
Masti, Narayanraddi67ea5912015-01-08 12:34:05 +05301828 }
1829
1830 if(psessionEntry != NULL && pSmeJoinReq->operationalRateSet.numRates > 0 ){
1831 if(!limCheck11BRateBitmap(pSmeJoinReq->rateBitMap)){
1832 psessionEntry->is11Gonly = true;
1833 }
1834 }
1835
krunal soni5afa96c2013-09-06 22:19:02 -07001836 psessionEntry->isAmsduSupportInAMPDU = pSmeJoinReq->isAmsduSupportInAMPDU;
Jeff Johnsone7245742012-09-05 17:12:55 -07001837
Jeff Johnson295189b2012-06-20 16:38:30 -07001838 /* Store Session related parameters */
1839 /* Store PE session Id in session Table */
1840 psessionEntry->peSessionId = sessionId;
1841
1842 /* store the smejoin req handle in session table */
1843 psessionEntry->pLimJoinReq = pSmeJoinReq;
1844
1845 /* Store SME session Id in sessionTable */
1846 psessionEntry->smeSessionId = pSmeJoinReq->sessionId;
1847
1848 /* Store SME transaction Id in session Table */
1849 psessionEntry->transactionId = pSmeJoinReq->transactionId;
1850
1851 /* Store beaconInterval */
1852 psessionEntry->beaconParams.beaconInterval = pSmeJoinReq->bssDescription.beaconInterval;
1853
1854 /* Copying of bssId is already done, while creating session */
1855 //sirCopyMacAddr(psessionEntry->bssId,pSmeJoinReq->bssId);
1856 sirCopyMacAddr(psessionEntry->selfMacAddr,pSmeJoinReq->selfMacAddr);
1857 psessionEntry->bssType = pSmeJoinReq->bsstype;
1858
1859 psessionEntry->statypeForBss = STA_ENTRY_PEER;
Sandeep Puligillaaea98a22013-12-04 13:36:32 +05301860 psessionEntry->limWmeEnabled = pSmeJoinReq->isWMEenabled;
1861 psessionEntry->limQosEnabled = pSmeJoinReq->isQosEnabled;
Sushant Kaushik74df8db2015-03-11 18:09:05 +05301862 psessionEntry->bOSENAssociation = pSmeJoinReq->bOSENAssociation;
Abhishek Singheef5c992016-01-27 13:41:54 +05301863 psessionEntry->bWPSAssociation = pSmeJoinReq->bWPSAssociation;
Jeff Johnson295189b2012-06-20 16:38:30 -07001864
Agarwal Ashish87039eb2014-01-15 14:13:15 +05301865 /* Store vendor specfic IE for CISCO AP */
Abhishek Singhbad2b322016-10-21 11:22:33 +05301866 ieLen = GET_IE_LEN_IN_BSS(pSmeJoinReq->bssDescription.length);
Agarwal Ashish87039eb2014-01-15 14:13:15 +05301867
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
Selvaraj, Sridhar716d30f2016-07-28 18:54:03 +05301899 if (cfgSetInt(pMac, WNI_CFG_VHT_SU_BEAMFORMEE_CAP,
1900 psessionEntry->txBFIniFeatureEnabled) != eSIR_SUCCESS)
1901 {
1902 limLog(pMac, LOGP, FL("could not set "
1903 "WNI_CFG_VHT_SU_BEAMFORMEE_CAP at CFG"));
1904 retCode = eSIR_LOGP_EXCEPTION;
1905 goto end;
1906 }
Shailender Karmuchi08f87c22013-01-17 12:51:24 -08001907 if( psessionEntry->txBFIniFeatureEnabled )
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"));
Nitesh Shah54046ee2016-07-19 15:23:51 +05302033 retCode = eSIR_SME_RESOURCES_UNAVAILABLE;
2034 goto end;
Jeff Johnson295189b2012-06-20 16:38:30 -07002035 }
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302036 (void) vos_mem_set((void *) pMlmJoinReq, val, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07002037
2038 /* PE SessionId is stored as a part of JoinReq*/
2039 pMlmJoinReq->sessionId = psessionEntry->peSessionId;
2040
2041 if (wlan_cfgGetInt(pMac, WNI_CFG_JOIN_FAILURE_TIMEOUT, (tANI_U32 *) &pMlmJoinReq->joinFailureTimeout)
2042 != eSIR_SUCCESS)
Sushant Kaushike3ca61c2015-03-19 18:33:25 +05302043 {
2044 limLog(pMac, LOGE, FL("could not retrieve JoinFailureTimer value "
2045 "setting it to default value"));
2046 pMlmJoinReq->joinFailureTimeout = JOIN_FAILURE_TIMEOUT;
2047 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002048
2049 /* copy operational rate from psessionEntry*/
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302050 vos_mem_copy((void*)&psessionEntry->rateSet, (void*)&pSmeJoinReq->operationalRateSet,
Jeff Johnson295189b2012-06-20 16:38:30 -07002051 sizeof(tSirMacRateSet));
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302052 vos_mem_copy((void*)&psessionEntry->extRateSet, (void*)&pSmeJoinReq->extendedRateSet,
Jeff Johnson295189b2012-06-20 16:38:30 -07002053 sizeof(tSirMacRateSet));
2054 //this may not be needed anymore now, as rateSet is now included in the session entry and MLM has session context.
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302055 vos_mem_copy((void*)&pMlmJoinReq->operationalRateSet, (void*)&psessionEntry->rateSet,
Jeff Johnson295189b2012-06-20 16:38:30 -07002056 sizeof(tSirMacRateSet));
2057
2058 psessionEntry->encryptType = pSmeJoinReq->UCEncryptionType;
2059
Jeff Johnson295189b2012-06-20 16:38:30 -07002060 pMlmJoinReq->bssDescription.length = psessionEntry->pLimJoinReq->bssDescription.length;
2061
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302062 vos_mem_copy((tANI_U8 *) &pMlmJoinReq->bssDescription.bssId,
Jeff Johnson295189b2012-06-20 16:38:30 -07002063 (tANI_U8 *) &psessionEntry->pLimJoinReq->bssDescription.bssId,
2064 psessionEntry->pLimJoinReq->bssDescription.length + 2);
2065
Jeff Johnson295189b2012-06-20 16:38:30 -07002066 psessionEntry->limCurrentBssCaps =
Jeff Johnsone7245742012-09-05 17:12:55 -07002067 psessionEntry->pLimJoinReq->bssDescription.capabilityInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07002068
Jeff Johnsone7245742012-09-05 17:12:55 -07002069 regMax = cfgGetRegulatoryMaxTransmitPower( pMac, psessionEntry->currentOperChannel );
Sandeep Puligillaa9eb9ad2014-05-27 14:42:50 +05302070 localPowerConstraint = regMax;
Abhishek Singhbad2b322016-10-21 11:22:33 +05302071 limExtractApCapability(pMac,
2072 (tANI_U8 *) psessionEntry->pLimJoinReq->bssDescription.ieFields,
2073 GET_IE_LEN_IN_BSS(psessionEntry->pLimJoinReq->bssDescription.length),
2074 &psessionEntry->limCurrentBssQosCaps,
2075 &psessionEntry->limCurrentBssPropCap,
2076 &pMac->lim.gLimCurrentBssUapsd,
2077 &localPowerConstraint,
2078 psessionEntry);
Sandeep Puligillaa9eb9ad2014-05-27 14:42:50 +05302079
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002080#ifdef FEATURE_WLAN_ESE
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002081 psessionEntry->maxTxPower = limGetMaxTxPower(regMax, localPowerConstraint, pMac->roam.configParam.nTxPowerCap);
Jeff Johnson295189b2012-06-20 16:38:30 -07002082#else
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302083 psessionEntry->maxTxPower = VOS_MIN( regMax, (localPowerConstraint) );
Jeff Johnson295189b2012-06-20 16:38:30 -07002084#endif
Sushant Kaushikece4b562015-04-09 18:27:33 +05302085 if (!psessionEntry->maxTxPower)
2086 {
2087 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR, FL("Tx power"
2088 "is zero. Setting it to default value %d"),
2089 TX_POWER_DEFAULT);
2090 psessionEntry->maxTxPower = TX_POWER_DEFAULT;
2091 }
2092
Sandeep Puligilla4ce02592014-04-22 09:05:57 +05302093 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
2094 "Regulatory max = %d, local power constraint = %d,"
Abhishek Singh57aebef2014-02-03 18:47:44 +05302095 " max tx = %d", regMax, localPowerConstraint,
2096 psessionEntry->maxTxPower );
Jeff Johnson295189b2012-06-20 16:38:30 -07002097
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;
Abhishek Singhbad2b322016-10-21 11:22:33 +05302352 limExtractApCapability(pMac,
2353 (tANI_U8 *) psessionEntry->pLimReAssocReq->bssDescription.ieFields,
2354 GET_IE_LEN_IN_BSS(
2355 psessionEntry->pLimReAssocReq->bssDescription.length),
2356 &psessionEntry->limReassocBssQosCaps,
2357 &psessionEntry->limReassocBssPropCap,
2358 &pMac->lim.gLimCurrentBssUapsd,
2359 &localPowerConstraint,
2360 psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07002361
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302362 psessionEntry->maxTxPower = VOS_MIN( regMax, (localPowerConstraint) );
Sushant Kaushikece4b562015-04-09 18:27:33 +05302363 if (!psessionEntry->maxTxPower)
2364 {
2365 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR, FL("Tx power "
2366 "is zero. Setting it to default value %d"),
2367 TX_POWER_DEFAULT);
2368 psessionEntry->maxTxPower = TX_POWER_DEFAULT;
2369 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002370#if defined WLAN_VOWIFI_DEBUG
Abhishek Singh57aebef2014-02-03 18:47:44 +05302371 limLog( pMac, LOGE, "Regulatory max = %d, local power constraint "
2372 "= %d, max tx = %d", regMax, localPowerConstraint,
2373 psessionEntry->maxTxPower );
Jeff Johnson295189b2012-06-20 16:38:30 -07002374#endif
2375 {
2376 #if 0
2377 if (wlan_cfgGetStr(pMac, WNI_CFG_SSID, pMac->lim.gLimReassocSSID.ssId,
2378 &cfgLen) != eSIR_SUCCESS)
2379 {
2380 /// Could not get SSID from CFG. Log error.
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002381 limLog(pMac, LOGP, FL("could not retrive SSID"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002382 }
2383 #endif//TO SUPPORT BT-AMP
2384
2385 /* Copy the SSID from sessio entry to local variable */
2386 #if 0
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302387 vos_mem_copy( pMac->lim.gLimReassocSSID.ssId,
Jeff Johnson295189b2012-06-20 16:38:30 -07002388 psessionEntry->ssId.ssId,
2389 psessionEntry->ssId.length);
2390 #endif
2391 psessionEntry->limReassocSSID.length = pReassocReq->ssId.length;
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302392 vos_mem_copy( psessionEntry->limReassocSSID.ssId,
Jeff Johnson295189b2012-06-20 16:38:30 -07002393 pReassocReq->ssId.ssId, psessionEntry->limReassocSSID.length);
2394
2395 }
2396
2397 if (pMac->lim.gLimCurrentBssUapsd)
2398 {
2399 pMac->lim.gUapsdPerAcBitmask = psessionEntry->pLimReAssocReq->uapsdPerAcBitmask;
Abhishek Singh57aebef2014-02-03 18:47:44 +05302400 limLog( pMac, LOG1, FL("UAPSD flag for all AC - 0x%2x"),
2401 pMac->lim.gUapsdPerAcBitmask);
Jeff Johnson295189b2012-06-20 16:38:30 -07002402 }
2403
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302404 pMlmReassocReq = vos_mem_malloc(sizeof(tLimMlmReassocReq));
2405 if ( NULL == pMlmReassocReq )
Jeff Johnson295189b2012-06-20 16:38:30 -07002406 {
2407 // Log error
2408 limLog(pMac, LOGP,
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302409 FL("call to AllocateMemory failed for mlmReassocReq"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002410
2411 retCode = eSIR_SME_RESOURCES_UNAVAILABLE;
2412 goto end;
2413 }
2414
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302415 vos_mem_copy( pMlmReassocReq->peerMacAddr,
Jeff Johnson295189b2012-06-20 16:38:30 -07002416 psessionEntry->limReAssocbssId,
2417 sizeof(tSirMacAddr));
2418
2419 if (wlan_cfgGetInt(pMac, WNI_CFG_REASSOCIATION_FAILURE_TIMEOUT,
2420 (tANI_U32 *) &pMlmReassocReq->reassocFailureTimeout)
2421 != eSIR_SUCCESS)
2422 {
2423 /**
2424 * Could not get ReassocFailureTimeout value
2425 * from CFG. Log error.
2426 */
2427 limLog(pMac, LOGP,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002428 FL("could not retrieve ReassocFailureTimeout value"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002429 }
2430
2431 if (cfgGetCapabilityInfo(pMac, &caps,psessionEntry) != eSIR_SUCCESS)
2432 {
2433 /**
2434 * Could not get Capabilities value
2435 * from CFG. Log error.
2436 */
2437 limLog(pMac, LOGP,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002438 FL("could not retrieve Capabilities value"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002439 }
Selvaraj, Sridhar5f149192016-04-15 12:53:28 +05302440
2441 lim_update_caps_info_for_bss(pMac, &caps,
2442 pReassocReq->bssDescription.capabilityInfo);
2443
2444 limLog(pMac, LOG1, FL("Capabilities info Reassoc: 0x%X"), caps);
2445
Jeff Johnson295189b2012-06-20 16:38:30 -07002446 pMlmReassocReq->capabilityInfo = caps;
2447
2448 /* Update PE sessionId*/
2449 pMlmReassocReq->sessionId = sessionId;
2450
2451 /* If telescopic beaconing is enabled, set listen interval to
2452 WNI_CFG_TELE_BCN_MAX_LI */
2453 if(wlan_cfgGetInt(pMac, WNI_CFG_TELE_BCN_WAKEUP_EN, &teleBcnEn) !=
2454 eSIR_SUCCESS)
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002455 limLog(pMac, LOGP, FL("Couldn't get WNI_CFG_TELE_BCN_WAKEUP_EN"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002456
2457 val = WNI_CFG_LISTEN_INTERVAL_STADEF;
2458
2459 if(teleBcnEn)
2460 {
2461 if(wlan_cfgGetInt(pMac, WNI_CFG_TELE_BCN_MAX_LI, &val) !=
2462 eSIR_SUCCESS)
2463 {
2464 /**
2465 * Could not get ListenInterval value
2466 * from CFG. Log error.
2467 */
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002468 limLog(pMac, LOGP, FL("could not retrieve ListenInterval"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002469 }
2470 }
2471 else
2472 {
2473 if (wlan_cfgGetInt(pMac, WNI_CFG_LISTEN_INTERVAL, &val) != eSIR_SUCCESS)
2474 {
2475 /**
2476 * Could not get ListenInterval value
2477 * from CFG. Log error.
2478 */
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002479 limLog(pMac, LOGP, FL("could not retrieve ListenInterval"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002480 }
2481 }
2482
2483 /* Delete all BA sessions before Re-Assoc.
2484 * BA frames are class 3 frames and the session
2485 * is lost upon disassociation and reassociation.
2486 */
2487
Ganesh Kondabattini01f75c92014-07-07 19:27:41 +05302488 limDeleteBASessions(pMac, psessionEntry, BA_BOTH_DIRECTIONS,
2489 eSIR_MAC_UNSPEC_FAILURE_REASON);
Jeff Johnson295189b2012-06-20 16:38:30 -07002490
2491 pMlmReassocReq->listenInterval = (tANI_U16) val;
2492
2493 /* Indicate whether spectrum management is enabled*/
2494 psessionEntry->spectrumMgtEnabled = pReassocReq->spectrumMgtIndicator;
2495
Rajesh Babu Prathipati043149f2014-06-06 13:33:45 +05302496 /* Enable the spectrum management if this is a DFS channel */
2497 if (psessionEntry->countryInfoPresent &&
2498 limIsconnectedOnDFSChannel(psessionEntry->currentOperChannel))
2499 {
2500 psessionEntry->spectrumMgtEnabled = TRUE;
2501 }
2502
Jeff Johnson295189b2012-06-20 16:38:30 -07002503 psessionEntry->limPrevSmeState = psessionEntry->limSmeState;
2504 psessionEntry->limSmeState = eLIM_SME_WT_REASSOC_STATE;
2505
Jeff Johnsone7245742012-09-05 17:12:55 -07002506 MTRACE(macTrace(pMac, TRACE_CODE_SME_STATE, psessionEntry->peSessionId, psessionEntry->limSmeState));
Jeff Johnson295189b2012-06-20 16:38:30 -07002507
2508 limPostMlmMessage(pMac,
2509 LIM_MLM_REASSOC_REQ,
2510 (tANI_U32 *) pMlmReassocReq);
2511 return;
2512
2513end:
2514 if (pReassocReq)
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302515 vos_mem_free( pReassocReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07002516
2517 if (psessionEntry)
2518 {
2519 // error occurred after we determined the session so extract
2520 // session and transaction info from there
2521 smeSessionId = psessionEntry->smeSessionId;
2522 transactionId = psessionEntry->transactionId;
2523 }
2524 else
2525 {
2526 // error occurred before or during the time we determined the session
2527 // so extract the session and transaction info from the message
2528 limGetSessionInfo(pMac,(tANI_U8*)pMsgBuf, &smeSessionId, &transactionId);
2529 }
2530
2531 /// Send Reassoc failure response to host
2532 /// (note psessionEntry may be NULL, but that's OK)
2533 limSendSmeJoinReassocRsp(pMac, eWNI_SME_REASSOC_RSP,
2534 retCode, eSIR_MAC_UNSPEC_FAILURE_STATUS,
2535 psessionEntry, smeSessionId, transactionId);
2536
2537} /*** end __limProcessSmeReassocReq() ***/
2538
2539
2540tANI_BOOLEAN sendDisassocFrame = 1;
2541/**
2542 * __limProcessSmeDisassocReq()
2543 *
2544 *FUNCTION:
2545 * This function is called to process SME_DISASSOC_REQ message
2546 * from HDD or upper layer application.
2547 *
2548 *LOGIC:
2549 *
2550 *ASSUMPTIONS:
2551 *
2552 *NOTE:
2553 *
2554 * @param pMac Pointer to Global MAC structure
2555 * @param *pMsgBuf A pointer to the SME message buffer
2556 * @return None
2557 */
2558
2559static void
2560__limProcessSmeDisassocReq(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
2561{
2562 tANI_U16 disassocTrigger, reasonCode;
2563 tLimMlmDisassocReq *pMlmDisassocReq;
2564 tSirResultCodes retCode = eSIR_SME_SUCCESS;
Jeff Johnson43971f52012-07-17 12:26:56 -07002565 tSirRetStatus status;
Jeff Johnson295189b2012-06-20 16:38:30 -07002566 tSirSmeDisassocReq smeDisassocReq;
2567 tpPESession psessionEntry = NULL;
2568 tANI_U8 sessionId;
2569 tANI_U8 smesessionId;
2570 tANI_U16 smetransactionId;
2571
Jeff Johnson295189b2012-06-20 16:38:30 -07002572
Jeff Johnson43971f52012-07-17 12:26:56 -07002573 if (pMsgBuf == NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -07002574 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002575 limLog(pMac, LOGE, FL("Buffer is Pointing to NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002576 return;
2577 }
2578
Jeff Johnson43971f52012-07-17 12:26:56 -07002579 limGetSessionInfo(pMac, (tANI_U8 *)pMsgBuf,&smesessionId, &smetransactionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07002580
Jeff Johnson43971f52012-07-17 12:26:56 -07002581 status = limDisassocReqSerDes(pMac, &smeDisassocReq, (tANI_U8 *) pMsgBuf);
Jeff Johnson295189b2012-06-20 16:38:30 -07002582
Jeff Johnson43971f52012-07-17 12:26:56 -07002583 if ( (eSIR_FAILURE == status) ||
2584 (!limIsSmeDisassocReqValid(pMac, &smeDisassocReq, psessionEntry)) )
Jeff Johnson295189b2012-06-20 16:38:30 -07002585 {
2586 PELOGE(limLog(pMac, LOGE,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002587 FL("received invalid SME_DISASSOC_REQ message"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07002588
2589 if (pMac->lim.gLimRspReqd)
2590 {
2591 pMac->lim.gLimRspReqd = false;
2592
2593 retCode = eSIR_SME_INVALID_PARAMETERS;
2594 disassocTrigger = eLIM_HOST_DISASSOC;
2595 goto sendDisassoc;
2596 }
2597
2598 return;
2599 }
2600
Jeff Johnson295189b2012-06-20 16:38:30 -07002601 if((psessionEntry = peFindSessionByBssid(pMac,smeDisassocReq.bssId,&sessionId))== NULL)
2602 {
Abhishek Singhcd09b562013-12-24 16:02:20 +05302603 limLog(pMac, LOGE,FL("session does not exist for given bssId "MAC_ADDRESS_STR),
2604 MAC_ADDR_ARRAY(smeDisassocReq.bssId));
Jeff Johnson295189b2012-06-20 16:38:30 -07002605 retCode = eSIR_SME_INVALID_PARAMETERS;
2606 disassocTrigger = eLIM_HOST_DISASSOC;
2607 goto sendDisassoc;
2608
2609 }
Abhishek Singhcd09b562013-12-24 16:02:20 +05302610 limLog(pMac, LOG1, FL("received DISASSOC_REQ message on sessionid %d"
2611 "Systemrole %d Reason: %u SmeState: %d from: "MAC_ADDRESS_STR),
2612 smesessionId,psessionEntry->limSystemRole,
2613 smeDisassocReq.reasonCode, pMac->lim.gLimSmeState,
2614 MAC_ADDR_ARRAY(smeDisassocReq.peerMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07002615
2616#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM //FEATURE_WLAN_DIAG_SUPPORT
2617 limDiagEventReport(pMac, WLAN_PE_DIAG_DISASSOC_REQ_EVENT, psessionEntry, 0, smeDisassocReq.reasonCode);
2618#endif //FEATURE_WLAN_DIAG_SUPPORT
2619
2620 /* Update SME session Id and SME transaction ID*/
2621
2622 psessionEntry->smeSessionId = smesessionId;
2623 psessionEntry->transactionId = smetransactionId;
2624
2625 switch (psessionEntry->limSystemRole)
2626 {
2627 case eLIM_STA_ROLE:
2628 case eLIM_BT_AMP_STA_ROLE:
2629 switch (psessionEntry->limSmeState)
2630 {
2631 case eLIM_SME_ASSOCIATED_STATE:
2632 case eLIM_SME_LINK_EST_STATE:
Kanchanapally, Vidyullathac796fc62015-03-17 10:45:28 +05302633 limLog(pMac, LOG1, FL("Rcvd SME_DISASSOC_REQ while in "
2634 "limSmeState: %d "),psessionEntry->limSmeState);
2635
Jeff Johnson295189b2012-06-20 16:38:30 -07002636 psessionEntry->limPrevSmeState = psessionEntry->limSmeState;
2637 psessionEntry->limSmeState= eLIM_SME_WT_DISASSOC_STATE;
Hoonki Lee8c9e99f2013-04-18 22:59:11 -07002638#ifdef FEATURE_WLAN_TDLS
2639 /* Delete all TDLS peers connected before leaving BSS*/
2640 limDeleteTDLSPeers(pMac, psessionEntry);
2641#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07002642 MTRACE(macTrace(pMac, TRACE_CODE_SME_STATE, psessionEntry->peSessionId, psessionEntry->limSmeState));
Jeff Johnson295189b2012-06-20 16:38:30 -07002643 break;
2644
2645 case eLIM_SME_WT_DEAUTH_STATE:
2646 /* PE shall still process the DISASSOC_REQ and proceed with
2647 * link tear down even if it had already sent a DEAUTH_IND to
2648 * to SME. pMac->lim.gLimPrevSmeState shall remain the same as
2649 * its been set when PE entered WT_DEAUTH_STATE.
2650 */
2651 psessionEntry->limSmeState= eLIM_SME_WT_DISASSOC_STATE;
Jeff Johnsone7245742012-09-05 17:12:55 -07002652 MTRACE(macTrace(pMac, TRACE_CODE_SME_STATE, psessionEntry->peSessionId, psessionEntry->limSmeState));
Abhishek Singhcd09b562013-12-24 16:02:20 +05302653 limLog(pMac, LOG1, FL("Rcvd SME_DISASSOC_REQ while in "
2654 "SME_WT_DEAUTH_STATE. "));
Jeff Johnson295189b2012-06-20 16:38:30 -07002655 break;
2656
2657 case eLIM_SME_WT_DISASSOC_STATE:
2658 /* PE Recieved a Disassoc frame. Normally it gets DISASSOC_CNF but it
2659 * received DISASSOC_REQ. Which means host is also trying to disconnect.
2660 * PE can continue processing DISASSOC_REQ and send the response instead
2661 * of failing the request. SME will anyway ignore DEAUTH_IND that was sent
2662 * for disassoc frame.
2663 *
2664 * It will send a disassoc, which is ok. However, we can use the global flag
2665 * sendDisassoc to not send disassoc frame.
2666 */
Abhishek Singhcd09b562013-12-24 16:02:20 +05302667 limLog(pMac, LOG1, FL("Rcvd SME_DISASSOC_REQ while in "
2668 "SME_WT_DISASSOC_STATE. "));
Jeff Johnson295189b2012-06-20 16:38:30 -07002669 break;
2670
2671 case eLIM_SME_JOIN_FAILURE_STATE: {
2672 /** Return Success as we are already in Disconnected State*/
Abhishek Singhcd09b562013-12-24 16:02:20 +05302673 limLog(pMac, LOG1, FL("Rcvd SME_DISASSOC_REQ while in "
2674 "eLIM_SME_JOIN_FAILURE_STATE. "));
Jeff Johnson295189b2012-06-20 16:38:30 -07002675 if (pMac->lim.gLimRspReqd) {
2676 retCode = eSIR_SME_SUCCESS;
2677 disassocTrigger = eLIM_HOST_DISASSOC;
2678 goto sendDisassoc;
2679 }
2680 }break;
2681 default:
2682 /**
2683 * STA is not currently associated.
2684 * Log error and send response to host
2685 */
2686 limLog(pMac, LOGE,
Sushant Kaushik1b645382014-10-13 16:39:36 +05302687 FL("received unexpected SME_DISASSOC_REQ in state %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002688 psessionEntry->limSmeState);
2689 limPrintSmeState(pMac, LOGE, psessionEntry->limSmeState);
2690
2691 if (pMac->lim.gLimRspReqd)
2692 {
2693 if (psessionEntry->limSmeState !=
2694 eLIM_SME_WT_ASSOC_STATE)
2695 pMac->lim.gLimRspReqd = false;
2696
2697 retCode = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
2698 disassocTrigger = eLIM_HOST_DISASSOC;
2699 goto sendDisassoc;
2700 }
2701
2702 return;
2703 }
2704
2705 break;
2706
2707 case eLIM_AP_ROLE:
2708 case eLIM_BT_AMP_AP_ROLE:
2709 // Fall through
2710 break;
2711
2712 case eLIM_STA_IN_IBSS_ROLE:
2713 default: // eLIM_UNKNOWN_ROLE
2714 limLog(pMac, LOGE,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002715 FL("received unexpected SME_DISASSOC_REQ for role %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002716 psessionEntry->limSystemRole);
2717
2718 retCode = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
2719 disassocTrigger = eLIM_HOST_DISASSOC;
2720 goto sendDisassoc;
2721 } // end switch (pMac->lim.gLimSystemRole)
2722
Edhar, Mahesh Kumar03cf7ff2015-11-26 17:59:29 +05302723 disassocTrigger = eLIM_HOST_DISASSOC;
2724 reasonCode = smeDisassocReq.reasonCode;
Jeff Johnson295189b2012-06-20 16:38:30 -07002725
2726 if (smeDisassocReq.doNotSendOverTheAir)
2727 {
Abhishek Singhcd09b562013-12-24 16:02:20 +05302728 limLog(pMac, LOG1, FL("do not send dissoc over the air"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002729 sendDisassocFrame = 0;
2730 }
2731 // Trigger Disassociation frame to peer MAC entity
Sachin Ahuja2fea3d12014-12-18 17:31:31 +05302732 limLog(pMac, LOG1, FL("Sending Disasscoc with disassoc Trigger"
2733 " : %d, reasonCode : %d"),
2734 disassocTrigger, reasonCode);
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302735 pMlmDisassocReq = vos_mem_malloc(sizeof(tLimMlmDisassocReq));
2736 if ( NULL == pMlmDisassocReq )
Jeff Johnson295189b2012-06-20 16:38:30 -07002737 {
2738 // Log error
2739 limLog(pMac, LOGP,
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302740 FL("call to AllocateMemory failed for mlmDisassocReq"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002741
2742 return;
2743 }
2744
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302745 vos_mem_copy( (tANI_U8 *) &pMlmDisassocReq->peerMacAddr,
Jeff Johnson295189b2012-06-20 16:38:30 -07002746 (tANI_U8 *) &smeDisassocReq.peerMacAddr,
2747 sizeof(tSirMacAddr));
2748
2749 pMlmDisassocReq->reasonCode = reasonCode;
2750 pMlmDisassocReq->disassocTrigger = disassocTrigger;
2751
2752 /* Update PE session ID*/
2753 pMlmDisassocReq->sessionId = sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -07002754
2755 limPostMlmMessage(pMac,
2756 LIM_MLM_DISASSOC_REQ,
2757 (tANI_U32 *) pMlmDisassocReq);
2758 return;
2759
2760sendDisassoc:
2761 if (psessionEntry)
2762 limSendSmeDisassocNtf(pMac, smeDisassocReq.peerMacAddr,
2763 retCode,
2764 disassocTrigger,
Jeff Johnson295189b2012-06-20 16:38:30 -07002765 1,smesessionId,smetransactionId,psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07002766 else
2767 limSendSmeDisassocNtf(pMac, smeDisassocReq.peerMacAddr,
2768 retCode,
2769 disassocTrigger,
Sudhir Sattayappa Kohalli5a8ac222013-03-06 12:41:42 -08002770 1, smesessionId, smetransactionId, NULL);
Jeff Johnson295189b2012-06-20 16:38:30 -07002771
2772
2773} /*** end __limProcessSmeDisassocReq() ***/
2774
2775
2776/** -----------------------------------------------------------------
2777 \brief __limProcessSmeDisassocCnf() - Process SME_DISASSOC_CNF
2778
2779 This function is called to process SME_DISASSOC_CNF message
2780 from HDD or upper layer application.
2781
2782 \param pMac - global mac structure
2783 \param pStaDs - station dph hash node
2784 \return none
2785 \sa
2786 ----------------------------------------------------------------- */
2787static void
2788__limProcessSmeDisassocCnf(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
2789{
2790 tSirSmeDisassocCnf smeDisassocCnf;
2791 tANI_U16 aid;
2792 tpDphHashNode pStaDs;
2793 tSirRetStatus status = eSIR_SUCCESS;
2794 tpPESession psessionEntry;
2795 tANI_U8 sessionId;
2796
2797
Abhishek Singh3cbf6052014-12-15 16:46:42 +05302798 limLog(pMac, LOG1, FL("received SME_DISASSOC_CNF message"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002799
2800 status = limDisassocCnfSerDes(pMac, &smeDisassocCnf,(tANI_U8 *) pMsgBuf);
2801
2802 if (status == eSIR_FAILURE)
2803 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002804 PELOGE(limLog(pMac, LOGE, FL("invalid SME_DISASSOC_CNF message"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07002805 return;
2806 }
2807
2808 if((psessionEntry = peFindSessionByBssid(pMac, smeDisassocCnf.bssId, &sessionId))== NULL)
2809 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002810 limLog(pMac, LOGE,FL("session does not exist for given bssId"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002811 return;
2812 }
2813
2814 if (!limIsSmeDisassocCnfValid(pMac, &smeDisassocCnf, psessionEntry))
2815 {
Abhishek Singhcd09b562013-12-24 16:02:20 +05302816 limLog(pMac, LOGE, FL("received invalid SME_DISASSOC_CNF message"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002817 return;
2818 }
2819
2820#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM //FEATURE_WLAN_DIAG_SUPPORT
2821 if (smeDisassocCnf.messageType == eWNI_SME_DISASSOC_CNF)
2822 limDiagEventReport(pMac, WLAN_PE_DIAG_DISASSOC_CNF_EVENT, psessionEntry, (tANI_U16)smeDisassocCnf.statusCode, 0);
2823 else if (smeDisassocCnf.messageType == eWNI_SME_DEAUTH_CNF)
2824 limDiagEventReport(pMac, WLAN_PE_DIAG_DEAUTH_CNF_EVENT, psessionEntry, (tANI_U16)smeDisassocCnf.statusCode, 0);
2825#endif //FEATURE_WLAN_DIAG_SUPPORT
2826
2827 switch (psessionEntry->limSystemRole)
2828 {
2829 case eLIM_STA_ROLE:
2830 case eLIM_BT_AMP_STA_ROLE: //To test reconn
2831 if ((psessionEntry->limSmeState != eLIM_SME_IDLE_STATE) &&
2832 (psessionEntry->limSmeState != eLIM_SME_WT_DISASSOC_STATE) &&
2833 (psessionEntry->limSmeState != eLIM_SME_WT_DEAUTH_STATE))
2834 {
2835 limLog(pMac, LOGE,
Sushant Kaushik1b645382014-10-13 16:39:36 +05302836 FL("received unexp SME_DISASSOC_CNF in state %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002837 psessionEntry->limSmeState);
2838 limPrintSmeState(pMac, LOGE, psessionEntry->limSmeState);
2839 return;
2840 }
2841 break;
2842
2843 case eLIM_AP_ROLE:
2844 // Fall through
Jeff Johnson295189b2012-06-20 16:38:30 -07002845 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07002846
2847 case eLIM_STA_IN_IBSS_ROLE:
2848 default: // eLIM_UNKNOWN_ROLE
2849 limLog(pMac, LOGE,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002850 FL("received unexpected SME_DISASSOC_CNF role %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002851 psessionEntry->limSystemRole);
2852
2853 return;
2854 }
2855
2856
2857 if ( (psessionEntry->limSmeState == eLIM_SME_WT_DISASSOC_STATE) ||
2858 (psessionEntry->limSmeState == eLIM_SME_WT_DEAUTH_STATE)
Jeff Johnson295189b2012-06-20 16:38:30 -07002859 || (psessionEntry->limSystemRole == eLIM_AP_ROLE )
Jeff Johnson295189b2012-06-20 16:38:30 -07002860 )
2861 {
2862 pStaDs = dphLookupHashEntry(pMac, smeDisassocCnf.peerMacAddr, &aid, &psessionEntry->dph.dphHashTable);
2863 if (pStaDs == NULL)
2864 {
Abhishek Singhcd09b562013-12-24 16:02:20 +05302865 PELOGE(limLog(pMac, LOGE, FL("received DISASSOC_CNF for a STA that "
2866 "does not have context, addr= "MAC_ADDRESS_STR),
2867 MAC_ADDR_ARRAY(smeDisassocCnf.peerMacAddr));)
Jeff Johnson295189b2012-06-20 16:38:30 -07002868 return;
2869 }
Wu Gao742b7352015-10-16 19:10:40 +08002870
2871 if(aid != smeDisassocCnf.assocId)
2872 {
2873 PELOGE(limLog(pMac, LOGE, FL("same peerMacAddr but assocId is different "
2874 "aid=%d, assocId=%d, addr= "MAC_ADDRESS_STR),
2875 aid, smeDisassocCnf.assocId, MAC_ADDR_ARRAY(smeDisassocCnf.peerMacAddr));)
2876 return;
2877 }
Padma, Santhosh Kumar05600d32015-07-24 13:00:57 +05302878 /*
2879 * If MlM state is either of del_sta or del_bss state, then no need to
2880 * go ahead and clean up further as there must be some cleanup in
2881 * progress from upper layer disassoc/deauth request.
2882 */
2883 if((pStaDs->mlmStaContext.mlmState == eLIM_MLM_WT_DEL_STA_RSP_STATE) ||
2884 (pStaDs->mlmStaContext.mlmState == eLIM_MLM_WT_DEL_BSS_RSP_STATE))
2885 {
2886 limLog(pMac, LOGE, FL("No need to cleanup for addr:"MAC_ADDRESS_STR
2887 "as Mlm state is %d"),
2888 MAC_ADDR_ARRAY(smeDisassocCnf.peerMacAddr),
2889 pStaDs->mlmStaContext.mlmState);
2890 return;
2891 }
2892
Madan Mohan Koyyalamudi23001722012-10-31 16:48:56 -07002893 /* Delete FT session if there exists one */
2894 limFTCleanup(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -07002895 limCleanupRxPath(pMac, pStaDs, psessionEntry);
Madan Mohan Koyyalamudia67d4332012-11-29 11:35:23 -08002896
2897 limCleanUpDisassocDeauthReq(pMac, (char*)&smeDisassocCnf.peerMacAddr, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07002898 }
2899
2900 return;
2901}
2902
2903
2904/**
2905 * __limProcessSmeDeauthReq()
2906 *
2907 *FUNCTION:
2908 * This function is called to process SME_DEAUTH_REQ message
2909 * from HDD or upper layer application.
2910 *
2911 *LOGIC:
2912 *
2913 *ASSUMPTIONS:
2914 *
2915 *NOTE:
2916 *
2917 * @param pMac Pointer to Global MAC structure
2918 * @param *pMsgBuf A pointer to the SME message buffer
2919 * @return None
2920 */
2921
2922static void
2923__limProcessSmeDeauthReq(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
2924{
2925 tANI_U16 deauthTrigger, reasonCode;
2926 tLimMlmDeauthReq *pMlmDeauthReq;
2927 tSirSmeDeauthReq smeDeauthReq;
2928 tSirResultCodes retCode = eSIR_SME_SUCCESS;
2929 tSirRetStatus status = eSIR_SUCCESS;
2930 tpPESession psessionEntry;
2931 tANI_U8 sessionId; //PE sessionId
2932 tANI_U8 smesessionId;
2933 tANI_U16 smetransactionId;
2934
Jeff Johnson295189b2012-06-20 16:38:30 -07002935
2936 status = limDeauthReqSerDes(pMac, &smeDeauthReq,(tANI_U8 *) pMsgBuf);
Jeff Johnson295189b2012-06-20 16:38:30 -07002937 limGetSessionInfo(pMac,(tANI_U8 *)pMsgBuf,&smesessionId,&smetransactionId);
2938
2939 //We need to get a session first but we don't even know if the message is correct.
2940 if((psessionEntry = peFindSessionByBssid(pMac, smeDeauthReq.bssId, &sessionId)) == NULL)
2941 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002942 limLog(pMac, LOGE,FL("session does not exist for given bssId"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002943 retCode = eSIR_SME_INVALID_PARAMETERS;
2944 deauthTrigger = eLIM_HOST_DEAUTH;
2945 goto sendDeauth;
2946
2947 }
2948
2949 if ((status == eSIR_FAILURE) || (!limIsSmeDeauthReqValid(pMac, &smeDeauthReq, psessionEntry)))
2950 {
Sachin Ahuja42354142015-01-06 19:48:35 +05302951 PELOGE(limLog(pMac, LOGE,FL
2952 ("received invalid SME_DEAUTH_REQ message"));)
2953 pMac->lim.gLimRspReqd = false;
Jeff Johnson295189b2012-06-20 16:38:30 -07002954
Sachin Ahuja42354142015-01-06 19:48:35 +05302955 retCode = eSIR_SME_INVALID_PARAMETERS;
2956 deauthTrigger = eLIM_HOST_DEAUTH;
2957 goto sendDeauth;
Jeff Johnson295189b2012-06-20 16:38:30 -07002958 }
Abhishek Singhcd09b562013-12-24 16:02:20 +05302959 limLog(pMac, LOG1,FL("received DEAUTH_REQ message on sessionid %d "
2960 "Systemrole %d with reasoncode %u in limSmestate %d from "
2961 MAC_ADDRESS_STR), smesessionId, psessionEntry->limSystemRole,
2962 smeDeauthReq.reasonCode, psessionEntry->limSmeState,
2963 MAC_ADDR_ARRAY(smeDeauthReq.peerMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07002964#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM //FEATURE_WLAN_DIAG_SUPPORT
2965 limDiagEventReport(pMac, WLAN_PE_DIAG_DEAUTH_REQ_EVENT, psessionEntry, 0, smeDeauthReq.reasonCode);
2966#endif //FEATURE_WLAN_DIAG_SUPPORT
2967
2968 /* Update SME session ID and Transaction ID */
2969 psessionEntry->smeSessionId = smesessionId;
2970 psessionEntry->transactionId = smetransactionId;
2971
2972
2973 switch (psessionEntry->limSystemRole)
2974 {
2975 case eLIM_STA_ROLE:
2976 case eLIM_BT_AMP_STA_ROLE:
2977
2978 switch (psessionEntry->limSmeState)
2979 {
2980 case eLIM_SME_ASSOCIATED_STATE:
2981 case eLIM_SME_LINK_EST_STATE:
2982 case eLIM_SME_WT_ASSOC_STATE:
2983 case eLIM_SME_JOIN_FAILURE_STATE:
2984 case eLIM_SME_IDLE_STATE:
2985 psessionEntry->limPrevSmeState = psessionEntry->limSmeState;
2986 psessionEntry->limSmeState = eLIM_SME_WT_DEAUTH_STATE;
Varun Reddy Yeturue3bbf6e2013-02-08 18:50:55 -08002987 MTRACE(macTrace(pMac, TRACE_CODE_SME_STATE, psessionEntry->peSessionId, psessionEntry->limSmeState));
Jeff Johnson295189b2012-06-20 16:38:30 -07002988
2989 // Send Deauthentication request to MLM below
2990
2991 break;
Sachin Ahujaa100dcc2014-07-03 14:30:18 +05302992 case eLIM_SME_WT_DEAUTH_STATE:
2993 /*
2994 * PE Recieved a Deauth frame. Normally it gets
2995 * DEAUTH_CNF but it received DEAUTH_REQ. Which
2996 * means host is also trying to disconnect.
2997 * PE can continue processing DEAUTH_REQ and send
2998 * the response instead of failing the request.
2999 * SME will anyway ignore DEAUTH_IND that was sent
3000 * for deauth frame.
3001 */
3002 limLog(pMac, LOG1, FL("Rcvd SME_DEAUTH_REQ while in "
3003 "SME_WT_DEAUTH_STATE. "));
3004 break;
Padma, Santhosh Kumar05600d32015-07-24 13:00:57 +05303005 case eLIM_SME_WT_DISASSOC_STATE:
3006 /*
3007 * PE Recieved a Disassoc frame. Normally it gets
3008 * DISASSOC_CNF but it received DEAUTH_REQ. This means
3009 * host is also trying to disconnect.
3010 */
3011 limLog(pMac, LOG1, FL("Rcvd SME_DEAUTH_REQ while in "
3012 "SME_WT_DISASSOC_STATE. "));
3013 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003014 default:
3015 /**
3016 * STA is not in a state to deauthenticate with
3017 * peer. Log error and send response to host.
3018 */
3019 limLog(pMac, LOGE,
Sushant Kaushik1b645382014-10-13 16:39:36 +05303020 FL("received unexp SME_DEAUTH_REQ in state %d"),
Abhishek Singhcd09b562013-12-24 16:02:20 +05303021 psessionEntry->limSmeState);
Jeff Johnson295189b2012-06-20 16:38:30 -07003022 limPrintSmeState(pMac, LOGE, psessionEntry->limSmeState);
3023
3024 if (pMac->lim.gLimRspReqd)
3025 {
3026 pMac->lim.gLimRspReqd = false;
3027
3028 retCode = eSIR_SME_STA_NOT_AUTHENTICATED;
3029 deauthTrigger = eLIM_HOST_DEAUTH;
Leela Venkata Kiran Kumar Reddy Chirala56df73f2014-01-30 14:18:00 -08003030 /**
3031 *here we received deauth request from AP so sme state is
3032 eLIM_SME_WT_DEAUTH_STATE.if we have ISSUED delSta then
3033 mlm state should be eLIM_MLM_WT_DEL_STA_RSP_STATE and if
3034 we got delBSS rsp then mlm state should be eLIM_MLM_IDLE_STATE
3035 so the below condition captures the state where delSta
3036 not done and firmware still in connected state.
3037 */
3038 if (psessionEntry->limSmeState == eLIM_SME_WT_DEAUTH_STATE &&
3039 psessionEntry->limMlmState != eLIM_MLM_IDLE_STATE &&
3040 psessionEntry->limMlmState != eLIM_MLM_WT_DEL_STA_RSP_STATE)
3041 {
3042 retCode = eSIR_SME_DEAUTH_STATUS;
3043 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003044 goto sendDeauth;
3045 }
3046
3047 return;
3048 }
3049
3050 break;
3051
3052 case eLIM_STA_IN_IBSS_ROLE:
Abhishek Singh92fbac22015-03-24 17:57:36 +05303053 limLog(pMac, LOGE,FL("Deauth not allowed in IBSS"));
3054 if (pMac->lim.gLimRspReqd)
3055 {
3056 pMac->lim.gLimRspReqd = false;
3057 retCode = eSIR_SME_INVALID_PARAMETERS;
3058 deauthTrigger = eLIM_HOST_DEAUTH;
3059 goto sendDeauth;
3060 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003061 return;
3062
3063 case eLIM_AP_ROLE:
3064 // Fall through
3065
3066 break;
3067
3068 default:
3069 limLog(pMac, LOGE,
Sushant Kaushik1b645382014-10-13 16:39:36 +05303070 FL("received unexpected SME_DEAUTH_REQ for role %d"),
Abhishek Singhcd09b562013-12-24 16:02:20 +05303071 psessionEntry->limSystemRole);
Abhishek Singh92fbac22015-03-24 17:57:36 +05303072 if (pMac->lim.gLimRspReqd)
3073 {
3074 pMac->lim.gLimRspReqd = false;
Jeff Johnson295189b2012-06-20 16:38:30 -07003075
Abhishek Singh92fbac22015-03-24 17:57:36 +05303076 retCode = eSIR_SME_INVALID_PARAMETERS;
3077 deauthTrigger = eLIM_HOST_DEAUTH;
3078 goto sendDeauth;
3079 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003080 return;
Abhishek Singh92fbac22015-03-24 17:57:36 +05303081
Jeff Johnson295189b2012-06-20 16:38:30 -07003082 } // end switch (pMac->lim.gLimSystemRole)
3083
3084 if (smeDeauthReq.reasonCode == eLIM_LINK_MONITORING_DEAUTH)
3085 {
3086 /// Deauthentication is triggered by Link Monitoring
Abhishek Singh3cbf6052014-12-15 16:46:42 +05303087 limLog(pMac, LOG1,
3088 FL("Deauthentication is triggered by Link Monitoring"));
3089 limLog(pMac, LOG1,
3090 FL("Set Trigger to eLIM_LINK_MONITORING_DEAUTH"));
3091 limLog(pMac, LOG1,
3092 FL("and Reason to eSIR_MAC_UNSPEC_FAILURE_REASON"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003093 deauthTrigger = eLIM_LINK_MONITORING_DEAUTH;
3094 reasonCode = eSIR_MAC_UNSPEC_FAILURE_REASON;
3095 }
3096 else
3097 {
3098 deauthTrigger = eLIM_HOST_DEAUTH;
3099 reasonCode = smeDeauthReq.reasonCode;
3100 }
3101
3102 // Trigger Deauthentication frame to peer MAC entity
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303103 pMlmDeauthReq = vos_mem_malloc(sizeof(tLimMlmDeauthReq));
3104 if ( NULL == pMlmDeauthReq )
Jeff Johnson295189b2012-06-20 16:38:30 -07003105 {
3106 // Log error
Abhishek Singh92fbac22015-03-24 17:57:36 +05303107 limLog(pMac, LOGE,
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303108 FL("call to AllocateMemory failed for mlmDeauthReq"));
Abhishek Singh92fbac22015-03-24 17:57:36 +05303109 if (pMac->lim.gLimRspReqd)
3110 {
3111 pMac->lim.gLimRspReqd = false;
3112 retCode = eSIR_SME_RESOURCES_UNAVAILABLE;
3113 deauthTrigger = eLIM_HOST_DEAUTH;
3114 goto sendDeauth;
3115 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003116 return;
3117 }
3118
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303119 vos_mem_copy( (tANI_U8 *) &pMlmDeauthReq->peerMacAddr,
Jeff Johnson295189b2012-06-20 16:38:30 -07003120 (tANI_U8 *) &smeDeauthReq.peerMacAddr,
3121 sizeof(tSirMacAddr));
3122
3123 pMlmDeauthReq->reasonCode = reasonCode;
3124 pMlmDeauthReq->deauthTrigger = deauthTrigger;
Jeff Johnson295189b2012-06-20 16:38:30 -07003125
3126 /* Update PE session Id*/
3127 pMlmDeauthReq->sessionId = sessionId;
3128
3129 limPostMlmMessage(pMac,
3130 LIM_MLM_DEAUTH_REQ,
3131 (tANI_U32 *) pMlmDeauthReq);
3132 return;
3133
3134sendDeauth:
3135 limSendSmeDeauthNtf(pMac, smeDeauthReq.peerMacAddr,
3136 retCode,
3137 deauthTrigger,
Jeff Johnson295189b2012-06-20 16:38:30 -07003138 1,
Jeff Johnson295189b2012-06-20 16:38:30 -07003139 smesessionId, smetransactionId);
3140} /*** end __limProcessSmeDeauthReq() ***/
3141
3142
3143
3144/**
3145 * __limProcessSmeSetContextReq()
3146 *
3147 *FUNCTION:
3148 * This function is called to process SME_SETCONTEXT_REQ message
3149 * from HDD or upper layer application.
3150 *
3151 *LOGIC:
3152 *
3153 *ASSUMPTIONS:
3154 *
3155 *NOTE:
3156 *
3157 * @param pMac Pointer to Global MAC structure
3158 * @param *pMsgBuf A pointer to the SME message buffer
3159 * @return None
3160 */
3161
3162static void
3163__limProcessSmeSetContextReq(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
3164{
3165 tpSirSmeSetContextReq pSetContextReq;
3166 tLimMlmSetKeysReq *pMlmSetKeysReq;
3167 tpPESession psessionEntry;
3168 tANI_U8 sessionId; //PE sessionID
3169 tANI_U8 smesessionId;
3170 tANI_U16 smetransactionId;
3171
3172
3173 PELOG1(limLog(pMac, LOG1,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003174 FL("received SETCONTEXT_REQ message")););
Jeff Johnson295189b2012-06-20 16:38:30 -07003175
3176
3177 if(pMsgBuf == NULL)
3178 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003179 limLog(pMac, LOGE,FL("Buffer is Pointing to NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003180 return;
3181 }
3182
3183 limGetSessionInfo(pMac,(tANI_U8 *)pMsgBuf,&smesessionId,&smetransactionId);
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303184
3185 pSetContextReq = vos_mem_malloc(sizeof(tSirKeys) * SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS);
3186 if ( NULL == pSetContextReq )
Jeff Johnson295189b2012-06-20 16:38:30 -07003187 {
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303188 limLog(pMac, LOGP, FL("call to AllocateMemory failed for pSetContextReq"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003189 return;
3190 }
3191
3192 if ((limSetContextReqSerDes(pMac, pSetContextReq, (tANI_U8 *) pMsgBuf) == eSIR_FAILURE) ||
3193 (!limIsSmeSetContextReqValid(pMac, pSetContextReq)))
3194 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003195 limLog(pMac, LOGW, FL("received invalid SME_SETCONTEXT_REQ message"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003196 goto end;
3197 }
3198
3199 if(pSetContextReq->keyMaterial.numKeys > SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS)
3200 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003201 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 -07003202 limSendSmeSetContextRsp(pMac,
3203 pSetContextReq->peerMacAddr,
Jeff Johnson295189b2012-06-20 16:38:30 -07003204 1,
Jeff Johnson295189b2012-06-20 16:38:30 -07003205 eSIR_SME_INVALID_PARAMETERS,NULL,
3206 smesessionId,smetransactionId);
3207
3208 goto end;
3209 }
3210
3211
3212 if((psessionEntry = peFindSessionByBssid(pMac, pSetContextReq->bssId, &sessionId)) == NULL)
3213 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003214 limLog(pMac, LOGW, FL("Session does not exist for given BSSID"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003215 limSendSmeSetContextRsp(pMac,
3216 pSetContextReq->peerMacAddr,
Jeff Johnson295189b2012-06-20 16:38:30 -07003217 1,
Jeff Johnson295189b2012-06-20 16:38:30 -07003218 eSIR_SME_INVALID_PARAMETERS,NULL,
3219 smesessionId,smetransactionId);
3220
3221 goto end;
3222 }
3223
3224#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM //FEATURE_WLAN_DIAG_SUPPORT
3225 limDiagEventReport(pMac, WLAN_PE_DIAG_SETCONTEXT_REQ_EVENT, psessionEntry, 0, 0);
3226#endif //FEATURE_WLAN_DIAG_SUPPORT
3227
3228
3229 if ((((psessionEntry->limSystemRole == eLIM_STA_ROLE) || (psessionEntry->limSystemRole == eLIM_BT_AMP_STA_ROLE)) &&
3230 (psessionEntry->limSmeState == eLIM_SME_LINK_EST_STATE)) ||
3231 (((psessionEntry->limSystemRole == eLIM_STA_IN_IBSS_ROLE) ||
3232 (psessionEntry->limSystemRole == eLIM_AP_ROLE)|| (psessionEntry->limSystemRole == eLIM_BT_AMP_AP_ROLE)) &&
3233 (psessionEntry->limSmeState == eLIM_SME_NORMAL_STATE)))
3234 {
3235 // Trigger MLM_SETKEYS_REQ
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303236 pMlmSetKeysReq = vos_mem_malloc(sizeof(tLimMlmSetKeysReq));
3237 if ( NULL == pMlmSetKeysReq )
Jeff Johnson295189b2012-06-20 16:38:30 -07003238 {
3239 // Log error
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303240 limLog(pMac, LOGP, FL("call to AllocateMemory failed for mlmSetKeysReq"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003241 goto end;
3242 }
Abhishek Singhb25e8442015-06-23 14:28:05 +05303243 vos_mem_zero(pMlmSetKeysReq,sizeof(tLimMlmSetKeysReq));
Jeff Johnson295189b2012-06-20 16:38:30 -07003244 pMlmSetKeysReq->edType = pSetContextReq->keyMaterial.edType;
3245 pMlmSetKeysReq->numKeys = pSetContextReq->keyMaterial.numKeys;
3246 if(pMlmSetKeysReq->numKeys > SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS)
3247 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003248 limLog(pMac, LOGP, FL("Num of keys exceeded max num of default keys limit"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003249 goto end;
3250 }
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303251 vos_mem_copy( (tANI_U8 *) &pMlmSetKeysReq->peerMacAddr,
Jeff Johnson295189b2012-06-20 16:38:30 -07003252 (tANI_U8 *) &pSetContextReq->peerMacAddr,
3253 sizeof(tSirMacAddr));
3254
Jeff Johnson295189b2012-06-20 16:38:30 -07003255
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303256 vos_mem_copy( (tANI_U8 *) &pMlmSetKeysReq->key,
Jeff Johnson295189b2012-06-20 16:38:30 -07003257 (tANI_U8 *) &pSetContextReq->keyMaterial.key,
3258 sizeof(tSirKeys) * (pMlmSetKeysReq->numKeys ? pMlmSetKeysReq->numKeys : 1));
3259
3260 pMlmSetKeysReq->sessionId = sessionId;
3261#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
3262 PELOG1(limLog(pMac, LOG1,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003263 FL("received SETCONTEXT_REQ message sessionId=%d"), pMlmSetKeysReq->sessionId););
Jeff Johnson295189b2012-06-20 16:38:30 -07003264#endif
3265
Jeff Johnson295189b2012-06-20 16:38:30 -07003266 if(((pSetContextReq->keyMaterial.edType == eSIR_ED_WEP40) || (pSetContextReq->keyMaterial.edType == eSIR_ED_WEP104))
3267 && (psessionEntry->limSystemRole == eLIM_AP_ROLE))
3268 {
3269 if(pSetContextReq->keyMaterial.key[0].keyLength)
3270 {
3271 tANI_U8 keyId;
3272 keyId = pSetContextReq->keyMaterial.key[0].keyId;
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303273 vos_mem_copy( (tANI_U8 *)&psessionEntry->WEPKeyMaterial[keyId],
Jeff Johnson295189b2012-06-20 16:38:30 -07003274 (tANI_U8 *) &pSetContextReq->keyMaterial, sizeof(tSirKeyMaterial));
3275 }
3276 else {
3277 tANI_U32 i;
3278 for( i = 0; i < SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS; i++)
3279 {
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303280 vos_mem_copy( (tANI_U8 *) &pMlmSetKeysReq->key[i],
Jeff Johnson295189b2012-06-20 16:38:30 -07003281 (tANI_U8 *)psessionEntry->WEPKeyMaterial[i].key, sizeof(tSirKeys));
3282 }
3283 }
3284 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003285
3286 limPostMlmMessage(pMac, LIM_MLM_SETKEYS_REQ, (tANI_U32 *) pMlmSetKeysReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07003287 }
3288 else
3289 {
3290 limLog(pMac, LOGE,
Sushant Kaushik1b645382014-10-13 16:39:36 +05303291 FL("received unexpected SME_SETCONTEXT_REQ for role %d, state=%d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07003292 psessionEntry->limSystemRole,
3293 psessionEntry->limSmeState);
3294 limPrintSmeState(pMac, LOGE, psessionEntry->limSmeState);
3295
3296 limSendSmeSetContextRsp(pMac, pSetContextReq->peerMacAddr,
Jeff Johnson295189b2012-06-20 16:38:30 -07003297 1,
Jeff Johnson295189b2012-06-20 16:38:30 -07003298 eSIR_SME_UNEXPECTED_REQ_RESULT_CODE,psessionEntry,
3299 smesessionId,
3300 smetransactionId);
3301 }
3302
3303end:
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05303304 vos_mem_zero(pSetContextReq,
3305 (sizeof(tSirKeys) * SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS));
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303306 vos_mem_free( pSetContextReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07003307 return;
3308} /*** end __limProcessSmeSetContextReq() ***/
3309
3310/**
3311 * __limProcessSmeRemoveKeyReq()
3312 *
3313 *FUNCTION:
3314 * This function is called to process SME_REMOVEKEY_REQ message
3315 * from HDD or upper layer application.
3316 *
3317 *LOGIC:
3318 *
3319 *ASSUMPTIONS:
3320 *
3321 *NOTE:
3322 *
3323 * @param pMac Pointer to Global MAC structure
3324 * @param *pMsgBuf A pointer to the SME message buffer
3325 * @return None
3326 */
3327
3328static void
3329__limProcessSmeRemoveKeyReq(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
3330{
3331 tpSirSmeRemoveKeyReq pRemoveKeyReq;
3332 tLimMlmRemoveKeyReq *pMlmRemoveKeyReq;
3333 tpPESession psessionEntry;
3334 tANI_U8 sessionId; //PE sessionID
3335 tANI_U8 smesessionId;
3336 tANI_U16 smetransactionId;
3337
Abhishek Singh3cbf6052014-12-15 16:46:42 +05303338 limLog(pMac, LOG1,
3339 FL("received SME_REMOVEKEY_REQ message"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003340
3341 if(pMsgBuf == NULL)
3342 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003343 limLog(pMac, LOGE,FL("Buffer is Pointing to NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003344 return;
3345 }
3346
3347
3348 limGetSessionInfo(pMac,(tANI_U8 *)pMsgBuf,&smesessionId,&smetransactionId);
3349
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303350 pRemoveKeyReq = vos_mem_malloc(sizeof(*pRemoveKeyReq));
3351 if ( NULL == pRemoveKeyReq )
Jeff Johnson295189b2012-06-20 16:38:30 -07003352 {
3353 //Log error
3354 limLog(pMac, LOGP,
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303355 FL("call to AllocateMemory failed for pRemoveKeyReq"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003356
3357 return;
3358 }
3359
3360 if ((limRemoveKeyReqSerDes(pMac,
3361 pRemoveKeyReq,
3362 (tANI_U8 *) pMsgBuf) == eSIR_FAILURE))
3363 {
3364 limLog(pMac, LOGW,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003365 FL("received invalid SME_REMOVECONTEXT_REQ message"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003366
3367 /* extra look up is needed since, session entry to be passed il limsendremovekey response */
3368
3369 if((psessionEntry = peFindSessionByBssid(pMac,pRemoveKeyReq->bssId,&sessionId))== NULL)
3370 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003371 limLog(pMac, LOGE,FL("session does not exist for given bssId"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003372 //goto end;
3373 }
3374
3375 limSendSmeRemoveKeyRsp(pMac,
3376 pRemoveKeyReq->peerMacAddr,
3377 eSIR_SME_INVALID_PARAMETERS,psessionEntry,
3378 smesessionId,smetransactionId);
3379
3380 goto end;
3381 }
3382
3383 if((psessionEntry = peFindSessionByBssid(pMac,pRemoveKeyReq->bssId, &sessionId))== NULL)
3384 {
3385 limLog(pMac, LOGE,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003386 FL("session does not exist for given bssId"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003387 limSendSmeRemoveKeyRsp(pMac,
3388 pRemoveKeyReq->peerMacAddr,
3389 eSIR_SME_UNEXPECTED_REQ_RESULT_CODE, NULL,
3390 smesessionId, smetransactionId);
3391 goto end;
3392 }
3393
3394
3395 if ((((psessionEntry->limSystemRole == eLIM_STA_ROLE)|| (psessionEntry->limSystemRole == eLIM_BT_AMP_STA_ROLE))&&
3396 (psessionEntry->limSmeState == eLIM_SME_LINK_EST_STATE)) ||
3397 (((psessionEntry->limSystemRole == eLIM_STA_IN_IBSS_ROLE) ||
3398 (psessionEntry->limSystemRole == eLIM_AP_ROLE)|| (psessionEntry->limSystemRole == eLIM_BT_AMP_AP_ROLE)) &&
3399 (psessionEntry->limSmeState == eLIM_SME_NORMAL_STATE)))
3400 {
3401 // Trigger MLM_REMOVEKEYS_REQ
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303402 pMlmRemoveKeyReq = vos_mem_malloc(sizeof(tLimMlmRemoveKeyReq));
3403 if ( NULL == pMlmRemoveKeyReq )
Jeff Johnson295189b2012-06-20 16:38:30 -07003404 {
3405 // Log error
3406 limLog(pMac, LOGP,
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303407 FL("call to AllocateMemory failed for mlmRemoveKeysReq"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003408
3409 goto end;
3410 }
3411
3412 pMlmRemoveKeyReq->edType = (tAniEdType)pRemoveKeyReq->edType;
3413 pMlmRemoveKeyReq->keyId = pRemoveKeyReq->keyId;
3414 pMlmRemoveKeyReq->wepType = pRemoveKeyReq->wepType;
3415 pMlmRemoveKeyReq->unicast = pRemoveKeyReq->unicast;
3416
3417 /* Update PE session Id */
3418 pMlmRemoveKeyReq->sessionId = sessionId;
3419
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303420 vos_mem_copy( (tANI_U8 *) &pMlmRemoveKeyReq->peerMacAddr,
Jeff Johnson295189b2012-06-20 16:38:30 -07003421 (tANI_U8 *) &pRemoveKeyReq->peerMacAddr,
3422 sizeof(tSirMacAddr));
3423
3424
3425 limPostMlmMessage(pMac,
3426 LIM_MLM_REMOVEKEY_REQ,
3427 (tANI_U32 *) pMlmRemoveKeyReq);
3428 }
3429 else
3430 {
3431 limLog(pMac, LOGE,
Sushant Kaushik1b645382014-10-13 16:39:36 +05303432 FL("received unexpected SME_REMOVEKEY_REQ for role %d, state=%d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07003433 psessionEntry->limSystemRole,
3434 psessionEntry->limSmeState);
3435 limPrintSmeState(pMac, LOGE, psessionEntry->limSmeState);
3436
3437 limSendSmeRemoveKeyRsp(pMac,
3438 pRemoveKeyReq->peerMacAddr,
3439 eSIR_SME_UNEXPECTED_REQ_RESULT_CODE,psessionEntry,
3440 smesessionId,smetransactionId);
3441 }
3442
3443end:
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303444 vos_mem_free( pRemoveKeyReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07003445} /*** end __limProcessSmeRemoveKeyReq() ***/
3446
Jeff Johnson295189b2012-06-20 16:38:30 -07003447void limProcessSmeGetScanChannelInfo(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
3448{
3449 tSirMsgQ mmhMsg;
3450 tpSmeGetScanChnRsp pSirSmeRsp;
3451 tANI_U16 len = 0;
Madan Mohan Koyyalamudide1b5bc2013-07-12 00:56:04 +05303452 tANI_U8 sessionId;
3453 tANI_U16 transactionId;
Jeff Johnson295189b2012-06-20 16:38:30 -07003454
3455 if(pMac->lim.scanChnInfo.numChnInfo > SIR_MAX_SUPPORTED_CHANNEL_LIST)
3456 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003457 limLog(pMac, LOGW, FL("numChn is out of bounds %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07003458 pMac->lim.scanChnInfo.numChnInfo);
3459 pMac->lim.scanChnInfo.numChnInfo = SIR_MAX_SUPPORTED_CHANNEL_LIST;
3460 }
3461
Abhishek Singh525045c2014-12-15 17:18:45 +05303462 limLog(pMac, LOG1,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003463 FL("Sending message %s with number of channels %d"),
Abhishek Singh525045c2014-12-15 17:18:45 +05303464 limMsgStr(eWNI_SME_GET_SCANNED_CHANNEL_RSP), pMac->lim.scanChnInfo.numChnInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -07003465
3466 len = sizeof(tSmeGetScanChnRsp) + (pMac->lim.scanChnInfo.numChnInfo - 1) * sizeof(tLimScanChn);
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303467 pSirSmeRsp = vos_mem_malloc(len);
3468 if ( NULL == pSirSmeRsp )
Jeff Johnson295189b2012-06-20 16:38:30 -07003469 {
3470 /// Buffer not available. Log error
3471 limLog(pMac, LOGP,
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303472 FL("call to AllocateMemory failed for JOIN/REASSOC_RSP"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003473
3474 return;
3475 }
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303476 vos_mem_set(pSirSmeRsp, len, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07003477
Jeff Johnson295189b2012-06-20 16:38:30 -07003478 pSirSmeRsp->mesgType = eWNI_SME_GET_SCANNED_CHANNEL_RSP;
3479 pSirSmeRsp->mesgLen = len;
Madan Mohan Koyyalamudide1b5bc2013-07-12 00:56:04 +05303480
3481 if (pMac->fScanOffload)
3482 {
3483 limGetSessionInfo(pMac,(tANI_U8 *)pMsgBuf,&sessionId,&transactionId);
3484 pSirSmeRsp->sessionId = sessionId;
3485 }
3486 else
3487 pSirSmeRsp->sessionId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003488
3489 if(pMac->lim.scanChnInfo.numChnInfo)
3490 {
3491 pSirSmeRsp->numChn = pMac->lim.scanChnInfo.numChnInfo;
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303492 vos_mem_copy( pSirSmeRsp->scanChn, pMac->lim.scanChnInfo.scanChn,
3493 sizeof(tLimScanChn) * pSirSmeRsp->numChn);
Jeff Johnson295189b2012-06-20 16:38:30 -07003494 }
3495 //Clear the list
3496 limRessetScanChannelInfo(pMac);
3497
3498 mmhMsg.type = eWNI_SME_GET_SCANNED_CHANNEL_RSP;
3499 mmhMsg.bodyptr = pSirSmeRsp;
3500 mmhMsg.bodyval = 0;
3501
3502 pMac->lim.gLimRspReqd = false;
Konamki, Sreelakshmi824f93e2015-07-31 12:55:48 +05303503 MTRACE(macTrace(pMac, TRACE_CODE_TX_SME_MSG, NO_SESSION, mmhMsg.type));
Jeff Johnson295189b2012-06-20 16:38:30 -07003504 limSysProcessMmhMsgApi(pMac, &mmhMsg, ePROT);
3505}
3506
3507
Jeff Johnson295189b2012-06-20 16:38:30 -07003508void limProcessSmeGetAssocSTAsInfo(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
3509{
Hanumantha Reddy Pothula0de10802016-02-11 17:29:27 +05303510 tSirSmeGetAssocSTAsReq getAssocSTAsReq = {0};
Jeff Johnson295189b2012-06-20 16:38:30 -07003511 tpDphHashNode pStaDs = NULL;
3512 tpPESession psessionEntry = NULL;
3513 tSap_Event sapEvent;
3514 tpWLAN_SAPEventCB pSapEventCallback = NULL;
3515 tpSap_AssocMacAddr pAssocStasTemp = NULL;// #include "sapApi.h"
3516 tANI_U8 sessionId = CSR_SESSION_ID_INVALID;
3517 tANI_U8 assocId = 0;
3518 tANI_U8 staCount = 0;
3519
3520 if (!limIsSmeGetAssocSTAsReqValid(pMac, &getAssocSTAsReq, (tANI_U8 *) pMsgBuf))
3521 {
3522 limLog(pMac, LOGE,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003523 FL("received invalid eWNI_SME_GET_ASSOC_STAS_REQ message"));
Girish Gowliafd42312014-07-24 13:13:59 +05303524 return;
Jeff Johnson295189b2012-06-20 16:38:30 -07003525 }
3526
3527 switch (getAssocSTAsReq.modId)
3528 {
3529/**
3530 case VOS_MODULE_ID_HAL:
3531 wdaPostCtrlMsg( pMac, &msgQ );
3532 return;
3533
3534 case VOS_MODULE_ID_TL:
3535 Post msg TL
3536 return;
3537*/
3538 case VOS_MODULE_ID_PE:
3539 default:
3540 break;
3541 }
3542
Jeff Johnson1250df42012-12-10 14:31:52 -08003543 // Get Associated stations from PE
Jeff Johnson295189b2012-06-20 16:38:30 -07003544 // Find PE session Entry
3545 if ((psessionEntry = peFindSessionByBssid(pMac, getAssocSTAsReq.bssId, &sessionId)) == NULL)
3546 {
3547 limLog(pMac, LOGE,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003548 FL("session does not exist for given bssId"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003549 goto limAssocStaEnd;
3550 }
3551
3552 if (psessionEntry->limSystemRole != eLIM_AP_ROLE)
3553 {
3554 limLog(pMac, LOGE,
Sushant Kaushik1b645382014-10-13 16:39:36 +05303555 FL("Received unexpected message in state %d, in role %d"),
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303556 psessionEntry->limSmeState, psessionEntry->limSystemRole);
Jeff Johnson295189b2012-06-20 16:38:30 -07003557 goto limAssocStaEnd;
3558 }
3559
3560 // Retrieve values obtained in the request message
3561 pSapEventCallback = (tpWLAN_SAPEventCB)getAssocSTAsReq.pSapEventCallback;
3562 pAssocStasTemp = (tpSap_AssocMacAddr)getAssocSTAsReq.pAssocStasArray;
3563
3564 for (assocId = 0; assocId < psessionEntry->dph.dphHashTable.size; assocId++)// Softap dphHashTable.size = 8
3565 {
3566 pStaDs = dphGetHashEntry(pMac, assocId, &psessionEntry->dph.dphHashTable);
3567
Abhishek Singh8a99b9f2015-03-31 14:18:26 +05303568 if ((NULL == pStaDs) || (NULL == pAssocStasTemp))
Jeff Johnson295189b2012-06-20 16:38:30 -07003569 continue;
3570
3571 if (pStaDs->valid)
3572 {
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303573 vos_mem_copy((tANI_U8 *)&pAssocStasTemp->staMac,
3574 (tANI_U8 *)&pStaDs->staAddr,
3575 sizeof(v_MACADDR_t)); // Mac address
Jeff Johnson295189b2012-06-20 16:38:30 -07003576 pAssocStasTemp->assocId = (v_U8_t)pStaDs->assocId; // Association Id
3577 pAssocStasTemp->staId = (v_U8_t)pStaDs->staIndex; // Station Id
3578
Kiet Lamb1233192013-11-28 13:38:20 +05303579 vos_mem_copy((tANI_U8 *)&pAssocStasTemp->supportedRates,
Leo Chang614d2072013-08-22 14:59:44 -07003580 (tANI_U8 *)&pStaDs->supportedRates,
3581 sizeof(tSirSupportedRates));
3582 pAssocStasTemp->ShortGI40Mhz = pStaDs->htShortGI40Mhz;
3583 pAssocStasTemp->ShortGI20Mhz = pStaDs->htShortGI20Mhz;
3584 pAssocStasTemp->Support40Mhz = pStaDs->htDsssCckRate40MHzSupport;
3585
Jeff Johnson295189b2012-06-20 16:38:30 -07003586 limLog(pMac, LOG1, FL("dph Station Number = %d"), staCount+1);
Arif Hussain24bafea2013-11-15 15:10:03 -08003587 limLog(pMac, LOG1, FL("MAC = " MAC_ADDRESS_STR),
3588 MAC_ADDR_ARRAY(pStaDs->staAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07003589 limLog(pMac, LOG1, FL("Association Id = %d"),pStaDs->assocId);
3590 limLog(pMac, LOG1, FL("Station Index = %d"),pStaDs->staIndex);
3591
3592 pAssocStasTemp++;
3593 staCount++;
3594 }
3595 }
3596
3597limAssocStaEnd:
3598 // Call hdd callback with sap event to send the list of associated stations from PE
3599 if (pSapEventCallback != NULL)
3600 {
3601 sapEvent.sapHddEventCode = eSAP_ASSOC_STA_CALLBACK_EVENT;
3602 sapEvent.sapevt.sapAssocStaListEvent.module = VOS_MODULE_ID_PE;
3603 sapEvent.sapevt.sapAssocStaListEvent.noOfAssocSta = staCount;
3604 sapEvent.sapevt.sapAssocStaListEvent.pAssocStas = (tpSap_AssocMacAddr)getAssocSTAsReq.pAssocStasArray;
3605 pSapEventCallback(&sapEvent, getAssocSTAsReq.pUsrContext);
3606 }
3607}
3608
3609
3610/**
3611 * limProcessSmeGetWPSPBCSessions
3612 *
3613 *FUNCTION:
3614 * This function is called when query the WPS PBC overlap message is received
3615 *
3616 *LOGIC:
3617 * This function parses get WPS PBC overlap information message and call callback to pass
3618 * WPS PBC overlap information back to hdd.
3619 *ASSUMPTIONS:
3620 *
3621 *
3622 *NOTE:
3623 *
3624 * @param pMac Pointer to Global MAC structure
3625 * @param pMsgBuf A pointer to WPS PBC overlap query message
3626*
3627 * @return None
3628 */
3629void limProcessSmeGetWPSPBCSessions(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
3630{
3631 tSirSmeGetWPSPBCSessionsReq GetWPSPBCSessionsReq;
3632 tpPESession psessionEntry = NULL;
3633 tSap_Event sapEvent;
3634 tpWLAN_SAPEventCB pSapEventCallback = NULL;
3635 tANI_U8 sessionId = CSR_SESSION_ID_INVALID;
3636 tSirMacAddr zeroMac = {0,0,0,0,0,0};
3637
3638 sapEvent.sapevt.sapGetWPSPBCSessionEvent.status = VOS_STATUS_E_FAULT;
3639
3640 if (limIsSmeGetWPSPBCSessionsReqValid(pMac, &GetWPSPBCSessionsReq, (tANI_U8 *) pMsgBuf) != eSIR_SUCCESS)
3641 {
3642 limLog(pMac, LOGE,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003643 FL("received invalid eWNI_SME_GET_ASSOC_STAS_REQ message"));
Girish Gowliafd42312014-07-24 13:13:59 +05303644 return;
Jeff Johnson295189b2012-06-20 16:38:30 -07003645 }
3646
Jeff Johnson1250df42012-12-10 14:31:52 -08003647 // Get Associated stations from PE
Jeff Johnson295189b2012-06-20 16:38:30 -07003648 // Find PE session Entry
3649 if ((psessionEntry = peFindSessionByBssid(pMac, GetWPSPBCSessionsReq.bssId, &sessionId)) == NULL)
3650 {
3651 limLog(pMac, LOGE,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003652 FL("session does not exist for given bssId"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003653 goto limGetWPSPBCSessionsEnd;
3654 }
3655
3656 if (psessionEntry->limSystemRole != eLIM_AP_ROLE)
3657 {
3658 limLog(pMac, LOGE,
Sushant Kaushik1b645382014-10-13 16:39:36 +05303659 FL("Received unexpected message in role %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07003660 psessionEntry->limSystemRole);
3661 goto limGetWPSPBCSessionsEnd;
3662 }
3663
Jeff Johnson1250df42012-12-10 14:31:52 -08003664 // Call hdd callback with sap event to send the WPS PBC overlap information
Jeff Johnson295189b2012-06-20 16:38:30 -07003665 sapEvent.sapHddEventCode = eSAP_GET_WPSPBC_SESSION_EVENT;
3666 sapEvent.sapevt.sapGetWPSPBCSessionEvent.module = VOS_MODULE_ID_PE;
3667
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303668 if (vos_mem_compare( zeroMac, GetWPSPBCSessionsReq.pRemoveMac, sizeof(tSirMacAddr)))
Jeff Johnson295189b2012-06-20 16:38:30 -07003669 { //This is GetWpsSession call
3670
3671 limGetWPSPBCSessions(pMac,
3672 sapEvent.sapevt.sapGetWPSPBCSessionEvent.addr.bytes, sapEvent.sapevt.sapGetWPSPBCSessionEvent.UUID_E,
3673 &sapEvent.sapevt.sapGetWPSPBCSessionEvent.wpsPBCOverlap, psessionEntry);
3674 }
3675 else
3676 {
3677 limRemovePBCSessions(pMac, GetWPSPBCSessionsReq.pRemoveMac,psessionEntry);
3678 /* don't have to inform the HDD/Host */
3679 return;
3680 }
3681
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003682 PELOG4(limLog(pMac, LOGE, FL("wpsPBCOverlap %d"), sapEvent.sapevt.sapGetWPSPBCSessionEvent.wpsPBCOverlap);)
Jeff Johnson295189b2012-06-20 16:38:30 -07003683 PELOG4(limPrintMacAddr(pMac, sapEvent.sapevt.sapGetWPSPBCSessionEvent.addr.bytes, LOG4);)
3684
3685 sapEvent.sapevt.sapGetWPSPBCSessionEvent.status = VOS_STATUS_SUCCESS;
3686
3687limGetWPSPBCSessionsEnd:
3688 pSapEventCallback = (tpWLAN_SAPEventCB)GetWPSPBCSessionsReq.pSapEventCallback;
Abhishek Singh8a99b9f2015-03-31 14:18:26 +05303689
3690 if (NULL != pSapEventCallback)
3691 pSapEventCallback(&sapEvent, GetWPSPBCSessionsReq.pUsrContext);
Jeff Johnson295189b2012-06-20 16:38:30 -07003692}
3693
Jeff Johnson295189b2012-06-20 16:38:30 -07003694
3695
3696/**
3697 * __limCounterMeasures()
3698 *
3699 * FUNCTION:
3700 * This function is called to "implement" MIC counter measure
3701 * and is *temporary* only
3702 *
3703 * LOGIC: on AP, disassoc all STA associated thru TKIP,
3704 * we don't do the proper STA disassoc sequence since the
3705 * BSS will be stoped anyway
3706 *
3707 *ASSUMPTIONS:
3708 *
3709 *NOTE:
3710 *
3711 * @param pMac Pointer to Global MAC structure
3712 * @return None
3713 */
3714
3715static void
3716__limCounterMeasures(tpAniSirGlobal pMac, tpPESession psessionEntry)
3717{
3718 tSirMacAddr mac = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
Abhishek Singh8944b222014-09-17 16:13:17 +05303719 /* If PMF is enabled then don't send broadcast disassociation */
3720 if ( ( (psessionEntry->limSystemRole == eLIM_AP_ROLE) ||
3721 (psessionEntry->limSystemRole == eLIM_BT_AMP_AP_ROLE) ||
3722 (psessionEntry->limSystemRole == eLIM_BT_AMP_STA_ROLE))
3723#ifdef WLAN_FEATURE_11W
3724 && !psessionEntry->limRmfEnabled
3725#endif
3726 )
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003727 limSendDisassocMgmtFrame(pMac, eSIR_MAC_MIC_FAILURE_REASON, mac, psessionEntry, FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003728
Jeff Johnson295189b2012-06-20 16:38:30 -07003729};
3730
3731
Jeff Johnson295189b2012-06-20 16:38:30 -07003732void
3733limProcessTkipCounterMeasures(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
3734{
3735 tSirSmeTkipCntrMeasReq tkipCntrMeasReq;
3736 tpPESession psessionEntry;
3737 tANI_U8 sessionId; //PE sessionId
3738
3739 if ( limTkipCntrMeasReqSerDes( pMac, &tkipCntrMeasReq, (tANI_U8 *) pMsgBuf ) != eSIR_SUCCESS )
3740 {
3741 limLog(pMac, LOGE,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003742 FL("received invalid eWNI_SME_TKIP_CNTR_MEAS_REQ message"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003743 return;
3744 }
3745
3746 if ( NULL == (psessionEntry = peFindSessionByBssid( pMac, tkipCntrMeasReq.bssId, &sessionId )) )
3747 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003748 limLog(pMac, LOGE, FL("session does not exist for given BSSID "));
Jeff Johnson295189b2012-06-20 16:38:30 -07003749 return;
3750 }
3751
3752 if ( tkipCntrMeasReq.bEnable )
3753 {
3754 __limCounterMeasures( pMac, psessionEntry );
3755 }
3756
3757 psessionEntry->bTkipCntrMeasActive = tkipCntrMeasReq.bEnable;
3758}
Jeff Johnson295189b2012-06-20 16:38:30 -07003759
3760
3761static void
3762__limHandleSmeStopBssRequest(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
3763{
3764 tSirSmeStopBssReq stopBssReq;
3765 tSirRetStatus status;
3766 tLimSmeStates prevState;
3767 tANI_U8 sessionId; //PE sessionId
3768 tpPESession psessionEntry;
3769 tANI_U8 smesessionId;
3770 tANI_U16 smetransactionId;
Sachin Ahuja51c08e62014-03-26 19:21:29 +05303771 tANI_U8 i = 0;
3772 tpDphHashNode pStaDs = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07003773
3774 limGetSessionInfo(pMac,(tANI_U8 *)pMsgBuf,&smesessionId,&smetransactionId);
3775
3776
3777
3778 if ((limStopBssReqSerDes(pMac, &stopBssReq, (tANI_U8 *) pMsgBuf) != eSIR_SUCCESS) ||
3779 !limIsSmeStopBssReqValid(pMsgBuf))
3780 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003781 PELOGW(limLog(pMac, LOGW, FL("received invalid SME_STOP_BSS_REQ message"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07003782 /// Send Stop BSS response to host
3783 limSendSmeRsp(pMac, eWNI_SME_STOP_BSS_RSP, eSIR_SME_INVALID_PARAMETERS,smesessionId,smetransactionId);
3784 return;
3785 }
3786
3787
3788 if((psessionEntry = peFindSessionByBssid(pMac,stopBssReq.bssId,&sessionId)) == NULL)
3789 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003790 limLog(pMac, LOGW, FL("session does not exist for given BSSID "));
Jeff Johnson295189b2012-06-20 16:38:30 -07003791 limSendSmeRsp(pMac, eWNI_SME_STOP_BSS_RSP, eSIR_SME_INVALID_PARAMETERS,smesessionId,smetransactionId);
3792 return;
3793 }
3794
3795#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM //FEATURE_WLAN_DIAG_SUPPORT
3796 limDiagEventReport(pMac, WLAN_PE_DIAG_STOP_BSS_REQ_EVENT, psessionEntry, 0, 0);
3797#endif //FEATURE_WLAN_DIAG_SUPPORT
3798
3799
3800 if ((psessionEntry->limSmeState != eLIM_SME_NORMAL_STATE) || /* Added For BT -AMP Support */
3801 (psessionEntry->limSystemRole == eLIM_STA_ROLE ))
3802 {
3803 /**
3804 * Should not have received STOP_BSS_REQ in states
3805 * other than 'normal' state or on STA in Infrastructure
3806 * mode. Log error and return response to host.
3807 */
3808 limLog(pMac, LOGE,
Sushant Kaushik1b645382014-10-13 16:39:36 +05303809 FL("received unexpected SME_STOP_BSS_REQ in state %d, for role %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07003810 psessionEntry->limSmeState, psessionEntry->limSystemRole);
3811 limPrintSmeState(pMac, LOGE, psessionEntry->limSmeState);
3812 /// Send Stop BSS response to host
3813 limSendSmeRsp(pMac, eWNI_SME_STOP_BSS_RSP, eSIR_SME_UNEXPECTED_REQ_RESULT_CODE,smesessionId,smetransactionId);
3814 return;
3815 }
3816
Jeff Johnson295189b2012-06-20 16:38:30 -07003817 if (psessionEntry->limSystemRole == eLIM_AP_ROLE )
3818 {
3819 limWPSPBCClose(pMac, psessionEntry);
3820 }
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003821 PELOGW(limLog(pMac, LOGW, FL("RECEIVED STOP_BSS_REQ with reason code=%d"), stopBssReq.reasonCode);)
Jeff Johnson295189b2012-06-20 16:38:30 -07003822
3823 prevState = psessionEntry->limSmeState;
3824
3825 psessionEntry->limSmeState = eLIM_SME_IDLE_STATE;
Jeff Johnsone7245742012-09-05 17:12:55 -07003826 MTRACE(macTrace(pMac, TRACE_CODE_SME_STATE, psessionEntry->peSessionId, psessionEntry->limSmeState));
Jeff Johnson295189b2012-06-20 16:38:30 -07003827
3828 /* Update SME session Id and Transaction Id */
3829 psessionEntry->smeSessionId = smesessionId;
3830 psessionEntry->transactionId = smetransactionId;
3831
Abhishek Singh8944b222014-09-17 16:13:17 +05303832 /* BTAMP_STA and STA_IN_IBSS should NOT send Disassoc frame.
3833 * If PMF is enabled then don't send broadcast disassociation */
3834 if ( ( (eLIM_STA_IN_IBSS_ROLE != psessionEntry->limSystemRole) &&
3835 (eLIM_BT_AMP_STA_ROLE != psessionEntry->limSystemRole) )
3836#ifdef WLAN_FEATURE_11W
3837 && !psessionEntry->limRmfEnabled
3838#endif
3839 )
Jeff Johnson295189b2012-06-20 16:38:30 -07003840 {
3841 tSirMacAddr bcAddr = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
3842 if ((stopBssReq.reasonCode == eSIR_SME_MIC_COUNTER_MEASURES))
3843 // Send disassoc all stations associated thru TKIP
3844 __limCounterMeasures(pMac,psessionEntry);
3845 else
Madan Mohan Koyyalamudi299b4862013-01-30 19:59:23 +05303846 limSendDisassocMgmtFrame(pMac, eSIR_MAC_DEAUTH_LEAVING_BSS_REASON, bcAddr, psessionEntry, FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003847 }
3848
3849 //limDelBss is also called as part of coalescing, when we send DEL BSS followed by Add Bss msg.
3850 pMac->lim.gLimIbssCoalescingHappened = false;
3851
Sachin Ahuja51c08e62014-03-26 19:21:29 +05303852 for(i = 1 ; i < pMac->lim.gLimAssocStaLimit ; i++)
3853 {
3854 pStaDs = dphGetHashEntry(pMac, i, &psessionEntry->dph.dphHashTable);
3855 if (NULL == pStaDs)
3856 continue;
3857 status = limDelSta(pMac, pStaDs, false, psessionEntry) ;
3858 if(eSIR_SUCCESS == status)
3859 {
3860 limDeleteDphHashEntry(pMac, pStaDs->staAddr, pStaDs->assocId, psessionEntry) ;
3861 limReleasePeerIdx(pMac, pStaDs->assocId, psessionEntry) ;
3862 }
3863 else
3864 {
3865 limLog(pMac, LOGE, FL("limDelSta failed with Status : %d"), status);
3866 VOS_ASSERT(0) ;
3867 }
3868 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003869 /* send a delBss to HAL and wait for a response */
3870 status = limDelBss(pMac, NULL,psessionEntry->bssIdx,psessionEntry);
3871
3872 if (status != eSIR_SUCCESS)
3873 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003874 PELOGE(limLog(pMac, LOGE, FL("delBss failed for bss %d"), psessionEntry->bssIdx);)
Jeff Johnson295189b2012-06-20 16:38:30 -07003875 psessionEntry->limSmeState= prevState;
3876
Jeff Johnsone7245742012-09-05 17:12:55 -07003877 MTRACE(macTrace(pMac, TRACE_CODE_SME_STATE, psessionEntry->peSessionId, psessionEntry->limSmeState));
Jeff Johnson295189b2012-06-20 16:38:30 -07003878
3879 limSendSmeRsp(pMac, eWNI_SME_STOP_BSS_RSP, eSIR_SME_STOP_BSS_FAILURE,smesessionId,smetransactionId);
3880 }
3881}
3882
3883
3884/**--------------------------------------------------------------
3885\fn __limProcessSmeStopBssReq
3886
3887\brief Wrapper for the function __limHandleSmeStopBssRequest
3888 This message will be defered until softmac come out of
3889 scan mode. Message should be handled even if we have
3890 detected radar in the current operating channel.
3891\param pMac
3892\param pMsg
3893
3894\return TRUE - If we consumed the buffer
3895 FALSE - If have defered the message.
3896 ---------------------------------------------------------------*/
3897static tANI_BOOLEAN
3898__limProcessSmeStopBssReq(tpAniSirGlobal pMac, tpSirMsgQ pMsg)
3899{
3900 if (__limIsDeferedMsgForLearn(pMac, pMsg))
3901 {
3902 /**
3903 * If message defered, buffer is not consumed yet.
3904 * So return false
3905 */
3906 return eANI_BOOLEAN_FALSE;
3907 }
3908 __limHandleSmeStopBssRequest(pMac, (tANI_U32 *) pMsg->bodyptr);
3909 return eANI_BOOLEAN_TRUE;
3910} /*** end __limProcessSmeStopBssReq() ***/
3911
3912
3913void limProcessSmeDelBssRsp(
3914 tpAniSirGlobal pMac,
3915 tANI_U32 body,tpPESession psessionEntry)
3916{
3917
3918 (void) body;
3919 SET_LIM_PROCESS_DEFD_MESGS(pMac, true);
3920 //TBD: get the sessionEntry
Ravi Joshib58ca0d2013-10-29 09:50:23 -07003921 limIbssDelete(pMac,psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07003922 dphHashTableClassInit(pMac, &psessionEntry->dph.dphHashTable);
3923 limDeletePreAuthList(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -07003924 limSendSmeRsp(pMac, eWNI_SME_STOP_BSS_RSP, eSIR_SME_SUCCESS,psessionEntry->smeSessionId,psessionEntry->transactionId);
3925 return;
3926}
3927
3928
Jeff Johnson295189b2012-06-20 16:38:30 -07003929/**---------------------------------------------------------------
3930\fn __limProcessSmeAssocCnfNew
3931\brief This function handles SME_ASSOC_CNF/SME_REASSOC_CNF
3932\ in BTAMP AP.
3933\
3934\param pMac
3935\param msgType - message type
3936\param pMsgBuf - a pointer to the SME message buffer
3937\return None
3938------------------------------------------------------------------*/
3939
3940 void
3941__limProcessSmeAssocCnfNew(tpAniSirGlobal pMac, tANI_U32 msgType, tANI_U32 *pMsgBuf)
3942{
3943 tSirSmeAssocCnf assocCnf;
3944 tpDphHashNode pStaDs = NULL;
3945 tpPESession psessionEntry= NULL;
3946 tANI_U8 sessionId;
3947
3948
3949 if(pMsgBuf == NULL)
3950 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003951 limLog(pMac, LOGE, FL("pMsgBuf is NULL "));
Jeff Johnson295189b2012-06-20 16:38:30 -07003952 goto end;
3953 }
3954
3955 if ((limAssocCnfSerDes(pMac, &assocCnf, (tANI_U8 *) pMsgBuf) == eSIR_FAILURE) ||
3956 !__limIsSmeAssocCnfValid(&assocCnf))
3957 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003958 limLog(pMac, LOGE, FL("Received invalid SME_RE(ASSOC)_CNF message "));
Jeff Johnson295189b2012-06-20 16:38:30 -07003959 goto end;
3960 }
3961
3962 if((psessionEntry = peFindSessionByBssid(pMac, assocCnf.bssId, &sessionId))== NULL)
3963 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003964 limLog(pMac, LOGE, FL("session does not exist for given bssId"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003965 goto end;
3966 }
3967
3968 if ( ((psessionEntry->limSystemRole != eLIM_AP_ROLE) && (psessionEntry->limSystemRole != eLIM_BT_AMP_AP_ROLE)) ||
3969 ((psessionEntry->limSmeState != eLIM_SME_NORMAL_STATE) && (psessionEntry->limSmeState != eLIM_SME_NORMAL_CHANNEL_SCAN_STATE)))
3970 {
Sushant Kaushik1b645382014-10-13 16:39:36 +05303971 limLog(pMac, LOGE, FL("Received unexpected message %X in state %d, in role %d"),
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303972 msgType, psessionEntry->limSmeState, psessionEntry->limSystemRole);
Jeff Johnson295189b2012-06-20 16:38:30 -07003973 goto end;
3974 }
3975
3976 pStaDs = dphGetHashEntry(pMac, assocCnf.aid, &psessionEntry->dph.dphHashTable);
3977
3978 if (pStaDs == NULL)
3979 {
Sachin Ahuja2fea3d12014-12-18 17:31:31 +05303980 limLog(pMac, LOGE,
3981 FL("Received invalid message %X due to no STA context, "
3982 "for aid %d, peer "),
3983 msgType, assocCnf.aid);
Jeff Johnson295189b2012-06-20 16:38:30 -07003984 limPrintMacAddr(pMac, assocCnf.peerMacAddr, LOG1);
3985
3986 /*
3987 ** send a DISASSOC_IND message to WSM to make sure
3988 ** the state in WSM and LIM is the same
3989 **/
3990 limSendSmeDisassocNtf( pMac, assocCnf.peerMacAddr, eSIR_SME_STA_NOT_ASSOCIATED,
3991 eLIM_PEER_ENTITY_DISASSOC, assocCnf.aid,psessionEntry->smeSessionId,psessionEntry->transactionId,psessionEntry);
3992 goto end;
3993 }
3994 if ((pStaDs &&
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303995 (( !vos_mem_compare( (tANI_U8 *) pStaDs->staAddr,
Jeff Johnson295189b2012-06-20 16:38:30 -07003996 (tANI_U8 *) assocCnf.peerMacAddr,
3997 sizeof(tSirMacAddr)) ) ||
3998 (pStaDs->mlmStaContext.mlmState != eLIM_MLM_WT_ASSOC_CNF_STATE) ||
3999 ((pStaDs->mlmStaContext.subType == LIM_ASSOC) &&
4000 (msgType != eWNI_SME_ASSOC_CNF)) ||
4001 ((pStaDs->mlmStaContext.subType == LIM_REASSOC) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07004002 (msgType != eWNI_SME_ASSOC_CNF))))) // since softap is passing this as ASSOC_CNF and subtype differs
Jeff Johnson295189b2012-06-20 16:38:30 -07004003 {
Sachin Ahuja2fea3d12014-12-18 17:31:31 +05304004 limLog(pMac, LOGE,
4005 FL("Received invalid message %X due to peerMacAddr mismatched "
4006 "or not in eLIM_MLM_WT_ASSOC_CNF_STATE state, for aid %d, peer "
4007 "StaD mlmState : %d"),
4008 msgType, assocCnf.aid, pStaDs->mlmStaContext.mlmState);
Jeff Johnson295189b2012-06-20 16:38:30 -07004009 limPrintMacAddr(pMac, assocCnf.peerMacAddr, LOG1);
4010 goto end;
4011 }
4012
4013 /*
4014 ** Deactivate/delet CNF_WAIT timer since ASSOC_CNF
4015 ** has been received
4016 **/
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004017 limLog(pMac, LOG1, FL("Received SME_ASSOC_CNF. Delete Timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004018 limDeactivateAndChangePerStaIdTimer(pMac, eLIM_CNF_WAIT_TIMER, pStaDs->assocId);
4019
4020 if (assocCnf.statusCode == eSIR_SME_SUCCESS)
4021 {
4022 /* In BTAMP-AP, PE already finished the WDA_ADD_STA sequence
4023 * when it had received Assoc Request frame. Now, PE just needs to send
4024 * Association Response frame to the requesting BTAMP-STA.
4025 */
4026 pStaDs->mlmStaContext.mlmState = eLIM_MLM_LINK_ESTABLISHED_STATE;
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004027 limLog(pMac, LOG1, FL("sending Assoc Rsp frame to STA (assoc id=%d) "), pStaDs->assocId);
Jeff Johnson295189b2012-06-20 16:38:30 -07004028 limSendAssocRspMgmtFrame( pMac, eSIR_SUCCESS, pStaDs->assocId, pStaDs->staAddr,
4029 pStaDs->mlmStaContext.subType, pStaDs, psessionEntry);
4030 goto end;
4031 } // (assocCnf.statusCode == eSIR_SME_SUCCESS)
4032 else
4033 {
4034 // SME_ASSOC_CNF status is non-success, so STA is not allowed to be associated
4035 /*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*/
4036 if(!pStaDs->mlmStaContext.updateContext)
4037 pStaDs->mlmStaContext.updateContext = 1;
Sachin Ahuja2fea3d12014-12-18 17:31:31 +05304038 limLog(pMac, LOG1, FL("Receive Assoc Cnf with status Code : %d(assoc id=%d) "),
4039 assocCnf.statusCode, pStaDs->assocId);
Jeff Johnson295189b2012-06-20 16:38:30 -07004040 limRejectAssociation(pMac, pStaDs->staAddr,
4041 pStaDs->mlmStaContext.subType,
4042 true, pStaDs->mlmStaContext.authType,
4043 pStaDs->assocId, true,
4044 eSIR_MAC_UNSPEC_FAILURE_STATUS, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07004045 }
4046
4047end:
4048 if((psessionEntry != NULL) && (pStaDs != NULL))
4049 {
4050 if ( psessionEntry->parsedAssocReq[pStaDs->assocId] != NULL )
4051 {
4052 if ( ((tpSirAssocReq)(psessionEntry->parsedAssocReq[pStaDs->assocId]))->assocReqFrame)
4053 {
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304054 vos_mem_free(((tpSirAssocReq)
4055 (psessionEntry->parsedAssocReq[pStaDs->assocId]))->assocReqFrame);
Jeff Johnson295189b2012-06-20 16:38:30 -07004056 ((tpSirAssocReq)(psessionEntry->parsedAssocReq[pStaDs->assocId]))->assocReqFrame = NULL;
4057 }
4058
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304059 vos_mem_free(psessionEntry->parsedAssocReq[pStaDs->assocId]);
Jeff Johnson295189b2012-06-20 16:38:30 -07004060 psessionEntry->parsedAssocReq[pStaDs->assocId] = NULL;
4061 }
4062 }
4063
4064} /*** end __limProcessSmeAssocCnfNew() ***/
4065
4066
Jeff Johnson295189b2012-06-20 16:38:30 -07004067
4068
4069static void
4070__limProcessSmeAddtsReq(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
4071{
4072 tpDphHashNode pStaDs;
4073 tSirMacAddr peerMac;
4074 tpSirAddtsReq pSirAddts;
4075 tANI_U32 timeout;
4076 tpPESession psessionEntry;
4077 tANI_U8 sessionId; //PE sessionId
4078 tANI_U8 smesessionId;
4079 tANI_U16 smetransactionId;
4080
4081
4082 if(pMsgBuf == NULL)
4083 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004084 limLog(pMac, LOGE,FL("Buffer is Pointing to NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004085 return;
4086 }
4087
4088 limGetSessionInfo(pMac,(tANI_U8 *)pMsgBuf,&smesessionId,&smetransactionId);
4089
4090 pSirAddts = (tpSirAddtsReq) pMsgBuf;
4091
4092 if((psessionEntry = peFindSessionByBssid(pMac, pSirAddts->bssId,&sessionId))== NULL)
4093 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004094 limLog(pMac, LOGE, "Session Does not exist for given bssId");
Jeff Johnson295189b2012-06-20 16:38:30 -07004095 return;
4096 }
4097#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM //FEATURE_WLAN_DIAG_SUPPORT
4098 limDiagEventReport(pMac, WLAN_PE_DIAG_ADDTS_REQ_EVENT, psessionEntry, 0, 0);
4099#endif //FEATURE_WLAN_DIAG_SUPPORT
4100
4101
4102
4103 /* if sta
4104 * - verify assoc state
4105 * - send addts request to ap
4106 * - wait for addts response from ap
4107 * if ap, just ignore with error log
4108 */
Abhishek Singh3cbf6052014-12-15 16:46:42 +05304109 limLog(pMac, LOG1,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004110 FL("Received SME_ADDTS_REQ (TSid %d, UP %d)"),
Jeff Johnson295189b2012-06-20 16:38:30 -07004111 pSirAddts->req.tspec.tsinfo.traffic.tsid,
Abhishek Singh3cbf6052014-12-15 16:46:42 +05304112 pSirAddts->req.tspec.tsinfo.traffic.userPrio);
Jeff Johnson295189b2012-06-20 16:38:30 -07004113
4114 if ((psessionEntry->limSystemRole != eLIM_STA_ROLE)&&(psessionEntry->limSystemRole != eLIM_BT_AMP_STA_ROLE))
4115 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004116 PELOGE(limLog(pMac, LOGE, "AddTs received on AP - ignoring");)
Jeff Johnson295189b2012-06-20 16:38:30 -07004117 limSendSmeAddtsRsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE, psessionEntry, pSirAddts->req.tspec,
4118 smesessionId,smetransactionId);
4119 return;
4120 }
4121
Jeff Johnson295189b2012-06-20 16:38:30 -07004122 pStaDs = dphGetHashEntry(pMac, DPH_STA_HASH_INDEX_PEER, &psessionEntry->dph.dphHashTable);
4123
4124 if(pStaDs == NULL)
4125 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004126 PELOGE(limLog(pMac, LOGE, "Cannot find AP context for addts req");)
Jeff Johnson295189b2012-06-20 16:38:30 -07004127 limSendSmeAddtsRsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE, psessionEntry, pSirAddts->req.tspec,
4128 smesessionId,smetransactionId);
4129 return;
4130 }
4131
4132 if ((! pStaDs->valid) ||
4133 (pStaDs->mlmStaContext.mlmState != eLIM_MLM_LINK_ESTABLISHED_STATE))
4134 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004135 PELOGE(limLog(pMac, LOGE, "AddTs received in invalid MLM state");)
Jeff Johnson295189b2012-06-20 16:38:30 -07004136 limSendSmeAddtsRsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE, psessionEntry, pSirAddts->req.tspec,
4137 smesessionId,smetransactionId);
4138 return;
4139 }
4140
4141 pSirAddts->req.wsmTspecPresent = 0;
4142 pSirAddts->req.wmeTspecPresent = 0;
4143 pSirAddts->req.lleTspecPresent = 0;
4144
4145 if ((pStaDs->wsmEnabled) &&
4146 (pSirAddts->req.tspec.tsinfo.traffic.accessPolicy != SIR_MAC_ACCESSPOLICY_EDCA))
4147 pSirAddts->req.wsmTspecPresent = 1;
4148 else if (pStaDs->wmeEnabled)
4149 pSirAddts->req.wmeTspecPresent = 1;
4150 else if (pStaDs->lleEnabled)
4151 pSirAddts->req.lleTspecPresent = 1;
4152 else
4153 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004154 PELOGW(limLog(pMac, LOGW, FL("ADDTS_REQ ignore - qos is disabled"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07004155 limSendSmeAddtsRsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE, psessionEntry, pSirAddts->req.tspec,
4156 smesessionId,smetransactionId);
4157 return;
4158 }
4159
4160 if ((psessionEntry->limSmeState != eLIM_SME_ASSOCIATED_STATE) &&
4161 (psessionEntry->limSmeState != eLIM_SME_LINK_EST_STATE))
4162 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004163 limLog(pMac, LOGE, "AddTs received in invalid LIMsme state (%d)",
Jeff Johnson295189b2012-06-20 16:38:30 -07004164 psessionEntry->limSmeState);
4165 limSendSmeAddtsRsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE, psessionEntry, pSirAddts->req.tspec,
4166 smesessionId,smetransactionId);
4167 return;
4168 }
4169
4170 if (pMac->lim.gLimAddtsSent)
4171 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004172 limLog(pMac, LOGE, "Addts (token %d, tsid %d, up %d) is still pending",
Jeff Johnson295189b2012-06-20 16:38:30 -07004173 pMac->lim.gLimAddtsReq.req.dialogToken,
4174 pMac->lim.gLimAddtsReq.req.tspec.tsinfo.traffic.tsid,
4175 pMac->lim.gLimAddtsReq.req.tspec.tsinfo.traffic.userPrio);
4176 limSendSmeAddtsRsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE, psessionEntry, pSirAddts->req.tspec,
4177 smesessionId,smetransactionId);
4178 return;
4179 }
4180
4181 #if 0
4182 val = sizeof(tSirMacAddr);
4183 if (wlan_cfgGetStr(pMac, WNI_CFG_BSSID, peerMac, &val) != eSIR_SUCCESS)
4184 {
4185 /// Could not get BSSID from CFG. Log error.
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004186 limLog(pMac, LOGP, FL("could not retrieve BSSID"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004187 return;
4188 }
4189 #endif
4190 sirCopyMacAddr(peerMac,psessionEntry->bssId);
4191
4192 // save the addts request
4193 pMac->lim.gLimAddtsSent = true;
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304194 vos_mem_copy( (tANI_U8 *) &pMac->lim.gLimAddtsReq, (tANI_U8 *) pSirAddts, sizeof(tSirAddtsReq));
Jeff Johnson295189b2012-06-20 16:38:30 -07004195
4196 // ship out the message now
4197 limSendAddtsReqActionFrame(pMac, peerMac, &pSirAddts->req,
4198 psessionEntry);
Abhishek Singh3cbf6052014-12-15 16:46:42 +05304199 limLog(pMac, LOG1, FL("Sent ADDTS request"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004200
4201 // start a timer to wait for the response
4202 if (pSirAddts->timeout)
4203 timeout = pSirAddts->timeout;
4204 else if (wlan_cfgGetInt(pMac, WNI_CFG_ADDTS_RSP_TIMEOUT, &timeout) != eSIR_SUCCESS)
4205 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004206 limLog(pMac, LOGP, FL("Unable to get Cfg param %d (Addts Rsp Timeout)"),
Jeff Johnson295189b2012-06-20 16:38:30 -07004207 WNI_CFG_ADDTS_RSP_TIMEOUT);
4208 return;
4209 }
4210
4211 timeout = SYS_MS_TO_TICKS(timeout);
4212 if (tx_timer_change(&pMac->lim.limTimers.gLimAddtsRspTimer, timeout, 0) != TX_SUCCESS)
4213 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004214 limLog(pMac, LOGP, FL("AddtsRsp timer change failed!"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004215 return;
4216 }
4217 pMac->lim.gLimAddtsRspTimerCount++;
4218 if (tx_timer_change_context(&pMac->lim.limTimers.gLimAddtsRspTimer,
4219 pMac->lim.gLimAddtsRspTimerCount) != TX_SUCCESS)
4220 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004221 limLog(pMac, LOGP, FL("AddtsRsp timer change failed!"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004222 return;
4223 }
Jeff Johnsone7245742012-09-05 17:12:55 -07004224 MTRACE(macTrace(pMac, TRACE_CODE_TIMER_ACTIVATE, psessionEntry->peSessionId, eLIM_ADDTS_RSP_TIMER));
Jeff Johnson295189b2012-06-20 16:38:30 -07004225
4226 //add the sessionId to the timer object
4227 pMac->lim.limTimers.gLimAddtsRspTimer.sessionId = sessionId;
4228 if (tx_timer_activate(&pMac->lim.limTimers.gLimAddtsRspTimer) != TX_SUCCESS)
4229 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004230 limLog(pMac, LOGP, FL("AddtsRsp timer activation failed!"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004231 return;
4232 }
4233 return;
4234}
4235
4236
4237static void
4238__limProcessSmeDeltsReq(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
4239{
4240 tSirMacAddr peerMacAddr;
4241 tANI_U8 ac;
4242 tSirMacTSInfo *pTsinfo;
4243 tpSirDeltsReq pDeltsReq = (tpSirDeltsReq) pMsgBuf;
4244 tpDphHashNode pStaDs = NULL;
4245 tpPESession psessionEntry;
4246 tANI_U8 sessionId;
4247 tANI_U32 status = eSIR_SUCCESS;
4248 tANI_U8 smesessionId;
4249 tANI_U16 smetransactionId;
4250
4251 limGetSessionInfo(pMac,(tANI_U8 *)pMsgBuf,&smesessionId,&smetransactionId);
4252
4253 if((psessionEntry = peFindSessionByBssid(pMac, pDeltsReq->bssId, &sessionId))== NULL)
4254 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004255 limLog(pMac, LOGE, "Session Does not exist for given bssId");
Jeff Johnson295189b2012-06-20 16:38:30 -07004256 status = eSIR_FAILURE;
4257 goto end;
4258 }
4259#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM //FEATURE_WLAN_DIAG_SUPPORT
4260 limDiagEventReport(pMac, WLAN_PE_DIAG_DELTS_REQ_EVENT, psessionEntry, 0, 0);
4261#endif //FEATURE_WLAN_DIAG_SUPPORT
4262
4263
4264 if (eSIR_SUCCESS != limValidateDeltsReq(pMac, pDeltsReq, peerMacAddr,psessionEntry))
4265 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004266 PELOGE(limLog(pMac, LOGE, FL("limValidateDeltsReq failed"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07004267 status = eSIR_FAILURE;
4268 limSendSmeDeltsRsp(pMac, pDeltsReq, eSIR_FAILURE,psessionEntry,smesessionId,smetransactionId);
4269 return;
4270 }
4271
Abhishek Singh3cbf6052014-12-15 16:46:42 +05304272 limLog(pMac, LOG1, FL("Sent DELTS request to station with "
4273 "assocId = %d MacAddr = "MAC_ADDRESS_STR),
4274 pDeltsReq->aid, MAC_ADDR_ARRAY(peerMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07004275
4276 limSendDeltsReqActionFrame(pMac, peerMacAddr, pDeltsReq->req.wmeTspecPresent, &pDeltsReq->req.tsinfo, &pDeltsReq->req.tspec,
4277 psessionEntry);
4278
4279 pTsinfo = pDeltsReq->req.wmeTspecPresent ? &pDeltsReq->req.tspec.tsinfo : &pDeltsReq->req.tsinfo;
4280
4281 /* We've successfully send DELTS frame to AP. Update the
4282 * dynamic UAPSD mask. The AC for this TSPEC to be deleted
4283 * is no longer trigger enabled or delivery enabled
4284 */
4285 limSetTspecUapsdMask(pMac, pTsinfo, CLEAR_UAPSD_MASK);
4286
4287 /* We're deleting the TSPEC, so this particular AC is no longer
4288 * admitted. PE needs to downgrade the EDCA
4289 * parameters(for the AC for which TS is being deleted) to the
4290 * next best AC for which ACM is not enabled, and send the
4291 * updated values to HAL.
4292 */
4293 ac = upToAc(pTsinfo->traffic.userPrio);
4294
4295 if(pTsinfo->traffic.direction == SIR_MAC_DIRECTION_UPLINK)
4296 {
4297 pMac->lim.gAcAdmitMask[SIR_MAC_DIRECTION_UPLINK] &= ~(1 << ac);
4298 }
4299 else if(pTsinfo->traffic.direction == SIR_MAC_DIRECTION_DNLINK)
4300 {
4301 pMac->lim.gAcAdmitMask[SIR_MAC_DIRECTION_DNLINK] &= ~(1 << ac);
4302 }
4303 else if(pTsinfo->traffic.direction == SIR_MAC_DIRECTION_BIDIR)
4304 {
4305 pMac->lim.gAcAdmitMask[SIR_MAC_DIRECTION_UPLINK] &= ~(1 << ac);
4306 pMac->lim.gAcAdmitMask[SIR_MAC_DIRECTION_DNLINK] &= ~(1 << ac);
4307 }
4308
4309 limSetActiveEdcaParams(pMac, psessionEntry->gLimEdcaParams, psessionEntry);
4310
4311 pStaDs = dphGetHashEntry(pMac, DPH_STA_HASH_INDEX_PEER, &psessionEntry->dph.dphHashTable);
4312 if (pStaDs != NULL)
4313 {
4314 if (pStaDs->aniPeer == eANI_BOOLEAN_TRUE)
4315 limSendEdcaParams(pMac, psessionEntry->gLimEdcaParamsActive, pStaDs->bssId, eANI_BOOLEAN_TRUE);
4316 else
4317 limSendEdcaParams(pMac, psessionEntry->gLimEdcaParamsActive, pStaDs->bssId, eANI_BOOLEAN_FALSE);
4318 status = eSIR_SUCCESS;
4319 }
4320 else
4321 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004322 limLog(pMac, LOGE, FL("Self entry missing in Hash Table "));
Jeff Johnson295189b2012-06-20 16:38:30 -07004323 status = eSIR_FAILURE;
4324 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004325#ifdef FEATURE_WLAN_ESE
4326#ifdef FEATURE_WLAN_ESE_UPLOAD
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004327 limSendSmeTsmIEInd(pMac, psessionEntry, 0, 0, 0);
4328#else
Jeff Johnson295189b2012-06-20 16:38:30 -07004329 limDeactivateAndChangeTimer(pMac,eLIM_TSM_TIMER);
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004330#endif /* FEATURE_WLAN_ESE_UPLOAD */
Jeff Johnson295189b2012-06-20 16:38:30 -07004331#endif
4332
4333 // send an sme response back
4334 end:
4335 limSendSmeDeltsRsp(pMac, pDeltsReq, eSIR_SUCCESS,psessionEntry,smesessionId,smetransactionId);
4336}
4337
4338
4339void
4340limProcessSmeAddtsRspTimeout(tpAniSirGlobal pMac, tANI_U32 param)
4341{
4342 //fetch the sessionEntry based on the sessionId
4343 tpPESession psessionEntry;
4344 if((psessionEntry = peFindSessionBySessionId(pMac, pMac->lim.limTimers.gLimAddtsRspTimer.sessionId))== NULL)
4345 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004346 limLog(pMac, LOGP,FL("Session Does not exist for given sessionID"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004347 return;
4348 }
4349
4350 if ( (psessionEntry->limSystemRole != eLIM_STA_ROLE) && (psessionEntry->limSystemRole != eLIM_BT_AMP_STA_ROLE) )
4351 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004352 limLog(pMac, LOGW, "AddtsRspTimeout in non-Sta role (%d)", psessionEntry->limSystemRole);
Jeff Johnson295189b2012-06-20 16:38:30 -07004353 pMac->lim.gLimAddtsSent = false;
4354 return;
4355 }
4356
4357 if (! pMac->lim.gLimAddtsSent)
4358 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004359 PELOGW(limLog(pMac, LOGW, "AddtsRspTimeout but no AddtsSent");)
Jeff Johnson295189b2012-06-20 16:38:30 -07004360 return;
4361 }
4362
4363 if (param != pMac->lim.gLimAddtsRspTimerCount)
4364 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004365 limLog(pMac, LOGE, FL("Invalid AddtsRsp Timer count %d (exp %d)"),
Jeff Johnson295189b2012-06-20 16:38:30 -07004366 param, pMac->lim.gLimAddtsRspTimerCount);
4367 return;
4368 }
4369
4370 // this a real response timeout
4371 pMac->lim.gLimAddtsSent = false;
4372 pMac->lim.gLimAddtsRspTimerCount++;
4373
4374 limSendSmeAddtsRsp(pMac, true, eSIR_SME_ADDTS_RSP_TIMEOUT, psessionEntry, pMac->lim.gLimAddtsReq.req.tspec,
4375 psessionEntry->smeSessionId, psessionEntry->transactionId);
4376}
4377
4378
4379/**
4380 * __limProcessSmeStatsRequest()
4381 *
4382 *FUNCTION:
4383 *
4384 *
4385 *NOTE:
4386 *
4387 * @param pMac Pointer to Global MAC structure
4388 * @param *pMsgBuf A pointer to the SME message buffer
4389 * @return None
4390 */
4391static void
4392__limProcessSmeStatsRequest(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
4393{
4394 tpAniGetStatsReq pStatsReq;
4395 tSirMsgQ msgQ;
4396 tpPESession psessionEntry;
4397 tANI_U8 sessionId;
4398
4399
4400 if(pMsgBuf == NULL)
4401 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004402 limLog(pMac, LOGE,FL("Buffer is Pointing to NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004403 return;
4404 }
4405
4406 pStatsReq = (tpAniGetStatsReq) pMsgBuf;
4407
4408 if((psessionEntry = peFindSessionByBssid(pMac,pStatsReq->bssId,&sessionId))== NULL)
4409 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004410 limLog(pMac, LOGE, FL("session does not exist for given bssId"));
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304411 vos_mem_free( pMsgBuf );
Leela Venkata Kiran Kumar Reddy Chiralad6c0fe22013-12-11 19:10:50 -08004412 pMsgBuf = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004413 return;
4414 }
4415
4416
4417
4418 switch(pStatsReq->msgType)
4419 {
4420 //Add Lim stats here. and send reqsponse.
4421
4422 //HAL maintained Stats.
4423 case eWNI_SME_STA_STAT_REQ:
4424 msgQ.type = WDA_STA_STAT_REQ;
4425 break;
4426 case eWNI_SME_AGGR_STAT_REQ:
4427 msgQ.type = WDA_AGGR_STAT_REQ;
4428 break;
4429 case eWNI_SME_GLOBAL_STAT_REQ:
4430 msgQ.type = WDA_GLOBAL_STAT_REQ;
4431 break;
4432 case eWNI_SME_STAT_SUMM_REQ:
4433 msgQ.type = WDA_STAT_SUMM_REQ;
4434 break;
4435 default: //Unknown request.
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004436 PELOGE(limLog(pMac, LOGE, "Unknown Statistics request");)
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304437 vos_mem_free( pMsgBuf );
Leela Venkata Kiran Kumar Reddy Chiralad6c0fe22013-12-11 19:10:50 -08004438 pMsgBuf = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004439 return;
4440 }
4441
Jeff Johnson295189b2012-06-20 16:38:30 -07004442 msgQ.reserved = 0;
4443 msgQ.bodyptr = pMsgBuf;
4444 msgQ.bodyval = 0;
Leela Venkata Kiran Kumar Reddy Chirala68a6abe2013-02-28 07:43:16 -08004445 if(NULL == psessionEntry)
4446 {
4447 MTRACE(macTraceMsgTx(pMac, NO_SESSION, msgQ.type));
4448 }
4449 else
4450 {
4451 MTRACE(macTraceMsgTx(pMac, psessionEntry->peSessionId, msgQ.type));
4452 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004453 if( eSIR_SUCCESS != (wdaPostCtrlMsg( pMac, &msgQ ))){
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004454 limLog(pMac, LOGP, "Unable to forward request");
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304455 vos_mem_free( pMsgBuf );
Leela Venkata Kiran Kumar Reddy Chiralad6c0fe22013-12-11 19:10:50 -08004456 pMsgBuf = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004457 return;
4458 }
4459
4460 return;
4461}
4462
4463
4464/**
4465 * __limProcessSmeGetStatisticsRequest()
4466 *
4467 *FUNCTION:
4468 *
4469 *
4470 *NOTE:
4471 *
4472 * @param pMac Pointer to Global MAC structure
4473 * @param *pMsgBuf A pointer to the SME message buffer
4474 * @return None
4475 */
4476static void
4477__limProcessSmeGetStatisticsRequest(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
4478{
4479 tpAniGetPEStatsReq pPEStatsReq;
4480 tSirMsgQ msgQ;
4481
4482 pPEStatsReq = (tpAniGetPEStatsReq) pMsgBuf;
4483
4484 //pPEStatsReq->msgType should be eWNI_SME_GET_STATISTICS_REQ
4485
4486 msgQ.type = WDA_GET_STATISTICS_REQ;
4487
Jeff Johnson295189b2012-06-20 16:38:30 -07004488 msgQ.reserved = 0;
4489 msgQ.bodyptr = pMsgBuf;
4490 msgQ.bodyval = 0;
Jeff Johnsone7245742012-09-05 17:12:55 -07004491 MTRACE(macTraceMsgTx(pMac, NO_SESSION, msgQ.type));
Jeff Johnson295189b2012-06-20 16:38:30 -07004492
4493 if( eSIR_SUCCESS != (wdaPostCtrlMsg( pMac, &msgQ ))){
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304494 vos_mem_free( pMsgBuf );
Leela Venkata Kiran Kumar Reddy Chiralad6c0fe22013-12-11 19:10:50 -08004495 pMsgBuf = NULL;
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004496 limLog(pMac, LOGP, "Unable to forward request");
Jeff Johnson295189b2012-06-20 16:38:30 -07004497 return;
4498 }
4499
4500 return;
4501}
4502
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004503#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004504/**
4505 *FUNCTION: __limProcessSmeGetTsmStatsRequest()
4506 *
4507 *NOTE:
4508 *
4509 * @param pMac Pointer to Global MAC structure
4510 * @param *pMsgBuf A pointer to the SME message buffer
4511 * @return None
4512 */
4513static void
4514__limProcessSmeGetTsmStatsRequest(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
4515{
4516 tSirMsgQ msgQ;
4517
4518 msgQ.type = WDA_TSM_STATS_REQ;
4519 msgQ.reserved = 0;
4520 msgQ.bodyptr = pMsgBuf;
4521 msgQ.bodyval = 0;
4522 MTRACE(macTraceMsgTx(pMac, NO_SESSION, msgQ.type));
4523
4524 if( eSIR_SUCCESS != (wdaPostCtrlMsg( pMac, &msgQ ))){
4525 vos_mem_free( pMsgBuf );
Leela Venkata Kiran Kumar Reddy Chiralad6c0fe22013-12-11 19:10:50 -08004526 pMsgBuf = NULL;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004527 limLog(pMac, LOGP, "Unable to forward request");
4528 return;
4529 }
4530}
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004531#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004532
4533
Jeff Johnson295189b2012-06-20 16:38:30 -07004534
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004535#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08004536/**
4537 * __limProcessSmeGetRoamRssiRequest()
4538 *
4539 *FUNCTION:
4540 *
4541 *
4542 *NOTE:
4543 *
4544 * @param pMac Pointer to Global MAC structure
4545 * @param *pMsgBuf A pointer to the SME message buffer
4546 * @return None
4547 */
4548static void
4549__limProcessSmeGetRoamRssiRequest(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
4550{
4551 tpAniGetRssiReq pPEGetRoamRssiReq = NULL;
4552 tSirMsgQ msgQ;
4553
4554 pPEGetRoamRssiReq = (tpAniGetRssiReq) pMsgBuf;
4555 msgQ.type = WDA_GET_ROAM_RSSI_REQ;
4556
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08004557 msgQ.reserved = 0;
4558 msgQ.bodyptr = pMsgBuf;
4559 msgQ.bodyval = 0;
4560 MTRACE(macTraceMsgTx(pMac, NO_SESSION, msgQ.type));
4561
4562 if( eSIR_SUCCESS != (wdaPostCtrlMsg( pMac, &msgQ ))){
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304563 vos_mem_free( pMsgBuf );
Leela Venkata Kiran Kumar Reddy Chiralad6c0fe22013-12-11 19:10:50 -08004564 pMsgBuf = NULL;
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004565 limLog(pMac, LOGP, "Unable to forward request");
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08004566 return;
4567 }
4568
4569 return;
4570}
4571#endif
4572
4573
Jeff Johnson295189b2012-06-20 16:38:30 -07004574static void
4575__limProcessSmeUpdateAPWPSIEs(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
4576{
4577 tpSirUpdateAPWPSIEsReq pUpdateAPWPSIEsReq;
4578 tpPESession psessionEntry;
4579 tANI_U8 sessionId; //PE sessionID
4580
4581 PELOG1(limLog(pMac, LOG1,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004582 FL("received UPDATE_APWPSIEs_REQ message")););
Jeff Johnson295189b2012-06-20 16:38:30 -07004583
4584 if(pMsgBuf == NULL)
4585 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004586 limLog(pMac, LOGE,FL("Buffer is Pointing to NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004587 return;
4588 }
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08004589
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304590 pUpdateAPWPSIEsReq = vos_mem_malloc(sizeof(tSirUpdateAPWPSIEsReq));
4591 if ( NULL == pUpdateAPWPSIEsReq )
Jeff Johnson295189b2012-06-20 16:38:30 -07004592 {
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304593 limLog(pMac, LOGP, FL("call to AllocateMemory failed for pUpdateAPWPSIEsReq"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004594 return;
4595 }
4596
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08004597 if ((limUpdateAPWPSIEsReqSerDes(pMac, pUpdateAPWPSIEsReq, (tANI_U8 *) pMsgBuf) == eSIR_FAILURE))
Jeff Johnson295189b2012-06-20 16:38:30 -07004598 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004599 limLog(pMac, LOGW, FL("received invalid SME_SETCONTEXT_REQ message"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004600 goto end;
4601 }
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08004602
Jeff Johnson295189b2012-06-20 16:38:30 -07004603 if((psessionEntry = peFindSessionByBssid(pMac, pUpdateAPWPSIEsReq->bssId, &sessionId)) == NULL)
4604 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004605 limLog(pMac, LOGW, FL("Session does not exist for given BSSID"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004606 goto end;
4607 }
4608
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304609 vos_mem_copy( &psessionEntry->APWPSIEs, &pUpdateAPWPSIEsReq->APWPSIEs, sizeof(tSirAPWPSIEs));
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08004610
Jeff Johnson295189b2012-06-20 16:38:30 -07004611 schSetFixedBeaconFields(pMac, psessionEntry);
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08004612 limSendBeaconInd(pMac, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07004613
4614end:
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304615 vos_mem_free( pUpdateAPWPSIEsReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07004616 return;
4617} /*** end __limProcessSmeUpdateAPWPSIEs(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf) ***/
4618
4619static void
4620__limProcessSmeHideSSID(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
4621{
4622 tpSirUpdateParams pUpdateParams;
4623 tpPESession psessionEntry;
4624
Abhishek Singh3cbf6052014-12-15 16:46:42 +05304625 limLog(pMac, LOG1,
4626 FL("received SME_HIDE_SSID message"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004627
4628 if(pMsgBuf == NULL)
4629 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004630 limLog(pMac, LOGE,FL("Buffer is Pointing to NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004631 return;
4632 }
4633
4634 pUpdateParams = (tpSirUpdateParams)pMsgBuf;
4635
4636 if((psessionEntry = peFindSessionBySessionId(pMac, pUpdateParams->sessionId)) == NULL)
4637 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004638 limLog(pMac, LOGW, "Session does not exist for given sessionId %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07004639 pUpdateParams->sessionId);
4640 return;
4641 }
4642
4643 /* Update the session entry */
4644 psessionEntry->ssidHidden = pUpdateParams->ssidHidden;
4645
4646 /* Update beacon */
4647 schSetFixedBeaconFields(pMac, psessionEntry);
4648 limSendBeaconInd(pMac, psessionEntry);
4649
4650 return;
4651} /*** end __limProcessSmeHideSSID(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf) ***/
4652
4653static void
4654__limProcessSmeSetWPARSNIEs(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
4655{
4656 tpSirUpdateAPWPARSNIEsReq pUpdateAPWPARSNIEsReq;
4657 tpPESession psessionEntry;
4658 tANI_U8 sessionId; //PE sessionID
4659
4660 if(pMsgBuf == NULL)
4661 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004662 limLog(pMac, LOGE,FL("Buffer is Pointing to NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004663 return;
4664 }
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304665
4666 pUpdateAPWPARSNIEsReq = vos_mem_malloc(sizeof(tSirUpdateAPWPSIEsReq));
4667 if ( NULL == pUpdateAPWPARSNIEsReq )
Jeff Johnson295189b2012-06-20 16:38:30 -07004668 {
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304669 limLog(pMac, LOGP, FL("call to AllocateMemory failed for pUpdateAPWPARSNIEsReq"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004670 return;
4671 }
4672
4673 if ((limUpdateAPWPARSNIEsReqSerDes(pMac, pUpdateAPWPARSNIEsReq, (tANI_U8 *) pMsgBuf) == eSIR_FAILURE))
4674 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004675 limLog(pMac, LOGW, FL("received invalid SME_SETCONTEXT_REQ message"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004676 goto end;
4677 }
4678
4679 if((psessionEntry = peFindSessionByBssid(pMac, pUpdateAPWPARSNIEsReq->bssId, &sessionId)) == NULL)
4680 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004681 limLog(pMac, LOGW, FL("Session does not exist for given BSSID"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004682 goto end;
4683 }
4684
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304685 vos_mem_copy(&psessionEntry->pLimStartBssReq->rsnIE,
4686 &pUpdateAPWPARSNIEsReq->APWPARSNIEs, sizeof(tSirRSNie));
Jeff Johnson295189b2012-06-20 16:38:30 -07004687
4688 limSetRSNieWPAiefromSmeStartBSSReqMessage(pMac, &psessionEntry->pLimStartBssReq->rsnIE, psessionEntry);
4689
4690 psessionEntry->pLimStartBssReq->privacy = 1;
4691 psessionEntry->privacy = 1;
4692
4693 schSetFixedBeaconFields(pMac, psessionEntry);
4694 limSendBeaconInd(pMac, psessionEntry);
4695
4696end:
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304697 vos_mem_free(pUpdateAPWPARSNIEsReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07004698 return;
4699} /*** end __limProcessSmeSetWPARSNIEs(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf) ***/
4700
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08004701/*
4702Update the beacon Interval dynamically if beaconInterval is different in MCC
4703*/
4704static void
4705__limProcessSmeChangeBI(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
4706{
4707 tpSirChangeBIParams pChangeBIParams;
4708 tpPESession psessionEntry;
4709 tANI_U8 sessionId = 0;
4710 tUpdateBeaconParams beaconParams;
4711
4712 PELOG1(limLog(pMac, LOG1,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004713 FL("received Update Beacon Interval message")););
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08004714
4715 if(pMsgBuf == NULL)
4716 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004717 limLog(pMac, LOGE,FL("Buffer is Pointing to NULL"));
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08004718 return;
4719 }
4720
Kaushik, Sushantfb156732014-01-07 15:36:03 +05304721 vos_mem_zero(&beaconParams, sizeof(tUpdateBeaconParams));
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08004722 pChangeBIParams = (tpSirChangeBIParams)pMsgBuf;
4723
4724 if((psessionEntry = peFindSessionByBssid(pMac, pChangeBIParams->bssId, &sessionId)) == NULL)
4725 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004726 limLog(pMac, LOGE, FL("Session does not exist for given BSSID"));
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08004727 return;
4728 }
4729
4730 /*Update sessionEntry Beacon Interval*/
4731 if(psessionEntry->beaconParams.beaconInterval !=
4732 pChangeBIParams->beaconInterval )
4733 {
4734 psessionEntry->beaconParams.beaconInterval = pChangeBIParams->beaconInterval;
4735 }
4736
4737 /*Update sch beaconInterval*/
4738 if(pMac->sch.schObject.gSchBeaconInterval !=
4739 pChangeBIParams->beaconInterval )
4740 {
4741 pMac->sch.schObject.gSchBeaconInterval = pChangeBIParams->beaconInterval;
4742
4743 PELOG1(limLog(pMac, LOG1,
4744 FL("LIM send update BeaconInterval Indication : %d"),pChangeBIParams->beaconInterval););
4745
4746 /* Update beacon */
4747 schSetFixedBeaconFields(pMac, psessionEntry);
4748
Sunil Ravib96f7b52013-05-22 21:40:05 -07004749 beaconParams.bssIdx = psessionEntry->bssIdx;
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08004750 //Set change in beacon Interval
4751 beaconParams.beaconInterval = pChangeBIParams->beaconInterval;
Jeff Johnson312557b2013-04-03 16:27:48 -07004752 beaconParams.paramChangeBitmap = PARAM_BCN_INTERVAL_CHANGED;
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08004753 limSendBeaconParams(pMac, &beaconParams, psessionEntry);
4754 }
4755
4756 return;
4757} /*** end __limProcessSmeChangeBI(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf) ***/
4758
Hardik Kantilal Patel62a3a762014-11-21 12:55:57 +05304759/** -------------------------------------------------------------
4760\fn
4761\brief handles indication message from HDD to update HT mode
4762\param tpAniSirGlobal pMac
4763\param tANI_U32 pMsgBuf
4764\return None
4765-------------------------------------------------------------*/
4766#ifdef WLAN_FEATURE_AP_HT40_24G
4767static void __limProcessSmeSetHT2040Mode(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
4768{
4769 tpSirSetHT2040Mode pSetHT2040Mode;
4770 tpPESession psessionEntry;
4771 tANI_U8 sessionId = 0;
4772 tUpdateVHTOpMode *pHtOpMode = NULL;
4773 vos_msg_t msg;
Jeff Johnson295189b2012-06-20 16:38:30 -07004774
Hardik Kantilal Patel62a3a762014-11-21 12:55:57 +05304775 PELOG1(limLog(pMac, LOGRW,
4776 FL("received Set HT 20/40 mode message")););
4777
4778 if(pMsgBuf == NULL)
4779 {
4780 limLog(pMac, LOGE,FL("Buffer is Pointing to NULL"));
4781 return;
4782 }
4783
4784 pSetHT2040Mode = (tpSirSetHT2040Mode)pMsgBuf;
4785
4786 if((psessionEntry = peFindSessionByBssid(pMac, pSetHT2040Mode->bssId,
4787 &sessionId)) == NULL)
4788 {
4789 limLog(pMac, LOGE, FL("Session does not exist for given BSSID "));
4790 limPrintMacAddr(pMac, pSetHT2040Mode->bssId, LOGE);
4791 return;
4792 }
4793
4794 limLog(pMac, LOGW, FL("Update session entry for cbMod=%d"),
4795 pSetHT2040Mode->cbMode);
4796
4797 /*Update sessionEntry HT related fields*/
4798 switch(pSetHT2040Mode->cbMode)
4799 {
4800 case PHY_SINGLE_CHANNEL_CENTERED:
4801 psessionEntry->htSecondaryChannelOffset = PHY_SINGLE_CHANNEL_CENTERED;
4802 psessionEntry->htRecommendedTxWidthSet = 0;
4803 break;
4804 case PHY_DOUBLE_CHANNEL_LOW_PRIMARY:
4805 psessionEntry->htSecondaryChannelOffset =
4806 PHY_DOUBLE_CHANNEL_LOW_PRIMARY;
4807 psessionEntry->htRecommendedTxWidthSet = 1;
4808 break;
4809 case PHY_DOUBLE_CHANNEL_HIGH_PRIMARY:
4810 psessionEntry->htSecondaryChannelOffset =
4811 PHY_DOUBLE_CHANNEL_HIGH_PRIMARY;
4812 psessionEntry->htRecommendedTxWidthSet = 1;
4813 break;
4814 default:
4815 limLog(pMac, LOGE,FL("Invalid cbMode"));
4816 return;
4817 }
4818
4819 limLog(pMac, LOGW, FL("Channel Bonding mode : %d"
4820 " htSecondaryChannelOffset: %d"
4821 " htRecommendedTxWidthSet :%d"),
4822 pSetHT2040Mode->cbMode,
4823 psessionEntry->htSecondaryChannelOffset,
4824 psessionEntry->htRecommendedTxWidthSet);
4825
4826 limLog(pMac, LOGW, FL("Update Beacon IEs"));
4827
4828 /* Update beacon */
4829 schSetFixedBeaconFields(pMac, psessionEntry);
4830 limSendBeaconInd(pMac, psessionEntry);
4831
4832 /* Update OP Mode */
4833 pHtOpMode = vos_mem_malloc(sizeof(tUpdateVHTOpMode));
4834 if ( NULL == pHtOpMode )
4835 {
4836 limLog(pMac, LOGE,
4837 FL("Not able to allocate memory for setting OP mode"));
4838 return;
4839 }
4840
4841 pHtOpMode->opMode = (psessionEntry->htSecondaryChannelOffset ==
4842 PHY_SINGLE_CHANNEL_CENTERED)?
4843 eHT_CHANNEL_WIDTH_20MHZ:eHT_CHANNEL_WIDTH_40MHZ;
4844
4845 /* Pass Self STA ID to FW. Based on Self STA ID FW will update the
4846 * operating mode for all connected STA.
4847 */
4848
4849 pHtOpMode->staId = psessionEntry->staId;
4850
4851 msg.type = WDA_UPDATE_OP_MODE;
4852 msg.reserved = 0;
4853 msg.bodyptr = pHtOpMode;
4854
4855 if (!VOS_IS_STATUS_SUCCESS(
4856 vos_mq_post_message(VOS_MODULE_ID_WDA, &msg)))
4857 {
4858 limLog(pMac, LOGE,
4859 FL("Not able to post WDA_UPDATE_OP_MODE message to WDA"));
4860 vos_mem_free(pHtOpMode);
4861 return;
4862 }
4863
4864 limLog(pMac, LOGW,
4865 FL("Notifed FW about OP mode: %d for staId=%d"),
4866 pHtOpMode->opMode, pHtOpMode->staId);
4867
4868 return;
4869}
4870#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004871
4872/** -------------------------------------------------------------
4873\fn limProcessSmeDelBaPeerInd
4874\brief handles indication message from HDD to send delete BA request
4875\param tpAniSirGlobal pMac
4876\param tANI_U32 pMsgBuf
4877\return None
4878-------------------------------------------------------------*/
4879void
4880limProcessSmeDelBaPeerInd(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
4881{
4882 tANI_U16 assocId =0;
4883 tpSmeDelBAPeerInd pSmeDelBAPeerInd = (tpSmeDelBAPeerInd)pMsgBuf;
4884 tpDphHashNode pSta;
4885 tpPESession psessionEntry;
4886 tANI_U8 sessionId;
4887
4888
4889
4890 if(NULL == pSmeDelBAPeerInd)
4891 return;
4892
4893 if ((psessionEntry = peFindSessionByBssid(pMac,pSmeDelBAPeerInd->bssId,&sessionId))==NULL)
4894 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004895 limLog(pMac, LOGE,FL("session does not exist for given bssId"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004896 return;
4897 }
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004898 limLog(pMac, LOGW, FL("called with staId = %d, tid = %d, baDirection = %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07004899 pSmeDelBAPeerInd->staIdx, pSmeDelBAPeerInd->baTID, pSmeDelBAPeerInd->baDirection);
4900
4901 pSta = dphLookupAssocId(pMac, pSmeDelBAPeerInd->staIdx, &assocId, &psessionEntry->dph.dphHashTable);
4902 if( eSIR_SUCCESS != limPostMlmDelBAReq( pMac,
4903 pSta,
4904 pSmeDelBAPeerInd->baDirection,
4905 pSmeDelBAPeerInd->baTID,
4906 eSIR_MAC_UNSPEC_FAILURE_REASON,psessionEntry))
4907 {
4908 limLog( pMac, LOGW,
4909 FL( "Failed to post LIM_MLM_DELBA_REQ to " ));
4910 if (pSta)
4911 limPrintMacAddr(pMac, pSta->staAddr, LOGW);
4912 }
4913}
4914
4915// --------------------------------------------------------------------
4916/**
4917 * __limProcessReportMessage
4918 *
4919 * FUNCTION: Processes the next received Radio Resource Management message
4920 *
4921 * LOGIC:
4922 *
4923 * ASSUMPTIONS:
4924 *
4925 * NOTE:
4926 *
4927 * @param None
4928 * @return None
4929 */
4930
4931void __limProcessReportMessage(tpAniSirGlobal pMac, tpSirMsgQ pMsg)
4932{
4933#ifdef WLAN_FEATURE_VOWIFI
4934 switch (pMsg->type)
4935 {
4936 case eWNI_SME_NEIGHBOR_REPORT_REQ_IND:
4937 rrmProcessNeighborReportReq( pMac, pMsg->bodyptr );
4938 break;
4939 case eWNI_SME_BEACON_REPORT_RESP_XMIT_IND:
4940 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004941#if defined(FEATURE_WLAN_ESE) && !defined(FEATURE_WLAN_ESE_UPLOAD)
Jeff Johnson295189b2012-06-20 16:38:30 -07004942 tpSirBeaconReportXmitInd pBcnReport=NULL;
4943 tpPESession psessionEntry=NULL;
4944 tANI_U8 sessionId;
Padma, Santhosh Kumar20d45a12016-04-05 13:11:00 +05304945 tpEsePEContext pEseContext = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004946
4947 if(pMsg->bodyptr == NULL)
4948 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004949 limLog(pMac, LOGE,FL("Buffer is Pointing to NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004950 return;
4951 }
4952 pBcnReport = (tpSirBeaconReportXmitInd )pMsg->bodyptr;
4953 if((psessionEntry = peFindSessionByBssid(pMac, pBcnReport->bssId,&sessionId))== NULL)
4954 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004955 limLog(pMac, LOGE, "Session Does not exist for given bssId");
Jeff Johnson295189b2012-06-20 16:38:30 -07004956 return;
4957 }
Padma, Santhosh Kumar20d45a12016-04-05 13:11:00 +05304958
4959 pEseContext = &psessionEntry->eseContext;
4960
4961 if (psessionEntry->isESEconnection && pEseContext->curMeasReq.isValid)
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004962 eseProcessBeaconReportXmit( pMac, pMsg->bodyptr);
Jeff Johnson295189b2012-06-20 16:38:30 -07004963 else
4964#endif
4965 rrmProcessBeaconReportXmit( pMac, pMsg->bodyptr );
4966 }
4967 break;
4968 }
4969#endif
4970}
4971
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004972#if defined(FEATURE_WLAN_ESE) || defined(WLAN_FEATURE_VOWIFI)
Jeff Johnson295189b2012-06-20 16:38:30 -07004973// --------------------------------------------------------------------
4974/**
4975 * limSendSetMaxTxPowerReq
4976 *
4977 * FUNCTION: Send SIR_HAL_SET_MAX_TX_POWER_REQ message to change the max tx power.
4978 *
4979 * LOGIC:
4980 *
4981 * ASSUMPTIONS:
4982 *
4983 * NOTE:
4984 *
4985 * @param txPower txPower to be set.
4986 * @param pSessionEntry session entry.
4987 * @return None
4988 */
4989tSirRetStatus
4990limSendSetMaxTxPowerReq ( tpAniSirGlobal pMac, tPowerdBm txPower, tpPESession pSessionEntry )
4991{
4992 tpMaxTxPowerParams pMaxTxParams = NULL;
4993 tSirRetStatus retCode = eSIR_SUCCESS;
4994 tSirMsgQ msgQ;
4995
4996 if( pSessionEntry == NULL )
4997 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004998 PELOGE(limLog(pMac, LOGE, "%s:%d: Inavalid parameters", __func__, __LINE__ );)
Jeff Johnson295189b2012-06-20 16:38:30 -07004999 return eSIR_FAILURE;
5000 }
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05305001
5002 pMaxTxParams = vos_mem_malloc(sizeof(tMaxTxPowerParams));
5003 if ( NULL == pMaxTxParams )
Jeff Johnson295189b2012-06-20 16:38:30 -07005004 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005005 limLog( pMac, LOGP, "%s:%d:Unable to allocate memory for pMaxTxParams ", __func__, __LINE__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005006 return eSIR_MEM_ALLOC_FAILED;
5007
5008 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005009#if defined(WLAN_VOWIFI_DEBUG) || defined(FEATURE_WLAN_ESE)
Abhishek Singh3cbf6052014-12-15 16:46:42 +05305010 limLog( pMac, LOG1,
5011 FL(" Allocated memory for pMaxTxParams, which will be freed in other module"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005012#endif
Kiran Kumar Lokerea4db3dc2013-03-25 18:05:24 -07005013 if( pMaxTxParams == NULL )
5014 {
Abhishek Singh3cbf6052014-12-15 16:46:42 +05305015 limLog( pMac, LOGE, FL("pMaxTxParams is NULL"));
Kiran Kumar Lokerea4db3dc2013-03-25 18:05:24 -07005016 return eSIR_FAILURE;
5017 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005018 pMaxTxParams->power = txPower;
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05305019 vos_mem_copy( pMaxTxParams->bssId, pSessionEntry->bssId, sizeof(tSirMacAddr) );
5020 vos_mem_copy( pMaxTxParams->selfStaMacAddr, pSessionEntry->selfMacAddr, sizeof(tSirMacAddr) );
Jeff Johnson295189b2012-06-20 16:38:30 -07005021
Jeff Johnson68ce9c42013-04-08 10:33:28 -07005022 msgQ.type = WDA_SET_MAX_TX_POWER_REQ;
5023 msgQ.bodyptr = pMaxTxParams;
5024 msgQ.bodyval = 0;
Abhishek Singh3cbf6052014-12-15 16:46:42 +05305025 limLog(pMac, LOG1, FL("Posting WDA_SET_MAX_TX_POWER_REQ to WDA"));
Jeff Johnson68ce9c42013-04-08 10:33:28 -07005026 MTRACE(macTraceMsgTx(pMac, pSessionEntry->peSessionId, msgQ.type));
5027 retCode = wdaPostCtrlMsg(pMac, &msgQ);
5028 if (eSIR_SUCCESS != retCode)
5029 {
5030 PELOGE(limLog(pMac, LOGE, FL("wdaPostCtrlMsg() failed"));)
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05305031 vos_mem_free(pMaxTxParams);
Jeff Johnson68ce9c42013-04-08 10:33:28 -07005032 }
5033 return retCode;
Jeff Johnson295189b2012-06-20 16:38:30 -07005034}
5035#endif
5036
5037/**
5038 * __limProcessSmeAddStaSelfReq()
5039 *
5040 *FUNCTION:
5041 * This function is called to process SME_ADD_STA_SELF_REQ message
5042 * from SME. It sends a SIR_HAL_ADD_STA_SELF_REQ message to HAL.
5043 *
5044 *LOGIC:
5045 *
5046 *ASSUMPTIONS:
5047 *
5048 *NOTE:
5049 *
5050 * @param pMac Pointer to Global MAC structure
5051 * @param *pMsgBuf A pointer to the SME message buffer
5052 * @return None
5053 */
5054
5055static void
5056__limProcessSmeAddStaSelfReq(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
5057{
5058 tSirMsgQ msg;
5059 tpAddStaSelfParams pAddStaSelfParams;
5060 tpSirSmeAddStaSelfReq pSmeReq = (tpSirSmeAddStaSelfReq) pMsgBuf;
5061
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05305062 pAddStaSelfParams = vos_mem_malloc(sizeof(tAddStaSelfParams));
5063 if ( NULL == pAddStaSelfParams )
Jeff Johnson295189b2012-06-20 16:38:30 -07005064 {
5065 limLog( pMac, LOGP, FL("Unable to allocate memory for tAddSelfStaParams") );
5066 return;
5067 }
5068
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05305069 vos_mem_copy( pAddStaSelfParams->selfMacAddr, pSmeReq->selfMacAddr, sizeof(tSirMacAddr) );
Kiran Kumar Lokeread7dbc82013-10-07 20:12:50 -07005070 pAddStaSelfParams->currDeviceMode = pSmeReq->currDeviceMode;
Jeff Johnson295189b2012-06-20 16:38:30 -07005071 msg.type = SIR_HAL_ADD_STA_SELF_REQ;
5072 msg.reserved = 0;
5073 msg.bodyptr = pAddStaSelfParams;
5074 msg.bodyval = 0;
5075
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005076 PELOGW(limLog(pMac, LOG1, FL("sending SIR_HAL_ADD_STA_SELF_REQ msg to HAL"));)
Jeff Johnsone7245742012-09-05 17:12:55 -07005077 MTRACE(macTraceMsgTx(pMac, NO_SESSION, msg.type));
Jeff Johnson295189b2012-06-20 16:38:30 -07005078
5079 if(eSIR_SUCCESS != wdaPostCtrlMsg(pMac, &msg))
5080 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005081 limLog(pMac, LOGP, FL("wdaPostCtrlMsg failed"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005082 }
5083 return;
5084} /*** end __limProcessAddStaSelfReq() ***/
5085
5086
5087/**
5088 * __limProcessSmeDelStaSelfReq()
5089 *
5090 *FUNCTION:
5091 * This function is called to process SME_DEL_STA_SELF_REQ message
5092 * from SME. It sends a SIR_HAL_DEL_STA_SELF_REQ message to HAL.
5093 *
5094 *LOGIC:
5095 *
5096 *ASSUMPTIONS:
5097 *
5098 *NOTE:
5099 *
5100 * @param pMac Pointer to Global MAC structure
5101 * @param *pMsgBuf A pointer to the SME message buffer
5102 * @return None
5103 */
5104
5105static void
5106__limProcessSmeDelStaSelfReq(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
5107{
5108 tSirMsgQ msg;
5109 tpDelStaSelfParams pDelStaSelfParams;
5110 tpSirSmeDelStaSelfReq pSmeReq = (tpSirSmeDelStaSelfReq) pMsgBuf;
5111
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05305112 pDelStaSelfParams = vos_mem_malloc(sizeof( tDelStaSelfParams));
5113 if ( NULL == pDelStaSelfParams )
Jeff Johnson295189b2012-06-20 16:38:30 -07005114 {
5115 limLog( pMac, LOGP, FL("Unable to allocate memory for tDelStaSelfParams") );
5116 return;
5117 }
5118
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05305119 vos_mem_copy( pDelStaSelfParams->selfMacAddr, pSmeReq->selfMacAddr, sizeof(tSirMacAddr) );
Jeff Johnson295189b2012-06-20 16:38:30 -07005120
5121 msg.type = SIR_HAL_DEL_STA_SELF_REQ;
5122 msg.reserved = 0;
5123 msg.bodyptr = pDelStaSelfParams;
5124 msg.bodyval = 0;
5125
Mukul Sharmacaf4aca2015-04-17 20:01:40 +05305126 PELOGW(limLog(pMac, LOG1, FL("sending SIR_HAL_DEL_STA_SELF_REQ msg to HAL"));)
Jeff Johnsone7245742012-09-05 17:12:55 -07005127 MTRACE(macTraceMsgTx(pMac, NO_SESSION, msg.type));
Jeff Johnson295189b2012-06-20 16:38:30 -07005128
5129 if(eSIR_SUCCESS != wdaPostCtrlMsg(pMac, &msg))
5130 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005131 limLog(pMac, LOGP, FL("wdaPostCtrlMsg failed"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005132 }
5133 return;
5134} /*** end __limProcessSmeDelStaSelfReq() ***/
5135
5136
Jeff Johnson295189b2012-06-20 16:38:30 -07005137/**
5138 * __limProcessSmeRegisterMgmtFrameReq()
5139 *
5140 *FUNCTION:
5141 * This function is called to process eWNI_SME_REGISTER_MGMT_FRAME_REQ message
5142 * from SME. It Register this information within PE.
5143 *
5144 *LOGIC:
5145 *
5146 *ASSUMPTIONS:
5147 *
5148 *NOTE:
5149 *
5150 * @param pMac Pointer to Global MAC structure
5151 * @param *pMsgBuf A pointer to the SME message buffer
5152 * @return None
5153 */
5154static void
5155__limProcessSmeRegisterMgmtFrameReq(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
5156{
5157 VOS_STATUS vosStatus;
5158 tpSirRegisterMgmtFrame pSmeReq = (tpSirRegisterMgmtFrame)pMsgBuf;
5159 tpLimMgmtFrameRegistration pLimMgmtRegistration = NULL, pNext = NULL;
Jeff Johnsond13512a2012-07-17 11:42:19 -07005160 tANI_BOOLEAN match = VOS_FALSE;
Abhishek Singh3cbf6052014-12-15 16:46:42 +05305161 limLog(pMac, LOG1,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005162 FL("registerFrame %d, frameType %d, matchLen %d"),
Abhishek Singh3cbf6052014-12-15 16:46:42 +05305163 pSmeReq->registerFrame, pSmeReq->frameType, pSmeReq->matchLen);
Jeff Johnson295189b2012-06-20 16:38:30 -07005164
Jeff Johnsond13512a2012-07-17 11:42:19 -07005165 /* First check whether entry exists already*/
5166
5167 vos_list_peek_front(&pMac->lim.gLimMgmtFrameRegistratinQueue,
5168 (vos_list_node_t**)&pLimMgmtRegistration);
5169
5170 while(pLimMgmtRegistration != NULL)
5171 {
5172 if (pLimMgmtRegistration->frameType == pSmeReq->frameType)
5173 {
5174 if(pSmeReq->matchLen)
5175 {
5176 if (pLimMgmtRegistration->matchLen == pSmeReq->matchLen)
5177 {
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05305178 if (vos_mem_compare( pLimMgmtRegistration->matchData,
Jeff Johnsond13512a2012-07-17 11:42:19 -07005179 pSmeReq->matchData, pLimMgmtRegistration->matchLen))
5180 {
Madan Mohan Koyyalamudic537df22012-10-22 15:07:08 -07005181 /* found match! */
5182 match = VOS_TRUE;
5183 break;
Jeff Johnsond13512a2012-07-17 11:42:19 -07005184 }
5185 }
5186 }
5187 else
5188 {
Madan Mohan Koyyalamudic537df22012-10-22 15:07:08 -07005189 /* found match! */
Jeff Johnsond13512a2012-07-17 11:42:19 -07005190 match = VOS_TRUE;
5191 break;
5192 }
5193 }
5194 vosStatus = vos_list_peek_next (
5195 &pMac->lim.gLimMgmtFrameRegistratinQueue,
5196 (vos_list_node_t*) pLimMgmtRegistration,
5197 (vos_list_node_t**) &pNext );
5198
5199 pLimMgmtRegistration = pNext;
5200 pNext = NULL;
5201
5202 }
5203
5204 if (match)
5205 {
5206 vos_list_remove_node(&pMac->lim.gLimMgmtFrameRegistratinQueue,
5207 (vos_list_node_t*)pLimMgmtRegistration);
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05305208 vos_mem_free(pLimMgmtRegistration);
Jeff Johnsond13512a2012-07-17 11:42:19 -07005209 }
5210
Jeff Johnson295189b2012-06-20 16:38:30 -07005211 if(pSmeReq->registerFrame)
5212 {
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05305213 pLimMgmtRegistration = vos_mem_malloc(sizeof(tLimMgmtFrameRegistration) + pSmeReq->matchLen);
5214 if ( pLimMgmtRegistration != NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -07005215 {
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05305216 vos_mem_set((void*)pLimMgmtRegistration,
5217 sizeof(tLimMgmtFrameRegistration) + pSmeReq->matchLen, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005218 pLimMgmtRegistration->frameType = pSmeReq->frameType;
5219 pLimMgmtRegistration->matchLen = pSmeReq->matchLen;
5220 pLimMgmtRegistration->sessionId = pSmeReq->sessionId;
5221 if(pSmeReq->matchLen)
5222 {
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05305223 vos_mem_copy(pLimMgmtRegistration->matchData,
5224 pSmeReq->matchData, pSmeReq->matchLen);
Jeff Johnson295189b2012-06-20 16:38:30 -07005225 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005226 vos_list_insert_front(&pMac->lim.gLimMgmtFrameRegistratinQueue,
5227 &pLimMgmtRegistration->node);
5228 }
5229 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005230
5231 return;
5232} /*** end __limProcessSmeRegisterMgmtFrameReq() ***/
Viral Modid86bde22012-12-10 13:09:21 -08005233
5234static tANI_BOOLEAN
Viral Modid440e682013-03-06 02:25:31 -08005235__limInsertSingleShotNOAForScan(tpAniSirGlobal pMac, tANI_U32 noaDuration)
Viral Modid86bde22012-12-10 13:09:21 -08005236{
5237 tpP2pPsParams pMsgNoA;
5238 tSirMsgQ msg;
Vinay Malekal62757362012-12-17 12:15:51 -08005239
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05305240 pMsgNoA = vos_mem_malloc(sizeof( tP2pPsConfig ));
5241 if ( NULL == pMsgNoA )
Viral Modid86bde22012-12-10 13:09:21 -08005242 {
5243 limLog( pMac, LOGP,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005244 FL( "Unable to allocate memory during NoA Update" ));
Viral Modid440e682013-03-06 02:25:31 -08005245 goto error;
Viral Modid86bde22012-12-10 13:09:21 -08005246 }
5247
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05305248 vos_mem_set((tANI_U8 *)pMsgNoA, sizeof(tP2pPsConfig), 0);
Viral Modid86bde22012-12-10 13:09:21 -08005249 /* Below params used for opp PS/periodic NOA and are don't care in this case - so initialized to 0 */
5250 pMsgNoA->opp_ps = 0;
5251 pMsgNoA->ctWindow = 0;
5252 pMsgNoA->duration = 0;
5253 pMsgNoA->interval = 0;
5254 pMsgNoA->count = 0;
Vinay Malekal62757362012-12-17 12:15:51 -08005255
Vinay Malekal62757362012-12-17 12:15:51 -08005256 /* Below params used for Single Shot NOA - so assign proper values */
5257 pMsgNoA->psSelection = P2P_SINGLE_NOA;
Viral Modid440e682013-03-06 02:25:31 -08005258 pMsgNoA->single_noa_duration = noaDuration;
Gopichand Nakkala096a1052012-12-21 07:05:34 -08005259
Viral Modid86bde22012-12-10 13:09:21 -08005260 /* Start Insert NOA timer
5261 * 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 -08005262 * or any other failure or reason, we still need to process the deferred SME req. The insert NOA
5263 * timer of 500 ms will ensure the stored SME req always gets processed
Viral Modid86bde22012-12-10 13:09:21 -08005264 */
5265 if (tx_timer_activate(&pMac->lim.limTimers.gLimP2pSingleShotNoaInsertTimer)
5266 == TX_TIMER_ERROR)
5267 {
5268 /// Could not activate Insert NOA timer.
5269 // Log error
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005270 limLog(pMac, LOGP, FL("could not activate Insert Single Shot NOA during scan timer"));
Viral Modid86bde22012-12-10 13:09:21 -08005271
5272 // send the scan response back with status failure and do not even call insert NOA
5273 limSendSmeScanRsp(pMac, sizeof(tSirSmeScanRsp), eSIR_SME_SCAN_FAILED, pMac->lim.gSmeSessionId, pMac->lim.gTransactionId);
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05305274 vos_mem_free(pMsgNoA);
Viral Modid440e682013-03-06 02:25:31 -08005275 goto error;
Viral Modid86bde22012-12-10 13:09:21 -08005276 }
5277
Viral Modid440e682013-03-06 02:25:31 -08005278 MTRACE(macTrace(pMac, TRACE_CODE_TIMER_ACTIVATE, NO_SESSION, eLIM_INSERT_SINGLESHOT_NOA_TIMER));
5279
Viral Modid86bde22012-12-10 13:09:21 -08005280 msg.type = WDA_SET_P2P_GO_NOA_REQ;
5281 msg.reserved = 0;
5282 msg.bodyptr = pMsgNoA;
5283 msg.bodyval = 0;
5284
5285 if(eSIR_SUCCESS != wdaPostCtrlMsg(pMac, &msg))
5286 {
5287 /* 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 -07005288 limLog(pMac, LOGP, FL("wdaPost Msg failed"));
Viral Modid440e682013-03-06 02:25:31 -08005289 /* Deactivate the NOA timer in failure case */
5290 limDeactivateAndChangeTimer(pMac, eLIM_INSERT_SINGLESHOT_NOA_TIMER);
5291 goto error;
Viral Modid86bde22012-12-10 13:09:21 -08005292 }
Viral Modid440e682013-03-06 02:25:31 -08005293 return FALSE;
Viral Modid86bde22012-12-10 13:09:21 -08005294
Viral Modid440e682013-03-06 02:25:31 -08005295error:
5296 /* In any of the failure cases, just go ahead with the processing of registered deferred SME request without
5297 * worrying about the NOA
5298 */
5299 limProcessRegdDefdSmeReqAfterNOAStart(pMac);
5300 // msg buffer is consumed and freed in above function so return FALSE
Viral Modid86bde22012-12-10 13:09:21 -08005301 return FALSE;
5302
5303}
5304
Viral Modid440e682013-03-06 02:25:31 -08005305static void __limRegisterDeferredSmeReqForNOAStart(tpAniSirGlobal pMac, tANI_U16 msgType, tANI_U32 *pMsgBuf)
5306{
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005307 limLog(pMac, LOG1, FL("Reg msgType %d"), msgType) ;
Viral Modid440e682013-03-06 02:25:31 -08005308 pMac->lim.gDeferMsgTypeForNOA = msgType;
5309 pMac->lim.gpDefdSmeMsgForNOA = pMsgBuf;
5310}
5311
5312static void __limDeregisterDeferredSmeReqAfterNOAStart(tpAniSirGlobal pMac)
5313{
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005314 limLog(pMac, LOG1, FL("Dereg msgType %d"), pMac->lim.gDeferMsgTypeForNOA) ;
Viral Modid440e682013-03-06 02:25:31 -08005315 pMac->lim.gDeferMsgTypeForNOA = 0;
5316 if (pMac->lim.gpDefdSmeMsgForNOA != NULL)
5317 {
5318 /* __limProcessSmeScanReq consumed the buffer. We can free it. */
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05305319 vos_mem_free(pMac->lim.gpDefdSmeMsgForNOA);
Viral Modid440e682013-03-06 02:25:31 -08005320 pMac->lim.gpDefdSmeMsgForNOA = NULL;
5321 }
5322}
5323
5324static
Ganesh Kondabattini16930072014-08-22 16:02:34 +05305325tANI_U32 limCalculateNOADuration(tpAniSirGlobal pMac, tANI_U16 msgType,
5326 tANI_U32 *pMsgBuf, tANI_BOOLEAN isPassiveScan)
Viral Modid440e682013-03-06 02:25:31 -08005327{
5328 tANI_U32 noaDuration = 0;
5329
5330 switch (msgType)
5331 {
5332 case eWNI_SME_SCAN_REQ:
5333 {
5334 tANI_U32 val;
5335 tANI_U8 i;
5336 tpSirSmeScanReq pScanReq = (tpSirSmeScanReq) pMsgBuf;
5337 if (wlan_cfgGetInt(pMac, WNI_CFG_PASSIVE_MAXIMUM_CHANNEL_TIME, &val) != eSIR_SUCCESS)
5338 {
5339 /*
5340 * Could not get max channel value
5341 * from CFG. Log error.
5342 */
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005343 limLog(pMac, LOGP, FL("could not retrieve passive max channel value"));
Viral Modid440e682013-03-06 02:25:31 -08005344
5345 /* use a default value of 110ms */
5346 val = DEFAULT_PASSIVE_MAX_CHANNEL_TIME;
5347 }
5348
5349 for (i = 0; i < pScanReq->channelList.numChannels; i++) {
5350 tANI_U8 channelNum = pScanReq->channelList.channelNumber[i];
5351
Ganesh Kondabattini8f6e3b32014-08-25 16:07:54 +05305352 if (pMac->miracast_mode) {
5353 noaDuration += DEFAULT_MIN_CHAN_TIME_DURING_MIRACAST +
5354 DEFAULT_MAX_CHAN_TIME_DURING_MIRACAST;
5355 } else if (isPassiveScan || !limActiveScanAllowed(pMac, channelNum)) {
Viral Modid440e682013-03-06 02:25:31 -08005356 /* using the value from WNI_CFG_PASSIVE_MINIMUM_CHANNEL_TIME as is done in
5357 * void limContinuePostChannelScan(tpAniSirGlobal pMac)
5358 */
5359 noaDuration += val;
Ganesh Kondabattini16930072014-08-22 16:02:34 +05305360 } else {
5361 /* Use min + max channel time to calculate the total duration of scan */
5362 noaDuration += pScanReq->minChannelTime + pScanReq->maxChannelTime;
Viral Modid440e682013-03-06 02:25:31 -08005363 }
5364 }
5365
5366 /* Adding an overhead of 20ms to account for the scan messaging delays */
5367 noaDuration += SCAN_MESSAGING_OVERHEAD;
5368 noaDuration *= CONV_MS_TO_US;
5369
5370 break;
5371 }
5372
5373 case eWNI_SME_OEM_DATA_REQ:
5374 noaDuration = OEM_DATA_NOA_DURATION*CONV_MS_TO_US; // use 60 msec as default
5375 break;
5376
5377 case eWNI_SME_REMAIN_ON_CHANNEL_REQ:
5378 {
5379 tSirRemainOnChnReq *pRemainOnChnReq = (tSirRemainOnChnReq *) pMsgBuf;
5380 noaDuration = (pRemainOnChnReq->duration)*CONV_MS_TO_US;
5381 break;
5382 }
5383
5384 case eWNI_SME_JOIN_REQ:
5385 noaDuration = JOIN_NOA_DURATION*CONV_MS_TO_US;
5386 break;
5387
5388 default:
5389 noaDuration = 0;
5390 break;
5391
5392 }
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005393 limLog(pMac, LOGW, FL("msgType %d noa %d"), msgType, noaDuration);
Viral Modid440e682013-03-06 02:25:31 -08005394 return noaDuration;
5395}
5396
5397void limProcessRegdDefdSmeReqAfterNOAStart(tpAniSirGlobal pMac)
5398{
Gopichand Nakkala7c4c3b92013-03-25 18:08:31 +05305399 tANI_BOOLEAN bufConsumed = TRUE;
Viral Modid440e682013-03-06 02:25:31 -08005400
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005401 limLog(pMac, LOG1, FL("Process defd sme req %d"), pMac->lim.gDeferMsgTypeForNOA);
Viral Modid440e682013-03-06 02:25:31 -08005402 if ( (pMac->lim.gDeferMsgTypeForNOA != 0) &&
5403 (pMac->lim.gpDefdSmeMsgForNOA != NULL) )
5404 {
5405 switch (pMac->lim.gDeferMsgTypeForNOA)
5406 {
5407 case eWNI_SME_SCAN_REQ:
5408 __limProcessSmeScanReq(pMac, pMac->lim.gpDefdSmeMsgForNOA);
5409 break;
5410 case eWNI_SME_OEM_DATA_REQ:
5411 __limProcessSmeOemDataReq(pMac, pMac->lim.gpDefdSmeMsgForNOA);
5412 break;
5413 case eWNI_SME_REMAIN_ON_CHANNEL_REQ:
Gopichand Nakkala7c4c3b92013-03-25 18:08:31 +05305414 bufConsumed = limProcessRemainOnChnlReq(pMac, pMac->lim.gpDefdSmeMsgForNOA);
5415 /* limProcessRemainOnChnlReq doesnt want us to free the buffer since
5416 * it is freed in limRemainOnChnRsp. this change is to avoid "double free"
5417 */
5418 if (FALSE == bufConsumed)
5419 {
5420 pMac->lim.gpDefdSmeMsgForNOA = NULL;
5421 }
Viral Modid440e682013-03-06 02:25:31 -08005422 break;
5423 case eWNI_SME_JOIN_REQ:
5424 __limProcessSmeJoinReq(pMac, pMac->lim.gpDefdSmeMsgForNOA);
5425 break;
5426 default:
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005427 limLog(pMac, LOGE, FL("Unknown deferred msg type %d"), pMac->lim.gDeferMsgTypeForNOA);
Viral Modid440e682013-03-06 02:25:31 -08005428 break;
5429 }
5430 __limDeregisterDeferredSmeReqAfterNOAStart(pMac);
5431 }
5432 else
5433 {
5434 limLog( pMac, LOGW, FL("start received from FW when no sme deferred msg pending. Do nothing."
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005435 "It might happen sometime when NOA start ind and timeout happen at the same time"));
Viral Modid440e682013-03-06 02:25:31 -08005436 }
5437}
Jeff Johnson295189b2012-06-20 16:38:30 -07005438
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05305439static void
5440__limProcessSmeResetApCapsChange(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
5441{
5442 tpSirResetAPCapsChange pResetCapsChange;
5443 tpPESession psessionEntry;
5444 tANI_U8 sessionId = 0;
5445 if (pMsgBuf == NULL)
5446 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005447 limLog(pMac, LOGE,FL("Buffer is Pointing to NULL"));
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05305448 return;
5449 }
5450
5451 pResetCapsChange = (tpSirResetAPCapsChange)pMsgBuf;
5452 psessionEntry = peFindSessionByBssid(pMac, pResetCapsChange->bssId, &sessionId);
5453 if (psessionEntry == NULL)
5454 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005455 limLog(pMac, LOGE, FL("Session does not exist for given BSSID"));
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05305456 return;
5457 }
5458
5459 psessionEntry->limSentCapsChangeNtf = false;
5460 return;
5461}
5462
Siddharth Bhal6af5d4e2014-09-29 21:11:16 +05305463static void
5464__limProcessSmeSpoofMacAddrRequest(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
5465{
5466 tSirMsgQ msg;
5467 tpSpoofMacAddrReqParams pSpoofMacAddrParams;
5468 tpSirSpoofMacAddrReq pSmeReq = (tpSirSpoofMacAddrReq) pMsgBuf;
5469
5470 pSpoofMacAddrParams = vos_mem_malloc(sizeof( tSpoofMacAddrReqParams));
5471 if ( NULL == pSpoofMacAddrParams )
5472 {
Siddharth Bhal4f3187c2014-10-09 21:38:08 +05305473 limLog( pMac, LOGE, FL("Unable to allocate memory for tDelStaSelfParams") );
Siddharth Bhal6af5d4e2014-09-29 21:11:16 +05305474 return;
5475 }
5476
5477 vos_mem_copy( pSpoofMacAddrParams->macAddr, pSmeReq->macAddr, sizeof(tSirMacAddr) );
5478
Siddharth Bhal4f3187c2014-10-09 21:38:08 +05305479 vos_mem_copy(pMac->lim.spoofMacAddr, pSmeReq->macAddr, VOS_MAC_ADDRESS_LEN);
5480
5481 limLog( pMac, LOG1, FL("Recieved Spoofed Mac Addr request with Addr:"
5482 MAC_ADDRESS_STR), MAC_ADDR_ARRAY(pMac->lim.spoofMacAddr) );
5483
Siddharth Bhal6af5d4e2014-09-29 21:11:16 +05305484 msg.type = WDA_SPOOF_MAC_ADDR_REQ;
5485 msg.reserved = 0;
5486 msg.bodyptr = pSpoofMacAddrParams;
5487 msg.bodyval = 0;
5488
5489 limLog(pMac, LOG1, FL("sending SIR_HAL_SPOOF_MAC_ADDR_REQ msg to HAL"));
5490 MTRACE(macTraceMsgTx(pMac, NO_SESSION, msg.type));
5491
5492 if(eSIR_SUCCESS != wdaPostCtrlMsg(pMac, &msg))
5493 {
Siddharth Bhal4f3187c2014-10-09 21:38:08 +05305494 limLog(pMac, LOGE, FL("wdaPostCtrlMsg failed for SIR_HAL_SPOOF_MAC_ADDR_REQ"));
Siddharth Bhal6af5d4e2014-09-29 21:11:16 +05305495 vos_mem_free(pSpoofMacAddrParams);
5496 }
5497 return;
5498}
5499
Jeff Johnson295189b2012-06-20 16:38:30 -07005500/**
Abhishek Singh7d624e12015-11-30 14:29:27 +05305501 * lim_register_mgmt_frame_ind_cb() - Save the Management frame
5502 * indication callback in PE.
5503 * @pMac: Mac pointer
5504 * @pMsgBuf: Msg pointer containing the callback
5505 *
5506 * This function is used save the Management frame
5507 * indication callback in PE.
5508 *
5509 * Return: None
5510 */
5511static void lim_register_mgmt_frame_ind_cb(tpAniSirGlobal pMac,
5512 tANI_U32 *msg_buf)
5513{
5514 struct sir_sme_mgmt_frame_cb_req *sme_req =
5515 (struct sir_sme_mgmt_frame_cb_req *)msg_buf;
5516
5517 if (NULL == msg_buf)
5518 {
5519 limLog(pMac, LOGE, FL("msg_buf is null"));
5520 return;
5521 }
5522 if (sme_req->callback)
5523 pMac->mgmt_frame_ind_cb =
5524 (sir_mgmt_frame_ind_callback)sme_req->callback;
5525 else
5526 limLog(pMac, LOGE, FL("sme_req->callback is null"));
5527}
5528
5529/**
Jeff Johnson295189b2012-06-20 16:38:30 -07005530 * limProcessSmeReqMessages()
5531 *
5532 *FUNCTION:
5533 * This function is called by limProcessMessageQueue(). This
5534 * function processes SME request messages from HDD or upper layer
5535 * application.
5536 *
5537 *LOGIC:
5538 *
5539 *ASSUMPTIONS:
5540 *
5541 *NOTE:
5542 *
5543 * @param pMac Pointer to Global MAC structure
5544 * @param msgType Indicates the SME message type
5545 * @param *pMsgBuf A pointer to the SME message buffer
5546 * @return Boolean - TRUE - if pMsgBuf is consumed and can be freed.
5547 * FALSE - if pMsgBuf is not to be freed.
5548 */
5549
5550tANI_BOOLEAN
5551limProcessSmeReqMessages(tpAniSirGlobal pMac, tpSirMsgQ pMsg)
5552{
5553 tANI_BOOLEAN bufConsumed = TRUE; //Set this flag to false within case block of any following message, that doesnt want pMsgBuf to be freed.
5554 tANI_U32 *pMsgBuf = pMsg->bodyptr;
Sudhir Sattayappa Kohalliabf751c2013-06-30 15:37:18 -07005555 tpSirSmeScanReq pScanReq;
Ganesh Kondabattini16930072014-08-22 16:02:34 +05305556 tANI_BOOLEAN isPassiveScan = FALSE;
5557
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005558 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 -07005559 limMsgStr(pMsg->type), pMsg->type,
5560 limSmeStateStr(pMac->lim.gLimSmeState), pMac->lim.gLimSmeState,
5561 limMlmStateStr(pMac->lim.gLimMlmState), pMac->lim.gLimMlmState );)
5562
Sudhir Sattayappa Kohalliabf751c2013-06-30 15:37:18 -07005563 pScanReq = (tpSirSmeScanReq) pMsgBuf;
Viral Modid440e682013-03-06 02:25:31 -08005564 /* Special handling of some SME Req msgs where we have an existing GO session and
5565 * want to insert NOA before processing those msgs. These msgs will be processed later when
5566 * start event happens
5567 */
5568 switch (pMsg->type)
5569 {
5570 case eWNI_SME_SCAN_REQ:
Ganesh Kondabattini16930072014-08-22 16:02:34 +05305571 pScanReq = (tpSirSmeScanReq) pMsgBuf;
5572 isPassiveScan = (pScanReq->scanType == eSIR_PASSIVE_SCAN) ? TRUE : FALSE;
Viral Modid440e682013-03-06 02:25:31 -08005573 case eWNI_SME_REMAIN_ON_CHANNEL_REQ:
Sudhir Sattayappa Kohalliabf751c2013-06-30 15:37:18 -07005574
5575 /* If scan is disabled return from here
5576 */
5577 if (pMac->lim.fScanDisabled)
5578 {
Sudhir Sattayappa Kohalliabf751c2013-06-30 15:37:18 -07005579 if (pMsg->type == eWNI_SME_SCAN_REQ)
5580 {
5581 limSendSmeScanRsp(pMac,
5582 offsetof(tSirSmeScanRsp,bssDescription[0]),
5583 eSIR_SME_INVALID_PARAMETERS,
5584 pScanReq->sessionId,
5585 pScanReq->transactionId);
5586
5587 bufConsumed = TRUE;
5588 }
5589 else if (pMsg->type == eWNI_SME_REMAIN_ON_CHANNEL_REQ)
5590 {
5591 pMac->lim.gpDefdSmeMsgForNOA = NULL;
5592 pMac->lim.gpLimRemainOnChanReq = (tpSirRemainOnChnReq )pMsgBuf;
5593 limRemainOnChnRsp(pMac,eHAL_STATUS_FAILURE, NULL);
5594
5595 /*
5596 * limRemainOnChnRsp will free the buffer this change is to
5597 * avoid "double free"
5598 */
5599 bufConsumed = FALSE;
5600 }
5601
Rashmi Ramanna6c13a342014-01-07 11:44:07 +05305602 limLog(pMac, LOGE,
5603 FL("Error: Scan Disabled."
5604 " Return with error status for SME Message %s(%d)"),
5605 limMsgStr(pMsg->type), pMsg->type);
5606
Sudhir Sattayappa Kohalliabf751c2013-06-30 15:37:18 -07005607 return bufConsumed;
5608 }
5609 /*
5610 * Do not add BREAK here
5611 */
5612 case eWNI_SME_OEM_DATA_REQ:
Viral Modid440e682013-03-06 02:25:31 -08005613 case eWNI_SME_JOIN_REQ:
5614 /* If we have an existing P2P GO session we need to insert NOA before actually process this SME Req */
5615 if ((limIsNOAInsertReqd(pMac) == TRUE) && IS_FEATURE_SUPPORTED_BY_FW(P2P_GO_NOA_DECOUPLE_INIT_SCAN))
5616 {
5617 tANI_U32 noaDuration;
5618 __limRegisterDeferredSmeReqForNOAStart(pMac, pMsg->type, pMsgBuf);
Ganesh Kondabattini16930072014-08-22 16:02:34 +05305619 noaDuration = limCalculateNOADuration(pMac, pMsg->type, pMsgBuf, isPassiveScan);
Viral Modid440e682013-03-06 02:25:31 -08005620 bufConsumed = __limInsertSingleShotNOAForScan(pMac, noaDuration);
5621 return bufConsumed;
5622 }
5623 }
5624 /* If no insert NOA required then execute the code below */
5625
Jeff Johnson295189b2012-06-20 16:38:30 -07005626 switch (pMsg->type)
5627 {
5628 case eWNI_SME_START_REQ:
5629 __limProcessSmeStartReq(pMac, pMsgBuf);
5630 break;
5631
5632 case eWNI_SME_SYS_READY_IND:
5633 bufConsumed = __limProcessSmeSysReadyInd(pMac, pMsgBuf);
5634 break;
5635
Jeff Johnson295189b2012-06-20 16:38:30 -07005636 case eWNI_SME_START_BSS_REQ:
5637 bufConsumed = __limProcessSmeStartBssReq(pMac, pMsg);
5638 break;
5639
5640 case eWNI_SME_SCAN_REQ:
Viral Modid440e682013-03-06 02:25:31 -08005641 __limProcessSmeScanReq(pMac, pMsgBuf);
Jeff Johnson295189b2012-06-20 16:38:30 -07005642 break;
5643
Jeff Johnsone7245742012-09-05 17:12:55 -07005644#ifdef FEATURE_OEM_DATA_SUPPORT
5645 case eWNI_SME_OEM_DATA_REQ:
5646 __limProcessSmeOemDataReq(pMac, pMsgBuf);
Jeff Johnsone7245742012-09-05 17:12:55 -07005647 break;
5648#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005649 case eWNI_SME_REMAIN_ON_CHANNEL_REQ:
5650 bufConsumed = limProcessRemainOnChnlReq(pMac, pMsgBuf);
5651 break;
5652
5653 case eWNI_SME_UPDATE_NOA:
5654 __limProcessSmeNoAUpdate(pMac, pMsgBuf);
5655 break;
Gopichand Nakkalac178ac82013-05-30 19:53:39 +05305656 case eWNI_SME_CLEAR_DFS_CHANNEL_LIST:
5657 __limProcessClearDfsChannelList(pMac, pMsg);
5658 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005659 case eWNI_SME_JOIN_REQ:
5660 __limProcessSmeJoinReq(pMac, pMsgBuf);
Jeff Johnson295189b2012-06-20 16:38:30 -07005661 break;
5662
5663 case eWNI_SME_AUTH_REQ:
5664 // __limProcessSmeAuthReq(pMac, pMsgBuf);
5665
5666 break;
5667
5668 case eWNI_SME_REASSOC_REQ:
5669 __limProcessSmeReassocReq(pMac, pMsgBuf);
5670
5671 break;
5672
5673 case eWNI_SME_PROMISCUOUS_MODE_REQ:
5674 //__limProcessSmePromiscuousReq(pMac, pMsgBuf);
5675
5676 break;
5677
5678 case eWNI_SME_DISASSOC_REQ:
5679 __limProcessSmeDisassocReq(pMac, pMsgBuf);
5680
5681 break;
5682
5683 case eWNI_SME_DISASSOC_CNF:
5684 case eWNI_SME_DEAUTH_CNF:
5685 __limProcessSmeDisassocCnf(pMac, pMsgBuf);
5686
5687 break;
5688
5689 case eWNI_SME_DEAUTH_REQ:
5690 __limProcessSmeDeauthReq(pMac, pMsgBuf);
5691
5692 break;
5693
Jeff Johnson295189b2012-06-20 16:38:30 -07005694
5695
5696 case eWNI_SME_SETCONTEXT_REQ:
5697 __limProcessSmeSetContextReq(pMac, pMsgBuf);
5698
5699 break;
5700
5701 case eWNI_SME_REMOVEKEY_REQ:
5702 __limProcessSmeRemoveKeyReq(pMac, pMsgBuf);
5703
5704 break;
5705
5706 case eWNI_SME_STOP_BSS_REQ:
5707 bufConsumed = __limProcessSmeStopBssReq(pMac, pMsg);
5708 break;
5709
5710 case eWNI_SME_ASSOC_CNF:
5711 case eWNI_SME_REASSOC_CNF:
5712 if (pMsg->type == eWNI_SME_ASSOC_CNF)
Abhishek Singh3cbf6052014-12-15 16:46:42 +05305713 limLog(pMac, LOG1, FL("Received ASSOC_CNF message"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005714 else
Abhishek Singh3cbf6052014-12-15 16:46:42 +05305715 limLog(pMac, LOG1, FL("Received REASSOC_CNF message"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005716 __limProcessSmeAssocCnfNew(pMac, pMsg->type, pMsgBuf);
5717 break;
5718
5719 case eWNI_SME_ADDTS_REQ:
Abhishek Singh3cbf6052014-12-15 16:46:42 +05305720 limLog(pMac, LOG1, FL("Received ADDTS_REQ message"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005721 __limProcessSmeAddtsReq(pMac, pMsgBuf);
5722 break;
5723
5724 case eWNI_SME_DELTS_REQ:
Abhishek Singh3cbf6052014-12-15 16:46:42 +05305725 limLog(pMac, LOG1, FL("Received DELTS_REQ message"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005726 __limProcessSmeDeltsReq(pMac, pMsgBuf);
5727 break;
5728
5729 case SIR_LIM_ADDTS_RSP_TIMEOUT:
Abhishek Singh3cbf6052014-12-15 16:46:42 +05305730 limLog(pMac, LOG1, FL("Received SIR_LIM_ADDTS_RSP_TIMEOUT message "));
Jeff Johnson295189b2012-06-20 16:38:30 -07005731 limProcessSmeAddtsRspTimeout(pMac, pMsg->bodyval);
5732 break;
5733
5734 case eWNI_SME_STA_STAT_REQ:
5735 case eWNI_SME_AGGR_STAT_REQ:
5736 case eWNI_SME_GLOBAL_STAT_REQ:
5737 case eWNI_SME_STAT_SUMM_REQ:
5738 __limProcessSmeStatsRequest( pMac, pMsgBuf);
5739 //HAL consumes pMsgBuf. It will be freed there. Set bufConsumed to false.
5740 bufConsumed = FALSE;
5741 break;
5742 case eWNI_SME_GET_STATISTICS_REQ:
5743 __limProcessSmeGetStatisticsRequest( pMac, pMsgBuf);
5744 //HAL consumes pMsgBuf. It will be freed there. Set bufConsumed to false.
5745 bufConsumed = FALSE;
5746 break;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005747#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08005748 case eWNI_SME_GET_ROAM_RSSI_REQ:
5749 __limProcessSmeGetRoamRssiRequest( pMac, pMsgBuf);
5750 //HAL consumes pMsgBuf. It will be freed there. Set bufConsumed to false.
5751 bufConsumed = FALSE;
5752 break;
5753#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005754#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005755 case eWNI_SME_GET_TSM_STATS_REQ:
5756 __limProcessSmeGetTsmStatsRequest( pMac, pMsgBuf);
5757 bufConsumed = FALSE;
5758 break;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005759#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Jeff Johnson295189b2012-06-20 16:38:30 -07005760 case eWNI_SME_DEL_BA_PEER_IND:
5761 limProcessSmeDelBaPeerInd(pMac, pMsgBuf);
5762 break;
5763 case eWNI_SME_GET_SCANNED_CHANNEL_REQ:
5764 limProcessSmeGetScanChannelInfo(pMac, pMsgBuf);
5765 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005766 case eWNI_SME_GET_ASSOC_STAS_REQ:
5767 limProcessSmeGetAssocSTAsInfo(pMac, pMsgBuf);
5768 break;
5769 case eWNI_SME_TKIP_CNTR_MEAS_REQ:
5770 limProcessTkipCounterMeasures(pMac, pMsgBuf);
5771 break;
5772
5773 case eWNI_SME_HIDE_SSID_REQ:
5774 __limProcessSmeHideSSID(pMac, pMsgBuf);
5775 break;
5776 case eWNI_SME_UPDATE_APWPSIE_REQ:
5777 __limProcessSmeUpdateAPWPSIEs(pMac, pMsgBuf);
5778 break;
5779 case eWNI_SME_GET_WPSPBC_SESSION_REQ:
5780 limProcessSmeGetWPSPBCSessions(pMac, pMsgBuf);
5781 break;
5782
5783 case eWNI_SME_SET_APWPARSNIEs_REQ:
5784 __limProcessSmeSetWPARSNIEs(pMac, pMsgBuf);
5785 break;
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08005786
5787 case eWNI_SME_CHNG_MCC_BEACON_INTERVAL:
5788 //Update the beaconInterval
5789 __limProcessSmeChangeBI(pMac, pMsgBuf );
5790 break;
Hardik Kantilal Patel62a3a762014-11-21 12:55:57 +05305791
5792#ifdef WLAN_FEATURE_AP_HT40_24G
5793 case eWNI_SME_SET_HT_2040_MODE:
5794 __limProcessSmeSetHT2040Mode(pMac, pMsgBuf);
5795 break;
5796#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005797
5798#if defined WLAN_FEATURE_VOWIFI
5799 case eWNI_SME_NEIGHBOR_REPORT_REQ_IND:
5800 case eWNI_SME_BEACON_REPORT_RESP_XMIT_IND:
5801 __limProcessReportMessage(pMac, pMsg);
5802 break;
5803#endif
5804
5805#if defined WLAN_FEATURE_VOWIFI_11R
5806 case eWNI_SME_FT_PRE_AUTH_REQ:
5807 bufConsumed = (tANI_BOOLEAN)limProcessFTPreAuthReq(pMac, pMsg);
5808 break;
5809 case eWNI_SME_FT_UPDATE_KEY:
5810 limProcessFTUpdateKey(pMac, pMsgBuf);
5811 break;
5812
5813 case eWNI_SME_FT_AGGR_QOS_REQ:
5814 limProcessFTAggrQosReq(pMac, pMsgBuf);
5815 break;
5816#endif
5817
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005818#if defined(FEATURE_WLAN_ESE) && !defined(FEATURE_WLAN_ESE_UPLOAD)
5819 case eWNI_SME_ESE_ADJACENT_AP_REPORT:
Jeff Johnson295189b2012-06-20 16:38:30 -07005820 limProcessAdjacentAPRepMsg ( pMac, pMsgBuf );
5821 break;
5822#endif
5823 case eWNI_SME_ADD_STA_SELF_REQ:
5824 __limProcessSmeAddStaSelfReq( pMac, pMsgBuf );
5825 break;
5826 case eWNI_SME_DEL_STA_SELF_REQ:
5827 __limProcessSmeDelStaSelfReq( pMac, pMsgBuf );
5828 break;
5829
Jeff Johnson295189b2012-06-20 16:38:30 -07005830 case eWNI_SME_REGISTER_MGMT_FRAME_REQ:
5831 __limProcessSmeRegisterMgmtFrameReq( pMac, pMsgBuf );
5832 break;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08005833#ifdef FEATURE_WLAN_TDLS
5834 case eWNI_SME_TDLS_SEND_MGMT_REQ:
5835 limProcessSmeTdlsMgmtSendReq(pMac, pMsgBuf);
5836 break;
5837 case eWNI_SME_TDLS_ADD_STA_REQ:
5838 limProcessSmeTdlsAddStaReq(pMac, pMsgBuf);
5839 break;
5840 case eWNI_SME_TDLS_DEL_STA_REQ:
5841 limProcessSmeTdlsDelStaReq(pMac, pMsgBuf);
5842 break;
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05305843 case eWNI_SME_TDLS_LINK_ESTABLISH_REQ:
5844 limProcesSmeTdlsLinkEstablishReq(pMac, pMsgBuf);
5845 break;
Atul Mittalc0f739f2014-07-31 13:47:47 +05305846// tdlsoffchan
5847 case eWNI_SME_TDLS_CHANNEL_SWITCH_REQ:
5848 limProcesSmeTdlsChanSwitchReq(pMac, pMsgBuf);
5849 break;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08005850#endif
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05305851 case eWNI_SME_RESET_AP_CAPS_CHANGED:
5852 __limProcessSmeResetApCapsChange(pMac, pMsgBuf);
5853 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005854
schang86c22c42013-03-13 18:41:24 -07005855 case eWNI_SME_SET_TX_POWER_REQ:
5856 limSendSetTxPowerReq(pMac, pMsgBuf);
5857 break ;
5858
Abhishek Singh00b71972016-01-07 10:51:04 +05305859#ifdef WLAN_FEATURE_RMC
5860 case eWNI_SME_ENABLE_RMC_REQ:
5861 limProcessRMCMessages(pMac, eLIM_RMC_ENABLE_REQ, pMsgBuf);
5862 break ;
5863
5864 case eWNI_SME_DISABLE_RMC_REQ:
5865 limProcessRMCMessages(pMac, eLIM_RMC_DISABLE_REQ, pMsgBuf);
5866 break ;
5867#endif /* WLAN_FEATURE_RMC */
5868
Siddharth Bhal6af5d4e2014-09-29 21:11:16 +05305869 case eWNI_SME_MAC_SPOOF_ADDR_IND:
5870 __limProcessSmeSpoofMacAddrRequest(pMac, pMsgBuf);
5871 break ;
Abhishek Singh7d624e12015-11-30 14:29:27 +05305872 case eWNI_SME_REGISTER_MGMT_FRAME_CB:
5873 lim_register_mgmt_frame_ind_cb(pMac, pMsgBuf);
5874 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005875 default:
5876 vos_mem_free((v_VOID_t*)pMsg->bodyptr);
5877 pMsg->bodyptr = NULL;
5878 break;
5879 } // switch (msgType)
5880
5881 return bufConsumed;
5882} /*** end limProcessSmeReqMessages() ***/