blob: d3925fca2382153cbacc38985a5579242661611b [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Abhishek Singh46310652018-01-03 17:52:03 +05302 * Copyright (c) 2012-2018 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"
Abhishek Singh46310652018-01-03 17:52:03 +053061#include "limSessionUtils.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070062
Abhishek Singh00b71972016-01-07 10:51:04 +053063#ifdef WLAN_FEATURE_RMC
64#include "limRMC.h"
65#endif
66
Jeff Johnson295189b2012-06-20 16:38:30 -070067#include "sapApi.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070068
69#if defined WLAN_FEATURE_VOWIFI
70#include "rrmApi.h"
71#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080072#if defined(FEATURE_WLAN_ESE) && !defined(FEATURE_WLAN_ESE_UPLOAD)
73#include "eseApi.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070074#endif
75
76#if defined WLAN_FEATURE_VOWIFI_11R
77#include <limFT.h>
78#endif
79
Padma, Santhosh Kumar67f479b2016-12-28 15:43:42 +053080#ifdef WLAN_FEATURE_LFR_MBB
81#include "lim_mbb.h"
82#endif
83
Jeff Johnson295189b2012-06-20 16:38:30 -070084
Abhishek Singh6e8ca792017-11-30 15:43:22 +053085#define JOIN_FAILURE_TIMEOUT 300 // in msecs
Viral Modid86bde22012-12-10 13:09:21 -080086/* This overhead is time for sending NOA start to host in case of GO/sending NULL data & receiving ACK
87 * 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 -080088 * taking care of sending null data and receiving ACK to/from AP/Also SetChannel with calibration is taking
89 * around 7ms .
Viral Modid86bde22012-12-10 13:09:21 -080090 */
Viral Modid440e682013-03-06 02:25:31 -080091#define SCAN_MESSAGING_OVERHEAD 20 // in msecs
92#define JOIN_NOA_DURATION 2000 // in msecs
93#define OEM_DATA_NOA_DURATION 60 // in msecs
94#define DEFAULT_PASSIVE_MAX_CHANNEL_TIME 110 // in msecs
Jeff Johnson295189b2012-06-20 16:38:30 -070095
Gopichand Nakkala096a1052012-12-21 07:05:34 -080096#define CONV_MS_TO_US 1024 //conversion factor from ms to us
97
Jeff Johnson295189b2012-06-20 16:38:30 -070098// SME REQ processing function templates
99static void __limProcessSmeStartReq(tpAniSirGlobal, tANI_U32 *);
100static tANI_BOOLEAN __limProcessSmeSysReadyInd(tpAniSirGlobal, tANI_U32 *);
101static tANI_BOOLEAN __limProcessSmeStartBssReq(tpAniSirGlobal, tpSirMsgQ pMsg);
Viral Modid440e682013-03-06 02:25:31 -0800102static void __limProcessSmeScanReq(tpAniSirGlobal, tANI_U32 *);
Jeff Johnson295189b2012-06-20 16:38:30 -0700103static void __limProcessSmeJoinReq(tpAniSirGlobal, tANI_U32 *);
104static void __limProcessSmeReassocReq(tpAniSirGlobal, tANI_U32 *);
105static void __limProcessSmeDisassocReq(tpAniSirGlobal, tANI_U32 *);
106static void __limProcessSmeDisassocCnf(tpAniSirGlobal, tANI_U32 *);
107static void __limProcessSmeDeauthReq(tpAniSirGlobal, tANI_U32 *);
108static void __limProcessSmeSetContextReq(tpAniSirGlobal, tANI_U32 *);
109static tANI_BOOLEAN __limProcessSmeStopBssReq(tpAniSirGlobal, tpSirMsgQ pMsg);
110
Jeff Johnson295189b2012-06-20 16:38:30 -0700111void __limProcessSmeAssocCnfNew(tpAniSirGlobal, tANI_U32, tANI_U32 *);
112
Jeff Johnson295189b2012-06-20 16:38:30 -0700113extern void peRegisterTLHandle(tpAniSirGlobal pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -0700114
Jeff Johnson295189b2012-06-20 16:38:30 -0700115
Jeff Johnson295189b2012-06-20 16:38:30 -0700116#ifdef BACKGROUND_SCAN_ENABLED
117
118// start the background scan timers if it hasn't already started
119static void
120__limBackgroundScanInitiate(tpAniSirGlobal pMac)
121{
122 if (pMac->lim.gLimBackgroundScanStarted)
123 return;
124
125 //make sure timer is created first
126 if (TX_TIMER_VALID(pMac->lim.limTimers.gLimBackgroundScanTimer))
127 {
128 limDeactivateAndChangeTimer(pMac, eLIM_BACKGROUND_SCAN_TIMER);
Jeff Johnsone7245742012-09-05 17:12:55 -0700129 MTRACE(macTrace(pMac, TRACE_CODE_TIMER_ACTIVATE, NO_SESSION, eLIM_BACKGROUND_SCAN_TIMER));
Jeff Johnson295189b2012-06-20 16:38:30 -0700130 if (tx_timer_activate(&pMac->lim.limTimers.gLimBackgroundScanTimer) != TX_SUCCESS)
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700131 limLog(pMac, LOGP, FL("could not activate background scan timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700132 pMac->lim.gLimBackgroundScanStarted = true;
133 pMac->lim.gLimBackgroundScanChannelId = 0;
134 }
135}
136
137#endif // BACKGROUND_SCAN_ENABLED
Jeff Johnson295189b2012-06-20 16:38:30 -0700138
139// determine if a fresh scan request must be issued or not
140/*
141* PE will do fresh scan, if all of the active sessions are in good state (Link Est or BSS Started)
142* If one of the sessions is not in one of the above states, then PE does not do fresh scan
143* If no session exists (scanning very first time), then PE will always do fresh scan if SME
144* asks it to do that.
145*/
146static tANI_U8
147__limFreshScanReqd(tpAniSirGlobal pMac, tANI_U8 returnFreshResults)
148{
149
150 tANI_U8 validState = TRUE;
151 int i;
152
153 if(pMac->lim.gLimSmeState != eLIM_SME_IDLE_STATE)
154 {
Sushant Kaushik59e6f362015-08-11 15:41:00 +0530155 limLog(pMac, LOG1, FL("setting fresh scan as false. sme state is %d"),
156 pMac->lim.gLimSmeState);
Jeff Johnson295189b2012-06-20 16:38:30 -0700157 return FALSE;
158 }
159 for(i =0; i < pMac->lim.maxBssId; i++)
160 {
161
162 if(pMac->lim.gpSession[i].valid == TRUE)
163 {
164 if(!( ( ( (pMac->lim.gpSession[i].bssType == eSIR_INFRASTRUCTURE_MODE) ||
165 (pMac->lim.gpSession[i].limSystemRole == eLIM_BT_AMP_STA_ROLE))&&
166 (pMac->lim.gpSession[i].limSmeState == eLIM_SME_LINK_EST_STATE) )||
167
168 ( ( (pMac->lim.gpSession[i].bssType == eSIR_IBSS_MODE)||
169 (pMac->lim.gpSession[i].limSystemRole == eLIM_BT_AMP_AP_ROLE)||
170 (pMac->lim.gpSession[i].limSystemRole == eLIM_BT_AMP_STA_ROLE) )&&
171 (pMac->lim.gpSession[i].limSmeState == eLIM_SME_NORMAL_STATE) )
Jeff Johnson295189b2012-06-20 16:38:30 -0700172 || ( ( ( (pMac->lim.gpSession[i].bssType == eSIR_INFRA_AP_MODE)
173 && ( pMac->lim.gpSession[i].pePersona == VOS_P2P_GO_MODE) )
174 || (pMac->lim.gpSession[i].limSystemRole == eLIM_AP_ROLE) )
175 && (pMac->lim.gpSession[i].limSmeState == eLIM_SME_NORMAL_STATE) )
Jeff Johnson295189b2012-06-20 16:38:30 -0700176 ))
177 {
178 validState = FALSE;
Sushant Kaushik59e6f362015-08-11 15:41:00 +0530179 limLog(pMac, LOG1, FL("setting fresh scan as false."
180 "bssType is %d system role is %d, smestate is %d"),
181 pMac->lim.gpSession[i].bssType,
182 pMac->lim.gpSession[i].limSystemRole,
183 pMac->lim.gpSession[i].limSmeState);
Jeff Johnson295189b2012-06-20 16:38:30 -0700184 break;
185 }
186
187 }
188 }
Rashmi Ramanna6c13a342014-01-07 11:44:07 +0530189 limLog(pMac, LOG1, FL("FreshScanReqd: %d "), validState);
Jeff Johnson295189b2012-06-20 16:38:30 -0700190
191 if( (validState) && (returnFreshResults & SIR_BG_SCAN_RETURN_FRESH_RESULTS))
192 return TRUE;
193
194 return FALSE;
195}
196
Jeff Johnson295189b2012-06-20 16:38:30 -0700197
198
199/**
200 * __limIsSmeAssocCnfValid()
201 *
202 *FUNCTION:
203 * This function is called by limProcessLmmMessages() upon
204 * receiving SME_ASSOC_CNF.
205 *
206 *LOGIC:
207 * Message validity checks are performed in this function
208 *
209 *ASSUMPTIONS:
210 *
211 *NOTE:
212 *
213 * @param pMeasReq Pointer to Received ASSOC_CNF message
214 * @return true When received SME_ASSOC_CNF is formatted
215 * correctly
216 * false otherwise
217 */
218
219inline static tANI_U8
220__limIsSmeAssocCnfValid(tpSirSmeAssocCnf pAssocCnf)
221{
222 if (limIsGroupAddr(pAssocCnf->peerMacAddr))
223 return false;
224 else
225 return true;
226} /*** end __limIsSmeAssocCnfValid() ***/
227
228
229/**
230 * __limGetSmeJoinReqSizeForAlloc()
231 *
232 *FUNCTION:
233 * This function is called in various places to get IE length
234 * from tSirBssDescription structure
235 * number being scanned.
236 *
237 *PARAMS:
238 *
239 *LOGIC:
240 *
241 *ASSUMPTIONS:
242 * NA
243 *
244 *NOTE:
245 * NA
246 *
247 * @param pBssDescr
248 * @return Total IE length
249 */
250
Padma, Santhosh Kumarf4966dc2017-01-03 18:56:00 +0530251tANI_U16
Jeff Johnson295189b2012-06-20 16:38:30 -0700252__limGetSmeJoinReqSizeForAlloc(tANI_U8 *pBuf)
253{
254 tANI_U16 len = 0;
255
256 if (!pBuf)
257 return len;
258
259 pBuf += sizeof(tANI_U16);
260 len = limGetU16( pBuf );
261 return (len + sizeof( tANI_U16 ));
262} /*** end __limGetSmeJoinReqSizeForAlloc() ***/
263
264
265/**----------------------------------------------------------------
266\fn __limIsDeferedMsgForLearn
267
268\brief Has role only if 11h is enabled. Not used on STA side.
269 Defers the message if SME is in learn state and brings
270 the LIM back to normal mode.
271
272\param pMac
273\param pMsg - Pointer to message posted from SME to LIM.
274\return TRUE - If defered
275 FALSE - Otherwise
276------------------------------------------------------------------*/
277static tANI_BOOLEAN
278__limIsDeferedMsgForLearn(tpAniSirGlobal pMac, tpSirMsgQ pMsg)
279{
280 if (limIsSystemInScanState(pMac))
281 {
282 if (limDeferMsg(pMac, pMsg) != TX_SUCCESS)
283 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700284 PELOGE(limLog(pMac, LOGE, FL("Could not defer Msg = %d"), pMsg->type);)
Jeff Johnson295189b2012-06-20 16:38:30 -0700285 return eANI_BOOLEAN_FALSE;
286 }
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700287 PELOG1(limLog(pMac, LOG1, FL("Defer the message, in learn mode type = %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -0700288 pMsg->type);)
289
290 /** Send finish scan req to HAL only if LIM is not waiting for any response
291 * from HAL like init scan rsp, start scan rsp etc.
292 */
293 if (GET_LIM_PROCESS_DEFD_MESGS(pMac))
294 {
295 //Set the resume channel to Any valid channel (invalid).
296 //This will instruct HAL to set it to any previous valid channel.
297 peSetResumeChannel(pMac, 0, 0);
298 limSendHalFinishScanReq(pMac, eLIM_HAL_FINISH_LEARN_WAIT_STATE);
299 }
300
301 return eANI_BOOLEAN_TRUE;
302 }
303 return eANI_BOOLEAN_FALSE;
304}
305
306/**----------------------------------------------------------------
307\fn __limIsDeferedMsgForRadar
308
309\brief Has role only if 11h is enabled. Not used on STA side.
310 Defers the message if radar is detected.
311
312\param pMac
313\param pMsg - Pointer to message posted from SME to LIM.
314\return TRUE - If defered
315 FALSE - Otherwise
316------------------------------------------------------------------*/
317static tANI_BOOLEAN
318__limIsDeferedMsgForRadar(tpAniSirGlobal pMac, tpSirMsgQ pMsg)
319{
320 /** fRadarDetCurOperChan will be set only if we detect radar in current
321 * operating channel and System Role == AP ROLE */
Jeff Johnsone7245742012-09-05 17:12:55 -0700322 //TODO: Need to take care radar detection.
323 //if (LIM_IS_RADAR_DETECTED(pMac))
324 if( 0 )
Jeff Johnson295189b2012-06-20 16:38:30 -0700325 {
326 if (limDeferMsg(pMac, pMsg) != TX_SUCCESS)
327 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700328 PELOGE(limLog(pMac, LOGE, FL("Could not defer Msg = %d"), pMsg->type);)
Jeff Johnson295189b2012-06-20 16:38:30 -0700329 return eANI_BOOLEAN_FALSE;
330 }
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700331 PELOG1(limLog(pMac, LOG1, FL("Defer the message, in learn mode type = %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -0700332 pMsg->type);)
333 return eANI_BOOLEAN_TRUE;
334 }
335 return eANI_BOOLEAN_FALSE;
336}
337
338
339/**
340 * __limProcessSmeStartReq()
341 *
342 *FUNCTION:
343 * This function is called to process SME_START_REQ message
344 * from HDD or upper layer application.
345 *
346 *LOGIC:
347 *
348 *ASSUMPTIONS:
349 *
350 *NOTE:
351 *
352 * @param pMac Pointer to Global MAC structure
353 * @param *pMsgBuf A pointer to the SME message buffer
354 * @return None
355 */
356
357static void
358__limProcessSmeStartReq(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
359{
360 tSirResultCodes retCode = eSIR_SME_SUCCESS;
361 tANI_U8 smesessionId;
362 tANI_U16 smetransactionId;
363
364
Abhishek Singh3cbf6052014-12-15 16:46:42 +0530365 limLog(pMac, LOG1, FL("Received SME_START_REQ"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700366
367 limGetSessionInfo(pMac,(tANI_U8 *)pMsgBuf,&smesessionId,&smetransactionId);
368
369 if (pMac->lim.gLimSmeState == eLIM_SME_OFFLINE_STATE)
370 {
371 pMac->lim.gLimSmeState = eLIM_SME_IDLE_STATE;
372
Jeff Johnsone7245742012-09-05 17:12:55 -0700373 MTRACE(macTrace(pMac, TRACE_CODE_SME_STATE, NO_SESSION, pMac->lim.gLimSmeState));
Jeff Johnson295189b2012-06-20 16:38:30 -0700374
375 /// By default do not return after first scan match
376 pMac->lim.gLimReturnAfterFirstMatch = 0;
377
378 /// Initialize MLM state machine
379 limInitMlm(pMac);
380
381 /// By default return unique scan results
382 pMac->lim.gLimReturnUniqueResults = true;
383 pMac->lim.gLimSmeScanResultLength = 0;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -0700384#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
385 pMac->lim.gLimSmeLfrScanResultLength = 0;
386#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700387
Jeff Johnson295189b2012-06-20 16:38:30 -0700388 if (((tSirSmeStartReq *) pMsgBuf)->sendNewBssInd)
389 {
390 /*
391 * Need to indicate new BSSs found during background scanning to
392 * host. Update this parameter at CFG
393 */
394 if (cfgSetInt(pMac, WNI_CFG_NEW_BSS_FOUND_IND, ((tSirSmeStartReq *) pMsgBuf)->sendNewBssInd)
395 != eSIR_SUCCESS)
396 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -0700397 limLog(pMac, LOGP, FL("could not set NEIGHBOR_BSS_IND at CFG"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700398 retCode = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
399 }
400 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700401 }
402 else
403 {
404 /**
405 * Should not have received eWNI_SME_START_REQ in states
406 * other than OFFLINE. Return response to host and
407 * log error
408 */
Sushant Kaushik1b645382014-10-13 16:39:36 +0530409 limLog(pMac, LOGE, FL("Invalid SME_START_REQ received in SME state %d"),pMac->lim.gLimSmeState );
Jeff Johnson295189b2012-06-20 16:38:30 -0700410 limPrintSmeState(pMac, LOGE, pMac->lim.gLimSmeState);
411 retCode = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
412 }
413 limSendSmeRsp(pMac, eWNI_SME_START_RSP, retCode,smesessionId,smetransactionId);
414} /*** end __limProcessSmeStartReq() ***/
415
416
417/** -------------------------------------------------------------
418\fn __limProcessSmeSysReadyInd
419\brief handles the notification from HDD. PE just forwards this message to HAL.
420\param tpAniSirGlobal pMac
421\param tANI_U32* pMsgBuf
422\return TRUE-Posting to HAL failed, so PE will consume the buffer.
423\ FALSE-Posting to HAL successful, so HAL will consume the buffer.
424 -------------------------------------------------------------*/
425static tANI_BOOLEAN
426__limProcessSmeSysReadyInd(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
427{
428 tSirMsgQ msg;
Abhinav Kumarc00a7842018-06-13 16:07:31 +0530429 tSirSmeReadyReq *ready_req = (tSirSmeReadyReq *) pMsgBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -0700430
431 msg.type = WDA_SYS_READY_IND;
432 msg.reserved = 0;
433 msg.bodyptr = pMsgBuf;
434 msg.bodyval = 0;
435
Jeff Johnson92751692013-03-06 16:00:33 -0800436 if (pMac->gDriverType != eDRIVER_TYPE_MFG)
Jeff Johnson295189b2012-06-20 16:38:30 -0700437 {
Jeff Johnson92751692013-03-06 16:00:33 -0800438 peRegisterTLHandle(pMac);
Abhinav Kumarc00a7842018-06-13 16:07:31 +0530439 pMac->lim.sme_msg_callback = ready_req->sme_msg_cb;
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;
Abhinav Kumarec306c62018-02-26 17:31:49 +05301126 if (pScanReq->channelList.numChannels > SIR_ESE_MAX_MEAS_IE_REQS)
1127 pScanReq->channelList.numChannels = SIR_ESE_MAX_MEAS_IE_REQS;
Ganesh Kondabattinif0fa07c2013-06-11 17:47:49 +05301128
1129 /* The tSirScanOffloadReq will reserve the space for first channel,
1130 so allocate the memory for (numChannels - 1) and uIEFieldLen */
1131 len = sizeof(tSirScanOffloadReq) + (pScanReq->channelList.numChannels - 1) +
1132 pScanReq->uIEFieldLen;
1133
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301134 pScanOffloadReq = vos_mem_malloc(len);
1135 if ( NULL == pScanOffloadReq )
Ganesh Kondabattinif0fa07c2013-06-11 17:47:49 +05301136 {
1137 limLog(pMac, LOGE,
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301138 FL("AllocateMemory failed for pScanOffloadReq"));
Ganesh Kondabattinif0fa07c2013-06-11 17:47:49 +05301139 return eHAL_STATUS_FAILURE;
1140 }
1141
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301142 vos_mem_set( (tANI_U8 *) pScanOffloadReq, len, 0);
Ganesh Kondabattinif0fa07c2013-06-11 17:47:49 +05301143
1144 msg.type = WDA_START_SCAN_OFFLOAD_REQ;
1145 msg.bodyptr = pScanOffloadReq;
1146 msg.bodyval = 0;
1147
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301148 vos_mem_copy((tANI_U8 *) pScanOffloadReq->bssId,
Ganesh Kondabattinif0fa07c2013-06-11 17:47:49 +05301149 (tANI_U8*) pScanReq->bssId,
1150 sizeof(tSirMacAddr));
1151
1152 if (pScanReq->numSsid > SIR_SCAN_MAX_NUM_SSID)
1153 {
1154 limLog(pMac, LOGE,
1155 FL("Invalid value (%d) for numSsid"), SIR_SCAN_MAX_NUM_SSID);
Kiet Lamb1233192013-11-28 13:38:20 +05301156 vos_mem_free (pScanOffloadReq);
Ganesh Kondabattinif0fa07c2013-06-11 17:47:49 +05301157 return eHAL_STATUS_FAILURE;
1158 }
1159
1160 pScanOffloadReq->numSsid = pScanReq->numSsid;
1161 for (i = 0; i < pScanOffloadReq->numSsid; i++)
1162 {
1163 pScanOffloadReq->ssId[i].length = pScanReq->ssId[i].length;
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301164 vos_mem_copy((tANI_U8 *) pScanOffloadReq->ssId[i].ssId,
Ganesh Kondabattinif0fa07c2013-06-11 17:47:49 +05301165 (tANI_U8 *) pScanReq->ssId[i].ssId,
1166 pScanOffloadReq->ssId[i].length);
1167 }
1168
1169 pScanOffloadReq->hiddenSsid = pScanReq->hiddenSsid;
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301170 vos_mem_copy((tANI_U8 *) pScanOffloadReq->selfMacAddr,
Ganesh Kondabattinif0fa07c2013-06-11 17:47:49 +05301171 (tANI_U8 *) pScanReq->selfMacAddr,
1172 sizeof(tSirMacAddr));
1173 pScanOffloadReq->bssType = pScanReq->bssType;
1174 pScanOffloadReq->dot11mode = pScanReq->dot11mode;
1175 pScanOffloadReq->scanType = pScanReq->scanType;
1176 pScanOffloadReq->minChannelTime = pScanReq->minChannelTime;
1177 pScanOffloadReq->maxChannelTime = pScanReq->maxChannelTime;
1178 pScanOffloadReq->p2pSearch = pScanReq->p2pSearch;
1179 pScanOffloadReq->sessionId = pScanReq->sessionId;
1180 pScanOffloadReq->channelList.numChannels =
1181 pScanReq->channelList.numChannels;
1182 p = &(pScanOffloadReq->channelList.channelNumber[0]);
1183 for (i = 0; i < pScanOffloadReq->channelList.numChannels; i++)
1184 p[i] = pScanReq->channelList.channelNumber[i];
1185
1186 pScanOffloadReq->uIEFieldLen = pScanReq->uIEFieldLen;
1187 pScanOffloadReq->uIEFieldOffset = len - pScanOffloadReq->uIEFieldLen;
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301188 vos_mem_copy((tANI_U8 *) p + i,
Ganesh Kondabattinif0fa07c2013-06-11 17:47:49 +05301189 (tANI_U8 *) pScanReq + pScanReq->uIEFieldOffset,
1190 pScanOffloadReq->uIEFieldLen);
1191
1192 rc = wdaPostCtrlMsg(pMac, &msg);
1193 if (rc != eSIR_SUCCESS)
1194 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001195 limLog(pMac, LOGE, FL("wdaPostCtrlMsg() return failure"));
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301196 vos_mem_free(pScanOffloadReq);
Ganesh Kondabattinif0fa07c2013-06-11 17:47:49 +05301197 return eHAL_STATUS_FAILURE;
1198 }
Rashmi Ramanna6c13a342014-01-07 11:44:07 +05301199 limLog(pMac, LOG1, FL("Processed Offload Scan Request Successfully"));
Ganesh Kondabattinif0fa07c2013-06-11 17:47:49 +05301200
1201 return eHAL_STATUS_SUCCESS;
1202}
Jeff Johnson295189b2012-06-20 16:38:30 -07001203
1204/**
1205 * __limProcessSmeScanReq()
1206 *
1207 *FUNCTION:
1208 * This function is called to process SME_SCAN_REQ message
1209 * from HDD or upper layer application.
1210 *
1211 *LOGIC:
1212 *
1213 *ASSUMPTIONS:
1214 *
1215 *NOTE:
1216 * 1. Periodic scanning should be requesting to return unique
1217 * scan results.
1218 *
1219 * @param pMac Pointer to Global MAC structure
1220 * @param *pMsgBuf A pointer to the SME message buffer
1221 * @return None
1222 */
1223
Viral Modid440e682013-03-06 02:25:31 -08001224static void
Jeff Johnson295189b2012-06-20 16:38:30 -07001225__limProcessSmeScanReq(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
1226{
1227 tANI_U32 len;
1228 tLimMlmScanReq *pMlmScanReq;
1229 tpSirSmeScanReq pScanReq;
1230 tANI_U8 i = 0;
1231
Sushant Kaushikb97a0082015-08-31 12:36:45 +05301232#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM //FEATURE_WLAN_DIAG_SUPPORT
Jeff Johnson295189b2012-06-20 16:38:30 -07001233 limDiagEventReport(pMac, WLAN_PE_DIAG_SCAN_REQ_EVENT, NULL, 0, 0);
1234#endif //FEATURE_WLAN_DIAG_SUPPORT
1235
1236 pScanReq = (tpSirSmeScanReq) pMsgBuf;
Sushant Kaushike0d2cce2014-04-10 14:36:07 +05301237 limLog(pMac, LOG1,FL("SME SCAN REQ numChan %d min %d max %d IELen %d"
1238 "first %d fresh %d unique %d type %s (%d)"
1239 " mode %s (%d)rsp %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07001240 pScanReq->channelList.numChannels,
1241 pScanReq->minChannelTime,
1242 pScanReq->maxChannelTime,
1243 pScanReq->uIEFieldLen,
1244 pScanReq->returnAfterFirstMatch,
1245 pScanReq->returnFreshResults,
1246 pScanReq->returnUniqueResults,
Sushant Kaushike0d2cce2014-04-10 14:36:07 +05301247 lim_ScanTypetoString(pScanReq->scanType),
Madan Mohan Koyyalamudi70bb4cb2012-10-18 19:31:25 -07001248 pScanReq->scanType,
Sushant Kaushike0d2cce2014-04-10 14:36:07 +05301249 lim_BackgroundScanModetoString(pScanReq->backgroundScanMode),
1250 pScanReq->backgroundScanMode, pMac->lim.gLimRspReqd ? 1 : 0);
Viral Modid86bde22012-12-10 13:09:21 -08001251
1252 /* Since scan req always requires a response, we will overwrite response required here.
1253 * This is added esp to take care of the condition where in p2p go case, we hold the scan req and
1254 * insert single NOA. We send the held scan request to FW later on getting start NOA ind from FW so
1255 * we lose state of the gLimRspReqd flag for the scan req if any other request comes by then.
1256 * e.g. While unit testing, we found when insert single NOA is done, we see a get stats request which turns the flag
1257 * gLimRspReqd to FALSE; now when we actually start the saved scan req for init scan after getting
1258 * NOA started, the gLimRspReqd being a global flag is showing FALSE instead of TRUE value for
1259 * this saved scan req. Since all scan reqs coming to lim require a response, there is no harm in setting
1260 * the global flag gLimRspReqd to TRUE here.
1261 */
1262 pMac->lim.gLimRspReqd = TRUE;
1263
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301264 /*copy the Self MAC address from SmeReq to the globalplace, used for sending probe req*/
Jeff Johnson295189b2012-06-20 16:38:30 -07001265 sirCopyMacAddr(pMac->lim.gSelfMacAddr, pScanReq->selfMacAddr);
1266
Abhishek Singhdaf95742015-10-13 14:53:21 +05301267 /* Check if scan req is not valid or link is already suspended*/
Abhishek Singh46310652018-01-03 17:52:03 +05301268 if (!limIsSmeScanReqValid(pMac, pScanReq) ||
1269 limIsLinkSuspended(pMac) || limIsChanSwitchRunning(pMac))
Jeff Johnson295189b2012-06-20 16:38:30 -07001270 {
Abhishek Singhdaf95742015-10-13 14:53:21 +05301271 limLog(pMac, LOGE,
Abhishek Singh46310652018-01-03 17:52:03 +05301272 FL("Received SME_SCAN_REQ with invalid params or link is suspended %d limIsChanSwitchRunning %d"),
1273 limIsLinkSuspended(pMac), limIsChanSwitchRunning(pMac));
Jeff Johnson295189b2012-06-20 16:38:30 -07001274
1275 if (pMac->lim.gLimRspReqd)
1276 {
1277 pMac->lim.gLimRspReqd = false;
1278
1279 limSendSmeScanRsp(pMac, sizeof(tSirSmeScanRsp), eSIR_SME_INVALID_PARAMETERS, pScanReq->sessionId, pScanReq->transactionId);
1280
1281 } // if (pMac->lim.gLimRspReqd)
1282
1283 return;
1284 }
1285
1286 //if scan is disabled then return as invalid scan request.
1287 //if scan in power save is disabled, and system is in power save mode, then ignore scan request.
1288 if( (pMac->lim.fScanDisabled) || (!pMac->lim.gScanInPowersave && !limIsSystemInActiveState(pMac)) )
1289 {
Rashmi Ramanna6c13a342014-01-07 11:44:07 +05301290 limLog(pMac, LOGE, FL("SCAN is disabled or SCAN in power save"
1291 " is disabled and system is in power save."));
Leela V Kiran Kumar Reddy Chirala6a458752013-02-16 15:41:27 -08001292 limSendSmeScanRsp(pMac, offsetof(tSirSmeScanRsp,bssDescription[0]), eSIR_SME_INVALID_PARAMETERS, pScanReq->sessionId, pScanReq->transactionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07001293 return;
1294 }
1295
1296
1297 /**
1298 * If scan request is received in idle, joinFailed
1299 * states or in link established state (in STA role)
1300 * or in normal state (in STA-in-IBSS/AP role) with
1301 * 'return fresh scan results' request from HDD or
1302 * it is periodic background scanning request,
1303 * trigger fresh scan request to MLM
1304 */
1305 if (__limFreshScanReqd(pMac, pScanReq->returnFreshResults))
1306 {
Ganesh Kondabattinif0fa07c2013-06-11 17:47:49 +05301307 if (pScanReq->returnFreshResults & SIR_BG_SCAN_PURGE_RESUTLS)
1308 {
1309 // Discard previously cached scan results
1310 limReInitScanResults(pMac);
1311 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001312
Ganesh Kondabattinif0fa07c2013-06-11 17:47:49 +05301313 pMac->lim.gLim24Band11dScanDone = 0;
1314 pMac->lim.gLim50Band11dScanDone = 0;
1315 pMac->lim.gLimReturnAfterFirstMatch =
1316 pScanReq->returnAfterFirstMatch;
1317 pMac->lim.gLimBackgroundScanMode =
1318 pScanReq->backgroundScanMode;
Jeff Johnson295189b2012-06-20 16:38:30 -07001319
Ganesh Kondabattinif0fa07c2013-06-11 17:47:49 +05301320 pMac->lim.gLimReturnUniqueResults =
1321 ((pScanReq->returnUniqueResults) > 0 ? true : false);
1322 /* De-activate Heartbeat timers for connected sessions while
1323 * scan is in progress if the system is in Active mode *
1324 * AND it is not a ROAMING ("background") scan */
1325 if(((ePMM_STATE_BMPS_WAKEUP == pMac->pmm.gPmmState) ||
1326 (ePMM_STATE_READY == pMac->pmm.gPmmState)) &&
1327 (pScanReq->backgroundScanMode != eSIR_ROAMING_SCAN ) &&
1328 (!IS_ACTIVEMODE_OFFLOAD_FEATURE_ENABLE))
1329 {
Jeff Johnson295189b2012-06-20 16:38:30 -07001330 for(i=0;i<pMac->lim.maxBssId;i++)
1331 {
Ganesh Kondabattinif0fa07c2013-06-11 17:47:49 +05301332 if((peFindSessionBySessionId(pMac,i) != NULL) &&
1333 (pMac->lim.gpSession[i].valid == TRUE) &&
1334 (eLIM_MLM_LINK_ESTABLISHED_STATE == pMac->lim.gpSession[i].limMlmState))
1335 {
1336 limHeartBeatDeactivateAndChangeTimer(pMac, peFindSessionBySessionId(pMac,i));
1337 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001338 }
Ganesh Kondabattinif0fa07c2013-06-11 17:47:49 +05301339 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001340
Ganesh Kondabattinif0fa07c2013-06-11 17:47:49 +05301341 if (pMac->fScanOffload)
1342 {
1343 if (eHAL_STATUS_SUCCESS !=
1344 limSendHalStartScanOffloadReq(pMac, pScanReq))
1345 {
Rashmi Ramanna6c13a342014-01-07 11:44:07 +05301346 limLog(pMac, LOGE, FL("Couldn't send Offload scan request"));
Ganesh Kondabattinif0fa07c2013-06-11 17:47:49 +05301347 limSendSmeScanRsp(pMac,
1348 offsetof(tSirSmeScanRsp, bssDescription[0]),
1349 eSIR_SME_INVALID_PARAMETERS,
1350 pScanReq->sessionId,
1351 pScanReq->transactionId);
1352 return;
1353 }
1354 }
1355 else
1356 {
1357
1358 /*Change Global SME state */
1359 /* Store the previous SME state */
Rashmi Ramanna6c13a342014-01-07 11:44:07 +05301360 limLog(pMac, LOG1, FL("Non Offload SCAN request "));
Ganesh Kondabattinif0fa07c2013-06-11 17:47:49 +05301361 pMac->lim.gLimPrevSmeState = pMac->lim.gLimSmeState;
1362 pMac->lim.gLimSmeState = eLIM_SME_WT_SCAN_STATE;
1363 MTRACE(macTrace(pMac, TRACE_CODE_SME_STATE, pScanReq->sessionId, pMac->lim.gLimSmeState));
1364
1365 if (pScanReq->channelList.numChannels == 0)
1366 {
1367 tANI_U32 cfg_len;
Rashmi Ramanna6c13a342014-01-07 11:44:07 +05301368
1369 limLog(pMac, LOG1,
1370 FL("Scan all channels as Number of channels is 0"));
Ganesh Kondabattinif0fa07c2013-06-11 17:47:49 +05301371 // Scan all channels
1372 len = sizeof(tLimMlmScanReq) +
Jeff Johnson295189b2012-06-20 16:38:30 -07001373 (sizeof( pScanReq->channelList.channelNumber ) * (WNI_CFG_VALID_CHANNEL_LIST_LEN - 1)) +
1374 pScanReq->uIEFieldLen;
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301375 pMlmScanReq = vos_mem_malloc(len);
1376 if ( NULL == pMlmScanReq )
Ganesh Kondabattinif0fa07c2013-06-11 17:47:49 +05301377 {
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301378 // Log error
1379 limLog(pMac, LOGP,
1380 FL("call to AllocateMemory failed for mlmScanReq (%d)"), len);
Jeff Johnson295189b2012-06-20 16:38:30 -07001381
Padma, Santhosh Kumar8fa85212015-02-18 12:24:56 +05301382 if (pMac->lim.gLimRspReqd)
1383 {
1384 pMac->lim.gLimRspReqd = false;
1385
1386 limSendSmeScanRsp(pMac, sizeof(tSirSmeScanRsp),
1387 eSIR_SME_RESOURCES_UNAVAILABLE,
1388 pScanReq->sessionId,
1389 pScanReq->transactionId);
1390 }
1391
Ganesh Kondabattinif0fa07c2013-06-11 17:47:49 +05301392 return;
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301393 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001394
Ganesh Kondabattinif0fa07c2013-06-11 17:47:49 +05301395 // Initialize this buffer
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301396 vos_mem_set( (tANI_U8 *) pMlmScanReq, len, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07001397
Ganesh Kondabattinif0fa07c2013-06-11 17:47:49 +05301398 cfg_len = WNI_CFG_VALID_CHANNEL_LIST_LEN;
1399 if (wlan_cfgGetStr(pMac, WNI_CFG_VALID_CHANNEL_LIST,
Jeff Johnson295189b2012-06-20 16:38:30 -07001400 pMlmScanReq->channelList.channelNumber,
1401 &cfg_len) != eSIR_SUCCESS)
Ganesh Kondabattinif0fa07c2013-06-11 17:47:49 +05301402 {
1403 /**
1404 * Could not get Valid channel list from CFG.
1405 * Log error.
1406 */
1407 limLog(pMac, LOGP,
1408 FL("could not retrieve Valid channel list"));
Padma, Santhosh Kumar778d8382015-03-04 17:41:22 +05301409
1410 if (pMac->lim.gLimRspReqd)
1411 {
1412 pMac->lim.gLimRspReqd = false;
1413
1414 limSendSmeScanRsp(pMac, sizeof(tSirSmeScanRsp),
1415 eSIR_SME_INVALID_PARAMETERS,
1416 pScanReq->sessionId,
1417 pScanReq->transactionId);
1418 }
Abhishek Singh2b055852015-10-07 14:14:13 +05301419 vos_mem_free(pMlmScanReq);
Padma, Santhosh Kumar778d8382015-03-04 17:41:22 +05301420 return;
Ganesh Kondabattinif0fa07c2013-06-11 17:47:49 +05301421 }
1422 pMlmScanReq->channelList.numChannels = (tANI_U8) cfg_len;
Padma, Santhosh Kumar778d8382015-03-04 17:41:22 +05301423
1424 //Ignore DFS channels if DFS scan is disabled
1425 if(pMac->scan.fEnableDFSChnlScan == DFS_CHNL_SCAN_DISABLED)
1426 {
1427 tANI_U8 numChan = 0;
1428 tANI_U8 channel_state;
1429 tANI_U8 *chan_ptr = pMlmScanReq->channelList.channelNumber;
1430
1431 limLog(pMac, LOG1,
1432 FL("Ignore DFS channels from valid channel list"));
1433
1434 VOS_TRACE_HEX_DUMP(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
1435 pMlmScanReq->channelList.channelNumber,
1436 pMlmScanReq->channelList.numChannels);
1437
1438 //Filter DFS channels
1439 for (i = 0; i < cfg_len; i++)
1440 {
1441 channel_state =
1442 vos_nv_getChannelEnabledState(*(chan_ptr + i));
1443
1444 //Allow channel if not DFS
1445 if(channel_state != NV_CHANNEL_DFS)
1446 {
1447 *(chan_ptr + numChan) = *(chan_ptr + i);
1448 numChan++;
1449 }
1450 }
1451 pMlmScanReq->channelList.numChannels = (tANI_U8) numChan;
1452
1453 limLog(pMac, LOG1, FL("No of valid channels %d, No of"
1454 "channels after filtering %d"), cfg_len, numChan);
1455
1456 limLog(pMac, LOG1, FL("Channel list after filtering: "));
1457
1458 VOS_TRACE_HEX_DUMP(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
1459 pMlmScanReq->channelList.channelNumber,
1460 pMlmScanReq->channelList.numChannels);
1461 }
Ganesh Kondabattinif0fa07c2013-06-11 17:47:49 +05301462 }
1463 else
1464 {
1465 len = sizeof( tLimMlmScanReq ) - sizeof( pScanReq->channelList.channelNumber ) +
1466 (sizeof( pScanReq->channelList.channelNumber ) * pScanReq->channelList.numChannels ) +
1467 pScanReq->uIEFieldLen;
Jeff Johnson295189b2012-06-20 16:38:30 -07001468
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301469 pMlmScanReq = vos_mem_malloc(len);
1470 if ( NULL == pMlmScanReq )
Ganesh Kondabattinif0fa07c2013-06-11 17:47:49 +05301471 {
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301472 // Log error
1473 limLog(pMac, LOGP,
1474 FL("call to AllocateMemory failed for mlmScanReq(%d)"), len);
Jeff Johnson295189b2012-06-20 16:38:30 -07001475
Padma, Santhosh Kumar8fa85212015-02-18 12:24:56 +05301476 if (pMac->lim.gLimRspReqd)
1477 {
1478 pMac->lim.gLimRspReqd = false;
1479
1480 limSendSmeScanRsp(pMac, sizeof(tSirSmeScanRsp),
1481 eSIR_SME_RESOURCES_UNAVAILABLE,
1482 pScanReq->sessionId,
1483 pScanReq->transactionId);
1484 }
1485
Ganesh Kondabattinif0fa07c2013-06-11 17:47:49 +05301486 return;
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301487 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001488
Ganesh Kondabattinif0fa07c2013-06-11 17:47:49 +05301489 // Initialize this buffer
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301490 vos_mem_set( (tANI_U8 *) pMlmScanReq, len, 0);
Ganesh Kondabattinif0fa07c2013-06-11 17:47:49 +05301491 pMlmScanReq->channelList.numChannels =
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301492 pScanReq->channelList.numChannels;
Jeff Johnson295189b2012-06-20 16:38:30 -07001493
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301494 vos_mem_copy( pMlmScanReq->channelList.channelNumber,
1495 pScanReq->channelList.channelNumber,
1496 pScanReq->channelList.numChannels);
1497 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001498
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301499 pMlmScanReq->uIEFieldLen = pScanReq->uIEFieldLen;
1500 pMlmScanReq->uIEFieldOffset = len - pScanReq->uIEFieldLen;
1501 if(pScanReq->uIEFieldLen)
1502 {
1503 vos_mem_copy( (tANI_U8 *)pMlmScanReq+ pMlmScanReq->uIEFieldOffset,
1504 (tANI_U8 *)pScanReq+(pScanReq->uIEFieldOffset),
1505 pScanReq->uIEFieldLen);
1506 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001507
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301508 pMlmScanReq->bssType = pScanReq->bssType;
1509 vos_mem_copy( pMlmScanReq->bssId,
1510 pScanReq->bssId,
1511 sizeof(tSirMacAddr));
1512 pMlmScanReq->numSsid = pScanReq->numSsid;
Jeff Johnson295189b2012-06-20 16:38:30 -07001513
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301514 i = 0;
1515 while (i < pMlmScanReq->numSsid)
1516 {
1517 vos_mem_copy( (tANI_U8 *) &pMlmScanReq->ssId[i],
Jeff Johnson295189b2012-06-20 16:38:30 -07001518 (tANI_U8 *) &pScanReq->ssId[i],
1519 pScanReq->ssId[i].length + 1);
1520
Ganesh Kondabattinif0fa07c2013-06-11 17:47:49 +05301521 i++;
1522 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001523
Jeff Johnson295189b2012-06-20 16:38:30 -07001524
Ganesh Kondabattinif0fa07c2013-06-11 17:47:49 +05301525 pMlmScanReq->scanType = pScanReq->scanType;
1526 pMlmScanReq->backgroundScanMode = pScanReq->backgroundScanMode;
Ganesh Kondabattini8f6e3b32014-08-25 16:07:54 +05301527 if (pMac->miracast_mode)
1528 {
1529 pMlmScanReq->minChannelTime = DEFAULT_MIN_CHAN_TIME_DURING_MIRACAST;
1530 pMlmScanReq->maxChannelTime = DEFAULT_MAX_CHAN_TIME_DURING_MIRACAST;
1531 }
1532 else
1533 {
1534 pMlmScanReq->minChannelTime = pScanReq->minChannelTime;
1535 pMlmScanReq->maxChannelTime = pScanReq->maxChannelTime;
1536 }
1537
Abhishek Singh3a93ee42016-09-29 17:00:03 +05301538 pMlmScanReq->min_chntime_btc_esco =
1539 pScanReq->min_chntime_btc_esco;
1540 pMlmScanReq->max_chntime_btc_esco =
1541 pScanReq->max_chntime_btc_esco;
Ganesh Kondabattinif0fa07c2013-06-11 17:47:49 +05301542 pMlmScanReq->dot11mode = pScanReq->dot11mode;
1543 pMlmScanReq->p2pSearch = pScanReq->p2pSearch;
Jeff Johnson295189b2012-06-20 16:38:30 -07001544
Ganesh Kondabattinif0fa07c2013-06-11 17:47:49 +05301545 //Store the smeSessionID and transaction ID for later use.
1546 pMac->lim.gSmeSessionId = pScanReq->sessionId;
1547 pMac->lim.gTransactionId = pScanReq->transactionId;
Jeff Johnson295189b2012-06-20 16:38:30 -07001548
Ganesh Kondabattinif0fa07c2013-06-11 17:47:49 +05301549 // Issue LIM_MLM_SCAN_REQ to MLM
Rashmi Ramanna6c13a342014-01-07 11:44:07 +05301550 limLog(pMac, LOG1, FL("Issue Scan request command to MLM "));
Ganesh Kondabattinif0fa07c2013-06-11 17:47:49 +05301551 limPostMlmMessage(pMac, LIM_MLM_SCAN_REQ, (tANI_U32 *) pMlmScanReq);
1552 }
1553 } // if ((pMac->lim.gLimSmeState == eLIM_SME_IDLE_STATE) || ...
Jeff Johnson295189b2012-06-20 16:38:30 -07001554
1555 else
1556 {
1557 /// In all other cases return 'cached' scan results
1558 if ((pMac->lim.gLimRspReqd) || pMac->lim.gLimReportBackgroundScanResults)
1559 {
1560 tANI_U16 scanRspLen = sizeof(tSirSmeScanRsp);
1561
1562 pMac->lim.gLimRspReqd = false;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07001563#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
1564 if (pScanReq->returnFreshResults & SIR_BG_SCAN_RETURN_LFR_CACHED_RESULTS)
Jeff Johnson295189b2012-06-20 16:38:30 -07001565 {
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07001566 pMac->lim.gLimSmeLfrScanResultLength = pMac->lim.gLimMlmLfrScanResultLength;
1567 if (pMac->lim.gLimSmeLfrScanResultLength == 0)
1568 {
1569 limSendSmeLfrScanRsp(pMac, scanRspLen,
1570 eSIR_SME_SUCCESS,
1571 pScanReq->sessionId,
1572 pScanReq->transactionId);
1573 }
1574 else
1575 {
1576 scanRspLen = sizeof(tSirSmeScanRsp) +
1577 pMac->lim.gLimSmeLfrScanResultLength -
1578 sizeof(tSirBssDescription);
1579 limSendSmeLfrScanRsp(pMac, scanRspLen, eSIR_SME_SUCCESS,
1580 pScanReq->sessionId, pScanReq->transactionId);
1581 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001582 }
1583 else
1584 {
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07001585#endif
1586 if (pMac->lim.gLimSmeScanResultLength == 0)
1587 {
1588 limSendSmeScanRsp(pMac, scanRspLen, eSIR_SME_SUCCESS,
1589 pScanReq->sessionId, pScanReq->transactionId);
1590 }
1591 else
1592 {
1593 scanRspLen = sizeof(tSirSmeScanRsp) +
1594 pMac->lim.gLimSmeScanResultLength -
1595 sizeof(tSirBssDescription);
1596 limSendSmeScanRsp(pMac, scanRspLen, eSIR_SME_SUCCESS,
1597 pScanReq->sessionId, pScanReq->transactionId);
1598 }
1599#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
Jeff Johnson295189b2012-06-20 16:38:30 -07001600 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07001601#endif
Rashmi Ramanna6c13a342014-01-07 11:44:07 +05301602 limLog(pMac, LOG1, FL("Cached scan results are returned "));
Jeff Johnson295189b2012-06-20 16:38:30 -07001603
1604 if (pScanReq->returnFreshResults & SIR_BG_SCAN_PURGE_RESUTLS)
1605 {
1606 // Discard previously cached scan results
1607 limReInitScanResults(pMac);
1608 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07001609#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
1610 if (pScanReq->returnFreshResults & SIR_BG_SCAN_PURGE_LFR_RESULTS)
1611 {
1612 // Discard previously cached scan results
1613 limReInitLfrScanResults(pMac);
1614 }
1615#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001616
1617 } // if (pMac->lim.gLimRspReqd)
1618 } // else ((pMac->lim.gLimSmeState == eLIM_SME_IDLE_STATE) || ...
1619
Jeff Johnson295189b2012-06-20 16:38:30 -07001620#ifdef BACKGROUND_SCAN_ENABLED
1621 // start background scans if needed
1622 // There is a bug opened against softmac. Need to enable when the bug is fixed.
1623 __limBackgroundScanInitiate(pMac);
1624#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001625
1626} /*** end __limProcessSmeScanReq() ***/
1627
Jeff Johnsone7245742012-09-05 17:12:55 -07001628#ifdef FEATURE_OEM_DATA_SUPPORT
Jeff Johnson295189b2012-06-20 16:38:30 -07001629
Jeff Johnsone7245742012-09-05 17:12:55 -07001630static void __limProcessSmeOemDataReq(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
1631{
1632 tpSirOemDataReq pOemDataReq;
1633 tLimMlmOemDataReq* pMlmOemDataReq;
1634
1635 pOemDataReq = (tpSirOemDataReq) pMsgBuf;
1636
1637 //post the lim mlm message now
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301638 pMlmOemDataReq = vos_mem_malloc(sizeof(tLimMlmOemDataReq));
1639 if ( NULL == pMlmOemDataReq )
Jeff Johnsone7245742012-09-05 17:12:55 -07001640 {
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301641 limLog(pMac, LOGP, FL("AllocateMemory failed for mlmOemDataReq"));
Jeff Johnsone7245742012-09-05 17:12:55 -07001642 return;
1643 }
1644
1645 //Initialize this buffer
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301646 vos_mem_set( pMlmOemDataReq, (sizeof(tLimMlmOemDataReq)), 0);
Jeff Johnsone7245742012-09-05 17:12:55 -07001647
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301648 vos_mem_copy( pMlmOemDataReq->selfMacAddr, pOemDataReq->selfMacAddr,
1649 sizeof(tSirMacAddr));
1650 vos_mem_copy( pMlmOemDataReq->oemDataReq, pOemDataReq->oemDataReq,
1651 OEM_DATA_REQ_SIZE);
Jeff Johnsone7245742012-09-05 17:12:55 -07001652
1653 //Issue LIM_MLM_OEM_DATA_REQ to MLM
1654 limPostMlmMessage(pMac, LIM_MLM_OEM_DATA_REQ, (tANI_U32*)pMlmOemDataReq);
1655
1656 return;
1657
1658} /*** end __limProcessSmeOemDataReq() ***/
1659
1660#endif //FEATURE_OEM_DATA_SUPPORT
Jeff Johnson295189b2012-06-20 16:38:30 -07001661
Gopichand Nakkalac178ac82013-05-30 19:53:39 +05301662/**
1663 * __limProcessClearDfsChannelList()
1664 *
1665 *FUNCTION:
1666 *Clear DFS channel list when country is changed/aquired.
1667.*This message is sent from SME.
1668 *
1669 *LOGIC:
1670 *
1671 *ASSUMPTIONS:
1672 *
1673 *NOTE:
1674 *
1675 * @param pMac Pointer to Global MAC structure
1676 * @param *pMsgBuf A pointer to the SME message buffer
1677 * @return None
1678 */
1679static void __limProcessClearDfsChannelList(tpAniSirGlobal pMac,
1680 tpSirMsgQ pMsg)
1681{
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301682 vos_mem_set( &pMac->lim.dfschannelList,
1683 sizeof(tSirDFSChannelList), 0);
Gopichand Nakkalac178ac82013-05-30 19:53:39 +05301684}
Jeff Johnson295189b2012-06-20 16:38:30 -07001685
1686/**
1687 * __limProcessSmeJoinReq()
1688 *
1689 *FUNCTION:
1690 * This function is called to process SME_JOIN_REQ message
1691 * from HDD or upper layer application.
1692 *
1693 *LOGIC:
1694 *
1695 *ASSUMPTIONS:
1696 *
1697 *NOTE:
1698 *
1699 * @param pMac Pointer to Global MAC structure
1700 * @param *pMsgBuf A pointer to the SME message buffer
1701 * @return None
1702 */
Jeff Johnson295189b2012-06-20 16:38:30 -07001703static void
1704__limProcessSmeJoinReq(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
1705{
1706 // tANI_U8 *pBuf;
1707 //tANI_U32 len;
1708// tSirMacAddr currentBssId;
1709 tpSirSmeJoinReq pSmeJoinReq = NULL;
1710 tLimMlmJoinReq *pMlmJoinReq;
1711 tSirResultCodes retCode = eSIR_SME_SUCCESS;
1712 tANI_U32 val = 0;
1713 tANI_U16 nSize;
1714 tANI_U8 sessionId;
1715 tpPESession psessionEntry = NULL;
Nitesh Shah54046ee2016-07-19 15:23:51 +05301716 tANI_U8 smesessionId = 0;
1717 tANI_U16 smetransactionId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001718 tPowerdBm localPowerConstraint = 0, regMax = 0;
Agarwal Ashish87039eb2014-01-15 14:13:15 +05301719 tANI_U16 ieLen;
1720 v_U8_t *vendorIE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001721
1722#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM //FEATURE_WLAN_DIAG_SUPPORT
1723 //Not sending any session, since it is not created yet. The response whould have correct state.
1724 limDiagEventReport(pMac, WLAN_PE_DIAG_JOIN_REQ_EVENT, NULL, 0, 0);
1725#endif //FEATURE_WLAN_DIAG_SUPPORT
1726
Abhishek Singh3cbf6052014-12-15 16:46:42 +05301727 limLog(pMac, LOG1, FL("Received SME_JOIN_REQ"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001728
1729#ifdef WLAN_FEATURE_VOWIFI
1730 /* Need to read the CFG here itself as this is used in limExtractAPCapability() below.
1731 * This CFG is actually read in rrmUpdateConfig() which is called later. Because this is not
1732 * read, RRM related path before calling rrmUpdateConfig() is not getting executed causing issues
1733 * like not honoring power constraint on 1st association after driver loading. */
1734 if (wlan_cfgGetInt(pMac, WNI_CFG_RRM_ENABLED, &val) != eSIR_SUCCESS)
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001735 limLog(pMac, LOGP, FL("cfg get rrm enabled failed"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001736 pMac->rrm.rrmPEContext.rrmEnable = (val) ? 1 : 0;
1737 val = 0;
1738#endif /* WLAN_FEATURE_VOWIFI */
1739
1740 /**
1741 * Expect Join request in idle state.
1742 * Reassociate request is expected in link established state.
1743 */
1744
1745 /* Global SME and LIM states are not defined yet for BT-AMP Support */
1746 if(pMac->lim.gLimSmeState == eLIM_SME_IDLE_STATE)
1747 {
1748 nSize = __limGetSmeJoinReqSizeForAlloc((tANI_U8*) pMsgBuf);
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301749
1750 pSmeJoinReq = vos_mem_malloc(nSize);
1751 if ( NULL == pSmeJoinReq )
Jeff Johnson295189b2012-06-20 16:38:30 -07001752 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05301753 limLog(pMac, LOGP, FL("call to AllocateMemory failed for "
1754 "pSmeJoinReq"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001755 retCode = eSIR_SME_RESOURCES_UNAVAILABLE;
1756 goto end;
1757 }
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301758 (void) vos_mem_set((void *) pSmeJoinReq, nSize, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07001759
Jeff Johnson295189b2012-06-20 16:38:30 -07001760 if ((limJoinReqSerDes(pMac, pSmeJoinReq, (tANI_U8 *)pMsgBuf) == eSIR_FAILURE) ||
1761 (!limIsSmeJoinReqValid(pMac, pSmeJoinReq)))
1762 {
1763 /// Received invalid eWNI_SME_JOIN_REQ
1764 // Log the event
Padma, Santhosh Kumar2b47ca82014-01-03 16:57:27 +05301765 limLog(pMac, LOGW, FL("SessionId:%d Received SME_JOIN_REQ with"
1766 "invalid data"),pSmeJoinReq->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07001767 retCode = eSIR_SME_INVALID_PARAMETERS;
1768 goto end;
1769 }
1770
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301771 //pMac->lim.gpLimJoinReq = pSmeJoinReq; TO SUPPORT BT-AMP, review os sep 23
Jeff Johnson295189b2012-06-20 16:38:30 -07001772
1773 /* check for the existence of start BSS session */
1774#ifdef FIXME_GEN6
1775 if(pSmeJoinReq->bsstype == eSIR_BTAMP_AP_MODE)
1776 {
1777 if(peValidateBtJoinRequest(pMac)!= TRUE)
1778 {
Padma, Santhosh Kumar2b47ca82014-01-03 16:57:27 +05301779 limLog(pMac, LOGW, FL("SessionId:%d Start Bss session"
1780 "not present::SME_JOIN_REQ in unexpected state"),
1781 pSmeJoinReq->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07001782 retCode = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
1783 psessionEntry = NULL;
1784 goto end;
1785 }
1786 }
1787
1788#endif
1789
1790
1791 if((psessionEntry = peFindSessionByBssid(pMac,pSmeJoinReq->bssDescription.bssId,&sessionId)) != NULL)
1792 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05301793 limLog(pMac, LOGE, FL("Session(%d) Already exists for BSSID: "
Sushant Kaushik1b645382014-10-13 16:39:36 +05301794 MAC_ADDRESS_STR" in limSmeState = %d"),sessionId,
Abhishek Singh57aebef2014-02-03 18:47:44 +05301795 MAC_ADDR_ARRAY(pSmeJoinReq->bssDescription.bssId),
1796 psessionEntry->limSmeState);
Jeff Johnson295189b2012-06-20 16:38:30 -07001797
1798 if(psessionEntry->limSmeState == eLIM_SME_LINK_EST_STATE)
1799 {
1800 // Received eWNI_SME_JOIN_REQ for same
1801 // BSS as currently associated.
1802 // Log the event and send success
Padma, Santhosh Kumar2b47ca82014-01-03 16:57:27 +05301803 PELOGW(limLog(pMac, LOGW, FL("SessionId:%d Received"
1804 "SME_JOIN_REQ for currently joined BSS"),sessionId);)
Jeff Johnson295189b2012-06-20 16:38:30 -07001805 /// Send Join success response to host
Deepthi Gowrif3e27252013-12-11 20:50:01 +05301806 retCode = eSIR_SME_ALREADY_JOINED_A_BSS;
1807 psessionEntry = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07001808 goto end;
1809 }
1810 else
1811 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05301812 PELOGE(limLog(pMac, LOGE, FL("SME_JOIN_REQ not for"
1813 "currently joined BSS"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001814 retCode = eSIR_SME_REFUSED;
1815 psessionEntry = NULL;
1816 goto end;
1817 }
1818 }
1819 else /* Session Entry does not exist for given BSSId */
1820 {
1821 /* Try to Create a new session */
1822 if((psessionEntry = peCreateSession(pMac,pSmeJoinReq->bssDescription.bssId,&sessionId, pMac->lim.maxStation)) == NULL)
1823 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001824 limLog(pMac, LOGE, FL("Session Can not be created "));
Jeff Johnson295189b2012-06-20 16:38:30 -07001825 retCode = eSIR_SME_RESOURCES_UNAVAILABLE;
1826 goto end;
1827 }
Padma, Santhosh Kumar2b47ca82014-01-03 16:57:27 +05301828 else
1829 limLog(pMac,LOG1,FL("SessionId:%d New session created"),
1830 sessionId);
Masti, Narayanraddi67ea5912015-01-08 12:34:05 +05301831 }
1832
1833 if(psessionEntry != NULL && pSmeJoinReq->operationalRateSet.numRates > 0 ){
1834 if(!limCheck11BRateBitmap(pSmeJoinReq->rateBitMap)){
1835 psessionEntry->is11Gonly = true;
1836 }
1837 }
1838
krunal soni5afa96c2013-09-06 22:19:02 -07001839 psessionEntry->isAmsduSupportInAMPDU = pSmeJoinReq->isAmsduSupportInAMPDU;
Jeff Johnsone7245742012-09-05 17:12:55 -07001840
Jeff Johnson295189b2012-06-20 16:38:30 -07001841 /* Store Session related parameters */
1842 /* Store PE session Id in session Table */
1843 psessionEntry->peSessionId = sessionId;
1844
1845 /* store the smejoin req handle in session table */
1846 psessionEntry->pLimJoinReq = pSmeJoinReq;
1847
1848 /* Store SME session Id in sessionTable */
1849 psessionEntry->smeSessionId = pSmeJoinReq->sessionId;
1850
1851 /* Store SME transaction Id in session Table */
1852 psessionEntry->transactionId = pSmeJoinReq->transactionId;
1853
1854 /* Store beaconInterval */
1855 psessionEntry->beaconParams.beaconInterval = pSmeJoinReq->bssDescription.beaconInterval;
1856
1857 /* Copying of bssId is already done, while creating session */
1858 //sirCopyMacAddr(psessionEntry->bssId,pSmeJoinReq->bssId);
1859 sirCopyMacAddr(psessionEntry->selfMacAddr,pSmeJoinReq->selfMacAddr);
1860 psessionEntry->bssType = pSmeJoinReq->bsstype;
1861
1862 psessionEntry->statypeForBss = STA_ENTRY_PEER;
Sandeep Puligillaaea98a22013-12-04 13:36:32 +05301863 psessionEntry->limWmeEnabled = pSmeJoinReq->isWMEenabled;
1864 psessionEntry->limQosEnabled = pSmeJoinReq->isQosEnabled;
Sushant Kaushik74df8db2015-03-11 18:09:05 +05301865 psessionEntry->bOSENAssociation = pSmeJoinReq->bOSENAssociation;
Abhishek Singheef5c992016-01-27 13:41:54 +05301866 psessionEntry->bWPSAssociation = pSmeJoinReq->bWPSAssociation;
Jeff Johnson295189b2012-06-20 16:38:30 -07001867
Agarwal Ashish87039eb2014-01-15 14:13:15 +05301868 /* Store vendor specfic IE for CISCO AP */
Abhishek Singhbad2b322016-10-21 11:22:33 +05301869 ieLen = GET_IE_LEN_IN_BSS(pSmeJoinReq->bssDescription.length);
Agarwal Ashish87039eb2014-01-15 14:13:15 +05301870
1871 vendorIE = limGetVendorIEOuiPtr(pMac, SIR_MAC_CISCO_OUI,
1872 SIR_MAC_CISCO_OUI_SIZE,
1873 ((tANI_U8 *)&pSmeJoinReq->bssDescription.ieFields) , ieLen);
1874
1875 if ( NULL != vendorIE )
1876 {
1877 limLog(pMac, LOGE,
1878 FL("DUT is trying to connect to Cisco AP"));
1879 psessionEntry->isCiscoVendorAP = TRUE;
1880 }
1881 else
1882 {
1883 psessionEntry->isCiscoVendorAP = FALSE;
1884 }
1885
Jeff Johnson295189b2012-06-20 16:38:30 -07001886 /* Copy the dot 11 mode in to the session table */
1887
1888 psessionEntry->dot11mode = pSmeJoinReq->dot11mode;
1889 psessionEntry->nwType = pSmeJoinReq->bssDescription.nwType;
Jeff Johnsone7245742012-09-05 17:12:55 -07001890#ifdef WLAN_FEATURE_11AC
1891 psessionEntry->vhtCapability = IS_DOT11_MODE_VHT(psessionEntry->dot11mode);
Jeff Johnson32d95a32012-09-10 13:15:23 -07001892 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO_MED,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001893 "***__limProcessSmeJoinReq: vhtCapability=%d****",psessionEntry->vhtCapability);
Shailender Karmuchi08f87c22013-01-17 12:51:24 -08001894 if (psessionEntry->vhtCapability )
1895 {
1896 psessionEntry->txBFIniFeatureEnabled = pSmeJoinReq->txBFIniFeatureEnabled;
1897
1898 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO_MED,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001899 "***__limProcessSmeJoinReq: txBFIniFeatureEnabled=%d****",
Shailender Karmuchi08f87c22013-01-17 12:51:24 -08001900 psessionEntry->txBFIniFeatureEnabled);
1901
Selvaraj, Sridhar716d30f2016-07-28 18:54:03 +05301902 if (cfgSetInt(pMac, WNI_CFG_VHT_SU_BEAMFORMEE_CAP,
1903 psessionEntry->txBFIniFeatureEnabled) != eSIR_SUCCESS)
1904 {
1905 limLog(pMac, LOGP, FL("could not set "
1906 "WNI_CFG_VHT_SU_BEAMFORMEE_CAP at CFG"));
1907 retCode = eSIR_LOGP_EXCEPTION;
1908 goto end;
1909 }
Shailender Karmuchi08f87c22013-01-17 12:51:24 -08001910 if( psessionEntry->txBFIniFeatureEnabled )
1911 {
Shailender Karmuchicc3fe442013-02-16 18:18:33 -08001912 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO_MED,
Abhishek Singh57aebef2014-02-03 18:47:44 +05301913 "***__limProcessSmeJoinReq: txBFCsnValue=%d****",
1914 pSmeJoinReq->txBFCsnValue);
Shailender Karmuchicc3fe442013-02-16 18:18:33 -08001915
1916 if (cfgSetInt(pMac, WNI_CFG_VHT_CSN_BEAMFORMEE_ANT_SUPPORTED, pSmeJoinReq->txBFCsnValue)
Shailender Karmuchi08f87c22013-01-17 12:51:24 -08001917 != eSIR_SUCCESS)
1918 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05301919 limLog(pMac, LOGP, FL("could not set "
1920 "WNI_CFG_VHT_CSN_BEAMFORMEE_ANT_SUPPORTED at CFG"));
Shailender Karmuchi08f87c22013-01-17 12:51:24 -08001921 retCode = eSIR_LOGP_EXCEPTION;
1922 goto end;
1923 }
Abhishek Singh6d5d29c2014-07-03 14:25:22 +05301924
1925 if ( FALSE == pMac->isMuBfsessionexist )
1926 psessionEntry->txMuBformee = pSmeJoinReq->txMuBformee;
Shailender Karmuchi08f87c22013-01-17 12:51:24 -08001927 }
Abhishek Singh6d5d29c2014-07-03 14:25:22 +05301928
1929 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
1930 "SmeJoinReq:txMuBformee=%d psessionEntry: txMuBformee = %d",
1931 pSmeJoinReq->txMuBformee, psessionEntry->txMuBformee);
1932
1933 if(cfgSetInt(pMac, WNI_CFG_VHT_MU_BEAMFORMEE_CAP, psessionEntry->txMuBformee)
1934 != eSIR_SUCCESS)
1935 {
1936 limLog(pMac, LOGE, FL("could not set "
1937 "WNI_CFG_VHT_MU_BEAMFORMEE_CAP at CFG"));
1938 retCode = eSIR_LOGP_EXCEPTION;
1939 goto end;
1940 }
1941
Shailender Karmuchi08f87c22013-01-17 12:51:24 -08001942 }
1943
Jeff Johnsone7245742012-09-05 17:12:55 -07001944#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001945
1946 /*Phy mode*/
1947 psessionEntry->gLimPhyMode = pSmeJoinReq->bssDescription.nwType;
1948
Abhishek Singhca6ec5d2015-06-24 13:13:27 +05301949 handleHTCapabilityandHTInfo(pMac, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07001950 /* Copy The channel Id to the session Table */
1951 psessionEntry->currentOperChannel = pSmeJoinReq->bssDescription.channelId;
Abhishek Singhe3beee22017-07-31 15:35:40 +05301952 psessionEntry->force_24ghz_in_ht20 = pSmeJoinReq->force_24ghz_in_ht20;
Jeff Johnsone7245742012-09-05 17:12:55 -07001953 psessionEntry->htSupportedChannelWidthSet = (pSmeJoinReq->cbMode)?1:0; // This is already merged value of peer and self - done by csr in csrGetCBModeFromIes
1954 psessionEntry->htRecommendedTxWidthSet = psessionEntry->htSupportedChannelWidthSet;
1955 psessionEntry->htSecondaryChannelOffset = pSmeJoinReq->cbMode;
Jeff Johnson295189b2012-06-20 16:38:30 -07001956
Chet Lanctot186b5732013-03-18 10:26:30 -07001957 /* Record if management frames need to be protected */
1958#ifdef WLAN_FEATURE_11W
1959 if(eSIR_ED_AES_128_CMAC == pSmeJoinReq->MgmtEncryptionType)
1960 {
1961 psessionEntry->limRmfEnabled = 1;
1962 }
1963 else
1964 {
1965 psessionEntry->limRmfEnabled = 0;
1966 }
1967#endif
1968
krunal soni8d13b092013-07-19 13:23:29 -07001969#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM
1970 psessionEntry->rssi = pSmeJoinReq->bssDescription.rssi;
1971#endif
1972
Jeff Johnson295189b2012-06-20 16:38:30 -07001973 /*Store Persona */
1974 psessionEntry->pePersona = pSmeJoinReq->staPersona;
1975 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
Abhishek Singhe3beee22017-07-31 15:35:40 +05301976 FL("PE PERSONA=%d cbMode %u force_24ghz_in_ht20 %d"),
1977 psessionEntry->pePersona,
1978 pSmeJoinReq->cbMode,
1979 psessionEntry->force_24ghz_in_ht20);
Jeff Johnson295189b2012-06-20 16:38:30 -07001980
1981 /* Copy the SSID from smejoinreq to session entry */
1982 psessionEntry->ssId.length = pSmeJoinReq->ssId.length;
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301983 vos_mem_copy( psessionEntry->ssId.ssId,
1984 pSmeJoinReq->ssId.ssId, psessionEntry->ssId.length);
1985
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001986 // Determin 11r or ESE connection based on input from SME
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301987 // which inturn is dependent on the profile the user wants to connect
1988 // to, So input is coming from supplicant
Jeff Johnson295189b2012-06-20 16:38:30 -07001989#ifdef WLAN_FEATURE_VOWIFI_11R
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301990 psessionEntry->is11Rconnection = pSmeJoinReq->is11Rconnection;
Jeff Johnson295189b2012-06-20 16:38:30 -07001991#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001992#ifdef FEATURE_WLAN_ESE
1993 psessionEntry->isESEconnection = pSmeJoinReq->isESEconnection;
Jeff Johnson295189b2012-06-20 16:38:30 -07001994#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001995#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301996 psessionEntry->isFastTransitionEnabled = pSmeJoinReq->isFastTransitionEnabled;
Jeff Johnson295189b2012-06-20 16:38:30 -07001997#endif
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301998
Jeff Johnson43971f52012-07-17 12:26:56 -07001999#ifdef FEATURE_WLAN_LFR
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302000 psessionEntry->isFastRoamIniFeatureEnabled = pSmeJoinReq->isFastRoamIniFeatureEnabled;
Jeff Johnson43971f52012-07-17 12:26:56 -07002001#endif
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302002 psessionEntry->txLdpcIniFeatureEnabled = pSmeJoinReq->txLdpcIniFeatureEnabled;
Gopichand Nakkalab2d2c312013-01-04 11:41:02 -08002003
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302004 if (psessionEntry->bssType == eSIR_INFRASTRUCTURE_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07002005 {
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302006 psessionEntry->limSystemRole = eLIM_STA_ROLE;
2007 }
2008 else if (psessionEntry->bssType == eSIR_BTAMP_AP_MODE)
2009 {
2010 psessionEntry->limSystemRole = eLIM_BT_AMP_STA_ROLE;
2011 }
2012 else
2013 {
2014 /* Throw an error and return and make sure to delete the session.*/
Abhishek Singh57aebef2014-02-03 18:47:44 +05302015 limLog(pMac, LOGE, FL("received SME_JOIN_REQ with invalid"
2016 " bss type %d"), psessionEntry->bssType);
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302017 retCode = eSIR_SME_INVALID_PARAMETERS;
2018 goto end;
2019 }
2020
2021 if (pSmeJoinReq->addIEScan.length)
2022 {
2023 vos_mem_copy( &psessionEntry->pLimJoinReq->addIEScan,
Jeff Johnson295189b2012-06-20 16:38:30 -07002024 &pSmeJoinReq->addIEScan, sizeof(tSirAddie));
2025 }
2026
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302027 if (pSmeJoinReq->addIEAssoc.length)
Jeff Johnson295189b2012-06-20 16:38:30 -07002028 {
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302029 vos_mem_copy( &psessionEntry->pLimJoinReq->addIEAssoc,
Jeff Johnson295189b2012-06-20 16:38:30 -07002030 &pSmeJoinReq->addIEAssoc, sizeof(tSirAddie));
2031 }
2032
Jeff Johnson295189b2012-06-20 16:38:30 -07002033 val = sizeof(tLimMlmJoinReq) + psessionEntry->pLimJoinReq->bssDescription.length + 2;
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302034 pMlmJoinReq = vos_mem_malloc(val);
2035 if ( NULL == pMlmJoinReq )
Jeff Johnson295189b2012-06-20 16:38:30 -07002036 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05302037 limLog(pMac, LOGP, FL("call to AllocateMemory "
2038 "failed for mlmJoinReq"));
Nitesh Shah54046ee2016-07-19 15:23:51 +05302039 retCode = eSIR_SME_RESOURCES_UNAVAILABLE;
2040 goto end;
Jeff Johnson295189b2012-06-20 16:38:30 -07002041 }
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302042 (void) vos_mem_set((void *) pMlmJoinReq, val, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07002043
2044 /* PE SessionId is stored as a part of JoinReq*/
2045 pMlmJoinReq->sessionId = psessionEntry->peSessionId;
2046
2047 if (wlan_cfgGetInt(pMac, WNI_CFG_JOIN_FAILURE_TIMEOUT, (tANI_U32 *) &pMlmJoinReq->joinFailureTimeout)
2048 != eSIR_SUCCESS)
Sushant Kaushike3ca61c2015-03-19 18:33:25 +05302049 {
2050 limLog(pMac, LOGE, FL("could not retrieve JoinFailureTimer value "
2051 "setting it to default value"));
Abhishek Singh6e8ca792017-11-30 15:43:22 +05302052 pMlmJoinReq->joinFailureTimeout =
2053 WNI_CFG_JOIN_FAILURE_TIMEOUT_STADEF;
Sushant Kaushike3ca61c2015-03-19 18:33:25 +05302054 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002055
2056 /* copy operational rate from psessionEntry*/
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302057 vos_mem_copy((void*)&psessionEntry->rateSet, (void*)&pSmeJoinReq->operationalRateSet,
Jeff Johnson295189b2012-06-20 16:38:30 -07002058 sizeof(tSirMacRateSet));
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302059 vos_mem_copy((void*)&psessionEntry->extRateSet, (void*)&pSmeJoinReq->extendedRateSet,
Jeff Johnson295189b2012-06-20 16:38:30 -07002060 sizeof(tSirMacRateSet));
2061 //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 +05302062 vos_mem_copy((void*)&pMlmJoinReq->operationalRateSet, (void*)&psessionEntry->rateSet,
Jeff Johnson295189b2012-06-20 16:38:30 -07002063 sizeof(tSirMacRateSet));
2064
2065 psessionEntry->encryptType = pSmeJoinReq->UCEncryptionType;
2066
Jeff Johnson295189b2012-06-20 16:38:30 -07002067 pMlmJoinReq->bssDescription.length = psessionEntry->pLimJoinReq->bssDescription.length;
2068
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302069 vos_mem_copy((tANI_U8 *) &pMlmJoinReq->bssDescription.bssId,
Jeff Johnson295189b2012-06-20 16:38:30 -07002070 (tANI_U8 *) &psessionEntry->pLimJoinReq->bssDescription.bssId,
2071 psessionEntry->pLimJoinReq->bssDescription.length + 2);
2072
Jeff Johnson295189b2012-06-20 16:38:30 -07002073 psessionEntry->limCurrentBssCaps =
Jeff Johnsone7245742012-09-05 17:12:55 -07002074 psessionEntry->pLimJoinReq->bssDescription.capabilityInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07002075
Jeff Johnsone7245742012-09-05 17:12:55 -07002076 regMax = cfgGetRegulatoryMaxTransmitPower( pMac, psessionEntry->currentOperChannel );
Sandeep Puligillaa9eb9ad2014-05-27 14:42:50 +05302077 localPowerConstraint = regMax;
Abhishek Singhbad2b322016-10-21 11:22:33 +05302078 limExtractApCapability(pMac,
2079 (tANI_U8 *) psessionEntry->pLimJoinReq->bssDescription.ieFields,
2080 GET_IE_LEN_IN_BSS(psessionEntry->pLimJoinReq->bssDescription.length),
2081 &psessionEntry->limCurrentBssQosCaps,
2082 &psessionEntry->limCurrentBssPropCap,
2083 &pMac->lim.gLimCurrentBssUapsd,
2084 &localPowerConstraint,
2085 psessionEntry);
Sandeep Puligillaa9eb9ad2014-05-27 14:42:50 +05302086
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002087#ifdef FEATURE_WLAN_ESE
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002088 psessionEntry->maxTxPower = limGetMaxTxPower(regMax, localPowerConstraint, pMac->roam.configParam.nTxPowerCap);
Jeff Johnson295189b2012-06-20 16:38:30 -07002089#else
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302090 psessionEntry->maxTxPower = VOS_MIN( regMax, (localPowerConstraint) );
Jeff Johnson295189b2012-06-20 16:38:30 -07002091#endif
Sushant Kaushikece4b562015-04-09 18:27:33 +05302092 if (!psessionEntry->maxTxPower)
2093 {
2094 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR, FL("Tx power"
2095 "is zero. Setting it to default value %d"),
2096 TX_POWER_DEFAULT);
2097 psessionEntry->maxTxPower = TX_POWER_DEFAULT;
2098 }
Abhinav Kumar5deb9cd2018-05-10 11:04:59 +05302099 psessionEntry->def_max_tx_pwr = psessionEntry->maxTxPower;
Sandeep Puligilla4ce02592014-04-22 09:05:57 +05302100 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
2101 "Regulatory max = %d, local power constraint = %d,"
Abhishek Singh57aebef2014-02-03 18:47:44 +05302102 " max tx = %d", regMax, localPowerConstraint,
2103 psessionEntry->maxTxPower );
Jeff Johnson295189b2012-06-20 16:38:30 -07002104
Agrawal Ashish0a4edfb2017-02-24 14:37:09 +05302105 if (pSmeJoinReq->powerCap.maxTxPower > psessionEntry->maxTxPower)
2106 {
2107 pSmeJoinReq->powerCap.maxTxPower = psessionEntry->maxTxPower;
2108 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
2109 "Update MaxTxPower in join Req to %d",
2110 pSmeJoinReq->powerCap.maxTxPower);
2111 }
2112
Jeff Johnson295189b2012-06-20 16:38:30 -07002113 if (pMac->lim.gLimCurrentBssUapsd)
2114 {
2115 pMac->lim.gUapsdPerAcBitmask = psessionEntry->pLimJoinReq->uapsdPerAcBitmask;
Abhishek Singh57aebef2014-02-03 18:47:44 +05302116 limLog( pMac, LOG1, FL("UAPSD flag for all AC - 0x%2x"),
2117 pMac->lim.gUapsdPerAcBitmask);
Jeff Johnson295189b2012-06-20 16:38:30 -07002118
2119 // resetting the dynamic uapsd mask
2120 pMac->lim.gUapsdPerAcDeliveryEnableMask = 0;
2121 pMac->lim.gUapsdPerAcTriggerEnableMask = 0;
2122 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002123
2124 psessionEntry->limRFBand = limGetRFBand(psessionEntry->currentOperChannel);
2125
2126 // Initialize 11h Enable Flag
2127 if(SIR_BAND_5_GHZ == psessionEntry->limRFBand)
2128 {
2129 if (wlan_cfgGetInt(pMac, WNI_CFG_11H_ENABLED, &val) != eSIR_SUCCESS)
Sushant Kaushike3ca61c2015-03-19 18:33:25 +05302130 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002131 limLog(pMac, LOGP, FL("Fail to get WNI_CFG_11H_ENABLED "));
Sushant Kaushike3ca61c2015-03-19 18:33:25 +05302132 psessionEntry->lim11hEnable = 1;
2133 }
2134 else
2135 psessionEntry->lim11hEnable = val;
Jeff Johnson295189b2012-06-20 16:38:30 -07002136 }
2137 else
2138 psessionEntry->lim11hEnable = 0;
2139
2140 //To care of the scenario when STA transitions from IBSS to Infrastructure mode.
2141 pMac->lim.gLimIbssCoalescingHappened = false;
2142
Jeff Johnsone7245742012-09-05 17:12:55 -07002143 psessionEntry->limPrevSmeState = psessionEntry->limSmeState;
2144 psessionEntry->limSmeState = eLIM_SME_WT_JOIN_STATE;
2145 MTRACE(macTrace(pMac, TRACE_CODE_SME_STATE, psessionEntry->peSessionId, psessionEntry->limSmeState));
Jeff Johnson295189b2012-06-20 16:38:30 -07002146
Abhishek Singh57aebef2014-02-03 18:47:44 +05302147 limLog(pMac, LOG1, FL("SME JoinReq:Sessionid %d SSID len %d SSID : %s "
2148 "Channel %d, BSSID "MAC_ADDRESS_STR), pMlmJoinReq->sessionId,
2149 psessionEntry->ssId.length,psessionEntry->ssId.ssId,
2150 psessionEntry->currentOperChannel,
2151 MAC_ADDR_ARRAY(psessionEntry->bssId));
Jeff Johnson295189b2012-06-20 16:38:30 -07002152
2153 /* Indicate whether spectrum management is enabled*/
2154 psessionEntry->spectrumMgtEnabled =
2155 pSmeJoinReq->spectrumMgtIndicator;
Rajesh Babu Prathipati043149f2014-06-06 13:33:45 +05302156
2157 /* Enable the spectrum management if this is a DFS channel */
2158 if (psessionEntry->countryInfoPresent &&
2159 limIsconnectedOnDFSChannel(psessionEntry->currentOperChannel))
2160 {
2161 psessionEntry->spectrumMgtEnabled = TRUE;
2162 }
2163
Abhishek Singh3cbf6052014-12-15 16:46:42 +05302164 limLog(pMac,LOG1,FL("SessionId: %d LIM_MLM_JOIN_REQ is posted to MLM "
2165 "SM"), pMlmJoinReq->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07002166 /* Issue LIM_MLM_JOIN_REQ to MLM */
2167 limPostMlmMessage(pMac, LIM_MLM_JOIN_REQ, (tANI_U32 *) pMlmJoinReq);
2168 return;
2169
2170 }
2171 else
2172 {
2173 /* Received eWNI_SME_JOIN_REQ un expected state */
Abhishek Singh57aebef2014-02-03 18:47:44 +05302174 limLog(pMac, LOGE, FL("received unexpected SME_JOIN_REQ "
Sushant Kaushik1b645382014-10-13 16:39:36 +05302175 "in state %d"), pMac->lim.gLimSmeState);
Jeff Johnson295189b2012-06-20 16:38:30 -07002176 limPrintSmeState(pMac, LOGE, pMac->lim.gLimSmeState);
2177 retCode = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
2178 psessionEntry = NULL;
2179 goto end;
2180
2181 }
2182
2183end:
2184 limGetSessionInfo(pMac,(tANI_U8*)pMsgBuf,&smesessionId,&smetransactionId);
2185
2186 if(pSmeJoinReq)
2187 {
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302188 vos_mem_free(pSmeJoinReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07002189 pSmeJoinReq = NULL;
2190 if (NULL != psessionEntry)
2191 {
2192 psessionEntry->pLimJoinReq = NULL;
2193 }
2194 }
2195
2196 if(retCode != eSIR_SME_SUCCESS)
2197 {
2198 if(NULL != psessionEntry)
2199 {
2200 peDeleteSession(pMac,psessionEntry);
2201 psessionEntry = NULL;
2202 }
2203 }
Abhishek Singh57aebef2014-02-03 18:47:44 +05302204 limLog(pMac, LOG1, FL("Sending failure status limSendSmeJoinReassocRsp"
2205 "on sessionid: %d with retCode = %d"),smesessionId, retCode);
Jeff Johnson295189b2012-06-20 16:38:30 -07002206 limSendSmeJoinReassocRsp(pMac, eWNI_SME_JOIN_RSP, retCode, eSIR_MAC_UNSPEC_FAILURE_STATUS,psessionEntry,smesessionId,smetransactionId);
2207} /*** end __limProcessSmeJoinReq() ***/
2208
2209
Agrawal Ashish01c66342017-01-27 12:52:25 +05302210#if defined FEATURE_WLAN_ESE || defined WLAN_FEATURE_VOWIFI
Madan Mohan Koyyalamudi3282c572012-11-09 17:01:41 -08002211tANI_U8 limGetMaxTxPower(tPowerdBm regMax, tPowerdBm apTxPower, tANI_U8 iniTxPower)
Jeff Johnson295189b2012-06-20 16:38:30 -07002212{
2213 tANI_U8 maxTxPower = 0;
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302214 tANI_U8 txPower = VOS_MIN( regMax, (apTxPower) );
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002215 txPower = VOS_MIN(txPower, iniTxPower);
Jeff Johnson295189b2012-06-20 16:38:30 -07002216 if((txPower >= MIN_TX_PWR_CAP) && (txPower <= MAX_TX_PWR_CAP))
2217 maxTxPower = txPower;
2218 else if (txPower < MIN_TX_PWR_CAP)
2219 maxTxPower = MIN_TX_PWR_CAP;
2220 else
2221 maxTxPower = MAX_TX_PWR_CAP;
2222
2223 return (maxTxPower);
2224}
2225#endif
2226
Jeff Johnson295189b2012-06-20 16:38:30 -07002227/**
2228 * __limProcessSmeReassocReq()
2229 *
2230 *FUNCTION:
2231 * This function is called to process SME_REASSOC_REQ message
2232 * from HDD or upper layer application.
2233 *
2234 *LOGIC:
2235 *
2236 *ASSUMPTIONS:
2237 *
2238 *NOTE:
2239 *
2240 * @param pMac Pointer to Global MAC structure
2241 * @param *pMsgBuf A pointer to the SME message buffer
2242 * @return None
2243 */
2244
2245static void
2246__limProcessSmeReassocReq(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
2247{
2248 tANI_U16 caps;
2249 tANI_U32 val;
Srinivas Girigowdac16730e2013-01-16 13:39:39 -08002250 tpSirSmeJoinReq pReassocReq = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002251 tLimMlmReassocReq *pMlmReassocReq;
2252 tSirResultCodes retCode = eSIR_SME_SUCCESS;
2253 tpPESession psessionEntry = NULL;
2254 tANI_U8 sessionId;
2255 tANI_U8 smeSessionId;
2256 tANI_U16 transactionId;
2257 tPowerdBm localPowerConstraint = 0, regMax = 0;
2258 tANI_U32 teleBcnEn = 0;
Madan Mohan Koyyalamudi7df624d2012-10-31 16:32:50 -07002259 tANI_U16 nSize;
Jeff Johnson295189b2012-06-20 16:38:30 -07002260
2261
Abhishek Singh127a8442014-12-15 17:31:27 +05302262 limLog(pMac, LOG1, FL("Received SME_REASSOC_REQ"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002263
Madan Mohan Koyyalamudi7df624d2012-10-31 16:32:50 -07002264 nSize = __limGetSmeJoinReqSizeForAlloc((tANI_U8 *) pMsgBuf);
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302265 pReassocReq = vos_mem_malloc(nSize);
2266 if ( NULL == pReassocReq )
Jeff Johnson295189b2012-06-20 16:38:30 -07002267 {
2268 // Log error
2269 limLog(pMac, LOGP,
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302270 FL("call to AllocateMemory failed for pReassocReq"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002271
2272 retCode = eSIR_SME_RESOURCES_UNAVAILABLE;
2273 goto end;
2274 }
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302275 (void) vos_mem_set((void *) pReassocReq, nSize, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07002276 if ((limJoinReqSerDes(pMac, (tpSirSmeJoinReq) pReassocReq,
2277 (tANI_U8 *) pMsgBuf) == eSIR_FAILURE) ||
2278 (!limIsSmeJoinReqValid(pMac,
2279 (tpSirSmeJoinReq) pReassocReq)))
2280 {
2281 /// Received invalid eWNI_SME_REASSOC_REQ
2282 // Log the event
2283 limLog(pMac, LOGW,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002284 FL("received SME_REASSOC_REQ with invalid data"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002285
2286 retCode = eSIR_SME_INVALID_PARAMETERS;
2287 goto end;
2288 }
2289
2290 if((psessionEntry = peFindSessionByBssid(pMac,pReassocReq->bssDescription.bssId,&sessionId))==NULL)
2291 {
2292 limPrintMacAddr(pMac, pReassocReq->bssDescription.bssId, LOGE);
Srinivas Girigowda2a69dcf2013-09-13 14:48:34 -07002293 limLog(pMac, LOGE, FL("Session does not exist for given bssId"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002294 retCode = eSIR_SME_INVALID_PARAMETERS;
2295 goto end;
2296 }
2297
Sushant Kaushikb97a0082015-08-31 12:36:45 +05302298#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM //FEATURE_WLAN_DIAG_SUPPORT
Deepthi Gowri639d5042015-11-16 20:23:39 +05302299 limDiagEventReport(pMac, WLAN_PE_DIAG_REASSOC_REQ_EVENT, psessionEntry,
2300 eSIR_SUCCESS, eSIR_SUCCESS);
Jeff Johnson295189b2012-06-20 16:38:30 -07002301#endif //FEATURE_WLAN_DIAG_SUPPORT
2302 //pMac->lim.gpLimReassocReq = pReassocReq;//TO SUPPORT BT-AMP
2303
2304 /* Store the reassoc handle in the session Table.. 23rd sep review */
2305 psessionEntry->pLimReAssocReq = pReassocReq;
Padma, Santhosh Kumar0d25d102014-07-17 15:08:48 +05302306 psessionEntry->dot11mode = pReassocReq->dot11mode;
2307 psessionEntry->vhtCapability = IS_DOT11_MODE_VHT(pReassocReq->dot11mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07002308
2309 /**
2310 * Reassociate request is expected
2311 * in link established state only.
2312 */
2313
2314 if (psessionEntry->limSmeState != eLIM_SME_LINK_EST_STATE)
2315 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002316#if defined(WLAN_FEATURE_VOWIFI_11R) || defined(FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07002317 if (psessionEntry->limSmeState == eLIM_SME_WT_REASSOC_STATE)
2318 {
2319 // May be from 11r FT pre-auth. So lets check it before we bail out
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08002320 limLog(pMac, LOG1, FL("Session in reassoc state is %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002321 psessionEntry->peSessionId);
2322
2323 // Make sure its our preauth bssid
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302324 if (!vos_mem_compare( pReassocReq->bssDescription.bssId,
Jeff Johnson295189b2012-06-20 16:38:30 -07002325 pMac->ft.ftPEContext.pFTPreAuthReq->preAuthbssId, 6))
2326 {
2327 limPrintMacAddr(pMac, pReassocReq->bssDescription.bssId, LOGE);
2328 limPrintMacAddr(pMac, pMac->ft.ftPEContext.pFTPreAuthReq->preAuthbssId, LOGE);
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002329 limLog(pMac, LOGP, FL("Unknown bssId in reassoc state"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002330 retCode = eSIR_SME_INVALID_PARAMETERS;
2331 goto end;
2332 }
2333
2334 limProcessMlmFTReassocReq(pMac, pMsgBuf, psessionEntry);
2335 return;
2336 }
2337#endif
2338 /// Should not have received eWNI_SME_REASSOC_REQ
2339 // Log the event
2340 limLog(pMac, LOGE,
Sushant Kaushik1b645382014-10-13 16:39:36 +05302341 FL("received unexpected SME_REASSOC_REQ in state %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002342 psessionEntry->limSmeState);
2343 limPrintSmeState(pMac, LOGE, psessionEntry->limSmeState);
2344
2345 retCode = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
2346 goto end;
2347 }
2348
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302349 vos_mem_copy( psessionEntry->limReAssocbssId,
Jeff Johnson295189b2012-06-20 16:38:30 -07002350 psessionEntry->pLimReAssocReq->bssDescription.bssId,
2351 sizeof(tSirMacAddr));
2352
2353 psessionEntry->limReassocChannelId =
2354 psessionEntry->pLimReAssocReq->bssDescription.channelId;
2355
Jeff Johnsone7245742012-09-05 17:12:55 -07002356 psessionEntry->reAssocHtSupportedChannelWidthSet =
2357 (psessionEntry->pLimReAssocReq->cbMode)?1:0;
2358 psessionEntry->reAssocHtRecommendedTxWidthSet =
2359 psessionEntry->reAssocHtSupportedChannelWidthSet;
2360 psessionEntry->reAssocHtSecondaryChannelOffset =
2361 psessionEntry->pLimReAssocReq->cbMode;
2362
Jeff Johnson295189b2012-06-20 16:38:30 -07002363 psessionEntry->limReassocBssCaps =
2364 psessionEntry->pLimReAssocReq->bssDescription.capabilityInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07002365 regMax = cfgGetRegulatoryMaxTransmitPower( pMac, psessionEntry->currentOperChannel );
2366 localPowerConstraint = regMax;
Abhishek Singhbad2b322016-10-21 11:22:33 +05302367 limExtractApCapability(pMac,
2368 (tANI_U8 *) psessionEntry->pLimReAssocReq->bssDescription.ieFields,
2369 GET_IE_LEN_IN_BSS(
2370 psessionEntry->pLimReAssocReq->bssDescription.length),
2371 &psessionEntry->limReassocBssQosCaps,
2372 &psessionEntry->limReassocBssPropCap,
2373 &pMac->lim.gLimCurrentBssUapsd,
2374 &localPowerConstraint,
2375 psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07002376
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302377 psessionEntry->maxTxPower = VOS_MIN( regMax, (localPowerConstraint) );
Sushant Kaushikece4b562015-04-09 18:27:33 +05302378 if (!psessionEntry->maxTxPower)
2379 {
2380 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR, FL("Tx power "
2381 "is zero. Setting it to default value %d"),
2382 TX_POWER_DEFAULT);
2383 psessionEntry->maxTxPower = TX_POWER_DEFAULT;
2384 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002385#if defined WLAN_VOWIFI_DEBUG
Abhishek Singh57aebef2014-02-03 18:47:44 +05302386 limLog( pMac, LOGE, "Regulatory max = %d, local power constraint "
2387 "= %d, max tx = %d", regMax, localPowerConstraint,
2388 psessionEntry->maxTxPower );
Jeff Johnson295189b2012-06-20 16:38:30 -07002389#endif
2390 {
2391 #if 0
2392 if (wlan_cfgGetStr(pMac, WNI_CFG_SSID, pMac->lim.gLimReassocSSID.ssId,
2393 &cfgLen) != eSIR_SUCCESS)
2394 {
2395 /// Could not get SSID from CFG. Log error.
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002396 limLog(pMac, LOGP, FL("could not retrive SSID"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002397 }
2398 #endif//TO SUPPORT BT-AMP
2399
2400 /* Copy the SSID from sessio entry to local variable */
2401 #if 0
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302402 vos_mem_copy( pMac->lim.gLimReassocSSID.ssId,
Jeff Johnson295189b2012-06-20 16:38:30 -07002403 psessionEntry->ssId.ssId,
2404 psessionEntry->ssId.length);
2405 #endif
2406 psessionEntry->limReassocSSID.length = pReassocReq->ssId.length;
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302407 vos_mem_copy( psessionEntry->limReassocSSID.ssId,
Jeff Johnson295189b2012-06-20 16:38:30 -07002408 pReassocReq->ssId.ssId, psessionEntry->limReassocSSID.length);
2409
2410 }
2411
2412 if (pMac->lim.gLimCurrentBssUapsd)
2413 {
2414 pMac->lim.gUapsdPerAcBitmask = psessionEntry->pLimReAssocReq->uapsdPerAcBitmask;
Abhishek Singh57aebef2014-02-03 18:47:44 +05302415 limLog( pMac, LOG1, FL("UAPSD flag for all AC - 0x%2x"),
2416 pMac->lim.gUapsdPerAcBitmask);
Jeff Johnson295189b2012-06-20 16:38:30 -07002417 }
2418
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302419 pMlmReassocReq = vos_mem_malloc(sizeof(tLimMlmReassocReq));
2420 if ( NULL == pMlmReassocReq )
Jeff Johnson295189b2012-06-20 16:38:30 -07002421 {
2422 // Log error
2423 limLog(pMac, LOGP,
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302424 FL("call to AllocateMemory failed for mlmReassocReq"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002425
2426 retCode = eSIR_SME_RESOURCES_UNAVAILABLE;
2427 goto end;
2428 }
2429
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302430 vos_mem_copy( pMlmReassocReq->peerMacAddr,
Jeff Johnson295189b2012-06-20 16:38:30 -07002431 psessionEntry->limReAssocbssId,
2432 sizeof(tSirMacAddr));
2433
2434 if (wlan_cfgGetInt(pMac, WNI_CFG_REASSOCIATION_FAILURE_TIMEOUT,
2435 (tANI_U32 *) &pMlmReassocReq->reassocFailureTimeout)
2436 != eSIR_SUCCESS)
2437 {
2438 /**
2439 * Could not get ReassocFailureTimeout value
2440 * from CFG. Log error.
2441 */
2442 limLog(pMac, LOGP,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002443 FL("could not retrieve ReassocFailureTimeout value"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002444 }
2445
2446 if (cfgGetCapabilityInfo(pMac, &caps,psessionEntry) != eSIR_SUCCESS)
2447 {
2448 /**
2449 * Could not get Capabilities value
2450 * from CFG. Log error.
2451 */
2452 limLog(pMac, LOGP,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002453 FL("could not retrieve Capabilities value"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002454 }
Selvaraj, Sridhar5f149192016-04-15 12:53:28 +05302455
2456 lim_update_caps_info_for_bss(pMac, &caps,
2457 pReassocReq->bssDescription.capabilityInfo);
2458
2459 limLog(pMac, LOG1, FL("Capabilities info Reassoc: 0x%X"), caps);
2460
Jeff Johnson295189b2012-06-20 16:38:30 -07002461 pMlmReassocReq->capabilityInfo = caps;
2462
2463 /* Update PE sessionId*/
2464 pMlmReassocReq->sessionId = sessionId;
2465
2466 /* If telescopic beaconing is enabled, set listen interval to
2467 WNI_CFG_TELE_BCN_MAX_LI */
2468 if(wlan_cfgGetInt(pMac, WNI_CFG_TELE_BCN_WAKEUP_EN, &teleBcnEn) !=
2469 eSIR_SUCCESS)
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002470 limLog(pMac, LOGP, FL("Couldn't get WNI_CFG_TELE_BCN_WAKEUP_EN"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002471
2472 val = WNI_CFG_LISTEN_INTERVAL_STADEF;
2473
2474 if(teleBcnEn)
2475 {
2476 if(wlan_cfgGetInt(pMac, WNI_CFG_TELE_BCN_MAX_LI, &val) !=
2477 eSIR_SUCCESS)
2478 {
2479 /**
2480 * Could not get ListenInterval value
2481 * from CFG. Log error.
2482 */
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002483 limLog(pMac, LOGP, FL("could not retrieve ListenInterval"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002484 }
2485 }
2486 else
2487 {
2488 if (wlan_cfgGetInt(pMac, WNI_CFG_LISTEN_INTERVAL, &val) != eSIR_SUCCESS)
2489 {
2490 /**
2491 * Could not get ListenInterval value
2492 * from CFG. Log error.
2493 */
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002494 limLog(pMac, LOGP, FL("could not retrieve ListenInterval"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002495 }
2496 }
2497
2498 /* Delete all BA sessions before Re-Assoc.
2499 * BA frames are class 3 frames and the session
2500 * is lost upon disassociation and reassociation.
2501 */
2502
Ganesh Kondabattini01f75c92014-07-07 19:27:41 +05302503 limDeleteBASessions(pMac, psessionEntry, BA_BOTH_DIRECTIONS,
2504 eSIR_MAC_UNSPEC_FAILURE_REASON);
Jeff Johnson295189b2012-06-20 16:38:30 -07002505
2506 pMlmReassocReq->listenInterval = (tANI_U16) val;
2507
2508 /* Indicate whether spectrum management is enabled*/
2509 psessionEntry->spectrumMgtEnabled = pReassocReq->spectrumMgtIndicator;
2510
Rajesh Babu Prathipati043149f2014-06-06 13:33:45 +05302511 /* Enable the spectrum management if this is a DFS channel */
2512 if (psessionEntry->countryInfoPresent &&
2513 limIsconnectedOnDFSChannel(psessionEntry->currentOperChannel))
2514 {
2515 psessionEntry->spectrumMgtEnabled = TRUE;
2516 }
2517
Jeff Johnson295189b2012-06-20 16:38:30 -07002518 psessionEntry->limPrevSmeState = psessionEntry->limSmeState;
2519 psessionEntry->limSmeState = eLIM_SME_WT_REASSOC_STATE;
2520
Jeff Johnsone7245742012-09-05 17:12:55 -07002521 MTRACE(macTrace(pMac, TRACE_CODE_SME_STATE, psessionEntry->peSessionId, psessionEntry->limSmeState));
Jeff Johnson295189b2012-06-20 16:38:30 -07002522
2523 limPostMlmMessage(pMac,
2524 LIM_MLM_REASSOC_REQ,
2525 (tANI_U32 *) pMlmReassocReq);
2526 return;
2527
2528end:
2529 if (pReassocReq)
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302530 vos_mem_free( pReassocReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07002531
2532 if (psessionEntry)
2533 {
2534 // error occurred after we determined the session so extract
2535 // session and transaction info from there
2536 smeSessionId = psessionEntry->smeSessionId;
2537 transactionId = psessionEntry->transactionId;
2538 }
2539 else
2540 {
2541 // error occurred before or during the time we determined the session
2542 // so extract the session and transaction info from the message
2543 limGetSessionInfo(pMac,(tANI_U8*)pMsgBuf, &smeSessionId, &transactionId);
2544 }
2545
2546 /// Send Reassoc failure response to host
2547 /// (note psessionEntry may be NULL, but that's OK)
2548 limSendSmeJoinReassocRsp(pMac, eWNI_SME_REASSOC_RSP,
2549 retCode, eSIR_MAC_UNSPEC_FAILURE_STATUS,
2550 psessionEntry, smeSessionId, transactionId);
2551
2552} /*** end __limProcessSmeReassocReq() ***/
2553
2554
2555tANI_BOOLEAN sendDisassocFrame = 1;
2556/**
2557 * __limProcessSmeDisassocReq()
2558 *
2559 *FUNCTION:
2560 * This function is called to process SME_DISASSOC_REQ message
2561 * from HDD or upper layer application.
2562 *
2563 *LOGIC:
2564 *
2565 *ASSUMPTIONS:
2566 *
2567 *NOTE:
2568 *
2569 * @param pMac Pointer to Global MAC structure
2570 * @param *pMsgBuf A pointer to the SME message buffer
2571 * @return None
2572 */
2573
2574static void
2575__limProcessSmeDisassocReq(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
2576{
2577 tANI_U16 disassocTrigger, reasonCode;
2578 tLimMlmDisassocReq *pMlmDisassocReq;
2579 tSirResultCodes retCode = eSIR_SME_SUCCESS;
Jeff Johnson43971f52012-07-17 12:26:56 -07002580 tSirRetStatus status;
Jeff Johnson295189b2012-06-20 16:38:30 -07002581 tSirSmeDisassocReq smeDisassocReq;
2582 tpPESession psessionEntry = NULL;
2583 tANI_U8 sessionId;
2584 tANI_U8 smesessionId;
2585 tANI_U16 smetransactionId;
2586
Jeff Johnson295189b2012-06-20 16:38:30 -07002587
Jeff Johnson43971f52012-07-17 12:26:56 -07002588 if (pMsgBuf == NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -07002589 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002590 limLog(pMac, LOGE, FL("Buffer is Pointing to NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002591 return;
2592 }
2593
Jeff Johnson43971f52012-07-17 12:26:56 -07002594 limGetSessionInfo(pMac, (tANI_U8 *)pMsgBuf,&smesessionId, &smetransactionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07002595
Jeff Johnson43971f52012-07-17 12:26:56 -07002596 status = limDisassocReqSerDes(pMac, &smeDisassocReq, (tANI_U8 *) pMsgBuf);
Jeff Johnson295189b2012-06-20 16:38:30 -07002597
Jeff Johnson43971f52012-07-17 12:26:56 -07002598 if ( (eSIR_FAILURE == status) ||
2599 (!limIsSmeDisassocReqValid(pMac, &smeDisassocReq, psessionEntry)) )
Jeff Johnson295189b2012-06-20 16:38:30 -07002600 {
2601 PELOGE(limLog(pMac, LOGE,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002602 FL("received invalid SME_DISASSOC_REQ message"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07002603
2604 if (pMac->lim.gLimRspReqd)
2605 {
2606 pMac->lim.gLimRspReqd = false;
2607
2608 retCode = eSIR_SME_INVALID_PARAMETERS;
2609 disassocTrigger = eLIM_HOST_DISASSOC;
2610 goto sendDisassoc;
2611 }
2612
2613 return;
2614 }
2615
Jeff Johnson295189b2012-06-20 16:38:30 -07002616 if((psessionEntry = peFindSessionByBssid(pMac,smeDisassocReq.bssId,&sessionId))== NULL)
2617 {
Abhishek Singhcd09b562013-12-24 16:02:20 +05302618 limLog(pMac, LOGE,FL("session does not exist for given bssId "MAC_ADDRESS_STR),
2619 MAC_ADDR_ARRAY(smeDisassocReq.bssId));
Jeff Johnson295189b2012-06-20 16:38:30 -07002620 retCode = eSIR_SME_INVALID_PARAMETERS;
2621 disassocTrigger = eLIM_HOST_DISASSOC;
2622 goto sendDisassoc;
2623
2624 }
Abhishek Singhcd09b562013-12-24 16:02:20 +05302625 limLog(pMac, LOG1, FL("received DISASSOC_REQ message on sessionid %d"
2626 "Systemrole %d Reason: %u SmeState: %d from: "MAC_ADDRESS_STR),
2627 smesessionId,psessionEntry->limSystemRole,
2628 smeDisassocReq.reasonCode, pMac->lim.gLimSmeState,
2629 MAC_ADDR_ARRAY(smeDisassocReq.peerMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07002630
2631#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM //FEATURE_WLAN_DIAG_SUPPORT
2632 limDiagEventReport(pMac, WLAN_PE_DIAG_DISASSOC_REQ_EVENT, psessionEntry, 0, smeDisassocReq.reasonCode);
2633#endif //FEATURE_WLAN_DIAG_SUPPORT
2634
2635 /* Update SME session Id and SME transaction ID*/
2636
2637 psessionEntry->smeSessionId = smesessionId;
2638 psessionEntry->transactionId = smetransactionId;
2639
2640 switch (psessionEntry->limSystemRole)
2641 {
2642 case eLIM_STA_ROLE:
2643 case eLIM_BT_AMP_STA_ROLE:
2644 switch (psessionEntry->limSmeState)
2645 {
2646 case eLIM_SME_ASSOCIATED_STATE:
2647 case eLIM_SME_LINK_EST_STATE:
Kanchanapally, Vidyullathac796fc62015-03-17 10:45:28 +05302648 limLog(pMac, LOG1, FL("Rcvd SME_DISASSOC_REQ while in "
2649 "limSmeState: %d "),psessionEntry->limSmeState);
2650
Jeff Johnson295189b2012-06-20 16:38:30 -07002651 psessionEntry->limPrevSmeState = psessionEntry->limSmeState;
2652 psessionEntry->limSmeState= eLIM_SME_WT_DISASSOC_STATE;
Hoonki Lee8c9e99f2013-04-18 22:59:11 -07002653#ifdef FEATURE_WLAN_TDLS
2654 /* Delete all TDLS peers connected before leaving BSS*/
2655 limDeleteTDLSPeers(pMac, psessionEntry);
2656#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07002657 MTRACE(macTrace(pMac, TRACE_CODE_SME_STATE, psessionEntry->peSessionId, psessionEntry->limSmeState));
Jeff Johnson295189b2012-06-20 16:38:30 -07002658 break;
2659
2660 case eLIM_SME_WT_DEAUTH_STATE:
2661 /* PE shall still process the DISASSOC_REQ and proceed with
2662 * link tear down even if it had already sent a DEAUTH_IND to
2663 * to SME. pMac->lim.gLimPrevSmeState shall remain the same as
2664 * its been set when PE entered WT_DEAUTH_STATE.
2665 */
2666 psessionEntry->limSmeState= eLIM_SME_WT_DISASSOC_STATE;
Jeff Johnsone7245742012-09-05 17:12:55 -07002667 MTRACE(macTrace(pMac, TRACE_CODE_SME_STATE, psessionEntry->peSessionId, psessionEntry->limSmeState));
Abhishek Singhcd09b562013-12-24 16:02:20 +05302668 limLog(pMac, LOG1, FL("Rcvd SME_DISASSOC_REQ while in "
2669 "SME_WT_DEAUTH_STATE. "));
Jeff Johnson295189b2012-06-20 16:38:30 -07002670 break;
2671
2672 case eLIM_SME_WT_DISASSOC_STATE:
2673 /* PE Recieved a Disassoc frame. Normally it gets DISASSOC_CNF but it
2674 * received DISASSOC_REQ. Which means host is also trying to disconnect.
2675 * PE can continue processing DISASSOC_REQ and send the response instead
2676 * of failing the request. SME will anyway ignore DEAUTH_IND that was sent
2677 * for disassoc frame.
2678 *
2679 * It will send a disassoc, which is ok. However, we can use the global flag
2680 * sendDisassoc to not send disassoc frame.
2681 */
Abhishek Singhcd09b562013-12-24 16:02:20 +05302682 limLog(pMac, LOG1, FL("Rcvd SME_DISASSOC_REQ while in "
2683 "SME_WT_DISASSOC_STATE. "));
Jeff Johnson295189b2012-06-20 16:38:30 -07002684 break;
2685
2686 case eLIM_SME_JOIN_FAILURE_STATE: {
2687 /** Return Success as we are already in Disconnected State*/
Abhishek Singhcd09b562013-12-24 16:02:20 +05302688 limLog(pMac, LOG1, FL("Rcvd SME_DISASSOC_REQ while in "
2689 "eLIM_SME_JOIN_FAILURE_STATE. "));
Jeff Johnson295189b2012-06-20 16:38:30 -07002690 if (pMac->lim.gLimRspReqd) {
2691 retCode = eSIR_SME_SUCCESS;
2692 disassocTrigger = eLIM_HOST_DISASSOC;
2693 goto sendDisassoc;
2694 }
2695 }break;
2696 default:
2697 /**
2698 * STA is not currently associated.
2699 * Log error and send response to host
2700 */
2701 limLog(pMac, LOGE,
Sushant Kaushik1b645382014-10-13 16:39:36 +05302702 FL("received unexpected SME_DISASSOC_REQ in state %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002703 psessionEntry->limSmeState);
2704 limPrintSmeState(pMac, LOGE, psessionEntry->limSmeState);
2705
2706 if (pMac->lim.gLimRspReqd)
2707 {
2708 if (psessionEntry->limSmeState !=
2709 eLIM_SME_WT_ASSOC_STATE)
2710 pMac->lim.gLimRspReqd = false;
2711
2712 retCode = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
2713 disassocTrigger = eLIM_HOST_DISASSOC;
2714 goto sendDisassoc;
2715 }
2716
2717 return;
2718 }
2719
2720 break;
2721
2722 case eLIM_AP_ROLE:
2723 case eLIM_BT_AMP_AP_ROLE:
2724 // Fall through
2725 break;
2726
2727 case eLIM_STA_IN_IBSS_ROLE:
2728 default: // eLIM_UNKNOWN_ROLE
2729 limLog(pMac, LOGE,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002730 FL("received unexpected SME_DISASSOC_REQ for role %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002731 psessionEntry->limSystemRole);
2732
2733 retCode = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
2734 disassocTrigger = eLIM_HOST_DISASSOC;
2735 goto sendDisassoc;
2736 } // end switch (pMac->lim.gLimSystemRole)
2737
Edhar, Mahesh Kumar03cf7ff2015-11-26 17:59:29 +05302738 disassocTrigger = eLIM_HOST_DISASSOC;
2739 reasonCode = smeDisassocReq.reasonCode;
Jeff Johnson295189b2012-06-20 16:38:30 -07002740
2741 if (smeDisassocReq.doNotSendOverTheAir)
2742 {
Abhishek Singhcd09b562013-12-24 16:02:20 +05302743 limLog(pMac, LOG1, FL("do not send dissoc over the air"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002744 sendDisassocFrame = 0;
2745 }
2746 // Trigger Disassociation frame to peer MAC entity
Sachin Ahuja2fea3d12014-12-18 17:31:31 +05302747 limLog(pMac, LOG1, FL("Sending Disasscoc with disassoc Trigger"
2748 " : %d, reasonCode : %d"),
2749 disassocTrigger, reasonCode);
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302750 pMlmDisassocReq = vos_mem_malloc(sizeof(tLimMlmDisassocReq));
2751 if ( NULL == pMlmDisassocReq )
Jeff Johnson295189b2012-06-20 16:38:30 -07002752 {
2753 // Log error
2754 limLog(pMac, LOGP,
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302755 FL("call to AllocateMemory failed for mlmDisassocReq"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002756
2757 return;
2758 }
2759
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302760 vos_mem_copy( (tANI_U8 *) &pMlmDisassocReq->peerMacAddr,
Jeff Johnson295189b2012-06-20 16:38:30 -07002761 (tANI_U8 *) &smeDisassocReq.peerMacAddr,
2762 sizeof(tSirMacAddr));
2763
2764 pMlmDisassocReq->reasonCode = reasonCode;
2765 pMlmDisassocReq->disassocTrigger = disassocTrigger;
2766
2767 /* Update PE session ID*/
2768 pMlmDisassocReq->sessionId = sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -07002769
2770 limPostMlmMessage(pMac,
2771 LIM_MLM_DISASSOC_REQ,
2772 (tANI_U32 *) pMlmDisassocReq);
2773 return;
2774
2775sendDisassoc:
2776 if (psessionEntry)
2777 limSendSmeDisassocNtf(pMac, smeDisassocReq.peerMacAddr,
2778 retCode,
2779 disassocTrigger,
Jeff Johnson295189b2012-06-20 16:38:30 -07002780 1,smesessionId,smetransactionId,psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07002781 else
2782 limSendSmeDisassocNtf(pMac, smeDisassocReq.peerMacAddr,
2783 retCode,
2784 disassocTrigger,
Sudhir Sattayappa Kohalli5a8ac222013-03-06 12:41:42 -08002785 1, smesessionId, smetransactionId, NULL);
Jeff Johnson295189b2012-06-20 16:38:30 -07002786
2787
2788} /*** end __limProcessSmeDisassocReq() ***/
2789
2790
2791/** -----------------------------------------------------------------
2792 \brief __limProcessSmeDisassocCnf() - Process SME_DISASSOC_CNF
2793
2794 This function is called to process SME_DISASSOC_CNF message
2795 from HDD or upper layer application.
2796
2797 \param pMac - global mac structure
2798 \param pStaDs - station dph hash node
2799 \return none
2800 \sa
2801 ----------------------------------------------------------------- */
2802static void
2803__limProcessSmeDisassocCnf(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
2804{
2805 tSirSmeDisassocCnf smeDisassocCnf;
2806 tANI_U16 aid;
2807 tpDphHashNode pStaDs;
2808 tSirRetStatus status = eSIR_SUCCESS;
2809 tpPESession psessionEntry;
2810 tANI_U8 sessionId;
2811
2812
Abhishek Singh3cbf6052014-12-15 16:46:42 +05302813 limLog(pMac, LOG1, FL("received SME_DISASSOC_CNF message"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002814
2815 status = limDisassocCnfSerDes(pMac, &smeDisassocCnf,(tANI_U8 *) pMsgBuf);
2816
2817 if (status == eSIR_FAILURE)
2818 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002819 PELOGE(limLog(pMac, LOGE, FL("invalid SME_DISASSOC_CNF message"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07002820 return;
2821 }
2822
2823 if((psessionEntry = peFindSessionByBssid(pMac, smeDisassocCnf.bssId, &sessionId))== NULL)
2824 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002825 limLog(pMac, LOGE,FL("session does not exist for given bssId"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002826 return;
2827 }
2828
2829 if (!limIsSmeDisassocCnfValid(pMac, &smeDisassocCnf, psessionEntry))
2830 {
Abhishek Singhcd09b562013-12-24 16:02:20 +05302831 limLog(pMac, LOGE, FL("received invalid SME_DISASSOC_CNF message"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002832 return;
2833 }
2834
2835#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM //FEATURE_WLAN_DIAG_SUPPORT
2836 if (smeDisassocCnf.messageType == eWNI_SME_DISASSOC_CNF)
2837 limDiagEventReport(pMac, WLAN_PE_DIAG_DISASSOC_CNF_EVENT, psessionEntry, (tANI_U16)smeDisassocCnf.statusCode, 0);
2838 else if (smeDisassocCnf.messageType == eWNI_SME_DEAUTH_CNF)
2839 limDiagEventReport(pMac, WLAN_PE_DIAG_DEAUTH_CNF_EVENT, psessionEntry, (tANI_U16)smeDisassocCnf.statusCode, 0);
2840#endif //FEATURE_WLAN_DIAG_SUPPORT
2841
2842 switch (psessionEntry->limSystemRole)
2843 {
2844 case eLIM_STA_ROLE:
2845 case eLIM_BT_AMP_STA_ROLE: //To test reconn
2846 if ((psessionEntry->limSmeState != eLIM_SME_IDLE_STATE) &&
2847 (psessionEntry->limSmeState != eLIM_SME_WT_DISASSOC_STATE) &&
2848 (psessionEntry->limSmeState != eLIM_SME_WT_DEAUTH_STATE))
2849 {
2850 limLog(pMac, LOGE,
Sushant Kaushik1b645382014-10-13 16:39:36 +05302851 FL("received unexp SME_DISASSOC_CNF in state %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002852 psessionEntry->limSmeState);
2853 limPrintSmeState(pMac, LOGE, psessionEntry->limSmeState);
2854 return;
2855 }
2856 break;
2857
2858 case eLIM_AP_ROLE:
2859 // Fall through
Jeff Johnson295189b2012-06-20 16:38:30 -07002860 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07002861
2862 case eLIM_STA_IN_IBSS_ROLE:
2863 default: // eLIM_UNKNOWN_ROLE
2864 limLog(pMac, LOGE,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002865 FL("received unexpected SME_DISASSOC_CNF role %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002866 psessionEntry->limSystemRole);
2867
2868 return;
2869 }
2870
2871
2872 if ( (psessionEntry->limSmeState == eLIM_SME_WT_DISASSOC_STATE) ||
2873 (psessionEntry->limSmeState == eLIM_SME_WT_DEAUTH_STATE)
Jeff Johnson295189b2012-06-20 16:38:30 -07002874 || (psessionEntry->limSystemRole == eLIM_AP_ROLE )
Jeff Johnson295189b2012-06-20 16:38:30 -07002875 )
2876 {
2877 pStaDs = dphLookupHashEntry(pMac, smeDisassocCnf.peerMacAddr, &aid, &psessionEntry->dph.dphHashTable);
2878 if (pStaDs == NULL)
2879 {
Abhishek Singhcd09b562013-12-24 16:02:20 +05302880 PELOGE(limLog(pMac, LOGE, FL("received DISASSOC_CNF for a STA that "
2881 "does not have context, addr= "MAC_ADDRESS_STR),
2882 MAC_ADDR_ARRAY(smeDisassocCnf.peerMacAddr));)
Jeff Johnson295189b2012-06-20 16:38:30 -07002883 return;
2884 }
Wu Gao742b7352015-10-16 19:10:40 +08002885
2886 if(aid != smeDisassocCnf.assocId)
2887 {
2888 PELOGE(limLog(pMac, LOGE, FL("same peerMacAddr but assocId is different "
2889 "aid=%d, assocId=%d, addr= "MAC_ADDRESS_STR),
2890 aid, smeDisassocCnf.assocId, MAC_ADDR_ARRAY(smeDisassocCnf.peerMacAddr));)
2891 return;
2892 }
Padma, Santhosh Kumar05600d32015-07-24 13:00:57 +05302893 /*
2894 * If MlM state is either of del_sta or del_bss state, then no need to
2895 * go ahead and clean up further as there must be some cleanup in
2896 * progress from upper layer disassoc/deauth request.
2897 */
2898 if((pStaDs->mlmStaContext.mlmState == eLIM_MLM_WT_DEL_STA_RSP_STATE) ||
2899 (pStaDs->mlmStaContext.mlmState == eLIM_MLM_WT_DEL_BSS_RSP_STATE))
2900 {
2901 limLog(pMac, LOGE, FL("No need to cleanup for addr:"MAC_ADDRESS_STR
2902 "as Mlm state is %d"),
2903 MAC_ADDR_ARRAY(smeDisassocCnf.peerMacAddr),
2904 pStaDs->mlmStaContext.mlmState);
2905 return;
2906 }
2907
Madan Mohan Koyyalamudi23001722012-10-31 16:48:56 -07002908 /* Delete FT session if there exists one */
2909 limFTCleanup(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -07002910 limCleanupRxPath(pMac, pStaDs, psessionEntry);
Madan Mohan Koyyalamudia67d4332012-11-29 11:35:23 -08002911
2912 limCleanUpDisassocDeauthReq(pMac, (char*)&smeDisassocCnf.peerMacAddr, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07002913 }
2914
2915 return;
2916}
2917
2918
2919/**
2920 * __limProcessSmeDeauthReq()
2921 *
2922 *FUNCTION:
2923 * This function is called to process SME_DEAUTH_REQ message
2924 * from HDD or upper layer application.
2925 *
2926 *LOGIC:
2927 *
2928 *ASSUMPTIONS:
2929 *
2930 *NOTE:
2931 *
2932 * @param pMac Pointer to Global MAC structure
2933 * @param *pMsgBuf A pointer to the SME message buffer
2934 * @return None
2935 */
2936
2937static void
2938__limProcessSmeDeauthReq(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
2939{
2940 tANI_U16 deauthTrigger, reasonCode;
2941 tLimMlmDeauthReq *pMlmDeauthReq;
2942 tSirSmeDeauthReq smeDeauthReq;
2943 tSirResultCodes retCode = eSIR_SME_SUCCESS;
2944 tSirRetStatus status = eSIR_SUCCESS;
2945 tpPESession psessionEntry;
2946 tANI_U8 sessionId; //PE sessionId
2947 tANI_U8 smesessionId;
2948 tANI_U16 smetransactionId;
2949
Jeff Johnson295189b2012-06-20 16:38:30 -07002950
2951 status = limDeauthReqSerDes(pMac, &smeDeauthReq,(tANI_U8 *) pMsgBuf);
Jeff Johnson295189b2012-06-20 16:38:30 -07002952 limGetSessionInfo(pMac,(tANI_U8 *)pMsgBuf,&smesessionId,&smetransactionId);
2953
2954 //We need to get a session first but we don't even know if the message is correct.
2955 if((psessionEntry = peFindSessionByBssid(pMac, smeDeauthReq.bssId, &sessionId)) == NULL)
2956 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002957 limLog(pMac, LOGE,FL("session does not exist for given bssId"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002958 retCode = eSIR_SME_INVALID_PARAMETERS;
2959 deauthTrigger = eLIM_HOST_DEAUTH;
2960 goto sendDeauth;
2961
2962 }
2963
2964 if ((status == eSIR_FAILURE) || (!limIsSmeDeauthReqValid(pMac, &smeDeauthReq, psessionEntry)))
2965 {
Sachin Ahuja42354142015-01-06 19:48:35 +05302966 PELOGE(limLog(pMac, LOGE,FL
2967 ("received invalid SME_DEAUTH_REQ message"));)
2968 pMac->lim.gLimRspReqd = false;
Jeff Johnson295189b2012-06-20 16:38:30 -07002969
Sachin Ahuja42354142015-01-06 19:48:35 +05302970 retCode = eSIR_SME_INVALID_PARAMETERS;
2971 deauthTrigger = eLIM_HOST_DEAUTH;
2972 goto sendDeauth;
Jeff Johnson295189b2012-06-20 16:38:30 -07002973 }
Abhishek Singhcd09b562013-12-24 16:02:20 +05302974 limLog(pMac, LOG1,FL("received DEAUTH_REQ message on sessionid %d "
2975 "Systemrole %d with reasoncode %u in limSmestate %d from "
2976 MAC_ADDRESS_STR), smesessionId, psessionEntry->limSystemRole,
2977 smeDeauthReq.reasonCode, psessionEntry->limSmeState,
2978 MAC_ADDR_ARRAY(smeDeauthReq.peerMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07002979#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM //FEATURE_WLAN_DIAG_SUPPORT
2980 limDiagEventReport(pMac, WLAN_PE_DIAG_DEAUTH_REQ_EVENT, psessionEntry, 0, smeDeauthReq.reasonCode);
2981#endif //FEATURE_WLAN_DIAG_SUPPORT
2982
2983 /* Update SME session ID and Transaction ID */
2984 psessionEntry->smeSessionId = smesessionId;
2985 psessionEntry->transactionId = smetransactionId;
2986
2987
2988 switch (psessionEntry->limSystemRole)
2989 {
2990 case eLIM_STA_ROLE:
2991 case eLIM_BT_AMP_STA_ROLE:
2992
2993 switch (psessionEntry->limSmeState)
2994 {
2995 case eLIM_SME_ASSOCIATED_STATE:
2996 case eLIM_SME_LINK_EST_STATE:
2997 case eLIM_SME_WT_ASSOC_STATE:
2998 case eLIM_SME_JOIN_FAILURE_STATE:
2999 case eLIM_SME_IDLE_STATE:
3000 psessionEntry->limPrevSmeState = psessionEntry->limSmeState;
3001 psessionEntry->limSmeState = eLIM_SME_WT_DEAUTH_STATE;
Varun Reddy Yeturue3bbf6e2013-02-08 18:50:55 -08003002 MTRACE(macTrace(pMac, TRACE_CODE_SME_STATE, psessionEntry->peSessionId, psessionEntry->limSmeState));
Jeff Johnson295189b2012-06-20 16:38:30 -07003003
3004 // Send Deauthentication request to MLM below
3005
3006 break;
Sachin Ahujaa100dcc2014-07-03 14:30:18 +05303007 case eLIM_SME_WT_DEAUTH_STATE:
3008 /*
3009 * PE Recieved a Deauth frame. Normally it gets
3010 * DEAUTH_CNF but it received DEAUTH_REQ. Which
3011 * means host is also trying to disconnect.
3012 * PE can continue processing DEAUTH_REQ and send
3013 * the response instead of failing the request.
3014 * SME will anyway ignore DEAUTH_IND that was sent
3015 * for deauth frame.
3016 */
3017 limLog(pMac, LOG1, FL("Rcvd SME_DEAUTH_REQ while in "
3018 "SME_WT_DEAUTH_STATE. "));
3019 break;
Padma, Santhosh Kumar05600d32015-07-24 13:00:57 +05303020 case eLIM_SME_WT_DISASSOC_STATE:
3021 /*
3022 * PE Recieved a Disassoc frame. Normally it gets
3023 * DISASSOC_CNF but it received DEAUTH_REQ. This means
3024 * host is also trying to disconnect.
3025 */
3026 limLog(pMac, LOG1, FL("Rcvd SME_DEAUTH_REQ while in "
3027 "SME_WT_DISASSOC_STATE. "));
3028 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003029 default:
3030 /**
3031 * STA is not in a state to deauthenticate with
3032 * peer. Log error and send response to host.
3033 */
3034 limLog(pMac, LOGE,
Sushant Kaushik1b645382014-10-13 16:39:36 +05303035 FL("received unexp SME_DEAUTH_REQ in state %d"),
Abhishek Singhcd09b562013-12-24 16:02:20 +05303036 psessionEntry->limSmeState);
Jeff Johnson295189b2012-06-20 16:38:30 -07003037 limPrintSmeState(pMac, LOGE, psessionEntry->limSmeState);
3038
3039 if (pMac->lim.gLimRspReqd)
3040 {
3041 pMac->lim.gLimRspReqd = false;
3042
3043 retCode = eSIR_SME_STA_NOT_AUTHENTICATED;
3044 deauthTrigger = eLIM_HOST_DEAUTH;
Leela Venkata Kiran Kumar Reddy Chirala56df73f2014-01-30 14:18:00 -08003045 /**
3046 *here we received deauth request from AP so sme state is
3047 eLIM_SME_WT_DEAUTH_STATE.if we have ISSUED delSta then
3048 mlm state should be eLIM_MLM_WT_DEL_STA_RSP_STATE and if
3049 we got delBSS rsp then mlm state should be eLIM_MLM_IDLE_STATE
3050 so the below condition captures the state where delSta
3051 not done and firmware still in connected state.
3052 */
3053 if (psessionEntry->limSmeState == eLIM_SME_WT_DEAUTH_STATE &&
3054 psessionEntry->limMlmState != eLIM_MLM_IDLE_STATE &&
3055 psessionEntry->limMlmState != eLIM_MLM_WT_DEL_STA_RSP_STATE)
3056 {
3057 retCode = eSIR_SME_DEAUTH_STATUS;
3058 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003059 goto sendDeauth;
3060 }
3061
3062 return;
3063 }
3064
3065 break;
3066
3067 case eLIM_STA_IN_IBSS_ROLE:
Abhishek Singh92fbac22015-03-24 17:57:36 +05303068 limLog(pMac, LOGE,FL("Deauth not allowed in IBSS"));
3069 if (pMac->lim.gLimRspReqd)
3070 {
3071 pMac->lim.gLimRspReqd = false;
3072 retCode = eSIR_SME_INVALID_PARAMETERS;
3073 deauthTrigger = eLIM_HOST_DEAUTH;
3074 goto sendDeauth;
3075 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003076 return;
3077
3078 case eLIM_AP_ROLE:
3079 // Fall through
3080
3081 break;
3082
3083 default:
3084 limLog(pMac, LOGE,
Sushant Kaushik1b645382014-10-13 16:39:36 +05303085 FL("received unexpected SME_DEAUTH_REQ for role %d"),
Abhishek Singhcd09b562013-12-24 16:02:20 +05303086 psessionEntry->limSystemRole);
Abhishek Singh92fbac22015-03-24 17:57:36 +05303087 if (pMac->lim.gLimRspReqd)
3088 {
3089 pMac->lim.gLimRspReqd = false;
Jeff Johnson295189b2012-06-20 16:38:30 -07003090
Abhishek Singh92fbac22015-03-24 17:57:36 +05303091 retCode = eSIR_SME_INVALID_PARAMETERS;
3092 deauthTrigger = eLIM_HOST_DEAUTH;
3093 goto sendDeauth;
3094 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003095 return;
Abhishek Singh92fbac22015-03-24 17:57:36 +05303096
Jeff Johnson295189b2012-06-20 16:38:30 -07003097 } // end switch (pMac->lim.gLimSystemRole)
3098
3099 if (smeDeauthReq.reasonCode == eLIM_LINK_MONITORING_DEAUTH)
3100 {
3101 /// Deauthentication is triggered by Link Monitoring
Abhishek Singh3cbf6052014-12-15 16:46:42 +05303102 limLog(pMac, LOG1,
3103 FL("Deauthentication is triggered by Link Monitoring"));
3104 limLog(pMac, LOG1,
3105 FL("Set Trigger to eLIM_LINK_MONITORING_DEAUTH"));
3106 limLog(pMac, LOG1,
3107 FL("and Reason to eSIR_MAC_UNSPEC_FAILURE_REASON"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003108 deauthTrigger = eLIM_LINK_MONITORING_DEAUTH;
3109 reasonCode = eSIR_MAC_UNSPEC_FAILURE_REASON;
3110 }
3111 else
3112 {
3113 deauthTrigger = eLIM_HOST_DEAUTH;
3114 reasonCode = smeDeauthReq.reasonCode;
3115 }
3116
3117 // Trigger Deauthentication frame to peer MAC entity
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303118 pMlmDeauthReq = vos_mem_malloc(sizeof(tLimMlmDeauthReq));
3119 if ( NULL == pMlmDeauthReq )
Jeff Johnson295189b2012-06-20 16:38:30 -07003120 {
3121 // Log error
Abhishek Singh92fbac22015-03-24 17:57:36 +05303122 limLog(pMac, LOGE,
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303123 FL("call to AllocateMemory failed for mlmDeauthReq"));
Abhishek Singh92fbac22015-03-24 17:57:36 +05303124 if (pMac->lim.gLimRspReqd)
3125 {
3126 pMac->lim.gLimRspReqd = false;
3127 retCode = eSIR_SME_RESOURCES_UNAVAILABLE;
3128 deauthTrigger = eLIM_HOST_DEAUTH;
3129 goto sendDeauth;
3130 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003131 return;
3132 }
3133
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303134 vos_mem_copy( (tANI_U8 *) &pMlmDeauthReq->peerMacAddr,
Jeff Johnson295189b2012-06-20 16:38:30 -07003135 (tANI_U8 *) &smeDeauthReq.peerMacAddr,
3136 sizeof(tSirMacAddr));
3137
3138 pMlmDeauthReq->reasonCode = reasonCode;
3139 pMlmDeauthReq->deauthTrigger = deauthTrigger;
Jeff Johnson295189b2012-06-20 16:38:30 -07003140
3141 /* Update PE session Id*/
3142 pMlmDeauthReq->sessionId = sessionId;
3143
3144 limPostMlmMessage(pMac,
3145 LIM_MLM_DEAUTH_REQ,
3146 (tANI_U32 *) pMlmDeauthReq);
3147 return;
3148
3149sendDeauth:
3150 limSendSmeDeauthNtf(pMac, smeDeauthReq.peerMacAddr,
3151 retCode,
3152 deauthTrigger,
Jeff Johnson295189b2012-06-20 16:38:30 -07003153 1,
Jeff Johnson295189b2012-06-20 16:38:30 -07003154 smesessionId, smetransactionId);
3155} /*** end __limProcessSmeDeauthReq() ***/
3156
3157
3158
3159/**
3160 * __limProcessSmeSetContextReq()
3161 *
3162 *FUNCTION:
3163 * This function is called to process SME_SETCONTEXT_REQ message
3164 * from HDD or upper layer application.
3165 *
3166 *LOGIC:
3167 *
3168 *ASSUMPTIONS:
3169 *
3170 *NOTE:
3171 *
3172 * @param pMac Pointer to Global MAC structure
3173 * @param *pMsgBuf A pointer to the SME message buffer
3174 * @return None
3175 */
3176
3177static void
3178__limProcessSmeSetContextReq(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
3179{
3180 tpSirSmeSetContextReq pSetContextReq;
3181 tLimMlmSetKeysReq *pMlmSetKeysReq;
3182 tpPESession psessionEntry;
3183 tANI_U8 sessionId; //PE sessionID
3184 tANI_U8 smesessionId;
3185 tANI_U16 smetransactionId;
3186
3187
3188 PELOG1(limLog(pMac, LOG1,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003189 FL("received SETCONTEXT_REQ message")););
Jeff Johnson295189b2012-06-20 16:38:30 -07003190
3191
3192 if(pMsgBuf == NULL)
3193 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003194 limLog(pMac, LOGE,FL("Buffer is Pointing to NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003195 return;
3196 }
3197
3198 limGetSessionInfo(pMac,(tANI_U8 *)pMsgBuf,&smesessionId,&smetransactionId);
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303199
3200 pSetContextReq = vos_mem_malloc(sizeof(tSirKeys) * SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS);
3201 if ( NULL == pSetContextReq )
Jeff Johnson295189b2012-06-20 16:38:30 -07003202 {
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303203 limLog(pMac, LOGP, FL("call to AllocateMemory failed for pSetContextReq"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003204 return;
3205 }
3206
3207 if ((limSetContextReqSerDes(pMac, pSetContextReq, (tANI_U8 *) pMsgBuf) == eSIR_FAILURE) ||
3208 (!limIsSmeSetContextReqValid(pMac, pSetContextReq)))
3209 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003210 limLog(pMac, LOGW, FL("received invalid SME_SETCONTEXT_REQ message"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003211 goto end;
3212 }
3213
3214 if(pSetContextReq->keyMaterial.numKeys > SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS)
3215 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003216 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 -07003217 limSendSmeSetContextRsp(pMac,
3218 pSetContextReq->peerMacAddr,
Jeff Johnson295189b2012-06-20 16:38:30 -07003219 1,
Jeff Johnson295189b2012-06-20 16:38:30 -07003220 eSIR_SME_INVALID_PARAMETERS,NULL,
3221 smesessionId,smetransactionId);
3222
3223 goto end;
3224 }
3225
3226
3227 if((psessionEntry = peFindSessionByBssid(pMac, pSetContextReq->bssId, &sessionId)) == NULL)
3228 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003229 limLog(pMac, LOGW, FL("Session does not exist for given BSSID"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003230 limSendSmeSetContextRsp(pMac,
3231 pSetContextReq->peerMacAddr,
Jeff Johnson295189b2012-06-20 16:38:30 -07003232 1,
Jeff Johnson295189b2012-06-20 16:38:30 -07003233 eSIR_SME_INVALID_PARAMETERS,NULL,
3234 smesessionId,smetransactionId);
3235
3236 goto end;
3237 }
3238
3239#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM //FEATURE_WLAN_DIAG_SUPPORT
3240 limDiagEventReport(pMac, WLAN_PE_DIAG_SETCONTEXT_REQ_EVENT, psessionEntry, 0, 0);
3241#endif //FEATURE_WLAN_DIAG_SUPPORT
3242
3243
3244 if ((((psessionEntry->limSystemRole == eLIM_STA_ROLE) || (psessionEntry->limSystemRole == eLIM_BT_AMP_STA_ROLE)) &&
3245 (psessionEntry->limSmeState == eLIM_SME_LINK_EST_STATE)) ||
3246 (((psessionEntry->limSystemRole == eLIM_STA_IN_IBSS_ROLE) ||
3247 (psessionEntry->limSystemRole == eLIM_AP_ROLE)|| (psessionEntry->limSystemRole == eLIM_BT_AMP_AP_ROLE)) &&
3248 (psessionEntry->limSmeState == eLIM_SME_NORMAL_STATE)))
3249 {
3250 // Trigger MLM_SETKEYS_REQ
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303251 pMlmSetKeysReq = vos_mem_malloc(sizeof(tLimMlmSetKeysReq));
3252 if ( NULL == pMlmSetKeysReq )
Jeff Johnson295189b2012-06-20 16:38:30 -07003253 {
3254 // Log error
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303255 limLog(pMac, LOGP, FL("call to AllocateMemory failed for mlmSetKeysReq"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003256 goto end;
3257 }
Abhishek Singhb25e8442015-06-23 14:28:05 +05303258 vos_mem_zero(pMlmSetKeysReq,sizeof(tLimMlmSetKeysReq));
Jeff Johnson295189b2012-06-20 16:38:30 -07003259 pMlmSetKeysReq->edType = pSetContextReq->keyMaterial.edType;
3260 pMlmSetKeysReq->numKeys = pSetContextReq->keyMaterial.numKeys;
3261 if(pMlmSetKeysReq->numKeys > SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS)
3262 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003263 limLog(pMac, LOGP, FL("Num of keys exceeded max num of default keys limit"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003264 goto end;
3265 }
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303266 vos_mem_copy( (tANI_U8 *) &pMlmSetKeysReq->peerMacAddr,
Jeff Johnson295189b2012-06-20 16:38:30 -07003267 (tANI_U8 *) &pSetContextReq->peerMacAddr,
3268 sizeof(tSirMacAddr));
3269
Jeff Johnson295189b2012-06-20 16:38:30 -07003270
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303271 vos_mem_copy( (tANI_U8 *) &pMlmSetKeysReq->key,
Jeff Johnson295189b2012-06-20 16:38:30 -07003272 (tANI_U8 *) &pSetContextReq->keyMaterial.key,
3273 sizeof(tSirKeys) * (pMlmSetKeysReq->numKeys ? pMlmSetKeysReq->numKeys : 1));
3274
3275 pMlmSetKeysReq->sessionId = sessionId;
3276#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
3277 PELOG1(limLog(pMac, LOG1,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003278 FL("received SETCONTEXT_REQ message sessionId=%d"), pMlmSetKeysReq->sessionId););
Jeff Johnson295189b2012-06-20 16:38:30 -07003279#endif
3280
Jeff Johnson295189b2012-06-20 16:38:30 -07003281 if(((pSetContextReq->keyMaterial.edType == eSIR_ED_WEP40) || (pSetContextReq->keyMaterial.edType == eSIR_ED_WEP104))
3282 && (psessionEntry->limSystemRole == eLIM_AP_ROLE))
3283 {
3284 if(pSetContextReq->keyMaterial.key[0].keyLength)
3285 {
3286 tANI_U8 keyId;
3287 keyId = pSetContextReq->keyMaterial.key[0].keyId;
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303288 vos_mem_copy( (tANI_U8 *)&psessionEntry->WEPKeyMaterial[keyId],
Jeff Johnson295189b2012-06-20 16:38:30 -07003289 (tANI_U8 *) &pSetContextReq->keyMaterial, sizeof(tSirKeyMaterial));
3290 }
3291 else {
3292 tANI_U32 i;
3293 for( i = 0; i < SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS; i++)
3294 {
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303295 vos_mem_copy( (tANI_U8 *) &pMlmSetKeysReq->key[i],
Jeff Johnson295189b2012-06-20 16:38:30 -07003296 (tANI_U8 *)psessionEntry->WEPKeyMaterial[i].key, sizeof(tSirKeys));
3297 }
3298 }
3299 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003300
3301 limPostMlmMessage(pMac, LIM_MLM_SETKEYS_REQ, (tANI_U32 *) pMlmSetKeysReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07003302 }
3303 else
3304 {
3305 limLog(pMac, LOGE,
Sushant Kaushik1b645382014-10-13 16:39:36 +05303306 FL("received unexpected SME_SETCONTEXT_REQ for role %d, state=%d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07003307 psessionEntry->limSystemRole,
3308 psessionEntry->limSmeState);
3309 limPrintSmeState(pMac, LOGE, psessionEntry->limSmeState);
3310
3311 limSendSmeSetContextRsp(pMac, pSetContextReq->peerMacAddr,
Jeff Johnson295189b2012-06-20 16:38:30 -07003312 1,
Jeff Johnson295189b2012-06-20 16:38:30 -07003313 eSIR_SME_UNEXPECTED_REQ_RESULT_CODE,psessionEntry,
3314 smesessionId,
3315 smetransactionId);
3316 }
3317
3318end:
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05303319 vos_mem_zero(pSetContextReq,
3320 (sizeof(tSirKeys) * SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS));
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303321 vos_mem_free( pSetContextReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07003322 return;
3323} /*** end __limProcessSmeSetContextReq() ***/
3324
3325/**
3326 * __limProcessSmeRemoveKeyReq()
3327 *
3328 *FUNCTION:
3329 * This function is called to process SME_REMOVEKEY_REQ message
3330 * from HDD or upper layer application.
3331 *
3332 *LOGIC:
3333 *
3334 *ASSUMPTIONS:
3335 *
3336 *NOTE:
3337 *
3338 * @param pMac Pointer to Global MAC structure
3339 * @param *pMsgBuf A pointer to the SME message buffer
3340 * @return None
3341 */
3342
3343static void
3344__limProcessSmeRemoveKeyReq(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
3345{
3346 tpSirSmeRemoveKeyReq pRemoveKeyReq;
3347 tLimMlmRemoveKeyReq *pMlmRemoveKeyReq;
3348 tpPESession psessionEntry;
3349 tANI_U8 sessionId; //PE sessionID
3350 tANI_U8 smesessionId;
3351 tANI_U16 smetransactionId;
3352
Abhishek Singh3cbf6052014-12-15 16:46:42 +05303353 limLog(pMac, LOG1,
3354 FL("received SME_REMOVEKEY_REQ message"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003355
3356 if(pMsgBuf == NULL)
3357 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003358 limLog(pMac, LOGE,FL("Buffer is Pointing to NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003359 return;
3360 }
3361
3362
3363 limGetSessionInfo(pMac,(tANI_U8 *)pMsgBuf,&smesessionId,&smetransactionId);
3364
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303365 pRemoveKeyReq = vos_mem_malloc(sizeof(*pRemoveKeyReq));
3366 if ( NULL == pRemoveKeyReq )
Jeff Johnson295189b2012-06-20 16:38:30 -07003367 {
3368 //Log error
3369 limLog(pMac, LOGP,
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303370 FL("call to AllocateMemory failed for pRemoveKeyReq"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003371
3372 return;
3373 }
3374
3375 if ((limRemoveKeyReqSerDes(pMac,
3376 pRemoveKeyReq,
3377 (tANI_U8 *) pMsgBuf) == eSIR_FAILURE))
3378 {
3379 limLog(pMac, LOGW,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003380 FL("received invalid SME_REMOVECONTEXT_REQ message"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003381
3382 /* extra look up is needed since, session entry to be passed il limsendremovekey response */
3383
3384 if((psessionEntry = peFindSessionByBssid(pMac,pRemoveKeyReq->bssId,&sessionId))== NULL)
3385 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003386 limLog(pMac, LOGE,FL("session does not exist for given bssId"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003387 //goto end;
3388 }
3389
3390 limSendSmeRemoveKeyRsp(pMac,
3391 pRemoveKeyReq->peerMacAddr,
3392 eSIR_SME_INVALID_PARAMETERS,psessionEntry,
3393 smesessionId,smetransactionId);
3394
3395 goto end;
3396 }
3397
3398 if((psessionEntry = peFindSessionByBssid(pMac,pRemoveKeyReq->bssId, &sessionId))== NULL)
3399 {
3400 limLog(pMac, LOGE,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003401 FL("session does not exist for given bssId"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003402 limSendSmeRemoveKeyRsp(pMac,
3403 pRemoveKeyReq->peerMacAddr,
3404 eSIR_SME_UNEXPECTED_REQ_RESULT_CODE, NULL,
3405 smesessionId, smetransactionId);
3406 goto end;
3407 }
3408
3409
3410 if ((((psessionEntry->limSystemRole == eLIM_STA_ROLE)|| (psessionEntry->limSystemRole == eLIM_BT_AMP_STA_ROLE))&&
3411 (psessionEntry->limSmeState == eLIM_SME_LINK_EST_STATE)) ||
3412 (((psessionEntry->limSystemRole == eLIM_STA_IN_IBSS_ROLE) ||
3413 (psessionEntry->limSystemRole == eLIM_AP_ROLE)|| (psessionEntry->limSystemRole == eLIM_BT_AMP_AP_ROLE)) &&
3414 (psessionEntry->limSmeState == eLIM_SME_NORMAL_STATE)))
3415 {
3416 // Trigger MLM_REMOVEKEYS_REQ
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303417 pMlmRemoveKeyReq = vos_mem_malloc(sizeof(tLimMlmRemoveKeyReq));
3418 if ( NULL == pMlmRemoveKeyReq )
Jeff Johnson295189b2012-06-20 16:38:30 -07003419 {
3420 // Log error
3421 limLog(pMac, LOGP,
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303422 FL("call to AllocateMemory failed for mlmRemoveKeysReq"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003423
3424 goto end;
3425 }
3426
3427 pMlmRemoveKeyReq->edType = (tAniEdType)pRemoveKeyReq->edType;
3428 pMlmRemoveKeyReq->keyId = pRemoveKeyReq->keyId;
3429 pMlmRemoveKeyReq->wepType = pRemoveKeyReq->wepType;
3430 pMlmRemoveKeyReq->unicast = pRemoveKeyReq->unicast;
3431
3432 /* Update PE session Id */
3433 pMlmRemoveKeyReq->sessionId = sessionId;
3434
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303435 vos_mem_copy( (tANI_U8 *) &pMlmRemoveKeyReq->peerMacAddr,
Jeff Johnson295189b2012-06-20 16:38:30 -07003436 (tANI_U8 *) &pRemoveKeyReq->peerMacAddr,
3437 sizeof(tSirMacAddr));
3438
3439
3440 limPostMlmMessage(pMac,
3441 LIM_MLM_REMOVEKEY_REQ,
3442 (tANI_U32 *) pMlmRemoveKeyReq);
3443 }
3444 else
3445 {
3446 limLog(pMac, LOGE,
Sushant Kaushik1b645382014-10-13 16:39:36 +05303447 FL("received unexpected SME_REMOVEKEY_REQ for role %d, state=%d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07003448 psessionEntry->limSystemRole,
3449 psessionEntry->limSmeState);
3450 limPrintSmeState(pMac, LOGE, psessionEntry->limSmeState);
3451
3452 limSendSmeRemoveKeyRsp(pMac,
3453 pRemoveKeyReq->peerMacAddr,
3454 eSIR_SME_UNEXPECTED_REQ_RESULT_CODE,psessionEntry,
3455 smesessionId,smetransactionId);
3456 }
3457
3458end:
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303459 vos_mem_free( pRemoveKeyReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07003460} /*** end __limProcessSmeRemoveKeyReq() ***/
3461
Jeff Johnson295189b2012-06-20 16:38:30 -07003462void limProcessSmeGetScanChannelInfo(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
3463{
3464 tSirMsgQ mmhMsg;
3465 tpSmeGetScanChnRsp pSirSmeRsp;
3466 tANI_U16 len = 0;
Madan Mohan Koyyalamudide1b5bc2013-07-12 00:56:04 +05303467 tANI_U8 sessionId;
3468 tANI_U16 transactionId;
Jeff Johnson295189b2012-06-20 16:38:30 -07003469
3470 if(pMac->lim.scanChnInfo.numChnInfo > SIR_MAX_SUPPORTED_CHANNEL_LIST)
3471 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003472 limLog(pMac, LOGW, FL("numChn is out of bounds %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07003473 pMac->lim.scanChnInfo.numChnInfo);
3474 pMac->lim.scanChnInfo.numChnInfo = SIR_MAX_SUPPORTED_CHANNEL_LIST;
3475 }
3476
Abhishek Singh525045c2014-12-15 17:18:45 +05303477 limLog(pMac, LOG1,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003478 FL("Sending message %s with number of channels %d"),
Abhishek Singh525045c2014-12-15 17:18:45 +05303479 limMsgStr(eWNI_SME_GET_SCANNED_CHANNEL_RSP), pMac->lim.scanChnInfo.numChnInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -07003480
3481 len = sizeof(tSmeGetScanChnRsp) + (pMac->lim.scanChnInfo.numChnInfo - 1) * sizeof(tLimScanChn);
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303482 pSirSmeRsp = vos_mem_malloc(len);
3483 if ( NULL == pSirSmeRsp )
Jeff Johnson295189b2012-06-20 16:38:30 -07003484 {
3485 /// Buffer not available. Log error
3486 limLog(pMac, LOGP,
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303487 FL("call to AllocateMemory failed for JOIN/REASSOC_RSP"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003488
3489 return;
3490 }
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303491 vos_mem_set(pSirSmeRsp, len, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07003492
Jeff Johnson295189b2012-06-20 16:38:30 -07003493 pSirSmeRsp->mesgType = eWNI_SME_GET_SCANNED_CHANNEL_RSP;
3494 pSirSmeRsp->mesgLen = len;
Madan Mohan Koyyalamudide1b5bc2013-07-12 00:56:04 +05303495
3496 if (pMac->fScanOffload)
3497 {
3498 limGetSessionInfo(pMac,(tANI_U8 *)pMsgBuf,&sessionId,&transactionId);
3499 pSirSmeRsp->sessionId = sessionId;
3500 }
3501 else
3502 pSirSmeRsp->sessionId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003503
3504 if(pMac->lim.scanChnInfo.numChnInfo)
3505 {
3506 pSirSmeRsp->numChn = pMac->lim.scanChnInfo.numChnInfo;
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303507 vos_mem_copy( pSirSmeRsp->scanChn, pMac->lim.scanChnInfo.scanChn,
3508 sizeof(tLimScanChn) * pSirSmeRsp->numChn);
Jeff Johnson295189b2012-06-20 16:38:30 -07003509 }
3510 //Clear the list
3511 limRessetScanChannelInfo(pMac);
3512
3513 mmhMsg.type = eWNI_SME_GET_SCANNED_CHANNEL_RSP;
3514 mmhMsg.bodyptr = pSirSmeRsp;
3515 mmhMsg.bodyval = 0;
3516
3517 pMac->lim.gLimRspReqd = false;
Konamki, Sreelakshmi824f93e2015-07-31 12:55:48 +05303518 MTRACE(macTrace(pMac, TRACE_CODE_TX_SME_MSG, NO_SESSION, mmhMsg.type));
Jeff Johnson295189b2012-06-20 16:38:30 -07003519 limSysProcessMmhMsgApi(pMac, &mmhMsg, ePROT);
3520}
3521
3522
Jeff Johnson295189b2012-06-20 16:38:30 -07003523void limProcessSmeGetAssocSTAsInfo(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
3524{
Hanumantha Reddy Pothula0de10802016-02-11 17:29:27 +05303525 tSirSmeGetAssocSTAsReq getAssocSTAsReq = {0};
Jeff Johnson295189b2012-06-20 16:38:30 -07003526 tpDphHashNode pStaDs = NULL;
3527 tpPESession psessionEntry = NULL;
3528 tSap_Event sapEvent;
3529 tpWLAN_SAPEventCB pSapEventCallback = NULL;
3530 tpSap_AssocMacAddr pAssocStasTemp = NULL;// #include "sapApi.h"
3531 tANI_U8 sessionId = CSR_SESSION_ID_INVALID;
3532 tANI_U8 assocId = 0;
3533 tANI_U8 staCount = 0;
3534
3535 if (!limIsSmeGetAssocSTAsReqValid(pMac, &getAssocSTAsReq, (tANI_U8 *) pMsgBuf))
3536 {
3537 limLog(pMac, LOGE,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003538 FL("received invalid eWNI_SME_GET_ASSOC_STAS_REQ message"));
Girish Gowliafd42312014-07-24 13:13:59 +05303539 return;
Jeff Johnson295189b2012-06-20 16:38:30 -07003540 }
3541
3542 switch (getAssocSTAsReq.modId)
3543 {
3544/**
3545 case VOS_MODULE_ID_HAL:
3546 wdaPostCtrlMsg( pMac, &msgQ );
3547 return;
3548
3549 case VOS_MODULE_ID_TL:
3550 Post msg TL
3551 return;
3552*/
3553 case VOS_MODULE_ID_PE:
3554 default:
3555 break;
3556 }
3557
Jeff Johnson1250df42012-12-10 14:31:52 -08003558 // Get Associated stations from PE
Jeff Johnson295189b2012-06-20 16:38:30 -07003559 // Find PE session Entry
3560 if ((psessionEntry = peFindSessionByBssid(pMac, getAssocSTAsReq.bssId, &sessionId)) == NULL)
3561 {
3562 limLog(pMac, LOGE,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003563 FL("session does not exist for given bssId"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003564 goto limAssocStaEnd;
3565 }
3566
3567 if (psessionEntry->limSystemRole != eLIM_AP_ROLE)
3568 {
3569 limLog(pMac, LOGE,
Sushant Kaushik1b645382014-10-13 16:39:36 +05303570 FL("Received unexpected message in state %d, in role %d"),
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303571 psessionEntry->limSmeState, psessionEntry->limSystemRole);
Jeff Johnson295189b2012-06-20 16:38:30 -07003572 goto limAssocStaEnd;
3573 }
3574
3575 // Retrieve values obtained in the request message
3576 pSapEventCallback = (tpWLAN_SAPEventCB)getAssocSTAsReq.pSapEventCallback;
3577 pAssocStasTemp = (tpSap_AssocMacAddr)getAssocSTAsReq.pAssocStasArray;
3578
3579 for (assocId = 0; assocId < psessionEntry->dph.dphHashTable.size; assocId++)// Softap dphHashTable.size = 8
3580 {
3581 pStaDs = dphGetHashEntry(pMac, assocId, &psessionEntry->dph.dphHashTable);
3582
Abhishek Singh8a99b9f2015-03-31 14:18:26 +05303583 if ((NULL == pStaDs) || (NULL == pAssocStasTemp))
Jeff Johnson295189b2012-06-20 16:38:30 -07003584 continue;
3585
3586 if (pStaDs->valid)
3587 {
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303588 vos_mem_copy((tANI_U8 *)&pAssocStasTemp->staMac,
3589 (tANI_U8 *)&pStaDs->staAddr,
3590 sizeof(v_MACADDR_t)); // Mac address
Jeff Johnson295189b2012-06-20 16:38:30 -07003591 pAssocStasTemp->assocId = (v_U8_t)pStaDs->assocId; // Association Id
3592 pAssocStasTemp->staId = (v_U8_t)pStaDs->staIndex; // Station Id
3593
Kiet Lamb1233192013-11-28 13:38:20 +05303594 vos_mem_copy((tANI_U8 *)&pAssocStasTemp->supportedRates,
Leo Chang614d2072013-08-22 14:59:44 -07003595 (tANI_U8 *)&pStaDs->supportedRates,
3596 sizeof(tSirSupportedRates));
3597 pAssocStasTemp->ShortGI40Mhz = pStaDs->htShortGI40Mhz;
3598 pAssocStasTemp->ShortGI20Mhz = pStaDs->htShortGI20Mhz;
3599 pAssocStasTemp->Support40Mhz = pStaDs->htDsssCckRate40MHzSupport;
3600
Jeff Johnson295189b2012-06-20 16:38:30 -07003601 limLog(pMac, LOG1, FL("dph Station Number = %d"), staCount+1);
Arif Hussain24bafea2013-11-15 15:10:03 -08003602 limLog(pMac, LOG1, FL("MAC = " MAC_ADDRESS_STR),
3603 MAC_ADDR_ARRAY(pStaDs->staAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07003604 limLog(pMac, LOG1, FL("Association Id = %d"),pStaDs->assocId);
3605 limLog(pMac, LOG1, FL("Station Index = %d"),pStaDs->staIndex);
3606
3607 pAssocStasTemp++;
3608 staCount++;
3609 }
3610 }
3611
3612limAssocStaEnd:
3613 // Call hdd callback with sap event to send the list of associated stations from PE
3614 if (pSapEventCallback != NULL)
3615 {
3616 sapEvent.sapHddEventCode = eSAP_ASSOC_STA_CALLBACK_EVENT;
3617 sapEvent.sapevt.sapAssocStaListEvent.module = VOS_MODULE_ID_PE;
3618 sapEvent.sapevt.sapAssocStaListEvent.noOfAssocSta = staCount;
3619 sapEvent.sapevt.sapAssocStaListEvent.pAssocStas = (tpSap_AssocMacAddr)getAssocSTAsReq.pAssocStasArray;
3620 pSapEventCallback(&sapEvent, getAssocSTAsReq.pUsrContext);
3621 }
3622}
3623
3624
3625/**
3626 * limProcessSmeGetWPSPBCSessions
3627 *
3628 *FUNCTION:
3629 * This function is called when query the WPS PBC overlap message is received
3630 *
3631 *LOGIC:
3632 * This function parses get WPS PBC overlap information message and call callback to pass
3633 * WPS PBC overlap information back to hdd.
3634 *ASSUMPTIONS:
3635 *
3636 *
3637 *NOTE:
3638 *
3639 * @param pMac Pointer to Global MAC structure
3640 * @param pMsgBuf A pointer to WPS PBC overlap query message
3641*
3642 * @return None
3643 */
3644void limProcessSmeGetWPSPBCSessions(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
3645{
3646 tSirSmeGetWPSPBCSessionsReq GetWPSPBCSessionsReq;
3647 tpPESession psessionEntry = NULL;
3648 tSap_Event sapEvent;
3649 tpWLAN_SAPEventCB pSapEventCallback = NULL;
3650 tANI_U8 sessionId = CSR_SESSION_ID_INVALID;
3651 tSirMacAddr zeroMac = {0,0,0,0,0,0};
3652
3653 sapEvent.sapevt.sapGetWPSPBCSessionEvent.status = VOS_STATUS_E_FAULT;
3654
3655 if (limIsSmeGetWPSPBCSessionsReqValid(pMac, &GetWPSPBCSessionsReq, (tANI_U8 *) pMsgBuf) != eSIR_SUCCESS)
3656 {
3657 limLog(pMac, LOGE,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003658 FL("received invalid eWNI_SME_GET_ASSOC_STAS_REQ message"));
Girish Gowliafd42312014-07-24 13:13:59 +05303659 return;
Jeff Johnson295189b2012-06-20 16:38:30 -07003660 }
3661
Jeff Johnson1250df42012-12-10 14:31:52 -08003662 // Get Associated stations from PE
Jeff Johnson295189b2012-06-20 16:38:30 -07003663 // Find PE session Entry
3664 if ((psessionEntry = peFindSessionByBssid(pMac, GetWPSPBCSessionsReq.bssId, &sessionId)) == NULL)
3665 {
3666 limLog(pMac, LOGE,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003667 FL("session does not exist for given bssId"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003668 goto limGetWPSPBCSessionsEnd;
3669 }
3670
3671 if (psessionEntry->limSystemRole != eLIM_AP_ROLE)
3672 {
3673 limLog(pMac, LOGE,
Sushant Kaushik1b645382014-10-13 16:39:36 +05303674 FL("Received unexpected message in role %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07003675 psessionEntry->limSystemRole);
3676 goto limGetWPSPBCSessionsEnd;
3677 }
3678
Jeff Johnson1250df42012-12-10 14:31:52 -08003679 // Call hdd callback with sap event to send the WPS PBC overlap information
Jeff Johnson295189b2012-06-20 16:38:30 -07003680 sapEvent.sapHddEventCode = eSAP_GET_WPSPBC_SESSION_EVENT;
3681 sapEvent.sapevt.sapGetWPSPBCSessionEvent.module = VOS_MODULE_ID_PE;
3682
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303683 if (vos_mem_compare( zeroMac, GetWPSPBCSessionsReq.pRemoveMac, sizeof(tSirMacAddr)))
Jeff Johnson295189b2012-06-20 16:38:30 -07003684 { //This is GetWpsSession call
3685
3686 limGetWPSPBCSessions(pMac,
3687 sapEvent.sapevt.sapGetWPSPBCSessionEvent.addr.bytes, sapEvent.sapevt.sapGetWPSPBCSessionEvent.UUID_E,
3688 &sapEvent.sapevt.sapGetWPSPBCSessionEvent.wpsPBCOverlap, psessionEntry);
3689 }
3690 else
3691 {
3692 limRemovePBCSessions(pMac, GetWPSPBCSessionsReq.pRemoveMac,psessionEntry);
3693 /* don't have to inform the HDD/Host */
3694 return;
3695 }
3696
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003697 PELOG4(limLog(pMac, LOGE, FL("wpsPBCOverlap %d"), sapEvent.sapevt.sapGetWPSPBCSessionEvent.wpsPBCOverlap);)
Jeff Johnson295189b2012-06-20 16:38:30 -07003698 PELOG4(limPrintMacAddr(pMac, sapEvent.sapevt.sapGetWPSPBCSessionEvent.addr.bytes, LOG4);)
3699
3700 sapEvent.sapevt.sapGetWPSPBCSessionEvent.status = VOS_STATUS_SUCCESS;
3701
3702limGetWPSPBCSessionsEnd:
3703 pSapEventCallback = (tpWLAN_SAPEventCB)GetWPSPBCSessionsReq.pSapEventCallback;
Abhishek Singh8a99b9f2015-03-31 14:18:26 +05303704
3705 if (NULL != pSapEventCallback)
3706 pSapEventCallback(&sapEvent, GetWPSPBCSessionsReq.pUsrContext);
Jeff Johnson295189b2012-06-20 16:38:30 -07003707}
3708
Jeff Johnson295189b2012-06-20 16:38:30 -07003709
3710
3711/**
3712 * __limCounterMeasures()
3713 *
3714 * FUNCTION:
3715 * This function is called to "implement" MIC counter measure
3716 * and is *temporary* only
3717 *
3718 * LOGIC: on AP, disassoc all STA associated thru TKIP,
3719 * we don't do the proper STA disassoc sequence since the
3720 * BSS will be stoped anyway
3721 *
3722 *ASSUMPTIONS:
3723 *
3724 *NOTE:
3725 *
3726 * @param pMac Pointer to Global MAC structure
3727 * @return None
3728 */
3729
3730static void
3731__limCounterMeasures(tpAniSirGlobal pMac, tpPESession psessionEntry)
3732{
3733 tSirMacAddr mac = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
Abhishek Singh8944b222014-09-17 16:13:17 +05303734 /* If PMF is enabled then don't send broadcast disassociation */
3735 if ( ( (psessionEntry->limSystemRole == eLIM_AP_ROLE) ||
3736 (psessionEntry->limSystemRole == eLIM_BT_AMP_AP_ROLE) ||
3737 (psessionEntry->limSystemRole == eLIM_BT_AMP_STA_ROLE))
3738#ifdef WLAN_FEATURE_11W
3739 && !psessionEntry->limRmfEnabled
3740#endif
3741 )
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003742 limSendDisassocMgmtFrame(pMac, eSIR_MAC_MIC_FAILURE_REASON, mac, psessionEntry, FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003743
Jeff Johnson295189b2012-06-20 16:38:30 -07003744};
3745
3746
Jeff Johnson295189b2012-06-20 16:38:30 -07003747void
3748limProcessTkipCounterMeasures(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
3749{
3750 tSirSmeTkipCntrMeasReq tkipCntrMeasReq;
3751 tpPESession psessionEntry;
3752 tANI_U8 sessionId; //PE sessionId
3753
3754 if ( limTkipCntrMeasReqSerDes( pMac, &tkipCntrMeasReq, (tANI_U8 *) pMsgBuf ) != eSIR_SUCCESS )
3755 {
3756 limLog(pMac, LOGE,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003757 FL("received invalid eWNI_SME_TKIP_CNTR_MEAS_REQ message"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003758 return;
3759 }
3760
3761 if ( NULL == (psessionEntry = peFindSessionByBssid( pMac, tkipCntrMeasReq.bssId, &sessionId )) )
3762 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003763 limLog(pMac, LOGE, FL("session does not exist for given BSSID "));
Jeff Johnson295189b2012-06-20 16:38:30 -07003764 return;
3765 }
3766
3767 if ( tkipCntrMeasReq.bEnable )
3768 {
3769 __limCounterMeasures( pMac, psessionEntry );
3770 }
3771
3772 psessionEntry->bTkipCntrMeasActive = tkipCntrMeasReq.bEnable;
3773}
Jeff Johnson295189b2012-06-20 16:38:30 -07003774
3775
3776static void
3777__limHandleSmeStopBssRequest(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
3778{
3779 tSirSmeStopBssReq stopBssReq;
3780 tSirRetStatus status;
3781 tLimSmeStates prevState;
3782 tANI_U8 sessionId; //PE sessionId
3783 tpPESession psessionEntry;
3784 tANI_U8 smesessionId;
3785 tANI_U16 smetransactionId;
Sachin Ahuja51c08e62014-03-26 19:21:29 +05303786 tANI_U8 i = 0;
3787 tpDphHashNode pStaDs = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07003788
3789 limGetSessionInfo(pMac,(tANI_U8 *)pMsgBuf,&smesessionId,&smetransactionId);
3790
3791
3792
3793 if ((limStopBssReqSerDes(pMac, &stopBssReq, (tANI_U8 *) pMsgBuf) != eSIR_SUCCESS) ||
3794 !limIsSmeStopBssReqValid(pMsgBuf))
3795 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003796 PELOGW(limLog(pMac, LOGW, FL("received invalid SME_STOP_BSS_REQ message"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07003797 /// Send Stop BSS response to host
3798 limSendSmeRsp(pMac, eWNI_SME_STOP_BSS_RSP, eSIR_SME_INVALID_PARAMETERS,smesessionId,smetransactionId);
3799 return;
3800 }
3801
3802
3803 if((psessionEntry = peFindSessionByBssid(pMac,stopBssReq.bssId,&sessionId)) == NULL)
3804 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003805 limLog(pMac, LOGW, FL("session does not exist for given BSSID "));
Jeff Johnson295189b2012-06-20 16:38:30 -07003806 limSendSmeRsp(pMac, eWNI_SME_STOP_BSS_RSP, eSIR_SME_INVALID_PARAMETERS,smesessionId,smetransactionId);
3807 return;
3808 }
3809
3810#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM //FEATURE_WLAN_DIAG_SUPPORT
3811 limDiagEventReport(pMac, WLAN_PE_DIAG_STOP_BSS_REQ_EVENT, psessionEntry, 0, 0);
3812#endif //FEATURE_WLAN_DIAG_SUPPORT
3813
3814
3815 if ((psessionEntry->limSmeState != eLIM_SME_NORMAL_STATE) || /* Added For BT -AMP Support */
3816 (psessionEntry->limSystemRole == eLIM_STA_ROLE ))
3817 {
3818 /**
3819 * Should not have received STOP_BSS_REQ in states
3820 * other than 'normal' state or on STA in Infrastructure
3821 * mode. Log error and return response to host.
3822 */
3823 limLog(pMac, LOGE,
Sushant Kaushik1b645382014-10-13 16:39:36 +05303824 FL("received unexpected SME_STOP_BSS_REQ in state %d, for role %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07003825 psessionEntry->limSmeState, psessionEntry->limSystemRole);
3826 limPrintSmeState(pMac, LOGE, psessionEntry->limSmeState);
3827 /// Send Stop BSS response to host
3828 limSendSmeRsp(pMac, eWNI_SME_STOP_BSS_RSP, eSIR_SME_UNEXPECTED_REQ_RESULT_CODE,smesessionId,smetransactionId);
3829 return;
3830 }
3831
Jeff Johnson295189b2012-06-20 16:38:30 -07003832 if (psessionEntry->limSystemRole == eLIM_AP_ROLE )
3833 {
3834 limWPSPBCClose(pMac, psessionEntry);
3835 }
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003836 PELOGW(limLog(pMac, LOGW, FL("RECEIVED STOP_BSS_REQ with reason code=%d"), stopBssReq.reasonCode);)
Jeff Johnson295189b2012-06-20 16:38:30 -07003837
3838 prevState = psessionEntry->limSmeState;
3839
3840 psessionEntry->limSmeState = eLIM_SME_IDLE_STATE;
Jeff Johnsone7245742012-09-05 17:12:55 -07003841 MTRACE(macTrace(pMac, TRACE_CODE_SME_STATE, psessionEntry->peSessionId, psessionEntry->limSmeState));
Jeff Johnson295189b2012-06-20 16:38:30 -07003842
3843 /* Update SME session Id and Transaction Id */
3844 psessionEntry->smeSessionId = smesessionId;
3845 psessionEntry->transactionId = smetransactionId;
3846
Abhishek Singh8944b222014-09-17 16:13:17 +05303847 /* BTAMP_STA and STA_IN_IBSS should NOT send Disassoc frame.
3848 * If PMF is enabled then don't send broadcast disassociation */
3849 if ( ( (eLIM_STA_IN_IBSS_ROLE != psessionEntry->limSystemRole) &&
3850 (eLIM_BT_AMP_STA_ROLE != psessionEntry->limSystemRole) )
3851#ifdef WLAN_FEATURE_11W
3852 && !psessionEntry->limRmfEnabled
3853#endif
3854 )
Jeff Johnson295189b2012-06-20 16:38:30 -07003855 {
3856 tSirMacAddr bcAddr = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
3857 if ((stopBssReq.reasonCode == eSIR_SME_MIC_COUNTER_MEASURES))
3858 // Send disassoc all stations associated thru TKIP
3859 __limCounterMeasures(pMac,psessionEntry);
3860 else
Madan Mohan Koyyalamudi299b4862013-01-30 19:59:23 +05303861 limSendDisassocMgmtFrame(pMac, eSIR_MAC_DEAUTH_LEAVING_BSS_REASON, bcAddr, psessionEntry, FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003862 }
3863
3864 //limDelBss is also called as part of coalescing, when we send DEL BSS followed by Add Bss msg.
3865 pMac->lim.gLimIbssCoalescingHappened = false;
3866
Sachin Ahuja51c08e62014-03-26 19:21:29 +05303867 for(i = 1 ; i < pMac->lim.gLimAssocStaLimit ; i++)
3868 {
3869 pStaDs = dphGetHashEntry(pMac, i, &psessionEntry->dph.dphHashTable);
3870 if (NULL == pStaDs)
3871 continue;
3872 status = limDelSta(pMac, pStaDs, false, psessionEntry) ;
3873 if(eSIR_SUCCESS == status)
3874 {
3875 limDeleteDphHashEntry(pMac, pStaDs->staAddr, pStaDs->assocId, psessionEntry) ;
3876 limReleasePeerIdx(pMac, pStaDs->assocId, psessionEntry) ;
3877 }
3878 else
3879 {
3880 limLog(pMac, LOGE, FL("limDelSta failed with Status : %d"), status);
3881 VOS_ASSERT(0) ;
3882 }
3883 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003884 /* send a delBss to HAL and wait for a response */
3885 status = limDelBss(pMac, NULL,psessionEntry->bssIdx,psessionEntry);
3886
3887 if (status != eSIR_SUCCESS)
3888 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003889 PELOGE(limLog(pMac, LOGE, FL("delBss failed for bss %d"), psessionEntry->bssIdx);)
Jeff Johnson295189b2012-06-20 16:38:30 -07003890 psessionEntry->limSmeState= prevState;
3891
Jeff Johnsone7245742012-09-05 17:12:55 -07003892 MTRACE(macTrace(pMac, TRACE_CODE_SME_STATE, psessionEntry->peSessionId, psessionEntry->limSmeState));
Jeff Johnson295189b2012-06-20 16:38:30 -07003893
3894 limSendSmeRsp(pMac, eWNI_SME_STOP_BSS_RSP, eSIR_SME_STOP_BSS_FAILURE,smesessionId,smetransactionId);
3895 }
3896}
3897
3898
3899/**--------------------------------------------------------------
3900\fn __limProcessSmeStopBssReq
3901
3902\brief Wrapper for the function __limHandleSmeStopBssRequest
3903 This message will be defered until softmac come out of
3904 scan mode. Message should be handled even if we have
3905 detected radar in the current operating channel.
3906\param pMac
3907\param pMsg
3908
3909\return TRUE - If we consumed the buffer
3910 FALSE - If have defered the message.
3911 ---------------------------------------------------------------*/
3912static tANI_BOOLEAN
3913__limProcessSmeStopBssReq(tpAniSirGlobal pMac, tpSirMsgQ pMsg)
3914{
3915 if (__limIsDeferedMsgForLearn(pMac, pMsg))
3916 {
3917 /**
3918 * If message defered, buffer is not consumed yet.
3919 * So return false
3920 */
3921 return eANI_BOOLEAN_FALSE;
3922 }
3923 __limHandleSmeStopBssRequest(pMac, (tANI_U32 *) pMsg->bodyptr);
3924 return eANI_BOOLEAN_TRUE;
3925} /*** end __limProcessSmeStopBssReq() ***/
3926
3927
3928void limProcessSmeDelBssRsp(
3929 tpAniSirGlobal pMac,
3930 tANI_U32 body,tpPESession psessionEntry)
3931{
3932
3933 (void) body;
3934 SET_LIM_PROCESS_DEFD_MESGS(pMac, true);
3935 //TBD: get the sessionEntry
Ravi Joshib58ca0d2013-10-29 09:50:23 -07003936 limIbssDelete(pMac,psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07003937 dphHashTableClassInit(pMac, &psessionEntry->dph.dphHashTable);
3938 limDeletePreAuthList(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -07003939 limSendSmeRsp(pMac, eWNI_SME_STOP_BSS_RSP, eSIR_SME_SUCCESS,psessionEntry->smeSessionId,psessionEntry->transactionId);
3940 return;
3941}
3942
3943
Jeff Johnson295189b2012-06-20 16:38:30 -07003944/**---------------------------------------------------------------
3945\fn __limProcessSmeAssocCnfNew
3946\brief This function handles SME_ASSOC_CNF/SME_REASSOC_CNF
3947\ in BTAMP AP.
3948\
3949\param pMac
3950\param msgType - message type
3951\param pMsgBuf - a pointer to the SME message buffer
3952\return None
3953------------------------------------------------------------------*/
3954
3955 void
3956__limProcessSmeAssocCnfNew(tpAniSirGlobal pMac, tANI_U32 msgType, tANI_U32 *pMsgBuf)
3957{
3958 tSirSmeAssocCnf assocCnf;
3959 tpDphHashNode pStaDs = NULL;
3960 tpPESession psessionEntry= NULL;
3961 tANI_U8 sessionId;
3962
3963
3964 if(pMsgBuf == NULL)
3965 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003966 limLog(pMac, LOGE, FL("pMsgBuf is NULL "));
Jeff Johnson295189b2012-06-20 16:38:30 -07003967 goto end;
3968 }
3969
3970 if ((limAssocCnfSerDes(pMac, &assocCnf, (tANI_U8 *) pMsgBuf) == eSIR_FAILURE) ||
3971 !__limIsSmeAssocCnfValid(&assocCnf))
3972 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003973 limLog(pMac, LOGE, FL("Received invalid SME_RE(ASSOC)_CNF message "));
Jeff Johnson295189b2012-06-20 16:38:30 -07003974 goto end;
3975 }
3976
3977 if((psessionEntry = peFindSessionByBssid(pMac, assocCnf.bssId, &sessionId))== NULL)
3978 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003979 limLog(pMac, LOGE, FL("session does not exist for given bssId"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003980 goto end;
3981 }
3982
3983 if ( ((psessionEntry->limSystemRole != eLIM_AP_ROLE) && (psessionEntry->limSystemRole != eLIM_BT_AMP_AP_ROLE)) ||
3984 ((psessionEntry->limSmeState != eLIM_SME_NORMAL_STATE) && (psessionEntry->limSmeState != eLIM_SME_NORMAL_CHANNEL_SCAN_STATE)))
3985 {
Sushant Kaushik1b645382014-10-13 16:39:36 +05303986 limLog(pMac, LOGE, FL("Received unexpected message %X in state %d, in role %d"),
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303987 msgType, psessionEntry->limSmeState, psessionEntry->limSystemRole);
Jeff Johnson295189b2012-06-20 16:38:30 -07003988 goto end;
3989 }
3990
3991 pStaDs = dphGetHashEntry(pMac, assocCnf.aid, &psessionEntry->dph.dphHashTable);
3992
3993 if (pStaDs == NULL)
3994 {
Sachin Ahuja2fea3d12014-12-18 17:31:31 +05303995 limLog(pMac, LOGE,
3996 FL("Received invalid message %X due to no STA context, "
3997 "for aid %d, peer "),
3998 msgType, assocCnf.aid);
Jeff Johnson295189b2012-06-20 16:38:30 -07003999 limPrintMacAddr(pMac, assocCnf.peerMacAddr, LOG1);
4000
4001 /*
4002 ** send a DISASSOC_IND message to WSM to make sure
4003 ** the state in WSM and LIM is the same
4004 **/
4005 limSendSmeDisassocNtf( pMac, assocCnf.peerMacAddr, eSIR_SME_STA_NOT_ASSOCIATED,
4006 eLIM_PEER_ENTITY_DISASSOC, assocCnf.aid,psessionEntry->smeSessionId,psessionEntry->transactionId,psessionEntry);
4007 goto end;
4008 }
4009 if ((pStaDs &&
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304010 (( !vos_mem_compare( (tANI_U8 *) pStaDs->staAddr,
Jeff Johnson295189b2012-06-20 16:38:30 -07004011 (tANI_U8 *) assocCnf.peerMacAddr,
4012 sizeof(tSirMacAddr)) ) ||
4013 (pStaDs->mlmStaContext.mlmState != eLIM_MLM_WT_ASSOC_CNF_STATE) ||
4014 ((pStaDs->mlmStaContext.subType == LIM_ASSOC) &&
4015 (msgType != eWNI_SME_ASSOC_CNF)) ||
4016 ((pStaDs->mlmStaContext.subType == LIM_REASSOC) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07004017 (msgType != eWNI_SME_ASSOC_CNF))))) // since softap is passing this as ASSOC_CNF and subtype differs
Jeff Johnson295189b2012-06-20 16:38:30 -07004018 {
Sachin Ahuja2fea3d12014-12-18 17:31:31 +05304019 limLog(pMac, LOGE,
4020 FL("Received invalid message %X due to peerMacAddr mismatched "
4021 "or not in eLIM_MLM_WT_ASSOC_CNF_STATE state, for aid %d, peer "
4022 "StaD mlmState : %d"),
4023 msgType, assocCnf.aid, pStaDs->mlmStaContext.mlmState);
Jeff Johnson295189b2012-06-20 16:38:30 -07004024 limPrintMacAddr(pMac, assocCnf.peerMacAddr, LOG1);
4025 goto end;
4026 }
4027
4028 /*
4029 ** Deactivate/delet CNF_WAIT timer since ASSOC_CNF
4030 ** has been received
4031 **/
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004032 limLog(pMac, LOG1, FL("Received SME_ASSOC_CNF. Delete Timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004033 limDeactivateAndChangePerStaIdTimer(pMac, eLIM_CNF_WAIT_TIMER, pStaDs->assocId);
4034
4035 if (assocCnf.statusCode == eSIR_SME_SUCCESS)
4036 {
4037 /* In BTAMP-AP, PE already finished the WDA_ADD_STA sequence
4038 * when it had received Assoc Request frame. Now, PE just needs to send
4039 * Association Response frame to the requesting BTAMP-STA.
4040 */
4041 pStaDs->mlmStaContext.mlmState = eLIM_MLM_LINK_ESTABLISHED_STATE;
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004042 limLog(pMac, LOG1, FL("sending Assoc Rsp frame to STA (assoc id=%d) "), pStaDs->assocId);
Kapil Gupta956c0c42017-06-16 19:24:31 +05304043 limSendAssocRspMgmtFrame(pMac, eSIR_SUCCESS, pStaDs->assocId,
4044 pStaDs->staAddr,
4045 pStaDs->mlmStaContext.subType, pStaDs,
4046 psessionEntry, NULL);
Jeff Johnson295189b2012-06-20 16:38:30 -07004047 goto end;
4048 } // (assocCnf.statusCode == eSIR_SME_SUCCESS)
4049 else
4050 {
4051 // SME_ASSOC_CNF status is non-success, so STA is not allowed to be associated
4052 /*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*/
4053 if(!pStaDs->mlmStaContext.updateContext)
4054 pStaDs->mlmStaContext.updateContext = 1;
Sachin Ahuja2fea3d12014-12-18 17:31:31 +05304055 limLog(pMac, LOG1, FL("Receive Assoc Cnf with status Code : %d(assoc id=%d) "),
4056 assocCnf.statusCode, pStaDs->assocId);
Jeff Johnson295189b2012-06-20 16:38:30 -07004057 limRejectAssociation(pMac, pStaDs->staAddr,
4058 pStaDs->mlmStaContext.subType,
4059 true, pStaDs->mlmStaContext.authType,
4060 pStaDs->assocId, true,
4061 eSIR_MAC_UNSPEC_FAILURE_STATUS, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07004062 }
4063
4064end:
4065 if((psessionEntry != NULL) && (pStaDs != NULL))
4066 {
4067 if ( psessionEntry->parsedAssocReq[pStaDs->assocId] != NULL )
4068 {
4069 if ( ((tpSirAssocReq)(psessionEntry->parsedAssocReq[pStaDs->assocId]))->assocReqFrame)
4070 {
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304071 vos_mem_free(((tpSirAssocReq)
4072 (psessionEntry->parsedAssocReq[pStaDs->assocId]))->assocReqFrame);
Jeff Johnson295189b2012-06-20 16:38:30 -07004073 ((tpSirAssocReq)(psessionEntry->parsedAssocReq[pStaDs->assocId]))->assocReqFrame = NULL;
4074 }
4075
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304076 vos_mem_free(psessionEntry->parsedAssocReq[pStaDs->assocId]);
Jeff Johnson295189b2012-06-20 16:38:30 -07004077 psessionEntry->parsedAssocReq[pStaDs->assocId] = NULL;
4078 }
4079 }
4080
4081} /*** end __limProcessSmeAssocCnfNew() ***/
4082
Agrawal Ashisha8e8a722016-10-18 19:07:45 +05304083#ifdef SAP_AUTH_OFFLOAD
4084/**
4085 * __lim_process_sme_assoc_offload_cnf() station connection confirmation
4086 * message from SME.
4087 * @pMac: SirGlobal handler
4088 * @msgType: message type
4089 * @pMsgBuf: message body
4090 *
4091 * This function handles the station connect confirm of
4092 * Software AP authentication offload feature
4093 *
4094 * Return: None
4095 */
4096 static void
4097__lim_process_sme_assoc_offload_cnf(tpAniSirGlobal pmac,
4098 tANI_U32 msg_type,
4099 tANI_U32 *pmsg_buf)
4100{
4101 tSirSmeAssocCnf assoc_cnf;
4102 tpDphHashNode sta_ds = NULL;
4103 tpPESession psession_entry= NULL;
4104 tANI_U8 session_id;
4105 tANI_U16 aid=0;
Jeff Johnson295189b2012-06-20 16:38:30 -07004106
Agrawal Ashisha8e8a722016-10-18 19:07:45 +05304107 if (pmsg_buf == NULL)
4108 {
4109 limLog(pmac, LOGE, FL("pmsg_buf is NULL "));
4110 return;
4111 }
4112
4113 if ((limAssocCnfSerDes(pmac, &assoc_cnf, (tANI_U8 *) pmsg_buf) ==
4114 eSIR_FAILURE) || !__limIsSmeAssocCnfValid(&assoc_cnf))
4115 {
4116 limLog(pmac, LOGE, FL("Received invalid SME_RE(ASSOC)_CNF message "));
4117 return;
4118 }
4119
4120 if((psession_entry =
4121 peFindSessionByBssid(pmac, assoc_cnf.bssId, &session_id))== NULL)
4122 {
4123 limLog(pmac, LOGE, FL("session does not exist for given bssId"));
4124 goto end;
4125 }
4126
4127 if ((!LIM_IS_AP_ROLE(psession_entry)) ||
4128 ((psession_entry->limSmeState != eLIM_SME_NORMAL_STATE) &&
4129 (psession_entry->limSmeState != eLIM_SME_NORMAL_CHANNEL_SCAN_STATE)))
4130 {
4131 limLog(pmac, LOGE,
4132 FL("Received unexpected message %X in state %X, in role %X"),
4133 msg_type, psession_entry->limSmeState,
4134 GET_LIM_SYSTEM_ROLE(psession_entry));
4135 goto end;
4136 }
4137 sta_ds = dphGetHashEntry(pmac,
4138 assoc_cnf.aid,
4139 &psession_entry->dph.dphHashTable);
4140 if (sta_ds != NULL)
4141 {
4142 aid = sta_ds->assocId;
4143 /* Deactivate/delete CNF_WAIT timer since ASSOC_CNF
4144 * has been received */
4145 limDeactivateAndChangePerStaIdTimer(pmac,
4146 eLIM_CNF_WAIT_TIMER,
4147 aid);
4148 }
Abhinav Kumarb4626d02018-02-26 18:16:30 +05304149 else
4150 {
4151 limLog(pmac, LOGE, FL("NULL sta_ds"));
4152 goto end;
4153 }
Agrawal Ashish25d9ef12017-01-10 20:27:50 +05304154 if (assoc_cnf.statusCode == eSIR_SME_SUCCESS)
4155 {
4156 sta_ds->mlmStaContext.mlmState = eLIM_MLM_LINK_ESTABLISHED_STATE;
4157 limLog(pmac, LOG1, FL("Set mlmState to eLIM_MLM_LINK_ESTABLISHED_STATE"));
4158 }
Agrawal Ashisha8e8a722016-10-18 19:07:45 +05304159
4160end:
4161 if((psession_entry != NULL) && (sta_ds != NULL))
4162 {
4163 if ( psession_entry->parsedAssocReq[aid] != NULL )
4164 {
4165 if ( ((tpSirAssocReq)
4166 (psession_entry->parsedAssocReq[aid]))->assocReqFrame)
4167 {
4168 vos_mem_free(((tpSirAssocReq)
4169 (psession_entry->parsedAssocReq[aid]))->assocReqFrame);
4170 ((tpSirAssocReq)
4171 (psession_entry->parsedAssocReq[aid]))->assocReqFrame =
4172 NULL;
4173 }
4174 vos_mem_free(psession_entry->parsedAssocReq[aid]);
4175 psession_entry->parsedAssocReq[aid] = NULL;
4176 }
4177 }
4178
4179} /*** end __lim_process_sme_assoc_offload_cnf() ***/
4180#endif /* SAP_AUTH_OFFLOAD */
Jeff Johnson295189b2012-06-20 16:38:30 -07004181
4182
4183static void
4184__limProcessSmeAddtsReq(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
4185{
4186 tpDphHashNode pStaDs;
4187 tSirMacAddr peerMac;
4188 tpSirAddtsReq pSirAddts;
4189 tANI_U32 timeout;
4190 tpPESession psessionEntry;
4191 tANI_U8 sessionId; //PE sessionId
4192 tANI_U8 smesessionId;
4193 tANI_U16 smetransactionId;
4194
4195
4196 if(pMsgBuf == NULL)
4197 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004198 limLog(pMac, LOGE,FL("Buffer is Pointing to NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004199 return;
4200 }
4201
4202 limGetSessionInfo(pMac,(tANI_U8 *)pMsgBuf,&smesessionId,&smetransactionId);
4203
4204 pSirAddts = (tpSirAddtsReq) pMsgBuf;
4205
4206 if((psessionEntry = peFindSessionByBssid(pMac, pSirAddts->bssId,&sessionId))== NULL)
4207 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004208 limLog(pMac, LOGE, "Session Does not exist for given bssId");
Jeff Johnson295189b2012-06-20 16:38:30 -07004209 return;
4210 }
4211#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM //FEATURE_WLAN_DIAG_SUPPORT
4212 limDiagEventReport(pMac, WLAN_PE_DIAG_ADDTS_REQ_EVENT, psessionEntry, 0, 0);
4213#endif //FEATURE_WLAN_DIAG_SUPPORT
4214
4215
4216
4217 /* if sta
4218 * - verify assoc state
4219 * - send addts request to ap
4220 * - wait for addts response from ap
4221 * if ap, just ignore with error log
4222 */
Abhishek Singh3cbf6052014-12-15 16:46:42 +05304223 limLog(pMac, LOG1,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004224 FL("Received SME_ADDTS_REQ (TSid %d, UP %d)"),
Jeff Johnson295189b2012-06-20 16:38:30 -07004225 pSirAddts->req.tspec.tsinfo.traffic.tsid,
Abhishek Singh3cbf6052014-12-15 16:46:42 +05304226 pSirAddts->req.tspec.tsinfo.traffic.userPrio);
Jeff Johnson295189b2012-06-20 16:38:30 -07004227
4228 if ((psessionEntry->limSystemRole != eLIM_STA_ROLE)&&(psessionEntry->limSystemRole != eLIM_BT_AMP_STA_ROLE))
4229 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004230 PELOGE(limLog(pMac, LOGE, "AddTs received on AP - ignoring");)
Jeff Johnson295189b2012-06-20 16:38:30 -07004231 limSendSmeAddtsRsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE, psessionEntry, pSirAddts->req.tspec,
4232 smesessionId,smetransactionId);
4233 return;
4234 }
4235
Jeff Johnson295189b2012-06-20 16:38:30 -07004236 pStaDs = dphGetHashEntry(pMac, DPH_STA_HASH_INDEX_PEER, &psessionEntry->dph.dphHashTable);
4237
4238 if(pStaDs == NULL)
4239 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004240 PELOGE(limLog(pMac, LOGE, "Cannot find AP context for addts req");)
Jeff Johnson295189b2012-06-20 16:38:30 -07004241 limSendSmeAddtsRsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE, psessionEntry, pSirAddts->req.tspec,
4242 smesessionId,smetransactionId);
4243 return;
4244 }
4245
4246 if ((! pStaDs->valid) ||
4247 (pStaDs->mlmStaContext.mlmState != eLIM_MLM_LINK_ESTABLISHED_STATE))
4248 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004249 PELOGE(limLog(pMac, LOGE, "AddTs received in invalid MLM state");)
Jeff Johnson295189b2012-06-20 16:38:30 -07004250 limSendSmeAddtsRsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE, psessionEntry, pSirAddts->req.tspec,
4251 smesessionId,smetransactionId);
4252 return;
4253 }
4254
4255 pSirAddts->req.wsmTspecPresent = 0;
4256 pSirAddts->req.wmeTspecPresent = 0;
4257 pSirAddts->req.lleTspecPresent = 0;
4258
4259 if ((pStaDs->wsmEnabled) &&
4260 (pSirAddts->req.tspec.tsinfo.traffic.accessPolicy != SIR_MAC_ACCESSPOLICY_EDCA))
4261 pSirAddts->req.wsmTspecPresent = 1;
4262 else if (pStaDs->wmeEnabled)
4263 pSirAddts->req.wmeTspecPresent = 1;
4264 else if (pStaDs->lleEnabled)
4265 pSirAddts->req.lleTspecPresent = 1;
4266 else
4267 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004268 PELOGW(limLog(pMac, LOGW, FL("ADDTS_REQ ignore - qos is disabled"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07004269 limSendSmeAddtsRsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE, psessionEntry, pSirAddts->req.tspec,
4270 smesessionId,smetransactionId);
4271 return;
4272 }
4273
4274 if ((psessionEntry->limSmeState != eLIM_SME_ASSOCIATED_STATE) &&
4275 (psessionEntry->limSmeState != eLIM_SME_LINK_EST_STATE))
4276 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004277 limLog(pMac, LOGE, "AddTs received in invalid LIMsme state (%d)",
Jeff Johnson295189b2012-06-20 16:38:30 -07004278 psessionEntry->limSmeState);
4279 limSendSmeAddtsRsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE, psessionEntry, pSirAddts->req.tspec,
4280 smesessionId,smetransactionId);
4281 return;
4282 }
4283
4284 if (pMac->lim.gLimAddtsSent)
4285 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004286 limLog(pMac, LOGE, "Addts (token %d, tsid %d, up %d) is still pending",
Jeff Johnson295189b2012-06-20 16:38:30 -07004287 pMac->lim.gLimAddtsReq.req.dialogToken,
4288 pMac->lim.gLimAddtsReq.req.tspec.tsinfo.traffic.tsid,
4289 pMac->lim.gLimAddtsReq.req.tspec.tsinfo.traffic.userPrio);
4290 limSendSmeAddtsRsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE, psessionEntry, pSirAddts->req.tspec,
4291 smesessionId,smetransactionId);
4292 return;
4293 }
4294
4295 #if 0
4296 val = sizeof(tSirMacAddr);
4297 if (wlan_cfgGetStr(pMac, WNI_CFG_BSSID, peerMac, &val) != eSIR_SUCCESS)
4298 {
4299 /// Could not get BSSID from CFG. Log error.
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004300 limLog(pMac, LOGP, FL("could not retrieve BSSID"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004301 return;
4302 }
4303 #endif
4304 sirCopyMacAddr(peerMac,psessionEntry->bssId);
4305
4306 // save the addts request
4307 pMac->lim.gLimAddtsSent = true;
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304308 vos_mem_copy( (tANI_U8 *) &pMac->lim.gLimAddtsReq, (tANI_U8 *) pSirAddts, sizeof(tSirAddtsReq));
Jeff Johnson295189b2012-06-20 16:38:30 -07004309
4310 // ship out the message now
4311 limSendAddtsReqActionFrame(pMac, peerMac, &pSirAddts->req,
4312 psessionEntry);
Abhishek Singh3cbf6052014-12-15 16:46:42 +05304313 limLog(pMac, LOG1, FL("Sent ADDTS request"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004314
4315 // start a timer to wait for the response
4316 if (pSirAddts->timeout)
4317 timeout = pSirAddts->timeout;
4318 else if (wlan_cfgGetInt(pMac, WNI_CFG_ADDTS_RSP_TIMEOUT, &timeout) != eSIR_SUCCESS)
4319 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004320 limLog(pMac, LOGP, FL("Unable to get Cfg param %d (Addts Rsp Timeout)"),
Jeff Johnson295189b2012-06-20 16:38:30 -07004321 WNI_CFG_ADDTS_RSP_TIMEOUT);
4322 return;
4323 }
4324
4325 timeout = SYS_MS_TO_TICKS(timeout);
4326 if (tx_timer_change(&pMac->lim.limTimers.gLimAddtsRspTimer, timeout, 0) != TX_SUCCESS)
4327 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004328 limLog(pMac, LOGP, FL("AddtsRsp timer change failed!"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004329 return;
4330 }
4331 pMac->lim.gLimAddtsRspTimerCount++;
4332 if (tx_timer_change_context(&pMac->lim.limTimers.gLimAddtsRspTimer,
4333 pMac->lim.gLimAddtsRspTimerCount) != TX_SUCCESS)
4334 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004335 limLog(pMac, LOGP, FL("AddtsRsp timer change failed!"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004336 return;
4337 }
Jeff Johnsone7245742012-09-05 17:12:55 -07004338 MTRACE(macTrace(pMac, TRACE_CODE_TIMER_ACTIVATE, psessionEntry->peSessionId, eLIM_ADDTS_RSP_TIMER));
Jeff Johnson295189b2012-06-20 16:38:30 -07004339
4340 //add the sessionId to the timer object
4341 pMac->lim.limTimers.gLimAddtsRspTimer.sessionId = sessionId;
4342 if (tx_timer_activate(&pMac->lim.limTimers.gLimAddtsRspTimer) != TX_SUCCESS)
4343 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004344 limLog(pMac, LOGP, FL("AddtsRsp timer activation failed!"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004345 return;
4346 }
4347 return;
4348}
4349
4350
4351static void
4352__limProcessSmeDeltsReq(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
4353{
4354 tSirMacAddr peerMacAddr;
4355 tANI_U8 ac;
4356 tSirMacTSInfo *pTsinfo;
4357 tpSirDeltsReq pDeltsReq = (tpSirDeltsReq) pMsgBuf;
4358 tpDphHashNode pStaDs = NULL;
4359 tpPESession psessionEntry;
4360 tANI_U8 sessionId;
4361 tANI_U32 status = eSIR_SUCCESS;
4362 tANI_U8 smesessionId;
4363 tANI_U16 smetransactionId;
4364
4365 limGetSessionInfo(pMac,(tANI_U8 *)pMsgBuf,&smesessionId,&smetransactionId);
4366
4367 if((psessionEntry = peFindSessionByBssid(pMac, pDeltsReq->bssId, &sessionId))== NULL)
4368 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004369 limLog(pMac, LOGE, "Session Does not exist for given bssId");
Jeff Johnson295189b2012-06-20 16:38:30 -07004370 status = eSIR_FAILURE;
4371 goto end;
4372 }
4373#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM //FEATURE_WLAN_DIAG_SUPPORT
4374 limDiagEventReport(pMac, WLAN_PE_DIAG_DELTS_REQ_EVENT, psessionEntry, 0, 0);
4375#endif //FEATURE_WLAN_DIAG_SUPPORT
4376
4377
4378 if (eSIR_SUCCESS != limValidateDeltsReq(pMac, pDeltsReq, peerMacAddr,psessionEntry))
4379 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004380 PELOGE(limLog(pMac, LOGE, FL("limValidateDeltsReq failed"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07004381 status = eSIR_FAILURE;
4382 limSendSmeDeltsRsp(pMac, pDeltsReq, eSIR_FAILURE,psessionEntry,smesessionId,smetransactionId);
4383 return;
4384 }
4385
Abhishek Singh3cbf6052014-12-15 16:46:42 +05304386 limLog(pMac, LOG1, FL("Sent DELTS request to station with "
4387 "assocId = %d MacAddr = "MAC_ADDRESS_STR),
4388 pDeltsReq->aid, MAC_ADDR_ARRAY(peerMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07004389
4390 limSendDeltsReqActionFrame(pMac, peerMacAddr, pDeltsReq->req.wmeTspecPresent, &pDeltsReq->req.tsinfo, &pDeltsReq->req.tspec,
4391 psessionEntry);
4392
4393 pTsinfo = pDeltsReq->req.wmeTspecPresent ? &pDeltsReq->req.tspec.tsinfo : &pDeltsReq->req.tsinfo;
4394
4395 /* We've successfully send DELTS frame to AP. Update the
4396 * dynamic UAPSD mask. The AC for this TSPEC to be deleted
4397 * is no longer trigger enabled or delivery enabled
4398 */
4399 limSetTspecUapsdMask(pMac, pTsinfo, CLEAR_UAPSD_MASK);
4400
4401 /* We're deleting the TSPEC, so this particular AC is no longer
4402 * admitted. PE needs to downgrade the EDCA
4403 * parameters(for the AC for which TS is being deleted) to the
4404 * next best AC for which ACM is not enabled, and send the
4405 * updated values to HAL.
4406 */
4407 ac = upToAc(pTsinfo->traffic.userPrio);
4408
4409 if(pTsinfo->traffic.direction == SIR_MAC_DIRECTION_UPLINK)
4410 {
4411 pMac->lim.gAcAdmitMask[SIR_MAC_DIRECTION_UPLINK] &= ~(1 << ac);
4412 }
4413 else if(pTsinfo->traffic.direction == SIR_MAC_DIRECTION_DNLINK)
4414 {
4415 pMac->lim.gAcAdmitMask[SIR_MAC_DIRECTION_DNLINK] &= ~(1 << ac);
4416 }
4417 else if(pTsinfo->traffic.direction == SIR_MAC_DIRECTION_BIDIR)
4418 {
4419 pMac->lim.gAcAdmitMask[SIR_MAC_DIRECTION_UPLINK] &= ~(1 << ac);
4420 pMac->lim.gAcAdmitMask[SIR_MAC_DIRECTION_DNLINK] &= ~(1 << ac);
4421 }
4422
4423 limSetActiveEdcaParams(pMac, psessionEntry->gLimEdcaParams, psessionEntry);
4424
4425 pStaDs = dphGetHashEntry(pMac, DPH_STA_HASH_INDEX_PEER, &psessionEntry->dph.dphHashTable);
4426 if (pStaDs != NULL)
4427 {
4428 if (pStaDs->aniPeer == eANI_BOOLEAN_TRUE)
4429 limSendEdcaParams(pMac, psessionEntry->gLimEdcaParamsActive, pStaDs->bssId, eANI_BOOLEAN_TRUE);
4430 else
4431 limSendEdcaParams(pMac, psessionEntry->gLimEdcaParamsActive, pStaDs->bssId, eANI_BOOLEAN_FALSE);
4432 status = eSIR_SUCCESS;
4433 }
4434 else
4435 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004436 limLog(pMac, LOGE, FL("Self entry missing in Hash Table "));
Jeff Johnson295189b2012-06-20 16:38:30 -07004437 status = eSIR_FAILURE;
4438 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004439#ifdef FEATURE_WLAN_ESE
4440#ifdef FEATURE_WLAN_ESE_UPLOAD
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004441 limSendSmeTsmIEInd(pMac, psessionEntry, 0, 0, 0);
4442#else
Jeff Johnson295189b2012-06-20 16:38:30 -07004443 limDeactivateAndChangeTimer(pMac,eLIM_TSM_TIMER);
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004444#endif /* FEATURE_WLAN_ESE_UPLOAD */
Jeff Johnson295189b2012-06-20 16:38:30 -07004445#endif
4446
4447 // send an sme response back
4448 end:
4449 limSendSmeDeltsRsp(pMac, pDeltsReq, eSIR_SUCCESS,psessionEntry,smesessionId,smetransactionId);
4450}
4451
4452
4453void
4454limProcessSmeAddtsRspTimeout(tpAniSirGlobal pMac, tANI_U32 param)
4455{
4456 //fetch the sessionEntry based on the sessionId
4457 tpPESession psessionEntry;
4458 if((psessionEntry = peFindSessionBySessionId(pMac, pMac->lim.limTimers.gLimAddtsRspTimer.sessionId))== NULL)
4459 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004460 limLog(pMac, LOGP,FL("Session Does not exist for given sessionID"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004461 return;
4462 }
4463
4464 if ( (psessionEntry->limSystemRole != eLIM_STA_ROLE) && (psessionEntry->limSystemRole != eLIM_BT_AMP_STA_ROLE) )
4465 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004466 limLog(pMac, LOGW, "AddtsRspTimeout in non-Sta role (%d)", psessionEntry->limSystemRole);
Jeff Johnson295189b2012-06-20 16:38:30 -07004467 pMac->lim.gLimAddtsSent = false;
4468 return;
4469 }
4470
4471 if (! pMac->lim.gLimAddtsSent)
4472 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004473 PELOGW(limLog(pMac, LOGW, "AddtsRspTimeout but no AddtsSent");)
Jeff Johnson295189b2012-06-20 16:38:30 -07004474 return;
4475 }
4476
4477 if (param != pMac->lim.gLimAddtsRspTimerCount)
4478 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004479 limLog(pMac, LOGE, FL("Invalid AddtsRsp Timer count %d (exp %d)"),
Jeff Johnson295189b2012-06-20 16:38:30 -07004480 param, pMac->lim.gLimAddtsRspTimerCount);
4481 return;
4482 }
4483
4484 // this a real response timeout
4485 pMac->lim.gLimAddtsSent = false;
4486 pMac->lim.gLimAddtsRspTimerCount++;
4487
4488 limSendSmeAddtsRsp(pMac, true, eSIR_SME_ADDTS_RSP_TIMEOUT, psessionEntry, pMac->lim.gLimAddtsReq.req.tspec,
4489 psessionEntry->smeSessionId, psessionEntry->transactionId);
4490}
4491
4492
4493/**
4494 * __limProcessSmeStatsRequest()
4495 *
4496 *FUNCTION:
4497 *
4498 *
4499 *NOTE:
4500 *
4501 * @param pMac Pointer to Global MAC structure
4502 * @param *pMsgBuf A pointer to the SME message buffer
4503 * @return None
4504 */
4505static void
4506__limProcessSmeStatsRequest(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
4507{
4508 tpAniGetStatsReq pStatsReq;
4509 tSirMsgQ msgQ;
4510 tpPESession psessionEntry;
4511 tANI_U8 sessionId;
4512
4513
4514 if(pMsgBuf == NULL)
4515 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004516 limLog(pMac, LOGE,FL("Buffer is Pointing to NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004517 return;
4518 }
4519
4520 pStatsReq = (tpAniGetStatsReq) pMsgBuf;
4521
4522 if((psessionEntry = peFindSessionByBssid(pMac,pStatsReq->bssId,&sessionId))== NULL)
4523 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004524 limLog(pMac, LOGE, FL("session does not exist for given bssId"));
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304525 vos_mem_free( pMsgBuf );
Leela Venkata Kiran Kumar Reddy Chiralad6c0fe22013-12-11 19:10:50 -08004526 pMsgBuf = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004527 return;
4528 }
4529
4530
4531
4532 switch(pStatsReq->msgType)
4533 {
4534 //Add Lim stats here. and send reqsponse.
4535
4536 //HAL maintained Stats.
4537 case eWNI_SME_STA_STAT_REQ:
4538 msgQ.type = WDA_STA_STAT_REQ;
4539 break;
4540 case eWNI_SME_AGGR_STAT_REQ:
4541 msgQ.type = WDA_AGGR_STAT_REQ;
4542 break;
4543 case eWNI_SME_GLOBAL_STAT_REQ:
4544 msgQ.type = WDA_GLOBAL_STAT_REQ;
4545 break;
4546 case eWNI_SME_STAT_SUMM_REQ:
4547 msgQ.type = WDA_STAT_SUMM_REQ;
4548 break;
4549 default: //Unknown request.
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004550 PELOGE(limLog(pMac, LOGE, "Unknown Statistics request");)
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304551 vos_mem_free( pMsgBuf );
Leela Venkata Kiran Kumar Reddy Chiralad6c0fe22013-12-11 19:10:50 -08004552 pMsgBuf = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004553 return;
4554 }
4555
Jeff Johnson295189b2012-06-20 16:38:30 -07004556 msgQ.reserved = 0;
4557 msgQ.bodyptr = pMsgBuf;
4558 msgQ.bodyval = 0;
Leela Venkata Kiran Kumar Reddy Chirala68a6abe2013-02-28 07:43:16 -08004559 if(NULL == psessionEntry)
4560 {
4561 MTRACE(macTraceMsgTx(pMac, NO_SESSION, msgQ.type));
4562 }
4563 else
4564 {
4565 MTRACE(macTraceMsgTx(pMac, psessionEntry->peSessionId, msgQ.type));
4566 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004567 if( eSIR_SUCCESS != (wdaPostCtrlMsg( pMac, &msgQ ))){
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004568 limLog(pMac, LOGP, "Unable to forward request");
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304569 vos_mem_free( pMsgBuf );
Leela Venkata Kiran Kumar Reddy Chiralad6c0fe22013-12-11 19:10:50 -08004570 pMsgBuf = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004571 return;
4572 }
4573
4574 return;
4575}
4576
4577
4578/**
4579 * __limProcessSmeGetStatisticsRequest()
4580 *
4581 *FUNCTION:
4582 *
4583 *
4584 *NOTE:
4585 *
4586 * @param pMac Pointer to Global MAC structure
4587 * @param *pMsgBuf A pointer to the SME message buffer
4588 * @return None
4589 */
4590static void
4591__limProcessSmeGetStatisticsRequest(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
4592{
4593 tpAniGetPEStatsReq pPEStatsReq;
4594 tSirMsgQ msgQ;
4595
4596 pPEStatsReq = (tpAniGetPEStatsReq) pMsgBuf;
4597
4598 //pPEStatsReq->msgType should be eWNI_SME_GET_STATISTICS_REQ
4599
4600 msgQ.type = WDA_GET_STATISTICS_REQ;
4601
Jeff Johnson295189b2012-06-20 16:38:30 -07004602 msgQ.reserved = 0;
4603 msgQ.bodyptr = pMsgBuf;
4604 msgQ.bodyval = 0;
Jeff Johnsone7245742012-09-05 17:12:55 -07004605 MTRACE(macTraceMsgTx(pMac, NO_SESSION, msgQ.type));
Jeff Johnson295189b2012-06-20 16:38:30 -07004606
4607 if( eSIR_SUCCESS != (wdaPostCtrlMsg( pMac, &msgQ ))){
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304608 vos_mem_free( pMsgBuf );
Leela Venkata Kiran Kumar Reddy Chiralad6c0fe22013-12-11 19:10:50 -08004609 pMsgBuf = NULL;
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004610 limLog(pMac, LOGP, "Unable to forward request");
Jeff Johnson295189b2012-06-20 16:38:30 -07004611 return;
4612 }
4613
4614 return;
4615}
4616
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004617#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004618/**
4619 *FUNCTION: __limProcessSmeGetTsmStatsRequest()
4620 *
4621 *NOTE:
4622 *
4623 * @param pMac Pointer to Global MAC structure
4624 * @param *pMsgBuf A pointer to the SME message buffer
4625 * @return None
4626 */
4627static void
4628__limProcessSmeGetTsmStatsRequest(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
4629{
4630 tSirMsgQ msgQ;
4631
4632 msgQ.type = WDA_TSM_STATS_REQ;
4633 msgQ.reserved = 0;
4634 msgQ.bodyptr = pMsgBuf;
4635 msgQ.bodyval = 0;
4636 MTRACE(macTraceMsgTx(pMac, NO_SESSION, msgQ.type));
4637
4638 if( eSIR_SUCCESS != (wdaPostCtrlMsg( pMac, &msgQ ))){
4639 vos_mem_free( pMsgBuf );
Leela Venkata Kiran Kumar Reddy Chiralad6c0fe22013-12-11 19:10:50 -08004640 pMsgBuf = NULL;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004641 limLog(pMac, LOGP, "Unable to forward request");
4642 return;
4643 }
4644}
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004645#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004646
4647
Jeff Johnson295189b2012-06-20 16:38:30 -07004648
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004649#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08004650/**
4651 * __limProcessSmeGetRoamRssiRequest()
4652 *
4653 *FUNCTION:
4654 *
4655 *
4656 *NOTE:
4657 *
4658 * @param pMac Pointer to Global MAC structure
4659 * @param *pMsgBuf A pointer to the SME message buffer
4660 * @return None
4661 */
4662static void
4663__limProcessSmeGetRoamRssiRequest(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
4664{
4665 tpAniGetRssiReq pPEGetRoamRssiReq = NULL;
4666 tSirMsgQ msgQ;
4667
4668 pPEGetRoamRssiReq = (tpAniGetRssiReq) pMsgBuf;
4669 msgQ.type = WDA_GET_ROAM_RSSI_REQ;
4670
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08004671 msgQ.reserved = 0;
4672 msgQ.bodyptr = pMsgBuf;
4673 msgQ.bodyval = 0;
4674 MTRACE(macTraceMsgTx(pMac, NO_SESSION, msgQ.type));
4675
4676 if( eSIR_SUCCESS != (wdaPostCtrlMsg( pMac, &msgQ ))){
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304677 vos_mem_free( pMsgBuf );
Leela Venkata Kiran Kumar Reddy Chiralad6c0fe22013-12-11 19:10:50 -08004678 pMsgBuf = NULL;
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004679 limLog(pMac, LOGP, "Unable to forward request");
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08004680 return;
4681 }
4682
4683 return;
4684}
4685#endif
4686
4687
Jeff Johnson295189b2012-06-20 16:38:30 -07004688static void
4689__limProcessSmeUpdateAPWPSIEs(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
4690{
4691 tpSirUpdateAPWPSIEsReq pUpdateAPWPSIEsReq;
4692 tpPESession psessionEntry;
4693 tANI_U8 sessionId; //PE sessionID
4694
4695 PELOG1(limLog(pMac, LOG1,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004696 FL("received UPDATE_APWPSIEs_REQ message")););
Jeff Johnson295189b2012-06-20 16:38:30 -07004697
4698 if(pMsgBuf == NULL)
4699 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004700 limLog(pMac, LOGE,FL("Buffer is Pointing to NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004701 return;
4702 }
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08004703
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304704 pUpdateAPWPSIEsReq = vos_mem_malloc(sizeof(tSirUpdateAPWPSIEsReq));
4705 if ( NULL == pUpdateAPWPSIEsReq )
Jeff Johnson295189b2012-06-20 16:38:30 -07004706 {
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304707 limLog(pMac, LOGP, FL("call to AllocateMemory failed for pUpdateAPWPSIEsReq"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004708 return;
4709 }
4710
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08004711 if ((limUpdateAPWPSIEsReqSerDes(pMac, pUpdateAPWPSIEsReq, (tANI_U8 *) pMsgBuf) == eSIR_FAILURE))
Jeff Johnson295189b2012-06-20 16:38:30 -07004712 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004713 limLog(pMac, LOGW, FL("received invalid SME_SETCONTEXT_REQ message"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004714 goto end;
4715 }
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08004716
Jeff Johnson295189b2012-06-20 16:38:30 -07004717 if((psessionEntry = peFindSessionByBssid(pMac, pUpdateAPWPSIEsReq->bssId, &sessionId)) == NULL)
4718 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004719 limLog(pMac, LOGW, FL("Session does not exist for given BSSID"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004720 goto end;
4721 }
4722
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304723 vos_mem_copy( &psessionEntry->APWPSIEs, &pUpdateAPWPSIEsReq->APWPSIEs, sizeof(tSirAPWPSIEs));
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08004724
Jeff Johnson295189b2012-06-20 16:38:30 -07004725 schSetFixedBeaconFields(pMac, psessionEntry);
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08004726 limSendBeaconInd(pMac, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07004727
4728end:
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304729 vos_mem_free( pUpdateAPWPSIEsReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07004730 return;
4731} /*** end __limProcessSmeUpdateAPWPSIEs(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf) ***/
4732
4733static void
4734__limProcessSmeHideSSID(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
4735{
4736 tpSirUpdateParams pUpdateParams;
4737 tpPESession psessionEntry;
4738
Abhishek Singh3cbf6052014-12-15 16:46:42 +05304739 limLog(pMac, LOG1,
4740 FL("received SME_HIDE_SSID message"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004741
4742 if(pMsgBuf == NULL)
4743 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004744 limLog(pMac, LOGE,FL("Buffer is Pointing to NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004745 return;
4746 }
4747
4748 pUpdateParams = (tpSirUpdateParams)pMsgBuf;
4749
4750 if((psessionEntry = peFindSessionBySessionId(pMac, pUpdateParams->sessionId)) == NULL)
4751 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004752 limLog(pMac, LOGW, "Session does not exist for given sessionId %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07004753 pUpdateParams->sessionId);
4754 return;
4755 }
4756
4757 /* Update the session entry */
4758 psessionEntry->ssidHidden = pUpdateParams->ssidHidden;
4759
4760 /* Update beacon */
4761 schSetFixedBeaconFields(pMac, psessionEntry);
4762 limSendBeaconInd(pMac, psessionEntry);
4763
4764 return;
4765} /*** end __limProcessSmeHideSSID(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf) ***/
4766
4767static void
4768__limProcessSmeSetWPARSNIEs(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
4769{
4770 tpSirUpdateAPWPARSNIEsReq pUpdateAPWPARSNIEsReq;
4771 tpPESession psessionEntry;
4772 tANI_U8 sessionId; //PE sessionID
4773
4774 if(pMsgBuf == NULL)
4775 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004776 limLog(pMac, LOGE,FL("Buffer is Pointing to NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004777 return;
4778 }
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304779
4780 pUpdateAPWPARSNIEsReq = vos_mem_malloc(sizeof(tSirUpdateAPWPSIEsReq));
4781 if ( NULL == pUpdateAPWPARSNIEsReq )
Jeff Johnson295189b2012-06-20 16:38:30 -07004782 {
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304783 limLog(pMac, LOGP, FL("call to AllocateMemory failed for pUpdateAPWPARSNIEsReq"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004784 return;
4785 }
4786
4787 if ((limUpdateAPWPARSNIEsReqSerDes(pMac, pUpdateAPWPARSNIEsReq, (tANI_U8 *) pMsgBuf) == eSIR_FAILURE))
4788 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004789 limLog(pMac, LOGW, FL("received invalid SME_SETCONTEXT_REQ message"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004790 goto end;
4791 }
4792
4793 if((psessionEntry = peFindSessionByBssid(pMac, pUpdateAPWPARSNIEsReq->bssId, &sessionId)) == NULL)
4794 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004795 limLog(pMac, LOGW, FL("Session does not exist for given BSSID"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004796 goto end;
4797 }
4798
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304799 vos_mem_copy(&psessionEntry->pLimStartBssReq->rsnIE,
4800 &pUpdateAPWPARSNIEsReq->APWPARSNIEs, sizeof(tSirRSNie));
Jeff Johnson295189b2012-06-20 16:38:30 -07004801
4802 limSetRSNieWPAiefromSmeStartBSSReqMessage(pMac, &psessionEntry->pLimStartBssReq->rsnIE, psessionEntry);
4803
4804 psessionEntry->pLimStartBssReq->privacy = 1;
4805 psessionEntry->privacy = 1;
4806
4807 schSetFixedBeaconFields(pMac, psessionEntry);
4808 limSendBeaconInd(pMac, psessionEntry);
4809
4810end:
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304811 vos_mem_free(pUpdateAPWPARSNIEsReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07004812 return;
4813} /*** end __limProcessSmeSetWPARSNIEs(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf) ***/
4814
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08004815/*
4816Update the beacon Interval dynamically if beaconInterval is different in MCC
4817*/
4818static void
4819__limProcessSmeChangeBI(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
4820{
4821 tpSirChangeBIParams pChangeBIParams;
4822 tpPESession psessionEntry;
4823 tANI_U8 sessionId = 0;
4824 tUpdateBeaconParams beaconParams;
4825
4826 PELOG1(limLog(pMac, LOG1,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004827 FL("received Update Beacon Interval message")););
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08004828
4829 if(pMsgBuf == NULL)
4830 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004831 limLog(pMac, LOGE,FL("Buffer is Pointing to NULL"));
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08004832 return;
4833 }
4834
Kaushik, Sushantfb156732014-01-07 15:36:03 +05304835 vos_mem_zero(&beaconParams, sizeof(tUpdateBeaconParams));
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08004836 pChangeBIParams = (tpSirChangeBIParams)pMsgBuf;
4837
4838 if((psessionEntry = peFindSessionByBssid(pMac, pChangeBIParams->bssId, &sessionId)) == NULL)
4839 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004840 limLog(pMac, LOGE, FL("Session does not exist for given BSSID"));
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08004841 return;
4842 }
4843
4844 /*Update sessionEntry Beacon Interval*/
4845 if(psessionEntry->beaconParams.beaconInterval !=
4846 pChangeBIParams->beaconInterval )
4847 {
4848 psessionEntry->beaconParams.beaconInterval = pChangeBIParams->beaconInterval;
4849 }
4850
4851 /*Update sch beaconInterval*/
4852 if(pMac->sch.schObject.gSchBeaconInterval !=
4853 pChangeBIParams->beaconInterval )
4854 {
4855 pMac->sch.schObject.gSchBeaconInterval = pChangeBIParams->beaconInterval;
4856
4857 PELOG1(limLog(pMac, LOG1,
4858 FL("LIM send update BeaconInterval Indication : %d"),pChangeBIParams->beaconInterval););
4859
4860 /* Update beacon */
4861 schSetFixedBeaconFields(pMac, psessionEntry);
4862
Sunil Ravib96f7b52013-05-22 21:40:05 -07004863 beaconParams.bssIdx = psessionEntry->bssIdx;
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08004864 //Set change in beacon Interval
4865 beaconParams.beaconInterval = pChangeBIParams->beaconInterval;
Jeff Johnson312557b2013-04-03 16:27:48 -07004866 beaconParams.paramChangeBitmap = PARAM_BCN_INTERVAL_CHANGED;
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08004867 limSendBeaconParams(pMac, &beaconParams, psessionEntry);
4868 }
4869
4870 return;
4871} /*** end __limProcessSmeChangeBI(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf) ***/
4872
Hardik Kantilal Patel62a3a762014-11-21 12:55:57 +05304873/** -------------------------------------------------------------
4874\fn
4875\brief handles indication message from HDD to update HT mode
4876\param tpAniSirGlobal pMac
4877\param tANI_U32 pMsgBuf
4878\return None
4879-------------------------------------------------------------*/
4880#ifdef WLAN_FEATURE_AP_HT40_24G
4881static void __limProcessSmeSetHT2040Mode(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
4882{
4883 tpSirSetHT2040Mode pSetHT2040Mode;
4884 tpPESession psessionEntry;
4885 tANI_U8 sessionId = 0;
4886 tUpdateVHTOpMode *pHtOpMode = NULL;
4887 vos_msg_t msg;
Jeff Johnson295189b2012-06-20 16:38:30 -07004888
Hardik Kantilal Patel62a3a762014-11-21 12:55:57 +05304889 PELOG1(limLog(pMac, LOGRW,
4890 FL("received Set HT 20/40 mode message")););
4891
4892 if(pMsgBuf == NULL)
4893 {
4894 limLog(pMac, LOGE,FL("Buffer is Pointing to NULL"));
4895 return;
4896 }
4897
4898 pSetHT2040Mode = (tpSirSetHT2040Mode)pMsgBuf;
4899
4900 if((psessionEntry = peFindSessionByBssid(pMac, pSetHT2040Mode->bssId,
4901 &sessionId)) == NULL)
4902 {
4903 limLog(pMac, LOGE, FL("Session does not exist for given BSSID "));
4904 limPrintMacAddr(pMac, pSetHT2040Mode->bssId, LOGE);
4905 return;
4906 }
4907
4908 limLog(pMac, LOGW, FL("Update session entry for cbMod=%d"),
4909 pSetHT2040Mode->cbMode);
4910
4911 /*Update sessionEntry HT related fields*/
4912 switch(pSetHT2040Mode->cbMode)
4913 {
4914 case PHY_SINGLE_CHANNEL_CENTERED:
4915 psessionEntry->htSecondaryChannelOffset = PHY_SINGLE_CHANNEL_CENTERED;
4916 psessionEntry->htRecommendedTxWidthSet = 0;
4917 break;
4918 case PHY_DOUBLE_CHANNEL_LOW_PRIMARY:
4919 psessionEntry->htSecondaryChannelOffset =
4920 PHY_DOUBLE_CHANNEL_LOW_PRIMARY;
4921 psessionEntry->htRecommendedTxWidthSet = 1;
4922 break;
4923 case PHY_DOUBLE_CHANNEL_HIGH_PRIMARY:
4924 psessionEntry->htSecondaryChannelOffset =
4925 PHY_DOUBLE_CHANNEL_HIGH_PRIMARY;
4926 psessionEntry->htRecommendedTxWidthSet = 1;
4927 break;
4928 default:
4929 limLog(pMac, LOGE,FL("Invalid cbMode"));
4930 return;
4931 }
4932
4933 limLog(pMac, LOGW, FL("Channel Bonding mode : %d"
4934 " htSecondaryChannelOffset: %d"
4935 " htRecommendedTxWidthSet :%d"),
4936 pSetHT2040Mode->cbMode,
4937 psessionEntry->htSecondaryChannelOffset,
4938 psessionEntry->htRecommendedTxWidthSet);
4939
4940 limLog(pMac, LOGW, FL("Update Beacon IEs"));
4941
4942 /* Update beacon */
4943 schSetFixedBeaconFields(pMac, psessionEntry);
4944 limSendBeaconInd(pMac, psessionEntry);
4945
4946 /* Update OP Mode */
4947 pHtOpMode = vos_mem_malloc(sizeof(tUpdateVHTOpMode));
4948 if ( NULL == pHtOpMode )
4949 {
4950 limLog(pMac, LOGE,
4951 FL("Not able to allocate memory for setting OP mode"));
4952 return;
4953 }
4954
4955 pHtOpMode->opMode = (psessionEntry->htSecondaryChannelOffset ==
4956 PHY_SINGLE_CHANNEL_CENTERED)?
4957 eHT_CHANNEL_WIDTH_20MHZ:eHT_CHANNEL_WIDTH_40MHZ;
4958
4959 /* Pass Self STA ID to FW. Based on Self STA ID FW will update the
4960 * operating mode for all connected STA.
4961 */
4962
4963 pHtOpMode->staId = psessionEntry->staId;
4964
4965 msg.type = WDA_UPDATE_OP_MODE;
4966 msg.reserved = 0;
4967 msg.bodyptr = pHtOpMode;
4968
4969 if (!VOS_IS_STATUS_SUCCESS(
4970 vos_mq_post_message(VOS_MODULE_ID_WDA, &msg)))
4971 {
4972 limLog(pMac, LOGE,
4973 FL("Not able to post WDA_UPDATE_OP_MODE message to WDA"));
4974 vos_mem_free(pHtOpMode);
4975 return;
4976 }
4977
4978 limLog(pMac, LOGW,
4979 FL("Notifed FW about OP mode: %d for staId=%d"),
4980 pHtOpMode->opMode, pHtOpMode->staId);
4981
4982 return;
4983}
4984#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004985
4986/** -------------------------------------------------------------
4987\fn limProcessSmeDelBaPeerInd
4988\brief handles indication message from HDD to send delete BA request
4989\param tpAniSirGlobal pMac
4990\param tANI_U32 pMsgBuf
4991\return None
4992-------------------------------------------------------------*/
4993void
4994limProcessSmeDelBaPeerInd(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
4995{
4996 tANI_U16 assocId =0;
4997 tpSmeDelBAPeerInd pSmeDelBAPeerInd = (tpSmeDelBAPeerInd)pMsgBuf;
4998 tpDphHashNode pSta;
4999 tpPESession psessionEntry;
5000 tANI_U8 sessionId;
5001
5002
5003
5004 if(NULL == pSmeDelBAPeerInd)
5005 return;
5006
5007 if ((psessionEntry = peFindSessionByBssid(pMac,pSmeDelBAPeerInd->bssId,&sessionId))==NULL)
5008 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005009 limLog(pMac, LOGE,FL("session does not exist for given bssId"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005010 return;
5011 }
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005012 limLog(pMac, LOGW, FL("called with staId = %d, tid = %d, baDirection = %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07005013 pSmeDelBAPeerInd->staIdx, pSmeDelBAPeerInd->baTID, pSmeDelBAPeerInd->baDirection);
5014
5015 pSta = dphLookupAssocId(pMac, pSmeDelBAPeerInd->staIdx, &assocId, &psessionEntry->dph.dphHashTable);
5016 if( eSIR_SUCCESS != limPostMlmDelBAReq( pMac,
5017 pSta,
5018 pSmeDelBAPeerInd->baDirection,
5019 pSmeDelBAPeerInd->baTID,
5020 eSIR_MAC_UNSPEC_FAILURE_REASON,psessionEntry))
5021 {
5022 limLog( pMac, LOGW,
5023 FL( "Failed to post LIM_MLM_DELBA_REQ to " ));
5024 if (pSta)
5025 limPrintMacAddr(pMac, pSta->staAddr, LOGW);
5026 }
5027}
5028
5029// --------------------------------------------------------------------
5030/**
5031 * __limProcessReportMessage
5032 *
5033 * FUNCTION: Processes the next received Radio Resource Management message
5034 *
5035 * LOGIC:
5036 *
5037 * ASSUMPTIONS:
5038 *
5039 * NOTE:
5040 *
5041 * @param None
5042 * @return None
5043 */
5044
5045void __limProcessReportMessage(tpAniSirGlobal pMac, tpSirMsgQ pMsg)
5046{
5047#ifdef WLAN_FEATURE_VOWIFI
5048 switch (pMsg->type)
5049 {
5050 case eWNI_SME_NEIGHBOR_REPORT_REQ_IND:
5051 rrmProcessNeighborReportReq( pMac, pMsg->bodyptr );
5052 break;
5053 case eWNI_SME_BEACON_REPORT_RESP_XMIT_IND:
5054 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005055#if defined(FEATURE_WLAN_ESE) && !defined(FEATURE_WLAN_ESE_UPLOAD)
Jeff Johnson295189b2012-06-20 16:38:30 -07005056 tpSirBeaconReportXmitInd pBcnReport=NULL;
5057 tpPESession psessionEntry=NULL;
5058 tANI_U8 sessionId;
Padma, Santhosh Kumar20d45a12016-04-05 13:11:00 +05305059 tpEsePEContext pEseContext = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005060
5061 if(pMsg->bodyptr == NULL)
5062 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005063 limLog(pMac, LOGE,FL("Buffer is Pointing to NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005064 return;
5065 }
5066 pBcnReport = (tpSirBeaconReportXmitInd )pMsg->bodyptr;
5067 if((psessionEntry = peFindSessionByBssid(pMac, pBcnReport->bssId,&sessionId))== NULL)
5068 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005069 limLog(pMac, LOGE, "Session Does not exist for given bssId");
Jeff Johnson295189b2012-06-20 16:38:30 -07005070 return;
5071 }
Padma, Santhosh Kumar20d45a12016-04-05 13:11:00 +05305072
5073 pEseContext = &psessionEntry->eseContext;
5074
5075 if (psessionEntry->isESEconnection && pEseContext->curMeasReq.isValid)
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005076 eseProcessBeaconReportXmit( pMac, pMsg->bodyptr);
Jeff Johnson295189b2012-06-20 16:38:30 -07005077 else
5078#endif
5079 rrmProcessBeaconReportXmit( pMac, pMsg->bodyptr );
5080 }
5081 break;
5082 }
5083#endif
5084}
5085
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005086#if defined(FEATURE_WLAN_ESE) || defined(WLAN_FEATURE_VOWIFI)
Jeff Johnson295189b2012-06-20 16:38:30 -07005087// --------------------------------------------------------------------
5088/**
5089 * limSendSetMaxTxPowerReq
5090 *
5091 * FUNCTION: Send SIR_HAL_SET_MAX_TX_POWER_REQ message to change the max tx power.
5092 *
5093 * LOGIC:
5094 *
5095 * ASSUMPTIONS:
5096 *
5097 * NOTE:
5098 *
5099 * @param txPower txPower to be set.
5100 * @param pSessionEntry session entry.
5101 * @return None
5102 */
5103tSirRetStatus
5104limSendSetMaxTxPowerReq ( tpAniSirGlobal pMac, tPowerdBm txPower, tpPESession pSessionEntry )
5105{
5106 tpMaxTxPowerParams pMaxTxParams = NULL;
5107 tSirRetStatus retCode = eSIR_SUCCESS;
5108 tSirMsgQ msgQ;
5109
5110 if( pSessionEntry == NULL )
5111 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005112 PELOGE(limLog(pMac, LOGE, "%s:%d: Inavalid parameters", __func__, __LINE__ );)
Jeff Johnson295189b2012-06-20 16:38:30 -07005113 return eSIR_FAILURE;
5114 }
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05305115
5116 pMaxTxParams = vos_mem_malloc(sizeof(tMaxTxPowerParams));
5117 if ( NULL == pMaxTxParams )
Jeff Johnson295189b2012-06-20 16:38:30 -07005118 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005119 limLog( pMac, LOGP, "%s:%d:Unable to allocate memory for pMaxTxParams ", __func__, __LINE__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005120 return eSIR_MEM_ALLOC_FAILED;
5121
5122 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005123#if defined(WLAN_VOWIFI_DEBUG) || defined(FEATURE_WLAN_ESE)
Abhishek Singh3cbf6052014-12-15 16:46:42 +05305124 limLog( pMac, LOG1,
5125 FL(" Allocated memory for pMaxTxParams, which will be freed in other module"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005126#endif
Kiran Kumar Lokerea4db3dc2013-03-25 18:05:24 -07005127 if( pMaxTxParams == NULL )
5128 {
Abhishek Singh3cbf6052014-12-15 16:46:42 +05305129 limLog( pMac, LOGE, FL("pMaxTxParams is NULL"));
Kiran Kumar Lokerea4db3dc2013-03-25 18:05:24 -07005130 return eSIR_FAILURE;
5131 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005132 pMaxTxParams->power = txPower;
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05305133 vos_mem_copy( pMaxTxParams->bssId, pSessionEntry->bssId, sizeof(tSirMacAddr) );
5134 vos_mem_copy( pMaxTxParams->selfStaMacAddr, pSessionEntry->selfMacAddr, sizeof(tSirMacAddr) );
Jeff Johnson295189b2012-06-20 16:38:30 -07005135
Jeff Johnson68ce9c42013-04-08 10:33:28 -07005136 msgQ.type = WDA_SET_MAX_TX_POWER_REQ;
5137 msgQ.bodyptr = pMaxTxParams;
5138 msgQ.bodyval = 0;
Abhishek Singh3cbf6052014-12-15 16:46:42 +05305139 limLog(pMac, LOG1, FL("Posting WDA_SET_MAX_TX_POWER_REQ to WDA"));
Jeff Johnson68ce9c42013-04-08 10:33:28 -07005140 MTRACE(macTraceMsgTx(pMac, pSessionEntry->peSessionId, msgQ.type));
5141 retCode = wdaPostCtrlMsg(pMac, &msgQ);
5142 if (eSIR_SUCCESS != retCode)
5143 {
5144 PELOGE(limLog(pMac, LOGE, FL("wdaPostCtrlMsg() failed"));)
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05305145 vos_mem_free(pMaxTxParams);
Jeff Johnson68ce9c42013-04-08 10:33:28 -07005146 }
5147 return retCode;
Jeff Johnson295189b2012-06-20 16:38:30 -07005148}
5149#endif
5150
5151/**
5152 * __limProcessSmeAddStaSelfReq()
5153 *
5154 *FUNCTION:
5155 * This function is called to process SME_ADD_STA_SELF_REQ message
5156 * from SME. It sends a SIR_HAL_ADD_STA_SELF_REQ message to HAL.
5157 *
5158 *LOGIC:
5159 *
5160 *ASSUMPTIONS:
5161 *
5162 *NOTE:
5163 *
5164 * @param pMac Pointer to Global MAC structure
5165 * @param *pMsgBuf A pointer to the SME message buffer
5166 * @return None
5167 */
5168
5169static void
5170__limProcessSmeAddStaSelfReq(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
5171{
5172 tSirMsgQ msg;
5173 tpAddStaSelfParams pAddStaSelfParams;
5174 tpSirSmeAddStaSelfReq pSmeReq = (tpSirSmeAddStaSelfReq) pMsgBuf;
5175
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05305176 pAddStaSelfParams = vos_mem_malloc(sizeof(tAddStaSelfParams));
5177 if ( NULL == pAddStaSelfParams )
Jeff Johnson295189b2012-06-20 16:38:30 -07005178 {
5179 limLog( pMac, LOGP, FL("Unable to allocate memory for tAddSelfStaParams") );
5180 return;
5181 }
5182
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05305183 vos_mem_copy( pAddStaSelfParams->selfMacAddr, pSmeReq->selfMacAddr, sizeof(tSirMacAddr) );
Kiran Kumar Lokeread7dbc82013-10-07 20:12:50 -07005184 pAddStaSelfParams->currDeviceMode = pSmeReq->currDeviceMode;
Jeff Johnson295189b2012-06-20 16:38:30 -07005185 msg.type = SIR_HAL_ADD_STA_SELF_REQ;
5186 msg.reserved = 0;
5187 msg.bodyptr = pAddStaSelfParams;
5188 msg.bodyval = 0;
5189
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005190 PELOGW(limLog(pMac, LOG1, FL("sending SIR_HAL_ADD_STA_SELF_REQ msg to HAL"));)
Jeff Johnsone7245742012-09-05 17:12:55 -07005191 MTRACE(macTraceMsgTx(pMac, NO_SESSION, msg.type));
Jeff Johnson295189b2012-06-20 16:38:30 -07005192
5193 if(eSIR_SUCCESS != wdaPostCtrlMsg(pMac, &msg))
5194 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005195 limLog(pMac, LOGP, FL("wdaPostCtrlMsg failed"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005196 }
5197 return;
5198} /*** end __limProcessAddStaSelfReq() ***/
5199
5200
5201/**
5202 * __limProcessSmeDelStaSelfReq()
5203 *
5204 *FUNCTION:
5205 * This function is called to process SME_DEL_STA_SELF_REQ message
5206 * from SME. It sends a SIR_HAL_DEL_STA_SELF_REQ message to HAL.
5207 *
5208 *LOGIC:
5209 *
5210 *ASSUMPTIONS:
5211 *
5212 *NOTE:
5213 *
5214 * @param pMac Pointer to Global MAC structure
5215 * @param *pMsgBuf A pointer to the SME message buffer
5216 * @return None
5217 */
5218
5219static void
5220__limProcessSmeDelStaSelfReq(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
5221{
5222 tSirMsgQ msg;
5223 tpDelStaSelfParams pDelStaSelfParams;
5224 tpSirSmeDelStaSelfReq pSmeReq = (tpSirSmeDelStaSelfReq) pMsgBuf;
5225
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05305226 pDelStaSelfParams = vos_mem_malloc(sizeof( tDelStaSelfParams));
5227 if ( NULL == pDelStaSelfParams )
Jeff Johnson295189b2012-06-20 16:38:30 -07005228 {
5229 limLog( pMac, LOGP, FL("Unable to allocate memory for tDelStaSelfParams") );
5230 return;
5231 }
5232
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05305233 vos_mem_copy( pDelStaSelfParams->selfMacAddr, pSmeReq->selfMacAddr, sizeof(tSirMacAddr) );
Jeff Johnson295189b2012-06-20 16:38:30 -07005234
5235 msg.type = SIR_HAL_DEL_STA_SELF_REQ;
5236 msg.reserved = 0;
5237 msg.bodyptr = pDelStaSelfParams;
5238 msg.bodyval = 0;
5239
Mukul Sharmacaf4aca2015-04-17 20:01:40 +05305240 PELOGW(limLog(pMac, LOG1, FL("sending SIR_HAL_DEL_STA_SELF_REQ msg to HAL"));)
Jeff Johnsone7245742012-09-05 17:12:55 -07005241 MTRACE(macTraceMsgTx(pMac, NO_SESSION, msg.type));
Jeff Johnson295189b2012-06-20 16:38:30 -07005242
5243 if(eSIR_SUCCESS != wdaPostCtrlMsg(pMac, &msg))
5244 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005245 limLog(pMac, LOGP, FL("wdaPostCtrlMsg failed"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005246 }
5247 return;
5248} /*** end __limProcessSmeDelStaSelfReq() ***/
5249
5250
Jeff Johnson295189b2012-06-20 16:38:30 -07005251/**
5252 * __limProcessSmeRegisterMgmtFrameReq()
5253 *
5254 *FUNCTION:
5255 * This function is called to process eWNI_SME_REGISTER_MGMT_FRAME_REQ message
5256 * from SME. It Register this information within PE.
5257 *
5258 *LOGIC:
5259 *
5260 *ASSUMPTIONS:
5261 *
5262 *NOTE:
5263 *
5264 * @param pMac Pointer to Global MAC structure
5265 * @param *pMsgBuf A pointer to the SME message buffer
5266 * @return None
5267 */
5268static void
5269__limProcessSmeRegisterMgmtFrameReq(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
5270{
5271 VOS_STATUS vosStatus;
5272 tpSirRegisterMgmtFrame pSmeReq = (tpSirRegisterMgmtFrame)pMsgBuf;
5273 tpLimMgmtFrameRegistration pLimMgmtRegistration = NULL, pNext = NULL;
Jeff Johnsond13512a2012-07-17 11:42:19 -07005274 tANI_BOOLEAN match = VOS_FALSE;
Abhishek Singh3cbf6052014-12-15 16:46:42 +05305275 limLog(pMac, LOG1,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005276 FL("registerFrame %d, frameType %d, matchLen %d"),
Abhishek Singh3cbf6052014-12-15 16:46:42 +05305277 pSmeReq->registerFrame, pSmeReq->frameType, pSmeReq->matchLen);
Jeff Johnson295189b2012-06-20 16:38:30 -07005278
Jeff Johnsond13512a2012-07-17 11:42:19 -07005279 /* First check whether entry exists already*/
5280
5281 vos_list_peek_front(&pMac->lim.gLimMgmtFrameRegistratinQueue,
5282 (vos_list_node_t**)&pLimMgmtRegistration);
5283
5284 while(pLimMgmtRegistration != NULL)
5285 {
5286 if (pLimMgmtRegistration->frameType == pSmeReq->frameType)
5287 {
5288 if(pSmeReq->matchLen)
5289 {
5290 if (pLimMgmtRegistration->matchLen == pSmeReq->matchLen)
5291 {
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05305292 if (vos_mem_compare( pLimMgmtRegistration->matchData,
Jeff Johnsond13512a2012-07-17 11:42:19 -07005293 pSmeReq->matchData, pLimMgmtRegistration->matchLen))
5294 {
Madan Mohan Koyyalamudic537df22012-10-22 15:07:08 -07005295 /* found match! */
5296 match = VOS_TRUE;
5297 break;
Jeff Johnsond13512a2012-07-17 11:42:19 -07005298 }
5299 }
5300 }
5301 else
5302 {
Madan Mohan Koyyalamudic537df22012-10-22 15:07:08 -07005303 /* found match! */
Jeff Johnsond13512a2012-07-17 11:42:19 -07005304 match = VOS_TRUE;
5305 break;
5306 }
5307 }
5308 vosStatus = vos_list_peek_next (
5309 &pMac->lim.gLimMgmtFrameRegistratinQueue,
5310 (vos_list_node_t*) pLimMgmtRegistration,
5311 (vos_list_node_t**) &pNext );
5312
5313 pLimMgmtRegistration = pNext;
5314 pNext = NULL;
5315
5316 }
5317
5318 if (match)
5319 {
5320 vos_list_remove_node(&pMac->lim.gLimMgmtFrameRegistratinQueue,
5321 (vos_list_node_t*)pLimMgmtRegistration);
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05305322 vos_mem_free(pLimMgmtRegistration);
Jeff Johnsond13512a2012-07-17 11:42:19 -07005323 }
5324
Jeff Johnson295189b2012-06-20 16:38:30 -07005325 if(pSmeReq->registerFrame)
5326 {
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05305327 pLimMgmtRegistration = vos_mem_malloc(sizeof(tLimMgmtFrameRegistration) + pSmeReq->matchLen);
5328 if ( pLimMgmtRegistration != NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -07005329 {
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05305330 vos_mem_set((void*)pLimMgmtRegistration,
5331 sizeof(tLimMgmtFrameRegistration) + pSmeReq->matchLen, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005332 pLimMgmtRegistration->frameType = pSmeReq->frameType;
5333 pLimMgmtRegistration->matchLen = pSmeReq->matchLen;
5334 pLimMgmtRegistration->sessionId = pSmeReq->sessionId;
5335 if(pSmeReq->matchLen)
5336 {
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05305337 vos_mem_copy(pLimMgmtRegistration->matchData,
5338 pSmeReq->matchData, pSmeReq->matchLen);
Jeff Johnson295189b2012-06-20 16:38:30 -07005339 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005340 vos_list_insert_front(&pMac->lim.gLimMgmtFrameRegistratinQueue,
5341 &pLimMgmtRegistration->node);
5342 }
5343 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005344
5345 return;
5346} /*** end __limProcessSmeRegisterMgmtFrameReq() ***/
Viral Modid86bde22012-12-10 13:09:21 -08005347
5348static tANI_BOOLEAN
Viral Modid440e682013-03-06 02:25:31 -08005349__limInsertSingleShotNOAForScan(tpAniSirGlobal pMac, tANI_U32 noaDuration)
Viral Modid86bde22012-12-10 13:09:21 -08005350{
5351 tpP2pPsParams pMsgNoA;
5352 tSirMsgQ msg;
Vinay Malekal62757362012-12-17 12:15:51 -08005353
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05305354 pMsgNoA = vos_mem_malloc(sizeof( tP2pPsConfig ));
5355 if ( NULL == pMsgNoA )
Viral Modid86bde22012-12-10 13:09:21 -08005356 {
5357 limLog( pMac, LOGP,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005358 FL( "Unable to allocate memory during NoA Update" ));
Viral Modid440e682013-03-06 02:25:31 -08005359 goto error;
Viral Modid86bde22012-12-10 13:09:21 -08005360 }
5361
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05305362 vos_mem_set((tANI_U8 *)pMsgNoA, sizeof(tP2pPsConfig), 0);
Viral Modid86bde22012-12-10 13:09:21 -08005363 /* Below params used for opp PS/periodic NOA and are don't care in this case - so initialized to 0 */
5364 pMsgNoA->opp_ps = 0;
5365 pMsgNoA->ctWindow = 0;
5366 pMsgNoA->duration = 0;
5367 pMsgNoA->interval = 0;
5368 pMsgNoA->count = 0;
Vinay Malekal62757362012-12-17 12:15:51 -08005369
Vinay Malekal62757362012-12-17 12:15:51 -08005370 /* Below params used for Single Shot NOA - so assign proper values */
5371 pMsgNoA->psSelection = P2P_SINGLE_NOA;
Viral Modid440e682013-03-06 02:25:31 -08005372 pMsgNoA->single_noa_duration = noaDuration;
Gopichand Nakkala096a1052012-12-21 07:05:34 -08005373
Viral Modid86bde22012-12-10 13:09:21 -08005374 /* Start Insert NOA timer
5375 * 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 -08005376 * or any other failure or reason, we still need to process the deferred SME req. The insert NOA
5377 * timer of 500 ms will ensure the stored SME req always gets processed
Viral Modid86bde22012-12-10 13:09:21 -08005378 */
5379 if (tx_timer_activate(&pMac->lim.limTimers.gLimP2pSingleShotNoaInsertTimer)
5380 == TX_TIMER_ERROR)
5381 {
5382 /// Could not activate Insert NOA timer.
5383 // Log error
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005384 limLog(pMac, LOGP, FL("could not activate Insert Single Shot NOA during scan timer"));
Viral Modid86bde22012-12-10 13:09:21 -08005385
5386 // send the scan response back with status failure and do not even call insert NOA
5387 limSendSmeScanRsp(pMac, sizeof(tSirSmeScanRsp), eSIR_SME_SCAN_FAILED, pMac->lim.gSmeSessionId, pMac->lim.gTransactionId);
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05305388 vos_mem_free(pMsgNoA);
Viral Modid440e682013-03-06 02:25:31 -08005389 goto error;
Viral Modid86bde22012-12-10 13:09:21 -08005390 }
5391
Viral Modid440e682013-03-06 02:25:31 -08005392 MTRACE(macTrace(pMac, TRACE_CODE_TIMER_ACTIVATE, NO_SESSION, eLIM_INSERT_SINGLESHOT_NOA_TIMER));
5393
Viral Modid86bde22012-12-10 13:09:21 -08005394 msg.type = WDA_SET_P2P_GO_NOA_REQ;
5395 msg.reserved = 0;
5396 msg.bodyptr = pMsgNoA;
5397 msg.bodyval = 0;
5398
5399 if(eSIR_SUCCESS != wdaPostCtrlMsg(pMac, &msg))
5400 {
5401 /* 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 -07005402 limLog(pMac, LOGP, FL("wdaPost Msg failed"));
Viral Modid440e682013-03-06 02:25:31 -08005403 /* Deactivate the NOA timer in failure case */
5404 limDeactivateAndChangeTimer(pMac, eLIM_INSERT_SINGLESHOT_NOA_TIMER);
5405 goto error;
Viral Modid86bde22012-12-10 13:09:21 -08005406 }
Viral Modid440e682013-03-06 02:25:31 -08005407 return FALSE;
Viral Modid86bde22012-12-10 13:09:21 -08005408
Viral Modid440e682013-03-06 02:25:31 -08005409error:
5410 /* In any of the failure cases, just go ahead with the processing of registered deferred SME request without
5411 * worrying about the NOA
5412 */
5413 limProcessRegdDefdSmeReqAfterNOAStart(pMac);
5414 // msg buffer is consumed and freed in above function so return FALSE
Viral Modid86bde22012-12-10 13:09:21 -08005415 return FALSE;
5416
5417}
5418
Viral Modid440e682013-03-06 02:25:31 -08005419static void __limRegisterDeferredSmeReqForNOAStart(tpAniSirGlobal pMac, tANI_U16 msgType, tANI_U32 *pMsgBuf)
5420{
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005421 limLog(pMac, LOG1, FL("Reg msgType %d"), msgType) ;
Viral Modid440e682013-03-06 02:25:31 -08005422 pMac->lim.gDeferMsgTypeForNOA = msgType;
5423 pMac->lim.gpDefdSmeMsgForNOA = pMsgBuf;
5424}
5425
5426static void __limDeregisterDeferredSmeReqAfterNOAStart(tpAniSirGlobal pMac)
5427{
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005428 limLog(pMac, LOG1, FL("Dereg msgType %d"), pMac->lim.gDeferMsgTypeForNOA) ;
Viral Modid440e682013-03-06 02:25:31 -08005429 pMac->lim.gDeferMsgTypeForNOA = 0;
5430 if (pMac->lim.gpDefdSmeMsgForNOA != NULL)
5431 {
5432 /* __limProcessSmeScanReq consumed the buffer. We can free it. */
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05305433 vos_mem_free(pMac->lim.gpDefdSmeMsgForNOA);
Viral Modid440e682013-03-06 02:25:31 -08005434 pMac->lim.gpDefdSmeMsgForNOA = NULL;
5435 }
5436}
5437
5438static
Ganesh Kondabattini16930072014-08-22 16:02:34 +05305439tANI_U32 limCalculateNOADuration(tpAniSirGlobal pMac, tANI_U16 msgType,
5440 tANI_U32 *pMsgBuf, tANI_BOOLEAN isPassiveScan)
Viral Modid440e682013-03-06 02:25:31 -08005441{
5442 tANI_U32 noaDuration = 0;
5443
5444 switch (msgType)
5445 {
5446 case eWNI_SME_SCAN_REQ:
5447 {
5448 tANI_U32 val;
5449 tANI_U8 i;
5450 tpSirSmeScanReq pScanReq = (tpSirSmeScanReq) pMsgBuf;
5451 if (wlan_cfgGetInt(pMac, WNI_CFG_PASSIVE_MAXIMUM_CHANNEL_TIME, &val) != eSIR_SUCCESS)
5452 {
5453 /*
5454 * Could not get max channel value
5455 * from CFG. Log error.
5456 */
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005457 limLog(pMac, LOGP, FL("could not retrieve passive max channel value"));
Viral Modid440e682013-03-06 02:25:31 -08005458
5459 /* use a default value of 110ms */
5460 val = DEFAULT_PASSIVE_MAX_CHANNEL_TIME;
5461 }
5462
5463 for (i = 0; i < pScanReq->channelList.numChannels; i++) {
5464 tANI_U8 channelNum = pScanReq->channelList.channelNumber[i];
5465
Ganesh Kondabattini8f6e3b32014-08-25 16:07:54 +05305466 if (pMac->miracast_mode) {
5467 noaDuration += DEFAULT_MIN_CHAN_TIME_DURING_MIRACAST +
5468 DEFAULT_MAX_CHAN_TIME_DURING_MIRACAST;
5469 } else if (isPassiveScan || !limActiveScanAllowed(pMac, channelNum)) {
Viral Modid440e682013-03-06 02:25:31 -08005470 /* using the value from WNI_CFG_PASSIVE_MINIMUM_CHANNEL_TIME as is done in
5471 * void limContinuePostChannelScan(tpAniSirGlobal pMac)
5472 */
5473 noaDuration += val;
Ganesh Kondabattini16930072014-08-22 16:02:34 +05305474 } else {
5475 /* Use min + max channel time to calculate the total duration of scan */
5476 noaDuration += pScanReq->minChannelTime + pScanReq->maxChannelTime;
Viral Modid440e682013-03-06 02:25:31 -08005477 }
5478 }
5479
5480 /* Adding an overhead of 20ms to account for the scan messaging delays */
5481 noaDuration += SCAN_MESSAGING_OVERHEAD;
5482 noaDuration *= CONV_MS_TO_US;
5483
5484 break;
5485 }
5486
5487 case eWNI_SME_OEM_DATA_REQ:
5488 noaDuration = OEM_DATA_NOA_DURATION*CONV_MS_TO_US; // use 60 msec as default
5489 break;
5490
5491 case eWNI_SME_REMAIN_ON_CHANNEL_REQ:
5492 {
5493 tSirRemainOnChnReq *pRemainOnChnReq = (tSirRemainOnChnReq *) pMsgBuf;
5494 noaDuration = (pRemainOnChnReq->duration)*CONV_MS_TO_US;
5495 break;
5496 }
5497
5498 case eWNI_SME_JOIN_REQ:
5499 noaDuration = JOIN_NOA_DURATION*CONV_MS_TO_US;
5500 break;
5501
5502 default:
5503 noaDuration = 0;
5504 break;
5505
5506 }
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005507 limLog(pMac, LOGW, FL("msgType %d noa %d"), msgType, noaDuration);
Viral Modid440e682013-03-06 02:25:31 -08005508 return noaDuration;
5509}
5510
5511void limProcessRegdDefdSmeReqAfterNOAStart(tpAniSirGlobal pMac)
5512{
Gopichand Nakkala7c4c3b92013-03-25 18:08:31 +05305513 tANI_BOOLEAN bufConsumed = TRUE;
Viral Modid440e682013-03-06 02:25:31 -08005514
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005515 limLog(pMac, LOG1, FL("Process defd sme req %d"), pMac->lim.gDeferMsgTypeForNOA);
Viral Modid440e682013-03-06 02:25:31 -08005516 if ( (pMac->lim.gDeferMsgTypeForNOA != 0) &&
5517 (pMac->lim.gpDefdSmeMsgForNOA != NULL) )
5518 {
5519 switch (pMac->lim.gDeferMsgTypeForNOA)
5520 {
5521 case eWNI_SME_SCAN_REQ:
5522 __limProcessSmeScanReq(pMac, pMac->lim.gpDefdSmeMsgForNOA);
5523 break;
5524 case eWNI_SME_OEM_DATA_REQ:
5525 __limProcessSmeOemDataReq(pMac, pMac->lim.gpDefdSmeMsgForNOA);
5526 break;
5527 case eWNI_SME_REMAIN_ON_CHANNEL_REQ:
Gopichand Nakkala7c4c3b92013-03-25 18:08:31 +05305528 bufConsumed = limProcessRemainOnChnlReq(pMac, pMac->lim.gpDefdSmeMsgForNOA);
5529 /* limProcessRemainOnChnlReq doesnt want us to free the buffer since
5530 * it is freed in limRemainOnChnRsp. this change is to avoid "double free"
5531 */
5532 if (FALSE == bufConsumed)
5533 {
5534 pMac->lim.gpDefdSmeMsgForNOA = NULL;
5535 }
Viral Modid440e682013-03-06 02:25:31 -08005536 break;
5537 case eWNI_SME_JOIN_REQ:
5538 __limProcessSmeJoinReq(pMac, pMac->lim.gpDefdSmeMsgForNOA);
5539 break;
5540 default:
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005541 limLog(pMac, LOGE, FL("Unknown deferred msg type %d"), pMac->lim.gDeferMsgTypeForNOA);
Viral Modid440e682013-03-06 02:25:31 -08005542 break;
5543 }
5544 __limDeregisterDeferredSmeReqAfterNOAStart(pMac);
5545 }
5546 else
5547 {
5548 limLog( pMac, LOGW, FL("start received from FW when no sme deferred msg pending. Do nothing."
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005549 "It might happen sometime when NOA start ind and timeout happen at the same time"));
Viral Modid440e682013-03-06 02:25:31 -08005550 }
5551}
Jeff Johnson295189b2012-06-20 16:38:30 -07005552
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05305553static void
5554__limProcessSmeResetApCapsChange(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
5555{
5556 tpSirResetAPCapsChange pResetCapsChange;
5557 tpPESession psessionEntry;
5558 tANI_U8 sessionId = 0;
5559 if (pMsgBuf == NULL)
5560 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005561 limLog(pMac, LOGE,FL("Buffer is Pointing to NULL"));
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05305562 return;
5563 }
5564
5565 pResetCapsChange = (tpSirResetAPCapsChange)pMsgBuf;
5566 psessionEntry = peFindSessionByBssid(pMac, pResetCapsChange->bssId, &sessionId);
5567 if (psessionEntry == NULL)
5568 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005569 limLog(pMac, LOGE, FL("Session does not exist for given BSSID"));
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05305570 return;
5571 }
5572
5573 psessionEntry->limSentCapsChangeNtf = false;
5574 return;
5575}
5576
Siddharth Bhal6af5d4e2014-09-29 21:11:16 +05305577static void
5578__limProcessSmeSpoofMacAddrRequest(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
5579{
5580 tSirMsgQ msg;
5581 tpSpoofMacAddrReqParams pSpoofMacAddrParams;
5582 tpSirSpoofMacAddrReq pSmeReq = (tpSirSpoofMacAddrReq) pMsgBuf;
5583
5584 pSpoofMacAddrParams = vos_mem_malloc(sizeof( tSpoofMacAddrReqParams));
5585 if ( NULL == pSpoofMacAddrParams )
5586 {
Siddharth Bhal4f3187c2014-10-09 21:38:08 +05305587 limLog( pMac, LOGE, FL("Unable to allocate memory for tDelStaSelfParams") );
Siddharth Bhal6af5d4e2014-09-29 21:11:16 +05305588 return;
5589 }
5590
5591 vos_mem_copy( pSpoofMacAddrParams->macAddr, pSmeReq->macAddr, sizeof(tSirMacAddr) );
5592
Siddharth Bhal4f3187c2014-10-09 21:38:08 +05305593 vos_mem_copy(pMac->lim.spoofMacAddr, pSmeReq->macAddr, VOS_MAC_ADDRESS_LEN);
5594
5595 limLog( pMac, LOG1, FL("Recieved Spoofed Mac Addr request with Addr:"
5596 MAC_ADDRESS_STR), MAC_ADDR_ARRAY(pMac->lim.spoofMacAddr) );
5597
Siddharth Bhal6af5d4e2014-09-29 21:11:16 +05305598 msg.type = WDA_SPOOF_MAC_ADDR_REQ;
5599 msg.reserved = 0;
5600 msg.bodyptr = pSpoofMacAddrParams;
5601 msg.bodyval = 0;
5602
5603 limLog(pMac, LOG1, FL("sending SIR_HAL_SPOOF_MAC_ADDR_REQ msg to HAL"));
5604 MTRACE(macTraceMsgTx(pMac, NO_SESSION, msg.type));
5605
5606 if(eSIR_SUCCESS != wdaPostCtrlMsg(pMac, &msg))
5607 {
Siddharth Bhal4f3187c2014-10-09 21:38:08 +05305608 limLog(pMac, LOGE, FL("wdaPostCtrlMsg failed for SIR_HAL_SPOOF_MAC_ADDR_REQ"));
Siddharth Bhal6af5d4e2014-09-29 21:11:16 +05305609 vos_mem_free(pSpoofMacAddrParams);
5610 }
5611 return;
5612}
5613
Jeff Johnson295189b2012-06-20 16:38:30 -07005614/**
Abhishek Singh7d624e12015-11-30 14:29:27 +05305615 * lim_register_mgmt_frame_ind_cb() - Save the Management frame
5616 * indication callback in PE.
5617 * @pMac: Mac pointer
5618 * @pMsgBuf: Msg pointer containing the callback
5619 *
5620 * This function is used save the Management frame
5621 * indication callback in PE.
5622 *
5623 * Return: None
5624 */
5625static void lim_register_mgmt_frame_ind_cb(tpAniSirGlobal pMac,
5626 tANI_U32 *msg_buf)
5627{
5628 struct sir_sme_mgmt_frame_cb_req *sme_req =
5629 (struct sir_sme_mgmt_frame_cb_req *)msg_buf;
5630
5631 if (NULL == msg_buf)
5632 {
5633 limLog(pMac, LOGE, FL("msg_buf is null"));
5634 return;
5635 }
5636 if (sme_req->callback)
5637 pMac->mgmt_frame_ind_cb =
5638 (sir_mgmt_frame_ind_callback)sme_req->callback;
5639 else
5640 limLog(pMac, LOGE, FL("sme_req->callback is null"));
5641}
Abhishek Singh2b0cf1c2017-10-30 17:36:38 +05305642
Abhishek Singh449c5372017-12-19 17:21:20 +05305643void lim_send_chan_switch_action_frame(tpAniSirGlobal mac_ctx,
Abhishek Singh2b0cf1c2017-10-30 17:36:38 +05305644 uint16_t new_channel, tpPESession session_entry)
5645{
5646 uint16_t op_class;
5647 uint8_t switch_mode = 0, i;
5648 tpDphHashNode psta;
5649 uint8_t switch_count;
5650 tpDphHashNode dph_node_array_ptr;
5651 offset_t ch_offset;
5652
5653 if (session_entry->gLimChannelSwitch.secondarySubBand >=
5654 PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_CENTERED)
5655 ch_offset = BW80;
5656 else
5657 ch_offset = session_entry->gLimChannelSwitch.secondarySubBand;
5658
5659 op_class = limGetOPClassFromChannel(mac_ctx->scan.countryCodeCurrent,
5660 new_channel, ch_offset);
5661
5662 switch_mode = session_entry->gLimChannelSwitch.switchMode;
5663
5664 switch_count = session_entry->gLimChannelSwitch.switchCount;
5665 dph_node_array_ptr = session_entry->dph.dphHashTable.pDphNodeArray;
5666
5667 for (i = 0; i < (mac_ctx->lim.maxStation + 1); i++) {
5668 psta = dph_node_array_ptr + i;
5669 if (!(psta && psta->added))
5670 continue;
5671 if (psta->staType == STA_ENTRY_PEER)
5672 lim_send_extended_chan_switch_action_frame(mac_ctx, psta->staAddr,
5673 switch_mode, op_class, new_channel,
5674 switch_count, session_entry);
5675 }
5676}
5677
Abhishek Singh02605092017-10-25 14:06:12 +05305678/**
5679 * lim_process_sme_set_csa_ie_request() - process sme dfs csa ie req
5680 *
5681 * @mac_ctx: Pointer to Global MAC structure
5682 * @msg_buf: pointer to the SME message buffer
5683 *
5684 * This function processes SME request messages from HDD or upper layer
5685 * application.
5686 *
5687 * Return: None
5688 */
5689static void lim_process_sme_set_csa_ie_request(tpAniSirGlobal mac_ctx,
5690 uint32_t *msg_buf)
5691{
5692 struct sir_ecsa_ie_req *csa_ie_req = (struct sir_ecsa_ie_req *)msg_buf;
5693 uint8_t session_id;
5694 tpPESession session_entry = NULL;
5695 tLimWiderBWChannelSwitchInfo *wider_bw_ch_switch;
5696
5697 if (!csa_ie_req) {
5698 limLog(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
5699 return;
5700 }
5701
5702 session_entry = peFindSessionByBssid(mac_ctx,
5703 csa_ie_req->bssid, &session_id);
5704 if (!session_entry) {
5705 limLog(mac_ctx, LOGE,
5706 FL("Session not found for given BSSID" MAC_ADDRESS_STR),
5707 MAC_ADDR_ARRAY(csa_ie_req->bssid));
5708 return;
5709 }
5710
5711 if (session_entry->valid && !LIM_IS_AP_ROLE(session_entry)) {
5712 limLog(mac_ctx, LOGE, FL("Invalid SystemRole %d"),
5713 GET_LIM_SYSTEM_ROLE(session_entry));
5714 return;
5715 }
5716
5717 /* target channel */
5718 session_entry->gLimChannelSwitch.primaryChannel = csa_ie_req->new_chan;
5719
5720 /* Channel switch announcement needs to be included in beacon */
5721 session_entry->include_ecsa_ie = true;
5722 session_entry->gLimChannelSwitch.switchCount =
5723 CHANNEL_SWITCH_BEACON_COUNT;
5724 session_entry->gLimChannelSwitch.secondarySubBand =
5725 csa_ie_req->cb_mode;
5726 session_entry->gLimChannelSwitch.switchMode = SAP_CHANNEL_SWITCH_MODE;
5727
5728 /* Now encode the Wider Ch BW element depending on the ch width */
5729 if (session_entry->vhtCapability &&
5730 (csa_ie_req->cb_mode >=
5731 PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_CENTERED)) {
5732 wider_bw_ch_switch = &session_entry->gLimWiderBWChannelSwitch;
5733 session_entry->include_wide_ch_bw_ie = true;
5734 wider_bw_ch_switch->newChanWidth = WNI_CFG_VHT_CHANNEL_WIDTH_80MHZ;
5735 /* Fetch the center channel based on the channel width */
5736 wider_bw_ch_switch->newCenterChanFreq0 =
5737 limGetCenterChannel(mac_ctx, csa_ie_req->new_chan,
5738 csa_ie_req->cb_mode,
5739 WNI_CFG_VHT_CHANNEL_WIDTH_80MHZ);
5740 }
5741 /* Send ECSA/CSA IE request from here */
5742 if (schSetFixedBeaconFields(mac_ctx, session_entry) != eSIR_SUCCESS) {
5743 limLog(mac_ctx, LOGE, FL("Unable to set CSA IE in beacon"));
5744 return;
5745 }
5746
Abhishek Singh2b0cf1c2017-10-30 17:36:38 +05305747 limSendBeaconInd(mac_ctx, session_entry);
Abhishek Singh02605092017-10-25 14:06:12 +05305748
Abhishek Singh2b0cf1c2017-10-30 17:36:38 +05305749 lim_send_chan_switch_action_frame(mac_ctx,
5750 csa_ie_req->new_chan, session_entry);
5751
5752 limLog(mac_ctx, LOG1, FL("IE count:%d chan:%d secondarySubBand:%d"),
Abhishek Singh02605092017-10-25 14:06:12 +05305753 session_entry->gLimChannelSwitch.switchCount,
5754 session_entry->gLimChannelSwitch.primaryChannel,
5755 session_entry->gLimChannelSwitch.secondarySubBand);
Abhishek Singh550aa8c2017-10-30 17:34:53 +05305756
5757 mac_ctx->lim.limTimers.g_lim_ap_ecsa_timer.sessionId =
5758 session_entry->peSessionId;
5759 limDeactivateAndChangeTimer(mac_ctx, eLIM_AP_ECSA_TIMER);
5760
5761 if (tx_timer_activate(&mac_ctx->lim.limTimers.g_lim_ap_ecsa_timer) !=
5762 TX_SUCCESS)
5763 {
5764 limLog(mac_ctx, LOGE, FL("Couldn't activate g_lim_ap_ecsa_timer"));
5765 lim_process_ap_ecsa_timeout(mac_ctx);
5766 }
5767}
5768
5769/**
5770 * lim_process_sme_channel_change_request() - process sme ch change req
5771 *
5772 * @mac_ctx: Pointer to Global MAC structure
5773 * @msg_buf: pointer to the SME message buffer
5774 *
5775 * This function is called to process SME_CHANNEL_CHANGE_REQ message
5776 *
5777 * Return: None
5778 */
5779static void lim_process_sme_channel_change_request(tpAniSirGlobal mac_ctx,
5780 uint32_t *msg_buf)
5781{
5782 struct sir_channel_chanege_req *ch_change_req;
5783 tpPESession session_entry;
5784 uint8_t session_id; /* PE session_id */
5785 int8_t max_tx_pwr;
5786 uint32_t val = 0;
Abhishek Singh02b823e2017-10-30 17:53:20 +05305787 uint8_t cb_mode;
Abhishek Singh550aa8c2017-10-30 17:34:53 +05305788
5789 if (!msg_buf) {
5790 limLog(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
5791 return;
5792 }
5793 ch_change_req = (struct sir_channel_chanege_req *)msg_buf;
5794
5795 max_tx_pwr = cfgGetRegulatoryMaxTransmitPower(mac_ctx,
5796 ch_change_req->new_chan);
5797
5798 if ((max_tx_pwr == WDA_MAX_TXPOWER_INVALID)) {
5799 limLog(mac_ctx, LOGE, FL("Invalid Request/max_tx_pwr"));
5800 return;
5801 }
5802
5803 session_entry = peFindSessionByBssid(mac_ctx,
5804 ch_change_req->bssid, &session_id);
5805 if (!session_entry) {
5806 limLog(mac_ctx, LOGE,
5807 FL("Session not found for given BSSID" MAC_ADDRESS_STR),
5808 MAC_ADDR_ARRAY(ch_change_req->bssid));
5809 return;
5810 }
5811
5812 if (session_entry->valid && !LIM_IS_AP_ROLE(session_entry)) {
5813 limLog(mac_ctx, LOGE, FL("Invalid SystemRole %d"),
5814 GET_LIM_SYSTEM_ROLE(session_entry));
5815 return;
5816 }
5817 if (session_entry->currentOperChannel ==
5818 ch_change_req->new_chan) {
5819 limLog(mac_ctx, LOGE, FL("target CH is same as current CH %d"),
5820 session_entry->currentOperChannel);
5821 return;
5822 }
5823
5824 session_entry->channelChangeReasonCode =
5825 LIM_SWITCH_CHANNEL_SAP_ECSA;
Abhishek Singhe3af5042017-11-30 11:42:23 +05305826 session_entry->channelChangeCSA = LIM_SWITCH_CHANNEL_CSA;
Abhishek Singh550aa8c2017-10-30 17:34:53 +05305827
Abhishek Singh02b823e2017-10-30 17:53:20 +05305828 limLog(mac_ctx, LOG1, FL("switch old chnl %d to new chnl %d, cb_mode %d"),
Abhishek Singh550aa8c2017-10-30 17:34:53 +05305829 session_entry->currentOperChannel,
5830 ch_change_req->new_chan,
5831 ch_change_req->cb_mode);
5832
Abhishek Singh02b823e2017-10-30 17:53:20 +05305833 cb_mode = ch_change_req->cb_mode;
5834
5835 if (session_entry->vhtCapability) {
5836 if (cb_mode <= PHY_DOUBLE_CHANNEL_HIGH_PRIMARY) {
5837 session_entry->vhtTxChannelWidthSet =
5838 WNI_CFG_VHT_CHANNEL_WIDTH_20_40MHZ;
5839 session_entry->apChanWidth = WNI_CFG_VHT_CHANNEL_WIDTH_20_40MHZ;
5840 /*
5841 * In case of DFS operation, If AP falls back to lower
5842 * bandwidth [< 80Mhz] then there is no need of
5843 * Center freq segment. So reset it to zero.
5844 */
5845 if (cfgSetInt(mac_ctx, WNI_CFG_VHT_CHANNEL_CENTER_FREQ_SEGMENT1, 0)
5846 != eSIR_SUCCESS)
5847 limLog(mac_ctx, LOGE,
5848 FL("couldn't set center freq seg 0 in beacon"));
5849 if (cfgSetInt(mac_ctx, WNI_CFG_VHT_CHANNEL_WIDTH,
5850 WNI_CFG_VHT_CHANNEL_WIDTH_20_40MHZ) != eSIR_SUCCESS)
5851 limLog(mac_ctx, LOGE, FL("could not set channel width to 20/40 in CFG"));
5852 session_entry->apCenterChan = 0;
5853 } else {
5854 uint32_t center_chan;
5855
5856 session_entry->vhtTxChannelWidthSet =
5857 WNI_CFG_VHT_CHANNEL_WIDTH_80MHZ;
5858 session_entry->apChanWidth = WNI_CFG_VHT_CHANNEL_WIDTH_80MHZ;
5859 center_chan = limGetCenterChannel(mac_ctx, ch_change_req->new_chan,
5860 cb_mode, WNI_CFG_VHT_CHANNEL_WIDTH_80MHZ);
5861 limLog(mac_ctx, LOGW,
5862 FL("***Center Channel for 80MHZ channel width = %d"),
5863 center_chan);
5864 session_entry->apCenterChan = center_chan;
5865 if (cfgSetInt(mac_ctx, WNI_CFG_VHT_CHANNEL_CENTER_FREQ_SEGMENT1,
5866 center_chan) != eSIR_SUCCESS)
5867 limLog(mac_ctx, LOGE, FL("could not set center freq seg 0 in beacon"));
5868 if (cfgSetInt(mac_ctx, WNI_CFG_VHT_CHANNEL_WIDTH,
5869 WNI_CFG_VHT_CHANNEL_WIDTH_80MHZ) != eSIR_SUCCESS)
5870 limLog(mac_ctx, LOGE, FL("could not set channel width to 80 in CFG"));
5871 }
5872 }
5873
Abhishek Singh550aa8c2017-10-30 17:34:53 +05305874 /* Store the New Channel Params in session_entry */
Abhishek Singh02b823e2017-10-30 17:53:20 +05305875 session_entry->htSecondaryChannelOffset = limGetHTCBState(cb_mode);
5876 session_entry->htSupportedChannelWidthSet = (cb_mode ? 1 : 0);
Abhishek Singh550aa8c2017-10-30 17:34:53 +05305877 session_entry->htRecommendedTxWidthSet =
5878 session_entry->htSupportedChannelWidthSet;
5879 session_entry->currentOperChannel = ch_change_req->new_chan;
5880 session_entry->limRFBand = limGetRFBand(session_entry->currentOperChannel);
5881 /* Initialize 11h Enable Flag */
5882 if (SIR_BAND_5_GHZ == session_entry->limRFBand) {
5883 if (wlan_cfgGetInt(mac_ctx, WNI_CFG_11H_ENABLED, &val) != eSIR_SUCCESS)
5884 limLog(mac_ctx, LOGE, FL("Fail to get WNI_CFG_11H_ENABLED"));
5885 }
5886
5887 session_entry->lim11hEnable = val;
5888 session_entry->dot11mode = ch_change_req->dot11mode;
5889 vos_mem_copy(&session_entry->rateSet, &ch_change_req->operational_rateset,
5890 sizeof(session_entry->rateSet));
5891 vos_mem_copy(&session_entry->extRateSet, &ch_change_req->extended_rateset,
5892 sizeof(session_entry->extRateSet));
5893 limSetChannel(mac_ctx, ch_change_req->new_chan,
5894 session_entry->htSecondaryChannelOffset,
5895 max_tx_pwr, session_entry->peSessionId);
Abhishek Singh02605092017-10-25 14:06:12 +05305896}
Abhishek Singh7d624e12015-11-30 14:29:27 +05305897
5898/**
Jeff Johnson295189b2012-06-20 16:38:30 -07005899 * limProcessSmeReqMessages()
5900 *
5901 *FUNCTION:
5902 * This function is called by limProcessMessageQueue(). This
5903 * function processes SME request messages from HDD or upper layer
5904 * application.
5905 *
5906 *LOGIC:
5907 *
5908 *ASSUMPTIONS:
5909 *
5910 *NOTE:
5911 *
5912 * @param pMac Pointer to Global MAC structure
5913 * @param msgType Indicates the SME message type
5914 * @param *pMsgBuf A pointer to the SME message buffer
5915 * @return Boolean - TRUE - if pMsgBuf is consumed and can be freed.
5916 * FALSE - if pMsgBuf is not to be freed.
5917 */
5918
5919tANI_BOOLEAN
5920limProcessSmeReqMessages(tpAniSirGlobal pMac, tpSirMsgQ pMsg)
5921{
5922 tANI_BOOLEAN bufConsumed = TRUE; //Set this flag to false within case block of any following message, that doesnt want pMsgBuf to be freed.
5923 tANI_U32 *pMsgBuf = pMsg->bodyptr;
Sudhir Sattayappa Kohalliabf751c2013-06-30 15:37:18 -07005924 tpSirSmeScanReq pScanReq;
Ganesh Kondabattini16930072014-08-22 16:02:34 +05305925 tANI_BOOLEAN isPassiveScan = FALSE;
5926
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005927 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 -07005928 limMsgStr(pMsg->type), pMsg->type,
5929 limSmeStateStr(pMac->lim.gLimSmeState), pMac->lim.gLimSmeState,
5930 limMlmStateStr(pMac->lim.gLimMlmState), pMac->lim.gLimMlmState );)
5931
Sudhir Sattayappa Kohalliabf751c2013-06-30 15:37:18 -07005932 pScanReq = (tpSirSmeScanReq) pMsgBuf;
Viral Modid440e682013-03-06 02:25:31 -08005933 /* Special handling of some SME Req msgs where we have an existing GO session and
5934 * want to insert NOA before processing those msgs. These msgs will be processed later when
5935 * start event happens
5936 */
5937 switch (pMsg->type)
5938 {
5939 case eWNI_SME_SCAN_REQ:
Ganesh Kondabattini16930072014-08-22 16:02:34 +05305940 pScanReq = (tpSirSmeScanReq) pMsgBuf;
5941 isPassiveScan = (pScanReq->scanType == eSIR_PASSIVE_SCAN) ? TRUE : FALSE;
Viral Modid440e682013-03-06 02:25:31 -08005942 case eWNI_SME_REMAIN_ON_CHANNEL_REQ:
Sudhir Sattayappa Kohalliabf751c2013-06-30 15:37:18 -07005943
5944 /* If scan is disabled return from here
5945 */
5946 if (pMac->lim.fScanDisabled)
5947 {
Sudhir Sattayappa Kohalliabf751c2013-06-30 15:37:18 -07005948 if (pMsg->type == eWNI_SME_SCAN_REQ)
5949 {
5950 limSendSmeScanRsp(pMac,
5951 offsetof(tSirSmeScanRsp,bssDescription[0]),
5952 eSIR_SME_INVALID_PARAMETERS,
5953 pScanReq->sessionId,
5954 pScanReq->transactionId);
5955
5956 bufConsumed = TRUE;
5957 }
5958 else if (pMsg->type == eWNI_SME_REMAIN_ON_CHANNEL_REQ)
5959 {
5960 pMac->lim.gpDefdSmeMsgForNOA = NULL;
5961 pMac->lim.gpLimRemainOnChanReq = (tpSirRemainOnChnReq )pMsgBuf;
5962 limRemainOnChnRsp(pMac,eHAL_STATUS_FAILURE, NULL);
5963
5964 /*
5965 * limRemainOnChnRsp will free the buffer this change is to
5966 * avoid "double free"
5967 */
5968 bufConsumed = FALSE;
5969 }
5970
Rashmi Ramanna6c13a342014-01-07 11:44:07 +05305971 limLog(pMac, LOGE,
5972 FL("Error: Scan Disabled."
5973 " Return with error status for SME Message %s(%d)"),
5974 limMsgStr(pMsg->type), pMsg->type);
5975
Sudhir Sattayappa Kohalliabf751c2013-06-30 15:37:18 -07005976 return bufConsumed;
5977 }
5978 /*
5979 * Do not add BREAK here
5980 */
5981 case eWNI_SME_OEM_DATA_REQ:
Viral Modid440e682013-03-06 02:25:31 -08005982 case eWNI_SME_JOIN_REQ:
5983 /* If we have an existing P2P GO session we need to insert NOA before actually process this SME Req */
5984 if ((limIsNOAInsertReqd(pMac) == TRUE) && IS_FEATURE_SUPPORTED_BY_FW(P2P_GO_NOA_DECOUPLE_INIT_SCAN))
5985 {
5986 tANI_U32 noaDuration;
5987 __limRegisterDeferredSmeReqForNOAStart(pMac, pMsg->type, pMsgBuf);
Ganesh Kondabattini16930072014-08-22 16:02:34 +05305988 noaDuration = limCalculateNOADuration(pMac, pMsg->type, pMsgBuf, isPassiveScan);
Viral Modid440e682013-03-06 02:25:31 -08005989 bufConsumed = __limInsertSingleShotNOAForScan(pMac, noaDuration);
5990 return bufConsumed;
5991 }
5992 }
5993 /* If no insert NOA required then execute the code below */
5994
Jeff Johnson295189b2012-06-20 16:38:30 -07005995 switch (pMsg->type)
5996 {
5997 case eWNI_SME_START_REQ:
5998 __limProcessSmeStartReq(pMac, pMsgBuf);
5999 break;
6000
6001 case eWNI_SME_SYS_READY_IND:
6002 bufConsumed = __limProcessSmeSysReadyInd(pMac, pMsgBuf);
6003 break;
6004
Jeff Johnson295189b2012-06-20 16:38:30 -07006005 case eWNI_SME_START_BSS_REQ:
6006 bufConsumed = __limProcessSmeStartBssReq(pMac, pMsg);
6007 break;
6008
6009 case eWNI_SME_SCAN_REQ:
Viral Modid440e682013-03-06 02:25:31 -08006010 __limProcessSmeScanReq(pMac, pMsgBuf);
Jeff Johnson295189b2012-06-20 16:38:30 -07006011 break;
6012
Jeff Johnsone7245742012-09-05 17:12:55 -07006013#ifdef FEATURE_OEM_DATA_SUPPORT
6014 case eWNI_SME_OEM_DATA_REQ:
6015 __limProcessSmeOemDataReq(pMac, pMsgBuf);
Jeff Johnsone7245742012-09-05 17:12:55 -07006016 break;
6017#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006018 case eWNI_SME_REMAIN_ON_CHANNEL_REQ:
6019 bufConsumed = limProcessRemainOnChnlReq(pMac, pMsgBuf);
6020 break;
6021
6022 case eWNI_SME_UPDATE_NOA:
6023 __limProcessSmeNoAUpdate(pMac, pMsgBuf);
6024 break;
Gopichand Nakkalac178ac82013-05-30 19:53:39 +05306025 case eWNI_SME_CLEAR_DFS_CHANNEL_LIST:
6026 __limProcessClearDfsChannelList(pMac, pMsg);
6027 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006028 case eWNI_SME_JOIN_REQ:
6029 __limProcessSmeJoinReq(pMac, pMsgBuf);
Jeff Johnson295189b2012-06-20 16:38:30 -07006030 break;
6031
6032 case eWNI_SME_AUTH_REQ:
6033 // __limProcessSmeAuthReq(pMac, pMsgBuf);
6034
6035 break;
6036
6037 case eWNI_SME_REASSOC_REQ:
6038 __limProcessSmeReassocReq(pMac, pMsgBuf);
6039
6040 break;
6041
6042 case eWNI_SME_PROMISCUOUS_MODE_REQ:
6043 //__limProcessSmePromiscuousReq(pMac, pMsgBuf);
6044
6045 break;
6046
6047 case eWNI_SME_DISASSOC_REQ:
6048 __limProcessSmeDisassocReq(pMac, pMsgBuf);
6049
6050 break;
6051
6052 case eWNI_SME_DISASSOC_CNF:
6053 case eWNI_SME_DEAUTH_CNF:
6054 __limProcessSmeDisassocCnf(pMac, pMsgBuf);
6055
6056 break;
6057
6058 case eWNI_SME_DEAUTH_REQ:
6059 __limProcessSmeDeauthReq(pMac, pMsgBuf);
6060
6061 break;
6062
Jeff Johnson295189b2012-06-20 16:38:30 -07006063
6064
6065 case eWNI_SME_SETCONTEXT_REQ:
6066 __limProcessSmeSetContextReq(pMac, pMsgBuf);
6067
6068 break;
6069
6070 case eWNI_SME_REMOVEKEY_REQ:
6071 __limProcessSmeRemoveKeyReq(pMac, pMsgBuf);
6072
6073 break;
6074
6075 case eWNI_SME_STOP_BSS_REQ:
6076 bufConsumed = __limProcessSmeStopBssReq(pMac, pMsg);
6077 break;
6078
6079 case eWNI_SME_ASSOC_CNF:
6080 case eWNI_SME_REASSOC_CNF:
6081 if (pMsg->type == eWNI_SME_ASSOC_CNF)
Abhishek Singh3cbf6052014-12-15 16:46:42 +05306082 limLog(pMac, LOG1, FL("Received ASSOC_CNF message"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006083 else
Abhishek Singh3cbf6052014-12-15 16:46:42 +05306084 limLog(pMac, LOG1, FL("Received REASSOC_CNF message"));
Agrawal Ashisha8e8a722016-10-18 19:07:45 +05306085#ifdef SAP_AUTH_OFFLOAD
6086 if (pMac->sap_auth_offload)
6087 __lim_process_sme_assoc_offload_cnf(pMac, pMsg->type, pMsgBuf);
6088 else
6089 __limProcessSmeAssocCnfNew(pMac, pMsg->type, pMsgBuf);
6090#else
Jeff Johnson295189b2012-06-20 16:38:30 -07006091 __limProcessSmeAssocCnfNew(pMac, pMsg->type, pMsgBuf);
Agrawal Ashisha8e8a722016-10-18 19:07:45 +05306092#endif /* SAP_AUTH_OFFLOAD */
Jeff Johnson295189b2012-06-20 16:38:30 -07006093 break;
6094
6095 case eWNI_SME_ADDTS_REQ:
Abhishek Singh3cbf6052014-12-15 16:46:42 +05306096 limLog(pMac, LOG1, FL("Received ADDTS_REQ message"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006097 __limProcessSmeAddtsReq(pMac, pMsgBuf);
6098 break;
6099
6100 case eWNI_SME_DELTS_REQ:
Abhishek Singh3cbf6052014-12-15 16:46:42 +05306101 limLog(pMac, LOG1, FL("Received DELTS_REQ message"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006102 __limProcessSmeDeltsReq(pMac, pMsgBuf);
6103 break;
6104
6105 case SIR_LIM_ADDTS_RSP_TIMEOUT:
Abhishek Singh3cbf6052014-12-15 16:46:42 +05306106 limLog(pMac, LOG1, FL("Received SIR_LIM_ADDTS_RSP_TIMEOUT message "));
Jeff Johnson295189b2012-06-20 16:38:30 -07006107 limProcessSmeAddtsRspTimeout(pMac, pMsg->bodyval);
6108 break;
6109
6110 case eWNI_SME_STA_STAT_REQ:
6111 case eWNI_SME_AGGR_STAT_REQ:
6112 case eWNI_SME_GLOBAL_STAT_REQ:
6113 case eWNI_SME_STAT_SUMM_REQ:
6114 __limProcessSmeStatsRequest( pMac, pMsgBuf);
6115 //HAL consumes pMsgBuf. It will be freed there. Set bufConsumed to false.
6116 bufConsumed = FALSE;
6117 break;
6118 case eWNI_SME_GET_STATISTICS_REQ:
6119 __limProcessSmeGetStatisticsRequest( pMac, pMsgBuf);
6120 //HAL consumes pMsgBuf. It will be freed there. Set bufConsumed to false.
6121 bufConsumed = FALSE;
6122 break;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08006123#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08006124 case eWNI_SME_GET_ROAM_RSSI_REQ:
6125 __limProcessSmeGetRoamRssiRequest( pMac, pMsgBuf);
6126 //HAL consumes pMsgBuf. It will be freed there. Set bufConsumed to false.
6127 bufConsumed = FALSE;
6128 break;
6129#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08006130#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07006131 case eWNI_SME_GET_TSM_STATS_REQ:
6132 __limProcessSmeGetTsmStatsRequest( pMac, pMsgBuf);
6133 bufConsumed = FALSE;
6134 break;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08006135#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Jeff Johnson295189b2012-06-20 16:38:30 -07006136 case eWNI_SME_DEL_BA_PEER_IND:
6137 limProcessSmeDelBaPeerInd(pMac, pMsgBuf);
6138 break;
6139 case eWNI_SME_GET_SCANNED_CHANNEL_REQ:
6140 limProcessSmeGetScanChannelInfo(pMac, pMsgBuf);
6141 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006142 case eWNI_SME_GET_ASSOC_STAS_REQ:
6143 limProcessSmeGetAssocSTAsInfo(pMac, pMsgBuf);
6144 break;
6145 case eWNI_SME_TKIP_CNTR_MEAS_REQ:
6146 limProcessTkipCounterMeasures(pMac, pMsgBuf);
6147 break;
6148
6149 case eWNI_SME_HIDE_SSID_REQ:
6150 __limProcessSmeHideSSID(pMac, pMsgBuf);
6151 break;
6152 case eWNI_SME_UPDATE_APWPSIE_REQ:
6153 __limProcessSmeUpdateAPWPSIEs(pMac, pMsgBuf);
6154 break;
6155 case eWNI_SME_GET_WPSPBC_SESSION_REQ:
6156 limProcessSmeGetWPSPBCSessions(pMac, pMsgBuf);
6157 break;
6158
6159 case eWNI_SME_SET_APWPARSNIEs_REQ:
6160 __limProcessSmeSetWPARSNIEs(pMac, pMsgBuf);
6161 break;
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08006162
6163 case eWNI_SME_CHNG_MCC_BEACON_INTERVAL:
6164 //Update the beaconInterval
6165 __limProcessSmeChangeBI(pMac, pMsgBuf );
6166 break;
Hardik Kantilal Patel62a3a762014-11-21 12:55:57 +05306167
6168#ifdef WLAN_FEATURE_AP_HT40_24G
6169 case eWNI_SME_SET_HT_2040_MODE:
6170 __limProcessSmeSetHT2040Mode(pMac, pMsgBuf);
6171 break;
6172#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006173
6174#if defined WLAN_FEATURE_VOWIFI
6175 case eWNI_SME_NEIGHBOR_REPORT_REQ_IND:
6176 case eWNI_SME_BEACON_REPORT_RESP_XMIT_IND:
6177 __limProcessReportMessage(pMac, pMsg);
6178 break;
6179#endif
6180
6181#if defined WLAN_FEATURE_VOWIFI_11R
6182 case eWNI_SME_FT_PRE_AUTH_REQ:
6183 bufConsumed = (tANI_BOOLEAN)limProcessFTPreAuthReq(pMac, pMsg);
6184 break;
6185 case eWNI_SME_FT_UPDATE_KEY:
6186 limProcessFTUpdateKey(pMac, pMsgBuf);
6187 break;
6188
6189 case eWNI_SME_FT_AGGR_QOS_REQ:
6190 limProcessFTAggrQosReq(pMac, pMsgBuf);
6191 break;
6192#endif
6193
Padma, Santhosh Kumar67f479b2016-12-28 15:43:42 +05306194#ifdef WLAN_FEATURE_LFR_MBB
6195 case eWNI_SME_MBB_PRE_AUTH_REASSOC_REQ:
6196 lim_process_pre_auth_reassoc_req(pMac, pMsg);
6197 bufConsumed = FALSE;
6198 break;
6199#endif
6200
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08006201#if defined(FEATURE_WLAN_ESE) && !defined(FEATURE_WLAN_ESE_UPLOAD)
6202 case eWNI_SME_ESE_ADJACENT_AP_REPORT:
Jeff Johnson295189b2012-06-20 16:38:30 -07006203 limProcessAdjacentAPRepMsg ( pMac, pMsgBuf );
6204 break;
6205#endif
6206 case eWNI_SME_ADD_STA_SELF_REQ:
6207 __limProcessSmeAddStaSelfReq( pMac, pMsgBuf );
6208 break;
6209 case eWNI_SME_DEL_STA_SELF_REQ:
6210 __limProcessSmeDelStaSelfReq( pMac, pMsgBuf );
6211 break;
6212
Jeff Johnson295189b2012-06-20 16:38:30 -07006213 case eWNI_SME_REGISTER_MGMT_FRAME_REQ:
6214 __limProcessSmeRegisterMgmtFrameReq( pMac, pMsgBuf );
6215 break;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08006216#ifdef FEATURE_WLAN_TDLS
6217 case eWNI_SME_TDLS_SEND_MGMT_REQ:
6218 limProcessSmeTdlsMgmtSendReq(pMac, pMsgBuf);
6219 break;
6220 case eWNI_SME_TDLS_ADD_STA_REQ:
6221 limProcessSmeTdlsAddStaReq(pMac, pMsgBuf);
6222 break;
6223 case eWNI_SME_TDLS_DEL_STA_REQ:
6224 limProcessSmeTdlsDelStaReq(pMac, pMsgBuf);
6225 break;
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05306226 case eWNI_SME_TDLS_LINK_ESTABLISH_REQ:
6227 limProcesSmeTdlsLinkEstablishReq(pMac, pMsgBuf);
6228 break;
Atul Mittalc0f739f2014-07-31 13:47:47 +05306229// tdlsoffchan
6230 case eWNI_SME_TDLS_CHANNEL_SWITCH_REQ:
6231 limProcesSmeTdlsChanSwitchReq(pMac, pMsgBuf);
6232 break;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08006233#endif
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05306234 case eWNI_SME_RESET_AP_CAPS_CHANGED:
6235 __limProcessSmeResetApCapsChange(pMac, pMsgBuf);
6236 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006237
schang86c22c42013-03-13 18:41:24 -07006238 case eWNI_SME_SET_TX_POWER_REQ:
6239 limSendSetTxPowerReq(pMac, pMsgBuf);
6240 break ;
6241
Abhishek Singh00b71972016-01-07 10:51:04 +05306242#ifdef WLAN_FEATURE_RMC
6243 case eWNI_SME_ENABLE_RMC_REQ:
6244 limProcessRMCMessages(pMac, eLIM_RMC_ENABLE_REQ, pMsgBuf);
6245 break ;
6246
6247 case eWNI_SME_DISABLE_RMC_REQ:
6248 limProcessRMCMessages(pMac, eLIM_RMC_DISABLE_REQ, pMsgBuf);
6249 break ;
6250#endif /* WLAN_FEATURE_RMC */
6251
Siddharth Bhal6af5d4e2014-09-29 21:11:16 +05306252 case eWNI_SME_MAC_SPOOF_ADDR_IND:
6253 __limProcessSmeSpoofMacAddrRequest(pMac, pMsgBuf);
6254 break ;
Abhishek Singh7d624e12015-11-30 14:29:27 +05306255 case eWNI_SME_REGISTER_MGMT_FRAME_CB:
6256 lim_register_mgmt_frame_ind_cb(pMac, pMsgBuf);
6257 break;
Abhishek Singh02605092017-10-25 14:06:12 +05306258 case eWNI_SME_SET_CHAN_SW_IE_REQ:
6259 lim_process_sme_set_csa_ie_request(pMac, pMsgBuf);
Abhishek Singh550aa8c2017-10-30 17:34:53 +05306260 break;
6261 case eWNI_SME_ECSA_CHAN_CHANGE_REQ:
6262 lim_process_sme_channel_change_request(pMac, pMsgBuf);
6263 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006264 default:
6265 vos_mem_free((v_VOID_t*)pMsg->bodyptr);
6266 pMsg->bodyptr = NULL;
6267 break;
6268 } // switch (msgType)
6269
6270 return bufConsumed;
6271} /*** end limProcessSmeReqMessages() ***/