blob: 371e27f4ccf67833197221fd36015015a1adf4b9 [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Rajeev Kumar Sirasanagandla2bb30b82019-01-07 22:30:16 +05302 * Copyright (c) 2012-2019 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;
Rajeev Kumar Sirasanagandla2bb30b82019-01-07 22:30:16 +05301544 pMlmScanReq->scan_randomize = pScanReq->scan_randomize;
1545 pMlmScanReq->nl_scan = pScanReq->nl_scan;
Jeff Johnson295189b2012-06-20 16:38:30 -07001546
Ganesh Kondabattinif0fa07c2013-06-11 17:47:49 +05301547 //Store the smeSessionID and transaction ID for later use.
1548 pMac->lim.gSmeSessionId = pScanReq->sessionId;
1549 pMac->lim.gTransactionId = pScanReq->transactionId;
Jeff Johnson295189b2012-06-20 16:38:30 -07001550
Ganesh Kondabattinif0fa07c2013-06-11 17:47:49 +05301551 // Issue LIM_MLM_SCAN_REQ to MLM
Rashmi Ramanna6c13a342014-01-07 11:44:07 +05301552 limLog(pMac, LOG1, FL("Issue Scan request command to MLM "));
Ganesh Kondabattinif0fa07c2013-06-11 17:47:49 +05301553 limPostMlmMessage(pMac, LIM_MLM_SCAN_REQ, (tANI_U32 *) pMlmScanReq);
1554 }
1555 } // if ((pMac->lim.gLimSmeState == eLIM_SME_IDLE_STATE) || ...
Jeff Johnson295189b2012-06-20 16:38:30 -07001556
1557 else
1558 {
1559 /// In all other cases return 'cached' scan results
1560 if ((pMac->lim.gLimRspReqd) || pMac->lim.gLimReportBackgroundScanResults)
1561 {
1562 tANI_U16 scanRspLen = sizeof(tSirSmeScanRsp);
1563
1564 pMac->lim.gLimRspReqd = false;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07001565#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
1566 if (pScanReq->returnFreshResults & SIR_BG_SCAN_RETURN_LFR_CACHED_RESULTS)
Jeff Johnson295189b2012-06-20 16:38:30 -07001567 {
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07001568 pMac->lim.gLimSmeLfrScanResultLength = pMac->lim.gLimMlmLfrScanResultLength;
1569 if (pMac->lim.gLimSmeLfrScanResultLength == 0)
1570 {
1571 limSendSmeLfrScanRsp(pMac, scanRspLen,
1572 eSIR_SME_SUCCESS,
1573 pScanReq->sessionId,
1574 pScanReq->transactionId);
1575 }
1576 else
1577 {
1578 scanRspLen = sizeof(tSirSmeScanRsp) +
1579 pMac->lim.gLimSmeLfrScanResultLength -
1580 sizeof(tSirBssDescription);
1581 limSendSmeLfrScanRsp(pMac, scanRspLen, eSIR_SME_SUCCESS,
1582 pScanReq->sessionId, pScanReq->transactionId);
1583 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001584 }
1585 else
1586 {
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07001587#endif
1588 if (pMac->lim.gLimSmeScanResultLength == 0)
1589 {
1590 limSendSmeScanRsp(pMac, scanRspLen, eSIR_SME_SUCCESS,
1591 pScanReq->sessionId, pScanReq->transactionId);
1592 }
1593 else
1594 {
1595 scanRspLen = sizeof(tSirSmeScanRsp) +
1596 pMac->lim.gLimSmeScanResultLength -
1597 sizeof(tSirBssDescription);
1598 limSendSmeScanRsp(pMac, scanRspLen, eSIR_SME_SUCCESS,
1599 pScanReq->sessionId, pScanReq->transactionId);
1600 }
1601#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
Jeff Johnson295189b2012-06-20 16:38:30 -07001602 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07001603#endif
Rashmi Ramanna6c13a342014-01-07 11:44:07 +05301604 limLog(pMac, LOG1, FL("Cached scan results are returned "));
Jeff Johnson295189b2012-06-20 16:38:30 -07001605
1606 if (pScanReq->returnFreshResults & SIR_BG_SCAN_PURGE_RESUTLS)
1607 {
1608 // Discard previously cached scan results
1609 limReInitScanResults(pMac);
1610 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07001611#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
1612 if (pScanReq->returnFreshResults & SIR_BG_SCAN_PURGE_LFR_RESULTS)
1613 {
1614 // Discard previously cached scan results
1615 limReInitLfrScanResults(pMac);
1616 }
1617#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001618
1619 } // if (pMac->lim.gLimRspReqd)
1620 } // else ((pMac->lim.gLimSmeState == eLIM_SME_IDLE_STATE) || ...
1621
Jeff Johnson295189b2012-06-20 16:38:30 -07001622#ifdef BACKGROUND_SCAN_ENABLED
1623 // start background scans if needed
1624 // There is a bug opened against softmac. Need to enable when the bug is fixed.
1625 __limBackgroundScanInitiate(pMac);
1626#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001627
1628} /*** end __limProcessSmeScanReq() ***/
1629
Jeff Johnsone7245742012-09-05 17:12:55 -07001630#ifdef FEATURE_OEM_DATA_SUPPORT
Jeff Johnson295189b2012-06-20 16:38:30 -07001631
Jeff Johnsone7245742012-09-05 17:12:55 -07001632static void __limProcessSmeOemDataReq(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
1633{
1634 tpSirOemDataReq pOemDataReq;
1635 tLimMlmOemDataReq* pMlmOemDataReq;
1636
1637 pOemDataReq = (tpSirOemDataReq) pMsgBuf;
1638
1639 //post the lim mlm message now
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301640 pMlmOemDataReq = vos_mem_malloc(sizeof(tLimMlmOemDataReq));
1641 if ( NULL == pMlmOemDataReq )
Jeff Johnsone7245742012-09-05 17:12:55 -07001642 {
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301643 limLog(pMac, LOGP, FL("AllocateMemory failed for mlmOemDataReq"));
Jeff Johnsone7245742012-09-05 17:12:55 -07001644 return;
1645 }
1646
1647 //Initialize this buffer
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301648 vos_mem_set( pMlmOemDataReq, (sizeof(tLimMlmOemDataReq)), 0);
Jeff Johnsone7245742012-09-05 17:12:55 -07001649
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301650 vos_mem_copy( pMlmOemDataReq->selfMacAddr, pOemDataReq->selfMacAddr,
1651 sizeof(tSirMacAddr));
1652 vos_mem_copy( pMlmOemDataReq->oemDataReq, pOemDataReq->oemDataReq,
1653 OEM_DATA_REQ_SIZE);
Jeff Johnsone7245742012-09-05 17:12:55 -07001654
1655 //Issue LIM_MLM_OEM_DATA_REQ to MLM
1656 limPostMlmMessage(pMac, LIM_MLM_OEM_DATA_REQ, (tANI_U32*)pMlmOemDataReq);
1657
1658 return;
1659
1660} /*** end __limProcessSmeOemDataReq() ***/
1661
1662#endif //FEATURE_OEM_DATA_SUPPORT
Jeff Johnson295189b2012-06-20 16:38:30 -07001663
Gopichand Nakkalac178ac82013-05-30 19:53:39 +05301664/**
1665 * __limProcessClearDfsChannelList()
1666 *
1667 *FUNCTION:
1668 *Clear DFS channel list when country is changed/aquired.
1669.*This message is sent from SME.
1670 *
1671 *LOGIC:
1672 *
1673 *ASSUMPTIONS:
1674 *
1675 *NOTE:
1676 *
1677 * @param pMac Pointer to Global MAC structure
1678 * @param *pMsgBuf A pointer to the SME message buffer
1679 * @return None
1680 */
1681static void __limProcessClearDfsChannelList(tpAniSirGlobal pMac,
1682 tpSirMsgQ pMsg)
1683{
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301684 vos_mem_set( &pMac->lim.dfschannelList,
1685 sizeof(tSirDFSChannelList), 0);
Gopichand Nakkalac178ac82013-05-30 19:53:39 +05301686}
Jeff Johnson295189b2012-06-20 16:38:30 -07001687
Abhinav Kumar6920f5a2019-08-05 18:55:11 +05301688#ifdef WLAN_FEATURE_SAE
1689/**
1690 * lim_update_sae_config()- This API update SAE session info to csr config
1691 * from join request.
1692 * @session: PE session
1693 * @sme_join_req: pointer to join request
1694 *
1695 * Return: None
1696 */
1697static void lim_update_sae_config(tpPESession session,
1698 tpSirSmeJoinReq sme_join_req)
1699{
1700 session->sae_pmk_cached = sme_join_req->sae_pmk_cached;
1701
1702 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_DEBUG,
1703 FL("pmk_cached %d for BSSID=" MAC_ADDRESS_STR),
1704 session->sae_pmk_cached,
1705 MAC_ADDR_ARRAY(sme_join_req->bssDescription.bssId));
1706}
1707#else
1708static inline void lim_update_sae_config(tpPESession session,
1709 tpSirSmeJoinReq sme_join_req)
1710{}
1711#endif
1712
Jeff Johnson295189b2012-06-20 16:38:30 -07001713/**
1714 * __limProcessSmeJoinReq()
1715 *
1716 *FUNCTION:
1717 * This function is called to process SME_JOIN_REQ message
1718 * from HDD or upper layer application.
1719 *
1720 *LOGIC:
1721 *
1722 *ASSUMPTIONS:
1723 *
1724 *NOTE:
1725 *
1726 * @param pMac Pointer to Global MAC structure
1727 * @param *pMsgBuf A pointer to the SME message buffer
1728 * @return None
1729 */
Jeff Johnson295189b2012-06-20 16:38:30 -07001730static void
1731__limProcessSmeJoinReq(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
1732{
1733 // tANI_U8 *pBuf;
1734 //tANI_U32 len;
1735// tSirMacAddr currentBssId;
1736 tpSirSmeJoinReq pSmeJoinReq = NULL;
1737 tLimMlmJoinReq *pMlmJoinReq;
1738 tSirResultCodes retCode = eSIR_SME_SUCCESS;
1739 tANI_U32 val = 0;
1740 tANI_U16 nSize;
1741 tANI_U8 sessionId;
1742 tpPESession psessionEntry = NULL;
Nitesh Shah54046ee2016-07-19 15:23:51 +05301743 tANI_U8 smesessionId = 0;
1744 tANI_U16 smetransactionId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001745 tPowerdBm localPowerConstraint = 0, regMax = 0;
Agarwal Ashish87039eb2014-01-15 14:13:15 +05301746 tANI_U16 ieLen;
1747 v_U8_t *vendorIE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001748
1749#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM //FEATURE_WLAN_DIAG_SUPPORT
1750 //Not sending any session, since it is not created yet. The response whould have correct state.
1751 limDiagEventReport(pMac, WLAN_PE_DIAG_JOIN_REQ_EVENT, NULL, 0, 0);
1752#endif //FEATURE_WLAN_DIAG_SUPPORT
1753
Abhishek Singh3cbf6052014-12-15 16:46:42 +05301754 limLog(pMac, LOG1, FL("Received SME_JOIN_REQ"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001755
1756#ifdef WLAN_FEATURE_VOWIFI
1757 /* Need to read the CFG here itself as this is used in limExtractAPCapability() below.
1758 * This CFG is actually read in rrmUpdateConfig() which is called later. Because this is not
1759 * read, RRM related path before calling rrmUpdateConfig() is not getting executed causing issues
1760 * like not honoring power constraint on 1st association after driver loading. */
1761 if (wlan_cfgGetInt(pMac, WNI_CFG_RRM_ENABLED, &val) != eSIR_SUCCESS)
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001762 limLog(pMac, LOGP, FL("cfg get rrm enabled failed"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001763 pMac->rrm.rrmPEContext.rrmEnable = (val) ? 1 : 0;
1764 val = 0;
1765#endif /* WLAN_FEATURE_VOWIFI */
1766
1767 /**
1768 * Expect Join request in idle state.
1769 * Reassociate request is expected in link established state.
1770 */
1771
1772 /* Global SME and LIM states are not defined yet for BT-AMP Support */
1773 if(pMac->lim.gLimSmeState == eLIM_SME_IDLE_STATE)
1774 {
1775 nSize = __limGetSmeJoinReqSizeForAlloc((tANI_U8*) pMsgBuf);
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301776
1777 pSmeJoinReq = vos_mem_malloc(nSize);
1778 if ( NULL == pSmeJoinReq )
Jeff Johnson295189b2012-06-20 16:38:30 -07001779 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05301780 limLog(pMac, LOGP, FL("call to AllocateMemory failed for "
1781 "pSmeJoinReq"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001782 retCode = eSIR_SME_RESOURCES_UNAVAILABLE;
1783 goto end;
1784 }
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301785 (void) vos_mem_set((void *) pSmeJoinReq, nSize, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07001786
Jeff Johnson295189b2012-06-20 16:38:30 -07001787 if ((limJoinReqSerDes(pMac, pSmeJoinReq, (tANI_U8 *)pMsgBuf) == eSIR_FAILURE) ||
1788 (!limIsSmeJoinReqValid(pMac, pSmeJoinReq)))
1789 {
1790 /// Received invalid eWNI_SME_JOIN_REQ
1791 // Log the event
Padma, Santhosh Kumar2b47ca82014-01-03 16:57:27 +05301792 limLog(pMac, LOGW, FL("SessionId:%d Received SME_JOIN_REQ with"
1793 "invalid data"),pSmeJoinReq->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07001794 retCode = eSIR_SME_INVALID_PARAMETERS;
1795 goto end;
1796 }
1797
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05301798 //pMac->lim.gpLimJoinReq = pSmeJoinReq; TO SUPPORT BT-AMP, review os sep 23
Jeff Johnson295189b2012-06-20 16:38:30 -07001799
1800 /* check for the existence of start BSS session */
1801#ifdef FIXME_GEN6
1802 if(pSmeJoinReq->bsstype == eSIR_BTAMP_AP_MODE)
1803 {
1804 if(peValidateBtJoinRequest(pMac)!= TRUE)
1805 {
Padma, Santhosh Kumar2b47ca82014-01-03 16:57:27 +05301806 limLog(pMac, LOGW, FL("SessionId:%d Start Bss session"
1807 "not present::SME_JOIN_REQ in unexpected state"),
1808 pSmeJoinReq->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07001809 retCode = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
1810 psessionEntry = NULL;
1811 goto end;
1812 }
1813 }
1814
1815#endif
1816
1817
1818 if((psessionEntry = peFindSessionByBssid(pMac,pSmeJoinReq->bssDescription.bssId,&sessionId)) != NULL)
1819 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05301820 limLog(pMac, LOGE, FL("Session(%d) Already exists for BSSID: "
Sushant Kaushik1b645382014-10-13 16:39:36 +05301821 MAC_ADDRESS_STR" in limSmeState = %d"),sessionId,
Abhishek Singh57aebef2014-02-03 18:47:44 +05301822 MAC_ADDR_ARRAY(pSmeJoinReq->bssDescription.bssId),
1823 psessionEntry->limSmeState);
Jeff Johnson295189b2012-06-20 16:38:30 -07001824
1825 if(psessionEntry->limSmeState == eLIM_SME_LINK_EST_STATE)
1826 {
1827 // Received eWNI_SME_JOIN_REQ for same
1828 // BSS as currently associated.
1829 // Log the event and send success
Padma, Santhosh Kumar2b47ca82014-01-03 16:57:27 +05301830 PELOGW(limLog(pMac, LOGW, FL("SessionId:%d Received"
1831 "SME_JOIN_REQ for currently joined BSS"),sessionId);)
Jeff Johnson295189b2012-06-20 16:38:30 -07001832 /// Send Join success response to host
Deepthi Gowrif3e27252013-12-11 20:50:01 +05301833 retCode = eSIR_SME_ALREADY_JOINED_A_BSS;
1834 psessionEntry = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07001835 goto end;
1836 }
1837 else
1838 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05301839 PELOGE(limLog(pMac, LOGE, FL("SME_JOIN_REQ not for"
1840 "currently joined BSS"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001841 retCode = eSIR_SME_REFUSED;
1842 psessionEntry = NULL;
1843 goto end;
1844 }
1845 }
1846 else /* Session Entry does not exist for given BSSId */
1847 {
1848 /* Try to Create a new session */
1849 if((psessionEntry = peCreateSession(pMac,pSmeJoinReq->bssDescription.bssId,&sessionId, pMac->lim.maxStation)) == NULL)
1850 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001851 limLog(pMac, LOGE, FL("Session Can not be created "));
Jeff Johnson295189b2012-06-20 16:38:30 -07001852 retCode = eSIR_SME_RESOURCES_UNAVAILABLE;
1853 goto end;
1854 }
Padma, Santhosh Kumar2b47ca82014-01-03 16:57:27 +05301855 else
1856 limLog(pMac,LOG1,FL("SessionId:%d New session created"),
1857 sessionId);
Masti, Narayanraddi67ea5912015-01-08 12:34:05 +05301858 }
1859
1860 if(psessionEntry != NULL && pSmeJoinReq->operationalRateSet.numRates > 0 ){
1861 if(!limCheck11BRateBitmap(pSmeJoinReq->rateBitMap)){
1862 psessionEntry->is11Gonly = true;
1863 }
1864 }
1865
krunal soni5afa96c2013-09-06 22:19:02 -07001866 psessionEntry->isAmsduSupportInAMPDU = pSmeJoinReq->isAmsduSupportInAMPDU;
Jeff Johnsone7245742012-09-05 17:12:55 -07001867
Jeff Johnson295189b2012-06-20 16:38:30 -07001868 /* Store Session related parameters */
1869 /* Store PE session Id in session Table */
1870 psessionEntry->peSessionId = sessionId;
1871
1872 /* store the smejoin req handle in session table */
1873 psessionEntry->pLimJoinReq = pSmeJoinReq;
1874
1875 /* Store SME session Id in sessionTable */
1876 psessionEntry->smeSessionId = pSmeJoinReq->sessionId;
1877
1878 /* Store SME transaction Id in session Table */
1879 psessionEntry->transactionId = pSmeJoinReq->transactionId;
1880
1881 /* Store beaconInterval */
1882 psessionEntry->beaconParams.beaconInterval = pSmeJoinReq->bssDescription.beaconInterval;
1883
1884 /* Copying of bssId is already done, while creating session */
1885 //sirCopyMacAddr(psessionEntry->bssId,pSmeJoinReq->bssId);
1886 sirCopyMacAddr(psessionEntry->selfMacAddr,pSmeJoinReq->selfMacAddr);
1887 psessionEntry->bssType = pSmeJoinReq->bsstype;
1888
1889 psessionEntry->statypeForBss = STA_ENTRY_PEER;
Sandeep Puligillaaea98a22013-12-04 13:36:32 +05301890 psessionEntry->limWmeEnabled = pSmeJoinReq->isWMEenabled;
1891 psessionEntry->limQosEnabled = pSmeJoinReq->isQosEnabled;
Sushant Kaushik74df8db2015-03-11 18:09:05 +05301892 psessionEntry->bOSENAssociation = pSmeJoinReq->bOSENAssociation;
Abhishek Singheef5c992016-01-27 13:41:54 +05301893 psessionEntry->bWPSAssociation = pSmeJoinReq->bWPSAssociation;
Jeff Johnson295189b2012-06-20 16:38:30 -07001894
Agarwal Ashish87039eb2014-01-15 14:13:15 +05301895 /* Store vendor specfic IE for CISCO AP */
Abhishek Singhbad2b322016-10-21 11:22:33 +05301896 ieLen = GET_IE_LEN_IN_BSS(pSmeJoinReq->bssDescription.length);
Agarwal Ashish87039eb2014-01-15 14:13:15 +05301897
1898 vendorIE = limGetVendorIEOuiPtr(pMac, SIR_MAC_CISCO_OUI,
1899 SIR_MAC_CISCO_OUI_SIZE,
1900 ((tANI_U8 *)&pSmeJoinReq->bssDescription.ieFields) , ieLen);
1901
1902 if ( NULL != vendorIE )
1903 {
1904 limLog(pMac, LOGE,
1905 FL("DUT is trying to connect to Cisco AP"));
1906 psessionEntry->isCiscoVendorAP = TRUE;
1907 }
1908 else
1909 {
1910 psessionEntry->isCiscoVendorAP = FALSE;
1911 }
1912
Jeff Johnson295189b2012-06-20 16:38:30 -07001913 /* Copy the dot 11 mode in to the session table */
1914
1915 psessionEntry->dot11mode = pSmeJoinReq->dot11mode;
1916 psessionEntry->nwType = pSmeJoinReq->bssDescription.nwType;
Jeff Johnsone7245742012-09-05 17:12:55 -07001917#ifdef WLAN_FEATURE_11AC
1918 psessionEntry->vhtCapability = IS_DOT11_MODE_VHT(psessionEntry->dot11mode);
Jeff Johnson32d95a32012-09-10 13:15:23 -07001919 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO_MED,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001920 "***__limProcessSmeJoinReq: vhtCapability=%d****",psessionEntry->vhtCapability);
Shailender Karmuchi08f87c22013-01-17 12:51:24 -08001921 if (psessionEntry->vhtCapability )
1922 {
1923 psessionEntry->txBFIniFeatureEnabled = pSmeJoinReq->txBFIniFeatureEnabled;
1924
1925 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO_MED,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07001926 "***__limProcessSmeJoinReq: txBFIniFeatureEnabled=%d****",
Shailender Karmuchi08f87c22013-01-17 12:51:24 -08001927 psessionEntry->txBFIniFeatureEnabled);
1928
Selvaraj, Sridhar716d30f2016-07-28 18:54:03 +05301929 if (cfgSetInt(pMac, WNI_CFG_VHT_SU_BEAMFORMEE_CAP,
1930 psessionEntry->txBFIniFeatureEnabled) != eSIR_SUCCESS)
1931 {
1932 limLog(pMac, LOGP, FL("could not set "
1933 "WNI_CFG_VHT_SU_BEAMFORMEE_CAP at CFG"));
1934 retCode = eSIR_LOGP_EXCEPTION;
1935 goto end;
1936 }
Shailender Karmuchi08f87c22013-01-17 12:51:24 -08001937 if( psessionEntry->txBFIniFeatureEnabled )
1938 {
Shailender Karmuchicc3fe442013-02-16 18:18:33 -08001939 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO_MED,
Abhishek Singh57aebef2014-02-03 18:47:44 +05301940 "***__limProcessSmeJoinReq: txBFCsnValue=%d****",
1941 pSmeJoinReq->txBFCsnValue);
Shailender Karmuchicc3fe442013-02-16 18:18:33 -08001942
1943 if (cfgSetInt(pMac, WNI_CFG_VHT_CSN_BEAMFORMEE_ANT_SUPPORTED, pSmeJoinReq->txBFCsnValue)
Shailender Karmuchi08f87c22013-01-17 12:51:24 -08001944 != eSIR_SUCCESS)
1945 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05301946 limLog(pMac, LOGP, FL("could not set "
1947 "WNI_CFG_VHT_CSN_BEAMFORMEE_ANT_SUPPORTED at CFG"));
Shailender Karmuchi08f87c22013-01-17 12:51:24 -08001948 retCode = eSIR_LOGP_EXCEPTION;
1949 goto end;
1950 }
Abhishek Singh6d5d29c2014-07-03 14:25:22 +05301951
1952 if ( FALSE == pMac->isMuBfsessionexist )
1953 psessionEntry->txMuBformee = pSmeJoinReq->txMuBformee;
Shailender Karmuchi08f87c22013-01-17 12:51:24 -08001954 }
Abhishek Singh6d5d29c2014-07-03 14:25:22 +05301955
1956 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
1957 "SmeJoinReq:txMuBformee=%d psessionEntry: txMuBformee = %d",
1958 pSmeJoinReq->txMuBformee, psessionEntry->txMuBformee);
1959
1960 if(cfgSetInt(pMac, WNI_CFG_VHT_MU_BEAMFORMEE_CAP, psessionEntry->txMuBformee)
1961 != eSIR_SUCCESS)
1962 {
1963 limLog(pMac, LOGE, FL("could not set "
1964 "WNI_CFG_VHT_MU_BEAMFORMEE_CAP at CFG"));
1965 retCode = eSIR_LOGP_EXCEPTION;
1966 goto end;
1967 }
1968
Shailender Karmuchi08f87c22013-01-17 12:51:24 -08001969 }
1970
Jeff Johnsone7245742012-09-05 17:12:55 -07001971#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001972
1973 /*Phy mode*/
1974 psessionEntry->gLimPhyMode = pSmeJoinReq->bssDescription.nwType;
1975
Abhishek Singhca6ec5d2015-06-24 13:13:27 +05301976 handleHTCapabilityandHTInfo(pMac, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07001977 /* Copy The channel Id to the session Table */
1978 psessionEntry->currentOperChannel = pSmeJoinReq->bssDescription.channelId;
Abhishek Singhe3beee22017-07-31 15:35:40 +05301979 psessionEntry->force_24ghz_in_ht20 = pSmeJoinReq->force_24ghz_in_ht20;
Jeff Johnsone7245742012-09-05 17:12:55 -07001980 psessionEntry->htSupportedChannelWidthSet = (pSmeJoinReq->cbMode)?1:0; // This is already merged value of peer and self - done by csr in csrGetCBModeFromIes
1981 psessionEntry->htRecommendedTxWidthSet = psessionEntry->htSupportedChannelWidthSet;
1982 psessionEntry->htSecondaryChannelOffset = pSmeJoinReq->cbMode;
Jeff Johnson295189b2012-06-20 16:38:30 -07001983
Chet Lanctot186b5732013-03-18 10:26:30 -07001984 /* Record if management frames need to be protected */
1985#ifdef WLAN_FEATURE_11W
1986 if(eSIR_ED_AES_128_CMAC == pSmeJoinReq->MgmtEncryptionType)
1987 {
1988 psessionEntry->limRmfEnabled = 1;
1989 }
1990 else
1991 {
1992 psessionEntry->limRmfEnabled = 0;
1993 }
1994#endif
1995
krunal soni8d13b092013-07-19 13:23:29 -07001996#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM
1997 psessionEntry->rssi = pSmeJoinReq->bssDescription.rssi;
1998#endif
1999
Jeff Johnson295189b2012-06-20 16:38:30 -07002000 /*Store Persona */
2001 psessionEntry->pePersona = pSmeJoinReq->staPersona;
2002 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
Abhishek Singhe3beee22017-07-31 15:35:40 +05302003 FL("PE PERSONA=%d cbMode %u force_24ghz_in_ht20 %d"),
2004 psessionEntry->pePersona,
2005 pSmeJoinReq->cbMode,
2006 psessionEntry->force_24ghz_in_ht20);
Jeff Johnson295189b2012-06-20 16:38:30 -07002007
2008 /* Copy the SSID from smejoinreq to session entry */
2009 psessionEntry->ssId.length = pSmeJoinReq->ssId.length;
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302010 vos_mem_copy( psessionEntry->ssId.ssId,
2011 pSmeJoinReq->ssId.ssId, psessionEntry->ssId.length);
2012
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002013 // Determin 11r or ESE connection based on input from SME
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302014 // which inturn is dependent on the profile the user wants to connect
2015 // to, So input is coming from supplicant
Jeff Johnson295189b2012-06-20 16:38:30 -07002016#ifdef WLAN_FEATURE_VOWIFI_11R
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302017 psessionEntry->is11Rconnection = pSmeJoinReq->is11Rconnection;
Jeff Johnson295189b2012-06-20 16:38:30 -07002018#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002019#ifdef FEATURE_WLAN_ESE
2020 psessionEntry->isESEconnection = pSmeJoinReq->isESEconnection;
Jeff Johnson295189b2012-06-20 16:38:30 -07002021#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002022#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302023 psessionEntry->isFastTransitionEnabled = pSmeJoinReq->isFastTransitionEnabled;
Jeff Johnson295189b2012-06-20 16:38:30 -07002024#endif
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302025
Jeff Johnson43971f52012-07-17 12:26:56 -07002026#ifdef FEATURE_WLAN_LFR
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302027 psessionEntry->isFastRoamIniFeatureEnabled = pSmeJoinReq->isFastRoamIniFeatureEnabled;
Jeff Johnson43971f52012-07-17 12:26:56 -07002028#endif
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302029 psessionEntry->txLdpcIniFeatureEnabled = pSmeJoinReq->txLdpcIniFeatureEnabled;
Gopichand Nakkalab2d2c312013-01-04 11:41:02 -08002030
Abhinav Kumar6920f5a2019-08-05 18:55:11 +05302031 lim_update_sae_config(psessionEntry, pSmeJoinReq);
2032
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302033 if (psessionEntry->bssType == eSIR_INFRASTRUCTURE_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07002034 {
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302035 psessionEntry->limSystemRole = eLIM_STA_ROLE;
2036 }
2037 else if (psessionEntry->bssType == eSIR_BTAMP_AP_MODE)
2038 {
2039 psessionEntry->limSystemRole = eLIM_BT_AMP_STA_ROLE;
2040 }
2041 else
2042 {
2043 /* Throw an error and return and make sure to delete the session.*/
Abhishek Singh57aebef2014-02-03 18:47:44 +05302044 limLog(pMac, LOGE, FL("received SME_JOIN_REQ with invalid"
2045 " bss type %d"), psessionEntry->bssType);
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302046 retCode = eSIR_SME_INVALID_PARAMETERS;
2047 goto end;
2048 }
2049
2050 if (pSmeJoinReq->addIEScan.length)
2051 {
2052 vos_mem_copy( &psessionEntry->pLimJoinReq->addIEScan,
Jeff Johnson295189b2012-06-20 16:38:30 -07002053 &pSmeJoinReq->addIEScan, sizeof(tSirAddie));
2054 }
2055
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302056 if (pSmeJoinReq->addIEAssoc.length)
Jeff Johnson295189b2012-06-20 16:38:30 -07002057 {
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302058 vos_mem_copy( &psessionEntry->pLimJoinReq->addIEAssoc,
Jeff Johnson295189b2012-06-20 16:38:30 -07002059 &pSmeJoinReq->addIEAssoc, sizeof(tSirAddie));
2060 }
2061
Jeff Johnson295189b2012-06-20 16:38:30 -07002062 val = sizeof(tLimMlmJoinReq) + psessionEntry->pLimJoinReq->bssDescription.length + 2;
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302063 pMlmJoinReq = vos_mem_malloc(val);
2064 if ( NULL == pMlmJoinReq )
Jeff Johnson295189b2012-06-20 16:38:30 -07002065 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05302066 limLog(pMac, LOGP, FL("call to AllocateMemory "
2067 "failed for mlmJoinReq"));
Nitesh Shah54046ee2016-07-19 15:23:51 +05302068 retCode = eSIR_SME_RESOURCES_UNAVAILABLE;
2069 goto end;
Jeff Johnson295189b2012-06-20 16:38:30 -07002070 }
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302071 (void) vos_mem_set((void *) pMlmJoinReq, val, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07002072
2073 /* PE SessionId is stored as a part of JoinReq*/
2074 pMlmJoinReq->sessionId = psessionEntry->peSessionId;
2075
2076 if (wlan_cfgGetInt(pMac, WNI_CFG_JOIN_FAILURE_TIMEOUT, (tANI_U32 *) &pMlmJoinReq->joinFailureTimeout)
2077 != eSIR_SUCCESS)
Sushant Kaushike3ca61c2015-03-19 18:33:25 +05302078 {
2079 limLog(pMac, LOGE, FL("could not retrieve JoinFailureTimer value "
2080 "setting it to default value"));
Abhishek Singh6e8ca792017-11-30 15:43:22 +05302081 pMlmJoinReq->joinFailureTimeout =
2082 WNI_CFG_JOIN_FAILURE_TIMEOUT_STADEF;
Sushant Kaushike3ca61c2015-03-19 18:33:25 +05302083 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002084
2085 /* copy operational rate from psessionEntry*/
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302086 vos_mem_copy((void*)&psessionEntry->rateSet, (void*)&pSmeJoinReq->operationalRateSet,
Jeff Johnson295189b2012-06-20 16:38:30 -07002087 sizeof(tSirMacRateSet));
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302088 vos_mem_copy((void*)&psessionEntry->extRateSet, (void*)&pSmeJoinReq->extendedRateSet,
Jeff Johnson295189b2012-06-20 16:38:30 -07002089 sizeof(tSirMacRateSet));
2090 //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 +05302091 vos_mem_copy((void*)&pMlmJoinReq->operationalRateSet, (void*)&psessionEntry->rateSet,
Jeff Johnson295189b2012-06-20 16:38:30 -07002092 sizeof(tSirMacRateSet));
2093
2094 psessionEntry->encryptType = pSmeJoinReq->UCEncryptionType;
2095
Jeff Johnson295189b2012-06-20 16:38:30 -07002096 pMlmJoinReq->bssDescription.length = psessionEntry->pLimJoinReq->bssDescription.length;
2097
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302098 vos_mem_copy((tANI_U8 *) &pMlmJoinReq->bssDescription.bssId,
Jeff Johnson295189b2012-06-20 16:38:30 -07002099 (tANI_U8 *) &psessionEntry->pLimJoinReq->bssDescription.bssId,
2100 psessionEntry->pLimJoinReq->bssDescription.length + 2);
2101
Jeff Johnson295189b2012-06-20 16:38:30 -07002102 psessionEntry->limCurrentBssCaps =
Jeff Johnsone7245742012-09-05 17:12:55 -07002103 psessionEntry->pLimJoinReq->bssDescription.capabilityInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07002104
Jeff Johnsone7245742012-09-05 17:12:55 -07002105 regMax = cfgGetRegulatoryMaxTransmitPower( pMac, psessionEntry->currentOperChannel );
Sandeep Puligillaa9eb9ad2014-05-27 14:42:50 +05302106 localPowerConstraint = regMax;
Abhishek Singhbad2b322016-10-21 11:22:33 +05302107 limExtractApCapability(pMac,
2108 (tANI_U8 *) psessionEntry->pLimJoinReq->bssDescription.ieFields,
2109 GET_IE_LEN_IN_BSS(psessionEntry->pLimJoinReq->bssDescription.length),
2110 &psessionEntry->limCurrentBssQosCaps,
2111 &psessionEntry->limCurrentBssPropCap,
2112 &pMac->lim.gLimCurrentBssUapsd,
2113 &localPowerConstraint,
2114 psessionEntry);
Sandeep Puligillaa9eb9ad2014-05-27 14:42:50 +05302115
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002116#ifdef FEATURE_WLAN_ESE
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002117 psessionEntry->maxTxPower = limGetMaxTxPower(regMax, localPowerConstraint, pMac->roam.configParam.nTxPowerCap);
Jeff Johnson295189b2012-06-20 16:38:30 -07002118#else
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302119 psessionEntry->maxTxPower = VOS_MIN( regMax, (localPowerConstraint) );
Jeff Johnson295189b2012-06-20 16:38:30 -07002120#endif
Sushant Kaushikece4b562015-04-09 18:27:33 +05302121 if (!psessionEntry->maxTxPower)
2122 {
2123 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR, FL("Tx power"
2124 "is zero. Setting it to default value %d"),
2125 TX_POWER_DEFAULT);
2126 psessionEntry->maxTxPower = TX_POWER_DEFAULT;
2127 }
Abhinav Kumar5deb9cd2018-05-10 11:04:59 +05302128 psessionEntry->def_max_tx_pwr = psessionEntry->maxTxPower;
Sandeep Puligilla4ce02592014-04-22 09:05:57 +05302129 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
2130 "Regulatory max = %d, local power constraint = %d,"
Abhishek Singh57aebef2014-02-03 18:47:44 +05302131 " max tx = %d", regMax, localPowerConstraint,
2132 psessionEntry->maxTxPower );
Jeff Johnson295189b2012-06-20 16:38:30 -07002133
Agrawal Ashish0a4edfb2017-02-24 14:37:09 +05302134 if (pSmeJoinReq->powerCap.maxTxPower > psessionEntry->maxTxPower)
2135 {
2136 pSmeJoinReq->powerCap.maxTxPower = psessionEntry->maxTxPower;
2137 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_INFO,
2138 "Update MaxTxPower in join Req to %d",
2139 pSmeJoinReq->powerCap.maxTxPower);
2140 }
2141
Jeff Johnson295189b2012-06-20 16:38:30 -07002142 if (pMac->lim.gLimCurrentBssUapsd)
2143 {
2144 pMac->lim.gUapsdPerAcBitmask = psessionEntry->pLimJoinReq->uapsdPerAcBitmask;
Abhishek Singh57aebef2014-02-03 18:47:44 +05302145 limLog( pMac, LOG1, FL("UAPSD flag for all AC - 0x%2x"),
2146 pMac->lim.gUapsdPerAcBitmask);
Jeff Johnson295189b2012-06-20 16:38:30 -07002147
2148 // resetting the dynamic uapsd mask
2149 pMac->lim.gUapsdPerAcDeliveryEnableMask = 0;
2150 pMac->lim.gUapsdPerAcTriggerEnableMask = 0;
2151 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002152
2153 psessionEntry->limRFBand = limGetRFBand(psessionEntry->currentOperChannel);
2154
2155 // Initialize 11h Enable Flag
2156 if(SIR_BAND_5_GHZ == psessionEntry->limRFBand)
2157 {
2158 if (wlan_cfgGetInt(pMac, WNI_CFG_11H_ENABLED, &val) != eSIR_SUCCESS)
Sushant Kaushike3ca61c2015-03-19 18:33:25 +05302159 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002160 limLog(pMac, LOGP, FL("Fail to get WNI_CFG_11H_ENABLED "));
Sushant Kaushike3ca61c2015-03-19 18:33:25 +05302161 psessionEntry->lim11hEnable = 1;
2162 }
2163 else
2164 psessionEntry->lim11hEnable = val;
Jeff Johnson295189b2012-06-20 16:38:30 -07002165 }
2166 else
2167 psessionEntry->lim11hEnable = 0;
2168
2169 //To care of the scenario when STA transitions from IBSS to Infrastructure mode.
2170 pMac->lim.gLimIbssCoalescingHappened = false;
2171
Jeff Johnsone7245742012-09-05 17:12:55 -07002172 psessionEntry->limPrevSmeState = psessionEntry->limSmeState;
2173 psessionEntry->limSmeState = eLIM_SME_WT_JOIN_STATE;
2174 MTRACE(macTrace(pMac, TRACE_CODE_SME_STATE, psessionEntry->peSessionId, psessionEntry->limSmeState));
Jeff Johnson295189b2012-06-20 16:38:30 -07002175
Abhishek Singh57aebef2014-02-03 18:47:44 +05302176 limLog(pMac, LOG1, FL("SME JoinReq:Sessionid %d SSID len %d SSID : %s "
2177 "Channel %d, BSSID "MAC_ADDRESS_STR), pMlmJoinReq->sessionId,
2178 psessionEntry->ssId.length,psessionEntry->ssId.ssId,
2179 psessionEntry->currentOperChannel,
2180 MAC_ADDR_ARRAY(psessionEntry->bssId));
Jeff Johnson295189b2012-06-20 16:38:30 -07002181
2182 /* Indicate whether spectrum management is enabled*/
2183 psessionEntry->spectrumMgtEnabled =
2184 pSmeJoinReq->spectrumMgtIndicator;
Rajesh Babu Prathipati043149f2014-06-06 13:33:45 +05302185
2186 /* Enable the spectrum management if this is a DFS channel */
2187 if (psessionEntry->countryInfoPresent &&
2188 limIsconnectedOnDFSChannel(psessionEntry->currentOperChannel))
2189 {
2190 psessionEntry->spectrumMgtEnabled = TRUE;
2191 }
2192
Abhishek Singh3cbf6052014-12-15 16:46:42 +05302193 limLog(pMac,LOG1,FL("SessionId: %d LIM_MLM_JOIN_REQ is posted to MLM "
2194 "SM"), pMlmJoinReq->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07002195 /* Issue LIM_MLM_JOIN_REQ to MLM */
2196 limPostMlmMessage(pMac, LIM_MLM_JOIN_REQ, (tANI_U32 *) pMlmJoinReq);
2197 return;
2198
2199 }
2200 else
2201 {
2202 /* Received eWNI_SME_JOIN_REQ un expected state */
Abhishek Singh57aebef2014-02-03 18:47:44 +05302203 limLog(pMac, LOGE, FL("received unexpected SME_JOIN_REQ "
Sushant Kaushik1b645382014-10-13 16:39:36 +05302204 "in state %d"), pMac->lim.gLimSmeState);
Jeff Johnson295189b2012-06-20 16:38:30 -07002205 limPrintSmeState(pMac, LOGE, pMac->lim.gLimSmeState);
2206 retCode = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
2207 psessionEntry = NULL;
2208 goto end;
2209
2210 }
2211
2212end:
2213 limGetSessionInfo(pMac,(tANI_U8*)pMsgBuf,&smesessionId,&smetransactionId);
2214
2215 if(pSmeJoinReq)
2216 {
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302217 vos_mem_free(pSmeJoinReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07002218 pSmeJoinReq = NULL;
2219 if (NULL != psessionEntry)
2220 {
2221 psessionEntry->pLimJoinReq = NULL;
2222 }
2223 }
2224
2225 if(retCode != eSIR_SME_SUCCESS)
2226 {
2227 if(NULL != psessionEntry)
2228 {
2229 peDeleteSession(pMac,psessionEntry);
2230 psessionEntry = NULL;
2231 }
2232 }
Abhishek Singh57aebef2014-02-03 18:47:44 +05302233 limLog(pMac, LOG1, FL("Sending failure status limSendSmeJoinReassocRsp"
2234 "on sessionid: %d with retCode = %d"),smesessionId, retCode);
Jeff Johnson295189b2012-06-20 16:38:30 -07002235 limSendSmeJoinReassocRsp(pMac, eWNI_SME_JOIN_RSP, retCode, eSIR_MAC_UNSPEC_FAILURE_STATUS,psessionEntry,smesessionId,smetransactionId);
2236} /*** end __limProcessSmeJoinReq() ***/
2237
2238
Agrawal Ashish01c66342017-01-27 12:52:25 +05302239#if defined FEATURE_WLAN_ESE || defined WLAN_FEATURE_VOWIFI
Madan Mohan Koyyalamudi3282c572012-11-09 17:01:41 -08002240tANI_U8 limGetMaxTxPower(tPowerdBm regMax, tPowerdBm apTxPower, tANI_U8 iniTxPower)
Jeff Johnson295189b2012-06-20 16:38:30 -07002241{
2242 tANI_U8 maxTxPower = 0;
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302243 tANI_U8 txPower = VOS_MIN( regMax, (apTxPower) );
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002244 txPower = VOS_MIN(txPower, iniTxPower);
Jeff Johnson295189b2012-06-20 16:38:30 -07002245 if((txPower >= MIN_TX_PWR_CAP) && (txPower <= MAX_TX_PWR_CAP))
2246 maxTxPower = txPower;
2247 else if (txPower < MIN_TX_PWR_CAP)
2248 maxTxPower = MIN_TX_PWR_CAP;
2249 else
2250 maxTxPower = MAX_TX_PWR_CAP;
2251
2252 return (maxTxPower);
2253}
2254#endif
2255
Jeff Johnson295189b2012-06-20 16:38:30 -07002256/**
2257 * __limProcessSmeReassocReq()
2258 *
2259 *FUNCTION:
2260 * This function is called to process SME_REASSOC_REQ message
2261 * from HDD or upper layer application.
2262 *
2263 *LOGIC:
2264 *
2265 *ASSUMPTIONS:
2266 *
2267 *NOTE:
2268 *
2269 * @param pMac Pointer to Global MAC structure
2270 * @param *pMsgBuf A pointer to the SME message buffer
2271 * @return None
2272 */
2273
2274static void
2275__limProcessSmeReassocReq(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
2276{
2277 tANI_U16 caps;
2278 tANI_U32 val;
Srinivas Girigowdac16730e2013-01-16 13:39:39 -08002279 tpSirSmeJoinReq pReassocReq = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002280 tLimMlmReassocReq *pMlmReassocReq;
2281 tSirResultCodes retCode = eSIR_SME_SUCCESS;
2282 tpPESession psessionEntry = NULL;
2283 tANI_U8 sessionId;
2284 tANI_U8 smeSessionId;
2285 tANI_U16 transactionId;
2286 tPowerdBm localPowerConstraint = 0, regMax = 0;
2287 tANI_U32 teleBcnEn = 0;
Madan Mohan Koyyalamudi7df624d2012-10-31 16:32:50 -07002288 tANI_U16 nSize;
Jeff Johnson295189b2012-06-20 16:38:30 -07002289
2290
Abhishek Singh127a8442014-12-15 17:31:27 +05302291 limLog(pMac, LOG1, FL("Received SME_REASSOC_REQ"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002292
Madan Mohan Koyyalamudi7df624d2012-10-31 16:32:50 -07002293 nSize = __limGetSmeJoinReqSizeForAlloc((tANI_U8 *) pMsgBuf);
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302294 pReassocReq = vos_mem_malloc(nSize);
2295 if ( NULL == pReassocReq )
Jeff Johnson295189b2012-06-20 16:38:30 -07002296 {
2297 // Log error
2298 limLog(pMac, LOGP,
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302299 FL("call to AllocateMemory failed for pReassocReq"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002300
2301 retCode = eSIR_SME_RESOURCES_UNAVAILABLE;
2302 goto end;
2303 }
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302304 (void) vos_mem_set((void *) pReassocReq, nSize, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07002305 if ((limJoinReqSerDes(pMac, (tpSirSmeJoinReq) pReassocReq,
2306 (tANI_U8 *) pMsgBuf) == eSIR_FAILURE) ||
2307 (!limIsSmeJoinReqValid(pMac,
2308 (tpSirSmeJoinReq) pReassocReq)))
2309 {
2310 /// Received invalid eWNI_SME_REASSOC_REQ
2311 // Log the event
2312 limLog(pMac, LOGW,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002313 FL("received SME_REASSOC_REQ with invalid data"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002314
2315 retCode = eSIR_SME_INVALID_PARAMETERS;
2316 goto end;
2317 }
2318
2319 if((psessionEntry = peFindSessionByBssid(pMac,pReassocReq->bssDescription.bssId,&sessionId))==NULL)
2320 {
2321 limPrintMacAddr(pMac, pReassocReq->bssDescription.bssId, LOGE);
Srinivas Girigowda2a69dcf2013-09-13 14:48:34 -07002322 limLog(pMac, LOGE, FL("Session does not exist for given bssId"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002323 retCode = eSIR_SME_INVALID_PARAMETERS;
2324 goto end;
2325 }
2326
Sushant Kaushikb97a0082015-08-31 12:36:45 +05302327#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM //FEATURE_WLAN_DIAG_SUPPORT
Deepthi Gowri639d5042015-11-16 20:23:39 +05302328 limDiagEventReport(pMac, WLAN_PE_DIAG_REASSOC_REQ_EVENT, psessionEntry,
2329 eSIR_SUCCESS, eSIR_SUCCESS);
Jeff Johnson295189b2012-06-20 16:38:30 -07002330#endif //FEATURE_WLAN_DIAG_SUPPORT
2331 //pMac->lim.gpLimReassocReq = pReassocReq;//TO SUPPORT BT-AMP
2332
2333 /* Store the reassoc handle in the session Table.. 23rd sep review */
2334 psessionEntry->pLimReAssocReq = pReassocReq;
Padma, Santhosh Kumar0d25d102014-07-17 15:08:48 +05302335 psessionEntry->dot11mode = pReassocReq->dot11mode;
2336 psessionEntry->vhtCapability = IS_DOT11_MODE_VHT(pReassocReq->dot11mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07002337
2338 /**
2339 * Reassociate request is expected
2340 * in link established state only.
2341 */
2342
2343 if (psessionEntry->limSmeState != eLIM_SME_LINK_EST_STATE)
2344 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002345#if defined(WLAN_FEATURE_VOWIFI_11R) || defined(FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07002346 if (psessionEntry->limSmeState == eLIM_SME_WT_REASSOC_STATE)
2347 {
2348 // May be from 11r FT pre-auth. So lets check it before we bail out
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08002349 limLog(pMac, LOG1, FL("Session in reassoc state is %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002350 psessionEntry->peSessionId);
2351
2352 // Make sure its our preauth bssid
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302353 if (!vos_mem_compare( pReassocReq->bssDescription.bssId,
Jeff Johnson295189b2012-06-20 16:38:30 -07002354 pMac->ft.ftPEContext.pFTPreAuthReq->preAuthbssId, 6))
2355 {
2356 limPrintMacAddr(pMac, pReassocReq->bssDescription.bssId, LOGE);
2357 limPrintMacAddr(pMac, pMac->ft.ftPEContext.pFTPreAuthReq->preAuthbssId, LOGE);
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002358 limLog(pMac, LOGP, FL("Unknown bssId in reassoc state"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002359 retCode = eSIR_SME_INVALID_PARAMETERS;
2360 goto end;
2361 }
2362
2363 limProcessMlmFTReassocReq(pMac, pMsgBuf, psessionEntry);
2364 return;
2365 }
2366#endif
2367 /// Should not have received eWNI_SME_REASSOC_REQ
2368 // Log the event
2369 limLog(pMac, LOGE,
Sushant Kaushik1b645382014-10-13 16:39:36 +05302370 FL("received unexpected SME_REASSOC_REQ in state %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002371 psessionEntry->limSmeState);
2372 limPrintSmeState(pMac, LOGE, psessionEntry->limSmeState);
2373
2374 retCode = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
2375 goto end;
2376 }
2377
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302378 vos_mem_copy( psessionEntry->limReAssocbssId,
Jeff Johnson295189b2012-06-20 16:38:30 -07002379 psessionEntry->pLimReAssocReq->bssDescription.bssId,
2380 sizeof(tSirMacAddr));
2381
2382 psessionEntry->limReassocChannelId =
2383 psessionEntry->pLimReAssocReq->bssDescription.channelId;
2384
Jeff Johnsone7245742012-09-05 17:12:55 -07002385 psessionEntry->reAssocHtSupportedChannelWidthSet =
2386 (psessionEntry->pLimReAssocReq->cbMode)?1:0;
2387 psessionEntry->reAssocHtRecommendedTxWidthSet =
2388 psessionEntry->reAssocHtSupportedChannelWidthSet;
2389 psessionEntry->reAssocHtSecondaryChannelOffset =
2390 psessionEntry->pLimReAssocReq->cbMode;
2391
Jeff Johnson295189b2012-06-20 16:38:30 -07002392 psessionEntry->limReassocBssCaps =
2393 psessionEntry->pLimReAssocReq->bssDescription.capabilityInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07002394 regMax = cfgGetRegulatoryMaxTransmitPower( pMac, psessionEntry->currentOperChannel );
2395 localPowerConstraint = regMax;
Abhishek Singhbad2b322016-10-21 11:22:33 +05302396 limExtractApCapability(pMac,
2397 (tANI_U8 *) psessionEntry->pLimReAssocReq->bssDescription.ieFields,
2398 GET_IE_LEN_IN_BSS(
2399 psessionEntry->pLimReAssocReq->bssDescription.length),
2400 &psessionEntry->limReassocBssQosCaps,
2401 &psessionEntry->limReassocBssPropCap,
2402 &pMac->lim.gLimCurrentBssUapsd,
2403 &localPowerConstraint,
2404 psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07002405
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302406 psessionEntry->maxTxPower = VOS_MIN( regMax, (localPowerConstraint) );
Sushant Kaushikece4b562015-04-09 18:27:33 +05302407 if (!psessionEntry->maxTxPower)
2408 {
2409 VOS_TRACE(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ERROR, FL("Tx power "
2410 "is zero. Setting it to default value %d"),
2411 TX_POWER_DEFAULT);
2412 psessionEntry->maxTxPower = TX_POWER_DEFAULT;
2413 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002414#if defined WLAN_VOWIFI_DEBUG
Abhishek Singh57aebef2014-02-03 18:47:44 +05302415 limLog( pMac, LOGE, "Regulatory max = %d, local power constraint "
2416 "= %d, max tx = %d", regMax, localPowerConstraint,
2417 psessionEntry->maxTxPower );
Jeff Johnson295189b2012-06-20 16:38:30 -07002418#endif
2419 {
2420 #if 0
2421 if (wlan_cfgGetStr(pMac, WNI_CFG_SSID, pMac->lim.gLimReassocSSID.ssId,
2422 &cfgLen) != eSIR_SUCCESS)
2423 {
2424 /// Could not get SSID from CFG. Log error.
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002425 limLog(pMac, LOGP, FL("could not retrive SSID"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002426 }
2427 #endif//TO SUPPORT BT-AMP
2428
2429 /* Copy the SSID from sessio entry to local variable */
2430 #if 0
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302431 vos_mem_copy( pMac->lim.gLimReassocSSID.ssId,
Jeff Johnson295189b2012-06-20 16:38:30 -07002432 psessionEntry->ssId.ssId,
2433 psessionEntry->ssId.length);
2434 #endif
2435 psessionEntry->limReassocSSID.length = pReassocReq->ssId.length;
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302436 vos_mem_copy( psessionEntry->limReassocSSID.ssId,
Jeff Johnson295189b2012-06-20 16:38:30 -07002437 pReassocReq->ssId.ssId, psessionEntry->limReassocSSID.length);
2438
2439 }
2440
2441 if (pMac->lim.gLimCurrentBssUapsd)
2442 {
2443 pMac->lim.gUapsdPerAcBitmask = psessionEntry->pLimReAssocReq->uapsdPerAcBitmask;
Abhishek Singh57aebef2014-02-03 18:47:44 +05302444 limLog( pMac, LOG1, FL("UAPSD flag for all AC - 0x%2x"),
2445 pMac->lim.gUapsdPerAcBitmask);
Jeff Johnson295189b2012-06-20 16:38:30 -07002446 }
2447
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302448 pMlmReassocReq = vos_mem_malloc(sizeof(tLimMlmReassocReq));
2449 if ( NULL == pMlmReassocReq )
Jeff Johnson295189b2012-06-20 16:38:30 -07002450 {
2451 // Log error
2452 limLog(pMac, LOGP,
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302453 FL("call to AllocateMemory failed for mlmReassocReq"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002454
2455 retCode = eSIR_SME_RESOURCES_UNAVAILABLE;
2456 goto end;
2457 }
2458
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302459 vos_mem_copy( pMlmReassocReq->peerMacAddr,
Jeff Johnson295189b2012-06-20 16:38:30 -07002460 psessionEntry->limReAssocbssId,
2461 sizeof(tSirMacAddr));
2462
2463 if (wlan_cfgGetInt(pMac, WNI_CFG_REASSOCIATION_FAILURE_TIMEOUT,
2464 (tANI_U32 *) &pMlmReassocReq->reassocFailureTimeout)
2465 != eSIR_SUCCESS)
2466 {
2467 /**
2468 * Could not get ReassocFailureTimeout value
2469 * from CFG. Log error.
2470 */
2471 limLog(pMac, LOGP,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002472 FL("could not retrieve ReassocFailureTimeout value"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002473 }
2474
2475 if (cfgGetCapabilityInfo(pMac, &caps,psessionEntry) != eSIR_SUCCESS)
2476 {
2477 /**
2478 * Could not get Capabilities value
2479 * from CFG. Log error.
2480 */
2481 limLog(pMac, LOGP,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002482 FL("could not retrieve Capabilities value"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002483 }
Selvaraj, Sridhar5f149192016-04-15 12:53:28 +05302484
2485 lim_update_caps_info_for_bss(pMac, &caps,
2486 pReassocReq->bssDescription.capabilityInfo);
2487
2488 limLog(pMac, LOG1, FL("Capabilities info Reassoc: 0x%X"), caps);
2489
Jeff Johnson295189b2012-06-20 16:38:30 -07002490 pMlmReassocReq->capabilityInfo = caps;
2491
2492 /* Update PE sessionId*/
2493 pMlmReassocReq->sessionId = sessionId;
2494
2495 /* If telescopic beaconing is enabled, set listen interval to
2496 WNI_CFG_TELE_BCN_MAX_LI */
2497 if(wlan_cfgGetInt(pMac, WNI_CFG_TELE_BCN_WAKEUP_EN, &teleBcnEn) !=
2498 eSIR_SUCCESS)
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002499 limLog(pMac, LOGP, FL("Couldn't get WNI_CFG_TELE_BCN_WAKEUP_EN"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002500
2501 val = WNI_CFG_LISTEN_INTERVAL_STADEF;
2502
2503 if(teleBcnEn)
2504 {
2505 if(wlan_cfgGetInt(pMac, WNI_CFG_TELE_BCN_MAX_LI, &val) !=
2506 eSIR_SUCCESS)
2507 {
2508 /**
2509 * Could not get ListenInterval value
2510 * from CFG. Log error.
2511 */
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002512 limLog(pMac, LOGP, FL("could not retrieve ListenInterval"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002513 }
2514 }
2515 else
2516 {
2517 if (wlan_cfgGetInt(pMac, WNI_CFG_LISTEN_INTERVAL, &val) != eSIR_SUCCESS)
2518 {
2519 /**
2520 * Could not get ListenInterval value
2521 * from CFG. Log error.
2522 */
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002523 limLog(pMac, LOGP, FL("could not retrieve ListenInterval"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002524 }
2525 }
2526
2527 /* Delete all BA sessions before Re-Assoc.
2528 * BA frames are class 3 frames and the session
2529 * is lost upon disassociation and reassociation.
2530 */
2531
Ganesh Kondabattini01f75c92014-07-07 19:27:41 +05302532 limDeleteBASessions(pMac, psessionEntry, BA_BOTH_DIRECTIONS,
2533 eSIR_MAC_UNSPEC_FAILURE_REASON);
Jeff Johnson295189b2012-06-20 16:38:30 -07002534
2535 pMlmReassocReq->listenInterval = (tANI_U16) val;
2536
2537 /* Indicate whether spectrum management is enabled*/
2538 psessionEntry->spectrumMgtEnabled = pReassocReq->spectrumMgtIndicator;
2539
Rajesh Babu Prathipati043149f2014-06-06 13:33:45 +05302540 /* Enable the spectrum management if this is a DFS channel */
2541 if (psessionEntry->countryInfoPresent &&
2542 limIsconnectedOnDFSChannel(psessionEntry->currentOperChannel))
2543 {
2544 psessionEntry->spectrumMgtEnabled = TRUE;
2545 }
2546
Jeff Johnson295189b2012-06-20 16:38:30 -07002547 psessionEntry->limPrevSmeState = psessionEntry->limSmeState;
2548 psessionEntry->limSmeState = eLIM_SME_WT_REASSOC_STATE;
2549
Jeff Johnsone7245742012-09-05 17:12:55 -07002550 MTRACE(macTrace(pMac, TRACE_CODE_SME_STATE, psessionEntry->peSessionId, psessionEntry->limSmeState));
Jeff Johnson295189b2012-06-20 16:38:30 -07002551
2552 limPostMlmMessage(pMac,
2553 LIM_MLM_REASSOC_REQ,
2554 (tANI_U32 *) pMlmReassocReq);
2555 return;
2556
2557end:
2558 if (pReassocReq)
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302559 vos_mem_free( pReassocReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07002560
2561 if (psessionEntry)
2562 {
2563 // error occurred after we determined the session so extract
2564 // session and transaction info from there
2565 smeSessionId = psessionEntry->smeSessionId;
2566 transactionId = psessionEntry->transactionId;
2567 }
2568 else
2569 {
2570 // error occurred before or during the time we determined the session
2571 // so extract the session and transaction info from the message
2572 limGetSessionInfo(pMac,(tANI_U8*)pMsgBuf, &smeSessionId, &transactionId);
2573 }
2574
2575 /// Send Reassoc failure response to host
2576 /// (note psessionEntry may be NULL, but that's OK)
2577 limSendSmeJoinReassocRsp(pMac, eWNI_SME_REASSOC_RSP,
2578 retCode, eSIR_MAC_UNSPEC_FAILURE_STATUS,
2579 psessionEntry, smeSessionId, transactionId);
2580
2581} /*** end __limProcessSmeReassocReq() ***/
2582
2583
2584tANI_BOOLEAN sendDisassocFrame = 1;
2585/**
2586 * __limProcessSmeDisassocReq()
2587 *
2588 *FUNCTION:
2589 * This function is called to process SME_DISASSOC_REQ message
2590 * from HDD or upper layer application.
2591 *
2592 *LOGIC:
2593 *
2594 *ASSUMPTIONS:
2595 *
2596 *NOTE:
2597 *
2598 * @param pMac Pointer to Global MAC structure
2599 * @param *pMsgBuf A pointer to the SME message buffer
2600 * @return None
2601 */
2602
2603static void
2604__limProcessSmeDisassocReq(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
2605{
2606 tANI_U16 disassocTrigger, reasonCode;
2607 tLimMlmDisassocReq *pMlmDisassocReq;
2608 tSirResultCodes retCode = eSIR_SME_SUCCESS;
Jeff Johnson43971f52012-07-17 12:26:56 -07002609 tSirRetStatus status;
Jeff Johnson295189b2012-06-20 16:38:30 -07002610 tSirSmeDisassocReq smeDisassocReq;
2611 tpPESession psessionEntry = NULL;
2612 tANI_U8 sessionId;
2613 tANI_U8 smesessionId;
2614 tANI_U16 smetransactionId;
2615
Jeff Johnson295189b2012-06-20 16:38:30 -07002616
Jeff Johnson43971f52012-07-17 12:26:56 -07002617 if (pMsgBuf == NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -07002618 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002619 limLog(pMac, LOGE, FL("Buffer is Pointing to NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002620 return;
2621 }
2622
Jeff Johnson43971f52012-07-17 12:26:56 -07002623 limGetSessionInfo(pMac, (tANI_U8 *)pMsgBuf,&smesessionId, &smetransactionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07002624
Jeff Johnson43971f52012-07-17 12:26:56 -07002625 status = limDisassocReqSerDes(pMac, &smeDisassocReq, (tANI_U8 *) pMsgBuf);
Jeff Johnson295189b2012-06-20 16:38:30 -07002626
Jeff Johnson43971f52012-07-17 12:26:56 -07002627 if ( (eSIR_FAILURE == status) ||
2628 (!limIsSmeDisassocReqValid(pMac, &smeDisassocReq, psessionEntry)) )
Jeff Johnson295189b2012-06-20 16:38:30 -07002629 {
2630 PELOGE(limLog(pMac, LOGE,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002631 FL("received invalid SME_DISASSOC_REQ message"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07002632
2633 if (pMac->lim.gLimRspReqd)
2634 {
2635 pMac->lim.gLimRspReqd = false;
2636
2637 retCode = eSIR_SME_INVALID_PARAMETERS;
2638 disassocTrigger = eLIM_HOST_DISASSOC;
2639 goto sendDisassoc;
2640 }
2641
2642 return;
2643 }
2644
Jeff Johnson295189b2012-06-20 16:38:30 -07002645 if((psessionEntry = peFindSessionByBssid(pMac,smeDisassocReq.bssId,&sessionId))== NULL)
2646 {
Abhishek Singhcd09b562013-12-24 16:02:20 +05302647 limLog(pMac, LOGE,FL("session does not exist for given bssId "MAC_ADDRESS_STR),
2648 MAC_ADDR_ARRAY(smeDisassocReq.bssId));
Jeff Johnson295189b2012-06-20 16:38:30 -07002649 retCode = eSIR_SME_INVALID_PARAMETERS;
2650 disassocTrigger = eLIM_HOST_DISASSOC;
2651 goto sendDisassoc;
2652
2653 }
Abhishek Singhcd09b562013-12-24 16:02:20 +05302654 limLog(pMac, LOG1, FL("received DISASSOC_REQ message on sessionid %d"
2655 "Systemrole %d Reason: %u SmeState: %d from: "MAC_ADDRESS_STR),
2656 smesessionId,psessionEntry->limSystemRole,
2657 smeDisassocReq.reasonCode, pMac->lim.gLimSmeState,
2658 MAC_ADDR_ARRAY(smeDisassocReq.peerMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07002659
2660#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM //FEATURE_WLAN_DIAG_SUPPORT
2661 limDiagEventReport(pMac, WLAN_PE_DIAG_DISASSOC_REQ_EVENT, psessionEntry, 0, smeDisassocReq.reasonCode);
2662#endif //FEATURE_WLAN_DIAG_SUPPORT
2663
2664 /* Update SME session Id and SME transaction ID*/
2665
2666 psessionEntry->smeSessionId = smesessionId;
2667 psessionEntry->transactionId = smetransactionId;
2668
2669 switch (psessionEntry->limSystemRole)
2670 {
2671 case eLIM_STA_ROLE:
2672 case eLIM_BT_AMP_STA_ROLE:
2673 switch (psessionEntry->limSmeState)
2674 {
Pragaspathi Thilagaraj1f523352018-11-29 17:50:39 +05302675 /* cleanup FT session and proceed with disconnect
2676 * if received disconnect from supplicant when roaming
2677 * and lim state is eLIM_SME_WT_REASSOC_STATE. As the
2678 * FT session would have already created but is not cleaned.
2679 * This will prevent sending duplicate add bss request,
2680 * if we try to disconnect and connect to the same AP
2681 */
2682 case eLIM_SME_WT_REASSOC_STATE:
2683 limFTCleanup(pMac);
2684 /* Fall through */
Jeff Johnson295189b2012-06-20 16:38:30 -07002685 case eLIM_SME_ASSOCIATED_STATE:
2686 case eLIM_SME_LINK_EST_STATE:
Kanchanapally, Vidyullathac796fc62015-03-17 10:45:28 +05302687 limLog(pMac, LOG1, FL("Rcvd SME_DISASSOC_REQ while in "
2688 "limSmeState: %d "),psessionEntry->limSmeState);
2689
Jeff Johnson295189b2012-06-20 16:38:30 -07002690 psessionEntry->limPrevSmeState = psessionEntry->limSmeState;
2691 psessionEntry->limSmeState= eLIM_SME_WT_DISASSOC_STATE;
Hoonki Lee8c9e99f2013-04-18 22:59:11 -07002692#ifdef FEATURE_WLAN_TDLS
2693 /* Delete all TDLS peers connected before leaving BSS*/
2694 limDeleteTDLSPeers(pMac, psessionEntry);
2695#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07002696 MTRACE(macTrace(pMac, TRACE_CODE_SME_STATE, psessionEntry->peSessionId, psessionEntry->limSmeState));
Jeff Johnson295189b2012-06-20 16:38:30 -07002697 break;
2698
2699 case eLIM_SME_WT_DEAUTH_STATE:
2700 /* PE shall still process the DISASSOC_REQ and proceed with
2701 * link tear down even if it had already sent a DEAUTH_IND to
2702 * to SME. pMac->lim.gLimPrevSmeState shall remain the same as
2703 * its been set when PE entered WT_DEAUTH_STATE.
2704 */
2705 psessionEntry->limSmeState= eLIM_SME_WT_DISASSOC_STATE;
Jeff Johnsone7245742012-09-05 17:12:55 -07002706 MTRACE(macTrace(pMac, TRACE_CODE_SME_STATE, psessionEntry->peSessionId, psessionEntry->limSmeState));
Abhishek Singhcd09b562013-12-24 16:02:20 +05302707 limLog(pMac, LOG1, FL("Rcvd SME_DISASSOC_REQ while in "
2708 "SME_WT_DEAUTH_STATE. "));
Jeff Johnson295189b2012-06-20 16:38:30 -07002709 break;
2710
2711 case eLIM_SME_WT_DISASSOC_STATE:
2712 /* PE Recieved a Disassoc frame. Normally it gets DISASSOC_CNF but it
2713 * received DISASSOC_REQ. Which means host is also trying to disconnect.
2714 * PE can continue processing DISASSOC_REQ and send the response instead
2715 * of failing the request. SME will anyway ignore DEAUTH_IND that was sent
2716 * for disassoc frame.
2717 *
2718 * It will send a disassoc, which is ok. However, we can use the global flag
2719 * sendDisassoc to not send disassoc frame.
2720 */
Abhishek Singhcd09b562013-12-24 16:02:20 +05302721 limLog(pMac, LOG1, FL("Rcvd SME_DISASSOC_REQ while in "
2722 "SME_WT_DISASSOC_STATE. "));
Jeff Johnson295189b2012-06-20 16:38:30 -07002723 break;
2724
2725 case eLIM_SME_JOIN_FAILURE_STATE: {
2726 /** Return Success as we are already in Disconnected State*/
Abhishek Singhcd09b562013-12-24 16:02:20 +05302727 limLog(pMac, LOG1, FL("Rcvd SME_DISASSOC_REQ while in "
2728 "eLIM_SME_JOIN_FAILURE_STATE. "));
Jeff Johnson295189b2012-06-20 16:38:30 -07002729 if (pMac->lim.gLimRspReqd) {
2730 retCode = eSIR_SME_SUCCESS;
2731 disassocTrigger = eLIM_HOST_DISASSOC;
2732 goto sendDisassoc;
2733 }
2734 }break;
2735 default:
2736 /**
2737 * STA is not currently associated.
2738 * Log error and send response to host
2739 */
2740 limLog(pMac, LOGE,
Sushant Kaushik1b645382014-10-13 16:39:36 +05302741 FL("received unexpected SME_DISASSOC_REQ in state %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002742 psessionEntry->limSmeState);
2743 limPrintSmeState(pMac, LOGE, psessionEntry->limSmeState);
2744
2745 if (pMac->lim.gLimRspReqd)
2746 {
2747 if (psessionEntry->limSmeState !=
2748 eLIM_SME_WT_ASSOC_STATE)
2749 pMac->lim.gLimRspReqd = false;
2750
2751 retCode = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
2752 disassocTrigger = eLIM_HOST_DISASSOC;
2753 goto sendDisassoc;
2754 }
2755
2756 return;
2757 }
2758
2759 break;
2760
2761 case eLIM_AP_ROLE:
2762 case eLIM_BT_AMP_AP_ROLE:
2763 // Fall through
2764 break;
2765
2766 case eLIM_STA_IN_IBSS_ROLE:
2767 default: // eLIM_UNKNOWN_ROLE
2768 limLog(pMac, LOGE,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002769 FL("received unexpected SME_DISASSOC_REQ for role %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002770 psessionEntry->limSystemRole);
2771
2772 retCode = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
2773 disassocTrigger = eLIM_HOST_DISASSOC;
2774 goto sendDisassoc;
2775 } // end switch (pMac->lim.gLimSystemRole)
2776
Edhar, Mahesh Kumar03cf7ff2015-11-26 17:59:29 +05302777 disassocTrigger = eLIM_HOST_DISASSOC;
2778 reasonCode = smeDisassocReq.reasonCode;
Jeff Johnson295189b2012-06-20 16:38:30 -07002779
2780 if (smeDisassocReq.doNotSendOverTheAir)
2781 {
Abhishek Singhcd09b562013-12-24 16:02:20 +05302782 limLog(pMac, LOG1, FL("do not send dissoc over the air"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002783 sendDisassocFrame = 0;
2784 }
2785 // Trigger Disassociation frame to peer MAC entity
Sachin Ahuja2fea3d12014-12-18 17:31:31 +05302786 limLog(pMac, LOG1, FL("Sending Disasscoc with disassoc Trigger"
2787 " : %d, reasonCode : %d"),
2788 disassocTrigger, reasonCode);
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302789 pMlmDisassocReq = vos_mem_malloc(sizeof(tLimMlmDisassocReq));
2790 if ( NULL == pMlmDisassocReq )
Jeff Johnson295189b2012-06-20 16:38:30 -07002791 {
2792 // Log error
2793 limLog(pMac, LOGP,
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302794 FL("call to AllocateMemory failed for mlmDisassocReq"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002795
2796 return;
2797 }
2798
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05302799 vos_mem_copy( (tANI_U8 *) &pMlmDisassocReq->peerMacAddr,
Jeff Johnson295189b2012-06-20 16:38:30 -07002800 (tANI_U8 *) &smeDisassocReq.peerMacAddr,
2801 sizeof(tSirMacAddr));
2802
2803 pMlmDisassocReq->reasonCode = reasonCode;
2804 pMlmDisassocReq->disassocTrigger = disassocTrigger;
2805
2806 /* Update PE session ID*/
2807 pMlmDisassocReq->sessionId = sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -07002808
2809 limPostMlmMessage(pMac,
2810 LIM_MLM_DISASSOC_REQ,
2811 (tANI_U32 *) pMlmDisassocReq);
2812 return;
2813
2814sendDisassoc:
2815 if (psessionEntry)
2816 limSendSmeDisassocNtf(pMac, smeDisassocReq.peerMacAddr,
2817 retCode,
2818 disassocTrigger,
Jeff Johnson295189b2012-06-20 16:38:30 -07002819 1,smesessionId,smetransactionId,psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07002820 else
2821 limSendSmeDisassocNtf(pMac, smeDisassocReq.peerMacAddr,
2822 retCode,
2823 disassocTrigger,
Sudhir Sattayappa Kohalli5a8ac222013-03-06 12:41:42 -08002824 1, smesessionId, smetransactionId, NULL);
Jeff Johnson295189b2012-06-20 16:38:30 -07002825
2826
2827} /*** end __limProcessSmeDisassocReq() ***/
2828
2829
2830/** -----------------------------------------------------------------
2831 \brief __limProcessSmeDisassocCnf() - Process SME_DISASSOC_CNF
2832
2833 This function is called to process SME_DISASSOC_CNF message
2834 from HDD or upper layer application.
2835
2836 \param pMac - global mac structure
2837 \param pStaDs - station dph hash node
2838 \return none
2839 \sa
2840 ----------------------------------------------------------------- */
2841static void
2842__limProcessSmeDisassocCnf(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
2843{
2844 tSirSmeDisassocCnf smeDisassocCnf;
2845 tANI_U16 aid;
2846 tpDphHashNode pStaDs;
2847 tSirRetStatus status = eSIR_SUCCESS;
2848 tpPESession psessionEntry;
2849 tANI_U8 sessionId;
2850
2851
Abhishek Singh3cbf6052014-12-15 16:46:42 +05302852 limLog(pMac, LOG1, FL("received SME_DISASSOC_CNF message"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002853
2854 status = limDisassocCnfSerDes(pMac, &smeDisassocCnf,(tANI_U8 *) pMsgBuf);
2855
2856 if (status == eSIR_FAILURE)
2857 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002858 PELOGE(limLog(pMac, LOGE, FL("invalid SME_DISASSOC_CNF message"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07002859 return;
2860 }
2861
2862 if((psessionEntry = peFindSessionByBssid(pMac, smeDisassocCnf.bssId, &sessionId))== NULL)
2863 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002864 limLog(pMac, LOGE,FL("session does not exist for given bssId"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002865 return;
2866 }
2867
2868 if (!limIsSmeDisassocCnfValid(pMac, &smeDisassocCnf, psessionEntry))
2869 {
Abhishek Singhcd09b562013-12-24 16:02:20 +05302870 limLog(pMac, LOGE, FL("received invalid SME_DISASSOC_CNF message"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002871 return;
2872 }
2873
2874#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM //FEATURE_WLAN_DIAG_SUPPORT
2875 if (smeDisassocCnf.messageType == eWNI_SME_DISASSOC_CNF)
2876 limDiagEventReport(pMac, WLAN_PE_DIAG_DISASSOC_CNF_EVENT, psessionEntry, (tANI_U16)smeDisassocCnf.statusCode, 0);
2877 else if (smeDisassocCnf.messageType == eWNI_SME_DEAUTH_CNF)
2878 limDiagEventReport(pMac, WLAN_PE_DIAG_DEAUTH_CNF_EVENT, psessionEntry, (tANI_U16)smeDisassocCnf.statusCode, 0);
2879#endif //FEATURE_WLAN_DIAG_SUPPORT
2880
2881 switch (psessionEntry->limSystemRole)
2882 {
2883 case eLIM_STA_ROLE:
2884 case eLIM_BT_AMP_STA_ROLE: //To test reconn
2885 if ((psessionEntry->limSmeState != eLIM_SME_IDLE_STATE) &&
2886 (psessionEntry->limSmeState != eLIM_SME_WT_DISASSOC_STATE) &&
2887 (psessionEntry->limSmeState != eLIM_SME_WT_DEAUTH_STATE))
2888 {
2889 limLog(pMac, LOGE,
Sushant Kaushik1b645382014-10-13 16:39:36 +05302890 FL("received unexp SME_DISASSOC_CNF in state %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002891 psessionEntry->limSmeState);
2892 limPrintSmeState(pMac, LOGE, psessionEntry->limSmeState);
2893 return;
2894 }
2895 break;
2896
2897 case eLIM_AP_ROLE:
2898 // Fall through
Jeff Johnson295189b2012-06-20 16:38:30 -07002899 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07002900
2901 case eLIM_STA_IN_IBSS_ROLE:
2902 default: // eLIM_UNKNOWN_ROLE
2903 limLog(pMac, LOGE,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002904 FL("received unexpected SME_DISASSOC_CNF role %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002905 psessionEntry->limSystemRole);
2906
2907 return;
2908 }
2909
2910
2911 if ( (psessionEntry->limSmeState == eLIM_SME_WT_DISASSOC_STATE) ||
2912 (psessionEntry->limSmeState == eLIM_SME_WT_DEAUTH_STATE)
Jeff Johnson295189b2012-06-20 16:38:30 -07002913 || (psessionEntry->limSystemRole == eLIM_AP_ROLE )
Jeff Johnson295189b2012-06-20 16:38:30 -07002914 )
2915 {
2916 pStaDs = dphLookupHashEntry(pMac, smeDisassocCnf.peerMacAddr, &aid, &psessionEntry->dph.dphHashTable);
2917 if (pStaDs == NULL)
2918 {
Abhishek Singhcd09b562013-12-24 16:02:20 +05302919 PELOGE(limLog(pMac, LOGE, FL("received DISASSOC_CNF for a STA that "
2920 "does not have context, addr= "MAC_ADDRESS_STR),
2921 MAC_ADDR_ARRAY(smeDisassocCnf.peerMacAddr));)
Jeff Johnson295189b2012-06-20 16:38:30 -07002922 return;
2923 }
Wu Gao742b7352015-10-16 19:10:40 +08002924
2925 if(aid != smeDisassocCnf.assocId)
2926 {
2927 PELOGE(limLog(pMac, LOGE, FL("same peerMacAddr but assocId is different "
2928 "aid=%d, assocId=%d, addr= "MAC_ADDRESS_STR),
2929 aid, smeDisassocCnf.assocId, MAC_ADDR_ARRAY(smeDisassocCnf.peerMacAddr));)
2930 return;
2931 }
Padma, Santhosh Kumar05600d32015-07-24 13:00:57 +05302932 /*
2933 * If MlM state is either of del_sta or del_bss state, then no need to
2934 * go ahead and clean up further as there must be some cleanup in
2935 * progress from upper layer disassoc/deauth request.
2936 */
2937 if((pStaDs->mlmStaContext.mlmState == eLIM_MLM_WT_DEL_STA_RSP_STATE) ||
2938 (pStaDs->mlmStaContext.mlmState == eLIM_MLM_WT_DEL_BSS_RSP_STATE))
2939 {
2940 limLog(pMac, LOGE, FL("No need to cleanup for addr:"MAC_ADDRESS_STR
2941 "as Mlm state is %d"),
2942 MAC_ADDR_ARRAY(smeDisassocCnf.peerMacAddr),
2943 pStaDs->mlmStaContext.mlmState);
2944 return;
2945 }
2946
Madan Mohan Koyyalamudi23001722012-10-31 16:48:56 -07002947 /* Delete FT session if there exists one */
2948 limFTCleanup(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -07002949 limCleanupRxPath(pMac, pStaDs, psessionEntry);
Madan Mohan Koyyalamudia67d4332012-11-29 11:35:23 -08002950
2951 limCleanUpDisassocDeauthReq(pMac, (char*)&smeDisassocCnf.peerMacAddr, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07002952 }
2953
2954 return;
2955}
2956
2957
2958/**
2959 * __limProcessSmeDeauthReq()
2960 *
2961 *FUNCTION:
2962 * This function is called to process SME_DEAUTH_REQ message
2963 * from HDD or upper layer application.
2964 *
2965 *LOGIC:
2966 *
2967 *ASSUMPTIONS:
2968 *
2969 *NOTE:
2970 *
2971 * @param pMac Pointer to Global MAC structure
2972 * @param *pMsgBuf A pointer to the SME message buffer
2973 * @return None
2974 */
2975
2976static void
2977__limProcessSmeDeauthReq(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
2978{
2979 tANI_U16 deauthTrigger, reasonCode;
2980 tLimMlmDeauthReq *pMlmDeauthReq;
2981 tSirSmeDeauthReq smeDeauthReq;
2982 tSirResultCodes retCode = eSIR_SME_SUCCESS;
2983 tSirRetStatus status = eSIR_SUCCESS;
2984 tpPESession psessionEntry;
2985 tANI_U8 sessionId; //PE sessionId
2986 tANI_U8 smesessionId;
2987 tANI_U16 smetransactionId;
2988
Jeff Johnson295189b2012-06-20 16:38:30 -07002989
2990 status = limDeauthReqSerDes(pMac, &smeDeauthReq,(tANI_U8 *) pMsgBuf);
Jeff Johnson295189b2012-06-20 16:38:30 -07002991 limGetSessionInfo(pMac,(tANI_U8 *)pMsgBuf,&smesessionId,&smetransactionId);
2992
2993 //We need to get a session first but we don't even know if the message is correct.
2994 if((psessionEntry = peFindSessionByBssid(pMac, smeDeauthReq.bssId, &sessionId)) == NULL)
2995 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07002996 limLog(pMac, LOGE,FL("session does not exist for given bssId"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002997 retCode = eSIR_SME_INVALID_PARAMETERS;
2998 deauthTrigger = eLIM_HOST_DEAUTH;
2999 goto sendDeauth;
3000
3001 }
3002
3003 if ((status == eSIR_FAILURE) || (!limIsSmeDeauthReqValid(pMac, &smeDeauthReq, psessionEntry)))
3004 {
Sachin Ahuja42354142015-01-06 19:48:35 +05303005 PELOGE(limLog(pMac, LOGE,FL
3006 ("received invalid SME_DEAUTH_REQ message"));)
3007 pMac->lim.gLimRspReqd = false;
Jeff Johnson295189b2012-06-20 16:38:30 -07003008
Sachin Ahuja42354142015-01-06 19:48:35 +05303009 retCode = eSIR_SME_INVALID_PARAMETERS;
3010 deauthTrigger = eLIM_HOST_DEAUTH;
3011 goto sendDeauth;
Jeff Johnson295189b2012-06-20 16:38:30 -07003012 }
Abhishek Singhcd09b562013-12-24 16:02:20 +05303013 limLog(pMac, LOG1,FL("received DEAUTH_REQ message on sessionid %d "
3014 "Systemrole %d with reasoncode %u in limSmestate %d from "
3015 MAC_ADDRESS_STR), smesessionId, psessionEntry->limSystemRole,
3016 smeDeauthReq.reasonCode, psessionEntry->limSmeState,
3017 MAC_ADDR_ARRAY(smeDeauthReq.peerMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07003018#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM //FEATURE_WLAN_DIAG_SUPPORT
3019 limDiagEventReport(pMac, WLAN_PE_DIAG_DEAUTH_REQ_EVENT, psessionEntry, 0, smeDeauthReq.reasonCode);
3020#endif //FEATURE_WLAN_DIAG_SUPPORT
3021
3022 /* Update SME session ID and Transaction ID */
3023 psessionEntry->smeSessionId = smesessionId;
3024 psessionEntry->transactionId = smetransactionId;
3025
3026
3027 switch (psessionEntry->limSystemRole)
3028 {
3029 case eLIM_STA_ROLE:
3030 case eLIM_BT_AMP_STA_ROLE:
3031
3032 switch (psessionEntry->limSmeState)
3033 {
3034 case eLIM_SME_ASSOCIATED_STATE:
3035 case eLIM_SME_LINK_EST_STATE:
3036 case eLIM_SME_WT_ASSOC_STATE:
3037 case eLIM_SME_JOIN_FAILURE_STATE:
3038 case eLIM_SME_IDLE_STATE:
3039 psessionEntry->limPrevSmeState = psessionEntry->limSmeState;
3040 psessionEntry->limSmeState = eLIM_SME_WT_DEAUTH_STATE;
Varun Reddy Yeturue3bbf6e2013-02-08 18:50:55 -08003041 MTRACE(macTrace(pMac, TRACE_CODE_SME_STATE, psessionEntry->peSessionId, psessionEntry->limSmeState));
Jeff Johnson295189b2012-06-20 16:38:30 -07003042
3043 // Send Deauthentication request to MLM below
3044
3045 break;
Sachin Ahujaa100dcc2014-07-03 14:30:18 +05303046 case eLIM_SME_WT_DEAUTH_STATE:
3047 /*
3048 * PE Recieved a Deauth frame. Normally it gets
3049 * DEAUTH_CNF but it received DEAUTH_REQ. Which
3050 * means host is also trying to disconnect.
3051 * PE can continue processing DEAUTH_REQ and send
3052 * the response instead of failing the request.
3053 * SME will anyway ignore DEAUTH_IND that was sent
3054 * for deauth frame.
3055 */
3056 limLog(pMac, LOG1, FL("Rcvd SME_DEAUTH_REQ while in "
3057 "SME_WT_DEAUTH_STATE. "));
3058 break;
Padma, Santhosh Kumar05600d32015-07-24 13:00:57 +05303059 case eLIM_SME_WT_DISASSOC_STATE:
3060 /*
3061 * PE Recieved a Disassoc frame. Normally it gets
3062 * DISASSOC_CNF but it received DEAUTH_REQ. This means
3063 * host is also trying to disconnect.
3064 */
3065 limLog(pMac, LOG1, FL("Rcvd SME_DEAUTH_REQ while in "
3066 "SME_WT_DISASSOC_STATE. "));
3067 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003068 default:
3069 /**
3070 * STA is not in a state to deauthenticate with
3071 * peer. Log error and send response to host.
3072 */
3073 limLog(pMac, LOGE,
Sushant Kaushik1b645382014-10-13 16:39:36 +05303074 FL("received unexp SME_DEAUTH_REQ in state %d"),
Abhishek Singhcd09b562013-12-24 16:02:20 +05303075 psessionEntry->limSmeState);
Jeff Johnson295189b2012-06-20 16:38:30 -07003076 limPrintSmeState(pMac, LOGE, psessionEntry->limSmeState);
3077
3078 if (pMac->lim.gLimRspReqd)
3079 {
3080 pMac->lim.gLimRspReqd = false;
3081
3082 retCode = eSIR_SME_STA_NOT_AUTHENTICATED;
3083 deauthTrigger = eLIM_HOST_DEAUTH;
Leela Venkata Kiran Kumar Reddy Chirala56df73f2014-01-30 14:18:00 -08003084 /**
3085 *here we received deauth request from AP so sme state is
3086 eLIM_SME_WT_DEAUTH_STATE.if we have ISSUED delSta then
3087 mlm state should be eLIM_MLM_WT_DEL_STA_RSP_STATE and if
3088 we got delBSS rsp then mlm state should be eLIM_MLM_IDLE_STATE
3089 so the below condition captures the state where delSta
3090 not done and firmware still in connected state.
3091 */
3092 if (psessionEntry->limSmeState == eLIM_SME_WT_DEAUTH_STATE &&
3093 psessionEntry->limMlmState != eLIM_MLM_IDLE_STATE &&
3094 psessionEntry->limMlmState != eLIM_MLM_WT_DEL_STA_RSP_STATE)
3095 {
3096 retCode = eSIR_SME_DEAUTH_STATUS;
3097 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003098 goto sendDeauth;
3099 }
3100
3101 return;
3102 }
3103
3104 break;
3105
3106 case eLIM_STA_IN_IBSS_ROLE:
Abhishek Singh92fbac22015-03-24 17:57:36 +05303107 limLog(pMac, LOGE,FL("Deauth not allowed in IBSS"));
3108 if (pMac->lim.gLimRspReqd)
3109 {
3110 pMac->lim.gLimRspReqd = false;
3111 retCode = eSIR_SME_INVALID_PARAMETERS;
3112 deauthTrigger = eLIM_HOST_DEAUTH;
3113 goto sendDeauth;
3114 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003115 return;
3116
3117 case eLIM_AP_ROLE:
3118 // Fall through
3119
3120 break;
3121
3122 default:
3123 limLog(pMac, LOGE,
Sushant Kaushik1b645382014-10-13 16:39:36 +05303124 FL("received unexpected SME_DEAUTH_REQ for role %d"),
Abhishek Singhcd09b562013-12-24 16:02:20 +05303125 psessionEntry->limSystemRole);
Abhishek Singh92fbac22015-03-24 17:57:36 +05303126 if (pMac->lim.gLimRspReqd)
3127 {
3128 pMac->lim.gLimRspReqd = false;
Jeff Johnson295189b2012-06-20 16:38:30 -07003129
Abhishek Singh92fbac22015-03-24 17:57:36 +05303130 retCode = eSIR_SME_INVALID_PARAMETERS;
3131 deauthTrigger = eLIM_HOST_DEAUTH;
3132 goto sendDeauth;
3133 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003134 return;
Abhishek Singh92fbac22015-03-24 17:57:36 +05303135
Jeff Johnson295189b2012-06-20 16:38:30 -07003136 } // end switch (pMac->lim.gLimSystemRole)
3137
3138 if (smeDeauthReq.reasonCode == eLIM_LINK_MONITORING_DEAUTH)
3139 {
3140 /// Deauthentication is triggered by Link Monitoring
Abhishek Singh3cbf6052014-12-15 16:46:42 +05303141 limLog(pMac, LOG1,
3142 FL("Deauthentication is triggered by Link Monitoring"));
3143 limLog(pMac, LOG1,
3144 FL("Set Trigger to eLIM_LINK_MONITORING_DEAUTH"));
3145 limLog(pMac, LOG1,
3146 FL("and Reason to eSIR_MAC_UNSPEC_FAILURE_REASON"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003147 deauthTrigger = eLIM_LINK_MONITORING_DEAUTH;
3148 reasonCode = eSIR_MAC_UNSPEC_FAILURE_REASON;
3149 }
3150 else
3151 {
3152 deauthTrigger = eLIM_HOST_DEAUTH;
3153 reasonCode = smeDeauthReq.reasonCode;
3154 }
3155
3156 // Trigger Deauthentication frame to peer MAC entity
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303157 pMlmDeauthReq = vos_mem_malloc(sizeof(tLimMlmDeauthReq));
3158 if ( NULL == pMlmDeauthReq )
Jeff Johnson295189b2012-06-20 16:38:30 -07003159 {
3160 // Log error
Abhishek Singh92fbac22015-03-24 17:57:36 +05303161 limLog(pMac, LOGE,
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303162 FL("call to AllocateMemory failed for mlmDeauthReq"));
Abhishek Singh92fbac22015-03-24 17:57:36 +05303163 if (pMac->lim.gLimRspReqd)
3164 {
3165 pMac->lim.gLimRspReqd = false;
3166 retCode = eSIR_SME_RESOURCES_UNAVAILABLE;
3167 deauthTrigger = eLIM_HOST_DEAUTH;
3168 goto sendDeauth;
3169 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003170 return;
3171 }
3172
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303173 vos_mem_copy( (tANI_U8 *) &pMlmDeauthReq->peerMacAddr,
Jeff Johnson295189b2012-06-20 16:38:30 -07003174 (tANI_U8 *) &smeDeauthReq.peerMacAddr,
3175 sizeof(tSirMacAddr));
3176
3177 pMlmDeauthReq->reasonCode = reasonCode;
3178 pMlmDeauthReq->deauthTrigger = deauthTrigger;
Jeff Johnson295189b2012-06-20 16:38:30 -07003179
3180 /* Update PE session Id*/
3181 pMlmDeauthReq->sessionId = sessionId;
3182
3183 limPostMlmMessage(pMac,
3184 LIM_MLM_DEAUTH_REQ,
3185 (tANI_U32 *) pMlmDeauthReq);
3186 return;
3187
3188sendDeauth:
3189 limSendSmeDeauthNtf(pMac, smeDeauthReq.peerMacAddr,
3190 retCode,
3191 deauthTrigger,
Jeff Johnson295189b2012-06-20 16:38:30 -07003192 1,
Jeff Johnson295189b2012-06-20 16:38:30 -07003193 smesessionId, smetransactionId);
3194} /*** end __limProcessSmeDeauthReq() ***/
3195
3196
3197
3198/**
3199 * __limProcessSmeSetContextReq()
3200 *
3201 *FUNCTION:
3202 * This function is called to process SME_SETCONTEXT_REQ message
3203 * from HDD or upper layer application.
3204 *
3205 *LOGIC:
3206 *
3207 *ASSUMPTIONS:
3208 *
3209 *NOTE:
3210 *
3211 * @param pMac Pointer to Global MAC structure
3212 * @param *pMsgBuf A pointer to the SME message buffer
3213 * @return None
3214 */
3215
3216static void
3217__limProcessSmeSetContextReq(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
3218{
3219 tpSirSmeSetContextReq pSetContextReq;
3220 tLimMlmSetKeysReq *pMlmSetKeysReq;
3221 tpPESession psessionEntry;
3222 tANI_U8 sessionId; //PE sessionID
3223 tANI_U8 smesessionId;
3224 tANI_U16 smetransactionId;
3225
3226
3227 PELOG1(limLog(pMac, LOG1,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003228 FL("received SETCONTEXT_REQ message")););
Jeff Johnson295189b2012-06-20 16:38:30 -07003229
3230
3231 if(pMsgBuf == NULL)
3232 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003233 limLog(pMac, LOGE,FL("Buffer is Pointing to NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003234 return;
3235 }
3236
3237 limGetSessionInfo(pMac,(tANI_U8 *)pMsgBuf,&smesessionId,&smetransactionId);
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303238
3239 pSetContextReq = vos_mem_malloc(sizeof(tSirKeys) * SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS);
3240 if ( NULL == pSetContextReq )
Jeff Johnson295189b2012-06-20 16:38:30 -07003241 {
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303242 limLog(pMac, LOGP, FL("call to AllocateMemory failed for pSetContextReq"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003243 return;
3244 }
3245
3246 if ((limSetContextReqSerDes(pMac, pSetContextReq, (tANI_U8 *) pMsgBuf) == eSIR_FAILURE) ||
3247 (!limIsSmeSetContextReqValid(pMac, pSetContextReq)))
3248 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003249 limLog(pMac, LOGW, FL("received invalid SME_SETCONTEXT_REQ message"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003250 goto end;
3251 }
3252
3253 if(pSetContextReq->keyMaterial.numKeys > SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS)
3254 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003255 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 -07003256 limSendSmeSetContextRsp(pMac,
3257 pSetContextReq->peerMacAddr,
Jeff Johnson295189b2012-06-20 16:38:30 -07003258 1,
Jeff Johnson295189b2012-06-20 16:38:30 -07003259 eSIR_SME_INVALID_PARAMETERS,NULL,
3260 smesessionId,smetransactionId);
3261
3262 goto end;
3263 }
3264
3265
3266 if((psessionEntry = peFindSessionByBssid(pMac, pSetContextReq->bssId, &sessionId)) == NULL)
3267 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003268 limLog(pMac, LOGW, FL("Session does not exist for given BSSID"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003269 limSendSmeSetContextRsp(pMac,
3270 pSetContextReq->peerMacAddr,
Jeff Johnson295189b2012-06-20 16:38:30 -07003271 1,
Jeff Johnson295189b2012-06-20 16:38:30 -07003272 eSIR_SME_INVALID_PARAMETERS,NULL,
3273 smesessionId,smetransactionId);
3274
3275 goto end;
3276 }
3277
3278#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM //FEATURE_WLAN_DIAG_SUPPORT
3279 limDiagEventReport(pMac, WLAN_PE_DIAG_SETCONTEXT_REQ_EVENT, psessionEntry, 0, 0);
3280#endif //FEATURE_WLAN_DIAG_SUPPORT
3281
3282
3283 if ((((psessionEntry->limSystemRole == eLIM_STA_ROLE) || (psessionEntry->limSystemRole == eLIM_BT_AMP_STA_ROLE)) &&
3284 (psessionEntry->limSmeState == eLIM_SME_LINK_EST_STATE)) ||
3285 (((psessionEntry->limSystemRole == eLIM_STA_IN_IBSS_ROLE) ||
3286 (psessionEntry->limSystemRole == eLIM_AP_ROLE)|| (psessionEntry->limSystemRole == eLIM_BT_AMP_AP_ROLE)) &&
3287 (psessionEntry->limSmeState == eLIM_SME_NORMAL_STATE)))
3288 {
3289 // Trigger MLM_SETKEYS_REQ
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303290 pMlmSetKeysReq = vos_mem_malloc(sizeof(tLimMlmSetKeysReq));
3291 if ( NULL == pMlmSetKeysReq )
Jeff Johnson295189b2012-06-20 16:38:30 -07003292 {
3293 // Log error
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303294 limLog(pMac, LOGP, FL("call to AllocateMemory failed for mlmSetKeysReq"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003295 goto end;
3296 }
Abhishek Singhb25e8442015-06-23 14:28:05 +05303297 vos_mem_zero(pMlmSetKeysReq,sizeof(tLimMlmSetKeysReq));
Jeff Johnson295189b2012-06-20 16:38:30 -07003298 pMlmSetKeysReq->edType = pSetContextReq->keyMaterial.edType;
3299 pMlmSetKeysReq->numKeys = pSetContextReq->keyMaterial.numKeys;
3300 if(pMlmSetKeysReq->numKeys > SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS)
3301 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003302 limLog(pMac, LOGP, FL("Num of keys exceeded max num of default keys limit"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003303 goto end;
3304 }
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303305 vos_mem_copy( (tANI_U8 *) &pMlmSetKeysReq->peerMacAddr,
Jeff Johnson295189b2012-06-20 16:38:30 -07003306 (tANI_U8 *) &pSetContextReq->peerMacAddr,
3307 sizeof(tSirMacAddr));
3308
Jeff Johnson295189b2012-06-20 16:38:30 -07003309
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303310 vos_mem_copy( (tANI_U8 *) &pMlmSetKeysReq->key,
Jeff Johnson295189b2012-06-20 16:38:30 -07003311 (tANI_U8 *) &pSetContextReq->keyMaterial.key,
3312 sizeof(tSirKeys) * (pMlmSetKeysReq->numKeys ? pMlmSetKeysReq->numKeys : 1));
3313
3314 pMlmSetKeysReq->sessionId = sessionId;
3315#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
3316 PELOG1(limLog(pMac, LOG1,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003317 FL("received SETCONTEXT_REQ message sessionId=%d"), pMlmSetKeysReq->sessionId););
Jeff Johnson295189b2012-06-20 16:38:30 -07003318#endif
3319
Jeff Johnson295189b2012-06-20 16:38:30 -07003320 if(((pSetContextReq->keyMaterial.edType == eSIR_ED_WEP40) || (pSetContextReq->keyMaterial.edType == eSIR_ED_WEP104))
3321 && (psessionEntry->limSystemRole == eLIM_AP_ROLE))
3322 {
3323 if(pSetContextReq->keyMaterial.key[0].keyLength)
3324 {
3325 tANI_U8 keyId;
3326 keyId = pSetContextReq->keyMaterial.key[0].keyId;
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303327 vos_mem_copy( (tANI_U8 *)&psessionEntry->WEPKeyMaterial[keyId],
Jeff Johnson295189b2012-06-20 16:38:30 -07003328 (tANI_U8 *) &pSetContextReq->keyMaterial, sizeof(tSirKeyMaterial));
3329 }
3330 else {
3331 tANI_U32 i;
3332 for( i = 0; i < SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS; i++)
3333 {
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303334 vos_mem_copy( (tANI_U8 *) &pMlmSetKeysReq->key[i],
Jeff Johnson295189b2012-06-20 16:38:30 -07003335 (tANI_U8 *)psessionEntry->WEPKeyMaterial[i].key, sizeof(tSirKeys));
3336 }
3337 }
3338 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003339
3340 limPostMlmMessage(pMac, LIM_MLM_SETKEYS_REQ, (tANI_U32 *) pMlmSetKeysReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07003341 }
3342 else
3343 {
3344 limLog(pMac, LOGE,
Sushant Kaushik1b645382014-10-13 16:39:36 +05303345 FL("received unexpected SME_SETCONTEXT_REQ for role %d, state=%d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07003346 psessionEntry->limSystemRole,
3347 psessionEntry->limSmeState);
3348 limPrintSmeState(pMac, LOGE, psessionEntry->limSmeState);
3349
3350 limSendSmeSetContextRsp(pMac, pSetContextReq->peerMacAddr,
Jeff Johnson295189b2012-06-20 16:38:30 -07003351 1,
Jeff Johnson295189b2012-06-20 16:38:30 -07003352 eSIR_SME_UNEXPECTED_REQ_RESULT_CODE,psessionEntry,
3353 smesessionId,
3354 smetransactionId);
3355 }
3356
3357end:
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05303358 vos_mem_zero(pSetContextReq,
3359 (sizeof(tSirKeys) * SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS));
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303360 vos_mem_free( pSetContextReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07003361 return;
3362} /*** end __limProcessSmeSetContextReq() ***/
3363
3364/**
3365 * __limProcessSmeRemoveKeyReq()
3366 *
3367 *FUNCTION:
3368 * This function is called to process SME_REMOVEKEY_REQ message
3369 * from HDD or upper layer application.
3370 *
3371 *LOGIC:
3372 *
3373 *ASSUMPTIONS:
3374 *
3375 *NOTE:
3376 *
3377 * @param pMac Pointer to Global MAC structure
3378 * @param *pMsgBuf A pointer to the SME message buffer
3379 * @return None
3380 */
3381
3382static void
3383__limProcessSmeRemoveKeyReq(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
3384{
3385 tpSirSmeRemoveKeyReq pRemoveKeyReq;
3386 tLimMlmRemoveKeyReq *pMlmRemoveKeyReq;
3387 tpPESession psessionEntry;
3388 tANI_U8 sessionId; //PE sessionID
3389 tANI_U8 smesessionId;
3390 tANI_U16 smetransactionId;
3391
Abhishek Singh3cbf6052014-12-15 16:46:42 +05303392 limLog(pMac, LOG1,
3393 FL("received SME_REMOVEKEY_REQ message"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003394
3395 if(pMsgBuf == NULL)
3396 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003397 limLog(pMac, LOGE,FL("Buffer is Pointing to NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003398 return;
3399 }
3400
3401
3402 limGetSessionInfo(pMac,(tANI_U8 *)pMsgBuf,&smesessionId,&smetransactionId);
3403
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303404 pRemoveKeyReq = vos_mem_malloc(sizeof(*pRemoveKeyReq));
3405 if ( NULL == pRemoveKeyReq )
Jeff Johnson295189b2012-06-20 16:38:30 -07003406 {
3407 //Log error
3408 limLog(pMac, LOGP,
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303409 FL("call to AllocateMemory failed for pRemoveKeyReq"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003410
3411 return;
3412 }
3413
3414 if ((limRemoveKeyReqSerDes(pMac,
3415 pRemoveKeyReq,
3416 (tANI_U8 *) pMsgBuf) == eSIR_FAILURE))
3417 {
3418 limLog(pMac, LOGW,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003419 FL("received invalid SME_REMOVECONTEXT_REQ message"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003420
3421 /* extra look up is needed since, session entry to be passed il limsendremovekey response */
3422
3423 if((psessionEntry = peFindSessionByBssid(pMac,pRemoveKeyReq->bssId,&sessionId))== NULL)
3424 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003425 limLog(pMac, LOGE,FL("session does not exist for given bssId"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003426 //goto end;
3427 }
3428
3429 limSendSmeRemoveKeyRsp(pMac,
3430 pRemoveKeyReq->peerMacAddr,
3431 eSIR_SME_INVALID_PARAMETERS,psessionEntry,
3432 smesessionId,smetransactionId);
3433
3434 goto end;
3435 }
3436
3437 if((psessionEntry = peFindSessionByBssid(pMac,pRemoveKeyReq->bssId, &sessionId))== NULL)
3438 {
3439 limLog(pMac, LOGE,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003440 FL("session does not exist for given bssId"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003441 limSendSmeRemoveKeyRsp(pMac,
3442 pRemoveKeyReq->peerMacAddr,
3443 eSIR_SME_UNEXPECTED_REQ_RESULT_CODE, NULL,
3444 smesessionId, smetransactionId);
3445 goto end;
3446 }
3447
3448
3449 if ((((psessionEntry->limSystemRole == eLIM_STA_ROLE)|| (psessionEntry->limSystemRole == eLIM_BT_AMP_STA_ROLE))&&
3450 (psessionEntry->limSmeState == eLIM_SME_LINK_EST_STATE)) ||
3451 (((psessionEntry->limSystemRole == eLIM_STA_IN_IBSS_ROLE) ||
3452 (psessionEntry->limSystemRole == eLIM_AP_ROLE)|| (psessionEntry->limSystemRole == eLIM_BT_AMP_AP_ROLE)) &&
3453 (psessionEntry->limSmeState == eLIM_SME_NORMAL_STATE)))
3454 {
3455 // Trigger MLM_REMOVEKEYS_REQ
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303456 pMlmRemoveKeyReq = vos_mem_malloc(sizeof(tLimMlmRemoveKeyReq));
3457 if ( NULL == pMlmRemoveKeyReq )
Jeff Johnson295189b2012-06-20 16:38:30 -07003458 {
3459 // Log error
3460 limLog(pMac, LOGP,
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303461 FL("call to AllocateMemory failed for mlmRemoveKeysReq"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003462
3463 goto end;
3464 }
3465
3466 pMlmRemoveKeyReq->edType = (tAniEdType)pRemoveKeyReq->edType;
3467 pMlmRemoveKeyReq->keyId = pRemoveKeyReq->keyId;
3468 pMlmRemoveKeyReq->wepType = pRemoveKeyReq->wepType;
3469 pMlmRemoveKeyReq->unicast = pRemoveKeyReq->unicast;
3470
3471 /* Update PE session Id */
3472 pMlmRemoveKeyReq->sessionId = sessionId;
3473
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303474 vos_mem_copy( (tANI_U8 *) &pMlmRemoveKeyReq->peerMacAddr,
Jeff Johnson295189b2012-06-20 16:38:30 -07003475 (tANI_U8 *) &pRemoveKeyReq->peerMacAddr,
3476 sizeof(tSirMacAddr));
3477
3478
3479 limPostMlmMessage(pMac,
3480 LIM_MLM_REMOVEKEY_REQ,
3481 (tANI_U32 *) pMlmRemoveKeyReq);
3482 }
3483 else
3484 {
3485 limLog(pMac, LOGE,
Sushant Kaushik1b645382014-10-13 16:39:36 +05303486 FL("received unexpected SME_REMOVEKEY_REQ for role %d, state=%d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07003487 psessionEntry->limSystemRole,
3488 psessionEntry->limSmeState);
3489 limPrintSmeState(pMac, LOGE, psessionEntry->limSmeState);
3490
3491 limSendSmeRemoveKeyRsp(pMac,
3492 pRemoveKeyReq->peerMacAddr,
3493 eSIR_SME_UNEXPECTED_REQ_RESULT_CODE,psessionEntry,
3494 smesessionId,smetransactionId);
3495 }
3496
3497end:
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303498 vos_mem_free( pRemoveKeyReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07003499} /*** end __limProcessSmeRemoveKeyReq() ***/
3500
Jeff Johnson295189b2012-06-20 16:38:30 -07003501void limProcessSmeGetScanChannelInfo(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
3502{
3503 tSirMsgQ mmhMsg;
3504 tpSmeGetScanChnRsp pSirSmeRsp;
3505 tANI_U16 len = 0;
Madan Mohan Koyyalamudide1b5bc2013-07-12 00:56:04 +05303506 tANI_U8 sessionId;
3507 tANI_U16 transactionId;
Jeff Johnson295189b2012-06-20 16:38:30 -07003508
3509 if(pMac->lim.scanChnInfo.numChnInfo > SIR_MAX_SUPPORTED_CHANNEL_LIST)
3510 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003511 limLog(pMac, LOGW, FL("numChn is out of bounds %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07003512 pMac->lim.scanChnInfo.numChnInfo);
3513 pMac->lim.scanChnInfo.numChnInfo = SIR_MAX_SUPPORTED_CHANNEL_LIST;
3514 }
3515
Abhishek Singh525045c2014-12-15 17:18:45 +05303516 limLog(pMac, LOG1,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003517 FL("Sending message %s with number of channels %d"),
Abhishek Singh525045c2014-12-15 17:18:45 +05303518 limMsgStr(eWNI_SME_GET_SCANNED_CHANNEL_RSP), pMac->lim.scanChnInfo.numChnInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -07003519
3520 len = sizeof(tSmeGetScanChnRsp) + (pMac->lim.scanChnInfo.numChnInfo - 1) * sizeof(tLimScanChn);
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303521 pSirSmeRsp = vos_mem_malloc(len);
3522 if ( NULL == pSirSmeRsp )
Jeff Johnson295189b2012-06-20 16:38:30 -07003523 {
3524 /// Buffer not available. Log error
3525 limLog(pMac, LOGP,
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303526 FL("call to AllocateMemory failed for JOIN/REASSOC_RSP"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003527
3528 return;
3529 }
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303530 vos_mem_set(pSirSmeRsp, len, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07003531
Jeff Johnson295189b2012-06-20 16:38:30 -07003532 pSirSmeRsp->mesgType = eWNI_SME_GET_SCANNED_CHANNEL_RSP;
3533 pSirSmeRsp->mesgLen = len;
Madan Mohan Koyyalamudide1b5bc2013-07-12 00:56:04 +05303534
3535 if (pMac->fScanOffload)
3536 {
3537 limGetSessionInfo(pMac,(tANI_U8 *)pMsgBuf,&sessionId,&transactionId);
3538 pSirSmeRsp->sessionId = sessionId;
3539 }
3540 else
3541 pSirSmeRsp->sessionId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003542
3543 if(pMac->lim.scanChnInfo.numChnInfo)
3544 {
3545 pSirSmeRsp->numChn = pMac->lim.scanChnInfo.numChnInfo;
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303546 vos_mem_copy( pSirSmeRsp->scanChn, pMac->lim.scanChnInfo.scanChn,
3547 sizeof(tLimScanChn) * pSirSmeRsp->numChn);
Jeff Johnson295189b2012-06-20 16:38:30 -07003548 }
3549 //Clear the list
3550 limRessetScanChannelInfo(pMac);
3551
3552 mmhMsg.type = eWNI_SME_GET_SCANNED_CHANNEL_RSP;
3553 mmhMsg.bodyptr = pSirSmeRsp;
3554 mmhMsg.bodyval = 0;
3555
3556 pMac->lim.gLimRspReqd = false;
Konamki, Sreelakshmi824f93e2015-07-31 12:55:48 +05303557 MTRACE(macTrace(pMac, TRACE_CODE_TX_SME_MSG, NO_SESSION, mmhMsg.type));
Jeff Johnson295189b2012-06-20 16:38:30 -07003558 limSysProcessMmhMsgApi(pMac, &mmhMsg, ePROT);
3559}
3560
3561
Jeff Johnson295189b2012-06-20 16:38:30 -07003562void limProcessSmeGetAssocSTAsInfo(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
3563{
Hanumantha Reddy Pothula0de10802016-02-11 17:29:27 +05303564 tSirSmeGetAssocSTAsReq getAssocSTAsReq = {0};
Jeff Johnson295189b2012-06-20 16:38:30 -07003565 tpDphHashNode pStaDs = NULL;
3566 tpPESession psessionEntry = NULL;
3567 tSap_Event sapEvent;
3568 tpWLAN_SAPEventCB pSapEventCallback = NULL;
3569 tpSap_AssocMacAddr pAssocStasTemp = NULL;// #include "sapApi.h"
3570 tANI_U8 sessionId = CSR_SESSION_ID_INVALID;
3571 tANI_U8 assocId = 0;
3572 tANI_U8 staCount = 0;
3573
3574 if (!limIsSmeGetAssocSTAsReqValid(pMac, &getAssocSTAsReq, (tANI_U8 *) pMsgBuf))
3575 {
3576 limLog(pMac, LOGE,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003577 FL("received invalid eWNI_SME_GET_ASSOC_STAS_REQ message"));
Girish Gowliafd42312014-07-24 13:13:59 +05303578 return;
Jeff Johnson295189b2012-06-20 16:38:30 -07003579 }
3580
3581 switch (getAssocSTAsReq.modId)
3582 {
3583/**
3584 case VOS_MODULE_ID_HAL:
3585 wdaPostCtrlMsg( pMac, &msgQ );
3586 return;
3587
3588 case VOS_MODULE_ID_TL:
3589 Post msg TL
3590 return;
3591*/
3592 case VOS_MODULE_ID_PE:
3593 default:
3594 break;
3595 }
3596
Jeff Johnson1250df42012-12-10 14:31:52 -08003597 // Get Associated stations from PE
Jeff Johnson295189b2012-06-20 16:38:30 -07003598 // Find PE session Entry
3599 if ((psessionEntry = peFindSessionByBssid(pMac, getAssocSTAsReq.bssId, &sessionId)) == NULL)
3600 {
3601 limLog(pMac, LOGE,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003602 FL("session does not exist for given bssId"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003603 goto limAssocStaEnd;
3604 }
3605
3606 if (psessionEntry->limSystemRole != eLIM_AP_ROLE)
3607 {
3608 limLog(pMac, LOGE,
Sushant Kaushik1b645382014-10-13 16:39:36 +05303609 FL("Received unexpected message in state %d, in role %d"),
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303610 psessionEntry->limSmeState, psessionEntry->limSystemRole);
Jeff Johnson295189b2012-06-20 16:38:30 -07003611 goto limAssocStaEnd;
3612 }
3613
3614 // Retrieve values obtained in the request message
3615 pSapEventCallback = (tpWLAN_SAPEventCB)getAssocSTAsReq.pSapEventCallback;
3616 pAssocStasTemp = (tpSap_AssocMacAddr)getAssocSTAsReq.pAssocStasArray;
3617
3618 for (assocId = 0; assocId < psessionEntry->dph.dphHashTable.size; assocId++)// Softap dphHashTable.size = 8
3619 {
3620 pStaDs = dphGetHashEntry(pMac, assocId, &psessionEntry->dph.dphHashTable);
3621
Abhishek Singh8a99b9f2015-03-31 14:18:26 +05303622 if ((NULL == pStaDs) || (NULL == pAssocStasTemp))
Jeff Johnson295189b2012-06-20 16:38:30 -07003623 continue;
3624
3625 if (pStaDs->valid)
3626 {
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303627 vos_mem_copy((tANI_U8 *)&pAssocStasTemp->staMac,
3628 (tANI_U8 *)&pStaDs->staAddr,
3629 sizeof(v_MACADDR_t)); // Mac address
Jeff Johnson295189b2012-06-20 16:38:30 -07003630 pAssocStasTemp->assocId = (v_U8_t)pStaDs->assocId; // Association Id
3631 pAssocStasTemp->staId = (v_U8_t)pStaDs->staIndex; // Station Id
3632
Kiet Lamb1233192013-11-28 13:38:20 +05303633 vos_mem_copy((tANI_U8 *)&pAssocStasTemp->supportedRates,
Leo Chang614d2072013-08-22 14:59:44 -07003634 (tANI_U8 *)&pStaDs->supportedRates,
3635 sizeof(tSirSupportedRates));
3636 pAssocStasTemp->ShortGI40Mhz = pStaDs->htShortGI40Mhz;
3637 pAssocStasTemp->ShortGI20Mhz = pStaDs->htShortGI20Mhz;
3638 pAssocStasTemp->Support40Mhz = pStaDs->htDsssCckRate40MHzSupport;
3639
Jeff Johnson295189b2012-06-20 16:38:30 -07003640 limLog(pMac, LOG1, FL("dph Station Number = %d"), staCount+1);
Arif Hussain24bafea2013-11-15 15:10:03 -08003641 limLog(pMac, LOG1, FL("MAC = " MAC_ADDRESS_STR),
3642 MAC_ADDR_ARRAY(pStaDs->staAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07003643 limLog(pMac, LOG1, FL("Association Id = %d"),pStaDs->assocId);
3644 limLog(pMac, LOG1, FL("Station Index = %d"),pStaDs->staIndex);
3645
3646 pAssocStasTemp++;
3647 staCount++;
3648 }
3649 }
3650
3651limAssocStaEnd:
3652 // Call hdd callback with sap event to send the list of associated stations from PE
3653 if (pSapEventCallback != NULL)
3654 {
3655 sapEvent.sapHddEventCode = eSAP_ASSOC_STA_CALLBACK_EVENT;
3656 sapEvent.sapevt.sapAssocStaListEvent.module = VOS_MODULE_ID_PE;
3657 sapEvent.sapevt.sapAssocStaListEvent.noOfAssocSta = staCount;
3658 sapEvent.sapevt.sapAssocStaListEvent.pAssocStas = (tpSap_AssocMacAddr)getAssocSTAsReq.pAssocStasArray;
3659 pSapEventCallback(&sapEvent, getAssocSTAsReq.pUsrContext);
3660 }
3661}
3662
3663
3664/**
3665 * limProcessSmeGetWPSPBCSessions
3666 *
3667 *FUNCTION:
3668 * This function is called when query the WPS PBC overlap message is received
3669 *
3670 *LOGIC:
3671 * This function parses get WPS PBC overlap information message and call callback to pass
3672 * WPS PBC overlap information back to hdd.
3673 *ASSUMPTIONS:
3674 *
3675 *
3676 *NOTE:
3677 *
3678 * @param pMac Pointer to Global MAC structure
3679 * @param pMsgBuf A pointer to WPS PBC overlap query message
3680*
3681 * @return None
3682 */
3683void limProcessSmeGetWPSPBCSessions(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
3684{
3685 tSirSmeGetWPSPBCSessionsReq GetWPSPBCSessionsReq;
3686 tpPESession psessionEntry = NULL;
3687 tSap_Event sapEvent;
3688 tpWLAN_SAPEventCB pSapEventCallback = NULL;
3689 tANI_U8 sessionId = CSR_SESSION_ID_INVALID;
3690 tSirMacAddr zeroMac = {0,0,0,0,0,0};
3691
3692 sapEvent.sapevt.sapGetWPSPBCSessionEvent.status = VOS_STATUS_E_FAULT;
3693
3694 if (limIsSmeGetWPSPBCSessionsReqValid(pMac, &GetWPSPBCSessionsReq, (tANI_U8 *) pMsgBuf) != eSIR_SUCCESS)
3695 {
3696 limLog(pMac, LOGE,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003697 FL("received invalid eWNI_SME_GET_ASSOC_STAS_REQ message"));
Girish Gowliafd42312014-07-24 13:13:59 +05303698 return;
Jeff Johnson295189b2012-06-20 16:38:30 -07003699 }
3700
Jeff Johnson1250df42012-12-10 14:31:52 -08003701 // Get Associated stations from PE
Jeff Johnson295189b2012-06-20 16:38:30 -07003702 // Find PE session Entry
3703 if ((psessionEntry = peFindSessionByBssid(pMac, GetWPSPBCSessionsReq.bssId, &sessionId)) == NULL)
3704 {
3705 limLog(pMac, LOGE,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003706 FL("session does not exist for given bssId"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003707 goto limGetWPSPBCSessionsEnd;
3708 }
3709
3710 if (psessionEntry->limSystemRole != eLIM_AP_ROLE)
3711 {
3712 limLog(pMac, LOGE,
Sushant Kaushik1b645382014-10-13 16:39:36 +05303713 FL("Received unexpected message in role %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07003714 psessionEntry->limSystemRole);
3715 goto limGetWPSPBCSessionsEnd;
3716 }
3717
Jeff Johnson1250df42012-12-10 14:31:52 -08003718 // Call hdd callback with sap event to send the WPS PBC overlap information
Jeff Johnson295189b2012-06-20 16:38:30 -07003719 sapEvent.sapHddEventCode = eSAP_GET_WPSPBC_SESSION_EVENT;
3720 sapEvent.sapevt.sapGetWPSPBCSessionEvent.module = VOS_MODULE_ID_PE;
3721
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05303722 if (vos_mem_compare( zeroMac, GetWPSPBCSessionsReq.pRemoveMac, sizeof(tSirMacAddr)))
Jeff Johnson295189b2012-06-20 16:38:30 -07003723 { //This is GetWpsSession call
3724
3725 limGetWPSPBCSessions(pMac,
3726 sapEvent.sapevt.sapGetWPSPBCSessionEvent.addr.bytes, sapEvent.sapevt.sapGetWPSPBCSessionEvent.UUID_E,
3727 &sapEvent.sapevt.sapGetWPSPBCSessionEvent.wpsPBCOverlap, psessionEntry);
3728 }
3729 else
3730 {
3731 limRemovePBCSessions(pMac, GetWPSPBCSessionsReq.pRemoveMac,psessionEntry);
3732 /* don't have to inform the HDD/Host */
3733 return;
3734 }
3735
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003736 PELOG4(limLog(pMac, LOGE, FL("wpsPBCOverlap %d"), sapEvent.sapevt.sapGetWPSPBCSessionEvent.wpsPBCOverlap);)
Jeff Johnson295189b2012-06-20 16:38:30 -07003737 PELOG4(limPrintMacAddr(pMac, sapEvent.sapevt.sapGetWPSPBCSessionEvent.addr.bytes, LOG4);)
3738
3739 sapEvent.sapevt.sapGetWPSPBCSessionEvent.status = VOS_STATUS_SUCCESS;
3740
3741limGetWPSPBCSessionsEnd:
3742 pSapEventCallback = (tpWLAN_SAPEventCB)GetWPSPBCSessionsReq.pSapEventCallback;
Abhishek Singh8a99b9f2015-03-31 14:18:26 +05303743
3744 if (NULL != pSapEventCallback)
3745 pSapEventCallback(&sapEvent, GetWPSPBCSessionsReq.pUsrContext);
Jeff Johnson295189b2012-06-20 16:38:30 -07003746}
3747
Jeff Johnson295189b2012-06-20 16:38:30 -07003748
3749
3750/**
3751 * __limCounterMeasures()
3752 *
3753 * FUNCTION:
3754 * This function is called to "implement" MIC counter measure
3755 * and is *temporary* only
3756 *
3757 * LOGIC: on AP, disassoc all STA associated thru TKIP,
3758 * we don't do the proper STA disassoc sequence since the
3759 * BSS will be stoped anyway
3760 *
3761 *ASSUMPTIONS:
3762 *
3763 *NOTE:
3764 *
3765 * @param pMac Pointer to Global MAC structure
3766 * @return None
3767 */
3768
3769static void
3770__limCounterMeasures(tpAniSirGlobal pMac, tpPESession psessionEntry)
3771{
3772 tSirMacAddr mac = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
Abhishek Singh8944b222014-09-17 16:13:17 +05303773 /* If PMF is enabled then don't send broadcast disassociation */
3774 if ( ( (psessionEntry->limSystemRole == eLIM_AP_ROLE) ||
3775 (psessionEntry->limSystemRole == eLIM_BT_AMP_AP_ROLE) ||
3776 (psessionEntry->limSystemRole == eLIM_BT_AMP_STA_ROLE))
3777#ifdef WLAN_FEATURE_11W
3778 && !psessionEntry->limRmfEnabled
3779#endif
3780 )
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003781 limSendDisassocMgmtFrame(pMac, eSIR_MAC_MIC_FAILURE_REASON, mac, psessionEntry, FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003782
Jeff Johnson295189b2012-06-20 16:38:30 -07003783};
3784
3785
Jeff Johnson295189b2012-06-20 16:38:30 -07003786void
3787limProcessTkipCounterMeasures(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
3788{
3789 tSirSmeTkipCntrMeasReq tkipCntrMeasReq;
3790 tpPESession psessionEntry;
3791 tANI_U8 sessionId; //PE sessionId
3792
3793 if ( limTkipCntrMeasReqSerDes( pMac, &tkipCntrMeasReq, (tANI_U8 *) pMsgBuf ) != eSIR_SUCCESS )
3794 {
3795 limLog(pMac, LOGE,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003796 FL("received invalid eWNI_SME_TKIP_CNTR_MEAS_REQ message"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003797 return;
3798 }
3799
3800 if ( NULL == (psessionEntry = peFindSessionByBssid( pMac, tkipCntrMeasReq.bssId, &sessionId )) )
3801 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003802 limLog(pMac, LOGE, FL("session does not exist for given BSSID "));
Jeff Johnson295189b2012-06-20 16:38:30 -07003803 return;
3804 }
3805
3806 if ( tkipCntrMeasReq.bEnable )
3807 {
3808 __limCounterMeasures( pMac, psessionEntry );
3809 }
3810
3811 psessionEntry->bTkipCntrMeasActive = tkipCntrMeasReq.bEnable;
3812}
Jeff Johnson295189b2012-06-20 16:38:30 -07003813
3814
3815static void
3816__limHandleSmeStopBssRequest(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
3817{
3818 tSirSmeStopBssReq stopBssReq;
3819 tSirRetStatus status;
3820 tLimSmeStates prevState;
3821 tANI_U8 sessionId; //PE sessionId
3822 tpPESession psessionEntry;
3823 tANI_U8 smesessionId;
3824 tANI_U16 smetransactionId;
Sachin Ahuja51c08e62014-03-26 19:21:29 +05303825 tANI_U8 i = 0;
3826 tpDphHashNode pStaDs = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07003827
3828 limGetSessionInfo(pMac,(tANI_U8 *)pMsgBuf,&smesessionId,&smetransactionId);
3829
3830
3831
3832 if ((limStopBssReqSerDes(pMac, &stopBssReq, (tANI_U8 *) pMsgBuf) != eSIR_SUCCESS) ||
3833 !limIsSmeStopBssReqValid(pMsgBuf))
3834 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003835 PELOGW(limLog(pMac, LOGW, FL("received invalid SME_STOP_BSS_REQ message"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07003836 /// Send Stop BSS response to host
3837 limSendSmeRsp(pMac, eWNI_SME_STOP_BSS_RSP, eSIR_SME_INVALID_PARAMETERS,smesessionId,smetransactionId);
3838 return;
3839 }
3840
3841
3842 if((psessionEntry = peFindSessionByBssid(pMac,stopBssReq.bssId,&sessionId)) == NULL)
3843 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003844 limLog(pMac, LOGW, FL("session does not exist for given BSSID "));
Jeff Johnson295189b2012-06-20 16:38:30 -07003845 limSendSmeRsp(pMac, eWNI_SME_STOP_BSS_RSP, eSIR_SME_INVALID_PARAMETERS,smesessionId,smetransactionId);
3846 return;
3847 }
3848
3849#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM //FEATURE_WLAN_DIAG_SUPPORT
3850 limDiagEventReport(pMac, WLAN_PE_DIAG_STOP_BSS_REQ_EVENT, psessionEntry, 0, 0);
3851#endif //FEATURE_WLAN_DIAG_SUPPORT
3852
3853
3854 if ((psessionEntry->limSmeState != eLIM_SME_NORMAL_STATE) || /* Added For BT -AMP Support */
3855 (psessionEntry->limSystemRole == eLIM_STA_ROLE ))
3856 {
3857 /**
3858 * Should not have received STOP_BSS_REQ in states
3859 * other than 'normal' state or on STA in Infrastructure
3860 * mode. Log error and return response to host.
3861 */
3862 limLog(pMac, LOGE,
Sushant Kaushik1b645382014-10-13 16:39:36 +05303863 FL("received unexpected SME_STOP_BSS_REQ in state %d, for role %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07003864 psessionEntry->limSmeState, psessionEntry->limSystemRole);
3865 limPrintSmeState(pMac, LOGE, psessionEntry->limSmeState);
3866 /// Send Stop BSS response to host
3867 limSendSmeRsp(pMac, eWNI_SME_STOP_BSS_RSP, eSIR_SME_UNEXPECTED_REQ_RESULT_CODE,smesessionId,smetransactionId);
3868 return;
3869 }
3870
Jeff Johnson295189b2012-06-20 16:38:30 -07003871 if (psessionEntry->limSystemRole == eLIM_AP_ROLE )
3872 {
3873 limWPSPBCClose(pMac, psessionEntry);
3874 }
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003875 PELOGW(limLog(pMac, LOGW, FL("RECEIVED STOP_BSS_REQ with reason code=%d"), stopBssReq.reasonCode);)
Jeff Johnson295189b2012-06-20 16:38:30 -07003876
3877 prevState = psessionEntry->limSmeState;
3878
3879 psessionEntry->limSmeState = eLIM_SME_IDLE_STATE;
Jeff Johnsone7245742012-09-05 17:12:55 -07003880 MTRACE(macTrace(pMac, TRACE_CODE_SME_STATE, psessionEntry->peSessionId, psessionEntry->limSmeState));
Jeff Johnson295189b2012-06-20 16:38:30 -07003881
3882 /* Update SME session Id and Transaction Id */
3883 psessionEntry->smeSessionId = smesessionId;
3884 psessionEntry->transactionId = smetransactionId;
3885
Abhishek Singh8944b222014-09-17 16:13:17 +05303886 /* BTAMP_STA and STA_IN_IBSS should NOT send Disassoc frame.
3887 * If PMF is enabled then don't send broadcast disassociation */
3888 if ( ( (eLIM_STA_IN_IBSS_ROLE != psessionEntry->limSystemRole) &&
3889 (eLIM_BT_AMP_STA_ROLE != psessionEntry->limSystemRole) )
3890#ifdef WLAN_FEATURE_11W
3891 && !psessionEntry->limRmfEnabled
3892#endif
3893 )
Jeff Johnson295189b2012-06-20 16:38:30 -07003894 {
3895 tSirMacAddr bcAddr = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
3896 if ((stopBssReq.reasonCode == eSIR_SME_MIC_COUNTER_MEASURES))
3897 // Send disassoc all stations associated thru TKIP
3898 __limCounterMeasures(pMac,psessionEntry);
3899 else
Madan Mohan Koyyalamudi299b4862013-01-30 19:59:23 +05303900 limSendDisassocMgmtFrame(pMac, eSIR_MAC_DEAUTH_LEAVING_BSS_REASON, bcAddr, psessionEntry, FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003901 }
3902
3903 //limDelBss is also called as part of coalescing, when we send DEL BSS followed by Add Bss msg.
3904 pMac->lim.gLimIbssCoalescingHappened = false;
3905
Sachin Ahuja51c08e62014-03-26 19:21:29 +05303906 for(i = 1 ; i < pMac->lim.gLimAssocStaLimit ; i++)
3907 {
3908 pStaDs = dphGetHashEntry(pMac, i, &psessionEntry->dph.dphHashTable);
3909 if (NULL == pStaDs)
3910 continue;
3911 status = limDelSta(pMac, pStaDs, false, psessionEntry) ;
3912 if(eSIR_SUCCESS == status)
3913 {
3914 limDeleteDphHashEntry(pMac, pStaDs->staAddr, pStaDs->assocId, psessionEntry) ;
3915 limReleasePeerIdx(pMac, pStaDs->assocId, psessionEntry) ;
3916 }
3917 else
3918 {
3919 limLog(pMac, LOGE, FL("limDelSta failed with Status : %d"), status);
3920 VOS_ASSERT(0) ;
3921 }
3922 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003923 /* send a delBss to HAL and wait for a response */
3924 status = limDelBss(pMac, NULL,psessionEntry->bssIdx,psessionEntry);
3925
3926 if (status != eSIR_SUCCESS)
3927 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07003928 PELOGE(limLog(pMac, LOGE, FL("delBss failed for bss %d"), psessionEntry->bssIdx);)
Jeff Johnson295189b2012-06-20 16:38:30 -07003929 psessionEntry->limSmeState= prevState;
3930
Jeff Johnsone7245742012-09-05 17:12:55 -07003931 MTRACE(macTrace(pMac, TRACE_CODE_SME_STATE, psessionEntry->peSessionId, psessionEntry->limSmeState));
Jeff Johnson295189b2012-06-20 16:38:30 -07003932
3933 limSendSmeRsp(pMac, eWNI_SME_STOP_BSS_RSP, eSIR_SME_STOP_BSS_FAILURE,smesessionId,smetransactionId);
3934 }
3935}
3936
3937
3938/**--------------------------------------------------------------
3939\fn __limProcessSmeStopBssReq
3940
3941\brief Wrapper for the function __limHandleSmeStopBssRequest
3942 This message will be defered until softmac come out of
3943 scan mode. Message should be handled even if we have
3944 detected radar in the current operating channel.
3945\param pMac
3946\param pMsg
3947
3948\return TRUE - If we consumed the buffer
3949 FALSE - If have defered the message.
3950 ---------------------------------------------------------------*/
3951static tANI_BOOLEAN
3952__limProcessSmeStopBssReq(tpAniSirGlobal pMac, tpSirMsgQ pMsg)
3953{
3954 if (__limIsDeferedMsgForLearn(pMac, pMsg))
3955 {
3956 /**
3957 * If message defered, buffer is not consumed yet.
3958 * So return false
3959 */
3960 return eANI_BOOLEAN_FALSE;
3961 }
3962 __limHandleSmeStopBssRequest(pMac, (tANI_U32 *) pMsg->bodyptr);
3963 return eANI_BOOLEAN_TRUE;
3964} /*** end __limProcessSmeStopBssReq() ***/
3965
3966
3967void limProcessSmeDelBssRsp(
3968 tpAniSirGlobal pMac,
3969 tANI_U32 body,tpPESession psessionEntry)
3970{
3971
3972 (void) body;
3973 SET_LIM_PROCESS_DEFD_MESGS(pMac, true);
3974 //TBD: get the sessionEntry
Ravi Joshib58ca0d2013-10-29 09:50:23 -07003975 limIbssDelete(pMac,psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07003976 dphHashTableClassInit(pMac, &psessionEntry->dph.dphHashTable);
3977 limDeletePreAuthList(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -07003978 limSendSmeRsp(pMac, eWNI_SME_STOP_BSS_RSP, eSIR_SME_SUCCESS,psessionEntry->smeSessionId,psessionEntry->transactionId);
3979 return;
3980}
3981
3982
Jeff Johnson295189b2012-06-20 16:38:30 -07003983/**---------------------------------------------------------------
3984\fn __limProcessSmeAssocCnfNew
3985\brief This function handles SME_ASSOC_CNF/SME_REASSOC_CNF
3986\ in BTAMP AP.
3987\
3988\param pMac
3989\param msgType - message type
3990\param pMsgBuf - a pointer to the SME message buffer
3991\return None
3992------------------------------------------------------------------*/
3993
3994 void
3995__limProcessSmeAssocCnfNew(tpAniSirGlobal pMac, tANI_U32 msgType, tANI_U32 *pMsgBuf)
3996{
3997 tSirSmeAssocCnf assocCnf;
3998 tpDphHashNode pStaDs = NULL;
3999 tpPESession psessionEntry= NULL;
4000 tANI_U8 sessionId;
4001
4002
4003 if(pMsgBuf == NULL)
4004 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004005 limLog(pMac, LOGE, FL("pMsgBuf is NULL "));
Jeff Johnson295189b2012-06-20 16:38:30 -07004006 goto end;
4007 }
4008
4009 if ((limAssocCnfSerDes(pMac, &assocCnf, (tANI_U8 *) pMsgBuf) == eSIR_FAILURE) ||
4010 !__limIsSmeAssocCnfValid(&assocCnf))
4011 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004012 limLog(pMac, LOGE, FL("Received invalid SME_RE(ASSOC)_CNF message "));
Jeff Johnson295189b2012-06-20 16:38:30 -07004013 goto end;
4014 }
4015
4016 if((psessionEntry = peFindSessionByBssid(pMac, assocCnf.bssId, &sessionId))== NULL)
4017 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004018 limLog(pMac, LOGE, FL("session does not exist for given bssId"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004019 goto end;
4020 }
4021
4022 if ( ((psessionEntry->limSystemRole != eLIM_AP_ROLE) && (psessionEntry->limSystemRole != eLIM_BT_AMP_AP_ROLE)) ||
4023 ((psessionEntry->limSmeState != eLIM_SME_NORMAL_STATE) && (psessionEntry->limSmeState != eLIM_SME_NORMAL_CHANNEL_SCAN_STATE)))
4024 {
Sushant Kaushik1b645382014-10-13 16:39:36 +05304025 limLog(pMac, LOGE, FL("Received unexpected message %X in state %d, in role %d"),
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304026 msgType, psessionEntry->limSmeState, psessionEntry->limSystemRole);
Jeff Johnson295189b2012-06-20 16:38:30 -07004027 goto end;
4028 }
4029
4030 pStaDs = dphGetHashEntry(pMac, assocCnf.aid, &psessionEntry->dph.dphHashTable);
4031
4032 if (pStaDs == NULL)
4033 {
Sachin Ahuja2fea3d12014-12-18 17:31:31 +05304034 limLog(pMac, LOGE,
4035 FL("Received invalid message %X due to no STA context, "
4036 "for aid %d, peer "),
4037 msgType, assocCnf.aid);
Jeff Johnson295189b2012-06-20 16:38:30 -07004038 limPrintMacAddr(pMac, assocCnf.peerMacAddr, LOG1);
4039
4040 /*
4041 ** send a DISASSOC_IND message to WSM to make sure
4042 ** the state in WSM and LIM is the same
4043 **/
4044 limSendSmeDisassocNtf( pMac, assocCnf.peerMacAddr, eSIR_SME_STA_NOT_ASSOCIATED,
4045 eLIM_PEER_ENTITY_DISASSOC, assocCnf.aid,psessionEntry->smeSessionId,psessionEntry->transactionId,psessionEntry);
4046 goto end;
4047 }
4048 if ((pStaDs &&
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304049 (( !vos_mem_compare( (tANI_U8 *) pStaDs->staAddr,
Jeff Johnson295189b2012-06-20 16:38:30 -07004050 (tANI_U8 *) assocCnf.peerMacAddr,
4051 sizeof(tSirMacAddr)) ) ||
4052 (pStaDs->mlmStaContext.mlmState != eLIM_MLM_WT_ASSOC_CNF_STATE) ||
4053 ((pStaDs->mlmStaContext.subType == LIM_ASSOC) &&
4054 (msgType != eWNI_SME_ASSOC_CNF)) ||
4055 ((pStaDs->mlmStaContext.subType == LIM_REASSOC) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07004056 (msgType != eWNI_SME_ASSOC_CNF))))) // since softap is passing this as ASSOC_CNF and subtype differs
Jeff Johnson295189b2012-06-20 16:38:30 -07004057 {
Sachin Ahuja2fea3d12014-12-18 17:31:31 +05304058 limLog(pMac, LOGE,
4059 FL("Received invalid message %X due to peerMacAddr mismatched "
4060 "or not in eLIM_MLM_WT_ASSOC_CNF_STATE state, for aid %d, peer "
4061 "StaD mlmState : %d"),
4062 msgType, assocCnf.aid, pStaDs->mlmStaContext.mlmState);
Jeff Johnson295189b2012-06-20 16:38:30 -07004063 limPrintMacAddr(pMac, assocCnf.peerMacAddr, LOG1);
4064 goto end;
4065 }
4066
4067 /*
4068 ** Deactivate/delet CNF_WAIT timer since ASSOC_CNF
4069 ** has been received
4070 **/
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004071 limLog(pMac, LOG1, FL("Received SME_ASSOC_CNF. Delete Timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004072 limDeactivateAndChangePerStaIdTimer(pMac, eLIM_CNF_WAIT_TIMER, pStaDs->assocId);
4073
4074 if (assocCnf.statusCode == eSIR_SME_SUCCESS)
4075 {
4076 /* In BTAMP-AP, PE already finished the WDA_ADD_STA sequence
4077 * when it had received Assoc Request frame. Now, PE just needs to send
4078 * Association Response frame to the requesting BTAMP-STA.
4079 */
4080 pStaDs->mlmStaContext.mlmState = eLIM_MLM_LINK_ESTABLISHED_STATE;
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004081 limLog(pMac, LOG1, FL("sending Assoc Rsp frame to STA (assoc id=%d) "), pStaDs->assocId);
Kapil Gupta956c0c42017-06-16 19:24:31 +05304082 limSendAssocRspMgmtFrame(pMac, eSIR_SUCCESS, pStaDs->assocId,
4083 pStaDs->staAddr,
4084 pStaDs->mlmStaContext.subType, pStaDs,
4085 psessionEntry, NULL);
Jeff Johnson295189b2012-06-20 16:38:30 -07004086 goto end;
4087 } // (assocCnf.statusCode == eSIR_SME_SUCCESS)
4088 else
4089 {
4090 // SME_ASSOC_CNF status is non-success, so STA is not allowed to be associated
4091 /*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*/
4092 if(!pStaDs->mlmStaContext.updateContext)
4093 pStaDs->mlmStaContext.updateContext = 1;
Sachin Ahuja2fea3d12014-12-18 17:31:31 +05304094 limLog(pMac, LOG1, FL("Receive Assoc Cnf with status Code : %d(assoc id=%d) "),
4095 assocCnf.statusCode, pStaDs->assocId);
Jeff Johnson295189b2012-06-20 16:38:30 -07004096 limRejectAssociation(pMac, pStaDs->staAddr,
4097 pStaDs->mlmStaContext.subType,
4098 true, pStaDs->mlmStaContext.authType,
4099 pStaDs->assocId, true,
4100 eSIR_MAC_UNSPEC_FAILURE_STATUS, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07004101 }
4102
4103end:
4104 if((psessionEntry != NULL) && (pStaDs != NULL))
4105 {
4106 if ( psessionEntry->parsedAssocReq[pStaDs->assocId] != NULL )
4107 {
4108 if ( ((tpSirAssocReq)(psessionEntry->parsedAssocReq[pStaDs->assocId]))->assocReqFrame)
4109 {
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304110 vos_mem_free(((tpSirAssocReq)
4111 (psessionEntry->parsedAssocReq[pStaDs->assocId]))->assocReqFrame);
Jeff Johnson295189b2012-06-20 16:38:30 -07004112 ((tpSirAssocReq)(psessionEntry->parsedAssocReq[pStaDs->assocId]))->assocReqFrame = NULL;
4113 }
4114
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304115 vos_mem_free(psessionEntry->parsedAssocReq[pStaDs->assocId]);
Jeff Johnson295189b2012-06-20 16:38:30 -07004116 psessionEntry->parsedAssocReq[pStaDs->assocId] = NULL;
4117 }
4118 }
4119
4120} /*** end __limProcessSmeAssocCnfNew() ***/
4121
Agrawal Ashisha8e8a722016-10-18 19:07:45 +05304122#ifdef SAP_AUTH_OFFLOAD
4123/**
4124 * __lim_process_sme_assoc_offload_cnf() station connection confirmation
4125 * message from SME.
4126 * @pMac: SirGlobal handler
4127 * @msgType: message type
4128 * @pMsgBuf: message body
4129 *
4130 * This function handles the station connect confirm of
4131 * Software AP authentication offload feature
4132 *
4133 * Return: None
4134 */
4135 static void
4136__lim_process_sme_assoc_offload_cnf(tpAniSirGlobal pmac,
4137 tANI_U32 msg_type,
4138 tANI_U32 *pmsg_buf)
4139{
4140 tSirSmeAssocCnf assoc_cnf;
4141 tpDphHashNode sta_ds = NULL;
4142 tpPESession psession_entry= NULL;
4143 tANI_U8 session_id;
4144 tANI_U16 aid=0;
Jeff Johnson295189b2012-06-20 16:38:30 -07004145
Agrawal Ashisha8e8a722016-10-18 19:07:45 +05304146 if (pmsg_buf == NULL)
4147 {
4148 limLog(pmac, LOGE, FL("pmsg_buf is NULL "));
4149 return;
4150 }
4151
4152 if ((limAssocCnfSerDes(pmac, &assoc_cnf, (tANI_U8 *) pmsg_buf) ==
4153 eSIR_FAILURE) || !__limIsSmeAssocCnfValid(&assoc_cnf))
4154 {
4155 limLog(pmac, LOGE, FL("Received invalid SME_RE(ASSOC)_CNF message "));
4156 return;
4157 }
4158
4159 if((psession_entry =
4160 peFindSessionByBssid(pmac, assoc_cnf.bssId, &session_id))== NULL)
4161 {
4162 limLog(pmac, LOGE, FL("session does not exist for given bssId"));
4163 goto end;
4164 }
4165
4166 if ((!LIM_IS_AP_ROLE(psession_entry)) ||
4167 ((psession_entry->limSmeState != eLIM_SME_NORMAL_STATE) &&
4168 (psession_entry->limSmeState != eLIM_SME_NORMAL_CHANNEL_SCAN_STATE)))
4169 {
4170 limLog(pmac, LOGE,
4171 FL("Received unexpected message %X in state %X, in role %X"),
4172 msg_type, psession_entry->limSmeState,
4173 GET_LIM_SYSTEM_ROLE(psession_entry));
4174 goto end;
4175 }
4176 sta_ds = dphGetHashEntry(pmac,
4177 assoc_cnf.aid,
4178 &psession_entry->dph.dphHashTable);
4179 if (sta_ds != NULL)
4180 {
4181 aid = sta_ds->assocId;
4182 /* Deactivate/delete CNF_WAIT timer since ASSOC_CNF
4183 * has been received */
4184 limDeactivateAndChangePerStaIdTimer(pmac,
4185 eLIM_CNF_WAIT_TIMER,
4186 aid);
4187 }
Abhinav Kumarb4626d02018-02-26 18:16:30 +05304188 else
4189 {
4190 limLog(pmac, LOGE, FL("NULL sta_ds"));
4191 goto end;
4192 }
Agrawal Ashish25d9ef12017-01-10 20:27:50 +05304193 if (assoc_cnf.statusCode == eSIR_SME_SUCCESS)
4194 {
4195 sta_ds->mlmStaContext.mlmState = eLIM_MLM_LINK_ESTABLISHED_STATE;
4196 limLog(pmac, LOG1, FL("Set mlmState to eLIM_MLM_LINK_ESTABLISHED_STATE"));
4197 }
Agrawal Ashisha8e8a722016-10-18 19:07:45 +05304198
4199end:
4200 if((psession_entry != NULL) && (sta_ds != NULL))
4201 {
4202 if ( psession_entry->parsedAssocReq[aid] != NULL )
4203 {
4204 if ( ((tpSirAssocReq)
4205 (psession_entry->parsedAssocReq[aid]))->assocReqFrame)
4206 {
4207 vos_mem_free(((tpSirAssocReq)
4208 (psession_entry->parsedAssocReq[aid]))->assocReqFrame);
4209 ((tpSirAssocReq)
4210 (psession_entry->parsedAssocReq[aid]))->assocReqFrame =
4211 NULL;
4212 }
4213 vos_mem_free(psession_entry->parsedAssocReq[aid]);
4214 psession_entry->parsedAssocReq[aid] = NULL;
4215 }
4216 }
4217
4218} /*** end __lim_process_sme_assoc_offload_cnf() ***/
4219#endif /* SAP_AUTH_OFFLOAD */
Jeff Johnson295189b2012-06-20 16:38:30 -07004220
4221
4222static void
4223__limProcessSmeAddtsReq(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
4224{
4225 tpDphHashNode pStaDs;
4226 tSirMacAddr peerMac;
4227 tpSirAddtsReq pSirAddts;
4228 tANI_U32 timeout;
4229 tpPESession psessionEntry;
4230 tANI_U8 sessionId; //PE sessionId
4231 tANI_U8 smesessionId;
4232 tANI_U16 smetransactionId;
4233
4234
4235 if(pMsgBuf == NULL)
4236 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004237 limLog(pMac, LOGE,FL("Buffer is Pointing to NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004238 return;
4239 }
4240
4241 limGetSessionInfo(pMac,(tANI_U8 *)pMsgBuf,&smesessionId,&smetransactionId);
4242
4243 pSirAddts = (tpSirAddtsReq) pMsgBuf;
4244
4245 if((psessionEntry = peFindSessionByBssid(pMac, pSirAddts->bssId,&sessionId))== NULL)
4246 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004247 limLog(pMac, LOGE, "Session Does not exist for given bssId");
Jeff Johnson295189b2012-06-20 16:38:30 -07004248 return;
4249 }
4250#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM //FEATURE_WLAN_DIAG_SUPPORT
4251 limDiagEventReport(pMac, WLAN_PE_DIAG_ADDTS_REQ_EVENT, psessionEntry, 0, 0);
4252#endif //FEATURE_WLAN_DIAG_SUPPORT
4253
4254
4255
4256 /* if sta
4257 * - verify assoc state
4258 * - send addts request to ap
4259 * - wait for addts response from ap
4260 * if ap, just ignore with error log
4261 */
Abhishek Singh3cbf6052014-12-15 16:46:42 +05304262 limLog(pMac, LOG1,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004263 FL("Received SME_ADDTS_REQ (TSid %d, UP %d)"),
Jeff Johnson295189b2012-06-20 16:38:30 -07004264 pSirAddts->req.tspec.tsinfo.traffic.tsid,
Abhishek Singh3cbf6052014-12-15 16:46:42 +05304265 pSirAddts->req.tspec.tsinfo.traffic.userPrio);
Jeff Johnson295189b2012-06-20 16:38:30 -07004266
4267 if ((psessionEntry->limSystemRole != eLIM_STA_ROLE)&&(psessionEntry->limSystemRole != eLIM_BT_AMP_STA_ROLE))
4268 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004269 PELOGE(limLog(pMac, LOGE, "AddTs received on AP - ignoring");)
Jeff Johnson295189b2012-06-20 16:38:30 -07004270 limSendSmeAddtsRsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE, psessionEntry, pSirAddts->req.tspec,
4271 smesessionId,smetransactionId);
4272 return;
4273 }
4274
Jeff Johnson295189b2012-06-20 16:38:30 -07004275 pStaDs = dphGetHashEntry(pMac, DPH_STA_HASH_INDEX_PEER, &psessionEntry->dph.dphHashTable);
4276
4277 if(pStaDs == NULL)
4278 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004279 PELOGE(limLog(pMac, LOGE, "Cannot find AP context for addts req");)
Jeff Johnson295189b2012-06-20 16:38:30 -07004280 limSendSmeAddtsRsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE, psessionEntry, pSirAddts->req.tspec,
4281 smesessionId,smetransactionId);
4282 return;
4283 }
4284
4285 if ((! pStaDs->valid) ||
4286 (pStaDs->mlmStaContext.mlmState != eLIM_MLM_LINK_ESTABLISHED_STATE))
4287 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004288 PELOGE(limLog(pMac, LOGE, "AddTs received in invalid MLM state");)
Jeff Johnson295189b2012-06-20 16:38:30 -07004289 limSendSmeAddtsRsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE, psessionEntry, pSirAddts->req.tspec,
4290 smesessionId,smetransactionId);
4291 return;
4292 }
4293
4294 pSirAddts->req.wsmTspecPresent = 0;
4295 pSirAddts->req.wmeTspecPresent = 0;
4296 pSirAddts->req.lleTspecPresent = 0;
4297
4298 if ((pStaDs->wsmEnabled) &&
4299 (pSirAddts->req.tspec.tsinfo.traffic.accessPolicy != SIR_MAC_ACCESSPOLICY_EDCA))
4300 pSirAddts->req.wsmTspecPresent = 1;
4301 else if (pStaDs->wmeEnabled)
4302 pSirAddts->req.wmeTspecPresent = 1;
4303 else if (pStaDs->lleEnabled)
4304 pSirAddts->req.lleTspecPresent = 1;
4305 else
4306 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004307 PELOGW(limLog(pMac, LOGW, FL("ADDTS_REQ ignore - qos is disabled"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07004308 limSendSmeAddtsRsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE, psessionEntry, pSirAddts->req.tspec,
4309 smesessionId,smetransactionId);
4310 return;
4311 }
4312
4313 if ((psessionEntry->limSmeState != eLIM_SME_ASSOCIATED_STATE) &&
4314 (psessionEntry->limSmeState != eLIM_SME_LINK_EST_STATE))
4315 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004316 limLog(pMac, LOGE, "AddTs received in invalid LIMsme state (%d)",
Jeff Johnson295189b2012-06-20 16:38:30 -07004317 psessionEntry->limSmeState);
4318 limSendSmeAddtsRsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE, psessionEntry, pSirAddts->req.tspec,
4319 smesessionId,smetransactionId);
4320 return;
4321 }
4322
4323 if (pMac->lim.gLimAddtsSent)
4324 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004325 limLog(pMac, LOGE, "Addts (token %d, tsid %d, up %d) is still pending",
Jeff Johnson295189b2012-06-20 16:38:30 -07004326 pMac->lim.gLimAddtsReq.req.dialogToken,
4327 pMac->lim.gLimAddtsReq.req.tspec.tsinfo.traffic.tsid,
4328 pMac->lim.gLimAddtsReq.req.tspec.tsinfo.traffic.userPrio);
4329 limSendSmeAddtsRsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE, psessionEntry, pSirAddts->req.tspec,
4330 smesessionId,smetransactionId);
4331 return;
4332 }
4333
4334 #if 0
4335 val = sizeof(tSirMacAddr);
4336 if (wlan_cfgGetStr(pMac, WNI_CFG_BSSID, peerMac, &val) != eSIR_SUCCESS)
4337 {
4338 /// Could not get BSSID from CFG. Log error.
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004339 limLog(pMac, LOGP, FL("could not retrieve BSSID"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004340 return;
4341 }
4342 #endif
4343 sirCopyMacAddr(peerMac,psessionEntry->bssId);
4344
4345 // save the addts request
4346 pMac->lim.gLimAddtsSent = true;
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304347 vos_mem_copy( (tANI_U8 *) &pMac->lim.gLimAddtsReq, (tANI_U8 *) pSirAddts, sizeof(tSirAddtsReq));
Jeff Johnson295189b2012-06-20 16:38:30 -07004348
4349 // ship out the message now
4350 limSendAddtsReqActionFrame(pMac, peerMac, &pSirAddts->req,
4351 psessionEntry);
Abhishek Singh3cbf6052014-12-15 16:46:42 +05304352 limLog(pMac, LOG1, FL("Sent ADDTS request"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004353
4354 // start a timer to wait for the response
4355 if (pSirAddts->timeout)
4356 timeout = pSirAddts->timeout;
4357 else if (wlan_cfgGetInt(pMac, WNI_CFG_ADDTS_RSP_TIMEOUT, &timeout) != eSIR_SUCCESS)
4358 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004359 limLog(pMac, LOGP, FL("Unable to get Cfg param %d (Addts Rsp Timeout)"),
Jeff Johnson295189b2012-06-20 16:38:30 -07004360 WNI_CFG_ADDTS_RSP_TIMEOUT);
4361 return;
4362 }
4363
4364 timeout = SYS_MS_TO_TICKS(timeout);
4365 if (tx_timer_change(&pMac->lim.limTimers.gLimAddtsRspTimer, timeout, 0) != TX_SUCCESS)
4366 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004367 limLog(pMac, LOGP, FL("AddtsRsp timer change failed!"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004368 return;
4369 }
4370 pMac->lim.gLimAddtsRspTimerCount++;
4371 if (tx_timer_change_context(&pMac->lim.limTimers.gLimAddtsRspTimer,
4372 pMac->lim.gLimAddtsRspTimerCount) != TX_SUCCESS)
4373 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004374 limLog(pMac, LOGP, FL("AddtsRsp timer change failed!"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004375 return;
4376 }
Jeff Johnsone7245742012-09-05 17:12:55 -07004377 MTRACE(macTrace(pMac, TRACE_CODE_TIMER_ACTIVATE, psessionEntry->peSessionId, eLIM_ADDTS_RSP_TIMER));
Jeff Johnson295189b2012-06-20 16:38:30 -07004378
4379 //add the sessionId to the timer object
4380 pMac->lim.limTimers.gLimAddtsRspTimer.sessionId = sessionId;
4381 if (tx_timer_activate(&pMac->lim.limTimers.gLimAddtsRspTimer) != TX_SUCCESS)
4382 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004383 limLog(pMac, LOGP, FL("AddtsRsp timer activation failed!"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004384 return;
4385 }
4386 return;
4387}
4388
4389
4390static void
4391__limProcessSmeDeltsReq(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
4392{
4393 tSirMacAddr peerMacAddr;
4394 tANI_U8 ac;
4395 tSirMacTSInfo *pTsinfo;
4396 tpSirDeltsReq pDeltsReq = (tpSirDeltsReq) pMsgBuf;
4397 tpDphHashNode pStaDs = NULL;
4398 tpPESession psessionEntry;
4399 tANI_U8 sessionId;
4400 tANI_U32 status = eSIR_SUCCESS;
4401 tANI_U8 smesessionId;
4402 tANI_U16 smetransactionId;
4403
4404 limGetSessionInfo(pMac,(tANI_U8 *)pMsgBuf,&smesessionId,&smetransactionId);
4405
4406 if((psessionEntry = peFindSessionByBssid(pMac, pDeltsReq->bssId, &sessionId))== NULL)
4407 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004408 limLog(pMac, LOGE, "Session Does not exist for given bssId");
Jeff Johnson295189b2012-06-20 16:38:30 -07004409 status = eSIR_FAILURE;
4410 goto end;
4411 }
4412#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM //FEATURE_WLAN_DIAG_SUPPORT
4413 limDiagEventReport(pMac, WLAN_PE_DIAG_DELTS_REQ_EVENT, psessionEntry, 0, 0);
4414#endif //FEATURE_WLAN_DIAG_SUPPORT
4415
4416
4417 if (eSIR_SUCCESS != limValidateDeltsReq(pMac, pDeltsReq, peerMacAddr,psessionEntry))
4418 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004419 PELOGE(limLog(pMac, LOGE, FL("limValidateDeltsReq failed"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07004420 status = eSIR_FAILURE;
4421 limSendSmeDeltsRsp(pMac, pDeltsReq, eSIR_FAILURE,psessionEntry,smesessionId,smetransactionId);
4422 return;
4423 }
4424
Abhishek Singh3cbf6052014-12-15 16:46:42 +05304425 limLog(pMac, LOG1, FL("Sent DELTS request to station with "
4426 "assocId = %d MacAddr = "MAC_ADDRESS_STR),
4427 pDeltsReq->aid, MAC_ADDR_ARRAY(peerMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07004428
4429 limSendDeltsReqActionFrame(pMac, peerMacAddr, pDeltsReq->req.wmeTspecPresent, &pDeltsReq->req.tsinfo, &pDeltsReq->req.tspec,
4430 psessionEntry);
4431
4432 pTsinfo = pDeltsReq->req.wmeTspecPresent ? &pDeltsReq->req.tspec.tsinfo : &pDeltsReq->req.tsinfo;
4433
4434 /* We've successfully send DELTS frame to AP. Update the
4435 * dynamic UAPSD mask. The AC for this TSPEC to be deleted
4436 * is no longer trigger enabled or delivery enabled
4437 */
4438 limSetTspecUapsdMask(pMac, pTsinfo, CLEAR_UAPSD_MASK);
4439
4440 /* We're deleting the TSPEC, so this particular AC is no longer
4441 * admitted. PE needs to downgrade the EDCA
4442 * parameters(for the AC for which TS is being deleted) to the
4443 * next best AC for which ACM is not enabled, and send the
4444 * updated values to HAL.
4445 */
4446 ac = upToAc(pTsinfo->traffic.userPrio);
4447
4448 if(pTsinfo->traffic.direction == SIR_MAC_DIRECTION_UPLINK)
4449 {
4450 pMac->lim.gAcAdmitMask[SIR_MAC_DIRECTION_UPLINK] &= ~(1 << ac);
4451 }
4452 else if(pTsinfo->traffic.direction == SIR_MAC_DIRECTION_DNLINK)
4453 {
4454 pMac->lim.gAcAdmitMask[SIR_MAC_DIRECTION_DNLINK] &= ~(1 << ac);
4455 }
4456 else if(pTsinfo->traffic.direction == SIR_MAC_DIRECTION_BIDIR)
4457 {
4458 pMac->lim.gAcAdmitMask[SIR_MAC_DIRECTION_UPLINK] &= ~(1 << ac);
4459 pMac->lim.gAcAdmitMask[SIR_MAC_DIRECTION_DNLINK] &= ~(1 << ac);
4460 }
4461
4462 limSetActiveEdcaParams(pMac, psessionEntry->gLimEdcaParams, psessionEntry);
4463
4464 pStaDs = dphGetHashEntry(pMac, DPH_STA_HASH_INDEX_PEER, &psessionEntry->dph.dphHashTable);
4465 if (pStaDs != NULL)
4466 {
4467 if (pStaDs->aniPeer == eANI_BOOLEAN_TRUE)
4468 limSendEdcaParams(pMac, psessionEntry->gLimEdcaParamsActive, pStaDs->bssId, eANI_BOOLEAN_TRUE);
4469 else
4470 limSendEdcaParams(pMac, psessionEntry->gLimEdcaParamsActive, pStaDs->bssId, eANI_BOOLEAN_FALSE);
4471 status = eSIR_SUCCESS;
4472 }
4473 else
4474 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004475 limLog(pMac, LOGE, FL("Self entry missing in Hash Table "));
Jeff Johnson295189b2012-06-20 16:38:30 -07004476 status = eSIR_FAILURE;
4477 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004478#ifdef FEATURE_WLAN_ESE
4479#ifdef FEATURE_WLAN_ESE_UPLOAD
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004480 limSendSmeTsmIEInd(pMac, psessionEntry, 0, 0, 0);
4481#else
Jeff Johnson295189b2012-06-20 16:38:30 -07004482 limDeactivateAndChangeTimer(pMac,eLIM_TSM_TIMER);
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004483#endif /* FEATURE_WLAN_ESE_UPLOAD */
Jeff Johnson295189b2012-06-20 16:38:30 -07004484#endif
4485
4486 // send an sme response back
4487 end:
4488 limSendSmeDeltsRsp(pMac, pDeltsReq, eSIR_SUCCESS,psessionEntry,smesessionId,smetransactionId);
4489}
4490
4491
4492void
4493limProcessSmeAddtsRspTimeout(tpAniSirGlobal pMac, tANI_U32 param)
4494{
4495 //fetch the sessionEntry based on the sessionId
4496 tpPESession psessionEntry;
4497 if((psessionEntry = peFindSessionBySessionId(pMac, pMac->lim.limTimers.gLimAddtsRspTimer.sessionId))== NULL)
4498 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004499 limLog(pMac, LOGP,FL("Session Does not exist for given sessionID"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004500 return;
4501 }
4502
4503 if ( (psessionEntry->limSystemRole != eLIM_STA_ROLE) && (psessionEntry->limSystemRole != eLIM_BT_AMP_STA_ROLE) )
4504 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004505 limLog(pMac, LOGW, "AddtsRspTimeout in non-Sta role (%d)", psessionEntry->limSystemRole);
Jeff Johnson295189b2012-06-20 16:38:30 -07004506 pMac->lim.gLimAddtsSent = false;
4507 return;
4508 }
4509
4510 if (! pMac->lim.gLimAddtsSent)
4511 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004512 PELOGW(limLog(pMac, LOGW, "AddtsRspTimeout but no AddtsSent");)
Jeff Johnson295189b2012-06-20 16:38:30 -07004513 return;
4514 }
4515
4516 if (param != pMac->lim.gLimAddtsRspTimerCount)
4517 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004518 limLog(pMac, LOGE, FL("Invalid AddtsRsp Timer count %d (exp %d)"),
Jeff Johnson295189b2012-06-20 16:38:30 -07004519 param, pMac->lim.gLimAddtsRspTimerCount);
4520 return;
4521 }
4522
4523 // this a real response timeout
4524 pMac->lim.gLimAddtsSent = false;
4525 pMac->lim.gLimAddtsRspTimerCount++;
4526
4527 limSendSmeAddtsRsp(pMac, true, eSIR_SME_ADDTS_RSP_TIMEOUT, psessionEntry, pMac->lim.gLimAddtsReq.req.tspec,
4528 psessionEntry->smeSessionId, psessionEntry->transactionId);
4529}
4530
4531
4532/**
4533 * __limProcessSmeStatsRequest()
4534 *
4535 *FUNCTION:
4536 *
4537 *
4538 *NOTE:
4539 *
4540 * @param pMac Pointer to Global MAC structure
4541 * @param *pMsgBuf A pointer to the SME message buffer
4542 * @return None
4543 */
4544static void
4545__limProcessSmeStatsRequest(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
4546{
4547 tpAniGetStatsReq pStatsReq;
4548 tSirMsgQ msgQ;
4549 tpPESession psessionEntry;
4550 tANI_U8 sessionId;
4551
4552
4553 if(pMsgBuf == NULL)
4554 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004555 limLog(pMac, LOGE,FL("Buffer is Pointing to NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004556 return;
4557 }
4558
4559 pStatsReq = (tpAniGetStatsReq) pMsgBuf;
4560
4561 if((psessionEntry = peFindSessionByBssid(pMac,pStatsReq->bssId,&sessionId))== NULL)
4562 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004563 limLog(pMac, LOGE, FL("session does not exist for given bssId"));
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304564 vos_mem_free( pMsgBuf );
Leela Venkata Kiran Kumar Reddy Chiralad6c0fe22013-12-11 19:10:50 -08004565 pMsgBuf = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004566 return;
4567 }
4568
4569
4570
4571 switch(pStatsReq->msgType)
4572 {
4573 //Add Lim stats here. and send reqsponse.
4574
4575 //HAL maintained Stats.
4576 case eWNI_SME_STA_STAT_REQ:
4577 msgQ.type = WDA_STA_STAT_REQ;
4578 break;
4579 case eWNI_SME_AGGR_STAT_REQ:
4580 msgQ.type = WDA_AGGR_STAT_REQ;
4581 break;
4582 case eWNI_SME_GLOBAL_STAT_REQ:
4583 msgQ.type = WDA_GLOBAL_STAT_REQ;
4584 break;
4585 case eWNI_SME_STAT_SUMM_REQ:
4586 msgQ.type = WDA_STAT_SUMM_REQ;
4587 break;
4588 default: //Unknown request.
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004589 PELOGE(limLog(pMac, LOGE, "Unknown Statistics request");)
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304590 vos_mem_free( pMsgBuf );
Leela Venkata Kiran Kumar Reddy Chiralad6c0fe22013-12-11 19:10:50 -08004591 pMsgBuf = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004592 return;
4593 }
4594
Jeff Johnson295189b2012-06-20 16:38:30 -07004595 msgQ.reserved = 0;
4596 msgQ.bodyptr = pMsgBuf;
4597 msgQ.bodyval = 0;
Leela Venkata Kiran Kumar Reddy Chirala68a6abe2013-02-28 07:43:16 -08004598 if(NULL == psessionEntry)
4599 {
4600 MTRACE(macTraceMsgTx(pMac, NO_SESSION, msgQ.type));
4601 }
4602 else
4603 {
4604 MTRACE(macTraceMsgTx(pMac, psessionEntry->peSessionId, msgQ.type));
4605 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004606 if( eSIR_SUCCESS != (wdaPostCtrlMsg( pMac, &msgQ ))){
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004607 limLog(pMac, LOGP, "Unable to forward request");
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;
Jeff Johnson295189b2012-06-20 16:38:30 -07004610 return;
4611 }
4612
4613 return;
4614}
4615
4616
4617/**
4618 * __limProcessSmeGetStatisticsRequest()
4619 *
4620 *FUNCTION:
4621 *
4622 *
4623 *NOTE:
4624 *
4625 * @param pMac Pointer to Global MAC structure
4626 * @param *pMsgBuf A pointer to the SME message buffer
4627 * @return None
4628 */
4629static void
4630__limProcessSmeGetStatisticsRequest(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
4631{
4632 tpAniGetPEStatsReq pPEStatsReq;
4633 tSirMsgQ msgQ;
4634
4635 pPEStatsReq = (tpAniGetPEStatsReq) pMsgBuf;
4636
4637 //pPEStatsReq->msgType should be eWNI_SME_GET_STATISTICS_REQ
4638
4639 msgQ.type = WDA_GET_STATISTICS_REQ;
4640
Jeff Johnson295189b2012-06-20 16:38:30 -07004641 msgQ.reserved = 0;
4642 msgQ.bodyptr = pMsgBuf;
4643 msgQ.bodyval = 0;
Jeff Johnsone7245742012-09-05 17:12:55 -07004644 MTRACE(macTraceMsgTx(pMac, NO_SESSION, msgQ.type));
Jeff Johnson295189b2012-06-20 16:38:30 -07004645
4646 if( eSIR_SUCCESS != (wdaPostCtrlMsg( pMac, &msgQ ))){
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304647 vos_mem_free( pMsgBuf );
Leela Venkata Kiran Kumar Reddy Chiralad6c0fe22013-12-11 19:10:50 -08004648 pMsgBuf = NULL;
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004649 limLog(pMac, LOGP, "Unable to forward request");
Jeff Johnson295189b2012-06-20 16:38:30 -07004650 return;
4651 }
4652
4653 return;
4654}
4655
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004656#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004657/**
4658 *FUNCTION: __limProcessSmeGetTsmStatsRequest()
4659 *
4660 *NOTE:
4661 *
4662 * @param pMac Pointer to Global MAC structure
4663 * @param *pMsgBuf A pointer to the SME message buffer
4664 * @return None
4665 */
4666static void
4667__limProcessSmeGetTsmStatsRequest(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
4668{
4669 tSirMsgQ msgQ;
4670
4671 msgQ.type = WDA_TSM_STATS_REQ;
4672 msgQ.reserved = 0;
4673 msgQ.bodyptr = pMsgBuf;
4674 msgQ.bodyval = 0;
4675 MTRACE(macTraceMsgTx(pMac, NO_SESSION, msgQ.type));
4676
4677 if( eSIR_SUCCESS != (wdaPostCtrlMsg( pMac, &msgQ ))){
4678 vos_mem_free( pMsgBuf );
Leela Venkata Kiran Kumar Reddy Chiralad6c0fe22013-12-11 19:10:50 -08004679 pMsgBuf = NULL;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004680 limLog(pMac, LOGP, "Unable to forward request");
4681 return;
4682 }
4683}
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004684#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004685
4686
Jeff Johnson295189b2012-06-20 16:38:30 -07004687
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004688#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08004689/**
4690 * __limProcessSmeGetRoamRssiRequest()
4691 *
4692 *FUNCTION:
4693 *
4694 *
4695 *NOTE:
4696 *
4697 * @param pMac Pointer to Global MAC structure
4698 * @param *pMsgBuf A pointer to the SME message buffer
4699 * @return None
4700 */
4701static void
4702__limProcessSmeGetRoamRssiRequest(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
4703{
4704 tpAniGetRssiReq pPEGetRoamRssiReq = NULL;
4705 tSirMsgQ msgQ;
4706
4707 pPEGetRoamRssiReq = (tpAniGetRssiReq) pMsgBuf;
4708 msgQ.type = WDA_GET_ROAM_RSSI_REQ;
4709
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08004710 msgQ.reserved = 0;
4711 msgQ.bodyptr = pMsgBuf;
4712 msgQ.bodyval = 0;
4713 MTRACE(macTraceMsgTx(pMac, NO_SESSION, msgQ.type));
4714
4715 if( eSIR_SUCCESS != (wdaPostCtrlMsg( pMac, &msgQ ))){
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304716 vos_mem_free( pMsgBuf );
Leela Venkata Kiran Kumar Reddy Chiralad6c0fe22013-12-11 19:10:50 -08004717 pMsgBuf = NULL;
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004718 limLog(pMac, LOGP, "Unable to forward request");
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08004719 return;
4720 }
4721
4722 return;
4723}
4724#endif
4725
4726
Jeff Johnson295189b2012-06-20 16:38:30 -07004727static void
4728__limProcessSmeUpdateAPWPSIEs(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
4729{
4730 tpSirUpdateAPWPSIEsReq pUpdateAPWPSIEsReq;
4731 tpPESession psessionEntry;
4732 tANI_U8 sessionId; //PE sessionID
4733
4734 PELOG1(limLog(pMac, LOG1,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004735 FL("received UPDATE_APWPSIEs_REQ message")););
Jeff Johnson295189b2012-06-20 16:38:30 -07004736
4737 if(pMsgBuf == NULL)
4738 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004739 limLog(pMac, LOGE,FL("Buffer is Pointing to NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004740 return;
4741 }
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08004742
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304743 pUpdateAPWPSIEsReq = vos_mem_malloc(sizeof(tSirUpdateAPWPSIEsReq));
4744 if ( NULL == pUpdateAPWPSIEsReq )
Jeff Johnson295189b2012-06-20 16:38:30 -07004745 {
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304746 limLog(pMac, LOGP, FL("call to AllocateMemory failed for pUpdateAPWPSIEsReq"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004747 return;
4748 }
4749
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08004750 if ((limUpdateAPWPSIEsReqSerDes(pMac, pUpdateAPWPSIEsReq, (tANI_U8 *) pMsgBuf) == eSIR_FAILURE))
Jeff Johnson295189b2012-06-20 16:38:30 -07004751 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004752 limLog(pMac, LOGW, FL("received invalid SME_SETCONTEXT_REQ message"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004753 goto end;
4754 }
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08004755
Jeff Johnson295189b2012-06-20 16:38:30 -07004756 if((psessionEntry = peFindSessionByBssid(pMac, pUpdateAPWPSIEsReq->bssId, &sessionId)) == NULL)
4757 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004758 limLog(pMac, LOGW, FL("Session does not exist for given BSSID"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004759 goto end;
4760 }
4761
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304762 vos_mem_copy( &psessionEntry->APWPSIEs, &pUpdateAPWPSIEsReq->APWPSIEs, sizeof(tSirAPWPSIEs));
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08004763
Jeff Johnson295189b2012-06-20 16:38:30 -07004764 schSetFixedBeaconFields(pMac, psessionEntry);
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08004765 limSendBeaconInd(pMac, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07004766
4767end:
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304768 vos_mem_free( pUpdateAPWPSIEsReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07004769 return;
4770} /*** end __limProcessSmeUpdateAPWPSIEs(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf) ***/
4771
4772static void
4773__limProcessSmeHideSSID(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
4774{
4775 tpSirUpdateParams pUpdateParams;
4776 tpPESession psessionEntry;
4777
Abhishek Singh3cbf6052014-12-15 16:46:42 +05304778 limLog(pMac, LOG1,
4779 FL("received SME_HIDE_SSID message"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004780
4781 if(pMsgBuf == NULL)
4782 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004783 limLog(pMac, LOGE,FL("Buffer is Pointing to NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004784 return;
4785 }
4786
4787 pUpdateParams = (tpSirUpdateParams)pMsgBuf;
4788
4789 if((psessionEntry = peFindSessionBySessionId(pMac, pUpdateParams->sessionId)) == NULL)
4790 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004791 limLog(pMac, LOGW, "Session does not exist for given sessionId %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07004792 pUpdateParams->sessionId);
4793 return;
4794 }
4795
4796 /* Update the session entry */
4797 psessionEntry->ssidHidden = pUpdateParams->ssidHidden;
4798
4799 /* Update beacon */
4800 schSetFixedBeaconFields(pMac, psessionEntry);
4801 limSendBeaconInd(pMac, psessionEntry);
4802
4803 return;
4804} /*** end __limProcessSmeHideSSID(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf) ***/
4805
4806static void
4807__limProcessSmeSetWPARSNIEs(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
4808{
4809 tpSirUpdateAPWPARSNIEsReq pUpdateAPWPARSNIEsReq;
4810 tpPESession psessionEntry;
4811 tANI_U8 sessionId; //PE sessionID
4812
4813 if(pMsgBuf == NULL)
4814 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004815 limLog(pMac, LOGE,FL("Buffer is Pointing to NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004816 return;
4817 }
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304818
4819 pUpdateAPWPARSNIEsReq = vos_mem_malloc(sizeof(tSirUpdateAPWPSIEsReq));
4820 if ( NULL == pUpdateAPWPARSNIEsReq )
Jeff Johnson295189b2012-06-20 16:38:30 -07004821 {
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304822 limLog(pMac, LOGP, FL("call to AllocateMemory failed for pUpdateAPWPARSNIEsReq"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004823 return;
4824 }
4825
4826 if ((limUpdateAPWPARSNIEsReqSerDes(pMac, pUpdateAPWPARSNIEsReq, (tANI_U8 *) pMsgBuf) == eSIR_FAILURE))
4827 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004828 limLog(pMac, LOGW, FL("received invalid SME_SETCONTEXT_REQ message"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004829 goto end;
4830 }
4831
4832 if((psessionEntry = peFindSessionByBssid(pMac, pUpdateAPWPARSNIEsReq->bssId, &sessionId)) == NULL)
4833 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004834 limLog(pMac, LOGW, FL("Session does not exist for given BSSID"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004835 goto end;
4836 }
4837
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304838 vos_mem_copy(&psessionEntry->pLimStartBssReq->rsnIE,
4839 &pUpdateAPWPARSNIEsReq->APWPARSNIEs, sizeof(tSirRSNie));
Jeff Johnson295189b2012-06-20 16:38:30 -07004840
4841 limSetRSNieWPAiefromSmeStartBSSReqMessage(pMac, &psessionEntry->pLimStartBssReq->rsnIE, psessionEntry);
4842
4843 psessionEntry->pLimStartBssReq->privacy = 1;
4844 psessionEntry->privacy = 1;
4845
4846 schSetFixedBeaconFields(pMac, psessionEntry);
4847 limSendBeaconInd(pMac, psessionEntry);
4848
4849end:
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05304850 vos_mem_free(pUpdateAPWPARSNIEsReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07004851 return;
4852} /*** end __limProcessSmeSetWPARSNIEs(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf) ***/
4853
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08004854/*
4855Update the beacon Interval dynamically if beaconInterval is different in MCC
4856*/
4857static void
4858__limProcessSmeChangeBI(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
4859{
4860 tpSirChangeBIParams pChangeBIParams;
4861 tpPESession psessionEntry;
4862 tANI_U8 sessionId = 0;
4863 tUpdateBeaconParams beaconParams;
4864
4865 PELOG1(limLog(pMac, LOG1,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004866 FL("received Update Beacon Interval message")););
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08004867
4868 if(pMsgBuf == NULL)
4869 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004870 limLog(pMac, LOGE,FL("Buffer is Pointing to NULL"));
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08004871 return;
4872 }
4873
Kaushik, Sushantfb156732014-01-07 15:36:03 +05304874 vos_mem_zero(&beaconParams, sizeof(tUpdateBeaconParams));
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08004875 pChangeBIParams = (tpSirChangeBIParams)pMsgBuf;
4876
4877 if((psessionEntry = peFindSessionByBssid(pMac, pChangeBIParams->bssId, &sessionId)) == NULL)
4878 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07004879 limLog(pMac, LOGE, FL("Session does not exist for given BSSID"));
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08004880 return;
4881 }
4882
4883 /*Update sessionEntry Beacon Interval*/
4884 if(psessionEntry->beaconParams.beaconInterval !=
4885 pChangeBIParams->beaconInterval )
4886 {
4887 psessionEntry->beaconParams.beaconInterval = pChangeBIParams->beaconInterval;
4888 }
4889
4890 /*Update sch beaconInterval*/
4891 if(pMac->sch.schObject.gSchBeaconInterval !=
4892 pChangeBIParams->beaconInterval )
4893 {
4894 pMac->sch.schObject.gSchBeaconInterval = pChangeBIParams->beaconInterval;
4895
4896 PELOG1(limLog(pMac, LOG1,
4897 FL("LIM send update BeaconInterval Indication : %d"),pChangeBIParams->beaconInterval););
4898
4899 /* Update beacon */
4900 schSetFixedBeaconFields(pMac, psessionEntry);
4901
Sunil Ravib96f7b52013-05-22 21:40:05 -07004902 beaconParams.bssIdx = psessionEntry->bssIdx;
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08004903 //Set change in beacon Interval
4904 beaconParams.beaconInterval = pChangeBIParams->beaconInterval;
Jeff Johnson312557b2013-04-03 16:27:48 -07004905 beaconParams.paramChangeBitmap = PARAM_BCN_INTERVAL_CHANGED;
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08004906 limSendBeaconParams(pMac, &beaconParams, psessionEntry);
4907 }
4908
4909 return;
4910} /*** end __limProcessSmeChangeBI(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf) ***/
4911
Hardik Kantilal Patel62a3a762014-11-21 12:55:57 +05304912/** -------------------------------------------------------------
4913\fn
4914\brief handles indication message from HDD to update HT mode
4915\param tpAniSirGlobal pMac
4916\param tANI_U32 pMsgBuf
4917\return None
4918-------------------------------------------------------------*/
4919#ifdef WLAN_FEATURE_AP_HT40_24G
4920static void __limProcessSmeSetHT2040Mode(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
4921{
4922 tpSirSetHT2040Mode pSetHT2040Mode;
4923 tpPESession psessionEntry;
4924 tANI_U8 sessionId = 0;
4925 tUpdateVHTOpMode *pHtOpMode = NULL;
4926 vos_msg_t msg;
Jeff Johnson295189b2012-06-20 16:38:30 -07004927
Hardik Kantilal Patel62a3a762014-11-21 12:55:57 +05304928 PELOG1(limLog(pMac, LOGRW,
4929 FL("received Set HT 20/40 mode message")););
4930
4931 if(pMsgBuf == NULL)
4932 {
4933 limLog(pMac, LOGE,FL("Buffer is Pointing to NULL"));
4934 return;
4935 }
4936
4937 pSetHT2040Mode = (tpSirSetHT2040Mode)pMsgBuf;
4938
4939 if((psessionEntry = peFindSessionByBssid(pMac, pSetHT2040Mode->bssId,
4940 &sessionId)) == NULL)
4941 {
4942 limLog(pMac, LOGE, FL("Session does not exist for given BSSID "));
4943 limPrintMacAddr(pMac, pSetHT2040Mode->bssId, LOGE);
4944 return;
4945 }
4946
4947 limLog(pMac, LOGW, FL("Update session entry for cbMod=%d"),
4948 pSetHT2040Mode->cbMode);
4949
4950 /*Update sessionEntry HT related fields*/
4951 switch(pSetHT2040Mode->cbMode)
4952 {
4953 case PHY_SINGLE_CHANNEL_CENTERED:
4954 psessionEntry->htSecondaryChannelOffset = PHY_SINGLE_CHANNEL_CENTERED;
4955 psessionEntry->htRecommendedTxWidthSet = 0;
4956 break;
4957 case PHY_DOUBLE_CHANNEL_LOW_PRIMARY:
4958 psessionEntry->htSecondaryChannelOffset =
4959 PHY_DOUBLE_CHANNEL_LOW_PRIMARY;
4960 psessionEntry->htRecommendedTxWidthSet = 1;
4961 break;
4962 case PHY_DOUBLE_CHANNEL_HIGH_PRIMARY:
4963 psessionEntry->htSecondaryChannelOffset =
4964 PHY_DOUBLE_CHANNEL_HIGH_PRIMARY;
4965 psessionEntry->htRecommendedTxWidthSet = 1;
4966 break;
4967 default:
4968 limLog(pMac, LOGE,FL("Invalid cbMode"));
4969 return;
4970 }
4971
4972 limLog(pMac, LOGW, FL("Channel Bonding mode : %d"
4973 " htSecondaryChannelOffset: %d"
4974 " htRecommendedTxWidthSet :%d"),
4975 pSetHT2040Mode->cbMode,
4976 psessionEntry->htSecondaryChannelOffset,
4977 psessionEntry->htRecommendedTxWidthSet);
4978
4979 limLog(pMac, LOGW, FL("Update Beacon IEs"));
4980
4981 /* Update beacon */
4982 schSetFixedBeaconFields(pMac, psessionEntry);
4983 limSendBeaconInd(pMac, psessionEntry);
4984
4985 /* Update OP Mode */
4986 pHtOpMode = vos_mem_malloc(sizeof(tUpdateVHTOpMode));
4987 if ( NULL == pHtOpMode )
4988 {
4989 limLog(pMac, LOGE,
4990 FL("Not able to allocate memory for setting OP mode"));
4991 return;
4992 }
4993
4994 pHtOpMode->opMode = (psessionEntry->htSecondaryChannelOffset ==
4995 PHY_SINGLE_CHANNEL_CENTERED)?
4996 eHT_CHANNEL_WIDTH_20MHZ:eHT_CHANNEL_WIDTH_40MHZ;
4997
4998 /* Pass Self STA ID to FW. Based on Self STA ID FW will update the
4999 * operating mode for all connected STA.
5000 */
5001
5002 pHtOpMode->staId = psessionEntry->staId;
5003
5004 msg.type = WDA_UPDATE_OP_MODE;
5005 msg.reserved = 0;
5006 msg.bodyptr = pHtOpMode;
5007
5008 if (!VOS_IS_STATUS_SUCCESS(
5009 vos_mq_post_message(VOS_MODULE_ID_WDA, &msg)))
5010 {
5011 limLog(pMac, LOGE,
5012 FL("Not able to post WDA_UPDATE_OP_MODE message to WDA"));
5013 vos_mem_free(pHtOpMode);
5014 return;
5015 }
5016
5017 limLog(pMac, LOGW,
5018 FL("Notifed FW about OP mode: %d for staId=%d"),
5019 pHtOpMode->opMode, pHtOpMode->staId);
5020
5021 return;
5022}
5023#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005024
5025/** -------------------------------------------------------------
5026\fn limProcessSmeDelBaPeerInd
5027\brief handles indication message from HDD to send delete BA request
5028\param tpAniSirGlobal pMac
5029\param tANI_U32 pMsgBuf
5030\return None
5031-------------------------------------------------------------*/
5032void
5033limProcessSmeDelBaPeerInd(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
5034{
5035 tANI_U16 assocId =0;
5036 tpSmeDelBAPeerInd pSmeDelBAPeerInd = (tpSmeDelBAPeerInd)pMsgBuf;
5037 tpDphHashNode pSta;
5038 tpPESession psessionEntry;
5039 tANI_U8 sessionId;
5040
5041
5042
5043 if(NULL == pSmeDelBAPeerInd)
5044 return;
5045
5046 if ((psessionEntry = peFindSessionByBssid(pMac,pSmeDelBAPeerInd->bssId,&sessionId))==NULL)
5047 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005048 limLog(pMac, LOGE,FL("session does not exist for given bssId"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005049 return;
5050 }
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005051 limLog(pMac, LOGW, FL("called with staId = %d, tid = %d, baDirection = %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07005052 pSmeDelBAPeerInd->staIdx, pSmeDelBAPeerInd->baTID, pSmeDelBAPeerInd->baDirection);
5053
5054 pSta = dphLookupAssocId(pMac, pSmeDelBAPeerInd->staIdx, &assocId, &psessionEntry->dph.dphHashTable);
5055 if( eSIR_SUCCESS != limPostMlmDelBAReq( pMac,
5056 pSta,
5057 pSmeDelBAPeerInd->baDirection,
5058 pSmeDelBAPeerInd->baTID,
5059 eSIR_MAC_UNSPEC_FAILURE_REASON,psessionEntry))
5060 {
5061 limLog( pMac, LOGW,
5062 FL( "Failed to post LIM_MLM_DELBA_REQ to " ));
5063 if (pSta)
5064 limPrintMacAddr(pMac, pSta->staAddr, LOGW);
5065 }
5066}
5067
5068// --------------------------------------------------------------------
5069/**
5070 * __limProcessReportMessage
5071 *
5072 * FUNCTION: Processes the next received Radio Resource Management message
5073 *
5074 * LOGIC:
5075 *
5076 * ASSUMPTIONS:
5077 *
5078 * NOTE:
5079 *
5080 * @param None
5081 * @return None
5082 */
5083
5084void __limProcessReportMessage(tpAniSirGlobal pMac, tpSirMsgQ pMsg)
5085{
5086#ifdef WLAN_FEATURE_VOWIFI
5087 switch (pMsg->type)
5088 {
5089 case eWNI_SME_NEIGHBOR_REPORT_REQ_IND:
5090 rrmProcessNeighborReportReq( pMac, pMsg->bodyptr );
5091 break;
5092 case eWNI_SME_BEACON_REPORT_RESP_XMIT_IND:
5093 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005094#if defined(FEATURE_WLAN_ESE) && !defined(FEATURE_WLAN_ESE_UPLOAD)
Jeff Johnson295189b2012-06-20 16:38:30 -07005095 tpSirBeaconReportXmitInd pBcnReport=NULL;
5096 tpPESession psessionEntry=NULL;
5097 tANI_U8 sessionId;
Padma, Santhosh Kumar20d45a12016-04-05 13:11:00 +05305098 tpEsePEContext pEseContext = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005099
5100 if(pMsg->bodyptr == NULL)
5101 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005102 limLog(pMac, LOGE,FL("Buffer is Pointing to NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005103 return;
5104 }
5105 pBcnReport = (tpSirBeaconReportXmitInd )pMsg->bodyptr;
5106 if((psessionEntry = peFindSessionByBssid(pMac, pBcnReport->bssId,&sessionId))== NULL)
5107 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005108 limLog(pMac, LOGE, "Session Does not exist for given bssId");
Jeff Johnson295189b2012-06-20 16:38:30 -07005109 return;
5110 }
Padma, Santhosh Kumar20d45a12016-04-05 13:11:00 +05305111
5112 pEseContext = &psessionEntry->eseContext;
5113
5114 if (psessionEntry->isESEconnection && pEseContext->curMeasReq.isValid)
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005115 eseProcessBeaconReportXmit( pMac, pMsg->bodyptr);
Jeff Johnson295189b2012-06-20 16:38:30 -07005116 else
5117#endif
5118 rrmProcessBeaconReportXmit( pMac, pMsg->bodyptr );
5119 }
5120 break;
5121 }
5122#endif
5123}
5124
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005125#if defined(FEATURE_WLAN_ESE) || defined(WLAN_FEATURE_VOWIFI)
Jeff Johnson295189b2012-06-20 16:38:30 -07005126// --------------------------------------------------------------------
5127/**
5128 * limSendSetMaxTxPowerReq
5129 *
5130 * FUNCTION: Send SIR_HAL_SET_MAX_TX_POWER_REQ message to change the max tx power.
5131 *
5132 * LOGIC:
5133 *
5134 * ASSUMPTIONS:
5135 *
5136 * NOTE:
5137 *
5138 * @param txPower txPower to be set.
5139 * @param pSessionEntry session entry.
5140 * @return None
5141 */
5142tSirRetStatus
5143limSendSetMaxTxPowerReq ( tpAniSirGlobal pMac, tPowerdBm txPower, tpPESession pSessionEntry )
5144{
5145 tpMaxTxPowerParams pMaxTxParams = NULL;
5146 tSirRetStatus retCode = eSIR_SUCCESS;
5147 tSirMsgQ msgQ;
5148
5149 if( pSessionEntry == NULL )
5150 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005151 PELOGE(limLog(pMac, LOGE, "%s:%d: Inavalid parameters", __func__, __LINE__ );)
Jeff Johnson295189b2012-06-20 16:38:30 -07005152 return eSIR_FAILURE;
5153 }
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05305154
5155 pMaxTxParams = vos_mem_malloc(sizeof(tMaxTxPowerParams));
5156 if ( NULL == pMaxTxParams )
Jeff Johnson295189b2012-06-20 16:38:30 -07005157 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005158 limLog( pMac, LOGP, "%s:%d:Unable to allocate memory for pMaxTxParams ", __func__, __LINE__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005159 return eSIR_MEM_ALLOC_FAILED;
5160
5161 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005162#if defined(WLAN_VOWIFI_DEBUG) || defined(FEATURE_WLAN_ESE)
Abhishek Singh3cbf6052014-12-15 16:46:42 +05305163 limLog( pMac, LOG1,
5164 FL(" Allocated memory for pMaxTxParams, which will be freed in other module"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005165#endif
Kiran Kumar Lokerea4db3dc2013-03-25 18:05:24 -07005166 if( pMaxTxParams == NULL )
5167 {
Abhishek Singh3cbf6052014-12-15 16:46:42 +05305168 limLog( pMac, LOGE, FL("pMaxTxParams is NULL"));
Kiran Kumar Lokerea4db3dc2013-03-25 18:05:24 -07005169 return eSIR_FAILURE;
5170 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005171 pMaxTxParams->power = txPower;
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05305172 vos_mem_copy( pMaxTxParams->bssId, pSessionEntry->bssId, sizeof(tSirMacAddr) );
5173 vos_mem_copy( pMaxTxParams->selfStaMacAddr, pSessionEntry->selfMacAddr, sizeof(tSirMacAddr) );
Jeff Johnson295189b2012-06-20 16:38:30 -07005174
Jeff Johnson68ce9c42013-04-08 10:33:28 -07005175 msgQ.type = WDA_SET_MAX_TX_POWER_REQ;
5176 msgQ.bodyptr = pMaxTxParams;
5177 msgQ.bodyval = 0;
Abhishek Singh3cbf6052014-12-15 16:46:42 +05305178 limLog(pMac, LOG1, FL("Posting WDA_SET_MAX_TX_POWER_REQ to WDA"));
Jeff Johnson68ce9c42013-04-08 10:33:28 -07005179 MTRACE(macTraceMsgTx(pMac, pSessionEntry->peSessionId, msgQ.type));
5180 retCode = wdaPostCtrlMsg(pMac, &msgQ);
5181 if (eSIR_SUCCESS != retCode)
5182 {
5183 PELOGE(limLog(pMac, LOGE, FL("wdaPostCtrlMsg() failed"));)
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05305184 vos_mem_free(pMaxTxParams);
Jeff Johnson68ce9c42013-04-08 10:33:28 -07005185 }
5186 return retCode;
Jeff Johnson295189b2012-06-20 16:38:30 -07005187}
5188#endif
5189
5190/**
5191 * __limProcessSmeAddStaSelfReq()
5192 *
5193 *FUNCTION:
5194 * This function is called to process SME_ADD_STA_SELF_REQ message
5195 * from SME. It sends a SIR_HAL_ADD_STA_SELF_REQ message to HAL.
5196 *
5197 *LOGIC:
5198 *
5199 *ASSUMPTIONS:
5200 *
5201 *NOTE:
5202 *
5203 * @param pMac Pointer to Global MAC structure
5204 * @param *pMsgBuf A pointer to the SME message buffer
5205 * @return None
5206 */
5207
5208static void
5209__limProcessSmeAddStaSelfReq(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
5210{
5211 tSirMsgQ msg;
5212 tpAddStaSelfParams pAddStaSelfParams;
5213 tpSirSmeAddStaSelfReq pSmeReq = (tpSirSmeAddStaSelfReq) pMsgBuf;
5214
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05305215 pAddStaSelfParams = vos_mem_malloc(sizeof(tAddStaSelfParams));
5216 if ( NULL == pAddStaSelfParams )
Jeff Johnson295189b2012-06-20 16:38:30 -07005217 {
5218 limLog( pMac, LOGP, FL("Unable to allocate memory for tAddSelfStaParams") );
5219 return;
5220 }
5221
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05305222 vos_mem_copy( pAddStaSelfParams->selfMacAddr, pSmeReq->selfMacAddr, sizeof(tSirMacAddr) );
Kiran Kumar Lokeread7dbc82013-10-07 20:12:50 -07005223 pAddStaSelfParams->currDeviceMode = pSmeReq->currDeviceMode;
Jeff Johnson295189b2012-06-20 16:38:30 -07005224 msg.type = SIR_HAL_ADD_STA_SELF_REQ;
5225 msg.reserved = 0;
5226 msg.bodyptr = pAddStaSelfParams;
5227 msg.bodyval = 0;
5228
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005229 PELOGW(limLog(pMac, LOG1, FL("sending SIR_HAL_ADD_STA_SELF_REQ msg to HAL"));)
Jeff Johnsone7245742012-09-05 17:12:55 -07005230 MTRACE(macTraceMsgTx(pMac, NO_SESSION, msg.type));
Jeff Johnson295189b2012-06-20 16:38:30 -07005231
5232 if(eSIR_SUCCESS != wdaPostCtrlMsg(pMac, &msg))
5233 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005234 limLog(pMac, LOGP, FL("wdaPostCtrlMsg failed"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005235 }
5236 return;
5237} /*** end __limProcessAddStaSelfReq() ***/
5238
5239
5240/**
5241 * __limProcessSmeDelStaSelfReq()
5242 *
5243 *FUNCTION:
5244 * This function is called to process SME_DEL_STA_SELF_REQ message
5245 * from SME. It sends a SIR_HAL_DEL_STA_SELF_REQ message to HAL.
5246 *
5247 *LOGIC:
5248 *
5249 *ASSUMPTIONS:
5250 *
5251 *NOTE:
5252 *
5253 * @param pMac Pointer to Global MAC structure
5254 * @param *pMsgBuf A pointer to the SME message buffer
5255 * @return None
5256 */
5257
5258static void
5259__limProcessSmeDelStaSelfReq(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
5260{
5261 tSirMsgQ msg;
5262 tpDelStaSelfParams pDelStaSelfParams;
5263 tpSirSmeDelStaSelfReq pSmeReq = (tpSirSmeDelStaSelfReq) pMsgBuf;
5264
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05305265 pDelStaSelfParams = vos_mem_malloc(sizeof( tDelStaSelfParams));
5266 if ( NULL == pDelStaSelfParams )
Jeff Johnson295189b2012-06-20 16:38:30 -07005267 {
5268 limLog( pMac, LOGP, FL("Unable to allocate memory for tDelStaSelfParams") );
5269 return;
5270 }
5271
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05305272 vos_mem_copy( pDelStaSelfParams->selfMacAddr, pSmeReq->selfMacAddr, sizeof(tSirMacAddr) );
Jeff Johnson295189b2012-06-20 16:38:30 -07005273
5274 msg.type = SIR_HAL_DEL_STA_SELF_REQ;
5275 msg.reserved = 0;
5276 msg.bodyptr = pDelStaSelfParams;
5277 msg.bodyval = 0;
5278
Mukul Sharmacaf4aca2015-04-17 20:01:40 +05305279 PELOGW(limLog(pMac, LOG1, FL("sending SIR_HAL_DEL_STA_SELF_REQ msg to HAL"));)
Jeff Johnsone7245742012-09-05 17:12:55 -07005280 MTRACE(macTraceMsgTx(pMac, NO_SESSION, msg.type));
Jeff Johnson295189b2012-06-20 16:38:30 -07005281
5282 if(eSIR_SUCCESS != wdaPostCtrlMsg(pMac, &msg))
5283 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005284 limLog(pMac, LOGP, FL("wdaPostCtrlMsg failed"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005285 }
5286 return;
5287} /*** end __limProcessSmeDelStaSelfReq() ***/
5288
5289
Jeff Johnson295189b2012-06-20 16:38:30 -07005290/**
5291 * __limProcessSmeRegisterMgmtFrameReq()
5292 *
5293 *FUNCTION:
5294 * This function is called to process eWNI_SME_REGISTER_MGMT_FRAME_REQ message
5295 * from SME. It Register this information within PE.
5296 *
5297 *LOGIC:
5298 *
5299 *ASSUMPTIONS:
5300 *
5301 *NOTE:
5302 *
5303 * @param pMac Pointer to Global MAC structure
5304 * @param *pMsgBuf A pointer to the SME message buffer
5305 * @return None
5306 */
5307static void
5308__limProcessSmeRegisterMgmtFrameReq(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
5309{
5310 VOS_STATUS vosStatus;
5311 tpSirRegisterMgmtFrame pSmeReq = (tpSirRegisterMgmtFrame)pMsgBuf;
5312 tpLimMgmtFrameRegistration pLimMgmtRegistration = NULL, pNext = NULL;
Jeff Johnsond13512a2012-07-17 11:42:19 -07005313 tANI_BOOLEAN match = VOS_FALSE;
Abhishek Singh3cbf6052014-12-15 16:46:42 +05305314 limLog(pMac, LOG1,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005315 FL("registerFrame %d, frameType %d, matchLen %d"),
Abhishek Singh3cbf6052014-12-15 16:46:42 +05305316 pSmeReq->registerFrame, pSmeReq->frameType, pSmeReq->matchLen);
Jeff Johnson295189b2012-06-20 16:38:30 -07005317
Jeff Johnsond13512a2012-07-17 11:42:19 -07005318 /* First check whether entry exists already*/
5319
5320 vos_list_peek_front(&pMac->lim.gLimMgmtFrameRegistratinQueue,
5321 (vos_list_node_t**)&pLimMgmtRegistration);
5322
5323 while(pLimMgmtRegistration != NULL)
5324 {
5325 if (pLimMgmtRegistration->frameType == pSmeReq->frameType)
5326 {
5327 if(pSmeReq->matchLen)
5328 {
5329 if (pLimMgmtRegistration->matchLen == pSmeReq->matchLen)
5330 {
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05305331 if (vos_mem_compare( pLimMgmtRegistration->matchData,
Jeff Johnsond13512a2012-07-17 11:42:19 -07005332 pSmeReq->matchData, pLimMgmtRegistration->matchLen))
5333 {
Madan Mohan Koyyalamudic537df22012-10-22 15:07:08 -07005334 /* found match! */
5335 match = VOS_TRUE;
5336 break;
Jeff Johnsond13512a2012-07-17 11:42:19 -07005337 }
5338 }
5339 }
5340 else
5341 {
Madan Mohan Koyyalamudic537df22012-10-22 15:07:08 -07005342 /* found match! */
Jeff Johnsond13512a2012-07-17 11:42:19 -07005343 match = VOS_TRUE;
5344 break;
5345 }
5346 }
5347 vosStatus = vos_list_peek_next (
5348 &pMac->lim.gLimMgmtFrameRegistratinQueue,
5349 (vos_list_node_t*) pLimMgmtRegistration,
5350 (vos_list_node_t**) &pNext );
5351
5352 pLimMgmtRegistration = pNext;
5353 pNext = NULL;
5354
5355 }
5356
5357 if (match)
5358 {
5359 vos_list_remove_node(&pMac->lim.gLimMgmtFrameRegistratinQueue,
5360 (vos_list_node_t*)pLimMgmtRegistration);
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05305361 vos_mem_free(pLimMgmtRegistration);
Jeff Johnsond13512a2012-07-17 11:42:19 -07005362 }
5363
Jeff Johnson295189b2012-06-20 16:38:30 -07005364 if(pSmeReq->registerFrame)
5365 {
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05305366 pLimMgmtRegistration = vos_mem_malloc(sizeof(tLimMgmtFrameRegistration) + pSmeReq->matchLen);
5367 if ( pLimMgmtRegistration != NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -07005368 {
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05305369 vos_mem_set((void*)pLimMgmtRegistration,
5370 sizeof(tLimMgmtFrameRegistration) + pSmeReq->matchLen, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005371 pLimMgmtRegistration->frameType = pSmeReq->frameType;
5372 pLimMgmtRegistration->matchLen = pSmeReq->matchLen;
5373 pLimMgmtRegistration->sessionId = pSmeReq->sessionId;
5374 if(pSmeReq->matchLen)
5375 {
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05305376 vos_mem_copy(pLimMgmtRegistration->matchData,
5377 pSmeReq->matchData, pSmeReq->matchLen);
Jeff Johnson295189b2012-06-20 16:38:30 -07005378 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005379 vos_list_insert_front(&pMac->lim.gLimMgmtFrameRegistratinQueue,
5380 &pLimMgmtRegistration->node);
5381 }
5382 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005383
5384 return;
5385} /*** end __limProcessSmeRegisterMgmtFrameReq() ***/
Viral Modid86bde22012-12-10 13:09:21 -08005386
5387static tANI_BOOLEAN
Viral Modid440e682013-03-06 02:25:31 -08005388__limInsertSingleShotNOAForScan(tpAniSirGlobal pMac, tANI_U32 noaDuration)
Viral Modid86bde22012-12-10 13:09:21 -08005389{
5390 tpP2pPsParams pMsgNoA;
5391 tSirMsgQ msg;
Vinay Malekal62757362012-12-17 12:15:51 -08005392
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05305393 pMsgNoA = vos_mem_malloc(sizeof( tP2pPsConfig ));
5394 if ( NULL == pMsgNoA )
Viral Modid86bde22012-12-10 13:09:21 -08005395 {
5396 limLog( pMac, LOGP,
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005397 FL( "Unable to allocate memory during NoA Update" ));
Viral Modid440e682013-03-06 02:25:31 -08005398 goto error;
Viral Modid86bde22012-12-10 13:09:21 -08005399 }
5400
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05305401 vos_mem_set((tANI_U8 *)pMsgNoA, sizeof(tP2pPsConfig), 0);
Viral Modid86bde22012-12-10 13:09:21 -08005402 /* Below params used for opp PS/periodic NOA and are don't care in this case - so initialized to 0 */
5403 pMsgNoA->opp_ps = 0;
5404 pMsgNoA->ctWindow = 0;
5405 pMsgNoA->duration = 0;
5406 pMsgNoA->interval = 0;
5407 pMsgNoA->count = 0;
Vinay Malekal62757362012-12-17 12:15:51 -08005408
Vinay Malekal62757362012-12-17 12:15:51 -08005409 /* Below params used for Single Shot NOA - so assign proper values */
5410 pMsgNoA->psSelection = P2P_SINGLE_NOA;
Viral Modid440e682013-03-06 02:25:31 -08005411 pMsgNoA->single_noa_duration = noaDuration;
Gopichand Nakkala096a1052012-12-21 07:05:34 -08005412
Viral Modid86bde22012-12-10 13:09:21 -08005413 /* Start Insert NOA timer
5414 * 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 -08005415 * or any other failure or reason, we still need to process the deferred SME req. The insert NOA
5416 * timer of 500 ms will ensure the stored SME req always gets processed
Viral Modid86bde22012-12-10 13:09:21 -08005417 */
5418 if (tx_timer_activate(&pMac->lim.limTimers.gLimP2pSingleShotNoaInsertTimer)
5419 == TX_TIMER_ERROR)
5420 {
5421 /// Could not activate Insert NOA timer.
5422 // Log error
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005423 limLog(pMac, LOGP, FL("could not activate Insert Single Shot NOA during scan timer"));
Viral Modid86bde22012-12-10 13:09:21 -08005424
5425 // send the scan response back with status failure and do not even call insert NOA
5426 limSendSmeScanRsp(pMac, sizeof(tSirSmeScanRsp), eSIR_SME_SCAN_FAILED, pMac->lim.gSmeSessionId, pMac->lim.gTransactionId);
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05305427 vos_mem_free(pMsgNoA);
Viral Modid440e682013-03-06 02:25:31 -08005428 goto error;
Viral Modid86bde22012-12-10 13:09:21 -08005429 }
5430
Viral Modid440e682013-03-06 02:25:31 -08005431 MTRACE(macTrace(pMac, TRACE_CODE_TIMER_ACTIVATE, NO_SESSION, eLIM_INSERT_SINGLESHOT_NOA_TIMER));
5432
Viral Modid86bde22012-12-10 13:09:21 -08005433 msg.type = WDA_SET_P2P_GO_NOA_REQ;
5434 msg.reserved = 0;
5435 msg.bodyptr = pMsgNoA;
5436 msg.bodyval = 0;
5437
5438 if(eSIR_SUCCESS != wdaPostCtrlMsg(pMac, &msg))
5439 {
5440 /* 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 -07005441 limLog(pMac, LOGP, FL("wdaPost Msg failed"));
Viral Modid440e682013-03-06 02:25:31 -08005442 /* Deactivate the NOA timer in failure case */
5443 limDeactivateAndChangeTimer(pMac, eLIM_INSERT_SINGLESHOT_NOA_TIMER);
5444 goto error;
Viral Modid86bde22012-12-10 13:09:21 -08005445 }
Viral Modid440e682013-03-06 02:25:31 -08005446 return FALSE;
Viral Modid86bde22012-12-10 13:09:21 -08005447
Viral Modid440e682013-03-06 02:25:31 -08005448error:
5449 /* In any of the failure cases, just go ahead with the processing of registered deferred SME request without
5450 * worrying about the NOA
5451 */
5452 limProcessRegdDefdSmeReqAfterNOAStart(pMac);
5453 // msg buffer is consumed and freed in above function so return FALSE
Viral Modid86bde22012-12-10 13:09:21 -08005454 return FALSE;
5455
5456}
5457
Viral Modid440e682013-03-06 02:25:31 -08005458static void __limRegisterDeferredSmeReqForNOAStart(tpAniSirGlobal pMac, tANI_U16 msgType, tANI_U32 *pMsgBuf)
5459{
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005460 limLog(pMac, LOG1, FL("Reg msgType %d"), msgType) ;
Viral Modid440e682013-03-06 02:25:31 -08005461 pMac->lim.gDeferMsgTypeForNOA = msgType;
5462 pMac->lim.gpDefdSmeMsgForNOA = pMsgBuf;
5463}
5464
5465static void __limDeregisterDeferredSmeReqAfterNOAStart(tpAniSirGlobal pMac)
5466{
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005467 limLog(pMac, LOG1, FL("Dereg msgType %d"), pMac->lim.gDeferMsgTypeForNOA) ;
Viral Modid440e682013-03-06 02:25:31 -08005468 pMac->lim.gDeferMsgTypeForNOA = 0;
5469 if (pMac->lim.gpDefdSmeMsgForNOA != NULL)
5470 {
5471 /* __limProcessSmeScanReq consumed the buffer. We can free it. */
Madan Mohan Koyyalamudi9e8ce1f2013-07-11 10:40:43 +05305472 vos_mem_free(pMac->lim.gpDefdSmeMsgForNOA);
Viral Modid440e682013-03-06 02:25:31 -08005473 pMac->lim.gpDefdSmeMsgForNOA = NULL;
5474 }
5475}
5476
5477static
Ganesh Kondabattini16930072014-08-22 16:02:34 +05305478tANI_U32 limCalculateNOADuration(tpAniSirGlobal pMac, tANI_U16 msgType,
5479 tANI_U32 *pMsgBuf, tANI_BOOLEAN isPassiveScan)
Viral Modid440e682013-03-06 02:25:31 -08005480{
5481 tANI_U32 noaDuration = 0;
5482
5483 switch (msgType)
5484 {
5485 case eWNI_SME_SCAN_REQ:
5486 {
5487 tANI_U32 val;
5488 tANI_U8 i;
5489 tpSirSmeScanReq pScanReq = (tpSirSmeScanReq) pMsgBuf;
5490 if (wlan_cfgGetInt(pMac, WNI_CFG_PASSIVE_MAXIMUM_CHANNEL_TIME, &val) != eSIR_SUCCESS)
5491 {
5492 /*
5493 * Could not get max channel value
5494 * from CFG. Log error.
5495 */
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005496 limLog(pMac, LOGP, FL("could not retrieve passive max channel value"));
Viral Modid440e682013-03-06 02:25:31 -08005497
5498 /* use a default value of 110ms */
5499 val = DEFAULT_PASSIVE_MAX_CHANNEL_TIME;
5500 }
5501
5502 for (i = 0; i < pScanReq->channelList.numChannels; i++) {
5503 tANI_U8 channelNum = pScanReq->channelList.channelNumber[i];
5504
Ganesh Kondabattini8f6e3b32014-08-25 16:07:54 +05305505 if (pMac->miracast_mode) {
5506 noaDuration += DEFAULT_MIN_CHAN_TIME_DURING_MIRACAST +
5507 DEFAULT_MAX_CHAN_TIME_DURING_MIRACAST;
5508 } else if (isPassiveScan || !limActiveScanAllowed(pMac, channelNum)) {
Viral Modid440e682013-03-06 02:25:31 -08005509 /* using the value from WNI_CFG_PASSIVE_MINIMUM_CHANNEL_TIME as is done in
5510 * void limContinuePostChannelScan(tpAniSirGlobal pMac)
5511 */
5512 noaDuration += val;
Ganesh Kondabattini16930072014-08-22 16:02:34 +05305513 } else {
5514 /* Use min + max channel time to calculate the total duration of scan */
5515 noaDuration += pScanReq->minChannelTime + pScanReq->maxChannelTime;
Viral Modid440e682013-03-06 02:25:31 -08005516 }
5517 }
5518
5519 /* Adding an overhead of 20ms to account for the scan messaging delays */
5520 noaDuration += SCAN_MESSAGING_OVERHEAD;
5521 noaDuration *= CONV_MS_TO_US;
5522
5523 break;
5524 }
5525
5526 case eWNI_SME_OEM_DATA_REQ:
5527 noaDuration = OEM_DATA_NOA_DURATION*CONV_MS_TO_US; // use 60 msec as default
5528 break;
5529
5530 case eWNI_SME_REMAIN_ON_CHANNEL_REQ:
5531 {
5532 tSirRemainOnChnReq *pRemainOnChnReq = (tSirRemainOnChnReq *) pMsgBuf;
5533 noaDuration = (pRemainOnChnReq->duration)*CONV_MS_TO_US;
5534 break;
5535 }
5536
5537 case eWNI_SME_JOIN_REQ:
5538 noaDuration = JOIN_NOA_DURATION*CONV_MS_TO_US;
5539 break;
5540
5541 default:
5542 noaDuration = 0;
5543 break;
5544
5545 }
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005546 limLog(pMac, LOGW, FL("msgType %d noa %d"), msgType, noaDuration);
Viral Modid440e682013-03-06 02:25:31 -08005547 return noaDuration;
5548}
5549
5550void limProcessRegdDefdSmeReqAfterNOAStart(tpAniSirGlobal pMac)
5551{
Gopichand Nakkala7c4c3b92013-03-25 18:08:31 +05305552 tANI_BOOLEAN bufConsumed = TRUE;
Viral Modid440e682013-03-06 02:25:31 -08005553
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005554 limLog(pMac, LOG1, FL("Process defd sme req %d"), pMac->lim.gDeferMsgTypeForNOA);
Viral Modid440e682013-03-06 02:25:31 -08005555 if ( (pMac->lim.gDeferMsgTypeForNOA != 0) &&
5556 (pMac->lim.gpDefdSmeMsgForNOA != NULL) )
5557 {
5558 switch (pMac->lim.gDeferMsgTypeForNOA)
5559 {
5560 case eWNI_SME_SCAN_REQ:
5561 __limProcessSmeScanReq(pMac, pMac->lim.gpDefdSmeMsgForNOA);
5562 break;
5563 case eWNI_SME_OEM_DATA_REQ:
5564 __limProcessSmeOemDataReq(pMac, pMac->lim.gpDefdSmeMsgForNOA);
5565 break;
5566 case eWNI_SME_REMAIN_ON_CHANNEL_REQ:
Gopichand Nakkala7c4c3b92013-03-25 18:08:31 +05305567 bufConsumed = limProcessRemainOnChnlReq(pMac, pMac->lim.gpDefdSmeMsgForNOA);
5568 /* limProcessRemainOnChnlReq doesnt want us to free the buffer since
5569 * it is freed in limRemainOnChnRsp. this change is to avoid "double free"
5570 */
5571 if (FALSE == bufConsumed)
5572 {
5573 pMac->lim.gpDefdSmeMsgForNOA = NULL;
5574 }
Viral Modid440e682013-03-06 02:25:31 -08005575 break;
5576 case eWNI_SME_JOIN_REQ:
5577 __limProcessSmeJoinReq(pMac, pMac->lim.gpDefdSmeMsgForNOA);
5578 break;
5579 default:
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005580 limLog(pMac, LOGE, FL("Unknown deferred msg type %d"), pMac->lim.gDeferMsgTypeForNOA);
Viral Modid440e682013-03-06 02:25:31 -08005581 break;
5582 }
5583 __limDeregisterDeferredSmeReqAfterNOAStart(pMac);
5584 }
5585 else
5586 {
5587 limLog( pMac, LOGW, FL("start received from FW when no sme deferred msg pending. Do nothing."
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005588 "It might happen sometime when NOA start ind and timeout happen at the same time"));
Viral Modid440e682013-03-06 02:25:31 -08005589 }
5590}
Jeff Johnson295189b2012-06-20 16:38:30 -07005591
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05305592static void
5593__limProcessSmeResetApCapsChange(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
5594{
5595 tpSirResetAPCapsChange pResetCapsChange;
5596 tpPESession psessionEntry;
5597 tANI_U8 sessionId = 0;
5598 if (pMsgBuf == NULL)
5599 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005600 limLog(pMac, LOGE,FL("Buffer is Pointing to NULL"));
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05305601 return;
5602 }
5603
5604 pResetCapsChange = (tpSirResetAPCapsChange)pMsgBuf;
5605 psessionEntry = peFindSessionByBssid(pMac, pResetCapsChange->bssId, &sessionId);
5606 if (psessionEntry == NULL)
5607 {
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005608 limLog(pMac, LOGE, FL("Session does not exist for given BSSID"));
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05305609 return;
5610 }
5611
5612 psessionEntry->limSentCapsChangeNtf = false;
5613 return;
5614}
5615
Siddharth Bhal6af5d4e2014-09-29 21:11:16 +05305616static void
5617__limProcessSmeSpoofMacAddrRequest(tpAniSirGlobal pMac, tANI_U32 *pMsgBuf)
5618{
5619 tSirMsgQ msg;
5620 tpSpoofMacAddrReqParams pSpoofMacAddrParams;
5621 tpSirSpoofMacAddrReq pSmeReq = (tpSirSpoofMacAddrReq) pMsgBuf;
5622
5623 pSpoofMacAddrParams = vos_mem_malloc(sizeof( tSpoofMacAddrReqParams));
5624 if ( NULL == pSpoofMacAddrParams )
5625 {
Siddharth Bhal4f3187c2014-10-09 21:38:08 +05305626 limLog( pMac, LOGE, FL("Unable to allocate memory for tDelStaSelfParams") );
Siddharth Bhal6af5d4e2014-09-29 21:11:16 +05305627 return;
5628 }
5629
5630 vos_mem_copy( pSpoofMacAddrParams->macAddr, pSmeReq->macAddr, sizeof(tSirMacAddr) );
5631
Siddharth Bhal4f3187c2014-10-09 21:38:08 +05305632 vos_mem_copy(pMac->lim.spoofMacAddr, pSmeReq->macAddr, VOS_MAC_ADDRESS_LEN);
5633
Rajeev Kumar Sirasanagandla2bb30b82019-01-07 22:30:16 +05305634 pMac->lim.spoof_mac_oui = pSmeReq->spoof_mac_oui;
5635
Siddharth Bhal4f3187c2014-10-09 21:38:08 +05305636 limLog( pMac, LOG1, FL("Recieved Spoofed Mac Addr request with Addr:"
5637 MAC_ADDRESS_STR), MAC_ADDR_ARRAY(pMac->lim.spoofMacAddr) );
5638
Siddharth Bhal6af5d4e2014-09-29 21:11:16 +05305639 msg.type = WDA_SPOOF_MAC_ADDR_REQ;
5640 msg.reserved = 0;
5641 msg.bodyptr = pSpoofMacAddrParams;
5642 msg.bodyval = 0;
5643
5644 limLog(pMac, LOG1, FL("sending SIR_HAL_SPOOF_MAC_ADDR_REQ msg to HAL"));
5645 MTRACE(macTraceMsgTx(pMac, NO_SESSION, msg.type));
5646
5647 if(eSIR_SUCCESS != wdaPostCtrlMsg(pMac, &msg))
5648 {
Siddharth Bhal4f3187c2014-10-09 21:38:08 +05305649 limLog(pMac, LOGE, FL("wdaPostCtrlMsg failed for SIR_HAL_SPOOF_MAC_ADDR_REQ"));
Siddharth Bhal6af5d4e2014-09-29 21:11:16 +05305650 vos_mem_free(pSpoofMacAddrParams);
5651 }
5652 return;
5653}
5654
Jeff Johnson295189b2012-06-20 16:38:30 -07005655/**
Abhishek Singh7d624e12015-11-30 14:29:27 +05305656 * lim_register_mgmt_frame_ind_cb() - Save the Management frame
5657 * indication callback in PE.
5658 * @pMac: Mac pointer
5659 * @pMsgBuf: Msg pointer containing the callback
5660 *
5661 * This function is used save the Management frame
5662 * indication callback in PE.
5663 *
5664 * Return: None
5665 */
5666static void lim_register_mgmt_frame_ind_cb(tpAniSirGlobal pMac,
5667 tANI_U32 *msg_buf)
5668{
5669 struct sir_sme_mgmt_frame_cb_req *sme_req =
5670 (struct sir_sme_mgmt_frame_cb_req *)msg_buf;
5671
5672 if (NULL == msg_buf)
5673 {
5674 limLog(pMac, LOGE, FL("msg_buf is null"));
5675 return;
5676 }
5677 if (sme_req->callback)
5678 pMac->mgmt_frame_ind_cb =
5679 (sir_mgmt_frame_ind_callback)sme_req->callback;
5680 else
5681 limLog(pMac, LOGE, FL("sme_req->callback is null"));
5682}
Abhishek Singh2b0cf1c2017-10-30 17:36:38 +05305683
Abhishek Singh449c5372017-12-19 17:21:20 +05305684void lim_send_chan_switch_action_frame(tpAniSirGlobal mac_ctx,
Abhishek Singh2b0cf1c2017-10-30 17:36:38 +05305685 uint16_t new_channel, tpPESession session_entry)
5686{
5687 uint16_t op_class;
5688 uint8_t switch_mode = 0, i;
5689 tpDphHashNode psta;
5690 uint8_t switch_count;
5691 tpDphHashNode dph_node_array_ptr;
5692 offset_t ch_offset;
5693
5694 if (session_entry->gLimChannelSwitch.secondarySubBand >=
5695 PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_CENTERED)
5696 ch_offset = BW80;
5697 else
5698 ch_offset = session_entry->gLimChannelSwitch.secondarySubBand;
5699
5700 op_class = limGetOPClassFromChannel(mac_ctx->scan.countryCodeCurrent,
5701 new_channel, ch_offset);
5702
5703 switch_mode = session_entry->gLimChannelSwitch.switchMode;
5704
5705 switch_count = session_entry->gLimChannelSwitch.switchCount;
5706 dph_node_array_ptr = session_entry->dph.dphHashTable.pDphNodeArray;
5707
Abhinav Kumar57552512018-11-28 11:21:50 +05305708 for (i = 0; i < session_entry->dph.dphHashTable.size; i++) {
Abhishek Singh2b0cf1c2017-10-30 17:36:38 +05305709 psta = dph_node_array_ptr + i;
5710 if (!(psta && psta->added))
5711 continue;
5712 if (psta->staType == STA_ENTRY_PEER)
5713 lim_send_extended_chan_switch_action_frame(mac_ctx, psta->staAddr,
5714 switch_mode, op_class, new_channel,
5715 switch_count, session_entry);
5716 }
5717}
5718
Abhishek Singh02605092017-10-25 14:06:12 +05305719/**
5720 * lim_process_sme_set_csa_ie_request() - process sme dfs csa ie req
5721 *
5722 * @mac_ctx: Pointer to Global MAC structure
5723 * @msg_buf: pointer to the SME message buffer
5724 *
5725 * This function processes SME request messages from HDD or upper layer
5726 * application.
5727 *
5728 * Return: None
5729 */
5730static void lim_process_sme_set_csa_ie_request(tpAniSirGlobal mac_ctx,
5731 uint32_t *msg_buf)
5732{
5733 struct sir_ecsa_ie_req *csa_ie_req = (struct sir_ecsa_ie_req *)msg_buf;
5734 uint8_t session_id;
5735 tpPESession session_entry = NULL;
5736 tLimWiderBWChannelSwitchInfo *wider_bw_ch_switch;
5737
5738 if (!csa_ie_req) {
5739 limLog(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
5740 return;
5741 }
5742
5743 session_entry = peFindSessionByBssid(mac_ctx,
5744 csa_ie_req->bssid, &session_id);
5745 if (!session_entry) {
5746 limLog(mac_ctx, LOGE,
5747 FL("Session not found for given BSSID" MAC_ADDRESS_STR),
5748 MAC_ADDR_ARRAY(csa_ie_req->bssid));
5749 return;
5750 }
5751
5752 if (session_entry->valid && !LIM_IS_AP_ROLE(session_entry)) {
5753 limLog(mac_ctx, LOGE, FL("Invalid SystemRole %d"),
5754 GET_LIM_SYSTEM_ROLE(session_entry));
5755 return;
5756 }
5757
5758 /* target channel */
5759 session_entry->gLimChannelSwitch.primaryChannel = csa_ie_req->new_chan;
5760
5761 /* Channel switch announcement needs to be included in beacon */
5762 session_entry->include_ecsa_ie = true;
5763 session_entry->gLimChannelSwitch.switchCount =
5764 CHANNEL_SWITCH_BEACON_COUNT;
5765 session_entry->gLimChannelSwitch.secondarySubBand =
5766 csa_ie_req->cb_mode;
5767 session_entry->gLimChannelSwitch.switchMode = SAP_CHANNEL_SWITCH_MODE;
5768
5769 /* Now encode the Wider Ch BW element depending on the ch width */
5770 if (session_entry->vhtCapability &&
5771 (csa_ie_req->cb_mode >=
5772 PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_CENTERED)) {
5773 wider_bw_ch_switch = &session_entry->gLimWiderBWChannelSwitch;
5774 session_entry->include_wide_ch_bw_ie = true;
5775 wider_bw_ch_switch->newChanWidth = WNI_CFG_VHT_CHANNEL_WIDTH_80MHZ;
5776 /* Fetch the center channel based on the channel width */
5777 wider_bw_ch_switch->newCenterChanFreq0 =
5778 limGetCenterChannel(mac_ctx, csa_ie_req->new_chan,
5779 csa_ie_req->cb_mode,
5780 WNI_CFG_VHT_CHANNEL_WIDTH_80MHZ);
5781 }
5782 /* Send ECSA/CSA IE request from here */
5783 if (schSetFixedBeaconFields(mac_ctx, session_entry) != eSIR_SUCCESS) {
5784 limLog(mac_ctx, LOGE, FL("Unable to set CSA IE in beacon"));
5785 return;
5786 }
5787
Abhishek Singh2b0cf1c2017-10-30 17:36:38 +05305788 limSendBeaconInd(mac_ctx, session_entry);
Abhishek Singh02605092017-10-25 14:06:12 +05305789
Abhishek Singh2b0cf1c2017-10-30 17:36:38 +05305790 lim_send_chan_switch_action_frame(mac_ctx,
5791 csa_ie_req->new_chan, session_entry);
5792
5793 limLog(mac_ctx, LOG1, FL("IE count:%d chan:%d secondarySubBand:%d"),
Abhishek Singh02605092017-10-25 14:06:12 +05305794 session_entry->gLimChannelSwitch.switchCount,
5795 session_entry->gLimChannelSwitch.primaryChannel,
5796 session_entry->gLimChannelSwitch.secondarySubBand);
Abhishek Singh550aa8c2017-10-30 17:34:53 +05305797
5798 mac_ctx->lim.limTimers.g_lim_ap_ecsa_timer.sessionId =
5799 session_entry->peSessionId;
5800 limDeactivateAndChangeTimer(mac_ctx, eLIM_AP_ECSA_TIMER);
5801
5802 if (tx_timer_activate(&mac_ctx->lim.limTimers.g_lim_ap_ecsa_timer) !=
5803 TX_SUCCESS)
5804 {
5805 limLog(mac_ctx, LOGE, FL("Couldn't activate g_lim_ap_ecsa_timer"));
5806 lim_process_ap_ecsa_timeout(mac_ctx);
5807 }
5808}
5809
5810/**
5811 * lim_process_sme_channel_change_request() - process sme ch change req
5812 *
5813 * @mac_ctx: Pointer to Global MAC structure
5814 * @msg_buf: pointer to the SME message buffer
5815 *
5816 * This function is called to process SME_CHANNEL_CHANGE_REQ message
5817 *
5818 * Return: None
5819 */
5820static void lim_process_sme_channel_change_request(tpAniSirGlobal mac_ctx,
5821 uint32_t *msg_buf)
5822{
5823 struct sir_channel_chanege_req *ch_change_req;
5824 tpPESession session_entry;
5825 uint8_t session_id; /* PE session_id */
5826 int8_t max_tx_pwr;
5827 uint32_t val = 0;
Abhishek Singh02b823e2017-10-30 17:53:20 +05305828 uint8_t cb_mode;
Abhishek Singh550aa8c2017-10-30 17:34:53 +05305829
5830 if (!msg_buf) {
5831 limLog(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
5832 return;
5833 }
5834 ch_change_req = (struct sir_channel_chanege_req *)msg_buf;
5835
5836 max_tx_pwr = cfgGetRegulatoryMaxTransmitPower(mac_ctx,
5837 ch_change_req->new_chan);
5838
5839 if ((max_tx_pwr == WDA_MAX_TXPOWER_INVALID)) {
5840 limLog(mac_ctx, LOGE, FL("Invalid Request/max_tx_pwr"));
5841 return;
5842 }
5843
5844 session_entry = peFindSessionByBssid(mac_ctx,
5845 ch_change_req->bssid, &session_id);
5846 if (!session_entry) {
5847 limLog(mac_ctx, LOGE,
5848 FL("Session not found for given BSSID" MAC_ADDRESS_STR),
5849 MAC_ADDR_ARRAY(ch_change_req->bssid));
5850 return;
5851 }
5852
5853 if (session_entry->valid && !LIM_IS_AP_ROLE(session_entry)) {
5854 limLog(mac_ctx, LOGE, FL("Invalid SystemRole %d"),
5855 GET_LIM_SYSTEM_ROLE(session_entry));
5856 return;
5857 }
5858 if (session_entry->currentOperChannel ==
5859 ch_change_req->new_chan) {
5860 limLog(mac_ctx, LOGE, FL("target CH is same as current CH %d"),
5861 session_entry->currentOperChannel);
5862 return;
5863 }
5864
5865 session_entry->channelChangeReasonCode =
5866 LIM_SWITCH_CHANNEL_SAP_ECSA;
Abhishek Singhe3af5042017-11-30 11:42:23 +05305867 session_entry->channelChangeCSA = LIM_SWITCH_CHANNEL_CSA;
Abhishek Singh550aa8c2017-10-30 17:34:53 +05305868
Abhishek Singh02b823e2017-10-30 17:53:20 +05305869 limLog(mac_ctx, LOG1, FL("switch old chnl %d to new chnl %d, cb_mode %d"),
Abhishek Singh550aa8c2017-10-30 17:34:53 +05305870 session_entry->currentOperChannel,
5871 ch_change_req->new_chan,
5872 ch_change_req->cb_mode);
5873
Abhishek Singh02b823e2017-10-30 17:53:20 +05305874 cb_mode = ch_change_req->cb_mode;
5875
5876 if (session_entry->vhtCapability) {
5877 if (cb_mode <= PHY_DOUBLE_CHANNEL_HIGH_PRIMARY) {
5878 session_entry->vhtTxChannelWidthSet =
5879 WNI_CFG_VHT_CHANNEL_WIDTH_20_40MHZ;
5880 session_entry->apChanWidth = WNI_CFG_VHT_CHANNEL_WIDTH_20_40MHZ;
5881 /*
5882 * In case of DFS operation, If AP falls back to lower
5883 * bandwidth [< 80Mhz] then there is no need of
5884 * Center freq segment. So reset it to zero.
5885 */
5886 if (cfgSetInt(mac_ctx, WNI_CFG_VHT_CHANNEL_CENTER_FREQ_SEGMENT1, 0)
5887 != eSIR_SUCCESS)
5888 limLog(mac_ctx, LOGE,
5889 FL("couldn't set center freq seg 0 in beacon"));
5890 if (cfgSetInt(mac_ctx, WNI_CFG_VHT_CHANNEL_WIDTH,
5891 WNI_CFG_VHT_CHANNEL_WIDTH_20_40MHZ) != eSIR_SUCCESS)
5892 limLog(mac_ctx, LOGE, FL("could not set channel width to 20/40 in CFG"));
5893 session_entry->apCenterChan = 0;
5894 } else {
5895 uint32_t center_chan;
5896
5897 session_entry->vhtTxChannelWidthSet =
5898 WNI_CFG_VHT_CHANNEL_WIDTH_80MHZ;
5899 session_entry->apChanWidth = WNI_CFG_VHT_CHANNEL_WIDTH_80MHZ;
5900 center_chan = limGetCenterChannel(mac_ctx, ch_change_req->new_chan,
5901 cb_mode, WNI_CFG_VHT_CHANNEL_WIDTH_80MHZ);
5902 limLog(mac_ctx, LOGW,
5903 FL("***Center Channel for 80MHZ channel width = %d"),
5904 center_chan);
5905 session_entry->apCenterChan = center_chan;
5906 if (cfgSetInt(mac_ctx, WNI_CFG_VHT_CHANNEL_CENTER_FREQ_SEGMENT1,
5907 center_chan) != eSIR_SUCCESS)
5908 limLog(mac_ctx, LOGE, FL("could not set center freq seg 0 in beacon"));
5909 if (cfgSetInt(mac_ctx, WNI_CFG_VHT_CHANNEL_WIDTH,
5910 WNI_CFG_VHT_CHANNEL_WIDTH_80MHZ) != eSIR_SUCCESS)
5911 limLog(mac_ctx, LOGE, FL("could not set channel width to 80 in CFG"));
5912 }
5913 }
5914
Abhishek Singh550aa8c2017-10-30 17:34:53 +05305915 /* Store the New Channel Params in session_entry */
Abhishek Singh02b823e2017-10-30 17:53:20 +05305916 session_entry->htSecondaryChannelOffset = limGetHTCBState(cb_mode);
5917 session_entry->htSupportedChannelWidthSet = (cb_mode ? 1 : 0);
Abhishek Singh550aa8c2017-10-30 17:34:53 +05305918 session_entry->htRecommendedTxWidthSet =
5919 session_entry->htSupportedChannelWidthSet;
5920 session_entry->currentOperChannel = ch_change_req->new_chan;
5921 session_entry->limRFBand = limGetRFBand(session_entry->currentOperChannel);
5922 /* Initialize 11h Enable Flag */
5923 if (SIR_BAND_5_GHZ == session_entry->limRFBand) {
5924 if (wlan_cfgGetInt(mac_ctx, WNI_CFG_11H_ENABLED, &val) != eSIR_SUCCESS)
5925 limLog(mac_ctx, LOGE, FL("Fail to get WNI_CFG_11H_ENABLED"));
5926 }
5927
5928 session_entry->lim11hEnable = val;
5929 session_entry->dot11mode = ch_change_req->dot11mode;
5930 vos_mem_copy(&session_entry->rateSet, &ch_change_req->operational_rateset,
5931 sizeof(session_entry->rateSet));
5932 vos_mem_copy(&session_entry->extRateSet, &ch_change_req->extended_rateset,
5933 sizeof(session_entry->extRateSet));
5934 limSetChannel(mac_ctx, ch_change_req->new_chan,
5935 session_entry->htSecondaryChannelOffset,
5936 max_tx_pwr, session_entry->peSessionId);
Abhishek Singh02605092017-10-25 14:06:12 +05305937}
Abhishek Singh7d624e12015-11-30 14:29:27 +05305938
5939/**
Jeff Johnson295189b2012-06-20 16:38:30 -07005940 * limProcessSmeReqMessages()
5941 *
5942 *FUNCTION:
5943 * This function is called by limProcessMessageQueue(). This
5944 * function processes SME request messages from HDD or upper layer
5945 * application.
5946 *
5947 *LOGIC:
5948 *
5949 *ASSUMPTIONS:
5950 *
5951 *NOTE:
5952 *
5953 * @param pMac Pointer to Global MAC structure
5954 * @param msgType Indicates the SME message type
5955 * @param *pMsgBuf A pointer to the SME message buffer
5956 * @return Boolean - TRUE - if pMsgBuf is consumed and can be freed.
5957 * FALSE - if pMsgBuf is not to be freed.
5958 */
5959
5960tANI_BOOLEAN
5961limProcessSmeReqMessages(tpAniSirGlobal pMac, tpSirMsgQ pMsg)
5962{
5963 tANI_BOOLEAN bufConsumed = TRUE; //Set this flag to false within case block of any following message, that doesnt want pMsgBuf to be freed.
5964 tANI_U32 *pMsgBuf = pMsg->bodyptr;
Sudhir Sattayappa Kohalliabf751c2013-06-30 15:37:18 -07005965 tpSirSmeScanReq pScanReq;
Ganesh Kondabattini16930072014-08-22 16:02:34 +05305966 tANI_BOOLEAN isPassiveScan = FALSE;
5967
Kiran Kumar Lokere531ca702013-04-01 13:24:23 -07005968 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 -07005969 limMsgStr(pMsg->type), pMsg->type,
5970 limSmeStateStr(pMac->lim.gLimSmeState), pMac->lim.gLimSmeState,
5971 limMlmStateStr(pMac->lim.gLimMlmState), pMac->lim.gLimMlmState );)
5972
Sudhir Sattayappa Kohalliabf751c2013-06-30 15:37:18 -07005973 pScanReq = (tpSirSmeScanReq) pMsgBuf;
Viral Modid440e682013-03-06 02:25:31 -08005974 /* Special handling of some SME Req msgs where we have an existing GO session and
5975 * want to insert NOA before processing those msgs. These msgs will be processed later when
5976 * start event happens
5977 */
5978 switch (pMsg->type)
5979 {
5980 case eWNI_SME_SCAN_REQ:
Ganesh Kondabattini16930072014-08-22 16:02:34 +05305981 pScanReq = (tpSirSmeScanReq) pMsgBuf;
5982 isPassiveScan = (pScanReq->scanType == eSIR_PASSIVE_SCAN) ? TRUE : FALSE;
Viral Modid440e682013-03-06 02:25:31 -08005983 case eWNI_SME_REMAIN_ON_CHANNEL_REQ:
Sudhir Sattayappa Kohalliabf751c2013-06-30 15:37:18 -07005984
5985 /* If scan is disabled return from here
5986 */
5987 if (pMac->lim.fScanDisabled)
5988 {
Sudhir Sattayappa Kohalliabf751c2013-06-30 15:37:18 -07005989 if (pMsg->type == eWNI_SME_SCAN_REQ)
5990 {
5991 limSendSmeScanRsp(pMac,
5992 offsetof(tSirSmeScanRsp,bssDescription[0]),
5993 eSIR_SME_INVALID_PARAMETERS,
5994 pScanReq->sessionId,
5995 pScanReq->transactionId);
5996
5997 bufConsumed = TRUE;
5998 }
5999 else if (pMsg->type == eWNI_SME_REMAIN_ON_CHANNEL_REQ)
6000 {
6001 pMac->lim.gpDefdSmeMsgForNOA = NULL;
6002 pMac->lim.gpLimRemainOnChanReq = (tpSirRemainOnChnReq )pMsgBuf;
6003 limRemainOnChnRsp(pMac,eHAL_STATUS_FAILURE, NULL);
6004
6005 /*
6006 * limRemainOnChnRsp will free the buffer this change is to
6007 * avoid "double free"
6008 */
6009 bufConsumed = FALSE;
6010 }
6011
Rashmi Ramanna6c13a342014-01-07 11:44:07 +05306012 limLog(pMac, LOGE,
6013 FL("Error: Scan Disabled."
6014 " Return with error status for SME Message %s(%d)"),
6015 limMsgStr(pMsg->type), pMsg->type);
6016
Sudhir Sattayappa Kohalliabf751c2013-06-30 15:37:18 -07006017 return bufConsumed;
6018 }
6019 /*
6020 * Do not add BREAK here
6021 */
6022 case eWNI_SME_OEM_DATA_REQ:
Viral Modid440e682013-03-06 02:25:31 -08006023 case eWNI_SME_JOIN_REQ:
6024 /* If we have an existing P2P GO session we need to insert NOA before actually process this SME Req */
6025 if ((limIsNOAInsertReqd(pMac) == TRUE) && IS_FEATURE_SUPPORTED_BY_FW(P2P_GO_NOA_DECOUPLE_INIT_SCAN))
6026 {
6027 tANI_U32 noaDuration;
6028 __limRegisterDeferredSmeReqForNOAStart(pMac, pMsg->type, pMsgBuf);
Ganesh Kondabattini16930072014-08-22 16:02:34 +05306029 noaDuration = limCalculateNOADuration(pMac, pMsg->type, pMsgBuf, isPassiveScan);
Viral Modid440e682013-03-06 02:25:31 -08006030 bufConsumed = __limInsertSingleShotNOAForScan(pMac, noaDuration);
6031 return bufConsumed;
6032 }
6033 }
6034 /* If no insert NOA required then execute the code below */
6035
Jeff Johnson295189b2012-06-20 16:38:30 -07006036 switch (pMsg->type)
6037 {
6038 case eWNI_SME_START_REQ:
6039 __limProcessSmeStartReq(pMac, pMsgBuf);
6040 break;
6041
6042 case eWNI_SME_SYS_READY_IND:
6043 bufConsumed = __limProcessSmeSysReadyInd(pMac, pMsgBuf);
6044 break;
6045
Jeff Johnson295189b2012-06-20 16:38:30 -07006046 case eWNI_SME_START_BSS_REQ:
6047 bufConsumed = __limProcessSmeStartBssReq(pMac, pMsg);
6048 break;
6049
6050 case eWNI_SME_SCAN_REQ:
Viral Modid440e682013-03-06 02:25:31 -08006051 __limProcessSmeScanReq(pMac, pMsgBuf);
Jeff Johnson295189b2012-06-20 16:38:30 -07006052 break;
6053
Jeff Johnsone7245742012-09-05 17:12:55 -07006054#ifdef FEATURE_OEM_DATA_SUPPORT
6055 case eWNI_SME_OEM_DATA_REQ:
6056 __limProcessSmeOemDataReq(pMac, pMsgBuf);
Jeff Johnsone7245742012-09-05 17:12:55 -07006057 break;
6058#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006059 case eWNI_SME_REMAIN_ON_CHANNEL_REQ:
6060 bufConsumed = limProcessRemainOnChnlReq(pMac, pMsgBuf);
6061 break;
6062
6063 case eWNI_SME_UPDATE_NOA:
6064 __limProcessSmeNoAUpdate(pMac, pMsgBuf);
6065 break;
Gopichand Nakkalac178ac82013-05-30 19:53:39 +05306066 case eWNI_SME_CLEAR_DFS_CHANNEL_LIST:
6067 __limProcessClearDfsChannelList(pMac, pMsg);
6068 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006069 case eWNI_SME_JOIN_REQ:
6070 __limProcessSmeJoinReq(pMac, pMsgBuf);
Jeff Johnson295189b2012-06-20 16:38:30 -07006071 break;
6072
6073 case eWNI_SME_AUTH_REQ:
6074 // __limProcessSmeAuthReq(pMac, pMsgBuf);
6075
6076 break;
6077
6078 case eWNI_SME_REASSOC_REQ:
6079 __limProcessSmeReassocReq(pMac, pMsgBuf);
6080
6081 break;
6082
6083 case eWNI_SME_PROMISCUOUS_MODE_REQ:
6084 //__limProcessSmePromiscuousReq(pMac, pMsgBuf);
6085
6086 break;
6087
6088 case eWNI_SME_DISASSOC_REQ:
6089 __limProcessSmeDisassocReq(pMac, pMsgBuf);
6090
6091 break;
6092
6093 case eWNI_SME_DISASSOC_CNF:
6094 case eWNI_SME_DEAUTH_CNF:
6095 __limProcessSmeDisassocCnf(pMac, pMsgBuf);
6096
6097 break;
6098
6099 case eWNI_SME_DEAUTH_REQ:
6100 __limProcessSmeDeauthReq(pMac, pMsgBuf);
6101
6102 break;
6103
Jeff Johnson295189b2012-06-20 16:38:30 -07006104
6105
6106 case eWNI_SME_SETCONTEXT_REQ:
6107 __limProcessSmeSetContextReq(pMac, pMsgBuf);
6108
6109 break;
6110
6111 case eWNI_SME_REMOVEKEY_REQ:
6112 __limProcessSmeRemoveKeyReq(pMac, pMsgBuf);
6113
6114 break;
6115
6116 case eWNI_SME_STOP_BSS_REQ:
6117 bufConsumed = __limProcessSmeStopBssReq(pMac, pMsg);
6118 break;
6119
6120 case eWNI_SME_ASSOC_CNF:
6121 case eWNI_SME_REASSOC_CNF:
6122 if (pMsg->type == eWNI_SME_ASSOC_CNF)
Abhishek Singh3cbf6052014-12-15 16:46:42 +05306123 limLog(pMac, LOG1, FL("Received ASSOC_CNF message"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006124 else
Abhishek Singh3cbf6052014-12-15 16:46:42 +05306125 limLog(pMac, LOG1, FL("Received REASSOC_CNF message"));
Agrawal Ashisha8e8a722016-10-18 19:07:45 +05306126#ifdef SAP_AUTH_OFFLOAD
6127 if (pMac->sap_auth_offload)
6128 __lim_process_sme_assoc_offload_cnf(pMac, pMsg->type, pMsgBuf);
6129 else
6130 __limProcessSmeAssocCnfNew(pMac, pMsg->type, pMsgBuf);
6131#else
Jeff Johnson295189b2012-06-20 16:38:30 -07006132 __limProcessSmeAssocCnfNew(pMac, pMsg->type, pMsgBuf);
Agrawal Ashisha8e8a722016-10-18 19:07:45 +05306133#endif /* SAP_AUTH_OFFLOAD */
Jeff Johnson295189b2012-06-20 16:38:30 -07006134 break;
6135
6136 case eWNI_SME_ADDTS_REQ:
Abhishek Singh3cbf6052014-12-15 16:46:42 +05306137 limLog(pMac, LOG1, FL("Received ADDTS_REQ message"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006138 __limProcessSmeAddtsReq(pMac, pMsgBuf);
6139 break;
6140
6141 case eWNI_SME_DELTS_REQ:
Abhishek Singh3cbf6052014-12-15 16:46:42 +05306142 limLog(pMac, LOG1, FL("Received DELTS_REQ message"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006143 __limProcessSmeDeltsReq(pMac, pMsgBuf);
6144 break;
6145
6146 case SIR_LIM_ADDTS_RSP_TIMEOUT:
Abhishek Singh3cbf6052014-12-15 16:46:42 +05306147 limLog(pMac, LOG1, FL("Received SIR_LIM_ADDTS_RSP_TIMEOUT message "));
Jeff Johnson295189b2012-06-20 16:38:30 -07006148 limProcessSmeAddtsRspTimeout(pMac, pMsg->bodyval);
6149 break;
6150
6151 case eWNI_SME_STA_STAT_REQ:
6152 case eWNI_SME_AGGR_STAT_REQ:
6153 case eWNI_SME_GLOBAL_STAT_REQ:
6154 case eWNI_SME_STAT_SUMM_REQ:
6155 __limProcessSmeStatsRequest( pMac, pMsgBuf);
6156 //HAL consumes pMsgBuf. It will be freed there. Set bufConsumed to false.
6157 bufConsumed = FALSE;
6158 break;
6159 case eWNI_SME_GET_STATISTICS_REQ:
6160 __limProcessSmeGetStatisticsRequest( pMac, pMsgBuf);
6161 //HAL consumes pMsgBuf. It will be freed there. Set bufConsumed to false.
6162 bufConsumed = FALSE;
6163 break;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08006164#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08006165 case eWNI_SME_GET_ROAM_RSSI_REQ:
6166 __limProcessSmeGetRoamRssiRequest( pMac, pMsgBuf);
6167 //HAL consumes pMsgBuf. It will be freed there. Set bufConsumed to false.
6168 bufConsumed = FALSE;
6169 break;
6170#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08006171#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07006172 case eWNI_SME_GET_TSM_STATS_REQ:
6173 __limProcessSmeGetTsmStatsRequest( pMac, pMsgBuf);
6174 bufConsumed = FALSE;
6175 break;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08006176#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Jeff Johnson295189b2012-06-20 16:38:30 -07006177 case eWNI_SME_DEL_BA_PEER_IND:
6178 limProcessSmeDelBaPeerInd(pMac, pMsgBuf);
6179 break;
6180 case eWNI_SME_GET_SCANNED_CHANNEL_REQ:
6181 limProcessSmeGetScanChannelInfo(pMac, pMsgBuf);
6182 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006183 case eWNI_SME_GET_ASSOC_STAS_REQ:
6184 limProcessSmeGetAssocSTAsInfo(pMac, pMsgBuf);
6185 break;
6186 case eWNI_SME_TKIP_CNTR_MEAS_REQ:
6187 limProcessTkipCounterMeasures(pMac, pMsgBuf);
6188 break;
6189
6190 case eWNI_SME_HIDE_SSID_REQ:
6191 __limProcessSmeHideSSID(pMac, pMsgBuf);
6192 break;
6193 case eWNI_SME_UPDATE_APWPSIE_REQ:
6194 __limProcessSmeUpdateAPWPSIEs(pMac, pMsgBuf);
6195 break;
6196 case eWNI_SME_GET_WPSPBC_SESSION_REQ:
6197 limProcessSmeGetWPSPBCSessions(pMac, pMsgBuf);
6198 break;
6199
6200 case eWNI_SME_SET_APWPARSNIEs_REQ:
6201 __limProcessSmeSetWPARSNIEs(pMac, pMsgBuf);
6202 break;
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -08006203
6204 case eWNI_SME_CHNG_MCC_BEACON_INTERVAL:
6205 //Update the beaconInterval
6206 __limProcessSmeChangeBI(pMac, pMsgBuf );
6207 break;
Hardik Kantilal Patel62a3a762014-11-21 12:55:57 +05306208
6209#ifdef WLAN_FEATURE_AP_HT40_24G
6210 case eWNI_SME_SET_HT_2040_MODE:
6211 __limProcessSmeSetHT2040Mode(pMac, pMsgBuf);
6212 break;
6213#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006214
6215#if defined WLAN_FEATURE_VOWIFI
6216 case eWNI_SME_NEIGHBOR_REPORT_REQ_IND:
6217 case eWNI_SME_BEACON_REPORT_RESP_XMIT_IND:
6218 __limProcessReportMessage(pMac, pMsg);
6219 break;
6220#endif
6221
6222#if defined WLAN_FEATURE_VOWIFI_11R
6223 case eWNI_SME_FT_PRE_AUTH_REQ:
6224 bufConsumed = (tANI_BOOLEAN)limProcessFTPreAuthReq(pMac, pMsg);
6225 break;
6226 case eWNI_SME_FT_UPDATE_KEY:
6227 limProcessFTUpdateKey(pMac, pMsgBuf);
6228 break;
6229
6230 case eWNI_SME_FT_AGGR_QOS_REQ:
6231 limProcessFTAggrQosReq(pMac, pMsgBuf);
6232 break;
6233#endif
6234
Padma, Santhosh Kumar67f479b2016-12-28 15:43:42 +05306235#ifdef WLAN_FEATURE_LFR_MBB
6236 case eWNI_SME_MBB_PRE_AUTH_REASSOC_REQ:
6237 lim_process_pre_auth_reassoc_req(pMac, pMsg);
6238 bufConsumed = FALSE;
6239 break;
6240#endif
6241
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08006242#if defined(FEATURE_WLAN_ESE) && !defined(FEATURE_WLAN_ESE_UPLOAD)
6243 case eWNI_SME_ESE_ADJACENT_AP_REPORT:
Jeff Johnson295189b2012-06-20 16:38:30 -07006244 limProcessAdjacentAPRepMsg ( pMac, pMsgBuf );
6245 break;
6246#endif
6247 case eWNI_SME_ADD_STA_SELF_REQ:
6248 __limProcessSmeAddStaSelfReq( pMac, pMsgBuf );
6249 break;
6250 case eWNI_SME_DEL_STA_SELF_REQ:
6251 __limProcessSmeDelStaSelfReq( pMac, pMsgBuf );
6252 break;
6253
Jeff Johnson295189b2012-06-20 16:38:30 -07006254 case eWNI_SME_REGISTER_MGMT_FRAME_REQ:
6255 __limProcessSmeRegisterMgmtFrameReq( pMac, pMsgBuf );
6256 break;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08006257#ifdef FEATURE_WLAN_TDLS
6258 case eWNI_SME_TDLS_SEND_MGMT_REQ:
6259 limProcessSmeTdlsMgmtSendReq(pMac, pMsgBuf);
6260 break;
6261 case eWNI_SME_TDLS_ADD_STA_REQ:
6262 limProcessSmeTdlsAddStaReq(pMac, pMsgBuf);
6263 break;
6264 case eWNI_SME_TDLS_DEL_STA_REQ:
6265 limProcessSmeTdlsDelStaReq(pMac, pMsgBuf);
6266 break;
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05306267 case eWNI_SME_TDLS_LINK_ESTABLISH_REQ:
6268 limProcesSmeTdlsLinkEstablishReq(pMac, pMsgBuf);
6269 break;
Atul Mittalc0f739f2014-07-31 13:47:47 +05306270// tdlsoffchan
6271 case eWNI_SME_TDLS_CHANNEL_SWITCH_REQ:
6272 limProcesSmeTdlsChanSwitchReq(pMac, pMsgBuf);
6273 break;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08006274#endif
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05306275 case eWNI_SME_RESET_AP_CAPS_CHANGED:
6276 __limProcessSmeResetApCapsChange(pMac, pMsgBuf);
6277 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006278
schang86c22c42013-03-13 18:41:24 -07006279 case eWNI_SME_SET_TX_POWER_REQ:
6280 limSendSetTxPowerReq(pMac, pMsgBuf);
6281 break ;
6282
Abhishek Singh00b71972016-01-07 10:51:04 +05306283#ifdef WLAN_FEATURE_RMC
6284 case eWNI_SME_ENABLE_RMC_REQ:
6285 limProcessRMCMessages(pMac, eLIM_RMC_ENABLE_REQ, pMsgBuf);
6286 break ;
6287
6288 case eWNI_SME_DISABLE_RMC_REQ:
6289 limProcessRMCMessages(pMac, eLIM_RMC_DISABLE_REQ, pMsgBuf);
6290 break ;
6291#endif /* WLAN_FEATURE_RMC */
6292
Siddharth Bhal6af5d4e2014-09-29 21:11:16 +05306293 case eWNI_SME_MAC_SPOOF_ADDR_IND:
6294 __limProcessSmeSpoofMacAddrRequest(pMac, pMsgBuf);
6295 break ;
Abhishek Singh7d624e12015-11-30 14:29:27 +05306296 case eWNI_SME_REGISTER_MGMT_FRAME_CB:
6297 lim_register_mgmt_frame_ind_cb(pMac, pMsgBuf);
6298 break;
Abhishek Singh02605092017-10-25 14:06:12 +05306299 case eWNI_SME_SET_CHAN_SW_IE_REQ:
6300 lim_process_sme_set_csa_ie_request(pMac, pMsgBuf);
Abhishek Singh550aa8c2017-10-30 17:34:53 +05306301 break;
6302 case eWNI_SME_ECSA_CHAN_CHANGE_REQ:
6303 lim_process_sme_channel_change_request(pMac, pMsgBuf);
6304 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006305 default:
6306 vos_mem_free((v_VOID_t*)pMsg->bodyptr);
6307 pMsg->bodyptr = NULL;
6308 break;
6309 } // switch (msgType)
6310
6311 return bufConsumed;
6312} /*** end limProcessSmeReqMessages() ***/